Skip to content

Add a mode to let toast stay in shadow pg - #163

Merged
serprex merged 13 commits into
mainfrom
harshil/toast-shadow
Sep 21, 2026
Merged

serprex merged 13 commits into
mainfrom
harshil/toast-shadow

Conversation

@harshil-goel

Copy link
Copy Markdown
Contributor

No description provided.

@harshil-goel
harshil-goel force-pushed the harshil/toast-shadow branch 3 times, most recently from 03e6d01 to 1b6b5e0 Compare September 17, 2026 14:44
Comment thread docs/configuration.md Resolved
@serprex
serprex force-pushed the harshil/toast-shadow branch from b0932a3 to b6df08f Compare September 17, 2026 16:35
Comment thread plans/shadow_toast.md Resolved
Comment thread docs/configuration.md Resolved
@serprex
serprex force-pushed the harshil/toast-shadow branch 2 times, most recently from fa5d98f to 54db6b9 Compare September 17, 2026 21:56
@serprex
serprex force-pushed the harshil/toast-shadow branch 2 times, most recently from 6c71638 to 67c2bc9 Compare September 17, 2026 23:39
Comment thread src/toast/shadow_store.rs Resolved
@serprex
serprex force-pushed the harshil/toast-shadow branch 5 times, most recently from e5451e1 to 72a3211 Compare September 20, 2026 16:50
harshil-goel and others added 11 commits September 21, 2026 14:14
Shadow keeps physical TOAST heaps and indexes as it replays source WAL, so
external values resolve through local index lookups instead of a ClickHouse
chunk mirror. Select with `[toast] mode = "shadow"`. Disabled mode leaves
external values unresolved, for destinations that do not want them

pgext gains a fetch op. Its snapshot is built by hand rather than through
get_toast_snapshot(): PG 18 exports SnapshotToastData, 16 and 17 have
neither. All three agree on what the read needs, snapshot_type selects
HeapTupleSatisfiesToast and a zeroed lsn/whenTaken disables the old-snapshot
check PG 16 still carries
Raise default value cap to 1 GiB, reserve 64 MiB per decoder

Size payload budget from cgroup or host memory

Serialize decode requests exceeding reserve

Fill oversized values with NULL or column defaults,
allow error policy as opt-in config
…gnores

Replay wait was short enough to trip on a busy shadow. TRUNCATE and rewrite
barriers now no-op when the store rejects writes, instead of erroring
Restart could resume past shadow's replay position, leaving shadow without
WAL it still needed, and the floor could release segments the same way

ShadowFloor folds both bounds into one place: it binds only when shadow holds
data, prefers the live replay position over the persisted seed, and aligns
down to a segment. A pinned start (`--start-lsn`, bootstrap end) stays
unbounded
…y through a record

A WAL record can span two files. If walshadow already rewrote that record,
restarting at file two could mix its rewritten beginning with its original ending

On startup, walshadow now:
- Looks for saved WAL in its output directory, then shadow PostgreSQL’s pg_wal directory
- Checks whether resume position contains an unfinished record’s continuation
- Loads that saved continuation, following it across pages and files if needed
- Replaces incoming bytes for that continuation with saved bytes

It also checks saved page addresses, continuation lengths, and incoming page headers,
so inconsistent continuation data causes an error
Add an option to preserve and reconnect to a compatible running shadow,
with systemd configuration for process-only restarts

Prefetch archived WAL into memory and replay through normal checkpoint,
pause and shutdown handling. Recovery reports through the shared metric
collectors, adding fetch, replay and queue wait

Honor configured object-store backfill concurrency
Limit memory held by ClickHouse insert batches

Count allocated buffer capacity and share memory limits across pending
batches and partial tables. Size batches by inserter count

Allow oversized rows to progress and expose OS thread count as a metric
Compare chunk xmin with sampled xid ceilings to detect replacements,
return fills for detected reuse and count them separately

Reject opt-in and configured tables whose TOAST heaps shadow cannot serve,
use configured TOAST store during backfill
@serprex
serprex merged commit be93401 into main Sep 21, 2026
21 checks passed
@serprex
serprex deleted the harshil/toast-shadow branch September 21, 2026 14:59
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.

3 participants