Skip to content

Commit

Permalink
Decrement expectedNumberOfClientsSendingRenews for expired leases (#1271
Browse files Browse the repository at this point in the history
)

Move the logic that decrements the expected number of clients into
cancelInternal - this should ensure that we're calling it both for
explicit cancels as well as well as when the instance lease expires.

Fixes #1266.
  • Loading branch information
snowp authored and troshko111 committed Jan 27, 2020
1 parent 1ef3c55 commit cefadab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,20 @@ protected boolean internalCancel(String appName, String id, boolean isReplicatio
}
invalidateCache(appName, vip, svip);
logger.info("Cancelled instance {}/{} (replication={})", appName, id, isReplication);
return true;
}
} finally {
read.unlock();
}

synchronized (lock) {
if (this.expectedNumberOfClientsSendingRenews > 0) {
// Since the client wants to cancel it, reduce the number of clients to send renews.
this.expectedNumberOfClientsSendingRenews = this.expectedNumberOfClientsSendingRenews - 1;
updateRenewsPerMinThreshold();
}
}

return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,7 @@ public boolean cancel(final String appName, final String id,
final boolean isReplication) {
if (super.cancel(appName, id, isReplication)) {
replicateToPeers(Action.Cancel, appName, id, null, null, isReplication);
synchronized (lock) {
if (this.expectedNumberOfClientsSendingRenews > 0) {
// Since the client wants to cancel it, reduce the number of clients to send renews
this.expectedNumberOfClientsSendingRenews = this.expectedNumberOfClientsSendingRenews - 1;
updateRenewsPerMinThreshold();
}
}

return true;
}
return false;
Expand Down

0 comments on commit cefadab

Please sign in to comment.