Skip to content

Backup disk#64222

Closed
AlexNsf wants to merge 2 commits intoClickHouse:masterfrom
AlexNsf:Backup-Disks
Closed

Backup disk#64222
AlexNsf wants to merge 2 commits intoClickHouse:masterfrom
AlexNsf:Backup-Disks

Conversation

@AlexNsf
Copy link
Copy Markdown

@AlexNsf AlexNsf commented May 22, 2024

Changelog category (leave one):

  • New Feature

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

Add backup disk, that reads metadata from ".backup" file to add some optimizations for working with backup. Closes #42154.

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/

Modify your CI run

NOTE: If your merge the PR with modified CI you MUST KNOW what you are doing
NOTE: Checked options will be applied if set before CI RunConfig/PrepareRunConfig step

Include tests (required builds will be added automatically):

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with Analyzer
  • All with Azure
  • Add your option here

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All with Aarch64
  • Add your option here

Extra options:

  • do not test (only style check)
  • disable merge-commit (no merge from master before tests)
  • disable CI cache (job reuse)

Only specified batches in multi-batch jobs:

  • 1
  • 2
  • 3
  • 4

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 22, 2024

CLA assistant check
All committers have signed the CLA.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 22, 2024
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-feature Pull request with new product feature label May 22, 2024
@robot-ch-test-poll4
Copy link
Copy Markdown
Contributor

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

This is an automated comment for commit c209657 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
A SyncThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS⏳ pending
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR⏳ pending
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests❌ failure
Mergeable CheckChecks if all other necessary checks are successful❌ failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure
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
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ 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. Integrational 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
PR CheckThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ 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
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

@kssenii kssenii self-assigned this Jun 11, 2024
namespace DB
{

DiskBackup::DiskBackup(const String & name_, DiskPtr delegate_, MetadataStoragePtr metadata_) : IDisk(name_), delegate(delegate_), metadata(metadata_)
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.

Could you please add some documentation to https://github.com/ClickHouse/ClickHouse/blob/master/docs/en/operations/storing-data.md about this disk? What its usecase, how to configure it and maybe some small usage example.

}

public:
DiskBackup(const String & name_, DiskPtr delegate_, MetadataStoragePtr metadata_);
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.

As I see this constructor is used only in unit test, because it was not clear how to create a config object from there? If so, take a look here

std::string xml(R"CONFIG(<clickhouse>
<named_collections>
<collection1>
<key1>value1</key1>
<key2>2</key2>
<key3>3.3</key3>
<key4>-4</key4>
</collection1>
<collection2>
<key4>value4</key4>
<key5>5</key5>
<key6>6.6</key6>
</collection2>
</named_collections>
</clickhouse>)CONFIG");
Poco::XML::DOMParser dom_parser;
Poco::AutoPtr<Poco::XML::Document> document = dom_parser.parseString(xml);
Poco::AutoPtr<Poco::Util::XMLConfiguration> config = new Poco::Util::XMLConfiguration(document);

may be you can do the same, so this constructor could be removed

extern const int NOT_IMPLEMENTED;
}

class DiskBackup : public IDisk
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.

It will be good to also add a comment before this class definition with a small explanation of the purpose of this class. A sentence about its purpose from #42154 will suffice.

delegate->createFile("test_folder/test.txt");

EXPECT_EQ(backup->isFile("test_folder/test.txt"), true);
EXPECT_EQ(backup->isDirectory("test_folder"), true);
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.

Need to also check that write operations are not allowed, you can use ASSERT_THROW for this


DiskBackup::DiskBackup(const String & name_, const Poco::Util::AbstractConfiguration & config_, const String & config_prefix_, const DisksMap & map_) : IDisk(name_)
{
String disk_delegate_name = config_.getString(config_prefix_ + ".disk_delegate");
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.

May be we can rename disk_delegate to just disk, because in some similar cases we use just "disk", for example for disk type "cache".

@@ -0,0 +1,105 @@
#include <filesystem>
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.

Let's also add a stateless test with disk created from SQL, see example here

SETTINGS disk = disk(name = 's3_disk', type = cache, max_size = '100Ki', path = ${CLICKHOUSE_TEST_UNIQUE_NAME}, disk = s3_disk);

@@ -0,0 +1,105 @@
#include <filesystem>
#include <fstream>
#include <memory>
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.

Also need an integration test which creates the disk with type backup and checks that we can read from it and that an attempt to write to it fails. Also check that server can be restarted (via node.restart_clickhouse()). Also check the same for customly created disk from SQL (mentioned in the comment above).

namespace DB
{

class MetadataStorageFromBackupFile final : public IMetadataStorage
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.

A small comment in code about this class here will also be good to have - its purpose and how it works - shortly.

return std::make_unique<StaticDirectoryIterator>(std::move(dir_file_paths));
}

for (const auto& listed_path: nodes.at(path).children)
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.

Suggested change
for (const auto& listed_path: nodes.at(path).children)
for (const auto & listed_path: nodes.at(path).children)

std::unordered_map<String /* path */, MetadataStorageFromBackupFilePseudoFileSystemNode> nodes;

public:
explicit MetadataStorageFromBackupFile(const String & path_to_backup_file);
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 do not see an object of this class being created anywhere, or I missed it somewhere?

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Aug 20, 2024

Dear @AlexNsf, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

2 similar comments
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Oct 22, 2024

Dear @AlexNsf, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Dec 24, 2024

Dear @AlexNsf, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@alexey-milovidov alexey-milovidov mentioned this pull request Dec 31, 2024
76 tasks
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 25, 2025

Dear @AlexNsf, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@azat
Copy link
Copy Markdown
Member

azat commented Mar 18, 2025

@AlexNsf thanks for your contribution!

This has been superseded by #75725, see #75725 (comment) this comment on "Database vs Disk" pros and cons.

@azat azat closed this Mar 18, 2025
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-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to access backups as a readonly disk.

6 participants