ByConity: S3 Part Upload Fails When an S3 Express One Zone Bucket is Specified

Bug Report

Briefly describe the bug

When I specify a storage policy which uses an S3 Express One Zone bucket, create a table that uses that storage policy, and try to insert into the table, below exception is thrown:

2024.08.01 19:30:07.301127 [ 227 ] {218421af-501a-4cdb-82df-c2e4d8672e86} (451553684895825933) <Error> DynamicQueryHandler: Code: 499, e.displayText() = DB::S3::S3Exception: Encounter exception when request s3, HTTP Code: 501, RemoteHost: , RequestID: 0165a84f8f0001910f6bc71e0509440814734b1e, ExceptionName: NotImplemented, ErrorMessage: Unable to parse ExceptionName: NotImplemented Message: This bucket does not support Content Md5 header., Extra:  SQLSTATE: HY000, Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x27209ed2 in /opt/byconity/bin/clickhouse
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x1076e0c0 in /opt/byconity/bin/clickhouse
2. DB::S3::S3Exception::S3Exception(Aws::S3::S3Error const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x109131f0 in /opt/byconity/bin/clickhouse
3. DB::S3::S3Util::upload(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, std::__1::shared_ptr<std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&, std::__1::optional<std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > const&, std::__1::optional<std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > const&) const @ 0x1091c93d in /opt/byconity/bin/clickhouse
4. DB::WriteBufferFromByteS3::makeSinglepartUpload() @ 0x20a0d2e0 in /opt/byconity/bin/clickhouse
5. DB::WriteBufferFromByteS3::finalizeImpl() @ 0x20a0d103 in /opt/byconity/bin/clickhouse
6. DB::WriteBuffer::finalize() @ 0x107bc40f in /opt/byconity/bin/clickhouse
7. DB::MergeTreeCNCHDataDumper::dumpTempPart(std::__1::shared_ptr<DB::IMergeTreeDataPart> const&, std::__1::shared_ptr<DB::IDisk> const&, bool) const @ 0x21e4bbd0 in /opt/byconity/bin/clickhouse
8. void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<DB::CnchDataWriter::dumpCnchParts(std::__1::vector<std::__1::shared_ptr<DB::IMergeTreeDataPart>, std::__1::allocator<std::__1::shared_ptr<DB::IMergeTreeDataPart> > > const&, std::__1::vector<std::__1::shared_ptr<DB::LocalDeleteBitmap>, std::__1::allocator<std::__1::shared_ptr<DB::LocalDeleteBitmap> > > const&, std::__1::vector<std::__1::shared_ptr<DB::IMergeTreeDataPart>, std::__1::allocator<std::__1::shared_ptr<DB::IMergeTreeDataPart> > > const&)::$_2, void ()> >(std::__1::__function::__policy_storage const*) @ 0x2013a965 in /opt/byconity/bin/clickhouse
9. ThreadPoolImpl<ThreadFromGlobalPool>::worker(std::__1::__list_iterator<ThreadFromGlobalPool, void*>) @ 0x107adef1 in /opt/byconity/bin/clickhouse
10. ThreadFromGlobalPool::ThreadFromGlobalPool<void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()>(void&&, void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()&&...)::'lambda'()::operator()() @ 0x107afa08 in /opt/byconity/bin/clickhouse
11. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x107aa600 in /opt/byconity/bin/clickhouse
12. void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()> >(void*) @ 0x107aea7a in /opt/byconity/bin/clickhouse
13. start_thread @ 0x7ea7 in /lib/x86_64-linux-gnu/libpthread-2.31.so
14. clone @ 0xfba6f in /lib/x86_64-linux-gnu/libc-2.31.so
 (version 21.8.7.1)

What I understood from this error message is that the Content-MD5 header should not be set when a PUT request is done for an S3 Express bucket. However I couldn’t find a configuration parameter that will disable the MD5 calculation inside the S3 client. Is there a way to disable this feature?

The result you expected

I expected the part to be uploaded without any errors, as in the normal S3 disk type.

How to Reproduce

Storage policy and disk configurations in server.yaml file:

storage_configuration:
      disks:
        server_s3_express_one_zone_disk_0:
          type: s3
          path: "s3-express-path"
          endpoint: https://s3express-usw2-az1.us-west-2.amazonaws.com
          region: us-west-2
          bucket: "<bucket-name>"
          use_environment_credentials: true

      policies:
        cnch_default_s3_express_one_zone:
          volumes:
            bytes3:
              default: server_s3_express_one_zone_disk_0
              disk: server_s3_express_one_zone_disk_0

Version

0.4.1

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

@Alima777 thanks for the initiative. I will need to redeploy the server with the custom release built locally to get the error stack trace, so I will be able to do that after a little while

Hi, @ozansz

I solved that issue by signing every request to S3 by doing the below change in src/IO/S3Common.cpp:

It seems we have to do some adaptations to support S3 Expression One Zone Bucket.

I updated the PullRequest:

client_settings.is_s3express_bucket ? Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::RequestDependent
                                                : Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never

Can you try it again?

Hi @ozansz

I also noticed that the AWS SDK in contrib/aws is not updated since 22 May 2023. This version of AWS SDK does not have definitions and support for some new features including the S3 Express One Zone storage class.

I think you are right. We didn’t update AWS SDK recently. I will try to update it later.