Zero 1.9
Query Correctness and Reliability
Installation
npm install @rocicorp/zero@1.9Overview
Zero 1.9 improves query/mutation correctness and reliability.
Features
- Litestream v5 restores: The official image now uses Litestream 0.5.15 for restores by default, which can handle legacy formats. The backup writes to S3 still use the legacy format. Also, legacy snapshots now retain the previous generation for six additional hours, preventing cleanup during an active restore. (#6260, #6267)
- End-to-end serving lag:
e2e_serving_lagmeasures completed replicated work from the upstream transaction commit throughzero-cachesync output. Upstream clock-skew estimate identifies measurements biased by clock differences. (#6312)
Performance
First Mutation Latency
On the first mutation, Zero Server fetches and caches PostgreSQL schema metadata. In benchmarks, that full request is 2.7x faster (done in #6292, thanks @diegopereira99!). This is most noticeable with cold-starts in serverless environments like AWS Lambda.
Cold Mutation Latency
Measured on M5 Pro. Lower is better.
Fixes
- Ordered queries now paginate and maintain windows correctly when cursor fields contain
NULL, including compound tie-break fields and reverse walks. (thanks @YevheniiKotyrlo!) - Rebuilt queries now deliver changed rows instead of occasionally leaving clients with stale results.
- Queries no longer drop rows or emit invalid SQL when given an inapplicable scalar hint, and scalar
NOT EXISTSnow handles empty orNULLresults. - Schema construction, CRUD mutators, and materialized views now preserve a key named
__proto__as user data. (thanks @tjenkinson!) - SQLite statement caches now retain at most 1,000 idle entries each, terminated client groups release custom-query timers and caches, and large replica transactions can spill dirty pages to WAL instead of retaining the complete write set in native memory.
- Missing replication-lag reports are retried and
total_lagno longer grows when reports stop arriving, while serving-lag metrics exclude disconnected or not-yet-validated client groups. zero-cachenow recovers from half-open PostgreSQL sockets, including over TLS, and the official image applies the bundled postgres.js disconnect patch.- With PostgreSQL
wal_sender_timeout=0, replication no longer enters a continuous reconnect loop. See WAL Sender Timeout. - Client connection attempts now time out across setup and the server handshake, abandon late sockets, and retry normally. Reconnect confirmations no longer produce false slow-query warnings or inflated materialization metrics.
- Different integration versions in a pnpm workspace no longer create peer-qualified duplicate copies of
@rocicorp/zero, fixing cross-package type and module-augmentation failures. - Replicated PostgreSQL type and nullability changes now preserve compound-index column order in SQLite replicas. To repair an affected replica, resync it from Postgres or recreate the PostgreSQL index.
- Expected schema and replica resets now log warnings instead of errors, and
zero-cacheskips Litestream restore when backups are not configured. (thanks @asterikx!) - Server CRUD updates and upserts no longer assign primary-key columns, avoiding PostgreSQL locks that could block concurrent foreign-key inserts. (thanks @shayonj!)
- Mutation and query API calls now retry all
5xxresponses using the existing four-attempt limit and backoff;4xxresponses still fail without retry. (thanks @shayonj!) - SQLite corruption failures now log bounded replica and integrity diagnostics and flush logs before exit. Oversized replication updates now identify the transaction, affected column, and value type without logging the value.
Breaking Changes
Existing Primary-Key Inserts
insert now succeeds without changing the row when its Zero primary key already exists; before 1.9, the server returned an error. A successful insert does not necessarily prove that a row was created.