Skip to content

Do not use fake tx for object storage disks - #89658

Merged
Michicosun merged 12 commits into
masterfrom
do_not_use_fake_tx
Jul 30, 2026
Merged

Michicosun merged 12 commits into
masterfrom
do_not_use_fake_tx

Conversation

@Michicosun

@Michicosun Michicosun commented Nov 6, 2025 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

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

This patch changes how object storage disk transactions work. Now, native to the metadata storage transactions will be used by default instead of the fake ones used before.

Version info

  • Merged into: 26.8.1.403 (included in 26.8 and later)

@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4aadfea]

Summary: ❌

job_name test_name status info comment
AST fuzzer (amd_debug, targeted, old_compatibility) FAIL
Logical error: Invalid number of columns in chunk pushed to OutputPort. Expected A, found B (STID: 2270-3452) FAIL cidb, issue
Integration tests (arm_binary, distributed plan, 2/4) FAIL
test_storage_s3_queue/test_system_stop.py::test_stopped_table_releases_hash_ring_slot FAIL cidb
test_storage_s3_queue/test_system_stop.py::test_refresh_survives_unready_dependencies FAIL cidb

AI Review

Summary

This PR removes FakeDiskTransaction from object_storage / encrypted disks and adds explicit part-storage commits across merge, mutation, insert, fetch, and lost-part recovery paths so the real transaction path works on object storage. The overall direction makes sense, but I do not think it is merge-ready: existing use_fake_transaction configs are still accepted as silent no-ops on upgrade, and the latest fix for the empty-part rollback deadlock still leaves the original self-deadlock reachable on the normal success path.

Findings

❌ Blockers

  • [src/Disks/DiskObjectStorage/RegisterDiskObjectStorage.cpp:77-87, src/Disks/DiskObjectStorage/DiskObjectStorage.cpp:73-75] [dismissed by author -- https://github.com/Do not use fake tx for object storage disks #89658#discussion_r3637233728] The object-storage creator still accepts arbitrary per-disk config keys, but DiskObjectStorage no longer reads use_fake_transaction at all. An upgraded server that still carries <use_fake_transaction>true|false</use_fake_transaction> keeps starting and silently switches from FakeDiskTransaction to DiskObjectStorageTransaction, which changes write visibility / rollback semantics with no startup error. Please either honor the key for a deprecation window or explicitly reject config_prefix + ".use_fake_transaction" so the migration is not silent.

  • [src/Disks/DiskEncrypted.cpp:528-542, src/Disks/DiskEncrypted.h:337-345] encrypted disks now always route createTransaction through DiskEncryptedTransaction, but the config path still accepts unknown per-disk keys. That gives the same silent-upgrade behavior for installations that still have <use_fake_transaction>true</use_fake_transaction> under an encrypted disk: startup succeeds, yet the disk silently switches transaction semantics. Please keep the old knob for a deprecation window or fail fast when the legacy key is present.

  • [src/Storages/MergeTree/MergeTreeData.cpp:6467-6477, src/Storages/MergeTree/MergeTreeData.cpp:9676-9689] The latest deadlock fix only covers the exception path. On success, rollback_tx_guard.reset() drops the borrowed-lock rollback, but transaction is still alive until the end of this block while the caller-owned lock is still held. ~MergeTreeData::Transaction then calls rollback() without that lock and reacquires lockParts(), so DROP/REPLACE PARTITION can still self-deadlock in exactly the same place. Keep the scope guard for failures, but still drain the transaction with transaction.rollback(&lock) (or an equivalent borrowed-lock path) before leaving the block.

Final Verdict

❌ Changes requested.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Nov 6, 2025
@clickhouse-gh

clickhouse-gh Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Dear @antonio2368, 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.

@clickhouse-gh clickhouse-gh Bot assigned antonio2368 and unassigned antonio2368 Jun 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Dear @antonio2368, 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.

@CheSema CheSema self-assigned this Jul 21, 2026
@CheSema

CheSema commented Jul 21, 2026

Copy link
Copy Markdown
Member

It is not Not for changelog for sure.
You here changes the internal logic how we work with disk. It should be not noticable but some thing could be different. It is better to mark as backward incompatible change to highlight it in the change log.

@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Jul 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

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

This PR reworks data-part commit/transaction semantics on the write, merge, and mutate paths (removing the fake-transaction shortcut and moving commits explicitly), and touches nothing in the SELECT read hot path. The only flagged query, ClickBench Q28, is a read-only SELECT showing a -5.6% shift where the two tests disagree and the underlying measurements were noisy (CV around 29%). That delta cannot plausibly come from this change and reads as run-to-run variance; the not_sure verdict is correct. No real performance signal here.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 28 not_sure 1082 1021 -5.6% 0.0007 Q28 is a read-only SELECT, but this PR only changes part-commit transaction handling on the insert/merge/mutate write paths. The -5.6% is run-to-run variance on noisy measurements, not a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 026b23a2-764a-4cf9-8948-8419791880c7
  • MIRAI run: 34ed4785-deec-4690-8315-bfefac824186
  • PR check IDs:
    • clickbench_860146_1785354099
    • clickbench_860276_1785354192
    • clickbench_860403_1785354235
    • tpch_adapted_1_official_860631_1785354362
    • tpch_adapted_1_official_860732_1785354366
    • tpch_adapted_1_official_860862_1785354435

}();

part_storage_for_loading->beginTransaction();
if (!to_remote_disk)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Pure mechanical change: with to_remote_disk=1 this method will write to disk, bypassing the data part storage.

Comment thread src/Disks/DiskEncrypted.h

/// Need to overwrite explicetly because this disk change
/// a lot of "delegate" methods.
return createEncryptedTransaction();

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.

Removing the last use_fake_transaction branch here gives encrypted disks the same silent-upgrade problem as object_storage: registerDiskEncrypted still builds the disk from the raw config and does not reject unknown per-disk keys, so an installation that keeps <use_fake_transaction>true</use_fake_transaction> will still start but will now switch from FakeDiskTransaction to the real DiskEncryptedTransaction path with no startup error. That changes part-write visibility and rollback semantics on upgrade. Please either keep honoring the setting for a deprecation window, or explicitly fail when config.has(config_prefix + ".use_fake_transaction") so the migration is not silent.

@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.40% +0.10%
Functions 92.10% 92.10% +0.00%
Branches 78.40% 78.50% +0.10%

Changed lines: Changed C/C++ lines covered: 122/125 (97.60%) · Uncovered code

Full report · Diff report

@Michicosun
Michicosun added this pull request to the merge queue Jul 30, 2026
Merged via the queue into master with commit 890ce3f Jul 30, 2026
176 of 179 checks passed
@Michicosun
Michicosun deleted the do_not_use_fake_tx branch July 30, 2026 08:30
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 30, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @Michicosun @antonio2368 @CheSema — a couple of suggestions to make this PR easier for reviewers and the changelog reader.

Description (currently incomplete):

  • Why: The description is essentially just the changelog entry; it does not mention that the use_fake_transaction config option is removed, nor list the many part-commit call sites that now must commit explicitly, nor how the zero-copy (to_remote_disk) fetch path is handled.

  • Suggested addition:

    Note that the use_fake_transaction disk configuration key is removed (silently ignored on upgrade). All MergeTree part-producing paths (insert sinks, merge tasks, mutate tasks, fetch, empty-lost-part creation) now explicitly commit the DataPartStorage transaction; DataPartsExchange::downloadPartToDisk skips beginning a transaction for zero-copy (to_remote_disk) fetches and guards commits with hasActiveTransaction().

Ignore this if the current title/body is intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes 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