1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 01:12:41 +01:00
phorge-phorge/src/infrastructure
epriestley 146fb646f9 Automatically degrade to read-only mode when unable to connect to the master
Summary:
Ref T4571. If we fail to connect to the master, automatically try to degrade into a temporary read-only mode ("UNREACHABLE") for the remainder of the request, if possible.

If the request was something like "load the homepage", that'll work fine. If it was something like "submit a comment", there's nothing we can do and we just have to fail.

Detecting this condition imposes a performance penalty: every request checks the connection and gives the database a long time to respond, since we don't want to drop writes unless we have to. So the degraded mode works, but it's really slow, and may perpetuate the problem if the root issue is load-related.

This lays the groundwork for improving this case by degrading futher into a "SEVERED" mode which will persist across requests. In the future, if several requests in a short period of time fail, we'll sever the database host and refuse to try to connect to it for a little while, connecting directly to replicas instead (basically, we're "health checking" the master, like a load balancer would health check a web application server). This will give us a better (much faster) degraded mode in a major service disruption, and reduce load on the master if the root cause is load-related, giving it a better chance of recovering on its own.

Test Plan:
  - Disabled master in config by changing the host/username, got degraded automatically to UNREACAHBLE mode immediately.
  - Faked full SEVERED mode, requests hit replicas and put me in the mode properly.
  - Made stuff work, hit some good pages.
  - Hit some non-cluster pages.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4571

Differential Revision: https://secure.phabricator.com/D15674
2016-04-10 12:20:13 -07:00
..
cluster Automatically degrade to read-only mode when unable to connect to the master 2016-04-10 12:20:13 -07:00
contentsource Modularize content sources 2016-03-26 11:59:45 -07:00
customfield Convert DrydockBlueprints to EditEngine 2016-03-03 15:21:25 -08:00
daemon Modularize content sources 2016-03-26 11:59:45 -07:00
diff Convert Differential to new layout 2016-03-12 13:04:21 -08:00
edges Bridge GitHub users into Phabricator and attribute actions to them 2016-03-28 13:10:32 -07:00
env Automatically degrade to read-only mode when unable to connect to the master 2016-04-10 12:20:13 -07:00
events Modernize Hovercard implementation 2015-12-24 12:18:28 -08:00
internationalization Fix translation of badge feed stories. 2016-03-29 10:56:36 -07:00
javelin Extend from Phobject 2015-06-15 18:02:27 +10:00
lint/linter Linter fixes 2015-12-03 07:44:23 +11:00
log Extend from Phobject 2015-06-15 18:02:27 +10:00
management Modularize content sources 2016-03-26 11:59:45 -07:00
markup Lay cluster.databases configuration groundwork for database clustering 2016-04-09 13:41:16 -07:00
query Introduce "bridged" objects 2016-03-22 15:06:57 -07:00
sms Various linter fixes 2015-08-11 22:36:55 +10:00
ssh phtize all the things 2015-05-22 21:16:39 +10:00
storage Automatically degrade to read-only mode when unable to connect to the master 2016-04-10 12:20:13 -07:00
testing Add a cluster.read-only option 2016-04-09 13:40:47 -07:00
time Extend from Phobject 2015-06-15 18:02:27 +10:00
util Improve error messages for bad hashtags and project names 2015-12-24 08:11:02 -08:00
PhabricatorEditor.php Mark some strings for translation 2015-06-09 23:06:52 +10:00