【TiDB Usage Environment】/Testing
【TiDB Version】6.5
【Reproduction Path】During data generation
【Encountered Issue: Problem Description and Impact】TTL manager has timed out, pessimistic locks may expire, please commit or rollback this transaction
【Resource Configuration】
【Attachments: Screenshots/Logs/Monitoring】
When encountering this error, it is recommended to check if the business logic can be optimized, such as splitting large transactions into smaller ones. Without using [large transactions], large transactions may trigger TiDB’s transaction limits.
You can appropriately adjust relevant parameters to meet transaction requirements.
In addition to the restriction that it cannot exceed the GC time, the TTL of a pessimistic lock has an upper limit, which is 1 hour by default. Therefore, a pessimistic transaction that takes more than 1 hour to execute may fail to commit. This timeout is specified by the TiDB parameter [performance.max-txn-ttl].
tidb_lock_wait_timeout: This parameter is used to set the maximum time TiDB waits for a pessimistic lock. If the waiting time exceeds this value, TiDB will automatically give up waiting, roll back the transaction, and return an error. You can appropriately increase the value of this parameter based on actual conditions to reduce the risk of pessimistic lock expiration.
tidb_gc_life_time: This parameter is used to set the interval for automatic GC (garbage collection) in TiDB. By appropriately adjusting this parameter, TiDB can more promptly reclaim expired data, reducing lock holding time and the risk of expiration.