2021-06-03 07:27:33 +00:00
|
|
|
# DataNode Flowgraph Recovery Design
|
|
|
|
|
|
|
|
update: 6.4.2021, by [Goose](https://github.com/XuanYang-cn)
|
2021-06-21 10:32:12 +00:00
|
|
|
update: 6.21.2021, by [Goose](https://github.com/XuanYang-cn)
|
2021-06-03 07:27:33 +00:00
|
|
|
|
|
|
|
## 1. Common Sense
|
2021-10-12 11:18:33 +00:00
|
|
|
|
|
|
|
A. One message stream to one vchannel, so there are one start position and one end position in one message pack
|
2021-06-03 07:27:33 +00:00
|
|
|
B. Only when datanode flushes, datanode will update every segment's position
|
|
|
|
An optimization: update position of
|
2021-10-12 11:18:33 +00:00
|
|
|
|
|
|
|
- a. Current flushing segment
|
|
|
|
- b. StartPosition of segments never been flushed.
|
|
|
|
C. DataNode auto-flush is a valid flush.
|
|
|
|
D. DDL messages are now in DML Vchannels.
|
2021-06-03 07:27:33 +00:00
|
|
|
|
2021-06-21 10:32:12 +00:00
|
|
|
## 2. Segments in Flowgraph
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## 3. Flowgraph Recovery
|
2021-10-12 11:18:33 +00:00
|
|
|
|
2021-06-03 07:27:33 +00:00
|
|
|
### A. Save checkpoints
|
2021-10-12 11:18:33 +00:00
|
|
|
|
2021-06-03 07:27:33 +00:00
|
|
|
When a flowgraph flushes a segment, we need to save these things:
|
2021-10-12 11:18:33 +00:00
|
|
|
|
2021-06-03 07:27:33 +00:00
|
|
|
- current segment's binlog paths,
|
|
|
|
- current segment positions,
|
2021-10-09 03:35:01 +00:00
|
|
|
- all other segments' current positions from replica (If a segment hasn't been flushed, save the position when datanode first meets it.)
|
2021-06-03 07:27:33 +00:00
|
|
|
|
|
|
|
Whether save successfully:
|
2021-10-12 11:18:33 +00:00
|
|
|
|
2021-10-11 13:17:27 +00:00
|
|
|
- If succeeded, flowgraph updates all segments' positions to replica
|
2021-06-03 07:27:33 +00:00
|
|
|
- If not
|
2021-10-12 11:18:33 +00:00
|
|
|
- For a grpc failure( this failure will appear after many times retry internally), crush itself.
|
|
|
|
- For a normal failure, retry save 10 times, if fail still, crush itself.
|
2021-06-03 07:27:33 +00:00
|
|
|
|
|
|
|
### B. Recovery from a set of checkpoints
|
2021-10-12 11:18:33 +00:00
|
|
|
|
2021-06-03 07:27:33 +00:00
|
|
|
1. We need all positions of all segments in this vchannel `p1, p2, ... pn`
|
|
|
|
|
2021-06-21 10:32:12 +00:00
|
|
|
A design of WatchDmChannelReq
|
2021-10-12 11:18:33 +00:00
|
|
|
|
|
|
|
```proto
|
2021-06-21 10:32:12 +00:00
|
|
|
message VchannelInfo {
|
|
|
|
int64 collectionID = 1;
|
|
|
|
string channelName = 2;
|
|
|
|
internal.MsgPosition seek_position = 3;
|
|
|
|
repeated SegmentInfo unflushedSegments = 4;
|
|
|
|
repeated int64 flushedSegments = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
message WatchDmChannelsRequest {
|
|
|
|
common.MsgBase base = 1;
|
|
|
|
repeated VchannelInfo vchannels = 2;
|
|
|
|
}
|
|
|
|
```
|
2021-06-03 07:27:33 +00:00
|
|
|
|
|
|
|
2. We want to filter msgPacks based on these positions.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
Supposing we have segment `s1, s2, s3`, corresponding position `p1, p2, p3`
|
2021-10-12 11:18:33 +00:00
|
|
|
|
|
|
|
- Sort positions in reverse order `p3, p2, p1`
|
|
|
|
- Get segments dup range time: `s3 ( p3 > mp_px > p1)`, `s2 (p2 > mp_px > p1)`, `s1(zero)`
|
|
|
|
- Seek from the earliest, in this example `p1`
|
|
|
|
- Then for every msgPack after seeking `p1`, the pseudocode:
|
2021-06-03 07:27:33 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
const filter_threshold = recovery_time
|
|
|
|
// mp means msgPack
|
|
|
|
for mp := seeking(p1) {
|
2021-10-12 11:18:33 +00:00
|
|
|
if mp.position.endtime < filter_threshod {
|
2021-06-03 07:27:33 +00:00
|
|
|
if mp.position < p3 {
|
|
|
|
filter s3
|
|
|
|
}
|
|
|
|
if mp.position < p2 {
|
|
|
|
filter s2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|