Skip to content

bugfix: retry Raft discovery bootstrap after transient failures - #1239

Draft
yangjj-iso wants to merge 3 commits into
apache:masterfrom
yangjj-iso:codex/fix-raft-bootstrap-retry
Draft

yangjj-iso wants to merge 3 commits into
apache:masterfrom
yangjj-iso:codex/fix-raft-bootstrap-retry

Conversation

@yangjj-iso

Copy link
Copy Markdown
Contributor
  • I have registered the PR changes in changes/dev.md and changes/dev_zh.md.

What this PR does

A transient login or metadata request failure during Raft discovery can leave the seed addresses cached without cluster metadata. The next Lookup then returns an empty result without retrying the request. This can leave the client unable to discover a coordinator after the service recovers.

This change retries metadata acquisition while cluster metadata is missing, reuses cached seed addresses, and starts periodic refresh after a successful fetch. Concurrent cold lookups wait for the bootstrap attempt and reuse the metadata it populates. Token reads and random endpoint selection are synchronized with periodic refresh.

Verification

  • Both cases in TestRaftLookupRetriesBootstrapAfterFailure fail on unchanged master (bb5b982) and pass with this change. Each case simulates one HTTP 503, then checks that concurrent lookups return the coordinator after recovery.
  • go test -race ./pkg/discovery -run '^TestRaftLookupRetriesBootstrapAfterFailure$' -count=100 passed on Go 1.20.14 and 1.25.5.
  • go test -race ./pkg/discovery/... -skip '^(TestWatch|TestSubscribeStartsWatchLoopPerVGroup)$' -count=1 passed on Go 1.25.5. Both excluded NamingServer tests also fail on unchanged master in this environment. TestWatch cannot access netlink, and TestSubscribeStartsWatchLoopPerVGroup times out.
  • go vet ./pkg/discovery/..., gofmt, and git diff --check passed.

OpenAI Codex generated the patch, regression tests, and this description and ran the local checks.

Raft service discovery retries bootstrap after a transient login or metadata request failure.

Retry metadata acquisition when seed addresses are already cached but
initial discovery failed. Serialize cold lookups and cover recovery from
both a failed login and a failed metadata request.

Generated-by: OpenAI Codex
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation coding milestone labels Nov 24, 2026
@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.44%. Comparing base (02bfd00) to head (7421f76).

Files with missing lines Patch % Lines
pkg/discovery/raft.go 94.73% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1239      +/-   ##
==========================================
+ Coverage   65.31%   65.44%   +0.12%     
==========================================
  Files         312      312              
  Lines       23890    23901      +11     
==========================================
+ Hits        15604    15641      +37     
+ Misses       6873     6856      -17     
+ Partials     1413     1404       -9     

☔ 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.

redyyang added 2 commits December 1, 2026 14:44
Signed-off-by: redyyang <redyyang@tencent.com>
Signed-off-by: redyyang <redyyang@tencent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working coding documentation Improvements or additions to documentation milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants