Skip to content

fix(local): reject equal HTTP/TCP ports and count only ClickHouse servers on start (#1452) - #1457

Merged
sdairs merged 1 commit into
claude/drop-query-provisioning-lockfrom
claude/local-start-equal-ports-ch-count
Nov 16, 2026
Merged

sdairs merged 1 commit into
claude/drop-query-provisioning-lockfrom
claude/local-start-equal-ports-ch-count

Conversation

@sdairs

@sdairs sdairs commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Why:

  1. Passing identical --http-port and --tcp-port on local clickhouse start exited 0 because the readiness probe checked HTTP /ping on http_port and TCP connectability on tcp_port, both satisfied by the single bound HTTP listener while the native TCP listener failed in server.log. Likewise, resolve_ports could assign an omitted port onto the port claimed by the other listener (such as --http-port 9000 or --tcp-port 8123).
  2. advisory_running_server_count_locked passed engine: None, so local clickhouse start inspected and counted running Docker Postgres instances in its "already running" note.

What:

  • Reject equal explicit --http-port and --tcp-port values at start_server entry (and in resolve_ports) as an ArgumentConflict usage error (exit 2) before scanning processes, locking metadata, or downloading a build.
  • Update resolve_ports so an omitted port skips any port claimed by the other listener, both at default selection and when scanning for a free port.
  • Pass Some(Engine::Clickhouse) in advisory_running_server_count_locked so local clickhouse start counts only running ClickHouse servers and does not inspect Postgres containers.
  • Document port distinctness in docs/guides/local-development.md.

QA: cargo fmt --all --check, cargo clippy -p clickhousectl --all-targets -- -D warnings (default and --no-default-features), and cargo test -p clickhousectl.

Risks: Low. Equal explicit HTTP and TCP ports could never produce a working native TCP listener; counting only ClickHouse servers matches the clickhousectl local clickhouse list hint printed by the note.

Closes #1452


Note

Low Risk
Targeted CLI validation and port-selection logic in local dev; no auth, data, or production-path changes.

Overview
local clickhouse start now rejects identical --http-port and --tcp-port as a usage error (exit 2) at the very beginning of start, before recovery, locks, downloads, or any .clickhouse state is touched.

Port resolution was tightened: resolve_ports refuses the same explicit port for both listeners, and when one port is omitted the auto-picker never assigns the port already claimed by the other listener (explicit or resolved). That avoids readiness passing on HTTP alone while native TCP never binds.

The informational “already running” note on start now counts only running ClickHouse servers, so Postgres metadata no longer triggers Docker container inspect during a ClickHouse start.

Docs note that HTTP and TCP ports must differ; tests cover conflict timing, omitted-port selection, and no Postgres inspect on ClickHouse start.

Reviewed by Cursor Bugbot for commit e13a778. Bugbot is set up for automated code reviews on this repo. Configure here.

@sdairs
sdairs requested a review from iskakaushik as a code owner November 13, 2026 20:53
@sdairs
sdairs added this pull request to stack #1285 November 13, 2026 22:43

@iskakaushik iskakaushik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@sdairs
sdairs merged commit 6e6c4de into main Nov 16, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

local clickhouse start: reject identical HTTP/TCP ports and count only ClickHouse servers

2 participants