[td-225] fix deadlock for client during query.
This commit is contained in:
parent
d61a05858a
commit
c96bf8b37d
|
@ -6293,6 +6293,19 @@ static void setQueryResultReady(SQInfo* pQInfo) {
|
|||
pthread_mutex_unlock(&pQInfo->lock);
|
||||
}
|
||||
|
||||
static bool doBuildResCheck(SQInfo* pQInfo) {
|
||||
bool buildRes = false;
|
||||
|
||||
pthread_mutex_lock(&pQInfo->lock);
|
||||
|
||||
pQInfo->dataReady = QUERY_RESULT_READY;
|
||||
buildRes = (pQInfo->rspContext != NULL);
|
||||
|
||||
pthread_mutex_unlock(&pQInfo->lock);
|
||||
|
||||
return buildRes;
|
||||
}
|
||||
|
||||
bool qTableQuery(qinfo_t qinfo) {
|
||||
SQInfo *pQInfo = (SQInfo *)qinfo;
|
||||
|
||||
|
@ -6303,16 +6316,13 @@ bool qTableQuery(qinfo_t qinfo) {
|
|||
|
||||
if (IS_QUERY_KILLED(pQInfo)) {
|
||||
qDebug("QInfo:%p it is already killed, abort", pQInfo);
|
||||
setQueryResultReady(pQInfo);
|
||||
return false;
|
||||
return doBuildResCheck(pQInfo);
|
||||
}
|
||||
|
||||
if (pQInfo->tableqinfoGroupInfo.numOfTables == 0) {
|
||||
setQueryStatus(pQInfo->runtimeEnv.pQuery, QUERY_COMPLETED);
|
||||
setQueryResultReady(pQInfo);
|
||||
|
||||
qDebug("QInfo:%p no table exists for query, abort", pQInfo);
|
||||
return false;
|
||||
setQueryStatus(pQInfo->runtimeEnv.pQuery, QUERY_COMPLETED);
|
||||
return doBuildResCheck(pQInfo);
|
||||
}
|
||||
|
||||
// error occurs, record the error code and return to client
|
||||
|
@ -6320,9 +6330,7 @@ bool qTableQuery(qinfo_t qinfo) {
|
|||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
pQInfo->code = ret;
|
||||
qDebug("QInfo:%p query abort due to error/cancel occurs, code:%s", pQInfo, tstrerror(pQInfo->code));
|
||||
|
||||
setQueryResultReady(pQInfo);
|
||||
return false;
|
||||
return doBuildResCheck(pQInfo);
|
||||
}
|
||||
|
||||
qDebug("QInfo:%p query task is launched", pQInfo);
|
||||
|
@ -6347,17 +6355,7 @@ bool qTableQuery(qinfo_t qinfo) {
|
|||
pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows);
|
||||
}
|
||||
|
||||
bool buildRes = false;
|
||||
pthread_mutex_lock(&pQInfo->lock);
|
||||
pQInfo->dataReady = QUERY_RESULT_READY;
|
||||
|
||||
if (pQInfo->rspContext != NULL) {
|
||||
buildRes = true;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_unlock(&pQInfo->lock);
|
||||
return buildRes;
|
||||
return doBuildResCheck(pQInfo);
|
||||
}
|
||||
|
||||
int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContext) {
|
||||
|
@ -6484,7 +6482,6 @@ int32_t qKillQuery(qinfo_t qinfo) {
|
|||
return TSDB_CODE_QRY_INVALID_QHANDLE;
|
||||
}
|
||||
|
||||
// sem_post(&pQInfo->dataReady);
|
||||
setQueryKilled(pQInfo);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue