[Fix][Connector-V2] Run Pulsar cleanup with connector classloader#11170
Open
DanielLeens wants to merge 4 commits into
Open
[Fix][Connector-V2] Run Pulsar cleanup with connector classloader#11170DanielLeens wants to merge 4 commits into
DanielLeens wants to merge 4 commits into
Conversation
1d81699 to
49c46d0
Compare
DanielLeens
commented
Jul 2, 2026
DanielLeens
left a comment
Contributor
Author
There was a problem hiding this comment.
Thanks for the contribution. I reviewed the latest head from the Pulsar source/sink shutdown paths through the classloader and cleanup-order boundaries, and this looks good to me.
What this PR solves
- User pain: Pulsar producer / consumer / client / admin cleanup can also run from engine-managed threads. If the thread context classloader no longer points at the Pulsar connector, lazy class resolution during close can fail. On top of that, the previous close order left shared admin/client resources easier to shut down before their users were fully stopped.
- Fix approach: run Pulsar cleanup through
PulsarConfigUtil.runWithConnectorClassLoader(...), stop the discovery executor before admin close, close split readers before the shared client, and preserve all cleanup failures instead of losing later ones. - One-line summary: this is a targeted Pulsar shutdown-boundary fix, not a behavior change in normal read/write semantics.
Full execution path I checked
Pulsar task shutdown
-> source reader / sink writer / committer / enumerator close
-> producer / consumer / client / admin cleanup
-> before this PR
-> wrong TCCL can break lazy class resolution during close
-> shared admin/client can be closed while readers or discovery still depend on them
-> after this PR
-> connector classloader is restored for cleanup
-> discovery executor stops before admin close
-> split readers close before shared client close
-> cleanup failures are aggregated instead of truncating later cleanup
Key findings
- The normal runtime path definitely hits this change because all Pulsar close paths now go through the helper.
- This PR improves two real lifecycle boundaries at once: classloader context during cleanup, and shutdown ordering of shared resources.
- The new tests cover the classloader boundary and the close-time contract on the writer/source side.
- I do not see a reopened blocker on the current head.
Findings
- No blocking issues from Daniel's side on the latest head.
Conclusion: can merge
- Blocking items
- None.
- Suggested non-blocking follow-up
- None.
Overall, this is a precise fix for the Pulsar cleanup boundary and shutdown ordering, and I'm happy to approve it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Replace the version-specific Pulsar/Netty/HK2 private-class preload workaround with a maintainable cleanup boundary.
Root cause
Pulsar can lazily resolve shaded Netty/Jersey implementation classes while closing producers, consumers, clients, and admins. SeaTunnel close paths can run from engine threads whose context classloader no longer points to the Pulsar connector, so hard-coding private helper class names only masks the symptom and will break across Pulsar dependency changes.
Changes
Validation
./mvnw -pl seatunnel-connectors-v2/connector-pulsar -am -nsu spotless:apply./mvnw -pl seatunnel-connectors-v2/connector-pulsar -nsu testseatunnel-engine-uiwas not included because this PR only changes the Pulsar connector backend module.