Skip to content

Fix broken part error while restoring to s3_plain_rewritable#66881

Merged
vitlibar merged 6 commits intoClickHouse:masterfrom
vitlibar:fix-broken-part-error-while-restoring-to-s3-plain-rewritable
Jul 25, 2024
Merged

Fix broken part error while restoring to s3_plain_rewritable#66881
vitlibar merged 6 commits intoClickHouse:masterfrom
vitlibar:fix-broken-part-error-while-restoring-to-s3-plain-rewritable

Conversation

@vitlibar
Copy link
Copy Markdown
Member

Changelog category:

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

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

Fix broken part error while restoring to a s3_plain_rewritable disk.

This PR fixes mysterious error columns.txt is not found while restoring parts to a disk with type s3_plain_rewritable.

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.

This is the first part of the fix. object_storage.isWriteOnce() returns false for s3_plain_rewritable disks, so it could actually remove restored files immediately after copying them to a destination disk.

Checking object_storage.isPlain() instead is more correct here and it also corresponds to DiskObjectStorageTransaction::writeFile().

Copy link
Copy Markdown
Member Author

@vitlibar vitlibar Jul 22, 2024

Choose a reason for hiding this comment

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

This is the second part of the fix. During RESTORE it copies parts from a backup to temporary directories on destination disks, and then attaches those parts to tables.

Earlies it created those temporary directories as subfolders of the /tmp/ folder on the destination disks. That didn't work good for the s3_plain_rewritable disk type because that kind of disk can't move a folder to any place, it can only rename it (keeping its parent the same).

So I changed that in this PR and now temporary directories are created in the data folder of a destination table, for example

/var/lib/clickhouse/data/db_name/table_name/tmp_restore_all_0_1_1_0-XXXXXXXX

So to attach such folders they have to be only renamed (and not to be moved to another location).

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.

I'm somewhat worried this change affects all disk types, not just plain_rewritable, though I can't think of any actual pitfalls. The advantage of the /tmp/ folder is that it provides a clear separation between temporary and persistent fs paths. Maybe scope this change to the plain_rewritable disk only?

Copy link
Copy Markdown
Member Author

@vitlibar vitlibar Jul 23, 2024

Choose a reason for hiding this comment

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

Actually the new way of naming temporary directories corresponds to how temporary directories have always been named by the INSERT command:

/var/lib/clickhouse/data/db_name/table_name/tmp_insert_all_0_1_1_0

So I think it could be just more consistent to use the same idea for RESTORE.

Copy link
Copy Markdown
Member Author

@vitlibar vitlibar Jul 22, 2024

Choose a reason for hiding this comment

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

The error message columns.txt is not found was not very helpful while I was investigating this issue. So I decided to improve the error message in case this error ever comes back.

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-bugfix Pull request with bugfix, not backported by default label Jul 22, 2024
@robot-ch-test-poll4
Copy link
Copy Markdown
Contributor

robot-ch-test-poll4 commented Jul 22, 2024

This is an automated comment for commit 2e25808 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help❌ failure
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Successful checks
Check nameDescriptionStatus
Bugfix validationChecks that either a new test (functional or integration) or there some changed tests that fail with the binary built on master branch✅ success
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

use "/var/lib/clickhouse/data/test/table/tmp_restore_all_0_1_1_0-XXXXXXXX"
instead of "/tmp/XXXXXXXX/data/test/table/0_1_1_0"
(because directories can only be renamed in s3_plain_rewritable, and not moved to another parent directory).
@vitlibar vitlibar force-pushed the fix-broken-part-error-while-restoring-to-s3-plain-rewritable branch from 8b200c1 to eb519c5 Compare July 22, 2024 15:14
@jkartseva
Copy link
Copy Markdown
Member

02864_restore_table_with_broken_part and test_backup_restore_s3 are failing, looking...

@jkartseva
Copy link
Copy Markdown
Member

jkartseva commented Jul 22, 2024

The test_backup_restore_s3 fix:

diff --git a/tests/integration/test_backup_restore_s3/test.py b/tests/integration/test_backup_restore_s3/test.py
index 4840f5afc66..381268ce7fe 100644
--- a/tests/integration/test_backup_restore_s3/test.py
+++ b/tests/integration/test_backup_restore_s3/test.py
@@ -254,6 +254,7 @@ def check_system_tables(backup_query_id=None):
         ("disk_s3_cache", "ObjectStorage", "S3", "Local"),
         ("disk_s3_other_bucket", "ObjectStorage", "S3", "Local"),
         ("disk_s3_plain", "ObjectStorage", "S3", "Plain"),
+        ("disk_s3_plain_rewritable", "ObjectStorage", "S3", "PlainRewritable"),
         ("disk_s3_restricted_user", "ObjectStorage", "S3", "Local"),
     )
     assert len(expected_disks) == len(disks)

@jkartseva
Copy link
Copy Markdown
Member

LGTM, but the tests have failed :( I'll look at them in the morning. Please also add 'pr-must-backport-cloud' tag.

@vitlibar
Copy link
Copy Markdown
Member Author

@vitlibar vitlibar enabled auto-merge July 25, 2024 11:16
@vitlibar vitlibar added this pull request to the merge queue Jul 25, 2024
Merged via the queue into ClickHouse:master with commit ac514a5 Jul 25, 2024
@vitlibar vitlibar deleted the fix-broken-part-error-while-restoring-to-s3-plain-rewritable branch July 25, 2024 11:49
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 25, 2024
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created-cloud deprecated label, NOOP label Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default 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