Skip to content

Commit 1d27305

Browse files
committed
Rewrite based on problems found during testing.
1 parent 468d3a4 commit 1d27305

File tree

1 file changed

+53
-29
lines changed

1 file changed

+53
-29
lines changed

modules/ROOT/pages/clustering/disaster-recovery.adoc

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ The `system` database contains the view of the cluster.
8282
This includes which servers and databases are present, where they live and how they are configured.
8383
During a disaster, the view of the cluster might need to change to reflect a new reality, for example by removing lost servers.
8484
Databases might also need to be recreated to regain write availability.
85-
Because both of these steps are executed by writing to the `system` database, this is a vital first step during disaster recovery.
85+
Because both of these steps are executed by modifying the `system` database, making the `system` database write available is a vital first step during disaster recovery.
8686

8787
==== Example verification
8888
The `system` database's write availability can be verified by using the xref:clustering/monitoring/status-check.adoc#monitoring-replication[Status check] procedure.
8989
The procedure should be called on all remaining primary allocations of the `system` database, in order to provide the correct view.
90-
The status check procedure writes a dummy transaction, and therefore the correctness of the procedure depends on the given timeout.
91-
The default timeout is 1 second, but depending on the network latency in the environment it might need to be extended.
90+
The default timeout for the procedure is 1 second, but depending on the network latency in the environment it might need to be extended to produce an accurate result.
9291
If any of the primary `system` allocations report `replicationSuccessful` = `TRUE`, the `system` database is write available.
9392
Therefore, the desired state has been verified.
9493

@@ -97,6 +96,12 @@ Therefore, the desired state has been verified.
9796
CALL dbms.cluster.statusCheck(["system"]);
9897
----
9998

99+
[NOTE]
100+
=====
101+
The write availability of a database configured to have a single primary cannot be checked with the status check, instead check that the primary is allocated on an available server and that it has `currentStatus` = `STARTED`.
102+
The procedure will still produce an accurate result if all but one primary have been lost during a disaster.
103+
=====
104+
100105
==== Path to correct state
101106
The following steps can be used to regain write availability for the `system` database if it has been lost.
102107
They create a new `system` database from the most up-to-date copy of the `system` database that can be found in the cluster.
@@ -142,9 +147,9 @@ All servers in the cluster's view are available and enabled.
142147
====
143148

144149
A lost server will still be in the `system` database's view of the cluster, but in an unavailable state.
145-
According to the view of the cluster, these lost servers are still hosting the databases they had before they became lost.
150+
Furthermore, according to the view of the cluster, these lost servers are still hosting the databases they had before they became lost.
146151
Therefore, informing the cluster of servers which are lost is not enough.
147-
The databases hosted on the lost servers also need to be moved onto servers which are actually in the cluster.
152+
The databases hosted on lost servers also need to be moved onto available servers in the cluster, before the lost servers can be removed.
148153

149154
==== Example verification
150155
The cluster's view of servers can be seen by listing the servers, see xref:clustering/servers.adoc#_listing_servers[Listing servers] for more information.
@@ -157,7 +162,7 @@ SHOW SERVERS;
157162

158163
==== Path to correct state
159164
The following steps can be used to remove lost servers and add new ones to the cluster.
160-
That includes moving any potential database allocations from lost servers to available servers in the cluster.
165+
That includes moving any potential database allocations from lost servers to available servers.
161166
These steps might also recreate some databases, since a database which has lost a majority of its primary allocations cannot be moved from one server to another.
162167

163168
.Guide
@@ -168,7 +173,6 @@ This prevents new database allocations from being moved to this server.
168173
. For each `CORDONED` server, make sure a new *unconstrained* server has been added to the cluster to take its place, see xref:clustering/servers.adoc#cluster-add-server[Add a server to the cluster] for more information.
169174
If servers were added in the 'System database write availability' step of this guide, additional servers might not be needed here.
170175
It is important that the new servers are unconstrained, or deallocating servers might be blocked even though enough servers were added.
171-
172176
+
173177
[NOTE]
174178
=====
@@ -177,32 +181,38 @@ However, not adding new servers reduces the capacity of the cluster to handle wo
177181
Furthermore, it might require the topology for a database to be altered to make deallocating servers and recreating databases possible.
178182
=====
179183
180-
. Run `SHOW DATABASES`. If a database show `currentStatus`= `offline` this database has been stopped.
181-
. For each stopped database, start them by running `START DATABASE stopped-db WAIT`.
182-
// Is it a problem that it might not have started yet here? Should I write a line about making sure it is started before checking the write availability?
183-
// Cannot use wait here, because we will hang on lost members that are stopped. Should poll for started state on all non-lost members, but there are some situation where we will not be able to start. So how long should they wait here?
184+
. For each stopped database (`currentStatus`= `offline`), start them by running `START DATABASE stopped-db`.
184185
This is necessary since stopped databases cannot be moved from one server to another.
185-
// And since status check doesn't work otherwise.
186+
Verify that they are in `currentStatus` = `started` on all servers which are not lost before moving to the next step, otherwise they might be recreated unnecessarily.
187+
If a database fails to start, leave it to be recreated in the next step of this guide.
186188
+
187189
[NOTE]
188190
=====
189191
A database can be set to `READ-ONLY` before it is started to avoid updates on a database that is desired to be stopped with the following command:
190192
`ALTER DATABASE database-name SET ACCESS READ ONLY`.
191193
=====
192-
. On each server, run `CALL dbms.cluster.statusCheck([])` to check the write availability for all databases on this server, see xref:clustering/monitoring/status-check.adoc#monitoring-replication[Monitoring replication] for more information.
193-
Depending on the environment, consider extending the timeout for this procedure.
194+
195+
. On each server, run `CALL dbms.cluster.statusCheck([])` to check the write availability for all databases running in primary mode on this server, see xref:clustering/monitoring/status-check.adoc#monitoring-replication[Monitoring replication] for more information.
196+
Depending on the network latency in the environment, consider extending the timeout for this procedure to produce an accurate result.
194197
If any of the primary allocations for a database report `replicationSuccessful` = `TRUE`, this database is write available.
198+
+
199+
[NOTE]
200+
=====
201+
The write availability of a database configured to have a single primary cannot be checked with the status check, instead check that the primary is allocated on an available server and that it has `currentStatus` = `STARTED`.
202+
The procedure will still produce an accurate result if all but one primary have been lost during a disaster.
203+
=====
204+
195205
. For each database that is not write available, recreate it to move it from lost servers and regain write availability.
196206
Go to xref:clustering/databases.adoc#recreate-databases[Recreate databases] for more information about recreate options.
197-
If any allocation has `currentStatus` = `QUARANTINED`, recreate them from backup using xref:clustering/databases.adoc#uri-seed[Backup as seed] or define seeding servers in the recreate procedure using xref:clustering/databases.adoc#specified-servers[Specified seeders] so that problematic allocations are excluded.
198207
Remember to make sure there are recent backups for the databases before recreating them, see xref:backup-restore/online-backup.adoc[Online backup] for more information.
199-
// What if a quarantined database had the desire to be stopped? Check quarantine before stopped?
208+
If any database has `currentStatus` = `QUARANTINED` on an available server, recreate them from backup using xref:clustering/databases.adoc#uri-seed[Backup as seed].
200209
+
201210
[NOTE]
202211
=====
203-
By using recreate with xref:clustering/databases.adoc#undefined-servers-backup[Undefined servers with fallback backup], also databases which have lost all allocation can be recreated.
204-
Otherwise, recreating with xref:clustering/databases.adoc#uri-seed[Backup as seed] must be used for that specific case.
212+
By using recreate with xref:clustering/databases.adoc#undefined-servers-backup[Undefined servers with fallback backup], the store will be replaced by the most up-to-date copy according to the cluster's view without manual intervention.
213+
Furthermore, this option will automatically recreate the database based on a backup if no available allocation can be found.
205214
=====
215+
206216
. For each `CORDONED` server, run `DEALLOCATE DATABASES FROM SERVER cordoned-server-id` on one of the available servers.
207217
This will try to move all database allocations from this server to an available server in the cluster.
208218
+
@@ -211,6 +221,7 @@ This will try to move all database allocations from this server to an available
211221
This operation might fail if enough unconstrained servers were not added to the cluster to replace lost servers.
212222
Another reason is that some available servers are also `CORDONED`.
213223
=====
224+
214225
. For each deallocating or deallocated server, run `DROP SERVER deallocated-server-id`.
215226
This removes the server from the cluster's view.
216227
====
@@ -221,32 +232,38 @@ This removes the server from the cluster's view.
221232

222233
==== State
223234
====
224-
All databases are write available.
235+
All databases which are desired to be started are write available.
225236
====
226237

227238
Once this state is verified, disaster recovery is complete.
228239
However, remember that previously stopped databases might have been started during this process.
229-
If they are still desired to be in stopped state, run `START DATABASE started-db WAIT`.
240+
If they are still desired to be in stopped state, run `STOP DATABASE started-db WAIT`.
230241

231-
[NOTE]
242+
[CAUTION]
232243
====
233-
Remember, recreating a database can take an unbounded amount of time since it may involve copying the store to a new server, as described in xref:clustering/databases.adoc#recreate-databases[Recreate databases].
234-
Therefore, an allocation with `currentStatus` = `STARTING` might reach the `requestedStatus` given some time.
244+
Remember, recreating a database takes an unbounded amount of time since it may involve copying the store to a new server, as described in xref:clustering/databases.adoc#recreate-databases[Recreate databases].
245+
Therefore, an allocation with `currentStatus` = `STARTING` will probably reach the `requestedStatus` given some time.
235246
====
236247

248+
[[example-verification]]
237249
==== Example verification
238250
All databases' write availability can be verified by using the xref:clustering/monitoring/status-check.adoc#monitoring-replication[Status check] procedure.
239251
The procedure should be called on all servers in the cluster, in order to provide the correct view.
240-
The status check procedure writes a dummy transaction, and therefore the correctness of the procedure depends on the given timeout.
241-
The default timeout is 1 second, but depending on the network latency in the environment it might need to be extended.
252+
The default timeout for the procedure is 1 second, but depending on the network latency in the environment it might need to be extended to produce an accurate result.
242253
If any of the primary allocations for a database report `replicationSuccessful` = `TRUE`, this database is write available.
243-
Therefore, the desired state has been verified when this is true for all databases.
254+
Therefore, the desired state has been verified when this is true for all *started* databases.
244255

245256
[source, shell]
246257
----
247258
CALL dbms.cluster.statusCheck([]);
248259
----
249260

261+
[NOTE]
262+
=====
263+
The write availability of a database configured to have a single primary cannot be checked with the status check, instead check that the primary is allocated on an available server and that it has `currentStatus` = `STARTED`.
264+
The procedure will still produce an accurate result if all but one primary have been lost during a disaster.
265+
=====
266+
250267
A stricter verification can be done to verify that all databases are in their desired states on all servers.
251268
For the stricter check, run `SHOW DATABASES` and verify that `requestedStatus` = `currentStatus` for all database allocations on all servers.
252269

@@ -258,15 +275,22 @@ Recreations might fail for different reasons, but one example is that the checks
258275
.Guide
259276
[%collapsible]
260277
====
261-
. Run `CALL dbms.cluster.statusCheck([])` on all servers to identify write unavailable databases, see xref:clustering/monitoring/status-check.adoc#monitoring-replication[Monitoring replication] for more information.
278+
. Identify all write unavailable databases that are desired to be `STARTED` by running `CALL dbms.cluster.statusCheck([])` as described in the xref:clustering/disaster-recovery.adoc#example-verification[Example verification] part of this disaster recovery step.
262279
. Recreate every database that is not write available and has not been recreated previously, see xref:clustering/databases.adoc#recreate-databases[Recreate databases] for more information.
263-
If any allocation has `currentStatus` = `QUARANTINED`, recreate them from backup using xref:clustering/databases.adoc#uri-seed[Backup as seed] or define seeding servers in the recreate procedure using xref:clustering/databases.adoc#specified-servers[Specified seeders] so that problematic allocations are excluded.
264280
Remember to make sure there are recent backups for the databases before recreating them, see xref:backup-restore/online-backup.adoc[Online backup] for more information.
281+
If any database has `currentStatus` = `QUARANTINED` on an available server, recreate them from backup using xref:clustering/databases.adoc#uri-seed[Backup as seed].
282+
+
283+
[NOTE]
284+
=====
285+
By using recreate with xref:clustering/databases.adoc#undefined-servers-backup[Undefined servers with fallback backup], the store will be replaced by the most up-to-date copy according to the cluster's view without manual intervention.
286+
Furthermore, this option will automatically recreate the database based on a backup if no available allocation can be found.
287+
=====
288+
265289
. Run `SHOW DATABASES` and check any recreated databases which are not write available.
266290
Recreating a database will not complete if one of the following messages is displayed in the message field:
267291
** `Seeders ServerId1 and ServerId2 have different checksums for transaction TransactionId. All seeders must have the same checksum for the same append index.`
268292
** `Seeders ServerId1 and ServerId2 have incompatible storeIds. All seeders must have compatible storeIds.`
269293
** `No store found on any of the seeders ServerId1, ServerId2...`
270-
. For each database which will not complete recreation, recreate them from backup using xref:clustering/databases.adoc#uri-seed[Backup as seed] or define seeding servers in the recreate procedure using xref:clustering/databases.adoc#specified-servers[Specified seeders] so that problematic allocations are excluded.
294+
. For each database which will not complete recreation, recreate them from backup using xref:clustering/databases.adoc#uri-seed[Backup as seed].
271295
272296
====

0 commit comments

Comments
 (0)