Chronos/DBWaitlist

Changelog / Chronos DB

Chronos DB 0.4.4

Attach to the Postgres you already run: tested on Postgres 12 to 18 and Supabase, and tables with row-level security, without a primary key, with generated columns or partitioned are attached. Main keeps up with Postgres as it changes (`serve --follow`), masked columns work on attached folders, and agents held to a tenant are held to it in child tables too

Beta12 changesDownloads

Shipped with Chronos Gateway 0.2.2, Chronos Gateway 0.2.1, Chronos Gateway 0.2.0.

Attach to the Postgres you already run: tested on Postgres 12 to 18 and Supabase, and tables with row-level security, without a primary key, with generated columns or partitioned are attached. Main keeps up with Postgres as it changes (serve --follow), masked columns work on attached folders, and agents held to a tenant are held to it in child tables too.

Changed from 0.4.3:

  • An agent held to a tenant can't write a table shared by every tenant. A table with neither the tenant column nor a foreign key to a table that has it (up to three hops) is still read whole, but writes to it are refused (42501), where they used to change it for every tenant. Give such a table the column or a key, or change it outside the agent.

The macOS builds need macOS 13 or later, as for 0.2.0.

  • Attach: tested on Postgres 12 to 18, and two fixes it found. A database whose encoding isn't UTF8 (LATIN1, WIN1252, ...) with any non-ASCII text couldn't be attached ("invalid byte sequence for encoding UTF8"): Chronos's connections now ask Postgres for UTF8, as libpq's clients do. A refresh now takes enum labels added in Postgres (ALTER TYPE ... ADD VALUE), in Postgres's order, before the rows that may hold them; until then no world could write a new label, even after a refresh (chronos refresh prints them, HTTP refresh lists them as labels). tests/attach_compat.rs runs about 80 cases (column types, key shapes, constraints, foreign keys, quoted names, a minimal role) under four database setups against whichever Postgres CHRONOS_TEST_PG names; tests/attach.rs runs on Postgres 12 too.
  • Attach: tables with row-level security. Attach refused every table with row-level security on, which on Supabase is every table its dashboard makes. Now it takes one the role reads past (a superuser, BYPASSRLS, the owner of a table that doesn't FORCE it, or a role a USING (true) WITH CHECK (true) policy for all commands shows every row, with no restrictive policy on it), since the copy then holds every row. It still refuses one whose policies hide rows from the role, now saying how to fix it, and a refresh still stops on such a table.
  • Attach: Postgres 11 or older is refused, saying so. It failed with Postgres's own "column attgenerated does not exist"; now attach says the version is too old and that it needs 12 or later, before it reads or makes anything there.
  • Attach: tables without a primary key. A table with none was refused. Now a unique index on NOT NULL columns stands for one (no WHERE, no expressions, not deferrable; a constraint's first, then the fewest columns): the write-back finds rows by it, main gets those columns as its primary key, and a refresh stops if the index goes or a column of it may be NULL. A table with neither is still refused, saying so.
  • Attach: tables with generated columns. A table with a GENERATED ALWAYS AS (...) STORED column was refused. Now it's attached: Postgres works the column out, and main too from the same expression; merges never send it, and it's never compared with Postgres's, so a value the two print differently isn't a conflict. A column that becomes generated, or stops being, stops the refresh.
  • Attach: partitioned tables. A partitioned table was refused. Now it's attached whole, as one plain table in main holding all its partitions' rows; a merge writes the partitioned table and Postgres puts each row in its partition (moving one whose partition key changed). Rows written by a trigger on a partition are found as on any table, and the table refreshed. A partition alone is refused, saying to attach its partitioned table.
  • Attach: refresh takes columns dropped, renamed or retyped in Postgres. A refresh took only added columns; any other change to a table's columns left it out until a new attach. Now a column dropped, renamed or retyped in Postgres is so in main too (altered in the refresh's report), and its rows then take Postgres's values. Attach keeps each column's attnum so a rename is told from a drop and an add (older folders fill it in at their next refresh). A world forked before such a change is refused at its merge, saying to fork again: its rows of that table were made in the old shape. A changed key, row-level security or generated column still needs a new attach.
  • Attach: masked columns. A folder attached to Postgres refused ALTER TABLE ... SET MASKED, so its columns couldn't be masked from agents. Now main takes SET MASKED and DROP MASKED (they change only what agents read, never Postgres); worlds forked after read the column masked, a refresh keeps the mask, and HTTP attached marks each masked column (mask) and gives each table's SQL name (sql). In a world it's refused, saying to mask on main.
  • Attach: serve --follow takes Postgres's changes as they happen. A refresh reads every row of every attached table, so keeping main fresh meant a refresh every few minutes, and rows no merge touched could be that old. Now chronos serve --follow reads a logical replication slot (test_decoding) every second and re-reads only the rows it names, by key, under the write-back lock; a merge's own writes coming back take nothing. A TRUNCATE, a delete under REPLICA IDENTITY NOTHING or a column change refreshes that table whole. It needs wal_level = logical and a role with REPLICATION; chronos refresh <folder> --unfollow drops the slot, which keeps Postgres's WAL until read.
  • Attach: a merge by columns settles Postgres's changes to other columns by itself. A row the world changed that someone changed in Postgres meanwhile was a conflict, even when the two changed different columns, and the merge had to be run again. Now a merge BY COLUMNS (the gateway's by_columns: true) that meets such rows runs once more by itself, after main took Postgres's rows: the world's columns and Postgres's combine, and only a column both changed is still a conflict.
  • Agents held to a tenant: child tables through foreign keys, and shared tables read-only. An agent made WITH (tenant = 'org_id = 42') was held to its tenant only in tables with the org_id column, and read and wrote every other table whole. Now a table without the column but with a foreign key to a table that has it, up to three hops away (order_items.order_id to orders.id, a note on an item through the item), shows it and lets it change only the rows whose key names a row of its tenant's, and a row it writes must name one (a null key names none). A table with neither is shared by every tenant: it still reads it whole, but an INSERT, UPDATE, DELETE, MERGE or COPY FROM of it is refused (42501), as are the row API's writes of it, since another tenant would see what it wrote. SHOW AGENT name PRIVILEGES says how each table is held to the tenant.
Chronos DB 0.4.4 · Chronos