Merge pull request #1527 from taosdata/hotfix/headfile

a wrong pointer in vnodeWriteToQueue
This commit is contained in:
slguan 2020-04-05 22:05:09 +08:00 committed by GitHub
commit 30aeadffd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 6 deletions

View File

@ -40,7 +40,7 @@ typedef struct {
SRpcMsg rpcMsg; SRpcMsg rpcMsg;
} SWriteMsg; } SWriteMsg;
typedef struct _thread_obj { typedef struct _wworker_pool {
int32_t max; // max number of workers int32_t max; // max number of workers
int32_t nextId; // from 0 to max-1, cyclic int32_t nextId; // from 0 to max-1, cyclic
SWriteWorker *writeWorker; SWriteWorker *writeWorker;

View File

@ -92,7 +92,7 @@ void *taosAllocateQitem(int size) {
void taosFreeQitem(void *param) { void taosFreeQitem(void *param) {
if (param == NULL) return; if (param == NULL) return;
//pTrace("item:%p is freed", param); pTrace("item:%p is freed", param);
char *temp = (char *)param; char *temp = (char *)param;
temp -= sizeof(STaosQnode); temp -= sizeof(STaosQnode);
@ -117,7 +117,7 @@ int taosWriteQitem(taos_queue param, int type, void *item) {
queue->numOfItems++; queue->numOfItems++;
if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1); 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); pthread_mutex_unlock(&queue->mutex);
@ -197,7 +197,7 @@ int taosGetQitem(taos_qall param, int *type, void **pitem) {
*pitem = pNode->item; *pitem = pNode->item;
*type = pNode->type; *type = pNode->type;
num = 1; num = 1;
// pTrace("item:%p is fetched, type:%d", *pitem, *type); pTrace("item:%p is fetched, type:%d", *pitem, *type);
} }
return num; return num;

View File

@ -165,7 +165,10 @@ void vnodeRelease(void *pVnodeRaw) {
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1); 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 // remove read queue
dnodeFreeRqueue(pVnode->rqueue); dnodeFreeRqueue(pVnode->rqueue);

View File

@ -255,7 +255,8 @@ int vnodeWriteToQueue(void *param, SWalHead *pHead, int type) {
SWalHead *pWal = (SWalHead *)taosAllocateQitem(size); SWalHead *pWal = (SWalHead *)taosAllocateQitem(size);
memcpy(pWal, pHead, size); memcpy(pWal, pHead, size);
taosWriteQitem(pVnode->wqueue, type, pHead); atomic_add_fetch_32(&pVnode->refCount, 1);
taosWriteQitem(pVnode->wqueue, type, pWal);
return 0; return 0;
} }

View File

@ -287,6 +287,8 @@ static int walRestoreWalFile(char *name, void *pVnode, int (*writeFp)(void *, SW
(*writeFp)(pVnode, pHead, TAOS_QTYPE_WAL); (*writeFp)(pVnode, pHead, TAOS_QTYPE_WAL);
} }
free(buffer);
return code; return code;
} }