Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1360 Support for poll maximum wait time #1417

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jakubmalek
Copy link

@jakubmalek jakubmalek commented Aug 6, 2024

Problem

The JDBC source task stoppage often results in the ungraceful shutdown, due to a long duration time for the polling operation which blocks the worker task thread.
If the connector is restarted and re-deployed on the same node, it may result in a missing JMX bean for the connector as the newly registered metrics will be removed once the task is finally stopped after graceful timeout.
This can case issues with monitoring as the metrics needs to be exported from the JMX.

Solution

The proposed solution is to introduce a new configuration property poll.max.wait.time.ms which limits the duration for which the worker task is blocked for a single polling call.
To make it possible, the polling operation should be run in a separated thread, where the task awaits for it to finish w up to the configured poll.max.wait.time.ms duration.
If the operation is not finished within poll.max.wait.time.ms the source task will return null list of records signaling no-data to the worker.
As the worker task runs in a loop, where its continuously polling the source task, the task will check if there is a previously started poll operation, and try to wait for it to finish each time. If there is no previous operation started, it will start new one, and apply the same logic.
This in consequence should limit the total duration for which the worker task thread can be blocked, thus allowing the graceful shutdown, regardless of the poll.interval.ms value nor the records fetching time.

For the backward compatibility it should be possible to set the poll.max.wait.time.ms to 0 where the task waits indefinitely for the polling result, without a separated thread.

Does this solution apply anywhere else?
  • yes
  • no
If yes, where?

Similar strategy can be applied to other types of source connectors where worker thread is blocked for extended time period during the SourceTask::poll call.

Test Strategy

To allow easier testing, I've extracted the related logic into JdbcSourceTaskPollExecutor class.

Testing done:
  • Unit tests
  • Integration tests
  • System tests
  • Manual tests

Release Plan

…aximum duration time for the poll operation
@jakubmalek jakubmalek requested a review from a team as a code owner August 6, 2024 09:30
Copy link

cla-assistant bot commented Aug 6, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

cla-assistant bot commented Aug 6, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant