fix(tsdb): fix race condition during set table list and drop tsdbreader.

This commit is contained in:
Haojun Liao 2024-08-27 13:45:39 +08:00
parent 403d46b77b
commit 0207f9689a
1 changed files with 9 additions and 2 deletions

View File

@ -4588,6 +4588,8 @@ int32_t tsdbSetTableList2(STsdbReader* pReader, const void* pTableList, int32_t
STableBlockScanInfo** p = NULL;
int32_t iter = 0;
(void)tsdbAcquireReader(pReader);
while ((p = tSimpleHashIterate(pReader->status.pTableMap, p, &iter)) != NULL) {
clearBlockScanInfo(*p);
}
@ -4595,12 +4597,14 @@ int32_t tsdbSetTableList2(STsdbReader* pReader, const void* pTableList, int32_t
if (size < num) {
code = ensureBlockScanInfoBuf(&pReader->blockInfoBuf, num);
if (code) {
(void) tsdbReleaseReader(pReader);
return code;
}
char* p1 = taosMemoryRealloc(pReader->status.uidList.tableUidList, sizeof(uint64_t) * num);
if (p1 == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
(void) tsdbReleaseReader(pReader);
return terrno;
}
pReader->status.uidList.tableUidList = (uint64_t*)p1;
@ -4617,16 +4621,19 @@ int32_t tsdbSetTableList2(STsdbReader* pReader, const void* pTableList, int32_t
STableBlockScanInfo* pInfo = NULL;
code = getPosInBlockInfoBuf(&pReader->blockInfoBuf, i, &pInfo);
if (code != TSDB_CODE_SUCCESS) {
(void) tsdbReleaseReader(pReader);
return code;
}
code = initTableBlockScanInfo(pInfo, pList[i].uid, pReader->status.pTableMap, pReader);
if (code != TSDB_CODE_SUCCESS) {
(void) tsdbReleaseReader(pReader);
return code;
}
}
return TDB_CODE_SUCCESS;
(void) tsdbReleaseReader(pReader);
return code;
}
uint64_t tsdbGetReaderMaxVersion2(STsdbReader* pReader) { return pReader->info.verRange.maxVer; }