diff --git a/src/dnode/src/dnodeWrite.c b/src/dnode/src/dnodeWrite.c index 2348cf62a4..aee14ed484 100644 --- a/src/dnode/src/dnodeWrite.c +++ b/src/dnode/src/dnodeWrite.c @@ -40,7 +40,7 @@ typedef struct { SRpcMsg rpcMsg; } SWriteMsg; -typedef struct _thread_obj { +typedef struct _wworker_pool { int32_t max; // max number of workers int32_t nextId; // from 0 to max-1, cyclic SWriteWorker *writeWorker; diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c index 6d75776ac8..2cf94267f8 100644 --- a/src/util/src/tqueue.c +++ b/src/util/src/tqueue.c @@ -92,7 +92,7 @@ void *taosAllocateQitem(int size) { void taosFreeQitem(void *param) { if (param == NULL) return; - //pTrace("item:%p is freed", param); + pTrace("item:%p is freed", param); char *temp = (char *)param; temp -= sizeof(STaosQnode); @@ -117,7 +117,7 @@ int taosWriteQitem(taos_queue param, int type, void *item) { queue->numOfItems++; if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1); - //pTrace("item:%p is put into queue, type:%d items:%d", item, type, queue->numOfItems); + pTrace("item:%p is put into queue, type:%d items:%d", item, type, queue->numOfItems); pthread_mutex_unlock(&queue->mutex); @@ -197,7 +197,7 @@ int taosGetQitem(taos_qall param, int *type, void **pitem) { *pitem = pNode->item; *type = pNode->type; num = 1; - // pTrace("item:%p is fetched, type:%d", *pitem, *type); + pTrace("item:%p is fetched, type:%d", *pitem, *type); } return num; diff --git a/src/vnode/main/src/vnodeMain.c b/src/vnode/main/src/vnodeMain.c index be41b6b7c1..5bb5ef55ef 100644 --- a/src/vnode/main/src/vnodeMain.c +++ b/src/vnode/main/src/vnodeMain.c @@ -165,7 +165,10 @@ void vnodeRelease(void *pVnodeRaw) { int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1); - if (refCount > 0) return; + if (refCount > 0) { + dTrace("pVnode:%p vgId:%d, release vnode, refCount:%d", pVnode, pVnode->vgId, refCount); + return; + } // remove read queue dnodeFreeRqueue(pVnode->rqueue); diff --git a/src/vnode/main/src/vnodeWrite.c b/src/vnode/main/src/vnodeWrite.c index 2c31f2243b..c6699bd62c 100644 --- a/src/vnode/main/src/vnodeWrite.c +++ b/src/vnode/main/src/vnodeWrite.c @@ -255,7 +255,8 @@ int vnodeWriteToQueue(void *param, SWalHead *pHead, int type) { SWalHead *pWal = (SWalHead *)taosAllocateQitem(size); memcpy(pWal, pHead, size); - taosWriteQitem(pVnode->wqueue, type, pHead); + atomic_add_fetch_32(&pVnode->refCount, 1); + taosWriteQitem(pVnode->wqueue, type, pWal); return 0; } diff --git a/src/vnode/wal/src/walMain.c b/src/vnode/wal/src/walMain.c index e192e91e8a..9708b0d9dc 100644 --- a/src/vnode/wal/src/walMain.c +++ b/src/vnode/wal/src/walMain.c @@ -287,6 +287,8 @@ static int walRestoreWalFile(char *name, void *pVnode, int (*writeFp)(void *, SW (*writeFp)(pVnode, pHead, TAOS_QTYPE_WAL); } + free(buffer); + return code; }