fix: resolve seek_to hang by routing time-based seeks via streaming store#1140
Open
SBALAVIGNESH123 wants to merge 2 commits intotimeplus-io:developfrom
Open
fix: resolve seek_to hang by routing time-based seeks via streaming store#1140SBALAVIGNESH123 wants to merge 2 commits intotimeplus-io:developfrom
SBALAVIGNESH123 wants to merge 2 commits intotimeplus-io:developfrom
Conversation
…tore When seek_to uses a relative or absolute time (e.g. '-15m') with enable_backfill_from_historical_store enabled, the query enters StreamingConcat mode which scans all historical MergeTree parts before streaming begins, causing the query to appear hung. This fix probes NativeLog first: if the streaming store still has the requested data, convert the time-based seek to a sequence-based seek and use QueryMode::Streaming, bypassing the expensive historical scan entirely. Falls back to existing StreamingConcat when the data has been compacted. Fixes timeplus-io#558
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.
Fixes #558
When using a time-based
seek_tolike'-15m'on a stream with a large TTL (say 30 days), the query hangs indefinitely because the backfill path kicks in — it scans all historical MergeTree parts before streaming can begin, andConcatStepblocks output until that entire scan is done. On a busy stream, this takes so long the query appears stuck.The root cause is that getQueryMode() always returns
StreamingConcatfor time-based seeks when backfill is enabled, even when the NativeLog streaming store still has the requested data readily available.This fix adds a simple check before entering
StreamingConcat: we probe NativeLog using the existing sequencesForTimestamps() API to see if the streaming store still holds data for the requested time range. If it does, we convert the time-based seek into a sequence-based seek and useQueryMode::Streaminginstead — completely skipping the expensive historical scan. If the data has been compacted away from NativeLog, we fall back to the existingStreamingConcatbehavior with no regression.This is the same pattern Kafka uses internally —
offsetsForTimes()converts timestamps to offsets, and then the consumer seeks by offset.Files changed: