1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00
phorge-phorge/src/applications/diffusion
epriestley 4244cad990 Move toward multi-master replicated repositories
Summary:
Ref T4292. This mostly implements the locking/versioning logic for multi-master repositories. It is only active on Git SSH pathways, and doesn't actually do anything useful yet: it just does bookkeeping so far.

When we read (e.g., `git fetch`) the logic goes like this:

- Get the read lock (unique to device + repository).
  - Read all the versions of the repository on every other device.
  - If any node has a newer version:
    - Fetch the newer version.
    - Increment our version to be the same as the version we fetched.
- Release the read lock.
- Actually do the fetch.

This makes sure that any time you do a read, you always read the most recently acknowledged write. You may have to wait for an internal fetch to happen (this isn't actually implemented yet) but the operation will always work like you expect it to.

When we write (e.g., `git push`) the logic goes like this:

- Get the write lock (unique to the repository).
  - Do all the read steps so we're up to date.
  - Mark a write pending.
    - Do the actual write.
  - Bump our version and mark our write finished.
- Release the write lock.

This allows you to write to any replica. Again, you might have to wait for a fetch first, but everything will work like you expect.

There's one notable failure mode here: if the network connection between the repository node and the database fails during the write, the write lock might be released even though a write is ongoing.

The "isWriting" column protects against that, by staying locked if we lose our connection to the database. This will currently "freeze" the repository (prevent any new writes) until an administrator can sort things out, since it'd dangerous to continue doing writes (we may lose data).

(Since we won't actually acknowledge the write, I think, we could probably smooth this out a bit and make it self-healing //most// of the time: basically, have the broken node rewind itself by updating from another good node. But that's a little more complex.)

Test Plan:
  - Pushed changes to a cluster-mode repository.
  - Viewed web interface, saw "writing" flag and version changes.
  - Pulled changes.
  - Faked various failures, got sensible states.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4292

Differential Revision: https://secure.phabricator.com/D15688
2016-04-12 08:57:57 -07:00
..
application Rough cut at new "pro" Diffusion edit UI skeleton 2016-04-12 05:37:54 -07:00
capability Simplify the implementation of PhabricatorPolicyCapability subclasses 2014-07-25 08:25:42 +10:00
conduit Modularize content sources 2016-03-26 11:59:45 -07:00
config Move FontIcon calls to Icon 2016-01-28 08:48:45 -08:00
controller Rough cut at new "pro" Diffusion edit UI skeleton 2016-04-12 05:37:54 -07:00
data Parse and display commit authorship date in Git in Diffusion 2016-01-11 09:32:37 -08:00
doorkeeper Partially modernize Doorkeeper/Asana bridge 2014-10-01 07:09:34 -07:00
edge Fix reverting commit language 2015-06-01 09:54:30 +10:00
engine Fix an issue with incorrect split head detection in Mercurial after pushing a medley of varied changes 2016-03-25 07:33:55 -07:00
engineextension Move PhabricatorHovercard to PHUIHovercard 2016-02-03 16:26:30 +00:00
exception Replace AphrontUsageException with AphrontMalformedRequestException 2015-09-03 10:04:17 -07:00
garbagecollector Support ID-based repository URIs, and canonicalize repository URIs 2016-02-18 09:56:28 -08:00
gitlfs Implement a Git LFS link table and basic batch API 2016-03-17 17:15:20 -07:00
herald Move various other callsites away from callsigns 2016-01-04 06:54:42 -08:00
management Move toward multi-master replicated repositories 2016-04-12 08:57:57 -07:00
panel Add "Mailing List" users 2015-06-03 18:42:33 -07:00
protocol Added an intercept to Mercurial's capabilities command to remove bundle2. 2015-10-10 07:14:48 -07:00
query Fix resolution of commits in SVN repositories without callsigns 2016-04-04 09:44:36 -07:00
remarkup Stop all object mentions from matching after "@" 2015-09-29 06:43:49 -07:00
request Remove uncalled DiffusionRequest->getCallsign() 2016-02-17 17:17:35 -08:00
response Implement a Git LFS server which supports no operations 2016-03-17 08:08:43 -07:00
ssh Move toward multi-master replicated repositories 2016-04-12 08:57:57 -07:00
symbol Extend from Phobject 2015-06-15 18:02:27 +10:00
typeahead Improve type and icon information in typeahead 2016-02-05 12:48:20 -08:00
view Make dates/times more concise in Diffusion 2016-03-18 09:11:09 -07:00
DiffusionLintSaveRunner.php Move repository URIs to a dedicated index 2016-01-13 09:34:31 -08:00