fix(p2p): resolve map race, nil iterator panic, and retry drops in replicator - #5200
fix(p2p): resolve map race, nil iterator panic, and retry drops in replicator#5200pranav718 wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📜 Recent review details🔇 Additional comments (2)
📝 WalkthroughWalkthroughThe P2P replicator now snapshots peer IDs before asynchronous dispatch, cancels request timeout contexts after each request, serializes completed retry handling, and returns on iterator creation errors. New tests cover concurrent map access and canceled retry completion. ChangesReplicator safety fixes
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change hardens P2P replication by preventing a map race and iterator panic, preserving retries after timeouts, and synchronizing retry updates. No actionable merge-blocking risk remains beyond normal checks and review. Assessment against linked issues
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Relevant issue(s)
Resolves #5199
Description
This PR hardens the P2P replicator subsystem (
internal/db/p2p/replicator.go) against concurrency races and runtime panics:pushLogToReplicators: Iteratingp.replicators[colID]without holdingp.repMuraced withupdateReplicatorson peer updates. Peer IDs are now safely copied into a local slice underp.repMu.Lock()prior to iteration.retryReplicators: Added the missingreturnstatement whenp.db.Multistore().Peerstore().Iterator()returns an error, preventingiter.Next()from panicking on anilpointer.pushLogToReplicators: When a replication request times out (context.DeadlineExceeded),handleReplicatorFailureis now passedp.ctxinstead of the expired network request context, ensuring retry records are properly persisted to the peerstore.handleCompletedReplicatorRetrywithhandleRetryMutex: Synchronizes peerstore retry record modifications with concurrent failure handlers.defer cancel()inside head iteration loops with explicit per-iteration cancellations.Tasks
repMulock inpushLogToReplicatorsretryReplicatorshandleCompletedReplicatorRetrywithhandleRetryMutexinternal/db/p2p/replicator_test.gogo test -race