other:merge 3.0
This commit is contained in:
commit
dfce7e7261
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Get Started
|
title: Get Started
|
||||||
description: 'Install TDengine from Docker image, apt-get or package, and run TAOS CLI and taosBenchmark to experience the features'
|
description: 'Install TDengine from Docker image, apt-get or package, and run TDengine CLI and taosBenchmark to experience the features'
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from "@theme/Tabs";
|
import Tabs from "@theme/Tabs";
|
||||||
|
@ -120,7 +120,7 @@ select * from t;
|
||||||
Query OK, 2 row(s) in set (0.003128s)
|
Query OK, 2 row(s) in set (0.003128s)
|
||||||
```
|
```
|
||||||
|
|
||||||
Besides executing SQL commands, system administrators can check running status, add/drop user accounts and manage the running instances. TAOS CLI with client driver can be installed and run on either Linux or Windows machines. For more details on CLI, please [check here](../reference/taos-shell/).
|
Besides executing SQL commands, system administrators can check running status, add/drop user accounts and manage the running instances. TDengine CLI with client driver can be installed and run on either Linux or Windows machines. For more details on CLI, please [check here](../reference/taos-shell/).
|
||||||
|
|
||||||
## Experience the blazing fast speed
|
## Experience the blazing fast speed
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ USE power;
|
||||||
|
|
||||||
## Create STable
|
## Create STable
|
||||||
|
|
||||||
In a time-series application, there may be multiple kinds of data collection points. For example, in the electrical power system there are meters, transformers, bus bars, switches, etc. For easy and efficient aggregation of multiple tables, one STable needs to be created for each kind of data collection point. For example, for the meters in [table 1](/tdinternal/arch#model_table1), the SQL statement below can be used to create the super table.
|
In a time-series application, there may be multiple kinds of data collection points. For example, in the electrical power system there are meters, transformers, bus bars, switches, etc. For easy and efficient aggregation of multiple tables, one STable needs to be created for each kind of data collection point. For example, for the meters in [table 1](/concept/#model_table1), the SQL statement below can be used to create the super table.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE STable meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);
|
CREATE STable meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import CStmt from "./_c_stmt.mdx";
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Application programs can execute `INSERT` statement through connectors to insert rows. The TAOS CLI can also be used to manually insert data.
|
Application programs can execute `INSERT` statement through connectors to insert rows. The TDengine CLI can also be used to manually insert data.
|
||||||
|
|
||||||
### Insert Single Row
|
### Insert Single Row
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: 立即开始
|
title: 立即开始
|
||||||
description: '从 Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TAOS CLI和工具 taosdemo 快速体验 TDengine 功能'
|
description: '从 Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TDengine CLI和工具 taosdemo 快速体验 TDengine 功能'
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from "@theme/Tabs";
|
import Tabs from "@theme/Tabs";
|
||||||
|
@ -122,7 +122,7 @@ select * from t;
|
||||||
Query OK, 2 row(s) in set (0.003128s)
|
Query OK, 2 row(s) in set (0.003128s)
|
||||||
```
|
```
|
||||||
|
|
||||||
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TAOS CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/)
|
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/)
|
||||||
|
|
||||||
## 使用 taosBenchmark 体验写入速度
|
## 使用 taosBenchmark 体验写入速度
|
||||||
|
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ typedef struct {
|
||||||
#define STREAM_TRIGGER_MAX_DELAY 3
|
#define STREAM_TRIGGER_MAX_DELAY 3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
char sourceDB[TSDB_DB_FNAME_LEN];
|
char sourceDB[TSDB_DB_FNAME_LEN];
|
||||||
char targetStbFullName[TSDB_TABLE_FNAME_LEN];
|
char targetStbFullName[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
|
@ -1539,7 +1539,7 @@ int32_t tDeserializeSCMCreateStreamReq(void* buf, int32_t bufLen, SCMCreateStrea
|
||||||
void tFreeSCMCreateStreamReq(SCMCreateStreamReq* pReq);
|
void tFreeSCMCreateStreamReq(SCMCreateStreamReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
char* sql;
|
char* sql;
|
||||||
char* executorMsg;
|
char* executorMsg;
|
||||||
|
@ -2001,16 +2001,17 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t tid;
|
int64_t tid;
|
||||||
int32_t status;
|
char status[TSDB_JOB_STATUS_LEN];
|
||||||
} SQuerySubDesc;
|
} SQuerySubDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
int64_t useconds;
|
int64_t useconds;
|
||||||
int64_t stime;
|
int64_t stime; // timestamp precision ms
|
||||||
int64_t reqRid;
|
int64_t reqRid;
|
||||||
int32_t pid;
|
int32_t pid;
|
||||||
|
bool stableQuery;
|
||||||
char fqdn[TSDB_FQDN_LEN];
|
char fqdn[TSDB_FQDN_LEN];
|
||||||
int32_t subPlanNum;
|
int32_t subPlanNum;
|
||||||
SArray* subDesc; // SArray<SQuerySubDesc>
|
SArray* subDesc; // SArray<SQuerySubDesc>
|
||||||
|
@ -2256,13 +2257,13 @@ typedef struct {
|
||||||
} SMqVDeleteRsp;
|
} SMqVDeleteRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_STREAM_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
int64_t streamId;
|
int8_t igNotExists;
|
||||||
} SMDropStreamTaskReq;
|
} SMDropStreamReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t reserved;
|
int8_t reserved;
|
||||||
} SMDropStreamTaskRsp;
|
} SMDropStreamRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
|
|
|
@ -65,6 +65,12 @@ extern "C" {
|
||||||
(list) = NULL; \
|
(list) = NULL; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define NODES_CLEAR_LIST(list) \
|
||||||
|
do { \
|
||||||
|
nodesClearList((list)); \
|
||||||
|
(list) = NULL; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
typedef enum ENodeType {
|
typedef enum ENodeType {
|
||||||
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
|
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
|
||||||
// VALUE, OPERATOR, FUNCTION and so on.
|
// VALUE, OPERATOR, FUNCTION and so on.
|
||||||
|
|
|
@ -69,6 +69,7 @@ typedef struct SScanLogicNode {
|
||||||
int16_t tsColId;
|
int16_t tsColId;
|
||||||
double filesFactor;
|
double filesFactor;
|
||||||
SArray* pSmaIndexes;
|
SArray* pSmaIndexes;
|
||||||
|
SNodeList* pPartTags;
|
||||||
} SScanLogicNode;
|
} SScanLogicNode;
|
||||||
|
|
||||||
typedef struct SJoinLogicNode {
|
typedef struct SJoinLogicNode {
|
||||||
|
@ -257,7 +258,7 @@ typedef struct STableScanPhysiNode {
|
||||||
double ratio;
|
double ratio;
|
||||||
int32_t dataRequired;
|
int32_t dataRequired;
|
||||||
SNodeList* pDynamicScanFuncs;
|
SNodeList* pDynamicScanFuncs;
|
||||||
SNodeList* pPartitionKeys;
|
SNodeList* pPartitionTags;
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
|
|
|
@ -351,6 +351,7 @@ typedef struct SQuery {
|
||||||
int32_t placeholderNum;
|
int32_t placeholderNum;
|
||||||
SArray* pPlaceholderValues;
|
SArray* pPlaceholderValues;
|
||||||
SNode* pPrepareRoot;
|
SNode* pPrepareRoot;
|
||||||
|
bool stableQuery;
|
||||||
} SQuery;
|
} SQuery;
|
||||||
|
|
||||||
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
||||||
|
|
|
@ -410,10 +410,10 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908)
|
#define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908)
|
||||||
#define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909)
|
#define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909)
|
||||||
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
|
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
|
||||||
|
#define TSDB_CODE_SYN_IS_LEADER TAOS_DEF_ERROR_CODE(0, 0x090B)
|
||||||
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x0910)
|
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x090C)
|
||||||
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x0911)
|
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x090D)
|
||||||
#define TSDB_CODE_SYN_NOT_IN_NEW_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0912)
|
#define TSDB_CODE_SYN_NOT_IN_NEW_CONFIG TAOS_DEF_ERROR_CODE(0, 0x090E)
|
||||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||||
|
|
||||||
// tq
|
// tq
|
||||||
|
|
|
@ -210,7 +210,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_TYPE_STR_MAX_LEN 32
|
#define TSDB_TYPE_STR_MAX_LEN 32
|
||||||
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_TOPIC_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_STREAM_FNAME_LEN TSDB_TABLE_FNAME_LEN
|
#define TSDB_STREAM_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
|
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
|
||||||
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
|
#define TSDB_PARTITION_KEY_LEN (TSDB_SUBSCRIBE_KEY_LEN + 20)
|
||||||
#define TSDB_COL_NAME_LEN 65
|
#define TSDB_COL_NAME_LEN 65
|
||||||
|
@ -243,6 +243,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_USET_PASSWORD_LEN 129
|
#define TSDB_USET_PASSWORD_LEN 129
|
||||||
#define TSDB_VERSION_LEN 12
|
#define TSDB_VERSION_LEN 12
|
||||||
#define TSDB_LABEL_LEN 8
|
#define TSDB_LABEL_LEN 8
|
||||||
|
#define TSDB_JOB_STATUS_LEN 32
|
||||||
|
|
||||||
#define TSDB_CLUSTER_ID_LEN 40
|
#define TSDB_CLUSTER_ID_LEN 40
|
||||||
#define TSDB_FQDN_LEN 128
|
#define TSDB_FQDN_LEN 128
|
||||||
|
|
|
@ -213,6 +213,7 @@ typedef struct SRequestObj {
|
||||||
SArray* tableList;
|
SArray* tableList;
|
||||||
SQueryExecMetric metric;
|
SQueryExecMetric metric;
|
||||||
SRequestSendRecvBody body;
|
SRequestSendRecvBody body;
|
||||||
|
bool stableQuery;
|
||||||
|
|
||||||
uint32_t prevCode; //previous error code: todo refactor, add update flag for catalog
|
uint32_t prevCode; //previous error code: todo refactor, add update flag for catalog
|
||||||
uint32_t retry;
|
uint32_t retry;
|
||||||
|
@ -294,7 +295,7 @@ void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
|
||||||
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
|
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
|
||||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||||
|
|
||||||
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port, int connType);
|
uint16_t port, int connType);
|
||||||
|
|
||||||
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
||||||
|
@ -305,6 +306,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
||||||
|
|
||||||
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
|
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
|
||||||
|
|
||||||
|
void taos_close_internal(void *taos);
|
||||||
|
|
||||||
// --- heartbeat
|
// --- heartbeat
|
||||||
// global, called by mgmt
|
// global, called by mgmt
|
||||||
int hbMgrInit();
|
int hbMgrInit();
|
||||||
|
|
|
@ -107,7 +107,7 @@ typedef struct STscStmt {
|
||||||
#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
||||||
#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
|
#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
|
||||||
|
|
||||||
TAOS_STMT *stmtInit(TAOS *taos);
|
TAOS_STMT *stmtInit(STscObj* taos);
|
||||||
int stmtClose(TAOS_STMT *stmt);
|
int stmtClose(TAOS_STMT *stmt);
|
||||||
int stmtExec(TAOS_STMT *stmt);
|
int stmtExec(TAOS_STMT *stmt);
|
||||||
const char *stmtErrstr(TAOS_STMT *stmt);
|
const char *stmtErrstr(TAOS_STMT *stmt);
|
||||||
|
|
|
@ -174,7 +174,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->query->killConnection) {
|
if (pRsp->query->killConnection) {
|
||||||
taos_close(pTscObj);
|
taos_close_internal(pTscObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->query->pQnodeList) {
|
if (pRsp->query->pQnodeList) {
|
||||||
|
@ -310,11 +310,12 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tstrncpy(desc.sql, pRequest->sqlstr, sizeof(desc.sql));
|
tstrncpy(desc.sql, pRequest->sqlstr, sizeof(desc.sql));
|
||||||
desc.stime = pRequest->metric.start;
|
desc.stime = pRequest->metric.start / 1000;
|
||||||
desc.queryId = pRequest->requestId;
|
desc.queryId = pRequest->requestId;
|
||||||
desc.useconds = now - pRequest->metric.start;
|
desc.useconds = now - pRequest->metric.start;
|
||||||
desc.reqRid = pRequest->self;
|
desc.reqRid = pRequest->self;
|
||||||
desc.pid = hbBasic->pid;
|
desc.pid = hbBasic->pid;
|
||||||
|
desc.stableQuery = pRequest->stableQuery;
|
||||||
taosGetFqdn(desc.fqdn);
|
taosGetFqdn(desc.fqdn);
|
||||||
desc.subPlanNum = pRequest->body.pDag ? pRequest->body.pDag->numOfSubplans : 0;
|
desc.subPlanNum = pRequest->body.pDag ? pRequest->body.pDag->numOfSubplans : 0;
|
||||||
|
|
||||||
|
@ -329,6 +330,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
||||||
if (code) {
|
if (code) {
|
||||||
taosArrayDestroy(desc.subDesc);
|
taosArrayDestroy(desc.subDesc);
|
||||||
desc.subDesc = NULL;
|
desc.subDesc = NULL;
|
||||||
|
desc.subPlanNum = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
desc.subDesc = NULL;
|
desc.subDesc = NULL;
|
||||||
|
@ -350,13 +352,6 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfQueries = pTscObj->pRequests ? taosHashGetSize(pTscObj->pRequests) : 0;
|
|
||||||
if (numOfQueries <= 0) {
|
|
||||||
releaseTscObj(connKey->tscRid);
|
|
||||||
tscDebug("no queries on connection");
|
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic));
|
SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic));
|
||||||
if (NULL == hbBasic) {
|
if (NULL == hbBasic) {
|
||||||
tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic));
|
tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic));
|
||||||
|
@ -364,6 +359,18 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hbBasic->connId = pTscObj->connId;
|
||||||
|
hbBasic->pid = taosGetPId();
|
||||||
|
taosGetAppName(hbBasic->app, NULL);
|
||||||
|
|
||||||
|
int32_t numOfQueries = pTscObj->pRequests ? taosHashGetSize(pTscObj->pRequests) : 0;
|
||||||
|
if (numOfQueries <= 0) {
|
||||||
|
req->query = hbBasic;
|
||||||
|
releaseTscObj(connKey->tscRid);
|
||||||
|
tscDebug("no queries on connection");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
hbBasic->queryDesc = taosArrayInit(numOfQueries, sizeof(SQueryDesc));
|
hbBasic->queryDesc = taosArrayInit(numOfQueries, sizeof(SQueryDesc));
|
||||||
if (NULL == hbBasic->queryDesc) {
|
if (NULL == hbBasic->queryDesc) {
|
||||||
tscWarn("taosArrayInit %d queryDesc failed", numOfQueries);
|
tscWarn("taosArrayInit %d queryDesc failed", numOfQueries);
|
||||||
|
@ -372,9 +379,6 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
hbBasic->connId = pTscObj->connId;
|
|
||||||
hbBasic->pid = taosGetPId();
|
|
||||||
taosGetAppName(hbBasic->app, NULL);
|
|
||||||
|
|
||||||
int32_t code = hbBuildQueryDesc(hbBasic, pTscObj);
|
int32_t code = hbBuildQueryDesc(hbBasic, pTscObj);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i
|
||||||
static STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param,
|
static STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param,
|
||||||
SAppInstInfo* pAppInfo, int connType);
|
SAppInstInfo* pAppInfo, int connType);
|
||||||
|
|
||||||
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port, int connType) {
|
uint16_t port, int connType) {
|
||||||
if (taos_init() != TSDB_CODE_SUCCESS) {
|
if (taos_init() != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -692,6 +692,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pRequest->stableQuery = pQuery->stableQuery;
|
||||||
|
|
||||||
return launchQueryImpl(pRequest, pQuery, false, NULL);
|
return launchQueryImpl(pRequest, pQuery, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,7 +919,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
|
||||||
|
|
||||||
terrno = pRequest->code;
|
terrno = pRequest->code;
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
taos_close(pTscObj);
|
taos_close_internal(pTscObj);
|
||||||
pTscObj = NULL;
|
pTscObj = NULL;
|
||||||
} else {
|
} else {
|
||||||
tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id,
|
tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id,
|
||||||
|
@ -952,8 +954,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
taosMemoryFreeClear(db);
|
taosMemoryFreeClear(db);
|
||||||
|
|
||||||
connectReq.connType = pObj->connType;
|
connectReq.connType = pObj->connType;
|
||||||
connectReq.pid = htonl(appInfo.pid);
|
connectReq.pid = appInfo.pid;
|
||||||
connectReq.startTime = htobe64(appInfo.startTime);
|
connectReq.startTime = appInfo.startTime;
|
||||||
|
|
||||||
tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app));
|
tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app));
|
||||||
tstrncpy(connectReq.user, pObj->user, sizeof(connectReq.user));
|
tstrncpy(connectReq.user, pObj->user, sizeof(connectReq.user));
|
||||||
|
@ -1081,7 +1083,12 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taos_connect_internal(ip, user, NULL, auth, db, port, CONN_TYPE__QUERY);
|
STscObj* pObj = taos_connect_internal(ip, user, NULL, auth, db, port, CONN_TYPE__QUERY);
|
||||||
|
if (pObj) {
|
||||||
|
return (TAOS*)pObj->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (TAOS*)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
||||||
|
|
|
@ -97,10 +97,15 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
||||||
pass = TSDB_DEFAULT_PASS;
|
pass = TSDB_DEFAULT_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
STscObj* pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
||||||
|
if (pObj) {
|
||||||
|
return (TAOS*)pObj->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (TAOS*)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_close(TAOS *taos) {
|
void taos_close_internal(void *taos) {
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +116,17 @@ void taos_close(TAOS *taos) {
|
||||||
taosRemoveRef(clientConnRefPool, pTscObj->id);
|
taosRemoveRef(clientConnRefPool, pTscObj->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void taos_close(TAOS *taos) {
|
||||||
|
STscObj* pObj = acquireTscObj((int64_t)taos);
|
||||||
|
if (NULL == pObj) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_close_internal(pObj);
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int taos_errno(TAOS_RES *tres) {
|
int taos_errno(TAOS_RES *tres) {
|
||||||
if (tres == NULL) {
|
if (tres == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -190,29 +206,36 @@ static void syncQueryFn(void *param, void *res, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||||
if (taos == NULL || sql == NULL) {
|
STscObj* pTscObj = acquireTscObj((int64_t)taos);
|
||||||
|
if (pTscObj == NULL || sql == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj *pTscObj = (STscObj *)taos;
|
|
||||||
|
|
||||||
#if SYNC_ON_TOP_OF_ASYNC
|
#if SYNC_ON_TOP_OF_ASYNC
|
||||||
SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||||
tsem_init(¶m->sem, 0, 0);
|
tsem_init(¶m->sem, 0, 0);
|
||||||
|
|
||||||
taos_query_a(pTscObj, sql, syncQueryFn, param);
|
taos_query_a(taos, sql, syncQueryFn, param);
|
||||||
tsem_wait(¶m->sem);
|
tsem_wait(¶m->sem);
|
||||||
|
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
|
|
||||||
return param->pRequest;
|
return param->pRequest;
|
||||||
#else
|
#else
|
||||||
size_t sqlLen = strlen(sql);
|
size_t sqlLen = strlen(sql);
|
||||||
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
|
||||||
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return execQuery(pTscObj, sql, sqlLen);
|
TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen);
|
||||||
|
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
|
|
||||||
|
return pRes;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,13 +452,15 @@ int taos_result_precision(TAOS_RES *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_select_db(TAOS *taos, const char *db) {
|
int taos_select_db(TAOS *taos, const char *db) {
|
||||||
STscObj *pObj = (STscObj *)taos;
|
STscObj* pObj = acquireTscObj((int64_t)taos);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return TSDB_CODE_TSC_DISCONNECTED;
|
return TSDB_CODE_TSC_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db == NULL || strlen(db) == 0) {
|
if (db == NULL || strlen(db) == 0) {
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +472,7 @@ int taos_select_db(TAOS *taos, const char *db) {
|
||||||
int32_t code = taos_errno(pRequest);
|
int32_t code = taos_errno(pRequest);
|
||||||
|
|
||||||
taos_free_result(pRequest);
|
taos_free_result(pRequest);
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,19 +619,26 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
||||||
int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
|
int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
|
||||||
|
|
||||||
void taos_reset_current_db(TAOS *taos) {
|
void taos_reset_current_db(TAOS *taos) {
|
||||||
if (taos == NULL) {
|
STscObj* pTscObj = acquireTscObj((int64_t)taos);
|
||||||
|
if (pTscObj == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetConnectDB(taos);
|
resetConnectDB(pTscObj);
|
||||||
|
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *taos_get_server_info(TAOS *taos) {
|
const char *taos_get_server_info(TAOS *taos) {
|
||||||
if (taos == NULL) {
|
STscObj* pTscObj = acquireTscObj((int64_t)taos);
|
||||||
|
if (pTscObj == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj *pTscObj = (STscObj *)taos;
|
releaseTscObj((int64_t)taos);
|
||||||
|
|
||||||
return pTscObj->ver;
|
return pTscObj->ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,6 +670,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery);
|
code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery);
|
||||||
|
pRequest->stableQuery = pQuery->stableQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -670,10 +704,14 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
||||||
ASSERT(fp != NULL);
|
STscObj* pTscObj = acquireTscObj((int64_t)taos);
|
||||||
|
if (pTscObj == NULL || sql == NULL || NULL == fp) {
|
||||||
if (taos == NULL || sql == NULL) {
|
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
if (pTscObj) {
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
}
|
||||||
fp(param, NULL, terrno);
|
fp(param, NULL, terrno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -688,7 +726,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = NULL;
|
SRequestObj *pRequest = NULL;
|
||||||
int32_t code = buildRequest(taos, sql, sqlLen, &pRequest);
|
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
fp(param, NULL, terrno);
|
fp(param, NULL, terrno);
|
||||||
|
@ -888,13 +926,18 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
||||||
if (taos == NULL) {
|
STscObj* pObj = acquireTscObj((int64_t)taos);
|
||||||
tscError("NULL parameter for %s", __FUNCTION__);
|
if (NULL == pObj) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
tscError("invalid parameter for %s", __FUNCTION__);
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stmtInit(taos);
|
TAOS_STMT* pStmt = stmtInit(pObj);
|
||||||
|
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
|
|
||||||
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||||
|
|
|
@ -309,7 +309,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
|
||||||
case SCHEMA_ACTION_ADD_COLUMN: {
|
case SCHEMA_ACTION_ADD_COLUMN: {
|
||||||
int n = sprintf(result, "alter stable `%s` add column ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` add column ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
||||||
TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery
|
TAOS_RES *res = taos_query((TAOS*)info->taos->id, result); // TODO async doAsyncQuery
|
||||||
code = taos_errno(res);
|
code = taos_errno(res);
|
||||||
const char *errStr = taos_errstr(res);
|
const char *errStr = taos_errstr(res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -323,7 +323,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
|
||||||
case SCHEMA_ACTION_ADD_TAG: {
|
case SCHEMA_ACTION_ADD_TAG: {
|
||||||
int n = sprintf(result, "alter stable `%s` add tag ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` add tag ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
||||||
TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery
|
TAOS_RES *res = taos_query((TAOS*)info->taos->id, result); // TODO async doAsyncQuery
|
||||||
code = taos_errno(res);
|
code = taos_errno(res);
|
||||||
const char *errStr = taos_errstr(res);
|
const char *errStr = taos_errstr(res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -337,7 +337,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
|
||||||
case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: {
|
case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: {
|
||||||
int n = sprintf(result, "alter stable `%s` modify column ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` modify column ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
||||||
TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery
|
TAOS_RES *res = taos_query((TAOS*)info->taos->id, result); // TODO async doAsyncQuery
|
||||||
code = taos_errno(res);
|
code = taos_errno(res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res));
|
uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res));
|
||||||
|
@ -350,7 +350,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
|
||||||
case SCHEMA_ACTION_CHANGE_TAG_SIZE: {
|
case SCHEMA_ACTION_CHANGE_TAG_SIZE: {
|
||||||
int n = sprintf(result, "alter stable `%s` modify tag ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` modify tag ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
smlBuildColumnDescription(action->alterSTable.field, result + n, capacity - n, &outBytes);
|
||||||
TAOS_RES *res = taos_query(info->taos, result); // TODO async doAsyncQuery
|
TAOS_RES *res = taos_query((TAOS*)info->taos->id, result); // TODO async doAsyncQuery
|
||||||
code = taos_errno(res);
|
code = taos_errno(res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res));
|
uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res));
|
||||||
|
@ -405,7 +405,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
|
||||||
pos--;
|
pos--;
|
||||||
++freeBytes;
|
++freeBytes;
|
||||||
outBytes = snprintf(pos, freeBytes, ")");
|
outBytes = snprintf(pos, freeBytes, ")");
|
||||||
TAOS_RES *res = taos_query(info->taos, result);
|
TAOS_RES *res = taos_query((TAOS*)info->taos->id, result);
|
||||||
code = taos_errno(res);
|
code = taos_errno(res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res));
|
uError("SML:0x%" PRIx64 " apply schema action. error : %s", info->id, taos_errstr(res));
|
||||||
|
@ -1453,9 +1453,9 @@ static void smlDestroyInfo(SSmlHandle *info) {
|
||||||
taosMemoryFreeClear(info);
|
taosMemoryFreeClear(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSmlHandle *smlBuildSmlInfo(TAOS *taos, SRequestObj *request, SMLProtocolType protocol, int8_t precision) {
|
static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLProtocolType protocol, int8_t precision){
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SSmlHandle *info = (SSmlHandle *)taosMemoryCalloc(1, sizeof(SSmlHandle));
|
SSmlHandle* info = (SSmlHandle*)taosMemoryCalloc(1, sizeof(SSmlHandle));
|
||||||
if (NULL == info) {
|
if (NULL == info) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1476,7 +1476,7 @@ static SSmlHandle *smlBuildSmlInfo(TAOS *taos, SRequestObj *request, SMLProtocol
|
||||||
}
|
}
|
||||||
((SVnodeModifOpStmt *)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV;
|
((SVnodeModifOpStmt *)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV;
|
||||||
|
|
||||||
info->taos = (STscObj *)taos;
|
info->taos = pTscObj;
|
||||||
code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog);
|
code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " get catalog error %d", info->id, code);
|
uError("SML:0x%" PRIx64 " get catalog error %d", info->id, code);
|
||||||
|
@ -2433,14 +2433,22 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
|
||||||
SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, TSDB_SQL_INSERT);
|
STscObj* pTscObj = acquireTscObj((int64_t)taos);
|
||||||
if (!request) {
|
if (NULL == pTscObj) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
uError("SML:taos_schemaless_insert invalid taos");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRequestObj* request = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT);
|
||||||
|
if(!request){
|
||||||
|
releaseTscObj((int64_t)taos);
|
||||||
uError("SML:taos_schemaless_insert error request is null");
|
uError("SML:taos_schemaless_insert error request is null");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
((STscObj *)taos)->schemalessType = 1;
|
pTscObj->schemalessType = 1;
|
||||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||||
|
|
||||||
int cnt = ceil(((double)numLines) / LINE_BATCH);
|
int cnt = ceil(((double)numLines) / LINE_BATCH);
|
||||||
|
@ -2455,7 +2463,7 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSchemalessDb(((STscObj *)taos), request) != TSDB_CODE_SUCCESS) {
|
if(isSchemalessDb(pTscObj, request) != TSDB_CODE_SUCCESS){
|
||||||
request->code = TSDB_CODE_SML_INVALID_DB_CONF;
|
request->code = TSDB_CODE_SML_INVALID_DB_CONF;
|
||||||
smlBuildInvalidDataMsg(&msg, "Cannot write data to a non schemaless database", NULL);
|
smlBuildInvalidDataMsg(&msg, "Cannot write data to a non schemaless database", NULL);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -2481,14 +2489,14 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < cnt; ++i) {
|
for (int i = 0; i < cnt; ++i) {
|
||||||
SRequestObj *req = (SRequestObj *)createRequest((STscObj *)taos, TSDB_SQL_INSERT);
|
SRequestObj* req = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT);
|
||||||
if (!req) {
|
if(!req){
|
||||||
request->code = TSDB_CODE_OUT_OF_MEMORY;
|
request->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
uError("SML:taos_schemaless_insert error request is null");
|
uError("SML:taos_schemaless_insert error request is null");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
SSmlHandle *info = smlBuildSmlInfo(taos, req, (SMLProtocolType)protocol, precision);
|
SSmlHandle* info = smlBuildSmlInfo(pTscObj, req, (SMLProtocolType)protocol, precision);
|
||||||
if (!info) {
|
if(!info){
|
||||||
request->code = TSDB_CODE_OUT_OF_MEMORY;
|
request->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
uError("SML:taos_schemaless_insert error SSmlHandle is null");
|
uError("SML:taos_schemaless_insert error SSmlHandle is null");
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -2520,8 +2528,9 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
||||||
end:
|
end:
|
||||||
taosThreadSpinDestroy(¶ms.lock);
|
taosThreadSpinDestroy(¶ms.lock);
|
||||||
tsem_destroy(¶ms.sem);
|
tsem_destroy(¶ms.sem);
|
||||||
// ((STscObj *)taos)->schemalessType = 0;
|
// ((STscObj *)taos)->schemalessType = 0;
|
||||||
((STscObj *)taos)->schemalessType = 1;
|
pTscObj->schemalessType = 1;
|
||||||
uDebug("resultend:%s", request->msgBuf);
|
uDebug("resultend:%s", request->msgBuf);
|
||||||
return (TAOS_RES *)request;
|
releaseTscObj((int64_t)taos);
|
||||||
|
return (TAOS_RES*)request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,7 +478,7 @@ int32_t stmtResetStmt(STscStmt* pStmt) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_STMT* stmtInit(TAOS* taos) {
|
TAOS_STMT* stmtInit(STscObj* taos) {
|
||||||
STscObj* pObj = (STscObj*)taos;
|
STscObj* pObj = (STscObj*)taos;
|
||||||
STscStmt* pStmt = NULL;
|
STscStmt* pStmt = NULL;
|
||||||
|
|
||||||
|
|
|
@ -257,8 +257,8 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
static const SSysDbTableSchema connectionsSchema[] = {
|
static const SSysDbTableSchema connectionsSchema[] = {
|
||||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
|
@ -302,19 +302,18 @@ static const SSysDbTableSchema offsetSchema[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema querySchema[] = {
|
static const SSysDbTableSchema querySchema[] = {
|
||||||
{.name = "query_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "query_id", .bytes = 26 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "req_id", .bytes = 8, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||||
|
{.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||||
|
{.name = "app", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "qid", .bytes = 22 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "exec_usec", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "sql_obj_id", .bytes = QUERY_OBJ_ID_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
|
||||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
|
||||||
{.name = "ep", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
|
||||||
{.name = "stable_query", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
{.name = "stable_query", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||||
{.name = "sub_queries", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "sub_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "sub_query_info", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "sub_status", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -210,6 +210,7 @@ static int32_t tSerializeSClientHbReq(SEncoder *pEncoder, const SClientHbReq *pR
|
||||||
if (tEncodeI64(pEncoder, desc->stime) < 0) return -1;
|
if (tEncodeI64(pEncoder, desc->stime) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, desc->reqRid) < 0) return -1;
|
if (tEncodeI64(pEncoder, desc->reqRid) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, desc->pid) < 0) return -1;
|
if (tEncodeI32(pEncoder, desc->pid) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, desc->stableQuery) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, desc->fqdn) < 0) return -1;
|
if (tEncodeCStr(pEncoder, desc->fqdn) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, desc->subPlanNum) < 0) return -1;
|
if (tEncodeI32(pEncoder, desc->subPlanNum) < 0) return -1;
|
||||||
|
|
||||||
|
@ -218,7 +219,7 @@ static int32_t tSerializeSClientHbReq(SEncoder *pEncoder, const SClientHbReq *pR
|
||||||
for (int32_t m = 0; m < snum; ++m) {
|
for (int32_t m = 0; m < snum; ++m) {
|
||||||
SQuerySubDesc *sDesc = taosArrayGet(desc->subDesc, m);
|
SQuerySubDesc *sDesc = taosArrayGet(desc->subDesc, m);
|
||||||
if (tEncodeI64(pEncoder, sDesc->tid) < 0) return -1;
|
if (tEncodeI64(pEncoder, sDesc->tid) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, sDesc->status) < 0) return -1;
|
if (tEncodeCStr(pEncoder, sDesc->status) < 0) return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -265,6 +266,7 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
|
||||||
if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1;
|
if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1;
|
if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, (int8_t*)&desc.stableQuery) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1;
|
if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1;
|
||||||
|
|
||||||
|
@ -277,7 +279,7 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
|
||||||
for (int32_t m = 0; m < snum; ++m) {
|
for (int32_t m = 0; m < snum; ++m) {
|
||||||
SQuerySubDesc sDesc = {0};
|
SQuerySubDesc sDesc = {0};
|
||||||
if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &sDesc.status) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, sDesc.status) < 0) return -1;
|
||||||
taosArrayPush(desc.subDesc, &sDesc);
|
taosArrayPush(desc.subDesc, &sDesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,27 +539,36 @@ typedef struct {
|
||||||
} SMqRebOutputObj;
|
} SMqRebOutputObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_STREAM_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
char sourceDb[TSDB_DB_FNAME_LEN];
|
// ctl
|
||||||
char targetDb[TSDB_DB_FNAME_LEN];
|
SRWLatch lock;
|
||||||
char targetSTbName[TSDB_TABLE_FNAME_LEN];
|
// create info
|
||||||
int64_t targetStbUid;
|
int64_t createTime;
|
||||||
int64_t createTime;
|
int64_t updateTime;
|
||||||
int64_t updateTime;
|
int32_t version;
|
||||||
int64_t uid;
|
int64_t smaId; // 0 for unused
|
||||||
int64_t dbUid;
|
// info
|
||||||
int32_t version;
|
int64_t uid;
|
||||||
int32_t vgNum;
|
int8_t status;
|
||||||
SRWLatch lock;
|
// config
|
||||||
int8_t status;
|
int8_t dropPolicy;
|
||||||
int8_t createdBy; // STREAM_CREATED_BY__USER or SMA
|
int8_t trigger;
|
||||||
int32_t fixedSinkVgId; // 0 for shuffle
|
int64_t triggerParam;
|
||||||
SVgObj fixedSinkVg;
|
int64_t watermark;
|
||||||
int64_t smaId; // 0 for unused
|
// source and target
|
||||||
int8_t trigger;
|
int64_t sourceDbUid;
|
||||||
int64_t triggerParam;
|
int64_t targetDbUid;
|
||||||
int64_t watermark;
|
char sourceDb[TSDB_DB_FNAME_LEN];
|
||||||
|
char targetDb[TSDB_DB_FNAME_LEN];
|
||||||
|
char targetSTbName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
int64_t targetStbUid;
|
||||||
|
int32_t fixedSinkVgId; // 0 for shuffle
|
||||||
|
// fixedSinkVg is not applicable for encode and decode
|
||||||
|
SVgObj fixedSinkVg;
|
||||||
|
|
||||||
|
// transformation
|
||||||
char* sql;
|
char* sql;
|
||||||
|
char* ast;
|
||||||
char* physicalPlan;
|
char* physicalPlan;
|
||||||
SArray* tasks; // SArray<SArray<SStreamTask>>
|
SArray* tasks; // SArray<SArray<SStreamTask>>
|
||||||
SSchemaWrapper outputSchema;
|
SSchemaWrapper outputSchema;
|
||||||
|
|
|
@ -32,6 +32,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream);
|
||||||
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
||||||
int64_t watermark, double filesFactor);
|
int64_t watermark, double filesFactor);
|
||||||
|
|
||||||
|
int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,8 +27,7 @@ void mndCleanupStb(SMnode *pMnode);
|
||||||
SStbObj *mndAcquireStb(SMnode *pMnode, char *stbName);
|
SStbObj *mndAcquireStb(SMnode *pMnode, char *stbName);
|
||||||
void mndReleaseStb(SMnode *pMnode, SStbObj *pStb);
|
void mndReleaseStb(SMnode *pMnode, SStbObj *pStb);
|
||||||
SSdbRaw *mndStbActionEncode(SStbObj *pStb);
|
SSdbRaw *mndStbActionEncode(SStbObj *pStb);
|
||||||
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbs, int32_t numOfStbs, void **ppRsp,
|
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbs, int32_t numOfStbs, void **ppRsp, int32_t *pRspLen);
|
||||||
int32_t *pRspLen);
|
|
||||||
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs);
|
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs);
|
||||||
|
|
||||||
int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate);
|
int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate);
|
||||||
|
@ -36,6 +35,9 @@ SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName);
|
||||||
int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreate, SDbObj *pDb);
|
int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreate, SDbObj *pDb);
|
||||||
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb);
|
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb);
|
||||||
|
|
||||||
|
void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst);
|
||||||
|
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,8 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
||||||
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans);
|
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||||
|
int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,34 +18,35 @@
|
||||||
#include "mndConsumer.h"
|
#include "mndConsumer.h"
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
int32_t sz = 0;
|
|
||||||
/*int32_t outputNameSz = 0;*/
|
|
||||||
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pObj->updateTime) < 0) return -1;
|
||||||
|
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI64(pEncoder, pObj->uid) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI8(pEncoder, pObj->dropPolicy) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pObj->triggerParam) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pObj->watermark) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI64(pEncoder, pObj->sourceDbUid) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pObj->targetDbUid) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->sourceDb) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->sourceDb) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->targetDb) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->targetDb) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->targetSTbName) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->targetSTbName) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->targetStbUid) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->targetStbUid) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pObj->updateTime) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pObj->uid) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pObj->dbUid) < 0) return -1;
|
|
||||||
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
|
|
||||||
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
|
||||||
if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1;
|
|
||||||
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pObj->triggerParam) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pObj->watermark) < 0) return -1;
|
|
||||||
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
|
||||||
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
|
||||||
/*if (tEncodeCStr(pEncoder, pObj->logicalPlan) < 0) return -1;*/
|
|
||||||
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
|
||||||
// TODO encode tasks
|
|
||||||
if (pObj->tasks) {
|
|
||||||
sz = taosArrayGetSize(pObj->tasks);
|
|
||||||
}
|
|
||||||
if (tEncodeI32(pEncoder, sz) < 0) return -1;
|
|
||||||
|
|
||||||
|
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
||||||
|
if (tEncodeCStr(pEncoder, pObj->ast) < 0) return -1;
|
||||||
|
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
||||||
|
|
||||||
|
int32_t sz = taosArrayGetSize(pObj->tasks);
|
||||||
|
if (tEncodeI32(pEncoder, sz) < 0) return -1;
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SArray *pArray = taosArrayGetP(pObj->tasks, i);
|
SArray *pArray = taosArrayGetP(pObj->tasks, i);
|
||||||
int32_t innerSz = taosArrayGetSize(pArray);
|
int32_t innerSz = taosArrayGetSize(pArray);
|
||||||
|
@ -58,40 +59,37 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
|
|
||||||
if (tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema) < 0) return -1;
|
if (tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema) < 0) return -1;
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (pObj->ColAlias != NULL) {
|
|
||||||
outputNameSz = taosArrayGetSize(pObj->ColAlias);
|
|
||||||
}
|
|
||||||
if (tEncodeI32(pEncoder, outputNameSz) < 0) return -1;
|
|
||||||
for (int32_t i = 0; i < outputNameSz; i++) {
|
|
||||||
char *name = taosArrayGetP(pObj->ColAlias, i);
|
|
||||||
if (tEncodeCStr(pEncoder, name) < 0) return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->updateTime) < 0) return -1;
|
||||||
|
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->uid) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI8(pDecoder, &pObj->dropPolicy) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->triggerParam) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->watermark) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->sourceDbUid) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pObj->targetDbUid) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->sourceDb) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->sourceDb) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->targetDb) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->targetDb) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->targetSTbName) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->targetSTbName) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->targetStbUid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->targetStbUid) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pObj->updateTime) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pObj->uid) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pObj->dbUid) < 0) return -1;
|
|
||||||
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
|
|
||||||
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
|
||||||
if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1;
|
|
||||||
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pObj->triggerParam) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pObj->watermark) < 0) return -1;
|
|
||||||
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
||||||
/*if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1;*/
|
if (tDecodeCStrAlloc(pDecoder, &pObj->ast) < 0) return -1;
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
||||||
|
|
||||||
pObj->tasks = NULL;
|
pObj->tasks = NULL;
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
if (tDecodeI32(pDecoder, &sz) < 0) return -1;
|
if (tDecodeI32(pDecoder, &sz) < 0) return -1;
|
||||||
|
@ -112,21 +110,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema) < 0) return -1;
|
if (tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema) < 0) return -1;
|
||||||
#if 0
|
|
||||||
int32_t outputNameSz;
|
|
||||||
if (tDecodeI32(pDecoder, &outputNameSz) < 0) return -1;
|
|
||||||
if (outputNameSz != 0) {
|
|
||||||
pObj->ColAlias = taosArrayInit(outputNameSz, sizeof(void *));
|
|
||||||
if (pObj->ColAlias == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int32_t i = 0; i < outputNameSz; i++) {
|
|
||||||
char *name;
|
|
||||||
if (tDecodeCStrAlloc(pDecoder, &name) < 0) return -1;
|
|
||||||
taosArrayPush(pObj->ColAlias, &name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,6 +370,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
SMnodeObj *pObj = mndAcquireMnode(pMnode, pDnode->id);
|
SMnodeObj *pObj = mndAcquireMnode(pMnode, pDnode->id);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
if (pObj->state != statusReq.mload.syncState) {
|
if (pObj->state != statusReq.mload.syncState) {
|
||||||
|
mInfo("dnode:%d, mnode syncstate from %s to %s", pObj->id, syncStr(pObj->state), syncStr(statusReq.mload.syncState));
|
||||||
pObj->state = statusReq.mload.syncState;
|
pObj->state = statusReq.mload.syncState;
|
||||||
pObj->stateStartTime = taosGetTimestampMs();
|
pObj->stateStartTime = taosGetTimestampMs();
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,7 +397,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
char logBuf[512] = {0};
|
char logBuf[512] = {0};
|
||||||
char *syncNodeStr = sync2SimpleStr(pMgmt->sync);
|
char *syncNodeStr = sync2SimpleStr(pMgmt->sync);
|
||||||
snprintf(logBuf, sizeof(logBuf), "==vnodeProcessSyncReq== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr);
|
snprintf(logBuf, sizeof(logBuf), "==mndProcessSyncMsg== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr);
|
||||||
static int64_t mndTick = 0;
|
static int64_t mndTick = 0;
|
||||||
if (++mndTick % 10 == 1) {
|
if (++mndTick % 10 == 1) {
|
||||||
mTrace("sync trace msg:%s, %s", TMSG_INFO(pMsg->msgType), syncNodeStr);
|
mTrace("sync trace msg:%s, %s", TMSG_INFO(pMsg->msgType), syncNodeStr);
|
||||||
|
@ -699,6 +699,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
|
|
||||||
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
|
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
|
||||||
pLoad->syncState = syncGetMyRole(pMnode->syncMgmt.sync);
|
pLoad->syncState = syncGetMyRole(pMnode->syncMgmt.sync);
|
||||||
|
mTrace("mnode current syncstate is %s", syncStr(pLoad->syncState));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -667,6 +667,10 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
}
|
}
|
||||||
if (pObj->pDnode && mndIsDnodeOnline(pObj->pDnode, curMs)) {
|
if (pObj->pDnode && mndIsDnodeOnline(pObj->pDnode, curMs)) {
|
||||||
roles = syncStr(pObj->state);
|
roles = syncStr(pObj->state);
|
||||||
|
if (pObj->state == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) {
|
||||||
|
roles = syncStr(TAOS_SYNC_STATE_ERROR);
|
||||||
|
mError("mnode:%d, is leader too", pObj->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
char b2[12 + VARSTR_HEADER_SIZE] = {0};
|
char b2[12 + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
|
|
@ -39,6 +39,7 @@ typedef struct {
|
||||||
int64_t lastAccessTimeMs;
|
int64_t lastAccessTimeMs;
|
||||||
uint64_t killId;
|
uint64_t killId;
|
||||||
int32_t numOfQueries;
|
int32_t numOfQueries;
|
||||||
|
SRWLatch queryLock;
|
||||||
SArray *pQueries; // SArray<SQueryDesc>
|
SArray *pQueries; // SArray<SQueryDesc>
|
||||||
} SConnObj;
|
} SConnObj;
|
||||||
|
|
||||||
|
@ -53,8 +54,8 @@ static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessConnectReq(SRpcMsg *pReq);
|
static int32_t mndProcessConnectReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessKillQueryReq(SRpcMsg *pReq);
|
static int32_t mndProcessKillQueryReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessKillConnReq(SRpcMsg *pReq);
|
static int32_t mndProcessKillConnReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitProfile(SMnode *pMnode) {
|
int32_t mndInitProfile(SMnode *pMnode) {
|
||||||
|
@ -74,9 +75,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_QUERY, mndProcessKillQueryReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_KILL_QUERY, mndProcessKillQueryReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_CONN, mndProcessKillConnReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_KILL_CONN, mndProcessKillConnReq);
|
||||||
|
|
||||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndCancelGetNextConn);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndCancelGetNextConn);
|
||||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndCancelGetNextQuery);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndCancelGetNextQuery);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -129,7 +130,9 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndFreeConn(SConnObj *pConn) {
|
static void mndFreeConn(SConnObj *pConn) {
|
||||||
|
taosWLockLatch(&pConn->queryLock);
|
||||||
taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc);
|
taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc);
|
||||||
|
taosWUnLockLatch(&pConn->queryLock);
|
||||||
|
|
||||||
mTrace("conn:%u, is destroyed, data:%p", pConn->id, pConn);
|
mTrace("conn:%u, is destroyed, data:%p", pConn->id, pConn);
|
||||||
}
|
}
|
||||||
|
@ -222,8 +225,6 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
goto CONN_OVER;
|
goto CONN_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndAcquireConn(pMnode, pConn->id);
|
|
||||||
|
|
||||||
SConnectRsp connectRsp = {0};
|
SConnectRsp connectRsp = {0};
|
||||||
connectRsp.acctId = pUser->acctId;
|
connectRsp.acctId = pUser->acctId;
|
||||||
connectRsp.superUser = pUser->superUser;
|
connectRsp.superUser = pUser->superUser;
|
||||||
|
@ -259,12 +260,17 @@ CONN_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
|
static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
|
||||||
|
taosWLockLatch(&pConn->queryLock);
|
||||||
|
|
||||||
taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc);
|
taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc);
|
||||||
|
|
||||||
pConn->pQueries = pBasic->queryDesc;
|
pConn->pQueries = pBasic->queryDesc;
|
||||||
|
pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0;
|
||||||
pBasic->queryDesc = NULL;
|
pBasic->queryDesc = NULL;
|
||||||
|
|
||||||
pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0;
|
mDebug("queries updated in conn %d, num:%d", pConn->id, pConn->numOfQueries);
|
||||||
|
|
||||||
|
taosWUnLockLatch(&pConn->queryLock);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -354,11 +360,6 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
||||||
} else {
|
} else {
|
||||||
mDebug("user:%s, conn:%u is freed and create a new conn:%u", connInfo.user, pBasic->connId, pConn->id);
|
mDebug("user:%s, conn:%u is freed and create a new conn:%u", connInfo.user, pBasic->connId, pConn->id);
|
||||||
}
|
}
|
||||||
} else if (pConn->killed) {
|
|
||||||
mError("user:%s, conn:%u is already killed", connInfo.user, pConn->id);
|
|
||||||
mndReleaseConn(pMnode, pConn);
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_CONNECTION;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryHbRspBasic *rspBasic = taosMemoryCalloc(1, sizeof(SQueryHbRspBasic));
|
SQueryHbRspBasic *rspBasic = taosMemoryCalloc(1, sizeof(SQueryHbRspBasic));
|
||||||
|
@ -389,6 +390,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
||||||
mndReleaseConn(pMnode, pConn);
|
mndReleaseConn(pMnode, pConn);
|
||||||
|
|
||||||
hbRsp.query = rspBasic;
|
hbRsp.query = rspBasic;
|
||||||
|
} else {
|
||||||
|
mDebug("no query info in hb msg");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t kvNum = taosHashGetSize(pHbReq->info);
|
int32_t kvNum = taosHashGetSize(pHbReq->info);
|
||||||
|
@ -559,75 +562,12 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t numOfRows = 0;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SConnObj *pConn = NULL;
|
int32_t numOfRows = 0;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
char *pWrite;
|
SConnObj *pConn = NULL;
|
||||||
char ipStr[TSDB_IPv4ADDR_LEN + 6];
|
|
||||||
|
|
||||||
if (pShow->pIter == NULL) {
|
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
|
||||||
pShow->pIter = taosCacheCreateIter(pMgmt->cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
|
||||||
pConn = mndGetNextConn(pMnode, pShow->pIter);
|
|
||||||
if (pConn == NULL) break;
|
|
||||||
|
|
||||||
cols = 0;
|
|
||||||
#if 0
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
*(uint32_t *)pWrite = pConn->id;
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
// app name
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->app, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
// app pid
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
*(int32_t *)pWrite = pConn->pid;
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
taosIpPort2String(pConn->ip, pConn->port, ipStr);
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
*(int64_t *)pWrite = pConn->loginTimeMs;
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
if (pConn->lastAccessTimeMs < pConn->loginTimeMs) pConn->lastAccessTimeMs = pConn->loginTimeMs;
|
|
||||||
*(int64_t *)pWrite = pConn->lastAccessTimeMs;
|
|
||||||
cols++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
numOfRows++;
|
|
||||||
}
|
|
||||||
|
|
||||||
pShow->numOfRows += numOfRows;
|
|
||||||
|
|
||||||
return numOfRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
|
||||||
SMnode *pMnode = pReq->info.node;
|
|
||||||
int32_t numOfRows = 0;
|
|
||||||
#if 0
|
|
||||||
SConnObj *pConn = NULL;
|
|
||||||
int32_t cols = 0;
|
|
||||||
char *pWrite;
|
|
||||||
void *pIter;
|
|
||||||
char str[TSDB_IPv4ADDR_LEN + 6] = {0};
|
|
||||||
|
|
||||||
if (pShow->pIter == NULL) {
|
if (pShow->pIter == NULL) {
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
@ -641,85 +581,142 @@ static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, char *data, in
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfRows + pConn->numOfQueries >= rows) {
|
cols = 0;
|
||||||
taosCacheDestroyIter(pShow->pIter);
|
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pConn->id, false);
|
||||||
|
|
||||||
|
char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(user, pConn->user);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)user, false);
|
||||||
|
|
||||||
|
char app[TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE];
|
||||||
|
STR_TO_VARSTR(app, pConn->app);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)app, false);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pConn->pid, false);
|
||||||
|
|
||||||
|
char endpoint[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port);
|
||||||
|
varDataLen(endpoint) = strlen(&endpoint[VARSTR_HEADER_SIZE]);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)endpoint, false);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pConn->loginTimeMs, false);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pConn->lastAccessTimeMs, false);
|
||||||
|
|
||||||
|
numOfRows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
pShow->numOfRows += numOfRows;
|
||||||
|
return numOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
int32_t cols = 0;
|
||||||
|
SConnObj *pConn = NULL;
|
||||||
|
|
||||||
|
if (pShow->pIter == NULL) {
|
||||||
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
pShow->pIter = taosCacheCreateIter(pMgmt->cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (numOfRows < rows) {
|
||||||
|
pConn = mndGetNextConn(pMnode, pShow->pIter);
|
||||||
|
if (pConn == NULL) {
|
||||||
pShow->pIter = NULL;
|
pShow->pIter = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pConn->numOfQueries; ++i) {
|
taosRLockLatch(&pConn->queryLock);
|
||||||
SQueryDesc *pDesc = pConn->pQueries + i;
|
if (NULL == pConn->pQueries || taosArrayGetSize(pConn->pQueries) <= 0) {
|
||||||
|
taosRUnLockLatch(&pConn->queryLock);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfQueries = taosArrayGetSize(pConn->pQueries);
|
||||||
|
for (int32_t i = 0; i < numOfQueries; ++i) {
|
||||||
|
SQueryDesc* pQuery = taosArrayGet(pConn->pQueries, i);
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
char queryId[26 + VARSTR_HEADER_SIZE] = {0};
|
||||||
*(int64_t *)pWrite = htobe64(pDesc->queryId);
|
sprintf(&queryId[VARSTR_HEADER_SIZE], "%x:%" PRIx64, pConn->id, pQuery->reqRid);
|
||||||
cols++;
|
varDataLen(queryId) = strlen(&queryId[VARSTR_HEADER_SIZE]);
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)queryId, false);
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
*(int64_t *)pWrite = htobe64(pConn->id);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pQuery->queryId, false);
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->pMeta->pSchemas[cols].bytes);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pConn->id, false);
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
char app[TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE];
|
||||||
snprintf(str, tListLen(str), "%s:%u", taosIpStr(pConn->ip), pConn->port);
|
STR_TO_VARSTR(app, pConn->app);
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->pMeta->pSchemas[cols].bytes);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
cols++;
|
colDataAppend(pColInfo, numOfRows, (const char *)app, false);
|
||||||
|
|
||||||
char handleBuf[24] = {0};
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
snprintf(handleBuf, tListLen(handleBuf), "%" PRIu64, htobe64(pDesc->qId));
|
colDataAppend(pColInfo, numOfRows, (const char *)&pQuery->pid, false);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, handleBuf, pShow->pMeta->pSchemas[cols].bytes);
|
char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
cols++;
|
STR_TO_VARSTR(user, pConn->user);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)user, false);
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
char endpoint[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0};
|
||||||
*(int64_t *)pWrite = htobe64(pDesc->stime);
|
sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port);
|
||||||
cols++;
|
varDataLen(endpoint) = strlen(&endpoint[VARSTR_HEADER_SIZE]);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)endpoint, false);
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
*(int64_t *)pWrite = htobe64(pDesc->useconds);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pQuery->stime, false);
|
||||||
cols++;
|
|
||||||
|
|
||||||
snprintf(str, tListLen(str), "0x%" PRIx64, htobe64(pDesc->sqlObjId));
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
colDataAppend(pColInfo, numOfRows, (const char *)&pQuery->useconds, false);
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
*(int32_t *)pWrite = htonl(pDesc->pid);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pQuery->stableQuery, false);
|
||||||
cols++;
|
|
||||||
|
|
||||||
char epBuf[TSDB_EP_LEN + 1] = {0};
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
snprintf(epBuf, tListLen(epBuf), "%s:%u", pDesc->fqdn, pConn->port);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pQuery->subPlanNum, false);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, epBuf, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
char subStatus[TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
*(bool *)pWrite = pDesc->stableQuery;
|
int32_t strSize = sizeof(subStatus);
|
||||||
cols++;
|
int32_t offset = VARSTR_HEADER_SIZE;
|
||||||
|
for (int32_t i = 0; i < pQuery->subPlanNum && offset < strSize; ++i) {
|
||||||
|
if (i) {
|
||||||
|
offset += snprintf(subStatus + offset, strSize - offset - 1, ",");
|
||||||
|
}
|
||||||
|
SQuerySubDesc* pDesc = taosArrayGet(pQuery->subDesc, i);
|
||||||
|
offset += snprintf(subStatus + offset, strSize - offset - 1, "%" PRIu64 ":%s", pDesc->tid, pDesc->status);
|
||||||
|
}
|
||||||
|
varDataLen(subStatus) = strlen(&subStatus[VARSTR_HEADER_SIZE]);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, subStatus, false);
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
char sql[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
*(int32_t *)pWrite = htonl(pDesc->numOfSub);
|
STR_TO_VARSTR(sql, pQuery->sql);
|
||||||
cols++;
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)sql, false);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->subSqlInfo, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->sql, pShow->pMeta->pSchemas[cols].bytes);
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosRUnLockLatch(&pConn->queryLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
pShow->numOfRows += numOfRows;
|
pShow->numOfRows += numOfRows;
|
||||||
#endif
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
|
||||||
int32_t mndAddSinkToTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SStreamTask* pTask) {
|
int32_t mndAddSinkToTask(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream, SStreamTask* pTask) {
|
||||||
pTask->dispatchType = TASK_DISPATCH__NONE;
|
pTask->dispatchType = TASK_DISPATCH__NONE;
|
||||||
// sink
|
// sink
|
||||||
if (pStream->createdBy == STREAM_CREATED_BY__SMA) {
|
if (pStream->smaId != 0) {
|
||||||
pTask->sinkType = TASK_SINK__SMA;
|
pTask->sinkType = TASK_SINK__SMA;
|
||||||
pTask->smaSink.smaId = pStream->smaId;
|
pTask->smaSink.smaId = pStream->smaId;
|
||||||
} else {
|
} else {
|
||||||
|
@ -275,7 +275,7 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb
|
||||||
pTask->execType = TASK_EXEC__NONE;
|
pTask->execType = TASK_EXEC__NONE;
|
||||||
|
|
||||||
// sink
|
// sink
|
||||||
if (pStream->createdBy == STREAM_CREATED_BY__SMA) {
|
if (pStream->smaId != 0) {
|
||||||
pTask->sinkType = TASK_SINK__SMA;
|
pTask->sinkType = TASK_SINK__SMA;
|
||||||
pTask->smaSink.smaId = pStream->smaId;
|
pTask->smaSink.smaId = pStream->smaId;
|
||||||
} else {
|
} else {
|
||||||
|
@ -321,7 +321,7 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj*
|
||||||
pTask->execType = TASK_EXEC__NONE;
|
pTask->execType = TASK_EXEC__NONE;
|
||||||
|
|
||||||
// sink
|
// sink
|
||||||
if (pStream->createdBy == STREAM_CREATED_BY__SMA) {
|
if (pStream->smaId != 0) {
|
||||||
pTask->sinkType = TASK_SINK__SMA;
|
pTask->sinkType = TASK_SINK__SMA;
|
||||||
pTask->smaSink.smaId = pStream->smaId;
|
pTask->smaSink.smaId = pStream->smaId;
|
||||||
} else {
|
} else {
|
||||||
|
@ -346,8 +346,6 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ASSERT(pStream->vgNum == 0);
|
|
||||||
|
|
||||||
int32_t totLevel = LIST_LENGTH(pPlan->pSubplans);
|
int32_t totLevel = LIST_LENGTH(pPlan->pSubplans);
|
||||||
ASSERT(totLevel <= 2);
|
ASSERT(totLevel <= 2);
|
||||||
pStream->tasks = taosArrayInit(totLevel, sizeof(void*));
|
pStream->tasks = taosArrayInit(totLevel, sizeof(void*));
|
||||||
|
@ -399,7 +397,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
pFinalTask->execType = TASK_EXEC__PIPE;
|
pFinalTask->execType = TASK_EXEC__PIPE;
|
||||||
SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->dbUid);
|
SVgObj* pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid);
|
||||||
if (mndAssignTaskToVg(pMnode, pTrans, pFinalTask, plan, pVgroup) < 0) {
|
if (mndAssignTaskToVg(pMnode, pTrans, pFinalTask, plan, pVgroup) < 0) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
|
@ -420,7 +418,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SVgObj* pVgroup;
|
SVgObj* pVgroup;
|
||||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
if (pVgroup->dbUid != pStream->dbUid) {
|
if (pVgroup->dbUid != pStream->sourceDbUid) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +461,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SVgObj* pVgroup;
|
SVgObj* pVgroup;
|
||||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
if (pVgroup->dbUid != pStream->dbUid) {
|
if (pVgroup->dbUid != pStream->sourceDbUid) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndInfoSchema.h"
|
#include "mndInfoSchema.h"
|
||||||
#include "mndMnode.h"
|
#include "mndMnode.h"
|
||||||
|
#include "mndScheduler.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndStb.h"
|
#include "mndStb.h"
|
||||||
#include "mndStream.h"
|
#include "mndStream.h"
|
||||||
|
@ -520,6 +521,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
memcpy(smaObj.db, pDb->name, TSDB_DB_FNAME_LEN);
|
memcpy(smaObj.db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
smaObj.createdTime = taosGetTimestampMs();
|
smaObj.createdTime = taosGetTimestampMs();
|
||||||
smaObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
smaObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||||
|
ASSERT(smaObj.uid != 0);
|
||||||
char resultTbName[TSDB_TABLE_FNAME_LEN + 16] = {0};
|
char resultTbName[TSDB_TABLE_FNAME_LEN + 16] = {0};
|
||||||
snprintf(resultTbName, TSDB_TABLE_FNAME_LEN + 16, "td.tsma.rst.tb.%s", pCreate->name);
|
snprintf(resultTbName, TSDB_TABLE_FNAME_LEN + 16, "td.tsma.rst.tb.%s", pCreate->name);
|
||||||
memcpy(smaObj.dstTbName, resultTbName, TSDB_TABLE_FNAME_LEN);
|
memcpy(smaObj.dstTbName, resultTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -556,13 +558,13 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
streamObj.createTime = taosGetTimestampMs();
|
streamObj.createTime = taosGetTimestampMs();
|
||||||
streamObj.updateTime = streamObj.createTime;
|
streamObj.updateTime = streamObj.createTime;
|
||||||
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
||||||
streamObj.dbUid = pDb->uid;
|
streamObj.sourceDbUid = pDb->uid;
|
||||||
streamObj.version = 1;
|
streamObj.version = 1;
|
||||||
streamObj.sql = pCreate->sql;
|
streamObj.sql = pCreate->sql;
|
||||||
streamObj.createdBy = STREAM_CREATED_BY__SMA;
|
|
||||||
streamObj.smaId = smaObj.uid;
|
streamObj.smaId = smaObj.uid;
|
||||||
streamObj.watermark = 0;
|
streamObj.watermark = 0;
|
||||||
streamObj.trigger = STREAM_TRIGGER_AT_ONCE;
|
streamObj.trigger = STREAM_TRIGGER_AT_ONCE;
|
||||||
|
streamObj.ast = strdup(smaObj.ast);
|
||||||
|
|
||||||
if (mndAllocSmaVgroup(pMnode, pDb, &streamObj.fixedSinkVg) != 0) {
|
if (mndAllocSmaVgroup(pMnode, pDb, &streamObj.fixedSinkVg) != 0) {
|
||||||
mError("sma:%s, failed to create since %s", smaObj.name, terrstr());
|
mError("sma:%s, failed to create since %s", smaObj.name, terrstr());
|
||||||
|
@ -571,6 +573,39 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
smaObj.dstVgId = streamObj.fixedSinkVg.vgId;
|
smaObj.dstVgId = streamObj.fixedSinkVg.vgId;
|
||||||
streamObj.fixedSinkVgId = smaObj.dstVgId;
|
streamObj.fixedSinkVgId = smaObj.dstVgId;
|
||||||
|
|
||||||
|
SNode *pAst = NULL;
|
||||||
|
if (nodesStringToNode(streamObj.ast, &pAst) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract output schema from ast
|
||||||
|
if (qExtractResultSchema(pAst, (int32_t *)&streamObj.outputSchema.nCols, &streamObj.outputSchema.pSchema) != 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQueryPlan *pPlan = NULL;
|
||||||
|
SPlanContext cxt = {
|
||||||
|
.pAstRoot = pAst,
|
||||||
|
.topicQuery = false,
|
||||||
|
.streamQuery = true,
|
||||||
|
.triggerType = streamObj.trigger,
|
||||||
|
.watermark = streamObj.watermark,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save physcial plan
|
||||||
|
if (nodesNodeToString((SNode *)pPlan, false, &streamObj.physicalPlan, NULL) != 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (pAst != NULL) nodesDestroyNode(pAst);
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
@ -585,7 +620,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
||||||
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, pTrans) != 0) goto _OVER;
|
if (mndScheduleStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
||||||
|
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
#include "mndSma.h"
|
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define STB_VER_NUMBER 1
|
#define STB_VER_NUMBER 1
|
||||||
|
@ -1271,7 +1270,8 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp, int32_t *smaVer) {
|
static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp,
|
||||||
|
int32_t *smaVer) {
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName);
|
snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName);
|
||||||
|
|
||||||
|
@ -1284,7 +1284,7 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
|
||||||
SStbObj *pStb = mndAcquireStb(pMnode, tbFName);
|
SStbObj *pStb = mndAcquireStb(pMnode, tbFName);
|
||||||
if (pStb == NULL) {
|
if (pStb == NULL) {
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB;
|
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1681,7 +1681,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t
|
||||||
pStbVersion->smaVer = ntohl(pStbVersion->smaVer);
|
pStbVersion->smaVer = ntohl(pStbVersion->smaVer);
|
||||||
|
|
||||||
STableMetaRsp metaRsp = {0};
|
STableMetaRsp metaRsp = {0};
|
||||||
int32_t smaVer = 0;
|
int32_t smaVer = 0;
|
||||||
mDebug("stb:%s.%s, start to retrieve meta", pStbVersion->dbFName, pStbVersion->stbName);
|
mDebug("stb:%s.%s, start to retrieve meta", pStbVersion->dbFName, pStbVersion->stbName);
|
||||||
if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp, &smaVer) != 0) {
|
if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp, &smaVer) != 0) {
|
||||||
metaRsp.numOfColumns = -1;
|
metaRsp.numOfColumns = -1;
|
||||||
|
@ -1697,8 +1697,8 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStbVersion->smaVer && pStbVersion->smaVer != smaVer) {
|
if (pStbVersion->smaVer && pStbVersion->smaVer != smaVer) {
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
STableIndexRsp indexRsp = {0};
|
STableIndexRsp indexRsp = {0};
|
||||||
indexRsp.pIndex = taosArrayInit(10, sizeof(STableIndexInfo));
|
indexRsp.pIndex = taosArrayInit(10, sizeof(STableIndexInfo));
|
||||||
if (NULL == indexRsp.pIndex) {
|
if (NULL == indexRsp.pIndex) {
|
||||||
|
@ -1769,16 +1769,23 @@ int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndExtractTableName(char *tableId, char *name) {
|
void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst) {
|
||||||
|
SName name = {0};
|
||||||
|
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
||||||
|
tNameGetFullDbName(&name, dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize) {
|
||||||
int32_t pos = -1;
|
int32_t pos = -1;
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
for (pos = 0; tableId[pos] != 0; ++pos) {
|
for (pos = 0; stbFullName[pos] != 0; ++pos) {
|
||||||
if (tableId[pos] == TS_PATH_DELIMITER[0]) num++;
|
if (stbFullName[pos] == TS_PATH_DELIMITER[0]) num++;
|
||||||
if (num == 2) break;
|
if (num == 2) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 2) {
|
if (num == 2) {
|
||||||
strcpy(name, tableId + pos + 1);
|
tstrncpy(dst, stbFullName + pos + 1, dstSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1808,7 +1815,7 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
|
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
char stbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char stbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
mndExtractTableName(pStb->name, &stbName[VARSTR_HEADER_SIZE]);
|
mndExtractTbNameFromStbFullName(pStb->name, &stbName[VARSTR_HEADER_SIZE], TSDB_TABLE_NAME_LEN);
|
||||||
varDataSetLen(stbName, strlen(&stbName[VARSTR_HEADER_SIZE]));
|
varDataSetLen(stbName, strlen(&stbName[VARSTR_HEADER_SIZE]));
|
||||||
|
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
|
@ -196,7 +196,8 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
||||||
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0) {
|
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0 || pCreate->sourceDB[0] == 0 ||
|
||||||
|
pCreate->targetStbFullName[0] == 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -232,6 +233,114 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, SCMCreateStreamReq *pCreate) {
|
||||||
|
SNode *pAst = NULL;
|
||||||
|
|
||||||
|
mDebug("stream:%s to create", pCreate->name);
|
||||||
|
memcpy(pObj->name, pCreate->name, TSDB_STREAM_FNAME_LEN);
|
||||||
|
pObj->createTime = taosGetTimestampMs();
|
||||||
|
pObj->updateTime = pObj->createTime;
|
||||||
|
pObj->version = 1;
|
||||||
|
pObj->smaId = 0;
|
||||||
|
|
||||||
|
pObj->uid = mndGenerateUid(pObj->name, strlen(pObj->name));
|
||||||
|
pObj->status = 0;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
pObj->dropPolicy = 0;
|
||||||
|
pObj->trigger = pCreate->triggerType;
|
||||||
|
pObj->triggerParam = pCreate->maxDelay;
|
||||||
|
pObj->watermark = pCreate->watermark;
|
||||||
|
|
||||||
|
memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN);
|
||||||
|
SDbObj *pSourceDb = mndAcquireDb(pMnode, pCreate->sourceDB);
|
||||||
|
if (pSourceDb == NULL) {
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
mDebug("stream:%s failed to create, source db %s not exist", pCreate->name, pObj->sourceDb);
|
||||||
|
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pObj->sourceDbUid = pSourceDb->uid;
|
||||||
|
|
||||||
|
memcpy(pObj->targetSTbName, pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
|
SDbObj *pTargetDb = mndAcquireDbByStb(pMnode, pObj->targetSTbName);
|
||||||
|
if (pTargetDb == NULL) {
|
||||||
|
mDebug("stream:%s failed to create, target db %s not exist", pCreate->name, pObj->targetDb);
|
||||||
|
terrno = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tstrncpy(pObj->targetDb, pTargetDb->name, TSDB_DB_FNAME_LEN);
|
||||||
|
|
||||||
|
pObj->targetStbUid = mndGenerateUid(pObj->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
pObj->targetDbUid = pTargetDb->uid;
|
||||||
|
|
||||||
|
pObj->sql = pCreate->sql;
|
||||||
|
pObj->ast = pCreate->ast;
|
||||||
|
|
||||||
|
pCreate->sql = NULL;
|
||||||
|
pCreate->ast = NULL;
|
||||||
|
|
||||||
|
// deserialize ast
|
||||||
|
if (nodesStringToNode(pObj->ast, &pAst) < 0) {
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract output schema from ast
|
||||||
|
if (qExtractResultSchema(pAst, (int32_t *)&pObj->outputSchema.nCols, &pObj->outputSchema.pSchema) != 0) {
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQueryPlan *pPlan = NULL;
|
||||||
|
SPlanContext cxt = {
|
||||||
|
.pAstRoot = pAst,
|
||||||
|
.topicQuery = false,
|
||||||
|
.streamQuery = true,
|
||||||
|
.triggerType = pObj->trigger == STREAM_TRIGGER_MAX_DELAY ? STREAM_TRIGGER_WINDOW_CLOSE : pObj->trigger,
|
||||||
|
.watermark = pObj->watermark,
|
||||||
|
};
|
||||||
|
|
||||||
|
// using ast and param to build physical plan
|
||||||
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save physcial plan
|
||||||
|
if (nodesNodeToString((SNode *)pPlan, false, &pObj->physicalPlan, NULL) != 0) {
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
FAIL:
|
||||||
|
if (pAst != NULL) nodesDestroyNode(pAst);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream);
|
||||||
|
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
|
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream);
|
||||||
|
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
|
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans) {
|
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans) {
|
||||||
SNode *pAst = NULL;
|
SNode *pAst = NULL;
|
||||||
|
|
||||||
|
@ -278,8 +387,8 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
|
||||||
SMCreateStbReq createReq = {0};
|
SMCreateStbReq createReq = {0};
|
||||||
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -321,7 +430,6 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mndCheckDbAuth(pMnode, user, MND_OPER_WRITE_DB, pDb) != 0) {
|
if (mndCheckDbAuth(pMnode, user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -357,24 +465,24 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
|
||||||
ASSERT(pTask->nodeId != 0);
|
ASSERT(pTask->nodeId != 0);
|
||||||
|
|
||||||
// vnode
|
// vnode
|
||||||
if (pTask->nodeId > 0) {
|
/*if (pTask->nodeId > 0) {*/
|
||||||
SVDropStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVDropStreamTaskReq));
|
SVDropStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVDropStreamTaskReq));
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
pReq->head.vgId = htonl(pTask->nodeId);
|
|
||||||
pReq->taskId = pTask->taskId;
|
|
||||||
STransAction action = {0};
|
|
||||||
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
|
||||||
action.pCont = pReq;
|
|
||||||
action.contLen = sizeof(SVDropStreamTaskReq);
|
|
||||||
action.msgType = TDMT_VND_STREAM_TASK_DROP;
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
pReq->head.vgId = htonl(pTask->nodeId);
|
||||||
|
pReq->taskId = pTask->taskId;
|
||||||
|
STransAction action = {0};
|
||||||
|
memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet));
|
||||||
|
action.pCont = pReq;
|
||||||
|
action.contLen = sizeof(SVDropStreamTaskReq);
|
||||||
|
action.msgType = TDMT_VND_STREAM_TASK_DROP;
|
||||||
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/*}*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -404,10 +512,9 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
|
||||||
streamObj.updateTime = streamObj.createTime;
|
streamObj.updateTime = streamObj.createTime;
|
||||||
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
||||||
streamObj.targetStbUid = mndGenerateUid(pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
streamObj.targetStbUid = mndGenerateUid(pCreate->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
||||||
streamObj.dbUid = pDb->uid;
|
streamObj.sourceDbUid = pDb->uid;
|
||||||
streamObj.version = 1;
|
streamObj.version = 1;
|
||||||
streamObj.sql = pCreate->sql;
|
streamObj.sql = pCreate->sql;
|
||||||
streamObj.createdBy = STREAM_CREATED_BY__USER;
|
|
||||||
// TODO
|
// TODO
|
||||||
streamObj.fixedSinkVgId = 0;
|
streamObj.fixedSinkVgId = 0;
|
||||||
streamObj.smaId = 0;
|
streamObj.smaId = 0;
|
||||||
|
@ -487,7 +594,8 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check auth
|
// TODO check read auth for source and write auth for target
|
||||||
|
#if 0
|
||||||
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
|
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
|
@ -497,9 +605,60 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (pTrans == NULL) {
|
||||||
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
mndTransSetDbName(pTrans, createStreamReq.sourceDB);
|
||||||
|
// TODO
|
||||||
|
/*mndTransSetDbName(pTrans, streamObj.targetDb);*/
|
||||||
|
mDebug("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name);
|
||||||
|
|
||||||
|
// build stream obj from request
|
||||||
|
SStreamObj streamObj = {0};
|
||||||
|
if (mndBuildStreamObjFromCreateReq(pMnode, &streamObj, &createStreamReq) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create stb for stream
|
||||||
|
if (mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->conn.user) < 0) {
|
||||||
|
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createStreamReq.name, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// schedule stream task for stream obj
|
||||||
|
if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) {
|
||||||
|
mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add stream to trans
|
||||||
|
if (mndPersistStream(pMnode, pTrans, &streamObj) < 0) {
|
||||||
|
mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute creation
|
||||||
|
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||||
|
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
|
||||||
|
/*code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);*/
|
||||||
|
/*if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;*/
|
||||||
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
@ -520,13 +679,19 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
/*SDbObj *pDb = NULL;*/
|
/*SDbObj *pDb = NULL;*/
|
||||||
/*SUserObj *pUser = NULL;*/
|
/*SUserObj *pUser = NULL;*/
|
||||||
|
|
||||||
SMDropStreamTaskReq dropStreamReq = *(SMDropStreamTaskReq *)pReq->pCont;
|
SMDropStreamReq dropReq = *(SMDropStreamReq *)pReq->pCont;
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, dropStreamReq.name);
|
pStream = mndAcquireStream(pMnode, dropReq.name);
|
||||||
|
|
||||||
if (pStream == NULL) {
|
if (pStream == NULL) {
|
||||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
if (dropReq.igNotExists) {
|
||||||
return -1;
|
mDebug("stream:%s, not exist, ignore not exist is set", dropReq.name);
|
||||||
|
code = 0;
|
||||||
|
goto DROP_STREAM_OVER;
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -539,18 +704,62 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("stream:%s, failed to drop since %s", dropStreamReq.name, terrstr());
|
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropStreamReq.name);
|
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name);
|
||||||
|
|
||||||
// drop all tasks
|
// drop all tasks
|
||||||
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||||
mError("stream:%s, failed to drop task since %s", dropStreamReq.name, terrstr());
|
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop stream
|
||||||
|
if (mndPersistDropStreamLog(pMnode, pTrans, pStream) < 0) {
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DROP_STREAM_OVER:
|
DROP_STREAM_OVER:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
SStreamObj *pStream = NULL;
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (pStream->sourceDbUid == pDb->uid || pStream->targetDbUid == pDb->uid) {
|
||||||
|
if (pStream->sourceDbUid != pStream->targetDbUid) {
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
// TODO drop all task on snode
|
||||||
|
if (mndPersistDropStreamLog(pMnode, pTrans, pStream) < 0) {
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (mndSetDropOffsetStreamLogs(pMnode, pTrans, pStream) < 0) {
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +778,7 @@ static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfS
|
||||||
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
if (pStream->dbUid == pDb->uid) {
|
if (pStream->sourceDbUid == pDb->uid) {
|
||||||
numOfStreams++;
|
numOfStreams++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,14 +256,6 @@ void mndSyncStart(SMnode *pMnode) {
|
||||||
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
|
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
|
||||||
syncStart(pMgmt->sync);
|
syncStart(pMgmt->sync);
|
||||||
mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
||||||
|
|
||||||
/*
|
|
||||||
if (pMgmt->standby) {
|
|
||||||
syncStartStandBy(pMgmt->sync);
|
|
||||||
} else {
|
|
||||||
syncStart(pMgmt->sync);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndSyncStop(SMnode *pMnode) {}
|
void mndSyncStop(SMnode *pMnode) {}
|
||||||
|
|
|
@ -873,7 +873,8 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray)
|
||||||
pAction->rawWritten = 0;
|
pAction->rawWritten = 0;
|
||||||
pAction->msgSent = 0;
|
pAction->msgSent = 0;
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
if (pAction->errCode == TSDB_CODE_RPC_REDIRECT) {
|
if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NOT_IN_NEW_CONFIG ||
|
||||||
|
pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps;
|
pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps;
|
||||||
mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage),
|
mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage),
|
||||||
action, pAction->epSet.inUse);
|
action, pAction->epSet.inUse);
|
||||||
|
@ -1126,7 +1127,6 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
||||||
pTrans->code = terrno;
|
pTrans->code = terrno;
|
||||||
mError("trans:%d, %s:%d is executed and failed to sync to other mnodes since %s", pTrans->id,
|
mError("trans:%d, %s:%d is executed and failed to sync to other mnodes since %s", pTrans->id,
|
||||||
mndTransStr(pAction->stage), pAction->id, terrstr());
|
mndTransStr(pAction->stage), pAction->id, terrstr());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
} else if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mDebug("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
mDebug("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||||
|
@ -1134,8 +1134,6 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
||||||
} else {
|
} else {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
mError("trans:%d, %s:%d failed to execute since %s", pTrans->id, mndTransStr(pAction->stage), pAction->id,
|
|
||||||
terrstr());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) {
|
||||||
|
|
||||||
TEST_F(MndTestProfile, 03_ConnectMsg_Show) {
|
TEST_F(MndTestProfile, 03_ConnectMsg_Show) {
|
||||||
test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", "");
|
test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", "");
|
||||||
EXPECT_EQ(test.GetShowRows(), 0);
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestProfile, 04_HeartBeatMsg) {
|
TEST_F(MndTestProfile, 04_HeartBeatMsg) {
|
||||||
|
|
|
@ -300,108 +300,6 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
|
||||||
pMetaRsp->precision = pVnode->config.tsdbCfg.precision;
|
pMetaRsp->precision = pVnode->config.tsdbCfg.precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|
||||||
int32_t ret = 0;
|
|
||||||
|
|
||||||
if (syncEnvIsStart()) {
|
|
||||||
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
|
|
||||||
assert(pSyncNode != NULL);
|
|
||||||
|
|
||||||
ESyncState state = syncGetMyRole(pVnode->sync);
|
|
||||||
SyncTerm currentTerm = syncGetMyTerm(pVnode->sync);
|
|
||||||
|
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
|
||||||
|
|
||||||
char logBuf[512] = {0};
|
|
||||||
char *syncNodeStr = sync2SimpleStr(pVnode->sync);
|
|
||||||
snprintf(logBuf, sizeof(logBuf), "==vnodeProcessSyncReq== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr);
|
|
||||||
static int64_t vndTick = 0;
|
|
||||||
if (++vndTick % 10 == 1) {
|
|
||||||
vTrace("sync trace msg:%s, %s", TMSG_INFO(pMsg->msgType), syncNodeStr);
|
|
||||||
}
|
|
||||||
syncRpcMsgLog2(logBuf, pMsg);
|
|
||||||
taosMemoryFree(syncNodeStr);
|
|
||||||
|
|
||||||
SRpcMsg *pRpcMsg = pMsg;
|
|
||||||
|
|
||||||
if (pRpcMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
|
||||||
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnTimeoutCb(pSyncNode, pSyncMsg);
|
|
||||||
syncTimeoutDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING) {
|
|
||||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnPingCb(pSyncNode, pSyncMsg);
|
|
||||||
syncPingDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
|
||||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
|
|
||||||
syncPingReplyDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
|
||||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
|
|
||||||
syncClientRequestDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
|
||||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnRequestVoteCb(pSyncNode, pSyncMsg);
|
|
||||||
syncRequestVoteDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
|
||||||
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnRequestVoteReplyCb(pSyncNode, pSyncMsg);
|
|
||||||
syncRequestVoteReplyDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
|
||||||
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnAppendEntriesCb(pSyncNode, pSyncMsg);
|
|
||||||
syncAppendEntriesDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
|
||||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg);
|
|
||||||
assert(pSyncMsg != NULL);
|
|
||||||
|
|
||||||
ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
|
||||||
|
|
||||||
} else if (pRpcMsg->msgType == TDMT_SYNC_SET_VNODE_STANDBY) {
|
|
||||||
ret = syncSetStandby(pVnode->sync);
|
|
||||||
vInfo("vgId:%d, set standby result:0x%x rid:%" PRId64, pVnode->config.vgId, ret, pVnode->sync);
|
|
||||||
SRpcMsg rsp = {.code = ret, .info = pMsg->info};
|
|
||||||
tmsgSendRsp(&rsp);
|
|
||||||
} else {
|
|
||||||
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
syncNodeRelease(pSyncNode);
|
|
||||||
} else {
|
|
||||||
vError("==vnodeProcessSyncReq== error syncEnv stop");
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != 0) {
|
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVCreateStbReq req = {0};
|
SVCreateStbReq req = {0};
|
||||||
SDecoder coder;
|
SDecoder coder;
|
||||||
|
|
|
@ -50,6 +50,33 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, tmsg_t type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t vnodeSetStandBy(SVnode *pVnode) {
|
||||||
|
vInfo("vgId:%d, start to set standby", TD_VID(pVnode));
|
||||||
|
|
||||||
|
if (syncSetStandby(pVnode->sync) == 0) {
|
||||||
|
vInfo("vgId:%d, set standby success", TD_VID(pVnode));
|
||||||
|
return 0;
|
||||||
|
} else if (terrno != TSDB_CODE_SYN_IS_LEADER) {
|
||||||
|
vError("vgId:%d, failed to set standby since %s", TD_VID(pVnode), terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncLeaderTransfer(pVnode->sync) != 0) {
|
||||||
|
vError("vgId:%d, failed to transfer leader since:%s", TD_VID(pVnode), terrstr());
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
vInfo("vgId:%d, transfer leader success", TD_VID(pVnode));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncSetStandby(pVnode->sync) == 0) {
|
||||||
|
vInfo("vgId:%d, set standby success", TD_VID(pVnode));
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
vError("vgId:%d, failed to set standby since %s", TD_VID(pVnode), terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
SAlterVnodeReq req = {0};
|
SAlterVnodeReq req = {0};
|
||||||
if (tDeserializeSAlterVnodeReq((char *)pMsg->pCont + sizeof(SMsgHead), pMsg->contLen - sizeof(SMsgHead), &req) != 0) {
|
if (tDeserializeSAlterVnodeReq((char *)pMsg->pCont + sizeof(SMsgHead), pMsg->contLen - sizeof(SMsgHead), &req) != 0) {
|
||||||
|
@ -72,7 +99,22 @@ static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncPropose(pVnode->sync, &rpcMsg, false);
|
int32_t code = syncPropose(pVnode->sync, &rpcMsg, false);
|
||||||
|
if (code != 0) {
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
|
||||||
|
vInfo("vgId:%d, failed to propose reconfig msg since %s", TD_VID(pVnode), terrstr());
|
||||||
|
if (terrno == TSDB_CODE_SYN_IS_LEADER) {
|
||||||
|
if (syncLeaderTransfer(pVnode->sync) != 0) {
|
||||||
|
vError("vgId:%d, failed to transfer leader since %s", TD_VID(pVnode), terrstr());
|
||||||
|
} else {
|
||||||
|
vInfo("vgId:%d, transfer leader success", TD_VID(pVnode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
terrno = code;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
|
@ -98,7 +140,6 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
vnodeAccumBlockMsg(pVnode, pMsg->msgType);
|
vnodeAccumBlockMsg(pVnode, pMsg->msgType);
|
||||||
|
|
||||||
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
SEpSet newEpSet = {0};
|
SEpSet newEpSet = {0};
|
||||||
syncGetEpSet(pVnode->sync, &newEpSet);
|
syncGetEpSet(pVnode->sync, &newEpSet);
|
||||||
|
@ -160,6 +201,108 @@ void vnodeApplyMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
|
int32_t ret = 0;
|
||||||
|
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
|
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
|
||||||
|
assert(pSyncNode != NULL);
|
||||||
|
|
||||||
|
ESyncState state = syncGetMyRole(pVnode->sync);
|
||||||
|
SyncTerm currentTerm = syncGetMyTerm(pVnode->sync);
|
||||||
|
|
||||||
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
|
|
||||||
|
char logBuf[512] = {0};
|
||||||
|
char *syncNodeStr = sync2SimpleStr(pVnode->sync);
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "==vnodeProcessSyncReq== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr);
|
||||||
|
static int64_t vndTick = 0;
|
||||||
|
if (++vndTick % 10 == 1) {
|
||||||
|
vTrace("sync trace msg:%s, %s", TMSG_INFO(pMsg->msgType), syncNodeStr);
|
||||||
|
}
|
||||||
|
syncRpcMsgLog2(logBuf, pMsg);
|
||||||
|
taosMemoryFree(syncNodeStr);
|
||||||
|
|
||||||
|
SRpcMsg *pRpcMsg = pMsg;
|
||||||
|
|
||||||
|
if (pRpcMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||||
|
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnTimeoutCb(pSyncNode, pSyncMsg);
|
||||||
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_PING) {
|
||||||
|
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnPingCb(pSyncNode, pSyncMsg);
|
||||||
|
syncPingDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||||
|
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
|
||||||
|
syncPingReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||||
|
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
|
||||||
|
syncClientRequestDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||||
|
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnRequestVoteCb(pSyncNode, pSyncMsg);
|
||||||
|
syncRequestVoteDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
|
||||||
|
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnRequestVoteReplyCb(pSyncNode, pSyncMsg);
|
||||||
|
syncRequestVoteReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
|
||||||
|
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnAppendEntriesCb(pSyncNode, pSyncMsg);
|
||||||
|
syncAppendEntriesDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
|
||||||
|
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg);
|
||||||
|
assert(pSyncMsg != NULL);
|
||||||
|
|
||||||
|
ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||||
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_SET_VNODE_STANDBY) {
|
||||||
|
ret = vnodeSetStandBy(pVnode);
|
||||||
|
if (ret != 0 && terrno != 0) ret = terrno;
|
||||||
|
SRpcMsg rsp = {.code = ret, .info = pMsg->info};
|
||||||
|
tmsgSendRsp(&rsp);
|
||||||
|
} else {
|
||||||
|
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
syncNodeRelease(pSyncNode);
|
||||||
|
} else {
|
||||||
|
vError("==vnodeProcessSyncReq== error syncEnv stop");
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t vnodeSyncEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
static int32_t vnodeSyncEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||||
int32_t code = tmsgPutToQueue(msgcb, SYNC_QUEUE, pMsg);
|
int32_t code = tmsgPutToQueue(msgcb, SYNC_QUEUE, pMsg);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -248,17 +391,17 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { return 0; }
|
static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { return 0; }
|
||||||
|
|
||||||
int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { return 0; }
|
static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { return 0; }
|
||||||
|
|
||||||
int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) { return 0; }
|
static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) { return 0; }
|
||||||
|
|
||||||
int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) { return 0; }
|
static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) { return 0; }
|
||||||
|
|
||||||
int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { return 0; }
|
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { return 0; }
|
||||||
|
|
||||||
int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { return 0; }
|
static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { return 0; }
|
||||||
|
|
||||||
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
|
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
|
||||||
|
@ -269,7 +412,6 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
pFsm->FpGetSnapshot = vnodeSyncGetSnapshot;
|
pFsm->FpGetSnapshot = vnodeSyncGetSnapshot;
|
||||||
pFsm->FpRestoreFinishCb = NULL;
|
pFsm->FpRestoreFinishCb = NULL;
|
||||||
pFsm->FpReConfigCb = vnodeSyncReconfig;
|
pFsm->FpReConfigCb = vnodeSyncReconfig;
|
||||||
|
|
||||||
pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead;
|
pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead;
|
||||||
pFsm->FpSnapshotStopRead = vnodeSnapshotStopRead;
|
pFsm->FpSnapshotStopRead = vnodeSnapshotStopRead;
|
||||||
pFsm->FpSnapshotDoRead = vnodeSnapshotDoRead;
|
pFsm->FpSnapshotDoRead = vnodeSnapshotDoRead;
|
||||||
|
@ -282,7 +424,6 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
|
|
||||||
int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
||||||
SSyncInfo syncInfo = {
|
SSyncInfo syncInfo = {
|
||||||
.isStandBy = false,
|
|
||||||
.snapshotEnable = false,
|
.snapshotEnable = false,
|
||||||
.vgId = pVnode->config.vgId,
|
.vgId = pVnode->config.vgId,
|
||||||
.isStandBy = pVnode->config.standby,
|
.isStandBy = pVnode->config.standby,
|
||||||
|
@ -311,13 +452,6 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
||||||
void vnodeSyncStart(SVnode *pVnode) {
|
void vnodeSyncStart(SVnode *pVnode) {
|
||||||
syncSetMsgCb(pVnode->sync, &pVnode->msgCb);
|
syncSetMsgCb(pVnode->sync, &pVnode->msgCb);
|
||||||
syncStart(pVnode->sync);
|
syncStart(pVnode->sync);
|
||||||
/*
|
|
||||||
if (pVnode->config.standby) {
|
|
||||||
syncStartStandBy(pVnode->sync);
|
|
||||||
} else {
|
|
||||||
syncStart(pVnode->sync);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); }
|
void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); }
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
* 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 "tref.h"
|
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
@ -21,6 +20,7 @@
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "tfill.h"
|
#include "tfill.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
#include "tref.h"
|
||||||
|
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -76,7 +76,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
||||||
#define realloc u_realloc
|
#define realloc u_realloc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
|
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
|
||||||
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
|
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
|
||||||
|
|
||||||
int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; }
|
int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; }
|
||||||
|
@ -2305,7 +2305,7 @@ typedef struct SFetchRspHandleWrapper {
|
||||||
} SFetchRspHandleWrapper;
|
} SFetchRspHandleWrapper;
|
||||||
|
|
||||||
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*) param;
|
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param;
|
||||||
|
|
||||||
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
if (pExchangeInfo == NULL) {
|
if (pExchangeInfo == NULL) {
|
||||||
|
@ -2313,7 +2313,7 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t index = pWrapper->sourceIndex;
|
int32_t index = pWrapper->sourceIndex;
|
||||||
SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index);
|
SSourceDataInfo* pSourceDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, index);
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -2321,9 +2321,9 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code)
|
||||||
|
|
||||||
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
||||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||||
pRsp->compLen = htonl(pRsp->compLen);
|
pRsp->compLen = htonl(pRsp->compLen);
|
||||||
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
||||||
pRsp->useconds = htobe64(pRsp->useconds);
|
pRsp->useconds = htobe64(pRsp->useconds);
|
||||||
|
|
||||||
ASSERT(pRsp != NULL);
|
ASSERT(pRsp != NULL);
|
||||||
qDebug("%s fetch rsp received, index:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfRows);
|
qDebug("%s fetch rsp received, index:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfRows);
|
||||||
|
@ -2385,9 +2385,9 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
||||||
|
|
||||||
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
pMsg->header.vgId = htonl(pSource->addr.nodeId);
|
||||||
pMsg->sId = htobe64(pSource->schedId);
|
pMsg->sId = htobe64(pSource->schedId);
|
||||||
pMsg->taskId = htobe64(pSource->taskId);
|
pMsg->taskId = htobe64(pSource->taskId);
|
||||||
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
pMsg->queryId = htobe64(pTaskInfo->id.queryId);
|
||||||
|
|
||||||
// send the fetch remote task result reques
|
// send the fetch remote task result reques
|
||||||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
@ -2399,14 +2399,14 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
}
|
}
|
||||||
|
|
||||||
SFetchRspHandleWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SFetchRspHandleWrapper));
|
SFetchRspHandleWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SFetchRspHandleWrapper));
|
||||||
pWrapper->exchangeId = pExchangeInfo->self;
|
pWrapper->exchangeId = pExchangeInfo->self;
|
||||||
pWrapper->sourceIndex = sourceIndex;
|
pWrapper->sourceIndex = sourceIndex;
|
||||||
|
|
||||||
pMsgSendInfo->param = pWrapper;
|
pMsgSendInfo->param = pWrapper;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||||
pMsgSendInfo->msgType = TDMT_VND_FETCH;
|
pMsgSendInfo->msgType = TDMT_VND_FETCH;
|
||||||
pMsgSendInfo->fp = loadRemoteDataCallback;
|
pMsgSendInfo->fp = loadRemoteDataCallback;
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
int32_t code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
|
int32_t code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
|
||||||
|
@ -2555,7 +2555,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo;
|
||||||
if (pRsp->numOfRows == 0) {
|
if (pRsp->numOfRows == 0) {
|
||||||
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
qDebug("%s vgId:%d, taskId:0x%" PRIx64 " index:%d completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||||
", completed:%d try next %d/%"PRIzu,
|
", completed:%d try next %d/%" PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pDataInfo->totalRows,
|
||||||
pExchangeInfo->loadInfo.totalRows, completed + 1, i + 1, totalSources);
|
pExchangeInfo->loadInfo.totalRows, completed + 1, i + 1, totalSources);
|
||||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||||
|
@ -2573,8 +2573,9 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->completed == 1) {
|
if (pRsp->completed == 1) {
|
||||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " index:%d completed, numOfRows:%d, rowsOfSource:%" PRIu64
|
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
||||||
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 ", completed:%d try next %d/%" PRIzu,
|
" index:%d completed, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64
|
||||||
|
", completed:%d try next %d/%" PRIzu,
|
||||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pRes->info.rows, pDataInfo->totalRows,
|
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i, pRes->info.rows, pDataInfo->totalRows,
|
||||||
pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources);
|
pLoadInfo->totalRows, pLoadInfo->totalSize, completed + 1, i + 1, totalSources);
|
||||||
completed += 1;
|
completed += 1;
|
||||||
|
@ -2628,7 +2629,7 @@ static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
int64_t endTs = taosGetTimestampUs();
|
int64_t endTs = taosGetTimestampUs();
|
||||||
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%.2fms", GET_TASKID(pTaskInfo),
|
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%.2fms", GET_TASKID(pTaskInfo),
|
||||||
totalSources, (endTs - startTs)/1000.0);
|
totalSources, (endTs - startTs) / 1000.0);
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
||||||
|
@ -2759,8 +2760,8 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const
|
||||||
SSourceDataInfo dataInfo = {0};
|
SSourceDataInfo dataInfo = {0};
|
||||||
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
dataInfo.status = EX_SOURCE_DATA_NOT_READY;
|
||||||
dataInfo.taskId = id;
|
dataInfo.taskId = id;
|
||||||
dataInfo.index = i;
|
dataInfo.index = i;
|
||||||
SSourceDataInfo *pDs = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
SSourceDataInfo* pDs = taosArrayPush(pInfo->pSourceDataInfo, &dataInfo);
|
||||||
if (pDs == NULL) {
|
if (pDs == NULL) {
|
||||||
taosArrayDestroy(pInfo->pSourceDataInfo);
|
taosArrayDestroy(pInfo->pSourceDataInfo);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -2774,7 +2775,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
|
||||||
size_t numOfSources = LIST_LENGTH(pExNode->pSrcEndPoints);
|
size_t numOfSources = LIST_LENGTH(pExNode->pSrcEndPoints);
|
||||||
|
|
||||||
if (numOfSources == 0) {
|
if (numOfSources == 0) {
|
||||||
qError("%s invalid number: %d of sources in exchange operator", id, (int32_t) numOfSources);
|
qError("%s invalid number: %d of sources in exchange operator", id, (int32_t)numOfSources);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2808,16 +2809,16 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
|
||||||
|
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
|
||||||
pInfo->seqLoadData = false;
|
pInfo->seqLoadData = false;
|
||||||
pInfo->pTransporter = pTransporter;
|
pInfo->pTransporter = pTransporter;
|
||||||
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
||||||
pOperator->name = "ExchangeOperator";
|
pOperator->name = "ExchangeOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE;
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfExprs = pInfo->pResult->info.numOfCols;
|
pOperator->numOfExprs = pInfo->pResult->info.numOfCols;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
||||||
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
||||||
|
@ -3935,7 +3936,7 @@ void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void doDestroyExchangeOperatorInfo(void* param) {
|
void doDestroyExchangeOperatorInfo(void* param) {
|
||||||
SExchangeInfo* pExInfo = (SExchangeInfo*) param;
|
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
||||||
|
|
||||||
taosArrayDestroy(pExInfo->pSources);
|
taosArrayDestroy(pExInfo->pSources);
|
||||||
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
||||||
|
@ -4422,8 +4423,8 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey){
|
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey) {
|
||||||
if(groupKey == NULL) {
|
if (groupKey == NULL) {
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4432,11 +4433,11 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
int32_t keyLen = 0;
|
int32_t keyLen = 0;
|
||||||
void *keyBuf = NULL;
|
void* keyBuf = NULL;
|
||||||
int32_t numOfGroupCols = taosArrayGetSize(groupKey);
|
int32_t numOfGroupCols = taosArrayGetSize(groupKey);
|
||||||
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
||||||
SColumn* pCol = taosArrayGet(groupKey, j);
|
SColumn* pCol = taosArrayGet(groupKey, j);
|
||||||
keyLen += pCol->bytes; // actual data + null_flag
|
keyLen += pCol->bytes; // actual data + null_flag
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols;
|
int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols;
|
||||||
|
@ -4447,9 +4448,9 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++){
|
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) {
|
||||||
STableKeyInfo *info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderInit(&mr, pHandle->meta, 0);
|
metaReaderInit(&mr, pHandle->meta, 0);
|
||||||
metaGetTableEntryByUid(&mr, info->uid);
|
metaGetTableEntryByUid(&mr, info->uid);
|
||||||
|
|
||||||
|
@ -4458,23 +4459,23 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
||||||
SColumn* pCol = taosArrayGet(groupKey, j);
|
SColumn* pCol = taosArrayGet(groupKey, j);
|
||||||
|
|
||||||
if(strcmp(pCol->name, "tbname") == 0){
|
if (strcmp(pCol->name, "tbname") == 0) {
|
||||||
isNull[i] = 0;
|
isNull[i] = 0;
|
||||||
memcpy(pStart, mr.me.name, strlen(mr.me.name));
|
memcpy(pStart, mr.me.name, strlen(mr.me.name));
|
||||||
pStart += strlen(mr.me.name);
|
pStart += strlen(mr.me.name);
|
||||||
}else{
|
} else {
|
||||||
STagVal tagVal = {0};
|
STagVal tagVal = {0};
|
||||||
tagVal.cid = pCol->colId;
|
tagVal.cid = pCol->colId;
|
||||||
const char* p = metaGetTableTagVal(&mr.me, pCol->type, &tagVal);
|
const char* p = metaGetTableTagVal(&mr.me, pCol->type, &tagVal);
|
||||||
if(p == NULL){
|
if (p == NULL) {
|
||||||
isNull[j] = 1;
|
isNull[j] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
isNull[i] = 0;
|
isNull[i] = 0;
|
||||||
if (pCol->type == TSDB_DATA_TYPE_JSON) {
|
if (pCol->type == TSDB_DATA_TYPE_JSON) {
|
||||||
// int32_t dataLen = getJsonValueLen(pkey->pData);
|
// int32_t dataLen = getJsonValueLen(pkey->pData);
|
||||||
// memcpy(pStart, (pkey->pData), dataLen);
|
// memcpy(pStart, (pkey->pData), dataLen);
|
||||||
// pStart += dataLen;
|
// pStart += dataLen;
|
||||||
} else if (IS_VAR_DATA_TYPE(pCol->type)) {
|
} else if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
memcpy(pStart, tagVal.pData, tagVal.nData);
|
memcpy(pStart, tagVal.pData, tagVal.nData);
|
||||||
pStart += tagVal.nData;
|
pStart += tagVal.nData;
|
||||||
|
@ -4486,7 +4487,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = (int32_t) (pStart - (char*)keyBuf);
|
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
||||||
uint64_t* groupId = taosHashGet(pTableListInfo->map, keyBuf, len);
|
uint64_t* groupId = taosHashGet(pTableListInfo->map, keyBuf, len);
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), groupId, sizeof(uint64_t));
|
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), groupId, sizeof(uint64_t));
|
||||||
|
@ -4523,7 +4524,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags);
|
||||||
code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
||||||
taosArrayDestroy(groupKeys);
|
taosArrayDestroy(groupKeys);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -4532,7 +4533,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -4542,11 +4543,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SArray* dataReaders = taosArrayInit(8, POINTER_BYTES);
|
SArray* dataReaders = taosArrayInit(8, POINTER_BYTES);
|
||||||
createMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId, pTagCond);
|
createMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId, pTagCond);
|
||||||
extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags);
|
||||||
generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json
|
generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
||||||
taosArrayDestroy(groupKeys);
|
taosArrayDestroy(groupKeys);
|
||||||
SOperatorInfo* pOperator =
|
SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, dataReaders, pHandle, pTaskInfo);
|
||||||
createTableMergeScanOperatorInfo(pTableScanNode, dataReaders, pHandle, pTaskInfo);
|
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -4571,16 +4571,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
|
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags);
|
||||||
int32_t code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json
|
int32_t code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json
|
||||||
taosArrayDestroy(groupKeys);
|
taosArrayDestroy(groupKeys);
|
||||||
if (code){
|
if (code) {
|
||||||
tsdbCleanupReadHandle(pDataReader);
|
tsdbCleanupReadHandle(pDataReader);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* pOperator =
|
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup);
|
||||||
createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup);
|
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||||
|
@ -4589,7 +4588,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
||||||
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode;
|
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
int32_t code = getTableList(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableListInfo, pScanPhyNode->node.pConditions);
|
int32_t code = getTableList(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableListInfo,
|
||||||
|
pScanPhyNode->node.pConditions);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -4667,7 +4667,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, &as, pTaskInfo, isStream);
|
createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, &as, pTaskInfo, isStream);
|
||||||
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL == type) {
|
||||||
SMergeIntervalPhysiNode * pIntervalPhyNode = (SMergeIntervalPhysiNode*)pPhyNode;
|
SMergeIntervalPhysiNode* pIntervalPhyNode = (SMergeIntervalPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
|
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||||
|
@ -5008,7 +5008,7 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa
|
||||||
|
|
||||||
SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
||||||
code = doFilterTag(pTagCond, &metaArg, res);
|
code = doFilterTag(pTagCond, &metaArg, res);
|
||||||
if (code == TSDB_CODE_INDEX_REBUILDING){ // todo
|
if (code == TSDB_CODE_INDEX_REBUILDING) { // todo
|
||||||
// doFilter();
|
// doFilter();
|
||||||
} else if (code != TSDB_CODE_SUCCESS) {
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid);
|
qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid);
|
||||||
|
@ -5369,4 +5369,3 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlF
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -468,8 +468,8 @@ int32_t udfdConnectToMnode() {
|
||||||
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
||||||
taosEncryptPass_c((uint8_t *)(TSDB_DEFAULT_PASS), strlen(TSDB_DEFAULT_PASS), pass);
|
taosEncryptPass_c((uint8_t *)(TSDB_DEFAULT_PASS), strlen(TSDB_DEFAULT_PASS), pass);
|
||||||
tstrncpy(connReq.passwd, pass, sizeof(connReq.passwd));
|
tstrncpy(connReq.passwd, pass, sizeof(connReq.passwd));
|
||||||
connReq.pid = htonl(taosGetPId());
|
connReq.pid = taosGetPId();
|
||||||
connReq.startTime = htobe64(taosGetTimestampMs());
|
connReq.startTime = taosGetTimestampMs();
|
||||||
|
|
||||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connReq);
|
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connReq);
|
||||||
void * pReq = rpcMallocCont(contLen);
|
void * pReq = rpcMallocCont(contLen);
|
||||||
|
|
|
@ -355,6 +355,7 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(tsColId);
|
COPY_SCALAR_FIELD(tsColId);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(filesFactor);
|
||||||
|
CLONE_NODE_LIST_FIELD(pPartTags);
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +496,7 @@ static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhys
|
||||||
COPY_SCALAR_FIELD(ratio);
|
COPY_SCALAR_FIELD(ratio);
|
||||||
COPY_SCALAR_FIELD(dataRequired);
|
COPY_SCALAR_FIELD(dataRequired);
|
||||||
CLONE_NODE_LIST_FIELD(pDynamicScanFuncs);
|
CLONE_NODE_LIST_FIELD(pDynamicScanFuncs);
|
||||||
CLONE_NODE_LIST_FIELD(pPartitionKeys);
|
CLONE_NODE_LIST_FIELD(pPartitionTags);
|
||||||
COPY_SCALAR_FIELD(interval);
|
COPY_SCALAR_FIELD(interval);
|
||||||
COPY_SCALAR_FIELD(offset);
|
COPY_SCALAR_FIELD(offset);
|
||||||
COPY_SCALAR_FIELD(sliding);
|
COPY_SCALAR_FIELD(sliding);
|
||||||
|
|
|
@ -515,6 +515,7 @@ static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
|
||||||
static const char* jkScanLogicPlanTableId = "TableId";
|
static const char* jkScanLogicPlanTableId = "TableId";
|
||||||
static const char* jkScanLogicPlanTableType = "TableType";
|
static const char* jkScanLogicPlanTableType = "TableType";
|
||||||
static const char* jkScanLogicPlanTagCond = "TagCond";
|
static const char* jkScanLogicPlanTagCond = "TagCond";
|
||||||
|
static const char* jkScanLogicPlanPartTags = "PartTags";
|
||||||
|
|
||||||
static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SScanLogicNode* pNode = (const SScanLogicNode*)pObj;
|
const SScanLogicNode* pNode = (const SScanLogicNode*)pObj;
|
||||||
|
@ -535,6 +536,9 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond);
|
code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodeListToJson(pJson, jkScanLogicPlanPartTags, pNode->pPartTags);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -559,6 +563,9 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond);
|
code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkScanLogicPlanPartTags, &pNode->pPartTags);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1368,6 +1375,7 @@ static const char* jkTableScanPhysiPlanTriggerType = "triggerType";
|
||||||
static const char* jkTableScanPhysiPlanWatermark = "watermark";
|
static const char* jkTableScanPhysiPlanWatermark = "watermark";
|
||||||
static const char* jkTableScanPhysiPlanTsColId = "tsColId";
|
static const char* jkTableScanPhysiPlanTsColId = "tsColId";
|
||||||
static const char* jkTableScanPhysiPlanFilesFactor = "FilesFactor";
|
static const char* jkTableScanPhysiPlanFilesFactor = "FilesFactor";
|
||||||
|
static const char* jkTableScanPhysiPlanPartitionTags = "PartitionTags";
|
||||||
|
|
||||||
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
||||||
|
@ -1421,6 +1429,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddDoubleToObject(pJson, jkTableScanPhysiPlanFilesFactor, pNode->filesFactor);
|
code = tjsonAddDoubleToObject(pJson, jkTableScanPhysiPlanFilesFactor, pNode->filesFactor);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodeListToJson(pJson, jkTableScanPhysiPlanPartitionTags, pNode->pPartitionTags);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1446,30 +1457,24 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanTriggerType, pNode->triggerType, code);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanTriggerType, pNode->triggerType, code);
|
||||||
|
@ -1483,6 +1488,10 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanFilesFactor, &pNode->filesFactor);
|
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanFilesFactor, &pNode->filesFactor);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanPartitionTags, &pNode->pPartitionTags);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||||
case QUERY_NODE_SHOW_CONFIGS_STMT:
|
case QUERY_NODE_SHOW_CONFIGS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_APPS_STMT:
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
|
|
|
@ -377,6 +377,16 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONNECTIONS,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowQueries(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_QUERIES,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowTransactions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowTransactions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS,
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
@ -447,6 +457,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
|
return collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
|
return collectMetaKeyFromShowQueries(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
return collectMetaKeyFromShowTransactions(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowTransactions(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
|
|
|
@ -42,6 +42,7 @@ typedef struct STranslateContext {
|
||||||
SExplainOptions* pExplainOpt;
|
SExplainOptions* pExplainOpt;
|
||||||
SParseMetaCache* pMetaCache;
|
SParseMetaCache* pMetaCache;
|
||||||
bool createStream;
|
bool createStream;
|
||||||
|
bool stableQuery;
|
||||||
} STranslateContext;
|
} STranslateContext;
|
||||||
|
|
||||||
typedef struct SFullDatabaseName {
|
typedef struct SFullDatabaseName {
|
||||||
|
@ -1508,6 +1509,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addNamespace(pCxt, pRealTable);
|
code = addNamespace(pCxt, pRealTable);
|
||||||
}
|
}
|
||||||
|
if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) {
|
||||||
|
pCxt->stableQuery = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_TEMP_TABLE: {
|
case QUERY_NODE_TEMP_TABLE: {
|
||||||
|
@ -4805,6 +4809,7 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl
|
||||||
|
|
||||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code && pClause->ignoreNotExists) {
|
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code && pClause->ignoreNotExists) {
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
goto over;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pIsSuperTable = false;
|
*pIsSuperTable = false;
|
||||||
|
@ -4898,7 +4903,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSuperTable) {
|
if (isSuperTable || 0 == taosHashGetSize(pVgroupHashmap)) {
|
||||||
taosHashCleanup(pVgroupHashmap);
|
taosHashCleanup(pVgroupHashmap);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -5343,6 +5348,8 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pQuery->stableQuery = pCxt->stableQuery;
|
||||||
|
|
||||||
if (pQuery->haveResultSet) {
|
if (pQuery->haveResultSet) {
|
||||||
if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) {
|
if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -109,9 +109,8 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent) ||
|
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent) ||
|
||||||
(QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode->pParent) &&
|
(QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode->pParent) && pNode->pParent->pParent &&
|
||||||
pNode->pParent->pParent &&
|
QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent->pParent))) {
|
||||||
QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent->pParent)) ) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !osdHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys);
|
return !osdHaveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys);
|
||||||
|
@ -222,9 +221,8 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) {
|
||||||
|
|
||||||
static void setScanWindowInfo(SScanLogicNode* pScan) {
|
static void setScanWindowInfo(SScanLogicNode* pScan) {
|
||||||
SLogicNode* pParent = pScan->node.pParent;
|
SLogicNode* pParent = pScan->node.pParent;
|
||||||
if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pParent) &&
|
if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pParent) && pParent->pParent &&
|
||||||
pParent->pParent &&
|
QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pParent->pParent)) {
|
||||||
QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pParent->pParent)) {
|
|
||||||
pParent = pParent->pParent;
|
pParent = pParent->pParent;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pParent)) {
|
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pParent)) {
|
||||||
|
@ -1041,12 +1039,55 @@ static int32_t smaOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan)
|
||||||
return smaOptimizeImpl(pCxt, pLogicSubplan, pScan);
|
return smaOptimizeImpl(pCxt, pLogicSubplan, pScan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) {
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
|
if (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType) {
|
||||||
|
*(bool*)pContext = true;
|
||||||
|
return DEAL_RES_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool partTagsOptHasCol(SNodeList* pPartKeys) {
|
||||||
|
bool hasCol = false;
|
||||||
|
nodesWalkExprs(pPartKeys, partTagsOptHasColImpl, &hasCol);
|
||||||
|
return hasCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
|
if (QUERY_NODE_LOGIC_PLAN_PARTITION != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) ||
|
||||||
|
QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !partTagsOptHasCol(((SPartitionLogicNode*)pNode)->pPartitionKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
|
||||||
|
SPartitionLogicNode* pPart =
|
||||||
|
(SPartitionLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, partTagsOptMayBeOptimized);
|
||||||
|
if (NULL == pPart) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pPart->node.pChildren, 0);
|
||||||
|
TSWAP(pPart->pPartitionKeys, pScan->pPartTags);
|
||||||
|
int32_t code = replaceLogicNode(pLogicSubplan, (SLogicNode*)pPart, (SLogicNode*)pScan);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
NODES_CLEAR_LIST(pPart->node.pChildren);
|
||||||
|
nodesDestroyNode((SNode*)pPart);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const SOptimizeRule optimizeRuleSet[] = {
|
static const SOptimizeRule optimizeRuleSet[] = {
|
||||||
{.pName = "OptimizeScanData", .optimizeFunc = osdOptimize},
|
{.pName = "OptimizeScanData", .optimizeFunc = osdOptimize},
|
||||||
{.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize},
|
{.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize},
|
||||||
{.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize},
|
{.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize},
|
||||||
{.pName = "SmaIndex", .optimizeFunc = smaOptimize}
|
{.pName = "SmaIndex", .optimizeFunc = smaOptimize},
|
||||||
|
{.pName = "PartitionByTags", .optimizeFunc = partTagsOptimize}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -500,7 +500,9 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName);
|
tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName);
|
||||||
pTableScan->dataRequired = pScanLogicNode->dataRequired;
|
pTableScan->dataRequired = pScanLogicNode->dataRequired;
|
||||||
pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs);
|
pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs);
|
||||||
if (NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) {
|
pTableScan->pPartitionTags = nodesCloneList(pScanLogicNode->pPartTags);
|
||||||
|
if ((NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) ||
|
||||||
|
(NULL != pScanLogicNode->pPartTags && NULL == pTableScan->pPartitionTags)) {
|
||||||
nodesDestroyNode((SNode*)pTableScan);
|
nodesDestroyNode((SNode*)pTableScan);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,9 @@ int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) {
|
||||||
|
|
||||||
for (int32_t m = 0; m < pLevel->taskNum; ++m) {
|
for (int32_t m = 0; m < pLevel->taskNum; ++m) {
|
||||||
SSchTask *pTask = taosArrayGet(pLevel->subTasks, m);
|
SSchTask *pTask = taosArrayGet(pLevel->subTasks, m);
|
||||||
SQuerySubDesc subDesc = {.tid = pTask->taskId, .status = pTask->status};
|
SQuerySubDesc subDesc = {0};
|
||||||
|
subDesc.tid = pTask->taskId;
|
||||||
|
strcpy(subDesc.status, jobTaskStatusStr(pTask->status));
|
||||||
|
|
||||||
taosArrayPush(pSub, &subDesc);
|
taosArrayPush(pSub, &subDesc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ int32_t syncSetStandby(int64_t rid) {
|
||||||
|
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_IS_LEADER;
|
||||||
sError("failed to set standby since it is leader, rid:%" PRId64, rid);
|
sError("failed to set standby since it is leader, rid:%" PRId64, rid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,9 +324,9 @@ void cliHandleResp(SCliConn* conn) {
|
||||||
tDebug("%s cli conn %p ref by app", CONN_GET_INST_LABEL(conn), conn);
|
tDebug("%s cli conn %p ref by app", CONN_GET_INST_LABEL(conn), conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn,
|
tDebug("%s cli conn %p %s received from %s:%d, local info:%s:%d, msg size:%d code:0x%x", pTransInst->label, conn,
|
||||||
TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port),
|
TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port),
|
||||||
taosInetNtoa(conn->localAddr.sin_addr), ntohs(conn->localAddr.sin_port), transMsg.contLen);
|
taosInetNtoa(conn->localAddr.sin_addr), ntohs(conn->localAddr.sin_port), transMsg.contLen, transMsg.code);
|
||||||
|
|
||||||
if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) {
|
if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) {
|
||||||
tTrace("except, server continue send while cli ignore it");
|
tTrace("except, server continue send while cli ignore it");
|
||||||
|
|
|
@ -285,13 +285,14 @@ static void uvHandleReq(SSvrConn* pConn) {
|
||||||
}
|
}
|
||||||
if (pConn->status == ConnNormal && pHead->noResp == 0) {
|
if (pConn->status == ConnNormal && pHead->noResp == 0) {
|
||||||
transRefSrvHandle(pConn);
|
transRefSrvHandle(pConn);
|
||||||
tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType),
|
tDebug("server conn %p %s received from %s:%d, local info:%s:%d, msg size:%d code:0x%x", pConn,
|
||||||
taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr),
|
|
||||||
ntohs(pConn->localAddr.sin_port), transMsg.contLen);
|
|
||||||
} else {
|
|
||||||
tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d ", pConn,
|
|
||||||
TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
|
TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
|
||||||
taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, pHead->noResp);
|
taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, transMsg.code);
|
||||||
|
} else {
|
||||||
|
tDebug("server conn %p %s received from %s:%d, local info:%s:%d, msg size:%d, resp:%d code:0x%x", pConn,
|
||||||
|
TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
|
||||||
|
taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, pHead->noResp,
|
||||||
|
transMsg.code);
|
||||||
// no ref here
|
// no ref here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -931,10 +931,6 @@ bool taosCacheIterNext(SCacheIter *pIter) {
|
||||||
SCacheObj *pCacheObj = pIter->pCacheObj;
|
SCacheObj *pCacheObj = pIter->pCacheObj;
|
||||||
|
|
||||||
if (pIter->index + 1 >= pIter->numOfObj) {
|
if (pIter->index + 1 >= pIter->numOfObj) {
|
||||||
if (pIter->entryIndex + 1 >= pCacheObj->capacity) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// release the reference for all objects in the snapshot
|
// release the reference for all objects in the snapshot
|
||||||
for (int32_t i = 0; i < pIter->numOfObj; ++i) {
|
for (int32_t i = 0; i < pIter->numOfObj; ++i) {
|
||||||
char *p = pIter->pCurrent[i]->data;
|
char *p = pIter->pCurrent[i]->data;
|
||||||
|
@ -942,6 +938,10 @@ bool taosCacheIterNext(SCacheIter *pIter) {
|
||||||
pIter->pCurrent[i] = NULL;
|
pIter->pCurrent[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pIter->entryIndex + 1 >= pCacheObj->capacity) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter->entryIndex++;
|
pIter->entryIndex++;
|
||||||
if (pIter->entryIndex >= pCacheObj->capacity) {
|
if (pIter->entryIndex >= pCacheObj->capacity) {
|
||||||
|
|
|
@ -412,7 +412,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_MISMATCHED_SIGNATURE, "Mismatched signature"
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CHECKSUM, "Invalid msg checksum")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CHECKSUM, "Invalid msg checksum")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGLEN, "Invalid msg length")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGLEN, "Invalid msg length")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGTYPE, "Invalid msg type")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGTYPE, "Invalid msg type")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_IS_LEADER, "Sync is leader")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_LEADER, "Sync not leader")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_LEADER, "Sync not leader")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_ONE_REPLICA, "Sync one replica")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_ONE_REPLICA, "Sync one replica")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_IN_NEW_CONFIG, "Sync not in new config")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_IN_NEW_CONFIG, "Sync not in new config")
|
||||||
|
|
|
@ -4,6 +4,11 @@ system sh/deploy.sh -n dnode2 -i 2
|
||||||
system sh/deploy.sh -n dnode3 -i 3
|
system sh/deploy.sh -n dnode3 -i 3
|
||||||
system sh/deploy.sh -n dnode4 -i 4
|
system sh/deploy.sh -n dnode4 -i 4
|
||||||
system sh/deploy.sh -n dnode5 -i 5
|
system sh/deploy.sh -n dnode5 -i 5
|
||||||
|
system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1
|
||||||
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
|
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
|
@ -128,9 +133,9 @@ if $rows != 1 then
|
||||||
endi
|
endi
|
||||||
if $data(2)[4] == leader then
|
if $data(2)[4] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 4
|
$leaderVnode = 2
|
||||||
$follower1 = 2
|
$follower1 = 3
|
||||||
$follower2 = 3
|
$follower2 = 4
|
||||||
endi
|
endi
|
||||||
if $data(2)[6] == leader then
|
if $data(2)[6] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
|
@ -140,9 +145,9 @@ if $data(2)[6] == leader then
|
||||||
endi
|
endi
|
||||||
if $data(2)[8] == leader then
|
if $data(2)[8] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 2
|
$leaderVnode = 4
|
||||||
$follower1 = 3
|
$follower1 = 2
|
||||||
$follower2 = 4
|
$follower2 = 3
|
||||||
endi
|
endi
|
||||||
if $leaderExist != 1 then
|
if $leaderExist != 1 then
|
||||||
goto step3
|
goto step3
|
||||||
|
@ -171,8 +176,6 @@ if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
print =============== step33: move follower1
|
print =============== step33: move follower1
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||||
|
|
|
@ -4,6 +4,11 @@ system sh/deploy.sh -n dnode2 -i 2
|
||||||
system sh/deploy.sh -n dnode3 -i 3
|
system sh/deploy.sh -n dnode3 -i 3
|
||||||
system sh/deploy.sh -n dnode4 -i 4
|
system sh/deploy.sh -n dnode4 -i 4
|
||||||
system sh/deploy.sh -n dnode5 -i 5
|
system sh/deploy.sh -n dnode5 -i 5
|
||||||
|
system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1
|
||||||
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
|
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
|
@ -128,9 +133,9 @@ if $rows != 1 then
|
||||||
endi
|
endi
|
||||||
if $data(2)[4] == leader then
|
if $data(2)[4] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 4
|
$leaderVnode = 2
|
||||||
$follower1 = 2
|
$follower1 = 3
|
||||||
$follower2 = 3
|
$follower2 = 4
|
||||||
endi
|
endi
|
||||||
if $data(2)[6] == leader then
|
if $data(2)[6] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
|
@ -140,9 +145,9 @@ if $data(2)[6] == leader then
|
||||||
endi
|
endi
|
||||||
if $data(2)[8] == leader then
|
if $data(2)[8] == leader then
|
||||||
$leaderExist = 1
|
$leaderExist = 1
|
||||||
$leaderVnode = 2
|
$leaderVnode = 4
|
||||||
$follower1 = 3
|
$follower1 = 2
|
||||||
$follower2 = 4
|
$follower2 = 3
|
||||||
endi
|
endi
|
||||||
if $leaderExist != 1 then
|
if $leaderExist != 1 then
|
||||||
goto step3
|
goto step3
|
||||||
|
@ -160,110 +165,22 @@ if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print =============== step32: move follower2
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
|
||||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
|
||||||
=======
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
|
|
||||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
|
||||||
=======
|
|
||||||
print =============== step32: move leader
|
print =============== step32: move leader
|
||||||
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
||||||
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
||||||
sql show d1.vgroups
|
sql show d1.vgroups
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
>>>>>>> origin/3.0
|
|
||||||
sql show d1.tables
|
sql show d1.tables
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
<<<<<<< HEAD
|
return
|
||||||
|
|
||||||
print =============== step33: move follower1
|
print =============== step33: move follower1
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
|
||||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
|
||||||
=======
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
|
|
||||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
|
||||||
=======
|
|
||||||
print =============== step33: move follower2
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
|
|
||||||
>>>>>>> origin/3.0
|
|
||||||
sql show d1.tables
|
|
||||||
if $rows != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print =============== step34: move follower2
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
|
||||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
|
||||||
=======
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
|
|
||||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
|
||||||
=======
|
|
||||||
print =============== step34: move follower1
|
|
||||||
print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode
|
|
||||||
sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
|
|
||||||
>>>>>>> origin/3.0
|
|
||||||
sql show d1.tables
|
|
||||||
if $rows != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print =============== step35: move follower1
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
|
||||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
|
||||||
sql show d1.tables
|
|
||||||
if $rows != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
=======
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
|
||||||
=======
|
|
||||||
print =============== step35: move 5
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode $follower2
|
|
||||||
sql show d1.vgroups
|
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
|
||||||
>>>>>>> origin/3.0
|
|
||||||
|
|
||||||
sql show d1.tables
|
|
||||||
if $rows != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print =============== step36: move follower2
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||||
=======
|
|
||||||
print =============== step36: move follower1
|
|
||||||
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
|
||||||
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
|
|
||||||
>>>>>>> origin/3.0
|
|
||||||
sql show d1.vgroups
|
sql show d1.vgroups
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
@ -272,11 +189,40 @@ if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
<<<<<<< HEAD
|
print =============== step34: move follower2
|
||||||
print =============== step37: move follower1
|
print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $leaderVnode
|
||||||
=======
|
sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $leaderVnode
|
||||||
|
sql show d1.vgroups
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
sql show d1.tables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step35: move leader
|
||||||
|
print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $follower1
|
||||||
|
sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $follower1
|
||||||
|
sql show d1.vgroups
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
sql show d1.tables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step36: move follower1
|
||||||
|
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||||
|
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode 5
|
||||||
|
sql show d1.vgroups
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
sql show d1.tables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
print =============== step37: move follower2
|
print =============== step37: move follower2
|
||||||
>>>>>>> origin/3.0
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5
|
||||||
sql show d1.vgroups
|
sql show d1.vgroups
|
||||||
|
@ -287,17 +233,9 @@ if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
|
|
||||||
=======
|
|
||||||
print =============== step38: move follower2
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
|
||||||
=======
|
|
||||||
print =============== step38: move leader
|
print =============== step38: move leader
|
||||||
print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2
|
print redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2
|
||||||
sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2
|
sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode $follower2
|
||||||
>>>>>>> origin/3.0
|
|
||||||
sql show d1.vgroups
|
sql show d1.vgroups
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
@ -305,18 +243,10 @@ sql show d1.tables
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> origin/3.0:tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
|
|
||||||
|
|
||||||
print =============== step39: move follower1
|
print =============== step39: move follower1
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower1
|
sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode $follower2
|
||||||
=======
|
|
||||||
|
|
||||||
print =============== step39: move 5
|
|
||||||
print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1
|
|
||||||
sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1
|
|
||||||
>>>>>>> origin/3.0
|
|
||||||
sql show d1.vgroups
|
sql show d1.vgroups
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
|
|
@ -251,8 +251,25 @@ class TDTestCase:
|
||||||
while 1:
|
while 1:
|
||||||
tdSql.query("show databases")
|
tdSql.query("show databases")
|
||||||
if tdSql.getRows() == 4:
|
if tdSql.getRows() == 4:
|
||||||
print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),)
|
print ('==================================================')
|
||||||
break
|
print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0))
|
||||||
|
index = 0
|
||||||
|
if tdSql.getData(0,0) == parameterDict['dbName']:
|
||||||
|
index = 0
|
||||||
|
elif tdSql.getData(1,0) == parameterDict['dbName']:
|
||||||
|
index = 1
|
||||||
|
elif tdSql.getData(2,0) == parameterDict['dbName']:
|
||||||
|
index = 2
|
||||||
|
elif tdSql.getData(3,0) == parameterDict['dbName']:
|
||||||
|
index = 3
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if tdSql.getData(index,19) == 'ready':
|
||||||
|
print("******************** index: %d"%index)
|
||||||
|
break
|
||||||
|
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
@ -378,8 +395,27 @@ class TDTestCase:
|
||||||
while 1:
|
while 1:
|
||||||
tdSql.query("show databases")
|
tdSql.query("show databases")
|
||||||
if tdSql.getRows() == 5:
|
if tdSql.getRows() == 5:
|
||||||
print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),)
|
print ('==================================================')
|
||||||
break
|
print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),tdSql.getData(3,0),tdSql.getData(4,0))
|
||||||
|
index = 0
|
||||||
|
if tdSql.getData(0,0) == parameterDict['dbName']:
|
||||||
|
index = 0
|
||||||
|
elif tdSql.getData(1,0) == parameterDict['dbName']:
|
||||||
|
index = 1
|
||||||
|
elif tdSql.getData(2,0) == parameterDict['dbName']:
|
||||||
|
index = 2
|
||||||
|
elif tdSql.getData(3,0) == parameterDict['dbName']:
|
||||||
|
index = 3
|
||||||
|
elif tdSql.getData(4,0) == parameterDict['dbName']:
|
||||||
|
index = 4
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if tdSql.getData(index,19) == 'ready':
|
||||||
|
print("******************** index: %d"%index)
|
||||||
|
break
|
||||||
|
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ python3 ./test.py -f 2-query/tail.py
|
||||||
|
|
||||||
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
python3 ./test.py -f 6-cluster/5dnode2mnode.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
|
#python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py
|
python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,12 @@ set /a a=0
|
||||||
if %1 == full (
|
if %1 == full (
|
||||||
echo Windows Taosd Full Test
|
echo Windows Taosd Full Test
|
||||||
set /a exitNum=0
|
set /a exitNum=0
|
||||||
for /F "usebackq tokens=*" %%i in (fulltest.bat) do (
|
del /Q /F failed.txt
|
||||||
|
set caseFile="fulltest.bat"
|
||||||
|
if not "%2" == "" (
|
||||||
|
set caseFile="%2"
|
||||||
|
)
|
||||||
|
for /F "usebackq tokens=*" %%i in (!caseFile!) do (
|
||||||
for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" (
|
for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" (
|
||||||
set /a a+=1
|
set /a a+=1
|
||||||
echo !a! Processing %%i
|
echo !a! Processing %%i
|
||||||
|
@ -13,7 +18,7 @@ if %1 == full (
|
||||||
set time1=!_timeTemp!
|
set time1=!_timeTemp!
|
||||||
echo Start at !time!
|
echo Start at !time!
|
||||||
call %%i ARG1 > result_!a!.txt 2>error_!a!.txt
|
call %%i ARG1 > result_!a!.txt 2>error_!a!.txt
|
||||||
if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 ) else ( call :colorEcho 0a "Success" &echo. )
|
if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
exit !exitNum!
|
exit !exitNum!
|
||||||
|
|
Loading…
Reference in New Issue