Skip to content

Commit 26647e5

Browse files
committed
Update faq and reference commands
1 parent 2867954 commit 26647e5

File tree

2 files changed

+72
-11
lines changed

2 files changed

+72
-11
lines changed

pages/clustering/faq.mdx

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@ import { CommunityLinks } from '/components/social-card/CommunityLinks'
99

1010
## High availability (general)
1111

12+
#### Do I need Memgraph Enterprise license for replication / HA?
13+
Memgraph offers replication-only features within the community edition. However, you need to perform failover
14+
techniques manually, or keep the system as-is and ensure that the instances are not down at any time.
15+
16+
For automatic failover, ensuring high availability, and observability of the whole cluster,
17+
you do need an Enterprise License, as it is a quality-of-life improvement, and requires little to no management.
18+
19+
Enterprise license can be validated if injected correctly by issueing the following command:
20+
```
21+
SHOW LICENSE INFO;
22+
```
23+
1224
#### Does Memgraph support chaining REPLICA instances?
1325
Memgraph at the moment doesn't support chaining REPLICA instances, that is, a REPLICA
14-
instance cannot be replicated on another REPLICA instance.
26+
instance cannot be replicated on another REPLICA instance. As the role of the instance is very
27+
distinct, the instance at a point in time can just be a MAIN instance, or a REPLICA instance, and
28+
can't serve as both.
1529

1630
#### Can a REPLICA listen to multiple MAIN instances?
1731
Memgraph enforces the behaviour that REPLICA can only listen to exactly one MAIN instance.
@@ -22,7 +36,8 @@ The instance UUID of each Memgraph is persisted on disk across restarts, so this
2236
cluster lifecycle.
2337

2438
#### Can a REPLICA create snapshots by itself?
25-
No. REPLICA can only receive snapshots during the recovery phase.
39+
No. REPLICA can only receive snapshots during the recovery phase. REPLICA instance is ensuring durability by
40+
receiving replication data from MAIN, and writing to its own disk storage.
2641

2742
#### Can a REPLICA create WALs by itself?
2843
Actually, this is being done in the system. When a MAIN is committing, it is sending the Delta objects to the REPLICA.
@@ -37,19 +52,62 @@ files, if it didn't write WALs during its period of being a REPLICA. If the old
3752
insufficient information to be sent to the new REPLICA. That's why REPLICA always needs to write down in WALs what it's
3853
being received.
3954

55+
#### What is the difference between SYNC and STRICT_SYNC replication mode?
56+
In SYNC mode, if a REPLICA does not commit, MAIN will still continue and commit its own data. This is to ensure at least some
57+
availability, because if the commit didn't pass, the whole system would be stuck on writes. However, this doesn't guarantee
58+
data consistency across instances, as MAIN instance can be ahead of a SYNC replica.
4059

41-
### High availability with Docker
60+
Because of this behaviour, Memgraph also supports STRICT_SYNC, which will commit the changes only if all instances agreed to
61+
commit. This ensures data consistency, but if any instance fails to commit, writes will not pass through MAIN.
4262

43-
### High availability with Docker Compose
63+
### High availability (setting up the cluster)
4464

45-
### High availability with K8s
65+
#### Which instance should I use to register the cluster?
66+
Registering instances should be done on a single coordinator. The chosen coordinator will become the cluster's leader.
4667

68+
#### Can I combine all three replication modes for registering REPLICAs in the cluster?
69+
You can only have 2 combinations of different replication modes:
70+
- `STRICT_SYNC` and `ASYNC` replicas
71+
- `SYNC` and `ASYNC` replicas
4772

73+
Combining `STRICT_SYNC` and `SYNC` replicas together doesn't have proper semantic meaning so it is forbidden. Reason for this
74+
is because MAIN will advance to commit the change in `SYNC` mode, while in the `STRICT_SYNC` mode it will fail.
4875

49-
<CommunityLinks/>
76+
### High availability (architecture)
77+
78+
#### Which replication mode should I use for achieving no data loss?
79+
For achieving no data loss, users should use the STRICT_SYNC replication mode, which is performing the two phase commit (2PC)
80+
protocol during the commit stage.
5081

82+
#### Which replication mode should I use for achieving maximum performance?
83+
For achieving maximum performance, users should use the ASYNC replication mode, which is using a background thread to replicate
84+
data. This mode is eventually consistent, but the MAIN instance does not wait for the REPLICAs to commit their changes.
5185

52-
Validate license is correctly set
53-
All the following queries can be run by querying directly coordinator 1, which we can conventionally assume to be the leader for the cluster.
86+
#### Which replication mode should I use for cross datacenter deployment?
87+
This again depends on whether you're okay with data loss, or eventual consistency:
88+
- no data-loss is a must: STRICT_SYNC
89+
- eventual consistency is fine: ASYNC
90+
- performance: ASYNC
91+
- no specific requirements: SYNC (default)
5492

55-
First, let’s validate that the license has been correctly set, by executing the following query:
93+
### High availability with K8s
94+
95+
#### Log files are filling up my disk space, what should I do?
96+
Memgraph currently does not support log retention. The best way currently to deal with this, is to specify the following
97+
two flags:
98+
- `--also-log-to-stderr=true`
99+
- `--log-file=` (yes, empty value)
100+
101+
on every data and coordinator instance.
102+
Additional thing you can do is to tail the container logs into a log aggregator, such as [OpenSearch](https://opensearch.org/),
103+
with which you will gain even more searching capabilities when troubleshooting.
104+
105+
If you don't have a log aggregator, the user is expected to periodically clean the log files, in order to manage the disk space,
106+
or reduce the log level of the instances.
107+
108+
Log levels are a setting which can be changed at runtime, with the command:
109+
```
110+
SET DATABASE SETTING `log.level` TO 'INFO';
111+
```
112+
113+
<CommunityLinks/>

pages/clustering/high-availability/ha-commands-reference.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ REGISTER INSTANCE instanceName ( AS ASYNC | AS STRICT_SYNC ) ? WITH CONFIG {"bol
2828

2929
This operation will result in writing to the Raft log.
3030

31-
In case the main instance already exists in the cluster, a replica instance will be automatically connected to the main. Constructs ( AS ASYNC | AS STRICT_SYNC ) serve to specify
32-
instance's replication mode when the instance behaves as replica. You can only have `STRICT_SYNC` and `ASYNC` or `SYNC` and `ASYNC` replicas together in the cluster. Combining `STRICT_SYNC`
31+
In case the main instance already exists in the cluster, a replica instance will be automatically connected to the main.
32+
If a replication mode is not specified, REPLICA will be registered in `SYNC` replication mode.
33+
Constructs `( AS ASYNC | AS STRICT_SYNC )` serve to specify a different replication mode other than `SYNC`.
34+
35+
You can only have `STRICT_SYNC` and `ASYNC` or `SYNC` and `ASYNC` replicas together in the cluster. Combining `STRICT_SYNC`
3336
and `SYNC` replicas together doesn't have proper semantic meaning so it is forbidden.
3437

3538

0 commit comments

Comments
 (0)