fix: harden SCQIndexing seek logic and de-flake queue cleanup tests#1700
Open
peter-lawrey wants to merge 4 commits intodevelopfrom
Open
fix: harden SCQIndexing seek logic and de-flake queue cleanup tests#1700peter-lawrey wants to merge 4 commits intodevelopfrom
peter-lawrey wants to merge 4 commits intodevelopfrom
Conversation
|
sam-ross
approved these changes
Mar 10, 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.



Drawing on this PR for inspiration #1699
This PR contains a manually curated subset of the broader AIDE-driven changes, focused on two areas:
SCQIndexing.sequenceForPosition(...)The selected changes keep the indexing fix and its focused regression coverage, while also consolidating test cleanup around a shared background-release helper to reduce file-handle and deletion flakiness.
Functional changes
SCQIndexing: safer and faster position-to-sequence lookup
SCQIndexing.sequenceForPosition(...)has been reworked to improve both correctness and search behaviour.Changes include:
use a read-only secondary-address lookup on the read path via
getSecondaryAddressReadOnly(...)replace the previous reverse linear slot search with:
findBestSecondarySlotForPosition(...)findBestSecondarySlotByReverseScan(...)fallback when holes are detectedextract
toSequenceIndex(...)to make index reconstruction clearerimprove variable naming in the indexing path:
usedPrimarySlotsprimarySlotusedSecondarySlotssecondarySlotfirstPositioncandidateAddresstidy
setPositionForSequenceNumber(...)naming for readability (secondarySlot,existingPosition)This addresses two practical issues in the old flow:
The implementation also preserves correctness in the presence of index holes by falling back to reverse scan when a zero slot is encountered during binary search.
Test changes
New SCQIndexing regression coverage
Added
SCQIndexingTestwith focused behavioural coverage for the selected indexing changes:sequenceForPositionMustNotCreateSecondaryIndexBlockssequenceForPositionMatchesLinearAndBinarySearchtailerCanReadAllEntriesWhenIndexHasHolessequenceForPositionWithInteriorHoleStillFindsCorrectAnchorsequenceForPositionMustNotCreateSecondaryIndexBlocksWithLargeQueueconcurrentTailersDoNotCorruptOrThrowtableStoreWriteLockSubprocessStartsWithin15SecondsTogether these tests protect:
Test cleanup and de-flaking
This PR also introduces a shared cleanup helper in
QueueTestCommon:drainBackgroundCleanup()The helper centralises:
BackgroundResourceReleaser.releasePendingResources()It is now used across a wide set of tests that previously:
BackgroundResourceReleaser.releasePendingResources()directly, orThis makes teardown more deterministic and reduces flakiness around:
QueueTestCommon updates
QueueTestCommonnow:drainBackgroundCleanup()Tests migrated to shared cleanup
The selected changes update a broad group of tests to use the shared cleanup path before deleting files or asserting release state, including areas such as:
Additional test hardening
A few additional adjustments were kept as part of this curated PR:
ChronicleHistoryReaderMainTestonly resets the security manager on pre-Java-17 runtimessome tests now extend
QueueTestCommonto gain consistent cleanup and exception-expectation supportAppenderFileHandleLeakTestwas tightened with:Why this PR
The chosen subset keeps the highest-value pieces of the original work:
SCQIndexingread/seek improvementIt deliberately avoids bundling unrelated planning artefacts or broader changes not needed for the final reviewed PR.