Skip to content

Fix race on bucket random evicion cache#5189

Open
SirTyson wants to merge 1 commit intostellar:masterfrom
SirTyson:bucket-index-race
Open

Fix race on bucket random evicion cache#5189
SirTyson wants to merge 1 commit intostellar:masterfrom
SirTyson:bucket-index-race

Conversation

@SirTyson
Copy link
Contributor

@SirTyson SirTyson commented Mar 19, 2026

Description

Resolves https://github.com/stellar/stellar-core-internal/issues/492

Originally I was going to create a thread-safe version of the random eviction cache do reduce contention, but until we observe a perf bottleneck related to this cache, just changing the lock to exclusive is the simplest fix.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a concurrency issue in the LiveBucketIndex random-eviction cache by ensuring cache lookups take a write/exclusive lock when they mutate cache-internal state (access counters / generation / last-access).

Changes:

  • Switch cache lookup locking in LiveBucketIndex::getCachedEntry from shared to exclusive to prevent concurrent mutation races.

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