TTL Task will not be canceled if facing write conflict #56422
Labels
affects-7.1
affects-7.5
affects-8.1
severity/major
sig/sql-infra
SIG: SQL Infra
type/bug
The issue is confirmed as a bug.
Bug Report
See the following function:
It'll update records in three tables:
tidb_ttl_table_status
,tidb_ttl_task
andtidb_ttl_job_history
. It's usually fine to write totidb_ttl_table_status
andtidb_ttl_job_history
, because thejob_manager
always holds the owner and runs as a single goroutine, but it may have conflict to write totidb_ttl_task
.When it faces a write conflict error, the job will be forgot by the job manager, and nobody will update the status, clean the tasks and update the history again.
The
DoGC
didn't work because it cleans the tasks using the following SQL:If the
tidb_ttl_table_status
is not updated, thetidb_ttl_task
will also not be cleaned.Therefore, I propose to execute this transaction in pessimistic mode. (Actually, it's not necessary to execute them in a single transaction. They are safe to be executed one-by-one.)
The text was updated successfully, but these errors were encountered: