diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 596c7528fd3..343c91a892f 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -6301,6 +6301,13 @@ bool fts_init_index(dict_table_t *table, /*!< in: Table with FTS */ if (!start_doc) { fts_cmp_set_sync_doc_id(table, 0, true, &start_doc); + /* fts_update_sync_doc_id() writes (doc_id + 1) to CONFIG table, + so we need to subtract 1 to get the actual synced doc_id. + This ensures the recovery query "FTS_DOC_ID > start_doc" won't + skip the first unsynced document. */ + if (start_doc) { + start_doc -= 1; + } cache->synced_doc_id = start_doc; }