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

KAFKA-10792 (2.5 backport): Prevent source task shutdown from blocking herder thread (#9669) #9880

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

C0urante
Copy link
Contributor

Backports the changes from #9669.

Changes the WorkerSourceTask class to only call SourceTask::stop from the task thread when the task is actually stopped (via Source:task::close just before WorkerTask::run completes), and only if an attempt has been made to start the task (which will not be the case if it was created in the paused state and then shut down before being started). This prevents SourceTask::stop from being indirectly invoked on the herder's thread, which can have adverse effects if the task is unable to shut down promptly.

Unit tests are tweaked where necessary to account for this new logic, which covers some edge cases mentioned in PR #5020 that were unaddressed up until now.

The existing integration tests for blocking connectors added later in 2.6 are backported here to provide cases for blocking source and sink tasks. Full coverage of every source/sink task method is intentionally omitted from these expanded tests in order to avoid inflating test runtime (each one adds an extra 5 seconds at minimum) and because the tests that are added here were sufficient to reproduce the bug with source task shutdown.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

…apache#9669)

Changes the `WorkerSourceTask` class to only call `SourceTask::stop` from the task thread when the task is actually stopped (via `Source:task::close` just before `WorkerTask::run` completes), and only if an attempt has been made to start the task (which will not be the case if it was created in the paused state and then shut down before being started). This prevents `SourceTask::stop` from being indirectly invoked on the herder's thread, which can have adverse effects if the task is unable to shut down promptly.

Unit tests are tweaked where necessary to account for this new logic, which covers some edge cases mentioned in PR apache#5020 that were unaddressed up until now.

The existing integration tests for blocking connectors are expanded to also include cases for blocking source and sink tasks. Full coverage of every source/sink task method is intentionally omitted from these expanded tests in order to avoid inflating test runtime (each one adds an extra 5 seconds at minimum) and because the tests that are added here were sufficient to reproduce the bug with source task shutdown.

Author: Chris Egerton <chrise@confluent.io>
Reviewers: Nigel Liang <nigel@nigelliang.com>, Tom Bentley <tbentley@redhat.com>, Randall Hauch <rhauch@gmail.com>
Copy link
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the backport, @C0urante.

@rhauch
Copy link
Contributor

rhauch commented Jan 14, 2021

I'm trying to get the builds to run properly, but I did pull locally and the build of that local branch does pass.

@rhauch
Copy link
Contributor

rhauch commented Jan 14, 2021

There seem to be environmental build issues; the builds are failing with "JDK" unknown and "maven" unknown.

I'm going to go ahead and merge this PR to the 2.5 branch.

@rhauch rhauch merged commit 36ae1f5 into apache:2.5 Jan 14, 2021
@C0urante C0urante deleted the kafka-10792-2.5 branch January 14, 2021 20:11
@C0urante
Copy link
Contributor Author

Thanks Randall!

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