fix(wal): snapshot end with no deleting
This commit is contained in:
parent
59646be215
commit
c2164dd8aa
|
@ -583,7 +583,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
pHandle->execHandle.execTb.suid = req.suid;
|
pHandle->execHandle.execTb.suid = req.suid;
|
||||||
SArray* tbUidList = taosArrayInit(0, sizeof(int64_t));
|
SArray* tbUidList = taosArrayInit(0, sizeof(int64_t));
|
||||||
vnodeGetCtbIdList(pTq->pVnode, req.suid, tbUidList);
|
vnodeGetCtbIdList(pTq->pVnode, req.suid, tbUidList);
|
||||||
tqDebug("vgId:%d, tq try get suid:%" PRId64, pTq->pVnode->config.vgId, req.suid);
|
tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, req.suid);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
||||||
tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid);
|
tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid);
|
||||||
|
|
|
@ -40,8 +40,8 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
||||||
.vgId = -1,
|
.vgId = -1,
|
||||||
.fsyncPeriod = 0,
|
.fsyncPeriod = 0,
|
||||||
.retentionPeriod = -1,
|
.retentionPeriod = -1,
|
||||||
.rollPeriod = -1,
|
.rollPeriod = 0,
|
||||||
.segSize = -1,
|
.segSize = 0,
|
||||||
.retentionSize = -1,
|
.retentionSize = -1,
|
||||||
.level = TAOS_WAL_WRITE,
|
.level = TAOS_WAL_WRITE,
|
||||||
},
|
},
|
||||||
|
|
|
@ -277,35 +277,37 @@ int32_t walEndSnapshot(SWal *pWal) {
|
||||||
tmp.firstVer = ver;
|
tmp.firstVer = ver;
|
||||||
// find files safe to delete
|
// find files safe to delete
|
||||||
SWalFileInfo *pInfo = taosArraySearch(pWal->fileInfoSet, &tmp, compareWalFileInfo, TD_LE);
|
SWalFileInfo *pInfo = taosArraySearch(pWal->fileInfoSet, &tmp, compareWalFileInfo, TD_LE);
|
||||||
if (ver >= pInfo->lastVer) {
|
if (pInfo) {
|
||||||
pInfo++;
|
if (ver >= pInfo->lastVer) {
|
||||||
}
|
pInfo++;
|
||||||
// iterate files, until the searched result
|
}
|
||||||
for (SWalFileInfo *iter = pWal->fileInfoSet->pData; iter < pInfo; iter++) {
|
// iterate files, until the searched result
|
||||||
if ((pWal->cfg.retentionSize != -1 && newTotSize > pWal->cfg.retentionSize) ||
|
for (SWalFileInfo *iter = pWal->fileInfoSet->pData; iter < pInfo; iter++) {
|
||||||
(pWal->cfg.retentionPeriod != -1 && iter->closeTs + pWal->cfg.retentionPeriod > ts)) {
|
if ((pWal->cfg.retentionSize != -1 && newTotSize > pWal->cfg.retentionSize) ||
|
||||||
// delete according to file size or close time
|
(pWal->cfg.retentionPeriod != -1 && iter->closeTs + pWal->cfg.retentionPeriod > ts)) {
|
||||||
deleteCnt++;
|
// delete according to file size or close time
|
||||||
newTotSize -= iter->fileSize;
|
deleteCnt++;
|
||||||
|
newTotSize -= iter->fileSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char fnameStr[WAL_FILE_LEN];
|
||||||
|
// remove file
|
||||||
|
for (int i = 0; i < deleteCnt; i++) {
|
||||||
|
pInfo = taosArrayGet(pWal->fileInfoSet, i);
|
||||||
|
walBuildLogName(pWal, pInfo->firstVer, fnameStr);
|
||||||
|
taosRemoveFile(fnameStr);
|
||||||
|
walBuildIdxName(pWal, pInfo->firstVer, fnameStr);
|
||||||
|
taosRemoveFile(fnameStr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
char fnameStr[WAL_FILE_LEN];
|
|
||||||
// remove file
|
|
||||||
for (int i = 0; i < deleteCnt; i++) {
|
|
||||||
pInfo = taosArrayGet(pWal->fileInfoSet, i);
|
|
||||||
walBuildLogName(pWal, pInfo->firstVer, fnameStr);
|
|
||||||
taosRemoveFile(fnameStr);
|
|
||||||
walBuildIdxName(pWal, pInfo->firstVer, fnameStr);
|
|
||||||
taosRemoveFile(fnameStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make new array, remove files
|
// make new array, remove files
|
||||||
taosArrayPopFrontBatch(pWal->fileInfoSet, deleteCnt);
|
taosArrayPopFrontBatch(pWal->fileInfoSet, deleteCnt);
|
||||||
if (taosArrayGetSize(pWal->fileInfoSet) == 0) {
|
if (taosArrayGetSize(pWal->fileInfoSet) == 0) {
|
||||||
pWal->writeCur = -1;
|
pWal->writeCur = -1;
|
||||||
pWal->vers.firstVer = -1;
|
pWal->vers.firstVer = -1;
|
||||||
} else {
|
} else {
|
||||||
pWal->vers.firstVer = ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, 0))->firstVer;
|
pWal->vers.firstVer = ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, 0))->firstVer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pWal->writeCur = taosArrayGetSize(pWal->fileInfoSet) - 1;
|
pWal->writeCur = taosArrayGetSize(pWal->fileInfoSet) - 1;
|
||||||
pWal->totSize = newTotSize;
|
pWal->totSize = newTotSize;
|
||||||
|
|
Loading…
Reference in New Issue