v.21.7Improvement

On server start, incorrectly partitioned parts remain detached instead of being removed

On server start, parts with incorrect partition ID would not be ever removed, but always detached. #25070. #25166 (Nikolai Kochetov).
Fix automatic removal of parts with incorrect partition ID on server start instead of detaching them.

Why it matters

Previously, parts with incorrect partition IDs were never removed but only detached on server startup. This behavior could lead to unwanted accumulation of detached parts and inefficient storage usage. The fix ensures that such parts are properly removed, improving storage hygiene and system stability.

How to use it

This improvement is applied automatically on server start with the updated ClickHouse version. No explicit configuration or action from users is required to benefit from this change.