Repository navigation
fix: inactivity rebuild timer should consult the rebuild threshold - #6510
Merged
lvca merged 3 commits intoAug 20, 2026
Merged
Conversation
The inactivity rebuild timer used to arm and fire on `pending > 0` alone, so a single insert into a large settled LSM_VECTOR index triggered a full O(N) graph rebuild about 15 seconds later (issue ArcadeData#6496). This commit adds an `inactivityRebuildIsWorthIt()` helper that checks the same effective rebuild threshold the search path uses, with a floor of `max(threshold/10, 1)` so a trickle of writes is still eventually absorbed rather than deferred forever. Both the arming path in `scheduleInactivityRebuild()` and the firing path in the TimerTask now consult this helper. Fixes ArcadeData#6496
Up to standards ✅🟢 Issues
|
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
…uild path The PR's inactivityRebuildIsWorthIt() applied the threshold/floor gate to every graph size, but a rebuild is only expensive once the graph has grown past ASYNC_REBUILD_MIN_GRAPH_SIZE (1000 vectors); below that, rebuildGraphBeforeSearch() already rebuilds synchronously and unconditionally on the search path because it's cheap enough not to matter. Gating the timer uniformly meant a small, low-volume index (well under the floor) never got its pending vectors flushed by the inactivity timer at all, breaking the documented guarantee that buffered vectors don't sit in the linear-scan delta buffer indefinitely - confirmed by running LSMVectorIndexRebuildTest against the unmodified PR branch, where deltaBufferShouldFlushAfterInactivityTimeout, timerShouldResetOnNewMutations and skippedInactivityRebuildShouldRetryUntilServed each hang for the full 11-minute Awaitility ceiling before failing. The threshold/floor check now only applies once the graph is large enough that a rebuild is genuinely O(index size); small graphs keep the prior "any pending mutation is worth flushing" behavior. Added Issue6496InactivityRebuildThresholdTest to reproduce the reported scenario directly (large settled index, single insert must not trigger a full rebuild on inactivity, but pending mutations at/above the floor still get rebuilt). All 15 tests in LSMVectorIndexRebuildTest and both new tests pass; the full com.arcadedb.index.vector package was run and the only failure (LSMVectorIndexAutoCompactionTest#anAttemptWhoseTaskIsNeverEnqueuedReleasesItsSlot) reproduces identically on unmodified main, unrelated to this change.
tae898
pushed a commit
to humemai/arcadedb-embedded-python
that referenced
this pull request
Aug 28, 2026
…graph as a small one The graph loads lazily on the first search, so `graphIndex == null` carries three meanings and only two of them mean "a rebuild here is cheap": no graph was ever built, the graph is genuinely tiny, or a large graph is fully persisted and this session has simply never loaded it. `inactivityRebuildIsWorthIt()` and the timer task's sync/async arm choice read the third as the first two, so the mutation threshold was skipped entirely and one insert into a reopened index rebuilt every vector, synchronously, on the timer thread. Ingest-then-idle - open, write, go quiet - is the ordinary shape of a loader process, and it is the one shape that never loads the graph. This is the same conflation ArcadeData#6772 fixed for a session that searches; that fix works by loading the persisted graph inside `ensureGraphAvailable()`, which the timer never calls. Both call sites now ask `inactivityRebuildScopeSize()` how many vectors a rebuild would actually cover. When nothing is resident and nothing has resolved what is on disk yet, the answer is the LIVE vector count rather than the persisted graph's node count: `buildGraphFromScratch()` covers the live set, so that is the direct measure of the cost being gated, and it gives the right answer where the two diverge - a large persisted graph whose vectors have since been deleted really is cheap to rebuild, and keeps being flushed promptly. Confined to the case `graphNotYetMaterialised()` identifies, so everything downstream of a resolution answers exactly as before, including the window where a rebuild nulls the resident graph before publishing its replacement. `rebuildGraphBeforeSearch()` is deliberately left reading `graphIndex` directly: `ensureGraphAvailable()` always runs immediately before it, and routing a search down the large-graph arm would hand it the async rebuild and an empty result set instead of a slow but correct one. New `persistedGraphNodeCount` stat, so "no graph exists" and "no graph is loaded" can be told apart from outside - the distinction the whole fix rests on. Regression test pins three behaviours, because fixing only the first is what broke three existing tests the last time this gate was touched (ArcadeData#6510 for ArcadeData#6496): one insert into a large-but-unloaded index rebuilds nothing; reaching the floor still rebuilds, so nothing is deferred forever; and a genuinely small persisted index still flushes on any pending mutation.
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.
Problem: The inactivity rebuild timer never consults the rebuild threshold. It arms and fires on
pending > 0alone, so a single insert into a large settled LSM_VECTOR index triggers a full O(N) graph rebuild about 15 seconds later (issue #6496).Fix: Add an
inactivityRebuildIsWorthIt()helper that checks the same effective rebuild threshold the search path uses, with a floor ofmax(threshold/10, 1)so a trickle of writes is still eventually absorbed rather than deferred forever. Both the arming path inscheduleInactivityRebuild()and the firing path in the TimerTask now consult this helper.Fixes #6496