enhance: fix data race and nil-slice edge case in BloomFilterSet.PkCandidateExist#49004
Conversation
…ndidateExist PkCandidateExist read s.currentStat and s.historyStats without holding statsMutex, unlike every other read method (MayPkExist, BatchPkExist, GetMinPk, GetMaxPk, MemSize). A concurrent UpdatePkCandidate or AddHistoricalStats call would produce a data race detectable by -race. Also replace `s.historyStats != nil` with an element-wise non-nil scan, matching the pattern already used by GetMinPk / GetMaxPk, so that an empty or nil-only slice is not misreported as ready. issue: milvus-io#48992 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Alex Korbonits <alex@korbonits.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: korbonits The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @korbonits! It looks like this is your first PR to milvus-io/milvus 🎉 |
|
[ci-v2-notice] To rerun ci-v2 checks, comment with:
If you have any questions or requests, please contact @zhikunyao. |
|
/ci-rerun-code-check |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #49004 +/- ##
==========================================
- Coverage 77.93% 77.93% -0.01%
==========================================
Files 2167 2167
Lines 356312 356321 +9
==========================================
- Hits 277687 277686 -1
- Misses 70054 70063 +9
- Partials 8571 8572 +1
🚀 New features to boost your workflow:
|
|
/ci-rerun-ut-go |
|
/ci-rerun-gosdk |
Summary
BloomFilterSet.PkCandidateExistreads.currentStatands.historyStatswithout holdingstatsMutex, while every other read method in the same struct (MayPkExist,BatchPkExist,GetMinPk,GetMaxPk,MemSize) takes the lock. A concurrentUpdatePkCandidateorAddHistoricalStatscall (both write under lock) produces a data race detectable by-race.Two issues fixed:
s.statsMutex.RLock()/RUnlock()toPkCandidateExist, consistent with all other read methods.s.historyStats != nilwith an element-wise non-nil scan, matching the pattern already used byGetMinPk/GetMaxPk. An empty slice or a slice of all-nil entries is now correctly reported as "not ready."issue: #48992
Test plan
TestPkCandidateExistcovering: empty set, current stat only, nil-only historyStats slice, empty historyStats slice, valid historical stat with nil current.TestInt64Pk,TestVarCharPk,TestHistoricalStat,TestMemSize) remain green.🤖 Generated with Claude Code