Skip to content

Use pointer instead of iterator for thread safe unordered_map usage#5749

Merged
ypatia merged 1 commit intomainfrom
yt/fix_race_map
Feb 13, 2026
Merged

Use pointer instead of iterator for thread safe unordered_map usage#5749
ypatia merged 1 commit intomainfrom
yt/fix_race_map

Conversation

@ypatia
Copy link
Member

@ypatia ypatia commented Feb 11, 2026

While reading remote global order writes code, chasing a corruption issue, I spotted that we were accessing an iterator of an unordered_map without synchronization which is not thread safe (afaik concurrent emplace() calls for other URIs may trigger an unordered_map rehash which invalidates iterators). I replaced the iterator with a pointer to the data instead to fix this

Relates to CLOUD-3368


TYPE: BUG
DESC: Use pointer instead of iterator for thread safe unordered_map usage

Copy link
Member

@teo-tsirpanis teo-tsirpanis left a comment

Choose a reason for hiding this comment

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

We are under a reader lock; how is this unsafe? Writes aren't suppose to happen during that code path.

@ypatia
Copy link
Member Author

ypatia commented Feb 12, 2026

We are under a reader lock; how is this unsafe? Writes aren't suppose to happen during that code path.

There is a unique_rl.unlock(); in both branches of the if statement, so we are not in a reader lock.

Copy link
Member

@teo-tsirpanis teo-tsirpanis left a comment

Choose a reason for hiding this comment

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

Approved per offline explanation.

@ypatia ypatia merged commit 828ba62 into main Feb 13, 2026
109 of 110 checks passed
@ypatia ypatia deleted the yt/fix_race_map branch February 13, 2026 13:41
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