Skip to content

Read buffered rows with the right table definition - #365

Merged
serprex merged 2 commits into
mainfrom
descriptor-consistency
Nov 26, 2026
Merged

serprex merged 2 commits into
mainfrom
descriptor-consistency

Conversation

@serprex

@serprex serprex commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Read buffered rows with the right table definition

Buffered rows could use the table definition at commit even if they
were written before a schema change. Use each row's WAL position to
look up its saved definition, including after restart.

Track missed catalog reads per table and allow later reads to continue.
Fill gaps where a later definition can safely read earlier rows, and
stop when no safe definition exists. This preserves new column values
in ClickHouse when a second ADD COLUMN goes unread.

Read table definitions only when WAL needs them

The 64-read and 10-second replay wait limits could skip a table
definition needed by buffered rows and stop replication.

Remove both per-transaction limits. Before sending WAL past a DDL
command, look ahead in buffered WAL. Skip the catalog read only when
a later read covers the same tables and no row needs the intermediate
definition. Catalog-only migrations can use a single commit read.
If the available WAL leaves any doubt, read at the current boundary.


Note

High Risk
Changes core catalog capture, descriptor timeline construction, and commit-time row decoding—incorrect gap filling or skip logic could mis-decode schema changes or stall replication.

Overview
Command-boundary catalog capture no longer degrades whole transactions via per-xact read caps or hold budgets. Failed or skipped reads are recorded as per-table misses, name-refresh events handle cache flushes, and timeline::build assembles WAL-ordered descriptor history at commit—fencing gaps only when compatible_reader cannot bridge them.

The WAL pump lookahead in wal_stream tracks row touches between command boundaries and can skip a shadow read when buffered WAL shows no heap rows need that definition before a later covering read. BoundaryInfo carries preceding_rows / following_rows for that decision; metrics add pending_skipped.

Buffered row decoding no longer depends on provisional PendingCatalog at drain time: DescriptorLog::rfn_history supplies per-LSN descriptors (including after restart), with StashUncovered when none exists. Config pending_max_* and related degrade reasons are removed; docs/plans and e2e tests move to fail_command_read_after for forced misses.

Reviewed by Cursor Bugbot for commit 62a34f8. Bugbot is set up for automated code reviews on this repo. Configure here.

@serprex
serprex requested a review from harshil-goel November 26, 2026 18:30
@serprex serprex changed the title Descriptor consistency Read buffered rows with the right table definition Nov 26, 2026
harshil-goel
harshil-goel previously approved these changes Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

AI review gate — AI review passed

Clean review from: Cursor Bugbot.

@security-ai-gate-reviewer security-ai-gate-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by the AI review gate on ed6fe37. Details in the approver's comment on this pull request.

@security-ai-gate-reviewer

security-ai-gate-reviewer Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

AI review gate — auto-approved

62a34f8c5952 is approved by security-ai-gate-reviewer[bot], an automated identity, not a human. The approval stands on the required AI review: Cursor Bugbot concluded green on this commit and the AI review gate is SUCCESS (its own comment has the verdict), and the change touches no path that requires a human reviewer. It is bound to this commit: a new push dismisses it and the approver re-evaluates.

History (latest 5 heads, newest first)

  • 62a34f8c5952 approved — green: Cursor Bugbot
  • ed6fe3770484 approved — green: Cursor Bugbot

Buffered rows could use the table definition at commit even if they
were written before a schema change. Use each row's WAL position to
look up its saved definition, including after restart.

Track missed catalog reads per table and allow later reads to continue.
Fill gaps where a later definition can safely read earlier rows, and
stop when no safe definition exists. This preserves new column values
in ClickHouse when a second ADD COLUMN goes unread.
The 64-read and 10-second replay wait limits could skip a table
definition needed by buffered rows and stop replication.

Remove both per-transaction limits. Before sending WAL past a DDL
command, look ahead in buffered WAL. Skip the catalog read only when
a later read covers the same tables and no row needs the intermediate
definition. Catalog-only migrations can use a single commit read.
If the available WAL leaves any doubt, read at the current boundary.

@security-ai-gate-reviewer security-ai-gate-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by the AI review gate on 62a34f8. Details in the approver's comment on this pull request.

@serprex
serprex merged commit 1713b3f into main Nov 26, 2026
10 checks passed
@serprex
serprex deleted the descriptor-consistency branch November 26, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants