Repository navigation
Conversation
Point `contrib/nats-io` at `ClickHouse/v3.13.0` (`137843892fbd`) of the ClickHouse fork https://github.com/ClickHouse/nats.c, which is upstream `v3.13.0` plus three build-portability patches (FreeBSD `sys/socket.h`, `stdio.h` in `n-unix.h`, `natsp.h` included first in `js.c` and `kv.c`). The previous fork patch "Remove legacy OpenSSL API usage" is dropped because it became obsolete: upstream now requires OpenSSL 1.1.1+ and removed the legacy init/cleanup calls and `TLSv1_2_client_method` usage itself. Notable upstream changes since v3.9.2 relevant to the NATS table engine: * `natsConnection_Close` now always flushes properly. * `nats_CloseAndWait` no longer segfaults on thread exit. * JetStream async pull no longer double-frees a message. * Fixed a deadlock in `js_MaybeFetchMore`. * libuv event loop no longer crashes if the connection is destroyed while consuming; the socket is closed only after polling is done. * `SSL_read`/`SSL_write` are protected with a mutex, and a possible hang during the TLS handshake was fixed. * Connection drain no longer causes a missed reply or a 100ms delay. * TLS is auto-enabled for the `tls://` URL scheme. * New `ObjectStore` API (`src/object.c`), per-message TTL and pull consumer priority groups. No changes were needed in `contrib/nats-io-cmake/CMakeLists.txt`: the only new source file is `src/object.c`, which implements the standalone `ObjectStore` public API and is not referenced by any translation unit ClickHouse compiles, so it stays out of the source list just like the `micro*.c` files already are. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Workflow [PR], commit [59ddc78] Summary: ❌
AI Review
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes36 object files changed (+86.10 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units53 translation units recompiled, 59 s compile time in total, 53 of them have a recent master baseline. |
|
🕵 A heads-up on ordering with #120202, which bumps the same submodule inside the current
#120202 should land first, since it is the only open path for all three. Whichever of the two merges second has to carry the other's commits forward — so if this one lands after #120202, please port those three onto the |
# Conflicts: # contrib/nats-io
Point `contrib/nats-io` at `ClickHouse/v3.13.0` (`6622c7dc92d0`) of the ClickHouse fork https://github.com/ClickHouse/nats.c, which is upstream `v3.13.0` plus five patches: * build portability: `sys/socket.h` on FreeBSD and `stdio.h` in `src/include/n-unix.h`, and `natsp.h` included before `ctype.h` in `src/js.c` and `src/kv.c` (clang 15); * libuv adapter: do not let an attach overtake a queued poll removal; * libuv adapter: do not close an already released poll handle; * retry `poll` on `EINTR` when waiting for a socket. Two older fork patches are dropped because upstream absorbed them: the legacy OpenSSL 1.1 API usage removal (upstream now requires OpenSSL 1.1.1+ and removed the legacy init/cleanup calls and `TLSv1_2_client_method` itself) and the libc `rand` replacement (v3.13.0 uses the `nats_Rand64` CMWC generator seeded from `RAND_bytes`). Notable upstream changes since v3.9.2 relevant to the NATS table engine: * TLS is auto-enabled for the `tls://` URL scheme, without an explicit `natsOptions_SetSecure` call. * `natsConnection_Close` now always flushes properly. * JetStream async pull no longer double-frees a message, and a deadlock in `js_MaybeFetchMore` was fixed. * The libuv event loop no longer crashes if the connection is destroyed while consuming; the socket is closed only after polling is done. * `SSL_read`/`SSL_write` are protected with a mutex, and a possible hang during the TLS handshake was fixed. * Connection drain no longer causes a missed reply or a 100ms delay. * New `ObjectStore` API (`src/object.c`), per-message TTL and pull consumer priority groups. No changes were needed in `contrib/nats-io-cmake/CMakeLists.txt`: the only new source file is `src/object.c`, which implements the standalone `ObjectStore` public API and is not referenced by any translation unit ClickHouse compiles, so it stays out of the source list just like the `micro*.c` files already are. `src/version.h` is checked in, not generated, and already carries 3.13.0. Co-Authored-By: Claude Code <[email protected]>
Since upstream nats.c b89b44d0 (part of v3.13.0), `natsLibuv_Read` calls `uv_poll_stop` from whichever thread removes the read event. On `DROP TABLE`, `natsConnection_Close` runs in the query thread while the `NATSHandler` loop thread is inside `uv_run`, so ThreadSanitizer reports a data race between `uv__io_stop` and `uv__io_poll`, and the `DROP` hung. Point `contrib/nats-io` at a fork commit that stops polling immediately only from the event loop thread: ClickHouse/nats.c#14 CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119507&sha=acb8e8bda856c88eda8525e5abbeec03074b0ce4&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%20targeted%29 PR: ClickHouse#119507 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sses `nats-io` v3.13.0 enables TLS by itself for a `tls://` address in `natsOptions_SetURL` / `natsOptions_SetServers`, unless the caller has explicitly called `natsOptions_SetSecure`. `NATSConnection` only called it for `nats_secure = 1`, so an explicit `nats_secure = 0` was lost. Carry the `changed` flag of the setting into `NATSConfiguration` and call `natsOptions_SetSecure(false)` when the setting is explicitly disabled. Document the `tls://` behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The The fix is in the fork, ClickHouse/nats.c#14: stop polling immediately only from the event loop thread. I also addressed the review comment about explicit |
`stacktraces_on_timeout_decorator` caught only `subprocess.TimeoutExpired`, which is raised when the 600 s `DEFAULT_QUERY_TIMEOUT` wait expires. A caller-supplied `timeout=` kills the client from a `Timer` instead, so `get_answer`, `get_error` and `get_answer_and_error` raise `QueryTimeoutExceedException`, and the `system.stack_trace` dump never ran on that path. Catch both exceptions. The dump now: - runs at most once per (test, host, port), because caller timeouts sit in retry loops (`exec_query_with_retry`, `query_with_retry`) and a dump against a wedged server costs up to its 60 s bound; - never raises: a failed dump is logged and the original exception propagates. Before, a dump that hit its own 60 s timeout replaced the original `TimeoutExpired` (PR ClickHouse#119507, test_storage_nats/test_nats_jet_stream.py::test_hiding_credentials); - targets the host the request was sent to, like `query(host=...)` does; - tags its rows with the test name (via `log_comment`) and logs where the dump went. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o` v3.13.0 fork
The bump dropped the ClickHouse-only `nats.c` fix 19edbc41 ("Destroy the
protocol parser on disconnect when an event loop is attached", backport of
nats-io/nats.c#1008) from the old `ClickHouse/v3.9.2` fork line. ClickHouse
drives `nats.c` through an external libuv event loop, so without it a half
decoded `MSG` payload could survive a reconnect and corrupt the next message.
The submodule now points to the cherry-pick of that commit on top of the
previously pinned 903972d7, pushed to the `ClickHouse/v3.13.0-parser-reset`
branch of https://github.com/ClickHouse/nats.c
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| @@ -1 +1 @@ | |||
| Subproject commit b88704dfeb55e0f1dee165b9c1daccb90d5816d4 | |||
| Subproject commit a988d8e1d37a0c22a66314e762250e7b8a8f0643 | |||
There was a problem hiding this comment.
Pinning contrib/nats-io to a988d8e1 still does not put this bump on the long-lived ClickHouse/v3.13.0 fork line that the PR description says it follows. Right now that SHA is reachable only from the two open staging branches behind ClickHouse/nats.c PRs #14 and #15, not from ClickHouse/v3.13.0 itself.
That makes the vendor pin fragile: if those PRs are merged with rewritten SHAs or the staging branches are deleted, a fresh git submodule update --init for this ClickHouse revision can stop fetching contrib/nats-io, and the next bump also loses the permanent branch that should carry these ClickHouse-only patches. Please merge the fork PRs first and then repin contrib/nats-io to the commit that actually lives on ClickHouse/v3.13.0.
There was a problem hiding this comment.
🕵 Agreed, this must be settled before merging. Status as of 2026-10-29: ClickHouse/nats.c PRs #14 and #15 are still open. #15 is stacked on #14, and its head a988d8e1 is 2 commits ahead of and 0 behind ClickHouse/v3.13.0 (6622c7dc). If a maintainer merges both with a fast-forward (or with merge commits, which keep a988d8e1 reachable from ClickHouse/v3.13.0), the current pin stays valid and needs no repin. A squash or rebase merge would change the SHAs, and then contrib/nats-io would need a repin here. I am not merging the fork PRs myself, because that is a merge decision for a human. Please do not merge this PR until #14 and #15 have landed on ClickHouse/v3.13.0.
There was a problem hiding this comment.
🕵 Status as of 2026-11-24, since this thread still describes the earlier v3.13.0 pin. The PR now pins contrib/nats-io to 523742ff, which is the head of ClickHouse/nats.c#17 (ClickHouse/v3.14.0-fixes). That commit is 2 commits ahead of and 0 behind ClickHouse/v3.14.0 (5bd80ee8), so it is not yet reachable from the long-lived branch, and the concern here still holds.
What is needed is a human merge of ClickHouse/nats.c#17 into ClickHouse/v3.14.0 with a fast-forward or a merge commit. Either keeps 523742ff reachable, and then this pin needs no change. A squash or rebase merge would rewrite the SHA and require a repin here. I authored that fork PR, so I am not merging it myself. Its CI is red on every job, which needs a look before merging.
Please do not merge this PR until 523742ff is on ClickHouse/v3.14.0. I am leaving this thread unresolved for that reason. The branch is otherwise current: master is merged in as 8ae8f7e6 without conflicts, and src/Storages/NATS compiles against the pinned submodule.
|
🕵 Status as of 2026-10-22: CI is green and the branch merges cleanly with The only remaining blocker is the one raised by the AI review: Related: ClickHouse/nats.c#14 |
Points `contrib/nats-io` at the `ClickHouse/v3.14.0` branch of the `ClickHouse/nats.c` fork (head 5bd80ee87513), which rebases the ClickHouse patch series onto upstream `v3.14.0`. `.gitmodules` already named the fork, so its URL is unchanged. Carried patches, all verified as still needed: - `src/include/n-unix.h`: include `<stdio.h>` (FreeBSD). - `src/js.c` and `src/kv.c`: include `natsp.h` before `ctype.h` for clang 15. - The event-loop fixes: parser teardown on disconnect for an attached event loop (`src/natsp.h`, `src/conn.c`), the libuv adapter poll-handle fixes (`src/adapters/libuv.h`) and the `EINTR` retry in `natsSock_WaitReady` (`src/unix/sock.c`). Patch dropped as obsolete: the `__FreeBSD__` arm of the `sys/socket.h` guard in `src/include/n-unix.h`, because upstream now includes `<sys/socket.h>` unconditionally. The two patches dropped in the previous bump (legacy OpenSSL API removal, libc `rand` replacement) are still absent from upstream and are not re-carried. No ClickHouse-side adaptation was required: `contrib/nats-io-cmake/CMakeLists.txt` still matches the v3.14.0 tree exactly (no source file was added or removed; `src/object.c` and `src/micro*.c` stay unused by `src/Storages/NATS`), `src/version.h` is checked in and now reports 3.14.0, and the public `nats.h` changes are purely additive. Co-Authored-By: Claude Code <[email protected]>
nats-io to v3.13.0nats-io from v3.9.2 to v3.14.0
The new pin carries two fixes on top of `ClickHouse/v3.14.0`: - The libuv adapter fix that stops polling immediately only from the event loop thread (`903972d7`), which the previous pin had dropped. It fixes the data race in `natsLibuv_Read` and the hanging `DROP TABLE` seen in the TSan integration tests: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119507&sha=acb8e8bda856c88eda8525e5abbeec03074b0ce4&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%20targeted%29 - A fix for a double release of the connection reference when a subscription fails after `natsSub_create` assigned `sub->conn`. Related: ClickHouse/nats.c#17 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bump
nats-iofrom v3.9.2 to v3.14.0.ClickHouse-side changes
src/Storages/NATS/NATSConnection.{h,cpp},StorageNATS.cpp— the library now enables TLS by itself fortls://addresses; an explicitnats_secure = 0still disables it, and the setting docs say so.Behaviour changes
tls://address innats_url/nats_server_listnow uses TLS withoutnats_secure = 1.Fork
<stdio.h>, clang-15 include order injs.c/kv.c, event-loop teardown, libuv poll-handle fix,EINTRretry.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Update
nats-iofrom v3.9.2 to v3.14.0.Workflow [PR]
Sync PR [sync-upstream/pr/119507]