suxiaogang223 opened a new pull request, #66612:
URL: https://github.com/apache/doris/pull/66612
### What problem does this PR solve?
Issue Number: Related to #65086
Related PR: #65868
Problem Summary:
The Paimon JNI writer had three resource-lifecycle gaps:
1. Native writer threads could remain attached to the JVM, and JNI local
references created during writer initialization were not scoped by a local
frame.
2. Paimon's temporary file IO bypassed Doris spill directory selection,
capacity checks, query cleanup, and spill metrics.
3. IO-manager close failures could stop cleanup early and hide subsequent
failures, while the native side could release resources still referenced by
Java after a failed close.
This PR:
- adds a reusable `Jni::ScopedEnv` utility that detaches only threads it
attached and safely clears the shared TLS cache before detaching;
- scopes JNI local references used by the Paimon writer;
- adds an `ExternalSpillDirectory` abstraction and a `DorisIOManager`
adapter so Paimon temporary IO participates in Doris spill capacity, metrics,
and query cleanup;
- makes Java IO-manager shutdown attempt all closes and aggregate failures;
- retains native memory and spill resources after a failed Java close,
preventing use-after-free, and rejects new writers after a close failure.
### Release note
None
### Check List (For Author)
- Test
- [ ] Regression test
- [x] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
Validation performed:
- FE/Paimon Java reactor build and 7 unit tests passed.
- BE files passed clang-format 16 `--dry-run --Werror`.
- `git diff --check` passed.
- BE compilation and regression tests were not run, following the requested
validation scope.
- Behavior changed:
- [ ] No.
- [x] Yes. Paimon temporary IO is now managed and accounted for by Doris
spill infrastructure, and JNI writer resources use scoped cleanup.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]