Repository navigation
storage: stage Postgres sink updates with COPY - #39706
patrickwwbutler wants to merge 1 commit into
Conversation
QA LLM Review1. HIGH -- A batch is sent as one CopyData message, so any batch over 1 GiB permanently crash-loops the sink
DetailsThe arrange operator seals one batch per capability ( I reproduced this on postgres:16 with rows in the staging-table shape. One 1.1 GiB CopyData message gets Fix: flush inside the row loop instead of per batch. The cursor only borrows the locally owned let n = diff.unsigned_abs();
for _ in 0..n {
buf.extend_from_slice(&scratch);
+ if buf.len() >= COPY_CHUNK_BYTES {
+ send_buffered(&client, ©_stmt, &mut copy, &mut buf)
+ .await?;
+ }
}
@@
statistics.inc_messages_staged_by(rows);
statistics.inc_bytes_staged_by(bytes);
-
- if buf.len() >= COPY_CHUNK_BYTES {
- send_buffered(&client, ©_stmt, &mut copy, &mut buf).await?;
- }2. MEDIUM -- Binary COPY into a stale staging table silently reinterprets values after
|
8e39a87 to
8a51055
Compare
Implement the encode operator and the staging half of the write loop. Every worker encodes its share of the sink's updates as COPY BINARY rows, tagged with the Materialize timestamp and a diff of 1 or -1. The write operator opens one SERIALIZABLE transaction per timestamp window, checks that the progress row still carries its epoch and the frontier it expects, and streams the window's rows into a session temporary table that ON COMMIT DELETE ROWS empties after every window. Applying a staged window to the target table is an unimplemented stub. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8a51055 to
22cc511
Compare
QA LLM Review1. MEDIUM -- Zero-column relations generate invalid COPY statements
For a zero-column source, DetailsMaterialize accepts On PostgreSQL 17, the generated statement fails at the leading comma. Removing that comma accepts the same binary staging row and returns |
Implement the encode operator and the staging half of the write loop.
Every worker encodes its share of the sink's updates as COPY BINARY
rows, tagged with the Materialize timestamp and a diff of 1 or -1. The
write operator opens one SERIALIZABLE transaction per timestamp window,
checks that the progress row still carries its epoch and the frontier it
expects, and streams the window's rows into a session temporary table
that ON COMMIT DELETE ROWS empties after every window.
Applying a staged window to the target table is an unimplemented stub.
Tests: covered by the unit tests that #39707 adds and by
test/pg-sinkat the top of this stack.🤖 Generated with Claude Code