* 1. Attempt to directly parse the wal. * 2. If the attempt fails, then it is necessary to parse the current snapshot, * After completion, repeat the steps of the first phase. */
| 53 | * After completion, repeat the steps of the first phase. |
| 54 | */ |
| 55 | void Sync::Start() { |
| 56 | auto s = readNextSeqFromFile(&next_seq_); |
| 57 | if (!s.IsOK()) { |
| 58 | ERROR("{}", s.Msg()); |
| 59 | return; |
| 60 | } |
| 61 | INFO("Start sync the data from kvrocks to redis"); |
| 62 | while (!IsStopped()) { |
| 63 | s = checkWalBoundary(); |
| 64 | if (!s.IsOK()) { |
| 65 | parseKVFromLocalStorage(); |
| 66 | } |
| 67 | s = incrementBatchLoop(); |
| 68 | if (!s.IsOK()) { |
| 69 | ERROR("{}", s.Msg()); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | void Sync::Stop() { |
| 75 | if (stop_flag_) return; |