hudi-agent commented on code in PR #19778:
URL: https://github.com/apache/hudi/pull/19778#discussion_r3901132025
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1661,12 +1661,35 @@ public void releaseResources(String instantTime) {
@Override
public void close() {
- // Stop timeline-server if running
- super.close();
- // Calling this here releases any resources used by your index, so make
sure to finish any related operations
- // before this point
- this.index.close();
- this.tableServiceClient.close();
+ // The index and the table service client are this class's own resources;
a failure while the
+ // base client releases its own must not leave them open.
+ Exception failure = null;
+ try {
+ // Stop timeline-server if running
+ super.close();
+ } catch (Exception e) {
+ failure = e;
+ }
+ try {
+ // Calling this here releases any resources used by your index, so make
sure to finish any related operations
+ // before this point
+ this.index.close();
+ } catch (Exception e) {
+ failure = failure == null ? e : addSuppressed(failure, e);
+ }
+ try {
+ this.tableServiceClient.close();
+ } catch (Exception e) {
+ failure = failure == null ? e : addSuppressed(failure, e);
+ }
+ if (failure != null) {
+ throw failure instanceof RuntimeException ? (RuntimeException) failure :
new HoodieException(failure);
+ }
+ }
Review Comment:
🤖 nit: `addSuppressed` does the same thing as `appendFailure` in the base
class, just with a different name and without the null-guard (so the call sites
need an inline ternary). Could you either promote `appendFailure` to
`protected` and reuse it here, or at least align the name so the two close()
paths are visually consistent?
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieClient.java:
##########
@@ -151,10 +151,40 @@ private static TransactionManager
buildTransactionManager(HoodieEngineContext co
*/
@Override
public void close() {
- stopEmbeddedServerView(true);
- this.context.setJobStatus("", "");
- this.heartbeatClient.close();
- this.txnManager.close();
+ // Each step owns a resource the others do not, and the transaction
manager holds the write
+ // lock, so an earlier failure must not stop the rest from being released.
+ Exception failure = null;
+ try {
+ stopEmbeddedServerView(true);
+ } catch (Exception e) {
+ failure = e;
+ }
+ try {
+ this.context.setJobStatus("", "");
+ } catch (Exception e) {
+ failure = appendFailure(failure, e);
+ }
+ try {
+ this.heartbeatClient.close();
+ } catch (Exception e) {
+ failure = appendFailure(failure, e);
+ }
+ try {
+ this.txnManager.close();
Review Comment:
🤖 The new test covers the subclass path (index fails -> tableServiceClient
still closes), but the base chain the description calls out as most important —
a failure in stopEmbeddedServerView/heartbeatClient still releasing
txnManager's write lock — isn't directly exercised (super.close() fully
succeeds in that test). Might be worth a small test for that path too, e.g.
inject a failure into stopEmbeddedServerView and assert txnManager.close()
still runs.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
--
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]