What we will subscribe to?
The leader of each group will be streaming out CDC updates. Later on, once we have namespaces(from multi tenancy), we will make it listen to updates accordingly.
We have made raft logs readable for CDC. Hence each raft entry would be read and sent as CDC event if necessary. This ensures all the guarantees we needed for CDC.
- CDC will be managed via config flags.
- CDC job will read the raft logs and decide which events to send based on the type of operation.
- Initially only Kafka will be provided as a sink. All alpha nodes are required to specify with the Kafka sink config, for CDC to work efficiently.
- Events will be sent out via leader node only.
- Events will be sent to Kafka topics named as
dgraph-cdc. Later with multi-tenancy, events will be distributed based on namespaces over the partitions.
Handling Drop operations:
There are 4 kinds of drop operations:
- Drop All
- Drop Data
- Drop Attribute
- Drop Type
Drop Event will be sent for each of these cases.
DROP ALL event would look like this:
There will be 2 kinds of events; Set and Delete that we will be emitting. Other DBs do support another operation
Update that would be costly for us to support because of extra lookup needed for that. We don’t intend to support that.
Raft entries will have information about
DataType. Information extracted from these entries would go into
Delete field of JSON below.
A Set mutation event updating
counter.val to 10 would look like this:
Similarly, a sample Delete mutation event of removing all values for predicate
Author.name for a node with
uid=7 would look like this:
Integration With Sink Clients
Initially, only two sink clients will be available i.e. Kafka and File.
- Kafka will adhere to the TLS encryption as well as sasl authentication. All the CDC events will be generated over the default topic and events will be distributed based on namespace over the partitions.
- File-based sinks are just dumping events into a file. This is generally useful in the case of testing.
Important things to note
- If the sink is failing or down, clients will not lose events. But it will lead to an increase in the raft files because CDC jobs read the raft logs and since no events are getting published, raft files are not getting cleared. Hence it becomes necessary to manage the cluster properly in case of failure events.
- In case of node crashes or leadership changes there might be duplicated events but no loss of events.
- In the case of live loader, there will be events for each predicate.
- In the case of an old cluster, CDC events will be sent from the last raft index available.
- In the case of bulk loader, there will be no events.
- Value for password fields will not be sent out in CDC events.
- CDC is not supported in case of ludicrous mode. We are working on fixing this. We will update the timelines for that later.
- Schema updates will not available over CDC at this moment. We are working on fixing this. We will update the timelines for that later.
Important: This is an enterprise feature.