diff --git a/packages/replicache/package.json b/packages/replicache/package.json index a9dd2bc849..07cb48c058 100644 --- a/packages/replicache/package.json +++ b/packages/replicache/package.json @@ -79,7 +79,7 @@ }, "devDependencies": { "@op-engineering/op-sqlite": "^18.2.5", - "@rocicorp/zero-sqlite3": "^1.1.7", + "@rocicorp/zero-sqlite3": "^1.2.0", "@types/command-line-args": "^5.2.3", "@types/command-line-usage": "^5.0.4", "command-line-args": "^6.0.2", @@ -100,7 +100,7 @@ }, "peerDependencies": { "@op-engineering/op-sqlite": "^18.2.5", - "@rocicorp/zero-sqlite3": "^1.1.7", + "@rocicorp/zero-sqlite3": "^1.2.0", "expo-sqlite": "^58.0.13" }, "peerDependenciesMeta": { diff --git a/packages/shared/src/objects.test.ts b/packages/shared/src/objects.test.ts index 2850485609..a9fa2173cd 100644 --- a/packages/shared/src/objects.test.ts +++ b/packages/shared/src/objects.test.ts @@ -1,6 +1,7 @@ import {expect, test} from 'vitest'; import { assignProperty, + getOwnProperty, mapAllEntries, mapEntries, mapValues, @@ -119,3 +120,20 @@ test('assignProperty safely assigns __proto__ as an own property', () => { expect(Object.hasOwn(target, '__proto__')).toBe(true); expect(target.__proto__).toBe('bar'); }); + +test('getOwnProperty reads own properties only', () => { + const object: Record = JSON.parse( + '{"a": 1, "__proto__": 2, "u": null}', + ); + expect(getOwnProperty(object, 'a')).toBe(1); + expect(getOwnProperty(object, '__proto__')).toBe(2); + expect(getOwnProperty(object, 'u')).toBe(null); + expect(getOwnProperty(object, 'missing')).toBe(undefined); + + const empty: Record = {}; + expect(getOwnProperty(empty, '__proto__')).toBe(undefined); + expect(getOwnProperty(empty, 'toString')).toBe(undefined); + expect(getOwnProperty(Object.create({inherited: 1}), 'inherited')).toBe( + undefined, + ); +}); diff --git a/packages/shared/src/objects.ts b/packages/shared/src/objects.ts index dec998346d..4bbc8fd82e 100644 --- a/packages/shared/src/objects.ts +++ b/packages/shared/src/objects.ts @@ -39,6 +39,19 @@ export function assignProperty( object[key] = value; } +/** + * Reads an own property of `object`, or `undefined` when `object` has no own + * property named `key`. A plain `object[key]` also finds inherited + * properties, so `object['__proto__']` is `Object.prototype` on an object + * with no such property of its own. + */ +export function getOwnProperty( + object: Readonly>, + key: string, +): T | undefined { + return Object.hasOwn(object, key) ? object[key] : undefined; +} + export function mapEntries( input: Record, mapper: (key: string, val: T) => [key: string, val: U], diff --git a/packages/shared/src/valita.ts b/packages/shared/src/valita.ts index 3606e708ec..b9e0008580 100644 --- a/packages/shared/src/valita.ts +++ b/packages/shared/src/valita.ts @@ -1,4 +1,5 @@ import * as v from '@badrap/valita'; +import {getOwnProperty} from './objects.ts'; export * from '@badrap/valita'; @@ -483,7 +484,7 @@ export function taggedObjectUnion( } const expectedTag = `Expected ${displayList('or', [...tagTypes])}`; const tagOf = (value: object): unknown => - Object.hasOwn(value, key) ? (value as Record)[key] : undefined; + getOwnProperty(value as Record, key); const type = v .unknown() .chain((value, options): v.ValitaResult> => { diff --git a/packages/z2s/src/compiler.ts b/packages/z2s/src/compiler.ts index 328754d449..aac751cf00 100644 --- a/packages/z2s/src/compiler.ts +++ b/packages/z2s/src/compiler.ts @@ -666,15 +666,23 @@ function where( switch (condition.type) { case 'and': - return sql`(${sql.join( - condition.conditions.map(c => where(spec, c, table)), - ' AND ', - )})`; + if (condition.conditions.length > 0) { + return sql`(${sql.join( + condition.conditions.map(c => where(spec, c, table)), + ' AND ', + )})`; + } else { + return sql`TRUE`; + } case 'or': - return sql`(${sql.join( - condition.conditions.map(c => where(spec, c, table)), - ' OR ', - )})`; + if (condition.conditions.length > 0) { + return sql`(${sql.join( + condition.conditions.map(c => where(spec, c, table)), + ' OR ', + )})`; + } else { + return sql`FALSE`; + } case 'correlatedSubquery': // `scalar` is deliberately ignored here. It is a planner hint for the // IVM engines, which have no cost-based planner and benefit from diff --git a/packages/zero-cache/package.json b/packages/zero-cache/package.json index b29d9e948c..8726a2d6e9 100644 --- a/packages/zero-cache/package.json +++ b/packages/zero-cache/package.json @@ -56,7 +56,7 @@ "@postgresql-typed/oids": "^0.2.0", "@rocicorp/lock": "^2.0.1", "@rocicorp/logger": "^6.1.0", - "@rocicorp/zero-sqlite3": "^1.1.7", + "@rocicorp/zero-sqlite3": "^1.2.0", "@types/basic-auth": "^1.1.8", "basic-auth": "^2.0.1", "cloudevents": "^10.0.0", diff --git a/packages/zero-cache/src/auth/write-authorizer.ts b/packages/zero-cache/src/auth/write-authorizer.ts index 1f257f1083..393a839947 100644 --- a/packages/zero-cache/src/auth/write-authorizer.ts +++ b/packages/zero-cache/src/auth/write-authorizer.ts @@ -5,6 +5,7 @@ import type {JWTPayload} from 'jose'; import {assert} from '../../../shared/src/asserts.ts'; import type {JSONValue, ReadonlyJSONValue} from '../../../shared/src/json.ts'; import {must} from '../../../shared/src/must.ts'; +import {assignProperty, getOwnProperty} from '../../../shared/src/objects.ts'; import * as v from '../../../shared/src/valita.ts'; import type {Condition} from '../../../zero-protocol/src/ast.ts'; import type { @@ -306,13 +307,15 @@ export class WriteAuthorizerImpl implements WriteAuthorizer { // Extract primary key values from operation value and validate they exist const values: Record = {}; for (const col of columns) { - const val = opValue[col]; + // Only own properties are values: every object inherits a `__proto__`. + const val = getOwnProperty(opValue, col); if (val === undefined) { throw new Error( `Primary key column '${col}' is missing from operation value for table ${tableName}`, ); } - values[col] = val; + // A plain assignment to `__proto__` would not add a property. + assignProperty(values, col, val); } return values; @@ -427,7 +430,10 @@ export class WriteAuthorizerImpl implements WriteAuthorizer { const applicableCellPolicies: Policy[] = []; if (cellPolicies) { for (const [column, policy] of Object.entries(cellPolicies)) { - if (action === 'update' && op.value[column] === undefined) { + if ( + action === 'update' && + getOwnProperty(op.value, column) === undefined + ) { // If the cell is not being updated, we do not need to check // the cell rules. continue; diff --git a/packages/zero-cache/src/config/zero-config.ts b/packages/zero-cache/src/config/zero-config.ts index 73493fbb0a..4feb164c5f 100644 --- a/packages/zero-cache/src/config/zero-config.ts +++ b/packages/zero-cache/src/config/zero-config.ts @@ -469,7 +469,7 @@ export const zeroOptions = { }, pgReplicationEpoch: { - type: v.number().optional(() => 0), + type: v.string().optional(() => '0'), desc: [ `Replication managers sharing the same epoch attempt to converge on a single`, `generation (i.e. the result of an initial-sync); if multiple tasks are started`, @@ -485,6 +485,7 @@ export const zeroOptions = { `new replication manager to wait for it. Incrementing the replication epoch is recommended`, `instead.`, ], + // TODO: Unhide when the db's epoch column is migrated to a text value in v1.14. hidden: true, }, diff --git a/packages/zero-cache/src/custom/fetch.ts b/packages/zero-cache/src/custom/fetch.ts index ce56c5ede2..1c8be44105 100644 --- a/packages/zero-cache/src/custom/fetch.ts +++ b/packages/zero-cache/src/custom/fetch.ts @@ -84,6 +84,15 @@ export const getBodyPreview = async ( const MAX_ATTEMPTS = 4; +/** + * A request to the API server (all attempts included) that takes at least + * this long is logged. A view-syncer waits for the response to a transform + * or validation request while it holds its client group's lock, so the + * client group is not sent changes in the meantime. Without the log, such a + * wait only shows up as a gap in the client group's log. + */ +export const SLOW_API_REQUEST_MS = 2000; + type ApiFailedReason = | typeof ErrorReason.HTTP | typeof ErrorReason.Parse @@ -367,8 +376,17 @@ export async function fetchFromAPIServer( result: attemptCount === 0 ? 'config_error' : 'fetch_error', attemptCount, }); + const durationMs = performance.now() - requestStart; apiRequests().add(1, attrs); - apiRequestDuration().recordMs(performance.now() - requestStart, attrs); + apiRequestDuration().recordMs(durationMs, attrs); + if (durationMs >= SLOW_API_REQUEST_MS) { + lc.warn?.('slow fetch from API server', { + operation: metricsOpts.operation, + result: attrs.result, + attemptCount, + durationMs, + }); + } apiInFlight().add(-1, metricAttrs); } } diff --git a/packages/zero-cache/src/server/runner/drain.test-worker.ts b/packages/zero-cache/src/server/runner/drain.test-worker.ts index eb0300961d..a29e37df0c 100644 --- a/packages/zero-cache/src/server/runner/drain.test-worker.ts +++ b/packages/zero-cache/src/server/runner/drain.test-worker.ts @@ -86,6 +86,7 @@ async function runSyncer() { createdAtMs: Date.now(), servedVersion: null, servingLagEligible: true, + awaitingAPIServer: false, pipelineHashes: () => [], clientSchemaKey: undefined, } as unknown as ViewSyncer & ActivityBasedService; diff --git a/packages/zero-cache/src/services/change-source/pg/change-source-init.ts b/packages/zero-cache/src/services/change-source/pg/change-source-init.ts index 7df8505336..fb4537210f 100644 --- a/packages/zero-cache/src/services/change-source/pg/change-source-init.ts +++ b/packages/zero-cache/src/services/change-source/pg/change-source-init.ts @@ -42,6 +42,7 @@ import {ensureShardSchema} from './schema/init.ts'; import * as ReplicaStage from './schema/replica-stage-enum.ts'; import {InitialSync, Replicate} from './schema/replica-stage-enum.ts'; import { + deleteUninitializedReplica, dropShard, getActiveReplicas, getReplicaAtVersion, @@ -88,7 +89,7 @@ export async function initializePostgresChangeSource( inactiveReplicaGracePeriodMs, pgChangeLog, }: InitializeOptions = { - epoch: 0, + epoch: '0', slotPerReplica: false, backupV5: true, inactiveReplicaGracePeriodMs: DEFAULT_INACTIVE_REPLICA_GRACE_PERIOD_MS, @@ -324,7 +325,7 @@ async function forkOrResumeReplica( lc: LogContext, sql: PostgresDB, shard: ShardID, - epoch: number, + epoch: string, slotFailover: boolean, replicaFile: string, {litestream, acquirePurgeLock, cleanup}: RestoreOptions, @@ -501,7 +502,7 @@ export async function getSourceAndDestinationReplicas( lc: LogContext, sql: PostgresDB, shard: ShardID, - epoch: number, + epoch: string, slotFailover: boolean, gracePeriodMs: number, /** @@ -536,6 +537,18 @@ export async function getSourceAndDestinationReplicas( let slotCreateMs: number | undefined; // The position that the source replica's slot must reach to be forked. let forkLSN: LSN | undefined; + // Releases the destination replica's slot and deletes its (uninitialized) + // row when the fork is abandoned. Otherwise, the row, which cannot be + // restored from, would remain until its slot is dropped by the + // replication-slot-cleanup-monitor. + const abandonDestination = async () => { + if (!destination) { + return; + } + const {initialSession, replica} = destination; + await endSession(initialSession); + await deleteUninitializedReplica(sql, shard, replica.id); + }; const lastLogged = new Map(); const shouldLog = (key: string, intervalMs: number) => { const now = Date.now(); @@ -558,7 +571,7 @@ export async function getSourceAndDestinationReplicas( } if (replicas.length === 0) { lc.info?.(`no suitable replicas to restore from`, {replicas}); - await endSession(destination?.initialSession); + await abandonDestination(); return undefined; } for (const replica of replicas) { @@ -722,7 +735,7 @@ export async function getSourceAndDestinationReplicas( lc.info?.(`resuming replica ${replica.id}@${replica.slot}`); // If a new replication slot was created in anticipation of forking, // cancel it - await endSession(destination?.initialSession); + await abandonDestination(); return { restoreFrom: replica, replicateTo: reserved.replica, @@ -737,7 +750,14 @@ export async function getSourceAndDestinationReplicas( } } } catch (e) { - await endSession(destination?.initialSession); + try { + await abandonDestination(); + } catch (cleanupErr) { + lc.warn?.( + `unable to abandon fork destination ${destination?.replica.id}`, + cleanupErr, + ); + } throw e; } } diff --git a/packages/zero-cache/src/services/change-source/pg/initial-sync.ts b/packages/zero-cache/src/services/change-source/pg/initial-sync.ts index b5e7e143ba..4aa55f2a3a 100644 --- a/packages/zero-cache/src/services/change-source/pg/initial-sync.ts +++ b/packages/zero-cache/src/services/change-source/pg/initial-sync.ts @@ -108,7 +108,7 @@ export type InitialSyncOptions = { }; export type ReplicaOptions = { - epoch: number; + epoch: string; backupV5: boolean; /** * Whether the replica's slot is acked only after transactions are stored in @@ -133,7 +133,7 @@ export async function initialSync( syncOptions: InitialSyncOptions, context: ServerContext, {epoch, backupV5, pgChangeLog}: ReplicaOptions = { - epoch: 0, + epoch: '0', backupV5: true, pgChangeLog: false, }, diff --git a/packages/zero-cache/src/services/change-source/pg/replication-slots.ts b/packages/zero-cache/src/services/change-source/pg/replication-slots.ts index ba8d8767ef..bd0ee31891 100644 --- a/packages/zero-cache/src/services/change-source/pg/replication-slots.ts +++ b/packages/zero-cache/src/services/change-source/pg/replication-slots.ts @@ -350,7 +350,7 @@ export async function createReplicaAndSlot( sql: PostgresDB, sessionName: string, shard: ShardID, - epoch: number, + epoch: string, replicaID: string, failover: boolean, backupOptions: BackupOptions, diff --git a/packages/zero-cache/src/services/change-source/pg/schema/init.ts b/packages/zero-cache/src/services/change-source/pg/schema/init.ts index 981d1878cd..218eed7f89 100644 --- a/packages/zero-cache/src/services/change-source/pg/schema/init.ts +++ b/packages/zero-cache/src/services/change-source/pg/schema/init.ts @@ -327,100 +327,28 @@ function getIncrementalMigrations( // v32: Upgrade the DDL event functions to include the shard's event // secret in every ddl event, and install the secret. - 32: { - migrateSchema: async (lc, sql) => { - const [{publications}] = await sql<{publications: string[]}[]>` - SELECT publications FROM ${sql(shardConfigTable)}`; - await setupTriggers( - lc, - sql, - {...shard, publications}, - installPartialIndexTriggers, - ); - lc.info?.(`Upgraded DDL event triggers`); - }, - }, + // Superseded by v40. // v34: Upgrade the DDL event functions to classify a column as an array // only if its type is the array type of its element, and to report // deferrable unique constraints as non-unique. - 34: { - migrateSchema: async (lc, sql) => { - const [{publications}] = await sql<{publications: string[]}[]>` - SELECT publications FROM ${sql(shardConfigTable)}`; - await setupTriggers( - lc, - sql, - {...shard, publications}, - installPartialIndexTriggers, - ); - lc.info?.(`Upgraded DDL event triggers`); - }, - }, + // Superseded by v40. // v36: Upgrade the DDL event triggers to fire for CREATE TABLE AS and // SELECT INTO. - 36: { - migrateSchema: async (lc, sql) => { - const [{publications}] = await sql<{publications: string[]}[]>` - SELECT publications FROM ${sql(shardConfigTable)}`; - await setupTriggers( - lc, - sql, - {...shard, publications}, - installPartialIndexTriggers, - ); - lc.info?.(`Upgraded DDL event triggers`); - }, - }, + // Superseded by v40. // v37: Upgrade the DDL event functions to report the partitions of a // partitioned table. - 37: { - migrateSchema: async (lc, sql) => { - const [{publications}] = await sql<{publications: string[]}[]>` - SELECT publications FROM ${sql(shardConfigTable)}`; - await setupTriggers( - lc, - sql, - {...shard, publications}, - installPartialIndexTriggers, - ); - lc.info?.(`Upgraded DDL event triggers`); - }, - }, + // Superseded by v40. // v38: Upgrade the DDL event triggers to fire for the commands that drop // the columns of a table with CASCADE, such as DROP TYPE. - 38: { - migrateSchema: async (lc, sql) => { - const [{publications}] = await sql<{publications: string[]}[]>` - SELECT publications FROM ${sql(shardConfigTable)}`; - await setupTriggers( - lc, - sql, - {...shard, publications}, - installPartialIndexTriggers, - ); - lc.info?.(`Upgraded DDL event triggers`); - }, - }, + // Superseded by v40. // v39: Upgrade the DDL event functions to report a unique index as not // unique when distinct values of its columns are the same on the replica. - 39: { - migrateSchema: async (lc, sql) => { - const [{publications}] = await sql<{publications: string[]}[]>` - SELECT publications FROM ${sql(shardConfigTable)}`; - await setupTriggers( - lc, - sql, - {...shard, publications}, - installPartialIndexTriggers, - ); - lc.info?.(`Upgraded DDL event triggers`); - }, - }, + // Superseded by v40. // v40: Upgrade the DDL event functions to report no primary key for one // with a column that is not published, and set the replica identity of diff --git a/packages/zero-cache/src/services/change-source/pg/schema/shard.ts b/packages/zero-cache/src/services/change-source/pg/schema/shard.ts index f1fb1336a0..89623ab11f 100644 --- a/packages/zero-cache/src/services/change-source/pg/schema/shard.ts +++ b/packages/zero-cache/src/services/change-source/pg/schema/shard.ts @@ -253,7 +253,9 @@ const replicaInfoSchema = v.object({ id: v.string(), rank: v.bigint(), slot: v.string(), - epoch: v.number(), + // The column is INT4 on shards created before epochs became TEXT (and is + // read as a number); accept both and normalize to a string. + epoch: v.union(v.number(), v.string()).map(String), generation: v.string(), stage: replicaStageSchema, backupPath: v.string().nullable(), @@ -323,7 +325,7 @@ export async function createReplica( shard: ShardID, id: string, slot: string, - epoch: number, + epoch: string, replicaVersion: string, {backupPath, backupV5, pgChangeLog}: BackupOptions, stage: ReplicaStage, @@ -381,6 +383,26 @@ export async function initRestoreReplica( return getReplicaState(sql, shard, destID); } +/** + * Deletes a replica created for a fork (i.e. in the `Restore` stage) that + * was abandoned before being initialized with {@link initRestoreReplica}. + * Its slot, once inactive and without a replica, is then dropped by + * `dropUnclaimedSlots()` or the replication-slot-cleanup-monitor. + * + * Only an uninitialized replica (i.e. with an empty `generation`) is deleted. + */ +export async function deleteUninitializedReplica( + sql: PostgresDB, + shard: ShardID, + id: string, +): Promise { + const schema = upstreamSchema(shard); + await sql` + DELETE FROM ${sql(schema)}.replicas + WHERE id = ${id} AND "generation" = ''; + `; +} + /** * Gets at the given version and optional ID. If no ID is specified, gets * the latest (i.e. highest rank) replica with that version. @@ -399,7 +421,7 @@ export async function getReplicaAtVersion( replicas."id", replicas."rank", replicas."slot", - replicas."epoch", + replicas."epoch"::text AS "epoch", replicas."generation", replicas."stage", replicas."backupPath", @@ -441,7 +463,7 @@ export async function getActiveReplicas( replicas."id", replicas."rank", replicas."slot", - replicas."epoch", + replicas."epoch"::text AS "epoch", replicas."generation", replicas."stage", replicas."backupPath", @@ -476,7 +498,7 @@ export async function getActiveReplicas( export async function getRestoreCandidates( sql: PostgresDB, shard: ShardID, - epoch: number, + epoch: string, ): Promise { const schema = sql(upstreamSchema(shard)); const results = await sql` @@ -484,7 +506,7 @@ export async function getRestoreCandidates( replicas."id", replicas."rank", replicas."slot", - replicas."epoch", + replicas."epoch"::text AS "epoch", replicas."generation", replicas."stage", replicas."backupPath", @@ -495,18 +517,31 @@ export async function getRestoreCandidates( FROM ${schema}.replicas JOIN pg_replication_slots slots ON slot = slot_name -- coalesce on the newest generation in the epoch + -- + -- "epoch" is compared as TEXT explicitly because the column is INT4 on + -- older shards: an uncast parameter would be prepared as INT4, and the + -- cached statement would then fail ("operator does not exist: text = + -- integer") once the column is altered to TEXT. WHERE generation = ( SELECT MAX(r.generation) FROM ${schema}.replicas r JOIN pg_replication_slots s ON r.slot = s.slot_name - WHERE r."epoch" = ${epoch} AND r."backupV5" + WHERE r."epoch"::text = ${epoch}::text AND r."backupV5" -- ignore orphaned InitialSyncs, which cannot be restored from AND (s."active" OR r."stage" != ${InitialSync}) AND s.restart_lsn IS NOT NULL AND s.wal_status IS DISTINCT FROM 'lost' + -- ignore fork destinations not yet initialized from a source + -- (see initRestoreReplica()), which cannot be restored from + AND r.generation != '' + -- ignore inactive replicas without a backup, e.g. a fork + -- destination whose task exited before taking over its slot + -- (which sets the backupPath), which cannot be restored from + AND (s."active" OR r."backupPath" IS NOT NULL) ) - AND "epoch" = ${epoch} AND "backupV5" + AND "epoch"::text = ${epoch}::text AND "backupV5" AND (slots.active OR "stage" != ${InitialSync}) + AND (slots.active OR "backupPath" IS NOT NULL) AND slots.restart_lsn IS NOT NULL AND slots.wal_status IS DISTINCT FROM 'lost' @@ -529,7 +564,7 @@ export async function getReplicaState( replicas."id", replicas."rank", replicas."slot", - replicas."epoch", + replicas."epoch"::text AS "epoch", replicas."generation", replicas."stage", replicas."backupPath", diff --git a/packages/zero-cache/src/services/change-source/protocol/backfill-progress.ts b/packages/zero-cache/src/services/change-source/protocol/backfill-progress.ts index 5338e09202..1fb042ec2e 100644 --- a/packages/zero-cache/src/services/change-source/protocol/backfill-progress.ts +++ b/packages/zero-cache/src/services/change-source/protocol/backfill-progress.ts @@ -1,5 +1,8 @@ import {deepEqual} from '../../../../../shared/src/json.ts'; -import {assignProperty} from '../../../../../shared/src/objects.ts'; +import { + assignProperty, + getOwnProperty, +} from '../../../../../shared/src/objects.ts'; import type { BackfillProgressMark, BackfillRequest, @@ -167,7 +170,7 @@ export function getTableSuperset( for (const [name, col] of Object.entries(req2.columns)) { // Not columns[name], which is Object.prototype for a column named // __proto__ that is missing from req1. - const exists = Object.hasOwn(columns, name) ? columns[name] : undefined; + const exists = getOwnProperty(columns, name); if (!exists) { assignProperty(columns, name, col); continue; diff --git a/packages/zero-cache/src/services/change-streamer/backfill-state.ts b/packages/zero-cache/src/services/change-streamer/backfill-state.ts index cdfe3427bf..2483bc33d2 100644 --- a/packages/zero-cache/src/services/change-streamer/backfill-state.ts +++ b/packages/zero-cache/src/services/change-streamer/backfill-state.ts @@ -1,7 +1,10 @@ import {unreachable} from '../../../../shared/src/asserts.ts'; import {BigIntJSON} from '../../../../shared/src/bigint-json.ts'; import {deepEqual} from '../../../../shared/src/json.ts'; -import {assignProperty} from '../../../../shared/src/objects.ts'; +import { + assignProperty, + getOwnProperty, +} from '../../../../shared/src/objects.ts'; import { acceptBackfill, covers, @@ -256,9 +259,7 @@ export class BackfillState { for (const name of [...relation.rowKey.columns, ...columns]) { // Not backfill.columns[name], which is Object.prototype for a column // named __proto__ that is not being backfilled. - const col = Object.hasOwn(backfill.columns, name) - ? backfill.columns[name] - : undefined; + const col = getOwnProperty(backfill.columns, name); if (!col) { continue; } diff --git a/packages/zero-cache/src/services/mutagen/mutagen.ts b/packages/zero-cache/src/services/mutagen/mutagen.ts index 313bab7267..b3da64bcb6 100644 --- a/packages/zero-cache/src/services/mutagen/mutagen.ts +++ b/packages/zero-cache/src/services/mutagen/mutagen.ts @@ -3,6 +3,10 @@ import type {LogContext} from '@rocicorp/logger'; import type {JWTPayload} from 'jose'; import postgres from 'postgres'; import {assert, unreachable} from '../../../../shared/src/asserts.ts'; +import { + assignProperty, + getOwnProperty, +} from '../../../../shared/src/objects.ts'; import {resolver} from '../../../../shared/src/resolver.ts'; import * as v from '../../../../shared/src/valita.ts'; import {ErrorKind} from '../../../../zero-protocol/src/error-kind.ts'; @@ -435,7 +439,13 @@ function getUpdateSQL( const {primaryKey, value} = update; const id: Record = {}; for (const key of primaryKey) { - id[key] = v.parse(value[key], primaryKeyValueSchema); + // A plain assignment to `__proto__` would not add a property, which + // would leave that column out of the WHERE clause. + assignProperty( + id, + key, + v.parse(getOwnProperty(value, key), primaryKeyValueSchema), + ); } return tx`UPDATE ${tx(table)} SET ${tx(value)} WHERE ${Object.entries( id, @@ -455,7 +465,8 @@ function getDeleteSQL( if (conditions.length > 0) { conditions.push(tx`AND`); } - conditions.push(tx`${tx(key)} = ${value[key]}`); + const keyValue = v.parse(getOwnProperty(value, key), primaryKeyValueSchema); + conditions.push(tx`${tx(key)} = ${keyValue}`); } return tx`DELETE FROM ${tx(tableName)} WHERE ${conditions}`; diff --git a/packages/zero-cache/src/services/replicator/change-processor.ts b/packages/zero-cache/src/services/replicator/change-processor.ts index 595d4545ae..8a13ae01fc 100644 --- a/packages/zero-cache/src/services/replicator/change-processor.ts +++ b/packages/zero-cache/src/services/replicator/change-processor.ts @@ -79,8 +79,6 @@ import {TableMetadataTracker} from './schema/table-metadata.ts'; export type ChangeProcessorMode = ReplicatorMode | 'initial-sync'; -const MAX_COMMIT_ATTEMPTS = 5; - const BIND_VALUE_TOO_BIG_ERROR = 'The bound string, buffer, or bigint is too big'; const MAX_SQLITE_BIND_BYTES = Math.min( @@ -1264,7 +1262,7 @@ class TransactionProcessor { } if (this.#mode !== 'initial-sync') { - this.#commit(); + this.#db.commit(); } const elapsedMs = Date.now() - this.#startMs; @@ -1279,41 +1277,6 @@ class TransactionProcessor { }; } - /** - * A wal2 `COMMIT` can fail with SQLITE_BUSY, without consulting the - * busy_timeout, if it switches wal files just as the `ServingCheckpointer` - * briefly locks the file it is switching to: the writer releases its locks - * on that file before taking the read lock that it needs on it. The - * transaction stays open and the switch has already happened, so the next - * attempt does not contend for that lock. - * - * No backoff is needed between attempts: the retry does not switch files - * again, so it never asks for the contended lock, whether or not the - * checkpointer still holds it. A second failure has some other cause. - * - * This is a workaround for a bug in SQLite's wal2 branch (in - * `walRestartLog()`), reported at - * https://sqlite.org/forum/forumpost/63ba0208a66aa7139119b56edb43a416b160ca1996a23de2b0da24ca48fb9b3a. - * The retry runs without the read lock the failed attempt meant to take. - * Remove it once zero-sqlite3 includes a fix. - */ - #commit() { - for (let attempt = 1; ; attempt++) { - try { - this.#db.commit(); - return; - } catch (e) { - if ( - attempt === MAX_COMMIT_ATTEMPTS || - !(e instanceof SqliteError && e.code === 'SQLITE_BUSY') - ) { - throw e; - } - this.#lc.warn?.(`SQLITE_BUSY on COMMIT (attempt ${attempt})`, e); - } - } - } - abort(lc: LogContext) { lc.info?.(`aborting transaction ${this.#version}`); this.#db.rollback(); diff --git a/packages/zero-cache/src/services/view-syncer/view-syncer.ts b/packages/zero-cache/src/services/view-syncer/view-syncer.ts index 7fcb53b9c5..18d50c488d 100644 --- a/packages/zero-cache/src/services/view-syncer/view-syncer.ts +++ b/packages/zero-cache/src/services/view-syncer/view-syncer.ts @@ -195,6 +195,11 @@ export interface ViewSyncer { readonly createdAtMs: number; readonly servedVersion: string | null; readonly servingLagEligible: boolean; + /** + * Whether the client group is waiting for the API server to respond to a + * transform or validation request, during which it is not sent changes. + */ + readonly awaitingAPIServer: boolean; // Shared-advance eligibility telemetry: which transformed queries this // client group runs, and the identity of its client schema. Pipelines with @@ -379,6 +384,9 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { */ #shuttingDown = false; readonly #initialized = resolver<'initialized'>(); + // Whether an initConnection has resolved #initialized, i.e. the CVR has + // been given its client schema. + #hasInitialized = false; #cvr: CVRSnapshot | undefined; /** @@ -773,6 +781,19 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { } try { + if ( + reloaded && + this.#hasInitialized && + this.#cvr.clientSchema === null + ) { + // The store no longer has the CVR this view-syncer initialized. + // No client of this instance can be reconciled with the reloaded + // one: stop so that all of them, not only the one whose operation + // reloaded the CVR, start over. + const e = clientSchemaMissingError(this.#cvr); + this.#stateChanges.fail(e); + throw e; + } if (reloaded && this.#cvr.pinnedUser !== null) { // Validation of every connection to this instance must agree with // the user the group was pinned to before it was (re)loaded. @@ -854,9 +875,7 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { // incompatible schema) after it has already destroyed the pipelines. this.#pipelinesHydrated = false; this.connContextManager.setSharedRetransformReady(false); - this.#pipelines.reset( - must(cvr.clientSchema, 'cvr.clientSchema missing after initialization'), - ); + this.#pipelines.reset(requireClientSchema(cvr)); return true; } @@ -917,10 +936,7 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { this.#batchTimeMs = undefined; await this.#runInLockWithCVR(async (lc, cvr) => { - const clientSchema = must( - cvr.clientSchema, - 'cvr.clientSchema missing after initialization', - ); + const clientSchema = requireClientSchema(cvr); if (!this.#pipelines.initialized()) { // On the first version-ready signal, connect to the replica. this.#pipelines.init(clientSchema); @@ -1083,9 +1099,7 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { `resetting pipelines: ${e.message}${e.breakdown ? ` (${e.breakdown})` : ''}`, ); this.#pipelineResets.add(1, {reason: e.reason}); - this.#pipelines.reset( - must(cvr.clientSchema, 'cvr.clientSchema missing after initialization'), - ); + this.#pipelines.reset(requireClientSchema(cvr)); version = this.#pipelines.currentVersion(); } const cvrVer = versionString(cvr.version); @@ -1237,6 +1251,25 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { ); } + #apiServerRequestsInFlight = 0; + + get awaitingAPIServer(): boolean { + return this.#apiServerRequestsInFlight > 0; + } + + /** + * Runs a request to the API server, during which {@link awaitingAPIServer} + * says that the client group is waiting for it. + */ + async #awaitAPIServer(request: () => Promise): Promise { + this.#apiServerRequestsInFlight++; + try { + return await request(); + } finally { + this.#apiServerRequestsInFlight--; + } + } + /** * Records that this client group is caught up through `stateVersion`, i.e. * everything the replica had at that version has been poked to clients. @@ -1562,6 +1595,7 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { ); // this.#authData and cvr (in particular cvr.clientSchema) have been // initialized, signal the run loop to run. + this.#hasInitialized = true; this.#initialized.resolve('initialized'); }, newClient, @@ -2197,7 +2231,9 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { lc, '#hydrateUnchangedQueries transforming custom queries', () => - customQueryTransformer.transform(connCtx, customQueries.values()), + this.#awaitAPIServer(() => + customQueryTransformer.transform(connCtx, customQueries.values()), + ), ), ); // Uncached results can also return the authoritative server userID @@ -2756,7 +2792,10 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { this.#runPriorityOp( lc, '#syncQueryPipelineSet transforming custom queries', - () => customQueryTransformer.transform(connCtx, queries), + () => + this.#awaitAPIServer(() => + customQueryTransformer.transform(connCtx, queries), + ), ), ); @@ -4376,7 +4415,10 @@ export class ViewSyncerService implements ViewSyncer, ActivityBasedService { try { let validation: ConnectionValidation | undefined = undefined; if (this.#customQueryTransformer) { - const response = await this.#customQueryTransformer.validate(connCtx); + const transformer = this.#customQueryTransformer; + const response = await this.#awaitAPIServer(() => + transformer.validate(connCtx), + ); if (response.kind === 'TransformFailed') { throw new ProtocolErrorWithLevel(response, 'warn'); } @@ -4581,6 +4623,33 @@ function checkClientAndCVRVersions( } } +/** + * Returns the client schema of a CVR that is used after the view-syncer has + * been initialized. + * + * `initConnection` only signals initialization once the schema is in the CVR, + * so a CVR without one was reloaded (after an error cleared the cached + * snapshot) from a store that no longer has what this view-syncer wrote, e.g. + * because the CVR's row was removed or the CVR db was restored to an earlier + * state. The clients' state cannot be reconciled with such a CVR, so they are + * told to start over, as they are when the CVR has been purged. + * + * `#runInLockWithCVR` rejects such a CVR when it reloads it, so this is not + * expected to throw. + */ +function requireClientSchema(cvr: CVRSnapshot): ClientSchema { + if (cvr.clientSchema === null) { + throw clientSchemaMissingError(cvr); + } + return cvr.clientSchema; +} + +function clientSchemaMissingError(cvr: CVRSnapshot): ClientNotFoundError { + return new ClientNotFoundError( + `CVR@${versionString(cvr.version)} has no client schema after initialization`, + ); +} + function isTransformFailedError(error: ProtocolError): boolean { return ( error.errorBody.kind === ErrorKind.TransformFailed && diff --git a/packages/zero-cache/src/workers/syncer.ts b/packages/zero-cache/src/workers/syncer.ts index 59a98d3c20..2c4cae49f1 100644 --- a/packages/zero-cache/src/workers/syncer.ts +++ b/packages/zero-cache/src/workers/syncer.ts @@ -56,7 +56,8 @@ export type ReplicaReadyState = { export type ServingLagViewSyncer = Pick< ViewSyncer, 'createdAtMs' | 'servedVersion' | 'servingLagEligible' ->; +> & + Partial>; export type ServingLagStats = { readonly activeClientGroups: number; @@ -68,10 +69,25 @@ export type ServingLagStats = { readonly maxMs: number; }; -type ServingLagDistribution = ServingLagStats & { - readonly lagsMs: readonly number[]; +/** + * The part of the serving lag that is not the API server's. A client group + * that is waiting for the API server to respond to a transform or validation + * request is not sent changes until it does, so it lags for as long as the + * API server takes. Because `maxMs` is the lag of the worst client group, a + * single such client group makes the whole worker look like it is behind. + */ +export type ServingLagAPIWaitStats = { + /** The lagging client groups that are waiting for the API server. */ + readonly laggingClientGroupsAwaitingAPI: number; + /** `maxMs` of the client groups that are not waiting for the API server. */ + readonly maxExcludingAPIWaitMs: number; }; +type ServingLagDistribution = ServingLagStats & + ServingLagAPIWaitStats & { + readonly lagsMs: readonly number[]; + }; + export type PipelineDedupViewSyncer = Pick< ViewSyncer, 'pipelineHashes' | 'clientSchemaKey' @@ -250,6 +266,8 @@ function computeServingLagDistributionMs( ): ServingLagDistribution { const lags: number[] = []; let laggingClientGroups = 0; + let laggingClientGroupsAwaitingAPI = 0; + let maxExcludingAPIWaitMs = 0; let firstNeededIndex = replicaReadyStates.length; for (const viewSyncer of viewSyncers) { @@ -274,6 +292,12 @@ function computeServingLagDistributionMs( lags.push(lagMs); if (lagMs > 0) { laggingClientGroups++; + if (viewSyncer.awaitingAPIServer) { + laggingClientGroupsAwaitingAPI++; + } + } + if (!viewSyncer.awaitingAPIServer) { + maxExcludingAPIWaitMs = Math.max(maxExcludingAPIWaitMs, lagMs); } } @@ -291,10 +315,22 @@ function computeServingLagDistributionMs( p75Ms: percentileNearestRank(lags, 75), p99Ms: percentileNearestRank(lags, 99), maxMs: lags.at(-1) ?? 0, + laggingClientGroupsAwaitingAPI, + maxExcludingAPIWaitMs, lagsMs: lags, }; } +export function computeServingLagAPIWaitStatsMs( + now: number, + replicaReadyStates: ReplicaReadyState[], + viewSyncers: Iterable, +): ServingLagAPIWaitStats { + const {laggingClientGroupsAwaitingAPI, maxExcludingAPIWaitMs} = + computeServingLagDistributionMs(now, replicaReadyStates, viewSyncers); + return {laggingClientGroupsAwaitingAPI, maxExcludingAPIWaitMs}; +} + export function computeServingLagStatsMs( now: number, replicaReadyStates: ReplicaReadyState[], @@ -592,6 +628,32 @@ export class Syncer implements SingletonService { result.observe(this.#computeServingLagDistribution().laggingClientGroups); }); + getOrCreateGauge('sync', 'serving_lag_excluding_api_wait', { + description: + 'sync.serving_lag of the client groups that are not waiting for the ' + + 'API server to respond to a transform or validation request. A ' + + 'client group is not sent changes while it waits, so when ' + + 'sync.serving_lag is high and this is not, the lag is the API ' + + "server's response time, not the view-syncer's.", + unit: 'millisecond', + }).addCallback(result => { + result.observe( + this.#computeServingLagDistribution().maxExcludingAPIWaitMs, + ); + }); + + getOrCreateGauge( + 'sync', + 'serving_lagging_client_groups_awaiting_api', + 'Number of active client groups with unserved replica changes that ' + + 'are waiting for the API server to respond to a transform or ' + + 'validation request', + ).addCallback(result => { + result.observe( + this.#computeServingLagDistribution().laggingClientGroupsAwaitingAPI, + ); + }); + getOrCreateGauge( 'sync', 'pipelines_total', diff --git a/packages/zero/package.json b/packages/zero/package.json index 266e40587b..1ae3a44a73 100644 --- a/packages/zero/package.json +++ b/packages/zero/package.json @@ -139,7 +139,7 @@ "@postgresql-typed/oids": "^0.2.0", "@rocicorp/lock": "^2.0.1", "@rocicorp/logger": "^6.1.0", - "@rocicorp/zero-sqlite3": "^1.1.7", + "@rocicorp/zero-sqlite3": "^1.2.0", "@standard-schema/spec": "^1.1.0", "@types/basic-auth": "^1.1.8", "@types/ws": "^8.18.1", diff --git a/packages/zql-integration-tests/package.json b/packages/zql-integration-tests/package.json index 737c098edc..d667e2ca62 100644 --- a/packages/zql-integration-tests/package.json +++ b/packages/zql-integration-tests/package.json @@ -24,7 +24,7 @@ "@faker-js/faker": "^10.6.0", "@rocicorp/logger": "^6.1.0", "@rocicorp/zero-previous": "npm:@rocicorp/zero@1.12.0", - "@rocicorp/zero-sqlite3": "^1.1.7", + "@rocicorp/zero-sqlite3": "^1.2.0", "@types/pg": "^8.20.0", "@types/tmp": "^0.2.6", "ast-to-zql": "workspace:*", diff --git a/packages/zqlite/package.json b/packages/zqlite/package.json index 4acd99b69d..8fbfa6916f 100644 --- a/packages/zqlite/package.json +++ b/packages/zqlite/package.json @@ -24,7 +24,7 @@ "@databases/sql": "^3.3.0", "@opentelemetry/api": "1.9.1", "@rocicorp/logger": "^6.1.0", - "@rocicorp/zero-sqlite3": "^1.1.7", + "@rocicorp/zero-sqlite3": "^1.2.0", "zql": "workspace:*" }, "devDependencies": { diff --git a/packages/zqlite/src/table-source.ts b/packages/zqlite/src/table-source.ts index 85afac2689..7f56dd8363 100644 --- a/packages/zqlite/src/table-source.ts +++ b/packages/zqlite/src/table-source.ts @@ -4,7 +4,7 @@ import type {LogConfig} from '../../otel/src/log-options.ts'; import {assert, unreachable} from '../../shared/src/asserts.ts'; import {getOrInsertComputed} from '../../shared/src/map.ts'; import {must} from '../../shared/src/must.ts'; -import {assignProperty} from '../../shared/src/objects.ts'; +import {assignProperty, getOwnProperty} from '../../shared/src/objects.ts'; import type {Writable} from '../../shared/src/writable.ts'; import type {Condition, Ordering} from '../../zero-protocol/src/ast.ts'; import type {Row, Value} from '../../zero-protocol/src/data.ts'; @@ -1169,9 +1169,7 @@ export function rawColumn( tableName: string, ): RawColumn { // Not a column that `valueTypes` merely inherits, e.g. `toString`. - const valueType = Object.hasOwn(valueTypes, name) - ? valueTypes[name] - : undefined; + const valueType = getOwnProperty(valueTypes, name); if (valueType === undefined) { throw invalidColumnError(valueTypes, name, tableName); } @@ -1213,6 +1211,8 @@ export function fromSQLiteRawRow( return newRow; } +const INT64_MIN = -(2n ** 63n); + function fromSQLiteType( valueType: ValueType, v: SQLiteValue, @@ -1229,6 +1229,16 @@ function fromSQLiteType( case 'string': case 'null': if (typeof v === 'bigint') { + if (v === INT64_MIN) { + // Since SQLite check-in 03f699544e (2026-10-21, in zero-sqlite3 + // 1.2.0), a REAL of exactly -2^63 bound to a column with INTEGER or + // NUMERIC affinity is stored as the integer -9223372036854775808, + // which safeIntegers(true) reads as a bigint. It used to stay a + // REAL, and a double reads back fine. -2^63 is exactly + // representable as a double, so converting it loses nothing. + // https://sqlite.org/src/info/03f699544e + return -(2 ** 63); + } if (v > Number.MAX_SAFE_INTEGER || v < Number.MIN_SAFE_INTEGER) { throw new UnsupportedValueError( `value ${v} (in ${tableName}.${column}) is outside of supported bounds`, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 29af088055..8cd2909e97 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,6 +18,7 @@ overrides: browserslist@<4.28.7: ^4.28.7 compression@<1.8.2: ^1.8.2 deepmerge-ts@<8.0.0: ^8.0.0 + effect@<3.22.1: ^3.22.1 esbuild: 0.28.2 fast-uri@>=3.0.0 <3.1.9: ^3.1.9 fast-uri@>=4.0.0 <4.2.3: ^4.2.3 @@ -574,8 +575,8 @@ importers: specifier: ^18.2.5 version: 18.2.5(react-native@0.88.0(@babel/core@7.29.7)(@types/react@19.3.0)(react@19.3.1))(react@19.3.1) '@rocicorp/zero-sqlite3': - specifier: ^1.1.7 - version: 1.1.7 + specifier: ^1.2.0 + version: 1.2.0 '@types/command-line-args': specifier: ^5.2.3 version: 5.2.3 @@ -938,8 +939,8 @@ importers: specifier: ^6.1.0 version: 6.1.0 '@rocicorp/zero-sqlite3': - specifier: ^1.1.7 - version: 1.1.7 + specifier: ^1.2.0 + version: 1.2.0 '@standard-schema/spec': specifier: ^1.1.0 version: 1.1.0 @@ -1143,8 +1144,8 @@ importers: specifier: ^6.1.0 version: 6.1.0 '@rocicorp/zero-sqlite3': - specifier: ^1.1.7 - version: 1.1.7 + specifier: ^1.2.0 + version: 1.2.0 '@types/basic-auth': specifier: ^1.1.8 version: 1.1.8 @@ -1820,8 +1821,8 @@ importers: specifier: npm:@rocicorp/zero@1.12.0 version: '@rocicorp/zero@1.12.0(@opentelemetry/core@2.12.0(@opentelemetry/api@1.9.1))' '@rocicorp/zero-sqlite3': - specifier: ^1.1.7 - version: 1.1.7 + specifier: ^1.2.0 + version: 1.2.0 '@types/pg': specifier: ^8.20.0 version: 8.20.0 @@ -1889,8 +1890,8 @@ importers: specifier: ^6.1.0 version: 6.1.0 '@rocicorp/zero-sqlite3': - specifier: ^1.1.7 - version: 1.1.7 + specifier: ^1.2.0 + version: 1.2.0 zql: specifier: workspace:* version: link:../zql @@ -6032,9 +6033,9 @@ packages: '@rocicorp/logger@6.1.0': resolution: {integrity: sha512-4jOOwem9veRxl7uH15PsmT48PRd3OzM7n3umkO8WCMt8M929MJml4kfeqAcga8feZAfUb/+DRjsvl4ySgPWqYQ==} - '@rocicorp/zero-sqlite3@1.1.7': - resolution: {integrity: sha512-aLcgrhws7mlr7pbe7pD/QDie5u4dzOrrkzYZMLdd338nKrE6vqbvIY2hBPyOJ81BAY/aJzZXYpDMxNTMlPl86A==} - engines: {bun: '>=1.1.0', node: 22.x || 24.x} + '@rocicorp/zero-sqlite3@1.2.0': + resolution: {integrity: sha512-Drwcuc+hLJrKL7tBoAGTLsbB8cQ/oVs/JM3T4uhblFZPJQeV/nTl715AKzIMNfDMT8XzCldJb92+M9gitCww7g==} + engines: {node: 22.x || 24.x} hasBin: true '@rocicorp/zero-virtual@0.7.0': @@ -8457,8 +8458,8 @@ packages: ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} - effect@3.20.0: - resolution: {integrity: sha512-qMLfDJscrNG8p/aw+IkT9W7fgj50Z4wG5bLBy0Txsxz8iUHjDIkOgO3SV0WZfnQbNG2VJYb0b+rDLMrhM4+Krw==} + effect@3.22.4: + resolution: {integrity: sha512-RNshu7AXVxxDh6aS4lothhJ+QoZ4xSykbWNaaVdvDN72RMyVwhCGdALkyl1TbEydgAmRIdD1eTyJqBUGwSBGDA==} electron-to-chromium@1.5.459: resolution: {integrity: sha512-4SC9HHSFjO/liAhifpdOL5hG9b4BP7/5G3y3UPZVO8trlAXr1CaUEEJL0gWK3kOcYcZrOA5rkwG45Gra/lTIgg==} @@ -18415,7 +18416,7 @@ snapshots: dependencies: c12: 3.3.4(magicast@0.5.5) deepmerge-ts: 8.0.2 - effect: 3.20.0 + effect: 3.22.4 empathic: 2.0.0 transitivePeerDependencies: - magicast @@ -18690,7 +18691,7 @@ snapshots: '@rocicorp/logger@6.1.0': {} - '@rocicorp/zero-sqlite3@1.1.7': + '@rocicorp/zero-sqlite3@1.2.0': dependencies: node-gyp-build: 4.8.4 @@ -18723,7 +18724,7 @@ snapshots: '@postgresql-typed/oids': 0.2.0 '@rocicorp/lock': 2.0.1 '@rocicorp/logger': 6.1.0 - '@rocicorp/zero-sqlite3': 1.1.7 + '@rocicorp/zero-sqlite3': 1.2.0 '@standard-schema/spec': 1.1.0 '@types/basic-auth': 1.1.8 '@types/ws': 8.18.2 @@ -21355,7 +21356,7 @@ snapshots: ee-first@1.1.1: {} - effect@3.20.0: + effect@3.22.4: dependencies: '@standard-schema/spec': 1.1.0 fast-check: 3.23.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index b42f7b3074..d693d38943 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -37,12 +37,15 @@ auditConfig: # fixed in glob 14, a new major. The bypass only affects callers that rely # on an AbortSignal to bound a walk. - GHSA-3g3m-2fjr-6pw4 + # picomatch <=4.0.7 (2.x and 4.x via vite, tinyglobby, fdir, micromatch and + # other dev tooling). No 4.0.8 on npm yet. The ReDoS needs + # attacker-controlled glob patterns. + - GHSA-fc5q-39xc-vjpf minimumReleaseAgeExclude: - '@rocicorp/zero-virtual@0.7.0' - '@badrap/valita@0.5.5' - - '@rocicorp/zero-sqlite3@1.1.5' - - '@rocicorp/zero-sqlite3@1.1.7' + - '@rocicorp/zero-sqlite3@1.2.0' - '@rocicorp/zero@1.12.0' # docusaurus-plugin-typedoc and typedoc-docusaurus-theme both import typedoc @@ -74,6 +77,7 @@ overrides: browserslist@<4.28.7: ^4.28.7 compression@<1.8.2: ^1.8.2 deepmerge-ts@<8.0.0: ^8.0.0 + effect@<3.22.1: ^3.22.1 esbuild: '0.28.2' fast-uri@>=3.0.0 <3.1.9: ^3.1.9 fast-uri@>=4.0.0 <4.2.3: ^4.2.3