Skip to content

Commit 79daab1

Browse files
Allow parameters in CREATE/ALTER DATABASE TOPOLOGY (#1911)
Document this change: neo-technology/neo4j#27665 --------- Co-authored-by: Reneta Popova <[email protected]>
1 parent 8ce27a8 commit 79daab1

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

modules/ROOT/pages/clustering/databases.adoc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ To create a database `foo` with 3 servers hosting the database in primary mode a
1919
----
2020
CREATE DATABASE foo TOPOLOGY 3 PRIMARIES 2 SECONDARIES
2121
----
22+
Alternatively, starting from 5.26, you can use link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/syntax/parameters[parameters] to provide the number of primaries and secondaries:
23+
24+
.Parameters
25+
[source,javascript, indent=0]
26+
----
27+
{
28+
"dbname": "foo",
29+
"primary": 3,
30+
"secondary": 2
31+
}
32+
----
33+
34+
.Query
35+
[source, cypher, indent=0]
36+
----
37+
CREATE DATABASE $dbname TOPOLOGY $primary PRIMARIES $secondary SECONDARIES
38+
----
2239

2340
The command can only be executed successfully if the cluster's servers are able to satisfy the specified topology.
2441
If they are not, the command results in an error.
@@ -50,6 +67,23 @@ To change the topology of the database `foo` from the previous example, the comm
5067
----
5168
ALTER DATABASE foo SET TOPOLOGY 2 PRIMARIES 1 SECONDARY
5269
----
70+
Alternatively, starting from 5.26, you can use link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/syntax/parameters[parameters] to provide the number of primaries and secondaries:
71+
72+
.Parameters
73+
[source,javascript, indent=0]
74+
----
75+
{
76+
"dbname": "foo",
77+
"primary": 2,
78+
"secondary": 1
79+
}
80+
----
81+
82+
.Query
83+
[source, cypher, indent=0]
84+
----
85+
ALTER DATABASE $dbname SET TOPOLOGY $primary PRIMARIES $secondary SECONDARIES
86+
----
5387

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

@@ -75,7 +109,7 @@ Keep in mind that during such a transition, the database will be unavailable for
75109
`ALTER DATABASE` commands are optionally idempotent, with the default behavior to fail with an error if the database does not exist.
76110
Appending `IF EXISTS` to the command ensures that no error is returned and nothing happens should the database not exist.
77111

78-
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.
112+
If the `ALTER DATABASE` command decreases the number of allocations of a database, allocations on xref:clustering/servers.adoc#cordoned-state[cordoned servers] are removed first.
79113

80114
.Query
81115
[source, cypher]
@@ -401,7 +435,7 @@ In this case, the address for `server01` is `localhost:7687` and thus, the serve
401435
The topology of `foo` is stored in the `system` database and when you create it, it is allocated according to the default topology (which can be shown with `CALL dbms.showTopologyGraphConfig`).
402436
This may be different from the topology of `foo` when it was backed up.
403437
If you want to ensure a certain allocation across the cluster, you can specify the desired topology with the `TOPOLOGY` clause in the `CREATE DATABASE` command.
404-
See <<#_create_database, `CREATE DATABASE`>> for more information.
438+
See <<create-database, `CREATE DATABASE`>> for more information.
405439
+
406440
[source, cypher, role=noplay]
407441
----

modules/ROOT/pages/clustering/servers.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ When a server is in the deallocated state, it no longer hosts any databases besi
9292
Additionally, deallocated servers cannot have any further databases allocated to them.
9393
Note that there is a known situation in which a previously deallocated offline server can transiently show as deallocating when restarting, it will, however, eventually return to the deallocated state without intervention.
9494

95+
[cordoned-state]
9596
=== Cordoned state
9697

9798
The _Cordoned_ state is similar to _Deallocating_ in that servers in this state will not be allocated to host additional databases.
9899
Unlike _Deallocating_ however, cordoned servers do not lose the databases they already host.
99-
It is worth noting that when decreasing the number of allocations of a database, allocations on cordoned servers are removed first.
100+
It is worth noting that when decreasing the number of allocations of a database, allocations on cordoned servers are removed first.
100101

101102
A server is transitioned from the _Enabled_ state to the _Cordoned_ state by executing the procedure `dbms.cluster.cordonServer`.
102103
A server in the _Cordoned_ state may be transitioned to _Deallocating_, or back to _Enabled_.

0 commit comments

Comments
 (0)