fix(lavasession): prevent stale reconnect candidates from polluting r…#2253
Conversation
Review Summary by QodoPrevent stale reconnect candidates from polluting reported providers
WalkthroughsDescription• Add generation counter to ReportedProviders to prevent stale reconnect candidates • Discard stale provider candidates after epoch transitions • Prevent "Failed to find reported provider in pairing list" errors • Add comprehensive test reproducing the reconnect race condition Diagramflowchart LR
RC["ReconnectCandidates captures<br/>generation snapshot"]
RC -- "epoch transition<br/>Reset() called" --> UT["UpdateAllProviders<br/>clears reportedProviders"]
UT -- "generation incremented" --> GC["Generation check<br/>in ReconnectProviders"]
GC -- "stale candidate<br/>generation mismatch" --> SKIP["Skip re-reporting<br/>stale provider"]
GC -- "current generation<br/>matches" --> REPORT["Re-report provider"]
File Changes1. protocol/lavasession/reported_providers.go
|
Code Review by Qodo
1. Generation check TOCTOU
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
6057301 to
ed7d6d8
Compare
ed7d6d8 to
56cd818
Compare
…eported providers ReconnectProviders could re-add a provider from a previous epoch after Reset() cleared the reported list during an epoch transition. Add a generation counter to ReportedProviders so stale candidates are discarded. Both success and error paths in ReconnectProviders now verify the generation under the same lock that performs the mutation, closing the TOCTOU gap. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56cd818 to
a7bd903
Compare
User description
…eported providers
ReconnectProviders could re-add a provider from a previous epoch after Reset() cleared the reported list during an epoch transition. Add a generation counter to ReportedProviders so stale candidates are discarded.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changemainbranchReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Prevent stale reconnect candidates from re-adding removed providers by tracking a generation counter in
ReportedProvidersand gatingReconnectProvidersprocessing during epoch transitions. IncludebackupProvidersin reported-provider filtering soConsumerSessionManagerno longer logs missing pairing entries when backup providers are reported.ReconnectProviderson the new generation counter, consolidating reporting logic underreportProviderLocked, and covering the epoch-transition race in a regression test so prior-epoch providers cannot reappear.Modified files (3)
Latest Contributors(2)
backupProviderswhen filtering reported entries soGetReportedProviderscan handle backup pools without emitting missing-pairing errors.Modified files (1)
Latest Contributors(2)