ubik: avoid early DISK_Begin calls we know will fail
commit7c7085061580ccce7b2d9c17df5604e5e97fcd81
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Mon, 22 May 2017 16:55:32 +0000 (22 12:55 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 3 Aug 2017 00:10:50 +0000 (2 20:10 -0400)
treebe388c61ee8f28f3743e8f05a474c683843b90cb
parent8f46ca082653116c9c42a69e2535be1bb2f0a2a9
ubik: avoid early DISK_Begin calls we know will fail

Currently, we can start a write transaction on a site immediately after
it is elected as the sync site. However, after commit d47beca1,
SDISK_Begin on remote sites will fail right after an election occurs
(since lastYesState is not set, and so urecovery_AllBetter will fail).
And after commit fac0b742, this error is always noticed and propagated
back to the application.

As a result, when we try to write immediately after a sync site is
elected, the transaction will fail with UNOQUORUM, the remote sites will
be marked as down, and we may lose quorum and require another election
to be performed. This can easily happen repeatedly for a site that
frequently tries to make changes to a ubik database.

To avoid marking other sites down and going through another election
process, do not allow write transactions until we know that lastYesState
is set on the remote sites. We do this by waiting until the next wave of
beacons are sent, which tell the remote sites that we are the sync site.
In other words, only allow write transactions after the sync site knows
that the remote sites also know that the sync site has been elected.

With this commit, a write transaction immediately after an election
will still fail with UNOQUORUM, but we avoid triggering an error on the
remote sites, and avoid losing quorum in this situation.

Change-Id: I9e1a76b4022e6d734af1165d94c12e90af04974d
Reviewed-on: https://gerrit.openafs.org/12592
Reviewed-by: Andrew Deason <adeason@dson.org>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
src/ubik/beacon.c
src/ubik/ubik.c
src/ubik/ubik.p.h