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

Fixing race condition in AsyncReaderImpl::shutdown #304

Conversation

Myllyenko
Copy link

This PR fixes a race condition that occurs upon invocation of AsyncReaderImpl::shutdown when the handlerExecutor field is set.

The problem we faced:

  1. User code calls AsyncReaderImpl::shutdown.
  2. Then following call chain follows: GrpcStreamRetrier::shutdownImpl -> AsyncReaderImpl::onShutdown -> AsyncReaderImpl::handleReaderClosed.
  3. handleReaderClosed sends an action calling eventHandler.onReaderClosed to handlerExecutor but does not wait for execution.
  4. AsyncReaderImpl::shutdown returns.
  5. User code shutdowns handlerExecutor.
  6. handlerExecutor rejects the action from the third step and eventHandler.onReaderClosed is never called.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 46.37%. Comparing base (16f2600) to head (e741432).

Files Patch % Lines
...java/tech/ydb/topic/read/impl/AsyncReaderImpl.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #304      +/-   ##
============================================
- Coverage     46.38%   46.37%   -0.02%     
  Complexity     1677     1677              
============================================
  Files           303      303              
  Lines         12109    12108       -1     
  Branches       1208     1208              
============================================
- Hits           5617     5615       -2     
- Misses         6054     6055       +1     
  Partials        438      438              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pnv1 pnv1 merged commit fd38171 into ydb-platform:master Aug 19, 2024
7 checks passed
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.

3 participants