Skip to content

Mark discovery as ready only after its endpoints are applied - #779

Merged
alex268 merged 2 commits into
ydb-platform:masterfrom
alex268:fix/discovery-ready-before-pool-update
Oct 21, 2026
Merged

alex268 merged 2 commits into
ydb-platform:masterfrom
alex268:fix/discovery-ready-before-pool-update

Conversation

@alex268

@alex268 alex268 commented Oct 21, 2026

Copy link
Copy Markdown
Member

Updated #768

YdbDiscovery.handleOk() set isStarted before handing the endpoints to the handler, and waitReady() checks isStarted without the lock. A request racing with the first discovery could therefore return from waitReady() while EndpointPool.setNewState() had not populated the pool yet, get a null endpoint from getEndpoint() and fail with a NullPointerException in GrpcChannelPool.getChannel(), reported as CLIENT_INTERNAL_ERROR.

The handler was also invoked under readyLock. With USE_DETECT_LOCAL_DC it pings the nodes, which can take seconds, and waiters blocked in the uninterruptible lock() past their own deadline.

Igor Melnichenko and others added 2 commits October 10, 2026 20:55
handleOk() set isStarted before handing the endpoints to the handler, and
waitReady() checks isStarted without the lock. A request racing with the
first discovery could therefore return from waitReady() while
EndpointPool.setNewState() had not populated the pool yet, get a null
endpoint from getEndpoint() and fail with a NullPointerException in
GrpcChannelPool.getChannel(), reported as CLIENT_INTERNAL_ERROR.

The handler was also invoked under readyLock. With USE_DETECT_LOCAL_DC it
pings the nodes, which can take seconds, and waiters blocked in the
uninterruptible lock() past their own deadline.

Apply the endpoints first and outside of the lock, then mark the discovery
as started and wake up the waiters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.68%. Comparing base (d854009) to head (3fbc548).
⚠️ Report is 29 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #779      +/-   ##
============================================
+ Coverage     75.47%   75.68%   +0.21%     
- Complexity     3755     3787      +32     
============================================
  Files           396      396              
  Lines         16842    16937      +95     
  Branches       1780     1789       +9     
============================================
+ Hits          12711    12819     +108     
+ Misses         3515     3502      -13     
  Partials        616      616              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alex268
alex268 merged commit 72cf818 into ydb-platform:master Oct 21, 2026
17 of 21 checks passed
@alex268
alex268 deleted the fix/discovery-ready-before-pool-update branch October 21, 2026 10:14
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.

2 participants