Skip to content

Commit e7356ce

Browse files
renetapopovaAlexicaWrightJPryce-Aklundh
authored
rearranged to accommodate all possible database states (#1045) (#1143)
Cherry-picks #1045 Co-authored-by: Jessica Wright <[email protected]> Co-authored-by: Jens Pryce-Åklundh <[email protected]>
1 parent c5dc708 commit e7356ce

File tree

4 files changed

+81
-61
lines changed

4 files changed

+81
-61
lines changed

modules/ROOT/pages/clustering/databases.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ ALTER DATABASE foo SET TOPOLOGY 2 PRIMARIES 1 SECONDARY
5252

5353
Like the `CREATE DATABASE` command, this command results in an error if the cluster does not contain sufficient servers to satisfy the requested topology.
5454

55-
Additionally, `ALTER DATABASE` is optionally idempotent and also results in an error if the database does not exist.
56-
It is possible to append the command with `IF EXISTS` to make sure that no error is returned if the database does not exist.
55+
When there is more than one possible permutation of the specified topology, Neo4j uses an allocator to decide how to spread the database across the cluster.
56+
Note, like `CREATE DATABASE`, the `ALTER DATABASE` command allocates the database and there is no requirement to execute `REALLOCATE DATABASES` unless there is a desire to re-balance databases across all servers that are part of the cluster.
5757

5858
When there is more than one possible permutation of the specified topology, Neo4j uses an allocator to decide how to spread the database across the cluster.
5959
Note, like `CREATE DATABASE`, the `ALTER DATABASE` command allocates the database and there is no requirement to execute `REALLOCATE DATABASES` unless there is a desire to re-balance databases across all servers that are part of the cluster.
@@ -73,8 +73,6 @@ Keep in mind that during such a transition, the database will be unavailable for
7373
`ALTER DATABASE` commands are optionally idempotent, with the default behavior to fail with an error if the database does not exist.
7474
Appending `IF EXISTS` to the command ensures that no error is returned and nothing happens should the database not exist.
7575

76-
If the `ALTER DATABASE` command decreases the number of allocations of a database, allocations on xref:clustering/servers.adoc#_cordoned_servers[cordoned servers] are removed first.
77-
7876
.Query
7977
[source, cypher]
8078
----

modules/ROOT/pages/clustering/monitoring/show-databases-monitoring.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ Note that for failed databases, `currentStatus` and `requestedStatus` are differ
4141
This can imply an error.
4242
For example:
4343

44-
* A database may take a while to transition from "offline" to "online", due to performing recovery.
44+
* A database may take a while to transition from `offline` to `online`, due to performing recovery.
4545
* During normal operation, the `currentStatus` of a database may be transiently different from its `requestedStatus`, due to a necessary automatic process, such as one server copying store files from another.
4646

47-
The possible statuses are `initial`, `offline`, `store copying`, `deallocating`, `unknown`, `dirty`, and `quarantined`.
47+
The possible values for `currentStatus` are `online`, `offline`, `starting`, `stopping`, `store copying`, `initial`, `deallocating`, `dirty`, `quarantined`, and `unknown`.
48+
The `requestedStatus` can only be `online` or `offline`.
49+
See xref::database-administration/standard-databases/manage-databases.adoc#database-states[Database states] for more information.
4850

4951
Additionally, note that databases hosted on servers that are offline are also returned by the `SHOW DATABASES` command.
5052
For such databases the `address` column displays `NULL`, the `currentStatus` column displays `unknown`, and the `statusMessage` displays `Server is unavailable`.

modules/ROOT/pages/database-administration/standard-databases/errors.adoc

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -62,55 +62,22 @@ As a result, the contents of the `statusMessage` column in the `SHOW DATABASE` q
6262

6363
However, databases may only be in one of a select number of states:
6464

65-
[options="header" cols="m,a"]
66-
|===
67-
| State
68-
| Description
69-
70-
| online
71-
| The database is running.
72-
73-
| offline
74-
| The database is not running.
75-
If the `statusMessage` column is filled, the database is not running because of a problem.
76-
77-
| starting
78-
| The database is not running, but is about to.
79-
80-
| stopping
81-
| The database is not running anymore, but still has not stopped completely.
82-
No offline operations (e.g. `load`/`dump`) can be performed yet.
83-
84-
| store copying
85-
| The database is currently being updated from another instance of Neo4j.
86-
87-
| initial
88-
| The database has not yet been created.
89-
90-
| dirty
91-
| This state implies an error has occurred.
92-
The database's underlying store files may be invalid.
93-
For more information, consult the `statusMessage` column or the server's logs.
94-
95-
| quarantined
96-
| The database is effectively stopped and its state may not be changed until no longer quarantined.
97-
For more information, consult the `statusMessage` column or the server's logs.
98-
99-
| unknown
100-
| This instance of Neo4j doesn’t know the state of this database.
101-
102-
| dropped
103-
| The database has been deleted.
104-
|===
105-
65+
* `online`
66+
* `offline`
67+
* `starting`
68+
* `stopping`
69+
* `store copying`
70+
* `initial`
71+
* `deallocating`
72+
* `dirty`
73+
* `quarantined`
74+
* `unknown`
75+
76+
For more details about the various states, see xref::database-administration/standard-databases/manage-databases.adoc#database-states[Database states].
10677
Most often, when a database management operation fails, Neo4j attempts to transition the database in question to the `offline` state.
10778
If the system is certain that no store files have yet been created, it transitions the database to `initial` instead.
10879
Similarly, if the system suspects that the store files underlying the database are invalid (incomplete, partially deleted, or corrupt), then it transitions the database to `dirty`.
10980

110-
[NOTE]
111-
====
112-
While `dropped` is a valid database state, it is only transiently observable, as database records are removed from `SHOW DATABASE` results once the `DROP` operation is complete.
113-
====
11481

11582
[[database-errors-retry]]
11683
== Retrying failed operations

modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,20 @@ The value can be either `online` or `offline`. label:default-output[]
8686
| currentStatus
8787
| The actual status of the database. label:default-output[]
8888

89-
The value can be one of the following:
90-
91-
* `online` - the database is running.
92-
* `offline` - the database is not running.
93-
* `starting` - the database is not running, but is about to.
94-
* `stopping` - the database is not running anymore but still has not stopped completely.
95-
Offline operations (e.g. `load`/`dump`) cannot be performed yet.
96-
* `store copying` - the database is currently being updated from another instance of Neo4j.
97-
* For other states, refer to the xref::database-administration/standard-databases/errors.adoc[Errors page].
89+
The possible statuses are:
90+
91+
* `online`
92+
* `offline`
93+
* `starting`
94+
* `stopping`
95+
* `store copying`
96+
* `initial`
97+
* `deallocating`
98+
* `dirty`
99+
* `quarantined`
100+
* `unknown`
101+
102+
See <<database-states>> for more information.
98103
| STRING
99104

100105
| statusMessage
@@ -186,13 +191,61 @@ However, some privileges enable users to see additional databases regardless of
186191

187192
If a user has not been granted `ACCESS` privilege to any databases nor any of the above special cases, the command can still be executed but it will only return the `system` database, which is always visible.
188193

194+
[[database-states]]
195+
=== Database states
196+
197+
A database's `currentStatus` can be one of the following:
198+
199+
[options="header" cols="m,a"]
200+
|===
201+
| State
202+
| Description
203+
204+
| online
205+
| The database is running.
206+
207+
| offline
208+
| The database is not running.
209+
If the `statusMessage` column is filled, the database is not running because of a problem.
210+
211+
| starting
212+
| The database is not running, but is about to.
213+
214+
| stopping
215+
| The database is not running anymore, but still has not stopped completely.
216+
No offline operations (e.g. `load`/`dump`) can be performed yet.
217+
218+
| store copying
219+
| The database is currently being updated from another instance of Neo4j.
220+
221+
| initial
222+
| The database has not yet been created.
223+
224+
| deallocating
225+
| Only applies to databases in a cluster.
226+
The database is still online but will eventually be offline due to a transfer of its role in the cluster to a different member.
227+
The status is `deallocting` until the transfer is complete, which can take anything from a second to a day or more.
228+
229+
| dirty
230+
| This state implies an error has occurred.
231+
The database's underlying store files may be invalid.
232+
For more information, consult the `statusMessage` column or the server's logs.
233+
234+
| quarantined
235+
| The database is effectively stopped and its state may not be changed until no longer quarantined.
236+
For more information, consult the `statusMessage` column or the server's logs.
237+
238+
| unknown
239+
| This instance of Neo4j does not know the state of this database.
240+
241+
|===
242+
189243
[NOTE]
190244
====
191245
Note that for failed databases, the `currentStatus` and `requestedStatus` are different.
192246
This often implies an error, but **that is not always the case**.
193247
For example, a database may take a while to transition from `offline` to `online` due to a performing recovery.
194248
Or, during normal operation, a database's `currentStatus` may be transiently different from its `requestedStatus` due to a necessary automatic process, such as one Neo4j instance copying store files from another.
195-
The possible statuses are `initial`, `online`, `offline`, `store copying` and `unknown`.
196249
====
197250

198251

0 commit comments

Comments
 (0)