Chronos/DBWaitlist

Changelog / Chronos DB

Chronos DB 0.1.2

Move from Postgres in one command: `chronos import <folder> postgres://...`

24 changesDownloads

Move from Postgres in one command: chronos import <folder> postgres://...

  • Reads a live Postgres's catalog and brings over schemas, enum types, sequences (continued past the rows), tables with their columns, defaults, keys, UNIQUE and CHECK, every row (COPY, text format, a table at a time), then foreign keys, indexes, views and materialized views. Extensions, functions, triggers, row-level security, roles, and anything Chronos refuses are listed in a report instead of stopping the import. --dry-run tries every definition on an empty in-memory database and writes nothing.
  • A small Postgres client of its own (TLS as libpq's sslmode, SCRAM-SHA-256), so the binary gains no dependency.

Stale-read check: merges that relied on rows that changed since the fork

  • A world forked WITH (check_reads = true) keeps what it reads (keys, a scan's range, index lookups, and whole tables for searches, bounded per table), and its merge is refused (40001) when any of it changed in the world it merges into since the fork, though it never wrote it. For an agent under a merge policy it's a reason like any rule, and the world is queued in SHOW REVIEWS; a policy with check_reads = true turns it on for all its agents' worlds, and they can't turn it off. Reads in a transaction count for its world. After a restart earlier reads are unknown, so such a merge is held.

Merging by columns, per table

  • ALTER TABLE t SET (merge_by_columns = true) makes every merge into a world with the setting combine a row both sides changed when they changed different columns, as MERGE ... BY COLUMNS does; RESET (merge_by_columns) goes back to whole rows, still the default. The same column changed on both sides always conflicts. The setting is a change to the table: in DIFF (merge: by columns), in DIFF ... AS SQL, and a schema change under merge policies.
  • A conflict whose rows all had different columns changed says so, and names BY COLUMNS and the table setting.

Merge policies

  • ALTER MERGE POLICY and CREATE MERGE POLICY read, change and write in one step: two changes at once both land, a policy dropped meanwhile isn't written back, and two creates of one name can't both succeed.
  • DROP MERGE POLICY name CASCADE takes the policy from its agents and drops it in one step; MCP's drop_merge_policy with release_agents uses it, so agents are never released without the drop.
  • SHOW REVIEWS: after a partial merge (ONLY TABLES, ONLY KEYS) of a queued world, changed_since is true. The world's version doesn't move, so clients' merges at the version they had still work.

What a change affects: readers of every changed column

  • DIFF WORLD w [TO b] READERS lists what in the database reads each column the diff changes: views and materialized views (traced column by column through their queries, views on views included), merge checks, triggers (by event and UPDATE OF), functions (where their text names the table and column), primary keys, unique constraints, foreign keys (both directions), CHECK constraints and indexes (expressions and WHERE included). Rows added or deleted reach every reader of their table.
  • Clients seen reading: SQL over the Postgres protocol records which columns each client reads (by role, and application_name), and over HTTP by agent; a change's readers name them with when they last read. REGISTER READER name ON table (cols) names readers outside SQL (exports, sync tools), kept in the world; UNREGISTER READER, SHOW READERS.
  • Critical readers: MARK READER billing CRITICAL / UNMARK READER mark a reader of any kind, in the world (forks carry it, DIFF shows it, SHOW READERS keeps who and when). DIFF ... READERS lists critical readers first, then by blast radius, with a critical column; merge policies get a critical rule (default false) that holds an agent's merge changing a column a critical reader reads.
  • Every answer ends with what was covered: since when reads have been recorded and through which doors, and that EXECUTE strings aren't followed, so "no readers" is never read as "nothing reads this".
  • Over HTTP, diff with readers: true and every merge dry_run return readers and coverage; over MCP, diff takes readers and merge_preview appends them; the Studio's Changes view shows them.

Merge checks: rules every merge's result must keep

  • CREATE [OR REPLACE] MERGE CHECK name [ON TABLES (...)] [WITH (timeout = '2s')] AS SELECT ..., DROP MERGE CHECK, SHOW MERGE CHECKS. A check is a query that must find nothing in what a merge would make. Every merge runs the checks for the tables it changes, on the world it merges into as the merge would leave it (partial merges and INTO included), inside the merge and under its locks, so two changes that are each fine but break a rule together are caught. Rows found refuse the merge (23514, HTTP 409) with the rows as the reason; an agent keeping to a merge policy is queued in SHOW REVIEWS instead. No one merges past a check, people included; only admin creates or drops one.
  • A check is one SELECT that changes nothing, run read only within its timeout (default 1 second; a merge it doesn't finish in is refused), stopping at the 11th row. MERGE ... DRY RUN names the checks that would fail and their rows in blocked.
  • Over MCP: merge_checks, set_merge_check, drop_merge_check; in safe mode the last two answer with the SQL for a person to run. See docs/guides/merge-checks.md.

Column defaults

  • A default Postgres works out afresh for each row is refused (0A000) instead of being evaluated once. DEFAULT random(), DEFAULT (nextval('q') + 100) or DEFAULT now() + interval '7 days' gave every row the same value; now CREATE TABLE, ADD COLUMN and SET DEFAULT refuse them, naming the column and the expression. Sequences, serial and identity columns, gen_random_uuid(), now() (and CURRENT_TIMESTAMP, transaction_timestamp(), statement_timestamp(), clock_timestamp()) and current_date are worked out per row, as before, and constant expressions still work. A subquery in a default is 0A000, as in Postgres.
  • DEFAULT reads arithmetic and || (DEFAULT 60 * 60, DEFAULT 'a' || 'b'); DEFAULT nextval('s') + 1 was a syntax error.
  • nextval('s'::regclass) defaults use the sequence. pg_dump and Postgres's catalog write serial and identity columns that way, and it was taken as a constant, so every insert got the same id. ALTER TABLE ... SET DEFAULT nextval('s'[::regclass]) on an integer column numbers it from the sequence, as the CREATE TABLE form does.
  • chronos import postgres:// brings a column with a refused default over without the default, and reports it (Supabase's timezone('utc'::text, now()) is one), instead of skipping the table.

Speed on many cores (a 32-core server, c2d-standard-32; BENCHMARKS.md was rerun on it against 13 rivals)

  • Joins and grouping over the protocol: the 20,000-row join + GROUP BY went from 11.5 ms to 4.4 ms (Postgres 17: 6.9 ms). Linux builds use mimalloc on glibc too (11.5 to 8.1 ms: glibc gave each query's big batches back to the kernel, and the next query faulted them in again); helper threads wait between queries instead of starting afresh for each step (8.5 to 7.4 ms; in process, a 200k count(*) 5.0 to 2.8 ms); tables of 8,192 rows or more split into up to 16 parts, so a 20,000-row table uses more than 4 cores (7.2 to 4.4 ms).
  • Agents writing on disk: 1,000 agents, each forking main, writing 1,000 rows one by one and merging, on one thread each: 5.0 s to 1.76–1.80 s. A world other than main logs its writes in batches (one lock taken per batch, not per row), and a thread finds its world without the branch map's lock. Merges on disk at 1,000 threads are still slow: p50 714–718 ms against Postgres's 128 ms at 25 workers.
  • Vector search p99: a vector graph counts as built only once its self-test has run. Before, the first searches ran beside 128 exact probe scans on every core: p99 8.6 ms, now 2.1–2.7 ms.

Durability

  • main and merges are synced as before. New: a crash can lose an open world's writes even after a later main commit was synced (they're logged in batches). After a crash each open world comes back as some prefix of its own writes, and it's flagged. See versions and crashes and operations.
Chronos DB 0.1.2 · Chronos