feat(wal): support restore from snapshot

This commit is contained in:
Liu Jicong 2022-06-02 11:38:04 +08:00
parent 114792424e
commit 361332505c
2 changed files with 9 additions and 0 deletions

View File

@ -184,6 +184,7 @@ int32_t walRollback(SWal *, int64_t ver);
// notify that previous logs can be pruned safely
int32_t walBeginSnapshot(SWal *, int64_t ver);
int32_t walEndSnapshot(SWal *);
void walRestoreFromSnapshot(SWal *, int64_t ver);
// int32_t walDataCorrupted(SWal*);
// read

View File

@ -18,6 +18,14 @@
#include "tchecksum.h"
#include "walInt.h"
void walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
pWal->vers.firstVer = -1;
pWal->vers.lastVer = ver;
pWal->vers.commitVer = ver - 1;
pWal->vers.snapshotVer = ver - 1;
pWal->vers.verInSnapshotting = -1;
}
int32_t walCommit(SWal *pWal, int64_t ver) {
ASSERT(pWal->vers.commitVer >= pWal->vers.snapshotVer);
ASSERT(pWal->vers.commitVer <= pWal->vers.lastVer);