-
Notifications
You must be signed in to change notification settings - Fork 94
fix: register SubXactCallback for subtransaction abort cleanup #269
Description
Summary
We register a XactCallback (for top-level transaction abort) but have no SubXactCallback. This causes issues when a subtransaction that created a BM25 index is rolled back via ROLLBACK TO SAVEPOINT:
-
Registry/shared memory leak: The
OAT_DROPhook doesn't fire during subtransaction abort, so the registry entry and shared DSA memory for the index are never cleaned up. -
LWLock tracking desync: If an error occurs during a BM25 scan inside a savepoint (between
tp_acquire_index_lockandtp_release_index_lock),LWLockReleaseAllreleases the lock during abort but ourlock_heldflag remainstrue. Since theXactCallbackonly fires on top-level abort, the desync persists until the top-level transaction ends.
Fix
Register a SubXactCallback in _PG_init that:
- On
SUBXACT_EVENT_ABORT_SUB: clean up build mode state (liketp_cleanup_build_mode_on_abort), resetlock_heldtracking, and clean up registry entries for indexes created in the aborted subtransaction.
Found during investigation of #247.