Skip to content

Use IDisk to store metadata files in Databases#72027

Merged
tuanpach merged 36 commits intoClickHouse:masterfrom
tuanpach:use-idisk-in-databases
Dec 16, 2024
Merged

Use IDisk to store metadata files in Databases#72027
tuanpach merged 36 commits intoClickHouse:masterfrom
tuanpach:use-idisk-in-databases

Conversation

@tuanpach
Copy link
Copy Markdown
Member

@tuanpach tuanpach commented Nov 18, 2024

Changelog category (leave one):

  • Improvement

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

Allow to use a configurable disk to store metadata files of databases and tables. The disk name can be set via database_disk.disk config parameter

Currently, we use std::filesystem to store metadata files in databases on the local disk. If local files do not persist after the instance restarts (or scale in/out), the metadata files will be lost.

This PR is to replace std::filesystem with IDisk. Although the metadata files are still on the local disk with DiskLocal, we can store them in other remote disks (e.g. DiskObjectStorage) if needed. So that the metadata files can be fetched after the instance restarts.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

CI Settings (Only check the boxes if you know what you are doing):

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64, release, debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

@tuanpach tuanpach marked this pull request as draft November 18, 2024 12:42
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-improvement Pull request with some product improvements label Nov 18, 2024
@kssenii kssenii self-assigned this Nov 18, 2024
@tuanpach tuanpach marked this pull request as ready for review November 19, 2024 02:44
@tuanpach tuanpach added the can be tested Allows running workflows for external contributors label Nov 19, 2024
@robot-clickhouse
Copy link
Copy Markdown
Member

robot-clickhouse commented Nov 19, 2024

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

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

Successful checks
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✅ 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
Stateless testsRuns stateless 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

@tuanpach tuanpach force-pushed the use-idisk-in-databases branch 2 times, most recently from f6f709f to f2e031f Compare November 19, 2024 07:39
Comment thread src/Databases/MySQL/DatabaseMaterializedMySQL.cpp Outdated
Comment thread src/Databases/DatabaseAtomic.cpp Outdated
Comment thread src/Databases/DatabaseAtomic.cpp Outdated
Comment thread src/Databases/DatabaseAtomic.cpp Outdated
Comment thread src/Databases/DatabaseAtomic.cpp Outdated
Comment thread src/Databases/DatabaseOrdinary.cpp Outdated
Comment thread src/Disks/DiskLocal.cpp Outdated
Comment thread src/Databases/DatabaseOnDisk.cpp Outdated
Comment thread src/Databases/DatabaseOnDisk.cpp Outdated
Comment thread src/Databases/DatabaseOnDisk.cpp Outdated
@tuanpach tuanpach force-pushed the use-idisk-in-databases branch 3 times, most recently from c86239c to 6de433c Compare November 22, 2024 08:10
@tuanpach tuanpach force-pushed the use-idisk-in-databases branch from 6de433c to 1e15cc5 Compare November 22, 2024 11:28
@tuanpach tuanpach force-pushed the use-idisk-in-databases branch from a3cc772 to 3a82b5e Compare November 25, 2024 06:33
2) Not use db_disk when setting up tmp path
@tuanpach tuanpach force-pushed the use-idisk-in-databases branch from c99ad9a to 3445789 Compare November 25, 2024 09:49
@tuanpach tuanpach force-pushed the use-idisk-in-databases branch from 508b48a to 4dd5b04 Compare November 27, 2024 09:13
@tuanpach
Copy link
Copy Markdown
Member Author

Comment thread src/Databases/DatabaseAtomic.cpp
Comment thread src/Databases/DatabaseAtomic.cpp
Comment thread tests/integration/test_merge_tree_s3/test.py
Comment thread src/Interpreters/loadMetadata.cpp Outdated
Comment thread src/Databases/DatabaseLazy.cpp
Comment thread src/Databases/DatabaseReplicated.cpp Outdated
Comment thread src/Databases/DatabaseOrdinary.cpp Outdated
Comment thread src/Interpreters/InterpreterCreateQuery.cpp Outdated
Comment thread src/Interpreters/Context.cpp
Comment thread src/Databases/DatabaseOnDisk.cpp Outdated
Comment thread src/Databases/DatabaseOnDisk.cpp Outdated
@tuanpach
Copy link
Copy Markdown
Member Author

tuanpach commented Dec 12, 2024

Hi @kssenii

There was a failed test. It was caused by reading cached mmap data with db_disk->readFile().

I fixed it by setting the read method to LocalFSReadMethod::read, so it will synchronously read files.

Comment thread src/Databases/DatabaseOnDisk.cpp
@tuanpach tuanpach enabled auto-merge December 13, 2024 23:32
@tuanpach tuanpach disabled auto-merge December 13, 2024 23:52
@tuanpach tuanpach added this pull request to the merge queue Dec 16, 2024
Merged via the queue into ClickHouse:master with commit 0249453 Dec 16, 2024
@tuanpach tuanpach deleted the use-idisk-in-databases branch December 16, 2024 07:10
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 16, 2024
@tuanpach tuanpach changed the title Use IDisk in Databases Use IDisk to store metadata files in Databases Jan 24, 2025
os.path.join(CONFIG_DIR, "storage_conf.xml"),
"/etc/clickhouse-server/config.d/storage_conf.xml",
)
node.start_clickhouse()
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.

Why this is required? I guess because now all disks will be initialized anyway?

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.

We start the cluster without the storage config first. So that we can start the s3 cluster start_s3_mock(cluster, "broken_s3", "8083"). If we add storage_conf.xml config first, the s3 cluster has not started, and the disk cannot be initialized at the beginning, so the cluster is unable to start.

@azat
Copy link
Copy Markdown
Member

azat commented Mar 7, 2025

@tuanpach it will be nice to have a test for this

@tuanpach
Copy link
Copy Markdown
Member Author

tuanpach commented Mar 7, 2025

@tuanpach it will be nice to have a test for this

We use a default disk, which is a DiskLocal in all tests. I think it is sufficient.

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 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.

6 participants