Skip to content

KAFKA-16987: Release connector resources after failure - #23056

Open
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-16987-failure-cleanup
Open

KAFKA-16987: Release connector resources after failure#23056
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-16987-failure-cleanup

Conversation

@lh0156

@lh0156 lh0156 commented Aug 3, 2026

Copy link
Copy Markdown

Summary

When a connector enters FAILED during initialization, startup, or an external failure notification, connector-owned resources can remain allocated until a later shutdown request. This change performs the failure cleanup immediately while preserving FAILED status so a later STOPPED target-state request can still be processed.

The cleanup calls connector.stop() at most once for each start lifecycle, preserves the original failure if stop() also throws, and continues closing the connector context, metrics, and offset resources.

Testing

  • Added parameterized source/sink lifecycle tests for initialization failure, startup failure, external failure, and stop failure during cleanup.
  • ./gradlew :connect:runtime:test --tests org.apache.kafka.connect.runtime.WorkerConnectorTest
  • ./gradlew :connect:runtime:test --tests org.apache.kafka.connect.integration.ConnectWorkerIntegrationTest.testStoppedState
  • ./gradlew :connect:runtime:spotlessCheck :connect:runtime:checkstyleMain :connect:runtime:checkstyleTest :connect:runtime:spotbugsMain
  • ./gradlew :connect:runtime:test completed 1,529 tests with one unrelated timing-sensitive OffsetStorageReader test failure; that test passed when rerun independently.

This contribution is my original work, and I license it to the Apache Software Foundation under the Apache License, Version 2.0.

Release connector-owned resources as soon as a connector enters FAILED while preserving the FAILED status for subsequent STOPPED requests. Add lifecycle tests covering initialization, startup, external, and cleanup failures for source and sink connectors.

Generated-by: OpenAI Codex (GPT-5)

Signed-off-by: Yunseop Eom <62834176+lh0156@users.noreply.github.com>
@github-actions github-actions Bot added triage PRs from the community connect labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connect triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant