{{ message }}
Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The synchronization issue is addressed consistently in both reviewed files, with no unresolved blocking issues.
0 open findings
What changed in this PR
This PR fixes a data race in concurrent access to object and resource pool free chunks.
Changes:
- Removes unlocked
_free_chunks.empty()checks. - Protects all free-chunk access with the existing mutex.
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
songgaoye
force-pushed
the
fix/pool-free-chunk-race
branch
from
October 18, 2026 00:59
32aa81f to
f2960fc
Compare
songgaoye
force-pushed
the
fix/pool-free-chunk-race
branch
from
October 18, 2026 01:44
f2960fc to
6681951
Compare
wwbmmm
reviewed
Oct 18, 2026
wwbmmm
left a comment
Contributor
There was a problem hiding this comment.
[replied by brpc-oncall robot] Removing the unlocked read fixes the data race, but it also deletes a deliberate fast path that avoided the global mutex in the high-contention case; please keep a race-free fast path (atomic free-chunk count) or show the cost is acceptable.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What problem does this PR solve?
Issue Number: resolve
Problem Summary:
ObjectPoolandResourcePoolaccess_free_chunksfrom multiple threads.pop_free_chunk()previously read_free_chunks.empty()before acquiring_free_chunks_mutex, whilepush_free_chunk()modifies the same vector underthe mutex. Concurrent reads and writes of
std::vectormetadata are a C++ datarace.
What is changed and the side effects?
Changed:
_nfree_chunks, a relaxed atomic count of global free chunks, to bothObjectPoolandResourcePool._free_chunks_mutexafter every successful push andpop.
pop_free_chunk()._free_chunks.empty()check after acquiring themutex.
cross-thread reuse.
Side effects:
Performance effects:
The empty-list fast path no longer reads
std::vectorwithoutsynchronization. A relaxed atomic load avoids mutex acquisition when no
global free chunk is available, preserving the intended hot-path behavior.
Breaking backward compatibility:
None.