Merge pull request #28659 from taosdata/fix/main/32800
fix vnode cannot restart while wal level =0
This commit is contained in:
commit
b0902e81eb
|
@ -424,6 +424,9 @@ static void printFileSet(int32_t vgId, SArray* fileSet, const char* str) {
|
||||||
|
|
||||||
int32_t walCheckAndRepairMeta(SWal* pWal) {
|
int32_t walCheckAndRepairMeta(SWal* pWal) {
|
||||||
// load log files, get first/snapshot/last version info
|
// load log files, get first/snapshot/last version info
|
||||||
|
if (pWal->cfg.level == TAOS_WAL_SKIP) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
const char* logPattern = "^[0-9]+.log$";
|
const char* logPattern = "^[0-9]+.log$";
|
||||||
const char* idxPattern = "^[0-9]+.idx$";
|
const char* idxPattern = "^[0-9]+.idx$";
|
||||||
|
|
|
@ -294,8 +294,11 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||||
static int32_t walRollImpl(SWal *pWal) {
|
static int32_t walRollImpl(SWal *pWal) {
|
||||||
int32_t code = 0, lino = 0;
|
int32_t code = 0, lino = 0;
|
||||||
|
|
||||||
|
if (pWal->cfg.level == TAOS_WAL_SKIP && pWal->pIdxFile != NULL && pWal->pLogFile != NULL) {
|
||||||
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
if (pWal->pIdxFile != NULL) {
|
if (pWal->pIdxFile != NULL) {
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP && (code = taosFsyncFile(pWal->pIdxFile)) != 0) {
|
if ((code = taosFsyncFile(pWal->pIdxFile)) != 0) {
|
||||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||||
}
|
}
|
||||||
code = taosCloseFile(&pWal->pIdxFile);
|
code = taosCloseFile(&pWal->pIdxFile);
|
||||||
|
@ -305,7 +308,7 @@ static int32_t walRollImpl(SWal *pWal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWal->pLogFile != NULL) {
|
if (pWal->pLogFile != NULL) {
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP && (code = taosFsyncFile(pWal->pLogFile)) != 0) {
|
if ((code = taosFsyncFile(pWal->pLogFile)) != 0) {
|
||||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||||
}
|
}
|
||||||
code = taosCloseFile(&pWal->pLogFile);
|
code = taosCloseFile(&pWal->pLogFile);
|
||||||
|
|
|
@ -455,3 +455,59 @@ TEST_F(WalRetentionEnv, repairMeta1) {
|
||||||
}
|
}
|
||||||
walCloseReader(pRead);
|
walCloseReader(pRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WalSkipLevel : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
static void SetUpTestCase() {
|
||||||
|
int code = walInit(NULL);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestCase() { walCleanUp(); }
|
||||||
|
|
||||||
|
void walResetEnv() {
|
||||||
|
TearDown();
|
||||||
|
taosRemoveDir(pathName);
|
||||||
|
SetUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
SWalCfg cfg;
|
||||||
|
cfg.rollPeriod = -1;
|
||||||
|
cfg.segSize = -1;
|
||||||
|
cfg.committed =-1;
|
||||||
|
cfg.retentionPeriod = -1;
|
||||||
|
cfg.retentionSize = 0;
|
||||||
|
cfg.rollPeriod = 0;
|
||||||
|
cfg.vgId = 1;
|
||||||
|
cfg.level = TAOS_WAL_SKIP;
|
||||||
|
pWal = walOpen(pathName, &cfg);
|
||||||
|
ASSERT(pWal != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
walClose(pWal);
|
||||||
|
pWal = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWal* pWal = NULL;
|
||||||
|
const char* pathName = TD_TMP_DIR_PATH "wal_test";
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(WalSkipLevel, restart) {
|
||||||
|
walResetEnv();
|
||||||
|
int code;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 100; i++) {
|
||||||
|
char newStr[100];
|
||||||
|
sprintf(newStr, "%s-%d", ranStr, i);
|
||||||
|
int len = strlen(newStr);
|
||||||
|
code = walAppendLog(pWal, i, 0, syncMeta, newStr, len);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TearDown();
|
||||||
|
|
||||||
|
SetUp();
|
||||||
|
}
|
Loading…
Reference in New Issue