v.21.3Improvement

Fixed Race Condition in Distributed DDL Task Execution and Cleanup

Fixed race between execution of distributed DDL tasks and cleanup of DDL queue. Now DDL task cannot be removed from ZooKeeper if there are active workers. Fixes #20016. #20448 (tavplubix).
Fixed a race condition between the execution of distributed DDL tasks and the cleanup of the DDL queue in ClickHouse.

Why it matters

This fix prevents distributed DDL tasks from being prematurely removed from ZooKeeper while there are still active workers processing them, ensuring proper synchronization and stability of distributed DDL execution.

How to use it

No user action is required; the fix is applied internally to handle the DDL queue management more robustly in distributed environments.