Skip to content

Revert "Support real hard links for plain_rewritable metadata." - #119276

Merged
alexey-milovidov merged 1 commit into
masterfrom
revert-110939-plain-rewritable-explicit-prefix-path
Sep 10, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
revert-110939-plain-rewritable-explicit-prefix-path

Conversation

@Algunenano

@Algunenano Algunenano commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Reverts #110939


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

Version info

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

@mintlify

mintlify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Sep 10, 2026, 4:24 PM

@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [79745e1]


AI Review

Summary

This PR reverts #110939 and removes the explicit plain_rewritable hard-link metadata path, but it also reintroduces two correctness regressions that were fixed in that PR independently of the feature work. In particular, an ordinary upgrade from the 2026-09-09 master revision that already wrote explicit metadata can no longer read that disk, and DROP TABLE on table_disk again leaves root-owned state behind. I do not think this rollback is safe to merge as-is.

Missing context / blind spots
  • ⚠️ The PR body only says it reverts #110939, so I could not validate whether a narrower rollback would address the motivating bug without dropping read compatibility for already-written metadata.
Findings

❌ Blockers

  • [src/Disks/DiskObjectStorage/MetadataStorages/PlainRewritable/MetadataStorageFromPlainRewritableObjectStorage.cpp:169-200] The revert stops understanding the explicit prefix.path layout that enable_hard_links already wrote after #110939 merged on 2026-09-09. On restart the loader now treats the whole metadata object as a path string and reconstructs blobs only as <directory_remote_path>/<filename>, so any directory that already used a real hard link becomes unreadable after upgrade.
    Suggested fix: keep read-compat for the explicit layout, or add a migration that rewrites those directories before removing the feature.
  • [src/Storages/StorageMergeTree.cpp:460-463] Removing the table_disk root cleanup reintroduces stale per-table state after DROP TABLE. Because table_disk keeps relative_data_path empty and removeRecursive("") is still a no-op for plain_rewritable, deduplication_logs/ and mutation_*.txt survive in the disk root and can affect the next table created on that disk.
    Suggested fix: keep the root cleanup or move it into dropAllData, and restore the deleted regression test.

⚠️ Majors

  • [src/Disks/DiskObjectStorage/MetadataStorages/PlainRewritable/MetadataStorageFromPlainRewritableObjectStorage.cpp:238] The revert also removes the guard that ignored a non-root prefix.path object with an empty logical path. LocalObjectStorage::writeObject still writes metadata objects directly to the final path, so a crash can leave a visible zero-byte prefix.path; this code will then overwrite the real root mapping with that random directory and send reads under / to the wrong place after restart.
    Suggested fix: keep ignoring non-root metadata objects whose contents are empty.
Tests
  • ⚠️ Please keep focused restart/attach coverage for a disk containing an explicit prefix.path, and keep a focused table_disk-drop regression test. CI stayed green after both behaviors regressed because the dedicated coverage disappeared with the full revert.
Final Verdict

Changes requested: the rollback backs out a risky feature, but it also drops upgrade compatibility and reopens the table_disk root-state bug.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 10, 2026
Comment on lines 169 to +200
@@ -217,28 +180,24 @@ void MetadataStorageFromPlainRewritableObjectStorage::load(bool is_initial_load,
}
}

/// In the implicit form, the files of the directory are the blobs stored under its prefix.
if (!has_explicit_file_list)
/// Load the list of files inside the directory.
for (auto dir_iterator = object_storage->iterate(layout->constructFilesDirectoryKey(remote_path.value()), 0, /*with_tags=*/ false, std::nullopt); dir_iterator->isValid(); dir_iterator->next())
{
for (auto dir_iterator = object_storage->iterate(layout->constructFilesDirectoryKey(remote_path.value()), 0, /*with_tags=*/ false, std::nullopt); dir_iterator->isValid(); dir_iterator->next())
const auto remote_file = dir_iterator->current();
const auto unpacked_remote_file_path = layout->parseFileObjectKey(remote_file->getPath());
if (!unpacked_remote_file_path.has_value())
{
const auto remote_file = dir_iterator->current();
const auto unpacked_remote_file_path = layout->parseFileObjectKey(remote_file->getPath());
if (!unpacked_remote_file_path.has_value())
{
LOG_WARNING(log, "Legacy layout is in use, ignoring '{}'", remote_file->getPath());
continue;
}

const auto & [directory_remote_path, filename] = unpacked_remote_file_path.value();
chassert(directory_remote_path == remote_path);

files.emplace(filename, FileRemoteInfo{
.bytes_size = remote_file->metadata->size_bytes,
.last_modified = remote_file->metadata->last_modified.epochTime(),
.blob_key = {},
});
LOG_WARNING(log, "Legacy layout is in use, ignoring '{}'", remote_file->getPath());
continue;
}

const auto & [directory_remote_path, filename] = unpacked_remote_file_path.value();
chassert(directory_remote_path == remote_path);

files.emplace(filename, FileRemoteInfo{
.bytes_size = remote_file->metadata->size_bytes,
.last_modified = remote_file->metadata->last_modified.epochTime(),
});

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 removes the explicit prefix.path reader entirely, but the feature was already merged on 2026-09-09 and disks can already contain that layout. A directory that ever used enable_hard_links = 1 now reloads the whole metadata object as its logical path here, and later getStorageObjectsIfExist reconstructs every blob as <directory_remote_path>/<filename> instead of using the stored cross-directory blob key. That makes an ordinary upgrade to this revert unable to read a plain_rewritable disk that already created a hard link.

If we need to stop creating new hard links, we still need read-compat for the explicit layout, or a migration that rewrites those directories first.


std::lock_guard guard(remote_layout_mutex);
remote_layout[local_path] = DirectoryRemoteInfo{remote_path.value(), metadata->etag, last_modified.epochTime(), std::move(files), has_explicit_file_list};
remote_layout[local_path] = DirectoryRemoteInfo{remote_path.value(), metadata->etag, last_modified.epochTime(), std::move(files)};

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.

The old guard for a non-root prefix.path object without a logical path is gone, but LocalObjectStorage::writeObject still writes directly to the final path unless an If-Match/If-None-Match flow is used. A crash during that write leaves a visible zero-byte metadata object; with this code, local_path stays empty and remote_layout[local_path] overwrites the real root mapping. On restart the root directory is hidden behind that random directory's prefix, so reads under / go to the wrong place again.

That bug is independent of hard links; we still need to ignore non-root metadata objects whose contents are empty.

Comment on lines -471 to -472
if ((*getSettings())[MergeTreeSetting::table_disk])
removeOwnFilesInDiskRootOnDrop();

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.

Dropping this special-case cleanup reintroduces the table_disk root-state bug. MergeTreeData::initializeDirectoriesAndFormatVersion leaves relative_data_path empty for table_disk, and MetadataStorageFromPlainObjectStorageRemoveRecursiveOperation::execute still turns removeRecursive("") into a no-op, so dropAllData() cannot remove state kept in the disk root. deduplication_logs/ and mutation_*.txt survive DROP TABLE, and the next table on the same disk can silently deduplicate new inserts or load stale mutation entries.

The deleted 05137_table_disk_drop_deduplication_log test was covering a real regression here, not the hard-link feature itself.

@alexey-milovidov
alexey-milovidov merged commit 2ade228 into master Sep 10, 2026
15 of 27 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-110939-plain-rewritable-explicit-prefix-path branch September 10, 2026 17:27
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... label Sep 10, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 10, 2026
@alexey-milovidov alexey-milovidov mentioned this pull request Sep 20, 2026
47 of 72 tasks

This branch was successfully deployed

1 active deployment
staging - docs — 79745e14 Deployed Sep 10, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-object-storage-disks Object-storage disk layer: DiskObjectStorage, metadata storage adapters, transaction support for ... pr-not-for-changelog This PR should not be mentioned in the changelog 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