[td-225] fix bug in hash

This commit is contained in:
Haojun Liao 2020-08-05 17:03:59 +08:00
parent 0ce566550d
commit 175dfb56a0
2 changed files with 25 additions and 29 deletions

View File

@ -318,6 +318,8 @@ static void incRefFn(void* ptNode) {
assert(ptNode != NULL); assert(ptNode != NULL);
SCacheDataNode** p = (SCacheDataNode**) ptNode; SCacheDataNode** p = (SCacheDataNode**) ptNode;
assert(T_REF_VAL_GET(*p) >= 0);
int32_t ret = T_REF_INC(*p); int32_t ret = T_REF_INC(*p);
assert(ret > 0); assert(ret > 0);
} }

View File

@ -186,40 +186,35 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
} else { } else {
assert(pCont != NULL); assert(pCont != NULL);
void** qhandle = (void**) pCont; void** qhandle = (void**) pCont;
// *handle = /*(void*) */pCont;
// handle = qAcquireQInfo(pVnode->qMgmt, (uint64_t) pCont); vDebug("vgId:%d, QInfo:%p, dnode continues to exec query", pVnode->vgId, *qhandle);
// if (handle == NULL) {
// vWarn("QInfo:%p invalid qhandle in continuing exec query, conn:%p", (void*) pCont, pReadMsg->rpcMsg.handle);
// code = TSDB_CODE_QRY_INVALID_QHANDLE;
// } else {
vDebug("vgId:%d, QInfo:%p, dnode continues to exec query", pVnode->vgId, *qhandle);
bool freehandle = false; bool freehandle = false;
bool buildRes = qTableQuery(*qhandle); // do execute query bool buildRes = qTableQuery(*qhandle); // do execute query
// build query rsp, the retrieve request has reached here already // build query rsp, the retrieve request has reached here already
if (buildRes) { if (buildRes) {
// update the connection info according to the retrieve connection // update the connection info according to the retrieve connection
pReadMsg->rpcMsg.handle = qGetResultRetrieveMsg(*qhandle); pReadMsg->rpcMsg.handle = qGetResultRetrieveMsg(*qhandle);
assert(pReadMsg->rpcMsg.handle != NULL); assert(pReadMsg->rpcMsg.handle != NULL);
vDebug("vgId:%d, QInfo:%p, start to build retrieval rsp after query paused, %p", pVnode->vgId, *qhandle, vDebug("vgId:%d, QInfo:%p, start to build retrieval rsp after query paused, %p", pVnode->vgId, *qhandle,
pReadMsg->rpcMsg.handle); pReadMsg->rpcMsg.handle);
code = vnodeDumpQueryResult(&pReadMsg->rspRet, pVnode, qhandle, &freehandle); code = vnodeDumpQueryResult(&pReadMsg->rspRet, pVnode, qhandle, &freehandle);
// todo test the error code case // todo test the error code case
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
code = TSDB_CODE_QRY_HAS_RSP; code = TSDB_CODE_QRY_HAS_RSP;
}
} else {
freehandle = qQueryCompleted(*qhandle);
} }
} else {
freehandle = qQueryCompleted(*qhandle);
}
// NOTE: if the qhandle is not put into vread queue or query is completed, free the qhandle. // NOTE: if the qhandle is not put into vread queue or query is completed, free the qhandle.
if (freehandle || (!buildRes)) { // if not build result, free it not by forced.
qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, freehandle); if (freehandle || (!buildRes)) {
} qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, freehandle);
}
} }
return code; return code;
@ -273,9 +268,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
void** dup = handle; void** dup = handle;
code = vnodeDumpQueryResult(pRet, pVnode, handle, &freeHandle); code = vnodeDumpQueryResult(pRet, pVnode, handle, &freeHandle);
qReleaseQInfo(pVnode->qMgmt, (void**) &handle, false);
// not added into task queue, the query must be completed already, free qhandle immediate // not added into task queue, the query must be completed already, free qhandle immediately
if (freeHandle) { if (freeHandle) {
qReleaseQInfo(pVnode->qMgmt, (void**) &dup, true); qReleaseQInfo(pVnode->qMgmt, (void**) &dup, true);
} }