Repository navigation
Fix exception in system log flush when table has extra columns - #102316
Conversation
The `SystemLog::flushImpl` method creates an INSERT query without an explicit column list. When the system log table has been altered to include extra columns (e.g. by a fuzzer or a user), the INSERT pipeline expects all table columns, but the block only contains the columns from `getColumnsDescription`. This causes a "Invalid number of columns in chunk pushed to OutputPort. Expected 23, found 22" exception. Fix by explicitly specifying column names in the INSERT query, so that extra columns added to the table get their default values instead of causing a mismatch. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=a4b72fe91e7c174e0a5347a49d32b5b3e5719d47&name_0=MasterCI&name_1=BuzzHouse%20%28amd_tsan%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [23f5def] Summary: ✅ AI ReviewSummaryThis PR fixes ClickHouse Rules
Final Verdict
|
| SET log_processors_profiles = 1; | ||
|
|
||
| SELECT 1 FORMAT Null; | ||
| SYSTEM FLUSH LOGS; |
There was a problem hiding this comment.
Should be SYSTEM FLUSH LOGS processors_profile_log
| @@ -0,0 +1,18 @@ | |||
| -- Verify that system log tables can be flushed after ALTER TABLE adds a column. | |||
There was a problem hiding this comment.
Missing -- Tags: no-parallel
The test does ALTER TABLE system.processors_profile_log ADD COLUMN / DROP COLUMN on a global system
table. Without the tag, it races with any concurrent test that flushes logs.
…ile_log` The test alters a global system table (`system.processors_profile_log`), so it must not run in parallel with other tests that flush logs. Also flush only the specific log table instead of all logs. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
tiandiwonder
left a comment
There was a problem hiding this comment.
better to test query_log as well.
|
Not quite... I'll have to convert to an sh test and configure clickhouse-local accordingly... |
…test `query_log` The `.sql` test failed in CI because `ALTER TABLE ... DROP COLUMN` on `system.processors_profile_log` is forbidden when materialized views reference the table. Convert to a `.sh` test so the cleanup can suppress errors from dependent views. Also add coverage for `query_log` per review feedback. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add `initializeSystemLogs` call to `LocalServer` so that `clickhouse-local` creates system log tables (like `query_log`, `processors_profile_log`) when they are configured via `--config-file`. Without a config, this is a no-op. Rewrite the test to run entirely in `clickhouse-local` with a custom config, avoiding ALTER on the shared server where materialized views prevent column modifications. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
|
||
| /// Initialize system logs if configured (e.g. query_log, processors_profile_log). | ||
| /// This must happen after the system database is attached. | ||
| global_context->initializeSystemLogs(); |
There was a problem hiding this comment.
initializeSystemLogs is now called unconditionally, even when --no-system-tables is set.
That option explicitly promises not to attach system tables, but this path can still create/start system logs (and potentially prepare system.query_log / system.processors_profile_log if configured), which violates the flag semantics and may fail in setups where the system DB is intentionally absent.
Please gate this call the same way as system table attachment, e.g.:
if (!getClientConfiguration().has("no-system-tables"))
global_context->initializeSystemLogs();… `query_log` query The style check requires that any test querying `system.query_log` or `system.query_thread_log` includes a `current_database = currentDatabase()` condition to avoid interfering with concurrent tests. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…alServer` When `--no-system-tables` is set, the system database is not attached, so initializing system logs would fail or violate the flag semantics. Skip the call in that case, consistent with how system table attachment is gated. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…onfigured A default `clickhouse-local` invocation has no system log sections in the config. Initializing `SystemLogs` regardless meant the unique pointer in `ContextSharedPart` was written during construction and again during teardown, racing under TSan with a concurrent read from a `BackgroundSchedulePool` worker that calls `getBackgroundSchedulePoolLog` after a task finishes. The race surfaced as a "Scraping system tables" failure in the `Stateless tests (amd_tsan, parallel, 1/2)` job, since CI scrapes system tables via short-lived `clickhouse-local` processes. Gate the call on the config actually containing at least one entry from `LIST_OF_ALL_SYSTEM_LOGS`. The custom config used by `04093_system_log_alter_column` declares `query_log` and `processors_profile_log`, so the regression test continues to exercise the original fix; default invocations stop touching `system_logs`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102316&sha=665b5c743abc6d9c6ac9946eb60d70df95ce08c8&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%201%2F2%29 PR: #102316 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
In `--only-system-tables` mode, `clickhouse-local` is meant to read existing persisted system tables (the stress test harness uses this to dump `system.query_log` after a run). Starting the system loggers there is unnecessary and triggers a TSan-visible data race between background pool work scheduled during system log startup and `~ContextSharedPart` resetting `async_read_counters_thread_pool_reader` during shutdown. CI report: #102316 TSan stack: https://s3.amazonaws.com/clickhouse-test-reports/PRs/102316/63cb4d0ded2a8ca7ef8a6825ce7295010a738235/stress_test_arm_tsan/job.log
LLVM Coverage Report
Changed lines: 100.00% (22/22) · Uncovered code |
The
SystemLog::flushImplmethod creates an INSERT query without an explicit column list. When the system log table has been altered to include extra columns (e.g. by a fuzzer or a user), the INSERT pipeline expects all table columns, but the block only contains the columns fromgetColumnsDescription. This causes a "Invalid number of columns in chunk pushed to OutputPort. Expected 23, found 22" exception.Fix by explicitly specifying column names in the INSERT query, so that extra columns added to the table get their default values instead of causing a mismatch.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=a4b72fe91e7c174e0a5347a49d32b5b3e5719d47&name_0=MasterCI&name_1=BuzzHouse%20%28amd_tsan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.5.1.216