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
|
|
|
|
2021-12-21 13:19:35 +00:00
|
|
|
A. One message stream to one vchannel, so there are one start and one end position in one message pack.
|
2021-11-08 02:40:59 +00:00
|
|
|
|
2021-12-17 10:52:15 +00:00
|
|
|
B. Only when DataNode flushes, DataNode will update every segment's position.
|
2021-06-03 07:27:33 +00:00
|
|
|
An optimization: update position of
|
2021-10-12 11:18:33 +00:00
|
|
|
|
2021-12-13 11:19:43 +00:00
|
|
|
1. Current flushing segment
|
|
|
|
2. StartPosition of segments has never been flushed.
|
2021-11-08 02:40:59 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
![segments](graphs/segments.png)
|
|
|
|
|
|
|
|
## 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-11-11 05:11:15 +00:00
|
|
|
- current segment's binlog paths.
|
|
|
|
- current segment positions.
|
2021-12-17 10:52:15 +00:00
|
|
|
- all other segments' current positions from the 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-12-17 08:58:46 +00:00
|
|
|
- If succeeded, flowgraph updates all segments' positions to the replica.
|
2021-06-03 07:27:33 +00:00
|
|
|
- If not
|
2021-12-22 09:09:40 +00:00
|
|
|
- For a grpc failure(this failure will appear after many times retry internally), crash itself.
|
|
|
|
- For a normal failure, retry save 10 times, if still fails, crash 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-10-26 06:32:56 +00:00
|
|
|
1. We need all positions of all segments in this vchannel `p1, p2, ... pn`.
|
2021-06-03 07:27:33 +00:00
|
|
|
|
2021-12-10 02:29:33 +00:00
|
|
|
Proto design for 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;
|
2023-03-04 15:21:50 +00:00
|
|
|
msgpb.MsgPosition seek_position = 3;
|
2021-06-21 10:32:12 +00:00
|
|
|
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.
|
|
|
|
|
|
|
|
![recovery](graphs/flowgraph_recovery_design.png)
|
|
|
|
|
2021-11-11 05:25:00 +00:00
|
|
|
Supposing we have segments `s1, s2, s3`, corresponding positions `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) {
|
2023-10-24 01:30:10 +00:00
|
|
|
if mp.position.endtime < filter_threshold {
|
2021-06-03 07:27:33 +00:00
|
|
|
if mp.position < p3 {
|
|
|
|
filter s3
|
|
|
|
}
|
|
|
|
if mp.position < p2 {
|
|
|
|
filter s2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|