Bug #118984 fts_optimize_read_deleted_doc_id_snapshot reads BEING_DELETED table twice
Submitted: 10 Sep 7:05 Modified: 12 Sep 14:13
Reporter: Yin Peng (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:9.4.0 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[10 Sep 7:05] Yin Peng
Description:
Function fts_optimize_read_deleted_doc_id_snapshot incorrectly reads from the BEING_DELETED auxiliary table twice, when the second read should be from the BEING_DELETED_CACHE table.

Additionally, it is noted that the function fts_sync_add_deleted_cache is designed to write the fts_cache_t::deleted_doc_ids structure into the DELETED_CACHE auxiliary table. However, the provenance of data within the fts_cache_t::deleted_doc_ids structure is unclear, as no code paths were found to initialize or update it. This ambiguity undermines the validity of operations dependent on this data.

How to repeat:
Read the code.

Suggested fix:
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index 76bb839a7a3..0ff93dd2440 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -2207,7 +2207,7 @@ func_exit:
                                   optim->to_delete);
 
   if (error == DB_SUCCESS) {
-    optim->fts_common_table.suffix = FTS_SUFFIX_BEING_DELETED;
+    optim->fts_common_table.suffix = FTS_SUFFIX_BEING_DELETED_CACHE;
 
     /* Read additional doc_ids to delete. */
     error = fts_table_fetch_doc_ids(optim->trx, &optim->fts_common_table,
[11 Sep 13:02] MySQL Verification Team
Thank you very much for your patch contribution, we appreciate it!

In order for us to continue the process of reviewing your contribution to MySQL, please send us a signed copy of the Oracle Contributor Agreement (OCA) as outlined in https://oca.opensource.oracle.com

Signing an OCA needs to be done only once and it's valid for all other Oracle governed Open Source projects as well.

Getting a signed/approved OCA on file will help us facilitate your contribution - this one, and others in the future.  

Please let me know, if you have any questions.

Thank you for your interest in MySQL.
[12 Sep 2:22] Yin Peng
OK, I will attach a patch later.
[12 Sep 2:23] Yin Peng
replace FTS_SUFFIX_BEING_DELETED with FTS_SUFFIX_BEING_DELETED_CACHE

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: patch.txt (text/plain), 569 bytes.

[12 Sep 14:13] MySQL Verification Team
Thanks for your contribution