v.21.8Improvement

Fix race condition in ALTER TABLE DETACH and background merges

Fix possible logical race condition between ALTER TABLE ... DETACH and background merges. #25605 (Azat Khuzhin).
Fix a potential logical race condition between ALTER TABLE ... DETACH operations and background merges in ClickHouse.

Why it matters

This fix addresses a concurrency issue where performing ALTER TABLE ... DETACH could conflict with ongoing background merges, potentially leading to unstable or incorrect table states. Resolving this improves the reliability and consistency of table modifications in ClickHouse.

How to use it

Users benefit from this fix automatically; no additional configuration or commands are needed to enable it. Simply upgrade to the version containing this patch to ensure safer ALTER TABLE ... DETACH operations alongside background merges.