ClickHouse / ClickHouse/clickhousectl

Corrupted `.clickhouse/servers/<name>.json`: `list`/`stop`/`remove` all fail with an opaque `io_error` and no guidance; the existing self-heal is undiscoverable

Open
#859 0 comments 0 reactions 0 assignees View on GitHub
bug local
Dominant language
Rust
Stars
74
Forks
5
Avg merge
2d 11h
Merged PRs (30d)
196

Description

## Validated scope and current-PR plan — 2026-09-11

This section records the QA review and the current decision to finalize existing PRs without opening new PRs. It supersedes the proposed routing/fix suggestions in the original report below; the original observations are retained. Central plan: #757.

### Disposition

Deferred from this existing-PR finalization pass. Keep the issue open; no new PR is requested now. This is not a resolution, a severity downgrade, or a waiver of release acceptance.

### Validation and corrections

Reproduced opaque JSON io_error for corrupt temporary metadata. A distinct ServerMetadataParse already exists but [output.rs:437](https://github.com/ClickHouse/clickhousectl/blob/d2c37f814fff53fe68d636e34103e2d0550bf84d/crates/clickhousectl/src/local/output.rs#L437) maps it to generic I/O. Improve structured guidance using that variant. Scope re-adoption promises to discoverable instances; do not suggest blindly deleting metadata or force-removing an unverified running process. Human path/cause reporting already differs from sanitized JSON.

---

## Original QA report

Found in the 2026-09-11 QA sweep of the combined PR stack at [`d2c37f81`](https://github.com/ClickHouse/clickhousectl/commit/d2c37f814fff53fe68d636e34103e2d0550bf84d), top PR #823, installed release build (package version still 0.4.2). Reproduced behaviour only; no implementation included.

Severity: medium; the one error code whose purpose is "something is broken" is the one with zero recovery guidance.

```sh
clickhousectl local server start --name s1
printf '{ this is not valid json' > .clickhouse/servers/s1.json
clickhousectl local server list # exit 1 {"error":{"code":"io_error","message":"Local I/O operation failed"}}
clickhousectl local server stop s1 # same
clickhousectl local server remove s1 # same — remove cannot repair
```

No file path, no `guidance` array (every other local error code in the README table has one), and the ClickHouse process stays running and orphaned. Deleting the file (not fixing it) makes the next `list` self-heal via PID discovery and regenerate metadata with `"started_at": "recovered"` — a good feature that nothing surfaces.

Suggested: for the server-metadata parse failure, a `guidance` entry naming the file and the recovery (`remove --force`, or "delete the file; the running server will be re-adopted"); let `remove --force` succeed on unparseable metadata.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in crates/clickhousectl/src/local/output.rs at line 437 and inspect the ServerMetadataParse variant and its callers. Reproduce the malformed .clickhouse/servers/.json case with list, stop, and remove, then verify that structured output identifies the metadata file and exposes the approved recovery path without unsafe removal guidance. Confirm the existing self-heal behavior remains discoverable.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.