Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aa76999
feat(TC-2917): stream cumulative WAL as immutable artifact parts
tinycloud-bot[bot] Nov 13, 2026
c251b72
feat(TC-2917): persist DuckDB files through artifact parts
tinycloud-bot[bot] Nov 13, 2026
92b37b3
fix(TC-2917): keep artifact reservations retryable during reclamation
tinycloud-bot[bot] Nov 13, 2026
670c5e9
fix(TC-2990): checkpoint DuckDB writes that change the main file
tinycloud-bot[bot] Nov 13, 2026
c441b37
fix(TC-2917): verify DuckDB checkpoint identity before owned WAL saves
tinycloud-bot[bot] Nov 13, 2026
7ef7cbd
fix(TC-2917): DuckDB cache cleanup without blocking other databases
tinycloud-bot[bot] Nov 13, 2026
327b09c
fix(TC-2917): carry DuckDB cleanup order in the types
tinycloud-bot[bot] Nov 13, 2026
69f69f6
feat(TC-2917): DuckDB disk headroom, spill limit and startup cache sweep
tinycloud-bot[bot] Nov 13, 2026
7e036fc
test(TC-2917): fallback holds no parts slot; bounded slot test; sinks…
tinycloud-bot[bot] Nov 13, 2026
56a0a69
fix(TC-2990): checkpoint DuckDB writes that change the main file
tinycloud-bot[bot] Nov 13, 2026
726ee4f
fix(TC-2990): bind the verified checkpoint without lineage; pin the W…
tinycloud-bot[bot] Nov 13, 2026
32cdd06
fix(TC-2917): DuckDB headroom refusals keep nothing; writes classifie…
tinycloud-bot[bot] Nov 14, 2026
a485ceb
fix(TC-2917): only plain queries skip the DuckDB disk floor; floor ch…
tinycloud-bot[bot] Nov 14, 2026
235dcd8
Merge #604 (fix/tc-2917-chunked-followups) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
e4579b2
Merge #589 (skgbafa/tc-2917-chunked-wal) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
ae1eda5
Merge #591 (skgbafa/tc-2917-chunked-duckdb) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
38206b7
Merge #597 (skgbafa/tc-2917-part-lifecycle) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
4ab632b
Merge #601 (skgbafa/tc-2917-duckdb-fs-cleanup) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
928f5e6
Merge #603 (skgbafa/tc-2917-duckdb-disk-gate) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
035e4e5
Merge #594 (skgbafa/tc-2990-duckdb-wal-base) into feat/tc-2917-train
tinycloud-bot[bot] Nov 19, 2026
b149543
fix(tc-2917): keep the legacy fallback for a row with no checkpoint part
tinycloud-bot[bot] Nov 19, 2026
a73125b
fix(tc-2917): DuckDB replacement-busy refusal is unavailable_retryable
tinycloud-bot[bot] Nov 19, 2026
6697e84
fix(tc-2917): keep the DuckDB busy tests at their module path
tinycloud-bot[bot] Nov 19, 2026
ddbea57
Merge remote-tracking branch 'origin/main' into HEAD
tinycloud-bot[bot] Nov 19, 2026
ae6e494
test(TC-2917): respect bounded artifact reclamation and contention
tinycloud-bot[bot] Nov 19, 2026
eb292a8
Merge remote-tracking branch 'origin/main' into aa33/tc2917-work
tinycloud-bot[bot] Nov 24, 2026
919cf7a
fix(tc-2917): publish/read WAL parts after the main merge; DuckDB hea…
tinycloud-bot[bot] Nov 24, 2026
9372f60
test(tc-2917): session_retire up/down/up rolls back around the forwar…
tinycloud-bot[bot] Nov 24, 2026
04f4fe7
style(tc-2917): rustfmt the new tests and snapshot_file call
tinycloud-bot[bot] Nov 24, 2026
830a035
fix(tc-2917): ship the DuckDB cache-cleanup failure at debug, not an …
tinycloud-bot[bot] Nov 24, 2026
a97b6ab
fix(tc-2917): re-runnable artifact migrations, DuckDB headroom error …
tinycloud-bot[bot] Nov 24, 2026
fcc5a1f
docs(tc-2917): CHANGELOG states only what the migration rollback test…
tinycloud-bot[bot] Nov 24, 2026
6d580eb
docs(tc-2917): chunked-artifacts ops doc states only what the rollbac…
tinycloud-bot[bot] Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
- Hooks honour renewal stamps. A hook ticket's `parent_exp` is now the cited delegations' current effective end, the one `/invoke` reads use: the latest admitted stamp of the node's current renewer epoch, capped by every ancestor, else the signed expiry. It is recomputed at every `/hooks/events` open and reopen, so a renewed grant (including an owner-lease-renewed one) keeps its subscription past its signed expiry, and a stream ends at the earliest of its ticket's `exp`, that current end and `hooks.max_ticket_ttl_seconds` (300 s by default) after it opened. Each open still checks the whole chain for revocation; a stream already open when a delegation in its chain is revoked, or when stamping stops, ends at that deadline and its reopen is refused. Unrenewed grants are unchanged. `/info` reports `hooks-effective-end-v1`. Details: TC-3174.
- Signed KV URLs honour renewal stamps. `POST /signed/kv` caps a URL at the cited delegations' current effective end, the one `/invoke` reads use (the latest admitted stamp of the node's current renewer epoch, capped by every ancestor, else the cited delegation's signed expiry), instead of the signed expiry, so a renewed grant can mint one past its signed expiry. Every `GET /signed/kv/<id>` recomputes that end and answers 401 `signed URL expired` once it has passed, even before the URL's stored `expiresAt`, for example when the grant's lease is revoked. Unrenewed grants are unchanged. Details: TC-3176.
- Signed KV URLs re-check revocation at every use. `GET /signed/kv/<id>` checks the whole delegation chain the URL was minted under (the cited delegations and every ancestor) and answers 401 `signed URL authority revoked` once any is revoked. Before, revocation was checked only at mint, so an already-minted URL kept serving content until its `expiresAt` (up to 300 s). Details: TC-3177.
- Artifact-part writers prioritize their own predecessor reclamation, keep replacement contention retryable, and distinguish capacity refusals from space-growth limits; existing database layouts can checkpoint before adopting WAL parts. Details: TC-2917.
- Chunked artifacts (flag on only): a write that races another checkpoint replacement of the same database now answers 503 `unavailable_retryable` with `Retry-After: 1` (SDK `NODE_BUSY`, retried automatically) instead of 402 storage-quota-exceeded, and does not arm the checkpoint back-off; a parts capacity refusal answers 507 `sql_database_size_limit` instead of 402. DuckDB answers the same: its replacement-busy 503 body now starts `unavailable_retryable: ` and so carries `Retry-After: 1` (before: `Database artifact replacement is temporarily unavailable`, no `Retry-After`, SDK `NETWORK_ERROR`). TC-2917.
- DuckDB cache cleanup no longer holds up lookups of other databases while files are deleted; a spill directory left by a stopped process no longer blocks hydration or discard, and a failed import leaves no staged or imported file behind. Details: TC-2917.
- DuckDB keeps disk headroom: a write or import that would leave less than `storage.duckdb.min_free_bytes` free, a write still running when free space drops below it, and a statement that spills past `storage.duckdb.max_temp_directory_size` answer `507 duckdb_disk_headroom`; each is counted as `tinycloud_disk_headroom_refusals_total{engine="duckdb"}`. A write refused this way keeps nothing: the database's local copy is dropped and reloaded from its last saved artifact, so neither a transaction that committed just before the refusal nor earlier statements of its batch are kept or saved later. Only plain queries and `EXPLAIN` without `ANALYZE` sent as `query` count as reads; anything else (including `PREPARE`/`EXECUTE`) counts as a write. Reservations share the node-wide disk budget with SQL. Both limits key on `storage.sql.chunked_artifacts`: unset, the floor is 2 GiB (provisional until production headroom is measured) and the spill limit 1 GiB per connection when it is on; otherwise both are off. With chunked artifacts on, the node refuses to start when the DuckDB floor is below `storage.sql.chunked_artifact_max_bytes`, so the floor cannot be 0. Details: TC-2917.
- At startup the node removes DuckDB spill directories and staging or renamed-aside cache files left by a stopped process, before it serves; the cache files themselves stay. Details: TC-2917.
- DuckDB headroom accounting: the bytes a write has already written leave its reservation (they are in the free-space reading), so two concurrent writes no longer stop each other inside the room the gate admitted them with. The snapshot copy a save takes is made beside the database's cache files, the filesystem the headroom measures, instead of in `$TMPDIR`; copies left by a stopped process are removed at startup. Details: TC-2917.
- DuckDB saves a complete checkpoint when a write changes its main file, and uses incremental WAL persistence only when that file still matches the stored checkpoint, so acknowledged writes remain recoverable after restart. Details: TC-2990.
- Opt-in SQL artifact parts also stream cumulative WAL updates, retaining the checkpoint until a full checkpoint is needed. Details: TC-2917.
- DuckDB can persist checkpoints, cumulative WAL and imports through the same opt-in bounded artifact parts. Details: TC-2917.
- Two PostgreSQL migrations ship with the artifact parts, `m20261113_020000_artifact_chunk_wal` and `m20261113_030000_artifact_part_lifecycle`, and they run at boot even with `chunked_artifacts` off. Their `down` refuses, so rolling back below this release is fix-forward only for them. Both `up` steps are re-runnable: running `up` again after deleting BOTH `seaql_migrations` rows (`m20261113_020000_artifact_chunk_wal` and `m20261113_030000_artifact_part_lifecycle`) is tested. Booting the previous image on the changed schema after such a row-only delete is proposed but untested. Details: TC-2917.
- Optional `spaces.registry_v2` enables independently verified owner-signed per-space hosting and read/write modes. Listed session grants activate replicas without an extra per-node hosting signature; mixed data/encryption grants retain their original proof and activate only locally served spaces. Unconfigured onboarding is unchanged. Details: TC-2481
- Registry hosting fixes: re-registering an unchanged valid grant activates newly listed spaces once, independently of CID registration. Registry unavailability keeps HTTP 503 through decrypt, hook, and invocation authorization. Share-holder named SQL reads are admitted by the registry like KV reads (defense in depth: no production route reaches them). Queued webhook deliveries follow the registry too: a space it no longer lists here stops sending them by the dispatcher's next pass, and an unreachable registry retries them. Details: TC-2481
- Optional `spaces.registry_cache_max_age_seconds` (default 0, off; at most 300; requires `registry_v2`) keeps reads and writes admitted from the last verified registry record while the registry is unreachable or answers 502/503/504, for at most that long after the last successful lookup; then 503 before any effect. Refusals discard the cached record, revocations still apply, the cache is memory-only, and activating a replica always needs the live registry. Registry lookups send `Cache-Control: no-cache`, so a cache in between can't confirm a withdrawn record. Details: TC-2481
Expand Down
126 changes: 115 additions & 11 deletions docs/operations/chunked-sql-artifacts.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Opt-in SQL checkpoint parts
# Opt-in database artifact parts

The first TC-2917 slice stores SQL checkpoints as immutable PostgreSQL parts.
Opt-in SQL and DuckDB persistence stores checkpoints and cumulative WAL as immutable PostgreSQL parts.
Each payload statement carries at most 1 MiB. A metadata-only compare-and-swap
publishes a sealed part; successful writes retain the existing durability and
lineage semantics. Hydration verifies the part CID before publishing its cache.

A database stored in parts is not held to the single-row read limit
(`storage.sql.max_artifact_read_bytes`, TC-2961): each statement reads at most
1 MiB, hydration stages the parts in files beside the cache, and the artifact
and account capacities bound its size. A read that keeps the whole database in
memory (a DuckDB export) still waits for one of the node's large-transfer slots
when it exceeds 8 MiB.
1 MiB, and hydration stages the parts in files beside the cache. Its size is
bounded by the artifact and account capacities when it is written; a read does
not re-check them, so a database written under a larger capacity still loads
whole after the capacity is lowered. A read into a sink that keeps the whole
artifact in memory waits for one of the node's large-transfer slots when it
exceeds 8 MiB. A SQL export of a database in parts is held to neither the read
limit nor a slot yet; that is required before the switch is enabled.

The switch is off by default. Set explicit capacities before enabling:

Expand All @@ -26,21 +29,31 @@ by this slice. The account capacity is charged to the space owner, across its
spaces, including legacy live artifacts, staged uploads and retained parts.
Reservations are atomic per owner. Quota refusal uses the SQL storage refusal.

This slice publishes a full checkpoint for each SQL mutation. WAL parts,
conversion of existing artifacts follow separately.
After a checkpoint, file-backed SQL mutations can publish an owned cumulative WAL
smaller than 8 MiB without rewriting the checkpoint. Larger WALs and writes
forbidden from growing use a fresh checkpoint. In-memory databases use
checkpoints. Both kinds of part use the same 1 MiB statement limit, and the
artifact ceiling covers checkpoint plus WAL together. Conversion of existing
artifacts follows separately. Enabling parts does not convert legacy rows or
bypass their single-row read limit: an existing legacy checkpoint or WAL over
64 MiB still answers `507 sql_database_size_limit` with the default limits.
The train includes no converter for those rows. Already-published parts load
without that single-row limit, including with the switch off.
Aborted and superseded parts enter a fenced deleting state; reclamation deletes
at most one payload chunk per statement and releases its charge only after all
bytes are gone. A periodic collector recovers uploads whose 120-second lease
expired. Lease expiry determines eligibility; part identity and state fence
uploads against concurrent reclamation. Active sealed uploads retain their lease
until publication. Deleted artifacts are reclaimed by the same mechanism.
It does not enable chunked DuckDB writes. Legacy data remains readable. Drain
DuckDB uses owned checkpoint and WAL files under the same capacities. Its
imports stream the already-buffered public request into bounded artifact
statements. Legacy data remains readable. Drain
older writers before enabling this format; turning the switch off does not
convert published parts back to legacy blobs. Current readers understand both
layouts; legacy persistence refuses a database already using parts.

Do not enable for prolonged operation until the approved ceiling load acceptance and
remaining migration/WAL slices are complete. On each test release, report
remaining conversion slice is complete. On each test release, report
reserved, staged and retained bytes from the following metadata-only inventory:

```sql
Expand Down Expand Up @@ -96,8 +109,99 @@ the same database's credit for a second simultaneous replacement.
Published parts have a distinct state and infinite lease, and are excluded from
both global and owner-local reclamation indexes. Inline cleanup is best effort,
scoped to the uploading owner, at most 16 steps and 100 ms per pass; its errors
do not fail the save. Background passes are limited to 128 steps and one second
do not fail the save. A writer first prioritizes its own database's eligible
predecessors for at most two seconds; active upload leases are never stolen.
Failed owners are excluded for the remainder of a collection pass so other
owners can continue. Owner-lock waits at reservation are bounded at 50 ms. Background passes are limited to 128 steps and one second
per 10-second tick. GC lock acquisition waits at most 50 ms per statement.
An owner already above its quota can replace a database with an equal or
smaller image; that exception admits no growth and does not free pending shrink
capacity for other databases.

A WAL publication checks the exact durable revision and checkpoint CID. It
replaces only the WAL pointer and logical CID, advancing the layout generation;
the checkpoint pointer and bytes remain unchanged. Readers verify each part CID
and the combined logical CID, then recheck both pointers and the generation
before publishing the cache. A full checkpoint retires both previous parts.
Each retired part releases its charge and associated overlap credit only after
its final chunk is removed, so a partially collected pair stays accounted.

Roll out WAL-capable readers to every instance before enabling the switch.
Checkpoint-only part readers fail closed on WAL layouts. Schema changes are
forward-only (the two PostgreSQL migrations' `down` refuses). Both `up` steps
are re-runnable: running `up` again after deleting BOTH `seaql_migrations` rows
(`m20261113_020000_artifact_chunk_wal` and
`m20261113_030000_artifact_part_lifecycle`) is tested. Booting the previous
image on the changed schema after such a row-only delete is proposed but
untested. Switching the feature off keeps existing layouts readable and
writable by the current binary, and does not downgrade their format.

New DuckDB databases with parts enabled start file-backed under the existing
node data directory, regardless of the in-memory threshold. Their actor fence
protects checkpoint/WAL copies. Closing or idle-evicting an actor removes its
cache files after the native connection is closed; the next access rehydrates
from durable parts. The files are renamed aside while the actor's registration
is held and deleted after it is released, so other databases' lookups do not
wait on the deletion; if the process stops in between, the next hydration of
that database removes them. A spill directory left by a stopped process does
not block hydration, and an import that fails leaves no staged or imported
file. Legacy actors retain their existing storage behavior.

For disk headroom, each successfully persisted open database retains at most
the configured artifact ceiling in checkpoint plus cumulative WAL. A full
checkpoint also needs an owned temporary copy while streaming, and old/new
versions overlap in PostgreSQL until their deletions commit. PostgreSQL can reuse deleted storage after vacuum; relation files need not
shrink. Size refusal occurs after native execution.

DuckDB keeps disk headroom on the filesystem behind its cache. Both limits key
on `storage.sql.chunked_artifacts`: with it on, `storage.duckdb.min_free_bytes`
defaults to 2 GiB and `storage.duckdb.max_temp_directory_size` to 1 GiB per
connection; with it off both stay off unless set. The 2 GiB floor is
provisional until the `storage_headroom` event shows real headroom on
production nodes; operators tune it by config. With chunked artifacts on, the
node refuses to start unless the floor is at least
`storage.sql.chunked_artifact_max_bytes`, so the floor cannot be turned off
(0) while they are on: a write's save copies the database once more, and the
write's claim is kept until that copy is on disk. Leave a margin above that.

- A write is any request that can change the database: executes, batches,
imports, and any query that is not purely plain `SELECT`-style queries and
`EXPLAIN` without `ANALYZE` (so an admin's `PREPARE … AS INSERT` and
`EXECUTE`, `CALL`, `CREATE SCHEMA` and the like count). SQL that fails to
parse or is refused also counts, so while free space is below the floor it
answers `507 duckdb_disk_headroom` rather than its 400 or 403.
- Before a write runs, it reserves its local database files' size (the bound
of the snapshot copy its save can take); an import reserves twice its size.
Reservations share the node-wide budget with SQL. A reservation that would
leave less than the floor is refused with `507 duckdb_disk_headroom` and
nothing runs.
- While a write runs, it is interrupted whenever free space is below what
other operations hold plus the floor. It answers `507 duckdb_disk_headroom`,
and the database's local copy is dropped and reloaded from its last saved
artifact on the next request. So nothing from the request is kept: not a
transaction that committed just before the interrupt was reported, and not
the earlier statements of a non-transactional batch.
- A statement that spills past the per-connection limit also answers
`507 duckdb_disk_headroom`. Read-only queries and exports reserve nothing and
are not interrupted for headroom; only the spill limit applies to them.
- Hydration is not gated: it writes at most the artifact ceiling and is freed
at eviction.
- At startup, before it serves, the node removes what a stopped process left in
the DuckDB cache: spill directories and staging or renamed-aside files. The
cache files themselves stay, because a legacy database reopens them.

Artifact, account and single-statement capacity refusals return 507. Existing
per-space growth refusals retain 402. A concurrent replacement or contended
reservation returns a retryable 503 without checkpoint back-off; staged
bookkeeping does not turn this positive pre-publication refusal into an
unknown write outcome. A genuinely lost publish reply retains its existing
unknown-outcome behavior. Expired uploads remain counted until collection.

An old-format checkpoint can be replaced by a full owned snapshot before WAL
parts attach. For DuckDB, both legacy and owned-WAL persistence first compare
the local main file's length and CID with the stored checkpoint under the
actor fence. A mismatch requires a complete checkpoint, including blocks
written directly to the main file by a large insert.

The feature remains off. Conversion and the ceiling-load benchmark still need
their separate acceptance before activation.
7 changes: 5 additions & 2 deletions docs/sql-block-store-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,11 @@ still refuses `enabled`).
checkpoint_content_hash, wal_end_bytes, wal_prefix_sha256)`, atomically with
the WAL it stores. A new checkpoint (`save`, or a chunked snapshot publish)
deletes every mark of the database atomically with the checkpoint, because
a checkpoint truncates the WAL; a space purge deletes them too. A rejected
save leaves no mark. "Atomically" is one transaction on SQLite and with a
a checkpoint truncates the WAL; a space purge deletes them too. A chunked
WAL part (`artifact_part` kind WAL) replaces the stored WAL the same way
but writes no mark, so a chunked database never gets `wal-delta-v1`: shadow
reads use the whole-WAL `wal-cum-v1` format (safe, but not incremental). A
rejected save leaves no mark. "Atomically" is one transaction on SQLite and with a
purge fence. On the PostgreSQL pool without a fence it is ONE autocommit
statement (a data-modifying CTE): the pool's statement timeout, its retry
classification and its did-the-write-apply tracking are defined over a
Expand Down
Loading
Loading