Merge pull request #27676 from taosdata/fix/TD-31891-remove-void-sdb
fix/TD-31891-remove-void-sdb
This commit is contained in:
commit
a662b59041
|
@ -68,7 +68,11 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
||||||
void sdbCleanup(SSdb *pSdb) {
|
void sdbCleanup(SSdb *pSdb) {
|
||||||
mInfo("start to cleanup sdb");
|
mInfo("start to cleanup sdb");
|
||||||
|
|
||||||
(void)sdbWriteFile(pSdb, 0);
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if ((code = sdbWriteFile(pSdb, 0)) != 0) {
|
||||||
|
mError("failed to write sdb file since %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
if (pSdb->currDir != NULL) {
|
if (pSdb->currDir != NULL) {
|
||||||
taosMemoryFreeClear(pSdb->currDir);
|
taosMemoryFreeClear(pSdb->currDir);
|
||||||
|
|
|
@ -258,8 +258,11 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("failed to read sdb file:%s head since %s", file, tstrerror(code));
|
mError("failed to read sdb file:%s head since %s", file, tstrerror(code));
|
||||||
taosMemoryFree(pRaw);
|
taosMemoryFree(pRaw);
|
||||||
(void)taosCloseFile(&pFile);
|
int32_t ret = 0;
|
||||||
return -1;
|
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||||
|
mError("failed to close sdb file:%s since %s", file, tstrerror(ret));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t tableVer[SDB_MAX] = {0};
|
int64_t tableVer[SDB_MAX] = {0};
|
||||||
|
@ -361,7 +364,9 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
pSdb->commitTerm, pSdb->commitConfig);
|
pSdb->commitTerm, pSdb->commitConfig);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
(void)taosCloseFile(&pFile);
|
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||||
|
mError("failed to close sdb file:%s since %s", file, tstrerror(ret));
|
||||||
|
}
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
@ -404,8 +409,11 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||||
code = sdbWriteFileHead(pSdb, pFile);
|
code = sdbWriteFileHead(pSdb, pFile);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("failed to write sdb file:%s head since %s", tmpfile, tstrerror(code));
|
mError("failed to write sdb file:%s head since %s", tmpfile, tstrerror(code));
|
||||||
(void)taosCloseFile(&pFile);
|
int32_t ret = 0;
|
||||||
return -1;
|
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||||
|
mError("failed to close sdb file:%s since %s", tmpfile, tstrerror(ret));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = SDB_MAX - 1; i >= 0; --i) {
|
for (int32_t i = SDB_MAX - 1; i >= 0; --i) {
|
||||||
|
@ -613,12 +621,18 @@ static void sdbCloseIter(SSdbIter *pIter) {
|
||||||
if (pIter == NULL) return;
|
if (pIter == NULL) return;
|
||||||
|
|
||||||
if (pIter->file != NULL) {
|
if (pIter->file != NULL) {
|
||||||
(void)taosCloseFile(&pIter->file);
|
int32_t ret = 0;
|
||||||
|
if ((ret = taosCloseFile(&pIter->file)) != 0) {
|
||||||
|
mError("failed to close sdb file since %s", tstrerror(ret));
|
||||||
|
}
|
||||||
pIter->file = NULL;
|
pIter->file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pIter->name != NULL) {
|
if (pIter->name != NULL) {
|
||||||
(void)taosRemoveFile(pIter->name);
|
int32_t ret = 0;
|
||||||
|
if ((ret = taosRemoveFile(pIter->name)) != 0) {
|
||||||
|
mError("failed to remove sdb file:%s since %s", pIter->name, tstrerror(ret));
|
||||||
|
}
|
||||||
taosMemoryFree(pIter->name);
|
taosMemoryFree(pIter->name);
|
||||||
pIter->name = NULL;
|
pIter->name = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,12 +174,12 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
if (insertFp != NULL) {
|
if (insertFp != NULL) {
|
||||||
code = (*insertFp)(pSdb, pRow->pObj);
|
code = (*insertFp)(pSdb, pRow->pObj);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
if (terrno == 0) terrno = TSDB_CODE_MND_TRANS_UNKNOW_ERROR;
|
if (taosHashRemove(hash, pRow->pObj, keySize) != 0) {
|
||||||
code = terrno;
|
mError("failed to remove row from hash");
|
||||||
(void)taosHashRemove(hash, pRow->pObj, keySize);
|
}
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = code;
|
|
||||||
sdbUnLock(pSdb, type);
|
sdbUnLock(pSdb, type);
|
||||||
|
terrno = code;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue