Skip to content

fix: crash when creating BM25 index on temp table#248

Merged
tjgreen42 merged 1 commit intomainfrom
fix/temp-table-crash
Mar 3, 2026
Merged

fix: crash when creating BM25 index on temp table#248
tjgreen42 merged 1 commit intomainfrom
fix/temp-table-crash

Conversation

@tjgreen42
Copy link
Copy Markdown
Collaborator

@tjgreen42 tjgreen42 commented Mar 3, 2026

Fixes #247.

Summary

  • FlushOneBuffer() asserts !BufferIsLocal(buffer), which fails for temporary tables whose buffers are backend-local
  • Guard every FlushOneBuffer call with !BufferIsLocal() to skip the flush for temp relations
  • This is safe because temp data is not WAL-logged and doesn't need crash-recovery durability

The fix covers 7 call sites across src/am/build.c (3) and src/state/metapage.c (4). FlushRelationBuffers() calls in the segment code already handle local buffers correctly.

Testing

FlushOneBuffer() asserts !BufferIsLocal(buffer), which fails for
temporary tables whose buffers are backend-local.  Guard every
FlushOneBuffer call with !BufferIsLocal() to skip the flush for
temp relations.  This is safe because temp data is not WAL-logged
and doesn't need crash-recovery durability.

Adds temp_table regression test covering the savepoint-rollback
and full-rollback crash scenarios from the bug report.
@tjgreen42 tjgreen42 force-pushed the fix/temp-table-crash branch from 6e8ec09 to ae1c221 Compare March 3, 2026 17:25
@tjgreen42 tjgreen42 marked this pull request as ready for review March 3, 2026 18:34
@tjgreen42 tjgreen42 merged commit ad4f832 into main Mar 3, 2026
15 checks passed
@tjgreen42 tjgreen42 deleted the fix/temp-table-crash branch March 3, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BM25 index scan inside a transaction that is rolled back crashes the PostgreSQL server

1 participant