Skip to content

Commit 70412cc

Browse files
authored
fix(db): pin the primary-key plan in the search retirement read-bound test (#8556)
The test disabled only sequential scans, so the planner could still answer a page with a bitmap scan that reads every remaining row. Which plan it chose depended on whether autovacuum had analyzed the fresh fixture rows, making the read-count assertion flaky in CI. Analyze the table and disable bitmap scans too, matching production's primary-key walk.
1 parent 2cef19f commit 70412cc

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/db/script-migrations/0027_retire_search_embeddings.integration.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,14 @@ describe('retiring dormant Search embeddings', () => {
415415
await sql`CREATE TRIGGER bound_document_update AFTER UPDATE ON document
416416
REFERENCING NEW TABLE AS changed_rows FOR EACH STATEMENT EXECUTE FUNCTION bound_document_update()`
417417
/**
418-
* On a table this small the planner may answer any page with a sequential scan, which reads
419-
* every row whatever the window; production pages use the primary key, so the test does too.
418+
* On a table this small the planner may answer any page with a sequential or bitmap scan, which
419+
* reads every remaining row whatever the window, and which one it picks depends on whether
420+
* autovacuum has analyzed the fresh rows. Production pages walk the primary key, so the test
421+
* analyzes the table and pins that plan.
420422
*/
423+
await sql`ANALYZE document`
421424
await sql`SET enable_seqscan = off`
425+
await sql`SET enable_bitmapscan = off`
422426
/** Document rows read by any scan, counted across committed and rolled-back pages alike. */
423427
async function documentReads() {
424428
await sql`SELECT pg_stat_force_next_flush()`
@@ -446,6 +450,7 @@ describe('retiring dormant Search embeddings', () => {
446450
).toBe(0)
447451
} finally {
448452
await sql`RESET enable_seqscan`
453+
await sql`RESET enable_bitmapscan`
449454
await sql`DROP TRIGGER IF EXISTS bound_document_update ON document`
450455
await sql`DROP FUNCTION bound_document_update()`
451456
}

0 commit comments

Comments
 (0)