-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker]Fix thread safety issues in BucketDelayedDeliveryTracker with StampedLock optimistic reads #24542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix][broker]Fix thread safety issues in BucketDelayedDeliveryTracker with StampedLock optimistic reads #24542
Conversation
|
@Apurva007 Please add the following content to your PR description and select a checkbox: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24542 +/- ##
============================================
+ Coverage 73.57% 74.26% +0.69%
- Complexity 32624 32898 +274
============================================
Files 1877 1869 -8
Lines 139502 146113 +6611
Branches 15299 16763 +1464
============================================
+ Hits 102638 108518 +5880
- Misses 28908 28964 +56
- Partials 7956 8631 +675
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Technoboy-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good work @Apurva007. Thanks for the contribution!
coderzc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… with StampedLock optimistic reads (apache#24542) (cherry picked from commit 86eb3b8) (cherry picked from commit 455a052)
… with StampedLock optimistic reads (apache#24542) (cherry picked from commit 86eb3b8) (cherry picked from commit 455a052)
… with StampedLock optimistic reads (apache#24542) (cherry picked from commit 86eb3b8)
… with StampedLock optimistic reads (apache#24542) (cherry picked from commit 86eb3b8)
|
Reopened #23190 |
…yTracker with StampedLock optimistic reads (apache#24542)" This reverts commit dfb3ca5. (cherry picked from commit 00f2433)
…yTracker with StampedLock optimistic reads (apache#24542)" This reverts commit dfb3ca5.
… with StampedLock optimistic reads (apache#24542) (cherry picked from commit 86eb3b8) (cherry picked from commit dfb3ca5)
…yTracker with StampedLock optimistic reads (apache#24542)" This reverts commit dfb3ca5. (cherry picked from commit 00f2433)
… with StampedLock optimistic reads (#24542)
…yTracker with StampedLock optimistic reads (apache#24542)" This reverts commit 455a052.
… with StampedLock optimistic reads (apache#24542)
… with StampedLock optimistic reads (apache#24542)
Motivation
Fixes #23190
BucketDelayedDeliveryTracker had thread safety issues in frequently called methods like
containsMessage()andnextDeliveryTime()that could lead to race conditions, incorrect duplicate detection, and scheduling inconsistencies under high concurrency loads.The issue manifested as:
containsMessage()leading to incorrect duplicate detectionnextDeliveryTime()causing scheduling inconsistenciesModifications
Added StampedLock for high-performance concurrency control
Applied optimistic reads to critical methods:
containsMessage()- Used for duplicate message detectionnextDeliveryTime()- Called frequently for message schedulingMaintained existing write operation synchronization
synchronizedfor simplicity and safetyRemoved unused data structure
immutableBucketsMapfield to reduce memory overheadimmutableBucketsRangeMapPerformance Improvements
Benchmark results show excellent performance across various concurrency scenarios:
Thread Safety Strategy
Verifying this change
BucketDelayedDeliveryTrackerThreadSafetyTestBucketDelayedDeliveryTrackerSimpleBenchmarkDoes this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes:
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: Link
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com