Skip to content

Backport #119853 to 26.6: Fix a server crash on a NATS table whose credentials the broker rejects - #120013

Merged
clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/119853
Sep 14, 2026
Merged

clickhouse-gh[bot] merged 3 commits into
26.6from
backport/26.6/119853

Conversation

@robot-clickhouse-ci-2

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #119853

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.6.7.15

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix labels Sep 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [941bc33]

Summary: ✅

alexey-milovidov and others added 2 commits September 14, 2026 21:37
On `master` the streaming cycle subscribes the consumers it finds unsubscribed
before it reads from them. 26.6 has no such step: `initializeConsumersFunc`
subscribes the consumers once, right after creating them, and `NATSSource`
subscribes a consumer it finds unsubscribed only for the duration of its own
cycle, unsubscribing it on destruction. A cycle over a consumer which has
nothing buffered yet ends at once, so the consumers rebuilt by the backported
recovery path held a subscription for a fraction of a millisecond every
500 ms and never received a message: the broker log of the failed CI run
shows `subscribed sid N` / `unsubscribed sid N` pairs after the credentials
are accepted again, and the table stayed idle.

Subscribe the rebuilt consumers right after creating them, the way
`initializeConsumersFunc` does for the first ones.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=120013&sha=2ce5c98f204faea061807a26a704af29a1490e3c&name_0=BackportPR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%204%2F6%29
PR: #120013

Co-Authored-By: Claude Fable 5.1 <[email protected]>
26.6 has neither `SYSTEM STOP <table>` for streaming engines nor the
`nats_wait_for_flush_interval` setting, so drop the two tests of a stopped
table recovering from a closed connection. Its JetStream consumer does not
acknowledge messages after the insert into the views either, so drop the test
of unacknowledged messages surviving the rotation; the remaining JetStream
test, which drains the backlog exactly once through the rebuilt connection,
passes on 26.6.

The NATS integration tests were removed from 26.6, so restore the pieces the
JetStream test needs: `__init__.py`, `nats_certs.sh` which `ClickHouseCluster`
runs for `with_nats=True`, and a `common.py` with the two helpers the test
uses.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=120013&sha=2ce5c98f204faea061807a26a704af29a1490e3c&name_0=BackportPR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%204%2F6%29
PR: #120013

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 The integration reds were the backported tests exercising things 26.6 does not have, plus one genuine gap in the backported recovery path on 26.6. Pushed two commits:

  • 97090610eadb subscribes the consumers rebuilt after a closed connection. On master the streaming cycle subscribes consumers it finds unsubscribed, but on 26.6 that is done once by initializeConsumersFunc, and NATSSource subscribes an unsubscribed consumer only for its own cycle. The broker log of the failed run shows the rebuilt consumer subscribing and unsubscribing within a millisecond every 500 ms and never receiving a message, so the table stayed idle after the credentials were accepted again (test_nats_credentials_rejected_after_rotation under ASan).
  • 941bc3337bd6 adapts the tests: 26.6 has neither SYSTEM STOP <table> for streaming engines nor nats_wait_for_flush_interval, so the two stopped-table tests are dropped; its JetStream consumer does not acknowledge after the insert into views, so the unacknowledged-redelivery test is dropped too. The NATS test directory had been removed from 26.6, so __init__.py, nats_certs.sh and a two-helper common.py are restored for the JetStream test, which failed to import before.

Locally on 26.6 with the branch's contrib/nats-io: test_nats_credentials_rejected_after_rotation and test_jetstream_credentials_rejected_after_rotation pass.

@clickhouse-gh
clickhouse-gh Bot merged commit a8021d4 into 26.6 Sep 14, 2026
38 of 39 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.6/119853 branch September 14, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants