Skip to content

Add ability to disable native copy for S3 - #51448

Merged
vitlibar merged 12 commits into
ClickHouse:masterfrom
azat:backups-native-copy
Jul 15, 2023
Merged

vitlibar merged 12 commits into
ClickHouse:masterfrom
azat:backups-native-copy

Conversation

@azat

@azat azat commented Jun 26, 2023 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Add ability to disable native copy for S3 (setting for BACKUP/RESTORE allow_s3_native_copy, and s3_allow_native_copy for s3/s3_plain disks)

Native copy uses CopyObject for S3/GCS, but in GCS the CopyObject is buggy - it does not always works. You can see the following error after 30 seconds timeout:

2023.06.21 14:31:08.614043 [ 1548 ] {75ba733c-fd43-4dc1-a7ef-18d68371ef96} <Information> AWSClient: AWSErrorMarshaller: Encountered AWSError 'InternalError': Copy spanning locations and/or storage classes could not complete within 30 seconds. Please use the Rewrite method in the JSON API (https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite) instead.

Note, that there is no auto-detection of proper CopyObject support because it takes 30 seconds to ensure in this, and besides my testing shows that the problem for GCS only for cross-buckets copy, within one bucket there are no problems.

Cc: @vitlibar
Cc: @antonio2368

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-improvement Pull request with some product improvements label Jun 26, 2023
@robot-clickhouse-ci-1

robot-clickhouse-ci-1 commented Jun 26, 2023 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit 2f23b6a with description of existing statuses. It's updated for the latest CI running
The full report is available here
The overall status of the commit is 🟡 pending

Check nameDescriptionStatus
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
Mergeable CheckChecks if all other necessary checks are successful🟢 success

@vitlibar vitlibar self-assigned this Jun 26, 2023
@antonio2368

Copy link
Copy Markdown
Member

Maybe do it in copyS3File and fallback to copyDataToS3File?
BACKUP/RESTORE are not the only place using native copy.

@azat

azat commented Jun 27, 2023

Copy link
Copy Markdown
Member Author

Maybe do it in copyS3File and fallback to copyDataToS3File?

Yeah I thought about this, but requests can takes 30 seconds before failing, which is quiet a long period for auto-detection

The error looks like this:

2023.06.21 14:31:08.614043 [ 1548 ] {75ba733c-fd43-4dc1-a7ef-18d68371ef96} <Information> AWSClient: AWSErrorMarshaller: Encountered AWSError 'InternalError': Copy spanning locations and/or storage classes could not complete within 30 seconds. Please use the Rewrite method in the JSON API (https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite) instead.

@antonio2368

Copy link
Copy Markdown
Member

@azat sorry, I meant using the setting inside the copyS3File and if it's set to false do copyDataToS3File

@azat

azat commented Jun 27, 2023

Copy link
Copy Markdown
Member Author

@azat sorry, I meant using the setting inside the copyS3File and if it's set to false do copyDataToS3File

@antonio2368 yep, I guess it make sense, so now there is s3_allow_native_copy attribute for disks that could be used to turn OFF native copy. Also there is a test for this with clickhouse-disks (the first ever test actually for clickhouse-disks)

@azat azat changed the title Add ability to disable native copy for BACKUP/RESTORE Add ability to disable native copy for S3 Jun 27, 2023
@azat

azat commented Jun 28, 2023

Copy link
Copy Markdown
Member Author

Integration tests (release) [4/4] — fail: 3, passed: 423, flaky: 0

Logging for native copy had been changed, so I've rewrote the test to check profile events instead of server logs.
Also note, that none of other builds (asan, tsan) does not shows the problem, because of the problem that had been fixed in #51514

@azat
azat force-pushed the backups-native-copy branch from e4503fc to 58c53ad Compare June 28, 2023 11:03
Comment thread src/Backups/BackupSettings.h Resolved
Comment thread src/IO/S3/copyS3File.h Resolved
Comment thread src/IO/S3/copyS3File.h Resolved
@azat

azat commented Jun 29, 2023

Copy link
Copy Markdown
Member Author

Test failures does not looks related (all tests below are flaky):

Integration tests (asan) [6/6] — fail: 1, passed: 449, flaky: 0

  • test_ssl_cert_authentication - flaky

Stateless tests (aarch64) — fail: 1, passed: 5363, skipped: 24
Stateless tests (release) — fail: 1, passed: 5381, skipped: 6

  • 00002_log_and_exception_messages_formatting

Stateless tests (release, wide parts enabled) — fail: 2, passed: 5378, skipped: 8

  • 02354_distributed_with_external_aggregation_memory_usage

@azat
azat requested a review from vitlibar June 30, 2023 08:32
@azat
azat force-pushed the backups-native-copy branch from 034bdbf to 4204a62 Compare July 6, 2023 16:22
@azat

azat commented Jul 6, 2023

Copy link
Copy Markdown
Member Author

@vitlibar can you take a look at this one please? I have more fixes on top of this.

@azat
azat force-pushed the backups-native-copy branch 2 times, most recently from 8643131 to 908a91c Compare July 8, 2023 12:33
@azat

azat commented Jul 8, 2023

Copy link
Copy Markdown
Member Author

Interesting that 00002_log_and_exception_messages_formatting constantly fails in one builds here, but this patches does not add/modify any single exception. @tavplubix maybe you will be interested. But maybe it is enough to wait for #51320

@tavplubix

Copy link
Copy Markdown
Member

I don't see any failures :)
Screenshot from 2023-07-08 14-37-40

(yes, it's because all CI statuses were wiped by force push, I will try to find some reports in the CI database...)

@tavplubix

Copy link
Copy Markdown
Member

Found some report with failure: https://s3.amazonaws.com/clickhouse-test-reports/51448/4204a625a5a1373db4bad625fcfbb0f8cf38f2b3/stateless_tests__release_.html

See run.log:

2023-07-07 11:14:14 00002_log_and_exception_messages_formatting:                            [ FAIL ] 8.87 sec. - result differs with reference: 
2023-07-07 11:14:14 --- /usr/share/clickhouse-test/queries/0_stateless/00002_log_and_exception_messages_formatting.reference	2023-07-07 10:27:18.546645601 +0000
2023-07-07 11:14:14 +++ /tmp/clickhouse-test/0_stateless/00002_log_and_exception_messages_formatting.stdout	2023-07-07 11:14:14.052932399 +0000
2023-07-07 11:14:14 @@ -1,7 +1,7 @@
2023-07-07 11:14:14  runtime messages	0.001
2023-07-07 11:14:14  runtime exceptions	0.05
2023-07-07 11:14:14  messages shorter than 10	1
2023-07-07 11:14:14 -messages shorter than 16	3
2023-07-07 11:14:14 +messages shorter than 16	4
2023-07-07 11:14:14  exceptions shorter than 30	3
2023-07-07 11:14:14  noisy messages	0.3
2023-07-07 11:14:14  noisy Trace messages	0.16

And below:

2023-07-07 11:14:22 Top short messages:
2023-07-07 11:14:22 
2023-07-07 11:14:22 c	message_format_string	substring(any(message), 1, 120)	min_length_without_exception_boilerplate
2023-07-07 11:14:22 UInt64	LowCardinality(String)	String	Int64
2023-07-07 11:14:22 3900	Processed: {}%	Processed: 2.5597440255974404%	2
2023-07-07 11:14:22 186	API mode: {}	API mode: AWS	-13
2023-07-07 11:14:22 3	{}	building file infos	-7
2023-07-07 11:14:22 2	Creating {}: {}	Creating table test_b6qfgn1i.data_native_copy: CREATE TABLE IF NOT EXISTS test_b6qfgn1i.data_native_copy (`key` Int32) E	683
2023-07-07 11:14:22 

So it fails because of short non-informative messages in logs. We should remove these messages or make them more informative.

@azat

azat commented Jul 8, 2023

Copy link
Copy Markdown
Member Author

So it fails because of short non-informative messages in logs. We should remove these messages or make them more informative

Yep, but this messages looks, they could be converted to the test log level, but I don't like this either.
The reason it fails only in this PR I guess because of the stateless test for BACKUP TO S3 that creates such messages.
@tavplubix Objections on updating the test expectations?

Also maybe it is better to check the message not message_format_string, since later can be concatenated from other things, but I guess you already thought about this and addressed some of such use cases?

@tavplubix

Copy link
Copy Markdown
Member

Objections on updating the test expectations?

Let's fix the bad messages

@azat

azat commented Jul 8, 2023

Copy link
Copy Markdown
Member Author

Let's fix the bad messages

I guess the problem is in "API mode: {}" (S3Client: API mode: AWS), and I don't see any problems here.
Maybe you have some suggestions then?

azat added 2 commits July 9, 2023 08:19
Native copy uses CopyObject for S3/GCS, but in GCS the CopyObject is
buggy - it does not always works.

Signed-off-by: Azat Khuzhin <[email protected]>
Previous patch implements this only for BACKUP/RESTORE, but it can be
useful for regular disks as well, so add allow_native_copy for disks.

Note, that there is s3_allow_native_copy query setting, since it looks
redundant, since it make sense only for S3 disks, and not on a per query
basis.

Signed-off-by: Azat Khuzhin <[email protected]>
azat added 8 commits July 9, 2023 08:20
Check profile events instead of some odd logs.

Signed-off-by: Azat Khuzhin <[email protected]>
Signed-off-by: Azat Khuzhin <[email protected]>
In ClickHouse#51135 the behavior of the `clickhouse-disks copy` had been changed,
let's temporary update the test (and continue discussion about this
change in that PR).

Signed-off-by: Azat Khuzhin <[email protected]>
@azat

azat commented Jul 9, 2023 •

Copy link
Copy Markdown
Member Author

src/Storages/StorageS3Settings.h

Rebased

Stateless tests (aarch64) — fail: 1, passed: 5363, skipped: 24

  • 00002_log_and_exception_messages_formatting - added API mode: {} to known_short_messages

@azat
azat force-pushed the backups-native-copy branch from 908a91c to ac97266 Compare July 9, 2023 06:22
Otherwise it is not possible to use clickhouse-disks with S3:

    $ clickhouse-disks -C /src/ch/clickhouse/tests/queries/0_stateless/02802_clickhouse_disks_s3_copy.xml --log-level test --disk s3_plain_native_copy copy default/test default/test.copy
    Failed to make request to: http://localhost:11111/test?list-type=2&max-keys=1&prefix=clickhouse-disks%2Fdefault%2Ftest.copy: Code: 49. DB::Exception: current_thread is not initialized. (LOGICAL_ERROR), Stack trace (when copying this message, always include the lines below):

    0. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/exception:134: Poco::Exception::Exception(String const&, int) @ 0x000000001ad7c872 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    1. ./.cmake-llvm16/./src/Common/Exception.cpp:94: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000011e2c4b7 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    2. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/string:1499: DB::Exception::Exception<char const (&) [34], void>(int, char const (&) [34]) @ 0x000000000d341e58 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    3. ./.cmake-llvm16/./src/Common/MemoryTrackerSwitcher.h:19: DB::(anonymous namespace)::SingleEndpointHTTPSessionPool::allocObject() @ 0x0000000012010e5a in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    4. ./.cmake-llvm16/./src/Common/PoolBase.h:174: PoolBase<Poco::Net::HTTPClientSession>::get(long) @ 0x0000000012011a6f in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    5. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/variant:797: DB::makePooledHTTPSession(Poco::URI const&, Poco::URI const&, DB::ConnectionTimeouts const&, unsigned long, bool, bool) @ 0x000000001200ec69 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    6. ./.cmake-llvm16/./src/IO/HTTPCommon.cpp:0: DB::makePooledHTTPSession(Poco::URI const&, DB::ConnectionTimeouts const&, unsigned long, bool, bool) @ 0x000000001200d909 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    7. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/variant:797: void DB::S3::PocoHTTPClient::makeRequestInternalImpl<true>(Aws::Http::HttpRequest&, DB::S3::ClientConfigurationPerRequest const&, std::shared_ptr<DB::S3::PocoHTTPResponse>&, Aws::Utils::RateLimits::RateLimiterInterface*, Aws::Utils::RateLimits::RateLimiterInterface*) const @ 0x00000000163f5157 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    8. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/string:1499: DB::S3::PocoHTTPClient::makeRequestInternal(Aws::Http::HttpRequest&, std::shared_ptr<DB::S3::PocoHTTPResponse>&, Aws::Utils::RateLimits::RateLimiterInterface*, Aws::Utils::RateLimits::RateLimiterInterface*) const @ 0x00000000163f465d in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    9. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:622: DB::S3::PocoHTTPClient::MakeRequest(std::shared_ptr<Aws::Http::HttpRequest> const&, Aws::Utils::RateLimits::RateLimiterInterface*, Aws::Utils::RateLimits::RateLimiterInterface*) const @ 0x00000000163f4454 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    10. ./.cmake-llvm16/./contrib/aws/src/aws-cpp-sdk-core/source/client/AWSClient.cpp:506: Aws::Client::AWSClient::AttemptOneRequest(std::shared_ptr<Aws::Http::HttpRequest> const&, Aws::AmazonWebServiceRequest const&, char const*, char const*, char const*) const @ 0x000000001ae2a922 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    11. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:612: Aws::Client::AWSClient::AttemptExhaustively(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const @ 0x000000001ae28299 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    12. ./.cmake-llvm16/./contrib/aws/src/aws-cpp-sdk-core/include/aws/core/utils/Outcome.h:160: Aws::Client::AWSXMLClient::MakeRequest(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const @ 0x000000001ae3c9ed in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    13. ./.cmake-llvm16/./contrib/aws/src/aws-cpp-sdk-core/source/client/AWSXmlClient.cpp:66: Aws::Client::AWSXMLClient::MakeRequest(Aws::AmazonWebServiceRequest const&, Aws::Endpoint::AWSEndpoint const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const @ 0x000000001ae3c995 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    14. ./.cmake-llvm16/./contrib/aws/generated/src/aws-cpp-sdk-s3/source/S3Client.cpp:0: Aws::S3::S3Client::ListObjectsV2(Aws::S3::Model::ListObjectsV2Request const&) const @ 0x000000001aee6666 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    15. ./.cmake-llvm16/./contrib/aws/src/aws-cpp-sdk-core/include/aws/core/utils/Outcome.h:160: DB::S3::Client::ListObjectsV2(DB::S3::ExtendedRequest<Aws::S3::Model::ListObjectsV2Request> const&) const @ 0x00000000163cee42 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    16. ./.cmake-llvm16/./contrib/aws/src/aws-cpp-sdk-core/include/aws/core/utils/Outcome.h:120: DB::S3ObjectStorage::listObjects(String const&, std::vector<DB::RelativePathWithMetadata, std::allocator<DB::RelativePathWithMetadata>>&, int) const @ 0x0000000016b582e2 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    17. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/vector:543: DB::IObjectStorage::existsOrHasAnyChild(String const&) const @ 0x000000001644ebe9 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    18. ./.cmake-llvm16/./src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.cpp:0: DB::MetadataStorageFromPlainObjectStorage::exists(String const&) const @ 0x0000000016b54a64 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    19. ./.cmake-llvm16/./src/Disks/IDisk.cpp:145: DB::IDisk::copyDirectoryContent(String const&, std::shared_ptr<DB::IDisk> const&, String const&) @ 0x0000000016b38fa0 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    20. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/string:1499: DB::CommandCopy::execute(std::vector<String, std::allocator<String>> const&, std::shared_ptr<DB::Context>&, Poco::Util::LayeredConfiguration&) @ 0x0000000012050403 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    21. ./.cmake-llvm16/./contrib/llvm-project/libcxx/include/vector:434: DB::DisksApp::main(std::vector<String, std::allocator<String>> const&) @ 0x000000001204bf02 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    22. ./.cmake-llvm16/./base/poco/Util/src/Application.cpp:0: Poco::Util::Application::run() @ 0x000000001ac7a666 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    23. ./.cmake-llvm16/./programs/disks/DisksApp.cpp:0: mainEntryClickHouseDisks(int, char**) @ 0x000000001204c550 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    24. ./.cmake-llvm16/./programs/main.cpp:0: main @ 0x000000000cfbadc4 in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
    25. ? @ 0x00007ffff7dc9850 in ?
    26. __libc_start_main @ 0x00007ffff7dc990a in ?
    27. _start @ 0x000000000cfba1ee in /src/ch/clickhouse/.cmake-llvm16/programs/clickhouse
     (version 23.7.1.1)
    AWSXmlClient: HTTP response code: -1
    Resolved remote host IP address:
    Request ID:
    Exception name:
    Error message: Code: 49. DB::Exception: current_thread is not initialized. (LOGICAL_ERROR) (version 23.7.1.1)
    0 response headers:
    If the signature check failed. This could be because of a time skew. Attempting to adjust the signer.
    Request failed, now waiting 1600 ms before attempting again.

Signed-off-by: Azat Khuzhin <[email protected]>
@azat
azat force-pushed the backups-native-copy branch from b2ea45b to 3c18a18 Compare July 9, 2023 12:21
@azat

azat commented Jul 9, 2023

Copy link
Copy Markdown
Member Author

Stateless tests flaky check (asan) — fail: 21, passed: 202

  • 00002_log_and_exception_messages_formatting - I guess it is OK for this test to fails in a flaky check

Stateless tests (tsan, s3 storage) [3/5] — Tests are not finished, fail: 7, passed: 498, skipped: 8

ThreadSanitizer: CHECK failed: tsan_interceptors_posix.cpp:2084 "((thr->slot)) != (0)" (0x0, 0x0) (tid=1171)

@azat
azat requested a review from vitlibar July 11, 2023 11:18
@azat

azat commented Jul 13, 2023

Copy link
Copy Markdown
Member Author

@vitlibar kind ping (this PR also fixes one unrelated bug - #52013) because of which CI is flaky, and flaky CI means - no merges.

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

Labels

pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants