Repository navigation
feat(storage): overlap grouped hash operations with IS/IX and leaf locks - #439
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 45 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 05:07
1edbdc6 to
786d2ad
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 05:07
c03140b to
4b51879
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 06:13
786d2ad to
d6dd9d7
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 06:13
4b51879 to
87ff924
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 06:49
d6dd9d7 to
cff8721
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 06:49
87ff924 to
096e5f4
Compare
8 tasks
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 07:38
096e5f4 to
820944c
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 07:38
cff8721 to
7becdf9
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 07:53
820944c to
4b2af55
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 07:53
7becdf9 to
213f827
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 08:18
4b2af55 to
c324bd5
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 08:18
213f827 to
3779d6d
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 08:22
c324bd5 to
af00b98
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
2 times, most recently
from
November 6, 2026 09:00
6c74792 to
bed42b6
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
2 times, most recently
from
November 6, 2026 09:08
b1445f8 to
3ddd040
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 09:08
bed42b6 to
78124f2
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 09:18
3ddd040 to
c9d034c
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 09:18
78124f2 to
a633b2a
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 09:26
c9d034c to
41ae9a5
Compare
thweetkomputer
force-pushed
the
zset-selection-intent-writes
branch
from
November 6, 2026 09:26
a633b2a to
52be961
Compare
thweetkomputer
force-pushed
the
hash-intent-operations
branch
from
November 6, 2026 09:59
41ae9a5 to
bd2f382
Compare
This was referenced Nov 6, 2026
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.
Context
Based directly on main. Existing grouped Hash commands serialize the whole key across page IO.
Behavior before and after
Standalone HGET/HMGET/HEXISTS/HSTRLEN, HSCAN and HLEN use IS; HSET/HMSET/HSETNX/HDEL/HINCRBY/HINCRBYFLOAT use IX with ordered leaf holds. Disjoint leaves can proceed while a conflicting command waits. Compact, full-value, externally locked and structural operations retain whole-key arbitration.
Implementation
Share the Hash-like intent adapter, refresh protected leaves across unrelated root publications, and prepare bounded Hash append batches. Merge changed-leaf count deltas into the latest root after resource waits, then allocate revision and sequence and stage without yielding. Retain the latest predecessor decision for recovery. Before a speculative replicated write, preserve its original replication request; an IX-to-X fallback discards attempt-derived canonical commands, expiration effects and publication coordinates before retrying against current key state.
Design decisions and alternatives
Splits, demotion, final deletion and oversized batches release all groups and intent before one X retry; no lock upgrade or retry loop. The shared adapter is also usable by Set, but this PR only enables Hash. The retry snapshot adds an owned command copy only for replicated intent writers; compact and unreplicated fast paths do not take this copy.
Documentation and comments
Updated transaction/grouped architecture and API/invariant comments. Durable formats are unchanged.
Test plan
The complete Hash/Set/sampling stack, rebased onto main including #445, passes the Debug build and 15 focused regressions covering intent concurrency, native-replica TTL fallback, sampling and latency diagnostics.
cmake --build build_debug --target lavik lavik_grouped_hash_write_e2e_test --parallel 6— passed (Debug, ARM64).build_debug/lavik_unit_tests --gtest_filter='GroupedHashTest.*:HashGroup*'— 52 passed.build_debug/lavik_grouped_hash_write_e2e_test "$PWD/build_debug/lavik" --gtest_filter='GroupedHashWriteE2e.IntentRetryDiscardsPreviousIncarnationReplicationTTL:GroupedHashWriteE2e.StructuralRetryReleasesGroupsBeforeTakingKeyX'— 2 passed. The native-replica TTL case reproduced the missing-key divergence before the fix and passes after it; it also verifies TTL preservation on a successful IX attempt.ctest --test-dir build_debug --output-on-failure -R '^lavik_grouped_hash_write_e2e\.(GroupedHashSetSamplingE2e\.|GroupedSetIntentE2e\.|GroupedHashWriteE2e\.(Intent|ConcurrentFinalDeletion|StructuralRetry))'— 13 passed on the combined Hash/Set/sampling stack, including both real primary/replica TTL regressions, in 83.88 seconds.The complete reordered stack has the same Git tree as the previously built version. Its existing binary passed all 13 Hash/Set concurrency, sampling and native-replica TTL regressions again in 79.04 seconds:
build_debug/lavik_grouped_hash_write_e2e_test /tmp/lavik-stack-reorder-20261106/lavik-combined-before-reorder \ --gtest_filter='GroupedHashSetSamplingE2e.*:GroupedSetIntentE2e.*:GroupedHashWriteE2e.Intent*:GroupedHashWriteE2e.ConcurrentFinalDeletion*:GroupedHashWriteE2e.StructuralRetry*'The group-lock handoff fixture chooses a leaf with insertion capacity under its persisted seed, so it exercises lock handoff without an unrelated structural X-lock retry.
Risk assessment
Publication merging and structural fallback are the main risks. Tests cover disjoint count updates, conflicting wait/wake, structural fallback with a queued IX holder, and concurrent final deletion followed by cold recovery.
Rollback plan
Revert this change after reverting dependent Set/sampling changes; there is no disk-format migration.
Reviewer guide
Start with
hash_api.cppandMergeHashPublication, then review the late prepared-batch callback ingrouped/mutation.cppand the concurrency E2E tests.Follow-up work
Enable the shared adapter for Set and separately add selected-leaf random operations.
Summary by CodeRabbit