Repository navigation
Revert "Resume a NATS JetStream subscription after a reconnect" - #119270
alexey-milovidov merged 1 commit into
Conversation
This reverts the changes of ClickHouse#115343 (merge commit 5564667), together with the three follow-up commits that only adjust the tests it added: 2abc75f, 8551a53 and 9eb7ad1. The NATS TLS certificate work that landed on top of the same files is kept: `src/Storages/NATS/NATSConnection.cpp` keeps its `ErrorCodes` block and `#include <Common/Exception.h>`, which the reverted commit had introduced and the certificate code now needs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [16ecb3c] AI ReviewSummaryThis PR reverts the JetStream reconnect-resume work from Findings❌ Blockers
Final VerdictChanges requested. |
| /// view is gone, and a materialized view whose target is `Null` legitimately ends in the same | ||
| /// discarding sink while being a view the table streams to. The check can only err towards | ||
| /// skipping a cycle whose pipeline would have inserted somewhere, which consumes nothing. | ||
| if (!checkDependencies(table_id)) |
There was a problem hiding this comment.
InterpreterInsertQuery::execute() can still build a NullSinkToStorage chain here when skip_destination_table is true and the last ready dependent view disappears in the gap between threadFunc()'s pre-check and this lookup (see InsertDependenciesBuilder::createChainWithDependencies()). The code below then still creates NATSSources and unconditionally ackConsumed() at the end of streamToViews(), so a DROP VIEW or DETACH TABLE in that window can acknowledge a full nats_max_block_size batch that reached no table.
We still need the post-execute() checkDependencies(table_id) guard that this revert removed, or some equivalent check before any source is created.
| consumer->finishAndReturnUnprocessed(INATSConsumer::SkippedMessages::Acknowledge); | ||
| consumer->unsubscribe(); | ||
| consumer->unsubscribe(/*finish_queue=*/true); | ||
| consumer->dropBuffered(); |
There was a problem hiding this comment.
This puts the JetStream backlog-loss path back on every unsubscribe/recovery. A closed pull subscription does not imply an empty local queue: if the broker restarts while the consumer is behind, onMsg may already have a large backlog of MessageData::msg handles buffered here. Clearing the queue after unsubscribe(/*finish_queue=*/true) destroys those handles without natsMsg_Nak, so the broker keeps the rows in AckPending until AckWait expires.
That means a graceful restart, SYSTEM STOP, or last-view drop can leave the view short for minutes even though the rows were already buffered locally. dropBuffered() is only safe once the subscription is already gone; this path still needs the old "wait for the backlog to drain or return it before destroying the subscription" behavior.
Reverts #115343.
The revert also undoes the three follow-up commits that only adjust the tests that pull request added (
2abc75f9c49,8551a53f2d5,9eb7ad13b55).The NATS TLS certificate work that landed on top of the same files is kept.
src/Storages/NATS/NATSConnection.cppkeeps itsErrorCodesblock and#include <Common/Exception.h>, which #115343 introduced andloadNATSCertificates/validateNATSCertificatesnow need.Related: #115343
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/119270]
Version info
26.9.1.1156(included in26.9and later)