Merge pull request #15669 from taosdata/fix/TD-18063
fix: fix clear cache caused deadlock issue
This commit is contained in:
commit
a1ca0487a4
|
@ -416,6 +416,7 @@ typedef struct SCtgCacheOperation {
|
||||||
bool syncOp;
|
bool syncOp;
|
||||||
tsem_t rspSem;
|
tsem_t rspSem;
|
||||||
bool stopQueue;
|
bool stopQueue;
|
||||||
|
bool unLocked;
|
||||||
} SCtgCacheOperation;
|
} SCtgCacheOperation;
|
||||||
|
|
||||||
typedef struct SCtgQNode {
|
typedef struct SCtgQNode {
|
||||||
|
|
|
@ -674,7 +674,13 @@ int32_t ctgEnqueue(SCatalog* pCtg, SCtgCacheOperation *operation) {
|
||||||
tsem_post(&gCtgMgmt.queue.reqSem);
|
tsem_post(&gCtgMgmt.queue.reqSem);
|
||||||
|
|
||||||
if (syncOp) {
|
if (syncOp) {
|
||||||
|
if (!operation->unLocked) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock);
|
||||||
|
}
|
||||||
tsem_wait(&operation->rspSem);
|
tsem_wait(&operation->rspSem);
|
||||||
|
if (!operation->unLocked) {
|
||||||
|
CTG_LOCK(CTG_READ, &gCtgMgmt.lock);
|
||||||
|
}
|
||||||
taosMemoryFree(operation);
|
taosMemoryFree(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,6 +1017,7 @@ int32_t ctgClearCacheEnqueue(SCatalog* pCtg, bool freeCtg, bool stopQueue, bool
|
||||||
op->opId = CTG_OP_CLEAR_CACHE;
|
op->opId = CTG_OP_CLEAR_CACHE;
|
||||||
op->syncOp = syncOp;
|
op->syncOp = syncOp;
|
||||||
op->stopQueue = stopQueue;
|
op->stopQueue = stopQueue;
|
||||||
|
op->unLocked = true;
|
||||||
|
|
||||||
SCtgClearCacheMsg *msg = taosMemoryMalloc(sizeof(SCtgClearCacheMsg));
|
SCtgClearCacheMsg *msg = taosMemoryMalloc(sizeof(SCtgClearCacheMsg));
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "catalogInt.h"
|
#include "catalogInt.h"
|
||||||
|
|
||||||
extern SCatalogMgmt gCtgMgmt;
|
extern SCatalogMgmt gCtgMgmt;
|
||||||
SCtgDebug gCTGDebug = {0};
|
SCtgDebug gCTGDebug = {.lockEnable = true};
|
||||||
|
|
||||||
void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
|
void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
|
||||||
ASSERT(*(int32_t*)param == 1);
|
ASSERT(*(int32_t*)param == 1);
|
||||||
|
|
|
@ -331,7 +331,7 @@ int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
SHashObj* pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
SHashObj* pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||||
if (NULL == pBatchs) {
|
if (NULL == pBatchs) {
|
||||||
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
pTask->pBatchs = pBatchs;
|
pTask->pBatchs = pBatchs;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue