diff --git a/test/database/postgres-vector.int.spec.ts b/test/database/postgres-vector.int.spec.ts index 96621d95613..594e541b1fd 100644 --- a/test/database/postgres-vector.int.spec.ts +++ b/test/database/postgres-vector.int.spec.ts @@ -12,6 +12,13 @@ import { test } from '../__helpers/int/vitest.js' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) +// Read through the primary. `payload.db.drizzle` is the withReplicas() handle whose reads +// default to a replica, which races replication lag right after a write. +const primaryDb = (payload: BasePayload): PostgresDB => { + const adapter = payload.db as PostgresAdapter + return adapter.primaryDrizzle ?? adapter.drizzle +} + test.suite({ db: (adapter) => adapter.startsWith('postgres') })( 'postgres vector custom column', () => { @@ -112,7 +119,7 @@ test.suite({ db: (adapter) => adapter.startsWith('postgres') })( const similarity = sql`1 - (${cosineDistance(payload.db.tables.posts.embedding, catEmbedding)})` - const db = payload.db.drizzle as PostgresDB + const db = primaryDb(payload) const res = await db .select() @@ -234,7 +241,7 @@ test.suite({ db: (adapter) => adapter.startsWith('postgres') })( const distance = sql`(${l2Distance(payload.db.tables.posts.embedding, catEmbedding)})` - const db = payload.db.drizzle as PostgresDB + const db = primaryDb(payload) const res = await db .select() @@ -346,7 +353,7 @@ test.suite({ db: (adapter) => adapter.startsWith('postgres') })( const similarity = sql`1 - (${jaccardDistance(payload.db.tables.posts.embedding, catEmbedding)})` - const db = payload.db.drizzle as PostgresDB + const db = primaryDb(payload) const res = await db .select() diff --git a/test/queues/int.spec.ts b/test/queues/int.spec.ts index e60fde15471..5f5748abcc5 100644 --- a/test/queues/int.spec.ts +++ b/test/queues/int.spec.ts @@ -1464,8 +1464,8 @@ test.suite({ config: './config.ts' })('Queues - Payload', () => { expect(payload.config.jobs.processingLease.duration).toBe(20 * 60 * 1000) expect(payload.config.jobs.processingLease.safetyBuffer).toBe(30_000) payload.config.jobs.deleteJobOnComplete = false - payload.config.jobs.processingLease.duration = 600 - payload.config.jobs.processingLease.safetyBuffer = 50 + payload.config.jobs.processingLease.duration = 5000 + payload.config.jobs.processingLease.safetyBuffer = 300 const postTitle = 'created by the healthy worker' const job = await payload.jobs.queue({ @@ -1486,7 +1486,7 @@ test.suite({ config: './config.ts' })('Queues - Payload', () => { ) .toBeTruthy() // Wait longer than the original lease. Heartbeats must keep the first worker active. - await wait(900) + await wait(6000) const secondWorkerResult = await payload.jobs.run({ silent: true }) const firstWorkerResult = await firstWorker