fix: lock mem items of tqueue

This commit is contained in:
Shengliang Guan 2022-10-21 19:12:03 +08:00
parent 5ee04e8059
commit 922436e7d4
2 changed files with 2 additions and 6 deletions

View File

@ -519,7 +519,7 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
do { do {
int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE); int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE);
if (itemSize == 0) { if (itemSize <= 0) {
vInfo("vgId:%d, start write vnode snapshot since apply queue is empty", pVnode->config.vgId); vInfo("vgId:%d, start write vnode snapshot since apply queue is empty", pVnode->config.vgId);
break; break;
} else { } else {
@ -572,7 +572,7 @@ static void vnodeRestoreFinish(struct SSyncFSM *pFsm) {
do { do {
int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE); int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE);
if (itemSize == 0) { if (itemSize <= 0) {
vInfo("vgId:%d, apply queue is empty, restore finish", pVnode->config.vgId); vInfo("vgId:%d, apply queue is empty, restore finish", pVnode->config.vgId);
break; break;
} else { } else {

View File

@ -141,14 +141,10 @@ int32_t taosQueueItemSize(STaosQueue *queue) {
} }
int64_t taosQueueMemorySize(STaosQueue *queue) { int64_t taosQueueMemorySize(STaosQueue *queue) {
#if 1
return queue->memOfItems;
#else
taosThreadMutexLock(&queue->mutex); taosThreadMutexLock(&queue->mutex);
int64_t memOfItems = queue->memOfItems; int64_t memOfItems = queue->memOfItems;
taosThreadMutexUnlock(&queue->mutex); taosThreadMutexUnlock(&queue->mutex);
return memOfItems; return memOfItems;
#endif
} }
void *taosAllocateQitem(int32_t size, EQItype itype) { void *taosAllocateQitem(int32_t size, EQItype itype) {