提交 83797800 编写于 作者: S shenglian zhou

[TD-11389]<fix>(query):pass sverion/tversion from vnode to client so that...

[TD-11389]<fix>(query):pass sverion/tversion from vnode to client so that client can clear meta when its meta is older
上级 a2d3c27a
......@@ -307,6 +307,8 @@ typedef struct {
int32_t row;
int16_t numOfCols;
int16_t precision;
int32_t sVersion;
int32_t tVersion;
bool completed;
int32_t code;
char * data;
......
......@@ -2755,6 +2755,8 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
pRes->numOfRows = htonl(pRetrieve->numOfRows);
pRes->precision = htons(pRetrieve->precision);
pRes->sVersion = htonl(pRetrieve->sVersion);
pRes->tVersion = htonl(pRetrieve->tVersion);
pRes->offset = htobe64(pRetrieve->offset);
pRes->useconds = htobe64(pRetrieve->useconds);
pRes->completed = (pRetrieve->completed == 1);
......
......@@ -1701,6 +1701,21 @@ void tscFreeSqlObj(SSqlObj* pSql) {
tscFreeMetaSqlObj(&pSql->svgroupRid);
SSqlCmd* pCmd = &pSql->cmd;
bool clearCachedMeta = false;
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
if (pQueryInfo != NULL) {
STableMeta* pTableMeta = NULL;
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
if (pTableMetaInfo != NULL) {
pTableMeta = pTableMetaInfo->pTableMeta;
}
if (pTableMeta != NULL) {
if (pTableMeta->sversion < pSql->res.sVersion || pTableMeta->tversion < pSql->res.tVersion) {
clearCachedMeta = true;
}
}
}
int32_t cmd = pCmd->command;
if (cmd < TSDB_SQL_INSERT || cmd == TSDB_SQL_RETRIEVE_GLOBALMERGE || cmd == TSDB_SQL_RETRIEVE_EMPTY_RESULT ||
cmd == TSDB_SQL_TABLE_JOIN_RETRIEVE) {
......@@ -1719,7 +1734,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
pSql->self = 0;
tscFreeSqlResult(pSql);
tscResetSqlCmd(pCmd, false, pSql->self);
tscResetSqlCmd(pCmd, clearCachedMeta, pSql->self);
tfree(pCmd->payload);
pCmd->allocSize = 0;
......
......@@ -545,6 +545,8 @@ typedef struct SRetrieveTableRsp {
int32_t numOfRows;
int8_t completed; // all results are returned to client
int16_t precision;
int32_t sVersion;
int32_t tVersion;
int64_t offset; // updated offset value for multi-vnode projection query
int64_t useconds;
int8_t compressed;
......
......@@ -228,6 +228,8 @@ typedef struct {
uint32_t numOfTables;
SArray *pGroupList;
SHashObj *map; // speedup acquire the tableQueryInfo by table uid
int32_t sVersion;
int32_t tVersion;
} STableGroupInfo;
#define TSDB_BLOCK_DIST_STEP_ROWS 16
......
......@@ -407,6 +407,8 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
}
(*pRsp)->precision = htons(pQueryAttr->precision);
(*pRsp)->sVersion = htonl(pQueryAttr->tableGroupInfo.sVersion);
(*pRsp)->tVersion = htonl(pQueryAttr->tableGroupInfo.tVersion);
(*pRsp)->compressed = (int8_t)((tsCompressColData != -1) && checkNeedToCompressQueryCol(pQInfo));
if (GET_NUM_OF_RESULTS(&(pQInfo->runtimeEnv)) > 0 && pQInfo->code == TSDB_CODE_SUCCESS) {
......
......@@ -3715,7 +3715,8 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
pGroupInfo->numOfTables = (uint32_t) taosArrayGetSize(res);
pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey);
pGroupInfo->sVersion = tsdbGetTableSchema(pTable)->version;
pGroupInfo->tVersion = pTagSchema->version;
tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu", tsdb,
pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList));
......@@ -3802,6 +3803,9 @@ int32_t tsdbGetOneTableGroup(STsdbRepo* tsdb, uint64_t uid, TSKEY startKey, STab
taosArrayPush(group, &info);
taosArrayPush(pGroupInfo->pGroupList, &group);
pGroupInfo->sVersion = tsdbGetTableSchema(pTable)->version;
pGroupInfo->tVersion = tsdbGetTableTagSchema(pTable)->version;
return TSDB_CODE_SUCCESS;
_error:
......@@ -3818,6 +3822,8 @@ int32_t tsdbGetTableGroupFromIdList(STsdbRepo* tsdb, SArray* pTableIdList, STabl
pGroupInfo->pGroupList = taosArrayInit(1, POINTER_BYTES);
SArray* group = taosArrayInit(1, sizeof(STableKeyInfo));
int32_t sVersion = -1;
int32_t tVersion = -1;
for(int32_t i = 0; i < size; ++i) {
STableIdInfo *id = taosArrayGet(pTableIdList, i);
......@@ -3839,6 +3845,18 @@ int32_t tsdbGetTableGroupFromIdList(STsdbRepo* tsdb, SArray* pTableIdList, STabl
STableKeyInfo info = {.pTable = pTable, .lastKey = id->key};
taosArrayPush(group, &info);
if (sVersion == -1) {
sVersion = tsdbGetTableSchema(pTable)->version;
} else {
assert (sVersion == tsdbGetTableSchema(pTable)->version);
}
if (tVersion == -1) {
tVersion = tsdbGetTableTagSchema(pTable)->version;
} else {
assert (tVersion == tsdbGetTableTagSchema(pTable)->version);
}
}
if (tsdbUnlockRepoMeta(tsdb) < 0) {
......@@ -3853,6 +3871,9 @@ int32_t tsdbGetTableGroupFromIdList(STsdbRepo* tsdb, SArray* pTableIdList, STabl
taosArrayDestroy(&group);
}
pGroupInfo->sVersion = sVersion;
pGroupInfo->tVersion = tVersion;
return TSDB_CODE_SUCCESS;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册