Zero 1.9
Query Correctness and Reliability
Installation
npm install @rocicorp/zero@1.9Overview
Zero 1.9 improves query/mutation correctness and contains numerous reliability improvements.
Features
zero_sync_e2e_serving_lagmeasures completed replicated work from the upstream transaction commit through view-syncer poke.zero_replication_upstream_clock_skewtries to identify measurements biased by clock differences. (#6312)
Performance
Cold Mutation Latency
Before running mutations, Zero Server fetches and caches PostgreSQL schema metadata. This is now 2.7x faster in Zero 1.9 (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
- Restores now use Litestream 0.5.15 for legacy-format compatibility, retry transient failures, clean up temporary databases and staged WAL files after failed or interrupted attempts, and retain the previous snapshot generation during active restores.
insertnow succeeds without changing the row when its Zero primary key already exists; before 1.9, the server returned an error.- Ordered queries now return correct results when cursor fields contain
NULL. (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 now release custom-query timers and caches.
- 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 diagnostics, delete the corrupted replica before exit, and support extended corruption errors, with deeper checks available as an opt-in.
- Oversized replication updates now identify the transaction, affected column, and value type without logging the value.
- Fatal replica-writer failures now surface as replication errors and cause
zero-cacheto exit with a failure instead of silently stopping replication. - Replication now recovers from upstream disconnects or stalled PostgreSQL writes while flow control is blocked.
- Mutations from multiple tabs in the same client group are no longer skipped or sent out of order.