Skip to content

Allow disks with empty folder while changing storage policy - #107736

Merged
alexey-milovidov merged 58 commits into
ClickHouse:masterfrom
UberDever:uberdever/feature/storage-policy-empty-disk
Sep 7, 2026
Merged

alexey-milovidov merged 58 commits into
ClickHouse:masterfrom
UberDever:uberdever/feature/storage-policy-empty-disk

Conversation

@UberDever

@UberDever UberDever commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

Allow ALTER TABLE ... MODIFY SETTING storage_policy for MergeTree tables when newly added disks contain only a matching format_version.txt and an empty detached/ directory under the table path.


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

Version info

  • Merged into: 26.9.1.912 (included in 26.9 and later)

@Ergus Ergus self-assigned this Jun 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [704b9e9]

Summary: ✅


AI Review

Summary

This PR makes ALTER TABLE ... MODIFY SETTING storage_policy accept a newly added disk only when the table path is otherwise empty except for a matching format_version.txt and an empty detached/. The live ALTER path is much safer now, but I still cannot approve it because the same disk-ownership invariant is still bypassed when a policy gains a disk through config reload.

Findings

❌ Blockers

  • [src/Storages/MergeTree/MergeTreeData.cpp:6504] [dismissed by author -- https://github.com/Allow disks with empty folder while changing storage policy #107736#discussion_r3511122120] The FIXME added here only documents the gap; the code still leaves it open. Context::updateStorageConfiguration publishes the widened selector before any table-level validation (src/Interpreters/Context.cpp:7464-7477), DatabaseCatalog::reloadDisksTask runs later and only logs failures (src/Interpreters/DatabaseCatalog.cpp:2221-2229), and initializeDiskOnConfigChange still just creates detached/ plus rewrites format_version.txt without checking existing contents (src/Storages/MergeTree/MergeTreeData.cpp:13760-13776). A stale all_0_0_0 or detached/all_0_0_0 on the new disk can therefore still be claimed after SYSTEM RELOAD CONFIG, then loaded on restart or deleted on DROP TABLE, so the ownership contract is only fixed on one entrypoint.
    Suggested fix: validate newly added disks before the new selector becomes visible, or make disk initialization synchronous and fail-closed so a bad disk aborts the config change instead of logging a warning after the selector is already live.
Tests
  • ⚠️ Add a focused config-reload regression: extend an existing policy with a pre-populated disk (one root part case and one detached/ part case are enough), run SYSTEM RELOAD CONFIG, and prove the reload rejects or defers the new selector until validation succeeds.
Final Verdict

❌ Changes requested. The ALTER path is fixed, but the same stale-data ownership hole remains on config reload.

LLVM Coverage Report

Measured on commit 704b9e9.

Metric Baseline Current Δ
Lines 88.80% 88.80% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.20% 81.10% -0.10%

Changed lines: Changed C/C++ lines covered: 66/67 (98.51%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 17, 2026

@Ergus Ergus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

initializeDiskOnConfigChange writes on format_version.txt and creates an empty detached on newly added disks during config reload.

A disk left in that state (format_version present, no parts) is emptyu of table data, but with this change a subsequent ALTER|MODIFY SETTING storage_policy onto it will throw a LOGICAL_ERROR, because the iteration hits format_version.txt (name not detached) and sets contains_table_data = true.

Maybe we should better mirror the established skip-list and ideally only flag entries that parse as real parts

@UberDever
UberDever requested a review from Ergus June 18, 2026 09:16
@UberDever

Copy link
Copy Markdown
Contributor Author

@Ergus Could you please add can_be_tested?

@Ergus Ergus added the can be tested Allows running workflows for external contributors label Jun 18, 2026
missing table dir: OK
format_version.txt: OK only if absent or matches current table format; bad/mismatch throws CORRUPTED_DATA
root tmp*: ignored, same as part loading
detached: OK only if empty or contains no parseable detached parts
root parseable part name: table data, reject
@UberDever
UberDever force-pushed the uberdever/feature/storage-policy-empty-disk branch from bcaa361 to a7fa6a7 Compare June 29, 2026 11:40
@UberDever

Copy link
Copy Markdown
Contributor Author

@Ergus Kindly ping

@Ergus Ergus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIS git log shows that delete_tmp_-related cleanup has been touched before (fe57210 "fix old tmp dirs cleanup"), so the exclusion from the periodic default may not have been accidental. Poterntial side effects of this change we could be missing?

Also, please update the changelog cause it doesn't describe the current implementation anymore. (the guard now also tolerates a matching format_version.txt, root temporary directories, and a detached folder containing non-part entries)

@Ergus

Ergus commented Jul 1, 2026

Copy link
Copy Markdown
Member

Hi @UberDever

Thanks for waiting...
Please merge master and push to trigger the CI again. The errors are apparently not related, but we cannot merge without a green CI

@Ergus Ergus left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking deeper into this:

getRootTemporaryDirectoryPrefixes() silently changes the two periodic cleanup callers that use the default (MergeTreeCleanupThread.cpp and ReplicatedMergeTreeCleanupThread.cpp): they never touched delete_tmp_. This is unrelated to the storage-policy change and isn't in the description/changelog.

FWIS startup/dropAllData/attach clean delete_tmp_ (where no concurrent removal runs); the threads excluded it precisely because they run alongside live remove(). None of the guards protects a delete_tmp_

  • temporary_parts never registers those names
  • isOldPartDirectory uses mtime which rename preserves

So a part older than temporary_directories_lifetime looks "old" the instant it's renamed.

On local disks this race is benign, but in zero-copy it can orphan blobs. Suppose that a remove drops the ZK ref via unlockSharedData before the move; if cleanup wins, local metadata could be deleted (because the cleanup path always uses keep_shared=true) blobs are kept but remove() then hits ENOENT with no ref left to reclaim them.

Does it makes sense to keep the periodic default as {"tmp_", "tmp-fetch_"} and pass the 3-prefix set explicitly only where the PR needs it (startup/drop already do). Else if the broadening is intended, please confirm that the zero-copy case can't leak.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged the latest master (clean, no conflicts) — merge commit c895bf71d13; the three changed translation units (MergeTreeData.cpp, StorageMergeTree.cpp, ReplicatedMergeTreeAttachThread.cpp) compile locally.

The only red at 94bd29ea — Stress test (arm_tsan), logical error assertTypeEquality in buildAdditionalFilter (HashJoinMethodsImpl.h:807) — is unrelated to this change: it is the known mixed-JOIN-ON-over-dictionary issue with the fix in progress in #113534. It can recur until that PR merges.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 CI status at c895bf71: all reds are unrelated to this change, each with a known cause and a fix already in flight:

No new review feedback; the three older inline threads remain addressed by the earlier revert/refactor. The reds should clear once the linked fixes merge. Nothing to change in this PR — waiting on green CI and a human merge decision.

@clickhouse-gh

clickhouse-gh Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

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

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

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

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Dear @Ergus, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

…torage-policy-empty-disk

# Conflicts:
#	ci/defs/job_configs.py
#	ci/jobs/check_style.py
#	ci/jobs/copilot_review_job.py
#	ci/jobs/scripts/find_tests.py
#	ci/jobs/scripts/functional_tests_results.py
#	ci/jobs/scripts/fuzzer/query-fuzzer-tweaks-users.xml
#	ci/jobs/scripts/generate_diff_coverage_report.sh
#	ci/jobs/sqlancer_job.sh
#	ci/praktika/cidb.py
#	ci/praktika/json.html
#	ci/tests/test_functional_tests_results.py
#	ci/workflows/pull_request.py
#	contrib/NuRaft
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParser.cpp
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParser.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParser.interp
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserBaseListener.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserBaseVisitor.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserListener.h
#	contrib/antlr4-grammars-cmake/generated/antlr4_grammars/PromQLParserVisitor.h
#	contrib/aws-c-http
#	contrib/chdig
#	contrib/llvm-project
#	contrib/rust_vendor
#	docker/keeper/Dockerfile
#	docker/server/Dockerfile.alpine
#	programs/client/Client.h
#	rust/workspace/Cargo.lock
#	src/AggregateFunctions/AggregateFunctionSequenceMatch.cpp
#	src/AggregateFunctions/TimeSeries/AggregateFunctionLast2Samples.h
#	src/AggregateFunctions/TimeSeries/AggregateFunctionTimeSeriesGroupArray.cpp
#	src/Analyzer/Passes/CrossToInnerJoinPass.cpp
#	src/Analyzer/Passes/GroupingFunctionsResolvePass.cpp
#	src/Backups/BackupFactory.h
#	src/Backups/BackupImpl.h
#	src/Backups/BackupSettings.cpp
#	src/Backups/BackupSettings.h
#	src/Backups/IBackup.h
#	src/Client/BuzzHouse/AST/SQLProtoStr.cpp
#	src/Client/BuzzHouse/Generator/RandomGenerator.cpp
#	src/Client/BuzzHouse/Generator/RandomGenerator.h
#	src/Client/ClientBase.h
#	src/Client/Suggest.h
#	src/Columns/IColumnUnique.h
#	src/Common/ColumnsHashing.h
#	src/Common/ColumnsHashingImpl.h
#	src/Common/Fiber.h
#	src/Common/OpenTelemetryTraceContext.cpp
#	src/Common/PoolBase.h
#	src/Common/ThreadStatus.h
#	src/Compression/CompressionFactory.h
#	src/Coordination/KeeperSnapshotManager.cpp
#	src/Coordination/KeeperStateMachine.h
#	src/Coordination/tests/gtest_coordination_snapshot.cpp
#	src/Core/PostgreSQL/PoolWithFailover.cpp
#	src/Core/PostgreSQLProtocol.h
#	src/DataTypes/DataTypeAggregateFunction.h
#	src/DataTypes/DataTypeTuple.cpp
#	src/DataTypes/Serializations/SerializationJSON.cpp
#	src/DataTypes/Serializations/SerializationString.cpp
#	src/Databases/DataLake/PaimonRestCatalog.cpp
#	src/Databases/MySQL/DatabaseMySQL.cpp
#	src/Disks/DiskObjectStorage/DiskObjectStorage.cpp
#	src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp
#	src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.h
#	src/Disks/DiskObjectStorage/MetadataStorages/Cache/MetadataStorageFromCacheObjectStorage.cpp
#	src/Disks/DiskObjectStorage/MetadataStorages/IMetadataStorage.h
#	src/Disks/DiskObjectStorage/MetadataStorages/Local/MetadataStorageFromDisk.h
#	src/Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage/AzureBlobStorageCommon.cpp
#	src/Disks/DiskObjectStorage/ObjectStorages/IObjectStorage.h
#	src/Formats/NativeWriter.cpp
#	src/Functions/CastOverloadResolver.cpp
#	src/Functions/FunctionFQDN.cpp
#	src/Functions/FunctionShowCertificate.cpp
#	src/Functions/FunctionStringOrArrayToT.h
#	src/Functions/FunctionsConversion.h
#	src/Functions/FunctionsJSON.cpp
#	src/Functions/FunctionsStringDistance.cpp
#	src/Functions/FunctionsTransactionCounters.cpp
#	src/Functions/TimeSeries/timeSeriesThrowDuplicateSeriesIf.cpp
#	src/Functions/UTCTimestampTransform.cpp
#	src/Functions/aiEmbed.cpp
#	src/Functions/array/arrayJoin.cpp
#	src/Functions/castOrDefault.cpp
#	src/Functions/filesystem.cpp
#	src/Functions/formatRow.cpp
#	src/Functions/match.cpp
#	src/Functions/queryID.cpp
#	src/Functions/rand.cpp
#	src/Functions/rand64.cpp
#	src/IO/ReadBufferFromFileDescriptor.cpp
#	src/IO/S3/Client.cpp
#	src/IO/S3/PocoHTTPClient.cpp
#	src/Interpreters/Access/InterpreterShowCreateAccessEntityQuery.cpp
#	src/Interpreters/AggregatedData.h
#	src/Interpreters/AggregationMethod.h
#	src/Interpreters/AsynchronousMetricLog.cpp
#	src/Interpreters/CancellationChecker.cpp
#	src/Interpreters/ClusterFunctionReadTask.h
#	src/Interpreters/ContextTimeSeriesTagsCollector.cpp
#	src/Interpreters/HashJoin/KeyGetter.h
#	src/Interpreters/InterpreterHypotheticalIndexQuery.cpp
#	src/Interpreters/MetricLog.cpp
#	src/Interpreters/ProcessList.cpp
#	src/Interpreters/SpillingHashJoin.cpp
#	src/Interpreters/SpillingHashJoin.h
#	src/Parsers/Access/ParserCreateQuotaQuery.cpp
#	src/Parsers/Access/ParserCreateUserQuery.cpp
#	src/Parsers/ExpressionElementParsers.cpp
#	src/Parsers/ExpressionListParsers.cpp
#	src/Parsers/Kusto/ParserKQLOperators.cpp
#	src/Parsers/Lexer.cpp
#	src/Parsers/ParserAlterQuery.cpp
#	src/Parsers/ParserCreateFunctionQuery.cpp
#	src/Parsers/ParserCreateQuery.cpp
#	src/Parsers/ParserExplainQuery.cpp
#	src/Parsers/ParserInsertQuery.cpp
#	src/Parsers/ParserOptimizeQuery.cpp
#	src/Parsers/ParserQueryWithOutput.cpp
#	src/Parsers/ParserSelectQuery.cpp
#	src/Parsers/ParserSelectWithUnionQuery.cpp
#	src/Parsers/ParserSetQuery.cpp
#	src/Parsers/ParserSystemQuery.cpp
#	src/Parsers/ParserTablesInSelectQuery.cpp
#	src/Processors/Executors/PipelineExecutor.cpp
#	src/Processors/Formats/Impl/MsgPackRowInputFormat.cpp
#	src/Processors/Formats/Impl/NativeORCBlockInputFormat.h
#	src/Processors/Formats/Impl/Parquet/Decoding.h
#	src/Processors/Formats/Impl/ProtobufListInputFormat.cpp
#	src/Processors/IProcessor.h
#	src/Processors/QueryPlan/AggregatingStep.cpp
#	src/Processors/QueryPlan/ArrayJoinStep.cpp
#	src/Processors/QueryPlan/ArrayJoinStep.h
#	src/Processors/QueryPlan/CreatingSetsStep.cpp
#	src/Processors/QueryPlan/CreatingSetsStep.h
#	src/Processors/QueryPlan/CubeStep.cpp
#	src/Processors/QueryPlan/ExpressionStep.cpp
#	src/Processors/QueryPlan/Optimizations/optimizeLazyMaterialization.cpp
#	src/Processors/QueryPlan/Optimizations/optimizeReadInOrder.h
#	src/Processors/QueryPlan/Optimizations/topKThroughJoin.cpp
#	src/Processors/QueryPlan/Optimizations/useVectorSearch.cpp
#	src/Processors/QueryPlan/PartsSplitter.cpp
#	src/Processors/QueryPlan/RollupStep.cpp
#	src/Processors/Sources/ShellCommandSource.cpp
#	src/Processors/Transforms/DistinctTransform.cpp
#	src/Processors/Transforms/FilterTransform.h
#	src/Processors/tests/gtest_update_pipeline.cpp
#	src/QueryPipeline/BlockIO.h
#	src/QueryPipeline/QueryPipelineBuilder.h
#	src/QueryPipeline/RemoteQueryExecutorReadContext.cpp
#	src/Server/DistributedQuery/StreamingExchangeSource.cpp
#	src/Server/HTTPHandlerFactory.h
#	src/Server/TCPHandler.h
#	src/Storages/KVStorageUtils.cpp
#	src/Storages/MergeTree/LoadedMergeTreeDataPartInfoForReader.h
#	src/Storages/MergeTree/MergeTask.h
#	src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp
#	src/Storages/MergeTree/MergeTreeDataWriter.h
#	src/Storages/MergeTree/MergeTreeIndexMinMax.h
#	src/Storages/MergeTree/MergeTreeIndexReader.cpp
#	src/Storages/MergeTree/MergeTreeIndicesSerialization.h
#	src/Storages/MergeTree/ReplicatedMergeTreeAttachThread.cpp
#	src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp
#	src/Storages/MergeTree/Streaming/CursorUtils.cpp
#	src/Storages/MergeTree/Streaming/CursorUtils.h
#	src/Storages/MergeTree/Streaming/MergeTreeBoundsSubscription.cpp
#	src/Storages/MergeTree/Streaming/MergeTreeBoundsSubscription.h
#	src/Storages/MergeTree/Streaming/MergeTreeCommitOrderSequentialSource.cpp
#	src/Storages/MergeTree/Streaming/MergeTreeCommitOrderSequentialSource.h
#	src/Storages/MergeTree/Streaming/StreamingChunkCursor.cpp
#	src/Storages/MergeTree/Streaming/StreamingChunkCursor.h
#	src/Storages/MergeTree/Streaming/SubscriptionEnrichment.cpp
#	src/Storages/MergeTree/Streaming/SubscriptionEnrichment.h
#	src/Storages/MergeTree/Streaming/tests/gtest_bounds_subscription.cpp
#	src/Storages/MergeTree/TextIndexUtils.h
#	src/Storages/MergeTree/WhatIfIndexEstimator.cpp
#	src/Storages/NATS/NATS_fwd.h
#	src/Storages/ObjectStorage/DataLakes/DataLakeStorageSettings.cpp
#	src/Storages/ObjectStorage/DataLakes/DataLakeStorageSettings.h
#	src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.h
#	src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp
#	src/Storages/ObjectStorage/IObjectIterator.h
#	src/Storages/ObjectStorage/StorageObjectStorage.h
#	src/Storages/ObjectStorage/StorageObjectStorageConfiguration.h
#	src/Storages/ObjectStorage/StorageObjectStorageSink.cpp
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueMetadata.cpp
#	src/Storages/PostgreSQL/MaterializedPostgreSQLConsumer.cpp
#	src/Storages/Statistics/tests/gtest_stats.cpp
#	src/Storages/StorageAlias.h
#	src/Storages/StorageMemory.h
#	src/Storages/StorageMerge.cpp
#	src/Storages/StorageMergeTreeTextIndex.cpp
#	src/Storages/StorageStripeLog.cpp
#	src/Storages/StorageTimeSeries.cpp
#	src/Storages/System/StorageSystemMutations.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/NodeEvaluationRangeGetter.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorAnd.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorOr.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applyBinaryOperatorUnless.cpp
#	src/Storages/TimeSeries/PrometheusQueryToSQL/applySimpleBinaryOperator.cpp
#	src/Storages/WindowView/StorageWindowView.cpp
#	tests/clickhouse-test
#	tests/integration/test_ai_functions/test.py
#	tests/integration/test_broken_projections/test.py
#	tests/integration/test_keeper_snapshot_chunked_transfer/test.py
#	tests/integration/test_prometheus_protocols/test_insert_select.py
#	tests/integration/test_replicated_users/test.py
#	tests/integration/test_storage_azure_blob_storage/test.py
#	tests/integration/test_storage_rabbitmq/test.py
#	tests/integration/test_storage_s3_queue/test_0.py
#	tests/integration/test_text_index_upgrade/test.py
#	tests/performance/README.md
#	tests/performance/scripts/README.md
#	tests/queries/0_stateless/00808_not_optimize_predicate.reference
#	tests/queries/0_stateless/00940_order_by_read_in_order_query_plan.reference
#	tests/queries/0_stateless/01396_inactive_replica_cleanup_nodes_zookeeper.sh
#	tests/queries/0_stateless/01414_push_predicate_when_contains_with_clause.reference
#	tests/queries/0_stateless/01471_with_format.oldanalyzer.reference
#	tests/queries/0_stateless/01471_with_format.reference
#	tests/queries/0_stateless/01495_subqueries_in_with_statement_4.oldanalyzer.reference
#	tests/queries/0_stateless/01495_subqueries_in_with_statement_4.reference
#	tests/queries/0_stateless/01515_with_global_and_with_propagation.reference
#	tests/queries/0_stateless/01582_move_to_prewhere_compact_parts.sql
#	tests/queries/0_stateless/01625_constraints_index_append.reference
#	tests/queries/0_stateless/01852_cast_operator_4.reference
#	tests/queries/0_stateless/02000_join_on_const.sql
#	tests/queries/0_stateless/02004_intersect_except_distinct_operators.oldanalyzer.reference
#	tests/queries/0_stateless/02004_intersect_except_operators.oldanalyzer.reference
#	tests/queries/0_stateless/02117_show_create_table_system.reference
#	tests/queries/0_stateless/02165_insert_from_infile.reference
#	tests/queries/0_stateless/02226_analyzer_or_like_combine.oldanalyzer.reference
#	tests/queries/0_stateless/02226_analyzer_or_like_combine.reference
#	tests/queries/0_stateless/02253_empty_part_checksums.sh
#	tests/queries/0_stateless/02346_text_index_direct_read.sql
#	tests/queries/0_stateless/02346_text_index_tokenizer_partially_materialized.sql
#	tests/queries/0_stateless/02377_executable_function_settings.sql
#	tests/queries/0_stateless/02428_parameterized_view.sh
#	tests/queries/0_stateless/02477_invalid_reads.sql
#	tests/queries/0_stateless/02496_remove_redundant_sorting.sh
#	tests/queries/0_stateless/02500_remove_redundant_distinct.reference
#	tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.reference
#	tests/queries/0_stateless/02500_remove_redundant_distinct_analyzer.sh
#	tests/queries/0_stateless/02516_join_with_totals_and_subquery_bug.reference
#	tests/queries/0_stateless/02800_clickhouse_local_default_settings.reference
#	tests/queries/0_stateless/02864_statistics_ddl.sql
#	tests/queries/0_stateless/02931_rewrite_sum_column_and_constant.reference
#	tests/queries/0_stateless/03001_matview_columns_after_modify_query.sh
#	tests/queries/0_stateless/03381_query_result_cache_old_analyzer.sql
#	tests/queries/0_stateless/03393_non_constant_second_argument_for_in.reference
#	tests/queries/0_stateless/03393_non_constant_second_argument_for_in.sql
#	tests/queries/0_stateless/03560_parallel_replicas_memory_bound_merging_projection.reference
#	tests/queries/0_stateless/03594_like_perfect_affix_rewrite_pass.reference
#	tests/queries/0_stateless/03601_inconsistent_table_names.reference
#	tests/queries/0_stateless/03628_subcolumns_of_columns_with_dot_in_name.sql
#	tests/queries/0_stateless/03701_optimize_inverse_dictionary_lookup_basic.reference
#	tests/queries/0_stateless/03702_optimize_inverse_dictionary_lookup_composite_and_layouts.reference
#	tests/queries/0_stateless/03703_optimize_inverse_dictionary_lookup_dictget_family.reference
#	tests/queries/0_stateless/03707_analyzer_convert_outer_any_to_inner.reference
#	tests/queries/0_stateless/03724_filter_assume_not_null_materialize.sql
#	tests/queries/0_stateless/03773_deterministic_functions_key_condition_explain.reference
#	tests/queries/0_stateless/03773_join_on_formatting.reference
#	tests/queries/0_stateless/03779_time_series_tags_functions.reference
#	tests/queries/0_stateless/03779_time_series_tags_functions.sql
#	tests/queries/0_stateless/03988_setting_use_partition_pruning.sql
#	tests/queries/0_stateless/04019_pipeline_stuck_sort_overflow.sql
#	tests/queries/0_stateless/04033_except_transformer_with_alias.sql
#	tests/queries/0_stateless/04093_text_index_separate_analysis.sql
#	tests/queries/0_stateless/04098_row_policy_disjunction_optimization.reference
#	tests/queries/0_stateless/04098_row_policy_disjunction_optimization.sql
#	tests/queries/0_stateless/04105_explain_syntax_parameterized_view.sql
#	tests/queries/0_stateless/04105_view_positional_args_via_local_plan.sh
#	tests/queries/0_stateless/04201_inverse_dictionary_lookup_edge_cases.reference
#	tests/queries/0_stateless/04207_pr_additional_filters.reference
#	tests/queries/0_stateless/04207_pr_additional_filters.sql
#	tests/queries/0_stateless/04209_statistics_retry_load.reference
#	tests/queries/0_stateless/04209_top_k_through_join_read_in_order_gate.reference
#	tests/queries/0_stateless/04209_top_k_through_join_read_in_order_gate.sql
#	tests/queries/0_stateless/04234_top_k_through_join_final_desc_gate.sql
#	tests/queries/0_stateless/04280_udf_normalizer_dangling_source_columns.sql
#	tests/queries/0_stateless/04308_distributed_totals_rollup_cube_not_distributed.sql
#	tests/queries/0_stateless/04320_distributed_plan_read_rejects.sql
#	tests/queries/0_stateless/04323_text_index_marks_empty_part.sh
#	tests/queries/0_stateless/04335_low_cardinality_mixed_key_join.sql
#	tests/queries/0_stateless/04338_analyzer_unknown_table_cross_database_hint.reference
#	tests/queries/0_stateless/04338_analyzer_unknown_table_cross_database_hint.sh
#	utils/list-versions/version_date.tsv
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged the latest master into the branch — merge commit be647092cf72 (new head).

This was a criss-cross merge (two merge bases), so git merge reported ~286 conflicts although the pull request only touches 6 files. Resolution was purely mechanical: every conflicted path outside the pull request's own file set was taken from master verbatim (including the contrib submodule gitlinks), and the single overlapping file, ReplicatedMergeTreeAttachThread.cpp, was re-merged against the real (newest) base with no conflicts. Verified invariant: git diff --cached origin/master --numstat is byte-identical to the pre-merge diff of the branch against its base — i.e. the result is exactly master plus this pull request's change (6 files). The three changed translation units (MergeTreeData.cpp, StorageMergeTree.cpp, ReplicatedMergeTreeAttachThread.cpp) compile locally.

CI status at the previous head d441c5ce: the only red was Stress test (amd_debug) — logical error Equal values are not contiguous within the range assumed to be sorted (STID: 2508-36d8), inside DistinctSortedStreamTransform / getEqualRangeEndAssumeSorted. That is a known DISTINCT-in-order problem unrelated to storage policies, tracked in #115455 (#115831 was closed as a duplicate of it).

The AI Review verdict is ✅ Approve and there are no unresolved review threads. @Ergus, could you take another look — your last comment (2026-07-08, "looking almost ready") asked for three tests, which the author added.

@abashkeev abashkeev added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged the latest master into the branch (clean, single merge base, no conflicts) — merge commit 704b9e9d1e46. The diff against master is still exactly the PR's own 6 files, and the three changed translation units (MergeTreeData.cpp, ReplicatedMergeTreeAttachThread.cpp, StorageMergeTree.cpp) compile. A new CI run is in progress.

Both reds at c4de425e were unrelated to this change:

  • Stateless tests (arm_binary, parallel): 05055_format_schema_source_query_background_access failed with CANNOT_PARSE_PROTOBUF_SCHEMA: File not found (all 14 reruns passed; it also failed on master the same day). Root cause is 03326_protobuf_schemas_race, which runs a bare SYSTEM CLEAR FORMAT SCHEMA CACHE in a loop and deletes the shared on-disk __cache__ files of parallel tests. Fix: Clear only the Protobuf cache in 03326_protobuf_schemas_race #118391
  • CH Inc sync: five private-only stateless failures (00910_zookeeper_test_alter_compression_codecs_long keeper transaction conflict on CREATE TABLE ... SharedMergeTree, 04669/04238/01900 600 s timeouts under MSan + distributed cache, 04365_cancel_insert_when_client_dies_distributed result mismatch). None touch storage policies or temporary-directory cleanup; 04238 is already tracked in the private repository.

No unresolved review threads. Still waiting on a human re-review and merge.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status at head 704b9e9d: the public PR workflow is fully green (including Code Review, Stress and perf jobs), the PR is MERGEABLE, and there are no unresolved review threads. The only red is CH Inc sync (private sync PR #61416), whose 6 failed jobs are all private-only and unrelated to this change (the PR only touches ALTER ... MODIFY SETTING storage_policy disk validation and the root temporary-directory prefix constants):

Reran only the failed private jobs (gh run rerun --failed, run 34022908140 attempt 2). Nothing to push; waiting on the sync rerun and a human re-review/merge.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 7, 2026
Merged via the queue into ClickHouse:master with commit 525bcb1 Sep 7, 2026
175 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 7, 2026
alexey-milovidov added a commit that referenced this pull request Sep 7, 2026
Three conflicts, all from #107736 (`storage-policy-empty-disk`), which replaced
the ad-hoc temporary-directory prefix lists of `clearOldTemporaryDirectories`
with two named constants and changed the parameter from `const NameSet &` to
`std::span<const std::string_view>`.

- `MergeTreeData.h`: keep this branch's `canRunDestructiveCleanup` next to
  `master`'s `ROOT_TEMPORARY_DIRECTORY_PREFIXES_FOR_BACKGROUND_CLEANUP` /
  `ROOT_TEMPORARY_DIRECTORY_PREFIXES_FOR_RECOVERY`; both sides added text at the
  same place for unrelated reasons.
- `StorageMergeTree::startup`: keep the `if (!leader_election)` guard around the
  startup cleanup - a follower must not delete the leader's temporary
  directories - with `master`'s call spelling
  (`ROOT_TEMPORARY_DIRECTORY_PREFIXES_FOR_RECOVERY`) and its updated `NOTE`.
- `MergeTreeData.cpp`: both sides added `#include <IO/ReadHelpers.h>`; keep this
  branch's `#include <IO/ReadSettings.h>` as well.

`MergeTreeCleanupThread` merged without a conflict but not correctly: its
`leader_election` branch still passed a braced list to what is now a
`std::span` parameter, which no longer compiles. It uses
`MergeTreeData::ROOT_TEMPORARY_DIRECTORY_PREFIXES_FOR_RECOVERY` now, the same
`{"tmp_", "delete_tmp_", "tmp-fetch_"}` set it spelled out before, so the
periodic sweep under `leader_election` still covers `delete_tmp_` and tables
without the setting keep the background-cleanup prefixes.

No submodule gitlink drift, 75 changed files against `master` (the same set as
before the merge), and the per-file counts of every leader-election marker are
identical before and after the merge.
pull Bot pushed a commit to TCeason/ClickHouse that referenced this pull request Sep 11, 2026
The test ran a bare `SYSTEM CLEAR FORMAT SCHEMA CACHE` a hundred times in a loop. Besides the in-memory Protobuf cache it also deletes every file of the on-disk `__cache__` directory under `format_schema_path`, which is shared by all tests of a parallel run. Any test relying on the cached schema of `format_schema_source = 'string'` or `'query'` that happened to run at the same time then failed with `CANNOT_PARSE_PROTOBUF_SCHEMA: File not found`, as `05055_format_schema_source_query_background_access` did in https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=107736&sha=c4de425e719ad1057d0da677efffe2fbd84a71b8&name_0=PR&name_1=Stateless%20tests%20(arm_binary,%20parallel) (ClickHouse#107736): the server log shows the schema stored at 08:31:14.867 and the `SELECT` failing at 08:31:15 while `03326` was clearing the cache every 0.27 s.

The schema of `03326` is a plain file in its own directory, not an entry of `__cache__`, so the race it exercises is the one with the in-memory `ProtobufSchemas` cache only. Use `SYSTEM CLEAR FORMAT SCHEMA CACHE FOR Protobuf`.

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

Labels

can be tested Allows running workflows for external contributors comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. pr-improvement Pull request with some product improvements 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.

5 participants