Merge pull request #2521 from taosdata/develop
merge develop into coverity_scan
This commit is contained in:
commit
25bbe208b9
10
.travis.yml
10
.travis.yml
|
@ -36,6 +36,8 @@ matrix:
|
||||||
- psmisc
|
- psmisc
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- export TZ=Asia/Harbin
|
||||||
|
- date
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
- mkdir debug
|
- mkdir debug
|
||||||
- cd debug
|
- cd debug
|
||||||
|
@ -150,6 +152,8 @@ matrix:
|
||||||
- DESC="trusty/gcc-4.8 build"
|
- DESC="trusty/gcc-4.8 build"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- export TZ=Asia/Harbin
|
||||||
|
- date
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
- mkdir debug
|
- mkdir debug
|
||||||
- cd debug
|
- cd debug
|
||||||
|
@ -173,6 +177,8 @@ matrix:
|
||||||
- cmake
|
- cmake
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- export TZ=Asia/Harbin
|
||||||
|
- date
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
- mkdir debug
|
- mkdir debug
|
||||||
- cd debug
|
- cd debug
|
||||||
|
@ -197,6 +203,8 @@ matrix:
|
||||||
- cmake
|
- cmake
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- export TZ=Asia/Harbin
|
||||||
|
- date
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
- mkdir debug
|
- mkdir debug
|
||||||
- cd debug
|
- cd debug
|
||||||
|
@ -225,6 +233,8 @@ matrix:
|
||||||
- DESC="trusty/gcc-4.8 build"
|
- DESC="trusty/gcc-4.8 build"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- export TZ=Asia/Harbin
|
||||||
|
- date
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
- mkdir debug
|
- mkdir debug
|
||||||
- cd debug
|
- cd debug
|
||||||
|
|
|
@ -84,7 +84,7 @@ typedef struct SRetrieveSupport {
|
||||||
SColumnModel * pFinalColModel; // colModel for final result
|
SColumnModel * pFinalColModel; // colModel for final result
|
||||||
SSubqueryState * pState;
|
SSubqueryState * pState;
|
||||||
int32_t subqueryIndex; // index of current vnode in vnode list
|
int32_t subqueryIndex; // index of current vnode in vnode list
|
||||||
SSqlObj * pParentSqlObj;
|
SSqlObj * pParentSql;
|
||||||
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
|
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
|
||||||
uint32_t numOfRetry; // record the number of retry times
|
uint32_t numOfRetry; // record the number of retry times
|
||||||
pthread_mutex_t queryMutex;
|
pthread_mutex_t queryMutex;
|
||||||
|
|
|
@ -36,6 +36,8 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql);
|
||||||
|
|
||||||
int32_t tscHandleMultivnodeInsert(SSqlObj *pSql);
|
int32_t tscHandleMultivnodeInsert(SSqlObj *pSql);
|
||||||
|
|
||||||
|
int32_t tscHandleInsertRetry(SSqlObj* pSql);
|
||||||
|
|
||||||
void tscBuildResFromSubqueries(SSqlObj *pSql);
|
void tscBuildResFromSubqueries(SSqlObj *pSql);
|
||||||
void **doSetResultRowData(SSqlObj *pSql, bool finalResult);
|
void **doSetResultRowData(SSqlObj *pSql, bool finalResult);
|
||||||
|
|
||||||
|
|
|
@ -213,8 +213,7 @@ typedef struct SQueryInfo {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int command;
|
int command;
|
||||||
uint8_t msgType;
|
uint8_t msgType;
|
||||||
bool autoCreated; // if the table is missing, on-the-fly create it. during getmeterMeta
|
bool autoCreated; // create table if it is not existed during retrieve table meta in mnode
|
||||||
int8_t dataSourceType; // load data from file or not
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
int32_t count;
|
int32_t count;
|
||||||
|
@ -223,17 +222,22 @@ typedef struct {
|
||||||
|
|
||||||
int32_t insertType;
|
int32_t insertType;
|
||||||
int32_t clauseIndex; // index of multiple subclause query
|
int32_t clauseIndex; // index of multiple subclause query
|
||||||
|
|
||||||
|
char * curSql; // current sql, resume position of sql after parsing paused
|
||||||
int8_t parseFinished;
|
int8_t parseFinished;
|
||||||
|
|
||||||
short numOfCols;
|
short numOfCols;
|
||||||
uint32_t allocSize;
|
uint32_t allocSize;
|
||||||
char * payload;
|
char * payload;
|
||||||
int32_t payloadLen;
|
int32_t payloadLen;
|
||||||
SQueryInfo **pQueryInfo;
|
SQueryInfo **pQueryInfo;
|
||||||
int32_t numOfClause;
|
int32_t numOfClause;
|
||||||
char * curSql; // current sql, resume position of sql after parsing paused
|
|
||||||
void * pTableList; // referred table involved in sql
|
|
||||||
int32_t batchSize; // for parameter ('?') binding and batch processing
|
int32_t batchSize; // for parameter ('?') binding and batch processing
|
||||||
int32_t numOfParams;
|
int32_t numOfParams;
|
||||||
|
|
||||||
|
int8_t dataSourceType; // load data from file or not
|
||||||
|
int8_t submitSchema; // submit block is built with table schema
|
||||||
|
SHashObj *pTableList; // referred table involved in sql
|
||||||
SArray *pDataBlocks; // SArray<STableDataBlocks*> submit data blocks after parsing sql
|
SArray *pDataBlocks; // SArray<STableDataBlocks*> submit data blocks after parsing sql
|
||||||
} SSqlCmd;
|
} SSqlCmd;
|
||||||
|
|
||||||
|
|
|
@ -431,6 +431,8 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tscDebug("%p get tableMeta successfully", pSql);
|
||||||
|
|
||||||
if (pSql->pStream == NULL) {
|
if (pSql->pStream == NULL) {
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
|
@ -446,20 +448,20 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
assert(code == TSDB_CODE_SUCCESS);
|
assert(code == TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert((tscGetNumOfTags(pTableMetaInfo->pTableMeta) != 0) && pSql->param != NULL);
|
||||||
assert((tscGetNumOfTags(pTableMetaInfo->pTableMeta) != 0) && pTableMetaInfo->vgroupIndex >= 0 && pSql->param != NULL);
|
|
||||||
|
|
||||||
SRetrieveSupport *trs = (SRetrieveSupport *)pSql->param;
|
SRetrieveSupport *trs = (SRetrieveSupport *)pSql->param;
|
||||||
SSqlObj * pParObj = trs->pParentSqlObj;
|
SSqlObj * pParObj = trs->pParentSql;
|
||||||
|
|
||||||
assert(pParObj->signature == pParObj && trs->subqueryIndex == pTableMetaInfo->vgroupIndex &&
|
|
||||||
tscGetNumOfTags(pTableMetaInfo->pTableMeta) != 0);
|
|
||||||
|
|
||||||
// NOTE: the vgroupInfo for the queried super table must be existed here.
|
// NOTE: the vgroupInfo for the queried super table must be existed here.
|
||||||
assert(pTableMetaInfo->vgroupList != NULL);
|
assert(pParObj->signature == pParObj && trs->subqueryIndex == pTableMetaInfo->vgroupIndex &&
|
||||||
|
pTableMetaInfo->vgroupIndex >= 0 && pTableMetaInfo->vgroupList != NULL);
|
||||||
|
|
||||||
if ((code = tscProcessSql(pSql)) == TSDB_CODE_SUCCESS) {
|
if ((code = tscProcessSql(pSql)) == TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goto _error;
|
||||||
} else { // continue to process normal async query
|
} else { // continue to process normal async query
|
||||||
if (pCmd->parseFinished) {
|
if (pCmd->parseFinished) {
|
||||||
tscDebug("%p update table meta in local cache, continue to process sql and send corresponding query", pSql);
|
tscDebug("%p update table meta in local cache, continue to process sql and send corresponding query", pSql);
|
||||||
|
@ -472,18 +474,41 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
assert(code == TSDB_CODE_SUCCESS);
|
assert(code == TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if failed to process sql, go to error handler
|
// in case of insert, redo parsing the sql string and build new submit data block for two reasons:
|
||||||
|
// 1. the table Id(tid & uid) may have been update, the submit block needs to be updated
|
||||||
|
// 2. vnode may need the schema information along with submit block to update its local table schema.
|
||||||
|
if (pCmd->command == TSDB_SQL_INSERT) {
|
||||||
|
tscDebug("%p redo parse sql string to build submit block", pSql);
|
||||||
|
|
||||||
|
pCmd->parseFinished = false;
|
||||||
|
if ((code = tsParseSql(pSql, true)) == TSDB_CODE_SUCCESS) {
|
||||||
|
/*
|
||||||
|
* Discard previous built submit blocks, and then parse the sql string again and build up all submit blocks,
|
||||||
|
* and send the required submit block according to index value in supporter to server.
|
||||||
|
*/
|
||||||
|
pSql->fp = pSql->fetchFp; // restore the fp
|
||||||
|
if ((code = tscHandleInsertRetry(pSql)) == TSDB_CODE_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {// in case of other query type, continue
|
||||||
if ((code = tscProcessSql(pSql)) == TSDB_CODE_SUCCESS) {
|
if ((code = tscProcessSql(pSql)) == TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// // todo update the submit message according to the new table meta
|
}
|
||||||
// // 1. table uid, 2. ip address
|
|
||||||
// code = tscSendMsgToServer(pSql);
|
goto _error;
|
||||||
// if (code == TSDB_CODE_SUCCESS) return;
|
|
||||||
} else {
|
} else {
|
||||||
tscDebug("%p continue parse sql after get table meta", pSql);
|
tscDebug("%p continue parse sql after get table meta", pSql);
|
||||||
|
|
||||||
code = tsParseSql(pSql, false);
|
code = tsParseSql(pSql, false);
|
||||||
|
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||||
|
return;
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STMT_INSERT)) {
|
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STMT_INSERT)) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
||||||
|
@ -492,45 +517,49 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
} else {
|
} else {
|
||||||
assert(code == TSDB_CODE_SUCCESS);
|
assert(code == TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pSql->fp)(pSql->param, pSql, code);
|
(*pSql->fp)(pSql->param, pSql, code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) return;
|
// proceed to invoke the tscDoQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // stream computing
|
} else { // stream computing
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
|
||||||
pRes->code = code;
|
|
||||||
|
|
||||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) return;
|
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
||||||
|
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||||
|
return;
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
if (code == TSDB_CODE_SUCCESS && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||||
code = tscGetSTableVgroupInfo(pSql, pCmd->clauseIndex);
|
code = tscGetSTableVgroupInfo(pSql, pCmd->clauseIndex);
|
||||||
pRes->code = code;
|
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||||
|
|
||||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
pSql->res.code = code;
|
|
||||||
tscQueueAsyncRes(pSql);
|
|
||||||
return;
|
return;
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSql->pStream) {
|
|
||||||
tscDebug("%p stream:%p meta is updated, start new query, command:%d", pSql, pSql->pStream, pSql->cmd.command);
|
tscDebug("%p stream:%p meta is updated, start new query, command:%d", pSql, pSql->pStream, pSql->cmd.command);
|
||||||
if (!pSql->cmd.parseFinished) {
|
if (!pSql->cmd.parseFinished) {
|
||||||
tsParseSql(pSql, false);
|
tsParseSql(pSql, false);
|
||||||
sem_post(&pSql->rspSem);
|
sem_post(&pSql->rspSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
tscDebug("%p get tableMeta successfully", pSql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDoQuery(pSql);
|
tscDoQuery(pSql);
|
||||||
|
return;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
pSql->res.code = code;
|
||||||
|
tscQueueAsyncRes(pSql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,7 +315,11 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
pReducer->finalRowSize = tscGetResRowLength(pQueryInfo->exprList);
|
pReducer->finalRowSize = tscGetResRowLength(pQueryInfo->exprList);
|
||||||
pReducer->resColModel = finalmodel;
|
pReducer->resColModel = finalmodel;
|
||||||
pReducer->resColModel->capacity = pReducer->nResultBufSize / pReducer->finalRowSize;
|
pReducer->resColModel->capacity = pReducer->nResultBufSize;
|
||||||
|
assert(pReducer->finalRowSize > 0);
|
||||||
|
if (pReducer->finalRowSize > 0) {
|
||||||
|
pReducer->resColModel->capacity /= pReducer->finalRowSize;
|
||||||
|
}
|
||||||
assert(pReducer->finalRowSize <= pReducer->rowSize);
|
assert(pReducer->finalRowSize <= pReducer->rowSize);
|
||||||
|
|
||||||
pReducer->pFinalRes = calloc(1, pReducer->rowSize * pReducer->resColModel->capacity);
|
pReducer->pFinalRes = calloc(1, pReducer->rowSize * pReducer->resColModel->capacity);
|
||||||
|
|
|
@ -802,7 +802,10 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaInfo *pSTableMeterMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX);
|
STableMetaInfo *pSTableMeterMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX);
|
||||||
tscSetTableFullName(pSTableMeterMetaInfo, &sToken, pSql);
|
code = tscSetTableFullName(pSTableMeterMetaInfo, &sToken, pSql);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
tstrncpy(pTag->name, pSTableMeterMetaInfo->name, sizeof(pTag->name));
|
tstrncpy(pTag->name, pSTableMeterMetaInfo->name, sizeof(pTag->name));
|
||||||
code = tscGetTableMeta(pSql, pSTableMeterMetaInfo);
|
code = tscGetTableMeta(pSql, pSTableMeterMetaInfo);
|
||||||
|
@ -1256,8 +1259,6 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
||||||
if ((code = tscMergeTableDataBlocks(pSql, pCmd->pDataBlocks)) != TSDB_CODE_SUCCESS) {
|
if ((code = tscMergeTableDataBlocks(pSql, pCmd->pDataBlocks)) != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -347,7 +347,6 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
|
||||||
int doProcessSql(SSqlObj *pSql) {
|
int doProcessSql(SSqlObj *pSql) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
if (pCmd->command == TSDB_SQL_SELECT ||
|
if (pCmd->command == TSDB_SQL_SELECT ||
|
||||||
pCmd->command == TSDB_SQL_FETCH ||
|
pCmd->command == TSDB_SQL_FETCH ||
|
||||||
|
@ -365,10 +364,13 @@ int doProcessSql(SSqlObj *pSql) {
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tscSendMsgToServer(pSql);
|
int32_t code = tscSendMsgToServer(pSql);
|
||||||
|
|
||||||
|
// NOTE: if code is TSDB_CODE_SUCCESS, pSql may have been released here already by other threads.
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pRes->code = code;
|
pRes->code = code;
|
||||||
tscQueueAsyncRes(pSql);
|
tscQueueAsyncRes(pSql);
|
||||||
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
typedef struct SInsertSupporter {
|
typedef struct SInsertSupporter {
|
||||||
SSubqueryState* pState;
|
SSubqueryState* pState;
|
||||||
SSqlObj* pSql;
|
SSqlObj* pSql;
|
||||||
|
int32_t index;
|
||||||
} SInsertSupporter;
|
} SInsertSupporter;
|
||||||
|
|
||||||
static void freeJoinSubqueryObj(SSqlObj* pSql);
|
static void freeJoinSubqueryObj(SSqlObj* pSql);
|
||||||
|
@ -936,8 +937,11 @@ static SJoinSupporter* tscUpdateSubqueryStatus(SSqlObj* pSql, int32_t numOfFetch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(pState != NULL);
|
||||||
|
if (pState != NULL) {
|
||||||
pState->numOfTotal = pSql->numOfSubs;
|
pState->numOfTotal = pSql->numOfSubs;
|
||||||
pState->numOfRemain = numOfFetch;
|
pState->numOfRemain = numOfFetch;
|
||||||
|
}
|
||||||
|
|
||||||
return pSupporter;
|
return pSupporter;
|
||||||
}
|
}
|
||||||
|
@ -1411,7 +1415,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
trs->subqueryIndex = i;
|
trs->subqueryIndex = i;
|
||||||
trs->pParentSqlObj = pSql;
|
trs->pParentSql = pSql;
|
||||||
trs->pFinalColModel = pModel;
|
trs->pFinalColModel = pModel;
|
||||||
|
|
||||||
pthread_mutexattr_t mutexattr;
|
pthread_mutexattr_t mutexattr;
|
||||||
|
@ -1496,7 +1500,7 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
|
||||||
tscError("sub:%p failed to flush data to disk, reason:%s", tres, tstrerror(code));
|
tscError("sub:%p failed to flush data to disk, reason:%s", tres, tstrerror(code));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SSqlObj* pParentSql = trsupport->pParentSqlObj;
|
SSqlObj* pParentSql = trsupport->pParentSql;
|
||||||
|
|
||||||
pParentSql->res.code = code;
|
pParentSql->res.code = code;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
@ -1505,8 +1509,45 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
|
||||||
tscHandleSubqueryError(trsupport, tres, pParentSql->res.code);
|
tscHandleSubqueryError(trsupport, tres, pParentSql->res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* current query failed, and the retry count is less than the available
|
||||||
|
* count, retry query clear previous retrieved data, then launch a new sub query
|
||||||
|
*/
|
||||||
|
static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, int32_t code) {
|
||||||
|
SSqlObj *pParentSql = trsupport->pParentSql;
|
||||||
|
int32_t subqueryIndex = trsupport->subqueryIndex;
|
||||||
|
|
||||||
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
|
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
||||||
|
|
||||||
|
tExtMemBufferClear(trsupport->pExtMemBuffer[subqueryIndex]);
|
||||||
|
|
||||||
|
// clear local saved number of results
|
||||||
|
trsupport->localBuffer->num = 0;
|
||||||
|
pthread_mutex_unlock(&trsupport->queryMutex);
|
||||||
|
|
||||||
|
tscTrace("%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSql, pSql,
|
||||||
|
tstrerror(code), subqueryIndex, trsupport->numOfRetry);
|
||||||
|
|
||||||
|
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSql, trsupport, pSql);
|
||||||
|
|
||||||
|
// todo add to async res or not??
|
||||||
|
if (pNew == NULL) {
|
||||||
|
tscError("%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d",
|
||||||
|
trsupport->pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex);
|
||||||
|
|
||||||
|
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
|
||||||
|
return pParentSql->res.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(pSql);
|
||||||
|
return tscProcessSql(pNew);
|
||||||
|
}
|
||||||
|
|
||||||
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
||||||
SSqlObj *pParentSql = trsupport->pParentSqlObj;
|
SSqlObj *pParentSql = trsupport->pParentSql;
|
||||||
int32_t subqueryIndex = trsupport->subqueryIndex;
|
int32_t subqueryIndex = trsupport->subqueryIndex;
|
||||||
|
|
||||||
assert(pSql != NULL);
|
assert(pSql != NULL);
|
||||||
|
@ -1532,31 +1573,9 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
subqueryIndex, pParentSql->res.code);
|
subqueryIndex, pParentSql->res.code);
|
||||||
} else {
|
} else {
|
||||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
||||||
/*
|
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
||||||
* current query failed, and the retry count is less than the available
|
|
||||||
* count, retry query clear previous retrieved data, then launch a new sub query
|
|
||||||
*/
|
|
||||||
tExtMemBufferClear(trsupport->pExtMemBuffer[subqueryIndex]);
|
|
||||||
|
|
||||||
// clear local saved number of results
|
|
||||||
trsupport->localBuffer->num = 0;
|
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
|
||||||
|
|
||||||
tscDebug("%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSqlObj, pSql,
|
|
||||||
tstrerror(numOfRows), subqueryIndex, trsupport->numOfRetry);
|
|
||||||
|
|
||||||
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSqlObj, trsupport, pSql);
|
|
||||||
if (pNew == NULL) {
|
|
||||||
tscError("%p sub:%p failed to create new subquery sqlObj due to out of memory, abort retry",
|
|
||||||
trsupport->pParentSqlObj, pSql);
|
|
||||||
|
|
||||||
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscProcessSql(pNew);
|
|
||||||
return;
|
|
||||||
} else { // reach the maximum retry count, abort
|
} else { // reach the maximum retry count, abort
|
||||||
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows);
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows);
|
||||||
tscError("%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s", pParentSql, pSql,
|
tscError("%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s", pParentSql, pSql,
|
||||||
|
@ -1597,7 +1616,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
|
|
||||||
static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* pSql) {
|
static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* pSql) {
|
||||||
int32_t idx = trsupport->subqueryIndex;
|
int32_t idx = trsupport->subqueryIndex;
|
||||||
SSqlObj * pPObj = trsupport->pParentSqlObj;
|
SSqlObj * pParentSql = trsupport->pParentSql;
|
||||||
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
||||||
|
|
||||||
SSubqueryState* pState = trsupport->pState;
|
SSubqueryState* pState = trsupport->pState;
|
||||||
|
@ -1607,7 +1626,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
|
|
||||||
// data in from current vnode is stored in cache and disk
|
// data in from current vnode is stored in cache and disk
|
||||||
uint32_t numOfRowsFromSubquery = trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->num;
|
uint32_t numOfRowsFromSubquery = trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->num;
|
||||||
tscDebug("%p sub:%p all data retrieved from ip:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pPObj, pSql,
|
tscDebug("%p sub:%p all data retrieved from ip:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pParentSql, pSql,
|
||||||
pTableMetaInfo->vgroupList->vgroups[0].ipAddr[0].fqdn, pTableMetaInfo->vgroupList->vgroups[0].vgId,
|
pTableMetaInfo->vgroupList->vgroups[0].ipAddr[0].fqdn, pTableMetaInfo->vgroupList->vgroups[0].vgId,
|
||||||
numOfRowsFromSubquery, idx);
|
numOfRowsFromSubquery, idx);
|
||||||
|
|
||||||
|
@ -1621,15 +1640,14 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
trsupport->localBuffer->num, colInfo);
|
trsupport->localBuffer->num, colInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tsTotalTmpDirGB != 0 && tsAvailTmpDirGB < tsMinimalTmpDirGB) {
|
if (tsTotalTmpDirGB != 0 && tsAvailTmpDirectorySpace < tsReservedTmpDirectorySpace) {
|
||||||
tscError("%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query", pPObj, pSql,
|
tscError("%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query", pParentSql, pSql,
|
||||||
tsAvailTmpDirGB, tsMinimalTmpDirGB);
|
tsAvailTmpDirectorySpace, tsReservedTmpDirectorySpace);
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, pSql, TSDB_CODE_TSC_NO_DISKSPACE);
|
return tscAbortFurtherRetryRetrieval(trsupport, pSql, TSDB_CODE_TSC_NO_DISKSPACE);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// each result for a vnode is ordered as an independant list,
|
// each result for a vnode is ordered as an independant list,
|
||||||
// then used as an input of loser tree for disk-based merge routine
|
// then used as an input of loser tree for disk-based merge
|
||||||
int32_t code = tscFlushTmpBuffer(trsupport->pExtMemBuffer[idx], pDesc, trsupport->localBuffer, pQueryInfo->groupbyExpr.orderType);
|
int32_t code = tscFlushTmpBuffer(trsupport->pExtMemBuffer[idx], pDesc, trsupport->localBuffer, pQueryInfo->groupbyExpr.orderType);
|
||||||
if (code != 0) { // set no disk space error info, and abort retry
|
if (code != 0) { // set no disk space error info, and abort retry
|
||||||
return tscAbortFurtherRetryRetrieval(trsupport, pSql, code);
|
return tscAbortFurtherRetryRetrieval(trsupport, pSql, code);
|
||||||
|
@ -1637,7 +1655,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
|
|
||||||
int32_t remain = -1;
|
int32_t remain = -1;
|
||||||
if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) {
|
if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) {
|
||||||
tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pPObj, pSql, trsupport->subqueryIndex,
|
tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex,
|
||||||
pState->numOfTotal - remain);
|
pState->numOfTotal - remain);
|
||||||
|
|
||||||
return tscFreeSubSqlObj(trsupport, pSql);
|
return tscFreeSubSqlObj(trsupport, pSql);
|
||||||
|
@ -1646,29 +1664,29 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
// all sub-queries are returned, start to local merge process
|
// all sub-queries are returned, start to local merge process
|
||||||
pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage;
|
pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage;
|
||||||
|
|
||||||
tscDebug("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pPObj,
|
tscDebug("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pParentSql,
|
||||||
pState->numOfTotal, pState->numOfRetrievedRows);
|
pState->numOfTotal, pState->numOfRetrievedRows);
|
||||||
|
|
||||||
SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pPObj->cmd, 0);
|
SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0);
|
||||||
tscClearInterpInfo(pPQueryInfo);
|
tscClearInterpInfo(pPQueryInfo);
|
||||||
|
|
||||||
tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfTotal, pDesc, trsupport->pFinalColModel, pPObj);
|
tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfTotal, pDesc, trsupport->pFinalColModel, pParentSql);
|
||||||
tscDebug("%p build loser tree completed", pPObj);
|
tscDebug("%p build loser tree completed", pParentSql);
|
||||||
|
|
||||||
pPObj->res.precision = pSql->res.precision;
|
pParentSql->res.precision = pSql->res.precision;
|
||||||
pPObj->res.numOfRows = 0;
|
pParentSql->res.numOfRows = 0;
|
||||||
pPObj->res.row = 0;
|
pParentSql->res.row = 0;
|
||||||
|
|
||||||
// only free once
|
// only free once
|
||||||
tfree(trsupport->pState);
|
tfree(trsupport->pState);
|
||||||
tscFreeSubSqlObj(trsupport, pSql);
|
tscFreeSubSqlObj(trsupport, pSql);
|
||||||
|
|
||||||
// set the command flag must be after the semaphore been correctly set.
|
// set the command flag must be after the semaphore been correctly set.
|
||||||
pPObj->cmd.command = TSDB_SQL_RETRIEVE_LOCALMERGE;
|
pParentSql->cmd.command = TSDB_SQL_RETRIEVE_LOCALMERGE;
|
||||||
if (pPObj->res.code == TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
||||||
(*pPObj->fp)(pPObj->param, pPObj, 0);
|
(*pParentSql->fp)(pParentSql->param, pParentSql, 0);
|
||||||
} else {
|
} else {
|
||||||
tscQueueAsyncRes(pPObj);
|
tscQueueAsyncRes(pParentSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1676,22 +1694,48 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
SRetrieveSupport *trsupport = (SRetrieveSupport *)param;
|
SRetrieveSupport *trsupport = (SRetrieveSupport *)param;
|
||||||
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
|
||||||
int32_t idx = trsupport->subqueryIndex;
|
int32_t idx = trsupport->subqueryIndex;
|
||||||
SSqlObj * pPObj = trsupport->pParentSqlObj;
|
SSqlObj * pParentSql = trsupport->pParentSql;
|
||||||
|
|
||||||
SSqlObj *pSql = (SSqlObj *)tres;
|
SSqlObj *pSql = (SSqlObj *)tres;
|
||||||
if (pSql == NULL) { // sql object has been released in error process, return immediately
|
if (pSql == NULL) { // sql object has been released in error process, return immediately
|
||||||
tscDebug("%p subquery has been released, idx:%d, abort", pPObj, idx);
|
tscDebug("%p subquery has been released, idx:%d, abort", pParentSql, idx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubqueryState* pState = trsupport->pState;
|
SSubqueryState* pState = trsupport->pState;
|
||||||
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pPObj->numOfSubs == pState->numOfTotal);
|
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal);
|
||||||
|
|
||||||
// query process and cancel query process may execute at the same time
|
// query process and cancel query process may execute at the same time
|
||||||
pthread_mutex_lock(&trsupport->queryMutex);
|
pthread_mutex_lock(&trsupport->queryMutex);
|
||||||
|
|
||||||
if (numOfRows < 0 || pPObj->res.code != TSDB_CODE_SUCCESS) {
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
return tscHandleSubqueryError(trsupport, pSql, numOfRows);
|
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
||||||
|
|
||||||
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
tscTrace("%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
|
||||||
|
pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(numOfRows), tstrerror(pParentSql->res.code));
|
||||||
|
|
||||||
|
tscHandleSubqueryError(param, tres, numOfRows);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
|
||||||
|
assert(numOfRows == taos_errno(pSql));
|
||||||
|
|
||||||
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||||
|
tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(numOfRows), trsupport->numOfRetry);
|
||||||
|
|
||||||
|
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(numOfRows));
|
||||||
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows); // set global code and abort
|
||||||
|
}
|
||||||
|
|
||||||
|
tscHandleSubqueryError(param, tres, numOfRows);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlRes * pRes = &pSql->res;
|
SSqlRes * pRes = &pSql->res;
|
||||||
|
@ -1701,14 +1745,13 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
assert(pRes->numOfRows == numOfRows);
|
assert(pRes->numOfRows == numOfRows);
|
||||||
int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows);
|
int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows);
|
||||||
|
|
||||||
tscDebug("%p sub:%p retrieve numOfRows:%" PRId64 " totalNumOfRows:%" PRIu64 " from ip:%s, orderOfSub:%d", pPObj, pSql,
|
tscDebug("%p sub:%p retrieve numOfRows:%" PRId64 " totalNumOfRows:%" PRIu64 " from ip:%s, orderOfSub:%d", pParentSql, pSql,
|
||||||
pRes->numOfRows, pState->numOfRetrievedRows, pSql->ipList.fqdn[pSql->ipList.inUse], idx);
|
pRes->numOfRows, pState->numOfRetrievedRows, pSql->ipList.fqdn[pSql->ipList.inUse], idx);
|
||||||
|
|
||||||
if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0)) {
|
if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0)) {
|
||||||
tscError("%p sub:%p num of OrderedRes is too many, max allowed:%" PRId32 " , current:%" PRId64,
|
tscError("%p sub:%p num of OrderedRes is too many, max allowed:%" PRId32 " , current:%" PRId64,
|
||||||
pPObj, pSql, tsMaxNumOfOrderedResults, num);
|
pParentSql, pSql, tsMaxNumOfOrderedResults, num);
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_SORTED_RES_TOO_MANY);
|
return tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_SORTED_RES_TOO_MANY);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG_VIEW
|
#ifdef _DEBUG_VIEW
|
||||||
|
@ -1719,11 +1762,11 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
tColModelDisplayEx(pDesc->pColumnModel, pRes->data, pRes->numOfRows, pRes->numOfRows, colInfo);
|
tColModelDisplayEx(pDesc->pColumnModel, pRes->data, pRes->numOfRows, pRes->numOfRows, colInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tsTotalTmpDirGB != 0 && tsAvailTmpDirGB < tsMinimalTmpDirGB) {
|
// no disk space for tmp directory
|
||||||
tscError("%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query", pPObj, pSql,
|
if (tsTotalTmpDirGB != 0 && tsAvailTmpDirectorySpace < tsReservedTmpDirectorySpace) {
|
||||||
tsAvailTmpDirGB, tsMinimalTmpDirGB);
|
tscError("%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query", pParentSql, pSql,
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
tsAvailTmpDirectorySpace, tsReservedTmpDirectorySpace);
|
||||||
return;
|
return tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = saveToBuffer(trsupport->pExtMemBuffer[idx], pDesc, trsupport->localBuffer, pRes->data,
|
int32_t ret = saveToBuffer(trsupport->pExtMemBuffer[idx], pDesc, trsupport->localBuffer, pRes->data,
|
||||||
|
@ -1768,72 +1811,50 @@ static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsu
|
||||||
void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
SRetrieveSupport *trsupport = (SRetrieveSupport *) param;
|
SRetrieveSupport *trsupport = (SRetrieveSupport *) param;
|
||||||
|
|
||||||
SSqlObj* pParentSql = trsupport->pParentSqlObj;
|
SSqlObj* pParentSql = trsupport->pParentSql;
|
||||||
SSqlObj* pSql = (SSqlObj *) tres;
|
SSqlObj* pSql = (SSqlObj *) tres;
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
assert(pSql->cmd.numOfClause == 1 && pQueryInfo->numOfTables == 1);
|
assert(pSql->cmd.numOfClause == 1 && pQueryInfo->numOfTables == 1);
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[trsupport->subqueryIndex];
|
||||||
|
|
||||||
SSubqueryState* pState = trsupport->pState;
|
// stable query killed or other subquery failed, all query stopped
|
||||||
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal);
|
|
||||||
|
|
||||||
// todo set error code
|
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
||||||
// stable query is killed, abort further retry
|
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
tscTrace("%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
|
||||||
|
pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(code), tstrerror(pParentSql->res.code));
|
||||||
|
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
tscHandleSubqueryError(param, tres, code);
|
||||||
code = pParentSql->res.code;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
tscDebug("%p query cancelled or failed, sub:%p, orderOfSub:%d abort, code:%s", pParentSql, pSql,
|
|
||||||
trsupport->subqueryIndex, tstrerror(code));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if a query on a vnode is failed, all retrieve operations from vnode that occurs later
|
* if a subquery on a vnode failed, all retrieve operations from vnode that occurs later
|
||||||
* than this one are actually not necessary, we simply call the tscRetrieveFromDnodeCallBack
|
* than this one are actually not necessary, we simply call the tscRetrieveFromDnodeCallBack
|
||||||
* function to abort current and remain retrieve process.
|
* function to abort current and remain retrieve process.
|
||||||
*
|
*
|
||||||
* NOTE: thread safe is required.
|
* NOTE: thread safe is required.
|
||||||
*/
|
*/
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) {
|
||||||
if (trsupport->numOfRetry++ >= MAX_NUM_OF_SUBQUERY_RETRY) {
|
assert(code == taos_errno(pSql));
|
||||||
tscDebug("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
|
|
||||||
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, code);
|
|
||||||
} else { // does not reach the maximum retry time, go on
|
|
||||||
tscDebug("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
|
||||||
|
|
||||||
SSqlObj *pNew = tscCreateSqlObjForSubquery(pParentSql, trsupport, pSql);
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||||
|
tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
||||||
if (pNew == NULL) {
|
if (tscReissueSubquery(trsupport, pSql, code) == TSDB_CODE_SUCCESS) {
|
||||||
tscError("%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d",
|
|
||||||
trsupport->pParentSqlObj, pSql, pVgroup->vgId, trsupport->subqueryIndex);
|
|
||||||
|
|
||||||
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
|
||||||
} else {
|
|
||||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
|
|
||||||
assert(pNewQueryInfo->pTableMetaInfo[0]->pTableMeta != NULL);
|
|
||||||
|
|
||||||
taos_free_result(pSql);
|
|
||||||
tscProcessSql(pNew);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
|
||||||
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, code); // set global code and abort
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) { // at least one peer subquery failed, abort current query
|
|
||||||
tscDebug("%p sub:%p query failed,ip:%s,vgId:%d,orderOfSub:%d,global code:%d", pParentSql, pSql,
|
|
||||||
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex, pParentSql->res.code);
|
|
||||||
|
|
||||||
tscHandleSubqueryError(param, tres, pParentSql->res.code);
|
tscHandleSubqueryError(param, tres, pParentSql->res.code);
|
||||||
} else { // success, proceed to retrieve data from dnode
|
return;
|
||||||
tscDebug("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSqlObj, pSql,
|
}
|
||||||
|
|
||||||
|
tscTrace("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql, pSql,
|
||||||
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
||||||
|
|
||||||
if (pSql->res.qhandle == 0) { // qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
|
if (pSql->res.qhandle == 0) { // qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
|
||||||
|
@ -1841,8 +1862,6 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
} else {
|
} else {
|
||||||
taos_fetch_rows_a(tres, tscRetrieveFromDnodeCallBack, param);
|
taos_fetch_rows_a(tres, tscRetrieveFromDnodeCallBack, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) {
|
static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) {
|
||||||
|
@ -1873,13 +1892,36 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
||||||
|
|
||||||
// release data block data
|
// release data block data
|
||||||
tfree(pState);
|
tfree(pState);
|
||||||
// pParentCmd->pDataBlocks = tscDestroyBlockArrayList(pParentCmd->pDataBlocks);
|
|
||||||
|
|
||||||
// restore user defined fp
|
// restore user defined fp
|
||||||
pParentObj->fp = pParentObj->fetchFp;
|
pParentObj->fp = pParentObj->fetchFp;
|
||||||
|
|
||||||
|
// todo remove this parameter in async callback function definition.
|
||||||
// all data has been sent to vnode, call user function
|
// all data has been sent to vnode, call user function
|
||||||
(*pParentObj->fp)(pParentObj->param, pParentObj, numOfRows);
|
int32_t v = (pParentObj->res.code != TSDB_CODE_SUCCESS)? pParentObj->res.code:pParentObj->res.numOfRows;
|
||||||
|
(*pParentObj->fp)(pParentObj->param, pParentObj, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* it is a subquery, so after parse the sql string, copy the submit block to payload of itself
|
||||||
|
* @param pSql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t tscHandleInsertRetry(SSqlObj* pSql) {
|
||||||
|
assert(pSql != NULL && pSql->param != NULL);
|
||||||
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
|
SSqlRes* pRes = &pSql->res;
|
||||||
|
|
||||||
|
SInsertSupporter* pSupporter = (SInsertSupporter*) pSql->param;
|
||||||
|
assert(pSupporter->index < pSupporter->pState->numOfTotal);
|
||||||
|
|
||||||
|
STableDataBlocks* pTableDataBlock = taosArrayGetP(pCmd->pDataBlocks, pSupporter->index);
|
||||||
|
pRes->code = tscCopyDataBlockToPayload(pSql, pTableDataBlock);
|
||||||
|
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||||
|
return pRes->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tscProcessSql(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
|
@ -1905,8 +1947,9 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter));
|
SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter));
|
||||||
pSupporter->pSql = pSql;
|
pSupporter->pSql = pSql;
|
||||||
pSupporter->pState = pState;
|
pSupporter->pState = pState;
|
||||||
|
pSupporter->index = numOfSub;
|
||||||
|
|
||||||
SSqlObj *pNew = createSimpleSubObj(pSql, multiVnodeInsertFinalize, pSupporter, TSDB_SQL_INSERT);//createSubqueryObj(pSql, 0, multiVnodeInsertFinalize, pSupporter1, TSDB_SQL_INSERT, NULL);
|
SSqlObj *pNew = createSimpleSubObj(pSql, multiVnodeInsertFinalize, pSupporter, TSDB_SQL_INSERT);
|
||||||
if (pNew == NULL) {
|
if (pNew == NULL) {
|
||||||
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, numOfSub, strerror(errno));
|
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, numOfSub, strerror(errno));
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -1937,6 +1980,8 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
return pRes->code; // free all allocated resource
|
return pRes->code; // free all allocated resource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
|
|
||||||
// use the local variable
|
// use the local variable
|
||||||
for (int32_t j = 0; j < numOfSub; ++j) {
|
for (int32_t j = 0; j < numOfSub; ++j) {
|
||||||
SSqlObj *pSub = pSql->pSubs[j];
|
SSqlObj *pSub = pSql->pSubs[j];
|
||||||
|
@ -1944,7 +1989,6 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
tscProcessSql(pSub);
|
tscProcessSql(pSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
|
|
@ -562,10 +562,8 @@ int32_t tscGetDataBlockFromList(void* pHashList, SArray* pDataBlockList, int64_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) {
|
static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bool includeSchema) {
|
||||||
// TODO: optimize this function, handle the case while binary is not presented
|
// TODO: optimize this function, handle the case while binary is not presented
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
STableMeta* pTableMeta = pTableDataBlock->pTableMeta;
|
STableMeta* pTableMeta = pTableDataBlock->pTableMeta;
|
||||||
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
|
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
|
||||||
SSchema* pSchema = tscGetTableSchema(pTableMeta);
|
SSchema* pSchema = tscGetTableSchema(pTableMeta);
|
||||||
|
@ -575,12 +573,33 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) {
|
||||||
pDataBlock += sizeof(SSubmitBlk);
|
pDataBlock += sizeof(SSubmitBlk);
|
||||||
|
|
||||||
int32_t flen = 0; // original total length of row
|
int32_t flen = 0; // original total length of row
|
||||||
for (int32_t i = 0; i < tinfo.numOfColumns; ++i) {
|
|
||||||
flen += TYPE_BYTES[pSchema[i].type];
|
// schema needs to be included into the submit data block
|
||||||
|
if (includeSchema) {
|
||||||
|
int32_t numOfCols = tscGetNumOfColumns(pTableDataBlock->pTableMeta);
|
||||||
|
for(int32_t j = 0; j < numOfCols; ++j) {
|
||||||
|
STColumn* pCol = (STColumn*) pDataBlock;
|
||||||
|
pCol->colId = pSchema[j].colId;
|
||||||
|
pCol->type = pSchema[j].type;
|
||||||
|
pCol->bytes = pSchema[j].bytes;
|
||||||
|
pCol->offset = 0;
|
||||||
|
|
||||||
|
pDataBlock += sizeof(STColumn);
|
||||||
|
flen += TYPE_BYTES[pSchema[j].type];
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t schemaSize = sizeof(STColumn) * numOfCols;
|
||||||
|
pBlock->schemaLen = schemaSize;
|
||||||
|
} else {
|
||||||
|
for (int32_t j = 0; j < tinfo.numOfColumns; ++j) {
|
||||||
|
flen += TYPE_BYTES[pSchema[j].type];
|
||||||
|
}
|
||||||
|
|
||||||
|
pBlock->schemaLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* p = pTableDataBlock->pData + sizeof(SSubmitBlk);
|
char* p = pTableDataBlock->pData + sizeof(SSubmitBlk);
|
||||||
pBlock->len = 0;
|
pBlock->dataLen = 0;
|
||||||
int32_t numOfRows = htons(pBlock->numOfRows);
|
int32_t numOfRows = htons(pBlock->numOfRows);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
|
@ -595,20 +614,21 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) {
|
||||||
p += pSchema[j].bytes;
|
p += pSchema[j].bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// p += pTableDataBlock->rowSize;
|
|
||||||
pDataBlock += dataRowLen(trow);
|
pDataBlock += dataRowLen(trow);
|
||||||
pBlock->len += dataRowLen(trow);
|
pBlock->dataLen += dataRowLen(trow);
|
||||||
}
|
}
|
||||||
|
|
||||||
len = pBlock->len;
|
int32_t len = pBlock->dataLen + pBlock->schemaLen;
|
||||||
pBlock->len = htonl(pBlock->len);
|
pBlock->dataLen = htonl(pBlock->dataLen);
|
||||||
|
pBlock->schemaLen = htonl(pBlock->schemaLen);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
|
int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
|
|
||||||
// the expanded size when a row data is converted to SDataRow format
|
// the maximum expanded size in byte when a row-wise data is converted to SDataRow format
|
||||||
const int32_t MAX_EXPAND_SIZE = TD_DATA_ROW_HEAD_SIZE + TYPE_BYTES[TSDB_DATA_TYPE_BINARY];
|
const int32_t MAX_EXPAND_SIZE = TD_DATA_ROW_HEAD_SIZE + TYPE_BYTES[TSDB_DATA_TYPE_BINARY];
|
||||||
|
|
||||||
void* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false);
|
void* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false);
|
||||||
|
@ -617,7 +637,6 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
|
||||||
size_t total = taosArrayGetSize(pTableDataBlockList);
|
size_t total = taosArrayGetSize(pTableDataBlockList);
|
||||||
for (int32_t i = 0; i < total; ++i) {
|
for (int32_t i = 0; i < total; ++i) {
|
||||||
STableDataBlocks* pOneTableBlock = taosArrayGetP(pTableDataBlockList, i);
|
STableDataBlocks* pOneTableBlock = taosArrayGetP(pTableDataBlockList, i);
|
||||||
|
|
||||||
STableDataBlocks* dataBuf = NULL;
|
STableDataBlocks* dataBuf = NULL;
|
||||||
|
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
|
@ -666,16 +685,17 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
|
||||||
pBlocks->uid = htobe64(pBlocks->uid);
|
pBlocks->uid = htobe64(pBlocks->uid);
|
||||||
pBlocks->sversion = htonl(pBlocks->sversion);
|
pBlocks->sversion = htonl(pBlocks->sversion);
|
||||||
pBlocks->numOfRows = htons(pBlocks->numOfRows);
|
pBlocks->numOfRows = htons(pBlocks->numOfRows);
|
||||||
|
pBlocks->schemaLen = 0;
|
||||||
|
|
||||||
// erase the empty space reserved for binary data
|
// erase the empty space reserved for binary data
|
||||||
int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock);
|
int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, pCmd->submitSchema);
|
||||||
assert(finalLen <= len);
|
assert(finalLen <= len);
|
||||||
|
|
||||||
dataBuf->size += (finalLen + sizeof(SSubmitBlk));
|
dataBuf->size += (finalLen + sizeof(SSubmitBlk));
|
||||||
assert(dataBuf->size <= dataBuf->nAllocSize);
|
assert(dataBuf->size <= dataBuf->nAllocSize);
|
||||||
|
|
||||||
// the length does not include the SSubmitBlk structure
|
// the length does not include the SSubmitBlk structure
|
||||||
pBlocks->len = htonl(finalLen);
|
pBlocks->dataLen = htonl(finalLen);
|
||||||
|
|
||||||
dataBuf->numOfTables += 1;
|
dataBuf->numOfTables += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,10 +128,10 @@ extern float tsTotalLogDirGB;
|
||||||
extern float tsTotalTmpDirGB;
|
extern float tsTotalTmpDirGB;
|
||||||
extern float tsTotalDataDirGB;
|
extern float tsTotalDataDirGB;
|
||||||
extern float tsAvailLogDirGB;
|
extern float tsAvailLogDirGB;
|
||||||
extern float tsAvailTmpDirGB;
|
extern float tsAvailTmpDirectorySpace;
|
||||||
extern float tsAvailDataDirGB;
|
extern float tsAvailDataDirGB;
|
||||||
extern float tsMinimalLogDirGB;
|
extern float tsMinimalLogDirGB;
|
||||||
extern float tsMinimalTmpDirGB;
|
extern float tsReservedTmpDirectorySpace;
|
||||||
extern float tsMinimalDataDirGB;
|
extern float tsMinimalDataDirGB;
|
||||||
extern int32_t tsTotalMemoryMB;
|
extern int32_t tsTotalMemoryMB;
|
||||||
extern int32_t tsVersion;
|
extern int32_t tsVersion;
|
||||||
|
|
|
@ -259,7 +259,7 @@ bool isNEleNull(SDataCol *pCol, int nEle) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
for (int i = 0; i < nEle; i++) {
|
for (int i = 0; i < nEle; i++) {
|
||||||
if (!isNull(varDataVal(tdGetColDataOfRow(pCol, i)), pCol->type)) return false;
|
if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -371,12 +371,14 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||||
|
|
||||||
if (keepData) {
|
if (keepData) {
|
||||||
pRet->cols[i].len = pDataCols->cols[i].len;
|
pRet->cols[i].len = pDataCols->cols[i].len;
|
||||||
|
if (pDataCols->cols[i].len > 0) {
|
||||||
memcpy(pRet->cols[i].pData, pDataCols->cols[i].pData, pDataCols->cols[i].len);
|
memcpy(pRet->cols[i].pData, pDataCols->cols[i].pData, pDataCols->cols[i].len);
|
||||||
if (pRet->cols[i].type == TSDB_DATA_TYPE_BINARY || pRet->cols[i].type == TSDB_DATA_TYPE_NCHAR) {
|
if (pRet->cols[i].type == TSDB_DATA_TYPE_BINARY || pRet->cols[i].type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
memcpy(pRet->cols[i].dataOff, pDataCols->cols[i].dataOff, sizeof(VarDataOffsetT) * pDataCols->maxPoints);
|
memcpy(pRet->cols[i].dataOff, pDataCols->cols[i].dataOff, sizeof(VarDataOffsetT) * pDataCols->maxPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
@ -443,9 +445,11 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
|
||||||
if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap
|
if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap
|
||||||
for (int i = 0; i < rowsToMerge; i++) {
|
for (int i = 0; i < rowsToMerge; i++) {
|
||||||
for (int j = 0; j < source->numOfCols; j++) {
|
for (int j = 0; j < source->numOfCols; j++) {
|
||||||
|
if (source->cols[j].len > 0) {
|
||||||
dataColAppendVal(target->cols + j, tdGetColDataOfRow(source->cols + j, i), target->numOfRows,
|
dataColAppendVal(target->cols + j, tdGetColDataOfRow(source->cols + j, i), target->numOfRows,
|
||||||
target->maxPoints);
|
target->maxPoints);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
target->numOfRows++;
|
target->numOfRows++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -479,9 +483,11 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limi
|
||||||
if (key1 <= key2) {
|
if (key1 <= key2) {
|
||||||
for (int i = 0; i < src1->numOfCols; i++) {
|
for (int i = 0; i < src1->numOfCols; i++) {
|
||||||
ASSERT(target->cols[i].type == src1->cols[i].type);
|
ASSERT(target->cols[i].type == src1->cols[i].type);
|
||||||
|
if (src1->cols[i].len > 0) {
|
||||||
dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfRows,
|
dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfRows,
|
||||||
target->maxPoints);
|
target->maxPoints);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
target->numOfRows++;
|
target->numOfRows++;
|
||||||
(*iter1)++;
|
(*iter1)++;
|
||||||
|
@ -489,9 +495,11 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limi
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < src2->numOfCols; i++) {
|
for (int i = 0; i < src2->numOfCols; i++) {
|
||||||
ASSERT(target->cols[i].type == src2->cols[i].type);
|
ASSERT(target->cols[i].type == src2->cols[i].type);
|
||||||
|
if (src2->cols[i].len > 0) {
|
||||||
dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfRows,
|
dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfRows,
|
||||||
target->maxPoints);
|
target->maxPoints);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
target->numOfRows++;
|
target->numOfRows++;
|
||||||
(*iter2)++;
|
(*iter2)++;
|
||||||
|
|
|
@ -43,7 +43,7 @@ int16_t tsNumOfTotalVnodes = TSDB_INVALID_VNODE_NUM;
|
||||||
int32_t tsNumOfMnodes = 3;
|
int32_t tsNumOfMnodes = 3;
|
||||||
|
|
||||||
// common
|
// common
|
||||||
int32_t tsRpcTimer = 300;
|
int32_t tsRpcTimer = 1000;
|
||||||
int32_t tsRpcMaxTime = 600; // seconds;
|
int32_t tsRpcMaxTime = 600; // seconds;
|
||||||
int32_t tsMaxShellConns = 5000;
|
int32_t tsMaxShellConns = 5000;
|
||||||
int32_t tsMaxConnections = 5000;
|
int32_t tsMaxConnections = 5000;
|
||||||
|
@ -170,9 +170,9 @@ int64_t tsStreamMax;
|
||||||
int32_t tsNumOfCores = 1;
|
int32_t tsNumOfCores = 1;
|
||||||
float tsTotalTmpDirGB = 0;
|
float tsTotalTmpDirGB = 0;
|
||||||
float tsTotalDataDirGB = 0;
|
float tsTotalDataDirGB = 0;
|
||||||
float tsAvailTmpDirGB = 0;
|
float tsAvailTmpDirectorySpace = 0;
|
||||||
float tsAvailDataDirGB = 0;
|
float tsAvailDataDirGB = 0;
|
||||||
float tsMinimalTmpDirGB = 0.1;
|
float tsReservedTmpDirectorySpace = 0.1;
|
||||||
float tsMinimalDataDirGB = 0.5;
|
float tsMinimalDataDirGB = 0.5;
|
||||||
int32_t tsTotalMemoryMB = 0;
|
int32_t tsTotalMemoryMB = 0;
|
||||||
int32_t tsVersion = 0;
|
int32_t tsVersion = 0;
|
||||||
|
@ -807,7 +807,7 @@ static void doInitGlobalConfig() {
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
cfg.option = "minimalTmpDirGB";
|
cfg.option = "minimalTmpDirGB";
|
||||||
cfg.ptr = &tsMinimalTmpDirGB;
|
cfg.ptr = &tsReservedTmpDirectorySpace;
|
||||||
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
|
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
||||||
cfg.minValue = 0.001;
|
cfg.minValue = 0.001;
|
||||||
|
|
|
@ -283,7 +283,8 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
|
||||||
}
|
}
|
||||||
tdAppendColVal(trow, val, c->type, c->bytes, c->offset);
|
tdAppendColVal(trow, val, c->type, c->bytes, c->offset);
|
||||||
}
|
}
|
||||||
pBlk->len = htonl(dataRowLen(trow));
|
pBlk->dataLen = htonl(dataRowLen(trow));
|
||||||
|
pBlk->schemaLen = 0;
|
||||||
|
|
||||||
pBlk->uid = htobe64(pObj->uid);
|
pBlk->uid = htobe64(pObj->uid);
|
||||||
pBlk->tid = htonl(pObj->tid);
|
pBlk->tid = htonl(pObj->tid);
|
||||||
|
|
|
@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
|
||||||
tdFreeSchema(pSchema);
|
tdFreeSchema(pSchema);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
char c = getchar();
|
char c = (char)getchar();
|
||||||
|
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 's':
|
case 's':
|
||||||
|
|
|
@ -113,6 +113,7 @@ void dnodeFreeMnodePqueue() {
|
||||||
void dnodeDispatchToMnodePeerQueue(SRpcMsg *pMsg) {
|
void dnodeDispatchToMnodePeerQueue(SRpcMsg *pMsg) {
|
||||||
if (!mnodeIsRunning() || tsMPeerQueue == NULL) {
|
if (!mnodeIsRunning() || tsMPeerQueue == NULL) {
|
||||||
dnodeSendRedirectMsg(pMsg, false);
|
dnodeSendRedirectMsg(pMsg, false);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ void dnodeFreeMnodeRqueue() {
|
||||||
void dnodeDispatchToMnodeReadQueue(SRpcMsg *pMsg) {
|
void dnodeDispatchToMnodeReadQueue(SRpcMsg *pMsg) {
|
||||||
if (!mnodeIsRunning() || tsMReadQueue == NULL) {
|
if (!mnodeIsRunning() || tsMReadQueue == NULL) {
|
||||||
dnodeSendRedirectMsg(pMsg, true);
|
dnodeSendRedirectMsg(pMsg, true);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ void dnodeFreeMnodeWqueue() {
|
||||||
void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) {
|
void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) {
|
||||||
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
|
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
|
||||||
dnodeSendRedirectMsg(pMsg, true);
|
dnodeSendRedirectMsg(pMsg, true);
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,15 @@
|
||||||
|
|
||||||
#define MPEER_CONTENT_LEN 2000
|
#define MPEER_CONTENT_LEN 2000
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pthread_t thread;
|
||||||
|
int32_t threadIndex;
|
||||||
|
int32_t failed;
|
||||||
|
int32_t opened;
|
||||||
|
int32_t vnodeNum;
|
||||||
|
int32_t * vnodeList;
|
||||||
|
} SOpenVnodeThread;
|
||||||
|
|
||||||
void * tsDnodeTmr = NULL;
|
void * tsDnodeTmr = NULL;
|
||||||
static void * tsStatusTimer = NULL;
|
static void * tsStatusTimer = NULL;
|
||||||
static uint32_t tsRebootTime;
|
static uint32_t tsRebootTime;
|
||||||
|
@ -242,28 +251,86 @@ static int32_t dnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dnodeOpenVnodes() {
|
static void *dnodeOpenVnode(void *param) {
|
||||||
|
SOpenVnodeThread *pThread = param;
|
||||||
char vnodeDir[TSDB_FILENAME_LEN * 3];
|
char vnodeDir[TSDB_FILENAME_LEN * 3];
|
||||||
int32_t failed = 0;
|
|
||||||
int32_t *vnodeList = (int32_t *)malloc(sizeof(int32_t) * TSDB_MAX_VNODES);
|
|
||||||
int32_t numOfVnodes;
|
|
||||||
int32_t status;
|
|
||||||
|
|
||||||
status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
|
dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
||||||
|
|
||||||
|
for (int32_t v = 0; v < pThread->vnodeNum; ++v) {
|
||||||
|
int32_t vgId = pThread->vnodeList[v];
|
||||||
|
snprintf(vnodeDir, TSDB_FILENAME_LEN * 3, "%s/vnode%d", tsVnodeDir, vgId);
|
||||||
|
if (vnodeOpen(vgId, vnodeDir) < 0) {
|
||||||
|
dError("vgId:%d, failed to open vnode by thread:%d", vgId, pThread->threadIndex);
|
||||||
|
pThread->failed++;
|
||||||
|
} else {
|
||||||
|
dDebug("vgId:%d, is openned by thread:%d", vgId, pThread->threadIndex);
|
||||||
|
pThread->opened++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dDebug("thread:%d, total vnodes:%d, openned:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened,
|
||||||
|
pThread->failed);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dnodeOpenVnodes() {
|
||||||
|
int32_t *vnodeList = calloc(TSDB_MAX_VNODES, sizeof(int32_t));
|
||||||
|
int32_t numOfVnodes;
|
||||||
|
int32_t status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
|
||||||
|
|
||||||
if (status != TSDB_CODE_SUCCESS) {
|
if (status != TSDB_CODE_SUCCESS) {
|
||||||
dInfo("Get dnode list failed");
|
dInfo("get dnode list failed");
|
||||||
free(vnodeList);
|
free(vnodeList);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
int32_t threadNum = tsNumOfCores;
|
||||||
snprintf(vnodeDir, TSDB_FILENAME_LEN * 3, "%s/vnode%d", tsVnodeDir, vnodeList[i]);
|
int32_t vnodesPerThread = numOfVnodes / threadNum + 1;
|
||||||
if (vnodeOpen(vnodeList[i], vnodeDir) < 0) failed++;
|
SOpenVnodeThread *threads = calloc(threadNum, sizeof(SOpenVnodeThread));
|
||||||
|
for (int32_t t = 0; t < threadNum; ++t) {
|
||||||
|
threads[t].threadIndex = t;
|
||||||
|
threads[t].vnodeList = calloc(vnodesPerThread, sizeof(int32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t v = 0; v < numOfVnodes; ++v) {
|
||||||
|
int32_t t = v % threadNum;
|
||||||
|
SOpenVnodeThread *pThread = &threads[t];
|
||||||
|
pThread->vnodeList[pThread->vnodeNum++] = vnodeList[v];
|
||||||
|
}
|
||||||
|
|
||||||
|
dDebug("start %d threads to open %d vnodes", threadNum, numOfVnodes);
|
||||||
|
|
||||||
|
for (int32_t t = 0; t < threadNum; ++t) {
|
||||||
|
SOpenVnodeThread *pThread = &threads[t];
|
||||||
|
if (pThread->vnodeNum == 0) continue;
|
||||||
|
|
||||||
|
pthread_attr_t thAttr;
|
||||||
|
pthread_attr_init(&thAttr);
|
||||||
|
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
if (pthread_create(&pThread->thread, &thAttr, dnodeOpenVnode, pThread) != 0) {
|
||||||
|
dError("thread:%d, failed to create thread to open vnode, reason:%s", pThread->threadIndex, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_attr_destroy(&thAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t openVnodes = 0;
|
||||||
|
int32_t failedVnodes = 0;
|
||||||
|
for (int32_t t = 0; t < threadNum; ++t) {
|
||||||
|
SOpenVnodeThread *pThread = &threads[t];
|
||||||
|
if (pThread->vnodeNum > 0 && pThread->thread) {
|
||||||
|
pthread_join(pThread->thread, NULL);
|
||||||
|
}
|
||||||
|
openVnodes += pThread->opened;
|
||||||
|
failedVnodes += pThread->failed;
|
||||||
|
free(pThread->vnodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(vnodeList);
|
free(vnodeList);
|
||||||
dInfo("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, numOfVnodes-failed, failed);
|
free(threads);
|
||||||
|
dInfo("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, openVnodes, failedVnodes);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +340,7 @@ void dnodeStartStream() {
|
||||||
int32_t status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
|
int32_t status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
|
||||||
|
|
||||||
if (status != TSDB_CODE_SUCCESS) {
|
if (status != TSDB_CODE_SUCCESS) {
|
||||||
dInfo("Get dnode list failed");
|
dInfo("get dnode list failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +359,7 @@ static void dnodeCloseVnodes() {
|
||||||
status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
|
status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
|
||||||
|
|
||||||
if (status != TSDB_CODE_SUCCESS) {
|
if (status != TSDB_CODE_SUCCESS) {
|
||||||
dInfo("Get dnode list failed");
|
dInfo("get dnode list failed");
|
||||||
free(vnodeList);
|
free(vnodeList);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct {
|
||||||
int32_t min; // min number of workers
|
int32_t min; // min number of workers
|
||||||
int32_t num; // current number of workers
|
int32_t num; // current number of workers
|
||||||
SReadWorker *readWorker;
|
SReadWorker *readWorker;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
} SReadWorkerPool;
|
} SReadWorkerPool;
|
||||||
|
|
||||||
static void *dnodeProcessReadQueue(void *param);
|
static void *dnodeProcessReadQueue(void *param);
|
||||||
|
@ -52,6 +53,7 @@ int32_t dnodeInitVnodeRead() {
|
||||||
readPool.max = tsNumOfCores * tsNumOfThreadsPerCore;
|
readPool.max = tsNumOfCores * tsNumOfThreadsPerCore;
|
||||||
if (readPool.max <= readPool.min * 2) readPool.max = 2 * readPool.min;
|
if (readPool.max <= readPool.min * 2) readPool.max = 2 * readPool.min;
|
||||||
readPool.readWorker = (SReadWorker *)calloc(sizeof(SReadWorker), readPool.max);
|
readPool.readWorker = (SReadWorker *)calloc(sizeof(SReadWorker), readPool.max);
|
||||||
|
pthread_mutex_init(&readPool.mutex, NULL);
|
||||||
|
|
||||||
if (readPool.readWorker == NULL) return -1;
|
if (readPool.readWorker == NULL) return -1;
|
||||||
for (int i = 0; i < readPool.max; ++i) {
|
for (int i = 0; i < readPool.max; ++i) {
|
||||||
|
@ -59,7 +61,7 @@ int32_t dnodeInitVnodeRead() {
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("dnode read is opened");
|
dInfo("dnode read is opened, min worker:%d max worker:%d", readPool.min, readPool.max);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +82,7 @@ void dnodeCleanupVnodeRead() {
|
||||||
|
|
||||||
free(readPool.readWorker);
|
free(readPool.readWorker);
|
||||||
taosCloseQset(readQset);
|
taosCloseQset(readQset);
|
||||||
|
pthread_mutex_destroy(&readPool.mutex);
|
||||||
|
|
||||||
dInfo("dnode read is closed");
|
dInfo("dnode read is closed");
|
||||||
}
|
}
|
||||||
|
@ -136,8 +139,12 @@ void dnodeDispatchToVnodeReadQueue(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void *dnodeAllocateVnodeRqueue(void *pVnode) {
|
void *dnodeAllocateVnodeRqueue(void *pVnode) {
|
||||||
|
pthread_mutex_lock(&readPool.mutex);
|
||||||
taos_queue queue = taosOpenQueue();
|
taos_queue queue = taosOpenQueue();
|
||||||
if (queue == NULL) return NULL;
|
if (queue == NULL) {
|
||||||
|
pthread_mutex_unlock(&readPool.mutex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
taosAddIntoQset(readQset, queue, pVnode);
|
taosAddIntoQset(readQset, queue, pVnode);
|
||||||
|
|
||||||
|
@ -160,6 +167,7 @@ void *dnodeAllocateVnodeRqueue(void *pVnode) {
|
||||||
} while (readPool.num < readPool.min);
|
} while (readPool.num < readPool.min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&readPool.mutex);
|
||||||
dDebug("pVnode:%p, read queue:%p is allocated", pVnode, queue);
|
dDebug("pVnode:%p, read queue:%p is allocated", pVnode, queue);
|
||||||
|
|
||||||
return queue;
|
return queue;
|
||||||
|
|
|
@ -47,6 +47,7 @@ typedef struct {
|
||||||
int32_t max; // max number of workers
|
int32_t max; // max number of workers
|
||||||
int32_t nextId; // from 0 to max-1, cyclic
|
int32_t nextId; // from 0 to max-1, cyclic
|
||||||
SWriteWorker *writeWorker;
|
SWriteWorker *writeWorker;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
} SWriteWorkerPool;
|
} SWriteWorkerPool;
|
||||||
|
|
||||||
static void *dnodeProcessWriteQueue(void *param);
|
static void *dnodeProcessWriteQueue(void *param);
|
||||||
|
@ -58,12 +59,13 @@ int32_t dnodeInitVnodeWrite() {
|
||||||
wWorkerPool.max = tsNumOfCores;
|
wWorkerPool.max = tsNumOfCores;
|
||||||
wWorkerPool.writeWorker = (SWriteWorker *)calloc(sizeof(SWriteWorker), wWorkerPool.max);
|
wWorkerPool.writeWorker = (SWriteWorker *)calloc(sizeof(SWriteWorker), wWorkerPool.max);
|
||||||
if (wWorkerPool.writeWorker == NULL) return -1;
|
if (wWorkerPool.writeWorker == NULL) return -1;
|
||||||
|
pthread_mutex_init(&wWorkerPool.mutex, NULL);
|
||||||
|
|
||||||
for (int32_t i = 0; i < wWorkerPool.max; ++i) {
|
for (int32_t i = 0; i < wWorkerPool.max; ++i) {
|
||||||
wWorkerPool.writeWorker[i].workerId = i;
|
wWorkerPool.writeWorker[i].workerId = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("dnode write is opened");
|
dInfo("dnode write is opened, max worker %d", wWorkerPool.max);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +86,7 @@ void dnodeCleanupVnodeWrite() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_destroy(&wWorkerPool.mutex);
|
||||||
free(wWorkerPool.writeWorker);
|
free(wWorkerPool.writeWorker);
|
||||||
dInfo("dnode write is closed");
|
dInfo("dnode write is closed");
|
||||||
}
|
}
|
||||||
|
@ -124,14 +127,19 @@ void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void *dnodeAllocateVnodeWqueue(void *pVnode) {
|
void *dnodeAllocateVnodeWqueue(void *pVnode) {
|
||||||
|
pthread_mutex_lock(&wWorkerPool.mutex);
|
||||||
SWriteWorker *pWorker = wWorkerPool.writeWorker + wWorkerPool.nextId;
|
SWriteWorker *pWorker = wWorkerPool.writeWorker + wWorkerPool.nextId;
|
||||||
void *queue = taosOpenQueue();
|
void *queue = taosOpenQueue();
|
||||||
if (queue == NULL) return NULL;
|
if (queue == NULL) {
|
||||||
|
pthread_mutex_unlock(&wWorkerPool.mutex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pWorker->qset == NULL) {
|
if (pWorker->qset == NULL) {
|
||||||
pWorker->qset = taosOpenQset();
|
pWorker->qset = taosOpenQset();
|
||||||
if (pWorker->qset == NULL) {
|
if (pWorker->qset == NULL) {
|
||||||
taosCloseQueue(queue);
|
taosCloseQueue(queue);
|
||||||
|
pthread_mutex_unlock(&wWorkerPool.mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +148,7 @@ void *dnodeAllocateVnodeWqueue(void *pVnode) {
|
||||||
if (pWorker->qall == NULL) {
|
if (pWorker->qall == NULL) {
|
||||||
taosCloseQset(pWorker->qset);
|
taosCloseQset(pWorker->qset);
|
||||||
taosCloseQueue(queue);
|
taosCloseQueue(queue);
|
||||||
|
pthread_mutex_unlock(&wWorkerPool.mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pthread_attr_t thAttr;
|
pthread_attr_t thAttr;
|
||||||
|
@ -163,6 +172,7 @@ void *dnodeAllocateVnodeWqueue(void *pVnode) {
|
||||||
wWorkerPool.nextId = (wWorkerPool.nextId + 1) % wWorkerPool.max;
|
wWorkerPool.nextId = (wWorkerPool.nextId + 1) % wWorkerPool.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&wWorkerPool.mutex);
|
||||||
dDebug("pVnode:%p, write queue:%p is allocated", pVnode, queue);
|
dDebug("pVnode:%p, write queue:%p is allocated", pVnode, queue);
|
||||||
|
|
||||||
return queue;
|
return queue;
|
||||||
|
@ -201,6 +211,8 @@ static void *dnodeProcessWriteQueue(void *param) {
|
||||||
int type;
|
int type;
|
||||||
void *pVnode, *item;
|
void *pVnode, *item;
|
||||||
|
|
||||||
|
dDebug("write worker:%d is running", pWorker->workerId);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
numOfMsgs = taosReadAllQitemsFromQset(pWorker->qset, pWorker->qall, &pVnode);
|
numOfMsgs = taosReadAllQitemsFromQset(pWorker->qset, pWorker->qall, &pVnode);
|
||||||
if (numOfMsgs == 0) {
|
if (numOfMsgs == 0) {
|
||||||
|
|
|
@ -153,6 +153,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_ALREAY_EXIST, 0, 0x0369, "mnode tag
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, 0, 0x036A, "mnode tag not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, 0, 0x036A, "mnode tag not exist")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_ALREAY_EXIST, 0, 0x036B, "mnode field already exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_ALREAY_EXIST, 0, 0x036B, "mnode field already exist")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_NOT_EXIST, 0, 0x036C, "mnode field not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_NOT_EXIST, 0, 0x036C, "mnode field not exist")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STABLE_NAME, 0, 0x036D, "mnode invalid stable name")
|
||||||
|
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_SELECTED, 0, 0x0380, "mnode db not selected")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_SELECTED, 0, 0x0380, "mnode db not selected")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ALREADY_EXIST, 0, 0x0381, "mnode database aleady exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ALREADY_EXIST, 0, 0x0381, "mnode database aleady exist")
|
||||||
|
|
|
@ -192,7 +192,8 @@ typedef struct SSubmitBlk {
|
||||||
int32_t tid; // table id
|
int32_t tid; // table id
|
||||||
int32_t padding; // TODO just for padding here
|
int32_t padding; // TODO just for padding here
|
||||||
int32_t sversion; // data schema version
|
int32_t sversion; // data schema version
|
||||||
int32_t len; // data part length, not including the SSubmitBlk head
|
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
||||||
|
int32_t schemaLen; // schema length, if length is 0, no schema exists
|
||||||
int16_t numOfRows; // total number of rows in current submit block
|
int16_t numOfRows; // total number of rows in current submit block
|
||||||
char data[];
|
char data[];
|
||||||
} SSubmitBlk;
|
} SSubmitBlk;
|
||||||
|
@ -618,7 +619,7 @@ typedef struct {
|
||||||
} SMDVnodeDesc;
|
} SMDVnodeDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_NAME_LEN];
|
char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN];
|
||||||
SMDVnodeCfg cfg;
|
SMDVnodeCfg cfg;
|
||||||
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
||||||
} SMDCreateVnodeMsg;
|
} SMDCreateVnodeMsg;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "tdataformat.h"
|
#include "tdataformat.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -170,6 +171,7 @@ typedef struct SDataBlockInfo {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t numOfTables;
|
size_t numOfTables;
|
||||||
SArray *pGroupList;
|
SArray *pGroupList;
|
||||||
|
SHashObj *map; // speedup acquire the tableQueryInfo from STableId
|
||||||
} STableGroupInfo;
|
} STableGroupInfo;
|
||||||
|
|
||||||
typedef struct SQueryRowCond {
|
typedef struct SQueryRowCond {
|
||||||
|
|
|
@ -790,7 +790,7 @@ int isCommentLine(char *line) {
|
||||||
void source_file(TAOS *con, char *fptr) {
|
void source_file(TAOS *con, char *fptr) {
|
||||||
wordexp_t full_path;
|
wordexp_t full_path;
|
||||||
int read_len = 0;
|
int read_len = 0;
|
||||||
char * cmd = calloc(1, MAX_COMMAND_SIZE);
|
char * cmd = calloc(1, tsMaxSQLStringLen+1);
|
||||||
size_t cmd_len = 0;
|
size_t cmd_len = 0;
|
||||||
char * line = NULL;
|
char * line = NULL;
|
||||||
size_t line_len = 0;
|
size_t line_len = 0;
|
||||||
|
@ -822,7 +822,7 @@ void source_file(TAOS *con, char *fptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((read_len = getline(&line, &line_len, f)) != -1) {
|
while ((read_len = getline(&line, &line_len, f)) != -1) {
|
||||||
if (read_len >= MAX_COMMAND_SIZE) continue;
|
if (read_len >= tsMaxSQLStringLen) continue;
|
||||||
line[--read_len] = '\0';
|
line[--read_len] = '\0';
|
||||||
|
|
||||||
if (read_len == 0 || isCommentLine(line)) { // line starts with #
|
if (read_len == 0 || isCommentLine(line)) { // line starts with #
|
||||||
|
@ -839,7 +839,7 @@ void source_file(TAOS *con, char *fptr) {
|
||||||
memcpy(cmd + cmd_len, line, read_len);
|
memcpy(cmd + cmd_len, line, read_len);
|
||||||
printf("%s%s\n", PROMPT_HEADER, cmd);
|
printf("%s%s\n", PROMPT_HEADER, cmd);
|
||||||
shellRunCommand(con, cmd);
|
shellRunCommand(con, cmd);
|
||||||
memset(cmd, 0, MAX_COMMAND_SIZE);
|
memset(cmd, 0, tsMaxSQLStringLen);
|
||||||
cmd_len = 0;
|
cmd_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -808,27 +808,31 @@ void *readMetric(void *sarg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void queryDB(TAOS *taos, char *command) {
|
void queryDB(TAOS *taos, char *command) {
|
||||||
int i = 5;
|
int i;
|
||||||
TAOS_RES *pSql = NULL;
|
TAOS_RES *pSql = NULL;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
while (i > 0 && code != 0) {
|
|
||||||
pSql = taos_query(taos, command);
|
for (i = 0; i < 5; i++) {
|
||||||
code = taos_errno(pSql);
|
if (NULL != pSql) {
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
pSql = NULL;
|
pSql = NULL;
|
||||||
if (code == 0) {
|
}
|
||||||
|
|
||||||
|
pSql = taos_query(taos, command);
|
||||||
|
code = taos_errno(pSql);
|
||||||
|
if (0 == code) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
|
fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
|
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taos_free_result(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync insertion
|
// sync insertion
|
||||||
|
|
|
@ -132,7 +132,7 @@ typedef struct SVgObj {
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int32_t lbDnodeId;
|
int32_t lbDnodeId;
|
||||||
int32_t lbTime;
|
int32_t lbTime;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN];
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
int8_t accessState;
|
int8_t accessState;
|
||||||
int8_t reserved0[5];
|
int8_t reserved0[5];
|
||||||
|
|
|
@ -287,7 +287,7 @@ void sdbUpdateSync() {
|
||||||
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
|
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
|
syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
|
||||||
strcpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeEp);
|
tstrncpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +367,7 @@ void sdbCleanUp() {
|
||||||
tsSdbObj.status = SDB_STATUS_CLOSING;
|
tsSdbObj.status = SDB_STATUS_CLOSING;
|
||||||
|
|
||||||
sdbCleanupWriteWorker();
|
sdbCleanupWriteWorker();
|
||||||
|
sdbDebug("sdb will be closed, version:%" PRId64, tsSdbObj.version);
|
||||||
|
|
||||||
if (tsSdbObj.sync) {
|
if (tsSdbObj.sync) {
|
||||||
syncStop(tsSdbObj.sync);
|
syncStop(tsSdbObj.sync);
|
||||||
|
@ -976,11 +977,11 @@ static void *sdbWorkerFp(void *param) {
|
||||||
tstrerror(pOper->retCode));
|
tstrerror(pOper->retCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeSendRpcMnodeWriteRsp(pOper->pMsg, pOper->retCode);
|
|
||||||
|
|
||||||
if (pOper != NULL) {
|
if (pOper != NULL) {
|
||||||
sdbDecRef(pOper->table, pOper->pObj);
|
sdbDecRef(pOper->table, pOper->pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dnodeSendRpcMnodeWriteRsp(pOper->pMsg, pOper->retCode);
|
||||||
}
|
}
|
||||||
taosFreeQitem(item);
|
taosFreeQitem(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,6 +281,7 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
SCMConnectMsg *pConnectMsg = pMsg->rpcMsg.pCont;
|
SCMConnectMsg *pConnectMsg = pMsg->rpcMsg.pCont;
|
||||||
|
SCMConnectRsp *pConnectRsp = NULL;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SRpcConnInfo connInfo;
|
SRpcConnInfo connInfo;
|
||||||
|
@ -309,7 +310,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
mnodeDecDbRef(pDb);
|
mnodeDecDbRef(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
|
pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
|
||||||
if (pConnectRsp == NULL) {
|
if (pConnectRsp == NULL) {
|
||||||
code = TSDB_CODE_MND_OUT_OF_MEMORY;
|
code = TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
goto connect_over;
|
goto connect_over;
|
||||||
|
@ -332,7 +333,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
connect_over:
|
connect_over:
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
rpcFreeCont(pConnectRsp);
|
if (pConnectRsp) rpcFreeCont(pConnectRsp);
|
||||||
mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
mLInfo("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
mLInfo("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
||||||
|
|
|
@ -382,11 +382,13 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt
|
||||||
pStable->numOfTables++;
|
pStable->numOfTables++;
|
||||||
|
|
||||||
if (pStable->vgHash == NULL) {
|
if (pStable->vgHash == NULL) {
|
||||||
pStable->vgHash = taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
pStable->vgHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStable->vgHash != NULL) {
|
if (pStable->vgHash != NULL) {
|
||||||
taosHashPut(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId));
|
if (taosHashGet(pStable->vgHash, &pCtable->vgId, sizeof(pCtable->vgId)) == NULL) {
|
||||||
|
taosHashPut(pStable->vgHash, &pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,10 +459,9 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
|
||||||
free(pNew);
|
free(pNew);
|
||||||
free(oldTableId);
|
free(oldTableId);
|
||||||
free(oldSchema);
|
free(oldSchema);
|
||||||
|
|
||||||
mnodeDecTableRef(pTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mnodeDecTableRef(pTable);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1254,13 +1255,13 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSuperTableObj *pTable = NULL;
|
SSuperTableObj *pTable = NULL;
|
||||||
char prefix[20] = {0};
|
char prefix[64] = {0};
|
||||||
int32_t prefixLen;
|
int32_t prefixLen;
|
||||||
|
|
||||||
SDbObj *pDb = mnodeGetDb(pShow->db);
|
SDbObj *pDb = mnodeGetDb(pShow->db);
|
||||||
if (pDb == NULL) return 0;
|
if (pDb == NULL) return 0;
|
||||||
|
|
||||||
strcpy(prefix, pDb->name);
|
tstrncpy(prefix, pDb->name, 64);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
strcat(prefix, TS_PATH_DELIMITER);
|
||||||
prefixLen = strlen(prefix);
|
prefixLen = strlen(prefix);
|
||||||
|
|
||||||
|
@ -1558,10 +1559,10 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO
|
||||||
|
|
||||||
static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
||||||
if (pTable != NULL) {
|
assert(pTable);
|
||||||
|
|
||||||
mDebug("app:%p:%p, table:%s, create table in id:%d, uid:%" PRIu64 ", result:%s", pMsg->rpcMsg.ahandle, pMsg,
|
mDebug("app:%p:%p, table:%s, create table in id:%d, uid:%" PRIu64 ", result:%s", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code));
|
pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code));
|
||||||
}
|
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) return code;
|
if (code != TSDB_CODE_SUCCESS) return code;
|
||||||
|
|
||||||
|
@ -1965,9 +1966,15 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
|
||||||
|
|
||||||
static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
||||||
SCMTableInfoMsg *pInfo = pMsg->rpcMsg.pCont;
|
SCMTableInfoMsg *pInfo = pMsg->rpcMsg.pCont;
|
||||||
STagData *pTag = (STagData *)pInfo->tags;
|
STagData *pTags = (STagData *)pInfo->tags;
|
||||||
|
int32_t tagLen = htonl(pTags->dataLen);
|
||||||
|
if (pTags->name[0] == 0) {
|
||||||
|
mError("app:%p:%p, table:%s, failed to create table on demand for stable is empty, tagLen:%d", pMsg->rpcMsg.ahandle,
|
||||||
|
pMsg, pInfo->tableId, tagLen);
|
||||||
|
return TSDB_CODE_MND_INVALID_STABLE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + htonl(pTag->dataLen);
|
int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + tagLen;
|
||||||
SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen);
|
SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen);
|
||||||
if (pCreateMsg == NULL) {
|
if (pCreateMsg == NULL) {
|
||||||
mError("app:%p:%p, table:%s, failed to create table while get meta info, no enough memory", pMsg->rpcMsg.ahandle,
|
mError("app:%p:%p, table:%s, failed to create table while get meta info, no enough memory", pMsg->rpcMsg.ahandle,
|
||||||
|
@ -1982,9 +1989,9 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
||||||
pCreateMsg->getMeta = 1;
|
pCreateMsg->getMeta = 1;
|
||||||
pCreateMsg->contLen = htonl(contLen);
|
pCreateMsg->contLen = htonl(contLen);
|
||||||
|
|
||||||
memcpy(pCreateMsg->schema, pInfo->tags, contLen - sizeof(SCMCreateTableMsg));
|
memcpy(pCreateMsg->schema, pTags, contLen - sizeof(SCMCreateTableMsg));
|
||||||
mDebug("app:%p:%p, table:%s, start to create on demand, stable:%s", pMsg->rpcMsg.ahandle, pMsg, pInfo->tableId,
|
mDebug("app:%p:%p, table:%s, start to create on demand, tagLen:%d stable:%s",
|
||||||
((STagData *)(pCreateMsg->schema))->name);
|
pMsg->rpcMsg.ahandle, pMsg, pInfo->tableId, tagLen, pTags->name);
|
||||||
|
|
||||||
rpcFreeCont(pMsg->rpcMsg.pCont);
|
rpcFreeCont(pMsg->rpcMsg.pCont);
|
||||||
pMsg->rpcMsg.msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE;
|
pMsg->rpcMsg.msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE;
|
||||||
|
@ -2370,10 +2377,21 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
|
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
strcpy(prefix, pDb->name);
|
tstrncpy(prefix, pDb->name, 64);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
strcat(prefix, TS_PATH_DELIMITER);
|
||||||
int32_t prefixLen = strlen(prefix);
|
int32_t prefixLen = strlen(prefix);
|
||||||
|
|
||||||
|
char* pattern = NULL;
|
||||||
|
if (pShow->payloadLen > 0) {
|
||||||
|
pattern = (char*)malloc(pShow->payloadLen + 1);
|
||||||
|
if (pattern == NULL) {
|
||||||
|
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(pattern, pShow->payload, pShow->payloadLen);
|
||||||
|
pattern[pShow->payloadLen] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = mnodeGetNextChildTable(pShow->pIter, &pTable);
|
pShow->pIter = mnodeGetNextChildTable(pShow->pIter, &pTable);
|
||||||
if (pTable == NULL) break;
|
if (pTable == NULL) break;
|
||||||
|
@ -2389,7 +2407,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
// pattern compare for table name
|
// pattern compare for table name
|
||||||
mnodeExtractTableName(pTable->info.tableId, tableName);
|
mnodeExtractTableName(pTable->info.tableId, tableName);
|
||||||
|
|
||||||
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, sizeof(tableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
if (pattern != NULL && patternMatch(pattern, tableName, sizeof(tableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2433,6 +2451,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
|
|
||||||
mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
||||||
mnodeDecDbRef(pDb);
|
mnodeDecDbRef(pDb);
|
||||||
|
free(pattern);
|
||||||
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
@ -2560,7 +2579,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
|
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
strcpy(prefix, pDb->name);
|
tstrncpy(prefix, pDb->name, 64);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
strcat(prefix, TS_PATH_DELIMITER);
|
||||||
int32_t prefixLen = strlen(prefix);
|
int32_t prefixLen = strlen(prefix);
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) {
|
||||||
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
||||||
|
|
||||||
SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj));
|
SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj));
|
||||||
tstrncpy(pVgroup->dbName, pDb->name, TSDB_DB_NAME_LEN);
|
tstrncpy(pVgroup->dbName, pDb->name, TSDB_ACCT_LEN + TSDB_DB_NAME_LEN);
|
||||||
pVgroup->numOfVnodes = pDb->cfg.replications;
|
pVgroup->numOfVnodes = pDb->cfg.replications;
|
||||||
pVgroup->createdTime = taosGetTimestampMs();
|
pVgroup->createdTime = taosGetTimestampMs();
|
||||||
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
|
|
|
@ -325,12 +325,12 @@ bool taosGetDisk() {
|
||||||
|
|
||||||
if (statvfs("/tmp", &info)) {
|
if (statvfs("/tmp", &info)) {
|
||||||
//tsTotalTmpDirGB = 0;
|
//tsTotalTmpDirGB = 0;
|
||||||
//tsAvailTmpDirGB = 0;
|
//tsAvailTmpDirectorySpace = 0;
|
||||||
uError("failed to get disk size, tmpDir:/tmp errno:%s", strerror(errno));
|
uError("failed to get disk size, tmpDir:/tmp errno:%s", strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tsTotalTmpDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit);
|
tsTotalTmpDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit);
|
||||||
tsAvailTmpDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit);
|
tsAvailTmpDirectorySpace = (float)((double)info.f_bavail * (double)info.f_frsize / unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -359,6 +359,8 @@ void httpExecCmd(HttpContext *pContext) {
|
||||||
|
|
||||||
void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
|
void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
|
||||||
HttpContext *pContext = param;
|
HttpContext *pContext = param;
|
||||||
|
taos_free_result(result);
|
||||||
|
|
||||||
if (pContext == NULL) return;
|
if (pContext == NULL) return;
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
|
|
|
@ -176,7 +176,8 @@ typedef struct SQueryRuntimeEnv {
|
||||||
void* pQueryHandle;
|
void* pQueryHandle;
|
||||||
void* pSecQueryHandle; // another thread for
|
void* pSecQueryHandle; // another thread for
|
||||||
SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||||
bool topBotQuery; // false;
|
bool topBotQuery; // false
|
||||||
|
int32_t prevGroupId; // previous executed group id
|
||||||
} SQueryRuntimeEnv;
|
} SQueryRuntimeEnv;
|
||||||
|
|
||||||
typedef struct SQInfo {
|
typedef struct SQInfo {
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <taosmsg.h>
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "qfill.h"
|
#include "qfill.h"
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "hashfunc.h"
|
|
||||||
#include "qExecutor.h"
|
#include "qExecutor.h"
|
||||||
#include "qUtil.h"
|
#include "qUtil.h"
|
||||||
#include "qast.h"
|
#include "qast.h"
|
||||||
|
@ -25,7 +23,6 @@
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "queryLog.h"
|
#include "queryLog.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tdataformat.h"
|
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
||||||
#include "tscUtil.h" // todo move the function to common module
|
#include "tscUtil.h" // todo move the function to common module
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
|
@ -91,6 +88,9 @@ typedef struct {
|
||||||
} SQueryStatusInfo;
|
} SQueryStatusInfo;
|
||||||
|
|
||||||
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
|
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
|
||||||
|
#define GET_NUM_OF_TABLEGROUP(q) taosArrayGetSize((q)->tableqinfoGroupInfo.pGroupList)
|
||||||
|
#define GET_TABLEGROUP(q, _index) ((SArray*) taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index)))
|
||||||
|
|
||||||
static void setQueryStatus(SQuery *pQuery, int8_t status);
|
static void setQueryStatus(SQuery *pQuery, int8_t status);
|
||||||
|
|
||||||
static bool isIntervalQuery(SQuery *pQuery) { return pQuery->intervalTime > 0; }
|
static bool isIntervalQuery(SQuery *pQuery) { return pQuery->intervalTime > 0; }
|
||||||
|
@ -1708,7 +1708,23 @@ static bool onlyFirstQuery(SQuery *pQuery) { return onlyOneQueryType(pQuery, TSD
|
||||||
|
|
||||||
static bool onlyLastQuery(SQuery *pQuery) { return onlyOneQueryType(pQuery, TSDB_FUNC_LAST, TSDB_FUNC_LAST_DST); }
|
static bool onlyLastQuery(SQuery *pQuery) { return onlyOneQueryType(pQuery, TSDB_FUNC_LAST, TSDB_FUNC_LAST_DST); }
|
||||||
|
|
||||||
static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
|
// todo refactor, add iterator
|
||||||
|
static void doExchangeTimeWindow(SQInfo* pQInfo) {
|
||||||
|
size_t t = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
for(int32_t i = 0; i < t; ++i) {
|
||||||
|
SArray* p1 = GET_TABLEGROUP(pQInfo, i);
|
||||||
|
|
||||||
|
size_t len = taosArrayGetSize(p1);
|
||||||
|
for(int32_t j = 0; j < len; ++j) {
|
||||||
|
STableQueryInfo* pTableQueryInfo = (STableQueryInfo*) taosArrayGetP(p1, j);
|
||||||
|
SWAP(pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey, TSKEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void changeExecuteScanOrder(SQInfo *pQInfo, bool stableQuery) {
|
||||||
|
SQuery* pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
|
|
||||||
// in case of point-interpolation query, use asc order scan
|
// in case of point-interpolation query, use asc order scan
|
||||||
char msg[] = "QInfo:%p scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%" PRId64
|
char msg[] = "QInfo:%p scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%" PRId64
|
||||||
"-%" PRId64 ", new qrange:%" PRId64 "-%" PRId64;
|
"-%" PRId64 ", new qrange:%" PRId64 "-%" PRId64;
|
||||||
|
@ -1748,6 +1764,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
|
||||||
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
|
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
|
||||||
|
|
||||||
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
||||||
|
doExchangeTimeWindow(pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
pQuery->order.order = TSDB_ORDER_ASC;
|
pQuery->order.order = TSDB_ORDER_ASC;
|
||||||
|
@ -1757,6 +1774,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
|
||||||
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
|
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
|
||||||
|
|
||||||
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
||||||
|
doExchangeTimeWindow(pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
pQuery->order.order = TSDB_ORDER_DESC;
|
pQuery->order.order = TSDB_ORDER_DESC;
|
||||||
|
@ -2219,7 +2237,7 @@ static void doSetTagValueInParam(void *tsdb, void* pTable, int32_t tagColId, tVa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
if (isNull(varDataVal(val), type)) {
|
if (isNull(val, type)) {
|
||||||
tag->nType = TSDB_DATA_TYPE_NULL;
|
tag->nType = TSDB_DATA_TYPE_NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2489,10 +2507,10 @@ int32_t mergeIntoGroupResult(SQInfo *pQInfo) {
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
int32_t ret = TSDB_CODE_SUCCESS;
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t numOfGroups = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
int32_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
|
||||||
while (pQInfo->groupIndex < numOfGroups) {
|
while (pQInfo->groupIndex < numOfGroups) {
|
||||||
SArray *group = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, pQInfo->groupIndex);
|
SArray *group = GET_TABLEGROUP(pQInfo, pQInfo->groupIndex);
|
||||||
ret = mergeIntoGroupResultImpl(pQInfo, group);
|
ret = mergeIntoGroupResultImpl(pQInfo, group);
|
||||||
if (ret < 0) { // not enough disk space to save the data into disk
|
if (ret < 0) { // not enough disk space to save the data into disk
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2525,7 +2543,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if all results has been sent to client
|
// check if all results has been sent to client
|
||||||
int32_t numOfGroup = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
int32_t numOfGroup = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
if (pQInfo->numOfGroupResultPages == 0 && pQInfo->groupIndex == numOfGroup) {
|
if (pQInfo->numOfGroupResultPages == 0 && pQInfo->groupIndex == numOfGroup) {
|
||||||
pQInfo->tableIndex = pQInfo->tableqinfoGroupInfo.numOfTables; // set query completed
|
pQInfo->tableIndex = pQInfo->tableqinfoGroupInfo.numOfTables; // set query completed
|
||||||
return;
|
return;
|
||||||
|
@ -2859,10 +2877,10 @@ void disableFuncInReverseScan(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfGroups = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
int32_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfGroups; ++i) {
|
for(int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
SArray *group = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, i);
|
SArray *group = GET_TABLEGROUP(pQInfo, i);
|
||||||
|
|
||||||
size_t t = taosArrayGetSize(group);
|
size_t t = taosArrayGetSize(group);
|
||||||
for (int32_t j = 0; j < t; ++j) {
|
for (int32_t j = 0; j < t; ++j) {
|
||||||
|
@ -3252,6 +3270,8 @@ static bool hasMainOutput(SQuery *pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static STableQueryInfo *createTableQueryInfo( SQueryRuntimeEnv *pRuntimeEnv, void* pTable, STimeWindow win) {
|
static STableQueryInfo *createTableQueryInfo( SQueryRuntimeEnv *pRuntimeEnv, void* pTable, STimeWindow win) {
|
||||||
|
SQuery* pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
STableQueryInfo *pTableQueryInfo = calloc(1, sizeof(STableQueryInfo));
|
STableQueryInfo *pTableQueryInfo = calloc(1, sizeof(STableQueryInfo));
|
||||||
|
|
||||||
pTableQueryInfo->win = win;
|
pTableQueryInfo->win = win;
|
||||||
|
@ -3260,7 +3280,15 @@ static STableQueryInfo *createTableQueryInfo( SQueryRuntimeEnv *pRuntimeEnv, voi
|
||||||
pTableQueryInfo->pTable = pTable;
|
pTableQueryInfo->pTable = pTable;
|
||||||
pTableQueryInfo->cur.vgroupIndex = -1;
|
pTableQueryInfo->cur.vgroupIndex = -1;
|
||||||
|
|
||||||
initWindowResInfo(&pTableQueryInfo->windowResInfo, pRuntimeEnv, 100, 100, TSDB_DATA_TYPE_INT);
|
int32_t initialSize = 1;
|
||||||
|
int32_t initialThreshold = 1;
|
||||||
|
|
||||||
|
if (isIntervalQuery(pQuery) || isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
||||||
|
initialSize = 20;
|
||||||
|
initialThreshold = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
initWindowResInfo(&pTableQueryInfo->windowResInfo, pRuntimeEnv, initialSize, initialThreshold, TSDB_DATA_TYPE_INT);
|
||||||
return pTableQueryInfo;
|
return pTableQueryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3273,26 +3301,34 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo, int32_t numOfCols)
|
||||||
free(pTableQueryInfo);
|
free(pTableQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentQueryTable(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *pTableQueryInfo) {
|
#define SET_CURRENT_QUERY_TABLE_INFO(_runtime, _tableInfo) \
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
do { \
|
||||||
pQuery->current = pTableQueryInfo;
|
SQuery *_query = (_runtime)->pQuery; \
|
||||||
|
_query->current = _tableInfo; \
|
||||||
assert(((pTableQueryInfo->lastKey >= pTableQueryInfo->win.skey) && QUERY_IS_ASC_QUERY(pQuery)) ||
|
assert((((_tableInfo)->lastKey >= (_tableInfo)->win.skey) && QUERY_IS_ASC_QUERY(_query)) || \
|
||||||
((pTableQueryInfo->lastKey <= pTableQueryInfo->win.skey) && !QUERY_IS_ASC_QUERY(pQuery)));
|
(((_tableInfo)->lastKey <= (_tableInfo)->win.skey) && !QUERY_IS_ASC_QUERY(_query))); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set output buffer for different group
|
* set output buffer for different group
|
||||||
|
* TODO opt performance if current group is identical to previous group
|
||||||
* @param pRuntimeEnv
|
* @param pRuntimeEnv
|
||||||
* @param pDataBlockInfo
|
* @param pDataBlockInfo
|
||||||
*/
|
*/
|
||||||
void setExecutionContext(SQInfo *pQInfo, void* pTable, int32_t groupIndex, TSKEY nextKey) {
|
void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) {
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->pQuery->current;
|
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->pQuery->current;
|
||||||
|
|
||||||
SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo;
|
||||||
int32_t GROUPRESULTID = 1;
|
|
||||||
|
|
||||||
|
// lastKey needs to be updated
|
||||||
|
pTableQueryInfo->lastKey = nextKey;
|
||||||
|
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
||||||
|
|
||||||
|
if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == groupIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t GROUPRESULTID = 1;
|
||||||
SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, pWindowResInfo, (char *)&groupIndex, sizeof(groupIndex));
|
SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, pWindowResInfo, (char *)&groupIndex, sizeof(groupIndex));
|
||||||
if (pWindowRes == NULL) {
|
if (pWindowRes == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -3309,11 +3345,10 @@ void setExecutionContext(SQInfo *pQInfo, void* pTable, int32_t groupIndex, TSKEY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// record the current active group id
|
||||||
|
pRuntimeEnv->prevGroupId = groupIndex;
|
||||||
setWindowResOutputBuf(pRuntimeEnv, pWindowRes);
|
setWindowResOutputBuf(pRuntimeEnv, pWindowRes);
|
||||||
initCtxOutputBuf(pRuntimeEnv);
|
initCtxOutputBuf(pRuntimeEnv);
|
||||||
|
|
||||||
pTableQueryInfo->lastKey = nextKey;
|
|
||||||
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult) {
|
void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pResult) {
|
||||||
|
@ -3349,7 +3384,7 @@ void setWindowResOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *
|
||||||
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
|
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
|
||||||
|
|
||||||
pCtx->resultInfo = &pResult->resultInfo[i];
|
pCtx->resultInfo = &pResult->resultInfo[i];
|
||||||
if (pCtx->resultInfo->complete) {
|
if (pCtx->resultInfo->initialized && pCtx->resultInfo->complete) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3479,7 +3514,7 @@ static int32_t getNumOfSubset(SQInfo *pQInfo) {
|
||||||
if (isGroupbyNormalCol(pQuery->pGroupbyExpr) || (isIntervalQuery(pQuery))) {
|
if (isGroupbyNormalCol(pQuery->pGroupbyExpr) || (isIntervalQuery(pQuery))) {
|
||||||
totalSubset = numOfClosedTimeWindow(&pQInfo->runtimeEnv.windowResInfo);
|
totalSubset = numOfClosedTimeWindow(&pQInfo->runtimeEnv.windowResInfo);
|
||||||
} else {
|
} else {
|
||||||
totalSubset = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
totalSubset = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalSubset;
|
return totalSubset;
|
||||||
|
@ -3620,25 +3655,20 @@ bool queryHasRemainResults(SQueryRuntimeEnv* pRuntimeEnv) {
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
SFillInfo *pFillInfo = pRuntimeEnv->pFillInfo;
|
SFillInfo *pFillInfo = pRuntimeEnv->pFillInfo;
|
||||||
|
|
||||||
// todo refactor
|
if (pQuery->limit.limit > 0 && pQuery->rec.total >= pQuery->limit.limit) {
|
||||||
if (pQuery->fillType == TSDB_FILL_NONE || (pQuery->fillType != TSDB_FILL_NONE && isPointInterpoQuery(pQuery))) {
|
|
||||||
assert(pFillInfo == NULL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQuery->limit.limit > 0 && pQuery->rec.rows >= pQuery->limit.limit) {
|
if (pQuery->fillType != TSDB_FILL_NONE && !isPointInterpoQuery(pQuery)) {
|
||||||
return false;
|
// There are results not returned to client yet, so filling operation applied to the remain result is required
|
||||||
}
|
// in the first place.
|
||||||
|
|
||||||
// There are results not returned to client, fill operation applied to the remain result set in the
|
|
||||||
// first place is required.
|
|
||||||
int32_t remain = taosNumOfRemainRows(pFillInfo);
|
int32_t remain = taosNumOfRemainRows(pFillInfo);
|
||||||
if (remain > 0) {
|
if (remain > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* While the code reaches here, there are no results returned to client now.
|
* While the code reaches here, there are no results remains now.
|
||||||
* If query is not completed yet, the gaps between two results blocks need to be handled after next data block
|
* If query is not completed yet, the gaps between two results blocks need to be handled after next data block
|
||||||
* is retrieved from TSDB.
|
* is retrieved from TSDB.
|
||||||
*
|
*
|
||||||
|
@ -3651,6 +3681,15 @@ bool queryHasRemainResults(SQueryRuntimeEnv* pRuntimeEnv) {
|
||||||
return numOfTotal > 0;
|
return numOfTotal > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// there are results waiting for returned to client.
|
||||||
|
if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED) &&
|
||||||
|
(isGroupbyNormalCol(pQuery->pGroupbyExpr) || isIntervalQuery(pQuery)) &&
|
||||||
|
(pRuntimeEnv->windowResInfo.size > 0)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3690,7 +3729,7 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int32_t *numOfInterpo) {
|
int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int32_t *numOfFilled) {
|
||||||
SQInfo* pQInfo = GET_QINFO_ADDR(pRuntimeEnv);
|
SQInfo* pQInfo = GET_QINFO_ADDR(pRuntimeEnv);
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
SFillInfo* pFillInfo = pRuntimeEnv->pFillInfo;
|
SFillInfo* pFillInfo = pRuntimeEnv->pFillInfo;
|
||||||
|
@ -3995,7 +4034,7 @@ static void setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) {
|
||||||
&& (!isGroupbyNormalCol(pQuery->pGroupbyExpr))
|
&& (!isGroupbyNormalCol(pQuery->pGroupbyExpr))
|
||||||
&& (!isFixedOutputQuery(pQuery))
|
&& (!isFixedOutputQuery(pQuery))
|
||||||
) {
|
) {
|
||||||
SArray* pa = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, 0);
|
SArray* pa = GET_TABLEGROUP(pQInfo, 0);
|
||||||
STableQueryInfo* pCheckInfo = taosArrayGetP(pa, 0);
|
STableQueryInfo* pCheckInfo = taosArrayGetP(pa, 0);
|
||||||
cond.twindow = pCheckInfo->win;
|
cond.twindow = pCheckInfo->win;
|
||||||
}
|
}
|
||||||
|
@ -4039,7 +4078,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
|
||||||
pQuery->precision = tsdbGetCfg(tsdb)->precision;
|
pQuery->precision = tsdbGetCfg(tsdb)->precision;
|
||||||
|
|
||||||
setScanLimitationByResultBuffer(pQuery);
|
setScanLimitationByResultBuffer(pQuery);
|
||||||
changeExecuteScanOrder(pQuery, false);
|
changeExecuteScanOrder(pQInfo, false);
|
||||||
setupQueryHandle(tsdb, pQInfo, isSTableQuery);
|
setupQueryHandle(tsdb, pQInfo, isSTableQuery);
|
||||||
|
|
||||||
pQInfo->tsdb = tsdb;
|
pQInfo->tsdb = tsdb;
|
||||||
|
@ -4049,6 +4088,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
|
||||||
pRuntimeEnv->pTSBuf = param;
|
pRuntimeEnv->pTSBuf = param;
|
||||||
pRuntimeEnv->cur.vgroupIndex = -1;
|
pRuntimeEnv->cur.vgroupIndex = -1;
|
||||||
pRuntimeEnv->stableQuery = isSTableQuery;
|
pRuntimeEnv->stableQuery = isSTableQuery;
|
||||||
|
pRuntimeEnv->prevGroupId = INT32_MIN;
|
||||||
|
|
||||||
if (param != NULL) {
|
if (param != NULL) {
|
||||||
int16_t order = (pQuery->order.order == pRuntimeEnv->pTSBuf->tsOrder) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
int16_t order = (pQuery->order.order == pRuntimeEnv->pTSBuf->tsOrder) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||||
|
@ -4139,33 +4179,13 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataBlockInfo blockInfo = tsdbRetrieveDataBlockInfo(pQueryHandle);
|
SDataBlockInfo blockInfo = tsdbRetrieveDataBlockInfo(pQueryHandle);
|
||||||
STableQueryInfo *pTableQueryInfo = NULL;
|
STableQueryInfo **pTableQueryInfo = (STableQueryInfo**) taosHashGet(pQInfo->tableqinfoGroupInfo.map, &blockInfo.tid, sizeof(blockInfo.tid));
|
||||||
|
if(pTableQueryInfo == NULL) {
|
||||||
// todo opt performance using hash table
|
|
||||||
size_t numOfGroup = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
|
||||||
for (int32_t i = 0; i < numOfGroup; ++i) {
|
|
||||||
SArray *group = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, i);
|
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(group);
|
|
||||||
for (int32_t j = 0; j < num; ++j) {
|
|
||||||
STableQueryInfo *p = taosArrayGetP(group, j);
|
|
||||||
|
|
||||||
STableId id = tsdbGetTableId(p->pTable);
|
|
||||||
if (id.tid == blockInfo.tid) {
|
|
||||||
assert(id.uid == blockInfo.uid);
|
|
||||||
pTableQueryInfo = p;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pTableQueryInfo != NULL) {
|
assert(*pTableQueryInfo != NULL);
|
||||||
break;
|
SET_CURRENT_QUERY_TABLE_INFO(pRuntimeEnv, *pTableQueryInfo);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(pTableQueryInfo != NULL);
|
|
||||||
setCurrentQueryTable(pRuntimeEnv, pTableQueryInfo);
|
|
||||||
|
|
||||||
SDataStatis *pStatis = NULL;
|
SDataStatis *pStatis = NULL;
|
||||||
SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis);
|
SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis);
|
||||||
|
@ -4173,11 +4193,11 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
|
||||||
if (!isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
if (!isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
|
||||||
if (!isIntervalQuery(pQuery)) {
|
if (!isIntervalQuery(pQuery)) {
|
||||||
int32_t step = QUERY_IS_ASC_QUERY(pQuery)? 1:-1;
|
int32_t step = QUERY_IS_ASC_QUERY(pQuery)? 1:-1;
|
||||||
setExecutionContext(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo->groupIndex, blockInfo.window.ekey + step);
|
setExecutionContext(pQInfo, (*pTableQueryInfo)->groupIndex, blockInfo.window.ekey + step);
|
||||||
} else { // interval query
|
} else { // interval query
|
||||||
TSKEY nextKey = blockInfo.window.skey;
|
TSKEY nextKey = blockInfo.window.skey;
|
||||||
setIntervalQueryRange(pQInfo, nextKey);
|
setIntervalQueryRange(pQInfo, nextKey);
|
||||||
/*int32_t ret = */setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
/*int32_t ret = */setAdditionalInfo(pQInfo, (*pTableQueryInfo)->pTable, *pTableQueryInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4197,7 +4217,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
|
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
|
||||||
SArray *group = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, 0);
|
SArray *group = GET_TABLEGROUP(pQInfo, 0);
|
||||||
STableQueryInfo* pCheckInfo = taosArrayGetP(group, index);
|
STableQueryInfo* pCheckInfo = taosArrayGetP(group, index);
|
||||||
|
|
||||||
setTagVal(pRuntimeEnv, pCheckInfo->pTable, pQInfo->tsdb);
|
setTagVal(pRuntimeEnv, pCheckInfo->pTable, pQInfo->tsdb);
|
||||||
|
@ -4261,7 +4281,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
setQueryStatus(pQuery, QUERY_COMPLETED);
|
setQueryStatus(pQuery, QUERY_COMPLETED);
|
||||||
|
|
||||||
size_t numOfGroups = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
|
||||||
if (isPointInterpoQuery(pQuery) || isFirstLastRowQuery(pQuery)) {
|
if (isPointInterpoQuery(pQuery) || isFirstLastRowQuery(pQuery)) {
|
||||||
resetCtxOutputBuf(pRuntimeEnv);
|
resetCtxOutputBuf(pRuntimeEnv);
|
||||||
|
@ -4311,7 +4331,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
||||||
taosArrayDestroy(s);
|
taosArrayDestroy(s);
|
||||||
|
|
||||||
// here we simply set the first table as current table
|
// here we simply set the first table as current table
|
||||||
pQuery->current = (STableQueryInfo*) taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, 0);
|
pQuery->current = (STableQueryInfo*) GET_TABLEGROUP(pQInfo, 0);
|
||||||
scanOneTableDataBlocks(pRuntimeEnv, pQuery->current->lastKey);
|
scanOneTableDataBlocks(pRuntimeEnv, pQuery->current->lastKey);
|
||||||
|
|
||||||
int64_t numOfRes = getNumOfResult(pRuntimeEnv);
|
int64_t numOfRes = getNumOfResult(pRuntimeEnv);
|
||||||
|
@ -4424,7 +4444,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
||||||
resetCtxOutputBuf(pRuntimeEnv);
|
resetCtxOutputBuf(pRuntimeEnv);
|
||||||
resetTimeWindowInfo(pRuntimeEnv, &pRuntimeEnv->windowResInfo);
|
resetTimeWindowInfo(pRuntimeEnv, &pRuntimeEnv->windowResInfo);
|
||||||
|
|
||||||
SArray *group = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, 0);
|
SArray *group = GET_TABLEGROUP(pQInfo, 0);
|
||||||
assert(taosArrayGetSize(group) == pQInfo->tableqinfoGroupInfo.numOfTables &&
|
assert(taosArrayGetSize(group) == pQInfo->tableqinfoGroupInfo.numOfTables &&
|
||||||
1 == taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList));
|
1 == taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList));
|
||||||
|
|
||||||
|
@ -4550,6 +4570,7 @@ static void doSaveContext(SQInfo *pQInfo) {
|
||||||
tsdbCleanupQueryHandle(pRuntimeEnv->pSecQueryHandle);
|
tsdbCleanupQueryHandle(pRuntimeEnv->pSecQueryHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pRuntimeEnv->prevGroupId = INT32_MIN;
|
||||||
pRuntimeEnv->pSecQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo);
|
pRuntimeEnv->pSecQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo);
|
||||||
|
|
||||||
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
|
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
|
||||||
|
@ -4575,9 +4596,9 @@ static void doCloseAllTimeWindowAfterScan(SQInfo *pQInfo) {
|
||||||
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
|
|
||||||
if (isIntervalQuery(pQuery)) {
|
if (isIntervalQuery(pQuery)) {
|
||||||
size_t numOfGroup = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
for (int32_t i = 0; i < numOfGroup; ++i) {
|
for (int32_t i = 0; i < numOfGroup; ++i) {
|
||||||
SArray *group = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, i);
|
SArray *group = GET_TABLEGROUP(pQInfo, i);
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(group);
|
size_t num = taosArrayGetSize(group);
|
||||||
for (int32_t j = 0; j < num; ++j) {
|
for (int32_t j = 0; j < num; ++j) {
|
||||||
|
@ -4794,7 +4815,7 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
pQuery->current = pTableInfo;
|
pQuery->current = pTableInfo;
|
||||||
|
|
||||||
int32_t numOfInterpo = 0;
|
int32_t numOfFilled = 0;
|
||||||
TSKEY newStartKey = TSKEY_INITIAL_VAL;
|
TSKEY newStartKey = TSKEY_INITIAL_VAL;
|
||||||
|
|
||||||
// skip blocks without load the actual data block from file if no filter condition present
|
// skip blocks without load the actual data block from file if no filter condition present
|
||||||
|
@ -4822,9 +4843,9 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
|
||||||
} else {
|
} else {
|
||||||
taosFillSetStartInfo(pRuntimeEnv->pFillInfo, pQuery->rec.rows, pQuery->window.ekey);
|
taosFillSetStartInfo(pRuntimeEnv->pFillInfo, pQuery->rec.rows, pQuery->window.ekey);
|
||||||
taosFillCopyInputDataFromFilePage(pRuntimeEnv->pFillInfo, (tFilePage**) pQuery->sdata);
|
taosFillCopyInputDataFromFilePage(pRuntimeEnv->pFillInfo, (tFilePage**) pQuery->sdata);
|
||||||
numOfInterpo = 0;
|
numOfFilled = 0;
|
||||||
|
|
||||||
pQuery->rec.rows = doFillGapsInResults(pRuntimeEnv, (tFilePage **)pQuery->sdata, &numOfInterpo);
|
pQuery->rec.rows = doFillGapsInResults(pRuntimeEnv, (tFilePage **)pQuery->sdata, &numOfFilled);
|
||||||
if (pQuery->rec.rows > 0 || Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
|
if (pQuery->rec.rows > 0 || Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
|
||||||
limitResults(pRuntimeEnv);
|
limitResults(pRuntimeEnv);
|
||||||
break;
|
break;
|
||||||
|
@ -4843,7 +4864,7 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
|
||||||
clearFirstNTimeWindow(pRuntimeEnv, pQInfo->groupIndex);
|
clearFirstNTimeWindow(pRuntimeEnv, pQInfo->groupIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
pQInfo->pointsInterpo += numOfInterpo;
|
pQInfo->pointsInterpo += numOfFilled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tableQueryImpl(SQInfo *pQInfo) {
|
static void tableQueryImpl(SQInfo *pQInfo) {
|
||||||
|
@ -4851,12 +4872,14 @@ static void tableQueryImpl(SQInfo *pQInfo) {
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
if (queryHasRemainResults(pRuntimeEnv)) {
|
if (queryHasRemainResults(pRuntimeEnv)) {
|
||||||
|
|
||||||
|
if (pQuery->fillType != TSDB_FILL_NONE) {
|
||||||
/*
|
/*
|
||||||
* There are remain results that are not returned due to result interpolation
|
* There are remain results that are not returned due to result interpolation
|
||||||
* So, we do keep in this procedure instead of launching retrieve procedure for next results.
|
* So, we do keep in this procedure instead of launching retrieve procedure for next results.
|
||||||
*/
|
*/
|
||||||
int32_t numOfInterpo = 0;
|
int32_t numOfFilled = 0;
|
||||||
pQuery->rec.rows = doFillGapsInResults(pRuntimeEnv, (tFilePage **)pQuery->sdata, &numOfInterpo);
|
pQuery->rec.rows = doFillGapsInResults(pRuntimeEnv, (tFilePage **)pQuery->sdata, &numOfFilled);
|
||||||
|
|
||||||
if (pQuery->rec.rows > 0) {
|
if (pQuery->rec.rows > 0) {
|
||||||
limitResults(pRuntimeEnv);
|
limitResults(pRuntimeEnv);
|
||||||
|
@ -4864,40 +4887,34 @@ static void tableQueryImpl(SQInfo *pQInfo) {
|
||||||
|
|
||||||
qDebug("QInfo:%p current:%" PRId64 " returned, total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total);
|
qDebug("QInfo:%p current:%" PRId64 " returned, total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// here we have scan all qualified data in both data file and cache
|
|
||||||
if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
|
|
||||||
// continue to get push data from the group result
|
|
||||||
if (isGroupbyNormalCol(pQuery->pGroupbyExpr) ||
|
|
||||||
((isIntervalQuery(pQuery) && pQuery->rec.total < pQuery->limit.limit))) {
|
|
||||||
// todo limit the output for interval query?
|
|
||||||
pQuery->rec.rows = 0;
|
pQuery->rec.rows = 0;
|
||||||
pQInfo->groupIndex = 0; // always start from 0
|
pQInfo->groupIndex = 0; // always start from 0
|
||||||
|
|
||||||
if (pRuntimeEnv->windowResInfo.size > 0) {
|
if (pRuntimeEnv->windowResInfo.size > 0) {
|
||||||
copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult);
|
copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult);
|
||||||
pQuery->rec.rows += pQuery->rec.rows;
|
|
||||||
|
|
||||||
clearFirstNTimeWindow(pRuntimeEnv, pQInfo->groupIndex);
|
clearFirstNTimeWindow(pRuntimeEnv, pQInfo->groupIndex);
|
||||||
|
|
||||||
if (pQuery->rec.rows > 0) {
|
if (pQuery->rec.rows > 0) {
|
||||||
qDebug("QInfo:%p %"PRId64" rows returned from group results, total:%"PRId64"", pQInfo, pQuery->rec.rows, pQuery->rec.total);
|
qDebug("QInfo:%p %"PRId64" rows returned from group results, total:%"PRId64"", pQInfo, pQuery->rec.rows, pQuery->rec.total);
|
||||||
return;
|
|
||||||
}
|
// there are not data remains
|
||||||
}
|
if (pRuntimeEnv->windowResInfo.size <= 0) {
|
||||||
|
qDebug("QInfo:%p query over, %"PRId64" rows are returned", pQInfo, pQuery->rec.total);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("QInfo:%p query over, %"PRId64" rows are returned", pQInfo, pQuery->rec.total);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// number of points returned during this query
|
// number of points returned during this query
|
||||||
pQuery->rec.rows = 0;
|
pQuery->rec.rows = 0;
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
assert(pQInfo->tableqinfoGroupInfo.numOfTables == 1);
|
assert(pQInfo->tableqinfoGroupInfo.numOfTables == 1);
|
||||||
SArray* g = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, 0);
|
SArray* g = GET_TABLEGROUP(pQInfo, 0);
|
||||||
STableQueryInfo* item = taosArrayGetP(g, 0);
|
STableQueryInfo* item = taosArrayGetP(g, 0);
|
||||||
|
|
||||||
// group by normal column, sliding window query, interval query are handled by interval query processor
|
// group by normal column, sliding window query, interval query are handled by interval query processor
|
||||||
|
@ -5609,6 +5626,8 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
|
|
||||||
pQInfo->tableqinfoGroupInfo.pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
|
pQInfo->tableqinfoGroupInfo.pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
|
||||||
pQInfo->tableqinfoGroupInfo.numOfTables = pTableGroupInfo->numOfTables;
|
pQInfo->tableqinfoGroupInfo.numOfTables = pTableGroupInfo->numOfTables;
|
||||||
|
pQInfo->tableqinfoGroupInfo.map = taosHashInit(pTableGroupInfo->numOfTables,
|
||||||
|
taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tableIndex = 0;
|
int tableIndex = 0;
|
||||||
|
@ -5637,6 +5656,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
item->groupIndex = i;
|
item->groupIndex = i;
|
||||||
item->tableIndex = tableIndex++;
|
item->tableIndex = tableIndex++;
|
||||||
taosArrayPush(p1, &item);
|
taosArrayPush(p1, &item);
|
||||||
|
taosHashPut(pQInfo->tableqinfoGroupInfo.map, &id.tid, sizeof(id.tid), &item, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pQInfo->tableqinfoGroupInfo.pGroupList, &p1);
|
taosArrayPush(pQInfo->tableqinfoGroupInfo.pGroupList, &p1);
|
||||||
|
@ -5658,26 +5678,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
return pQInfo;
|
return pQInfo;
|
||||||
|
|
||||||
_cleanup:
|
_cleanup:
|
||||||
//tfree(pQuery->fillVal);
|
|
||||||
|
|
||||||
//if (pQuery->sdata != NULL) {
|
|
||||||
// for (int16_t col = 0; col < pQuery->numOfOutput; ++col) {
|
|
||||||
// tfree(pQuery->sdata[col]);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
//tfree(pQuery->sdata);
|
|
||||||
//tfree(pQuery->pFilterInfo);
|
|
||||||
//tfree(pQuery->colList);
|
|
||||||
|
|
||||||
//tfree(pExprs);
|
|
||||||
//tfree(pGroupbyExpr);
|
|
||||||
|
|
||||||
//taosArrayDestroy(pQInfo->arrTableIdInfo);
|
|
||||||
//tsdbDestoryTableGroup(&pQInfo->tableGroupInfo);
|
|
||||||
//
|
|
||||||
//tfree(pQInfo);
|
|
||||||
freeQInfo(pQInfo);
|
freeQInfo(pQInfo);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -5712,7 +5712,6 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only the successful complete requries the sem_post/over = 1 operations.
|
|
||||||
if ((QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.skey > pQuery->window.ekey)) ||
|
if ((QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.skey > pQuery->window.ekey)) ||
|
||||||
(!QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.ekey > pQuery->window.skey))) {
|
(!QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.ekey > pQuery->window.skey))) {
|
||||||
qDebug("QInfo:%p no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo, pQuery->window.skey,
|
qDebug("QInfo:%p no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo, pQuery->window.skey,
|
||||||
|
@ -5784,9 +5783,9 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor, extract method to destroytableDataInfo
|
// todo refactor, extract method to destroytableDataInfo
|
||||||
int32_t numOfGroups = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
int32_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
for (int32_t i = 0; i < numOfGroups; ++i) {
|
for (int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
SArray *p = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, i);
|
SArray *p = GET_TABLEGROUP(pQInfo, i);;
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(p);
|
size_t num = taosArrayGetSize(p);
|
||||||
for(int32_t j = 0; j < num; ++j) {
|
for(int32_t j = 0; j < num; ++j) {
|
||||||
|
@ -5800,7 +5799,7 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pQInfo->tableqinfoGroupInfo.pGroupList);
|
taosArrayDestroy(pQInfo->tableqinfoGroupInfo.pGroupList);
|
||||||
|
taosHashCleanup(pQInfo->tableqinfoGroupInfo.map);
|
||||||
tsdbDestoryTableGroup(&pQInfo->tableGroupInfo);
|
tsdbDestoryTableGroup(&pQInfo->tableGroupInfo);
|
||||||
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
||||||
|
|
||||||
|
@ -5910,7 +5909,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
|
||||||
|
|
||||||
if ((code = convertQueryMsg(pQueryMsg, &pTableIdList, &pExprMsg, &tagCond, &tbnameCond, &pGroupColIndex, &pTagColumnInfo)) !=
|
if ((code = convertQueryMsg(pQueryMsg, &pTableIdList, &pExprMsg, &tagCond, &tbnameCond, &pGroupColIndex, &pTagColumnInfo)) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryMsg->numOfTables <= 0) {
|
if (pQueryMsg->numOfTables <= 0) {
|
||||||
|
@ -6027,7 +6026,7 @@ void qDestroyQueryInfo(qinfo_t qHandle, void (*fp)(void*), void* param) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t ref = T_REF_DEC(pQInfo);
|
int32_t ref = T_REF_DEC(pQInfo);
|
||||||
qDebug("QInfo:%p dec refCount, value:%d", pQInfo, ref);
|
qDebug("QInfo:%p dec refCount, value:%d", pQInfo, ref);
|
||||||
|
|
||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
|
@ -6053,6 +6052,11 @@ void qTableQuery(qinfo_t qinfo, void (*fp)(void*), void* param) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pQInfo->tableqinfoGroupInfo.numOfTables == 0) {
|
||||||
|
qDebug("QInfo:%p no table exists for query, abort", pQInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug("QInfo:%p query task is launched", pQInfo);
|
qDebug("QInfo:%p query task is launched", pQInfo);
|
||||||
|
|
||||||
if (onlyQueryTags(pQInfo->runtimeEnv.pQuery)) {
|
if (onlyQueryTags(pQInfo->runtimeEnv.pQuery)) {
|
||||||
|
@ -6175,14 +6179,14 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
size_t numOfGroup = taosArrayGetSize(pQInfo->tableqinfoGroupInfo.pGroupList);
|
size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
assert(numOfGroup == 0 || numOfGroup == 1);
|
assert(numOfGroup == 0 || numOfGroup == 1);
|
||||||
|
|
||||||
if (numOfGroup == 0) {
|
if (numOfGroup == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pa = taosArrayGetP(pQInfo->tableqinfoGroupInfo.pGroupList, 0);
|
SArray* pa = GET_TABLEGROUP(pQInfo, 0);
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(pa);
|
size_t num = taosArrayGetSize(pa);
|
||||||
assert(num == pQInfo->tableqinfoGroupInfo.numOfTables);
|
assert(num == pQInfo->tableqinfoGroupInfo.numOfTables);
|
||||||
|
|
|
@ -133,7 +133,6 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pWindowResInfo->size = remain;
|
pWindowResInfo->size = remain;
|
||||||
printf("---------------size:%ld\n", taosHashGetSize(pWindowResInfo->hashList));
|
|
||||||
for (int32_t k = 0; k < pWindowResInfo->size; ++k) {
|
for (int32_t k = 0; k < pWindowResInfo->size; ++k) {
|
||||||
SWindowResult *pResult = &pWindowResInfo->pResult[k];
|
SWindowResult *pResult = &pWindowResInfo->pResult[k];
|
||||||
int32_t *p = (int32_t *)taosHashGet(pWindowResInfo->hashList, (const char *)&pResult->window.skey,
|
int32_t *p = (int32_t *)taosHashGet(pWindowResInfo->hashList, (const char *)&pResult->window.skey,
|
||||||
|
|
|
@ -209,8 +209,7 @@ int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FILL_IS_ASC_FILL(pFillInfo) ? (pFillInfo->numOfRows - pFillInfo->rowIdx)
|
return FILL_IS_ASC_FILL(pFillInfo) ? (pFillInfo->numOfRows - pFillInfo->rowIdx) : pFillInfo->rowIdx + 1;
|
||||||
: pFillInfo->rowIdx + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: refactor
|
// todo: refactor
|
||||||
|
|
|
@ -631,5 +631,5 @@ void exprSerializeTest2() {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
TEST(testCase, astTest) {
|
TEST(testCase, astTest) {
|
||||||
exprSerializeTest2();
|
// exprSerializeTest2();
|
||||||
}
|
}
|
|
@ -665,6 +665,12 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
|
||||||
return pConn;
|
return pConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if code is not 0, it means it is simple reqhead, just ignore
|
||||||
|
if (pHead->code != 0) {
|
||||||
|
terrno = TSDB_CODE_RPC_ALREADY_PROCESSED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int sid = taosAllocateId(pRpc->idPool);
|
int sid = taosAllocateId(pRpc->idPool);
|
||||||
if (sid <= 0) {
|
if (sid <= 0) {
|
||||||
tError("%s maximum number of sessions:%d is reached", pRpc->label, pRpc->sessions);
|
tError("%s maximum number of sessions:%d is reached", pRpc->label, pRpc->sessions);
|
||||||
|
@ -1028,6 +1034,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
||||||
rpcMsg.ahandle = pConn->ahandle;
|
rpcMsg.ahandle = pConn->ahandle;
|
||||||
|
|
||||||
if ( rpcIsReq(pHead->msgType) ) {
|
if ( rpcIsReq(pHead->msgType) ) {
|
||||||
|
if (rpcMsg.contLen > 0) {
|
||||||
rpcMsg.handle = pConn;
|
rpcMsg.handle = pConn;
|
||||||
rpcAddRef(pRpc); // add the refCount for requests
|
rpcAddRef(pRpc); // add the refCount for requests
|
||||||
|
|
||||||
|
@ -1037,6 +1044,10 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
||||||
|
|
||||||
// notify the server app
|
// notify the server app
|
||||||
(*(pRpc->cfp))(&rpcMsg, NULL);
|
(*(pRpc->cfp))(&rpcMsg, NULL);
|
||||||
|
} else {
|
||||||
|
tDebug("%s, message body is empty, ignore", pConn->info);
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// it's a response
|
// it's a response
|
||||||
SRpcReqContext *pContext = pConn->pContext;
|
SRpcReqContext *pContext = pConn->pContext;
|
||||||
|
|
|
@ -419,7 +419,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
|
||||||
tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen);
|
tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// tDebug("malloc mem: %p", buffer);
|
tDebug("TCP malloc mem: %p", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = buffer + tsRpcOverhead;
|
msg = buffer + tsRpcOverhead;
|
||||||
|
|
|
@ -212,7 +212,7 @@ static void *taosRecvUdpData(void *param) {
|
||||||
tError("%s failed to allocate memory, size:%ld", pConn->label, dataLen);
|
tError("%s failed to allocate memory, size:%ld", pConn->label, dataLen);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// tTrace("malloc mem: %p", tmsg);
|
tDebug("UDP malloc mem: %p", tmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmsg += tsRpcOverhead; // overhead for SRpcReqContext
|
tmsg += tsRpcOverhead; // overhead for SRpcReqContext
|
||||||
|
|
|
@ -383,8 +383,8 @@ int tsdbLoadCompIdx(SRWHelper* pHelper, void* target);
|
||||||
int tsdbLoadCompInfo(SRWHelper* pHelper, void* target);
|
int tsdbLoadCompInfo(SRWHelper* pHelper, void* target);
|
||||||
int tsdbLoadCompData(SRWHelper* phelper, SCompBlock* pcompblock, void* target);
|
int tsdbLoadCompData(SRWHelper* phelper, SCompBlock* pcompblock, void* target);
|
||||||
void tsdbGetDataStatis(SRWHelper* pHelper, SDataStatis* pStatis, int numOfCols);
|
void tsdbGetDataStatis(SRWHelper* pHelper, SDataStatis* pStatis, int numOfCols);
|
||||||
int tsdbLoadBlockDataCols(SRWHelper* pHelper, SDataCols* pDataCols, int blkIdx, int16_t* colIds, int numOfColIds);
|
int tsdbLoadBlockDataCols(SRWHelper* pHelper, SCompBlock* pCompBlock, int16_t* colIds, int numOfColIds);
|
||||||
int tsdbLoadBlockData(SRWHelper* pHelper, SCompBlock* pCompBlock, SDataCols* target);
|
int tsdbLoadBlockData(SRWHelper* pHelper, SCompBlock* pCompBlock);
|
||||||
|
|
||||||
// ------------------ tsdbMain.c
|
// ------------------ tsdbMain.c
|
||||||
#define REPO_ID(r) (r)->config.tsdbId
|
#define REPO_ID(r) (r)->config.tsdbId
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
const char *tsdbFileSuffix[] = {".head", ".data", ".last", "", ".h", ".h"};
|
const char *tsdbFileSuffix[] = {".head", ".data", ".last", "", ".h", ".l"};
|
||||||
|
|
||||||
static int tsdbInitFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type);
|
static int tsdbInitFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type);
|
||||||
static void tsdbDestroyFile(SFile *pFile);
|
static void tsdbDestroyFile(SFile *pFile);
|
||||||
|
|
|
@ -768,7 +768,8 @@ static SSubmitBlk *tsdbGetSubmitMsgNext(SSubmitMsgIter *pIter) {
|
||||||
SSubmitBlk *pBlock = pIter->pBlock;
|
SSubmitBlk *pBlock = pIter->pBlock;
|
||||||
if (pBlock == NULL) return NULL;
|
if (pBlock == NULL) return NULL;
|
||||||
|
|
||||||
pBlock->len = htonl(pBlock->len);
|
pBlock->dataLen = htonl(pBlock->dataLen);
|
||||||
|
pBlock->schemaLen = htonl(pBlock->schemaLen);
|
||||||
pBlock->numOfRows = htons(pBlock->numOfRows);
|
pBlock->numOfRows = htons(pBlock->numOfRows);
|
||||||
pBlock->uid = htobe64(pBlock->uid);
|
pBlock->uid = htobe64(pBlock->uid);
|
||||||
pBlock->tid = htonl(pBlock->tid);
|
pBlock->tid = htonl(pBlock->tid);
|
||||||
|
@ -776,11 +777,11 @@ static SSubmitBlk *tsdbGetSubmitMsgNext(SSubmitMsgIter *pIter) {
|
||||||
pBlock->sversion = htonl(pBlock->sversion);
|
pBlock->sversion = htonl(pBlock->sversion);
|
||||||
pBlock->padding = htonl(pBlock->padding);
|
pBlock->padding = htonl(pBlock->padding);
|
||||||
|
|
||||||
pIter->len = pIter->len + sizeof(SSubmitBlk) + pBlock->len;
|
pIter->len = pIter->len + sizeof(SSubmitBlk) + pBlock->dataLen;
|
||||||
if (pIter->len >= pIter->totalLen) {
|
if (pIter->len >= pIter->totalLen) {
|
||||||
pIter->pBlock = NULL;
|
pIter->pBlock = NULL;
|
||||||
} else {
|
} else {
|
||||||
pIter->pBlock = (SSubmitBlk *)((char *)pBlock + pBlock->len + sizeof(SSubmitBlk));
|
pIter->pBlock = (SSubmitBlk *)((char *)pBlock + pBlock->dataLen + sizeof(SSubmitBlk));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBlock;
|
return pBlock;
|
||||||
|
@ -832,10 +833,10 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
|
static int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
|
||||||
if (pBlock->len <= 0) return -1;
|
if (pBlock->dataLen <= 0) return -1;
|
||||||
pIter->totalLen = pBlock->len;
|
pIter->totalLen = pBlock->dataLen;
|
||||||
pIter->len = 0;
|
pIter->len = 0;
|
||||||
pIter->row = (SDataRow)(pBlock->data);
|
pIter->row = (SDataRow)(pBlock->data+pBlock->schemaLen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
|
||||||
ASSERT(pTableData->numOfRows == tSkipListGetSize(pTableData->pData));
|
ASSERT(pTableData->numOfRows == tSkipListGetSize(pTableData->pData));
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
|
tsdbTrace("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
|
||||||
TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), key);
|
TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), key);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -443,12 +443,14 @@ static int tsdbCommitMeta(STsdbRepo *pRepo) {
|
||||||
if (tdUpdateKVStoreRecord(pMeta->pStore, pAct->uid, (void *)(pCont->cont), pCont->len) < 0) {
|
if (tdUpdateKVStoreRecord(pMeta->pStore, pAct->uid, (void *)(pCont->cont), pCont->len) < 0) {
|
||||||
tsdbError("vgId:%d failed to update meta with uid %" PRIu64 " since %s", REPO_ID(pRepo), pAct->uid,
|
tsdbError("vgId:%d failed to update meta with uid %" PRIu64 " since %s", REPO_ID(pRepo), pAct->uid,
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
|
tdKVStoreEndCommit(pMeta->pStore);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
} else if (pAct->act == TSDB_DROP_META) {
|
} else if (pAct->act == TSDB_DROP_META) {
|
||||||
if (tdDropKVStoreRecord(pMeta->pStore, pAct->uid) < 0) {
|
if (tdDropKVStoreRecord(pMeta->pStore, pAct->uid) < 0) {
|
||||||
tsdbError("vgId:%d failed to drop meta with uid %" PRIu64 " since %s", REPO_ID(pRepo), pAct->uid,
|
tsdbError("vgId:%d failed to drop meta with uid %" PRIu64 " since %s", REPO_ID(pRepo), pAct->uid,
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
|
tdKVStoreEndCommit(pMeta->pStore);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -480,14 +480,12 @@ int tsdbUpdateTable(STsdbRepo *pRepo, STable *pTable, STableCfg *pCfg) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
STsdbMeta *pMeta = pRepo->tsdbMeta;
|
STsdbMeta *pMeta = pRepo->tsdbMeta;
|
||||||
|
|
||||||
if (pTable->type == TSDB_SUPER_TABLE) {
|
if ((pTable->type == TSDB_SUPER_TABLE) && (schemaVersion(pTable->tagSchema) < schemaVersion(pCfg->tagSchema))) {
|
||||||
if (schemaVersion(pTable->tagSchema) < schemaVersion(pCfg->tagSchema)) {
|
|
||||||
if (tsdbUpdateTableTagSchema(pTable, pCfg->tagSchema) < 0) {
|
if (tsdbUpdateTableTagSchema(pTable, pCfg->tagSchema) < 0) {
|
||||||
tsdbError("vgId:%d failed to update table %s tag schema since %s", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
tsdbError("vgId:%d failed to update table %s tag schema since %s", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,13 +550,13 @@ int tsdbUnlockRepoMeta(STsdbRepo *pRepo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbRefTable(STable *pTable) {
|
void tsdbRefTable(STable *pTable) {
|
||||||
int16_t ref = T_REF_INC(pTable);
|
int32_t ref = T_REF_INC(pTable);
|
||||||
UNUSED(ref);
|
UNUSED(ref);
|
||||||
// tsdbDebug("ref table %"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
// tsdbDebug("ref table %"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbUnRefTable(STable *pTable) {
|
void tsdbUnRefTable(STable *pTable) {
|
||||||
int16_t ref = T_REF_DEC(pTable);
|
int32_t ref = T_REF_DEC(pTable);
|
||||||
tsdbDebug("unref table uid:%"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
tsdbDebug("unref table uid:%"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
||||||
|
|
||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
|
@ -598,7 +596,7 @@ static int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is restored from file", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is restored from file", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
||||||
TABLE_TID(pTable), TABLE_UID(pTable));
|
TABLE_TID(pTable), TABLE_UID(pTable));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -799,7 +797,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx) {
|
||||||
pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, TABLE_UID(pTable), TABLE_TID(pTable), pTable->sql, tsdbGetTableSchema(pTable));
|
pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, TABLE_UID(pTable), TABLE_TID(pTable), pTable->sql, tsdbGetTableSchema(pTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
||||||
TABLE_TID(pTable), TABLE_UID(pTable));
|
TABLE_TID(pTable), TABLE_UID(pTable));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1215,7 +1213,7 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
|
||||||
while (tSkipListIterNext(pIter)) {
|
while (tSkipListIterNext(pIter)) {
|
||||||
STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
|
STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
|
||||||
ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE);
|
ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE);
|
||||||
pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, pTable);
|
pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, tTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
tSkipListDestroyIter(pIter);
|
tSkipListDestroyIter(pIter);
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
#include "tsdbMain.h"
|
#include "tsdbMain.h"
|
||||||
|
|
||||||
|
#define TSDB_GET_COMPCOL_LEN(nCols) (sizeof(SCompData) + sizeof(SCompCol) * (nCols) + sizeof(TSCKSUM))
|
||||||
|
|
||||||
static bool tsdbShouldCreateNewLast(SRWHelper *pHelper);
|
static bool tsdbShouldCreateNewLast(SRWHelper *pHelper);
|
||||||
static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDataCols, int rowsToWrite,
|
static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDataCols, int rowsToWrite,
|
||||||
SCompBlock *pCompBlock, bool isLast, bool isSuperBlock);
|
SCompBlock *pCompBlock, bool isLast, bool isSuperBlock);
|
||||||
|
@ -42,17 +44,16 @@ static void tsdbResetHelperBlockImpl(SRWHelper *pHelper);
|
||||||
static void tsdbResetHelperBlock(SRWHelper *pHelper);
|
static void tsdbResetHelperBlock(SRWHelper *pHelper);
|
||||||
static int tsdbInitHelperBlock(SRWHelper *pHelper);
|
static int tsdbInitHelperBlock(SRWHelper *pHelper);
|
||||||
static int tsdbInitHelper(SRWHelper *pHelper, STsdbRepo *pRepo, tsdb_rw_helper_t type);
|
static int tsdbInitHelper(SRWHelper *pHelper, STsdbRepo *pRepo, tsdb_rw_helper_t type);
|
||||||
static int comparColIdCompCol(const void *arg1, const void *arg2);
|
|
||||||
static int comparColIdDataCol(const void *arg1, const void *arg2);
|
|
||||||
static int tsdbLoadSingleColumnData(int fd, SCompBlock *pCompBlock, SCompCol *pCompCol, void *buf);
|
|
||||||
static int tsdbLoadSingleBlockDataCols(SRWHelper *pHelper, SCompBlock *pCompBlock, int16_t *colIds, int numOfColIds,
|
|
||||||
SDataCols *pDataCols);
|
|
||||||
static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32_t len, int8_t comp, int numOfRows,
|
static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32_t len, int8_t comp, int numOfRows,
|
||||||
int maxPoints, char *buffer, int bufferSize);
|
int maxPoints, char *buffer, int bufferSize);
|
||||||
|
static int tsdbLoadBlockDataColsImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *pDataCols, int16_t *colIds,
|
||||||
|
int numOfColIds);
|
||||||
static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *pDataCols);
|
static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *pDataCols);
|
||||||
static int tsdbEncodeSCompIdx(void **buf, SCompIdx *pIdx);
|
static int tsdbEncodeSCompIdx(void **buf, SCompIdx *pIdx);
|
||||||
static void *tsdbDecodeSCompIdx(void *buf, SCompIdx *pIdx);
|
static void *tsdbDecodeSCompIdx(void *buf, SCompIdx *pIdx);
|
||||||
static void tsdbDestroyHelperBlock(SRWHelper *pHelper);
|
static void tsdbDestroyHelperBlock(SRWHelper *pHelper);
|
||||||
|
static int tsdbLoadColData(SRWHelper *pHelper, SFile *pFile, SCompBlock *pCompBlock, SCompCol *pCompCol,
|
||||||
|
SDataCol *pDataCol);
|
||||||
|
|
||||||
// ---------------------- INTERNAL FUNCTIONS ----------------------
|
// ---------------------- INTERNAL FUNCTIONS ----------------------
|
||||||
int tsdbInitReadHelper(SRWHelper *pHelper, STsdbRepo *pRepo) {
|
int tsdbInitReadHelper(SRWHelper *pHelper, STsdbRepo *pRepo) {
|
||||||
|
@ -120,19 +121,20 @@ int tsdbSetAndOpenHelperFile(SRWHelper *pHelper, SFileGroup *pGroup) {
|
||||||
if (tsendfile(pHelper->files.nHeadF.fd, pHelper->files.headF.fd, NULL, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE) {
|
if (tsendfile(pHelper->files.nHeadF.fd, pHelper->files.headF.fd, NULL, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE) {
|
||||||
tsdbError("vgId:%d failed to sendfile %d bytes from file %s to %s since %s", REPO_ID(pHelper->pRepo),
|
tsdbError("vgId:%d failed to sendfile %d bytes from file %s to %s since %s", REPO_ID(pHelper->pRepo),
|
||||||
TSDB_FILE_HEAD_SIZE, pHelper->files.headF.fname, pHelper->files.nHeadF.fname, strerror(errno));
|
TSDB_FILE_HEAD_SIZE, pHelper->files.headF.fname, pHelper->files.nHeadF.fname, strerror(errno));
|
||||||
errno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and open .l file if should
|
// Create and open .l file if should
|
||||||
if (tsdbShouldCreateNewLast(pHelper)) {
|
if (tsdbShouldCreateNewLast(pHelper)) {
|
||||||
if (tsdbOpenFile(&(pHelper->files.nLastF), O_WRONLY | O_CREAT) < 0) goto _err;
|
if (tsdbOpenFile(&(pHelper->files.nLastF), O_WRONLY | O_CREAT) < 0) goto _err;
|
||||||
if (tsendfile(pHelper->files.nLastF.fd, pHelper->files.lastF.fd, NULL, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE)
|
if (tsendfile(pHelper->files.nLastF.fd, pHelper->files.lastF.fd, NULL, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE) {
|
||||||
tsdbError("vgId:%d failed to sendfile %d bytes from file %s to %s since %s", REPO_ID(pHelper->pRepo),
|
tsdbError("vgId:%d failed to sendfile %d bytes from file %s to %s since %s", REPO_ID(pHelper->pRepo),
|
||||||
TSDB_FILE_HEAD_SIZE, pHelper->files.lastF.fname, pHelper->files.nLastF.fname, strerror(errno));
|
TSDB_FILE_HEAD_SIZE, pHelper->files.lastF.fname, pHelper->files.nLastF.fname, strerror(errno));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tsdbOpenFile(&(pHelper->files.dataF), O_RDONLY) < 0) goto _err;
|
if (tsdbOpenFile(&(pHelper->files.dataF), O_RDONLY) < 0) goto _err;
|
||||||
if (tsdbOpenFile(&(pHelper->files.lastF), O_RDONLY) < 0) goto _err;
|
if (tsdbOpenFile(&(pHelper->files.lastF), O_RDONLY) < 0) goto _err;
|
||||||
|
@ -162,8 +164,8 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
|
||||||
if (pHelper->files.lastF.fd > 0) {
|
if (pHelper->files.lastF.fd > 0) {
|
||||||
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
||||||
fsync(pHelper->files.lastF.fd);
|
fsync(pHelper->files.lastF.fd);
|
||||||
close(pHelper->files.lastF.fd);
|
|
||||||
}
|
}
|
||||||
|
close(pHelper->files.lastF.fd);
|
||||||
pHelper->files.lastF.fd = -1;
|
pHelper->files.lastF.fd = -1;
|
||||||
}
|
}
|
||||||
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
if (helperType(pHelper) == TSDB_WRITE_HELPER) {
|
||||||
|
@ -315,7 +317,7 @@ int tsdbMoveLastBlockIfNeccessary(SRWHelper *pHelper) {
|
||||||
ASSERT(pCompBlock->last);
|
ASSERT(pCompBlock->last);
|
||||||
|
|
||||||
if (pCompBlock->numOfSubBlocks > 1) {
|
if (pCompBlock->numOfSubBlocks > 1) {
|
||||||
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, pIdx->numOfBlocks - 1), NULL) < 0) return -1;
|
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, pIdx->numOfBlocks - 1)) < 0) return -1;
|
||||||
ASSERT(pHelper->pDataCols[0]->numOfRows > 0 && pHelper->pDataCols[0]->numOfRows < pCfg->minRowsPerFileBlock);
|
ASSERT(pHelper->pDataCols[0]->numOfRows > 0 && pHelper->pDataCols[0]->numOfRows < pCfg->minRowsPerFileBlock);
|
||||||
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.nLastF), pHelper->pDataCols[0],
|
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.nLastF), pHelper->pDataCols[0],
|
||||||
pHelper->pDataCols[0]->numOfRows, &compBlock, true, true) < 0)
|
pHelper->pDataCols[0]->numOfRows, &compBlock, true, true) < 0)
|
||||||
|
@ -510,14 +512,34 @@ int tsdbLoadCompInfo(SRWHelper *pHelper, void *target) {
|
||||||
|
|
||||||
int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target) {
|
int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target) {
|
||||||
ASSERT(pCompBlock->numOfSubBlocks <= 1);
|
ASSERT(pCompBlock->numOfSubBlocks <= 1);
|
||||||
int fd = (pCompBlock->last) ? pHelper->files.lastF.fd : pHelper->files.dataF.fd;
|
SFile *pFile = (pCompBlock->last) ? &(pHelper->files.lastF) : &(pHelper->files.dataF);
|
||||||
|
|
||||||
if (lseek(fd, pCompBlock->offset, SEEK_SET) < 0) return -1;
|
if (lseek(pFile->fd, pCompBlock->offset, SEEK_SET) < 0) {
|
||||||
|
tsdbError("vgId:%d failed to lseek file %s since %s", REPO_ID(pHelper->pRepo), pFile->fname, strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
size_t tsize = sizeof(SCompData) + sizeof(SCompCol) * pCompBlock->numOfCols + sizeof(TSCKSUM);
|
size_t tsize = TSDB_GET_COMPCOL_LEN(pCompBlock->numOfCols);
|
||||||
pHelper->pCompData = trealloc((void *)pHelper->pCompData, tsize);
|
pHelper->pCompData = trealloc((void *)pHelper->pCompData, tsize);
|
||||||
if (pHelper->pCompData == NULL) return -1;
|
if (pHelper->pCompData == NULL) {
|
||||||
if (tread(fd, (void *)pHelper->pCompData, tsize) < tsize) return -1;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tread(pFile->fd, (void *)pHelper->pCompData, tsize) < tsize) {
|
||||||
|
tsdbError("vgId:%d failed to read %zu bytes from file %s since %s", REPO_ID(pHelper->pRepo), tsize, pFile->fname,
|
||||||
|
strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!taosCheckChecksumWhole((uint8_t *)pHelper->pCompData, tsize)) {
|
||||||
|
tsdbError("vgId:%d file %s is broken, offset %" PRId64 " size %zu", REPO_ID(pHelper->pRepo), pFile->fname,
|
||||||
|
(int64_t)pCompBlock->offset, tsize);
|
||||||
|
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(pCompBlock->numOfCols == pHelper->pCompData->numOfCols);
|
ASSERT(pCompBlock->numOfCols == pHelper->pCompData->numOfCols);
|
||||||
|
|
||||||
|
@ -554,30 +576,31 @@ void tsdbGetDataStatis(SRWHelper *pHelper, SDataStatis *pStatis, int numOfCols)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx, int16_t *colIds, int numOfColIds) {
|
int tsdbLoadBlockDataCols(SRWHelper *pHelper, SCompBlock *pCompBlock, int16_t *colIds, int numOfColIds) {
|
||||||
SCompBlock *pCompBlock = pHelper->pCompInfo->blocks + blkIdx;
|
|
||||||
|
|
||||||
ASSERT(pCompBlock->numOfSubBlocks >= 1); // Must be super block
|
ASSERT(pCompBlock->numOfSubBlocks >= 1); // Must be super block
|
||||||
|
|
||||||
int numOfSubBlocks = pCompBlock->numOfSubBlocks;
|
int numOfSubBlocks = pCompBlock->numOfSubBlocks;
|
||||||
SCompBlock *pStartBlock =
|
if (numOfSubBlocks > 1) pCompBlock = (SCompBlock *)POINTER_SHIFT(pHelper->pCompInfo, pCompBlock->offset);
|
||||||
(numOfSubBlocks == 1) ? pCompBlock : (SCompBlock *)((char *)pHelper->pCompInfo->blocks + pCompBlock->offset);
|
|
||||||
|
|
||||||
if (tsdbLoadSingleBlockDataCols(pHelper, pStartBlock, colIds, numOfColIds, pDataCols) < 0) return -1;
|
tdResetDataCols(pHelper->pDataCols[0]);
|
||||||
|
if (tsdbLoadBlockDataColsImpl(pHelper, pCompBlock, pHelper->pDataCols[0], colIds, numOfColIds) < 0) goto _err;
|
||||||
for (int i = 1; i < numOfSubBlocks; i++) {
|
for (int i = 1; i < numOfSubBlocks; i++) {
|
||||||
pStartBlock++;
|
tdResetDataCols(pHelper->pDataCols[1]);
|
||||||
if (tsdbLoadSingleBlockDataCols(pHelper, pStartBlock, colIds, numOfColIds, pHelper->pDataCols[1]) < 0) return -1;
|
pCompBlock++;
|
||||||
tdMergeDataCols(pDataCols, pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows);
|
if (tsdbLoadBlockDataColsImpl(pHelper, pCompBlock, pHelper->pDataCols[1], colIds, numOfColIds) < 0) goto _err;
|
||||||
|
if (tdMergeDataCols(pHelper->pDataCols[0], pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows) < 0) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *target) {
|
int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock) {
|
||||||
// SCompBlock *pCompBlock = pHelper->pCompInfo->blocks + blkIdx;
|
|
||||||
|
|
||||||
int numOfSubBlock = pCompBlock->numOfSubBlocks;
|
int numOfSubBlock = pCompBlock->numOfSubBlocks;
|
||||||
if (numOfSubBlock > 1) pCompBlock = (SCompBlock *)((char *)pHelper->pCompInfo + pCompBlock->offset);
|
if (numOfSubBlock > 1) pCompBlock = (SCompBlock *)POINTER_SHIFT(pHelper->pCompInfo, pCompBlock->offset);
|
||||||
|
|
||||||
tdResetDataCols(pHelper->pDataCols[0]);
|
tdResetDataCols(pHelper->pDataCols[0]);
|
||||||
if (tsdbLoadBlockDataImpl(pHelper, pCompBlock, pHelper->pDataCols[0]) < 0) goto _err;
|
if (tsdbLoadBlockDataImpl(pHelper, pCompBlock, pHelper->pDataCols[0]) < 0) goto _err;
|
||||||
|
@ -588,8 +611,6 @@ int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *tar
|
||||||
if (tdMergeDataCols(pHelper->pDataCols[0], pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows) < 0) goto _err;
|
if (tdMergeDataCols(pHelper->pDataCols[0], pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows) < 0) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (target) TODO
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -648,7 +669,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
|
||||||
// Compress the data if neccessary
|
// Compress the data if neccessary
|
||||||
int tcol = 0;
|
int tcol = 0;
|
||||||
int32_t toffset = 0;
|
int32_t toffset = 0;
|
||||||
int32_t tsize = sizeof(SCompData) + sizeof(SCompCol) * nColsNotAllNull + sizeof(TSCKSUM);
|
int32_t tsize = TSDB_GET_COMPCOL_LEN(nColsNotAllNull);
|
||||||
int32_t lsize = tsize;
|
int32_t lsize = tsize;
|
||||||
for (int ncol = 0; ncol < pDataCols->numOfCols; ncol++) {
|
for (int ncol = 0; ncol < pDataCols->numOfCols; ncol++) {
|
||||||
if (tcol >= nColsNotAllNull) break;
|
if (tcol >= nColsNotAllNull) break;
|
||||||
|
@ -770,7 +791,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
|
||||||
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
||||||
} else {
|
} else {
|
||||||
// Load
|
// Load
|
||||||
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx), NULL) < 0) goto _err;
|
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx)) < 0) goto _err;
|
||||||
ASSERT(pHelper->pDataCols[0]->numOfRows <= blockAtIdx(pHelper, blkIdx)->numOfRows);
|
ASSERT(pHelper->pDataCols[0]->numOfRows <= blockAtIdx(pHelper, blkIdx)->numOfRows);
|
||||||
// Merge
|
// Merge
|
||||||
if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, rowsWritten) < 0) goto _err;
|
if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, rowsWritten) < 0) goto _err;
|
||||||
|
@ -826,7 +847,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
|
||||||
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
|
||||||
} else { // Load-Merge-Write
|
} else { // Load-Merge-Write
|
||||||
// Load
|
// Load
|
||||||
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx), NULL) < 0) goto _err;
|
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx)) < 0) goto _err;
|
||||||
if (blockAtIdx(pHelper, blkIdx)->last) pHelper->hasOldLastBlock = false;
|
if (blockAtIdx(pHelper, blkIdx)->last) pHelper->hasOldLastBlock = false;
|
||||||
|
|
||||||
rowsWritten = rows3;
|
rowsWritten = rows3;
|
||||||
|
@ -1183,52 +1204,13 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int comparColIdCompCol(const void *arg1, const void *arg2) {
|
|
||||||
return (*(int16_t *)arg1) - ((SCompCol *)arg2)->colId;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int comparColIdDataCol(const void *arg1, const void *arg2) {
|
|
||||||
return (*(int16_t *)arg1) - ((SDataCol *)arg2)->colId;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tsdbLoadSingleColumnData(int fd, SCompBlock *pCompBlock, SCompCol *pCompCol, void *buf) {
|
|
||||||
size_t tsize = sizeof(SCompData) + sizeof(SCompCol) * pCompBlock->numOfCols;
|
|
||||||
if (lseek(fd, pCompBlock->offset + tsize + pCompCol->offset, SEEK_SET) < 0) return -1;
|
|
||||||
if (tread(fd, buf, pCompCol->len) < pCompCol->len) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tsdbLoadSingleBlockDataCols(SRWHelper *pHelper, SCompBlock *pCompBlock, int16_t *colIds, int numOfColIds,
|
|
||||||
SDataCols *pDataCols) {
|
|
||||||
if (tsdbLoadCompData(pHelper, pCompBlock, NULL) < 0) return -1;
|
|
||||||
int fd = (pCompBlock->last) ? pHelper->files.lastF.fd : pHelper->files.dataF.fd;
|
|
||||||
|
|
||||||
void *ptr = NULL;
|
|
||||||
for (int i = 0; i < numOfColIds; i++) {
|
|
||||||
int16_t colId = colIds[i];
|
|
||||||
|
|
||||||
ptr = bsearch((void *)&colId, (void *)pHelper->pCompData->cols, pHelper->pCompData->numOfCols, sizeof(SCompCol),
|
|
||||||
comparColIdCompCol);
|
|
||||||
if (ptr == NULL) continue;
|
|
||||||
SCompCol *pCompCol = (SCompCol *)ptr;
|
|
||||||
|
|
||||||
ptr =
|
|
||||||
bsearch((void *)&colId, (void *)(pDataCols->cols), pDataCols->numOfCols, sizeof(SDataCol), comparColIdDataCol);
|
|
||||||
ASSERT(ptr != NULL);
|
|
||||||
SDataCol *pDataCol = (SDataCol *)ptr;
|
|
||||||
|
|
||||||
pDataCol->len = pCompCol->len;
|
|
||||||
if (tsdbLoadSingleColumnData(fd, pCompBlock, pCompCol, pDataCol->pData) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32_t len, int8_t comp, int numOfRows,
|
static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32_t len, int8_t comp, int numOfRows,
|
||||||
int maxPoints, char *buffer, int bufferSize) {
|
int maxPoints, char *buffer, int bufferSize) {
|
||||||
// Verify by checksum
|
// Verify by checksum
|
||||||
if (!taosCheckChecksumWhole((uint8_t *)content, len)) return -1;
|
if (!taosCheckChecksumWhole((uint8_t *)content, len)) {
|
||||||
|
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Decode the data
|
// Decode the data
|
||||||
if (comp) {
|
if (comp) {
|
||||||
|
@ -1249,10 +1231,97 @@ static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *pDataCols) {
|
static int tsdbLoadColData(SRWHelper *pHelper, SFile *pFile, SCompBlock *pCompBlock, SCompCol *pCompCol,
|
||||||
|
SDataCol *pDataCol) {
|
||||||
|
ASSERT(pDataCol->colId == pCompCol->colId);
|
||||||
|
int tsize = pDataCol->bytes * pCompBlock->numOfRows + COMP_OVERFLOW_BYTES;
|
||||||
|
pHelper->pBuffer = trealloc(pHelper->pBuffer, pCompCol->len);
|
||||||
|
if (pHelper->pBuffer == NULL) {
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pHelper->compBuffer = trealloc(pHelper->compBuffer, tsize);
|
||||||
|
if (pHelper->compBuffer == NULL) {
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lseek(pFile->fd, pCompCol->offset, SEEK_SET) < 0) {
|
||||||
|
tsdbError("vgId:%d failed to lseek file %s since %s", REPO_ID(pHelper->pRepo), pFile->fname, strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tread(pFile->fd, pHelper->pBuffer, pCompCol->len) < pCompCol->len) {
|
||||||
|
tsdbError("vgId:%d failed to read %d bytes from file %s since %s", REPO_ID(pHelper->pRepo), pCompCol->len, pFile->fname,
|
||||||
|
strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsdbCheckAndDecodeColumnData(pDataCol, pHelper->pBuffer, pCompCol->len, pCompBlock->algorithm,
|
||||||
|
pCompBlock->numOfRows, pHelper->pRepo->config.maxRowsPerFileBlock,
|
||||||
|
pHelper->compBuffer, tsizeof(pHelper->compBuffer)) < 0) {
|
||||||
|
tsdbError("vgId:%d file %s is broken at column %d offset %" PRId64, REPO_ID(pHelper->pRepo), pFile->fname, pCompCol->colId,
|
||||||
|
(int64_t)pCompCol->offset);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tsdbLoadBlockDataColsImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *pDataCols, int16_t *colIds, int numOfColIds) {
|
||||||
ASSERT(pCompBlock->numOfSubBlocks <= 1);
|
ASSERT(pCompBlock->numOfSubBlocks <= 1);
|
||||||
|
|
||||||
SCompData *pCompData = (SCompData *)pHelper->pBuffer;
|
SFile * pFile = (pCompBlock->last) ? &(pHelper->files.lastF) : &(pHelper->files.dataF);
|
||||||
|
|
||||||
|
if (tsdbLoadCompData(pHelper, pCompBlock, NULL) < 0) goto _err;
|
||||||
|
|
||||||
|
int dcol = 0;
|
||||||
|
int ccol = 0;
|
||||||
|
for (int i = 0; i < numOfColIds; i++) {
|
||||||
|
int16_t colId = colIds[i];
|
||||||
|
SDataCol *pDataCol = NULL;
|
||||||
|
SCompCol *pCompCol = NULL;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
ASSERT(dcol < pDataCols->numOfCols);
|
||||||
|
pDataCol = &pDataCols->cols[dcol];
|
||||||
|
ASSERT(pDataCol->colId <= colId);
|
||||||
|
if (pDataCol->colId == colId) break;
|
||||||
|
dcol++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pDataCol->colId == colId);
|
||||||
|
|
||||||
|
while (ccol < pCompBlock->numOfCols) {
|
||||||
|
pCompCol = &pHelper->pCompData->cols[ccol];
|
||||||
|
if (pCompCol->colId >= colId) break;
|
||||||
|
ccol++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ccol >= pCompBlock->numOfCols || pCompCol->colId > colId) {
|
||||||
|
dataColSetNEleNull(pDataCol, pCompBlock->numOfRows, pDataCols->maxPoints);
|
||||||
|
dcol++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pCompCol->colId == pDataCol->colId);
|
||||||
|
|
||||||
|
if (tsdbLoadColData(pHelper, pFile, pCompBlock, pCompCol, pDataCol) < 0) goto _err;
|
||||||
|
dcol++;
|
||||||
|
ccol++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *pDataCols) {
|
||||||
|
ASSERT(pCompBlock->numOfSubBlocks <= 1);
|
||||||
|
|
||||||
SFile *pFile = (pCompBlock->last) ? &(pHelper->files.lastF) : &(pHelper->files.dataF);
|
SFile *pFile = (pCompBlock->last) ? &(pHelper->files.lastF) : &(pHelper->files.dataF);
|
||||||
|
|
||||||
|
@ -1262,6 +1331,8 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCompData *pCompData = (SCompData *)pHelper->pBuffer;
|
||||||
|
|
||||||
int fd = pFile->fd;
|
int fd = pFile->fd;
|
||||||
if (lseek(fd, pCompBlock->offset, SEEK_SET) < 0) {
|
if (lseek(fd, pCompBlock->offset, SEEK_SET) < 0) {
|
||||||
tsdbError("vgId:%d tid:%d failed to lseek file %s since %s", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid,
|
tsdbError("vgId:%d tid:%d failed to lseek file %s since %s", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid,
|
||||||
|
@ -1277,7 +1348,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
|
||||||
}
|
}
|
||||||
ASSERT(pCompData->numOfCols == pCompBlock->numOfCols);
|
ASSERT(pCompData->numOfCols == pCompBlock->numOfCols);
|
||||||
|
|
||||||
int32_t tsize = sizeof(SCompData) + sizeof(SCompCol) * pCompBlock->numOfCols + sizeof(TSCKSUM);
|
int32_t tsize = TSDB_GET_COMPCOL_LEN(pCompBlock->numOfCols);
|
||||||
if (!taosCheckChecksumWhole((uint8_t *)pCompData, tsize)) {
|
if (!taosCheckChecksumWhole((uint8_t *)pCompData, tsize)) {
|
||||||
tsdbError("vgId:%d file %s block data is corrupted offset %" PRId64 " len %d", REPO_ID(pHelper->pRepo),
|
tsdbError("vgId:%d file %s block data is corrupted offset %" PRId64 " len %d", REPO_ID(pHelper->pRepo),
|
||||||
pFile->fname, (int64_t)(pCompBlock->offset), pCompBlock->len);
|
pFile->fname, (int64_t)(pCompBlock->offset), pCompBlock->len);
|
||||||
|
@ -1315,8 +1386,11 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
|
||||||
}
|
}
|
||||||
if (tsdbCheckAndDecodeColumnData(pDataCol, (char *)pCompData + tsize + pCompCol->offset, pCompCol->len,
|
if (tsdbCheckAndDecodeColumnData(pDataCol, (char *)pCompData + tsize + pCompCol->offset, pCompCol->len,
|
||||||
pCompBlock->algorithm, pCompBlock->numOfRows, pDataCols->maxPoints,
|
pCompBlock->algorithm, pCompBlock->numOfRows, pDataCols->maxPoints,
|
||||||
pHelper->compBuffer, tsizeof(pHelper->compBuffer)) < 0)
|
pHelper->compBuffer, tsizeof(pHelper->compBuffer)) < 0) {
|
||||||
|
tsdbError("vgId:%d file %s is broken at column %d offset %" PRId64, REPO_ID(pHelper->pRepo), pFile->fname,
|
||||||
|
pCompCol->colId, (int64_t)pCompCol->offset);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
}
|
||||||
dcol++;
|
dcol++;
|
||||||
ccol++;
|
ccol++;
|
||||||
} else if (pCompCol->colId < pDataCol->colId) {
|
} else if (pCompCol->colId < pDataCol->colId) {
|
||||||
|
|
|
@ -148,7 +148,7 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
|
||||||
pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
||||||
pQueryHandle->cur.fid = -1;
|
pQueryHandle->cur.fid = -1;
|
||||||
pQueryHandle->cur.win = TSWINDOW_INITIALIZER;
|
pQueryHandle->cur.win = TSWINDOW_INITIALIZER;
|
||||||
pQueryHandle->checkFiles = true;//ASCENDING_TRAVERSE(pQueryHandle->order);
|
pQueryHandle->checkFiles = true;
|
||||||
pQueryHandle->activeIndex = 0; // current active table index
|
pQueryHandle->activeIndex = 0; // current active table index
|
||||||
pQueryHandle->qinfo = qinfo;
|
pQueryHandle->qinfo = qinfo;
|
||||||
pQueryHandle->outputCapacity = ((STsdbRepo*)tsdb)->config.maxRowsPerFileBlock;
|
pQueryHandle->outputCapacity = ((STsdbRepo*)tsdb)->config.maxRowsPerFileBlock;
|
||||||
|
@ -475,11 +475,15 @@ static int32_t binarySearchForBlock(SCompBlock* pBlock, int32_t numOfBlocks, TSK
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlocks, int32_t type) {
|
static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlocks, int32_t type) {
|
||||||
// todo check open file failed
|
|
||||||
SFileGroup* fileGroup = pQueryHandle->pFileGroup;
|
SFileGroup* fileGroup = pQueryHandle->pFileGroup;
|
||||||
|
|
||||||
assert(fileGroup->files[TSDB_FILE_TYPE_HEAD].fname > 0);
|
assert(fileGroup->files[TSDB_FILE_TYPE_HEAD].fname > 0);
|
||||||
tsdbSetAndOpenHelperFile(&pQueryHandle->rhelper, fileGroup);
|
|
||||||
|
int32_t code = tsdbSetAndOpenHelperFile(&pQueryHandle->rhelper, fileGroup);
|
||||||
|
|
||||||
|
//open file failed, return error code to client
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
// load all the comp offset value for all tables in this file
|
// load all the comp offset value for all tables in this file
|
||||||
*numOfBlocks = 0;
|
*numOfBlocks = 0;
|
||||||
|
@ -538,17 +542,12 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDataBlockInfo getTrueDataBlockInfo(STableCheckInfo* pCheckInfo, SCompBlock* pBlock) {
|
#define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \
|
||||||
SDataBlockInfo info = {
|
((SDataBlockInfo){.window = {.skey = (_block)->keyFirst, .ekey = (_block)->keyLast}, \
|
||||||
.window = {.skey = pBlock->keyFirst, .ekey = pBlock->keyLast},
|
.numOfCols = (_block)->numOfCols, \
|
||||||
.numOfCols = pBlock->numOfCols,
|
.rows = (_block)->numOfRows, \
|
||||||
.rows = pBlock->numOfRows,
|
.tid = (_checkInfo)->tableId.tid, \
|
||||||
.tid = pCheckInfo->tableId.tid,
|
.uid = (_checkInfo)->tableId.uid})
|
||||||
.uid = pCheckInfo->tableId.uid,
|
|
||||||
};
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SArray* getColumnIdList(STsdbQueryHandle* pQueryHandle) {
|
static SArray* getColumnIdList(STsdbQueryHandle* pQueryHandle) {
|
||||||
size_t numOfCols = QH_GET_NUM_OF_COLS(pQueryHandle);
|
size_t numOfCols = QH_GET_NUM_OF_COLS(pQueryHandle);
|
||||||
|
@ -593,13 +592,12 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
|
||||||
if (pCheckInfo->pDataCols == NULL) {
|
if (pCheckInfo->pDataCols == NULL) {
|
||||||
STsdbMeta* pMeta = tsdbGetMeta(pRepo);
|
STsdbMeta* pMeta = tsdbGetMeta(pRepo);
|
||||||
// TODO
|
// TODO
|
||||||
pCheckInfo->pDataCols =
|
pCheckInfo->pDataCols = tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock);
|
||||||
tdNewDataCols(pMeta->maxRowBytes, pMeta->maxCols, pRepo->config.maxRowsPerFileBlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tdInitDataCols(pCheckInfo->pDataCols, tsdbGetTableSchema(pCheckInfo->pTableObj));
|
tdInitDataCols(pCheckInfo->pDataCols, tsdbGetTableSchema(pCheckInfo->pTableObj));
|
||||||
|
|
||||||
if (tsdbLoadBlockData(&(pQueryHandle->rhelper), pBlock, NULL) == 0) {
|
if (tsdbLoadBlockData(&(pQueryHandle->rhelper), pBlock) == 0) {
|
||||||
SDataBlockLoadInfo* pBlockLoadInfo = &pQueryHandle->dataBlockLoadInfo;
|
SDataBlockLoadInfo* pBlockLoadInfo = &pQueryHandle->dataBlockLoadInfo;
|
||||||
|
|
||||||
pBlockLoadInfo->fileGroup = pQueryHandle->pFileGroup;
|
pBlockLoadInfo->fileGroup = pQueryHandle->pFileGroup;
|
||||||
|
@ -623,7 +621,7 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
|
||||||
|
|
||||||
static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo){
|
static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo){
|
||||||
SQueryFilePos* cur = &pQueryHandle->cur;
|
SQueryFilePos* cur = &pQueryHandle->cur;
|
||||||
SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlock);
|
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
||||||
|
|
||||||
/*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo);
|
/*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo);
|
||||||
SDataRow row = getSDataRowInTableMem(pCheckInfo);
|
SDataRow row = getSDataRowInTableMem(pCheckInfo);
|
||||||
|
@ -943,7 +941,7 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
|
||||||
static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock,
|
static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock,
|
||||||
SArray* sa) {
|
SArray* sa) {
|
||||||
SQueryFilePos* cur = &pQueryHandle->cur;
|
SQueryFilePos* cur = &pQueryHandle->cur;
|
||||||
SDataBlockInfo blockInfo = getTrueDataBlockInfo(pCheckInfo, pBlock);
|
SDataBlockInfo blockInfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
||||||
|
|
||||||
initTableMemIterator(pQueryHandle, pCheckInfo);
|
initTableMemIterator(pQueryHandle, pCheckInfo);
|
||||||
SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0];
|
SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0];
|
||||||
|
@ -1319,8 +1317,8 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
|
||||||
|
|
||||||
assert(cnt <= numOfBlocks && numOfQualTables <= numOfTables); // the pTableQueryInfo[j]->numOfBlocks may be 0
|
assert(cnt <= numOfBlocks && numOfQualTables <= numOfTables); // the pTableQueryInfo[j]->numOfBlocks may be 0
|
||||||
sup.numOfTables = numOfQualTables;
|
sup.numOfTables = numOfQualTables;
|
||||||
SLoserTreeInfo* pTree = NULL;
|
|
||||||
|
|
||||||
|
SLoserTreeInfo* pTree = NULL;
|
||||||
uint8_t ret = tLoserTreeCreate(&pTree, sup.numOfTables, &sup, dataBlockOrderCompar);
|
uint8_t ret = tLoserTreeCreate(&pTree, sup.numOfTables, &sup, dataBlockOrderCompar);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
cleanBlockOrderSupporter(&sup, numOfTables);
|
cleanBlockOrderSupporter(&sup, numOfTables);
|
||||||
|
@ -1359,16 +1357,18 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo opt for only one table case
|
// todo opt for only one table case
|
||||||
static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) {
|
static int32_t getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle, bool* exists) {
|
||||||
pQueryHandle->numOfBlocks = 0;
|
pQueryHandle->numOfBlocks = 0;
|
||||||
SQueryFilePos* cur = &pQueryHandle->cur;
|
SQueryFilePos* cur = &pQueryHandle->cur;
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t numOfBlocks = 0;
|
int32_t numOfBlocks = 0;
|
||||||
int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
||||||
|
|
||||||
while ((pQueryHandle->pFileGroup = tsdbGetFileGroupNext(&pQueryHandle->fileIter)) != NULL) {
|
while ((pQueryHandle->pFileGroup = tsdbGetFileGroupNext(&pQueryHandle->fileIter)) != NULL) {
|
||||||
int32_t type = ASCENDING_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL;
|
int32_t type = ASCENDING_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL;
|
||||||
if (getFileCompInfo(pQueryHandle, &numOfBlocks, type) != TSDB_CODE_SUCCESS) {
|
if ((code = getFileCompInfo(pQueryHandle, &numOfBlocks, type)) != TSDB_CODE_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,20 +1393,25 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) {
|
||||||
|
|
||||||
// no data in file anymore
|
// no data in file anymore
|
||||||
if (pQueryHandle->numOfBlocks <= 0) {
|
if (pQueryHandle->numOfBlocks <= 0) {
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
assert(pQueryHandle->pFileGroup == NULL);
|
assert(pQueryHandle->pFileGroup == NULL);
|
||||||
cur->fid = -1; // denote that there are no data in file anymore
|
}
|
||||||
|
|
||||||
return false;
|
cur->fid = -1; // denote that there are no data in file anymore
|
||||||
|
*exists = false;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->slot = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:pQueryHandle->numOfBlocks-1;
|
cur->slot = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:pQueryHandle->numOfBlocks-1;
|
||||||
cur->fid = pQueryHandle->pFileGroup->fileId;
|
cur->fid = pQueryHandle->pFileGroup->fileId;
|
||||||
|
|
||||||
STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot];
|
STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot];
|
||||||
return loadFileDataBlock(pQueryHandle, pBlockInfo->compBlock, pBlockInfo->pTableCheckInfo);
|
*exists = loadFileDataBlock(pQueryHandle, pBlockInfo->compBlock, pBlockInfo->pTableCheckInfo);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) {
|
static int32_t getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle, bool* exists) {
|
||||||
STsdbFileH* pFileHandle = tsdbGetFile(pQueryHandle->pTsdb);
|
STsdbFileH* pFileHandle = tsdbGetFile(pQueryHandle->pTsdb);
|
||||||
SQueryFilePos* cur = &pQueryHandle->cur;
|
SQueryFilePos* cur = &pQueryHandle->cur;
|
||||||
|
|
||||||
|
@ -1419,7 +1424,7 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) {
|
||||||
tsdbInitFileGroupIter(pFileHandle, &pQueryHandle->fileIter, pQueryHandle->order);
|
tsdbInitFileGroupIter(pFileHandle, &pQueryHandle->fileIter, pQueryHandle->order);
|
||||||
tsdbSeekFileGroupIter(&pQueryHandle->fileIter, fid);
|
tsdbSeekFileGroupIter(&pQueryHandle->fileIter, fid);
|
||||||
|
|
||||||
return getDataBlocksInFilesImpl(pQueryHandle);
|
return getDataBlocksInFilesImpl(pQueryHandle, exists);
|
||||||
} else {
|
} else {
|
||||||
// check if current file block is all consumed
|
// check if current file block is all consumed
|
||||||
STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot];
|
STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot];
|
||||||
|
@ -1430,7 +1435,7 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) {
|
||||||
if ((cur->slot == pQueryHandle->numOfBlocks - 1 && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
|
if ((cur->slot == pQueryHandle->numOfBlocks - 1 && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
|
||||||
(cur->slot == 0 && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
|
(cur->slot == 0 && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
|
||||||
// all data blocks in current file has been checked already, try next file if exists
|
// all data blocks in current file has been checked already, try next file if exists
|
||||||
return getDataBlocksInFilesImpl(pQueryHandle);
|
return getDataBlocksInFilesImpl(pQueryHandle, exists);
|
||||||
} else {
|
} else {
|
||||||
// next block of the same file
|
// next block of the same file
|
||||||
int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1;
|
int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1;
|
||||||
|
@ -1440,11 +1445,15 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) {
|
||||||
cur->blockCompleted = false;
|
cur->blockCompleted = false;
|
||||||
|
|
||||||
STableBlockInfo* pNext = &pQueryHandle->pDataBlockInfo[cur->slot];
|
STableBlockInfo* pNext = &pQueryHandle->pDataBlockInfo[cur->slot];
|
||||||
return loadFileDataBlock(pQueryHandle, pNext->compBlock, pNext->pTableCheckInfo);
|
*exists = loadFileDataBlock(pQueryHandle, pNext->compBlock, pNext->pTableCheckInfo);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleDataMergeIfNeeded(pQueryHandle, pBlockInfo->compBlock, pCheckInfo);
|
handleDataMergeIfNeeded(pQueryHandle, pBlockInfo->compBlock, pCheckInfo);
|
||||||
return pQueryHandle->realNumOfRows > 0;
|
*exists = pQueryHandle->realNumOfRows > 0;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1576,8 +1585,14 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryHandle->checkFiles) {
|
if (pQueryHandle->checkFiles) {
|
||||||
if (getDataBlocksInFiles(pQueryHandle)) {
|
bool exists = true;
|
||||||
return true;
|
int32_t code = getDataBlocksInFiles(pQueryHandle, &exists);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
pQueryHandle->activeIndex = 0;
|
pQueryHandle->activeIndex = 0;
|
||||||
|
@ -1824,7 +1839,7 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) {
|
||||||
if (pHandle->cur.mixBlock) {
|
if (pHandle->cur.mixBlock) {
|
||||||
return pHandle->pColumns;
|
return pHandle->pColumns;
|
||||||
} else {
|
} else {
|
||||||
SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlockInfo->compBlock);
|
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlockInfo->compBlock);
|
||||||
assert(pHandle->realNumOfRows <= binfo.rows);
|
assert(pHandle->realNumOfRows <= binfo.rows);
|
||||||
|
|
||||||
// data block has been loaded, todo extract method
|
// data block has been loaded, todo extract method
|
||||||
|
|
|
@ -22,7 +22,7 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
|
|
||||||
#define T_REF_DECLARE() \
|
#define T_REF_DECLARE() \
|
||||||
struct { \
|
struct { \
|
||||||
int16_t val; \
|
int32_t val; \
|
||||||
} _ref;
|
} _ref;
|
||||||
|
|
||||||
#define T_REF_REGISTER_FUNC(s, e) \
|
#define T_REF_REGISTER_FUNC(s, e) \
|
||||||
|
@ -31,7 +31,7 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
_ref_fn_t end; \
|
_ref_fn_t end; \
|
||||||
} _ref_func = {.begin = (s), .end = (e)};
|
} _ref_func = {.begin = (s), .end = (e)};
|
||||||
|
|
||||||
#define T_REF_INC(x) (atomic_add_fetch_16(&((x)->_ref.val), 1))
|
#define T_REF_INC(x) (atomic_add_fetch_32(&((x)->_ref.val), 1))
|
||||||
|
|
||||||
#define T_REF_INC_WITH_CB(x, p) \
|
#define T_REF_INC_WITH_CB(x, p) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -41,11 +41,11 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define T_REF_DEC(x) (atomic_sub_fetch_16(&((x)->_ref.val), 1))
|
#define T_REF_DEC(x) (atomic_sub_fetch_32(&((x)->_ref.val), 1))
|
||||||
|
|
||||||
#define T_REF_DEC_WITH_CB(x, p) \
|
#define T_REF_DEC_WITH_CB(x, p) \
|
||||||
do { \
|
do { \
|
||||||
int32_t v = atomic_sub_fetch_16(&((x)->_ref.val), 1); \
|
int32_t v = atomic_sub_fetch_32(&((x)->_ref.val), 1); \
|
||||||
if (v == 0 && (p)->_ref_func.end != NULL) { \
|
if (v == 0 && (p)->_ref_func.end != NULL) { \
|
||||||
(p)->_ref_func.end((x)); \
|
(p)->_ref_func.end((x)); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -415,7 +415,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
int16_t ref = T_REF_DEC(pNode);
|
int32_t ref = T_REF_DEC(pNode);
|
||||||
uDebug("%p data released, refcnt:%d", pNode, ref);
|
uDebug("%p data released, refcnt:%d", pNode, ref);
|
||||||
|
|
||||||
if (_remove) {
|
if (_remove) {
|
||||||
|
|
|
@ -259,6 +259,7 @@ int tdUpdateKVStoreRecord(SKVStore *pStore, uint64_t uid, void *cont, int contLe
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashPut(pStore->map, (void *)(&uid), sizeof(uid), (void *)(&rInfo), sizeof(rInfo));
|
taosHashPut(pStore->map, (void *)(&uid), sizeof(uid), (void *)(&rInfo), sizeof(rInfo));
|
||||||
|
uDebug("put uid %" PRIu64 " into kvStore %s", uid, pStore->fname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +293,7 @@ int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid) {
|
||||||
pStore->info.tombSize += (rInfo.size + sizeof(SKVRecord) * 2);
|
pStore->info.tombSize += (rInfo.size + sizeof(SKVRecord) * 2);
|
||||||
|
|
||||||
taosHashRemove(pStore->map, (void *)(&uid), sizeof(uid));
|
taosHashRemove(pStore->map, (void *)(&uid), sizeof(uid));
|
||||||
|
uDebug("drop uid %" PRIu64 " from KV store %s", uid, pStore->fname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,15 @@ void taosCloseQueue(taos_queue param) {
|
||||||
if (param == NULL) return;
|
if (param == NULL) return;
|
||||||
STaosQueue *queue = (STaosQueue *)param;
|
STaosQueue *queue = (STaosQueue *)param;
|
||||||
STaosQnode *pTemp;
|
STaosQnode *pTemp;
|
||||||
|
STaosQset *qset;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&queue->mutex);
|
||||||
STaosQnode *pNode = queue->head;
|
STaosQnode *pNode = queue->head;
|
||||||
queue->head = NULL;
|
queue->head = NULL;
|
||||||
|
qset = queue->qset;
|
||||||
|
pthread_mutex_unlock(&queue->mutex);
|
||||||
|
|
||||||
if (queue->qset) taosRemoveFromQset(queue->qset, queue);
|
if (queue->qset) taosRemoveFromQset(qset, queue);
|
||||||
|
|
||||||
pthread_mutex_lock(&queue->mutex);
|
pthread_mutex_lock(&queue->mutex);
|
||||||
|
|
||||||
|
@ -95,7 +100,7 @@ void *taosAllocateQitem(int size) {
|
||||||
void taosFreeQitem(void *param) {
|
void taosFreeQitem(void *param) {
|
||||||
if (param == NULL) return;
|
if (param == NULL) return;
|
||||||
|
|
||||||
uDebug("item:%p is freed", param);
|
uTrace("item:%p is freed", param);
|
||||||
char *temp = (char *)param;
|
char *temp = (char *)param;
|
||||||
temp -= sizeof(STaosQnode);
|
temp -= sizeof(STaosQnode);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
@ -119,7 +124,7 @@ int taosWriteQitem(taos_queue param, int type, void *item) {
|
||||||
|
|
||||||
queue->numOfItems++;
|
queue->numOfItems++;
|
||||||
if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1);
|
if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1);
|
||||||
uDebug("item:%p is put into queue:%p, type:%d items:%d", item, queue, type, queue->numOfItems);
|
uTrace("item:%p is put into queue:%p, type:%d items:%d", item, queue, type, queue->numOfItems);
|
||||||
|
|
||||||
pthread_mutex_unlock(&queue->mutex);
|
pthread_mutex_unlock(&queue->mutex);
|
||||||
|
|
||||||
|
@ -201,7 +206,7 @@ int taosGetQitem(taos_qall param, int *type, void **pitem) {
|
||||||
*pitem = pNode->item;
|
*pitem = pNode->item;
|
||||||
*type = pNode->type;
|
*type = pNode->type;
|
||||||
num = 1;
|
num = 1;
|
||||||
uDebug("item:%p is fetched, type:%d", *pitem, *type);
|
uTrace("item:%p is fetched, type:%d", *pitem, *type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
@ -339,7 +344,7 @@ int taosReadQitemFromQset(taos_qset param, int *type, void **pitem, void **phand
|
||||||
queue->numOfItems--;
|
queue->numOfItems--;
|
||||||
atomic_sub_fetch_32(&qset->numOfItems, 1);
|
atomic_sub_fetch_32(&qset->numOfItems, 1);
|
||||||
code = 1;
|
code = 1;
|
||||||
uDebug("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
|
uTrace("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&queue->mutex);
|
pthread_mutex_unlock(&queue->mutex);
|
||||||
|
|
|
@ -56,9 +56,11 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
|
||||||
year -= 1;
|
year -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t res = 367*((int64_t)mon)/12;
|
//int64_t res = (((((int64_t) (year/4 - year/100 + year/400 + 367*mon/12 + day) +
|
||||||
|
// year*365 - 719499)*24 + hour)*60 + min)*60 + sec);
|
||||||
res += ((int64_t)(year/4 - year/100 + year/400 + day + year*365) - 719499); // this value may be less than 0
|
int64_t res;
|
||||||
|
res = 367*((int64_t)mon)/12;
|
||||||
|
res += year/4 - year/100 + year/400 + day + ((int64_t)year)*365 - 719499;
|
||||||
res = res*24;
|
res = res*24;
|
||||||
res = ((res + hour) * 60 + min) * 60 + sec;
|
res = ((res + hour) * 60 + min) * 60 + sec;
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,8 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
|
||||||
|
|
||||||
char tsdbDir[TSDB_FILENAME_LEN] = {0};
|
char tsdbDir[TSDB_FILENAME_LEN] = {0};
|
||||||
sprintf(tsdbDir, "%s/vnode%d/tsdb", tsVnodeDir, pVnodeCfg->cfg.vgId);
|
sprintf(tsdbDir, "%s/vnode%d/tsdb", tsVnodeDir, pVnodeCfg->cfg.vgId);
|
||||||
code = tsdbCreateRepo(tsdbDir, &tsdbCfg);
|
if (tsdbCreateRepo(tsdbDir, &tsdbCfg) < 0) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
vError("vgId:%d, failed to create tsdb in vnode, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(terrno));
|
||||||
vError("vgId:%d, failed to create tsdb in vnode, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code));
|
|
||||||
return TSDB_CODE_VND_INIT_FAILED;
|
return TSDB_CODE_VND_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,6 +604,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId);
|
vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId);
|
||||||
free(content);
|
free(content);
|
||||||
|
fclose(fp);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,10 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
||||||
pRet->rsp = pRsp;
|
pRet->rsp = pRsp;
|
||||||
|
|
||||||
// current connect is broken
|
// current connect is broken
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
if (vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, pQInfo, pVnode->vgId) != TSDB_CODE_SUCCESS) {
|
if (vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, pQInfo, pVnode->vgId) != TSDB_CODE_SUCCESS) {
|
||||||
vError("vgId:%d, QInfo:%p, dnode query discarded since link is broken, %p", pVnode->vgId, pQInfo, pReadMsg->rpcMsg.handle);
|
vError("vgId:%d, QInfo:%p, dnode query discarded since link is broken, %p", pVnode->vgId, pQInfo,
|
||||||
|
pReadMsg->rpcMsg.handle);
|
||||||
pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||||
|
|
||||||
// NOTE: there two refcount, needs to kill twice, todo refactor
|
// NOTE: there two refcount, needs to kill twice, todo refactor
|
||||||
|
@ -120,6 +122,12 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
||||||
return pRsp->code;
|
return pRsp->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vTrace("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
|
||||||
|
} else {
|
||||||
|
assert(pQInfo == NULL);
|
||||||
|
vnodeRelease(pVnode);
|
||||||
|
}
|
||||||
|
|
||||||
vDebug("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
|
vDebug("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
|
||||||
} else {
|
} else {
|
||||||
assert(pCont != NULL);
|
assert(pCont != NULL);
|
||||||
|
@ -129,7 +137,6 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQInfo != NULL) {
|
if (pQInfo != NULL) {
|
||||||
vDebug("vgId:%d, QInfo:%p, do qTableQuery", pVnode->vgId, pQInfo);
|
|
||||||
qTableQuery(pQInfo, vnodeRelease, pVnode); // do execute query
|
qTableQuery(pQInfo, vnodeRelease, pVnode); // do execute query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
|
||||||
|
|
||||||
// save insert result into item
|
// save insert result into item
|
||||||
|
|
||||||
vDebug("vgId:%d, submit msg is processed", pVnode->vgId);
|
vTrace("vgId:%d, submit msg is processed", pVnode->vgId);
|
||||||
|
|
||||||
pRet->len = sizeof(SShellSubmitRspMsg);
|
pRet->len = sizeof(SShellSubmitRspMsg);
|
||||||
pRet->rsp = rpcMallocCont(pRet->len);
|
pRet->rsp = rpcMallocCont(pRet->len);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
4. pip install ../src/connector/python/linux/python2 ; pip3 install
|
4. pip install ../src/connector/python/linux/python2 ; pip3 install
|
||||||
../src/connector/python/linux/python3
|
../src/connector/python/linux/python3
|
||||||
|
|
||||||
5. pip install numpy; pip3 install numpy
|
5. pip install numpy; pip3 install numpy (numpy is required only if you need to run querySort.py)
|
||||||
|
|
||||||
> Note: Both Python2 and Python3 are currently supported by the Python test
|
> Note: Both Python2 and Python3 are currently supported by the Python test
|
||||||
> framework. Since Python2 is no longer officially supported by Python Software
|
> framework. Since Python2 is no longer officially supported by Python Software
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
|
||||||
# Coloured Echoes #
|
# Coloured Echoes #
|
||||||
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||||
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
||||||
|
@ -16,6 +18,17 @@ function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") &&
|
||||||
function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } #
|
function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } #
|
||||||
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
|
||||||
|
function setMaxTablesPerVnode {
|
||||||
|
echo "/etc/taos/taos.cfg maxTablesPerVnode will be set to $1"
|
||||||
|
|
||||||
|
hasText=`grep "maxTablesPerVnode" /etc/taos/taos.cfg`
|
||||||
|
if [[ -z "$hasText" ]]; then
|
||||||
|
echo "maxTablesPerVnode $1" >> /etc/taos/taos.cfg
|
||||||
|
else
|
||||||
|
sed -i 's/^maxTablesPerVnode.*$/maxTablesPerVnode '"$1"'/g' /etc/taos/taos.cfg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function setMaxConnections {
|
function setMaxConnections {
|
||||||
echo "/etc/taos/taos.cfg maxConnection will be set to $1"
|
echo "/etc/taos/taos.cfg maxConnection will be set to $1"
|
||||||
|
|
||||||
|
@ -27,6 +40,28 @@ function setMaxConnections {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setQDebugFlag {
|
||||||
|
echo "/etc/taos/taos.cfg qDebugFlag will be set to $1"
|
||||||
|
|
||||||
|
hasText=`grep -w "qDebugFlag" /etc/taos/taos.cfg`
|
||||||
|
if [[ -z "$hasText" ]]; then
|
||||||
|
echo "qDebugFlag $1" >> /etc/taos/taos.cfg
|
||||||
|
else
|
||||||
|
sed -i 's/^qDebugFlag.*$/qDebugFlag '"$1"'/g' /etc/taos/taos.cfg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function setDebugFlag {
|
||||||
|
echo "/etc/taos/taos.cfg DebugFlag will be set to $1"
|
||||||
|
|
||||||
|
hasText=`grep -w "DebugFlag" /etc/taos/taos.cfg`
|
||||||
|
if [[ -z "$hasText" ]]; then
|
||||||
|
echo "DebugFlag $1" >> /etc/taos/taos.cfg
|
||||||
|
else
|
||||||
|
sed -i 's/^DebugFlag.*$/DebugFlag '"$1"'/g' /etc/taos/taos.cfg
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function setWal {
|
function setWal {
|
||||||
echo "/etc/taos/taos.cfg walLevel will be set to $1"
|
echo "/etc/taos/taos.cfg walLevel will be set to $1"
|
||||||
|
|
||||||
|
@ -47,9 +82,10 @@ function collectSysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTDengine {
|
function buildTDengine {
|
||||||
cd /root/TDengine
|
echoInfo "Build TDengine"
|
||||||
|
cd $WORK_DIR/TDengine
|
||||||
|
|
||||||
git remote update
|
git remote update > /dev/null
|
||||||
REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop`
|
REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop`
|
||||||
LOCAL_COMMIT=`git rev-parse --short @`
|
LOCAL_COMMIT=`git rev-parse --short @`
|
||||||
|
|
||||||
|
@ -59,29 +95,17 @@ function buildTDengine {
|
||||||
echo "repo up-to-date"
|
echo "repo up-to-date"
|
||||||
else
|
else
|
||||||
echo "repo need to pull"
|
echo "repo need to pull"
|
||||||
git pull
|
git pull > /dev/null
|
||||||
|
|
||||||
LOCAL_COMMIT=`git rev-parse --short @`
|
LOCAL_COMMIT=`git rev-parse --short @`
|
||||||
cd debug
|
cd debug
|
||||||
rm -rf *
|
rm -rf *
|
||||||
cmake ..
|
cmake .. > /dev/null
|
||||||
make > /dev/null
|
make > /dev/null
|
||||||
make install
|
make install
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function restartTaosd {
|
|
||||||
systemctl stop taosd
|
|
||||||
pkill -KILL -x taosd
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
rm -rf /mnt/var/log/taos/*
|
|
||||||
rm -rf /mnt/var/lib/taos/*
|
|
||||||
|
|
||||||
taosd 2>&1 > /dev/null &
|
|
||||||
sleep 10
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendReport {
|
function sendReport {
|
||||||
receiver="sdsang@taosdata.com, sangshuduo@gmail.com"
|
receiver="sdsang@taosdata.com, sangshuduo@gmail.com"
|
||||||
mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n"
|
mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n"
|
||||||
|
@ -93,57 +117,90 @@ function sendReport {
|
||||||
(cat - && uuencode perftest-13d-wal1-$today.log perftest-13d-wal1-$today.log)| \
|
(cat - && uuencode perftest-13d-wal1-$today.log perftest-13d-wal1-$today.log)| \
|
||||||
(cat - && uuencode perftest-13d-wal1-report.csv perftest-13d-wal1-report-$today.csv) | \
|
(cat - && uuencode perftest-13d-wal1-report.csv perftest-13d-wal1-report-$today.csv) | \
|
||||||
(cat - && uuencode perftest-13d-wal1-report.png perftest-13d-wal1-report-$today.png) | \
|
(cat - && uuencode perftest-13d-wal1-report.png perftest-13d-wal1-report-$today.png) | \
|
||||||
|
(cat - && uuencode perftest-var10k-int10s-wal1-$today.log perftest-var10k-int10s-wal1-$today.log)| \
|
||||||
|
(cat - && uuencode perftest-var10k-int10s-wal1-report.csv perftest-var10k-int10s-wal1-report-$today.csv) | \
|
||||||
|
(cat - && uuencode perftest-var10k-int10s-wal1-report.png perftest-var10k-int10s-wal1-report-$today.png) | \
|
||||||
(cat - && uuencode taosdemo-wal1-$today.log taosdemo-wal1-$today.log) | \
|
(cat - && uuencode taosdemo-wal1-$today.log taosdemo-wal1-$today.log) | \
|
||||||
(cat - && uuencode taosdemo-wal1-report.csv taosdemo-wal1-report-$today.csv) | \
|
(cat - && uuencode taosdemo-wal1-report.csv taosdemo-wal1-report-$today.csv) | \
|
||||||
(cat - && uuencode taosdemo-rps-wal1-report.csv taosdemo-rps-wal1-report-$today.csv) | \
|
|
||||||
(cat - && uuencode taosdemo-wal1-report.png taosdemo-wal1-report-$today.png) | \
|
(cat - && uuencode taosdemo-wal1-report.png taosdemo-wal1-report-$today.png) | \
|
||||||
|
(cat - && uuencode taosdemo-rps-wal1-report.csv taosdemo-rps-wal1-report-$today.csv) | \
|
||||||
|
(cat - && uuencode taosdemo-rps-wal1-report.png taosdemo-rps-wal1-report-$today.png) | \
|
||||||
(cat - && uuencode perftest-1d-wal2-$today.log perftest-1d-wal2-$today.log)| \
|
(cat - && uuencode perftest-1d-wal2-$today.log perftest-1d-wal2-$today.log)| \
|
||||||
(cat - && uuencode perftest-1d-wal2-report.csv perftest-1d-wal2-report-$today.csv) | \
|
(cat - && uuencode perftest-1d-wal2-report.csv perftest-1d-wal2-report-$today.csv) | \
|
||||||
(cat - && uuencode perftest-1d-wal2-report.png perftest-1d-wal2-report-$today.png) | \
|
(cat - && uuencode perftest-1d-wal2-report.png perftest-1d-wal2-report-$today.png) | \
|
||||||
(cat - && uuencode perftest-13d-wal2-$today.log perftest-13d-wal2-$today.log)| \
|
(cat - && uuencode perftest-13d-wal2-$today.log perftest-13d-wal2-$today.log)| \
|
||||||
(cat - && uuencode perftest-13d-wal2-report.csv perftest-13d-wal2-report-$today.csv) | \
|
(cat - && uuencode perftest-13d-wal2-report.csv perftest-13d-wal2-report-$today.csv) | \
|
||||||
(cat - && uuencode perftest-13d-wal2-report.png perftest-13d-wal2-report-$today.png) | \
|
(cat - && uuencode perftest-13d-wal2-report.png perftest-13d-wal2-report-$today.png) | \
|
||||||
|
(cat - && uuencode perftest-var10k-int10s-wal2-$today.log perftest-var10k-int10s-wal2-$today.log)| \
|
||||||
|
(cat - && uuencode perftest-var10k-int10s-wal2-report.csv perftest-var10k-int10s-wal2-report-$today.csv) | \
|
||||||
|
(cat - && uuencode perftest-var10k-int10s-wal2-report.png perftest-var10k-int10s-wal2-report-$today.png) | \
|
||||||
(cat - && uuencode taosdemo-wal2-$today.log taosdemo-wal2-$today.log) | \
|
(cat - && uuencode taosdemo-wal2-$today.log taosdemo-wal2-$today.log) | \
|
||||||
(cat - && uuencode taosdemo-wal2-report.csv taosdemo-wal2-report-$today.csv) | \
|
(cat - && uuencode taosdemo-wal2-report.csv taosdemo-wal2-report-$today.csv) | \
|
||||||
|
(cat - && uuencode taosdemo-wal2-report.png taosdemo-wal2-report-$today.png) | \
|
||||||
(cat - && uuencode taosdemo-rps-wal2-report.csv taosdemo-rps-wal2-report-$today.csv) | \
|
(cat - && uuencode taosdemo-rps-wal2-report.csv taosdemo-rps-wal2-report-$today.csv) | \
|
||||||
|
(cat - && uuencode taosdemo-rps-wal2-report.png taosdemo-rps-wal2-report-$today.png) | \
|
||||||
(cat - && uuencode sysinfo.log sysinfo.txt) | \
|
(cat - && uuencode sysinfo.log sysinfo.txt) | \
|
||||||
(cat - && uuencode taos.cfg taos-cfg-$today.txt) | \
|
(cat - && uuencode taos.cfg taos-cfg-$today.txt) | \
|
||||||
ssmtp "${receiver}"
|
ssmtp "${receiver}"
|
||||||
}
|
}
|
||||||
|
|
||||||
today=`date +"%Y%m%d"`
|
today=`date +"%Y%m%d"`
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
echo -e "cron-ran-at-${today}" >> cron.log
|
echo -e "cron-ran-at-${today}" >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
echoInfo "Build TDengine"
|
|
||||||
buildTDengine
|
buildTDengine
|
||||||
|
|
||||||
############################
|
############################
|
||||||
setMaxConnections 100
|
setMaxConnections 1000
|
||||||
|
setMaxTablesPerVnode 6000
|
||||||
|
setDebugFlag 131
|
||||||
|
setQDebugFlag 131
|
||||||
|
|
||||||
############################
|
############################
|
||||||
setWal "2"
|
setWal "2"
|
||||||
|
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
./perftest-tsdb-compare-1d.sh "wal2"
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
cd /root
|
|
||||||
./perftest-tsdb-compare-13d.sh "wal2"
|
|
||||||
|
|
||||||
cd /root
|
|
||||||
./perftest-taosdemo.sh "wal2"
|
./perftest-taosdemo.sh "wal2"
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
|
cd $WORK_DIR
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
./perftest-tsdb-compare-1d.sh
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
|
cd $WORK_DIR
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
./perftest-tsdb-compare-13d.sh
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
|
cd $WORK_DIR
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
./perftest-tsdb-compare-var10k-int10s.sh
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
setWal "1"
|
setWal "1"
|
||||||
|
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
./perftest-tsdb-compare-1d.sh "wal1"
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
cd /root
|
|
||||||
./perftest-tsdb-compare-13d.sh "wal1"
|
|
||||||
|
|
||||||
cd /root
|
|
||||||
./perftest-taosdemo.sh "wal1"
|
./perftest-taosdemo.sh "wal1"
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
|
cd $WORK_DIR
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
./perftest-tsdb-compare-1d.sh
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
|
cd $WORK_DIR
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
./perftest-tsdb-compare-13d.sh
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
|
cd $WORK_DIR
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
./perftest-tsdb-compare-var10k-int10s.sh
|
||||||
|
date >> $WORK_DIR/cron.log
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
collectSysInfo
|
collectSysInfo
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
|
||||||
|
walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
if [[ "$walLevel" -eq "2" ]]; then
|
||||||
|
walPostfix="wal2"
|
||||||
|
elif [[ "$walLevel" -eq "1" ]]; then
|
||||||
|
walPostfix="wal1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
|
||||||
# Coloured Echoes
|
# Coloured Echoes
|
||||||
function red_echo { echo -e "\033[31m$@\033[0m"; }
|
function red_echo { echo -e "\033[31m$@\033[0m"; }
|
||||||
function green_echo { echo -e "\033[32m$@\033[0m"; }
|
function green_echo { echo -e "\033[32m$@\033[0m"; }
|
||||||
|
@ -17,13 +32,20 @@ function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf
|
||||||
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; }
|
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; }
|
||||||
|
|
||||||
function restartTaosd {
|
function restartTaosd {
|
||||||
|
echo "Stop taosd"
|
||||||
systemctl stop taosd
|
systemctl stop taosd
|
||||||
pkill -KILL -x taosd
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
sleep 10
|
while [ -n "$PID" ]
|
||||||
|
do
|
||||||
|
pkill -TERM -x taosd
|
||||||
|
sleep 1
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
done
|
||||||
|
|
||||||
rm -rf /mnt/var/log/taos/*
|
rm -rf $logDir/*
|
||||||
rm -rf /mnt/var/lib/taos/*
|
rm -rf $dataDir/*
|
||||||
|
|
||||||
|
echo "Start taosd"
|
||||||
taosd 2>&1 > /dev/null &
|
taosd 2>&1 > /dev/null &
|
||||||
sleep 10
|
sleep 10
|
||||||
}
|
}
|
||||||
|
@ -32,7 +54,7 @@ function runCreateTableOnly {
|
||||||
echoInfo "Restart Taosd"
|
echoInfo "Restart Taosd"
|
||||||
restartTaosd
|
restartTaosd
|
||||||
|
|
||||||
/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -n 0 2>&1 | tee taosdemo-$1-$today.log"
|
/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -n 0 2>&1 | tee taosdemo-$walPostfix-$today.log"
|
||||||
demoCreateTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'`
|
demoCreateTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +62,7 @@ function runDeleteTableOnly {
|
||||||
echoInfo "Restart Taosd"
|
echoInfo "Restart Taosd"
|
||||||
restartTaosd
|
restartTaosd
|
||||||
|
|
||||||
/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -t 0 -D 1 2>&1 | tee taosdemo-$1-$today.log"
|
/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -t 0 -D 1 2>&1 | tee taosdemo-$walPostfix-$today.log"
|
||||||
demoDeleteTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'`
|
demoDeleteTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,41 +70,44 @@ function runCreateTableThenInsert {
|
||||||
echoInfo "Restart Taosd"
|
echoInfo "Restart Taosd"
|
||||||
restartTaosd
|
restartTaosd
|
||||||
|
|
||||||
/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo 2>&1 | tee -a taosdemo-$1-$today.log"
|
/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo 2>&1 | tee -a taosdemo-$walPostfix-$today.log"
|
||||||
demoTableAndInsert=`grep "Total:" totaltime.out|awk '{print $2}'`
|
demoTableAndInsert=`grep "Total:" totaltime.out|awk '{print $2}'`
|
||||||
demoRPS=`grep "records\/second" taosdemo-$1-$today.log | tail -n1 | awk '{print $13}'`
|
demoRPS=`grep "records\/second" taosdemo-$walPostfix-$today.log | tail -n1 | awk '{print $13}'`
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateTaosdemoPlot {
|
function generateTaosdemoPlot {
|
||||||
echo "${today} $1, demoCreateTableOnly: ${demoCreateTableOnly}, demoDeleteTableOnly: ${demoDeleteTableOnly}, demoTableAndInsert: ${demoTableAndInsert}" | tee -a taosdemo-$today.log
|
echo "${today} $walPostfix, demoCreateTableOnly: ${demoCreateTableOnly}, demoDeleteTableOnly: ${demoDeleteTableOnly}, demoTableAndInsert: ${demoTableAndInsert}" | tee -a taosdemo-$today.log
|
||||||
echo "${today}, ${demoCreateTableOnly}, ${demoDeleteTableOnly}, ${demoTableAndInsert}">> taosdemo-$1-report.csv
|
echo "${today}, ${demoCreateTableOnly}, ${demoDeleteTableOnly}, ${demoTableAndInsert}">> taosdemo-$walPostfix-report.csv
|
||||||
echo "${today}, ${demoRPS}" >> taosdemo-rps-$1-report.csv
|
echo "${today}, ${demoRPS}" >> taosdemo-rps-$walPostfix-report.csv
|
||||||
|
|
||||||
csvLines=`cat taosdemo-$1-report.csv | wc -l`
|
csvLines=`cat taosdemo-$walPostfix-report.csv | wc -l`
|
||||||
|
|
||||||
if [ "$csvLines" -gt "10" ]; then
|
if [ "$csvLines" -gt "10" ]; then
|
||||||
sed -i '1d' taosdemo-$1-report.csv
|
sed -i '1d' taosdemo-$walPostfix-report.csv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
csvLines=`cat taosdemo-rps-$1-report.csv | wc -l`
|
csvLines=`cat taosdemo-rps-$walPostfix-report.csv | wc -l`
|
||||||
|
|
||||||
if [ "$csvLines" -gt "10" ]; then
|
if [ "$csvLines" -gt "10" ]; then
|
||||||
sed -i '1d' taosdemo-rps-$1-report.csv
|
sed -i '1d' taosdemo-rps-$walPostfix-report.csv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gnuplot -e "filename='taosdemo-$1-report'" -p taosdemo-csv2png.gnuplot
|
gnuplot -e "filename='taosdemo-$walPostfix-report'" -p taosdemo-csv2png.gnuplot
|
||||||
gnuplot -e "filename='taosdemo-rps-$1-report'" -p taosdemo-rps-csv2png.gnuplot
|
gnuplot -e "filename='taosdemo-rps-$walPostfix-report'" -p taosdemo-rps-csv2png.gnuplot
|
||||||
}
|
}
|
||||||
|
|
||||||
today=`date +"%Y%m%d"`
|
today=`date +"%Y%m%d"`
|
||||||
|
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
echoInfo "Test Create Table Only "
|
echoInfo "Test Create Table Only "
|
||||||
runCreateTableOnly $1
|
runCreateTableOnly
|
||||||
echoInfo "Test Create Table then Insert data"
|
echoInfo "Test Create Table then Insert data"
|
||||||
runDeleteTableOnly $1
|
runDeleteTableOnly
|
||||||
echoInfo "Test Create Table then Insert data"
|
echoInfo "Test Create Table then Insert data"
|
||||||
runCreateTableThenInsert $1
|
runCreateTableThenInsert
|
||||||
echoInfo "Generate plot for taosdemo"
|
echoInfo "Generate plot for taosdemo"
|
||||||
generateTaosdemoPlot $1
|
generateTaosdemoPlot
|
||||||
echoInfo "End of TaosDemo Test"
|
|
||||||
|
tar czf $WORK_DIR/taos-log-taosdemo-$today.tar.gz $logDir/*
|
||||||
|
|
||||||
|
echoInfo "End of TaosDemo Test" | tee -a $WORK_DIR/cron.log
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare
|
||||||
|
|
||||||
|
walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
if [[ "$walLevel" -eq "2" ]]; then
|
||||||
|
walPostfix="wal2"
|
||||||
|
elif [[ "$walLevel" -eq "1" ]]; then
|
||||||
|
walPostfix="wal1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
|
||||||
# Coloured Echoes #
|
# Coloured Echoes #
|
||||||
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||||
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
||||||
|
@ -17,13 +33,20 @@ function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf
|
||||||
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
|
||||||
function restartTaosd {
|
function restartTaosd {
|
||||||
|
echo "Stop taosd"
|
||||||
systemctl stop taosd
|
systemctl stop taosd
|
||||||
pkill -KILL -x taosd
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
sleep 10
|
while [ -n "$PID" ]
|
||||||
|
do
|
||||||
|
pkill -TERM -x taosd
|
||||||
|
sleep 1
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
done
|
||||||
|
|
||||||
rm -rf /mnt/var/log/taos/*
|
rm -rf $logDir/*
|
||||||
rm -rf /mnt/var/lib/taos/*
|
rm -rf $dataDir/*
|
||||||
|
|
||||||
|
echo "Start taosd"
|
||||||
taosd 2>&1 > /dev/null &
|
taosd 2>&1 > /dev/null &
|
||||||
sleep 10
|
sleep 10
|
||||||
}
|
}
|
||||||
|
@ -32,27 +55,30 @@ function runPerfTest13d {
|
||||||
echoInfo "Restart Taosd"
|
echoInfo "Restart Taosd"
|
||||||
restartTaosd
|
restartTaosd
|
||||||
|
|
||||||
cd /home/taos/tliu/timeseriesdatabase-comparisons/build/tsdbcompare
|
cd $WORK_DIR/$TSDB_CMP_DIR
|
||||||
./runreal-13d-csv.sh $1 2>&1 | tee /root/perftest-13d-$1-$today.log
|
./runTDengine.sh -d 13 -w -q 2>&1 | tee $WORK_DIR/perftest-13d-$walPostfix-$today.log
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatePerfPlot13d {
|
function generatePerfPlot13d {
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
|
|
||||||
csvLines=`cat perftest-13d-$1-report.csv | wc -l`
|
csvLines=`cat perftest-13d-$walPostfix-report.csv | wc -l`
|
||||||
|
|
||||||
if [ "$csvLines" -gt "10" ]; then
|
if [ "$csvLines" -gt "10" ]; then
|
||||||
sed -i '1d' perftest-13d-$1-report.csv
|
sed -i '1d' perftest-13d-$walPostfix-report.csv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gnuplot -e "filename='perftest-13d-$1-report'" -p perftest-csv2png.gnuplot
|
gnuplot -e "filename='perftest-13d-$walPostfix-report'" -p perftest-csv2png.gnuplot
|
||||||
}
|
}
|
||||||
|
|
||||||
today=`date +"%Y%m%d"`
|
today=`date +"%Y%m%d"`
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
|
|
||||||
echoInfo "run Performance Test with 13 days data"
|
echoInfo "run Performance Test with 13 days data"
|
||||||
runPerfTest13d $1
|
runPerfTest13d $1
|
||||||
echoInfo "Generate plot of 13 days data"
|
echoInfo "Generate plot of 13 days data"
|
||||||
generatePerfPlot13d $1
|
generatePerfPlot13d $1
|
||||||
echoInfo "End of TSDB-Compare 13-days-data Test"
|
|
||||||
|
tar czf $WORK_DIR/taos-log-13d-$today.tar.gz $logDir/*
|
||||||
|
|
||||||
|
echoInfo "End of TSDB-Compare 13-days-data Test" | tee -a $WORK_DIR/cron.log
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare
|
||||||
|
|
||||||
|
walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
if [[ "$walLevel" -eq "2" ]]; then
|
||||||
|
walPostfix="wal2"
|
||||||
|
elif [[ "$walLevel" -eq "1" ]]; then
|
||||||
|
walPostfix="wal1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
|
||||||
# Coloured Echoes #
|
# Coloured Echoes #
|
||||||
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||||
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
||||||
|
@ -17,13 +33,20 @@ function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf
|
||||||
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
|
||||||
function restartTaosd {
|
function restartTaosd {
|
||||||
|
echo "Stop taosd"
|
||||||
systemctl stop taosd
|
systemctl stop taosd
|
||||||
pkill -KILL -x taosd
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
sleep 10
|
while [ -n "$PID" ]
|
||||||
|
do
|
||||||
|
pkill -TERM -x taosd
|
||||||
|
sleep 1
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
done
|
||||||
|
|
||||||
rm -rf /mnt/var/log/taos/*
|
rm -rf $logDir/*
|
||||||
rm -rf /mnt/var/lib/taos/*
|
rm -rf $dataDir/*
|
||||||
|
|
||||||
|
echo "Start taosd"
|
||||||
taosd 2>&1 > /dev/null &
|
taosd 2>&1 > /dev/null &
|
||||||
sleep 10
|
sleep 10
|
||||||
}
|
}
|
||||||
|
@ -32,27 +55,30 @@ function runPerfTest1d {
|
||||||
echoInfo "Restart Taosd"
|
echoInfo "Restart Taosd"
|
||||||
restartTaosd
|
restartTaosd
|
||||||
|
|
||||||
cd /home/taos/tliu/timeseriesdatabase-comparisons/build/tsdbcompare
|
cd $WORK_DIR/$TSDB_CMP_DIR
|
||||||
./runreal-1d-csv.sh $1 2>&1 | tee /root/perftest-1d-$1-$today.log
|
./runTDengine.sh -d 1 -w -q 2>&1 | tee $WORK_DIR/perftest-1d-$walPostfix-$today.log
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatePerfPlot1d {
|
function generatePerfPlot1d {
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
|
|
||||||
csvLines=`cat perftest-1d-$1-report.csv | wc -l`
|
csvLines=`cat perftest-1d-$walPostfix-report.csv | wc -l`
|
||||||
|
|
||||||
if [ "$csvLines" -gt "10" ]; then
|
if [ "$csvLines" -gt "10" ]; then
|
||||||
sed -i '2d' perftest-1d-$1-report.csv
|
sed -i '1d' perftest-1d-$walPostfix-report.csv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gnuplot -e "filename='perftest-1d-$1-report'" -p perftest-csv2png.gnuplot
|
gnuplot -e "filename='perftest-1d-$walPostfix-report'" -p perftest-csv2png.gnuplot
|
||||||
}
|
}
|
||||||
|
|
||||||
today=`date +"%Y%m%d"`
|
today=`date +"%Y%m%d"`
|
||||||
cd /root
|
cd $WORK_DIR
|
||||||
|
|
||||||
echoInfo "run Performance Test with 1 day data"
|
echoInfo "run Performance Test with 1 day data"
|
||||||
runPerfTest1d $1
|
runPerfTest1d
|
||||||
echoInfo "Generate plot of 1 day data"
|
echoInfo "Generate plot of 1 day data"
|
||||||
generatePerfPlot1d $1
|
generatePerfPlot1d
|
||||||
echoInfo "End of TSDB-Compare 1-day-data Test"
|
|
||||||
|
tar czf $WORK_DIR/taos-log-1d-$today.tar.gz $logDir/*
|
||||||
|
|
||||||
|
echoInfo "End of TSDB-Compare 1-day-data Test" | tee -a $WORK_DIR/cron.log
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare
|
||||||
|
|
||||||
|
walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
if [[ "$walLevel" -eq "2" ]]; then
|
||||||
|
walPostfix="wal2"
|
||||||
|
elif [[ "$walLevel" -eq "1" ]]; then
|
||||||
|
walPostfix="wal1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
|
||||||
|
# Coloured Echoes #
|
||||||
|
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||||
|
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
||||||
|
function yellow_echo { echo -e "\033[33m$@\033[0m"; } #
|
||||||
|
function white_echo { echo -e "\033[1;37m$@\033[0m"; } #
|
||||||
|
# Coloured Printfs #
|
||||||
|
function red_printf { printf "\033[31m$@\033[0m"; } #
|
||||||
|
function green_printf { printf "\033[32m$@\033[0m"; } #
|
||||||
|
function yellow_printf { printf "\033[33m$@\033[0m"; } #
|
||||||
|
function white_printf { printf "\033[1;37m$@\033[0m"; } #
|
||||||
|
# Debugging Outputs #
|
||||||
|
function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } #
|
||||||
|
function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } #
|
||||||
|
function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
|
||||||
|
function restartTaosd {
|
||||||
|
echo "Stop taosd"
|
||||||
|
systemctl stop taosd
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
while [ -n "$PID" ]
|
||||||
|
do
|
||||||
|
pkill -TERM -x taosd
|
||||||
|
sleep 1
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf $logDir/*
|
||||||
|
rm -rf $dataDir/*
|
||||||
|
|
||||||
|
echo "Start taosd"
|
||||||
|
taosd 2>&1 > /dev/null &
|
||||||
|
sleep 10
|
||||||
|
}
|
||||||
|
|
||||||
|
function runPerfTestVar10K {
|
||||||
|
echoInfo "Restart Taosd"
|
||||||
|
restartTaosd
|
||||||
|
|
||||||
|
cd $WORK_DIR/$TSDB_CMP_DIR
|
||||||
|
./runTDengine.sh -v 10000 -i 100 -w -q 2>&1 | tee $WORK_DIR/perftest-var10k-int100s-$walPostfix-$today.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function generatePerfPlotVar10K {
|
||||||
|
cd $WORK_DIR
|
||||||
|
|
||||||
|
csvLines=`cat perftest-var10k-int100s-$walPostfix-report.csv | wc -l`
|
||||||
|
|
||||||
|
if [ "$csvLines" -gt "10" ]; then
|
||||||
|
sed -i '1d' perftest-var10k-int100s-$walPostfix-report.csv
|
||||||
|
fi
|
||||||
|
|
||||||
|
gnuplot -e "filename='perftest-var10k-int100s-$walPostfix-report'" -p perftest-csv2png.gnuplot
|
||||||
|
}
|
||||||
|
|
||||||
|
today=`date +"%Y%m%d"`
|
||||||
|
cd $WORK_DIR
|
||||||
|
|
||||||
|
echoInfo "run Performance Test with 10K tables data"
|
||||||
|
runPerfTestVar10K
|
||||||
|
echoInfo "Generate plot of 10K tables data"
|
||||||
|
generatePerfPlotVar10K
|
||||||
|
|
||||||
|
tar czf $WORK_DIR/taos-log-var10k-int100s-$today.tar.gz $logDir/*
|
||||||
|
|
||||||
|
echoInfo "End of TSDB-Compare var10k-int100s-tables-data Test" | tee -a $WORK_DIR/cron.log
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare
|
||||||
|
|
||||||
|
walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
if [[ "$walLevel" -eq "2" ]]; then
|
||||||
|
walPostfix="wal2"
|
||||||
|
elif [[ "$walLevel" -eq "1" ]]; then
|
||||||
|
walPostfix="wal1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
|
||||||
|
# Coloured Echoes #
|
||||||
|
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||||
|
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
||||||
|
function yellow_echo { echo -e "\033[33m$@\033[0m"; } #
|
||||||
|
function white_echo { echo -e "\033[1;37m$@\033[0m"; } #
|
||||||
|
# Coloured Printfs #
|
||||||
|
function red_printf { printf "\033[31m$@\033[0m"; } #
|
||||||
|
function green_printf { printf "\033[32m$@\033[0m"; } #
|
||||||
|
function yellow_printf { printf "\033[33m$@\033[0m"; } #
|
||||||
|
function white_printf { printf "\033[1;37m$@\033[0m"; } #
|
||||||
|
# Debugging Outputs #
|
||||||
|
function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } #
|
||||||
|
function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } #
|
||||||
|
function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
||||||
|
|
||||||
|
function restartTaosd {
|
||||||
|
echo "Stop taosd"
|
||||||
|
systemctl stop taosd
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
while [ -n "$PID" ]
|
||||||
|
do
|
||||||
|
pkill -TERM -x taosd
|
||||||
|
sleep 1
|
||||||
|
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf $logDir/*
|
||||||
|
rm -rf $dataDir/*
|
||||||
|
|
||||||
|
echo "Start taosd"
|
||||||
|
taosd 2>&1 > /dev/null &
|
||||||
|
sleep 10
|
||||||
|
}
|
||||||
|
|
||||||
|
function runPerfTestVar10K {
|
||||||
|
echoInfo "Restart Taosd"
|
||||||
|
restartTaosd
|
||||||
|
|
||||||
|
cd $WORK_DIR/$TSDB_CMP_DIR
|
||||||
|
./runTDengine.sh -v 10000 -w -q 2>&1 | tee $WORK_DIR/perftest-var10k-int10s-$walPostfix-$today.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function generatePerfPlotVar10K {
|
||||||
|
cd $WORK_DIR
|
||||||
|
|
||||||
|
csvLines=`cat perftest-var10k-int10s-$walPostfix-report.csv | wc -l`
|
||||||
|
|
||||||
|
if [ "$csvLines" -gt "10" ]; then
|
||||||
|
sed -i '1d' perftest-var10k-int10s-$walPostfix-report.csv
|
||||||
|
fi
|
||||||
|
|
||||||
|
gnuplot -e "filename='perftest-var10k-int10s-$walPostfix-report'" -p perftest-csv2png.gnuplot
|
||||||
|
}
|
||||||
|
|
||||||
|
today=`date +"%Y%m%d"`
|
||||||
|
cd $WORK_DIR
|
||||||
|
|
||||||
|
echoInfo "run Performance Test with 10K tables data"
|
||||||
|
runPerfTestVar10K
|
||||||
|
echoInfo "Generate plot of 10K tables data"
|
||||||
|
generatePerfPlotVar10K
|
||||||
|
|
||||||
|
tar czf $WORK_DIR/taos-log-var10k-int10s-$today.tar.gz $logDir/*
|
||||||
|
|
||||||
|
echoInfo "End of TSDB-Compare var10k-int10s-tables-data Test" | tee -a $WORK_DIR/cron.log
|
|
@ -0,0 +1,251 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
DATA_DIR=/mnt/data
|
||||||
|
|
||||||
|
# Color setting
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
GREEN_DARK='\033[0;32m'
|
||||||
|
GREEN_UNDERLINE='\033[4;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
# default value
|
||||||
|
DEFAULT_BATCH=5000
|
||||||
|
DEFAULT_DAYS=1
|
||||||
|
DEFAULT_INTERVAL=1
|
||||||
|
DEFAULT_SCALEVAR=10
|
||||||
|
DEFAULT_DOPREPARE=false
|
||||||
|
DEFAULT_DOWRITE=false
|
||||||
|
DEFAULT_DOQUERY=false
|
||||||
|
|
||||||
|
# function
|
||||||
|
function do_prepare {
|
||||||
|
echo
|
||||||
|
echo "---------------Generating Data-----------------"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Prepare data for InfluxDB...."
|
||||||
|
|
||||||
|
echo "bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval $interval_s \
|
||||||
|
-scale-var $scalevar -use-case devops -timestamp-start $TIME_START \
|
||||||
|
-timestamp-end $TIME_END > $DATA_FILE"
|
||||||
|
|
||||||
|
bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval $interval_s \
|
||||||
|
-scale-var $scalevar -use-case devops -timestamp-start $TIME_START \
|
||||||
|
-timestamp-end $TIME_END > $DATA_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_write {
|
||||||
|
echo "cat $DATA_FILE | bin/bulk_load_influx \
|
||||||
|
--batch-size=$batch --workers=20 --urls=http://172.15.1.5:8086 | grep loaded"
|
||||||
|
INFLUXRES=`cat $DATA_FILE | bin/bulk_load_influx \
|
||||||
|
--batch-size=$batch --workers=20 --urls="http://172.15.1.5:8086" | grep loaded`
|
||||||
|
|
||||||
|
echo -e "${GREEN}InfluxDB writing result:${NC}"
|
||||||
|
echo -e "${GREEN}$INFLUXRES${NC}"
|
||||||
|
DATA=`echo $INFLUXRES|awk '{print($2)}'`
|
||||||
|
TMP=`echo $INFLUXRES|awk '{print($5)}'`
|
||||||
|
IFWTM=`echo ${TMP%s*}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_query {
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "------------------Querying Data-----------------"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "start query test, query max from 8 hosts group by 1 hour, InfluxDB"
|
||||||
|
echo
|
||||||
|
|
||||||
|
#Test case 1
|
||||||
|
#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ;
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers.
|
||||||
|
echo "IFQS1=bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-all -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
IFQS1=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-all -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo -e "${GREEN}InfluxDB query test case 1 result:${NC}"
|
||||||
|
echo -e "${GREEN}$IFQS1${NC}"
|
||||||
|
TMP=`echo $IFQS1|awk '{print($4)}'`
|
||||||
|
IFQ1=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
#Test case 2
|
||||||
|
#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h);
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers
|
||||||
|
echo "IFQS2=bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-allbyhr -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls=http://172.15.1.5:8086 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
IFQS2=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-allbyhr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb \
|
||||||
|
-urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo -e "${GREEN}InfluxDB query test case 2 result:${NC}"
|
||||||
|
echo -e "${GREEN}$IFQS2${NC}"
|
||||||
|
TMP=`echo $IFQS2|awk '{print($4)}'`
|
||||||
|
IFQ2=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
#Test case 3
|
||||||
|
#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time <y interval(10m);
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers, y-x =12 hour
|
||||||
|
echo "IFQS3=bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-12-hr -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls=http://172.15.1.5:8086 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
IFQS3=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-12-hr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb \
|
||||||
|
-urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo -e "${GREEN}InfluxDB query test case 3 result:${NC}"
|
||||||
|
echo -e "${GREEN}$IFQS3${NC}"
|
||||||
|
TMP=`echo $IFQS3|awk '{print($4)}'`
|
||||||
|
IFQ3=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
#Test case 4
|
||||||
|
#测试用例4,随机查询1个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1分钟为粒度,查询每1分钟的最大值
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time <y interval(10m);
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers, y-x =1 hours
|
||||||
|
echo "IFQS4=bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-1-hr -scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb -urls=http://172.15.1.5:8086 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
IFQS4=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-1-hr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_influxdb \
|
||||||
|
-urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo -e "${GREEN}InfluxDB query test case 4 result:${NC}"
|
||||||
|
echo -e "${GREEN}$IFQS4${NC}"
|
||||||
|
TMP=`echo $IFQS4|awk '{print($4)}'`
|
||||||
|
IFQ4=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
batch=$DEFAULT_BATCH
|
||||||
|
days=$DEFAULT_DAYS
|
||||||
|
interval=$DEFAULT_INTERVAL
|
||||||
|
scalevar=$DEFAULT_SCALEVAR
|
||||||
|
doprepare=$DEFAULT_DOPREPARE
|
||||||
|
dowrite=$DEFAULT_DOWRITE
|
||||||
|
doquery=$DEFAULT_DOQUERY
|
||||||
|
|
||||||
|
help="$(basename "$0") [-h] [-b batchsize] [-d data-of-days] [-i interval] [-v scalevar] [-p false for don't prepare] [-w false for don't do write] [-q false for don't do query]"
|
||||||
|
|
||||||
|
while getopts ':b:d:i:v:pwqh' flag; do
|
||||||
|
case "${flag}" in
|
||||||
|
b) batch=${OPTARG};;
|
||||||
|
d) days=${OPTARG};;
|
||||||
|
i) interval=${OPTARG};;
|
||||||
|
v) scalevar=${OPTARG};;
|
||||||
|
p) doprepare=${OPTARG};;
|
||||||
|
w) dowrite=${OPTARG};;
|
||||||
|
q) doquery=${OPTARG};;
|
||||||
|
:) echo -e "{RED}Missing argument!{NC}"
|
||||||
|
echo "$help"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
h) echo "$help"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $scalevar -eq 10000 ]]
|
||||||
|
then
|
||||||
|
TIME_START="2018-01-01T00:00:00Z"
|
||||||
|
TIME_END="2018-01-02T00:00:00Z"
|
||||||
|
|
||||||
|
if [[ $interval -eq 100 ]]
|
||||||
|
then
|
||||||
|
interval_s=100s
|
||||||
|
DATA_FILE=$DATA_DIR/influxdb-var10k-int100s.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-influxdb-report-var10k-int100s.csv
|
||||||
|
else
|
||||||
|
interval_s=10s
|
||||||
|
DATA_FILE=$DATA_DIR/influxdb-var10k-int10s.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-influxdb-report-var10k-int10s.csv
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ $days -eq 1 ]]
|
||||||
|
then
|
||||||
|
TIME_START="2018-01-01T00:00:00Z"
|
||||||
|
TIME_END="2018-01-02T00:00:00Z"
|
||||||
|
DATA_FILE=$DATA_DIR/influxdb-1d.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-influxdb-report-1d.csv
|
||||||
|
elif [[ $days -eq 13 ]]
|
||||||
|
then
|
||||||
|
TIME_START="2018-01-01T00:00:00Z"
|
||||||
|
TIME_END="2018-01-14T00:00:00Z"
|
||||||
|
DATA_FILE=$DATA_DIR/influxdb-13d.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-influxdb-report-13d.csv
|
||||||
|
else
|
||||||
|
echo -e "{RED} don't support input $days{NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
interval_s=${interval}s
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "TIME_START: $TIME_START, TIME_END: $TIME_END, DATA_FILE: $DATA_FILE"
|
||||||
|
echo "doprepare: $doprepare, dowrite: $dowrite, doquery: $doquery"
|
||||||
|
|
||||||
|
if $doprepare;
|
||||||
|
then
|
||||||
|
do_prepare
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker network create --ip-range 172.15.1.255/24 --subnet 172.15.1.1/16 tsdbcomp >>/dev/null 2>&1
|
||||||
|
INFLUX=`docker run -d -p 8086:8086 --net tsdbcomp --ip 172.15.1.5 influxdb` >>/dev/null 2>&1
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
if $dowrite;
|
||||||
|
then
|
||||||
|
echo -e "Start test InfluxDB writting, result in ${GREEN}Green line${NC}"
|
||||||
|
do_write
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $doquery;
|
||||||
|
then
|
||||||
|
echo -e "Start test InfluxDB query, result in ${GREEN}Green line${NC}"
|
||||||
|
do_query
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "======================================================"
|
||||||
|
echo " tsdb performance comparision "
|
||||||
|
echo "======================================================"
|
||||||
|
if $dowrite;
|
||||||
|
then
|
||||||
|
echo -e " Writing $DATA records test takes: "
|
||||||
|
printf " InfluxDB | %-4.5f Seconds \n" $IFWTM
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $doquery;
|
||||||
|
then
|
||||||
|
echo " Query test cases: "
|
||||||
|
echo " case 1: select the max(value) from all data "
|
||||||
|
echo " filtered out 8 hosts "
|
||||||
|
echo " Query test case 1 takes: "
|
||||||
|
printf " InfluxDB | %-4.5f Seconds \n" $IFQ1
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo " case 2: select the max(value) from all data "
|
||||||
|
echo " filtered out 8 hosts with an interval of 1 hour "
|
||||||
|
echo " case 2 takes: "
|
||||||
|
printf " InfluxDB | %-4.5f Seconds \n" $IFQ2
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo " case 3: select the max(value) from random 12 hours"
|
||||||
|
echo " data filtered out 8 hosts with an interval of 10 min "
|
||||||
|
echo " filtered out 8 hosts interval(1h) "
|
||||||
|
echo " case 3 takes: "
|
||||||
|
printf " InfluxDB | %-4.5f Seconds \n" $IFQ3
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo " case 4: select the max(value) from random 1 hour data "
|
||||||
|
echo " data filtered out 8 hosts with an interval of 1 min "
|
||||||
|
echo " case 4 takes: "
|
||||||
|
printf " InfluxDB | %-4.5f Seconds \n" $IFQ4
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker stop $INFLUX >>/dev/null 2>&1
|
||||||
|
docker container rm -f $INFLUX >>/dev/null 2>&1
|
||||||
|
docker network rm tsdbcomp >>/dev/null 2>&1
|
||||||
|
|
||||||
|
today=`date +"%Y%m%d"`
|
||||||
|
echo "${today}, ${IFWTM}, ${IFQ1}, ${IFQ2}, ${IFQ3}, ${IFQ4}" >> $RECORD_CSV_FILE
|
|
@ -0,0 +1,283 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
WORK_DIR=/mnt/root
|
||||||
|
DATA_DIR=/mnt/data
|
||||||
|
|
||||||
|
# Color setting
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
GREEN_DARK='\033[0;32m'
|
||||||
|
GREEN_UNDERLINE='\033[4;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
# default value
|
||||||
|
DEFAULT_BATCH=5000
|
||||||
|
DEFAULT_DAYS=1
|
||||||
|
DEFAULT_INTERVAL=1
|
||||||
|
DEFAULT_SCALEVAR=10
|
||||||
|
DEFAULT_DOPREPARE=false
|
||||||
|
DEFAULT_DOWRITE=false
|
||||||
|
DEFAULT_DOQUERY=false
|
||||||
|
|
||||||
|
# function
|
||||||
|
function do_prepare {
|
||||||
|
echo
|
||||||
|
echo "---------------Generating Data-----------------"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Prepare data for TDengine...."
|
||||||
|
|
||||||
|
# bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > $DATA_DIR/tdengine.dat
|
||||||
|
echo "bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval $interval_s \
|
||||||
|
-tdschema-file config/TDengineSchema.toml -scale-var $scalevar \
|
||||||
|
-use-case devops -timestamp-start $TIME_START \
|
||||||
|
-timestamp-end $TIME_END \
|
||||||
|
> $DATA_FILE"
|
||||||
|
|
||||||
|
bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval $interval_s \
|
||||||
|
-tdschema-file config/TDengineSchema.toml -scale-var $scalevar \
|
||||||
|
-use-case devops -timestamp-start $TIME_START \
|
||||||
|
-timestamp-end $TIME_END \
|
||||||
|
> $DATA_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_write {
|
||||||
|
echo "TDENGINERES=cat $DATA_FILE |bin/bulk_load_tdengine --url 127.0.0.1:0 \
|
||||||
|
--batch-size $batch -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded"
|
||||||
|
|
||||||
|
TDENGINERES=`cat $DATA_FILE |bin/bulk_load_tdengine --url 127.0.0.1:0 \
|
||||||
|
--batch-size $batch -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded`
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}TDengine writing result:${NC}"
|
||||||
|
echo -e "${GREEN}$TDENGINERES${NC}"
|
||||||
|
DATA=`echo $TDENGINERES|awk '{print($2)}'`
|
||||||
|
TMP=`echo $TDENGINERES|awk '{print($5)}'`
|
||||||
|
TDWTM=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_query {
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "------------------Querying Data-----------------"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "start query test, query max from 8 hosts group by 1 hour, TDengine"
|
||||||
|
echo
|
||||||
|
|
||||||
|
#Test case 1
|
||||||
|
#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ;
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers.
|
||||||
|
echo "TDQS1=bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls=http://127.0.0.1:6020 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}TDengine query test case 1 result:${NC}"
|
||||||
|
echo -e "${GREEN}$TDQS1${NC}"
|
||||||
|
TMP=`echo $TDQS1|awk '{print($4)}'`
|
||||||
|
TDQ1=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
#Test case 2
|
||||||
|
#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h);
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers
|
||||||
|
echo "TDQS2=bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls=http://127.0.0.1:6020 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall`
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}TDengine query test case 2 result:${NC}"
|
||||||
|
echo -e "${GREEN}$TDQS2${NC}"
|
||||||
|
TMP=`echo $TDQS2|awk '{print($4)}'`
|
||||||
|
TDQ2=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
#Test case 3
|
||||||
|
#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time <y interval(10m);
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers, y-x =12 hour
|
||||||
|
echo "TDQS3=bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-12-hr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls=http://127.0.0.1:6020 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
TDQS3=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-12-hr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}TDengine query test case 3 result:${NC}"
|
||||||
|
echo -e "${GREEN}$TDQS3${NC}"
|
||||||
|
TMP=`echo $TDQS3|awk '{print($4)}'`
|
||||||
|
TDQ3=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
#Test case 4
|
||||||
|
#测试用例4,随机查询1个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1分钟为粒度,查询每1分钟的最大值
|
||||||
|
#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time <y interval(10m);
|
||||||
|
# a,b,c,d,e,f,g,h are random 8 numbers, y-x =1 hours
|
||||||
|
echo "TDQS4=bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-1-hr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls=http://127.0.0.1:6020 -workers 50 -print-interval 0|grep wall"
|
||||||
|
|
||||||
|
TDQS4=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-1-hr \
|
||||||
|
-scale-var $scalevar -queries 1000 | bin/query_benchmarker_tdengine \
|
||||||
|
-urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall`
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN}TDengine query test case 4 result:${NC}"
|
||||||
|
echo -e "${GREEN}$TDQS4${NC}"
|
||||||
|
TMP=`echo $TDQS4|awk '{print($4)}'`
|
||||||
|
TDQ4=`echo ${TMP%s*}`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
batch=$DEFAULT_BATCH
|
||||||
|
days=$DEFAULT_DAYS
|
||||||
|
interval=$DEFAULT_INTERVAL
|
||||||
|
scalevar=$DEFAULT_SCALEVAR
|
||||||
|
doprepare=$DEFAULT_DOPREPARE
|
||||||
|
dowrite=$DEFAULT_DOWRITE
|
||||||
|
doquery=$DEFAULT_DOQUERY
|
||||||
|
|
||||||
|
help="$(basename "$0") [-h] [-b batchsize] [-d data-of-days] [-i interval] [-v scalevar] [-p false for don't prepare] [-w false for don't do write] [-q false for don't do query]"
|
||||||
|
|
||||||
|
while getopts ':b:d:i:v:pwqh' flag; do
|
||||||
|
case "${flag}" in
|
||||||
|
b) batch=${OPTARG};;
|
||||||
|
d) days=${OPTARG};;
|
||||||
|
i) interval=${OPTARG};;
|
||||||
|
v) scalevar=${OPTARG};;
|
||||||
|
p) doprepare=${OPTARG};;
|
||||||
|
w) dowrite=${OPTARG};;
|
||||||
|
q) doquery=${OPTARG};;
|
||||||
|
:) echo -e "{RED}Missing argument!{NC}"
|
||||||
|
echo "$help"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
h) echo "$help"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
|
||||||
|
if [[ "$walLevel" -eq "2" ]]; then
|
||||||
|
walPostfix="wal2"
|
||||||
|
elif [[ "$walLevel" -eq "1" ]]; then
|
||||||
|
walPostfix="wal1"
|
||||||
|
else
|
||||||
|
echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN} $walPostfix found! ${NC}"
|
||||||
|
|
||||||
|
if [[ $scalevar -eq 10000 ]]
|
||||||
|
then
|
||||||
|
TIME_START="2018-01-01T00:00:00Z"
|
||||||
|
TIME_END="2018-01-02T00:00:00Z"
|
||||||
|
|
||||||
|
if [[ $interval -eq 100 ]]
|
||||||
|
then
|
||||||
|
interval_s=100s
|
||||||
|
DATA_FILE=$DATA_DIR/tdengine-var10k-int100s.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-var10k-int100s-$walPostfix-report.csv
|
||||||
|
else
|
||||||
|
interval_s=10s
|
||||||
|
DATA_FILE=$DATA_DIR/tdengine-var10k-int10s.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-var10k-int10s-$walPostfix-report.csv
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ $days -eq 1 ]]
|
||||||
|
then
|
||||||
|
TIME_START="2018-01-01T00:00:00Z"
|
||||||
|
TIME_END="2018-01-02T00:00:00Z"
|
||||||
|
DATA_FILE=$DATA_DIR/tdengine-1d.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-1d-$walPostfix-report.csv
|
||||||
|
elif [[ $days -eq 13 ]]
|
||||||
|
then
|
||||||
|
TIME_START="2018-01-01T00:00:00Z"
|
||||||
|
TIME_END="2018-01-14T00:00:00Z"
|
||||||
|
DATA_FILE=$DATA_DIR/tdengine-13d.dat
|
||||||
|
RECORD_CSV_FILE=$WORK_DIR/perftest-13d-$walPostfix-report.csv
|
||||||
|
else
|
||||||
|
echo -e "{RED} don't support input $days{NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
interval_s=${interval}s
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "TIME_START: $TIME_START, TIME_END: $TIME_END, DATA_FILE: $DATA_FILE"
|
||||||
|
echo "doprepare: $doprepare, dowrite: $dowrite, doquery: $doquery"
|
||||||
|
|
||||||
|
if $doprepare;
|
||||||
|
then
|
||||||
|
do_prepare
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
if $dowrite;
|
||||||
|
then
|
||||||
|
echo -e "Start test TDengine writting, result in ${GREEN}Green line${NC}"
|
||||||
|
do_write
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $doquery;
|
||||||
|
then
|
||||||
|
echo -e "Start test TDengine query, result in ${GREEN}Green line${NC}"
|
||||||
|
do_query
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "======================================================"
|
||||||
|
echo " tsdb performance comparision "
|
||||||
|
echo "======================================================"
|
||||||
|
if $dowrite;
|
||||||
|
then
|
||||||
|
echo -e " Writing $DATA records test takes: "
|
||||||
|
printf " TDengine | %-4.5f Seconds \n" $TDWTM
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $doquery;
|
||||||
|
then
|
||||||
|
echo " Query test cases: "
|
||||||
|
echo " case 1: select the max(value) from all data "
|
||||||
|
echo " filtered out 8 hosts "
|
||||||
|
echo " Query test case 1 takes: "
|
||||||
|
printf " TDengine | %-4.5f Seconds \n" $TDQ1
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo " case 2: select the max(value) from all data "
|
||||||
|
echo " filtered out 8 hosts with an interval of 1 hour "
|
||||||
|
echo " case 2 takes: "
|
||||||
|
printf " TDengine | %-4.5f Seconds \n" $TDQ2
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo " case 3: select the max(value) from random 12 hours"
|
||||||
|
echo " data filtered out 8 hosts with an interval of 10 min "
|
||||||
|
echo " filtered out 8 hosts interval(1h) "
|
||||||
|
echo " case 3 takes: "
|
||||||
|
printf " TDengine | %-4.5f Seconds \n" $TDQ3
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
echo " case 4: select the max(value) from random 1 hour data "
|
||||||
|
echo " data filtered out 8 hosts with an interval of 1 min "
|
||||||
|
echo " case 4 takes: "
|
||||||
|
printf " TDengine | %-4.5f Seconds \n" $TDQ4
|
||||||
|
echo "------------------------------------------------------"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086"
|
||||||
|
#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020"
|
||||||
|
today=`date +"%Y%m%d"`
|
||||||
|
echo "${today}, ${TDWTM}, ${TDQ1}, ${TDQ2}, ${TDQ3}, ${TDQ4}" >> $RECORD_CSV_FILE
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/user/bin/gnuplot
|
||||||
|
reset
|
||||||
|
set terminal png
|
||||||
|
|
||||||
|
set title filename font ",20"
|
||||||
|
|
||||||
|
set ylabel "Time in Seconds"
|
||||||
|
|
||||||
|
set xdata time
|
||||||
|
set timefmt "%Y%m%d"
|
||||||
|
set format x "%Y-%m-%d"
|
||||||
|
set xlabel "Date"
|
||||||
|
|
||||||
|
set style data linespoints
|
||||||
|
|
||||||
|
set terminal pngcairo size 1024,768 enhanced font 'Segoe UI, 10'
|
||||||
|
set output filename . '.png'
|
||||||
|
set datafile separator ','
|
||||||
|
|
||||||
|
set key reverse Left outside
|
||||||
|
set grid
|
||||||
|
|
||||||
|
|
||||||
|
plot filename . '.csv' using 1:2 title "Request Per Second"
|
|
@ -79,10 +79,6 @@ class TDTestCase:
|
||||||
"select * from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
"select * from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
tdSql.checkRows(6)
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
tdSql.query(
|
|
||||||
"select * from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id order by ts desc")
|
|
||||||
tdSql.checkColumnSorted(0, "desc")
|
|
||||||
|
|
||||||
tdSql.error(
|
tdSql.error(
|
||||||
"select ts, pressure, temperature, id, dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
"select ts, pressure, temperature, id, dscrption from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
|
|
||||||
|
@ -116,8 +112,7 @@ class TDTestCase:
|
||||||
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
|
||||||
tdSql.checkRows(6)
|
tdSql.checkRows(6)
|
||||||
|
|
||||||
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.pid, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id")
|
tdSql.error("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.pid, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id")
|
||||||
tdSql.checkRows(2)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is proprietary and confidential to TAOS Technologies.
|
||||||
|
# No part of this file may be reproduced, stored, transmitted,
|
||||||
|
# disclosed or used in any form or by any means other than as
|
||||||
|
# expressly provided by the written permission from Jianhui Tao
|
||||||
|
#
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import taos
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class MetadataQuery:
|
||||||
|
def initConnection(self):
|
||||||
|
self.tables = 100000
|
||||||
|
self.records = 10
|
||||||
|
self.numOfTherads = 10
|
||||||
|
self.ts = 1537146000000
|
||||||
|
self.host = "127.0.0.1"
|
||||||
|
self.user = "root"
|
||||||
|
self.password = "taosdata"
|
||||||
|
self.config = "/etc/taos"
|
||||||
|
|
||||||
|
def connectDB(self):
|
||||||
|
self.conn = taos.connect(
|
||||||
|
self.host,
|
||||||
|
self.user,
|
||||||
|
self.password,
|
||||||
|
self.config)
|
||||||
|
return self.conn.cursor()
|
||||||
|
|
||||||
|
def createStable(self):
|
||||||
|
print("================= Create stable meters =================")
|
||||||
|
cursor = self.connectDB()
|
||||||
|
cursor.execute("drop database if exists test")
|
||||||
|
cursor.execute("create database test")
|
||||||
|
cursor.execute("use test")
|
||||||
|
cursor.execute('''create table if not exists meters (ts timestamp, speed int) tags(
|
||||||
|
tgcol1 tinyint, tgcol2 smallint, tgcol3 int, tgcol4 bigint, tgcol5 float, tgcol6 double, tgcol7 bool, tgcol8 binary(20), tgcol9 nchar(20),
|
||||||
|
tgcol10 tinyint, tgcol11 smallint, tgcol12 int, tgcol13 bigint, tgcol14 float, tgcol15 double, tgcol16 bool, tgcol17 binary(20), tgcol18 nchar(20),
|
||||||
|
tgcol19 tinyint, tgcol20 smallint, tgcol21 int, tgcol22 bigint, tgcol23 float, tgcol24 double, tgcol25 bool, tgcol26 binary(20), tgcol27 nchar(20),
|
||||||
|
tgcol28 tinyint, tgcol29 smallint, tgcol30 int, tgcol31 bigint, tgcol32 float, tgcol33 double, tgcol34 bool, tgcol35 binary(20), tgcol36 nchar(20),
|
||||||
|
tgcol37 tinyint, tgcol38 smallint, tgcol39 int, tgcol40 bigint, tgcol41 float, tgcol42 double, tgcol43 bool, tgcol44 binary(20), tgcol45 nchar(20),
|
||||||
|
tgcol46 tinyint, tgcol47 smallint, tgcol48 int, tgcol49 bigint, tgcol50 float, tgcol51 double, tgcol52 bool, tgcol53 binary(20), tgcol54 nchar(20))''')
|
||||||
|
cursor.close()
|
||||||
|
self.conn.close()
|
||||||
|
|
||||||
|
def createTablesAndInsertData(self, threadID):
|
||||||
|
cursor = self.connectDB()
|
||||||
|
cursor.execute("use test")
|
||||||
|
base = threadID * self.tables
|
||||||
|
|
||||||
|
tablesPerThread = int (self.tables / self.numOfTherads)
|
||||||
|
for i in range(tablesPerThread):
|
||||||
|
cursor.execute(
|
||||||
|
'''create table t%d using meters tags(
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')''' %
|
||||||
|
(base + i + 1,
|
||||||
|
(base + i) %100, (base + i) %10000, (base + i) %1000000, (base + i) %100000000, (base + i) %100 * 1.1, (base + i) %100 * 2.3, (base + i) %2, (base + i) %100, (base + i) %100,
|
||||||
|
(base + i) %100, (base + i) %10000, (base + i) %1000000, (base + i) %100000000, (base + i) %100 * 1.1, (base + i) %100 * 2.3, (base + i) %2, (base + i) %100, (base + i) %100,
|
||||||
|
(base + i) %100, (base + i) %10000, (base + i) %1000000, (base + i) %100000000, (base + i) %100 * 1.1, (base + i) %100 * 2.3, (base + i) %2, (base + i) %100, (base + i) %100,
|
||||||
|
(base + i) %100, (base + i) %10000, (base + i) %1000000, (base + i) %100000000, (base + i) %100 * 1.1, (base + i) %100 * 2.3, (base + i) %2, (base + i) %100, (base + i) %100,
|
||||||
|
(base + i) %100, (base + i) %10000, (base + i) %1000000, (base + i) %100000000, (base + i) %100 * 1.1, (base + i) %100 * 2.3, (base + i) %2, (base + i) %100, (base + i) %100,
|
||||||
|
(base + i) %100, (base + i) %10000, (base + i) %1000000, (base + i) %100000000, (base + i) %100 * 1.1, (base + i) %100 * 2.3, (base + i) %2, (base + i) %100, (base + i) %100))
|
||||||
|
for j in range(self.records):
|
||||||
|
cursor.execute(
|
||||||
|
"insert into t%d values(%d, %d)" %
|
||||||
|
(base + i + 1, self.ts + j, j))
|
||||||
|
cursor.close()
|
||||||
|
self.conn.close()
|
||||||
|
|
||||||
|
def queryData(self, query):
|
||||||
|
cursor = self.connectDB()
|
||||||
|
cursor.execute("use test")
|
||||||
|
|
||||||
|
print("================= query tag data =================")
|
||||||
|
startTime = datetime.now()
|
||||||
|
cursor.execute(query)
|
||||||
|
cursor.fetchall()
|
||||||
|
endTime = datetime.now()
|
||||||
|
print(
|
||||||
|
"Query time for the above query is %d seconds" %
|
||||||
|
(endTime - startTime).seconds)
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
self.conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
t = MetadataQuery()
|
||||||
|
t.initConnection()
|
||||||
|
t.createStable()
|
||||||
|
|
||||||
|
print(
|
||||||
|
"================= Create %d tables and insert %d records into each table =================" %
|
||||||
|
(t.tables, t.records))
|
||||||
|
startTime = datetime.now()
|
||||||
|
for i in range(t.numOfTherads):
|
||||||
|
thread = threading.Thread(
|
||||||
|
target=t.createTablesAndInsertData, args=(i,))
|
||||||
|
thread.start()
|
||||||
|
thread.join()
|
||||||
|
endTime = datetime.now()
|
||||||
|
diff = (endTime - startTime).seconds
|
||||||
|
print(
|
||||||
|
"spend %d seconds to create %d tables and insert %d records into each table" %
|
||||||
|
(diff, t.tables, t.records))
|
||||||
|
|
||||||
|
query = '''select tgcol1, tgcol2, tgcol3, tgcol4, tgcol5, tgcol6, tgcol7, tgcol8, tgcol9,
|
||||||
|
tgcol10, tgcol11, tgcol12, tgcol13, tgcol14, tgcol15, tgcol16, tgcol17, tgcol18,
|
||||||
|
tgcol19, tgcol20, tgcol21, tgcol22, tgcol23, tgcol24, tgcol25, tgcol26, tgcol27,
|
||||||
|
tgcol28, tgcol29, tgcol30, tgcol31, tgcol32, tgcol33, tgcol34, tgcol35, tgcol36,
|
||||||
|
tgcol37, tgcol38, tgcol39, tgcol40, tgcol41, tgcol42, tgcol43, tgcol44, tgcol45,
|
||||||
|
tgcol46, tgcol47, tgcol48, tgcol49, tgcol50, tgcol51, tgcol52, tgcol53, tgcol54
|
||||||
|
from meters where tgcol1 > 10 AND tgcol1 < 100 and tgcol2 > 100 and tgcol2 < 1000 or tgcol3 > 10000 or tgcol7 = true
|
||||||
|
or tgcol8 like '%2' and tgcol10 < 10'''
|
||||||
|
|
||||||
|
t.queryData(query)
|
|
@ -16,6 +16,7 @@ import taos
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
@ -26,6 +27,46 @@ class TDTestCase:
|
||||||
self.rowNum = 10
|
self.rowNum = 10
|
||||||
self.ts = 1537146000000
|
self.ts = 1537146000000
|
||||||
|
|
||||||
|
def checkColumnSorted(self, col, order):
|
||||||
|
frame = inspect.stack()[1]
|
||||||
|
callerModule = inspect.getmodule(frame[0])
|
||||||
|
callerFilename = callerModule.__file__
|
||||||
|
|
||||||
|
if col < 0:
|
||||||
|
tdLog.exit(
|
||||||
|
"%s failed: sql:%s, col:%d is smaller than zero" %
|
||||||
|
(callerFilename, tdSql.sql, col))
|
||||||
|
if col > tdSql.queryCols:
|
||||||
|
tdLog.exit(
|
||||||
|
"%s failed: sql:%s, col:%d is larger than queryCols:%d" %
|
||||||
|
(callerFilename, tdSql.sql, col, tdSql.queryCols))
|
||||||
|
|
||||||
|
matrix = np.array(tdSql.queryResult)
|
||||||
|
list = matrix[:, 0]
|
||||||
|
|
||||||
|
if order == "" or order.upper() == "ASC":
|
||||||
|
if all(sorted(list) == list):
|
||||||
|
tdLog.info(
|
||||||
|
"sql:%s, column :%d is sorted in accending order as expected" %
|
||||||
|
(tdSql.sql, col))
|
||||||
|
else:
|
||||||
|
tdLog.exit(
|
||||||
|
"%s failed: sql:%s, col:%d is not sorted in accesnind order" %
|
||||||
|
(callerFilename, tdSql.sql, col))
|
||||||
|
elif order.upper() == "DESC":
|
||||||
|
if all(sorted(list, reverse=True) == list):
|
||||||
|
tdLog.info(
|
||||||
|
"sql:%s, column :%d is sorted in decending order as expected" %
|
||||||
|
(tdSql.sql, col))
|
||||||
|
else:
|
||||||
|
tdLog.exit(
|
||||||
|
"%s failed: sql:%s, col:%d is not sorted in decending order" %
|
||||||
|
(callerFilename, tdSql.sql, col))
|
||||||
|
else:
|
||||||
|
tdLog.exit(
|
||||||
|
"%s failed: sql:%s, the order provided for col:%d is not correct" %
|
||||||
|
(callerFilename, tdSql.sql, col))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
|
@ -49,11 +90,11 @@ class TDTestCase:
|
||||||
print("======= step 2: verify order for each column =========")
|
print("======= step 2: verify order for each column =========")
|
||||||
# sort for timestamp in asc order
|
# sort for timestamp in asc order
|
||||||
tdSql.query("select * from st order by ts asc")
|
tdSql.query("select * from st order by ts asc")
|
||||||
tdSql.checkColumnSorted(0, "asc")
|
self.checkColumnSorted(0, "asc")
|
||||||
|
|
||||||
# sort for timestamp in desc order
|
# sort for timestamp in desc order
|
||||||
tdSql.query("select * from st order by ts desc")
|
tdSql.query("select * from st order by ts desc")
|
||||||
tdSql.checkColumnSorted(0, "desc")
|
self.checkColumnSorted(0, "desc")
|
||||||
|
|
||||||
for i in range(1, 10):
|
for i in range(1, 10):
|
||||||
tdSql.error("select * from st order by tbcol%d" % i)
|
tdSql.error("select * from st order by tbcol%d" % i)
|
||||||
|
@ -63,17 +104,17 @@ class TDTestCase:
|
||||||
tdSql.query(
|
tdSql.query(
|
||||||
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d" %
|
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d" %
|
||||||
(i, i))
|
(i, i))
|
||||||
tdSql.checkColumnSorted(1, "")
|
self.checkColumnSorted(1, "")
|
||||||
|
|
||||||
tdSql.query(
|
tdSql.query(
|
||||||
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" %
|
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" %
|
||||||
(i, i))
|
(i, i))
|
||||||
tdSql.checkColumnSorted(1, "asc")
|
self.checkColumnSorted(1, "asc")
|
||||||
|
|
||||||
tdSql.query(
|
tdSql.query(
|
||||||
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" %
|
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" %
|
||||||
(i, i))
|
(i, i))
|
||||||
tdSql.checkColumnSorted(1, "desc")
|
self.checkColumnSorted(1, "desc")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -43,7 +43,7 @@ python3 ./test.py -f tag_lite/commit.py
|
||||||
python3 ./test.py -f tag_lite/create.py
|
python3 ./test.py -f tag_lite/create.py
|
||||||
python3 ./test.py -f tag_lite/datatype.py
|
python3 ./test.py -f tag_lite/datatype.py
|
||||||
python3 ./test.py -f tag_lite/datatype-without-alter.py
|
python3 ./test.py -f tag_lite/datatype-without-alter.py
|
||||||
# python3 ./test.py -f tag_lite/delete.py
|
python3 ./test.py -f tag_lite/delete.py
|
||||||
python3 ./test.py -f tag_lite/double.py
|
python3 ./test.py -f tag_lite/double.py
|
||||||
python3 ./test.py -f tag_lite/float.py
|
python3 ./test.py -f tag_lite/float.py
|
||||||
python3 ./test.py -f tag_lite/int_binary.py
|
python3 ./test.py -f tag_lite/int_binary.py
|
||||||
|
@ -134,9 +134,10 @@ python3 ./test.py -f table/del_stable.py
|
||||||
python3 ./test.py -f query/filter.py
|
python3 ./test.py -f query/filter.py
|
||||||
python3 ./test.py -f query/filterAllIntTypes.py
|
python3 ./test.py -f query/filterAllIntTypes.py
|
||||||
python3 ./test.py -f query/filterFloatAndDouble.py
|
python3 ./test.py -f query/filterFloatAndDouble.py
|
||||||
|
python3 ./test.py -f query/filterOtherTypes.py
|
||||||
|
python3 ./test.py -f query/queryError.py
|
||||||
python3 ./test.py -f query/querySort.py
|
python3 ./test.py -f query/querySort.py
|
||||||
|
|
||||||
|
|
||||||
#stream
|
#stream
|
||||||
python3 ./test.py -f stream/stream1.py
|
python3 ./test.py -f stream/stream1.py
|
||||||
python3 ./test.py -f stream/stream2.py
|
python3 ./test.py -f stream/stream2.py
|
||||||
|
|
|
@ -8,24 +8,8 @@ python3 ./test.py $1 -s && sleep 1
|
||||||
# insert
|
# insert
|
||||||
python3 ./test.py $1 -f insert/basic.py
|
python3 ./test.py $1 -f insert/basic.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f insert/int.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/float.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/bigint.py
|
python3 ./test.py $1 -f insert/bigint.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f insert/bool.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/double.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/smallint.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/tinyint.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/binary.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/date.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f insert/nchar.py
|
python3 ./test.py $1 -f insert/nchar.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f insert/multi.py
|
python3 ./test.py $1 -f insert/multi.py
|
||||||
|
@ -42,18 +26,6 @@ python3 ./test.py $1 -s && sleep 1
|
||||||
# import
|
# import
|
||||||
python3 ./test.py $1 -f import_merge/importDataLastSub.py
|
python3 ./test.py $1 -f import_merge/importDataLastSub.py
|
||||||
python3 ./test.py $1 -s && sleep 1
|
python3 ./test.py $1 -s && sleep 1
|
||||||
python3 ./test.py $1 -f import_merge/importHead.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f import_merge/importLastT.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f import_merge/importSpan.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f import_merge/importTail.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f import_merge/importTRestart.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
python3 ./test.py $1 -f import_merge/importInsertThenImport.py
|
|
||||||
python3 ./test.py $1 -s && sleep 1
|
|
||||||
|
|
||||||
#tag
|
#tag
|
||||||
python3 ./test.py $1 -f tag_lite/filter.py
|
python3 ./test.py $1 -f tag_lite/filter.py
|
||||||
|
|
|
@ -17,7 +17,6 @@ import time
|
||||||
import datetime
|
import datetime
|
||||||
import inspect
|
import inspect
|
||||||
from util.log import *
|
from util.log import *
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
|
||||||
class TDSql:
|
class TDSql:
|
||||||
|
@ -201,45 +200,5 @@ class TDSql:
|
||||||
tdLog.info("sql:%s, affectedRows:%d == expect:%d" %
|
tdLog.info("sql:%s, affectedRows:%d == expect:%d" %
|
||||||
(self.sql, self.affectedRows, expectAffectedRows))
|
(self.sql, self.affectedRows, expectAffectedRows))
|
||||||
|
|
||||||
def checkColumnSorted(self, col, order):
|
|
||||||
frame = inspect.stack()[1]
|
|
||||||
callerModule = inspect.getmodule(frame[0])
|
|
||||||
callerFilename = callerModule.__file__
|
|
||||||
|
|
||||||
if col < 0:
|
|
||||||
tdLog.exit(
|
|
||||||
"%s failed: sql:%s, col:%d is smaller than zero" %
|
|
||||||
(callerFilename, self.sql, col))
|
|
||||||
if col > self.queryCols:
|
|
||||||
tdLog.exit(
|
|
||||||
"%s failed: sql:%s, col:%d is larger than queryCols:%d" %
|
|
||||||
(callerFilename, self.sql, col, self.queryCols))
|
|
||||||
|
|
||||||
matrix = np.array(self.queryResult)
|
|
||||||
list = matrix[:, 0]
|
|
||||||
|
|
||||||
if order == "" or order.upper() == "ASC":
|
|
||||||
if all(sorted(list) == list):
|
|
||||||
tdLog.info(
|
|
||||||
"sql:%s, column :%d is sorted in accending order as expected" %
|
|
||||||
(self.sql, col))
|
|
||||||
else:
|
|
||||||
tdLog.exit(
|
|
||||||
"%s failed: sql:%s, col:%d is not sorted in accesnind order" %
|
|
||||||
(callerFilename, self.sql, col))
|
|
||||||
elif order.upper() == "DESC":
|
|
||||||
if all(sorted(list, reverse=True) == list):
|
|
||||||
tdLog.info(
|
|
||||||
"sql:%s, column :%d is sorted in decending order as expected" %
|
|
||||||
(self.sql, col))
|
|
||||||
else:
|
|
||||||
tdLog.exit(
|
|
||||||
"%s failed: sql:%s, col:%d is not sorted in decending order" %
|
|
||||||
(callerFilename, self.sql, col))
|
|
||||||
else:
|
|
||||||
tdLog.exit(
|
|
||||||
"%s failed: sql:%s, the order provided for col:%d is not correct" %
|
|
||||||
(callerFilename, self.sql, col))
|
|
||||||
|
|
||||||
|
|
||||||
tdSql = TDSql()
|
tdSql = TDSql()
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
run general/cache/new_metrics.sim
|
run general/cache/new_metrics.sim
|
||||||
run general/column/commit.sim
|
|
||||||
run general/compress/compress.sim
|
|
||||||
run general/compute/interval.sim
|
run general/compute/interval.sim
|
||||||
run general/db/basic4.sim
|
run general/http/restful_full.sim
|
||||||
run general/field/binary.sim
|
|
||||||
run general/http/restful_insert.sim
|
|
||||||
run general/import/commit.sim
|
run general/import/commit.sim
|
||||||
run general/import/replica1.sim
|
run general/import/replica1.sim
|
||||||
run general/parser/auto_create_tb_drop_tb.sim
|
run general/parser/auto_create_tb_drop_tb.sim
|
||||||
run general/parser/binary_escapeCharacter.sim
|
run general/parser/binary_escapeCharacter.sim
|
||||||
run general/parser/select_from_cache_disk.sim
|
run general/parser/select_from_cache_disk.sim
|
||||||
|
run general/parser/null_char.sim
|
||||||
|
run general/parser/alter.sim
|
||||||
run general/stable/vnode3.sim
|
run general/stable/vnode3.sim
|
||||||
run general/table/autocreate.sim
|
|
||||||
run general/table/fill.sim
|
|
||||||
run general/table/vgroup.sim
|
|
||||||
run general/tag/filter.sim
|
run general/tag/filter.sim
|
||||||
|
run general/table/vgroup.sim
|
||||||
run general/user/authority.sim
|
run general/user/authority.sim
|
||||||
run general/user/pass_alter.sim
|
|
||||||
run general/vector/metrics_mix.sim
|
run general/vector/metrics_mix.sim
|
||||||
run general/vector/table_field.sim
|
run general/vector/table_field.sim
|
||||||
|
run general/user/authority.sim
|
||||||
|
run general/tag/set.sim
|
||||||
|
run general/table/delete_writing.sim
|
||||||
|
run general/stable/disk.sim
|
||||||
|
|
|
@ -232,24 +232,3 @@ cd ../../../debug; make
|
||||||
./test.sh -f general/vector/table_mix.sim
|
./test.sh -f general/vector/table_mix.sim
|
||||||
./test.sh -f general/vector/table_query.sim
|
./test.sh -f general/vector/table_query.sim
|
||||||
./test.sh -f general/vector/table_time.sim
|
./test.sh -f general/vector/table_time.sim
|
||||||
|
|
||||||
./test.sh -f unique/account/account_create.sim
|
|
||||||
./test.sh -f unique/account/account_delete.sim
|
|
||||||
./test.sh -f unique/account/account_len.sim
|
|
||||||
./test.sh -f unique/account/authority.sim
|
|
||||||
./test.sh -f unique/account/basic.sim
|
|
||||||
./test.sh -f unique/account/paras.sim
|
|
||||||
./test.sh -f unique/account/pass_alter.sim
|
|
||||||
./test.sh -f unique/account/pass_len.sim
|
|
||||||
./test.sh -f unique/account/usage.sim
|
|
||||||
./test.sh -f unique/account/user_create.sim
|
|
||||||
./test.sh -f unique/account/user_len.sim
|
|
||||||
|
|
||||||
./test.sh -f unique/cluster/balance1.sim
|
|
||||||
./test.sh -f unique/cluster/balance2.sim
|
|
||||||
./test.sh -f unique/dnode/balance1.sim
|
|
||||||
./test.sh -f unique/dnode/balance2.sim
|
|
||||||
./test.sh -f unique/stable/dnode3.sim
|
|
||||||
./test.sh -f unique/mnode/mgmt22.sim
|
|
||||||
./test.sh -f unique/mnode/mgmt33.sim
|
|
||||||
./test.sh -f unique/vnode/many.sim
|
|
|
@ -102,9 +102,10 @@ cd ../../../debug; make
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
|
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
|
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
|
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
|
||||||
|
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim
|
||||||
./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim
|
./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
##unsupport run general/alter/cached_schema_after_alter.sim
|
##unsupport run general/alter/cached_schema_after_alter.sim
|
||||||
unsupport run general/alter/count.sim
|
run general/alter/count.sim
|
||||||
unsupport run general/alter/import.sim
|
run general/alter/import.sim
|
||||||
##unsupport run general/alter/insert1.sim
|
##unsupport run general/alter/insert1.sim
|
||||||
unsupport run general/alter/insert2.sim
|
run general/alter/insert2.sim
|
||||||
unsupport run general/alter/metrics.sim
|
run general/alter/metrics.sim
|
||||||
unsupport run general/alter/table.sim
|
run general/alter/table.sim
|
||||||
run general/cache/new_metrics.sim
|
run general/cache/new_metrics.sim
|
||||||
run general/cache/restart_metrics.sim
|
run general/cache/restart_metrics.sim
|
||||||
run general/cache/restart_table.sim
|
run general/cache/restart_table.sim
|
||||||
|
@ -86,14 +86,14 @@ run general/insert/query_block2_file.sim
|
||||||
run general/insert/query_file_memory.sim
|
run general/insert/query_file_memory.sim
|
||||||
run general/insert/query_multi_file.sim
|
run general/insert/query_multi_file.sim
|
||||||
run general/insert/tcp.sim
|
run general/insert/tcp.sim
|
||||||
##unsupport run general/parser/alter.sim
|
run general/parser/alter.sim
|
||||||
run general/parser/alter1.sim
|
run general/parser/alter1.sim
|
||||||
run general/parser/alter_stable.sim
|
run general/parser/alter_stable.sim
|
||||||
run general/parser/auto_create_tb.sim
|
run general/parser/auto_create_tb.sim
|
||||||
run general/parser/auto_create_tb_drop_tb.sim
|
run general/parser/auto_create_tb_drop_tb.sim
|
||||||
run general/parser/col_arithmetic_operation.sim
|
run general/parser/col_arithmetic_operation.sim
|
||||||
run general/parser/columnValue.sim
|
run general/parser/columnValue.sim
|
||||||
#run general/parser/commit.sim
|
run general/parser/commit.sim
|
||||||
run general/parser/create_db.sim
|
run general/parser/create_db.sim
|
||||||
run general/parser/create_mt.sim
|
run general/parser/create_mt.sim
|
||||||
run general/parser/create_tb.sim
|
run general/parser/create_tb.sim
|
||||||
|
@ -106,7 +106,7 @@ run general/parser/first_last.sim
|
||||||
##unsupport run general/parser/import_file.sim
|
##unsupport run general/parser/import_file.sim
|
||||||
run general/parser/lastrow.sim
|
run general/parser/lastrow.sim
|
||||||
run general/parser/nchar.sim
|
run general/parser/nchar.sim
|
||||||
##unsupport run general/parser/null_char.sim
|
run general/parser/null_char.sim
|
||||||
run general/parser/single_row_in_tb.sim
|
run general/parser/single_row_in_tb.sim
|
||||||
run general/parser/select_from_cache_disk.sim
|
run general/parser/select_from_cache_disk.sim
|
||||||
run general/parser/limit.sim
|
run general/parser/limit.sim
|
||||||
|
@ -132,7 +132,7 @@ run general/parser/groupby.sim
|
||||||
run general/parser/bug.sim
|
run general/parser/bug.sim
|
||||||
run general/parser/tags_dynamically_specifiy.sim
|
run general/parser/tags_dynamically_specifiy.sim
|
||||||
run general/parser/set_tag_vals.sim
|
run general/parser/set_tag_vals.sim
|
||||||
##unsupport run general/parser/repeatAlter.sim
|
run general/parser/repeatAlter.sim
|
||||||
##unsupport run general/parser/slimit_alter_tags.sim
|
##unsupport run general/parser/slimit_alter_tags.sim
|
||||||
##unsupport run general/parser/stream_on_sys.sim
|
##unsupport run general/parser/stream_on_sys.sim
|
||||||
run general/parser/stream.sim
|
run general/parser/stream.sim
|
||||||
|
@ -142,6 +142,8 @@ run general/stable/dnode3.sim
|
||||||
run general/stable/metrics.sim
|
run general/stable/metrics.sim
|
||||||
run general/stable/values.sim
|
run general/stable/values.sim
|
||||||
run general/stable/vnode3.sim
|
run general/stable/vnode3.sim
|
||||||
|
run general/stable/refcount.sim
|
||||||
|
run general/stable/show.sim
|
||||||
run general/table/autocreate.sim
|
run general/table/autocreate.sim
|
||||||
run general/table/basic1.sim
|
run general/table/basic1.sim
|
||||||
run general/table/basic2.sim
|
run general/table/basic2.sim
|
||||||
|
|
|
@ -112,7 +112,7 @@ echo "numOfLogLines 100000000" >> $TAOS_CFG
|
||||||
echo "dDebugFlag 135" >> $TAOS_CFG
|
echo "dDebugFlag 135" >> $TAOS_CFG
|
||||||
echo "mDebugFlag 135" >> $TAOS_CFG
|
echo "mDebugFlag 135" >> $TAOS_CFG
|
||||||
echo "sdbDebugFlag 135" >> $TAOS_CFG
|
echo "sdbDebugFlag 135" >> $TAOS_CFG
|
||||||
echo "rpcDebugFlag 143" >> $TAOS_CFG
|
echo "rpcDebugFlag 135" >> $TAOS_CFG
|
||||||
echo "tmrDebugFlag 131" >> $TAOS_CFG
|
echo "tmrDebugFlag 131" >> $TAOS_CFG
|
||||||
echo "cDebugFlag 135" >> $TAOS_CFG
|
echo "cDebugFlag 135" >> $TAOS_CFG
|
||||||
echo "httpDebugFlag 135" >> $TAOS_CFG
|
echo "httpDebugFlag 135" >> $TAOS_CFG
|
||||||
|
|
|
@ -64,7 +64,7 @@ print ======== step7
|
||||||
$lastRows = $data00
|
$lastRows = $data00
|
||||||
print ======== loop Times $x
|
print ======== loop Times $x
|
||||||
|
|
||||||
if $x < 2 then
|
if $x < 5 then
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
goto loop
|
goto loop
|
||||||
endi
|
endi
|
||||||
|
|
|
@ -75,7 +75,7 @@ print ======== step8
|
||||||
$lastRows = $data00
|
$lastRows = $data00
|
||||||
print ======== loop Times $x
|
print ======== loop Times $x
|
||||||
|
|
||||||
if $x < 2 then
|
if $x < 5 then
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
goto loop
|
goto loop
|
||||||
endi
|
endi
|
||||||
|
|
Loading…
Reference in New Issue