fix(hazelcast): use atomic operations for tag list updates#308
Merged
Conversation
Switches setTags from a racy Get → SetWithTTL pattern to atomic PutIfAbsentWithTTL / ReplaceIfSame primitives, and refreshes the tag's TTL on every Set (including the duplicate-key case). Aligns the Hazelcast tag-handling shape with the Memcache store. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
|
Thank you for this update @semihbkgr |
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.
Replaces the racy
Get → modify → SetWithTTLpattern insetTagswith atomic operations to remove race conditions under concurrent modification of the same tag. Two writers appending to the same tag could each Get the same value and overwrite each other's appends, silently dropping keys from the tag list.Following the same approach as the Memcache store, the update is now done via:
PutIfAbsentWithTTL— atomic create-if-absent on the first-writer path (counterpart of memcache'sAdd).ReplaceIfSame— atomic CAS on the update path (counterpart of memcache'sCompareAndSwap); paired withSetTTLto refresh the tag's expiration.SetTTLon the duplicate-key path so re-Setof an existing(key, tag)still refreshes the tag's TTL — same fix as fix(memcache): refresh tag TTL when re-Setting an existing (key, tag) #307 for memcache.Mock regenerated via mockgen. Tests cover all three paths: create, CAS update, and duplicate-key TTL refresh.