v.22.2Improvement
Cancel Merges Before Table Lock to Prevent DEADLOCK_AVOIDED Error in TRUNCATE Query
Cancel merges before acquiring table lock forTRUNCATEquery to avoidDEADLOCK_AVOIDEDerror in some cases. Fixes #34302. #34304 (tavplubix).
Why it matters
This feature addresses a deadlock scenario that occurs duringTRUNCATE operations by cancelling ongoing merges before locking the table. It improves stability and reliability when truncating tables by avoiding deadlock errors.How to use it
No special configuration is needed. The fix is applied automatically toTRUNCATE queries in ClickHouse to cancel merges before acquiring the table lock.