fix(state): guard gateway FTS rebuild + comment early flag-set
Add the foreign-holder guard to gateway/session.py::_rebuild_fts_once(), the third FTS rebuild path that was not covered by the original fix. Also add a comment explaining why _fts_runtime_rebuild_attempted is set before the foreign-holder check: the fail-open path that follows persists FTS_STALE_KEY so the next startup retries via _recover_stale_fts.
This commit is contained in:
@@ -3875,6 +3875,19 @@ class SessionStore:
|
||||
db = self._db
|
||||
if db is None or not hasattr(db, "rebuild_fts"):
|
||||
return False
|
||||
# Guard against the same WAL split-brain risk as the automatic
|
||||
# rebuild paths: skip when a foreign process holds state.db or
|
||||
# its WAL sidecars open.
|
||||
if hasattr(db, "_foreign_state_db_holders"):
|
||||
foreign_holders = db._foreign_state_db_holders()
|
||||
if foreign_holders:
|
||||
logger.warning(
|
||||
"Skipping Session DB FTS rebuild while foreign processes "
|
||||
"hold the database or WAL sidecars (%s); canonical "
|
||||
"transcript writes remain available.",
|
||||
foreign_holders,
|
||||
)
|
||||
return False
|
||||
try:
|
||||
rebuilt = db.rebuild_fts()
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user