1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 19:02:41 +01:00
phorge-phorge/src/applications
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
..
almanac Make PullLocal smart about which repositories it should pull 2016-04-12 05:37:30 -07:00
aphlict Update "should not run as root" message 2015-10-31 11:20:23 +00:00
arcanist/conduit Remove remaining arcanist project code 2015-07-08 19:37:28 +10:00
audit Modularize content sources 2016-03-26 11:59:45 -07:00
auth Add a session engine extension point 2016-04-05 15:19:47 -07:00
badges First stab at a badges typeahead 2016-04-11 10:33:07 -07:00
base Convert every two-column application except Maniphest to curtain views 2016-03-06 10:44:07 -08:00
cache Automatically sever databases after prolonged unreachability 2016-04-11 08:43:52 -07:00
calendar Account for raw limits properly in CalendarEventQuery 2016-04-07 08:39:27 -07:00
celerity Don't require one-time tokens to view file resources 2016-04-06 14:14:36 -07:00
chatlog Update chatlog to newPage() 2016-04-02 13:20:55 -07:00
conduit Expose column positions via maniphest.edit 2016-04-06 09:14:14 -07:00
config Rough cut of repository cluster status panel 2016-04-12 05:38:10 -07:00
conpherence Update Conpherence to newPage 2016-04-02 13:21:09 -07:00
console Separate external editor integration from callsigns 2016-01-04 06:54:01 -08:00
countdown Support sorting countdowns by end date 2016-04-07 12:37:55 -07:00
daemon Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
dashboard Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
differential Normalize case on active operations 2016-04-06 17:33:59 -07:00
diffusion Move toward multi-master replicated repositories 2016-04-12 08:57:57 -07:00
diviner Update Diviner to modern UI 2016-04-02 17:18:51 -07:00
doorkeeper Bridge GitHub users into Phabricator and attribute actions to them 2016-03-28 13:10:32 -07:00
draft/storage Fix EditEngine preview/draft for first comment on a task you didn't create 2015-12-05 09:57:45 -08:00
drydock Update Drydock remaining pages to new UI 2016-04-05 07:25:43 -07:00
fact Update Facts for newPage 2016-04-03 15:07:52 -07:00
feed Update Feed Story page for newPage 2016-04-03 15:34:07 -07:00
files Don't require POST to download LFS files from main domain 2016-04-07 08:55:32 -07:00
flag Move FontIcon calls to Icon 2016-01-28 08:48:45 -08:00
fund Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
harbormaster Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
help Update Help for newPage 2016-04-05 07:26:31 -07:00
herald Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
home Update Home for newPage 2016-04-05 13:53:54 -07:00
legalpad Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
lipsum Modularize content sources 2016-03-26 11:59:45 -07:00
macro Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
maniphest Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
meta Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
metamta Update MetaMTA to new UI 2016-04-05 07:26:46 -07:00
multimeter Add a cluster.read-only option 2016-04-09 13:40:47 -07:00
notification Add a cluster.read-only option 2016-04-09 13:40:47 -07:00
nuance Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
oauthserver Make OAuth scope handling more flexible 2016-04-05 13:53:33 -07:00
owners Update Owners edit paths page to new UI 2016-04-03 12:40:11 -07:00
passphrase Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
paste Add badges.edit and badges.search to Conduit API 2016-04-05 16:25:55 -07:00
people Fix spelling error 2016-04-11 09:26:08 -07:00
phame Update EditEngine for two column 2016-03-28 09:18:55 -07:00
phid Bridge GitHub users into Phabricator and attribute actions to them 2016-03-28 13:10:32 -07:00
phlux Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
pholio Moderize Pholio UI 2016-04-01 12:29:32 -07:00
phortune Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
phpast Update phpast for new UI 2016-04-05 13:52:59 -07:00
phragment Moderize Phragment 2016-04-02 14:24:40 +00:00
phrequent Add a Phrequent curtain extension 2016-03-10 18:45:04 -08:00
phriction Update PhrictionDocument to newPage 2016-04-02 13:21:46 -07:00
phurl Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
policy Simplify locking of Almanac cluster services 2016-02-25 03:38:39 -08:00
ponder Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
project Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
releeph Update Releeph to new UI 2016-04-05 13:16:10 -07:00
remarkup/conduit phtize all the things 2015-05-22 21:16:39 +10:00
repository Move toward multi-master replicated repositories 2016-04-12 08:57:57 -07:00
search Update Search edit page for new UI 2016-04-05 07:26:09 -07:00
settings Update Settings/Config UI 2016-04-08 22:00:38 +00:00
slowvote Convert Slowvote Edit page to new UI 2016-03-31 19:06:59 -07:00
spaces Normalize casing on property boxes 2016-04-06 15:33:15 -07:00
subscriptions Allow stacked comment actions to be explicitly ordered 2016-04-06 09:15:27 -07:00
support/application Implement the getName method in PhabricatorApplication subclasses 2014-07-23 23:52:50 +10:00
system Automatically degrade to read-only mode when unable to connect to the master 2016-04-10 12:20:13 -07:00
tokens Update Tokens for newPage 2016-04-02 13:22:24 -07:00
transactions Convert Countdown to EditEngine 2016-04-07 12:34:07 -07:00
typeahead Update typeahead for new UI 2016-04-04 12:45:56 -07:00
uiexample Update UIExamples for newPage 2016-04-02 13:22:41 -07:00
xhprof Update XHProf for newPage 2016-04-04 08:40:49 -07:00