[BUG] ClickHouse always inserts into a Distributed table, breaking single-node deployments
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
`initClient0` always executes `CREATE_DISTRIBUTED_TABLE_SQL` using `config.getClusterName()`, and `consume0` always inserts into `request_log_distributed`. On a single-node ClickHouse (no cluster configured), `clusterName` is null -> `Distributed('null', ...)`, the distributed table creation fails (caught and logged), so `request_log_distributed` is never created, and every batch insert then fails.
## Location
```
shenyu-plugin-logging-clickhouse/.../client/ClickHouseLogCollectClient.java:140, 87
ClickHouseLoggingConstant.java:68 (PRE_INSERT_SQL targets request_log_distributed)
```
## Impact
On a single-node ClickHouse deployment without a `clusterName` configured, all log batches throw on insert; `AbstractLogCollector` catches and drops them, so no logs are persisted.
## Suggested fix
Only create/insert-through the distributed table when `clusterName` is configured; otherwise insert directly into `request_log`.
## Related existing issue(s)
None
_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with ClickHouseLogCollectClient.java at initClient0 and consume0, then inspect ClickHouseLoggingConstant.java:68 where PRE_INSERT_SQL targets request_log_distributed. Trace how config.getClusterName() selects table creation and insertion. Done means single-node deployments insert into request_log without a cluster name, while configured clusters continue using the distributed table.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clickhouse, java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100