Merge branch 'feature/query' of https://github.com/taosdata/TDengine into feature/query
This commit is contained in:
commit
8964ebddcd
|
@ -20,8 +20,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "qextbuffer.h"
|
#include "qExtbuffer.h"
|
||||||
#include "qfill.h"
|
#include "qFill.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
||||||
#include "tsclient.h"
|
#include "tsclient.h"
|
||||||
|
|
|
@ -23,11 +23,11 @@ extern "C" {
|
||||||
/*
|
/*
|
||||||
* @date 2018/09/30
|
* @date 2018/09/30
|
||||||
*/
|
*/
|
||||||
#include "os.h"
|
|
||||||
#include "tbuffer.h"
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "qextbuffer.h"
|
#include "os.h"
|
||||||
|
#include "qExtbuffer.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "tbuffer.h"
|
||||||
#include "tscLocalMerge.h"
|
#include "tscLocalMerge.h"
|
||||||
#include "tsclient.h"
|
#include "tsclient.h"
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ bool hasMoreClauseToTry(SSqlObj* pSql);
|
||||||
void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
|
void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
|
||||||
void tscAsyncQuerySingleRowForNextVnode(void *param, TAOS_RES *tres, int numOfRows);
|
void tscAsyncQuerySingleRowForNextVnode(void *param, TAOS_RES *tres, int numOfRows);
|
||||||
void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp);
|
void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp);
|
||||||
int tscSetMgmtIpListFromCfg(const char *first, const char *second);
|
int tscSetMgmtEpSetFromCfg(const char *first, const char *second);
|
||||||
|
|
||||||
void* malloc_throw(size_t size);
|
void* malloc_throw(size_t size);
|
||||||
void* calloc_throw(size_t nmemb, size_t size);
|
void* calloc_throw(size_t nmemb, size_t size);
|
||||||
|
|
|
@ -31,8 +31,8 @@ extern "C" {
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
#include "qExecutor.h"
|
#include "qExecutor.h"
|
||||||
|
#include "qTsbuf.h"
|
||||||
#include "qsqlparser.h"
|
#include "qsqlparser.h"
|
||||||
#include "qtsbuf.h"
|
|
||||||
#include "tcmdtype.h"
|
#include "tcmdtype.h"
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
|
@ -306,7 +306,7 @@ typedef struct SSqlObj {
|
||||||
char * sqlstr;
|
char * sqlstr;
|
||||||
char retry;
|
char retry;
|
||||||
char maxRetry;
|
char maxRetry;
|
||||||
SRpcIpSet ipList;
|
SRpcEpSet epSet;
|
||||||
char listed;
|
char listed;
|
||||||
tsem_t rspSem;
|
tsem_t rspSem;
|
||||||
SSqlCmd cmd;
|
SSqlCmd cmd;
|
||||||
|
@ -350,7 +350,7 @@ void tscInitMsgsFp();
|
||||||
|
|
||||||
int tsParseSql(SSqlObj *pSql, bool initial);
|
int tsParseSql(SSqlObj *pSql, bool initial);
|
||||||
|
|
||||||
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet);
|
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet);
|
||||||
int tscProcessSql(SSqlObj *pSql);
|
int tscProcessSql(SSqlObj *pSql);
|
||||||
|
|
||||||
int tscRenewTableMeta(SSqlObj *pSql, char *tableId);
|
int tscRenewTableMeta(SSqlObj *pSql, char *tableId);
|
||||||
|
@ -456,7 +456,7 @@ extern void * tscQhandle;
|
||||||
extern int tscKeepConn[];
|
extern int tscKeepConn[];
|
||||||
extern int tsInsertHeadSize;
|
extern int tsInsertHeadSize;
|
||||||
extern int tscNumOfThreads;
|
extern int tscNumOfThreads;
|
||||||
extern SRpcIpSet tscMgmtIpSet;
|
extern SRpcEpSet tscMgmtEpSet;
|
||||||
|
|
||||||
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
|
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "qextbuffer.h"
|
#include "qAst.h"
|
||||||
#include "qfill.h"
|
#include "qExtbuffer.h"
|
||||||
#include "qhistogram.h"
|
#include "qFill.h"
|
||||||
#include "qpercentile.h"
|
#include "qHistogram.h"
|
||||||
#include "qsyntaxtreefunction.h"
|
#include "qPercentile.h"
|
||||||
#include "qtsbuf.h"
|
#include "qSyntaxtreefunction.h"
|
||||||
|
#include "qTsbuf.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "qast.h"
|
|
||||||
#include "tscLog.h"
|
#include "tscLog.h"
|
||||||
#include "tscSubquery.h"
|
#include "tscSubquery.h"
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
|
@ -74,7 +74,7 @@ for (int32_t i = 0; i < (ctx)->tagInfo.numOfTagCols; ++i) { \
|
||||||
void noop1(SQLFunctionCtx *UNUSED_PARAM(pCtx)) {}
|
void noop1(SQLFunctionCtx *UNUSED_PARAM(pCtx)) {}
|
||||||
void noop2(SQLFunctionCtx *UNUSED_PARAM(pCtx), int32_t UNUSED_PARAM(index)) {}
|
void noop2(SQLFunctionCtx *UNUSED_PARAM(pCtx), int32_t UNUSED_PARAM(index)) {}
|
||||||
|
|
||||||
void doFinalizer(SQLFunctionCtx *pCtx) { resetResultInfo(GET_RES_INFO(pCtx)); }
|
void doFinalizer(SQLFunctionCtx *pCtx) { RESET_RESULT_INFO(GET_RES_INFO(pCtx)); }
|
||||||
|
|
||||||
typedef struct tValuePair {
|
typedef struct tValuePair {
|
||||||
tVariant v;
|
tVariant v;
|
||||||
|
@ -330,12 +330,6 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the numOfRes should be kept, since it may be used later
|
|
||||||
* and allow the ResultInfo to be re initialized
|
|
||||||
*/
|
|
||||||
void resetResultInfo(SResultInfo *pResInfo) { pResInfo->initialized = false; }
|
|
||||||
|
|
||||||
void setResultInfoBuf(SResultInfo *pResInfo, int32_t size, bool superTable, char* buf) {
|
void setResultInfoBuf(SResultInfo *pResInfo, int32_t size, bool superTable, char* buf) {
|
||||||
assert(pResInfo->interResultBuf == NULL);
|
assert(pResInfo->interResultBuf == NULL);
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
|
|
||||||
#include "tcache.h"
|
#include "qExtbuffer.h"
|
||||||
#include "tscUtil.h"
|
|
||||||
#include "tsclient.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tscLog.h"
|
#include "tcache.h"
|
||||||
#include "qextbuffer.h"
|
|
||||||
#include "tschemautil.h"
|
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
#include "tscLog.h"
|
||||||
|
#include "tscUtil.h"
|
||||||
|
#include "tschemautil.h"
|
||||||
|
#include "tsclient.h"
|
||||||
|
|
||||||
static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, int16_t type, size_t valueLength);
|
static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, int16_t type, size_t valueLength);
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "qAst.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "qast.h"
|
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tscLog.h"
|
#include "tscLog.h"
|
||||||
|
@ -2355,9 +2355,9 @@ bool validateIpAddress(const char* ip, size_t size) {
|
||||||
|
|
||||||
strncpy(tmp, ip, size);
|
strncpy(tmp, ip, size);
|
||||||
|
|
||||||
in_addr_t ipAddr = inet_addr(tmp);
|
in_addr_t epAddr = inet_addr(tmp);
|
||||||
|
|
||||||
return ipAddr != INADDR_NONE;
|
return epAddr != INADDR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
|
|
||||||
#define TSC_MGMT_VNODE 999
|
#define TSC_MGMT_VNODE 999
|
||||||
|
|
||||||
SRpcIpSet tscMgmtIpSet;
|
SRpcEpSet tscMgmtEpSet;
|
||||||
SRpcIpSet tscDnodeIpSet;
|
SRpcEpSet tscDnodeEpSet;
|
||||||
|
|
||||||
int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0};
|
int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0};
|
||||||
|
|
||||||
|
@ -44,44 +44,44 @@ void tscSaveSubscriptionProgress(void* sub);
|
||||||
|
|
||||||
static int32_t minMsgSize() { return tsRpcHeadSize + 100; }
|
static int32_t minMsgSize() { return tsRpcHeadSize + 100; }
|
||||||
|
|
||||||
static void tscSetDnodeIpList(SSqlObj* pSql, SCMVgroupInfo* pVgroupInfo) {
|
static void tscSetDnodeEpSet(SSqlObj* pSql, SCMVgroupInfo* pVgroupInfo) {
|
||||||
SRpcIpSet* pIpList = &pSql->ipList;
|
SRpcEpSet* pEpSet = &pSql->epSet;
|
||||||
pIpList->inUse = 0;
|
pEpSet->inUse = 0;
|
||||||
if (pVgroupInfo == NULL) {
|
if (pVgroupInfo == NULL) {
|
||||||
pIpList->numOfIps = 0;
|
pEpSet->numOfEps = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pIpList->numOfIps = pVgroupInfo->numOfIps;
|
pEpSet->numOfEps = pVgroupInfo->numOfEps;
|
||||||
for(int32_t i = 0; i < pVgroupInfo->numOfIps; ++i) {
|
for(int32_t i = 0; i < pVgroupInfo->numOfEps; ++i) {
|
||||||
strcpy(pIpList->fqdn[i], pVgroupInfo->ipAddr[i].fqdn);
|
strcpy(pEpSet->fqdn[i], pVgroupInfo->epAddr[i].fqdn);
|
||||||
pIpList->port[i] = pVgroupInfo->ipAddr[i].port;
|
pEpSet->port[i] = pVgroupInfo->epAddr[i].port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscPrintMgmtIp() {
|
void tscPrintMgmtEp() {
|
||||||
if (tscMgmtIpSet.numOfIps <= 0) {
|
if (tscMgmtEpSet.numOfEps <= 0) {
|
||||||
tscError("invalid mnode IP list:%d", tscMgmtIpSet.numOfIps);
|
tscError("invalid mnode EP list:%d", tscMgmtEpSet.numOfEps);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < tscMgmtIpSet.numOfIps; ++i) {
|
for (int i = 0; i < tscMgmtEpSet.numOfEps; ++i) {
|
||||||
tscDebug("mnode index:%d %s:%d", i, tscMgmtIpSet.fqdn[i], tscMgmtIpSet.port[i]);
|
tscDebug("mnode index:%d %s:%d", i, tscMgmtEpSet.fqdn[i], tscMgmtEpSet.port[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSetMgmtIpList(SRpcIpSet *pIpList) {
|
void tscSetMgmtEpSet(SRpcEpSet *pEpSet) {
|
||||||
tscMgmtIpSet.numOfIps = pIpList->numOfIps;
|
tscMgmtEpSet.numOfEps = pEpSet->numOfEps;
|
||||||
tscMgmtIpSet.inUse = pIpList->inUse;
|
tscMgmtEpSet.inUse = pEpSet->inUse;
|
||||||
for (int32_t i = 0; i < tscMgmtIpSet.numOfIps; ++i) {
|
for (int32_t i = 0; i < tscMgmtEpSet.numOfEps; ++i) {
|
||||||
tscMgmtIpSet.port[i] = htons(pIpList->port[i]);
|
tscMgmtEpSet.port[i] = htons(pEpSet->port[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
|
void tscUpdateEpSet(void *ahandle, SRpcEpSet *pEpSet) {
|
||||||
tscMgmtIpSet = *pIpSet;
|
tscMgmtEpSet = *pEpSet;
|
||||||
tscDebug("mnode IP list is changed for ufp is called, numOfIps:%d inUse:%d", tscMgmtIpSet.numOfIps, tscMgmtIpSet.inUse);
|
tscDebug("mnode EP list is changed for ufp is called, numOfEps:%d inUse:%d", tscMgmtEpSet.numOfEps, tscMgmtEpSet.inUse);
|
||||||
for (int32_t i = 0; i < tscMgmtIpSet.numOfIps; ++i) {
|
for (int32_t i = 0; i < tscMgmtEpSet.numOfEps; ++i) {
|
||||||
tscDebug("index:%d fqdn:%s port:%d", i, tscMgmtIpSet.fqdn[i], tscMgmtIpSet.port[i]);
|
tscDebug("index:%d fqdn:%s port:%d", i, tscMgmtEpSet.fqdn[i], tscMgmtEpSet.port[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ void tscUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
|
||||||
UNUSED_FUNC
|
UNUSED_FUNC
|
||||||
static int32_t tscGetMgmtConnMaxRetryTimes() {
|
static int32_t tscGetMgmtConnMaxRetryTimes() {
|
||||||
int32_t factor = 2;
|
int32_t factor = 2;
|
||||||
return tscMgmtIpSet.numOfIps * factor;
|
return tscMgmtEpSet.numOfEps * factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
|
void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
|
||||||
|
@ -111,9 +111,9 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
SCMHeartBeatRsp *pRsp = (SCMHeartBeatRsp *)pRes->pRsp;
|
SCMHeartBeatRsp *pRsp = (SCMHeartBeatRsp *)pRes->pRsp;
|
||||||
SRpcIpSet * pIpList = &pRsp->ipList;
|
SRpcEpSet * pEpSet = &pRsp->epSet;
|
||||||
if (pIpList->numOfIps > 0)
|
if (pEpSet->numOfEps > 0)
|
||||||
tscSetMgmtIpList(pIpList);
|
tscSetMgmtEpSet(pEpSet);
|
||||||
|
|
||||||
pSql->pTscObj->connId = htonl(pRsp->connId);
|
pSql->pTscObj->connId = htonl(pRsp->connId);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
|
|
||||||
// set the mgmt ip list
|
// set the mgmt ip list
|
||||||
if (pSql->cmd.command >= TSDB_SQL_MGMT) {
|
if (pSql->cmd.command >= TSDB_SQL_MGMT) {
|
||||||
pSql->ipList = tscMgmtIpSet;
|
pSql->epSet = tscMgmtEpSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen);
|
memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen);
|
||||||
|
@ -203,11 +203,11 @@ int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
// Otherwise, the pSql object may have been released already during the response function, which is
|
// Otherwise, the pSql object may have been released already during the response function, which is
|
||||||
// processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
|
// processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
|
||||||
// cause crash.
|
// cause crash.
|
||||||
rpcSendRequest(pObj->pDnodeConn, &pSql->ipList, &rpcMsg);
|
rpcSendRequest(pObj->pDnodeConn, &pSql->epSet, &rpcMsg);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
|
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
SSqlObj *pSql = (SSqlObj *)rpcMsg->ahandle;
|
SSqlObj *pSql = (SSqlObj *)rpcMsg->ahandle;
|
||||||
if (pSql == NULL || pSql->signature != pSql) {
|
if (pSql == NULL || pSql->signature != pSql) {
|
||||||
tscError("%p sql is already released", pSql);
|
tscError("%p sql is already released", pSql);
|
||||||
|
@ -237,57 +237,36 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCmd->command < TSDB_SQL_MGMT) {
|
if (pCmd->command < TSDB_SQL_MGMT) {
|
||||||
if (pIpSet) pSql->ipList = *pIpSet;
|
if (pEpSet) pSql->epSet = *pEpSet;
|
||||||
} else {
|
} else {
|
||||||
if (pIpSet) tscMgmtIpSet = *pIpSet;
|
if (pEpSet) tscMgmtEpSet = *pEpSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rpcMsg->pCont == NULL) {
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
rpcMsg->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
|
||||||
} else {
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
|
||||||
// if (rpcMsg->code != TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
|
||||||
// if (pCmd->command == TSDB_SQL_CONNECT) {
|
|
||||||
// rpcMsg->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
|
||||||
// rpcFreeCont(rpcMsg->pCont);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (pCmd->command == TSDB_SQL_HB) {
|
int32_t cmd = pCmd->command;
|
||||||
// rpcMsg->code = TSDB_CODE_RPC_NOT_READY;
|
if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_FETCH || cmd == TSDB_SQL_INSERT || cmd == TSDB_SQL_UPDATE_TAGS_VAL) &&
|
||||||
// rpcFreeCont(rpcMsg->pCont);
|
(rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID ||
|
||||||
// return;
|
rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID ||
|
||||||
// }
|
rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL ||
|
||||||
|
rpcMsg->code == TSDB_CODE_TDB_TABLE_RECONFIGURE)) {
|
||||||
|
tscWarn("%p it shall renew table meta, code:%s, retry:%d", pSql, tstrerror(rpcMsg->code), ++pSql->retry);
|
||||||
|
|
||||||
// if (pCmd->command == TSDB_SQL_META || pCmd->command == TSDB_SQL_DESCRIBE_TABLE ||
|
// set the flag to denote that sql string needs to be re-parsed and build submit block with table schema
|
||||||
// pCmd->command == TSDB_SQL_STABLEVGROUP || pCmd->command == TSDB_SQL_SHOW ||
|
if (rpcMsg->code == TSDB_CODE_TDB_TABLE_RECONFIGURE) {
|
||||||
// pCmd->command == TSDB_SQL_RETRIEVE) {
|
pSql->cmd.submitSchema = 1;
|
||||||
// // get table meta/vgroup query will not retry, do nothing
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ((pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_INSERT ||
|
pSql->res.code = rpcMsg->code; // keep the previous error code
|
||||||
pCmd->command == TSDB_SQL_UPDATE_TAGS_VAL) &&
|
if (pSql->retry > pSql->maxRetry) {
|
||||||
(rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID ||
|
tscError("%p max retry %d reached, give up", pSql, pSql->maxRetry);
|
||||||
rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || rpcMsg->code == TSDB_CODE_TDB_TABLE_RECONFIGURE)) {
|
} else {
|
||||||
tscWarn("%p it shall renew table meta, code:%s, retry:%d", pSql, tstrerror(rpcMsg->code), ++pSql->retry);
|
rpcMsg->code = tscRenewTableMeta(pSql, pTableMetaInfo->name);
|
||||||
// set the flag to denote that sql string needs to be re-parsed and build submit block with table schema
|
|
||||||
if (rpcMsg->code == TSDB_CODE_TDB_TABLE_RECONFIGURE) {
|
|
||||||
pSql->cmd.submitSchema = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSql->res.code = rpcMsg->code; // keep the previous error code
|
// if there is an error occurring, proceed to the following error handling procedure.
|
||||||
if (pSql->retry > pSql->maxRetry) {
|
if (rpcMsg->code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||||
tscError("%p max retry %d reached, give up", pSql, pSql->maxRetry);
|
rpcFreeCont(rpcMsg->pCont);
|
||||||
} else {
|
return;
|
||||||
rpcMsg->code = tscRenewTableMeta(pSql, pTableMetaInfo->name);
|
|
||||||
|
|
||||||
// if there is an error occurring, proceed to the following error handling procedure.
|
|
||||||
// todo add test cases
|
|
||||||
if (rpcMsg->code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
|
||||||
rpcFreeCont(rpcMsg->pCont);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +400,7 @@ int tscProcessSql(SSqlObj *pSql) {
|
||||||
return pSql->res.code;
|
return pSql->res.code;
|
||||||
}
|
}
|
||||||
} else if (pCmd->command < TSDB_SQL_LOCAL) {
|
} else if (pCmd->command < TSDB_SQL_LOCAL) {
|
||||||
pSql->ipList = tscMgmtIpSet;
|
pSql->epSet = tscMgmtEpSet;
|
||||||
} else { // local handler
|
} else { // local handler
|
||||||
return (*tscProcessMsgRsp[pCmd->command])(pSql);
|
return (*tscProcessMsgRsp[pCmd->command])(pSql);
|
||||||
}
|
}
|
||||||
|
@ -525,10 +504,10 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
// pSql->cmd.payloadLen is set during copying data into payload
|
// pSql->cmd.payloadLen is set during copying data into payload
|
||||||
pSql->cmd.msgType = TSDB_MSG_TYPE_SUBMIT;
|
pSql->cmd.msgType = TSDB_MSG_TYPE_SUBMIT;
|
||||||
tscSetDnodeIpList(pSql, &pTableMeta->vgroupInfo);
|
tscSetDnodeEpSet(pSql, &pTableMeta->vgroupInfo);
|
||||||
|
|
||||||
tscDebug("%p build submit msg, vgId:%d numOfTables:%d numberOfIP:%d", pSql, vgId, pSql->cmd.numOfTablesInSubmit,
|
tscDebug("%p build submit msg, vgId:%d numOfTables:%d numberOfEP:%d", pSql, vgId, pSql->cmd.numOfTablesInSubmit,
|
||||||
pSql->ipList.numOfIps);
|
pSql->epSet.numOfEps);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,7 +547,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
|
||||||
pVgroupInfo = &pTableMeta->vgroupInfo;
|
pVgroupInfo = &pTableMeta->vgroupInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscSetDnodeIpList(pSql, pVgroupInfo);
|
tscSetDnodeEpSet(pSql, pVgroupInfo);
|
||||||
if (pVgroupInfo != NULL) {
|
if (pVgroupInfo != NULL) {
|
||||||
pQueryMsg->head.vgId = htonl(pVgroupInfo->vgId);
|
pQueryMsg->head.vgId = htonl(pVgroupInfo->vgId);
|
||||||
}
|
}
|
||||||
|
@ -580,7 +559,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
|
||||||
|
|
||||||
pQueryMsg->numOfTables = htonl(1); // set the number of tables
|
pQueryMsg->numOfTables = htonl(1); // set the number of tables
|
||||||
pMsg += sizeof(STableIdInfo);
|
pMsg += sizeof(STableIdInfo);
|
||||||
} else { // it is a subquery of the super table query, this IP info is acquired from vgroupInfo
|
} else { // it is a subquery of the super table query, this EP info is acquired from vgroupInfo
|
||||||
int32_t index = pTableMetaInfo->vgroupIndex;
|
int32_t index = pTableMetaInfo->vgroupIndex;
|
||||||
int32_t numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables);
|
int32_t numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables);
|
||||||
assert(index >= 0 && index < numOfVgroups);
|
assert(index >= 0 && index < numOfVgroups);
|
||||||
|
@ -590,7 +569,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
|
||||||
SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, index);
|
SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, index);
|
||||||
|
|
||||||
// set the vgroup info
|
// set the vgroup info
|
||||||
tscSetDnodeIpList(pSql, &pTableIdList->vgInfo);
|
tscSetDnodeEpSet(pSql, &pTableIdList->vgInfo);
|
||||||
pQueryMsg->head.vgId = htonl(pTableIdList->vgInfo.vgId);
|
pQueryMsg->head.vgId = htonl(pTableIdList->vgInfo.vgId);
|
||||||
|
|
||||||
int32_t numOfTables = taosArrayGetSize(pTableIdList->itemList);
|
int32_t numOfTables = taosArrayGetSize(pTableIdList->itemList);
|
||||||
|
@ -1323,7 +1302,7 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
|
||||||
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
tscSetDnodeIpList(pSql, &pTableMetaInfo->pTableMeta->vgroupInfo);
|
tscSetDnodeEpSet(pSql, &pTableMetaInfo->pTableMeta->vgroupInfo);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1658,8 +1637,8 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
pMetaMsg->contLen = htons(pMetaMsg->contLen);
|
pMetaMsg->contLen = htons(pMetaMsg->contLen);
|
||||||
pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns);
|
pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns);
|
||||||
|
|
||||||
if (pMetaMsg->sid < 0 || pMetaMsg->vgroup.numOfIps < 0) {
|
if (pMetaMsg->sid < 0 || pMetaMsg->vgroup.numOfEps < 0) {
|
||||||
tscError("invalid meter vgId:%d, sid%d", pMetaMsg->vgroup.numOfIps, pMetaMsg->sid);
|
tscError("invalid meter vgId:%d, sid%d", pMetaMsg->vgroup.numOfEps, pMetaMsg->sid);
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,8 +1652,8 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pMetaMsg->vgroup.numOfIps; ++i) {
|
for (int i = 0; i < pMetaMsg->vgroup.numOfEps; ++i) {
|
||||||
pMetaMsg->vgroup.ipAddr[i].port = htons(pMetaMsg->vgroup.ipAddr[i].port);
|
pMetaMsg->vgroup.epAddr[i].port = htons(pMetaMsg->vgroup.epAddr[i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = pMetaMsg->schema;
|
SSchema* pSchema = pMetaMsg->schema;
|
||||||
|
@ -1850,10 +1829,10 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
|
||||||
SCMVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j];
|
SCMVgroupInfo *pVgroups = &pInfo->vgroupList->vgroups[j];
|
||||||
|
|
||||||
pVgroups->vgId = htonl(pVgroups->vgId);
|
pVgroups->vgId = htonl(pVgroups->vgId);
|
||||||
assert(pVgroups->numOfIps >= 1);
|
assert(pVgroups->numOfEps >= 1);
|
||||||
|
|
||||||
for (int32_t k = 0; k < pVgroups->numOfIps; ++k) {
|
for (int32_t k = 0; k < pVgroups->numOfEps; ++k) {
|
||||||
pVgroups->ipAddr[k].port = htons(pVgroups->ipAddr[k].port);
|
pVgroups->epAddr[k].port = htons(pVgroups->epAddr[k].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
pMsg += size;
|
pMsg += size;
|
||||||
|
@ -1946,8 +1925,8 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
|
||||||
assert(len <= sizeof(pObj->db));
|
assert(len <= sizeof(pObj->db));
|
||||||
tstrncpy(pObj->db, temp, sizeof(pObj->db));
|
tstrncpy(pObj->db, temp, sizeof(pObj->db));
|
||||||
|
|
||||||
if (pConnect->ipList.numOfIps > 0)
|
if (pConnect->epSet.numOfEps > 0)
|
||||||
tscSetMgmtIpList(&pConnect->ipList);
|
tscSetMgmtEpSet(&pConnect->epSet);
|
||||||
|
|
||||||
strcpy(pObj->sversion, pConnect->serverVersion);
|
strcpy(pObj->sversion, pConnect->serverVersion);
|
||||||
pObj->writeAuth = pConnect->writeAuth;
|
pObj->writeAuth = pConnect->writeAuth;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "qast.h"
|
#include "qAst.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tnote.h"
|
#include "tnote.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
@ -62,8 +62,8 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip) {
|
if (ip) {
|
||||||
if (tscSetMgmtIpListFromCfg(ip, NULL) < 0) return NULL;
|
if (tscSetMgmtEpSetFromCfg(ip, NULL) < 0) return NULL;
|
||||||
if (port) tscMgmtIpSet.port[0] = port;
|
if (port) tscMgmtEpSet.port[0] = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pDnodeConn = NULL;
|
void *pDnodeConn = NULL;
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
*/
|
*/
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "qtsbuf.h"
|
#include "qAst.h"
|
||||||
#include "qast.h"
|
#include "qTsbuf.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
#include "tscLog.h"
|
#include "tscLog.h"
|
||||||
#include "tscSubquery.h"
|
#include "tscSubquery.h"
|
||||||
|
@ -458,7 +458,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(info.vgInfo.numOfIps != 0);
|
assert(info.vgInfo.numOfEps != 0);
|
||||||
|
|
||||||
vgTables = taosArrayInit(4, sizeof(STableIdInfo));
|
vgTables = taosArrayInit(4, sizeof(STableIdInfo));
|
||||||
info.itemList = vgTables;
|
info.itemList = vgTables;
|
||||||
|
@ -1600,8 +1600,8 @@ 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", pParentSql, pSql,
|
tscDebug("%p sub:%p all data retrieved from ep:%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].epAddr[0].fqdn, pTableMetaInfo->vgroupList->vgroups[0].vgId,
|
||||||
numOfRowsFromSubquery, idx);
|
numOfRowsFromSubquery, idx);
|
||||||
|
|
||||||
tColModelCompact(pDesc->pColumnModel, trsupport->localBuffer, pDesc->pColumnModel->capacity);
|
tColModelCompact(pDesc->pColumnModel, trsupport->localBuffer, pDesc->pColumnModel->capacity);
|
||||||
|
@ -1719,8 +1719,8 @@ 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", pParentSql, pSql,
|
tscDebug("%p sub:%p retrieve numOfRows:%" PRId64 " totalNumOfRows:%" PRIu64 " from ep:%s, orderOfSub:%d", pParentSql, pSql,
|
||||||
pRes->numOfRows, pState->numOfRetrievedRows, pSql->ipList.fqdn[pSql->ipList.inUse], idx);
|
pRes->numOfRows, pState->numOfRetrievedRows, pSql->epSet.fqdn[pSql->epSet.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,
|
||||||
|
@ -1828,8 +1828,8 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTrace("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql, pSql,
|
tscTrace("%p sub:%p query complete, ep:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql, pSql,
|
||||||
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
pVgroup->epAddr[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
|
||||||
tscRetrieveFromDnodeCallBack(param, pSql, 0);
|
tscRetrieveFromDnodeCallBack(param, pSql, 0);
|
||||||
|
|
|
@ -41,7 +41,7 @@ int tscNumOfThreads;
|
||||||
|
|
||||||
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
||||||
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
void taosInitNote(int numOfNoteLines, int maxNotes, char* lable);
|
||||||
void tscUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet);
|
void tscUpdateEpSet(void *ahandle, SRpcEpSet *pEpSet);
|
||||||
|
|
||||||
void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
|
void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
|
||||||
taosGetDisk();
|
taosGetDisk();
|
||||||
|
@ -116,8 +116,8 @@ void taos_init_imp() {
|
||||||
taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note");
|
taosInitNote(tsNumOfLogLines / 10, 1, (char*)"tsc_note");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tscSetMgmtIpListFromCfg(tsFirst, tsSecond) < 0) {
|
if (tscSetMgmtEpSetFromCfg(tsFirst, tsSecond) < 0) {
|
||||||
tscError("failed to init mnode IP list");
|
tscError("failed to init mnode EP list");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
* 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 "os.h"
|
|
||||||
#include "hash.h"
|
|
||||||
#include "tscUtil.h"
|
#include "tscUtil.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "qAst.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "qast.h"
|
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tkey.h"
|
#include "tkey.h"
|
||||||
#include "tmd5.h"
|
#include "tmd5.h"
|
||||||
|
@ -2145,17 +2145,17 @@ char* strdup_throw(const char* str) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscSetMgmtIpListFromCfg(const char *first, const char *second) {
|
int tscSetMgmtEpSetFromCfg(const char *first, const char *second) {
|
||||||
tscMgmtIpSet.numOfIps = 0;
|
tscMgmtEpSet.numOfEps = 0;
|
||||||
tscMgmtIpSet.inUse = 0;
|
tscMgmtEpSet.inUse = 0;
|
||||||
|
|
||||||
if (first && first[0] != 0) {
|
if (first && first[0] != 0) {
|
||||||
if (strlen(first) >= TSDB_EP_LEN) {
|
if (strlen(first) >= TSDB_EP_LEN) {
|
||||||
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosGetFqdnPortFromEp(first, tscMgmtIpSet.fqdn[tscMgmtIpSet.numOfIps], &tscMgmtIpSet.port[tscMgmtIpSet.numOfIps]);
|
taosGetFqdnPortFromEp(first, tscMgmtEpSet.fqdn[tscMgmtEpSet.numOfEps], &tscMgmtEpSet.port[tscMgmtEpSet.numOfEps]);
|
||||||
tscMgmtIpSet.numOfIps++;
|
tscMgmtEpSet.numOfEps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (second && second[0] != 0) {
|
if (second && second[0] != 0) {
|
||||||
|
@ -2163,11 +2163,11 @@ int tscSetMgmtIpListFromCfg(const char *first, const char *second) {
|
||||||
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosGetFqdnPortFromEp(second, tscMgmtIpSet.fqdn[tscMgmtIpSet.numOfIps], &tscMgmtIpSet.port[tscMgmtIpSet.numOfIps]);
|
taosGetFqdnPortFromEp(second, tscMgmtEpSet.fqdn[tscMgmtEpSet.numOfEps], &tscMgmtEpSet.port[tscMgmtEpSet.numOfEps]);
|
||||||
tscMgmtIpSet.numOfIps++;
|
tscMgmtEpSet.numOfEps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tscMgmtIpSet.numOfIps == 0) {
|
if ( tscMgmtEpSet.numOfEps == 0) {
|
||||||
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "TDengine",
|
"name": "TDengine",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -2302,9 +2302,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.13",
|
"version": "4.17.19",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.13.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
|
||||||
"integrity": "sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA=="
|
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ=="
|
||||||
},
|
},
|
||||||
"log-symbols": {
|
"log-symbols": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"q": "^1.5.0"
|
"q": "^1.5.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.19",
|
||||||
"yarn": "^1.22.0"
|
"yarn": "^1.22.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/taosdata/TDengine/tree/develop/src/connector/grafana/tdengine"
|
"homepage": "https://github.com/taosdata/TDengine/tree/develop/src/connector/grafana/tdengine"
|
||||||
|
|
|
@ -1888,14 +1888,10 @@ locate-path@^3.0.0:
|
||||||
p-locate "^3.0.0"
|
p-locate "^3.0.0"
|
||||||
path-exists "^3.0.0"
|
path-exists "^3.0.0"
|
||||||
|
|
||||||
lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.4, lodash@^4.2.0, lodash@~4.17.10, lodash@~4.17.5:
|
lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.2.0, lodash@~4.17.10, lodash@~4.17.5:
|
||||||
version "4.17.13"
|
version "4.17.19"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
|
||||||
|
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
|
||||||
lodash@^4.17.15:
|
|
||||||
version "4.17.15"
|
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
|
||||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
|
||||||
|
|
||||||
log-symbols@2.2.0:
|
log-symbols@2.2.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
|
|
|
@ -103,9 +103,6 @@ void cqClose(void *handle) {
|
||||||
SCqContext *pContext = handle;
|
SCqContext *pContext = handle;
|
||||||
if (handle == NULL) return;
|
if (handle == NULL) return;
|
||||||
|
|
||||||
taosTmrCleanUp(pContext->tmrCtrl);
|
|
||||||
pContext->tmrCtrl = NULL;
|
|
||||||
|
|
||||||
// stop all CQs
|
// stop all CQs
|
||||||
cqStop(pContext);
|
cqStop(pContext);
|
||||||
|
|
||||||
|
@ -125,6 +122,9 @@ void cqClose(void *handle) {
|
||||||
|
|
||||||
pthread_mutex_destroy(&pContext->mutex);
|
pthread_mutex_destroy(&pContext->mutex);
|
||||||
|
|
||||||
|
taosTmrCleanUp(pContext->tmrCtrl);
|
||||||
|
pContext->tmrCtrl = NULL;
|
||||||
|
|
||||||
cTrace("vgId:%d, CQ is closed", pContext->vgId);
|
cTrace("vgId:%d, CQ is closed", pContext->vgId);
|
||||||
free(pContext);
|
free(pContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ void* dnodeGetVnodeTsdb(void *pVnode);
|
||||||
void dnodeReleaseVnode(void *pVnode);
|
void dnodeReleaseVnode(void *pVnode);
|
||||||
|
|
||||||
void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell);
|
void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell);
|
||||||
void dnodeGetMnodeIpSetForPeer(void *ipSet);
|
void dnodeGetMnodeEpSetForPeer(void *epSet);
|
||||||
void dnodeGetMnodeIpSetForShell(void *ipSet);
|
void dnodeGetMnodeEpSetForShell(void *epSet);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ void * tsDnodeTmr = NULL;
|
||||||
static void * tsStatusTimer = NULL;
|
static void * tsStatusTimer = NULL;
|
||||||
static uint32_t tsRebootTime;
|
static uint32_t tsRebootTime;
|
||||||
|
|
||||||
static SRpcIpSet tsDMnodeIpSet = {0};
|
static SRpcEpSet tsDMnodeEpSet = {0};
|
||||||
static SDMMnodeInfos tsDMnodeInfos = {0};
|
static SDMMnodeInfos tsDMnodeInfos = {0};
|
||||||
static SDMDnodeCfg tsDnodeCfg = {0};
|
static SDMDnodeCfg tsDnodeCfg = {0};
|
||||||
static taos_qset tsMgmtQset = NULL;
|
static taos_qset tsMgmtQset = NULL;
|
||||||
|
@ -90,21 +90,21 @@ int32_t dnodeInitMgmt() {
|
||||||
tsRebootTime = taosGetTimestampSec();
|
tsRebootTime = taosGetTimestampSec();
|
||||||
|
|
||||||
if (!dnodeReadMnodeInfos()) {
|
if (!dnodeReadMnodeInfos()) {
|
||||||
memset(&tsDMnodeIpSet, 0, sizeof(SRpcIpSet));
|
memset(&tsDMnodeEpSet, 0, sizeof(SRpcEpSet));
|
||||||
memset(&tsDMnodeInfos, 0, sizeof(SDMMnodeInfos));
|
memset(&tsDMnodeInfos, 0, sizeof(SDMMnodeInfos));
|
||||||
|
|
||||||
tsDMnodeIpSet.numOfIps = 1;
|
tsDMnodeEpSet.numOfEps = 1;
|
||||||
taosGetFqdnPortFromEp(tsFirst, tsDMnodeIpSet.fqdn[0], &tsDMnodeIpSet.port[0]);
|
taosGetFqdnPortFromEp(tsFirst, tsDMnodeEpSet.fqdn[0], &tsDMnodeEpSet.port[0]);
|
||||||
|
|
||||||
if (strcmp(tsSecond, tsFirst) != 0) {
|
if (strcmp(tsSecond, tsFirst) != 0) {
|
||||||
tsDMnodeIpSet.numOfIps = 2;
|
tsDMnodeEpSet.numOfEps = 2;
|
||||||
taosGetFqdnPortFromEp(tsSecond, tsDMnodeIpSet.fqdn[1], &tsDMnodeIpSet.port[1]);
|
taosGetFqdnPortFromEp(tsSecond, tsDMnodeEpSet.fqdn[1], &tsDMnodeEpSet.port[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tsDMnodeIpSet.inUse = tsDMnodeInfos.inUse;
|
tsDMnodeEpSet.inUse = tsDMnodeInfos.inUse;
|
||||||
tsDMnodeIpSet.numOfIps = tsDMnodeInfos.nodeNum;
|
tsDMnodeEpSet.numOfEps = tsDMnodeInfos.nodeNum;
|
||||||
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
|
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
|
||||||
taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSet.fqdn[i], &tsDMnodeIpSet.port[i]);
|
taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeEpSet.fqdn[i], &tsDMnodeEpSet.port[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,27 +450,27 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
|
||||||
return taosCfgDynamicOptions(pCfg->config);
|
return taosCfgDynamicOptions(pCfg->config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeUpdateMnodeIpSetForPeer(SRpcIpSet *pIpSet) {
|
void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) {
|
||||||
dInfo("mnode IP list for is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse);
|
dInfo("mnode EP list for is changed, numOfEps:%d inUse:%d", pEpSet->numOfEps, pEpSet->inUse);
|
||||||
for (int i = 0; i < pIpSet->numOfIps; ++i) {
|
for (int i = 0; i < pEpSet->numOfEps; ++i) {
|
||||||
pIpSet->port[i] -= TSDB_PORT_DNODEDNODE;
|
pEpSet->port[i] -= TSDB_PORT_DNODEDNODE;
|
||||||
dInfo("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i])
|
dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
tsDMnodeIpSet = *pIpSet;
|
tsDMnodeEpSet = *pEpSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeGetMnodeIpSetForPeer(void *ipSetRaw) {
|
void dnodeGetMnodeEpSetForPeer(void *epSetRaw) {
|
||||||
SRpcIpSet *ipSet = ipSetRaw;
|
SRpcEpSet *epSet = epSetRaw;
|
||||||
*ipSet = tsDMnodeIpSet;
|
*epSet = tsDMnodeEpSet;
|
||||||
|
|
||||||
for (int i=0; i<ipSet->numOfIps; ++i)
|
for (int i=0; i<epSet->numOfEps; ++i)
|
||||||
ipSet->port[i] += TSDB_PORT_DNODEDNODE;
|
epSet->port[i] += TSDB_PORT_DNODEDNODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeGetMnodeIpSetForShell(void *ipSetRaw) {
|
void dnodeGetMnodeEpSetForShell(void *epSetRaw) {
|
||||||
SRpcIpSet *ipSet = ipSetRaw;
|
SRpcEpSet *epSet = epSetRaw;
|
||||||
*ipSet = tsDMnodeIpSet;
|
*epSet = tsDMnodeEpSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
|
static void dnodeProcessStatusRsp(SRpcMsg *pMsg) {
|
||||||
|
@ -536,10 +536,10 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) {
|
||||||
dInfo("mnode index:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
|
dInfo("mnode index:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsDMnodeIpSet.inUse = tsDMnodeInfos.inUse;
|
tsDMnodeEpSet.inUse = tsDMnodeInfos.inUse;
|
||||||
tsDMnodeIpSet.numOfIps = tsDMnodeInfos.nodeNum;
|
tsDMnodeEpSet.numOfEps = tsDMnodeInfos.nodeNum;
|
||||||
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
|
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
|
||||||
taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSet.fqdn[i], &tsDMnodeIpSet.port[i]);
|
taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeEpSet.fqdn[i], &tsDMnodeEpSet.port[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeSaveMnodeInfos();
|
dnodeSaveMnodeInfos();
|
||||||
|
@ -549,10 +549,10 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) {
|
||||||
static bool dnodeReadMnodeInfos() {
|
static bool dnodeReadMnodeInfos() {
|
||||||
char ipFile[TSDB_FILENAME_LEN*2] = {0};
|
char ipFile[TSDB_FILENAME_LEN*2] = {0};
|
||||||
|
|
||||||
sprintf(ipFile, "%s/mnodeIpList.json", tsDnodeDir);
|
sprintf(ipFile, "%s/mnodeEpSet.json", tsDnodeDir);
|
||||||
FILE *fp = fopen(ipFile, "r");
|
FILE *fp = fopen(ipFile, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
dDebug("failed to read mnodeIpList.json, file not exist");
|
dDebug("failed to read mnodeEpSet.json, file not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,40 +563,40 @@ static bool dnodeReadMnodeInfos() {
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
free(content);
|
free(content);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
dError("failed to read mnodeIpList.json, content is null");
|
dError("failed to read mnodeEpSet.json, content is null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content[len] = 0;
|
content[len] = 0;
|
||||||
cJSON* root = cJSON_Parse(content);
|
cJSON* root = cJSON_Parse(content);
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
dError("failed to read mnodeIpList.json, invalid json format");
|
dError("failed to read mnodeEpSet.json, invalid json format");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* inUse = cJSON_GetObjectItem(root, "inUse");
|
cJSON* inUse = cJSON_GetObjectItem(root, "inUse");
|
||||||
if (!inUse || inUse->type != cJSON_Number) {
|
if (!inUse || inUse->type != cJSON_Number) {
|
||||||
dError("failed to read mnodeIpList.json, inUse not found");
|
dError("failed to read mnodeEpSet.json, inUse not found");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
tsDMnodeInfos.inUse = inUse->valueint;
|
tsDMnodeInfos.inUse = inUse->valueint;
|
||||||
|
|
||||||
cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum");
|
cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum");
|
||||||
if (!nodeNum || nodeNum->type != cJSON_Number) {
|
if (!nodeNum || nodeNum->type != cJSON_Number) {
|
||||||
dError("failed to read mnodeIpList.json, nodeNum not found");
|
dError("failed to read mnodeEpSet.json, nodeNum not found");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
tsDMnodeInfos.nodeNum = nodeNum->valueint;
|
tsDMnodeInfos.nodeNum = nodeNum->valueint;
|
||||||
|
|
||||||
cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos");
|
cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos");
|
||||||
if (!nodeInfos || nodeInfos->type != cJSON_Array) {
|
if (!nodeInfos || nodeInfos->type != cJSON_Array) {
|
||||||
dError("failed to read mnodeIpList.json, nodeInfos not found");
|
dError("failed to read mnodeEpSet.json, nodeInfos not found");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = cJSON_GetArraySize(nodeInfos);
|
int size = cJSON_GetArraySize(nodeInfos);
|
||||||
if (size != tsDMnodeInfos.nodeNum) {
|
if (size != tsDMnodeInfos.nodeNum) {
|
||||||
dError("failed to read mnodeIpList.json, nodeInfos size not matched");
|
dError("failed to read mnodeEpSet.json, nodeInfos size not matched");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,14 +606,14 @@ static bool dnodeReadMnodeInfos() {
|
||||||
|
|
||||||
cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId");
|
cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId");
|
||||||
if (!nodeId || nodeId->type != cJSON_Number) {
|
if (!nodeId || nodeId->type != cJSON_Number) {
|
||||||
dError("failed to read mnodeIpList.json, nodeId not found");
|
dError("failed to read mnodeEpSet.json, nodeId not found");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
tsDMnodeInfos.nodeInfos[i].nodeId = nodeId->valueint;
|
tsDMnodeInfos.nodeInfos[i].nodeId = nodeId->valueint;
|
||||||
|
|
||||||
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
|
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
|
||||||
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
|
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
|
||||||
dError("failed to read mnodeIpList.json, nodeName not found");
|
dError("failed to read mnodeEpSet.json, nodeName not found");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
strncpy(tsDMnodeInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_EP_LEN);
|
strncpy(tsDMnodeInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_EP_LEN);
|
||||||
|
@ -621,7 +621,7 @@ static bool dnodeReadMnodeInfos() {
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
dInfo("read mnode iplist successed, numOfIps:%d inUse:%d", tsDMnodeInfos.nodeNum, tsDMnodeInfos.inUse);
|
dInfo("read mnode epSet successed, numOfEps:%d inUse:%d", tsDMnodeInfos.nodeNum, tsDMnodeInfos.inUse);
|
||||||
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
|
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
|
||||||
dInfo("mnode:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
|
dInfo("mnode:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
|
||||||
}
|
}
|
||||||
|
@ -635,7 +635,7 @@ PARSE_OVER:
|
||||||
|
|
||||||
static void dnodeSaveMnodeInfos() {
|
static void dnodeSaveMnodeInfos() {
|
||||||
char ipFile[TSDB_FILENAME_LEN] = {0};
|
char ipFile[TSDB_FILENAME_LEN] = {0};
|
||||||
sprintf(ipFile, "%s/mnodeIpList.json", tsDnodeDir);
|
sprintf(ipFile, "%s/mnodeEpSet.json", tsDnodeDir);
|
||||||
FILE *fp = fopen(ipFile, "w");
|
FILE *fp = fopen(ipFile, "w");
|
||||||
if (!fp) return;
|
if (!fp) return;
|
||||||
|
|
||||||
|
@ -663,11 +663,11 @@ static void dnodeSaveMnodeInfos() {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
free(content);
|
free(content);
|
||||||
|
|
||||||
dInfo("save mnode iplist successed");
|
dInfo("save mnode epSet successed");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *dnodeGetMnodeMasterEp() {
|
char *dnodeGetMnodeMasterEp() {
|
||||||
return tsDMnodeInfos.nodeInfos[tsDMnodeIpSet.inUse].nodeEp;
|
return tsDMnodeInfos.nodeInfos[tsDMnodeEpSet.inUse].nodeEp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* dnodeGetMnodeInfos() {
|
void* dnodeGetMnodeInfos() {
|
||||||
|
@ -726,9 +726,9 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
|
||||||
.msgType = TSDB_MSG_TYPE_DM_STATUS
|
.msgType = TSDB_MSG_TYPE_DM_STATUS
|
||||||
};
|
};
|
||||||
|
|
||||||
SRpcIpSet ipSet;
|
SRpcEpSet epSet;
|
||||||
dnodeGetMnodeIpSetForPeer(&ipSet);
|
dnodeGetMnodeEpSetForPeer(&epSet);
|
||||||
dnodeSendMsgToDnode(&ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(&epSet, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dnodeReadDnodeCfg() {
|
static bool dnodeReadDnodeCfg() {
|
||||||
|
@ -817,20 +817,20 @@ void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell) {
|
||||||
SRpcConnInfo connInfo = {0};
|
SRpcConnInfo connInfo = {0};
|
||||||
rpcGetConnInfo(rpcMsg->handle, &connInfo);
|
rpcGetConnInfo(rpcMsg->handle, &connInfo);
|
||||||
|
|
||||||
SRpcIpSet ipSet = {0};
|
SRpcEpSet epSet = {0};
|
||||||
if (forShell) {
|
if (forShell) {
|
||||||
dnodeGetMnodeIpSetForShell(&ipSet);
|
dnodeGetMnodeEpSetForShell(&epSet);
|
||||||
} else {
|
} else {
|
||||||
dnodeGetMnodeIpSetForPeer(&ipSet);
|
dnodeGetMnodeEpSetForPeer(&epSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("msg:%s will be redirected, dnodeIp:%s user:%s, numOfIps:%d inUse:%d", taosMsg[rpcMsg->msgType],
|
dDebug("msg:%s will be redirected, dnodeIp:%s user:%s, numOfEps:%d inUse:%d", taosMsg[rpcMsg->msgType],
|
||||||
taosIpStr(connInfo.clientIp), connInfo.user, ipSet.numOfIps, ipSet.inUse);
|
taosIpStr(connInfo.clientIp), connInfo.user, epSet.numOfEps, epSet.inUse);
|
||||||
|
|
||||||
for (int i = 0; i < ipSet.numOfIps; ++i) {
|
for (int i = 0; i < epSet.numOfEps; ++i) {
|
||||||
dDebug("mnode index:%d %s:%d", i, ipSet.fqdn[i], ipSet.port[i]);
|
dDebug("mnode index:%d %s:%d", i, epSet.fqdn[i], epSet.port[i]);
|
||||||
ipSet.port[i] = htons(ipSet.port[i]);
|
epSet.port[i] = htons(epSet.port[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcSendRedirectRsp(rpcMsg->handle, &ipSet);
|
rpcSendRedirectRsp(rpcMsg->handle, &epSet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,11 @@
|
||||||
#include "dnodeVWrite.h"
|
#include "dnodeVWrite.h"
|
||||||
#include "dnodeMPeer.h"
|
#include "dnodeMPeer.h"
|
||||||
|
|
||||||
extern void dnodeUpdateMnodeIpSetForPeer(SRpcIpSet *pIpSet);
|
extern void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet);
|
||||||
static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
||||||
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *);
|
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *);
|
||||||
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
|
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
|
||||||
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet);
|
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet);
|
||||||
static void *tsDnodeServerRpc = NULL;
|
static void *tsDnodeServerRpc = NULL;
|
||||||
static void *tsDnodeClientRpc = NULL;
|
static void *tsDnodeClientRpc = NULL;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ void dnodeCleanupServer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
|
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
SRpcMsg rspMsg = {
|
SRpcMsg rspMsg = {
|
||||||
.handle = pMsg->handle,
|
.handle = pMsg->handle,
|
||||||
.pCont = NULL,
|
.pCont = NULL,
|
||||||
|
@ -148,9 +148,9 @@ void dnodeCleanupClient() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
|
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
if (pMsg->msgType == TSDB_MSG_TYPE_DM_STATUS_RSP && pIpSet) {
|
if (pMsg->msgType == TSDB_MSG_TYPE_DM_STATUS_RSP && pEpSet) {
|
||||||
dnodeUpdateMnodeIpSetForPeer(pIpSet);
|
dnodeUpdateMnodeEpSetForPeer(pEpSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dnodeProcessRspMsgFp[pMsg->msgType]) {
|
if (dnodeProcessRspMsgFp[pMsg->msgType]) {
|
||||||
|
@ -166,12 +166,12 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
|
||||||
dnodeProcessRspMsgFp[msgType] = fp;
|
dnodeProcessRspMsgFp[msgType] = fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) {
|
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg) {
|
||||||
rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg);
|
rpcSendRequest(tsDnodeClientRpc, epSet, rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
|
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
|
||||||
SRpcIpSet ipSet = {0};
|
SRpcEpSet epSet = {0};
|
||||||
dnodeGetMnodeIpSetForPeer(&ipSet);
|
dnodeGetMnodeEpSetForPeer(&epSet);
|
||||||
rpcSendRecv(tsDnodeClientRpc, &ipSet, rpcMsg, rpcRsp);
|
rpcSendRecv(tsDnodeClientRpc, &epSet, rpcMsg, rpcRsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "dnodeShell.h"
|
#include "dnodeShell.h"
|
||||||
|
|
||||||
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
||||||
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *);
|
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *);
|
||||||
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
static void * tsDnodeShellRpc = NULL;
|
static void * tsDnodeShellRpc = NULL;
|
||||||
static int32_t tsDnodeQueryReqNum = 0;
|
static int32_t tsDnodeQueryReqNum = 0;
|
||||||
|
@ -108,7 +108,7 @@ void dnodeCleanupShell() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
|
void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.handle = pMsg->handle,
|
.handle = pMsg->handle,
|
||||||
.pCont = NULL,
|
.pCont = NULL,
|
||||||
|
|
|
@ -39,13 +39,13 @@ SDnodeStatisInfo dnodeGetStatisInfo();
|
||||||
|
|
||||||
bool dnodeIsFirstDeploy();
|
bool dnodeIsFirstDeploy();
|
||||||
char * dnodeGetMnodeMasterEp();
|
char * dnodeGetMnodeMasterEp();
|
||||||
void dnodeGetMnodeIpSetForPeer(void *ipSet);
|
void dnodeGetMnodeEpSetForPeer(void *epSet);
|
||||||
void dnodeGetMnodeIpSetForShell(void *ipSet);
|
void dnodeGetMnodeEpSetForShell(void *epSet);
|
||||||
void * dnodeGetMnodeInfos();
|
void * dnodeGetMnodeInfos();
|
||||||
int32_t dnodeGetDnodeId();
|
int32_t dnodeGetDnodeId();
|
||||||
|
|
||||||
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
|
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
|
||||||
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg);
|
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg);
|
||||||
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
|
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
|
||||||
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid);
|
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid);
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ extern char *taosMsg[];
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char fqdn[TSDB_FQDN_LEN];
|
char fqdn[TSDB_FQDN_LEN];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
} SIpAddr;
|
} SEpAddr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t numOfVnodes;
|
int32_t numOfVnodes;
|
||||||
|
@ -306,7 +306,7 @@ typedef struct {
|
||||||
int8_t reserved1;
|
int8_t reserved1;
|
||||||
int8_t reserved2;
|
int8_t reserved2;
|
||||||
int32_t connId;
|
int32_t connId;
|
||||||
SRpcIpSet ipList;
|
SRpcEpSet epSet;
|
||||||
} SCMConnectRsp;
|
} SCMConnectRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -648,8 +648,8 @@ typedef struct SCMSTableVgroupMsg {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int8_t numOfIps;
|
int8_t numOfEps;
|
||||||
SIpAddr ipAddr[TSDB_MAX_REPLICA];
|
SEpAddr epAddr[TSDB_MAX_REPLICA];
|
||||||
} SCMVgroupInfo;
|
} SCMVgroupInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -753,7 +753,7 @@ typedef struct {
|
||||||
uint32_t onlineDnodes;
|
uint32_t onlineDnodes;
|
||||||
uint32_t connId;
|
uint32_t connId;
|
||||||
int8_t killConnection;
|
int8_t killConnection;
|
||||||
SRpcIpSet ipList;
|
SRpcEpSet epSet;
|
||||||
} SCMHeartBeatRsp;
|
} SCMHeartBeatRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -28,12 +28,12 @@ extern "C" {
|
||||||
|
|
||||||
extern int tsRpcHeadSize;
|
extern int tsRpcHeadSize;
|
||||||
|
|
||||||
typedef struct SRpcIpSet {
|
typedef struct SRpcEpSet {
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
int8_t numOfIps;
|
int8_t numOfEps;
|
||||||
uint16_t port[TSDB_MAX_REPLICA];
|
uint16_t port[TSDB_MAX_REPLICA];
|
||||||
char fqdn[TSDB_MAX_REPLICA][TSDB_FQDN_LEN];
|
char fqdn[TSDB_MAX_REPLICA][TSDB_FQDN_LEN];
|
||||||
} SRpcIpSet;
|
} SRpcEpSet;
|
||||||
|
|
||||||
typedef struct SRpcConnInfo {
|
typedef struct SRpcConnInfo {
|
||||||
uint32_t clientIp;
|
uint32_t clientIp;
|
||||||
|
@ -67,7 +67,7 @@ typedef struct SRpcInit {
|
||||||
char *ckey; // ciphering key
|
char *ckey; // ciphering key
|
||||||
|
|
||||||
// call back to process incoming msg, code shall be ignored by server app
|
// call back to process incoming msg, code shall be ignored by server app
|
||||||
void (*cfp)(SRpcMsg *, SRpcIpSet *);
|
void (*cfp)(SRpcMsg *, SRpcEpSet *);
|
||||||
|
|
||||||
// call back to retrieve the client auth info, for server app only
|
// call back to retrieve the client auth info, for server app only
|
||||||
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
@ -78,11 +78,11 @@ void rpcClose(void *);
|
||||||
void *rpcMallocCont(int contLen);
|
void *rpcMallocCont(int contLen);
|
||||||
void rpcFreeCont(void *pCont);
|
void rpcFreeCont(void *pCont);
|
||||||
void *rpcReallocCont(void *ptr, int contLen);
|
void *rpcReallocCont(void *ptr, int contLen);
|
||||||
void rpcSendRequest(void *thandle, const SRpcIpSet *pIpSet, SRpcMsg *pMsg);
|
void rpcSendRequest(void *thandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
void rpcSendResponse(const SRpcMsg *pMsg);
|
void rpcSendResponse(const SRpcMsg *pMsg);
|
||||||
void rpcSendRedirectRsp(void *pConn, const SRpcIpSet *pIpSet);
|
void rpcSendRedirectRsp(void *pConn, const SRpcEpSet *pEpSet);
|
||||||
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
||||||
void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
||||||
void rpcCancelRequest(void *pContext);
|
void rpcCancelRequest(void *pContext);
|
||||||
|
|
||||||
|
|
|
@ -210,10 +210,10 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
(void)snprintf(mnodeWal, TSDB_FILENAME_LEN*2, "%s/mnode/wal/wal0", arguments.dataDir);
|
(void)snprintf(mnodeWal, TSDB_FILENAME_LEN*2, "%s/mnode/wal/wal0", arguments.dataDir);
|
||||||
walModWalFile(mnodeWal);
|
walModWalFile(mnodeWal);
|
||||||
|
|
||||||
// 2. modfiy dnode config: mnodeIpList.json
|
// 2. modfiy dnode config: mnodeEpSet.json
|
||||||
char dnodeIpList[TSDB_FILENAME_LEN*2] = {0};
|
char dnodeEpSet[TSDB_FILENAME_LEN*2] = {0};
|
||||||
(void)snprintf(dnodeIpList, TSDB_FILENAME_LEN*2, "%s/dnode/mnodeIpList.json", arguments.dataDir);
|
(void)snprintf(dnodeEpSet, TSDB_FILENAME_LEN*2, "%s/dnode/mnodeEpSet.json", arguments.dataDir);
|
||||||
modDnodeIpList(dnodeIpList);
|
modDnodeEpSet(dnodeEpSet);
|
||||||
|
|
||||||
// 3. modify vnode config: config.json
|
// 3. modify vnode config: config.json
|
||||||
char vnodeDir[TSDB_FILENAME_LEN*2] = {0};
|
char vnodeDir[TSDB_FILENAME_LEN*2] = {0};
|
||||||
|
|
|
@ -71,7 +71,7 @@ int tSystemShell(const char * cmd);
|
||||||
void taosMvFile(char* destFile, char *srcFile) ;
|
void taosMvFile(char* destFile, char *srcFile) ;
|
||||||
void walModWalFile(char* walfile);
|
void walModWalFile(char* walfile);
|
||||||
SdnodeIfo* getDnodeInfo(int32_t dnodeId);
|
SdnodeIfo* getDnodeInfo(int32_t dnodeId);
|
||||||
void modDnodeIpList(char* dnodeIpList);
|
void modDnodeEpSet(char* dnodeEpSet);
|
||||||
void modAllVnode(char *vnodeDir);
|
void modAllVnode(char *vnodeDir);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
|
|
||||||
static SDMMnodeInfos tsDnodeIpInfos = {0};
|
static SDMMnodeInfos tsDnodeIpInfos = {0};
|
||||||
|
|
||||||
static bool dnodeReadMnodeInfos(char* dnodeIpList) {
|
static bool dnodeReadMnodeInfos(char* dnodeEpSet) {
|
||||||
FILE *fp = fopen(dnodeIpList, "r");
|
FILE *fp = fopen(dnodeEpSet, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
printf("failed to read mnodeIpList.json, file not exist\n");
|
printf("failed to read mnodeEpSet.json, file not exist\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,40 +37,40 @@ static bool dnodeReadMnodeInfos(char* dnodeIpList) {
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
free(content);
|
free(content);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
printf("failed to read mnodeIpList.json, content is null\n");
|
printf("failed to read mnodeEpSet.json, content is null\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content[len] = 0;
|
content[len] = 0;
|
||||||
cJSON* root = cJSON_Parse(content);
|
cJSON* root = cJSON_Parse(content);
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
printf("failed to read mnodeIpList.json, invalid json format\n");
|
printf("failed to read mnodeEpSet.json, invalid json format\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* inUse = cJSON_GetObjectItem(root, "inUse");
|
cJSON* inUse = cJSON_GetObjectItem(root, "inUse");
|
||||||
if (!inUse || inUse->type != cJSON_Number) {
|
if (!inUse || inUse->type != cJSON_Number) {
|
||||||
printf("failed to read mnodeIpList.json, inUse not found\n");
|
printf("failed to read mnodeEpSet.json, inUse not found\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
tsDnodeIpInfos.inUse = inUse->valueint;
|
tsDnodeIpInfos.inUse = inUse->valueint;
|
||||||
|
|
||||||
cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum");
|
cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum");
|
||||||
if (!nodeNum || nodeNum->type != cJSON_Number) {
|
if (!nodeNum || nodeNum->type != cJSON_Number) {
|
||||||
printf("failed to read mnodeIpList.json, nodeNum not found\n");
|
printf("failed to read mnodeEpSet.json, nodeNum not found\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
tsDnodeIpInfos.nodeNum = nodeNum->valueint;
|
tsDnodeIpInfos.nodeNum = nodeNum->valueint;
|
||||||
|
|
||||||
cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos");
|
cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos");
|
||||||
if (!nodeInfos || nodeInfos->type != cJSON_Array) {
|
if (!nodeInfos || nodeInfos->type != cJSON_Array) {
|
||||||
printf("failed to read mnodeIpList.json, nodeInfos not found\n");
|
printf("failed to read mnodeEpSet.json, nodeInfos not found\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = cJSON_GetArraySize(nodeInfos);
|
int size = cJSON_GetArraySize(nodeInfos);
|
||||||
if (size != tsDnodeIpInfos.nodeNum) {
|
if (size != tsDnodeIpInfos.nodeNum) {
|
||||||
printf("failed to read mnodeIpList.json, nodeInfos size not matched\n");
|
printf("failed to read mnodeEpSet.json, nodeInfos size not matched\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,14 +80,14 @@ static bool dnodeReadMnodeInfos(char* dnodeIpList) {
|
||||||
|
|
||||||
cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId");
|
cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId");
|
||||||
if (!nodeId || nodeId->type != cJSON_Number) {
|
if (!nodeId || nodeId->type != cJSON_Number) {
|
||||||
printf("failed to read mnodeIpList.json, nodeId not found\n");
|
printf("failed to read mnodeEpSet.json, nodeId not found\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
tsDnodeIpInfos.nodeInfos[i].nodeId = nodeId->valueint;
|
tsDnodeIpInfos.nodeInfos[i].nodeId = nodeId->valueint;
|
||||||
|
|
||||||
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
|
cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp");
|
||||||
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
|
if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) {
|
||||||
printf("failed to read mnodeIpList.json, nodeName not found\n");
|
printf("failed to read mnodeEpSet.json, nodeName not found\n");
|
||||||
goto PARSE_OVER;
|
goto PARSE_OVER;
|
||||||
}
|
}
|
||||||
strncpy(tsDnodeIpInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_EP_LEN);
|
strncpy(tsDnodeIpInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_EP_LEN);
|
||||||
|
@ -102,7 +102,7 @@ static bool dnodeReadMnodeInfos(char* dnodeIpList) {
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
//printf("read mnode iplist successed, numOfIps:%d inUse:%d\n", tsDnodeIpInfos.nodeNum, tsDnodeIpInfos.inUse);
|
//printf("read mnode epSet successed, numOfEps:%d inUse:%d\n", tsDnodeIpInfos.nodeNum, tsDnodeIpInfos.inUse);
|
||||||
//for (int32_t i = 0; i < tsDnodeIpInfos.nodeNum; i++) {
|
//for (int32_t i = 0; i < tsDnodeIpInfos.nodeNum; i++) {
|
||||||
// printf("mnode:%d, %s\n", tsDnodeIpInfos.nodeInfos[i].nodeId, tsDnodeIpInfos.nodeInfos[i].nodeEp);
|
// printf("mnode:%d, %s\n", tsDnodeIpInfos.nodeInfos[i].nodeId, tsDnodeIpInfos.nodeInfos[i].nodeEp);
|
||||||
//}
|
//}
|
||||||
|
@ -115,8 +115,8 @@ PARSE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dnodeSaveMnodeInfos(char* dnodeIpList) {
|
static void dnodeSaveMnodeInfos(char* dnodeEpSet) {
|
||||||
FILE *fp = fopen(dnodeIpList, "w");
|
FILE *fp = fopen(dnodeEpSet, "w");
|
||||||
if (!fp) return;
|
if (!fp) return;
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
@ -143,13 +143,13 @@ static void dnodeSaveMnodeInfos(char* dnodeIpList) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
free(content);
|
free(content);
|
||||||
|
|
||||||
printf("mod mnode iplist successed\n");
|
printf("mod mnode epSet successed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void modDnodeIpList(char* dnodeIpList)
|
void modDnodeEpSet(char* dnodeEpSet)
|
||||||
{
|
{
|
||||||
(void)dnodeReadMnodeInfos(dnodeIpList);
|
(void)dnodeReadMnodeInfos(dnodeEpSet);
|
||||||
dnodeSaveMnodeInfos(dnodeIpList);
|
dnodeSaveMnodeInfos(dnodeEpSet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,12 @@ void mnodeIncMnodeRef(struct SMnodeObj *pMnode);
|
||||||
void mnodeDecMnodeRef(struct SMnodeObj *pMnode);
|
void mnodeDecMnodeRef(struct SMnodeObj *pMnode);
|
||||||
|
|
||||||
char * mnodeGetMnodeRoleStr();
|
char * mnodeGetMnodeRoleStr();
|
||||||
void mnodeGetMnodeIpSetForPeer(SRpcIpSet *ipSet);
|
void mnodeGetMnodeEpSetForPeer(SRpcEpSet *epSet);
|
||||||
void mnodeGetMnodeIpSetForShell(SRpcIpSet *ipSet);
|
void mnodeGetMnodeEpSetForShell(SRpcEpSet *epSet);
|
||||||
char* mnodeGetMnodeMasterEp();
|
char* mnodeGetMnodeMasterEp();
|
||||||
|
|
||||||
void mnodeGetMnodeInfos(void *mnodes);
|
void mnodeGetMnodeInfos(void *mnodes);
|
||||||
void mnodeUpdateMnodeIpSet();
|
void mnodeUpdateMnodeEpSet();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@ int32_t mnodeGetAvailableVgroup(struct SMnodeMsg *pMsg, SVgObj **pVgroup, int32_
|
||||||
|
|
||||||
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable);
|
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable);
|
||||||
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable);
|
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable);
|
||||||
void mnodeSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle);
|
void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle);
|
||||||
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle);
|
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle);
|
||||||
void mnodeSendAlterVgroupMsg(SVgObj *pVgroup);
|
void mnodeSendAlterVgroupMsg(SVgObj *pVgroup);
|
||||||
|
|
||||||
SRpcIpSet mnodeGetIpSetFromVgroup(SVgObj *pVgroup);
|
SRpcEpSet mnodeGetEpSetFromVgroup(SVgObj *pVgroup);
|
||||||
SRpcIpSet mnodeGetIpSetFromIp(char *ep);
|
SRpcEpSet mnodeGetEpSetFromIp(char *ep);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,14 +289,14 @@ static int32_t mnodeProcessCfgDnodeMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pCmCfgDnode->ep);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pCmCfgDnode->ep);
|
||||||
if (dnodeId != 0) {
|
if (dnodeId != 0) {
|
||||||
SDnodeObj *pDnode = mnodeGetDnode(dnodeId);
|
SDnodeObj *pDnode = mnodeGetDnode(dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("failed to cfg dnode, invalid dnodeId:%d", dnodeId);
|
mError("failed to cfg dnode, invalid dnodeId:%d", dnodeId);
|
||||||
return TSDB_CODE_MND_DNODE_NOT_EXIST;
|
return TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
}
|
}
|
||||||
ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp);
|
epSet = mnodeGetEpSetFromIp(pDnode->dnodeEp);
|
||||||
mnodeDecDnodeRef(pDnode);
|
mnodeDecDnodeRef(pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ static int32_t mnodeProcessCfgDnodeMsg(SMnodeMsg *pMsg) {
|
||||||
};
|
};
|
||||||
|
|
||||||
mInfo("dnode:%s, is configured by %s", pCmCfgDnode->ep, pMsg->pUser->user);
|
mInfo("dnode:%s, is configured by %s", pCmCfgDnode->ep, pMsg->pUser->user);
|
||||||
dnodeSendMsgToDnode(&ipSet, &rpcMdCfgDnodeMsg);
|
dnodeSendMsgToDnode(&epSet, &rpcMdCfgDnodeMsg);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -399,9 +399,9 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
SVgObj *pVgroup = mnodeGetVgroup(pVload->vgId);
|
SVgObj *pVgroup = mnodeGetVgroup(pVload->vgId);
|
||||||
if (pVgroup == NULL) {
|
if (pVgroup == NULL) {
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pDnode->dnodeEp);
|
||||||
mInfo("dnode:%d, vgId:%d not exist in mnode, drop it", pDnode->dnodeId, pVload->vgId);
|
mInfo("dnode:%d, vgId:%d not exist in mnode, drop it", pDnode->dnodeId, pVload->vgId);
|
||||||
mnodeSendDropVnodeMsg(pVload->vgId, &ipSet, NULL);
|
mnodeSendDropVnodeMsg(pVload->vgId, &epSet, NULL);
|
||||||
} else {
|
} else {
|
||||||
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
|
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
|
||||||
pAccess->vgId = htonl(pVload->vgId);
|
pAccess->vgId = htonl(pVload->vgId);
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
|
|
||||||
static void * tsMnodeSdb = NULL;
|
static void * tsMnodeSdb = NULL;
|
||||||
static int32_t tsMnodeUpdateSize = 0;
|
static int32_t tsMnodeUpdateSize = 0;
|
||||||
static SRpcIpSet tsMnodeIpSetForShell;
|
static SRpcEpSet tsMnodeEpSetForShell;
|
||||||
static SRpcIpSet tsMnodeIpSetForPeer;
|
static SRpcEpSet tsMnodeEpSetForPeer;
|
||||||
static SDMMnodeInfos tsMnodeInfos;
|
static SDMMnodeInfos tsMnodeInfos;
|
||||||
static int32_t mnodeGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mnodeGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
@ -123,7 +123,7 @@ static int32_t mnodeMnodeActionRestored() {
|
||||||
sdbFreeIter(pIter);
|
sdbFreeIter(pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeUpdateMnodeIpSet();
|
mnodeUpdateMnodeEpSet();
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -204,13 +204,13 @@ char *mnodeGetMnodeRoleStr(int32_t role) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeUpdateMnodeIpSet() {
|
void mnodeUpdateMnodeEpSet() {
|
||||||
mInfo("update mnodes ipset, numOfIps:%d ", mnodeGetMnodesNum());
|
mInfo("update mnodes epSet, numOfEps:%d ", mnodeGetMnodesNum());
|
||||||
|
|
||||||
mnodeMnodeWrLock();
|
mnodeMnodeWrLock();
|
||||||
|
|
||||||
memset(&tsMnodeIpSetForShell, 0, sizeof(SRpcIpSet));
|
memset(&tsMnodeEpSetForShell, 0, sizeof(SRpcEpSet));
|
||||||
memset(&tsMnodeIpSetForPeer, 0, sizeof(SRpcIpSet));
|
memset(&tsMnodeEpSetForPeer, 0, sizeof(SRpcEpSet));
|
||||||
memset(&tsMnodeInfos, 0, sizeof(SDMMnodeInfos));
|
memset(&tsMnodeInfos, 0, sizeof(SDMMnodeInfos));
|
||||||
|
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
|
@ -222,20 +222,20 @@ void mnodeUpdateMnodeIpSet() {
|
||||||
|
|
||||||
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
|
SDnodeObj *pDnode = mnodeGetDnode(pMnode->mnodeId);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
strcpy(tsMnodeIpSetForShell.fqdn[index], pDnode->dnodeFqdn);
|
strcpy(tsMnodeEpSetForShell.fqdn[index], pDnode->dnodeFqdn);
|
||||||
tsMnodeIpSetForShell.port[index] = htons(pDnode->dnodePort);
|
tsMnodeEpSetForShell.port[index] = htons(pDnode->dnodePort);
|
||||||
mDebug("mnode:%d, for shell fqdn:%s %d", pDnode->dnodeId, tsMnodeIpSetForShell.fqdn[index], htons(tsMnodeIpSetForShell.port[index]));
|
mDebug("mnode:%d, for shell fqdn:%s %d", pDnode->dnodeId, tsMnodeEpSetForShell.fqdn[index], htons(tsMnodeEpSetForShell.port[index]));
|
||||||
|
|
||||||
strcpy(tsMnodeIpSetForPeer.fqdn[index], pDnode->dnodeFqdn);
|
strcpy(tsMnodeEpSetForPeer.fqdn[index], pDnode->dnodeFqdn);
|
||||||
tsMnodeIpSetForPeer.port[index] = htons(pDnode->dnodePort + TSDB_PORT_DNODEDNODE);
|
tsMnodeEpSetForPeer.port[index] = htons(pDnode->dnodePort + TSDB_PORT_DNODEDNODE);
|
||||||
mDebug("mnode:%d, for peer fqdn:%s %d", pDnode->dnodeId, tsMnodeIpSetForPeer.fqdn[index], htons(tsMnodeIpSetForPeer.port[index]));
|
mDebug("mnode:%d, for peer fqdn:%s %d", pDnode->dnodeId, tsMnodeEpSetForPeer.fqdn[index], htons(tsMnodeEpSetForPeer.port[index]));
|
||||||
|
|
||||||
tsMnodeInfos.nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
|
tsMnodeInfos.nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
|
||||||
strcpy(tsMnodeInfos.nodeInfos[index].nodeEp, pDnode->dnodeEp);
|
strcpy(tsMnodeInfos.nodeInfos[index].nodeEp, pDnode->dnodeEp);
|
||||||
|
|
||||||
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) {
|
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) {
|
||||||
tsMnodeIpSetForShell.inUse = index;
|
tsMnodeEpSetForShell.inUse = index;
|
||||||
tsMnodeIpSetForPeer.inUse = index;
|
tsMnodeEpSetForPeer.inUse = index;
|
||||||
tsMnodeInfos.inUse = index;
|
tsMnodeInfos.inUse = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,23 +248,23 @@ void mnodeUpdateMnodeIpSet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
tsMnodeInfos.nodeNum = index;
|
tsMnodeInfos.nodeNum = index;
|
||||||
tsMnodeIpSetForShell.numOfIps = index;
|
tsMnodeEpSetForShell.numOfEps = index;
|
||||||
tsMnodeIpSetForPeer.numOfIps = index;
|
tsMnodeEpSetForPeer.numOfEps = index;
|
||||||
|
|
||||||
sdbFreeIter(pIter);
|
sdbFreeIter(pIter);
|
||||||
|
|
||||||
mnodeMnodeUnLock();
|
mnodeMnodeUnLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeGetMnodeIpSetForPeer(SRpcIpSet *ipSet) {
|
void mnodeGetMnodeEpSetForPeer(SRpcEpSet *epSet) {
|
||||||
mnodeMnodeRdLock();
|
mnodeMnodeRdLock();
|
||||||
*ipSet = tsMnodeIpSetForPeer;
|
*epSet = tsMnodeEpSetForPeer;
|
||||||
mnodeMnodeUnLock();
|
mnodeMnodeUnLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeGetMnodeIpSetForShell(SRpcIpSet *ipSet) {
|
void mnodeGetMnodeEpSetForShell(SRpcEpSet *epSet) {
|
||||||
mnodeMnodeRdLock();
|
mnodeMnodeRdLock();
|
||||||
*ipSet = tsMnodeIpSetForShell;
|
*epSet = tsMnodeEpSetForShell;
|
||||||
mnodeMnodeUnLock();
|
mnodeMnodeUnLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ int32_t mnodeAddMnode(int32_t dnodeId) {
|
||||||
code = TSDB_CODE_MND_SDB_ERROR;
|
code = TSDB_CODE_MND_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeUpdateMnodeIpSet();
|
mnodeUpdateMnodeEpSet();
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ void mnodeDropMnodeLocal(int32_t dnodeId) {
|
||||||
mnodeDecMnodeRef(pMnode);
|
mnodeDecMnodeRef(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeUpdateMnodeIpSet();
|
mnodeUpdateMnodeEpSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mnodeDropMnode(int32_t dnodeId) {
|
int32_t mnodeDropMnode(int32_t dnodeId) {
|
||||||
|
@ -330,7 +330,7 @@ int32_t mnodeDropMnode(int32_t dnodeId) {
|
||||||
|
|
||||||
sdbDecRef(tsMnodeSdb, pMnode);
|
sdbDecRef(tsMnodeSdb, pMnode);
|
||||||
|
|
||||||
mnodeUpdateMnodeIpSet();
|
mnodeUpdateMnodeEpSet();
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,14 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
if (!sdbIsMaster()) {
|
if (!sdbIsMaster()) {
|
||||||
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
|
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
|
||||||
SRpcIpSet *ipSet = rpcMallocCont(sizeof(SRpcIpSet));
|
SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet));
|
||||||
mnodeGetMnodeIpSetForPeer(ipSet);
|
mnodeGetMnodeEpSetForPeer(epSet);
|
||||||
rpcRsp->rsp = ipSet;
|
rpcRsp->rsp = epSet;
|
||||||
rpcRsp->len = sizeof(SRpcIpSet);
|
rpcRsp->len = sizeof(SRpcEpSet);
|
||||||
|
|
||||||
mDebug("%p, msg:%s in mpeer queue, will be redireced inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], ipSet->inUse);
|
mDebug("%p, msg:%s in mpeer queue, will be redireced inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], epSet->inUse);
|
||||||
for (int32_t i = 0; i < ipSet->numOfIps; ++i) {
|
for (int32_t i = 0; i < epSet->numOfEps; ++i) {
|
||||||
mDebug("mnode index:%d ip:%s:%d", i, ipSet->fqdn[i], htons(ipSet->port[i]));
|
mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_RPC_REDIRECT;
|
return TSDB_CODE_RPC_REDIRECT;
|
||||||
|
|
|
@ -49,14 +49,14 @@ int32_t mnodeProcessRead(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
if (!sdbIsMaster()) {
|
if (!sdbIsMaster()) {
|
||||||
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
|
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
|
||||||
SRpcIpSet *ipSet = rpcMallocCont(sizeof(SRpcIpSet));
|
SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet));
|
||||||
mnodeGetMnodeIpSetForShell(ipSet);
|
mnodeGetMnodeEpSetForShell(epSet);
|
||||||
rpcRsp->rsp = ipSet;
|
rpcRsp->rsp = epSet;
|
||||||
rpcRsp->len = sizeof(SRpcIpSet);
|
rpcRsp->len = sizeof(SRpcEpSet);
|
||||||
|
|
||||||
mDebug("%p, msg:%s in mread queue, will be redireced, inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], ipSet->inUse);
|
mDebug("%p, msg:%s in mread queue, will be redireced, inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], epSet->inUse);
|
||||||
for (int32_t i = 0; i < ipSet->numOfIps; ++i) {
|
for (int32_t i = 0; i < epSet->numOfEps; ++i) {
|
||||||
mDebug("mnode index:%d ip:%s:%d", i, ipSet->fqdn[i], htons(ipSet->port[i]));
|
mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_RPC_REDIRECT;
|
return TSDB_CODE_RPC_REDIRECT;
|
||||||
|
|
|
@ -219,7 +219,7 @@ void sdbUpdateMnodeRoles() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeUpdateMnodeIpSet();
|
mnodeUpdateMnodeEpSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion) {
|
static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion) {
|
||||||
|
|
|
@ -270,7 +270,7 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
pHBRsp->onlineDnodes = htonl(mnodeGetOnlinDnodesNum());
|
pHBRsp->onlineDnodes = htonl(mnodeGetOnlinDnodesNum());
|
||||||
pHBRsp->totalDnodes = htonl(mnodeGetDnodesNum());
|
pHBRsp->totalDnodes = htonl(mnodeGetDnodesNum());
|
||||||
mnodeGetMnodeIpSetForShell(&pHBRsp->ipList);
|
mnodeGetMnodeEpSetForShell(&pHBRsp->epSet);
|
||||||
|
|
||||||
pMsg->rpcRsp.rsp = pHBRsp;
|
pMsg->rpcRsp.rsp = pHBRsp;
|
||||||
pMsg->rpcRsp.len = sizeof(SCMHeartBeatRsp);
|
pMsg->rpcRsp.len = sizeof(SCMHeartBeatRsp);
|
||||||
|
@ -335,7 +335,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
pConnectRsp->writeAuth = pUser->writeAuth;
|
pConnectRsp->writeAuth = pUser->writeAuth;
|
||||||
pConnectRsp->superAuth = pUser->superAuth;
|
pConnectRsp->superAuth = pUser->superAuth;
|
||||||
|
|
||||||
mnodeGetMnodeIpSetForShell(&pConnectRsp->ipList);
|
mnodeGetMnodeEpSetForShell(&pConnectRsp->epSet);
|
||||||
|
|
||||||
connect_over:
|
connect_over:
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -910,9 +910,9 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
mInfo("app:%p:%p, stable:%s, send drop stable msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mInfo("app:%p:%p, stable:%s, send drop stable msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
pVgroup->vgId);
|
pVgroup->vgId);
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pVgroup);
|
SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pVgroup);
|
||||||
SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE};
|
SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE};
|
||||||
dnodeSendMsgToDnode(&ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(&epSet, &rpcMsg);
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
}
|
}
|
||||||
taosHashDestroyIter(pIter);
|
taosHashDestroyIter(pIter);
|
||||||
|
@ -1484,10 +1484,10 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
|
||||||
SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode;
|
SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode;
|
||||||
if (pDnode == NULL) break;
|
if (pDnode == NULL) break;
|
||||||
|
|
||||||
tstrncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN);
|
tstrncpy(pVgroupInfo->vgroups[vgSize].epAddr[vn].fqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN);
|
||||||
pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(pDnode->dnodePort);
|
pVgroupInfo->vgroups[vgSize].epAddr[vn].port = htons(pDnode->dnodePort);
|
||||||
|
|
||||||
pVgroupInfo->vgroups[vgSize].numOfIps++;
|
pVgroupInfo->vgroups[vgSize].numOfEps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vgSize++;
|
vgSize++;
|
||||||
|
@ -1615,7 +1615,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pMsg->pVgroup);
|
SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pMsg->pVgroup);
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.ahandle = pMsg,
|
.ahandle = pMsg,
|
||||||
.pCont = pMDCreate,
|
.pCont = pMDCreate,
|
||||||
|
@ -1624,7 +1624,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
.msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE
|
.msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
dnodeSendMsgToDnode(&ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(&epSet, &rpcMsg);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1788,7 +1788,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
|
||||||
pDrop->sid = htonl(pTable->sid);
|
pDrop->sid = htonl(pTable->sid);
|
||||||
pDrop->uid = htobe64(pTable->uid);
|
pDrop->uid = htobe64(pTable->uid);
|
||||||
|
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pMsg->pVgroup);
|
SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pMsg->pVgroup);
|
||||||
|
|
||||||
mInfo("app:%p:%p, table:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mInfo("app:%p:%p, table:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pDrop->tableId, pTable->vgId, pTable->sid, pTable->uid);
|
pDrop->tableId, pTable->vgId, pTable->sid, pTable->uid);
|
||||||
|
@ -1803,7 +1803,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
|
||||||
|
|
||||||
if (!needReturn) rpcMsg.ahandle = NULL;
|
if (!needReturn) rpcMsg.ahandle = NULL;
|
||||||
|
|
||||||
dnodeSendMsgToDnode(&ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(&epSet, &rpcMsg);
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
@ -1842,7 +1842,7 @@ static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pMsg->pVgroup);
|
SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pMsg->pVgroup);
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.ahandle = pMsg,
|
.ahandle = pMsg,
|
||||||
.pCont = pMDCreate,
|
.pCont = pMDCreate,
|
||||||
|
@ -1854,7 +1854,7 @@ static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
mDebug("app:%p:%p, ctable %s, send alter column msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
mDebug("app:%p:%p, ctable %s, send alter column msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||||
pMsg->pVgroup->vgId);
|
pMsg->pVgroup->vgId);
|
||||||
|
|
||||||
dnodeSendMsgToDnode(&ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(&epSet, &rpcMsg);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1996,9 +1996,9 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
|
||||||
for (int32_t i = 0; i < pMsg->pVgroup->numOfVnodes; ++i) {
|
for (int32_t i = 0; i < pMsg->pVgroup->numOfVnodes; ++i) {
|
||||||
SDnodeObj *pDnode = mnodeGetDnode(pMsg->pVgroup->vnodeGid[i].dnodeId);
|
SDnodeObj *pDnode = mnodeGetDnode(pMsg->pVgroup->vnodeGid[i].dnodeId);
|
||||||
if (pDnode == NULL) break;
|
if (pDnode == NULL) break;
|
||||||
strcpy(pMeta->vgroup.ipAddr[i].fqdn, pDnode->dnodeFqdn);
|
strcpy(pMeta->vgroup.epAddr[i].fqdn, pDnode->dnodeFqdn);
|
||||||
pMeta->vgroup.ipAddr[i].port = htons(pDnode->dnodePort + TSDB_PORT_DNODESHELL);
|
pMeta->vgroup.epAddr[i].port = htons(pDnode->dnodePort + TSDB_PORT_DNODESHELL);
|
||||||
pMeta->vgroup.numOfIps++;
|
pMeta->vgroup.numOfEps++;
|
||||||
mnodeDecDnodeRef(pDnode);
|
mnodeDecDnodeRef(pDnode);
|
||||||
}
|
}
|
||||||
pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId);
|
pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId);
|
||||||
|
|
|
@ -317,9 +317,9 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dnodeExist) {
|
if (!dnodeExist) {
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pDnode->dnodeEp);
|
||||||
mError("vgId:%d, dnode:%d not exist in mnode, drop it", pVload->vgId, pDnode->dnodeId);
|
mError("vgId:%d, dnode:%d not exist in mnode, drop it", pVload->vgId, pDnode->dnodeId);
|
||||||
mnodeSendDropVnodeMsg(pVload->vgId, &ipSet, NULL);
|
mnodeSendDropVnodeMsg(pVload->vgId, &epSet, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,29 +809,29 @@ static SMDCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
|
||||||
return pVnode;
|
return pVnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcIpSet mnodeGetIpSetFromVgroup(SVgObj *pVgroup) {
|
SRpcEpSet mnodeGetEpSetFromVgroup(SVgObj *pVgroup) {
|
||||||
SRpcIpSet ipSet = {
|
SRpcEpSet epSet = {
|
||||||
.numOfIps = pVgroup->numOfVnodes,
|
.numOfEps = pVgroup->numOfVnodes,
|
||||||
.inUse = 0,
|
.inUse = 0,
|
||||||
};
|
};
|
||||||
for (int i = 0; i < pVgroup->numOfVnodes; ++i) {
|
for (int i = 0; i < pVgroup->numOfVnodes; ++i) {
|
||||||
strcpy(ipSet.fqdn[i], pVgroup->vnodeGid[i].pDnode->dnodeFqdn);
|
strcpy(epSet.fqdn[i], pVgroup->vnodeGid[i].pDnode->dnodeFqdn);
|
||||||
ipSet.port[i] = pVgroup->vnodeGid[i].pDnode->dnodePort + TSDB_PORT_DNODEDNODE;
|
epSet.port[i] = pVgroup->vnodeGid[i].pDnode->dnodePort + TSDB_PORT_DNODEDNODE;
|
||||||
}
|
}
|
||||||
return ipSet;
|
return epSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcIpSet mnodeGetIpSetFromIp(char *ep) {
|
SRpcEpSet mnodeGetEpSetFromIp(char *ep) {
|
||||||
SRpcIpSet ipSet;
|
SRpcEpSet epSet;
|
||||||
|
|
||||||
ipSet.numOfIps = 1;
|
epSet.numOfEps = 1;
|
||||||
ipSet.inUse = 0;
|
epSet.inUse = 0;
|
||||||
taosGetFqdnPortFromEp(ep, ipSet.fqdn[0], &ipSet.port[0]);
|
taosGetFqdnPortFromEp(ep, epSet.fqdn[0], &epSet.port[0]);
|
||||||
ipSet.port[0] += TSDB_PORT_DNODEDNODE;
|
epSet.port[0] += TSDB_PORT_DNODEDNODE;
|
||||||
return ipSet;
|
return epSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeSendAlterVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet) {
|
static void mnodeSendAlterVnodeMsg(SVgObj *pVgroup, SRpcEpSet *epSet) {
|
||||||
SMDAlterVnodeMsg *pAlter = mnodeBuildVnodeMsg(pVgroup);
|
SMDAlterVnodeMsg *pAlter = mnodeBuildVnodeMsg(pVgroup);
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.ahandle = NULL,
|
.ahandle = NULL,
|
||||||
|
@ -840,21 +840,21 @@ static void mnodeSendAlterVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet) {
|
||||||
.code = 0,
|
.code = 0,
|
||||||
.msgType = TSDB_MSG_TYPE_MD_ALTER_VNODE
|
.msgType = TSDB_MSG_TYPE_MD_ALTER_VNODE
|
||||||
};
|
};
|
||||||
dnodeSendMsgToDnode(ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(epSet, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeSendAlterVgroupMsg(SVgObj *pVgroup) {
|
void mnodeSendAlterVgroupMsg(SVgObj *pVgroup) {
|
||||||
mDebug("vgId:%d, send alter all vnodes msg, numOfVnodes:%d db:%s", pVgroup->vgId, pVgroup->numOfVnodes,
|
mDebug("vgId:%d, send alter all vnodes msg, numOfVnodes:%d db:%s", pVgroup->vgId, pVgroup->numOfVnodes,
|
||||||
pVgroup->dbName);
|
pVgroup->dbName);
|
||||||
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
||||||
mDebug("vgId:%d, index:%d, send alter vnode msg to dnode %s", pVgroup->vgId, i,
|
mDebug("vgId:%d, index:%d, send alter vnode msg to dnode %s", pVgroup->vgId, i,
|
||||||
pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
||||||
mnodeSendAlterVnodeMsg(pVgroup, &ipSet);
|
mnodeSendAlterVnodeMsg(pVgroup, &epSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
|
static void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcEpSet *epSet, void *ahandle) {
|
||||||
SMDCreateVnodeMsg *pCreate = mnodeBuildVnodeMsg(pVgroup);
|
SMDCreateVnodeMsg *pCreate = mnodeBuildVnodeMsg(pVgroup);
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.ahandle = ahandle,
|
.ahandle = ahandle,
|
||||||
|
@ -863,17 +863,17 @@ static void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *aha
|
||||||
.code = 0,
|
.code = 0,
|
||||||
.msgType = TSDB_MSG_TYPE_MD_CREATE_VNODE
|
.msgType = TSDB_MSG_TYPE_MD_CREATE_VNODE
|
||||||
};
|
};
|
||||||
dnodeSendMsgToDnode(ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(epSet, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) {
|
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) {
|
||||||
mDebug("vgId:%d, send create all vnodes msg, numOfVnodes:%d db:%s", pVgroup->vgId, pVgroup->numOfVnodes,
|
mDebug("vgId:%d, send create all vnodes msg, numOfVnodes:%d db:%s", pVgroup->vgId, pVgroup->numOfVnodes,
|
||||||
pVgroup->dbName);
|
pVgroup->dbName);
|
||||||
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
||||||
mDebug("vgId:%d, index:%d, send create vnode msg to dnode %s, ahandle:%p", pVgroup->vgId,
|
mDebug("vgId:%d, index:%d, send create vnode msg to dnode %s, ahandle:%p", pVgroup->vgId,
|
||||||
i, pVgroup->vnodeGid[i].pDnode->dnodeEp, ahandle);
|
i, pVgroup->vnodeGid[i].pDnode->dnodeEp, ahandle);
|
||||||
mnodeSendCreateVnodeMsg(pVgroup, &ipSet, ahandle);
|
mnodeSendCreateVnodeMsg(pVgroup, &epSet, ahandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ static SMDDropVnodeMsg *mnodeBuildDropVnodeMsg(int32_t vgId) {
|
||||||
return pDrop;
|
return pDrop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) {
|
void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle) {
|
||||||
SMDDropVnodeMsg *pDrop = mnodeBuildDropVnodeMsg(vgId);
|
SMDDropVnodeMsg *pDrop = mnodeBuildDropVnodeMsg(vgId);
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.ahandle = ahandle,
|
.ahandle = ahandle,
|
||||||
|
@ -935,16 +935,16 @@ void mnodeSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) {
|
||||||
.code = 0,
|
.code = 0,
|
||||||
.msgType = TSDB_MSG_TYPE_MD_DROP_VNODE
|
.msgType = TSDB_MSG_TYPE_MD_DROP_VNODE
|
||||||
};
|
};
|
||||||
dnodeSendMsgToDnode(ipSet, &rpcMsg);
|
dnodeSendMsgToDnode(epSet, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) {
|
static void mnodeSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) {
|
||||||
pVgroup->status = TAOS_VG_STATUS_DROPPING; // deleting
|
pVgroup->status = TAOS_VG_STATUS_DROPPING; // deleting
|
||||||
mDebug("vgId:%d, send drop all vnodes msg, ahandle:%p", pVgroup->vgId, ahandle);
|
mDebug("vgId:%d, send drop all vnodes msg, ahandle:%p", pVgroup->vgId, ahandle);
|
||||||
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
|
||||||
mDebug("vgId:%d, send drop vnode msg to dnode:%d, ahandle:%p", pVgroup->vgId, pVgroup->vnodeGid[i].dnodeId, ahandle);
|
mDebug("vgId:%d, send drop vnode msg to dnode:%d, ahandle:%p", pVgroup->vgId, pVgroup->vnodeGid[i].dnodeId, ahandle);
|
||||||
mnodeSendDropVnodeMsg(pVgroup->vgId, &ipSet, ahandle);
|
mnodeSendDropVnodeMsg(pVgroup->vgId, &epSet, ahandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,8 +998,8 @@ static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("vgId:%d, send create vnode msg to dnode %s for vnode cfg msg", pVgroup->vgId, pDnode->dnodeEp);
|
mDebug("vgId:%d, send create vnode msg to dnode %s for vnode cfg msg", pVgroup->vgId, pDnode->dnodeEp);
|
||||||
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp);
|
SRpcEpSet epSet = mnodeGetEpSetFromIp(pDnode->dnodeEp);
|
||||||
mnodeSendCreateVnodeMsg(pVgroup, &ipSet, NULL);
|
mnodeSendCreateVnodeMsg(pVgroup, &epSet, NULL);
|
||||||
|
|
||||||
mnodeDecDnodeRef(pDnode);
|
mnodeDecDnodeRef(pDnode);
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
|
|
|
@ -49,16 +49,16 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
if (!sdbIsMaster()) {
|
if (!sdbIsMaster()) {
|
||||||
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
|
SMnodeRsp *rpcRsp = &pMsg->rpcRsp;
|
||||||
SRpcIpSet *ipSet = rpcMallocCont(sizeof(SRpcIpSet));
|
SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet));
|
||||||
mnodeGetMnodeIpSetForShell(ipSet);
|
mnodeGetMnodeEpSetForShell(epSet);
|
||||||
rpcRsp->rsp = ipSet;
|
rpcRsp->rsp = epSet;
|
||||||
rpcRsp->len = sizeof(SRpcIpSet);
|
rpcRsp->len = sizeof(SRpcEpSet);
|
||||||
|
|
||||||
mDebug("app:%p:%p, msg:%s will be redireced inUse:%d", pMsg->rpcMsg.ahandle, pMsg, taosMsg[pMsg->rpcMsg.msgType],
|
mDebug("app:%p:%p, msg:%s will be redireced inUse:%d", pMsg->rpcMsg.ahandle, pMsg, taosMsg[pMsg->rpcMsg.msgType],
|
||||||
ipSet->inUse);
|
epSet->inUse);
|
||||||
for (int32_t i = 0; i < ipSet->numOfIps; ++i) {
|
for (int32_t i = 0; i < epSet->numOfEps; ++i) {
|
||||||
mDebug("app:%p:%p, mnode index:%d ip:%s:%d", pMsg->rpcMsg.ahandle, pMsg, i, ipSet->fqdn[i],
|
mDebug("app:%p:%p, mnode index:%d ep:%s:%d", pMsg->rpcMsg.ahandle, pMsg, i, epSet->fqdn[i],
|
||||||
htons(ipSet->port[i]));
|
htons(epSet->port[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_RPC_REDIRECT;
|
return TSDB_CODE_RPC_REDIRECT;
|
||||||
|
|
|
@ -45,7 +45,6 @@ typedef void (*__do_filter_suppl_fn_t)(void *, void *);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
typedef struct tQueryInfo {
|
typedef struct tQueryInfo {
|
||||||
int32_t colIndex; // index of column in schema
|
|
||||||
uint8_t optr; // expression operator
|
uint8_t optr; // expression operator
|
||||||
SSchema sch; // schema of tags
|
SSchema sch; // schema of tags
|
||||||
char* q;
|
char* q;
|
|
@ -18,16 +18,16 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "qfill.h"
|
#include "qFill.h"
|
||||||
#include "qresultBuf.h"
|
#include "qResultbuf.h"
|
||||||
|
#include "qTsbuf.h"
|
||||||
#include "qsqlparser.h"
|
#include "qsqlparser.h"
|
||||||
#include "qtsbuf.h"
|
#include "query.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsqlfunction.h"
|
#include "tsqlfunction.h"
|
||||||
#include "query.h"
|
|
||||||
|
|
||||||
struct SColumnFilterElem;
|
struct SColumnFilterElem;
|
||||||
typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2);
|
typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2);
|
||||||
|
@ -158,7 +158,7 @@ typedef struct SQueryRuntimeEnv {
|
||||||
SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo
|
SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo
|
||||||
SQuery* pQuery;
|
SQuery* pQuery;
|
||||||
SQLFunctionCtx* pCtx;
|
SQLFunctionCtx* pCtx;
|
||||||
int16_t numOfRowsPerPage;
|
int32_t numOfRowsPerPage;
|
||||||
int16_t offset[TSDB_MAX_COLUMNS];
|
int16_t offset[TSDB_MAX_COLUMNS];
|
||||||
uint16_t scanFlag; // denotes reversed scan of data or not
|
uint16_t scanFlag; // denotes reversed scan of data or not
|
||||||
SFillInfo* pFillInfo;
|
SFillInfo* pFillInfo;
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
||||||
#include "tdataformat.h"
|
#include "tdataformat.h"
|
||||||
#include "talgo.h"
|
#include "talgo.h"
|
||||||
|
|
||||||
#define DEFAULT_PAGE_SIZE (1024L*64) // 16k larger than the SHistoInfo
|
#define DEFAULT_PAGE_SIZE (1024L*4) // 16k larger than the SHistoInfo
|
||||||
#define MAX_TMPFILE_PATH_LENGTH PATH_MAX
|
#define MAX_TMPFILE_PATH_LENGTH PATH_MAX
|
||||||
#define INITIAL_ALLOCATION_BUFFER_SIZE 64
|
#define INITIAL_ALLOCATION_BUFFER_SIZE 64
|
||||||
|
|
|
@ -21,8 +21,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "qExtbuffer.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "qextbuffer.h"
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
STColumn col; // column info
|
STColumn col; // column info
|
|
@ -16,7 +16,7 @@
|
||||||
#ifndef TDENGINE_QPERCENTILE_H
|
#ifndef TDENGINE_QPERCENTILE_H
|
||||||
#define TDENGINE_QPERCENTILE_H
|
#define TDENGINE_QPERCENTILE_H
|
||||||
|
|
||||||
#include "qextbuffer.h"
|
#include "qExtbuffer.h"
|
||||||
|
|
||||||
typedef struct MinMaxEntry {
|
typedef struct MinMaxEntry {
|
||||||
union {
|
union {
|
|
@ -20,9 +20,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
|
||||||
#include "qextbuffer.h"
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "qExtbuffer.h"
|
||||||
|
|
||||||
typedef struct SArray* SIDList;
|
typedef struct SArray* SIDList;
|
||||||
|
|
||||||
|
@ -33,14 +33,19 @@ typedef struct SDiskbasedResultBuf {
|
||||||
int32_t fd; // data file fd
|
int32_t fd; // data file fd
|
||||||
int32_t allocateId; // allocated page id
|
int32_t allocateId; // allocated page id
|
||||||
int32_t incStep; // minimum allocated pages
|
int32_t incStep; // minimum allocated pages
|
||||||
char* pBuf; // mmap buffer pointer
|
void* pBuf; // mmap buffer pointer
|
||||||
char* path; // file path
|
char* path; // file path
|
||||||
|
int32_t pageSize; // current used page size
|
||||||
|
int32_t inMemPages; // numOfPages that are allocated in memory
|
||||||
SHashObj* idsTable; // id hash table
|
SHashObj* idsTable; // id hash table
|
||||||
SIDList list; // for each id, there is a page id list
|
SIDList list; // for each id, there is a page id list
|
||||||
|
|
||||||
|
void* iBuf; // inmemory buf
|
||||||
|
void* handle; // for debug purpose
|
||||||
} SDiskbasedResultBuf;
|
} SDiskbasedResultBuf;
|
||||||
|
|
||||||
#define DEFAULT_INTERN_BUF_PAGE_SIZE (8192L*5)
|
#define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L)
|
||||||
|
#define DEFAULT_INMEM_BUF_PAGES 10
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create disk-based result buffer
|
* create disk-based result buffer
|
||||||
|
@ -49,7 +54,8 @@ typedef struct SDiskbasedResultBuf {
|
||||||
* @param rowSize
|
* @param rowSize
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t size, int32_t rowSize, void* handle);
|
int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t numOfPages, int32_t rowSize, int32_t pagesize,
|
||||||
|
int32_t inMemPages, void* handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -81,8 +87,14 @@ SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId);
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
#define GET_RES_BUF_PAGE_BY_ID(buf, id) ((tFilePage*)((buf)->pBuf + DEFAULT_INTERN_BUF_PAGE_SIZE*(id)))
|
//#define getResBufPage(buf, id) ((tFilePage*)((buf)->pBuf + (buf)->pageSize * (id)))
|
||||||
|
static FORCE_INLINE tFilePage* getResBufPage(SDiskbasedResultBuf* pResultBuf, int32_t id) {
|
||||||
|
if (id < pResultBuf->inMemPages) {
|
||||||
|
return pResultBuf->iBuf + id * pResultBuf->pageSize;
|
||||||
|
} else {
|
||||||
|
return pResultBuf->pBuf + (id - pResultBuf->inMemPages) * pResultBuf->pageSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* get the total buffer size in the format of disk file
|
* get the total buffer size in the format of disk file
|
||||||
* @param pResultBuf
|
* @param pResultBuf
|
|
@ -49,7 +49,7 @@ static FORCE_INLINE char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int3
|
||||||
assert(pResult != NULL && pRuntimeEnv != NULL);
|
assert(pResult != NULL && pRuntimeEnv != NULL);
|
||||||
|
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
tFilePage *page = GET_RES_BUF_PAGE_BY_ID(pRuntimeEnv->pResultBuf, pResult->pos.pageId);
|
tFilePage *page = getResBufPage(pRuntimeEnv->pResultBuf, pResult->pos.pageId);
|
||||||
int32_t realRowId = pResult->pos.rowId * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery);
|
int32_t realRowId = pResult->pos.rowId * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery);
|
||||||
|
|
||||||
return ((char *)page->data) + pRuntimeEnv->offset[columnIndex] * pRuntimeEnv->numOfRowsPerPage +
|
return ((char *)page->data) + pRuntimeEnv->offset[columnIndex] * pRuntimeEnv->numOfRowsPerPage +
|
||||||
|
@ -59,6 +59,4 @@ static FORCE_INLINE char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int3
|
||||||
__filter_func_t *getRangeFilterFuncArray(int32_t type);
|
__filter_func_t *getRangeFilterFuncArray(int32_t type);
|
||||||
__filter_func_t *getValueFilterFuncArray(int32_t type);
|
__filter_func_t *getValueFilterFuncArray(int32_t type);
|
||||||
|
|
||||||
bool supportPrefilter(int32_t type);
|
|
||||||
|
|
||||||
#endif // TDENGINE_QUERYUTIL_H
|
#endif // TDENGINE_QUERYUTIL_H
|
||||||
|
|
|
@ -255,7 +255,15 @@ extern int32_t functionCompatList[]; // compatible check array list
|
||||||
|
|
||||||
bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const char *minval, const char *maxval);
|
bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const char *minval, const char *maxval);
|
||||||
|
|
||||||
void resetResultInfo(SResultInfo *pResInfo);
|
/**
|
||||||
|
* the numOfRes should be kept, since it may be used later
|
||||||
|
* and allow the ResultInfo to be re initialized
|
||||||
|
*/
|
||||||
|
#define RESET_RESULT_INFO(_r) \
|
||||||
|
do { \
|
||||||
|
(_r)->initialized = false; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
void setResultInfoBuf(SResultInfo *pResInfo, int32_t size, bool superTable, char* buf);
|
void setResultInfoBuf(SResultInfo *pResInfo, int32_t size, bool superTable, char* buf);
|
||||||
|
|
||||||
static FORCE_INLINE void initResultInfo(SResultInfo *pResInfo) {
|
static FORCE_INLINE void initResultInfo(SResultInfo *pResInfo) {
|
||||||
|
|
|
@ -16,17 +16,17 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tname.h"
|
|
||||||
#include "qast.h"
|
|
||||||
#include "tsdb.h"
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
|
#include "qAst.h"
|
||||||
|
#include "qSyntaxtreefunction.h"
|
||||||
#include "qsqlparser.h"
|
#include "qsqlparser.h"
|
||||||
#include "qsyntaxtreefunction.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "tbuffer.h"
|
#include "tbuffer.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
|
#include "tname.h"
|
||||||
|
#include "tsdb.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
#include "tsqlfunction.h"
|
#include "tsqlfunction.h"
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
|
@ -678,7 +678,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
|
||||||
|
|
||||||
tstr *name = (tstr*) tsdbGetTableName(*(void**) pData);
|
tstr *name = (tstr*) tsdbGetTableName(*(void**) pData);
|
||||||
// todo speed up by using hash
|
// todo speed up by using hash
|
||||||
if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pQueryInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
if (pQueryInfo->optr == TSDB_RELATION_IN) {
|
if (pQueryInfo->optr == TSDB_RELATION_IN) {
|
||||||
addToResult = pQueryInfo->compare(name, pQueryInfo->q);
|
addToResult = pQueryInfo->compare(name, pQueryInfo->q);
|
||||||
} else if (pQueryInfo->optr == TSDB_RELATION_LIKE) {
|
} else if (pQueryInfo->optr == TSDB_RELATION_LIKE) {
|
||||||
|
@ -716,7 +716,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
|
||||||
}
|
}
|
||||||
|
|
||||||
tQueryInfo *pQueryInfo = pExpr->_node.info;
|
tQueryInfo *pQueryInfo = pExpr->_node.info;
|
||||||
if (pQueryInfo->colIndex == 0 && pQueryInfo->optr != TSDB_RELATION_LIKE) {
|
if (pQueryInfo->sch.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX && pQueryInfo->optr != TSDB_RELATION_LIKE) {
|
||||||
tQueryIndexColumn(pSkipList, pQueryInfo, result);
|
tQueryIndexColumn(pSkipList, pQueryInfo, result);
|
||||||
} else {
|
} else {
|
||||||
tQueryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn);
|
tQueryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn);
|
|
@ -13,19 +13,19 @@
|
||||||
* 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 "os.h"
|
#include "os.h"
|
||||||
|
#include "qFill.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "qfill.h"
|
|
||||||
#include "taosmsg.h"
|
|
||||||
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
#include "qAst.h"
|
||||||
#include "qExecutor.h"
|
#include "qExecutor.h"
|
||||||
|
#include "qResultbuf.h"
|
||||||
#include "qUtil.h"
|
#include "qUtil.h"
|
||||||
#include "qresultBuf.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "queryLog.h"
|
#include "queryLog.h"
|
||||||
#include "qast.h"
|
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
@ -50,11 +50,6 @@
|
||||||
|
|
||||||
#define SDATA_BLOCK_INITIALIZER (SDataBlockInfo) {{0}, 0}
|
#define SDATA_BLOCK_INITIALIZER (SDataBlockInfo) {{0}, 0}
|
||||||
|
|
||||||
/* get the qinfo struct address from the query struct address */
|
|
||||||
#define GET_COLUMN_BYTES(query, colidx) \
|
|
||||||
((query)->colList[(query)->pSelectExpr[colidx].base.colInfo.colIndex].bytes)
|
|
||||||
#define GET_COLUMN_TYPE(query, colidx) ((query)->colList[(query)->pSelectExpr[colidx].base.colInfo.colIndex].type)
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// when query starts to execute, this status will set
|
// when query starts to execute, this status will set
|
||||||
QUERY_NOT_COMPLETED = 0x1u,
|
QUERY_NOT_COMPLETED = 0x1u,
|
||||||
|
@ -238,9 +233,7 @@ bool isGroupbyNormalCol(SSqlGroupbyExpr *pGroupbyExpr) {
|
||||||
for (int32_t i = 0; i < pGroupbyExpr->numOfGroupCols; ++i) {
|
for (int32_t i = 0; i < pGroupbyExpr->numOfGroupCols; ++i) {
|
||||||
SColIndex *pColIndex = taosArrayGet(pGroupbyExpr->columnInfo, i);
|
SColIndex *pColIndex = taosArrayGet(pGroupbyExpr->columnInfo, i);
|
||||||
if (pColIndex->flag == TSDB_COL_NORMAL) {
|
if (pColIndex->flag == TSDB_COL_NORMAL) {
|
||||||
/*
|
//make sure the normal column locates at the second position if tbname exists in group by clause
|
||||||
* make sure the normal column locates at the second position if tbname exists in group by clause
|
|
||||||
*/
|
|
||||||
if (pGroupbyExpr->numOfGroupCols > 1) {
|
if (pGroupbyExpr->numOfGroupCols > 1) {
|
||||||
assert(pColIndex->colIndex > 0);
|
assert(pColIndex->colIndex > 0);
|
||||||
}
|
}
|
||||||
|
@ -299,6 +292,17 @@ bool isSelectivityWithTagsQuery(SQuery *pQuery) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isProjQuery(SQuery *pQuery) {
|
||||||
|
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||||
|
int32_t functId = pQuery->pSelectExpr[i].base.functionId;
|
||||||
|
if (functId != TSDB_FUNC_PRJ && functId != TSDB_FUNC_TAGPRJ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool isTSCompQuery(SQuery *pQuery) { return pQuery->pSelectExpr[0].base.functionId == TSDB_FUNC_TS_COMP; }
|
bool isTSCompQuery(SQuery *pQuery) { return pQuery->pSelectExpr[0].base.functionId == TSDB_FUNC_TS_COMP; }
|
||||||
|
|
||||||
static bool limitResults(SQueryRuntimeEnv* pRuntimeEnv) {
|
static bool limitResults(SQueryRuntimeEnv* pRuntimeEnv) {
|
||||||
|
@ -394,15 +398,15 @@ static SWindowResult *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin
|
||||||
if (pWindowResInfo->size >= pWindowResInfo->capacity) {
|
if (pWindowResInfo->size >= pWindowResInfo->capacity) {
|
||||||
int64_t newCap = pWindowResInfo->capacity * 1.5;
|
int64_t newCap = pWindowResInfo->capacity * 1.5;
|
||||||
char *t = realloc(pWindowResInfo->pResult, newCap * sizeof(SWindowResult));
|
char *t = realloc(pWindowResInfo->pResult, newCap * sizeof(SWindowResult));
|
||||||
if (t != NULL) {
|
if (t == NULL) {
|
||||||
pWindowResInfo->pResult = (SWindowResult *)t;
|
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
|
||||||
int32_t inc = newCap - pWindowResInfo->capacity;
|
|
||||||
memset(&pWindowResInfo->pResult[pWindowResInfo->capacity], 0, sizeof(SWindowResult) * inc);
|
|
||||||
} else {
|
|
||||||
// todo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pWindowResInfo->pResult = (SWindowResult *)t;
|
||||||
|
|
||||||
|
int32_t inc = newCap - pWindowResInfo->capacity;
|
||||||
|
memset(&pWindowResInfo->pResult[pWindowResInfo->capacity], 0, sizeof(SWindowResult) * inc);
|
||||||
|
|
||||||
for (int32_t i = pWindowResInfo->capacity; i < newCap; ++i) {
|
for (int32_t i = pWindowResInfo->capacity; i < newCap; ++i) {
|
||||||
createQueryResultInfo(pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, pRuntimeEnv->interBufSize);
|
createQueryResultInfo(pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, pRuntimeEnv->interBufSize);
|
||||||
}
|
}
|
||||||
|
@ -475,7 +479,7 @@ static int32_t addNewWindowResultBuf(SWindowResult *pWindowRes, SDiskbasedResult
|
||||||
pData = getNewDataBuf(pResultBuf, sid, &pageId);
|
pData = getNewDataBuf(pResultBuf, sid, &pageId);
|
||||||
} else {
|
} else {
|
||||||
pageId = getLastPageId(list);
|
pageId = getLastPageId(list);
|
||||||
pData = GET_RES_BUF_PAGE_BY_ID(pResultBuf, pageId);
|
pData = getResBufPage(pResultBuf, pageId);
|
||||||
|
|
||||||
if (pData->num >= numOfRowsPerPage) {
|
if (pData->num >= numOfRowsPerPage) {
|
||||||
pData = getNewDataBuf(pResultBuf, sid, &pageId);
|
pData = getNewDataBuf(pResultBuf, sid, &pageId);
|
||||||
|
@ -1008,7 +1012,6 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, char *pDat
|
||||||
case TSDB_DATA_TYPE_BIGINT: v = GET_INT64_VAL(pData); break;
|
case TSDB_DATA_TYPE_BIGINT: v = GET_INT64_VAL(pData); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assert(pRuntimeEnv->windowResInfo.hashList->size <= 2);
|
|
||||||
SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, &pRuntimeEnv->windowResInfo, pData, bytes, true);
|
SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, &pRuntimeEnv->windowResInfo, pData, bytes, true);
|
||||||
if (pWindowRes == NULL) {
|
if (pWindowRes == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1053,9 +1056,9 @@ static char *getGroupbyColumnData(SQuery *pQuery, int16_t *type, int16_t *bytes,
|
||||||
*type = pQuery->colList[colIndex].type;
|
*type = pQuery->colList[colIndex].type;
|
||||||
*bytes = pQuery->colList[colIndex].bytes;
|
*bytes = pQuery->colList[colIndex].bytes;
|
||||||
/*
|
/*
|
||||||
* the colIndex is acquired from the first meter of all qualified meters in this vnode during query prepare
|
* the colIndex is acquired from the first tables of all qualified tables in this vnode during query prepare
|
||||||
* stage, the remain meter may not have the required column in cache actually. So, the validation of required
|
* stage, the remain tables may not have the required column in cache actually. So, the validation of required
|
||||||
* column in cache with the corresponding meter schema is reinforced.
|
* column in cache with the corresponding schema is reinforced.
|
||||||
*/
|
*/
|
||||||
int32_t numOfCols = taosArrayGetSize(pDataBlock);
|
int32_t numOfCols = taosArrayGetSize(pDataBlock);
|
||||||
|
|
||||||
|
@ -1206,9 +1209,8 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// interval window query
|
// interval window query, decide the time window according to the primary timestamp
|
||||||
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||||
// decide the time window according to the primary timestamp
|
|
||||||
int64_t ts = tsCols[offset];
|
int64_t ts = tsCols[offset];
|
||||||
STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery);
|
STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery);
|
||||||
|
|
||||||
|
@ -1230,8 +1232,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
GET_NEXT_TIMEWINDOW(pQuery, &nextWin);
|
GET_NEXT_TIMEWINDOW(pQuery, &nextWin);
|
||||||
if (/*pWindowResInfo->startTime > nextWin.skey ||*/
|
if ((nextWin.skey > pQuery->window.ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||||
(nextWin.skey > pQuery->window.ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
|
|
||||||
(nextWin.skey < pQuery->window.ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
(nextWin.skey < pQuery->window.ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1489,6 +1490,8 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
|
||||||
goto _clean;
|
goto _clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("QInfo:%p setup runtime env1", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
|
|
||||||
pRuntimeEnv->offset[0] = 0;
|
pRuntimeEnv->offset[0] = 0;
|
||||||
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||||
SSqlFuncMsg *pSqlFuncMsg = &pQuery->pSelectExpr[i].base;
|
SSqlFuncMsg *pSqlFuncMsg = &pQuery->pSelectExpr[i].base;
|
||||||
|
@ -1533,6 +1536,8 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("QInfo:%p setup runtime env2", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
|
|
||||||
// set the order information for top/bottom query
|
// set the order information for top/bottom query
|
||||||
int32_t functionId = pCtx->functionId;
|
int32_t functionId = pCtx->functionId;
|
||||||
|
|
||||||
|
@ -1553,17 +1558,25 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("QInfo:%p setup runtime env3", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
|
|
||||||
char* buf = (char*) pRuntimeEnv->resultInfo + sizeof(SResultInfo) * pQuery->numOfOutput;
|
char* buf = (char*) pRuntimeEnv->resultInfo + sizeof(SResultInfo) * pQuery->numOfOutput;
|
||||||
|
|
||||||
// set the intermediate result output buffer
|
// set the intermediate result output buffer
|
||||||
setWindowResultInfo(pRuntimeEnv->resultInfo, pQuery, pRuntimeEnv->stableQuery, buf);
|
setWindowResultInfo(pRuntimeEnv->resultInfo, pQuery, pRuntimeEnv->stableQuery, buf);
|
||||||
|
|
||||||
|
qDebug("QInfo:%p setup runtime env4", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
|
|
||||||
// if it is group by normal column, do not set output buffer, the output buffer is pResult
|
// if it is group by normal column, do not set output buffer, the output buffer is pResult
|
||||||
if (!isGroupbyNormalCol(pQuery->pGroupbyExpr) && !pRuntimeEnv->stableQuery) {
|
if (!pRuntimeEnv->groupbyNormalCol && !pRuntimeEnv->stableQuery) {
|
||||||
resetCtxOutputBuf(pRuntimeEnv);
|
resetCtxOutputBuf(pRuntimeEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("QInfo:%p setup runtime env5", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
|
|
||||||
setCtxTagColumnInfo(pRuntimeEnv, pRuntimeEnv->pCtx);
|
setCtxTagColumnInfo(pRuntimeEnv, pRuntimeEnv->pCtx);
|
||||||
|
|
||||||
|
qDebug("QInfo:%p init completed", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_clean:
|
_clean:
|
||||||
|
@ -1915,9 +1928,20 @@ static int32_t getInitialPageNum(SQInfo *pQInfo) {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t getNumOfRowsInResultPage(SQuery *pQuery, bool topBotQuery, bool isSTableQuery) {
|
static void getIntermediateBufInfo(SQueryRuntimeEnv* pRuntimeEnv, int32_t* ps, int32_t* rowsize) {
|
||||||
int32_t rowSize = pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, topBotQuery, isSTableQuery);
|
SQuery* pQuery = pRuntimeEnv->pQuery;
|
||||||
return (DEFAULT_INTERN_BUF_PAGE_SIZE - sizeof(tFilePage)) / rowSize;
|
|
||||||
|
*rowsize = pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery);
|
||||||
|
int32_t overhead = sizeof(tFilePage);
|
||||||
|
|
||||||
|
// one page contains at least two rows
|
||||||
|
*ps = DEFAULT_INTERN_BUF_PAGE_SIZE;
|
||||||
|
while(((*rowsize) * 2) > (*ps) - overhead) {
|
||||||
|
*ps = (*ps << 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
pRuntimeEnv->numOfRowsPerPage = ((*ps) - sizeof(tFilePage)) / (*rowsize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_BINARY && (_t) != TSDB_DATA_TYPE_NCHAR)
|
#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_BINARY && (_t) != TSDB_DATA_TYPE_NCHAR)
|
||||||
|
@ -2043,8 +2067,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle,
|
||||||
} else { // check if this data block is required to load
|
} else { // check if this data block is required to load
|
||||||
|
|
||||||
// Calculate all time windows that are overlapping or contain current data block.
|
// Calculate all time windows that are overlapping or contain current data block.
|
||||||
// If current data block is contained by all possible time window, loading current
|
// If current data block is contained by all possible time window, do not load current data block.
|
||||||
// data block is not needed.
|
|
||||||
if (QUERY_IS_INTERVAL_QUERY(pQuery) && overlapWithTimeWindow(pQuery, pBlockInfo)) {
|
if (QUERY_IS_INTERVAL_QUERY(pQuery) && overlapWithTimeWindow(pQuery, pBlockInfo)) {
|
||||||
status = BLK_DATA_ALL_NEEDED;
|
status = BLK_DATA_ALL_NEEDED;
|
||||||
}
|
}
|
||||||
|
@ -2364,6 +2387,18 @@ static void doSetTagValueInParam(void *tsdb, void* pTable, int32_t tagColId, tVa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t numOfTags, int16_t colId) {
|
||||||
|
assert(pTagColList != NULL && numOfTags > 0);
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < numOfTags; ++i) {
|
||||||
|
if (pTagColList[i].colId == colId) {
|
||||||
|
return &pTagColList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
|
void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
SQInfo* pQInfo = GET_QINFO_ADDR(pRuntimeEnv);
|
SQInfo* pQInfo = GET_QINFO_ADDR(pRuntimeEnv);
|
||||||
|
@ -2372,16 +2407,10 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
|
||||||
if (pQuery->numOfOutput == 1 && pExprInfo->base.functionId == TSDB_FUNC_TS_COMP) {
|
if (pQuery->numOfOutput == 1 && pExprInfo->base.functionId == TSDB_FUNC_TS_COMP) {
|
||||||
assert(pExprInfo->base.numOfParams == 1);
|
assert(pExprInfo->base.numOfParams == 1);
|
||||||
|
|
||||||
// todo refactor extract function.
|
int16_t tagColId = pExprInfo->base.arg->argValue.i64;
|
||||||
int16_t type = -1, bytes = -1;
|
SColumnInfo* pColInfo = doGetTagColumnInfoById(pQuery->tagColList, pQuery->numOfTags, tagColId);
|
||||||
for(int32_t i = 0; i < pQuery->numOfTags; ++i) {
|
|
||||||
if (pQuery->tagColList[i].colId == pExprInfo->base.arg->argValue.i64) {
|
|
||||||
type = pQuery->tagColList[i].type;
|
|
||||||
bytes = pQuery->tagColList[i].bytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doSetTagValueInParam(tsdb, pTable, pExprInfo->base.arg->argValue.i64, &pRuntimeEnv->pCtx[0].tag, type, bytes);
|
doSetTagValueInParam(tsdb, pTable, tagColId, &pRuntimeEnv->pCtx[0].tag, pColInfo->type, pColInfo->bytes);
|
||||||
} else {
|
} else {
|
||||||
// set tag value, by which the results are aggregated.
|
// set tag value, by which the results are aggregated.
|
||||||
for (int32_t idx = 0; idx < pQuery->numOfOutput; ++idx) {
|
for (int32_t idx = 0; idx < pQuery->numOfOutput; ++idx) {
|
||||||
|
@ -2399,20 +2428,14 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
|
||||||
|
|
||||||
// set the join tag for first column
|
// set the join tag for first column
|
||||||
SSqlFuncMsg *pFuncMsg = &pExprInfo->base;
|
SSqlFuncMsg *pFuncMsg = &pExprInfo->base;
|
||||||
if ((pFuncMsg->functionId == TSDB_FUNC_TS || pFuncMsg->functionId == TSDB_FUNC_PRJ) && pFuncMsg->colInfo.colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX &&
|
if ((pFuncMsg->functionId == TSDB_FUNC_TS || pFuncMsg->functionId == TSDB_FUNC_PRJ) && pRuntimeEnv->pTSBuf != NULL &&
|
||||||
pRuntimeEnv->pTSBuf != NULL) {
|
pFuncMsg->colInfo.colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||||
assert(pFuncMsg->numOfParams == 1);
|
assert(pFuncMsg->numOfParams == 1);
|
||||||
|
|
||||||
// todo refactor
|
int16_t tagColId = pExprInfo->base.arg->argValue.i64;
|
||||||
int16_t type = -1, bytes = -1;
|
SColumnInfo* pColInfo = doGetTagColumnInfoById(pQuery->tagColList, pQuery->numOfTags, tagColId);
|
||||||
for(int32_t i = 0; i < pQuery->numOfTags; ++i) {
|
|
||||||
if (pQuery->tagColList[i].colId == pExprInfo->base.arg->argValue.i64) {
|
|
||||||
type = pQuery->tagColList[i].type;
|
|
||||||
bytes = pQuery->tagColList[i].bytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doSetTagValueInParam(tsdb, pTable, pExprInfo->base.arg->argValue.i64, &pRuntimeEnv->pCtx[0].tag, type, bytes);
|
doSetTagValueInParam(tsdb, pTable, tagColId, &pRuntimeEnv->pCtx[0].tag, pColInfo->type, pColInfo->bytes);
|
||||||
qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64,
|
qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64,
|
||||||
pRuntimeEnv->pCtx[0].tag.i64Key)
|
pRuntimeEnv->pCtx[0].tag.i64Key)
|
||||||
}
|
}
|
||||||
|
@ -2429,7 +2452,7 @@ static void doMerge(SQueryRuntimeEnv *pRuntimeEnv, int64_t timestamp, SWindowRes
|
||||||
pCtx[i].aOutputBuf = pCtx[i].aOutputBuf + pCtx[i].outputBytes;
|
pCtx[i].aOutputBuf = pCtx[i].aOutputBuf + pCtx[i].outputBytes;
|
||||||
pCtx[i].currentStage = FIRST_STAGE_MERGE;
|
pCtx[i].currentStage = FIRST_STAGE_MERGE;
|
||||||
|
|
||||||
resetResultInfo(pCtx[i].resultInfo);
|
RESET_RESULT_INFO(pCtx[i].resultInfo);
|
||||||
aAggs[functionId].init(&pCtx[i]);
|
aAggs[functionId].init(&pCtx[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2666,7 +2689,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) {
|
||||||
int32_t size = taosArrayGetSize(list);
|
int32_t size = taosArrayGetSize(list);
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
int32_t* pgId = taosArrayGet(list, i);
|
int32_t* pgId = taosArrayGet(list, i);
|
||||||
tFilePage *pData = GET_RES_BUF_PAGE_BY_ID(pResultBuf, *pgId);
|
tFilePage *pData = getResBufPage(pResultBuf, *pgId);
|
||||||
total += pData->num;
|
total += pData->num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2675,7 +2698,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) {
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
for (int32_t j = 0; j < size; ++j) {
|
for (int32_t j = 0; j < size; ++j) {
|
||||||
int32_t* pgId = taosArrayGet(list, j);
|
int32_t* pgId = taosArrayGet(list, j);
|
||||||
tFilePage *pData = GET_RES_BUF_PAGE_BY_ID(pResultBuf, *pgId);
|
tFilePage *pData = getResBufPage(pResultBuf, *pgId);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||||
int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes;
|
int32_t bytes = pRuntimeEnv->pCtx[i].outputBytes;
|
||||||
|
@ -2865,10 +2888,10 @@ int32_t flushFromResultBuf(SQInfo *pQInfo) {
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf;
|
SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf;
|
||||||
int32_t capacity = (DEFAULT_INTERN_BUF_PAGE_SIZE - sizeof(tFilePage)) / pQuery->rowSize;
|
|
||||||
|
|
||||||
// the base value for group result, since the maximum number of table for each vnode will not exceed 100,000.
|
// the base value for group result, since the maximum number of table for each vnode will not exceed 100,000.
|
||||||
int32_t pageId = -1;
|
int32_t pageId = -1;
|
||||||
|
int32_t capacity = pResultBuf->numOfRowsPerPage;
|
||||||
|
|
||||||
int32_t remain = pQuery->sdata[0]->num;
|
int32_t remain = pQuery->sdata[0]->num;
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
|
@ -3038,7 +3061,7 @@ void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
* set the output buffer information and intermediate buffer
|
* set the output buffer information and intermediate buffer
|
||||||
* not all queries require the interResultBuf, such as COUNT/TAGPRJ/PRJ/TAG etc.
|
* not all queries require the interResultBuf, such as COUNT/TAGPRJ/PRJ/TAG etc.
|
||||||
*/
|
*/
|
||||||
resetResultInfo(&pRuntimeEnv->resultInfo[i]);
|
RESET_RESULT_INFO(&pRuntimeEnv->resultInfo[i]);
|
||||||
pCtx->resultInfo = &pRuntimeEnv->resultInfo[i];
|
pCtx->resultInfo = &pRuntimeEnv->resultInfo[i];
|
||||||
|
|
||||||
// set the timestamp output buffer for top/bottom/diff query
|
// set the timestamp output buffer for top/bottom/diff query
|
||||||
|
@ -3077,7 +3100,7 @@ void forwardCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, int64_t output) {
|
||||||
pRuntimeEnv->pCtx[j].ptsOutputBuf += TSDB_KEYSIZE * output;
|
pRuntimeEnv->pCtx[j].ptsOutputBuf += TSDB_KEYSIZE * output;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetResultInfo(pRuntimeEnv->pCtx[j].resultInfo);
|
RESET_RESULT_INFO(pRuntimeEnv->pCtx[j].resultInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3331,8 +3354,8 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
|
||||||
if (pRuntimeEnv->pSecQueryHandle == NULL) {
|
if (pRuntimeEnv->pSecQueryHandle == NULL) {
|
||||||
longjmp(pRuntimeEnv->env, terrno);
|
longjmp(pRuntimeEnv->env, terrno);
|
||||||
}
|
}
|
||||||
pRuntimeEnv->windowResInfo.curIndex = qstatus.windowIndex;
|
|
||||||
|
|
||||||
|
pRuntimeEnv->windowResInfo.curIndex = qstatus.windowIndex;
|
||||||
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
|
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
|
||||||
pRuntimeEnv->scanFlag = REPEAT_SCAN;
|
pRuntimeEnv->scanFlag = REPEAT_SCAN;
|
||||||
|
|
||||||
|
@ -3467,7 +3490,6 @@ void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t GROUPRESULTID = 1;
|
|
||||||
SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, pWindowResInfo, (char *)&groupIndex,
|
SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, pWindowResInfo, (char *)&groupIndex,
|
||||||
sizeof(groupIndex), true);
|
sizeof(groupIndex), true);
|
||||||
if (pWindowRes == NULL) {
|
if (pWindowRes == NULL) {
|
||||||
|
@ -3479,7 +3501,7 @@ void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) {
|
||||||
* all group belong to one result set, and each group result has different group id so set the id to be one
|
* all group belong to one result set, and each group result has different group id so set the id to be one
|
||||||
*/
|
*/
|
||||||
if (pWindowRes->pos.pageId == -1) {
|
if (pWindowRes->pos.pageId == -1) {
|
||||||
if (addNewWindowResultBuf(pWindowRes, pRuntimeEnv->pResultBuf, GROUPRESULTID, pRuntimeEnv->numOfRowsPerPage) !=
|
if (addNewWindowResultBuf(pWindowRes, pRuntimeEnv->pResultBuf, groupIndex, pRuntimeEnv->numOfRowsPerPage) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4149,6 +4171,7 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
|
||||||
} else {
|
} else {
|
||||||
pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo);
|
pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4174,10 +4197,9 @@ static SFillColInfo* taosCreateFillColInfo(SQuery* pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bool isSTableQuery) {
|
int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bool isSTableQuery) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
|
|
||||||
pQuery->precision = tsdbGetCfg(tsdb)->precision;
|
pQuery->precision = tsdbGetCfg(tsdb)->precision;
|
||||||
|
@ -4186,6 +4208,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
|
||||||
|
|
||||||
setScanLimitationByResultBuffer(pQuery);
|
setScanLimitationByResultBuffer(pQuery);
|
||||||
changeExecuteScanOrder(pQInfo, false);
|
changeExecuteScanOrder(pQInfo, false);
|
||||||
|
|
||||||
code = setupQueryHandle(tsdb, pQInfo, isSTableQuery);
|
code = setupQueryHandle(tsdb, pQInfo, isSTableQuery);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -4212,33 +4235,42 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRuntimeEnv->numOfRowsPerPage = getNumOfRowsInResultPage(pQuery, pRuntimeEnv->topBotQuery, isSTableQuery);
|
int32_t ps = DEFAULT_PAGE_SIZE;
|
||||||
|
int32_t rowsize = 0;
|
||||||
|
getIntermediateBufInfo(pRuntimeEnv, &ps, &rowsize);
|
||||||
|
|
||||||
if (isSTableQuery && !onlyQueryTags(pRuntimeEnv->pQuery)) {
|
if (isSTableQuery && !onlyQueryTags(pRuntimeEnv->pQuery)) {
|
||||||
int32_t rows = getInitialPageNum(pQInfo);
|
int32_t numOfPages = getInitialPageNum(pQInfo);
|
||||||
code = createDiskbasedResultBuffer(&pRuntimeEnv->pResultBuf, rows, pQuery->rowSize, pQInfo);
|
code = createDiskbasedResultBuffer(&pRuntimeEnv->pResultBuf, numOfPages, rowsize, ps, numOfPages, pQInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
if (!QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||||
int16_t type = TSDB_DATA_TYPE_NULL;
|
int16_t type = TSDB_DATA_TYPE_NULL;
|
||||||
|
int32_t threshold = 0;
|
||||||
|
|
||||||
if (pRuntimeEnv->groupbyNormalCol) { // group by columns not tags;
|
if (pRuntimeEnv->groupbyNormalCol) { // group by columns not tags;
|
||||||
type = getGroupbyColumnType(pQuery, pQuery->pGroupbyExpr);
|
type = getGroupbyColumnType(pQuery, pQuery->pGroupbyExpr);
|
||||||
|
threshold = 4000;
|
||||||
} else {
|
} else {
|
||||||
type = TSDB_DATA_TYPE_INT; // group id
|
type = TSDB_DATA_TYPE_INT; // group id
|
||||||
|
threshold = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
if (threshold < 8) {
|
||||||
|
threshold = 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, 32, 4096, type);
|
code = initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, 8, threshold, type);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pRuntimeEnv->groupbyNormalCol || QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
} else if (pRuntimeEnv->groupbyNormalCol || QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||||
int32_t rows = getInitialPageNum(pQInfo);
|
int32_t numOfResultRows = getInitialPageNum(pQInfo);
|
||||||
code = createDiskbasedResultBuffer(&pRuntimeEnv->pResultBuf, rows, pQuery->rowSize, pQInfo);
|
getIntermediateBufInfo(pRuntimeEnv, &ps, &rowsize);
|
||||||
|
|
||||||
|
code = createDiskbasedResultBuffer(&pRuntimeEnv->pResultBuf, numOfResultRows, rowsize, ps, numOfResultRows, pQInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -4250,7 +4282,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
|
||||||
type = TSDB_DATA_TYPE_TIMESTAMP;
|
type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, rows, 4096, type);
|
code = initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, numOfResultRows, 4096, type);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -5693,7 +5725,6 @@ static void doUpdateExprColumnIndex(SQuery *pQuery) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int compareTableIdInfo(const void* a, const void* b) {
|
static int compareTableIdInfo(const void* a, const void* b) {
|
||||||
const STableIdInfo* x = (const STableIdInfo*)a;
|
const STableIdInfo* x = (const STableIdInfo*)a;
|
||||||
const STableIdInfo* y = (const STableIdInfo*)b;
|
const STableIdInfo* y = (const STableIdInfo*)b;
|
||||||
|
@ -5709,13 +5740,18 @@ static void calResultBufSize(SQuery* pQuery) {
|
||||||
const int32_t RESULT_MSG_MIN_ROWS = 8192;
|
const int32_t RESULT_MSG_MIN_ROWS = 8192;
|
||||||
const float RESULT_THRESHOLD_RATIO = 0.85;
|
const float RESULT_THRESHOLD_RATIO = 0.85;
|
||||||
|
|
||||||
int32_t numOfRes = RESULT_MSG_MIN_SIZE / pQuery->rowSize;
|
if (isProjQuery(pQuery)) {
|
||||||
if (numOfRes < RESULT_MSG_MIN_ROWS) {
|
int32_t numOfRes = RESULT_MSG_MIN_SIZE / pQuery->rowSize;
|
||||||
numOfRes = RESULT_MSG_MIN_ROWS;
|
if (numOfRes < RESULT_MSG_MIN_ROWS) {
|
||||||
}
|
numOfRes = RESULT_MSG_MIN_ROWS;
|
||||||
|
}
|
||||||
|
|
||||||
pQuery->rec.capacity = numOfRes;
|
pQuery->rec.capacity = numOfRes;
|
||||||
pQuery->rec.threshold = numOfRes * RESULT_THRESHOLD_RATIO;
|
pQuery->rec.threshold = numOfRes * RESULT_THRESHOLD_RATIO;
|
||||||
|
} else { // in case of non-prj query, a smaller output buffer will be used.
|
||||||
|
pQuery->rec.capacity = 4096;
|
||||||
|
pQuery->rec.threshold = pQuery->rec.capacity * RESULT_THRESHOLD_RATIO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, SSqlGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs,
|
static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, SSqlGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs,
|
||||||
|
@ -5727,6 +5763,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
if (pQInfo == NULL) {
|
if (pQInfo == NULL) {
|
||||||
goto _cleanup_qinfo;
|
goto _cleanup_qinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// to make sure third party won't overwrite this structure
|
// to make sure third party won't overwrite this structure
|
||||||
pQInfo->signature = pQInfo;
|
pQInfo->signature = pQInfo;
|
||||||
pQInfo->tableGroupInfo = *pTableGroupInfo;
|
pQInfo->tableGroupInfo = *pTableGroupInfo;
|
||||||
|
@ -5926,6 +5963,7 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
|
||||||
pQuery->window.ekey, pQuery->order.order);
|
pQuery->window.ekey, pQuery->order.order);
|
||||||
setQueryStatus(pQuery, QUERY_COMPLETED);
|
setQueryStatus(pQuery, QUERY_COMPLETED);
|
||||||
pQInfo->tableqinfoGroupInfo.numOfTables = 0;
|
pQInfo->tableqinfoGroupInfo.numOfTables = 0;
|
||||||
|
|
||||||
sem_post(&pQInfo->dataReady);
|
sem_post(&pQInfo->dataReady);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -6044,11 +6082,10 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
|
|
||||||
tfree(pQuery->sdata);
|
tfree(pQuery->sdata);
|
||||||
tfree(pQuery);
|
tfree(pQuery);
|
||||||
|
pQInfo->signature = 0;
|
||||||
|
|
||||||
qDebug("QInfo:%p QInfo is freed", pQInfo);
|
qDebug("QInfo:%p QInfo is freed", pQInfo);
|
||||||
|
|
||||||
// destroy signature, in order to avoid the query process pass the object safety check
|
|
||||||
memset(pQInfo, 0, sizeof(SQInfo));
|
|
||||||
tfree(pQInfo);
|
tfree(pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6136,16 +6173,17 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
char * tagCond = NULL, *tbnameCond = NULL;
|
char *tagCond = NULL;
|
||||||
SArray * pTableIdList = NULL;
|
char *tbnameCond = NULL;
|
||||||
SSqlFuncMsg **pExprMsg = NULL;
|
SArray *pTableIdList = NULL;
|
||||||
SColIndex * pGroupColIndex = NULL;
|
SSqlFuncMsg **pExprMsg = NULL;
|
||||||
SColumnInfo* pTagColumnInfo = NULL;
|
SExprInfo *pExprs = NULL;
|
||||||
SExprInfo *pExprs = NULL;
|
SColIndex *pGroupColIndex = NULL;
|
||||||
SSqlGroupbyExpr *pGroupbyExpr = NULL;
|
SColumnInfo *pTagColumnInfo = NULL;
|
||||||
|
SSqlGroupbyExpr *pGroupbyExpr = NULL;
|
||||||
|
|
||||||
if ((code = convertQueryMsg(pQueryMsg, &pTableIdList, &pExprMsg, &tagCond, &tbnameCond, &pGroupColIndex, &pTagColumnInfo)) !=
|
code = convertQueryMsg(pQueryMsg, &pTableIdList, &pExprMsg, &tagCond, &tbnameCond, &pGroupColIndex, &pTagColumnInfo);
|
||||||
TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6172,6 +6210,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
|
||||||
|
|
||||||
bool isSTableQuery = false;
|
bool isSTableQuery = false;
|
||||||
STableGroupInfo tableGroupInfo = {0};
|
STableGroupInfo tableGroupInfo = {0};
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_TABLE_QUERY)) {
|
if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_TABLE_QUERY)) {
|
||||||
STableIdInfo *id = taosArrayGet(pTableIdList, 0);
|
STableIdInfo *id = taosArrayGet(pTableIdList, 0);
|
||||||
|
@ -6182,7 +6221,6 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
|
||||||
}
|
}
|
||||||
} else if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY|TSDB_QUERY_TYPE_STABLE_QUERY)) {
|
} else if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY|TSDB_QUERY_TYPE_STABLE_QUERY)) {
|
||||||
isSTableQuery = true;
|
isSTableQuery = true;
|
||||||
// TODO: need a macro from TSDB to check if table is super table
|
|
||||||
|
|
||||||
// also note there's possibility that only one table in the super table
|
// also note there's possibility that only one table in the super table
|
||||||
if (!TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY)) {
|
if (!TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY)) {
|
||||||
|
@ -6194,10 +6232,11 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
|
||||||
numOfGroupByCols = 0;
|
numOfGroupByCols = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("qmsg:%p query stable, uid:%"PRId64", tid:%d", pQueryMsg, id->uid, id->tid);
|
||||||
code = tsdbQuerySTableByTagCond(tsdb, id->uid, tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, tbnameCond, &tableGroupInfo, pGroupColIndex,
|
code = tsdbQuerySTableByTagCond(tsdb, id->uid, tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, tbnameCond, &tableGroupInfo, pGroupColIndex,
|
||||||
numOfGroupByCols);
|
numOfGroupByCols);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("qmsg:%p failed to QueryStable, reason: %s", pQueryMsg, tstrerror(code));
|
qError("qmsg:%p failed to query stable, reason: %s", pQueryMsg, tstrerror(code));
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -6208,6 +6247,9 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
|
||||||
|
|
||||||
qDebug("qmsg:%p query on %zu tables in one group from client", pQueryMsg, tableGroupInfo.numOfTables);
|
qDebug("qmsg:%p query on %zu tables in one group from client", pQueryMsg, tableGroupInfo.numOfTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t el = taosGetTimestampUs() - st;
|
||||||
|
qDebug("qmsg:%p tag filter completed, numOfTables:%zu, elapsed time:%"PRId64"us", pQueryMsg, tableGroupInfo.numOfTables, el);
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -6247,7 +6289,7 @@ _over:
|
||||||
*pQInfo = NULL;
|
*pQInfo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if failed to add ref for all meters in this query, abort current query
|
// if failed to add ref for all tables in this query, abort current query
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,15 @@
|
||||||
* 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 "qExtbuffer.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tulog.h"
|
#include "queryLog.h"
|
||||||
#include "qextbuffer.h"
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tsqlfunction.h"
|
#include "tsqlfunction.h"
|
||||||
#include "ttime.h"
|
#include "tulog.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "queryLog.h"
|
|
||||||
|
|
||||||
#define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \
|
#define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \
|
||||||
(data + (schema)->pFields[colId].offset * (allrow) + (rowId) * (schema)->pFields[colId].field.bytes)
|
(data + (schema)->pFields[colId].offset * (allrow) + (rowId) * (schema)->pFields[colId].field.bytes)
|
|
@ -13,9 +13,9 @@
|
||||||
* 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 "qFill.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "qfill.h"
|
#include "qExtbuffer.h"
|
||||||
#include "qextbuffer.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tsqlfunction.h"
|
#include "tsqlfunction.h"
|
|
@ -554,5 +554,3 @@ __filter_func_t* getValueFilterFuncArray(int32_t type) {
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supportPrefilter(int32_t type) { return type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR; }
|
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "qhistogram.h"
|
#include "qHistogram.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
|
@ -13,12 +13,12 @@
|
||||||
* 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 "qPercentile.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tulog.h"
|
#include "queryLog.h"
|
||||||
#include "qpercentile.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "queryLog.h"
|
#include "tulog.h"
|
||||||
|
|
||||||
tExtMemBuffer *releaseBucketsExceptFor(tMemBucket *pMemBucket, int16_t segIdx, int16_t slotIdx) {
|
tExtMemBuffer *releaseBucketsExceptFor(tMemBucket *pMemBucket, int16_t segIdx, int16_t slotIdx) {
|
||||||
tExtMemBuffer *pBuffer = NULL;
|
tExtMemBuffer *pBuffer = NULL;
|
|
@ -0,0 +1,218 @@
|
||||||
|
#include "qResultbuf.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "qExtbuffer.h"
|
||||||
|
#include "queryLog.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
|
||||||
|
int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t numOfPages, int32_t rowSize,
|
||||||
|
int32_t pagesize, int32_t inMemPages, void* handle) {
|
||||||
|
|
||||||
|
*pResultBuf = calloc(1, sizeof(SDiskbasedResultBuf));
|
||||||
|
SDiskbasedResultBuf* pResBuf = *pResultBuf;
|
||||||
|
if (pResBuf == NULL) {
|
||||||
|
return TSDB_CODE_COM_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
pResBuf->pageSize = pagesize;
|
||||||
|
pResBuf->numOfPages = inMemPages; // all pages are in buffer in the first place
|
||||||
|
pResBuf->inMemPages = inMemPages;
|
||||||
|
assert(inMemPages <= numOfPages);
|
||||||
|
|
||||||
|
pResBuf->numOfRowsPerPage = (pagesize - sizeof(tFilePage)) / rowSize;
|
||||||
|
|
||||||
|
pResBuf->totalBufSize = pResBuf->numOfPages * pagesize;
|
||||||
|
pResBuf->incStep = 4;
|
||||||
|
pResBuf->allocateId = -1;
|
||||||
|
|
||||||
|
pResBuf->iBuf = calloc(pResBuf->inMemPages, pResBuf->pageSize);
|
||||||
|
|
||||||
|
// init id hash table
|
||||||
|
pResBuf->idsTable = taosHashInit(numOfPages, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
||||||
|
pResBuf->list = taosArrayInit(numOfPages, POINTER_BYTES);
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
getTmpfilePath("tsdb_qbuf", path);
|
||||||
|
pResBuf->path = strdup(path);
|
||||||
|
|
||||||
|
pResBuf->fd = FD_INITIALIZER;
|
||||||
|
pResBuf->pBuf = NULL;
|
||||||
|
|
||||||
|
qDebug("QInfo:%p create resBuf for output, page size:%d, initial pages:%d, %" PRId64 "bytes", handle,
|
||||||
|
pResBuf->pageSize, pResBuf->numOfPages, pResBuf->totalBufSize);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getNumOfResultBufGroupId(SDiskbasedResultBuf* pResultBuf) { return taosHashGetSize(pResultBuf->idsTable); }
|
||||||
|
|
||||||
|
int32_t getResBufSize(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->totalBufSize; }
|
||||||
|
|
||||||
|
#define NUM_OF_PAGES_ON_DISK(_r) ((_r)->numOfPages - (_r)->inMemPages)
|
||||||
|
#define FILE_SIZE_ON_DISK(_r) (NUM_OF_PAGES_ON_DISK(_r) * (_r)->pageSize)
|
||||||
|
|
||||||
|
static int32_t createDiskResidesBuf(SDiskbasedResultBuf* pResultBuf) {
|
||||||
|
pResultBuf->fd = open(pResultBuf->path, O_CREAT | O_RDWR, 0666);
|
||||||
|
if (!FD_VALID(pResultBuf->fd)) {
|
||||||
|
qError("failed to create tmp file: %s on disk. %s", pResultBuf->path, strerror(errno));
|
||||||
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pResultBuf->numOfPages == pResultBuf->inMemPages);
|
||||||
|
pResultBuf->numOfPages += pResultBuf->incStep;
|
||||||
|
|
||||||
|
int32_t ret = ftruncate(pResultBuf->fd, NUM_OF_PAGES_ON_DISK(pResultBuf) * pResultBuf->pageSize);
|
||||||
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("failed to create tmp file: %s on disk. %s", pResultBuf->path, strerror(errno));
|
||||||
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
pResultBuf->pBuf = mmap(NULL, FILE_SIZE_ON_DISK(pResultBuf), PROT_READ | PROT_WRITE, MAP_SHARED, pResultBuf->fd, 0);
|
||||||
|
if (pResultBuf->pBuf == MAP_FAILED) {
|
||||||
|
qError("QInfo:%p failed to map temp file: %s. %s", pResultBuf->handle, pResultBuf->path, strerror(errno));
|
||||||
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
pResultBuf->totalBufSize = pResultBuf->numOfPages * pResultBuf->pageSize;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t incNumOfPages) {
|
||||||
|
assert(pResultBuf->numOfPages * pResultBuf->pageSize == pResultBuf->totalBufSize);
|
||||||
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
if (pResultBuf->pBuf == NULL) {
|
||||||
|
assert(pResultBuf->fd == FD_INITIALIZER);
|
||||||
|
|
||||||
|
if ((ret = createDiskResidesBuf(pResultBuf)) != TSDB_CODE_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = munmap(pResultBuf->pBuf, FILE_SIZE_ON_DISK(pResultBuf));
|
||||||
|
pResultBuf->numOfPages += incNumOfPages;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* disk-based output buffer is exhausted, try to extend the disk-based buffer, the available disk space may
|
||||||
|
* be insufficient
|
||||||
|
*/
|
||||||
|
ret = ftruncate(pResultBuf->fd, NUM_OF_PAGES_ON_DISK(pResultBuf) * pResultBuf->pageSize);
|
||||||
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
// dError("QInfo:%p failed to create intermediate result output file:%s. %s", pQInfo, pSupporter->extBufFile,
|
||||||
|
// strerror(errno));
|
||||||
|
return TSDB_CODE_QRY_NO_DISKSPACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pResultBuf->totalBufSize = pResultBuf->numOfPages * pResultBuf->pageSize;
|
||||||
|
pResultBuf->pBuf = mmap(NULL, FILE_SIZE_ON_DISK(pResultBuf), PROT_READ | PROT_WRITE, MAP_SHARED, pResultBuf->fd, 0);
|
||||||
|
|
||||||
|
if (pResultBuf->pBuf == MAP_FAILED) {
|
||||||
|
// dError("QInfo:%p failed to map temp file: %s. %s", pQInfo, pSupporter->extBufFile, strerror(errno));
|
||||||
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NO_AVAILABLE_PAGES(_b) ((_b)->allocateId == (_b)->numOfPages - 1)
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t getGroupIndex(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
|
||||||
|
assert(pResultBuf != NULL);
|
||||||
|
|
||||||
|
char* p = taosHashGet(pResultBuf->idsTable, (const char*)&groupId, sizeof(int32_t));
|
||||||
|
if (p == NULL) { // it is a new group id
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t slot = GET_INT32_VAL(p);
|
||||||
|
assert(slot >= 0 && slot < taosHashGetSize(pResultBuf->idsTable));
|
||||||
|
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t addNewGroupId(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
|
||||||
|
int32_t num = getNumOfResultBufGroupId(pResultBuf); // the num is the newest allocated group id slot
|
||||||
|
taosHashPut(pResultBuf->idsTable, (const char*)&groupId, sizeof(int32_t), &num, sizeof(int32_t));
|
||||||
|
|
||||||
|
SArray* pa = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
taosArrayPush(pResultBuf->list, &pa);
|
||||||
|
|
||||||
|
assert(taosArrayGetSize(pResultBuf->list) == taosHashGetSize(pResultBuf->idsTable));
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void registerPageId(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32_t pageId) {
|
||||||
|
int32_t slot = getGroupIndex(pResultBuf, groupId);
|
||||||
|
if (slot < 0) {
|
||||||
|
slot = addNewGroupId(pResultBuf, groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
SIDList pList = taosArrayGetP(pResultBuf->list, slot);
|
||||||
|
taosArrayPush(pList, &pageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32_t* pageId) {
|
||||||
|
if (NO_AVAILABLE_PAGES(pResultBuf)) {
|
||||||
|
if (extendDiskFileSize(pResultBuf, pResultBuf->incStep) != TSDB_CODE_SUCCESS) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// register new id in this group
|
||||||
|
*pageId = (++pResultBuf->allocateId);
|
||||||
|
registerPageId(pResultBuf, groupId, *pageId);
|
||||||
|
|
||||||
|
// clear memory for the new page
|
||||||
|
tFilePage* page = getResBufPage(pResultBuf, *pageId);
|
||||||
|
memset(page, 0, pResultBuf->pageSize);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getNumOfRowsPerPage(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->numOfRowsPerPage; }
|
||||||
|
|
||||||
|
SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
|
||||||
|
int32_t slot = getGroupIndex(pResultBuf, groupId);
|
||||||
|
if (slot < 0) {
|
||||||
|
return taosArrayInit(1, sizeof(int32_t));
|
||||||
|
} else {
|
||||||
|
return taosArrayGetP(pResultBuf->list, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) {
|
||||||
|
if (pResultBuf == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FD_VALID(pResultBuf->fd)) {
|
||||||
|
qDebug("QInfo:%p disk-based output buffer closed, total:%" PRId64 " bytes, file created:%s, file size:%d", handle,
|
||||||
|
pResultBuf->totalBufSize, pResultBuf->path, FILE_SIZE_ON_DISK(pResultBuf));
|
||||||
|
|
||||||
|
close(pResultBuf->fd);
|
||||||
|
munmap(pResultBuf->pBuf, FILE_SIZE_ON_DISK(pResultBuf));
|
||||||
|
pResultBuf->pBuf = NULL;
|
||||||
|
} else {
|
||||||
|
qDebug("QInfo:%p disk-based output buffer closed, total:%" PRId64 " bytes, no file created", handle,
|
||||||
|
pResultBuf->totalBufSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink(pResultBuf->path);
|
||||||
|
tfree(pResultBuf->path);
|
||||||
|
|
||||||
|
size_t size = taosArrayGetSize(pResultBuf->list);
|
||||||
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
|
SArray* pa = taosArrayGetP(pResultBuf->list, i);
|
||||||
|
taosArrayDestroy(pa);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pResultBuf->list);
|
||||||
|
taosHashCleanup(pResultBuf->idsTable);
|
||||||
|
|
||||||
|
tfree(pResultBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getLastPageId(SIDList pList) {
|
||||||
|
size_t size = taosArrayGetSize(pList);
|
||||||
|
return *(int32_t*) taosArrayGet(pList, size - 1);
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "qsyntaxtreefunction.h"
|
#include "qSyntaxtreefunction.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "qtsbuf.h"
|
#include "qTsbuf.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "taoserror.h"
|
|
||||||
|
|
||||||
static int32_t getDataStartOffset();
|
static int32_t getDataStartOffset();
|
||||||
static void TSBufUpdateVnodeInfo(STSBuf* pTSBuf, int32_t index, STSVnodeBlockInfo* pBlockInfo);
|
static void TSBufUpdateVnodeInfo(STSBuf* pTSBuf, int32_t index, STSVnodeBlockInfo* pBlockInfo);
|
|
@ -26,12 +26,10 @@ int32_t getOutputInterResultBufSize(SQuery* pQuery) {
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||||
assert(pQuery->pSelectExpr[i].interBytes <= DEFAULT_INTERN_BUF_PAGE_SIZE);
|
|
||||||
size += pQuery->pSelectExpr[i].interBytes;
|
size += pQuery->pSelectExpr[i].interBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +241,7 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
|
||||||
size_t size = pRuntimeEnv->pQuery->pSelectExpr[i].bytes;
|
size_t size = pRuntimeEnv->pQuery->pSelectExpr[i].bytes;
|
||||||
memset(s, 0, size);
|
memset(s, 0, size);
|
||||||
|
|
||||||
resetResultInfo(pResultInfo);
|
RESET_RESULT_INFO(pResultInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
pWindowRes->numOfRows = 0;
|
pWindowRes->numOfRows = 0;
|
||||||
|
|
|
@ -1,184 +0,0 @@
|
||||||
#include "qresultBuf.h"
|
|
||||||
#include "hash.h"
|
|
||||||
#include "qextbuffer.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
#include "queryLog.h"
|
|
||||||
|
|
||||||
int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t size, int32_t rowSize, void* handle) {
|
|
||||||
*pResultBuf = calloc(1, sizeof(SDiskbasedResultBuf));
|
|
||||||
SDiskbasedResultBuf* pResBuf = *pResultBuf;
|
|
||||||
if (pResBuf == NULL) {
|
|
||||||
return TSDB_CODE_COM_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
pResBuf->numOfRowsPerPage = (DEFAULT_INTERN_BUF_PAGE_SIZE - sizeof(tFilePage)) / rowSize;
|
|
||||||
pResBuf->numOfPages = size;
|
|
||||||
|
|
||||||
pResBuf->totalBufSize = pResBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE;
|
|
||||||
pResBuf->incStep = 4;
|
|
||||||
|
|
||||||
// init id hash table
|
|
||||||
pResBuf->idsTable = taosHashInit(size, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
|
|
||||||
pResBuf->list = taosArrayInit(size, POINTER_BYTES);
|
|
||||||
|
|
||||||
char path[4096] = {0};
|
|
||||||
getTmpfilePath("tsdb_qbuf", path);
|
|
||||||
pResBuf->path = strdup(path);
|
|
||||||
|
|
||||||
pResBuf->fd = open(pResBuf->path, O_CREAT | O_RDWR, 0666);
|
|
||||||
if (!FD_VALID(pResBuf->fd)) {
|
|
||||||
qError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno));
|
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ret = ftruncate(pResBuf->fd, pResBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE);
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
|
||||||
qError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno));
|
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
pResBuf->pBuf = mmap(NULL, pResBuf->totalBufSize, PROT_READ | PROT_WRITE, MAP_SHARED, pResBuf->fd, 0);
|
|
||||||
if (pResBuf->pBuf == MAP_FAILED) {
|
|
||||||
qError("QInfo:%p failed to map temp file: %s. %s", handle, pResBuf->path, strerror(errno));
|
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug("QInfo:%p create tmp file for output result:%s, %" PRId64 "bytes", handle, pResBuf->path,
|
|
||||||
pResBuf->totalBufSize);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getNumOfResultBufGroupId(SDiskbasedResultBuf* pResultBuf) { return taosHashGetSize(pResultBuf->idsTable); }
|
|
||||||
|
|
||||||
int32_t getResBufSize(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->totalBufSize; }
|
|
||||||
|
|
||||||
static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t numOfPages) {
|
|
||||||
assert(pResultBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE == pResultBuf->totalBufSize);
|
|
||||||
|
|
||||||
int32_t ret = munmap(pResultBuf->pBuf, pResultBuf->totalBufSize);
|
|
||||||
pResultBuf->numOfPages += numOfPages;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* disk-based output buffer is exhausted, try to extend the disk-based buffer, the available disk space may
|
|
||||||
* be insufficient
|
|
||||||
*/
|
|
||||||
ret = ftruncate(pResultBuf->fd, pResultBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE);
|
|
||||||
if (ret != 0) {
|
|
||||||
// dError("QInfo:%p failed to create intermediate result output file:%s. %s", pQInfo, pSupporter->extBufFile,
|
|
||||||
// strerror(errno));
|
|
||||||
return TSDB_CODE_QRY_NO_DISKSPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
pResultBuf->totalBufSize = pResultBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE;
|
|
||||||
pResultBuf->pBuf = mmap(NULL, pResultBuf->totalBufSize, PROT_READ | PROT_WRITE, MAP_SHARED, pResultBuf->fd, 0);
|
|
||||||
|
|
||||||
if (pResultBuf->pBuf == MAP_FAILED) {
|
|
||||||
// dError("QInfo:%p failed to map temp file: %s. %s", pQInfo, pSupporter->extBufFile, strerror(errno));
|
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE bool noMoreAvailablePages(SDiskbasedResultBuf* pResultBuf) {
|
|
||||||
return (pResultBuf->allocateId == pResultBuf->numOfPages - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t getGroupIndex(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
|
|
||||||
assert(pResultBuf != NULL);
|
|
||||||
|
|
||||||
char* p = taosHashGet(pResultBuf->idsTable, (const char*)&groupId, sizeof(int32_t));
|
|
||||||
if (p == NULL) { // it is a new group id
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t slot = GET_INT32_VAL(p);
|
|
||||||
assert(slot >= 0 && slot < taosHashGetSize(pResultBuf->idsTable));
|
|
||||||
|
|
||||||
return slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t addNewGroupId(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
|
|
||||||
int32_t num = getNumOfResultBufGroupId(pResultBuf); // the num is the newest allocated group id slot
|
|
||||||
taosHashPut(pResultBuf->idsTable, (const char*)&groupId, sizeof(int32_t), &num, sizeof(int32_t));
|
|
||||||
|
|
||||||
SArray* pa = taosArrayInit(1, sizeof(int32_t));
|
|
||||||
taosArrayPush(pResultBuf->list, &pa);
|
|
||||||
|
|
||||||
assert(taosArrayGetSize(pResultBuf->list) == taosHashGetSize(pResultBuf->idsTable));
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void registerPageId(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32_t pageId) {
|
|
||||||
int32_t slot = getGroupIndex(pResultBuf, groupId);
|
|
||||||
if (slot < 0) {
|
|
||||||
slot = addNewGroupId(pResultBuf, groupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
SIDList pList = taosArrayGetP(pResultBuf->list, slot);
|
|
||||||
taosArrayPush(pList, &pageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32_t* pageId) {
|
|
||||||
if (noMoreAvailablePages(pResultBuf)) {
|
|
||||||
if (extendDiskFileSize(pResultBuf, pResultBuf->incStep) != TSDB_CODE_SUCCESS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register new id in this group
|
|
||||||
*pageId = (pResultBuf->allocateId++);
|
|
||||||
registerPageId(pResultBuf, groupId, *pageId);
|
|
||||||
|
|
||||||
tFilePage* page = GET_RES_BUF_PAGE_BY_ID(pResultBuf, *pageId);
|
|
||||||
|
|
||||||
// clear memory for the new page
|
|
||||||
memset(page, 0, DEFAULT_INTERN_BUF_PAGE_SIZE);
|
|
||||||
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getNumOfRowsPerPage(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->numOfRowsPerPage; }
|
|
||||||
|
|
||||||
SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId) {
|
|
||||||
int32_t slot = getGroupIndex(pResultBuf, groupId);
|
|
||||||
if (slot < 0) {
|
|
||||||
return taosArrayInit(1, sizeof(int32_t));
|
|
||||||
} else {
|
|
||||||
return taosArrayGetP(pResultBuf->list, slot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) {
|
|
||||||
if (pResultBuf == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FD_VALID(pResultBuf->fd)) {
|
|
||||||
close(pResultBuf->fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug("QInfo:%p disk-based output buffer closed, %" PRId64 " bytes, file:%s", handle, pResultBuf->totalBufSize, pResultBuf->path);
|
|
||||||
munmap(pResultBuf->pBuf, pResultBuf->totalBufSize);
|
|
||||||
unlink(pResultBuf->path);
|
|
||||||
|
|
||||||
tfree(pResultBuf->path);
|
|
||||||
|
|
||||||
size_t size = taosArrayGetSize(pResultBuf->list);
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
|
||||||
SArray* pa = taosArrayGetP(pResultBuf->list, i);
|
|
||||||
taosArrayDestroy(pa);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(pResultBuf->list);
|
|
||||||
taosHashCleanup(pResultBuf->idsTable);
|
|
||||||
|
|
||||||
tfree(pResultBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getLastPageId(SIDList pList) {
|
|
||||||
size_t size = taosArrayGetSize(pList);
|
|
||||||
return *(int32_t*) taosArrayGet(pList, size - 1);
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "qAst.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "qast.h"
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
#include "qhistogram.h"
|
#include "qHistogram.h"
|
||||||
|
|
||||||
/* test validate the names for table/database */
|
/* test validate the names for table/database */
|
||||||
TEST(testCase, histogram_binary_search) {
|
TEST(testCase, histogram_binary_search) {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "qResultbuf.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "qresultBuf.h"
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
|
#include "qTsbuf.h"
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "qtsbuf.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,7 @@ typedef struct {
|
||||||
char secret[TSDB_KEY_LEN]; // secret for the link
|
char secret[TSDB_KEY_LEN]; // secret for the link
|
||||||
char ckey[TSDB_KEY_LEN]; // ciphering key
|
char ckey[TSDB_KEY_LEN]; // ciphering key
|
||||||
|
|
||||||
void (*cfp)(SRpcMsg *, SRpcIpSet *);
|
void (*cfp)(SRpcMsg *, SRpcEpSet *);
|
||||||
int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
|
@ -71,7 +71,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SRpcInfo *pRpc; // associated SRpcInfo
|
SRpcInfo *pRpc; // associated SRpcInfo
|
||||||
SRpcIpSet ipSet; // ip list provided by app
|
SRpcEpSet epSet; // ip list provided by app
|
||||||
void *ahandle; // handle provided by app
|
void *ahandle; // handle provided by app
|
||||||
void *signature; // for validation
|
void *signature; // for validation
|
||||||
struct SRpcConn *pConn; // pConn allocated
|
struct SRpcConn *pConn; // pConn allocated
|
||||||
|
@ -80,12 +80,12 @@ typedef struct {
|
||||||
int32_t contLen; // content length
|
int32_t contLen; // content length
|
||||||
int32_t code; // error code
|
int32_t code; // error code
|
||||||
int16_t numOfTry; // number of try for different servers
|
int16_t numOfTry; // number of try for different servers
|
||||||
int8_t oldInUse; // server IP inUse passed by app
|
int8_t oldInUse; // server EP inUse passed by app
|
||||||
int8_t redirect; // flag to indicate redirect
|
int8_t redirect; // flag to indicate redirect
|
||||||
int8_t connType; // connection type
|
int8_t connType; // connection type
|
||||||
SRpcMsg *pRsp; // for synchronous API
|
SRpcMsg *pRsp; // for synchronous API
|
||||||
tsem_t *pSem; // for synchronous API
|
tsem_t *pSem; // for synchronous API
|
||||||
SRpcIpSet *pSet; // for synchronous API
|
SRpcEpSet *pSet; // for synchronous API
|
||||||
char msg[0]; // RpcHead starts from here
|
char msg[0]; // RpcHead starts from here
|
||||||
} SRpcReqContext;
|
} SRpcReqContext;
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ void *rpcReallocCont(void *ptr, int contLen) {
|
||||||
return start + sizeof(SRpcReqContext) + sizeof(SRpcHead);
|
return start + sizeof(SRpcReqContext) + sizeof(SRpcHead);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpcSendRequest(void *shandle, const SRpcIpSet *pIpSet, SRpcMsg *pMsg) {
|
void rpcSendRequest(void *shandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
SRpcInfo *pRpc = (SRpcInfo *)shandle;
|
SRpcInfo *pRpc = (SRpcInfo *)shandle;
|
||||||
SRpcReqContext *pContext;
|
SRpcReqContext *pContext;
|
||||||
|
|
||||||
|
@ -364,11 +364,11 @@ void rpcSendRequest(void *shandle, const SRpcIpSet *pIpSet, SRpcMsg *pMsg) {
|
||||||
pContext->ahandle = pMsg->ahandle;
|
pContext->ahandle = pMsg->ahandle;
|
||||||
pContext->signature = pContext;
|
pContext->signature = pContext;
|
||||||
pContext->pRpc = (SRpcInfo *)shandle;
|
pContext->pRpc = (SRpcInfo *)shandle;
|
||||||
pContext->ipSet = *pIpSet;
|
pContext->epSet = *pEpSet;
|
||||||
pContext->contLen = contLen;
|
pContext->contLen = contLen;
|
||||||
pContext->pCont = pMsg->pCont;
|
pContext->pCont = pMsg->pCont;
|
||||||
pContext->msgType = pMsg->msgType;
|
pContext->msgType = pMsg->msgType;
|
||||||
pContext->oldInUse = pIpSet->inUse;
|
pContext->oldInUse = pEpSet->inUse;
|
||||||
|
|
||||||
pContext->connType = RPC_CONN_UDPC;
|
pContext->connType = RPC_CONN_UDPC;
|
||||||
if (contLen > tsRpcMaxUdpSize) pContext->connType = RPC_CONN_TCPC;
|
if (contLen > tsRpcMaxUdpSize) pContext->connType = RPC_CONN_TCPC;
|
||||||
|
@ -458,15 +458,15 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpcSendRedirectRsp(void *thandle, const SRpcIpSet *pIpSet) {
|
void rpcSendRedirectRsp(void *thandle, const SRpcEpSet *pEpSet) {
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg;
|
||||||
memset(&rpcMsg, 0, sizeof(rpcMsg));
|
memset(&rpcMsg, 0, sizeof(rpcMsg));
|
||||||
|
|
||||||
rpcMsg.contLen = sizeof(SRpcIpSet);
|
rpcMsg.contLen = sizeof(SRpcEpSet);
|
||||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||||
if (rpcMsg.pCont == NULL) return;
|
if (rpcMsg.pCont == NULL) return;
|
||||||
|
|
||||||
memcpy(rpcMsg.pCont, pIpSet, sizeof(SRpcIpSet));
|
memcpy(rpcMsg.pCont, pEpSet, sizeof(SRpcEpSet));
|
||||||
|
|
||||||
rpcMsg.code = TSDB_CODE_RPC_REDIRECT;
|
rpcMsg.code = TSDB_CODE_RPC_REDIRECT;
|
||||||
rpcMsg.handle = thandle;
|
rpcMsg.handle = thandle;
|
||||||
|
@ -488,7 +488,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
|
void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
|
||||||
SRpcReqContext *pContext;
|
SRpcReqContext *pContext;
|
||||||
pContext = (SRpcReqContext *) (pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext));
|
pContext = (SRpcReqContext *) (pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext));
|
||||||
|
|
||||||
|
@ -498,9 +498,9 @@ void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, SRpcMsg *pMsg, SRpcMsg *pRsp)
|
||||||
tsem_init(&sem, 0, 0);
|
tsem_init(&sem, 0, 0);
|
||||||
pContext->pSem = &sem;
|
pContext->pSem = &sem;
|
||||||
pContext->pRsp = pRsp;
|
pContext->pRsp = pRsp;
|
||||||
pContext->pSet = pIpSet;
|
pContext->pSet = pEpSet;
|
||||||
|
|
||||||
rpcSendRequest(shandle, pIpSet, pMsg);
|
rpcSendRequest(shandle, pEpSet, pMsg);
|
||||||
|
|
||||||
tsem_wait(&sem);
|
tsem_wait(&sem);
|
||||||
tsem_destroy(&sem);
|
tsem_destroy(&sem);
|
||||||
|
@ -755,11 +755,11 @@ static SRpcConn *rpcGetConnObj(SRpcInfo *pRpc, int sid, SRecvInfo *pRecv) {
|
||||||
static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) {
|
static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) {
|
||||||
SRpcConn *pConn;
|
SRpcConn *pConn;
|
||||||
SRpcInfo *pRpc = pContext->pRpc;
|
SRpcInfo *pRpc = pContext->pRpc;
|
||||||
SRpcIpSet *pIpSet = &pContext->ipSet;
|
SRpcEpSet *pEpSet = &pContext->epSet;
|
||||||
|
|
||||||
pConn = rpcGetConnFromCache(pRpc->pCache, pIpSet->fqdn[pIpSet->inUse], pIpSet->port[pIpSet->inUse], pContext->connType);
|
pConn = rpcGetConnFromCache(pRpc->pCache, pEpSet->fqdn[pEpSet->inUse], pEpSet->port[pEpSet->inUse], pContext->connType);
|
||||||
if ( pConn == NULL || pConn->user[0] == 0) {
|
if ( pConn == NULL || pConn->user[0] == 0) {
|
||||||
pConn = rpcOpenConn(pRpc, pIpSet->fqdn[pIpSet->inUse], pIpSet->port[pIpSet->inUse], pContext->connType);
|
pConn = rpcOpenConn(pRpc, pEpSet->fqdn[pEpSet->inUse], pEpSet->port[pEpSet->inUse], pContext->connType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pConn) {
|
if (pConn) {
|
||||||
|
@ -1020,16 +1020,16 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) {
|
||||||
pContext->pConn = NULL;
|
pContext->pConn = NULL;
|
||||||
if (pContext->pRsp) {
|
if (pContext->pRsp) {
|
||||||
// for synchronous API
|
// for synchronous API
|
||||||
memcpy(pContext->pSet, &pContext->ipSet, sizeof(SRpcIpSet));
|
memcpy(pContext->pSet, &pContext->epSet, sizeof(SRpcEpSet));
|
||||||
memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg));
|
memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg));
|
||||||
tsem_post(pContext->pSem);
|
tsem_post(pContext->pSem);
|
||||||
} else {
|
} else {
|
||||||
// for asynchronous API
|
// for asynchronous API
|
||||||
SRpcIpSet *pIpSet = NULL;
|
SRpcEpSet *pEpSet = NULL;
|
||||||
if (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect)
|
if (pContext->epSet.inUse != pContext->oldInUse || pContext->redirect)
|
||||||
pIpSet = &pContext->ipSet;
|
pEpSet = &pContext->epSet;
|
||||||
|
|
||||||
(*pRpc->cfp)(pMsg, pIpSet);
|
(*pRpc->cfp)(pMsg, pEpSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// free the request message
|
// free the request message
|
||||||
|
@ -1070,9 +1070,9 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
||||||
pConn->pContext = NULL;
|
pConn->pContext = NULL;
|
||||||
pConn->pReqMsg = NULL;
|
pConn->pReqMsg = NULL;
|
||||||
|
|
||||||
// for UDP, port may be changed by server, the port in ipSet shall be used for cache
|
// for UDP, port may be changed by server, the port in epSet shall be used for cache
|
||||||
if (pHead->code != TSDB_CODE_RPC_TOO_SLOW) {
|
if (pHead->code != TSDB_CODE_RPC_TOO_SLOW) {
|
||||||
rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType);
|
rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->epSet.port[pContext->epSet.inUse], pConn->connType);
|
||||||
} else {
|
} else {
|
||||||
rpcCloseConn(pConn);
|
rpcCloseConn(pConn);
|
||||||
}
|
}
|
||||||
|
@ -1087,10 +1087,10 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
|
||||||
|
|
||||||
if (pHead->code == TSDB_CODE_RPC_REDIRECT) {
|
if (pHead->code == TSDB_CODE_RPC_REDIRECT) {
|
||||||
pContext->numOfTry = 0;
|
pContext->numOfTry = 0;
|
||||||
memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet));
|
memcpy(&pContext->epSet, pHead->content, sizeof(pContext->epSet));
|
||||||
tDebug("%s, redirect is received, numOfIps:%d", pConn->info, pContext->ipSet.numOfIps);
|
tDebug("%s, redirect is received, numOfEps:%d", pConn->info, pContext->epSet.numOfEps);
|
||||||
for (int i=0; i<pContext->ipSet.numOfIps; ++i)
|
for (int i=0; i<pContext->epSet.numOfEps; ++i)
|
||||||
pContext->ipSet.port[i] = htons(pContext->ipSet.port[i]);
|
pContext->epSet.port[i] = htons(pContext->epSet.port[i]);
|
||||||
rpcSendReqToServer(pRpc, pContext);
|
rpcSendReqToServer(pRpc, pContext);
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
} else if (pHead->code == TSDB_CODE_RPC_NOT_READY) {
|
} else if (pHead->code == TSDB_CODE_RPC_NOT_READY) {
|
||||||
|
@ -1269,7 +1269,7 @@ static void rpcProcessConnError(void *param, void *id) {
|
||||||
|
|
||||||
tDebug("%s %p, connection error happens", pRpc->label, pContext->ahandle);
|
tDebug("%s %p, connection error happens", pRpc->label, pContext->ahandle);
|
||||||
|
|
||||||
if (pContext->numOfTry >= pContext->ipSet.numOfIps) {
|
if (pContext->numOfTry >= pContext->epSet.numOfEps) {
|
||||||
rpcMsg.msgType = pContext->msgType+1;
|
rpcMsg.msgType = pContext->msgType+1;
|
||||||
rpcMsg.ahandle = pContext->ahandle;
|
rpcMsg.ahandle = pContext->ahandle;
|
||||||
rpcMsg.code = pContext->code;
|
rpcMsg.code = pContext->code;
|
||||||
|
@ -1279,8 +1279,8 @@ static void rpcProcessConnError(void *param, void *id) {
|
||||||
rpcNotifyClient(pContext, &rpcMsg);
|
rpcNotifyClient(pContext, &rpcMsg);
|
||||||
} else {
|
} else {
|
||||||
// move to next IP
|
// move to next IP
|
||||||
pContext->ipSet.inUse++;
|
pContext->epSet.inUse++;
|
||||||
pContext->ipSet.inUse = pContext->ipSet.inUse % pContext->ipSet.numOfIps;
|
pContext->epSet.inUse = pContext->epSet.inUse % pContext->epSet.numOfEps;
|
||||||
rpcSendReqToServer(pRpc, pContext);
|
rpcSendReqToServer(pRpc, pContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
int index;
|
||||||
SRpcIpSet ipSet;
|
SRpcEpSet epSet;
|
||||||
int num;
|
int num;
|
||||||
int numOfReqs;
|
int numOfReqs;
|
||||||
int msgSize;
|
int msgSize;
|
||||||
|
@ -32,11 +32,11 @@ typedef struct {
|
||||||
void *pRpc;
|
void *pRpc;
|
||||||
} SInfo;
|
} SInfo;
|
||||||
|
|
||||||
static void processResponse(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
|
static void processResponse(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
SInfo *pInfo = (SInfo *)pMsg->ahandle;
|
SInfo *pInfo = (SInfo *)pMsg->ahandle;
|
||||||
tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code);
|
tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code);
|
||||||
|
|
||||||
if (pIpSet) pInfo->ipSet = *pIpSet;
|
if (pEpSet) pInfo->epSet = *pEpSet;
|
||||||
|
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
sem_post(&pInfo->rspSem);
|
sem_post(&pInfo->rspSem);
|
||||||
|
@ -57,7 +57,7 @@ static void *sendRequest(void *param) {
|
||||||
rpcMsg.ahandle = pInfo;
|
rpcMsg.ahandle = pInfo;
|
||||||
rpcMsg.msgType = 1;
|
rpcMsg.msgType = 1;
|
||||||
tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
|
tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
|
||||||
rpcSendRequest(pInfo->pRpc, &pInfo->ipSet, &rpcMsg);
|
rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg);
|
||||||
if ( pInfo->num % 20000 == 0 )
|
if ( pInfo->num % 20000 == 0 )
|
||||||
tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
|
tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
|
||||||
sem_wait(&pInfo->rspSem);
|
sem_wait(&pInfo->rspSem);
|
||||||
|
@ -71,7 +71,7 @@ static void *sendRequest(void *param) {
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
SRpcInit rpcInit;
|
SRpcInit rpcInit;
|
||||||
SRpcIpSet ipSet;
|
SRpcEpSet epSet;
|
||||||
int msgSize = 128;
|
int msgSize = 128;
|
||||||
int numOfReqs = 0;
|
int numOfReqs = 0;
|
||||||
int appThreads = 1;
|
int appThreads = 1;
|
||||||
|
@ -82,12 +82,12 @@ int main(int argc, char *argv[]) {
|
||||||
pthread_attr_t thattr;
|
pthread_attr_t thattr;
|
||||||
|
|
||||||
// server info
|
// server info
|
||||||
ipSet.numOfIps = 1;
|
epSet.numOfEps = 1;
|
||||||
ipSet.inUse = 0;
|
epSet.inUse = 0;
|
||||||
ipSet.port[0] = 7000;
|
epSet.port[0] = 7000;
|
||||||
ipSet.port[1] = 7000;
|
epSet.port[1] = 7000;
|
||||||
strcpy(ipSet.fqdn[0], serverIp);
|
strcpy(epSet.fqdn[0], serverIp);
|
||||||
strcpy(ipSet.fqdn[1], "192.168.0.1");
|
strcpy(epSet.fqdn[1], "192.168.0.1");
|
||||||
|
|
||||||
// client info
|
// client info
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
@ -105,9 +105,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
for (int i=1; i<argc; ++i) {
|
for (int i=1; i<argc; ++i) {
|
||||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||||
ipSet.port[0] = atoi(argv[++i]);
|
epSet.port[0] = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
||||||
tstrncpy(ipSet.fqdn[0], argv[++i], sizeof(ipSet.fqdn[0]));
|
tstrncpy(epSet.fqdn[0], argv[++i], sizeof(epSet.fqdn[0]));
|
||||||
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
||||||
rpcInit.numOfThreads = atoi(argv[++i]);
|
rpcInit.numOfThreads = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
||||||
|
@ -131,7 +131,7 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
printf("\nusage: %s [options] \n", argv[0]);
|
printf("\nusage: %s [options] \n", argv[0]);
|
||||||
printf(" [-i ip]: first server IP address, default is:%s\n", serverIp);
|
printf(" [-i ip]: first server IP address, default is:%s\n", serverIp);
|
||||||
printf(" [-p port]: server port number, default is:%d\n", ipSet.port[0]);
|
printf(" [-p port]: server port number, default is:%d\n", epSet.port[0]);
|
||||||
printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads);
|
printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads);
|
||||||
printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions);
|
printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions);
|
||||||
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
|
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
|
||||||
|
@ -168,7 +168,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
for (int i=0; i<appThreads; ++i) {
|
for (int i=0; i<appThreads; ++i) {
|
||||||
pInfo->index = i;
|
pInfo->index = i;
|
||||||
pInfo->ipSet = ipSet;
|
pInfo->epSet = epSet;
|
||||||
pInfo->numOfReqs = numOfReqs;
|
pInfo->numOfReqs = numOfReqs;
|
||||||
pInfo->msgSize = msgSize;
|
pInfo->msgSize = msgSize;
|
||||||
sem_init(&pInfo->rspSem, 0, 0);
|
sem_init(&pInfo->rspSem, 0, 0);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
int index;
|
||||||
SRpcIpSet ipSet;
|
SRpcEpSet epSet;
|
||||||
int num;
|
int num;
|
||||||
int numOfReqs;
|
int numOfReqs;
|
||||||
int msgSize;
|
int msgSize;
|
||||||
|
@ -51,7 +51,7 @@ static void *sendRequest(void *param) {
|
||||||
rpcMsg.msgType = 1;
|
rpcMsg.msgType = 1;
|
||||||
tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
|
tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
|
||||||
|
|
||||||
rpcSendRecv(pInfo->pRpc, &pInfo->ipSet, &rpcMsg, &rspMsg);
|
rpcSendRecv(pInfo->pRpc, &pInfo->epSet, &rpcMsg, &rspMsg);
|
||||||
|
|
||||||
// handle response
|
// handle response
|
||||||
if (rspMsg.code != 0) terror++;
|
if (rspMsg.code != 0) terror++;
|
||||||
|
@ -72,7 +72,7 @@ static void *sendRequest(void *param) {
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
SRpcInit rpcInit;
|
SRpcInit rpcInit;
|
||||||
SRpcIpSet ipSet;
|
SRpcEpSet epSet;
|
||||||
int msgSize = 128;
|
int msgSize = 128;
|
||||||
int numOfReqs = 0;
|
int numOfReqs = 0;
|
||||||
int appThreads = 1;
|
int appThreads = 1;
|
||||||
|
@ -83,12 +83,12 @@ int main(int argc, char *argv[]) {
|
||||||
pthread_attr_t thattr;
|
pthread_attr_t thattr;
|
||||||
|
|
||||||
// server info
|
// server info
|
||||||
ipSet.numOfIps = 1;
|
epSet.numOfEps = 1;
|
||||||
ipSet.inUse = 0;
|
epSet.inUse = 0;
|
||||||
ipSet.port[0] = 7000;
|
epSet.port[0] = 7000;
|
||||||
ipSet.port[1] = 7000;
|
epSet.port[1] = 7000;
|
||||||
strcpy(ipSet.fqdn[0], serverIp);
|
strcpy(epSet.fqdn[0], serverIp);
|
||||||
strcpy(ipSet.fqdn[1], "192.168.0.1");
|
strcpy(epSet.fqdn[1], "192.168.0.1");
|
||||||
|
|
||||||
// client info
|
// client info
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
@ -106,9 +106,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
for (int i=1; i<argc; ++i) {
|
for (int i=1; i<argc; ++i) {
|
||||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||||
ipSet.port[0] = atoi(argv[++i]);
|
epSet.port[0] = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-i") ==0 && i < argc-1) {
|
||||||
tstrncpy(ipSet.fqdn[0], argv[++i], sizeof(ipSet.fqdn[0]));
|
tstrncpy(epSet.fqdn[0], argv[++i], sizeof(epSet.fqdn[0]));
|
||||||
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-t")==0 && i < argc-1) {
|
||||||
rpcInit.numOfThreads = atoi(argv[++i]);
|
rpcInit.numOfThreads = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
} else if (strcmp(argv[i], "-m")==0 && i < argc-1) {
|
||||||
|
@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
printf("\nusage: %s [options] \n", argv[0]);
|
printf("\nusage: %s [options] \n", argv[0]);
|
||||||
printf(" [-i ip]: first server IP address, default is:%s\n", serverIp);
|
printf(" [-i ip]: first server IP address, default is:%s\n", serverIp);
|
||||||
printf(" [-p port]: server port number, default is:%d\n", ipSet.port[0]);
|
printf(" [-p port]: server port number, default is:%d\n", epSet.port[0]);
|
||||||
printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads);
|
printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads);
|
||||||
printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions);
|
printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions);
|
||||||
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
|
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
|
||||||
|
@ -168,7 +168,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
for (int i=0; i<appThreads; ++i) {
|
for (int i=0; i<appThreads; ++i) {
|
||||||
pInfo->index = i;
|
pInfo->index = i;
|
||||||
pInfo->ipSet = ipSet;
|
pInfo->epSet = epSet;
|
||||||
pInfo->numOfReqs = numOfReqs;
|
pInfo->numOfReqs = numOfReqs;
|
||||||
pInfo->msgSize = msgSize;
|
pInfo->msgSize = msgSize;
|
||||||
sem_init(&pInfo->rspSem, 0, 0);
|
sem_init(&pInfo->rspSem, 0, 0);
|
||||||
|
|
|
@ -103,7 +103,7 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void processRequestMsg(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
|
void processRequestMsg(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
SRpcMsg *pTemp;
|
SRpcMsg *pTemp;
|
||||||
|
|
||||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg));
|
pTemp = taosAllocateQitem(sizeof(SRpcMsg));
|
||||||
|
|
|
@ -148,7 +148,7 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
|
||||||
STsdbRepo *pRepo = (STsdbRepo *)repo;
|
STsdbRepo *pRepo = (STsdbRepo *)repo;
|
||||||
int vgId = REPO_ID(pRepo);
|
int vgId = REPO_ID(pRepo);
|
||||||
|
|
||||||
tsdbStopStream(repo);
|
tsdbStopStream(pRepo);
|
||||||
|
|
||||||
if (toCommit) {
|
if (toCommit) {
|
||||||
tsdbAsyncCommit(pRepo);
|
tsdbAsyncCommit(pRepo);
|
||||||
|
@ -1126,6 +1126,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void tsdbStopStream(STsdbRepo *pRepo) {
|
static void tsdbStopStream(STsdbRepo *pRepo) {
|
||||||
STsdbMeta *pMeta = pRepo->tsdbMeta;
|
STsdbMeta *pMeta = pRepo->tsdbMeta;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
|
|
||||||
#include "../../../query/inc/qast.h" // todo move to common module
|
#include "../../query/inc/qAst.h" // todo move to common module
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbMain.h"
|
#include "tsdbMain.h"
|
||||||
|
@ -240,7 +240,7 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
|
||||||
|
|
||||||
pQueryHandle->defaultLoadColumn = getDefaultLoadColumns(pQueryHandle, true);
|
pQueryHandle->defaultLoadColumn = getDefaultLoadColumns(pQueryHandle, true);
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%zu in query", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo));
|
tsdbDebug("%p total numOfTable:%zu in query, %p", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo), pQueryHandle->qinfo);
|
||||||
|
|
||||||
tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo);
|
tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo);
|
||||||
tsdbInitCompBlockLoadInfo(&pQueryHandle->compBlockLoadInfo);
|
tsdbInitCompBlockLoadInfo(&pQueryHandle->compBlockLoadInfo);
|
||||||
|
@ -331,7 +331,8 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
|
||||||
tsdbDebug("%p uid:%" PRId64", tid:%d check data in mem from skey:%" PRId64 ", order:%d, %p", pHandle,
|
tsdbDebug("%p uid:%" PRId64", tid:%d check data in mem from skey:%" PRId64 ", order:%d, %p", pHandle,
|
||||||
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo);
|
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo);
|
||||||
} else {
|
} else {
|
||||||
tsdbDebug("%p uid:%" PRId64 ", tid:%d no data in mem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid);
|
tsdbDebug("%p uid:%"PRId64", tid:%d no data in mem, %p", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid,
|
||||||
|
pHandle->qinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!imemEmpty) {
|
if (!imemEmpty) {
|
||||||
|
@ -343,7 +344,8 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
|
||||||
tsdbDebug("%p uid:%" PRId64", tid:%d check data in imem from skey:%" PRId64 ", order:%d, %p", pHandle,
|
tsdbDebug("%p uid:%" PRId64", tid:%d check data in imem from skey:%" PRId64 ", order:%d, %p", pHandle,
|
||||||
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo);
|
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo);
|
||||||
} else {
|
} else {
|
||||||
tsdbDebug("%p uid:%"PRId64", tid:%d no data in imem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid);
|
tsdbDebug("%p uid:%"PRId64", tid:%d no data in imem, %p", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid,
|
||||||
|
pHandle->qinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -354,7 +356,7 @@ static void destroyTableMemIterator(STableCheckInfo* pCheckInfo) {
|
||||||
tSkipListDestroyIter(pCheckInfo->iiter);
|
tSkipListDestroyIter(pCheckInfo->iiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
|
SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
|
||||||
SDataRow rmem = NULL, rimem = NULL;
|
SDataRow rmem = NULL, rimem = NULL;
|
||||||
if (pCheckInfo->iter) {
|
if (pCheckInfo->iter) {
|
||||||
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter);
|
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter);
|
||||||
|
@ -371,20 +373,35 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rmem != NULL && rimem != NULL) {
|
if (rmem != NULL && rimem != NULL) {
|
||||||
if (dataRowKey(rmem) < dataRowKey(rimem)) {
|
TSKEY r1 = dataRowKey(rmem);
|
||||||
pCheckInfo->chosen = 0;
|
TSKEY r2 = dataRowKey(rimem);
|
||||||
return rmem;
|
|
||||||
} else if (dataRowKey(rmem) == dataRowKey(rimem)) {
|
if (r1 == r2) { // data ts are duplicated, ignore the data in mem
|
||||||
// data ts are duplicated, ignore the data in mem
|
|
||||||
tSkipListIterNext(pCheckInfo->iter);
|
tSkipListIterNext(pCheckInfo->iter);
|
||||||
pCheckInfo->chosen = 1;
|
pCheckInfo->chosen = 1;
|
||||||
return rimem;
|
return rimem;
|
||||||
} else {
|
} else {
|
||||||
pCheckInfo->chosen = 1;
|
if (ASCENDING_TRAVERSE(order)) {
|
||||||
return rimem;
|
if (r1 < r2) {
|
||||||
|
pCheckInfo->chosen = 0;
|
||||||
|
return rmem;
|
||||||
|
} else {
|
||||||
|
pCheckInfo->chosen = 1;
|
||||||
|
return rimem;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (r1 < r2) {
|
||||||
|
pCheckInfo->chosen = 1;
|
||||||
|
return rimem;
|
||||||
|
} else {
|
||||||
|
pCheckInfo->chosen = 0;
|
||||||
|
return rmem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// at least one (rmem or rimem) is absent here
|
||||||
if (rmem != NULL) {
|
if (rmem != NULL) {
|
||||||
pCheckInfo->chosen = 0;
|
pCheckInfo->chosen = 0;
|
||||||
return rmem;
|
return rmem;
|
||||||
|
@ -398,7 +415,7 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool moveToNextRow(STableCheckInfo* pCheckInfo) {
|
static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) {
|
||||||
bool hasNext = false;
|
bool hasNext = false;
|
||||||
if (pCheckInfo->chosen == 0) {
|
if (pCheckInfo->chosen == 0) {
|
||||||
if (pCheckInfo->iter != NULL) {
|
if (pCheckInfo->iter != NULL) {
|
||||||
|
@ -412,19 +429,17 @@ static bool moveToNextRow(STableCheckInfo* pCheckInfo) {
|
||||||
if (pCheckInfo->iiter != NULL) {
|
if (pCheckInfo->iiter != NULL) {
|
||||||
return tSkipListIterGet(pCheckInfo->iiter) != NULL;
|
return tSkipListIterGet(pCheckInfo->iiter) != NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else { //pCheckInfo->chosen == 1
|
||||||
if (pCheckInfo->chosen == 1) {
|
if (pCheckInfo->iiter != NULL) {
|
||||||
if (pCheckInfo->iiter != NULL) {
|
hasNext = tSkipListIterNext(pCheckInfo->iiter);
|
||||||
hasNext = tSkipListIterNext(pCheckInfo->iiter);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
return hasNext;
|
return hasNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCheckInfo->iter != NULL) {
|
if (pCheckInfo->iter != NULL) {
|
||||||
return tSkipListIterGet(pCheckInfo->iter) != NULL;
|
return tSkipListIterGet(pCheckInfo->iter) != NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +460,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
|
||||||
initTableMemIterator(pHandle, pCheckInfo);
|
initTableMemIterator(pHandle, pCheckInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataRow row = getSDataRowInTableMem(pCheckInfo);
|
SDataRow row = getSDataRowInTableMem(pCheckInfo, pHandle->order);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +665,7 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
|
||||||
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(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, pQueryHandle->order);
|
||||||
|
|
||||||
TSKEY key = (row != NULL)? dataRowKey(row):TSKEY_INITIAL_VAL;
|
TSKEY key = (row != NULL)? dataRowKey(row):TSKEY_INITIAL_VAL;
|
||||||
cur->pos = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:(binfo.rows-1);
|
cur->pos = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:(binfo.rows-1);
|
||||||
|
@ -1033,7 +1048,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
} else if (pCheckInfo->iter != NULL || pCheckInfo->iiter != NULL) {
|
} else if (pCheckInfo->iter != NULL || pCheckInfo->iiter != NULL) {
|
||||||
SSkipListNode* node = NULL;
|
SSkipListNode* node = NULL;
|
||||||
do {
|
do {
|
||||||
SDataRow row = getSDataRowInTableMem(pCheckInfo);
|
SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1061,9 +1076,9 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
cur->lastKey = key + step;
|
cur->lastKey = key + step;
|
||||||
cur->mixBlock = true;
|
cur->mixBlock = true;
|
||||||
|
|
||||||
moveToNextRow(pCheckInfo);
|
moveToNextRowInMem(pCheckInfo);
|
||||||
} else if (key == tsArray[pos]) { // data in buffer has the same timestamp of data in file block, ignore it
|
} else if (key == tsArray[pos]) { // data in buffer has the same timestamp of data in file block, ignore it
|
||||||
moveToNextRow(pCheckInfo);
|
moveToNextRowInMem(pCheckInfo);
|
||||||
} else if ((key > tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
|
} else if ((key > tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
|
||||||
(key < tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
|
(key < tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
|
||||||
if (cur->win.skey == TSKEY_INITIAL_VAL) {
|
if (cur->win.skey == TSKEY_INITIAL_VAL) {
|
||||||
|
@ -1072,7 +1087,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
|
|
||||||
int32_t end = doBinarySearchKey(pCols->cols[0].pData, pCols->numOfRows, key, order);
|
int32_t end = doBinarySearchKey(pCols->cols[0].pData, pCols->numOfRows, key, order);
|
||||||
if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it
|
if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it
|
||||||
moveToNextRow(pCheckInfo);
|
moveToNextRowInMem(pCheckInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t start = -1;
|
int32_t start = -1;
|
||||||
|
@ -1376,7 +1391,7 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tsdbDebug("%p %d data blocks sort completed", pQueryHandle, cnt);
|
tsdbDebug("%p %d data blocks sort completed, %p", pQueryHandle, cnt, pQueryHandle->qinfo);
|
||||||
cleanBlockOrderSupporter(&sup, numOfTables);
|
cleanBlockOrderSupporter(&sup, numOfTables);
|
||||||
free(pTree);
|
free(pTree);
|
||||||
|
|
||||||
|
@ -1754,7 +1769,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
|
||||||
STable* pTable = pCheckInfo->pTableObj;
|
STable* pTable = pCheckInfo->pTableObj;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
SDataRow row = getSDataRowInTableMem(pCheckInfo);
|
SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1775,11 +1790,11 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
|
||||||
copyOneRowFromMem(pQueryHandle, maxRowsToRead, numOfRows, row, pMeta, numOfCols, pTable);
|
copyOneRowFromMem(pQueryHandle, maxRowsToRead, numOfRows, row, pMeta, numOfCols, pTable);
|
||||||
|
|
||||||
if (++numOfRows >= maxRowsToRead) {
|
if (++numOfRows >= maxRowsToRead) {
|
||||||
moveToNextRow(pCheckInfo);
|
moveToNextRowInMem(pCheckInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while(moveToNextRow(pCheckInfo));
|
} while(moveToNextRowInMem(pCheckInfo));
|
||||||
|
|
||||||
assert(numOfRows <= maxRowsToRead);
|
assert(numOfRows <= maxRowsToRead);
|
||||||
|
|
||||||
|
@ -1869,7 +1884,6 @@ int32_t tsdbRetrieveDataBlockStatisInfo(TsdbQueryHandleT* pQueryHandle, SDataSta
|
||||||
pHandle->statis[i].numOfNull = pBlockInfo->compBlock->numOfRows;
|
pHandle->statis[i].numOfNull = pBlockInfo->compBlock->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo opt perf
|
|
||||||
SColumnInfo* pColInfo = taosArrayGet(pHandle->pColumns, i);
|
SColumnInfo* pColInfo = taosArrayGet(pHandle->pColumns, i);
|
||||||
if (pColInfo->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (pColInfo->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
pHandle->statis[i].min = pBlockInfo->compBlock->keyFirst;
|
pHandle->statis[i].min = pBlockInfo->compBlock->keyFirst;
|
||||||
|
@ -1961,43 +1975,20 @@ static void destroyHelper(void* param) {
|
||||||
free(param);
|
free(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TAG_INVALID_COLUMN_INDEX -2
|
|
||||||
static int32_t getTagColumnIndex(STSchema* pTSchema, SSchema* pSchema) {
|
|
||||||
// filter on table name(TBNAME)
|
|
||||||
if (strcasecmp(pSchema->name, TSQL_TBNAME_L) == 0) {
|
|
||||||
return TSDB_TBNAME_COLUMN_INDEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int32_t i = 0; i < schemaNCols(pTSchema); ++i) {
|
|
||||||
STColumn* pColumn = &pTSchema->columns[i];
|
|
||||||
if (pColumn->bytes == pSchema->bytes && pColumn->type == pSchema->type && pColumn->colId == pSchema->colId) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void filterPrepare(void* expr, void* param) {
|
void filterPrepare(void* expr, void* param) {
|
||||||
tExprNode* pExpr = (tExprNode*)expr;
|
tExprNode* pExpr = (tExprNode*)expr;
|
||||||
if (pExpr->_node.info != NULL) {
|
if (pExpr->_node.info != NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t i = 0;
|
|
||||||
pExpr->_node.info = calloc(1, sizeof(tQueryInfo));
|
pExpr->_node.info = calloc(1, sizeof(tQueryInfo));
|
||||||
|
|
||||||
STSchema* pTSSchema = (STSchema*) param;
|
STSchema* pTSSchema = (STSchema*) param;
|
||||||
|
|
||||||
tQueryInfo* pInfo = pExpr->_node.info;
|
tQueryInfo* pInfo = pExpr->_node.info;
|
||||||
tVariant* pCond = pExpr->_node.pRight->pVal;
|
tVariant* pCond = pExpr->_node.pRight->pVal;
|
||||||
SSchema* pSchema = pExpr->_node.pLeft->pSchema;
|
SSchema* pSchema = pExpr->_node.pLeft->pSchema;
|
||||||
|
|
||||||
int32_t index = getTagColumnIndex(pTSSchema, pSchema);
|
|
||||||
assert((index >= 0 && i < TSDB_MAX_TAGS) || (index == TSDB_TBNAME_COLUMN_INDEX) || index == TAG_INVALID_COLUMN_INDEX);
|
|
||||||
|
|
||||||
pInfo->sch = *pSchema;
|
pInfo->sch = *pSchema;
|
||||||
pInfo->colIndex = index;
|
|
||||||
pInfo->optr = pExpr->_node.optr;
|
pInfo->optr = pExpr->_node.optr;
|
||||||
pInfo->compare = getComparFunc(pSchema->type, pInfo->optr);
|
pInfo->compare = getComparFunc(pSchema->type, pInfo->optr);
|
||||||
pInfo->param = pTSSchema;
|
pInfo->param = pTSSchema;
|
||||||
|
@ -2143,7 +2134,7 @@ bool indexedNodeFilterFp(const void* pNode, void* param) {
|
||||||
|
|
||||||
char* val = NULL;
|
char* val = NULL;
|
||||||
|
|
||||||
if (pInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
val = (char*) TABLE_NAME(pTable);
|
val = (char*) TABLE_NAME(pTable);
|
||||||
} else {
|
} else {
|
||||||
val = tdGetKVRowValOfCol(pTable->tagVal, pInfo->sch.colId);
|
val = tdGetKVRowValOfCol(pTable->tagVal, pInfo->sch.colId);
|
||||||
|
|
|
@ -522,7 +522,7 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
|
||||||
void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
|
||||||
const char* tdengineTmpFileNamePrefix = "tdengine-";
|
const char* tdengineTmpFileNamePrefix = "tdengine-";
|
||||||
|
|
||||||
char tmpPath[PATH_MAX] = {0};
|
char tmpPath[PATH_MAX];
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
char *tmpDir = getenv("tmp");
|
char *tmpDir = getenv("tmp");
|
||||||
|
|
|
@ -340,6 +340,13 @@ void vnodeRelease(void *pVnodeRaw) {
|
||||||
tsdbCloseRepo(pVnode->tsdb, 1);
|
tsdbCloseRepo(pVnode->tsdb, 1);
|
||||||
pVnode->tsdb = NULL;
|
pVnode->tsdb = NULL;
|
||||||
|
|
||||||
|
// stop continuous query
|
||||||
|
if (pVnode->cq) {
|
||||||
|
void *cq = pVnode->cq;
|
||||||
|
pVnode->cq = NULL;
|
||||||
|
cqClose(cq);
|
||||||
|
}
|
||||||
|
|
||||||
if (pVnode->wal)
|
if (pVnode->wal)
|
||||||
walClose(pVnode->wal);
|
walClose(pVnode->wal);
|
||||||
pVnode->wal = NULL;
|
pVnode->wal = NULL;
|
||||||
|
@ -511,13 +518,6 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
|
||||||
syncStop(sync);
|
syncStop(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop continuous query
|
|
||||||
if (pVnode->cq) {
|
|
||||||
void *cq = pVnode->cq;
|
|
||||||
pVnode->cq = NULL;
|
|
||||||
cqClose(cq);
|
|
||||||
}
|
|
||||||
|
|
||||||
vTrace("vgId:%d, vnode will cleanup, refCount:%d", pVnode->vgId, pVnode->refCount);
|
vTrace("vgId:%d, vnode will cleanup, refCount:%d", pVnode->vgId, pVnode->refCount);
|
||||||
|
|
||||||
// release local resources only after cutting off outside connections
|
// release local resources only after cutting off outside connections
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
select * from db.devices;
|
|
@ -13,8 +13,9 @@ typedef struct {
|
||||||
char sql[256];
|
char sql[256];
|
||||||
char dataDir[256];
|
char dataDir[256];
|
||||||
int filesNum;
|
int filesNum;
|
||||||
int writeClients;
|
int clients;
|
||||||
int rowsPerRequest;
|
int rowsPerRequest;
|
||||||
|
int write;
|
||||||
} ProArgs;
|
} ProArgs;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -41,7 +42,7 @@ int main(int argc, char *argv[]) {
|
||||||
statis.totalRows = 0;
|
statis.totalRows = 0;
|
||||||
parseArg(argc, argv);
|
parseArg(argc, argv);
|
||||||
|
|
||||||
if (arguments.writeClients > 0) {
|
if (arguments.write) {
|
||||||
writeData();
|
writeData();
|
||||||
} else {
|
} else {
|
||||||
readData();
|
readData();
|
||||||
|
@ -52,7 +53,7 @@ void parseArg(int argc, char *argv[]) {
|
||||||
strcpy(arguments.sql, "./sqlCmd.txt");
|
strcpy(arguments.sql, "./sqlCmd.txt");
|
||||||
strcpy(arguments.dataDir, "./testdata");
|
strcpy(arguments.dataDir, "./testdata");
|
||||||
arguments.filesNum = 2;
|
arguments.filesNum = 2;
|
||||||
arguments.writeClients = 0;
|
arguments.clients = 1;
|
||||||
arguments.rowsPerRequest = 100;
|
arguments.rowsPerRequest = 100;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
@ -83,12 +84,12 @@ void parseArg(int argc, char *argv[]) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "-writeClients") == 0) {
|
else if (strcmp(argv[i], "-clients") == 0) {
|
||||||
if (i < argc - 1) {
|
if (i < argc - 1) {
|
||||||
arguments.writeClients = atoi(argv[++i]);
|
arguments.clients = atoi(argv[++i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "'-writeClients' requires a parameter, default:%d\n", arguments.writeClients);
|
fprintf(stderr, "'-clients' requires a parameter, default:%d\n", arguments.clients);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +102,9 @@ void parseArg(int argc, char *argv[]) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[i], "-w") == 0) {
|
||||||
|
arguments.write = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +219,7 @@ void writeDataImp(void *param) {
|
||||||
|
|
||||||
void writeData() {
|
void writeData() {
|
||||||
printf("write data\n");
|
printf("write data\n");
|
||||||
printf("---- writeClients: %d\n", arguments.writeClients);
|
printf("---- clients: %d\n", arguments.clients);
|
||||||
printf("---- dataDir: %s\n", arguments.dataDir);
|
printf("---- dataDir: %s\n", arguments.dataDir);
|
||||||
printf("---- numOfFiles: %d\n", arguments.filesNum);
|
printf("---- numOfFiles: %d\n", arguments.filesNum);
|
||||||
printf("---- rowsPerRequest: %d\n", arguments.rowsPerRequest);
|
printf("---- rowsPerRequest: %d\n", arguments.rowsPerRequest);
|
||||||
|
@ -243,12 +247,12 @@ void writeData() {
|
||||||
|
|
||||||
int64_t st = getTimeStampMs();
|
int64_t st = getTimeStampMs();
|
||||||
|
|
||||||
int a = arguments.filesNum / arguments.writeClients;
|
int a = arguments.filesNum / arguments.clients;
|
||||||
int b = arguments.filesNum % arguments.writeClients;
|
int b = arguments.filesNum % arguments.clients;
|
||||||
int last = 0;
|
int last = 0;
|
||||||
|
|
||||||
ThreadObj *threads = calloc((size_t)arguments.writeClients, sizeof(ThreadObj));
|
ThreadObj *threads = calloc((size_t)arguments.clients, sizeof(ThreadObj));
|
||||||
for (int i = 0; i < arguments.writeClients; ++i) {
|
for (int i = 0; i < arguments.clients; ++i) {
|
||||||
ThreadObj *pthread = threads + i;
|
ThreadObj *pthread = threads + i;
|
||||||
pthread_attr_t thattr;
|
pthread_attr_t thattr;
|
||||||
pthread->threadId = i + 1;
|
pthread->threadId = i + 1;
|
||||||
|
@ -264,7 +268,7 @@ void writeData() {
|
||||||
pthread_create(&pthread->pid, &thattr, (void *(*)(void *))writeDataImp, pthread);
|
pthread_create(&pthread->pid, &thattr, (void *(*)(void *))writeDataImp, pthread);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < arguments.writeClients; i++) {
|
for (int i = 0; i < arguments.clients; i++) {
|
||||||
pthread_join(threads[i].pid, NULL);
|
pthread_join(threads[i].pid, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,17 +276,15 @@ void writeData() {
|
||||||
float seconds = (float)elapsed / 1000;
|
float seconds = (float)elapsed / 1000;
|
||||||
float rs = (float)statis.totalRows / seconds;
|
float rs = (float)statis.totalRows / seconds;
|
||||||
|
|
||||||
|
free(threads);
|
||||||
|
|
||||||
printf("---- Spent %f seconds to insert %ld records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs);
|
printf("---- Spent %f seconds to insert %ld records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void readData() {
|
void readDataImp(void *param)
|
||||||
printf("read data\n");
|
{
|
||||||
printf("---- sql: %s\n", arguments.sql);
|
ThreadObj *pThread = (ThreadObj *)param;
|
||||||
|
printf("Thread %d\n", pThread->threadId);
|
||||||
void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0);
|
|
||||||
if (taos == NULL)
|
|
||||||
taos_error(taos);
|
|
||||||
|
|
||||||
FILE *fp = fopen(arguments.sql, "r");
|
FILE *fp = fopen(arguments.sql, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
printf("failed to open file %s\n", arguments.sql);
|
printf("failed to open file %s\n", arguments.sql);
|
||||||
|
@ -290,6 +292,10 @@ void readData() {
|
||||||
}
|
}
|
||||||
printf("open file %s success\n", arguments.sql);
|
printf("open file %s success\n", arguments.sql);
|
||||||
|
|
||||||
|
void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0);
|
||||||
|
if (taos == NULL)
|
||||||
|
taos_error(taos);
|
||||||
|
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
|
@ -325,9 +331,36 @@ void readData() {
|
||||||
|
|
||||||
int64_t elapsed = getTimeStampMs() - st;
|
int64_t elapsed = getTimeStampMs() - st;
|
||||||
float seconds = (float)elapsed / 1000;
|
float seconds = (float)elapsed / 1000;
|
||||||
printf("---- Spent %f seconds to query: %s", seconds, line);
|
printf("---- Spent %f seconds to retrieve %d records, Thread:%d query: %s\n", seconds, rows, pThread->threadId, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void readData() {
|
||||||
|
printf("read data\n");
|
||||||
|
printf("---- sql: %s\n", arguments.sql);
|
||||||
|
printf("---- clients: %d\n", arguments.clients);
|
||||||
|
|
||||||
|
void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0);
|
||||||
|
if (taos == NULL)
|
||||||
|
taos_error(taos);
|
||||||
|
|
||||||
|
ThreadObj *threads = calloc((size_t)arguments.clients, sizeof(ThreadObj));
|
||||||
|
|
||||||
|
for (int i = 0; i < arguments.clients; ++i) {
|
||||||
|
ThreadObj *pthread = threads + i;
|
||||||
|
pthread_attr_t thattr;
|
||||||
|
pthread->threadId = i + 1;
|
||||||
|
pthread_attr_init(&thattr);
|
||||||
|
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
pthread_create(&pthread->pid, &thattr, (void *(*)(void *))readDataImp, pthread);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < arguments.clients; i++) {
|
||||||
|
pthread_join(threads[i].pid, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(threads);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DATA_DIR=/mnt/root/testdata
|
||||||
|
NUM_LOOP=5
|
||||||
|
|
||||||
|
function printTo {
|
||||||
|
if $verbose ; then
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
TDTESTQ5OUT=tdengineTestQ5.out
|
||||||
|
|
||||||
|
function runTest {
|
||||||
|
totalThroughput=0
|
||||||
|
for i in `seq 1 $NUM_LOOP`; do
|
||||||
|
for c in `seq 1 $clients`; do
|
||||||
|
records[$c]=0
|
||||||
|
spentTime[$c]=0
|
||||||
|
throughput[$c]=0
|
||||||
|
done
|
||||||
|
printTo "loop i:$i, $TDTEST_DIR/tdengineTest \
|
||||||
|
-clients $clients -sql q5.txt"
|
||||||
|
restartTaosd
|
||||||
|
beginMS=`date +%s%3N`
|
||||||
|
$TDTEST_DIR/tdengineTest \
|
||||||
|
-clients $clients -sql $TDTEST_DIR/q5.txt > $TDTESTQ5OUT
|
||||||
|
endMS=`date +%s%3N`
|
||||||
|
totalRecords=0
|
||||||
|
for c in `seq 1 $clients`; do
|
||||||
|
records[$c]=`grep Thread:$c $TDTESTQ5OUT | awk '{print $7}'`
|
||||||
|
totalRecords=`echo "$totalRecords + ${records[$c]}"|bc`
|
||||||
|
done
|
||||||
|
spending=`echo "scale=4; x = ($endMS - $beginMS)/1000; if (x<1) print 0; x"|bc`
|
||||||
|
throughput=`echo "scale=4; x= $totalRecords / $spending; if (x<1) print 0; x" | bc`
|
||||||
|
printTo "spending: $spending sec, throughput: $throughput"
|
||||||
|
totalThroughput=`echo "scale=4; x = $totalThroughput + $throughput; if(x<1) print 0; x"|bc`
|
||||||
|
done
|
||||||
|
avgThrougput=`echo "scale=4; x = $totalThroughput / $NUM_LOOP; if (x<1) print 0; x"|bc`
|
||||||
|
echo "avg Throughput: $avgThrougput"
|
||||||
|
}
|
||||||
|
|
||||||
|
function restartTaosd {
|
||||||
|
printTo "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
|
||||||
|
|
||||||
|
printTo "Start taosd"
|
||||||
|
$TAOSD_DIR/taosd > /dev/null 2>&1 &
|
||||||
|
sleep 10
|
||||||
|
}
|
||||||
|
|
||||||
|
################ Main ################
|
||||||
|
|
||||||
|
master=false
|
||||||
|
develop=true
|
||||||
|
verbose=false
|
||||||
|
|
||||||
|
clients=1
|
||||||
|
|
||||||
|
while : ; do
|
||||||
|
case $1 in
|
||||||
|
-v)
|
||||||
|
verbose=true
|
||||||
|
shift ;;
|
||||||
|
|
||||||
|
master)
|
||||||
|
master=true
|
||||||
|
develop=false
|
||||||
|
shift ;;
|
||||||
|
|
||||||
|
develop)
|
||||||
|
master=false
|
||||||
|
develop=true
|
||||||
|
shift ;;
|
||||||
|
|
||||||
|
-c)
|
||||||
|
clients=$2
|
||||||
|
shift 2;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if $master ; then
|
||||||
|
printTo "Test master branch.."
|
||||||
|
cp /mnt/root/cfg/master/taos.cfg /etc/taos/taos.cfg
|
||||||
|
WORK_DIR=/mnt/root/TDengine.master
|
||||||
|
else
|
||||||
|
printTo "Test develop branch.."
|
||||||
|
cp /mnt/root/cfg/10billion/taos.cfg /etc/taos/taos.cfg
|
||||||
|
WORK_DIR=/mnt/root/TDengine
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAOSD_DIR=$WORK_DIR/debug/build/bin
|
||||||
|
TDTEST_DIR=$WORK_DIR/tests/comparisonTest/tdengine
|
||||||
|
|
||||||
|
runTest
|
||||||
|
|
||||||
|
printTo "Test done!"
|
|
@ -5,7 +5,6 @@ NUM_LOOP=5
|
||||||
NUM_OF_FILES=100
|
NUM_OF_FILES=100
|
||||||
|
|
||||||
rowsPerRequest=(1 100 500 1000 2000)
|
rowsPerRequest=(1 100 500 1000 2000)
|
||||||
numOfClients=(1 2 3 4 5 6 7)
|
|
||||||
|
|
||||||
function printTo {
|
function printTo {
|
||||||
if $verbose ; then
|
if $verbose ; then
|
||||||
|
@ -15,7 +14,7 @@ function printTo {
|
||||||
|
|
||||||
function runTest {
|
function runTest {
|
||||||
printf "R/R, "
|
printf "R/R, "
|
||||||
for c in ${numOfClients[@]}; do
|
for c in `seq 1 $clients`; do
|
||||||
if [ "$c" == "1" ]; then
|
if [ "$c" == "1" ]; then
|
||||||
printf "$c client, "
|
printf "$c client, "
|
||||||
else
|
else
|
||||||
|
@ -26,7 +25,7 @@ function runTest {
|
||||||
|
|
||||||
for r in ${rowsPerRequest[@]}; do
|
for r in ${rowsPerRequest[@]}; do
|
||||||
printf "$r, "
|
printf "$r, "
|
||||||
for c in ${numOfClients[@]}; do
|
for c in `seq 1 $clients`; do
|
||||||
totalRPR=0
|
totalRPR=0
|
||||||
for i in `seq 1 $NUM_LOOP`; do
|
for i in `seq 1 $NUM_LOOP`; do
|
||||||
restartTaosd
|
restartTaosd
|
||||||
|
@ -34,12 +33,12 @@ function runTest {
|
||||||
printTo "loop i:$i, $TDTEST_DIR/tdengineTest \
|
printTo "loop i:$i, $TDTEST_DIR/tdengineTest \
|
||||||
-dataDir $DATA_DIR \
|
-dataDir $DATA_DIR \
|
||||||
-numOfFiles $NUM_OF_FILES \
|
-numOfFiles $NUM_OF_FILES \
|
||||||
-writeClients $c \
|
-w -clients $c \
|
||||||
-rowsPerRequest $r"
|
-rowsPerRequest $r"
|
||||||
RPR=`$TDTEST_DIR/tdengineTest \
|
RPR=`$TDTEST_DIR/tdengineTest \
|
||||||
-dataDir $DATA_DIR \
|
-dataDir $DATA_DIR \
|
||||||
-numOfFiles 1 \
|
-numOfFiles 1 \
|
||||||
-writeClients $c \
|
-w -clients $c \
|
||||||
-rowsPerRequest $r \
|
-rowsPerRequest $r \
|
||||||
| grep speed | awk '{print $(NF-1)}'`
|
| grep speed | awk '{print $(NF-1)}'`
|
||||||
totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc`
|
totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc`
|
||||||
|
@ -73,25 +72,29 @@ function restartTaosd {
|
||||||
master=false
|
master=false
|
||||||
develop=true
|
develop=true
|
||||||
verbose=false
|
verbose=false
|
||||||
|
clients=1
|
||||||
|
|
||||||
for arg in "$@"
|
while : ; do
|
||||||
do
|
case $1 in
|
||||||
case $arg in
|
|
||||||
-v)
|
-v)
|
||||||
verbose=true
|
verbose=true
|
||||||
;;
|
shift ;;
|
||||||
|
|
||||||
master)
|
master)
|
||||||
master=true
|
master=true
|
||||||
develop=false
|
develop=false
|
||||||
;;
|
shift ;;
|
||||||
|
|
||||||
develop)
|
develop)
|
||||||
master=false
|
master=false
|
||||||
develop=true
|
develop=true
|
||||||
;;
|
shift ;;
|
||||||
|
|
||||||
|
-c)
|
||||||
|
clients=$2
|
||||||
|
shift 2;;
|
||||||
*)
|
*)
|
||||||
;;
|
break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue