Skip to content

KSQL-15025 | Address misc items for ksql - #11059

Open
Vedarth Sharma (VedarthConfluent) wants to merge 2 commits into
8.0.xfrom
vesharma/8.0.x/ksql-15000-pattern-c
Open

KSQL-15025 | Address misc items for ksql#11059
Vedarth Sharma (VedarthConfluent) wants to merge 2 commits into
8.0.xfrom
vesharma/8.0.x/ksql-15000-pattern-c

Conversation

@VedarthConfluent

Copy link
Copy Markdown
Member

Description

What behavior do you want to change, why, how does your patch achieve the changes?
Address misc items for ksql

Testing done

Describe the testing strategy. Unit and integration tests are expected for any behavior changes.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")
  • Do these changes have compatibility implications for rollback? If so, ensure that the ksql command version is bumped.

…/2 clients and print-consumer on terminal paths

Two related resource leaks on terminal paths:

(1) KsqlClient.close() walked only the two HTTP/1 client fields
(httpNonTlsClient, httpTlsClient). The HTTP/2 variants
(httpNonTlsClientHttp2 and httpTlsClientHttp2) each own a Netty
channel pool and event-loop threads; leaving them un-closed leaks one
pool per construct/close cycle. Test harnesses, hot reloads, and any
reconnect path that recreates the client accumulates dangling pools.
Fix: close both HTTP/2 clients in close() with the same swallow-and-
continue pattern as the HTTP/1 closes.

(2) BlockingPrintPublisher.doSend() exited its outer loop when
messagesWritten >= limit (LIMIT clause) but only closed topicConsumer
when isClosed() was true. The KafkaConsumer (Selector thread + broker
connections) leaked until the connection's end handler eventually
fired, which on abrupt client disconnect may not happen. Fix: also
close when the limit has been reached. The SEND_MAX_BATCH_SIZE
re-schedule path keeps messagesWritten < limit, so it is not affected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@confluent-cla-assistant

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

…sher closed at LIMIT, not just close the consumer

The previous commit closed topicConsumer when the doSend() loop
terminated because LIMIT was reached. That correctly stopped the
KafkaConsumer leak, but introduced a latent race: messagesWritten is
a local variable reset on every doSend() invocation. If maybeSend()
triggered another doSend() after LIMIT (which happens because
BasePublisher's demand bookkeeping is asynchronous), the second
doSend() would have messagesWritten=0, pass the loop guard, and try
to topicConsumer.poll() on the now-closed consumer.

Fix: when LIMIT is reached, set `closed = true` before scheduling
sendComplete. The next doSend() invocation - if there is one - exits
at the !isClosed() guard without touching the consumer. The bottom
close-block can revert to the original `if (isClosed())` condition
because closed=true now reflects both shutdown paths.

This shows up in CI on PR #11059 as failures in the
PRINT '...' LIMIT N integration tests in ApiIntegrationTest and
RestApiTest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant