[td-225]fix bug found by regression test.
This commit is contained in:
parent
6e015f2cf6
commit
cbbb059385
|
@ -7237,7 +7237,7 @@ void tscPrintSelNodeList(SSqlObj* pSql, int32_t subClauseIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpLen =
|
tmpLen =
|
||||||
sprintf(tmpBuf, "%s(uid:%" PRId64 ", %d)", name, pExpr->base.uid, pExpr->base.colInfo.colId);
|
sprintf(tmpBuf, "%s(uid:%" PRIu64 ", %d)", name, pExpr->base.uid, pExpr->base.colInfo.colId);
|
||||||
|
|
||||||
if (tmpLen + offset >= totalBufSize - 1) break;
|
if (tmpLen + offset >= totalBufSize - 1) break;
|
||||||
|
|
||||||
|
@ -8135,9 +8135,6 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
tscDebug("0x%"PRIx64" retrieve table meta %s from local buf", pSql->self, name);
|
tscDebug("0x%"PRIx64" retrieve table meta %s from local buf", pSql->self, name);
|
||||||
|
|
||||||
// avoid mem leak, may should update pTableMeta
|
// avoid mem leak, may should update pTableMeta
|
||||||
const char* pTableName = tNameGetTableName(pname);
|
|
||||||
size_t nameLen = strlen(pTableName);
|
|
||||||
|
|
||||||
void* pVgroupIdList = NULL;
|
void* pVgroupIdList = NULL;
|
||||||
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
code = tscCreateTableMetaFromSTableMeta(pTableMeta, name, pSql->pBuf);
|
code = tscCreateTableMetaFromSTableMeta(pTableMeta, name, pSql->pBuf);
|
||||||
|
@ -8150,11 +8147,12 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
} else if (pTableMeta->tableType == TSDB_SUPER_TABLE) {
|
} else if (pTableMeta->tableType == TSDB_SUPER_TABLE) {
|
||||||
// the vgroup list of super table is not kept in local buffer, so here need retrieve it from the mnode each time
|
// the vgroup list of super table is not kept in local buffer, so here need retrieve it from the mnode each time
|
||||||
void* pv = taosCacheAcquireByKey(tscVgroupListBuf, pTableName, nameLen);
|
tscDebug("0x%"PRIx64" try to acquire cached super table %s vgroup id list", pSql->self, name);
|
||||||
|
void* pv = taosCacheAcquireByKey(tscVgroupListBuf, name, len);
|
||||||
if (pv == NULL) {
|
if (pv == NULL) {
|
||||||
char* t = strdup(name);
|
char* t = strdup(name);
|
||||||
taosArrayPush(pVgroupList, &t);
|
taosArrayPush(pVgroupList, &t);
|
||||||
tscDebug("0x%"PRIx64" failed to retrieve stable %s vgroup id list in cache, try fetch from mnode", pSql->self, pTableName);
|
tscDebug("0x%"PRIx64" failed to retrieve stable %s vgroup id list in cache, try fetch from mnode", pSql->self, name);
|
||||||
} else {
|
} else {
|
||||||
tFilePage* pdata = (tFilePage*) pv;
|
tFilePage* pdata = (tFilePage*) pv;
|
||||||
pVgroupIdList = taosArrayInit((size_t) pdata->num, sizeof(int32_t));
|
pVgroupIdList = taosArrayInit((size_t) pdata->num, sizeof(int32_t));
|
||||||
|
@ -8167,10 +8165,10 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashGet(pCmd->pTableMetaMap, pTableName, nameLen) == NULL) {
|
if (taosHashGet(pCmd->pTableMetaMap, name, len) == NULL) {
|
||||||
STableMeta* pMeta = tscTableMetaDup(pTableMeta);
|
STableMeta* pMeta = tscTableMetaDup(pTableMeta);
|
||||||
STableMetaVgroupInfo tvi = { .pTableMeta = pMeta, .vgroupIdList = pVgroupIdList};
|
STableMetaVgroupInfo tvi = { .pTableMeta = pMeta, .vgroupIdList = pVgroupIdList};
|
||||||
taosHashPut(pCmd->pTableMetaMap, pTableName, nameLen, &tvi, sizeof(STableMetaVgroupInfo));
|
taosHashPut(pCmd->pTableMetaMap, name, len, &tvi, sizeof(STableMetaVgroupInfo));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Add to the retrieve table meta array list.
|
// Add to the retrieve table meta array list.
|
||||||
|
@ -8290,8 +8288,9 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod
|
||||||
strncpy(pTableMetaInfo->aliasName, tNameGetTableName(&pTableMetaInfo->name), tListLen(pTableMetaInfo->aliasName));
|
strncpy(pTableMetaInfo->aliasName, tNameGetTableName(&pTableMetaInfo->name), tListLen(pTableMetaInfo->aliasName));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* name = tNameGetTableName(&pTableMetaInfo->name);
|
char fname[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
STableMetaVgroupInfo* p = taosHashGet(pCmd->pTableMetaMap, name, strlen(name));
|
tNameExtractFullName(&pTableMetaInfo->name, fname);
|
||||||
|
STableMetaVgroupInfo* p = taosHashGet(pCmd->pTableMetaMap, fname, strnlen(fname, TSDB_TABLE_FNAME_LEN));
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = tscTableMetaDup(p->pTableMeta);
|
pTableMetaInfo->pTableMeta = tscTableMetaDup(p->pTableMeta);
|
||||||
assert(pTableMetaInfo->pTableMeta != NULL);
|
assert(pTableMetaInfo->pTableMeta != NULL);
|
||||||
|
|
|
@ -391,9 +391,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAGS_VAL) &&
|
if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAGS_VAL) &&
|
||||||
(rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID ||
|
(rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID || // change the retry procedure
|
||||||
rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID ||
|
/*(*/rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID ||
|
||||||
rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL ||
|
rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || // change the retry procedure
|
||||||
rpcMsg->code == TSDB_CODE_APP_NOT_READY)) {
|
rpcMsg->code == TSDB_CODE_APP_NOT_READY)) {
|
||||||
|
|
||||||
pSql->retry++;
|
pSql->retry++;
|
||||||
|
@ -404,7 +404,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
tscError("0x%"PRIx64" max retry %d reached, give up", pSql->self, pSql->maxRetry);
|
tscError("0x%"PRIx64" max retry %d reached, give up", pSql->self, pSql->maxRetry);
|
||||||
} else {
|
} else {
|
||||||
// wait for a little bit moment and then retry
|
// wait for a little bit moment and then retry
|
||||||
// todo do not sleep in rpc callback thread, add this process into queueu to process
|
// todo do not sleep in rpc callback thread, add this process into queue to process
|
||||||
if (rpcMsg->code == TSDB_CODE_APP_NOT_READY || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
|
if (rpcMsg->code == TSDB_CODE_APP_NOT_READY || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
|
||||||
int32_t duration = getWaitingTimeInterval(pSql->retry);
|
int32_t duration = getWaitingTimeInterval(pSql->retry);
|
||||||
taosMsleep(duration);
|
taosMsleep(duration);
|
||||||
|
@ -2214,15 +2214,10 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SName sn = {0};
|
|
||||||
tNameFromString(&sn, pMetaMsg->tableFname, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
|
||||||
|
|
||||||
if (pMultiMeta->metaClone == 1 || pTableMeta->tableType == TSDB_SUPER_TABLE) {
|
if (pMultiMeta->metaClone == 1 || pTableMeta->tableType == TSDB_SUPER_TABLE) {
|
||||||
STableMetaVgroupInfo p = {.pTableMeta = pTableMeta,};
|
STableMetaVgroupInfo p = {.pTableMeta = pTableMeta,};
|
||||||
|
size_t keyLen = strnlen(pMetaMsg->tableFname, TSDB_TABLE_FNAME_LEN);
|
||||||
const char* tableName = tNameGetTableName(&sn);
|
taosHashPut(pParentCmd->pTableMetaMap, pMetaMsg->tableFname, keyLen, &p, sizeof(STableMetaVgroupInfo));
|
||||||
size_t keyLen = strlen(tableName);
|
|
||||||
taosHashPut(pParentCmd->pTableMetaMap, tableName, keyLen, &p, sizeof(STableMetaVgroupInfo));
|
|
||||||
} else {
|
} else {
|
||||||
freeMeta = true;
|
freeMeta = true;
|
||||||
}
|
}
|
||||||
|
@ -2251,10 +2246,13 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < pMultiMeta->numOfVgroup; ++i) {
|
for(int32_t i = 0; i < pMultiMeta->numOfVgroup; ++i) {
|
||||||
char* name = pMsg;
|
char fname[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
pMsg += TSDB_TABLE_NAME_LEN;
|
tstrncpy(fname, pMsg, TSDB_TABLE_FNAME_LEN);
|
||||||
|
size_t len = strnlen(fname, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
STableMetaVgroupInfo* p = taosHashGet(pParentCmd->pTableMetaMap, name, strnlen(name, TSDB_TABLE_NAME_LEN));
|
pMsg += TSDB_TABLE_FNAME_LEN;
|
||||||
|
|
||||||
|
STableMetaVgroupInfo* p = taosHashGet(pParentCmd->pTableMetaMap, fname, len);
|
||||||
assert(p != NULL);
|
assert(p != NULL);
|
||||||
|
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
|
@ -2262,9 +2260,7 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
taosArrayDestroy(p->vgroupIdList);
|
taosArrayDestroy(p->vgroupIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
char tableName[TSDB_TABLE_FNAME_LEN] = {0};
|
p->vgroupIdList = createVgroupIdListFromMsg(pMsg, pSet, fname, &size, pSql->self);
|
||||||
tstrncpy(tableName, name, TSDB_TABLE_NAME_LEN);
|
|
||||||
p->vgroupIdList = createVgroupIdListFromMsg(pMsg, pSet, tableName, &size, pSql->self);
|
|
||||||
|
|
||||||
int32_t numOfVgId = (int32_t) taosArrayGetSize(p->vgroupIdList);
|
int32_t numOfVgId = (int32_t) taosArrayGetSize(p->vgroupIdList);
|
||||||
int32_t s = sizeof(tFilePage) + numOfVgId * sizeof(int32_t);
|
int32_t s = sizeof(tFilePage) + numOfVgId * sizeof(int32_t);
|
||||||
|
@ -2273,11 +2269,10 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
idList->num = numOfVgId;
|
idList->num = numOfVgId;
|
||||||
memcpy(idList->data, TARRAY_GET_START(p->vgroupIdList), numOfVgId * sizeof(int32_t));
|
memcpy(idList->data, TARRAY_GET_START(p->vgroupIdList), numOfVgId * sizeof(int32_t));
|
||||||
|
|
||||||
void* idListInst = taosCachePut(tscVgroupListBuf, tableName, strlen(tableName), idList, s, 5000);
|
void* idListInst = taosCachePut(tscVgroupListBuf, fname, len, idList, s, 5000);
|
||||||
taosCacheRelease(tscVgroupListBuf, (void*) &idListInst, false);
|
taosCacheRelease(tscVgroupListBuf, (void*) &idListInst, false);
|
||||||
|
|
||||||
tfree(idList);
|
tfree(idList);
|
||||||
|
|
||||||
pMsg += size;
|
pMsg += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2918,7 +2913,7 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
|
||||||
|
|
||||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
if (pTableMeta) {
|
if (pTableMeta) {
|
||||||
tscDebug("0x%"PRIx64" update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64, pSql->self, name,
|
tscDebug("0x%"PRIx64" update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRIu64, pSql->self, name,
|
||||||
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid);
|
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,10 +88,7 @@ enum {
|
||||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_STABLE, "show-create-stable")
|
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_STABLE, "show-create-stable")
|
||||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_DATABASE, "show-create-database")
|
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_DATABASE, "show-create-database")
|
||||||
|
|
||||||
/*
|
// build empty result instead of accessing dnode to fetch result reset the client cache
|
||||||
* build empty result instead of accessing dnode to fetch result
|
|
||||||
* reset the client cache
|
|
||||||
*/
|
|
||||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RETRIEVE_EMPTY_RESULT, "retrieve-empty-result" )
|
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RETRIEVE_EMPTY_RESULT, "retrieve-empty-result" )
|
||||||
|
|
||||||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RESET_CACHE, "reset-cache" )
|
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RESET_CACHE, "reset-cache" )
|
||||||
|
|
|
@ -1812,12 +1812,8 @@ static int32_t getVgroupInfoLength(SSTableVgroupMsg* pInfo, int32_t numOfTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* serializeVgroupInfo(SSTableObj *pTable, char* name, char* msg, SMnodeMsg* pMsgBody, void* handle) {
|
static char* serializeVgroupInfo(SSTableObj *pTable, char* name, char* msg, SMnodeMsg* pMsgBody, void* handle) {
|
||||||
SName sn = {0};
|
strncpy(msg, name, TSDB_TABLE_FNAME_LEN);
|
||||||
tNameFromString(&sn, name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
msg += TSDB_TABLE_FNAME_LEN;
|
||||||
const char* tableName = tNameGetTableName(&sn);
|
|
||||||
|
|
||||||
strncpy(msg, tableName, TSDB_TABLE_NAME_LEN);
|
|
||||||
msg += TSDB_TABLE_NAME_LEN;
|
|
||||||
|
|
||||||
if (pTable->vgHash == NULL) {
|
if (pTable->vgHash == NULL) {
|
||||||
mDebug("msg:%p, app:%p stable:%s, no vgroup exist while get stable vgroup info", pMsgBody, handle, name);
|
mDebug("msg:%p, app:%p stable:%s, no vgroup exist while get stable vgroup info", pMsgBody, handle, name);
|
||||||
|
|
Loading…
Reference in New Issue