Repository navigation
feat(storage): use IS and selected groups for zset range reads - #435
Merged
Merged
Conversation
|
Caution Review failedThe pull request is closed.
Warning Some tools did not complete. Review the errors below.
|
thweetkomputer
force-pushed
the
zset-range-intent-reads
branch
from
November 5, 2026 11:12
819ecde to
b30065a
Compare
thweetkomputer
force-pushed
the
zset-cardinality-intent-read
branch
2 times, most recently
from
November 5, 2026 12:35
e5a303d to
698772c
Compare
thweetkomputer
force-pushed
the
zset-range-intent-reads
branch
2 times, most recently
from
November 6, 2026 05:07
5681af9 to
54d48dd
Compare
thweetkomputer
force-pushed
the
zset-cardinality-intent-read
branch
2 times, most recently
from
November 6, 2026 06:13
54698e3 to
ad0146c
Compare
thweetkomputer
force-pushed
the
zset-range-intent-reads
branch
from
November 6, 2026 06:13
54d48dd to
88784f8
Compare
thweetkomputer
force-pushed
the
zset-cardinality-intent-read
branch
from
November 6, 2026 06:49
ad0146c to
9b9bd17
Compare
thweetkomputer
force-pushed
the
zset-range-intent-reads
branch
2 times, most recently
from
November 6, 2026 07:38
2d57e86 to
9b90efd
Compare
thweetkomputer
force-pushed
the
zset-cardinality-intent-read
branch
2 times, most recently
from
November 6, 2026 07:53
a2e82c6 to
262f033
Compare
thweetkomputer
force-pushed
the
zset-range-intent-reads
branch
2 times, most recently
from
November 6, 2026 08:18
17551b7 to
fe76457
Compare
thweetkomputer
force-pushed
the
zset-cardinality-intent-read
branch
from
November 6, 2026 08:18
262f033 to
265fd1c
Compare
thweetkomputer
force-pushed
the
zset-range-intent-reads
branch
from
November 6, 2026 08:22
fe76457 to
c94dfd7
Compare
thweetkomputer
changed the base branch from
zset-cardinality-intent-read
to
main
November 6, 2026 08:22
Move optional diagnostics after group-lock and commit-control arguments, and update declarations, definitions and every caller while preserving effective argument values and defaults.
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
Grouped range, rank and count reads take whole-key S and wait for unrelated group writers. Let these projections use key IS and protect only the payload groups they require.
Behavior before and after
Grouped ZRANGE aliases, ZRANK/ZREVRANK, ZCOUNT and ZLEXCOUNT acquire the required group S holds in identity order, revalidate routing and capture one immutable directory for counts and bounds. Rank also protects its member leaf. Ambiguous routing falls back once to key S.
Score counts lock partial boundary pages. Score LIMIT/OFFSET uses resident ranks to skip unrelated pages, including reverse ranges. Mixed-score lexical projections protect every ordered page because there is no lexical directory.
Implementation
Page loaders validate protected group revisions while unrelated roots publish. The common logical view is captured after acquisition, so concurrent changes to preceding cardinality cannot shift a range midway through its read.
Optional
OnlineLatencyTrace* diagnosticsis the final parameter in the affected storage helpers. Group-lock flags, retry outputs and deferred commit state precede it. Declarations, definitions and callers use the same order; callers that supply diagnostics explicitly supply any preceding default control argument. The dependent PRs apply the same convention to their additional helpers and calls.Design decisions and alternatives
Retain group holds across waits and IO, with one whole-key fallback when routing cannot be validated. Parameter reordering preserves each argument value and default, including
group_locked; it does not treat a diagnostic pointer as a Boolean flag.Documentation and comments
The grouped-collections architecture describes IS range/rank/count projections and their common-view boundary. Existing ownership and lock-precondition comments remain applicable to the parameter-order cleanup, which does not change that architectural model.
Test plan
The Debug build for this PR passed, followed by 25 focused tests: 24 CTest cases plus the trace lifecycle metrics test. Coverage includes range/rank/count semantics, lock wait/wakeup, member projections, recovery, native replication, dependent commits and latency tracing.
The first latency E2E attempt received HTTP 502 because the environment proxied its loopback metrics request. That case and the remaining dependent-commit case passed with loopback proxy bypass:
NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost ctest --test-dir build_debug --output-on-failure --stop-on-failure -R '^lavik_latency_diagnostics_e2e$|^lavik_tx_commit_retry_e2e\.dependent$'The complete stack through #441 also built and passed 17 focused tests for Hash/Set intents and sampling, replication TTL fallback, zset batch/selected writes and latency diagnostics:
cmake --build build_debug --target lavik lavik_unit_tests lavik_grouped_ordered_write_e2e_test lavik_grouped_hash_write_e2e_test --parallel 4 NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost ctest --test-dir build_debug --output-on-failure --stop-on-failure -R '^lavik_grouped_hash_write_e2e\.(GroupedHashWriteE2e\.(Intent.*|ConcurrentFinalDeletionRetriesUnderKeyX)|GroupedSetIntentE2e\..*|GroupedHashSetSamplingE2e\..*)$|^lavik_grouped_ordered_write_e2e\.GroupedSortedSetWriteE2e\.(SamplingReadsLockOnlyTheirWindow|BatchWritesOrderAllGroupsAndPublishAtomically|SelectedWritesProtectPredicatesAndAllowMemberReads|PopRevalidatesSelectionAfterReleasingReadLocks)$|^lavik_latency_diagnostics_e2e$'Formatting checks passed. Each rebased tree was checked against the prior source with only the parameter-order transformation applied.
Risk assessment
The relevant boundaries are routing revalidation, group-lock lifetime, common-view consistency and trace forwarding. The focused tests exercise these paths, including disjoint progress and conflicting writers. Compact values and externally locked transaction callers retain their existing protection; durable formats and wire replies are unchanged.
Rollback plan
Revert the feature and helper-signature changes together with dependent call-site updates. No storage migration is required.
Reviewer guide
Start with
TryConcurrentSortedSetRangeRead, then the grouped page loaders andExecuteGroupedSortedSetLocked. The parameter-order cleanup is a separate commit. This PR is based directly on main.Follow-up work
PRs #436–#441 extend intent locking to sampling, additional writes and Hash/Set operations. Their callers have been adapted to the final diagnostics parameter and remain independently reviewable against their immediate bases.