Skip to content

fix loading old S3 tables with globbed paths - #115277

Merged
fm4v merged 9 commits into
masterfrom
ncb/fix-issue-114705
Aug 26, 2026
Merged

fm4v merged 9 commits into
masterfrom
ncb/fix-issue-114705

Conversation

@bharatnc

@bharatnc bharatnc commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Before ClickHouse 26.6, S3 tables could use a path like **.parquet together
with PARTITION BY. These tables were read-only, so ClickHouse ignored PARTITION BY.

#86746 changed this in ClickHouse 26.6. #107437 also changed how the default
strategy is selected. ClickHouse now tries to use either hive or wildcard. Neither works
with this kind of path unless it contains {_partition_id}. Because of this, tables created
before 26.6 can fail to load after an upgrade.

Use the old behavior for these tables when partition_strategy is not set.
Invalid strategies that users set explicitly still fail.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Closes: #114705

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

Fix loading old S3 tables with globbed paths and PARTITION BY after upgrading from versions before 26.6.


Workflow [PR]
Sync PR [sync-upstream/pr/115277]

Version info

  • Backported to: 26.8.1.2010

@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d9e3080]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, flaky) ERROR IGNORED

AI Review

Summary

This PR restores the pre-26.6 "ignore PARTITION BY" behavior for globbed object-storage paths without an explicit partition_strategy, and it persists inferred partition_strategy = 'none' for new plain-path S3/Azure tables created under a wildcard default. The remaining problem is that pre-existing plain-path tables from older releases still reload as hive, so the upgrade regression described in #114705 is not fully resolved yet.

Missing context / blind spots
  • ⚠️ CI was still in progress when I reviewed this on 2026-08-25. Only early checks such as Style check, Fast test, Build (arm_tidy), Build (wasm_parser), and the build-profile diff had finished; the main build/test matrix had not completed yet.
Findings

⚠️ Majors

  • src/Storages/ObjectStorage/StorageObjectStorageConfiguration.cpp:244 Existing pre-26.6 plain-path tables are still upgraded to hive on ATTACH / startup. A table created on 26.5 as ENGINE = S3('.../root', 'Parquet') PARTITION BY d had effective strategy none, but this branch still forces hive, which makes PARTITION BY active and flips the implicit partition_columns_in_data_file default to false. New CREATEs are stable because this PR persists partition_strategy = 'none', but old metadata never gets that marker, so the plain-path upgrade regression from #114705 remains.
Final Verdict

Needs changes: the fix is incomplete for already-existing plain-path object-storage tables created before 26.6.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.30% 87.20% -0.10%
Functions 91.90% 91.90% +0.00%
Branches 79.40% 79.30% -0.10%

Changed lines: Changed C/C++ lines covered: 158/161 (98.14%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d9e30809d with master 7ac28ea38 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of aedfbaa1c; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 709.93 MiB 706.90 MiB -3.03 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

19 object files changed (+19.77 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/StorageObjectStorage.cpp.o 525.53 KiB 542.81 KiB +17.29 KiB (+3.29%)

737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

112 translation units recompiled, 1028 s compile time in total, 112 of them have a recent master baseline.

Job report

@bharatnc
bharatnc force-pushed the ncb/fix-issue-114705 branch from 9101e0f to d1ce3db Compare August 19, 2026 03:59
@bharatnc
bharatnc force-pushed the ncb/fix-issue-114705 branch from 6bfd257 to e301cbb Compare August 20, 2026 15:58
@bharatnc
bharatnc force-pushed the ncb/fix-issue-114705 branch from b1326f0 to 71b211d Compare August 21, 2026 02:42
@bharatnc

Copy link
Copy Markdown
Contributor Author

@groeneai can you investigate why the build is failing?

@groeneai

Copy link
Copy Markdown
Collaborator

No build is failing. All 40 Build (*) jobs are green on 8a253f5b4, and the build profile diff bot reports "No significant changes". The only red job is Integration tests (amd_asan_ubsan, flaky), and its failure is not an assertion in your tests.

What actually happened (job log): 399 PASSED, 0 FAILED. Both tests you added passed on all three xdist workers:

04:20:53 [gw2] [ 14%] PASSED test_storage_hdfs/test.py::test_globbed_path_partition_by_round_trips
04:20:54 [gw2] [ 15%] PASSED test_storage_hdfs/test.py::test_plain_path_wildcard_default_is_rejected

At 98% the job was killed:

05:03:24 [gw0] node down: Not properly terminated
05:14:56 WARNING: Timeout exceeded [3244], sending SIGTERM to process group [932]
05:24:52 ERROR: Job killed, exit code [137]

Root cause is the container memory limit, from dmesg.log in the job artifacts:

oom-kill:constraint=CONSTRAINT_MEMCG,...,task=clickhouse,pid=75724
Memory cgroup out of memory: Killed process 75724 (clickhouse)
memory: usage 62679004kB, limit 62679004kB, failcnt 14197148

The kernel OOM-killed 8 processes inside the job container (3 clickhouse, 3 python3.13, then pytest and dockerd), which is what took gw0 down and left the session to time out.

The arithmetic is the interesting part. ci/jobs/integration_test_job.py sizes workers as min(ncpu // 5, mem_gb // 20) for --dist=each, and the job logged ncpu: 16, mem_gb: 61, so it chose 3 workers and budgeted 3 x 20 = 60 GiB. But Utils.physical_memory() reads SC_PHYS_PAGES, which is the host, while the container's hierarchical_memory_limit is 59.78 GiB. Under --dist=each every worker runs the full module set with its own cluster, and test_storage_s3 alone defines 11 instances, so peak was 33 clickhouse processes at 57.7 GiB combined against a 59.78 GiB ceiling.

This is not your diff. test_query_condition_cache, where gw0 died, is not touched by your PR, and the same job is red on 66 distinct PRs in the last 10 days. It is tracked by #112984 ("Bound the integration tests' nested containers by the job's memory limit"), which is still open.

One caveat on unblocking: I would not expect a plain re-run to help here. I checked dmesg.log for all five commits you have pushed to this PR and every one shows CONSTRAINT_MEMCG kills, so on this module set the job is over budget by construction rather than intermittently. Your Bugfix validation (integration tests, amd64/aarch64) jobs, which run the same modules under loadfile with the 11 GiB-per-worker budget, are green. Getting this one green likely needs #112984 (or a --workers override for this job), not another attempt.

@bharatnc

Copy link
Copy Markdown
Contributor Author

and the same job is red on 66 distinct PRs in the last 10 days.
@groeneai give me 3 examples where the PRs failed with the same error for the same integration test.

@groeneai

Copy link
Copy Markdown
Collaborator

First a correction to my own number, because it does not answer what you asked. The 66 was job-level breadth: every red of Integration tests (amd_asan_ubsan, flaky) in 10 days (CIDB check_status IN ('error','failure') -> 66 distinct PRs, 13727 rows). Most of those are ordinary per-test assertion failures in unrelated modules, so it is the wrong population for your question. For the narrow predicate, same module and same error, the counts are: this kill shape anywhere = 5 PRs in 10 days, 7 in 60; in test_storage_s3/test.py specifically = 3 PRs in 10 days (yours among them), 4 in 60.

Three PRs other than yours, same module, same error (container CONSTRAINT_MEMCG OOM -> xdist worker node down -> job timeout -> exit code [137]), none of them touching your change:

104431 at a7210f9a3, 2026-08-20. 267 PASSED, 0 FAILED, killed at test_query_condition_cache_overwrite_invalidation. Timeout exceeded [3250], exit code [137]. dmesg has 8 CONSTRAINT_MEMCG kills (2 clickhouse, 3 python3.13, python3, pytest, dockerd), memory: usage 62679004kB, limit 62679004kB.
report | dmesg

114054 at 1aca96656, 2026-08-14. 262 PASSED, 0 FAILED, killed at test_query_condition_cache. Timeout exceeded [3247], exit code [137]. dmesg has 8 CONSTRAINT_MEMCG kills, same victim set, limit 62678996kB.
report | dmesg

109310 at aae9b2910, 2026-07-13, since merged. 258 PASSED, killed at test_query_condition_cache_overwrite_invalidation with node down: Not properly terminated, Timeout exceeded [3255], exit code [137]. dmesg has 5 CONSTRAINT_MEMCG kills. This run also had 3 genuine per-test FAILEDs of its own, so only the kill is comparable, not the whole job.
report | dmesg

Two more in the 10-day window have the identical kill shape in a different module, so they support the mechanism but not the same-test half of the question: 111663 (test_rename_column, 3 CONSTRAINT_MEMCG kills including pytest and dockerd) and 113589 (test_parallel_replicas_over_distributed, no memcg line in its dmesg, so that is the plain xdist-death variant and not this).

On why the module is the stable part and the victim test is not: this check runs --dist=each, so every worker runs the whole module set with its own cluster, and test_storage_s3/test.py declares 11 instances. ci/jobs/integration_test_job.py:930 sizes workers = min(ncpu // 5, mem_gb // 20); your job logs ncpu: 16, mem_gb: 61, so 3 workers and 60 GiB budgeted against a container limit of 59.78 GiB, because Utils.physical_memory() reads the host rather than the cgroup. Whichever test is in flight when the ceiling is hit is the one that appears to die, which is why the victim test differs across these runs while the module does not.

@bharatnc

Copy link
Copy Markdown
Contributor Author

@groeneai but what triggered sudden failure of test_storage_s3/test.py in this PR which is consistent if the same test is not failing on master or on other PRs? If this is not the case, can you actually point to test_storage_s3/test.py failing else where outside of this PR because of the same reason?

@groeneai

Copy link
Copy Markdown
Collaborator

Direct answers: nothing in your diff triggered it, and no, I cannot point at another PR where test_storage_s3/test.py fails this way on its own merits. The trigger is that your PR edits tests/integration/test_storage_s3/test.py, and that is the only thing needed.

Why editing the file is the trigger. Integration tests (*, flaky) exists only in the PR workflow (ci/workflows/pull_request.py:119) and its scope is derived from your changed files (ci/jobs/integration_test_job.py:970-977): touch a module, and that module gets run. It then runs --dist=each, meaning every xdist worker runs the whole module set concurrently with its own Docker cluster (:1282-1287). Your job log shows the result: pytest test_storage_hdfs/test.py test_storage_s3/test.py -n 3 --dist=each. test_storage_s3/test.py declares 11 instances, so -n 3 starts ~33 ClickHouse containers at once. Sizing is min(ncpu // 5, mem_gb // 20) with MAX_MEM_PER_WORKER_DIST_EACH = 20 (:46-53, :930); your log reports ncpu: 16, mem_gb: 61, giving 3 workers budgeting 60 GiB, while the container ceiling in your dmesg is limit 62679004kB = 59.78 GiB. It is a permanent overcommit, so the kernel kills whatever is running. That is why it looks consistent, and why the killed-at test moves around between runs (test_file_pruning_with_hive_style_partitioning_2, test_schema_inference_cache_multi_path, test_object_tags, ...): the module is the stable identifier, the test is not.

This is also why master is green. Master never runs this job at all: 60 days of CIDB has 159155 rows / 726 PRs and 0 non-PR runs. The regular integration jobs run --dist=loadfile with MAX_MEM_PER_WORKER = 11 (:47, :1292), one file per worker, and test_storage_s3/test.py has 0 failures there in 30 days on master (68351 OK on amd_tsan, 68523 on asan db-disk, 68175 on msan, 84133 on llvm_coverage).

On your second question, the honest answer. In 90 days, 9 PRs ran test_storage_s3/test.py in this job. They split cleanly by outcome, and the split is not about the PR's content:

PR shas that ran the module killed (exit 137) ordinary test failures
115277 (yours) 5 5 0
104431 4 4 0
109310 2 2 0
114054 1 1 0
91062, 104889, 106794, 106855, 108074 11 0 11

The five in the bottom row exited 1 with real assertion failures and their dmesg is 263 bytes with 0 CONSTRAINT_MEMCG lines. The four above exited 137 with 5-8 memcg kills each and identical ceilings (62679004, 62678996, 62678948 kB) - the same shape as yours, killing clickhouse, python3.13, pytest and dockerd. So: I can point at three other PRs killed while running exactly this module, but in none of them is test_storage_s3/test.py itself at fault, which I think is the substance of what you are asking.

The cleanest evidence that your diff is irrelevant is PR 104431, which already ran the natural experiment. Four consecutive shas edited test_storage_s3/test.py and all four were killed at exit 137. Then sha 6bee9b218, whose commit message is "Move the unpinned-read query-condition-cache test to its own module", moved its tests into test_storage_s3_query_condition_cache_unpinned/. Its flaky job then ran pytest test_storage_s3_query_condition_cache_unpinned/test.py instead, 3 passed, and it has been green on both shas since. Same PR, same author, same runner type, same job; the only change was whether test_storage_s3/test.py was in scope.

Why now, and the actual defect. --dist=each for this job landed in March (bb4e03d5e), and the per-worker budget was raised to 20 GiB in June (a5098b84c). The real bug is that Utils.physical_memory() reads host memory (61 GiB) while the job runs inside a container capped at 59.78 GiB, so the sizing math is against the wrong number. There is a mechanism for this - dist_each_sequential in ci/jobs/scripts/integration_tests_configs.py moves heavy modules to the sequential -n 1 phase - and test_storage_s3/test.py is simply not on the list, even though at 11 instances it is heavier than test_storage_delta/test.py (5) which is. I am tracking the containment fix in 112984; adding this module to dist_each_sequential would clear your PR specifically.

Nothing here needs a change from you, and I would not read that job as a signal about this PR.

Comment on lines +240 to +244
if (!is_create_query)
{
case FileLikeEngineDefaultPartitionStrategy::WILDCARD:
{
/// The path has no `{_partition_id}` placeholder (checked above), so
/// `PartitionStrategyFactory::get` will raise `BAD_ARGUMENTS`.
partition_strategy_type = PartitionStrategyFactory::StrategyType::WILDCARD;
break;
}
case FileLikeEngineDefaultPartitionStrategy::HIVE:
/// Backward compatibility on ATTACH / server startup / RESTORE / replicated-DDL replay:
/// derive the implicit strategy from the path rather than from the mutable default.
partition_strategy_type = PartitionStrategyFactory::StrategyType::HIVE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This still does not preserve the pre-26.6 behavior for existing plain-path tables. A 26.5 table like ENGINE = S3('.../root', 'Parquet') PARTITION BY d stored no explicit partition_strategy, so on reload it reaches this branch and is still forced to hive. That turns a previously ignored PARTITION BY into an active hive strategy and also flips the implicit partition_columns_in_data_file default to false.

New CREATEs are stable because this PR now persists partition_strategy = 'none', but pre-existing metadata never gets that marker. So the upgrade side of #114705 is still unresolved for the "393 plain-path tables" called out in the issue, even though the PR body closes it.

@clickhouse-gh

clickhouse-gh Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 39 queries analysed

no significant changes detected. K_source=6 K_base=12 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 2bebbb92-025a-4f92-940f-0dfe2262b196
  • MIRAI run: 249bcf6e-ae58-44f2-8d81-d4ee2856c153
  • PR check IDs:
    • clickbench_282294_1787635684
    • clickbench_282300_1787635684
    • clickbench_282307_1787635684
    • tpch_adapted_1_official_282327_1787635684
    • tpch_adapted_1_official_282336_1787635684
    • tpch_adapted_1_official_282365_1787635684

@fm4v
fm4v added this pull request to the merge queue Aug 26, 2026
Merged via the queue into master with commit 25364ca Aug 26, 2026
177 of 179 checks passed
@fm4v
fm4v deleted the ncb/fix-issue-114705 branch August 26, 2026 07:52
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 26, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 26, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 26, 2026
Backport #115277 to 26.8: fix loading old S3 tables with globbed paths
@clickgapai

Copy link
Copy Markdown
Contributor
Reproducer
-- 26.6 / 26.7: fails with Code: 36 BAD_ARGUMENTS
--   "Partition strategy hive can not be used with a globbed path"
-- 26.5 and older, and master after #115277: creates fine.
CREATE TABLE t (d Date, x UInt64)
ENGINE = S3('s3://bucket/test_04909/**.parquet', 'Parquet')
PARTITION BY d;

-- Same failure hits metadata load, so a table created before 26.6
-- aborts server startup after the upgrade.

Results:

  • Culprit PR: Make hive partition strategy a default under compatibility setting Make hive partition strategy a default under compatibility setting #86746
  • Reproduces on: 26.7, 26.6
  • Does not reproduce on: master, 26.5, 26.3, 25.8
  • Tested versions: master, 26.7, 26.6, 26.5, 26.3, 25.8
  • Also tested (unsupported, context only): 26.2 clean
  • ✓ Fix is on master — this PR's change fixes the bug on master. The releases listed above still have the bug and need the backport.

Backport the fix to 26.7, 26.6.

CC introducing PR author: @kssenii
CC introducing PR reviewer: @jkartseva @alexey-milovidov

CC component owner: @scanhex12 @divanik

Analysis metadata

comp-object-storage · Severity P2 · Finding phase_d_pr115277

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 5, 2026
Blargian pushed a commit to Blargian/ClickHouse that referenced this pull request Nov 3, 2026
… parser

Since ClickHouse#115277 the server persists an implicit `none` partition strategy of an
object storage table as a trailing `partition_strategy = 'none'` engine
argument, for S3 and Azure. The Azure readers of a positional argument list,
`AzureStorageParsedArguments::fromAST` and
`addStructureAndFormatToArgsIfNeededAzure`, evaluated every argument as a
constant expression, so that `equals` node failed with UNKNOWN_IDENTIFIER. An
AzureBlobStorage table created with PARTITION BY under
`file_like_engine_default_partition_strategy = 'wildcard'` (the default for
`compatibility` older than 26.6) could not be attached again, and the server
did not start.

Both readers now split off the trailing `identifier = value` arguments.
`fromAST` accepts `partition_strategy` and `partition_columns_in_data_file`
there, applies them like their positional forms and keeps the arguments in the
AST as written. Other keys, a key given both positionally and as a key-value
argument, and key-value arguments after fewer than three positional ones are
rejected. The key must be an identifier, so a positional constant such as
`1 = 1` keeps its meaning. `addStructureAndFormatToArgsIfNeededAzure`
completes the positional arguments and appends the key-value ones back.

The reading side is fixed because only it lets tables already written by 26.8
and 26.9 load again.

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

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3 table with a globbed path and PARTITION BY is rejected since 26.6, and pre-existing tables of that shape no longer load

9 participants