src/paxos_lease.c | 48 +++++++++++++++---------------------------------
1 file changed, 15 insertions(+), 33 deletions(-)
New commits:
commit f1d109a5b5017c431db16b02f056a806f584c077
Author: David Teigland <teigland(a)redhat.com>
Date: Fri Jan 30 16:08:37 2015 -0600
sanlock: fail acquire with IDLIVE more quickly
When attempting to acquire a lease held by another
host, we check if the owner is alive by seeing its
delta lease timestamp change, and then return the
IDLIVE failure.
If the paxos acquire function doesn't immediately see
a change in the owner's timestamp, it can also check
if the local renewal thread saw the owner's timestamp
change the last time it was checked, and if so return
IDLIVE. This avoids having to potentially wait and
watch the delta lease for a number of seconds before
failing with IDLIVE.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/paxos_lease.c b/src/paxos_lease.c
index 7ada225..df60ee6 100644
--- a/src/paxos_lease.c
+++ b/src/paxos_lease.c
@@ -1389,33 +1389,6 @@ static int write_new_leader(struct task *task,
* 6 i/os = 3 1MB reads, 3 512 byte writes
*/
-/*
- * When a lease is held by host A, and host B attempts to acquire it,
- * host B will sometimes fail quickly (within a second) with IDLIVE/-243,
- * but other times will fail slowly (several seconds) with IDLIVE/-243.
- * This comes from the fact that this function (on B) is looking for a change
- * in A's delta timestamp. To detect a timestamp change, we compare the
- * last timestamp from A that was seen by our own renewal thread, against
- * the delta timestamp from A that we read here directly.
- *
- * time X: our own delta renewal thread reads A's delta timestamp as 100
- * time Y: host A renews its delta lease, writing timestamp 120
- * time Z: our own delta renewal thread reads A's delta timestamp as 120
- *
- * If we try to acquire a resource lease held by A between time X and Y,
- * paxos_lease_acquire() will read A's timestamp as 100, the same as our
- * own renewal thread last saw. paxos_lease_acquire() will reread A's
- * delta lease once a second until it changes at time Y, at which point
- * it will return IDLIVE. If Y is very shortly before Z, then
- * paxos_lease_acquire() can take up to 20 seconds to return IDLIVE.
- *
- * If we try to acquire a resource lease held by A between time Y and Z,
- * paxos_lease_acquire() will read A's timestamp as 120, which is newer
- * than our own renewal thread last saw. paxos_lease_acquire() will
- * fail immediately returning IDLIVE. If Y is very shortly after X,
- * then paxos_lease_acquire() will return IDLIVE quickly most of the time.
- */
-
int paxos_lease_acquire(struct task *task,
struct token *token,
uint32_t flags,
@@ -1605,9 +1578,19 @@ int paxos_lease_acquire(struct task *task,
goto skip_live_check;
}
- /* the owner is renewing its host_id so it's alive */
+ /*
+ * Check if the owner is alive:
+ *
+ * 1. We just read the delta lease of the owner (host_id_leader).
+ * If that has a newer timestamp than the timestamp last seen by
+ * our own renewal thread (last_timestamp), then the owner is alive.
+ *
+ * 2. If our own renewal thread saw the owner's timestamp change
+ * the last time it was checked, then consider the owner to be alive.
+ */
- if (host_id_leader.timestamp != last_timestamp) {
+ if ((host_id_leader.timestamp != last_timestamp) ||
+ (hs.last_live && (hs.last_check == hs.last_live))) {
if (flags & PAXOS_ACQUIRE_QUIET_FAIL) {
log_token(token, "paxos_acquire owner %llu "
"delta %llu %llu %llu alive",
@@ -1654,10 +1637,9 @@ int paxos_lease_acquire(struct task *task,
goto out;
}
-
- /* if the owner hasn't renewed its host_id lease for
- host_dead_seconds then its watchdog should have fired
- by now */
+ /* If the owner hasn't renewed its host_id lease for
+ host_dead_seconds then its watchdog should have fired by
+ now. */
now = monotime();
Show replies by date