Skip to content

Store minio audit/server log tables on an explicit local disk, not the default policy - #110430

Merged
alexey-milovidov merged 5 commits into
masterfrom
fix-minio-log-tables-explicit-local-disk
Jul 17, 2026
Merged

alexey-milovidov merged 5 commits into
masterfrom
fix-minio-log-tables-explicit-local-disk

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #110333 (merged), addressing the review note that pinning
system.minio_audit_logs / system.minio_server_logs to SETTINGS storage_policy = 'default' is not enough for the private repo: there default is cloud-based (object storage), so the tables would still live on S3 - the audit-log feedback loop and the slow post-run INTO OUTFILE dump that reads them back from S3 both persist.

These are diagnostics about S3 activity; there is no reason to store them on S3. Instead of relying on what default resolves to, pin each table to a dedicated local disk with an explicit SETTINGS disk = disk(type = 'local', path = '/var/lib/clickhouse/disks/<table>/'). That path is inside custom_local_disks_base_directory (/var/lib/clickhouse/disks/, set by custom_disks_base_path.xml, which install.sh always installs), so the disk is created locally regardless of the server's default merge_tree policy - correct in both the public repo (where default is local) and the private/cloud repo (where default is object storage). Each table uses its own path so it gets its own disk. The change lives in the shared ci/jobs/scripts/clickhouse_proc.py, so it flows to the private repo via the sync.

The guard test (ci/tests/test_minio_log_tables_local_storage.py) is updated to require the explicit local-disk pin and to reject a regression back to storage_policy = 'default'.

Lifecycle (addressing the AI review finding): the pinned disk paths live outside the per-run server data directory (run_path*) that ClickHouseProc.start wipes, so a restart destroys the tables' metadata but not their data - every bugfix-validation binary swap would leak the previous incarnation's parts. create_minio_log_tables therefore now wipes the two disk directories as its first setup step, before re-creating the tables; both call sites run right after a fresh start, so no live table references them at that point. The guard test also requires this reset step and checks that it covers exactly the pinned disk paths.

Verified with clickhouse local: with the default merge_tree policy overridden to a non-local policy, a plain CREATE lands on the override, while the disk = disk(type = 'local', ...) pin lands on a dedicated local disk, bypassing the override entirely.

Related: #110333
Related: #110333 (comment)

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not for changelog.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Version info

  • Merged into: 26.7.1.1065 (included in 26.7 and later)

Follow-up to the review of the initial fix: pinning
`system.minio_audit_logs` / `system.minio_server_logs` to
`SETTINGS storage_policy = 'default'` is not enough. In the public repo
`default` is a local policy, but in the private/cloud repo `default` is
cloud-based (object storage), so pinning to it would still put these
tables on S3 - the audit-log feedback loop and the slow post-run dump
that reads them back from S3 both persist there.

Pin each table to a dedicated local disk instead, with an explicit
`SETTINGS disk = disk(type = 'local', path = '/var/lib/clickhouse/disks/...')`.
That path is inside `custom_local_disks_base_directory`
(`/var/lib/clickhouse/disks/`, set by `custom_disks_base_path.xml`, which
`install.sh` always installs), so the disk is created locally regardless
of what `default` resolves to - correct in both the public and the
private/cloud repo. Each table uses its own path so it gets its own disk.

Update the guard test to require the explicit local-disk pin and reject a
regression back to `storage_policy = 'default'`.

Verified with `clickhouse local`: with the default `merge_tree` policy
overridden to a non-local policy, a plain `CREATE` lands on the override
while the `disk = disk(type = 'local', ...)` pin lands on a dedicated
local disk, bypassing the override.

#110333 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2f13925]

Summary: ✅


AI Review

Summary

This PR moves system.minio_audit_logs and system.minio_server_logs off the repo-dependent default storage policy onto explicit local disks, then clears those pinned disk directories before re-creating the tables so bugfix-validation restarts do not leak stale parts. I do not see a remaining correctness or safety issue in the current diff; the two earlier review findings are addressed in the current code.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 14, 2026
Comment thread ci/jobs/scripts/clickhouse_proc.py Resolved
@Algunenano Algunenano self-assigned this Jul 15, 2026
alexey-milovidov and others added 2 commits July 15, 2026 11:14
The explicit local disks at /var/lib/clickhouse/disks/minio_*_logs/ live
outside the per-run server data directory (run_path*) that
`ClickHouseProc.start` wipes, so a restart destroys the tables' metadata
but not their data: every bugfix-validation binary swap re-runs
`create_minio_log_tables` and would leak the previous incarnation's parts
(~1.5 GB of audit logs on sanitizer s3 runs). Wipe the two disk
directories as the first setup step - both call sites run right after a
fresh `start`, so no live table references them. Extend the guard test to
require the reset step and that it covers exactly the pinned disk paths.

Addresses the AI review finding on
#110430

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/scripts/clickhouse_proc.py Resolved
alexey-milovidov added a commit that referenced this pull request Jul 16, 2026
…haredMergeTree

The `min_block`/`max_block` values derived via `splitByChar('_', part_name)`
and a hard `::UInt64` cast were computed in a `WITH` clause and referenced in
the `WHERE` filter, so they got evaluated for every `system.part_log` row of
the table before the `min_block = 1 AND max_block = ...` filter could narrow
them down. Under `SharedMergeTree`, `part_log` for this table can contain
extra rows whose `part_name` is a filesystem path, so the cast threw
`CANNOT_PARSE_TEXT` and failed the test.

Replace the hard cast with `toUInt64OrNull`, so malformed `part_name` values
parse to `NULL` and get filtered out by the `WHERE` clause instead of
throwing, keeping `SharedMergeTree` coverage instead of tagging the test out
via `no-shared-merge-tree` (per review feedback on this change).

Related: #110430
The reset step in `ClickHouseProc.create_minio_log_tables` shelled out to
`rm -rf /var/lib/clickhouse/disks/minio_audit_logs/ .../minio_server_logs/`.
Those paths live outside `run_path*` and can persist across jobs, so a stale
or planted symlink at either path would make `rm -rf .../` follow it and
recursively delete whatever it points at instead of just the log tables' own
directory.

Replace it with `ClickHouseProc._reset_minio_log_disk_dirs`, which refuses to
remove a path that is a symlink and only `shutil.rmtree`s a verified real
directory. The guard test now requires this symlink check and rejects a
regression back to the shell `rm -rf` form.

Related: #110430
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The only CI failure, Stress test (amd_asan_ubsan), is unrelated to this Python-only CI-script PR: it is an UndefinedBehaviorSanitizer report in the SZ3 codec (LinearQuantizer.hpp:45, NaN cast to long), present on master and several unrelated PRs since #108788. Fix: #110762.

@alexey-milovidov
alexey-milovidov merged commit 3cb8e29 into master Jul 17, 2026
350 of 352 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-minio-log-tables-explicit-local-disk branch July 17, 2026 02:37
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 17, 2026
raimannma pushed a commit to raimannma/ClickHouse that referenced this pull request Jul 17, 2026
The test verifies local vertical-merge mechanics (compact to wide parts)
by parsing MergeTree part names from `system.part_log` with
`splitByChar('_', part_name)[2]::UInt64`. With `SharedMergeTree`,
`part_log` for the table can contain extra entries whose `part_name` is a
filesystem path, so the cast throws `CANNOT_PARSE_TEXT`:

    Cannot parse string 'work/clickhouse-private/clickhouse-private/ci/tmp/run' as UInt64

Observed in the "CH Inc sync" run of
ClickHouse#110430 in "Stateless tests
(amd_asan_ubsan, distributed cache, meta in keeper, s3 storage, parallel,
1/2)". The test is already listed as cloud-incompatible in the private
repo; this tag makes the shared-merge-tree stateless runs skip it too.

Co-Authored-By: Claude Fable 5 <[email protected]>
pull Bot pushed a commit to Spencerx/ClickHouse that referenced this pull request Jul 18, 2026
`SZ3::LinearQuantizer::quantize_and_overwrite` cast
`fabs(data - pred) * error_bound_reciprocal` straight to `int64_t`. For NaN or
infinite input (or a finite value out of int64 range) that cast is undefined
behavior, reported by UBSan in stress tests as
`LinearQuantizer.hpp:45:49: runtime error: nan is outside the range of
representable values of type 'long'`. Such values can never be quantized -
the error-bound recheck sends them to the unpredictable (lossless) path anyway -
so the fix routes them there before the cast, in the `ClickHouse/SZ3` fork
(commit dda0caee243719d1dad10a9f05bc18eeedc2ab6b on `ClickHouse/v3.3.2`).
Behavior for in-range values is unchanged.

The new test `04603_sz3_codec_non_finite` checks that NaN and infinities
round-trip exactly through `SZ3` (they are stored losslessly), both on insert
and after a merge, and would trigger the UBSan report without the fix.

Seen in: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110430&sha=2f139250fec65930580e67de7ebd07b87392fd16&name_0=PR&name_1=Stress%20test%20%28amd_asan_ubsan%29
On PR: ClickHouse#110430
Caused by: ClickHouse#108788

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The explicit local disks at /var/lib/clickhouse/disks/minio_*_logs/ live
outside the per-run server data directory (run_path*) that
`ClickHouseProc.start` wipes, so a restart destroys the tables' metadata
but not their data: every bugfix-validation binary swap re-runs
`create_minio_log_tables` and would leak the previous incarnation's parts
(~1.5 GB of audit logs on sanitizer s3 runs). Wipe the two disk
directories as the first setup step - both call sites run right after a
fresh `start`, so no live table references them. Extend the guard test to
require the reset step and that it covers exactly the pinned disk paths.

Addresses the AI review finding on
ClickHouse#110430

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The reset step in `ClickHouseProc.create_minio_log_tables` shelled out to
`rm -rf /var/lib/clickhouse/disks/minio_audit_logs/ .../minio_server_logs/`.
Those paths live outside `run_path*` and can persist across jobs, so a stale
or planted symlink at either path would make `rm -rf .../` follow it and
recursively delete whatever it points at instead of just the log tables' own
directory.

Replace it with `ClickHouseProc._reset_minio_log_disk_dirs`, which refuses to
remove a path that is a symlink and only `shutil.rmtree`s a verified real
directory. The guard test now requires this symlink check and rejects a
regression back to the shell `rm -rf` form.

Related: ClickHouse#110430
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…bles-explicit-local-disk

Store minio audit/server log tables on an explicit local disk, not the `default` policy
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The test verifies local vertical-merge mechanics (compact to wide parts)
by parsing MergeTree part names from `system.part_log` with
`splitByChar('_', part_name)[2]::UInt64`. With `SharedMergeTree`,
`part_log` for the table can contain extra entries whose `part_name` is a
filesystem path, so the cast throws `CANNOT_PARSE_TEXT`:

    Cannot parse string 'work/clickhouse-private/clickhouse-private/ci/tmp/run' as UInt64

Observed in the "CH Inc sync" run of
ClickHouse#110430 in "Stateless tests
(amd_asan_ubsan, distributed cache, meta in keeper, s3 storage, parallel,
1/2)". The test is already listed as cloud-incompatible in the private
repo; this tag makes the shared-merge-tree stateless runs skip it too.

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…haredMergeTree

The `min_block`/`max_block` values derived via `splitByChar('_', part_name)`
and a hard `::UInt64` cast were computed in a `WITH` clause and referenced in
the `WHERE` filter, so they got evaluated for every `system.part_log` row of
the table before the `min_block = 1 AND max_block = ...` filter could narrow
them down. Under `SharedMergeTree`, `part_log` for this table can contain
extra rows whose `part_name` is a filesystem path, so the cast threw
`CANNOT_PARSE_TEXT` and failed the test.

Replace the hard cast with `toUInt64OrNull`, so malformed `part_name` values
parse to `NULL` and get filtered out by the `WHERE` clause instead of
throwing, keeping `SharedMergeTree` coverage instead of tagging the test out
via `no-shared-merge-tree` (per review feedback on this change).

Related: ClickHouse#110430
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
`SZ3::LinearQuantizer::quantize_and_overwrite` cast
`fabs(data - pred) * error_bound_reciprocal` straight to `int64_t`. For NaN or
infinite input (or a finite value out of int64 range) that cast is undefined
behavior, reported by UBSan in stress tests as
`LinearQuantizer.hpp:45:49: runtime error: nan is outside the range of
representable values of type 'long'`. Such values can never be quantized -
the error-bound recheck sends them to the unpredictable (lossless) path anyway -
so the fix routes them there before the cast, in the `ClickHouse/SZ3` fork
(commit dda0caee243719d1dad10a9f05bc18eeedc2ab6b on `ClickHouse/v3.3.2`).
Behavior for in-range values is unchanged.

The new test `04603_sz3_codec_non_finite` checks that NaN and infinities
round-trip exactly through `SZ3` (they are stored losslessly), both on insert
and after a merge, and would trigger the UBSan report without the fix.

Seen in: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110430&sha=2f139250fec65930580e67de7ebd07b87392fd16&name_0=PR&name_1=Stress%20test%20%28amd_asan_ubsan%29
On PR: ClickHouse#110430
Caused by: ClickHouse#108788

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants