Repository navigation
Accept only MergeTree sources for an incremental refresh - #131814
Conversation
An incremental refresh (`APPEND INCREMENTAL`) resumes from the cursor that the read reports through `Context::getStreamingCursor`, and only a `MergeTree` read reports it. When other engines support `STREAM`, a source of such an engine would be read from the beginning on every refresh, appending the same rows again. Reject it, and explain in `Context.h` that `StreamingCursor` exists only for the incremental refresh. Related: #42990 Related: #131769 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [22109b8] Summary: ✅
AI ReviewSummaryRestricts Final VerdictStatus: ✅ Approve. |
|
We will support incremental refresh from Merge, Distributed, as well as from all streaming table engines, would we? |
|
Because this is one of the goals of #42990 - infinite and consistent consumption from a stream with the possibility to insert into another table of a stream. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 20 s compile time in total, 7 of them have a recent master baseline. |
A bounded streaming read of a `FileLog` table reports the offsets it read up to
through the holder of an incremental refresh, with the inode of every file
(`{file: {offset, inode}}`), so a `FileLog` table can be the source of an
incremental refresh. A file replaced by another one with the same name or
truncated since the cursor was taken is read from the beginning.
Related: #131814 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
For an incremental refresh from a `Distributed` table, the initiator sets the internal setting `report_streaming_cursor` for the shards. A shard then creates the holder of the cursor for the query and sends the cursor its bounded streaming read advanced to in the new `StreamingCursor` server packet (protocol version 54497) before `EndOfStream`. The initiator keeps the cursors under the shard numbers, and fails if a shard does not send one. A local shard, including the local fallback of a lazy remote shard, reports through a child holder under the shard number. A streaming read for an incremental refresh of a table that does not report the cursor is refused by the analyzer, e.g. on a shard. `MultiplexedConnections` and `HedgedConnections` pass the new packet through; the native protocol spec describes it. Related: #131814 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bounded streaming read of a `Kafka` table reports the offsets it read up to through the holder of an incremental refresh, so a `Kafka` table can be the source of an incremental refresh, which resumes every refresh from them without a consumer group. Related: #131814 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bounded read of every table of a `Merge` table reports its cursor under the database and the table through a child holder, so a `Merge` table can be the source of an incremental refresh. A table that does not report the cursor is refused on every refresh, as the matching tables may change. The cursor of a table with dots in the database or the table name is found by the parts of the name, as the cursor tree splits the keys by dots. Related: #131814 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bounded streaming read of a `NATS` table with `nats_stream` reports the stream sequence it read up to through the holder of an incremental refresh, so such a table can be the source of an incremental refresh. Related: #131814 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bounded streaming read of a `RabbitMQ` table with stream queues reports the offsets it read up to through the holder of an incremental refresh, so such a table can be the source of an incremental refresh; a message that arrives after the end of a bounded read is appended by the next refresh. Related: #131814 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A streaming read of a `Memory` table accepts a cursor
`{epoch, generation, block_number}`, and a bounded read reports it through the
holder of an incremental refresh, so a `Memory` table can be the source of an
incremental refresh. The epoch is a random number of the server process, as the
generations of the data are numbered anew in every process. A cursor of another
process or of a generation that started empty (`TRUNCATE`) means that all the
blocks are new; a generation that a mutation rewrote cannot be resumed after a
position in a previous one, so the refresh fails.
Related: #131814 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Yes. This PR is in the merge queue as it is (it only refuses the sources that cannot resume yet). The rest is in #132145, which replaces the
|
An incremental refresh of a refreshable materialized view (
APPEND INCREMENTAL) resumes from the cursor that the read reports throughContext::getStreamingCursor, and only aMergeTreeread reports it. The source was required only to supportSTREAM, which was true just forMergeTreetables. WithSTREAMsupport for other engines (the PRs below), a source of such an engine would be read from the beginning on every refresh, appending the same rows again. This PR rejects such sources, and explains inContext.hthatStreamingCursorexists only for the incremental refresh and other streaming queries must not rely on it (per the review of the first version).The engine PRs are based on this commit, and each of them tests the rejection for its engine:
Merge: Streaming queries with cursors for Merge tables #131815Distributed: Streaming queries with cursors for Distributed tables #131816Kafka: Streaming queries with cursors for Kafka tables #131818FileLog: Streaming queries with cursors for FileLog tables #131819NATS: Streaming queries with cursors for NATS JetStream tables #131820RabbitMQ: Streaming queries with cursors for RabbitMQ stream queues #131821Related: #42990
Related: #131769
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131814]
Version info
26.11.1.2520-master(included in26.11and later)