Skip to main content

Module fts_sync

Module fts_sync 

Source
Expand description

Commit-time FTS propagation (P107.1).

sync_indexes_on_commit is invoked by the connection layer’s commit pipe-line (Step 4.5 of Connection::commit_write_txn) with the txn’s written (table_id, row_id) pairs. For every registered FTS index over a touched table it snapshots the current text values of those rows and applies them to the on-disk Tantivy index via akar_fts::build::apply_doc_writes: an update replaces the row’s document, a delete (NULL / missing column) removes it.

This is the single incremental writer AND the single reloader: the hook reloads the shared akar_fts::index::FtsIndexHandle reader after applying writes (P107.2). The PhysicalFtsScan read path only reuses that cached reader — never opening, reloading, or writing. Failures here are non-fatal by contract — they are surfaced as warnings by the caller so a stale index can never roll back an already-durable commit.

Crash recovery (P107.3): the Tantivy segment commit is the crash boundary. A crash between the durable akar commit and this hook’s apply_doc_writes commit loses only the in-flight increment (the index ends stale, never over-visible, never corrupt — FtsIndexHandle::open_on_disk reopens the last committed generation); the last committed state always survives. Pinned by test_fts_crash_recovery_last_committed_survives (akar-fts) and test_fts_crash_recovery_across_db_reopen (akar-main).

Functions§

sync_indexes_on_commit
Apply the written rows of a committed transaction to every FTS index over a touched table.