Merge pull request #28803 from taosdata/fix/main/TD-32915
fix:skip begin&end snapshot while wal level = 0.
This commit is contained in:
commit
afcdd4e4b3
|
@ -376,6 +376,10 @@ static FORCE_INLINE int32_t walCheckAndRoll(SWal *pWal) {
|
|||
int32_t walBeginSnapshot(SWal *pWal, int64_t ver, int64_t logRetention) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (pWal->cfg.level == TAOS_WAL_SKIP) {
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
if (logRetention < 0) {
|
||||
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||
}
|
||||
|
@ -404,6 +408,10 @@ _exit:
|
|||
int32_t walEndSnapshot(SWal *pWal) {
|
||||
int32_t code = 0, lino = 0;
|
||||
|
||||
if (pWal->cfg.level == TAOS_WAL_SKIP) {
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&pWal->mutex));
|
||||
int64_t ver = pWal->vers.verInSnapshotting;
|
||||
|
||||
|
|
|
@ -511,3 +511,26 @@ TEST_F(WalSkipLevel, restart) {
|
|||
|
||||
SetUp();
|
||||
}
|
||||
|
||||
TEST_F(WalSkipLevel, roll) {
|
||||
int code;
|
||||
int i;
|
||||
for (i = 0; i < 100; i++) {
|
||||
code = walAppendLog(pWal, i, 0, syncMeta, (void*)ranStr, ranStrLen);
|
||||
ASSERT_EQ(code, 0);
|
||||
code = walCommit(pWal, i);
|
||||
}
|
||||
walBeginSnapshot(pWal, i - 1, 0);
|
||||
walEndSnapshot(pWal);
|
||||
code = walAppendLog(pWal, 5, 0, syncMeta, (void*)ranStr, ranStrLen);
|
||||
ASSERT_NE(code, 0);
|
||||
for (; i < 200; i++) {
|
||||
code = walAppendLog(pWal, i, 0, syncMeta, (void*)ranStr, ranStrLen);
|
||||
ASSERT_EQ(code, 0);
|
||||
code = walCommit(pWal, i);
|
||||
}
|
||||
code = walBeginSnapshot(pWal, i - 1, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
code = walEndSnapshot(pWal);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
Loading…
Reference in New Issue