Skip to content

Update detached-parts KB for recent ClickHouse behavior and safer recipes#162

Closed
BorisTyshkevich wants to merge 1 commit intomainfrom
codex/detached-parts-accuracy-2026
Closed

Update detached-parts KB for recent ClickHouse behavior and safer recipes#162
BorisTyshkevich wants to merge 1 commit intomainfrom
codex/detached-parts-accuracy-2026

Conversation

@BorisTyshkevich
Copy link
Contributor

Closes #161

Summary

This PR updates content/en/altinity-kb-useful-queries/detached-parts.md for correctness with recent ClickHouse versions and adds safer operational guidance.

What changed

  • Added explicit version scope:
    • 23.10+ as primary behavior (manual detached-part cleanup)
    • 22.6-23.9 as compatibility note (historical timeout cleanup behavior)
  • Reworked reason guidance into a single reason/action matrix.
  • Added nullable semantics for system.detached_parts.reason ('' vs NULL).
  • Replaced risky broad-cleanup guidance with SQL-first workflow.
  • Added copy-paste recipes for:
    • inventory by reason/size/time,
    • invalid detached-name detection,
    • replica-health gate check,
    • safe-drop generation for covered ignored|clone parts,
    • user-detached attach generation,
    • stale temporary prefix triage,
    • downgrade edge-case helper (broken-on-start_ rename helper).
  • Added references to upstream docs/changelog/source and relevant GitHub issues/PRs.

Why

  • Avoid dangerous cleanup patterns (rm -r as default operational path).
  • Align article claims with upstream behavior changes.
  • Provide practical diagnostics for rare detached-part edge cases seen in GitHub issues.

Notes

  • No runtime/product code changes.
  • Documentation-only update.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

count() AS parts,
formatReadableSize(sum(bytes_on_disk)) AS total_bytes,
min(modification_time) AS oldest,
max(modification_time) AS newest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this query is version specific, as those 3 fields were added later.

WHERE partition_id IS NULL
OR min_block_number IS NULL
OR max_block_number IS NULL
ORDER BY modification_time DESC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly does it 'detect'? Why needed?

```sql
SELECT metric, value
FROM system.asynchronous_metrics
WHERE metric IN ('NumberOfDetachedParts', 'NumberOfDetachedByUserParts')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not add any extra information to above (but can be used on dashboard or for alerting)

3. Validate part coverage for "usually safe" reasons (`ignored`, `clone`).
4. Drop with `ALTER ... DROP DETACHED ... SETTINGS allow_drop_detached=1`.

Check replica health first:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why writing about that here? it's obvious prerequirement. Like 'you should have your PC on'.

AND d.reason IN ('ignored', 'clone')
AND d.min_block_number >= p.min_block_number
AND d.max_block_number <= p.max_block_number
ORDER BY d.database, d.table, d.name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did someone test it? On different versions?

Code: 46. DB::Exception: Received from localhost:9000. DB::Exception: Unknown function quoteString. Maybe you meant: ['queryString','toString']: While processing database, table, name, reason, concat('ALTER TABLE `', database, '`.`', table, '` DROP DETACHED PART ', quoteString(name), ' SETTINGS allow_drop_detached=1;') AS drop_sql. (UNKNOWN_FUNCTION)


### Recovery Recipes

Attach user-detached parts (`reason = ''`):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it really be 'recovered'? Or it wil lead to data duplication

@filimonov
Copy link
Member

Typical AI slop, makes article worse.

@filimonov filimonov closed this Mar 3, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update detached-parts KB for ClickHouse 23.10+ accuracy and safe cleanup recipes

3 participants