Merge pull request #5553 from taosdata/hotfix/TD-3448
[TD-3448]Fix cq get empty vgroup and crash issue
This commit is contained in:
commit
8512726778
|
@ -613,7 +613,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) {
|
||||||
tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen;
|
tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg) {
|
static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg, int32_t *succeed) {
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0);
|
||||||
TSKEY dfltKey = htobe64(pQueryMsg->window.skey);
|
TSKEY dfltKey = htobe64(pQueryMsg->window.skey);
|
||||||
|
|
||||||
|
@ -626,9 +626,14 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
|
||||||
assert(index >= 0);
|
assert(index >= 0);
|
||||||
|
|
||||||
SVgroupInfo* pVgroupInfo = NULL;
|
SVgroupInfo* pVgroupInfo = NULL;
|
||||||
if (pTableMetaInfo->vgroupList->numOfVgroups > 0) {
|
if (pTableMetaInfo->vgroupList && pTableMetaInfo->vgroupList->numOfVgroups > 0) {
|
||||||
assert(index < pTableMetaInfo->vgroupList->numOfVgroups);
|
assert(index < pTableMetaInfo->vgroupList->numOfVgroups);
|
||||||
pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index];
|
pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index];
|
||||||
|
} else {
|
||||||
|
tscError("%p No vgroup info found", pSql);
|
||||||
|
|
||||||
|
*succeed = 0;
|
||||||
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
vgId = pVgroupInfo->vgId;
|
vgId = pVgroupInfo->vgId;
|
||||||
|
@ -948,8 +953,13 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
pQueryMsg->secondStageOutput = 0;
|
pQueryMsg->secondStageOutput = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t succeed = 1;
|
||||||
|
|
||||||
// serialize the table info (sid, uid, tags)
|
// serialize the table info (sid, uid, tags)
|
||||||
pMsg = doSerializeTableInfo(pQueryMsg, pSql, pMsg);
|
pMsg = doSerializeTableInfo(pQueryMsg, pSql, pMsg, &succeed);
|
||||||
|
if (succeed == 0) {
|
||||||
|
return TSDB_CODE_TSC_APP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SSqlGroupbyExpr *pGroupbyExpr = &pQueryInfo->groupbyExpr;
|
SSqlGroupbyExpr *pGroupbyExpr = &pQueryInfo->groupbyExpr;
|
||||||
if (pGroupbyExpr->numOfGroupCols > 0) {
|
if (pGroupbyExpr->numOfGroupCols > 0) {
|
||||||
|
@ -2081,19 +2091,24 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
|
||||||
assert(pInfo->vgroupList != NULL);
|
assert(pInfo->vgroupList != NULL);
|
||||||
|
|
||||||
pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups;
|
pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups;
|
||||||
for (int32_t j = 0; j < pInfo->vgroupList->numOfVgroups; ++j) {
|
if (pInfo->vgroupList->numOfVgroups <= 0) {
|
||||||
//just init, no need to lock
|
//tfree(pInfo->vgroupList);
|
||||||
SVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j];
|
tscError("%p empty vgroup info", pSql);
|
||||||
|
} else {
|
||||||
|
for (int32_t j = 0; j < pInfo->vgroupList->numOfVgroups; ++j) {
|
||||||
|
//just init, no need to lock
|
||||||
|
SVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j];
|
||||||
|
|
||||||
SVgroupMsg *vmsg = &pVgroupMsg->vgroups[j];
|
SVgroupMsg *vmsg = &pVgroupMsg->vgroups[j];
|
||||||
pVgroups->vgId = htonl(vmsg->vgId);
|
pVgroups->vgId = htonl(vmsg->vgId);
|
||||||
pVgroups->numOfEps = vmsg->numOfEps;
|
pVgroups->numOfEps = vmsg->numOfEps;
|
||||||
|
|
||||||
assert(pVgroups->numOfEps >= 1 && pVgroups->vgId >= 1);
|
assert(pVgroups->numOfEps >= 1 && pVgroups->vgId >= 1);
|
||||||
|
|
||||||
for (int32_t k = 0; k < pVgroups->numOfEps; ++k) {
|
for (int32_t k = 0; k < pVgroups->numOfEps; ++k) {
|
||||||
pVgroups->epAddr[k].port = htons(vmsg->epAddr[k].port);
|
pVgroups->epAddr[k].port = htons(vmsg->epAddr[k].port);
|
||||||
pVgroups->epAddr[k].fqdn = strndup(vmsg->epAddr[k].fqdn, tListLen(vmsg->epAddr[k].fqdn));
|
pVgroups->epAddr[k].fqdn = strndup(vmsg->epAddr[k].fqdn, tListLen(vmsg->epAddr[k].fqdn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue