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

SAMZA-2510: Incorrect shutdown status due to race between runloop and process callback thread #1344

Merged
merged 6 commits into from
Apr 15, 2020

Conversation

mynameborat
Copy link
Contributor

@mynameborat mynameborat commented Apr 14, 2020

Symptom: A race between the process callback thread and the runloop thread can result in incorrect shutdown status for shutdown triggered by end of stream.
Issue: Currently runloop performs message choosing and dispatching in a loop indefinitely until interrupted by a shutdown request or an exception during processing. In async mode, message completion is notified by the process callback thread using onComplete() and onFailure() to represent corresponding success and failure. The failure callback updates the exception code within the runloop to notify processing failures. Similarly, shutdown can be requested by user code or end of stream messages through various scopes(task level, container level). These requests are notified to the runloop through shutdownNow flag.
Currently as long as shutdownNow flag is not set, the exception code is promptly seen by the runloop and propagated upstream correctly. However, if a shutdown triggered by end of stream is requested, runloop doesn't check the exception code before exiting.
Changes: Make sure we check the exception code before we exit. Also, set the exception code on process failure before updating the state to done to promptly signal runloop about failure.
Tests: Added unit tests to check if the exception is thrown even if the shutdown is requested ahead of callback failure.
API Changes: None
Usage Instructions: None
Upgrade Instructions: None

@mynameborat mynameborat merged commit 470ae2c into apache:master Apr 15, 2020
@mynameborat mynameborat deleted the runloop-fix branch April 15, 2020 23:08
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