Skip to content

Add AWS MSK IAM authentication for Kafka table engine - #96100

Merged
antaljanosbenjamin merged 15 commits into
ClickHouse:masterfrom
kalavt:feature/aws_msk_iam_auth_v2
Jun 29, 2026
Merged

antaljanosbenjamin merged 15 commits into
ClickHouse:masterfrom
kalavt:feature/aws_msk_iam_auth_v2

Conversation

@kalavt

@kalavt kalavt commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • New Feature

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

Added AWS_MSK_IAM as a supported value for kafka_sasl_mechanism, enabling ClickHouse to authenticate with Amazon MSK using IAM roles without managing SASL/SCRAM credentials.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Description

Implements AWS MSK IAM authentication for the Kafka table engine. ClickHouse can now authenticate with Amazon Managed Streaming for Apache Kafka (MSK) using IAM roles instead of managing SASL/SCRAM credentials or mTLS certificates.

Motivation

Users running ClickHouse on AWS commonly connect to MSK clusters. MSK IAM authentication is the preferred approach — it integrates with existing IAM role policies, requires no credential rotation, and works with instance profiles, ECS task roles, and EKS service accounts out of the box.

Changes

  • Added src/Storages/Kafka/AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest, callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue + set_oauthbearer_token_refresh_callback
  • KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (value unknown to librdkafka); sets SASL_SSL + OAUTHBEARER inside setupAuthentication
  • StorageKafka / StorageKafka2: added ensureOAuthContext() to share a single S3CredentialsProviderChain across all consumers (mutex-guarded)
  • KafkaSettings: new settings kafka_sasl_mechanism = 'AWS_MSK_IAM' and kafka_aws_region (auto-detected from broker hostname if not set)
  • contrib/cppkafka: updated to release-0.4.1 for set_oauthbearer_token_refresh_callback support
  • Documentation updated with setup examples, IAM policy snippets, and PrivateLink / custom DNS guidance

New settings

Setting Default Description
kafka_sasl_mechanism (existing) Added AWS_MSK_IAM as a supported value
kafka_aws_region "" AWS region for MSK IAM auth. Auto-detected from broker address if not set. Required for PrivateLink or custom DNS.

Example

CREATE TABLE kafka_msk (...)
ENGINE = Kafka
SETTINGS
    kafka_broker_list = 'b-1.my-cluster.kafka.us-east-1.amazonaws.com:9098',
    kafka_topic_list = 'my-topic',
    kafka_group_name = 'my-group',
    kafka_format = 'JSONEachRow',
    kafka_sasl_mechanism = 'AWS_MSK_IAM';
    -- kafka_aws_region is auto-detected from the broker address

Requires USE_AWS_S3=1 (enabled by default in official builds).

Version info

  • Merged into: 26.7.1.241 (included in 26.7 and later)

@kalavt

kalavt commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

ClickHouse/cppkafka#5

@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 27167b7 to bbf19ed Compare February 5, 2026 18:01
@kalavt

kalavt commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

@antaljanosbenjamin for your review, sorry decided open new PR hope this won't trouble you.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Feb 5, 2026
@clickhouse-gh

clickhouse-gh Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ca5c1a6]

Summary: ✅


AI Review

Summary

This PR adds AWS_MSK_IAM support to the Kafka table engine, including region extraction, an OAUTHBEARER token refresh callback backed by the S3 credential provider chain, documentation, and focused parsing/config tests. The implementation addresses most earlier review comments, but I am not ready to approve because the core signed-token path is still untested, and one previously dismissed China-partition endpoint mismatch remains in the current code.

Missing context / blind spots
  • ⚠️ Latest PR CI was still running during this review. The direct PR report had no completed test rows yet, and only Style check had reported success; completed build, unit, and stateless results would close this gap.
Findings
  • ⚠️ Majors
  • [src/Storages/Kafka/AWSMSKIAMAuth.cpp:64] [dismissed by author -- https://github.com/Add AWS MSK IAM authentication for Kafka table engine #96100#discussion_r3368652760] extractRegionFromBroker accepts .amazonaws.com.cn broker endpoints and isValidAWSRegion accepts cn-*, but generateAWSMSKToken still signs every token for kafka.<region>.amazonaws.com. Since presigning is local, this does not produce a clear AWS signing-time error; accepted China endpoints will instead fail later during broker authentication. Please either reject cn-* / .amazonaws.com.cn explicitly for AWS_MSK_IAM, or make signing partition-aware.
Tests
  • ⚠️ [src/Storages/Kafka/AWSMSKIAMAuth.cpp:58] The tests cover region parsing and config rewriting, but they do not exercise generateAWSMSKToken or the OAUTH callback. Add a deterministic unit test with static dummy AWS credentials that decodes the generated token and checks the expected host/query parameters, User-Agent, base64url encoding, and expiry. No live AWS or Kafka dependency is needed.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: add direct signed-token coverage for AWS_MSK_IAM, and either reject unsupported China-partition endpoints with a clear exception or implement partition-aware signing.

@antaljanosbenjamin antaljanosbenjamin self-assigned this Feb 5, 2026
@antaljanosbenjamin

Copy link
Copy Markdown
Member

I updated the PR description. Next time please keep the format, otherwise our CI cannot pick up the necessary information.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Feb 6, 2026
Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Outdated
Comment on lines +101 to +102
std::mutex g_contexts_mutex;
std::unordered_map<OAuthBearerTokenRefreshContext*, std::shared_ptr<OAuthBearerTokenRefreshContext>> g_contexts;

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.

We don't need a global container for this. Check how set_assignment_callback and oauthBearerTokenRefreshCallback is used. We have to do similar here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review!

The current implementation no longer uses a global container. We now use ensureOAuthContext() on the storage object — each StorageKafka/StorageKafka2 instance holds a single shared_ptr<OAuthBearerTokenRefreshContext> guarded by a mutex, and the librdkafka callback captures that shared_ptr by value.

This is consistent with how set_assignment_callback and the interceptor callbacks are structured: the context lives on the storage, and the lambda captures a reference to it. The only difference here is we use a shared_ptr (rather than a raw ref) because librdkafka can invoke the OAUTHBEARER callback from an internal thread after the storage has started shutting down — the shared_ptr ensures the CredentialsProvider outlives those calls safely.

@clickhouse-gh clickhouse-gh Bot added the submodule changed At least one submodule changed in this PR. label Feb 26, 2026
@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 9aed2d6 to 85b74bc Compare May 11, 2026 10:33
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 11, 2026
kalavt added a commit to kalavt/ClickHouse that referenced this pull request May 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
@kalavt kalavt changed the title feat: Add AWS MSK IAM authentication support for Kafka Add AWS MSK IAM authentication for Kafka table engine May 11, 2026
kalavt added a commit to kalavt/ClickHouse that referenced this pull request May 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 85b74bc to 92c445e Compare May 11, 2026 11:00
Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Resolved
Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Resolved
kalavt added a commit to kalavt/ClickHouse that referenced this pull request May 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 92c445e to 215336b Compare May 11, 2026 11:11
kalavt added a commit to kalavt/ClickHouse that referenced this pull request May 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 215336b to 1c7bb15 Compare May 11, 2026 11:15
kalavt added a commit to kalavt/ClickHouse that referenced this pull request May 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 1c7bb15 to 83429b8 Compare May 11, 2026 11:28
kalavt added a commit to kalavt/ClickHouse that referenced this pull request May 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
@kalavt
kalavt force-pushed the feature/aws_msk_iam_auth_v2 branch from 83429b8 to adfe9fe Compare May 11, 2026 12:05
Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Resolved
@antaljanosbenjamin

Copy link
Copy Markdown
Member

I couldn't spend time on this PR recently, will look into it again.

Comment on lines +130 to +133
catch (...) // NOLINT(bugprone-empty-catch)
{
// Ok: non-setup exceptions (e.g. missing AWS credentials) are acceptable here.
}

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.

If an exception is thrown in setupAuthentication, then the following two checks won't be checked. So I think we should ensure no exception is thrown.

Comment on lines +173 to +174
{
// Ok: non-region exceptions (e.g. missing AWS credentials) are acceptable here.

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.

What if the function throws before the region check is done in setupAuthentication?

Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Resolved
Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Outdated
Comment on lines +214 to +216
String token = generateAWSMSKToken(context->region, credentials);

auto now = std::chrono::system_clock::now();

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 be conservative on the expiry time.

Suggested change
String token = generateAWSMSKToken(context->region, credentials);
auto now = std::chrono::system_clock::now();
auto now = std::chrono::system_clock::now();
String token = generateAWSMSKToken(context->region, credentials);

&& !boost::iequals(kafka_config.get("security.protocol"), "SASL_SSL"))
LOG_WARNING(
params.log,
"kafka_security_protocol='{}' will be overridden to 'SASL_SSL' — AWS MSK IAM requires SASL_SSL.",

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
"kafka_security_protocol='{}' will be overridden to 'SASL_SSL' — AWS MSK IAM requires SASL_SSL.",
"kafka_security_protocol='{}' will be overridden to 'SASL_SSL' - AWS MSK IAM requires SASL_SSL.",

Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Outdated
Comment on lines +188 to +190
"AWS MSK IAM: cached OAuth context uses region '{}' but broker list '{}' resolves to region '{}'. "
"Consumer and producer must connect to MSK clusters in the same AWS region.",
context_holder->region, broker_list, effective_region);

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
"AWS MSK IAM: cached OAuth context uses region '{}' but broker list '{}' resolves to region '{}'. "
"Consumer and producer must connect to MSK clusters in the same AWS region.",
context_holder->region, broker_list, effective_region);
"AWS MSK IAM: Different regions used: already configured region is '{}' but got another region '{}'. "
"Consumer and producer of the same table must connect to MSK clusters in the same AWS region.",
context_holder->region, effective_region);

kalavt and others added 2 commits June 7, 2026 10:46
- Fix UBSan: guard LOG_DEBUG against null logger
- Fix loop condition: start <= size() -> start < size()
- Support China partition broker hostnames (.amazonaws.com.cn)
- Move timestamp before token generation for conservative expiry
- Replace em-dash with ASCII hyphen in log message
- Improve region mismatch error message wording
- Strengthen test assertions (move checks outside try/catch)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Comment thread src/Storages/Kafka/AWSMSKIAMAuth.cpp Resolved

@antaljanosbenjamin antaljanosbenjamin left a comment

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.

Once the unit tests are passing, I think we are good to merge this.

constexpr std::chrono::seconds TOKEN_LIFETIME{300};
constexpr std::chrono::seconds PRESIGNED_URL_EXPIRY{900};

String generateAWSMSKToken(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the only code that proves the new AWS_MSK_IAM mechanism can produce a token MSK will accept, but none of the added tests exercise generateAWSMSKToken or the OAUTH callback. The current tests only cover region parsing and config rewriting, so a regression in the signed URL shape (Action, service scope, User-Agent, base64url encoding, or expiry) would still pass while the feature fails at runtime.

Please add a deterministic unit test with static dummy AWS credentials that invokes this token generation path, decodes the token, and asserts the expected host/query parameters and expiry. Making generateAWSMSKToken test-visible is enough; no live AWS or Kafka dependency is needed.

@clickhouse-gh

clickhouse-gh Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.70% 84.60% -0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.30% 77.20% -0.10%

Changed lines: Changed C/C++ lines covered by tests: 232/257 (90.27%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@kalavt

kalavt commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@antaljanosbenjamin
All CI checks pass except CH Inc sync which is an internal sync job unrelated to this PR,
might related to contrib/cppkafka submodule change?

@flaviomalavazi

Copy link
Copy Markdown
Contributor

@kalavt, I've opened a PR against your branch to try to improve test coverage for the authentication piece :)

@antaljanosbenjamin

Copy link
Copy Markdown
Member

Sorry, this flew under my radar. Merging it.

@antaljanosbenjamin antaljanosbenjamin removed the submodule changed At least one submodule changed in this PR. label Jun 29, 2026
@antaljanosbenjamin
antaljanosbenjamin added this pull request to the merge queue Jun 29, 2026
@antaljanosbenjamin
antaljanosbenjamin removed this pull request from the merge queue due to a manual request Jun 29, 2026
@antaljanosbenjamin
antaljanosbenjamin added this pull request to the merge queue Jun 29, 2026
Merged via the queue into ClickHouse:master with commit f39e096 Jun 29, 2026
166 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 29, 2026
alexey-milovidov pushed a commit to andremm/ClickHouse that referenced this pull request Jul 2, 2026
…rowsOnZeroChecksum

The test deliberately exercises the zero-checksum guard in
`getBackupDataFileName`, which throws `DB::Exception(LOGICAL_ERROR, ...)`.
On non-debug, non-sanitizer builds (e.g. `Unit tests (amd_llvm_coverage)`)
the test passes, but `Exception::~Exception()` then logs the exception
through `ForcedCriticalErrorsLogger` because `LOGICAL_ERROR` is treated
as an "important" error code unless `markAsLogged` has been called. The
resulting `Code: 49. DB::Exception: Backup checksum should not be zero
(test.bin). (LOGICAL_ERROR)` line plus its full stack trace ends up on
the gtest binary's stderr after the test's `[ OK ]` line.

When an unrelated test in the same `unit_tests_dbms` binary later hangs
(e.g. `SchedulerWorkloadResourceManager.DropNotEmptyQueueLong` per the
report linked below), the wrapping `gdb -batch ... -ex run` runner times
out, kills the binary mid-suite, and `gtest.json` is never written. The
Praktika `from_gtest` parser then has nothing to parse and falls back to
log-scraping, which surfaces the leaked `Backup checksum should not be
zero` stack trace as a fake `-FunctionsStress` failure in CIDB. Sixteen
hits across `Unit tests (amd_llvm_coverage)` on PRs ClickHouse#100177, ClickHouse#105784,
ClickHouse#96100 over the past 60 days follow this pattern; the underlying
contributor is the chronic `SchedulerWorkloadResourceManager` /
`FunctionsStress` family hang, not the backup test.

Replace `EXPECT_THROW(..., Exception)` with an equivalent `try` block
that calls `markAsLogged` on the caught exception, mirroring the pattern
already used in `executeQuery.cpp` (commit 64a4caa "Mark fuzzer
exceptions as logged to prevent ForcedCriticalErrorsLogger") to suppress
the stray stack trace. Verified locally: built `unit_tests_dbms` in
release mode (`-O3 -DNDEBUG`, `ENABLE_TESTS=1`, no sanitizer) and
confirmed the pre-fix binary prints a 17-frame stack trace to stderr on
this test, while the post-fix binary runs the test silently with
`[ OK ]` and no trace.

Related: ClickHouse#100177

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Implements SASL_SSL/OAUTHBEARER-based authentication for AWS MSK IAM
using SigV4-presigned URLs as tokens, as required by the MSK IAM auth
protocol.

New setting: kafka_sasl_mechanism = 'AWS_MSK_IAM'
New setting: kafka_aws_region (auto-detected from broker hostname if not set)

Implementation:
- AWSMSKIAMAuth.{h,cpp}: token generation via AWSAuthV4Signer::PresignRequest,
  callback registered with librdkafka via rd_kafka_conf_enable_sasl_queue +
  set_oauthbearer_token_refresh_callback
- KafkaConfigLoader: skips writing sasl.mechanism for AWS_MSK_IAM (librdkafka
  does not know this value); sets SASL_SSL and OAUTHBEARER inside setupAuthentication
- StorageKafka / StorageKafka2: ensureOAuthContext() ensures a single shared
  S3CredentialsProviderChain across all consumers (thread-safe, mutex-guarded)
- cppkafka submodule updated to release-0.4.1 for set_oauthbearer_token_refresh_callback

Closes ClickHouse#96100
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Skip `use_environment_credentials` in `setKafkaConfigValue` (not a
librdkafka property). Add `NOLINT` and `Ok` comment to suppress
`bugprone-empty-catch` in the gtest.

ClickHouse#96100
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
- Remove case-insensitive flag from region regex; `(?i)` could return
  uppercase regions that then fail `isValidAWSRegion`'s lowercase check
- Scan all brokers for region auto-detection instead of only the first,
  so configs with a custom alias as the first broker still work

ClickHouse#96100
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…uth_v2

Add AWS MSK IAM authentication for Kafka table engine
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…rowsOnZeroChecksum

The test deliberately exercises the zero-checksum guard in
`getBackupDataFileName`, which throws `DB::Exception(LOGICAL_ERROR, ...)`.
On non-debug, non-sanitizer builds (e.g. `Unit tests (amd_llvm_coverage)`)
the test passes, but `Exception::~Exception()` then logs the exception
through `ForcedCriticalErrorsLogger` because `LOGICAL_ERROR` is treated
as an "important" error code unless `markAsLogged` has been called. The
resulting `Code: 49. DB::Exception: Backup checksum should not be zero
(test.bin). (LOGICAL_ERROR)` line plus its full stack trace ends up on
the gtest binary's stderr after the test's `[ OK ]` line.

When an unrelated test in the same `unit_tests_dbms` binary later hangs
(e.g. `SchedulerWorkloadResourceManager.DropNotEmptyQueueLong` per the
report linked below), the wrapping `gdb -batch ... -ex run` runner times
out, kills the binary mid-suite, and `gtest.json` is never written. The
Praktika `from_gtest` parser then has nothing to parse and falls back to
log-scraping, which surfaces the leaked `Backup checksum should not be
zero` stack trace as a fake `-FunctionsStress` failure in CIDB. Sixteen
hits across `Unit tests (amd_llvm_coverage)` on PRs ClickHouse#100177, ClickHouse#105784,
ClickHouse#96100 over the past 60 days follow this pattern; the underlying
contributor is the chronic `SchedulerWorkloadResourceManager` /
`FunctionsStress` family hang, not the backup test.

Replace `EXPECT_THROW(..., Exception)` with an equivalent `try` block
that calls `markAsLogged` on the caught exception, mirroring the pattern
already used in `executeQuery.cpp` (commit 64a4caa "Mark fuzzer
exceptions as logged to prevent ForcedCriticalErrorsLogger") to suppress
the stray stack trace. Verified locally: built `unit_tests_dbms` in
release mode (`-O3 -DNDEBUG`, `ENABLE_TESTS=1`, no sanitizer) and
confirmed the pre-fix binary prints a 17-frame stack trace to stderr on
this test, while the post-fix binary runs the test silently with
`[ OK ]` and no trace.

Related: ClickHouse#100177

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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 manual approve Manual approve required to run CI pr-feature Pull request with new product feature 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