hudi-agent commented on code in PR #19571:
URL: https://github.com/apache/hudi/pull/19571#discussion_r3748698568


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/StorageBasedLockProvider.java:
##########
@@ -458,8 +458,15 @@ public void unlock() {
       if (heartbeatManager.hasActiveHeartbeat()) {
         logger.debug("Owner {}: Gracefully shutting down heartbeat.", ownerId);
         if (!heartbeatManager.stopHeartbeat(true)) {
+          // The heartbeat task would not stop, so we must not expire the 
lock: the task could
+          // still renew it after we returned. See 
LockProviderHeartbeatManager#stopHeartbeat for
+          // which of the two sub-cases (interrupted vs. still-inflight) was 
logged.
+          logger.error("Owner {}: Cannot release lock {} - heartbeat failed to 
stop, so the lock is "
+                  + "left un-expired and will be reclaimed only after its 
lease elapses. "
+                  + "interrupted={}", ownerId, lockFilePath, 
Thread.currentThread().isInterrupted());
           
hoodieLockMetrics.ifPresent(HoodieLockMetrics::updateLockReleaseFailureMetric);
-          throw new 
HoodieLockException(generateLockStateMessage(FAILED_TO_RELEASE));
+          throw new HoodieLockException(
+              generateLockStateMessage(FAILED_TO_RELEASE, 
"HEARTBEAT_STOP_FAILED"));

Review Comment:
   🤖 nit: could you lift these cause strings (`"HEARTBEAT_STOP_FAILED"`, 
`"INTERRUPTED_DURING_THROTTLE_BACKOFF"`, `"THROTTLE_RETRIES_EXHAUSTED"`, 
`"EXPIRE_WRITE_FAILED"`) into private static final String constants? Right now 
they're scattered across call sites and matched against raw literals in tests — 
a rename would break at runtime, not compile time, and there's no single place 
to see the full set.
   
   <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]

Reply via email to