Skip to content

Commit

Permalink
[AMORO-3410] cancel renew procedure after releasing block (#3421)
Browse files Browse the repository at this point in the history
* issue_3410 cancel renew procedure after releasing block

* fix checkstyle
  • Loading branch information
Aireed authored Feb 10, 2025
1 parent a922fe8 commit 9bfe609
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public void release(Blocker blocker) {
} catch (TException e) {
throw new IllegalStateException(
"failed to release " + tableIdentifier + "'s blocker " + blocker.blockerId(), e);
} finally {
// Regardless of whether the lock was successfully released, we will no longer renew the lock.
if (blocker instanceof RenewableBlocker) {
((RenewableBlocker) blocker).cancelRenew();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.amoro.AmsClient;
import org.apache.amoro.api.BlockableOperation;
import org.apache.amoro.api.NoSuchObjectException;
import org.apache.amoro.shade.guava32.com.google.common.annotations.VisibleForTesting;
import org.apache.amoro.shade.guava32.com.google.common.base.Preconditions;
import org.apache.amoro.shade.guava32.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.amoro.table.TableIdentifier;
Expand Down Expand Up @@ -103,6 +104,11 @@ public void renewAsync() {
.scheduleAtFixedRate(this::doRenew, interval, interval, TimeUnit.MILLISECONDS);
}

@VisibleForTesting
public ScheduledFuture getRenewTaskFuture() {
return this.renewTaskFuture;
}

private void doRenew() {
try {
this.expirationTime =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public void testBlockAndRelease() throws OperationConflictException {
BasicTableBlockerManager blockerManager = (BasicTableBlockerManager) tableBlockerManager;

Blocker block = blockerManager.block(OPERATIONS);
Assert.assertTrue(block instanceof RenewableBlocker);

blockerManager.release(block);
Assert.assertTrue(((RenewableBlocker) block).getRenewTaskFuture() == null);
}
}

0 comments on commit 9bfe609

Please sign in to comment.