Commit 3d604a5
committed
Fix data race in MemTable::GetBloomFilter() on ARM weak memory model
Use release-acquire memory ordering instead of relaxed to ensure
DynamicBloom object is fully initialized before pointer publication.
Problem:
- On ARM (weak memory model), using relaxed ordering allows the pointer
to be published before DynamicBloom::data_ is initialized
- Readers may see non-null pointer but access uninitialized data_,
causing crashes
Solution:
- Use memory_order_acquire for load and memory_order_release for store
- This establishes synchronizes-with relationship, guaranteeing readers
only see fully initialized objects
Performance impact:
- The acquire load executes on every call (hot path in Get/Add operations)
- Overhead is minimal: typically 0-2 cycles on x86 (same as relaxed),
~1-3 cycles on ARM (may add memory barrier)
- This overhead is <1% of total latency compared to subsequent bloom
filter operations (hash computation + memory access)
Signed-off-by: hhwyt <hhwyt1@gmail.com>1 parent 2b04d05 commit 3d604a5
1 file changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
722 | | - | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
723 | 736 | | |
724 | 737 | | |
725 | 738 | | |
| |||
729 | 742 | | |
730 | 743 | | |
731 | 744 | | |
732 | | - | |
| 745 | + | |
733 | 746 | | |
734 | 747 | | |
735 | 748 | | |
| |||
0 commit comments