update: 5.21.2021, by [Goose](https://github.com/XuanYang-cn)
update: 6.03.2021, by [Goose](https://github.com/XuanYang-cn)
update: 6.21.2021, by [Goose](https://github.com/XuanYang-cn)
## What's DataNode?
...
...
@@ -41,7 +42,7 @@ Vchannel is stateful because we don't want to process twice what's already proce
already persistant. In DataNode's terminology, a message is processed if it's been flushed.
DataService tells DataNode stateful vchannel infos through RPC `WatchDmChannels`, so that DataNode won't process
the same messages over and over again. So flowgraph needs ability to comsume messages in the middle of a vchannel.
the same messages over and over again. So flowgraph needs ability to consume messages in the middle of a vchannel.
DataNode tells DataService vchannel states after each flush through RPC `SaveBinlogPaths`, so that DataService
keep the vchannel states update.
...
...
@@ -51,7 +52,7 @@ keep the vchannel states update.
### 1. DataNode no longer interacts with Etcd except service registering
#### **O1-1** DataService rather than DataNode saves binlog paths into Etcd
#### DataService rather than DataNode saves binlog paths into Etcd
![datanode_design](graphs/datanode_design_01.jpg)
...
...
@@ -65,36 +66,23 @@ message ID2PathList {
repeatedstringPaths=2;
}
messageCheckPoint{
int64segmentID=1;
internal.MsgPositionposition=2;
int64num_of_rows=3;
}
messageSaveBinlogPathsRequest{
common.MsgBasebase=1;
int64segmentID=2;
int64collectionID=3;
ID2PathListfield2BinlogPaths=4;
ID2PathListcoll2TsBinlogPaths=5;
ID2PathListcoll2DdlBinlogPaths=6;
repeatedinternal.MsgPositionstart_positions=7;
repeatedinternal.MsgPositionend_positions=8;
repeatedID2PathListfield2BinlogPaths=4;
repeatedCheckPointcheckPoints=7;
repeatedSegmentStartPositionstart_positions=6;
boolflushed=7;
}
```
##### DataService Etcd Binlog Meta Design
The same as DataNode
```proto
// key: ${prefix}/${segmentID}/${fieldID}/${idx}
messageSegmentFieldBinlogMeta{
int64fieldID=1;
stringbinlog_path=2;
}
// key: ${prefix}/${collectionID}/${idx}
messageDDLBinlogMeta{
stringddl_binlog_path=1;
stringts_binlog_path=2;
}
```
### 4. DataNode with collection with flowgraph with vchannel designs
#### The winner
...
...
@@ -107,22 +95,17 @@ message DDLBinlogMeta {
Change `WatchDmChannelsRequest` proto.
``` proto
messagePositionPair{
internal.MsgPositionstart_position=1;
internal.MsgPositionend_position=2;
}
messageVchannelPair{
messageVchannelInfo{
int64collectionID=1;
stringdml_vchannel_name=2;
stringddl_vchannel_name=3;
PositionPairddl_position=4;
PositionPairdml_position=5;
stringchannelName=2;
internal.MsgPositionseek_position=3;
repeatedSegmentInfounflushedSegments=4;
repeatedint64flushedSegments=5;
}
messageWatchDmChannelsRequest{
common.MsgBasebase=1;
repeatedVchannelPairvchannels=2;
repeatedVchannelInfovchannels=2;
}
```
...
...
@@ -134,8 +117,9 @@ type DataNode struct {
...
vchan2Syncmap[string]*dataSyncService
vchan2FlushChmap[string]chan<-*flushMsg
clearSignalchanUniqueID
...
replicaReplica// TODO remove
}
// DataSyncService
...
...
@@ -147,7 +131,6 @@ type dataSyncService struct {
idAllocatorallocatorInterface
msFactorymsgstream.Factory
collectionIDUniqueID
segmentIDs[]UniqueID// getSegmentIDs() of Replica
}
```
...
...
@@ -155,24 +138,12 @@ DataNode Init -> Resigter to Etcd -> Discovery data service -> Discover master s
WatchDmChannels -> new dataSyncService -> HEALTH
```proto
messageWatchDmChannelsRequest{
common.MsgBasebase=1;
repeatedVchannelPairvchannels=2;
}
```
`WatchDmChannels:`
1. If `DataNode.vchan2Sync` is empty, DataNode is in IDLE, `WatchDmChannels` will create new dataSyncService for every unique vchannel, then DataNode is in HEALTH.
2. If vchannel name of `VchannelPair` is not in `DataNode.vchan2Sync`, create a new dataSyncService.
3. If vchannel name of `VchannelPair` is in `DataNode.vchan2Sync`, ignore.