fix: possible race condition
This commit is contained in:
parent
003e4a886d
commit
5e45ecd3fd
|
@ -397,6 +397,7 @@ struct STbData {
|
|||
tb_uid_t uid;
|
||||
TSKEY minKey;
|
||||
TSKEY maxKey;
|
||||
SRWLatch lock;
|
||||
SDelData *pHead;
|
||||
SDelData *pTail;
|
||||
SMemSkipList sl;
|
||||
|
|
|
@ -181,6 +181,7 @@ int32_t tsdbDeleteTableData(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid
|
|||
pDelData->sKey = sKey;
|
||||
pDelData->eKey = eKey;
|
||||
pDelData->pNext = NULL;
|
||||
taosWLockLatch(&pTbData->lock);
|
||||
if (pTbData->pHead == NULL) {
|
||||
ASSERT(pTbData->pTail == NULL);
|
||||
pTbData->pHead = pTbData->pTail = pDelData;
|
||||
|
@ -188,6 +189,7 @@ int32_t tsdbDeleteTableData(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid
|
|||
pTbData->pTail->pNext = pDelData;
|
||||
pTbData->pTail = pDelData;
|
||||
}
|
||||
taosWUnLockLatch(&pTbData->lock);
|
||||
|
||||
pMemTable->nDel++;
|
||||
pMemTable->minVer = TMIN(pMemTable->minVer, version);
|
||||
|
@ -401,6 +403,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid
|
|||
SL_NODE_BACKWARD(pTbData->sl.pHead, iLevel) = NULL;
|
||||
SL_NODE_FORWARD(pTbData->sl.pTail, iLevel) = NULL;
|
||||
}
|
||||
taosInitRWLatch(&pTbData->lock);
|
||||
|
||||
taosWLockLatch(&pMemTable->latch);
|
||||
|
||||
|
|
|
@ -22,9 +22,14 @@
|
|||
#include "tsdbUtil2.h"
|
||||
#include "tsimplehash.h"
|
||||
|
||||
#define INIT_TIMEWINDOW(_w) do { (_w)->skey = INT64_MAX; (_w)->ekey = INT64_MIN;} while(0);
|
||||
#define INIT_TIMEWINDOW(_w) \
|
||||
do { \
|
||||
(_w)->skey = INT64_MAX; \
|
||||
(_w)->ekey = INT64_MIN; \
|
||||
} while (0);
|
||||
|
||||
static bool overlapWithDelSkylineWithoutVer(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, int32_t order);
|
||||
static bool overlapWithDelSkylineWithoutVer(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord,
|
||||
int32_t order);
|
||||
|
||||
static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) {
|
||||
int32_t num = numOfTables / pBuf->numPerBucket;
|
||||
|
@ -650,6 +655,7 @@ void loadMemTombData(SArray** ppMemDelData, STbData* pMemTbData, STbData* piMemT
|
|||
|
||||
SDelData* p = NULL;
|
||||
if (pMemTbData != NULL) {
|
||||
taosRLockLatch(&pMemTbData->lock);
|
||||
p = pMemTbData->pHead;
|
||||
while (p) {
|
||||
if (p->version <= ver) {
|
||||
|
@ -658,6 +664,7 @@ void loadMemTombData(SArray** ppMemDelData, STbData* pMemTbData, STbData* piMemT
|
|||
|
||||
p = p->pNext;
|
||||
}
|
||||
taosRUnLockLatch(&pMemTbData->lock);
|
||||
}
|
||||
|
||||
if (piMemTbData != NULL) {
|
||||
|
@ -903,7 +910,8 @@ static int32_t sortUidComparFn(const void* p1, const void* p2) {
|
|||
}
|
||||
}
|
||||
|
||||
bool isCleanSttBlock(SArray* pTimewindowList, STimeWindow* pQueryWindow, STableBlockScanInfo *pScanInfo, int32_t order) {
|
||||
bool isCleanSttBlock(SArray* pTimewindowList, STimeWindow* pQueryWindow, STableBlockScanInfo* pScanInfo,
|
||||
int32_t order) {
|
||||
// check if it overlap with del skyline
|
||||
taosArraySort(pTimewindowList, sortUidComparFn);
|
||||
|
||||
|
|
Loading…
Reference in New Issue