Log post-rebuild vacuum failures and clarify vacuum-await scope

This commit is contained in:
Yiorgis Gozadinos 2026-04-24 15:31:36 +03:00
parent 2ad51f5dca
commit 729899299b
No known key found for this signature in database

View file

@ -31,10 +31,13 @@ async def rebuild_database(
if mode is None: if mode is None:
mode = RebuildMode.FULL mode = RebuildMode.FULL
# Wait for any background vacuum before destructive table operations. # Wait for any already-scheduled background vacuum before the destructive
# Rebuild drops and recreates tables (+ creates indices); a concurrent # table operations at the top of RECHUNK / FULL. Rebuild drops and
# optimize on the same table fails with "CreateIndex transaction was # recreates tables (and creates indices); a concurrent optimize on the
# preempted" from lance. # same table fails with "CreateIndex transaction was preempted" from
# lance. Note: FULL calls create_document_from_source inside its loop,
# which may schedule *new* background vacuums — those run after the
# destructive phase and are fine.
await client._await_vacuum_tasks() await client._await_vacuum_tasks()
# Update settings to current config # Update settings to current config
@ -60,12 +63,14 @@ async def rebuild_database(
async for doc_id in _rebuild_full(client, documents): async for doc_id in _rebuild_full(client, documents):
yield doc_id yield doc_id
# Final maintenance if auto_vacuum enabled # Final maintenance if auto_vacuum enabled. Swallowing only so that a
# failed post-rebuild optimize doesn't mask a successful rebuild — but
# log it so the failure is visible in the output.
if client._config.storage.auto_vacuum: if client._config.storage.auto_vacuum:
try: try:
await client.store.vacuum() await client.store.vacuum()
except Exception: except Exception:
pass logger.warning("Post-rebuild vacuum failed", exc_info=True)
async def _rebuild_title_only( async def _rebuild_title_only(