Merge branch '3.0' into feature/3_liaohj
This commit is contained in:
commit
282630a394
|
|
@ -202,6 +202,10 @@ The configuration parameters in the URL are as follows.
|
||||||
- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
|
- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
|
||||||
- charset: specify the charset to parse the string, this parameter is valid only when set batchfetch to true.
|
- charset: specify the charset to parse the string, this parameter is valid only when set batchfetch to true.
|
||||||
- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false.
|
- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false.
|
||||||
|
- httpConnectTimeout: REST connection timeout in milliseconds, the default value is 5000 ms.
|
||||||
|
- httpSocketTimeout: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when batchfetch is false.
|
||||||
|
- messageWaitTimeout: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when batchfetch is true.
|
||||||
|
- useSSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection.
|
||||||
|
|
||||||
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
|
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
|
||||||
|
|
||||||
|
|
@ -257,14 +261,18 @@ In the above example, a connection is established to `taosdemo.com`, port is 603
|
||||||
|
|
||||||
The configuration parameters in properties are as follows.
|
The configuration parameters in properties are as follows.
|
||||||
|
|
||||||
- TSDBDriver.PROPERTY_KEY_USER: Login TDengine user name, default value 'root'.
|
- TSDBDriver.PROPERTY_KEY_USER: login TDengine user name, default value 'root'.
|
||||||
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
|
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
|
||||||
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
|
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
|
||||||
- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false.
|
- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false.
|
||||||
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: Only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
|
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
|
||||||
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
|
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
|
||||||
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
|
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
|
||||||
- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone.
|
- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone.
|
||||||
|
- TSDBDriver.HTTP_CONNECT_TIMEOUT: REST connection timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection.
|
||||||
|
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection and batchfetch is false.
|
||||||
|
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when using JDBC REST connection and batchfetch is true.
|
||||||
|
- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection. It only takes effect when using using JDBC REST connection.
|
||||||
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
|
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
|
||||||
|
|
||||||
### Priority of configuration parameters
|
### Priority of configuration parameters
|
||||||
|
|
@ -812,11 +820,12 @@ Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develo
|
||||||
|
|
||||||
## Recent update logs
|
## Recent update logs
|
||||||
|
|
||||||
| taos-jdbcdriver version | major changes |
|
| taos-jdbcdriver version | major changes |
|
||||||
| :---------------------: | :------------------------------------------: |
|
| :---------------------: | :--------------------------------------------: |
|
||||||
| 2.0.38 | JDBC REST connections add bulk pull function |
|
| 2.0.39 - 2.0.40 | Add REST connection/request timeout parameters |
|
||||||
| 2.0.37 | Added support for json tags |
|
| 2.0.38 | JDBC REST connections add bulk pull function |
|
||||||
| 2.0.36 | Add support for schemaless writing |
|
| 2.0.37 | Support json tags |
|
||||||
|
| 2.0.36 | Support schemaless writing |
|
||||||
|
|
||||||
## Frequently Asked Questions
|
## Frequently Asked Questions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,10 @@ url 中的配置参数如下:
|
||||||
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
||||||
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
||||||
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
||||||
|
- httpConnectTimeout: 连接超时时间,单位 ms, 默认值为 5000。
|
||||||
|
- httpSocketTimeout: socket 超时时间,单位 ms,默认值为 5000。仅在 batchfetch 设置为 false 时生效。
|
||||||
|
- messageWaitTimeout: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 batchfetch 设置为 true 时生效。
|
||||||
|
- useSSL: 连接中是否使用 SSL。
|
||||||
|
|
||||||
**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。
|
**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。
|
||||||
|
|
||||||
|
|
@ -264,7 +268,11 @@ properties 中的配置参数如下:
|
||||||
- TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。
|
- TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。
|
||||||
- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。
|
- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。
|
||||||
- TSDBDriver.PROPERTY_KEY_TIME_ZONE:仅在使用 JDBC 原生连接时生效。 客户端使用的时区,默认值为系统当前时区。
|
- TSDBDriver.PROPERTY_KEY_TIME_ZONE:仅在使用 JDBC 原生连接时生效。 客户端使用的时区,默认值为系统当前时区。
|
||||||
- 此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。
|
- TSDBDriver.HTTP_CONNECT_TIMEOUT: 连接超时时间,单位 ms, 默认值为 5000。仅在 REST 连接时生效。
|
||||||
|
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket 超时时间,单位 ms,默认值为 5000。仅在 REST 连接且 batchfetch 设置为 false 时生效。
|
||||||
|
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 REST 连接且 batchfetch 设置为 true 时生效。
|
||||||
|
- TSDBDriver.PROPERTY_KEY_USE_SSL: 连接中是否使用 SSL。仅在 REST 连接时生效。
|
||||||
|
此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。
|
||||||
|
|
||||||
### 配置参数的优先级
|
### 配置参数的优先级
|
||||||
|
|
||||||
|
|
@ -809,6 +817,7 @@ Query OK, 1 row(s) in set (0.000141s)
|
||||||
|
|
||||||
| taos-jdbcdriver 版本 | 主要变化 |
|
| taos-jdbcdriver 版本 | 主要变化 |
|
||||||
| :------------------: | :----------------------------: |
|
| :------------------: | :----------------------------: |
|
||||||
|
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 |
|
||||||
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
||||||
| 2.0.37 | 增加对 json tag 支持 |
|
| 2.0.37 | 增加对 json tag 支持 |
|
||||||
| 2.0.36 | 增加对 schemaless 写入支持 |
|
| 2.0.36 | 增加对 schemaless 写入支持 |
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ typedef struct SReadHandle {
|
||||||
bool initMetaReader;
|
bool initMetaReader;
|
||||||
bool initTableReader;
|
bool initTableReader;
|
||||||
bool initTqReader;
|
bool initTqReader;
|
||||||
|
int32_t numOfVgroups;
|
||||||
} SReadHandle;
|
} SReadHandle;
|
||||||
|
|
||||||
// in queue mode, data streams are seperated by msg
|
// in queue mode, data streams are seperated by msg
|
||||||
|
|
|
||||||
|
|
@ -162,9 +162,12 @@ typedef struct SRequestConnInfo {
|
||||||
SEpSet mgmtEps;
|
SEpSet mgmtEps;
|
||||||
} SRequestConnInfo;
|
} SRequestConnInfo;
|
||||||
|
|
||||||
|
typedef void (*__freeFunc)(void *param);
|
||||||
|
|
||||||
typedef struct SMsgSendInfo {
|
typedef struct SMsgSendInfo {
|
||||||
__async_send_cb_fn_t fp; // async callback function
|
__async_send_cb_fn_t fp; // async callback function
|
||||||
STargetInfo target; // for update epset
|
STargetInfo target; // for update epset
|
||||||
|
__freeFunc paramFreeFp;
|
||||||
void* param;
|
void* param;
|
||||||
uint64_t requestId;
|
uint64_t requestId;
|
||||||
uint64_t requestObjRefId;
|
uint64_t requestObjRefId;
|
||||||
|
|
@ -188,6 +191,8 @@ int32_t cleanupTaskQueue();
|
||||||
*/
|
*/
|
||||||
int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
|
int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
|
||||||
|
|
||||||
|
void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
||||||
|
|
||||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
||||||
bool persistHandle, void* ctx);
|
bool persistHandle, void* ctx);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ typedef struct SStreamTask {
|
||||||
int64_t startVer;
|
int64_t startVer;
|
||||||
int64_t checkpointVer;
|
int64_t checkpointVer;
|
||||||
int64_t processedVer;
|
int64_t processedVer;
|
||||||
|
int32_t numOfVgroups;
|
||||||
|
|
||||||
// children info
|
// children info
|
||||||
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
|
|
||||||
extern bool gRaftDetailLog;
|
extern bool gRaftDetailLog;
|
||||||
|
|
||||||
#define SYNC_RESP_TTL_MS 5000
|
#define SYNC_RESP_TTL_MS 10000
|
||||||
|
|
||||||
#define SYNC_MAX_BATCH_SIZE 500
|
#define SYNC_MAX_BATCH_SIZE 500
|
||||||
#define SYNC_INDEX_BEGIN 0
|
#define SYNC_INDEX_BEGIN 0
|
||||||
|
|
|
||||||
|
|
@ -286,13 +286,10 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
if (pInst == NULL || NULL == *pInst) {
|
if (pInst == NULL || NULL == *pInst) {
|
||||||
taosThreadMutexUnlock(&appInfo.mutex);
|
taosThreadMutexUnlock(&appInfo.mutex);
|
||||||
tscError("cluster not exist, key:%s", key);
|
tscError("cluster not exist, key:%s", key);
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
tFreeClientHbBatchRsp(&pRsp);
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
||||||
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), (*pInst)->onlineDnodes, (*pInst)->totalDnodes);
|
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), (*pInst)->onlineDnodes, (*pInst)->totalDnodes);
|
||||||
|
|
@ -716,6 +713,7 @@ static void *hbThreadFunc(void *param) {
|
||||||
pInfo->msgInfo.len = tlen;
|
pInfo->msgInfo.len = tlen;
|
||||||
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
||||||
pInfo->param = strdup(pAppHbMgr->key);
|
pInfo->param = strdup(pAppHbMgr->key);
|
||||||
|
pInfo->paramFreeFp = taosMemoryFree;
|
||||||
pInfo->requestId = generateRequestId();
|
pInfo->requestId = generateRequestId();
|
||||||
pInfo->requestObjRefId = 0;
|
pInfo->requestObjRefId = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
||||||
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
|
||||||
|
|
||||||
static bool stringLengthCheck(const char* str, size_t maxsize) {
|
static bool stringLengthCheck(const char* str, size_t maxsize) {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
|
|
@ -1215,13 +1214,6 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
return pMsgSendInfo;
|
return pMsgSendInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
|
||||||
assert(pMsgBody != NULL);
|
|
||||||
taosMemoryFreeClear(pMsgBody->target.dbFName);
|
|
||||||
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
|
||||||
taosMemoryFreeClear(pMsgBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
if (NULL == pEpSet) {
|
if (NULL == pEpSet) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,8 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
if (pRequest->body.queryFp != NULL) {
|
if (pRequest->body.queryFp != NULL) {
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -278,6 +280,8 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
pRequest->body.resInfo.execRes.res = alterRsp.pMeta;
|
pRequest->body.resInfo.execRes.res = alterRsp.pMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
if (pRequest->body.queryFp != NULL) {
|
if (pRequest->body.queryFp != NULL) {
|
||||||
SExecResult* pRes = &pRequest->body.resInfo.execRes;
|
SExecResult* pRes = &pRequest->body.resInfo.execRes;
|
||||||
|
|
||||||
|
|
@ -387,6 +391,8 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tFreeSShowVariablesRsp(&rsp);
|
tFreeSShowVariablesRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
|
|
||||||
if (pRequest->body.queryFp != NULL) {
|
if (pRequest->body.queryFp != NULL) {
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1217,6 +1217,9 @@ static int32_t smlParseCols(const char *data, int32_t len, SArray *cols, char *c
|
||||||
kv->value = value;
|
kv->value = value;
|
||||||
kv->length = valueLen;
|
kv->length = valueLen;
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
|
if(valueLen > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){
|
||||||
|
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||||
|
}
|
||||||
kv->type = TSDB_DATA_TYPE_NCHAR;
|
kv->type = TSDB_DATA_TYPE_NCHAR;
|
||||||
} else {
|
} else {
|
||||||
int32_t ret = smlParseValue(kv, msg);
|
int32_t ret = smlParseValue(kv, msg);
|
||||||
|
|
|
||||||
|
|
@ -504,6 +504,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
||||||
pMsgSendInfo->requestId = generateRequestId();
|
pMsgSendInfo->requestId = generateRequestId();
|
||||||
pMsgSendInfo->requestObjRefId = 0;
|
pMsgSendInfo->requestObjRefId = 0;
|
||||||
pMsgSendInfo->param = pParam;
|
pMsgSendInfo->param = pParam;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->fp = tmqCommitCb2;
|
pMsgSendInfo->fp = tmqCommitCb2;
|
||||||
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
pMsgSendInfo->msgType = TDMT_VND_MQ_COMMIT_OFFSET;
|
||||||
// send msg
|
// send msg
|
||||||
|
|
|
||||||
|
|
@ -556,7 +556,7 @@ static void taosSetSystemCfg(SConfig *pCfg) {
|
||||||
osSetSystemLocale(locale, charset);
|
osSetSystemLocale(locale, charset);
|
||||||
|
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetConsoleEcho(enableCore);
|
taosSetCoreDump(enableCore);
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
tsVersion = 30000000;
|
tsVersion = 30000000;
|
||||||
|
|
@ -675,7 +675,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
||||||
case 'e': {
|
case 'e': {
|
||||||
if (strcasecmp("enableCoreFile", name) == 0) {
|
if (strcasecmp("enableCoreFile", name) == 0) {
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetConsoleEcho(enableCore);
|
taosSetCoreDump(enableCore);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -383,6 +383,11 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
// exec
|
// exec
|
||||||
pInnerTask->execType = TASK_EXEC__PIPE;
|
pInnerTask->execType = TASK_EXEC__PIPE;
|
||||||
|
|
||||||
|
SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb);
|
||||||
|
ASSERT(pDbObj != NULL);
|
||||||
|
sdbRelease(pSdb, pSourceDb);
|
||||||
|
pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups;
|
||||||
|
|
||||||
if (tsSchedStreamToSnode) {
|
if (tsSchedStreamToSnode) {
|
||||||
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
||||||
if (pSnode == NULL) {
|
if (pSnode == NULL) {
|
||||||
|
|
|
||||||
|
|
@ -153,23 +153,22 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
||||||
if (insertFp != NULL) {
|
if (insertFp != NULL) {
|
||||||
code = (*insertFp)(pSdb, pRow->pObj);
|
code = (*insertFp)(pSdb, pRow->pObj);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
taosThreadRwlockWrlock(pLock);
|
|
||||||
taosHashRemove(hash, pRow->pObj, keySize);
|
taosHashRemove(hash, pRow->pObj, keySize);
|
||||||
taosThreadRwlockUnlock(pLock);
|
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
if (pSdb->keyTypes[pRow->type] == SDB_KEY_INT32) {
|
if (pSdb->keyTypes[pRow->type] == SDB_KEY_INT32) {
|
||||||
pSdb->maxId[pRow->type] = TMAX(pSdb->maxId[pRow->type], *((int32_t *)pRow->pObj));
|
pSdb->maxId[pRow->type] = TMAX(pSdb->maxId[pRow->type], *((int32_t *)pRow->pObj));
|
||||||
}
|
}
|
||||||
|
|
@ -194,7 +193,6 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
SSdbRow *pOldRow = *ppOldRow;
|
SSdbRow *pOldRow = *ppOldRow;
|
||||||
pOldRow->status = pRaw->status;
|
pOldRow->status = pRaw->status;
|
||||||
sdbPrintOper(pSdb, pOldRow, "update");
|
sdbPrintOper(pSdb, pOldRow, "update");
|
||||||
taosThreadRwlockUnlock(pLock);
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
||||||
|
|
@ -202,6 +200,7 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj);
|
code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pNewRow, false);
|
sdbFreeRow(pSdb, pNewRow, false);
|
||||||
|
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,10 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg);
|
||||||
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
||||||
void tsdbMemTableDestroy(SMemTable *pMemTable);
|
void tsdbMemTableDestroy(SMemTable *pMemTable);
|
||||||
void tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData);
|
void tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData);
|
||||||
|
void tsdbRefMemTable(SMemTable *pMemTable);
|
||||||
|
void tsdbUnrefMemTable(SMemTable *pMemTable);
|
||||||
|
int32_t tsdbTakeMemSnapshot(STsdb *pTsdb, SMemTable **ppMem, SMemTable **ppIMem);
|
||||||
|
void tsdbUntakeMemSnapshot(STsdb *pTsdb, SMemTable *pMem, SMemTable *pIMem);
|
||||||
// STbDataIter
|
// STbDataIter
|
||||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||||
|
|
@ -273,23 +277,14 @@ typedef struct {
|
||||||
} SRtn;
|
} SRtn;
|
||||||
|
|
||||||
struct STsdb {
|
struct STsdb {
|
||||||
char *path;
|
char *path;
|
||||||
SVnode *pVnode;
|
SVnode *pVnode;
|
||||||
TdThreadMutex mutex;
|
STsdbKeepCfg keepCfg;
|
||||||
bool repoLocked;
|
TdThreadRwlock rwLock;
|
||||||
STsdbKeepCfg keepCfg;
|
SMemTable *mem;
|
||||||
SMemTable *mem;
|
SMemTable *imem;
|
||||||
SMemTable *imem;
|
STsdbFS *pFS;
|
||||||
SRtn rtn;
|
SLRUCache *lruCache;
|
||||||
STsdbFS *fs;
|
|
||||||
SLRUCache *lruCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct STable {
|
|
||||||
uint64_t suid;
|
|
||||||
uint64_t uid;
|
|
||||||
STSchema *pSchema; // latest schema
|
|
||||||
STSchema *pCacheSchema; // cached cache
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TSDBKEY {
|
struct TSDBKEY {
|
||||||
|
|
@ -330,21 +325,19 @@ struct STbData {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMemTable {
|
struct SMemTable {
|
||||||
SRWLatch latch;
|
SRWLatch latch;
|
||||||
STsdb *pTsdb;
|
STsdb *pTsdb;
|
||||||
int32_t nRef;
|
SVBufPool *pPool;
|
||||||
TSKEY minKey;
|
volatile int32_t nRef;
|
||||||
TSKEY maxKey;
|
TSKEY minKey;
|
||||||
int64_t minVersion;
|
TSKEY maxKey;
|
||||||
int64_t maxVersion;
|
int64_t minVersion;
|
||||||
int64_t nRow;
|
int64_t maxVersion;
|
||||||
int64_t nDel;
|
int64_t nRow;
|
||||||
SArray *aTbData; // SArray<STbData*>
|
int64_t nDel;
|
||||||
|
SArray *aTbData; // SArray<STbData*>
|
||||||
};
|
};
|
||||||
|
|
||||||
int tsdbLockRepo(STsdb *pTsdb);
|
|
||||||
int tsdbUnlockRepo(STsdb *pTsdb);
|
|
||||||
|
|
||||||
struct TSDBROW {
|
struct TSDBROW {
|
||||||
int8_t type; // 0 for row from tsRow, 1 for row from block data
|
int8_t type; // 0 for row from tsRow, 1 for row from block data
|
||||||
union {
|
union {
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,13 @@ struct SVBufPoolNode {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVBufPool {
|
struct SVBufPool {
|
||||||
SVBufPool* next;
|
SVBufPool* next;
|
||||||
int64_t nRef;
|
SVnode* pVnode;
|
||||||
int64_t size;
|
volatile int32_t nRef;
|
||||||
uint8_t* ptr;
|
int64_t size;
|
||||||
SVBufPoolNode* pTail;
|
uint8_t* ptr;
|
||||||
SVBufPoolNode node;
|
SVBufPoolNode* pTail;
|
||||||
|
SVBufPoolNode node;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
int32_t vnodeOpenBufPool(SVnode* pVnode, int64_t size);
|
||||||
|
|
@ -78,7 +79,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
||||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||||
void vnodeQueryClose(SVnode* pVnode);
|
void vnodeQueryClose(SVnode* pVnode);
|
||||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg);
|
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
|
|
||||||
// vnodeCommit.c
|
// vnodeCommit.c
|
||||||
int32_t vnodeBegin(SVnode* pVnode);
|
int32_t vnodeBegin(SVnode* pVnode);
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,8 @@ typedef struct SSnapDataHdr SSnapDataHdr;
|
||||||
// vnd.h
|
// vnd.h
|
||||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||||
|
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||||
|
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
typedef struct SMCtbCursor SMCtbCursor;
|
typedef struct SMCtbCursor SMCtbCursor;
|
||||||
|
|
@ -247,26 +249,26 @@ struct STsdbKeepCfg {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVnode {
|
struct SVnode {
|
||||||
char* path;
|
char* path;
|
||||||
SVnodeCfg config;
|
SVnodeCfg config;
|
||||||
SVState state;
|
SVState state;
|
||||||
STfs* pTfs;
|
STfs* pTfs;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
SVBufPool* pPool;
|
TdThreadMutex mutex;
|
||||||
SVBufPool* inUse;
|
TdThreadCond poolNotEmpty;
|
||||||
SVBufPool* onCommit;
|
SVBufPool* pPool;
|
||||||
SVBufPool* onRecycle;
|
SVBufPool* inUse;
|
||||||
SMeta* pMeta;
|
SMeta* pMeta;
|
||||||
SSma* pSma;
|
SSma* pSma;
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
SSink* pSink;
|
SSink* pSink;
|
||||||
tsem_t canCommit;
|
tsem_t canCommit;
|
||||||
int64_t sync;
|
int64_t sync;
|
||||||
int32_t blockCount;
|
int32_t blockCount;
|
||||||
tsem_t syncSem;
|
tsem_t syncSem;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
||||||
|
|
|
||||||
|
|
@ -591,7 +591,11 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
};
|
};
|
||||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||||
} else {
|
} else {
|
||||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, NULL);
|
SReadHandle mgHandle = {
|
||||||
|
.vnode = NULL,
|
||||||
|
.numOfVgroups = pTask->numOfVgroups,
|
||||||
|
};
|
||||||
|
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
|
||||||
}
|
}
|
||||||
ASSERT(pTask->exec.executor);
|
ASSERT(pTask->exec.executor);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
||||||
|
|
||||||
switch (state->state) {
|
switch (state->state) {
|
||||||
case SFSNEXTROW_FS:
|
case SFSNEXTROW_FS:
|
||||||
state->aDFileSet = state->pTsdb->fs->cState->aDFileSet;
|
state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet;
|
||||||
state->nFileSet = taosArrayGetSize(state->aDFileSet);
|
state->nFileSet = taosArrayGetSize(state->aDFileSet);
|
||||||
state->iFileSet = state->nFileSet;
|
state->iFileSet = state->nFileSet;
|
||||||
|
|
||||||
|
|
@ -793,6 +793,9 @@ typedef struct {
|
||||||
TSDBROW memRow, imemRow, fsRow;
|
TSDBROW memRow, imemRow, fsRow;
|
||||||
|
|
||||||
TsdbNextRowState input[3];
|
TsdbNextRowState input[3];
|
||||||
|
SMemTable *pMemTable;
|
||||||
|
SMemTable *pIMemTable;
|
||||||
|
STsdb *pTsdb;
|
||||||
} CacheNextRowIter;
|
} CacheNextRowIter;
|
||||||
|
|
||||||
static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTsdb) {
|
static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTsdb) {
|
||||||
|
|
@ -800,21 +803,25 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
||||||
|
|
||||||
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||||
|
|
||||||
|
tsdbTakeMemSnapshot(pTsdb, &pIter->pMemTable, &pIter->pIMemTable);
|
||||||
|
|
||||||
STbData *pMem = NULL;
|
STbData *pMem = NULL;
|
||||||
if (pTsdb->mem) {
|
if (pIter->pMemTable) {
|
||||||
tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
tsdbGetTbDataFromMemTable(pIter->pMemTable, suid, uid, &pMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
STbData *pIMem = NULL;
|
STbData *pIMem = NULL;
|
||||||
if (pTsdb->imem) {
|
if (pIter->pIMemTable) {
|
||||||
tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
tsdbGetTbDataFromMemTable(pIter->pIMemTable, suid, uid, &pIMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pIter->pTsdb = pTsdb;
|
||||||
|
|
||||||
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
pIter->pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||||
|
|
||||||
SDelIdx delIdx;
|
SDelIdx delIdx;
|
||||||
|
|
||||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
|
||||||
|
|
@ -878,6 +885,8 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) {
|
||||||
taosArrayDestroy(pIter->pSkyline);
|
taosArrayDestroy(pIter->pSkyline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tsdbUntakeMemSnapshot(pIter->pTsdb, pIter->pMemTable, pIter->pIMemTable);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
_err:
|
_err:
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -1189,7 +1198,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
|
|
||||||
SDelIdx delIdx;
|
SDelIdx delIdx;
|
||||||
|
|
||||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
|
||||||
|
|
@ -1377,7 +1386,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||||
|
|
||||||
SDelIdx delIdx;
|
SDelIdx delIdx;
|
||||||
|
|
||||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,26 @@ int32_t tsdbBegin(STsdb *pTsdb) {
|
||||||
|
|
||||||
if (!pTsdb) return code;
|
if (!pTsdb) return code;
|
||||||
|
|
||||||
code = tsdbMemTableCreate(pTsdb, &pTsdb->mem);
|
SMemTable *pMemTable;
|
||||||
|
code = tsdbMemTableCreate(pTsdb, &pMemTable);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
|
// lock
|
||||||
|
code = taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
|
if (code) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(code);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTsdb->mem = pMemTable;
|
||||||
|
|
||||||
|
// unlock
|
||||||
|
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
if (code) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(code);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
@ -83,9 +100,11 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
||||||
// TODO: lock?
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->mem = NULL;
|
pTsdb->mem = NULL;
|
||||||
tsdbMemTableDestroy(pMemTable);
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
|
tsdbUnrefMemTable(pMemTable);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +158,7 @@ static int32_t tsdbCommitDelStart(SCommitter *pCommitter) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDelFile *pDelFileR = pTsdb->fs->nState->pDelFile;
|
SDelFile *pDelFileR = pTsdb->pFS->nState->pDelFile;
|
||||||
if (pDelFileR) {
|
if (pDelFileR) {
|
||||||
code = tsdbDelFReaderOpen(&pCommitter->pDelFReader, pDelFileR, pTsdb, NULL);
|
code = tsdbDelFReaderOpen(&pCommitter->pDelFReader, pDelFileR, pTsdb, NULL);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
@ -228,7 +247,7 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
|
||||||
code = tsdbUpdateDelFileHdr(pCommitter->pDelFWriter);
|
code = tsdbUpdateDelFileHdr(pCommitter->pDelFWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pCommitter->pDelFWriter->fDel);
|
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pCommitter->pDelFWriter->fDel);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbDelFWriterClose(&pCommitter->pDelFWriter, 1);
|
code = tsdbDelFWriterClose(&pCommitter->pDelFWriter, 1);
|
||||||
|
|
@ -263,7 +282,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
taosArrayClear(pCommitter->aBlockIdx);
|
taosArrayClear(pCommitter->aBlockIdx);
|
||||||
tMapDataReset(&pCommitter->oBlockMap);
|
tMapDataReset(&pCommitter->oBlockMap);
|
||||||
tBlockDataReset(&pCommitter->oBlockData);
|
tBlockDataReset(&pCommitter->oBlockData);
|
||||||
pRSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, pCommitter->commitFid, TD_EQ);
|
pRSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, pCommitter->commitFid, TD_EQ);
|
||||||
if (pRSet) {
|
if (pRSet) {
|
||||||
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
@ -836,7 +855,7 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// upsert SDFileSet
|
// upsert SDFileSet
|
||||||
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->fs->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// close and sync
|
// close and sync
|
||||||
|
|
@ -941,10 +960,10 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
||||||
memset(pCommitter, 0, sizeof(*pCommitter));
|
memset(pCommitter, 0, sizeof(*pCommitter));
|
||||||
ASSERT(pTsdb->mem && pTsdb->imem == NULL);
|
ASSERT(pTsdb->mem && pTsdb->imem == NULL);
|
||||||
|
|
||||||
// lock();
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->imem = pTsdb->mem;
|
pTsdb->imem = pTsdb->mem;
|
||||||
pTsdb->mem = NULL;
|
pTsdb->mem = NULL;
|
||||||
// unlock();
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
pCommitter->pTsdb = pTsdb;
|
pCommitter->pTsdb = pTsdb;
|
||||||
pCommitter->commitID = pTsdb->pVnode->state.commitID;
|
pCommitter->commitID = pTsdb->pVnode->state.commitID;
|
||||||
|
|
@ -954,7 +973,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
||||||
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
||||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
||||||
|
|
||||||
code = tsdbFSBegin(pTsdb->fs);
|
code = tsdbFSBegin(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -1135,13 +1154,16 @@ static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) {
|
||||||
SMemTable *pMemTable = pTsdb->imem;
|
SMemTable *pMemTable = pTsdb->imem;
|
||||||
|
|
||||||
if (eno == 0) {
|
if (eno == 0) {
|
||||||
code = tsdbFSCommit(pTsdb->fs);
|
code = tsdbFSCommit(pTsdb->pFS);
|
||||||
} else {
|
} else {
|
||||||
code = tsdbFSRollback(pTsdb->fs);
|
code = tsdbFSRollback(pTsdb->pFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbMemTableDestroy(pMemTable);
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->imem = NULL;
|
pTsdb->imem = NULL;
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
|
tsdbUnrefMemTable(pMemTable);
|
||||||
|
|
||||||
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
||||||
return code;
|
return code;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) {
|
||||||
}
|
}
|
||||||
taosInitRWLatch(&pMemTable->latch);
|
taosInitRWLatch(&pMemTable->latch);
|
||||||
pMemTable->pTsdb = pTsdb;
|
pMemTable->pTsdb = pTsdb;
|
||||||
|
pMemTable->pPool = pTsdb->pVnode->inUse;
|
||||||
pMemTable->nRef = 1;
|
pMemTable->nRef = 1;
|
||||||
pMemTable->minKey = TSKEY_MAX;
|
pMemTable->minKey = TSKEY_MAX;
|
||||||
pMemTable->maxKey = TSKEY_MIN;
|
pMemTable->maxKey = TSKEY_MIN;
|
||||||
|
|
@ -54,6 +55,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable) {
|
||||||
taosMemoryFree(pMemTable);
|
taosMemoryFree(pMemTable);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
vnodeBufPoolRef(pMemTable->pPool);
|
||||||
|
|
||||||
*ppMemTable = pMemTable;
|
*ppMemTable = pMemTable;
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -65,6 +67,7 @@ _err:
|
||||||
|
|
||||||
void tsdbMemTableDestroy(SMemTable *pMemTable) {
|
void tsdbMemTableDestroy(SMemTable *pMemTable) {
|
||||||
if (pMemTable) {
|
if (pMemTable) {
|
||||||
|
vnodeBufPoolUnRef(pMemTable->pPool);
|
||||||
taosArrayDestroy(pMemTable->aTbData);
|
taosArrayDestroy(pMemTable->aTbData);
|
||||||
taosMemoryFree(pMemTable);
|
taosMemoryFree(pMemTable);
|
||||||
}
|
}
|
||||||
|
|
@ -590,3 +593,58 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbGetNRowsInTbData(STbData *pTbData) { return pTbData->sl.size; }
|
int32_t tsdbGetNRowsInTbData(STbData *pTbData) { return pTbData->sl.size; }
|
||||||
|
|
||||||
|
void tsdbRefMemTable(SMemTable *pMemTable) {
|
||||||
|
int32_t nRef = atomic_fetch_add_32(&pMemTable->nRef, 1);
|
||||||
|
ASSERT(nRef > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbUnrefMemTable(SMemTable *pMemTable) {
|
||||||
|
int32_t nRef = atomic_sub_fetch_32(&pMemTable->nRef, 1);
|
||||||
|
if (nRef == 0) {
|
||||||
|
tsdbMemTableDestroy(pMemTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbTakeMemSnapshot(STsdb *pTsdb, SMemTable **ppMem, SMemTable **ppIMem) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
// lock
|
||||||
|
code = taosThreadRwlockRdlock(&pTsdb->rwLock);
|
||||||
|
if (code) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(code);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// take snapshot
|
||||||
|
*ppMem = pTsdb->mem;
|
||||||
|
*ppIMem = pTsdb->imem;
|
||||||
|
|
||||||
|
if (*ppMem) {
|
||||||
|
tsdbRefMemTable(*ppMem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ppIMem) {
|
||||||
|
tsdbRefMemTable(*ppIMem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// unlock
|
||||||
|
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
if (code) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(code);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbUntakeMemSnapshot(STsdb *pTsdb, SMemTable *pMem, SMemTable *pIMem) {
|
||||||
|
if (pMem) {
|
||||||
|
tsdbUnrefMemTable(pMem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pIMem) {
|
||||||
|
tsdbUnrefMemTable(pIMem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -54,8 +54,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
||||||
taosRealPath(pTsdb->path, NULL, slen);
|
taosRealPath(pTsdb->path, NULL, slen);
|
||||||
pTsdb->pVnode = pVnode;
|
pTsdb->pVnode = pVnode;
|
||||||
pTsdb->repoLocked = false;
|
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
||||||
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
|
||||||
if (!pKeepCfg) {
|
if (!pKeepCfg) {
|
||||||
tsdbSetKeepCfg(&pTsdb->keepCfg, &pVnode->config.tsdbCfg);
|
tsdbSetKeepCfg(&pTsdb->keepCfg, &pVnode->config.tsdbCfg);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -67,7 +66,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||||
|
|
||||||
// open tsdb
|
// open tsdb
|
||||||
if (tsdbFSOpen(pTsdb, &pTsdb->fs) < 0) {
|
if (tsdbFSOpen(pTsdb, &pTsdb->pFS) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,33 +87,10 @@ _err:
|
||||||
|
|
||||||
int tsdbClose(STsdb **pTsdb) {
|
int tsdbClose(STsdb **pTsdb) {
|
||||||
if (*pTsdb) {
|
if (*pTsdb) {
|
||||||
taosThreadMutexDestroy(&(*pTsdb)->mutex);
|
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||||
tsdbFSClose((*pTsdb)->fs);
|
tsdbFSClose((*pTsdb)->pFS);
|
||||||
tsdbCloseCache((*pTsdb)->lruCache);
|
tsdbCloseCache((*pTsdb)->lruCache);
|
||||||
taosMemoryFreeClear(*pTsdb);
|
taosMemoryFreeClear(*pTsdb);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbLockRepo(STsdb *pTsdb) {
|
|
||||||
int code = taosThreadMutexLock(&pTsdb->mutex);
|
|
||||||
if (code != 0) {
|
|
||||||
tsdbError("vgId:%d, failed to lock tsdb since %s", TD_VID(pTsdb->pVnode), strerror(errno));
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pTsdb->repoLocked = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tsdbUnlockRepo(STsdb *pTsdb) {
|
|
||||||
// ASSERT(IS_REPO_LOCKED(pTsdb));
|
|
||||||
pTsdb->repoLocked = false;
|
|
||||||
int code = taosThreadMutexUnlock(&pTsdb->mutex);
|
|
||||||
if (code != 0) {
|
|
||||||
tsdbError("vgId:%d, failed to unlock tsdb since %s", TD_VID(pTsdb->pVnode), strerror(errno));
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,8 @@ struct STsdbReader {
|
||||||
char* idStr; // query info handle, for debug purpose
|
char* idStr; // query info handle, for debug purpose
|
||||||
int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
|
int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
|
||||||
SBlockLoadSuppInfo suppInfo;
|
SBlockLoadSuppInfo suppInfo;
|
||||||
|
SMemTable* pMem;
|
||||||
|
SMemTable* pIMem;
|
||||||
|
|
||||||
SIOCostSummary cost;
|
SIOCostSummary cost;
|
||||||
STSchema* pSchema;
|
STSchema* pSchema;
|
||||||
|
|
@ -1880,8 +1882,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
int32_t backward = (!ASCENDING_TRAVERSE(pReader->order));
|
int32_t backward = (!ASCENDING_TRAVERSE(pReader->order));
|
||||||
|
|
||||||
STbData* d = NULL;
|
STbData* d = NULL;
|
||||||
if (pReader->pTsdb->mem != NULL) {
|
if (pReader->pMem != NULL) {
|
||||||
tsdbGetTbDataFromMemTable(pReader->pTsdb->mem, pReader->suid, pBlockScanInfo->uid, &d);
|
tsdbGetTbDataFromMemTable(pReader->pMem, pReader->suid, pBlockScanInfo->uid, &d);
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
|
@ -1901,8 +1903,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
||||||
}
|
}
|
||||||
|
|
||||||
STbData* di = NULL;
|
STbData* di = NULL;
|
||||||
if (pReader->pTsdb->imem != NULL) {
|
if (pReader->pIMem != NULL) {
|
||||||
tsdbGetTbDataFromMemTable(pReader->pTsdb->imem, pReader->suid, pBlockScanInfo->uid, &di);
|
tsdbGetTbDataFromMemTable(pReader->pIMem, pReader->suid, pBlockScanInfo->uid, &di);
|
||||||
if (di != NULL) {
|
if (di != NULL) {
|
||||||
code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter);
|
code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
|
@ -1938,7 +1940,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
|
|
||||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
|
|
||||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->cState);
|
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
SDelFReader* pDelFReader = NULL;
|
SDelFReader* pDelFReader = NULL;
|
||||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||||
|
|
@ -2828,7 +2830,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
|
|
||||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||||
|
|
||||||
STsdbFSState* pFState = pReader->pTsdb->fs->cState;
|
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||||
|
|
||||||
|
|
@ -2842,6 +2844,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tsdbTakeMemSnapshot(pReader->pTsdb, &pReader->pMem, &pReader->pIMem);
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
|
@ -2857,6 +2861,8 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
||||||
|
|
||||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||||
|
|
||||||
|
tsdbUntakeMemSnapshot(pReader->pTsdb, pReader->pMem, pReader->pIMem);
|
||||||
|
|
||||||
taosMemoryFreeClear(pSupInfo->plist);
|
taosMemoryFreeClear(pSupInfo->plist);
|
||||||
taosMemoryFree(pSupInfo->colIds);
|
taosMemoryFree(pSupInfo->colIds);
|
||||||
|
|
||||||
|
|
@ -3075,7 +3081,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
||||||
|
|
||||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||||
|
|
||||||
STsdbFSState* pFState = pReader->pTsdb->fs->cState;
|
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||||
resetDataBlockScanInfo(pReader->status.pTableMap);
|
resetDataBlockScanInfo(pReader->status.pTableMap);
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ static int32_t tsdbDoRetentionImpl(STsdb *pTsdb, int64_t now, int8_t try, int8_t
|
||||||
STsdbFSState *pState;
|
STsdbFSState *pState;
|
||||||
|
|
||||||
if (try) {
|
if (try) {
|
||||||
pState = pTsdb->fs->cState;
|
pState = pTsdb->pFS->cState;
|
||||||
*canDo = 0;
|
*canDo = 0;
|
||||||
} else {
|
} else {
|
||||||
pState = pTsdb->fs->nState;
|
pState = pTsdb->pFS->nState;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t iSet = 0; iSet < taosArrayGetSize(pState->aDFileSet); iSet++) {
|
for (int32_t iSet = 0; iSet < taosArrayGetSize(pState->aDFileSet); iSet++) {
|
||||||
|
|
@ -83,7 +83,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
||||||
if (!canDo) goto _exit;
|
if (!canDo) goto _exit;
|
||||||
|
|
||||||
// begin
|
// begin
|
||||||
code = tsdbFSBegin(pTsdb->fs);
|
code = tsdbFSBegin(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// do retention
|
// do retention
|
||||||
|
|
@ -91,7 +91,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// commit
|
// commit
|
||||||
code = tsdbFSCommit(pTsdb->fs);
|
code = tsdbFSCommit(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
|
@ -99,6 +99,6 @@ _exit:
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||||
tsdbFSRollback(pTsdb->fs);
|
tsdbFSRollback(pTsdb->pFS);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (pReader->pDataFReader == NULL) {
|
if (pReader->pDataFReader == NULL) {
|
||||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->cState, pReader->fid, TD_GT);
|
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->cState, pReader->fid, TD_GT);
|
||||||
|
|
||||||
if (pSet == NULL) goto _exit;
|
if (pSet == NULL) goto _exit;
|
||||||
|
|
||||||
|
|
@ -159,7 +159,7 @@ _err:
|
||||||
static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STsdb* pTsdb = pReader->pTsdb;
|
STsdb* pTsdb = pReader->pTsdb;
|
||||||
SDelFile* pDelFile = pTsdb->fs->cState->pDelFile;
|
SDelFile* pDelFile = pTsdb->pFS->cState->pDelFile;
|
||||||
|
|
||||||
if (pReader->pDelFReader == NULL) {
|
if (pReader->pDelFReader == NULL) {
|
||||||
if (pDelFile == NULL) {
|
if (pDelFile == NULL) {
|
||||||
|
|
@ -798,7 +798,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
|
||||||
code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW, NULL);
|
code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW, NULL);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSStateUpsertDFileSet(pTsdb->fs->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
code = tsdbFSStateUpsertDFileSet(pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
|
code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
|
||||||
|
|
@ -843,7 +843,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
|
||||||
pWriter->fid = fid;
|
pWriter->fid = fid;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid, TD_EQ);
|
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, fid, TD_EQ);
|
||||||
if (pSet) {
|
if (pSet) {
|
||||||
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
|
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
@ -907,7 +907,7 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
|
||||||
STsdb* pTsdb = pWriter->pTsdb;
|
STsdb* pTsdb = pWriter->pTsdb;
|
||||||
|
|
||||||
if (pWriter->pDelFWriter == NULL) {
|
if (pWriter->pDelFWriter == NULL) {
|
||||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->nState);
|
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->nState);
|
||||||
|
|
||||||
// reader
|
// reader
|
||||||
if (pDelFile) {
|
if (pDelFile) {
|
||||||
|
|
@ -1017,7 +1017,7 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
|
||||||
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
|
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pWriter->pDelFWriter->fDel);
|
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pWriter->pDelFWriter->fDel);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
|
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
|
||||||
|
|
@ -1096,7 +1096,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbFSBegin(pTsdb->fs);
|
code = tsdbFSBegin(pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
|
|
@ -1113,7 +1113,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||||
STsdbSnapWriter* pWriter = *ppWriter;
|
STsdbSnapWriter* pWriter = *ppWriter;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
code = tsdbFSRollback(pWriter->pTsdb->fs);
|
code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
} else {
|
} else {
|
||||||
code = tsdbSnapWriteDataEnd(pWriter);
|
code = tsdbSnapWriteDataEnd(pWriter);
|
||||||
|
|
@ -1122,7 +1122,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||||
code = tsdbSnapWriteDelEnd(pWriter);
|
code = tsdbSnapWriteDelEnd(pWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
code = tsdbFSCommit(pWriter->pTsdb->fs);
|
code = tsdbFSCommit(pWriter->pTsdb->pFS);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/* ------------------------ STRUCTURES ------------------------ */
|
/* ------------------------ STRUCTURES ------------------------ */
|
||||||
|
|
||||||
static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool);
|
static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool);
|
||||||
static int vnodeBufPoolDestroy(SVBufPool *pPool);
|
static int vnodeBufPoolDestroy(SVBufPool *pPool);
|
||||||
|
|
||||||
int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
||||||
|
|
@ -28,7 +28,7 @@ int vnodeOpenBufPool(SVnode *pVnode, int64_t size) {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
// create pool
|
// create pool
|
||||||
ret = vnodeBufPoolCreate(size, &pPool);
|
ret = vnodeBufPoolCreate(pVnode, size, &pPool);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
vnodeCloseBufPool(pVnode);
|
vnodeCloseBufPool(pVnode);
|
||||||
|
|
@ -120,7 +120,7 @@ void vnodeBufPoolFree(SVBufPool *pPool, void *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATIC METHODS -------------------
|
// STATIC METHODS -------------------
|
||||||
static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool) {
|
static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool) {
|
||||||
SVBufPool *pPool;
|
SVBufPool *pPool;
|
||||||
|
|
||||||
pPool = taosMemoryMalloc(sizeof(SVBufPool) + size);
|
pPool = taosMemoryMalloc(sizeof(SVBufPool) + size);
|
||||||
|
|
@ -130,6 +130,7 @@ static int vnodeBufPoolCreate(int64_t size, SVBufPool **ppPool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pPool->next = NULL;
|
pPool->next = NULL;
|
||||||
|
pPool->pVnode = pVnode;
|
||||||
pPool->nRef = 0;
|
pPool->nRef = 0;
|
||||||
pPool->size = 0;
|
pPool->size = 0;
|
||||||
pPool->ptr = pPool->node.data;
|
pPool->ptr = pPool->node.data;
|
||||||
|
|
@ -146,4 +147,26 @@ static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||||
vnodeBufPoolReset(pPool);
|
vnodeBufPoolReset(pPool);
|
||||||
taosMemoryFree(pPool);
|
taosMemoryFree(pPool);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnodeBufPoolRef(SVBufPool *pPool) {
|
||||||
|
int32_t nRef = atomic_fetch_add_32(&pPool->nRef, 1);
|
||||||
|
ASSERT(nRef > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnodeBufPoolUnRef(SVBufPool *pPool) {
|
||||||
|
int32_t nRef = atomic_sub_fetch_32(&pPool->nRef, 1);
|
||||||
|
if (nRef == 0) {
|
||||||
|
SVnode *pVnode = pPool->pVnode;
|
||||||
|
|
||||||
|
vnodeBufPoolReset(pPool);
|
||||||
|
|
||||||
|
taosThreadMutexLock(&pVnode->mutex);
|
||||||
|
|
||||||
|
pPool->next = pVnode->pPool;
|
||||||
|
pVnode->pPool = pPool;
|
||||||
|
taosThreadCondSignal(&pVnode->poolNotEmpty);
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
#define VND_INFO_FNAME "vnode.json"
|
#define VND_INFO_FNAME "vnode.json"
|
||||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||||
|
|
||||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||||
|
|
@ -27,18 +27,18 @@ static void vnodeWaitCommit(SVnode *pVnode);
|
||||||
|
|
||||||
int vnodeBegin(SVnode *pVnode) {
|
int vnodeBegin(SVnode *pVnode) {
|
||||||
// alloc buffer pool
|
// alloc buffer pool
|
||||||
/* pthread_mutex_lock(); */
|
taosThreadMutexLock(&pVnode->mutex);
|
||||||
|
|
||||||
while (pVnode->pPool == NULL) {
|
while (pVnode->pPool == NULL) {
|
||||||
/* pthread_cond_wait(); */
|
taosThreadCondWait(&pVnode->poolNotEmpty, &pVnode->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->inUse = pVnode->pPool;
|
pVnode->inUse = pVnode->pPool;
|
||||||
|
pVnode->inUse->nRef = 1;
|
||||||
pVnode->pPool = pVnode->inUse->next;
|
pVnode->pPool = pVnode->inUse->next;
|
||||||
pVnode->inUse->next = NULL;
|
pVnode->inUse->next = NULL;
|
||||||
/* ref pVnode->inUse buffer pool */
|
|
||||||
|
|
||||||
/* pthread_mutex_unlock(); */
|
taosThreadMutexUnlock(&pVnode->mutex);
|
||||||
|
|
||||||
pVnode->state.commitID++;
|
pVnode->state.commitID++;
|
||||||
// begin meta
|
// begin meta
|
||||||
|
|
@ -217,7 +217,7 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64, TD_VID(pVnode), pVnode->state.commitID,
|
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64, TD_VID(pVnode), pVnode->state.commitID,
|
||||||
pVnode->state.applied);
|
pVnode->state.applied);
|
||||||
|
|
||||||
pVnode->onCommit = pVnode->inUse;
|
vnodeBufPoolUnRef(pVnode->inUse);
|
||||||
pVnode->inUse = NULL;
|
pVnode->inUse = NULL;
|
||||||
|
|
||||||
// save info
|
// save info
|
||||||
|
|
@ -284,10 +284,6 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
|
|
||||||
// apply the commit (TODO)
|
// apply the commit (TODO)
|
||||||
walEndSnapshot(pVnode->pWal);
|
walEndSnapshot(pVnode->pWal);
|
||||||
vnodeBufPoolReset(pVnode->onCommit);
|
|
||||||
pVnode->onCommit->next = pVnode->pPool;
|
|
||||||
pVnode->pPool = pVnode->onCommit;
|
|
||||||
pVnode->onCommit = NULL;
|
|
||||||
|
|
||||||
vInfo("vgId:%d, commit over", TD_VID(pVnode));
|
vInfo("vgId:%d, commit over", TD_VID(pVnode));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
tsem_init(&pVnode->syncSem, 0, 0);
|
tsem_init(&pVnode->syncSem, 0, 0);
|
||||||
tsem_init(&(pVnode->canCommit), 0, 1);
|
tsem_init(&(pVnode->canCommit), 0, 1);
|
||||||
|
taosThreadMutexInit(&pVnode->mutex, NULL);
|
||||||
|
taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
|
||||||
|
|
||||||
// open buffer pool
|
// open buffer pool
|
||||||
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
||||||
|
|
@ -195,6 +197,8 @@ void vnodeClose(SVnode *pVnode) {
|
||||||
// destroy handle
|
// destroy handle
|
||||||
tsem_destroy(&(pVnode->canCommit));
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
tsem_destroy(&pVnode->syncSem);
|
tsem_destroy(&pVnode->syncSem);
|
||||||
|
taosThreadCondDestroy(&pVnode->poolNotEmpty);
|
||||||
|
taosThreadMutexDestroy(&pVnode->mutex);
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,6 +532,14 @@ typedef struct SCtgOperation {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define CTG_API_JENTER() do { \
|
||||||
|
CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \
|
||||||
|
CTG_LOCK(CTG_READ, &gCtgMgmt.lock); \
|
||||||
|
if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_CTG_OUT_OF_SERVICE); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define CTG_API_LEAVE_NOLOCK(c) do { \
|
#define CTG_API_LEAVE_NOLOCK(c) do { \
|
||||||
int32_t __code = c; \
|
int32_t __code = c; \
|
||||||
|
|
|
||||||
|
|
@ -244,10 +244,11 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
||||||
int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SCtgJob* pJob = NULL;
|
||||||
|
|
||||||
CTG_API_ENTER();
|
CTG_API_JENTER();
|
||||||
|
|
||||||
SCtgJob* pJob = taosAcquireRef(gCtgMgmt.jobPool, cbParam->refId);
|
pJob = taosAcquireRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
qDebug("ctg job refId 0x%" PRIx64 " already dropped", cbParam->refId);
|
qDebug("ctg job refId 0x%" PRIx64 " already dropped", cbParam->refId);
|
||||||
goto _return;
|
goto _return;
|
||||||
|
|
@ -266,8 +267,6 @@ _return:
|
||||||
if (pJob) {
|
if (pJob) {
|
||||||
taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId);
|
taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(param);
|
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
@ -293,6 +292,7 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
||||||
param->taskId = pTask->taskId;
|
param->taskId = pTask->taskId;
|
||||||
|
|
||||||
msgSendInfo->param = param;
|
msgSendInfo->param = param;
|
||||||
|
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
msgSendInfo->fp = ctgHandleMsgCallback;
|
msgSendInfo->fp = ctgHandleMsgCallback;
|
||||||
|
|
||||||
*pMsgSendInfo = msgSendInfo;
|
*pMsgSendInfo = msgSendInfo;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,6 @@ _return:
|
||||||
tsem_post(&pInserter->ready);
|
tsem_post(&pInserter->ready);
|
||||||
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(param);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +109,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
|
||||||
pParam->pInserter = pInserter;
|
pParam->pInserter = pInserter;
|
||||||
|
|
||||||
pMsgSendInfo->param = pParam;
|
pMsgSendInfo->param = pParam;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = ntohl(pMsg->length);
|
pMsgSendInfo->msgInfo.len = ntohl(pMsg->length);
|
||||||
pMsgSendInfo->msgType = TDMT_VND_SUBMIT;
|
pMsgSendInfo->msgType = TDMT_VND_SUBMIT;
|
||||||
|
|
|
||||||
|
|
@ -1994,16 +1994,9 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tsem_post(&pExchangeInfo->ready);
|
tsem_post(&pExchangeInfo->ready);
|
||||||
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
taosReleaseRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||||
|
|
||||||
taosMemoryFree(pWrapper);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
|
||||||
assert(pMsgBody != NULL);
|
|
||||||
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
|
||||||
taosMemoryFreeClear(pMsgBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
||||||
assert(pMsg->info.ahandle != NULL);
|
assert(pMsg->info.ahandle != NULL);
|
||||||
|
|
@ -2063,6 +2056,7 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
pWrapper->sourceIndex = sourceIndex;
|
pWrapper->sourceIndex = sourceIndex;
|
||||||
|
|
||||||
pMsgSendInfo->param = pWrapper;
|
pMsgSendInfo->param = pWrapper;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->msgInfo.pData = pMsg;
|
pMsgSendInfo->msgInfo.pData = pMsg;
|
||||||
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
pMsgSendInfo->msgInfo.len = sizeof(SResFetchReq);
|
||||||
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
pMsgSendInfo->msgType = pSource->fetchMsgType;
|
||||||
|
|
@ -4424,7 +4418,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
.calTrigger = pTableScanNode->triggerType,
|
.calTrigger = pTableScanNode->triggerType,
|
||||||
.maxTs = INT64_MIN,
|
.maxTs = INT64_MIN,
|
||||||
};
|
};
|
||||||
if (pHandle) {
|
if (pHandle->vnode) {
|
||||||
int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags,
|
int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags,
|
||||||
pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
||||||
if (code) {
|
if (code) {
|
||||||
|
|
@ -4590,7 +4584,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
int32_t children = 0;
|
int32_t children = 0;
|
||||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) {
|
||||||
int32_t children = 1;
|
int32_t children = pHandle->numOfVgroups;
|
||||||
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) {
|
||||||
pOptr = createSortOperatorInfo(ops[0], (SSortPhysiNode*)pPhyNode, pTaskInfo);
|
pOptr = createSortOperatorInfo(ops[0], (SSortPhysiNode*)pPhyNode, pTaskInfo);
|
||||||
|
|
|
||||||
|
|
@ -1538,7 +1538,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle) {
|
if (pHandle->vnode) {
|
||||||
SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
|
||||||
STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info;
|
STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info;
|
||||||
if (pHandle->version > 0) {
|
if (pHandle->version > 0) {
|
||||||
|
|
|
||||||
|
|
@ -5098,12 +5098,7 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) {
|
static void doModeAdd(SModeInfo* pInfo, char* data) {
|
||||||
// ignore null elements
|
|
||||||
if (isNull) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
||||||
SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
||||||
if (pHashItem == NULL) {
|
if (pHashItem == NULL) {
|
||||||
|
|
@ -5128,10 +5123,16 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||||
|
|
||||||
|
int32_t numOfElems = 0;
|
||||||
int32_t startOffset = pCtx->offset;
|
int32_t startOffset = pCtx->offset;
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
doModeAdd(pInfo, data, colDataIsNull_s(pInputCol, i));
|
if (colDataIsNull_s(pInputCol, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfElems++;
|
||||||
|
doModeAdd(pInfo, data);
|
||||||
|
|
||||||
if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) {
|
if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) {
|
||||||
taosHashCleanup(pInfo->pHash);
|
taosHashCleanup(pInfo->pHash);
|
||||||
|
|
@ -5139,7 +5140,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VAL(pResInfo, 1, 1);
|
SET_VAL(pResInfo, numOfElems, 1);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -5661,7 +5662,12 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
|
||||||
double r = ((v - pDerivInfo->prevValue) * pDerivInfo->tsWindow) / (tsList[i] - pDerivInfo->prevTs);
|
double r = ((v - pDerivInfo->prevValue) * pDerivInfo->tsWindow) / (tsList[i] - pDerivInfo->prevTs);
|
||||||
if (pDerivInfo->ignoreNegative && r < 0) {
|
if (pDerivInfo->ignoreNegative && r < 0) {
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutput, pos, (const char*)&r, false);
|
if (isinf(r) || isnan(r)) {
|
||||||
|
colDataAppendNULL(pOutput, pos);
|
||||||
|
} else {
|
||||||
|
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (pTsOutput != NULL) {
|
if (pTsOutput != NULL) {
|
||||||
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -5688,7 +5694,12 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) {
|
||||||
double r = ((pDerivInfo->prevValue - v) * pDerivInfo->tsWindow) / (pDerivInfo->prevTs - tsList[i]);
|
double r = ((pDerivInfo->prevValue - v) * pDerivInfo->tsWindow) / (pDerivInfo->prevTs - tsList[i]);
|
||||||
if (pDerivInfo->ignoreNegative && r < 0) {
|
if (pDerivInfo->ignoreNegative && r < 0) {
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutput, pos, (const char*)&r, false);
|
if (isinf(r) || isnan(r)) {
|
||||||
|
colDataAppendNULL(pOutput, pos);
|
||||||
|
} else {
|
||||||
|
colDataAppend(pOutput, pos, (const char*)&r, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (pTsOutput != NULL) {
|
if (pTsOutput != NULL) {
|
||||||
colDataAppendInt64(pTsOutput, pos, &pDerivInfo->prevTs);
|
colDataAppendInt64(pTsOutput, pos, &pDerivInfo->prevTs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1923,15 +1923,18 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
|
||||||
return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond);
|
return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needOutput = false;
|
||||||
switch (classifyCondition(*pCondition)) {
|
switch (classifyCondition(*pCondition)) {
|
||||||
case COND_TYPE_PRIMARY_KEY:
|
case COND_TYPE_PRIMARY_KEY:
|
||||||
if (NULL != pPrimaryKeyCond) {
|
if (NULL != pPrimaryKeyCond) {
|
||||||
*pPrimaryKeyCond = *pCondition;
|
*pPrimaryKeyCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COND_TYPE_TAG_INDEX:
|
case COND_TYPE_TAG_INDEX:
|
||||||
if (NULL != pTagIndexCond) {
|
if (NULL != pTagIndexCond) {
|
||||||
*pTagIndexCond = *pCondition;
|
*pTagIndexCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
if (NULL != pTagCond) {
|
if (NULL != pTagCond) {
|
||||||
SNode* pTempCond = *pCondition;
|
SNode* pTempCond = *pCondition;
|
||||||
|
|
@ -1942,21 +1945,26 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pTagCond = pTempCond;
|
*pTagCond = pTempCond;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COND_TYPE_TAG:
|
case COND_TYPE_TAG:
|
||||||
if (NULL != pTagCond) {
|
if (NULL != pTagCond) {
|
||||||
*pTagCond = *pCondition;
|
*pTagCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COND_TYPE_NORMAL:
|
case COND_TYPE_NORMAL:
|
||||||
default:
|
default:
|
||||||
if (NULL != pOtherCond) {
|
if (NULL != pOtherCond) {
|
||||||
*pOtherCond = *pCondition;
|
*pOtherCond = *pCondition;
|
||||||
|
needOutput = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*pCondition = NULL;
|
if (needOutput) {
|
||||||
|
*pCondition = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,16 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
||||||
|
assert(pMsgBody != NULL);
|
||||||
|
taosMemoryFreeClear(pMsgBody->target.dbFName);
|
||||||
|
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
||||||
|
if (pMsgBody->paramFreeFp) {
|
||||||
|
(*pMsgBody->paramFreeFp)(pMsgBody->param);
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pMsgBody);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
||||||
bool persistHandle, void* rpcCtx) {
|
bool persistHandle, void* rpcCtx) {
|
||||||
char* pMsg = rpcMallocCont(pInfo->msgInfo.len);
|
char* pMsg = rpcMallocCont(pInfo->msgInfo.len);
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ typedef struct SSchJob {
|
||||||
bool fetched;
|
bool fetched;
|
||||||
int32_t resNumOfRows;
|
int32_t resNumOfRows;
|
||||||
SSchResInfo userRes;
|
SSchResInfo userRes;
|
||||||
const char *sql;
|
char *sql;
|
||||||
SQueryProfileSummary summary;
|
SQueryProfileSummary summary;
|
||||||
} SSchJob;
|
} SSchJob;
|
||||||
|
|
||||||
|
|
@ -461,7 +461,6 @@ int32_t schJobFetchRows(SSchJob *pJob);
|
||||||
int32_t schJobFetchRowsA(SSchJob *pJob);
|
int32_t schJobFetchRowsA(SSchJob *pJob);
|
||||||
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId);
|
int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId);
|
||||||
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList);
|
||||||
void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo);
|
|
||||||
char* schGetOpStr(SCH_OP_TYPE type);
|
char* schGetOpStr(SCH_OP_TYPE type);
|
||||||
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync);
|
||||||
int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq);
|
int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq);
|
||||||
|
|
|
||||||
|
|
@ -675,6 +675,7 @@ void schFreeJobImpl(void *job) {
|
||||||
|
|
||||||
taosMemoryFreeClear(pJob->userRes.execRes);
|
taosMemoryFreeClear(pJob->userRes.execRes);
|
||||||
taosMemoryFreeClear(pJob->fetchRes);
|
taosMemoryFreeClear(pJob->fetchRes);
|
||||||
|
taosMemoryFreeClear(pJob->sql);
|
||||||
taosMemoryFree(pJob);
|
taosMemoryFree(pJob);
|
||||||
|
|
||||||
int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1);
|
int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1);
|
||||||
|
|
@ -718,7 +719,9 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
|
||||||
|
|
||||||
pJob->attr.explainMode = pReq->pDag->explainInfo.mode;
|
pJob->attr.explainMode = pReq->pDag->explainInfo.mode;
|
||||||
pJob->conn = *pReq->pConn;
|
pJob->conn = *pReq->pConn;
|
||||||
pJob->sql = pReq->sql;
|
if (pReq->sql) {
|
||||||
|
pJob->sql = strdup(pReq->sql);
|
||||||
|
}
|
||||||
pJob->pDag = pReq->pDag;
|
pJob->pDag = pReq->pDag;
|
||||||
pJob->chkKillFp = pReq->chkKillFp;
|
pJob->chkKillFp = pReq->chkKillFp;
|
||||||
pJob->chkKillParam = pReq->chkKillParam;
|
pJob->chkKillParam = pReq->chkKillParam;
|
||||||
|
|
|
||||||
|
|
@ -386,7 +386,6 @@ int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
schProcessOnCbEnd(pJob, pTask, code);
|
schProcessOnCbEnd(pJob, pTask, code);
|
||||||
|
|
||||||
taosMemoryFreeClear(pMsg->pData);
|
taosMemoryFreeClear(pMsg->pData);
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
|
|
||||||
qDebug("end to handle rsp msg, type:%s, handle:%p, code:%s", TMSG_INFO(pMsg->msgType), pMsg->handle,
|
qDebug("end to handle rsp msg, type:%s, handle:%p, code:%s", TMSG_INFO(pMsg->msgType), pMsg->handle,
|
||||||
tstrerror(rspCode));
|
tstrerror(rspCode));
|
||||||
|
|
@ -398,7 +397,6 @@ int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId,
|
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId,
|
||||||
code);
|
code);
|
||||||
taosMemoryFreeClear(param);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,8 +445,8 @@ int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SCH_ERR_JRET(schProcessOnTaskStatusRsp(&rsp.epId, rsp.taskStatus));
|
SCH_ERR_JRET(schProcessOnTaskStatusRsp(&rsp.epId, rsp.taskStatus));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
tFreeSSchedulerHbRsp(&rsp);
|
tFreeSSchedulerHbRsp(&rsp);
|
||||||
taosMemoryFree(param);
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
@ -514,7 +512,9 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param));
|
SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param));
|
||||||
|
|
||||||
SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp));
|
SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp));
|
||||||
|
|
||||||
if (pJob) {
|
if (pJob) {
|
||||||
|
|
@ -535,7 +535,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
schFreeSMsgSendInfo(msgSendInfo);
|
destroySendMsgInfo(msgSendInfo);
|
||||||
|
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
@ -676,6 +676,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
param->pTrans = pJob->conn.pTrans;
|
param->pTrans = pJob->conn.pTrans;
|
||||||
|
|
||||||
pMsgSendInfo->param = param;
|
pMsgSendInfo->param = param;
|
||||||
|
pMsgSendInfo->paramFreeFp = taosMemoryFree;
|
||||||
pMsgSendInfo->fp = fp;
|
pMsgSendInfo->fp = fp;
|
||||||
|
|
||||||
SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo};
|
SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo};
|
||||||
|
|
@ -795,6 +796,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) {
|
||||||
pDst->param = NULL;
|
pDst->param = NULL;
|
||||||
|
|
||||||
SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param));
|
SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param));
|
||||||
|
pDst->paramFreeFp = taosMemoryFree;
|
||||||
|
|
||||||
*dst = pDst;
|
*dst = pDst;
|
||||||
|
|
||||||
|
|
@ -861,8 +863,7 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsgSendInfo) {
|
if (pMsgSendInfo) {
|
||||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
destroySendMsgInfo(pMsgSendInfo);
|
||||||
taosMemoryFreeClear(pMsgSendInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,12 @@ char* schGetOpStr(SCH_OP_TYPE type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void schFreeHbTrans(SSchHbTrans *pTrans) {
|
||||||
|
rpcReleaseHandle(pTrans->trans.pHandle, TAOS_CONN_CLIENT);
|
||||||
|
|
||||||
|
schFreeRpcCtx(&pTrans->rpcCtx);
|
||||||
|
}
|
||||||
|
|
||||||
void schCleanClusterHb(void* pTrans) {
|
void schCleanClusterHb(void* pTrans) {
|
||||||
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
|
||||||
|
|
@ -57,7 +63,7 @@ void schCleanClusterHb(void* pTrans) {
|
||||||
while (hb) {
|
while (hb) {
|
||||||
if (hb->trans.pTrans == pTrans) {
|
if (hb->trans.pTrans == pTrans) {
|
||||||
SQueryNodeEpId* pEpId = taosHashGetKey(hb, NULL);
|
SQueryNodeEpId* pEpId = taosHashGetKey(hb, NULL);
|
||||||
rpcReleaseHandle(hb->trans.pHandle, TAOS_CONN_CLIENT);
|
schFreeHbTrans(hb);
|
||||||
taosHashRemove(schMgmt.hbConnections, pEpId, sizeof(SQueryNodeEpId));
|
taosHashRemove(schMgmt.hbConnections, pEpId, sizeof(SQueryNodeEpId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,8 +74,6 @@ void schCleanClusterHb(void* pTrans) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId) {
|
int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId) {
|
||||||
return TSDB_CODE_SUCCESS; // TODO ENABLE IT WHEN RPC IS READY
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_LOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
|
@ -82,7 +86,7 @@ int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *ep
|
||||||
|
|
||||||
int64_t taskNum = atomic_load_64(&hb->taskNum);
|
int64_t taskNum = atomic_load_64(&hb->taskNum);
|
||||||
if (taskNum <= 0) {
|
if (taskNum <= 0) {
|
||||||
rpcReleaseHandle(hb->trans.pHandle, TAOS_CONN_CLIENT);
|
schFreeHbTrans(hb);
|
||||||
taosHashRemove(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId));
|
taosHashRemove(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId));
|
||||||
}
|
}
|
||||||
SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
|
@ -265,9 +269,7 @@ void schFreeRpcCtxVal(const void *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgSendInfo *pMsgSendInfo = (SMsgSendInfo *)arg;
|
SMsgSendInfo *pMsgSendInfo = (SMsgSendInfo *)arg;
|
||||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
destroySendMsgInfo(pMsgSendInfo);
|
||||||
taosMemoryFreeClear(pMsgSendInfo->msgInfo.pData);
|
|
||||||
taosMemoryFreeClear(pMsgSendInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void schFreeRpcCtx(SRpcCtx *pCtx) {
|
void schFreeRpcCtx(SRpcCtx *pCtx) {
|
||||||
|
|
@ -290,15 +292,6 @@ void schFreeRpcCtx(SRpcCtx *pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void schFreeSMsgSendInfo(SMsgSendInfo *msgSendInfo) {
|
|
||||||
if (NULL == msgSendInfo) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(msgSendInfo->param);
|
|
||||||
taosMemoryFree(msgSendInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) {
|
int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) {
|
||||||
int32_t s = taosHashGetSize(pTaskList);
|
int32_t s = taosHashGetSize(pTaskList);
|
||||||
if (s <= 0) {
|
if (s <= 0) {
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
||||||
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
||||||
|
if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1;
|
||||||
|
|
||||||
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
||||||
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
||||||
|
|
@ -118,6 +119,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
||||||
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
||||||
|
if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1;
|
||||||
|
|
||||||
int32_t epSz;
|
int32_t epSz;
|
||||||
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
||||||
|
|
|
||||||
|
|
@ -1552,7 +1552,8 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
} else {
|
} else {
|
||||||
snprintf(logBuf, sizeof(logBuf), "%s", str);
|
snprintf(logBuf, sizeof(logBuf), "%s", str);
|
||||||
}
|
}
|
||||||
sDebug("%s", logBuf);
|
// sDebug("%s", logBuf);
|
||||||
|
sInfo("%s", logBuf);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int len = 256 + userStrLen;
|
int len = 256 + userStrLen;
|
||||||
|
|
@ -1573,7 +1574,8 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
|
||||||
} else {
|
} else {
|
||||||
snprintf(s, len, "%s", str);
|
snprintf(s, len, "%s", str);
|
||||||
}
|
}
|
||||||
sDebug("%s", s);
|
// sDebug("%s", s);
|
||||||
|
sInfo("%s", s);
|
||||||
taosMemoryFree(s);
|
taosMemoryFree(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,15 +120,18 @@ void syncRespClean(SSyncRespMgr *pObj) {
|
||||||
void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl) {
|
void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl) {
|
||||||
SRespStub *pStub = (SRespStub *)taosHashIterate(pObj->pRespHash, NULL);
|
SRespStub *pStub = (SRespStub *)taosHashIterate(pObj->pRespHash, NULL);
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
int sum = 0;
|
||||||
SSyncNode *pSyncNode = pObj->data;
|
SSyncNode *pSyncNode = pObj->data;
|
||||||
|
|
||||||
SArray *delIndexArray = taosArrayInit(0, sizeof(uint64_t));
|
SArray *delIndexArray = taosArrayInit(0, sizeof(uint64_t));
|
||||||
ASSERT(delIndexArray != NULL);
|
ASSERT(delIndexArray != NULL);
|
||||||
|
sDebug("vgId:%d, resp mgr begin clean by ttl", pSyncNode->vgId);
|
||||||
|
|
||||||
while (pStub) {
|
while (pStub) {
|
||||||
size_t len;
|
size_t len;
|
||||||
void * key = taosHashGetKey(pStub, &len);
|
void *key = taosHashGetKey(pStub, &len);
|
||||||
uint64_t *pSeqNum = (uint64_t *)key;
|
uint64_t *pSeqNum = (uint64_t *)key;
|
||||||
|
sum++;
|
||||||
|
|
||||||
int64_t nowMS = taosGetTimestampMs();
|
int64_t nowMS = taosGetTimestampMs();
|
||||||
if (nowMS - pStub->createTime > ttl) {
|
if (nowMS - pStub->createTime > ttl) {
|
||||||
|
|
@ -155,7 +158,7 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t arraySize = taosArrayGetSize(delIndexArray);
|
int32_t arraySize = taosArrayGetSize(delIndexArray);
|
||||||
sDebug("vgId:%d, resp mgr clean by ttl, cnt:%d, array-size:%d", pSyncNode->vgId, cnt, arraySize);
|
sDebug("vgId:%d, resp mgr end clean by ttl, sum:%d, cnt:%d, array-size:%d", pSyncNode->vgId, sum, cnt, arraySize);
|
||||||
|
|
||||||
for (int32_t i = 0; i < arraySize; ++i) {
|
for (int32_t i = 0; i < arraySize; ++i) {
|
||||||
uint64_t *pSeqNum = taosArrayGet(delIndexArray, i);
|
uint64_t *pSeqNum = taosArrayGet(delIndexArray, i);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@
|
||||||
# unsupport ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim
|
# unsupport ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim
|
||||||
# unsupport ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim
|
# unsupport ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim
|
||||||
# unsupport ./test.sh -f tsim/dnode/vnode_clean.sim
|
# unsupport ./test.sh -f tsim/dnode/vnode_clean.sim
|
||||||
|
./test.sh -f tsim/dnode/use_dropped_dnode.sim
|
||||||
|
|
||||||
# ---- import
|
# ---- import
|
||||||
./test.sh -f tsim/import/basic.sim
|
./test.sh -f tsim/import/basic.sim
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/deploy.sh -n dnode2 -i 2
|
||||||
|
system sh/deploy.sh -n dnode3 -i 3
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
system sh/exec.sh -n dnode2 -s start
|
||||||
|
system sh/exec.sh -n dnode3 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print =============== step1 create dnode2
|
||||||
|
sql create dnode $hostname port 7200
|
||||||
|
sql create dnode $hostname port 7300
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
step1:
|
||||||
|
$ = $x + 1
|
||||||
|
sleep 1000
|
||||||
|
if $x == 10 then
|
||||||
|
print ====> dnode not online!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
print ===> $data20 $data21 $data22 $data23 $data24 $data25
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data(1)[4] != ready then
|
||||||
|
goto step1
|
||||||
|
endi
|
||||||
|
if $data(2)[4] != ready then
|
||||||
|
goto step1
|
||||||
|
endi
|
||||||
|
if $data(3)[4] != ready then
|
||||||
|
goto step1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step2 drop dnode 3
|
||||||
|
sql drop dnode 3
|
||||||
|
sql create dnode $hostname port 7300
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
step2:
|
||||||
|
$ = $x + 1
|
||||||
|
sleep 1000
|
||||||
|
if $x == 10 then
|
||||||
|
print ====> dnode not online!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
print ===> $data20 $data21 $data22 $data23 $data24 $data25
|
||||||
|
print ===> $data30 $data31 $data32 $data33 $data34 $data35
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data(1)[4] != ready then
|
||||||
|
goto step2
|
||||||
|
endi
|
||||||
|
if $data(2)[4] != ready then
|
||||||
|
goto step2
|
||||||
|
endi
|
||||||
|
if $data(3)[4] != null then
|
||||||
|
goto step2
|
||||||
|
endi
|
||||||
|
if $data(4)[4] != offline then
|
||||||
|
goto step2
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step3: create dnode 4
|
||||||
|
sleep 1000
|
||||||
|
system sh/exec.sh -n dnode3 -s stop -x SIGINT
|
||||||
|
system sh/deploy.sh -n dnode3 -i 3
|
||||||
|
system sh/exec.sh -n dnode3 -s start
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
step3:
|
||||||
|
$ = $x + 1
|
||||||
|
sleep 1000
|
||||||
|
if $x == 10 then
|
||||||
|
print ====> dnode not online!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
print ===> $data20 $data21 $data22 $data23 $data24 $data25
|
||||||
|
print ===> $data30 $data31 $data32 $data33 $data34 $data35
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data(1)[4] != ready then
|
||||||
|
goto step3
|
||||||
|
endi
|
||||||
|
if $data(2)[4] != ready then
|
||||||
|
goto step3
|
||||||
|
endi
|
||||||
|
if $data(3)[4] != null then
|
||||||
|
goto step3
|
||||||
|
endi
|
||||||
|
if $data(4)[4] != ready then
|
||||||
|
goto step3
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== step4: create mnode 4
|
||||||
|
sql create mnode on dnode 4
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
step4:
|
||||||
|
$ = $x + 1
|
||||||
|
sleep 1000
|
||||||
|
if $x == 10 then
|
||||||
|
print ====> dnode not online!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show mnodes
|
||||||
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data(1)[2] != leader then
|
||||||
|
goto step4
|
||||||
|
endi
|
||||||
|
if $data(4)[2] != follower then
|
||||||
|
goto step4
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
|
system sh/exec.sh -n dnode3 -s stop -x SIGINT
|
||||||
|
|
@ -24,7 +24,7 @@ class TDTestCase:
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
self.dbname = 'db'
|
self.dbname = 'db'
|
||||||
self.delaytime = 10
|
self.delaytime = 3
|
||||||
def get_database_info(self):
|
def get_database_info(self):
|
||||||
tdSql.query('select database()')
|
tdSql.query('select database()')
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
|
|
@ -42,12 +42,13 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,0,version_info)
|
tdSql.checkData(0,0,version_info)
|
||||||
|
|
||||||
def get_server_status(self):
|
def get_server_status(self):
|
||||||
|
sleep(self.delaytime)
|
||||||
tdSql.query('select server_status()')
|
tdSql.query('select server_status()')
|
||||||
tdSql.checkData(0,0,1)
|
tdSql.checkData(0,0,1)
|
||||||
#!for bug
|
#!for bug
|
||||||
# tdDnodes.stoptaosd(1)
|
tdDnodes.stoptaosd(1)
|
||||||
# sleep(self.delaytime)
|
sleep(self.delaytime)
|
||||||
# tdSql.error('select server_status()')
|
tdSql.error('select server_status()')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.get_database_info()
|
self.get_database_info()
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ class TDTestCase:
|
||||||
#taosc core dumped
|
#taosc core dumped
|
||||||
tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))")
|
tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))")
|
||||||
tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;")
|
tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;")
|
||||||
|
tdSql.query("select name,diff(mv) AS difka FROM (SELECT ts,name,mv FROM (SELECT _wstart as ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0))) group BY name ;")
|
||||||
tdSql.query("SELECT _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0)")
|
tdSql.query("SELECT _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0)")
|
||||||
|
|
||||||
# 7. avg-load
|
# 7. avg-load
|
||||||
|
|
@ -124,9 +125,16 @@ class TDTestCase:
|
||||||
|
|
||||||
#it's already supported:
|
#it's already supported:
|
||||||
# last-loc
|
# last-loc
|
||||||
tdSql.query("")
|
tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;")
|
||||||
|
|
||||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
|
||||||
|
#2. low-fuel
|
||||||
|
tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;")
|
||||||
|
|
||||||
|
# 3. avg-vs-projected-fuel-consumption
|
||||||
|
tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
|
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
|
||||||
self.prepareData()
|
self.prepareData()
|
||||||
self.tsbsIotQuery()
|
self.tsbsIotQuery()
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ class TDTestCase:
|
||||||
tdSql.error("alter database db strict 'off'")
|
tdSql.error("alter database db strict 'off'")
|
||||||
# tdSql.execute('alter database db strict 'on'')
|
# tdSql.execute('alter database db strict 'on'')
|
||||||
# tdSql.query('show databases;')
|
# tdSql.query('show databases;')
|
||||||
# tdSql.checkData(2,5,'strict')
|
# tdSql.checkData(2,5,'on')
|
||||||
|
|
||||||
def getConnection(self, dnode):
|
def getConnection(self, dnode):
|
||||||
host = dnode.cfgDict["fqdn"]
|
host = dnode.cfgDict["fqdn"]
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ class TDTestCase:
|
||||||
'ctbPrefix': 'ctb',
|
'ctbPrefix': 'ctb',
|
||||||
'ctbNum': 200,
|
'ctbNum': 200,
|
||||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
"rowsPerTbl": 1000,
|
"rowsPerTbl": 100,
|
||||||
"batchNum": 5000
|
"batchNum": 5000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ class TDTestCase:
|
||||||
tdSql.checkRows(rowsPerStb)
|
tdSql.checkRows(rowsPerStb)
|
||||||
def run(self):
|
def run(self):
|
||||||
# print(self.master_dnode.cfgDict)
|
# print(self.master_dnode.cfgDict)
|
||||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
|
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class TDTestCase:
|
||||||
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
|
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
|
||||||
tdLog.printNoPrefix("======== test case 1: ")
|
tdLog.printNoPrefix("======== test case 1: ")
|
||||||
paraDict = {'dbName': 'db',
|
paraDict = {'dbName': 'db',
|
||||||
'dbNumbers': 20,
|
'dbNumbers': 6,
|
||||||
'dropFlag': 1,
|
'dropFlag': 1,
|
||||||
'event': '',
|
'event': '',
|
||||||
'vgroups': 4,
|
'vgroups': 4,
|
||||||
|
|
@ -110,7 +110,7 @@ class TDTestCase:
|
||||||
print(tdSql.queryResult)
|
print(tdSql.queryResult)
|
||||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||||
|
|
||||||
# create database and stable
|
tdLog.info("create database and stable")
|
||||||
tdDnodes=cluster.dnodes
|
tdDnodes=cluster.dnodes
|
||||||
stopcount =0
|
stopcount =0
|
||||||
threads=[]
|
threads=[]
|
||||||
|
|
@ -156,10 +156,16 @@ class TDTestCase:
|
||||||
|
|
||||||
for tr in threads:
|
for tr in threads:
|
||||||
tr.join()
|
tr.join()
|
||||||
|
tdLog.info("check dnode number:")
|
||||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||||
clusterComCheck.checkDbRows(allDbNumbers)
|
tdSql.query("show databases")
|
||||||
for i in range(restartNumbers):
|
tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers-2))
|
||||||
clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
|
|
||||||
|
# tdLog.info("check DB Rows:")
|
||||||
|
# clusterComCheck.checkDbRows(allDbNumbers)
|
||||||
|
# tdLog.info("check DB Status on by on")
|
||||||
|
# for i in range(restartNumbers):
|
||||||
|
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import TDDnodes
|
||||||
|
from util.dnodes import TDDnode
|
||||||
|
from util.cluster import *
|
||||||
|
sys.path.append("./6-cluster")
|
||||||
|
from clusterCommonCreate import *
|
||||||
|
from clusterCommonCheck import clusterComCheck
|
||||||
|
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import subprocess
|
||||||
|
from multiprocessing import Process
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import inspect
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
|
||||||
|
def init(self,conn ,logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
self.TDDnodes = None
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
self.host = socket.gethostname()
|
||||||
|
|
||||||
|
|
||||||
|
def getBuildPath(self):
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
|
break
|
||||||
|
return buildPath
|
||||||
|
|
||||||
|
def _async_raise(self, tid, exctype):
|
||||||
|
"""raises the exception, performs cleanup if needed"""
|
||||||
|
if not inspect.isclass(exctype):
|
||||||
|
exctype = type(exctype)
|
||||||
|
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
|
||||||
|
if res == 0:
|
||||||
|
raise ValueError("invalid thread id")
|
||||||
|
elif res != 1:
|
||||||
|
# """if it returns a number greater than one, you're in trouble,
|
||||||
|
# and you should call it again with exc=NULL to revert the effect"""
|
||||||
|
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
|
||||||
|
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||||
|
|
||||||
|
def stopThread(self,thread):
|
||||||
|
self._async_raise(thread.ident, SystemExit)
|
||||||
|
|
||||||
|
|
||||||
|
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: ")
|
||||||
|
paraDict = {'dbName': 'db',
|
||||||
|
'dbNumbers': 6,
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 4,
|
||||||
|
'replica': 3,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'stbNumbers': 100,
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbNum': 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
dnodeNumbers=int(dnodeNumbers)
|
||||||
|
mnodeNums=int(mnodeNums)
|
||||||
|
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||||
|
allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
|
||||||
|
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||||
|
|
||||||
|
tdLog.info("first check dnode and mnode")
|
||||||
|
tdSql.query("show dnodes;")
|
||||||
|
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||||
|
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||||
|
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||||
|
clusterComCheck.checkMnodeStatus(1)
|
||||||
|
|
||||||
|
# fisr add three mnodes;
|
||||||
|
tdLog.info("fisr add three mnodes and check mnode status")
|
||||||
|
tdSql.execute("create mnode on dnode 2")
|
||||||
|
clusterComCheck.checkMnodeStatus(2)
|
||||||
|
tdSql.execute("create mnode on dnode 3")
|
||||||
|
clusterComCheck.checkMnodeStatus(3)
|
||||||
|
|
||||||
|
# add some error operations and
|
||||||
|
tdLog.info("Confirm the status of the dnode again")
|
||||||
|
tdSql.error("create mnode on dnode 2")
|
||||||
|
tdSql.query("show dnodes;")
|
||||||
|
print(tdSql.queryResult)
|
||||||
|
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||||
|
|
||||||
|
tdLog.info("create database and stable")
|
||||||
|
tdDnodes=cluster.dnodes
|
||||||
|
stopcount =0
|
||||||
|
threads=[]
|
||||||
|
for i in range(restartNumbers):
|
||||||
|
dbNameIndex = '%s%d'%(paraDict["dbName"],i)
|
||||||
|
newTdSql=tdCom.newTdSql()
|
||||||
|
threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(newTdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])))
|
||||||
|
|
||||||
|
for tr in threads:
|
||||||
|
tr.start()
|
||||||
|
|
||||||
|
tdLog.info("Take turns stopping Mnodes ")
|
||||||
|
while stopcount < restartNumbers:
|
||||||
|
tdLog.info(" restart loop: %d"%stopcount )
|
||||||
|
if stopRole == "mnode":
|
||||||
|
for i in range(mnodeNums):
|
||||||
|
tdDnodes[i].stoptaosd()
|
||||||
|
# sleep(10)
|
||||||
|
tdDnodes[i].starttaosd()
|
||||||
|
# sleep(10)
|
||||||
|
elif stopRole == "vnode":
|
||||||
|
for i in range(vnodeNumbers):
|
||||||
|
tdDnodes[i+mnodeNums].stoptaosd()
|
||||||
|
# sleep(10)
|
||||||
|
tdDnodes[i+mnodeNums].starttaosd()
|
||||||
|
# sleep(10)
|
||||||
|
elif stopRole == "dnode":
|
||||||
|
for i in range(dnodeNumbers):
|
||||||
|
tdDnodes[i].stoptaosd()
|
||||||
|
# sleep(10)
|
||||||
|
tdDnodes[i].starttaosd()
|
||||||
|
# sleep(10)
|
||||||
|
|
||||||
|
# dnodeNumbers don't include database of schema
|
||||||
|
if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||||
|
tdLog.info("check dnodes status is ready")
|
||||||
|
else:
|
||||||
|
tdLog.info("check dnodes status is not ready")
|
||||||
|
self.stopThread(threads)
|
||||||
|
tdLog.exit("one or more of dnodes failed to start ")
|
||||||
|
# self.check3mnode()
|
||||||
|
stopcount+=1
|
||||||
|
|
||||||
|
for tr in threads:
|
||||||
|
tr.join()
|
||||||
|
tdLog.info("check dnode number:")
|
||||||
|
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||||
|
tdSql.query("show databases")
|
||||||
|
tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers-2))
|
||||||
|
|
||||||
|
# tdLog.info("check DB Rows:")
|
||||||
|
# clusterComCheck.checkDbRows(allDbNumbers)
|
||||||
|
# tdLog.info("check DB Status on by on")
|
||||||
|
# for i in range(restartNumbers):
|
||||||
|
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
# print(self.master_dnode.cfgDict)
|
||||||
|
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode')
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
@ -189,7 +189,8 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.execute("use %s" %(paraDict["dbName"]))
|
tdSql.execute("use %s" %(paraDict["dbName"]))
|
||||||
tdSql.query("show stables")
|
tdSql.query("show stables")
|
||||||
tdSql.checkRows(allStbNumbers)
|
tdLog.debug("we find %d stables but exepect to create %d stables "%(tdSql.queryRows,allStbNumbers))
|
||||||
|
# tdSql.checkRows(allStbNumbers)
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,10 @@ class TDTestCase:
|
||||||
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
|
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
|
||||||
tdLog.printNoPrefix("======== test case 1: ")
|
tdLog.printNoPrefix("======== test case 1: ")
|
||||||
paraDict = {'dbName': 'db',
|
paraDict = {'dbName': 'db',
|
||||||
'dbNumbers': 20,
|
'dbNumbers': 8,
|
||||||
'dropFlag': 1,
|
'dropFlag': 1,
|
||||||
'event': '',
|
'event': '',
|
||||||
'vgroups': 4,
|
'vgroups': 2,
|
||||||
'replica': 1,
|
'replica': 1,
|
||||||
'stbName': 'stb',
|
'stbName': 'stb',
|
||||||
'stbNumbers': 100,
|
'stbNumbers': 100,
|
||||||
|
|
@ -124,49 +124,54 @@ class TDTestCase:
|
||||||
for tr in threads:
|
for tr in threads:
|
||||||
tr.start()
|
tr.start()
|
||||||
|
|
||||||
tdLog.info("Take turns stopping Mnodes ")
|
# tdLog.info("Take turns stopping Mnodes ")
|
||||||
while stopcount < restartNumbers:
|
# while stopcount < restartNumbers:
|
||||||
tdLog.info(" restart loop: %d"%stopcount )
|
# tdLog.info(" restart loop: %d"%stopcount )
|
||||||
if stopRole == "mnode":
|
# if stopRole == "mnode":
|
||||||
for i in range(mnodeNums):
|
# for i in range(mnodeNums):
|
||||||
tdDnodes[i].stoptaosd()
|
# tdDnodes[i].stoptaosd()
|
||||||
# sleep(10)
|
# # sleep(10)
|
||||||
tdDnodes[i].starttaosd()
|
# tdDnodes[i].starttaosd()
|
||||||
# sleep(10)
|
# # sleep(10)
|
||||||
elif stopRole == "vnode":
|
# elif stopRole == "vnode":
|
||||||
for i in range(vnodeNumbers):
|
# for i in range(vnodeNumbers):
|
||||||
tdDnodes[i+mnodeNums].stoptaosd()
|
# tdDnodes[i+mnodeNums].stoptaosd()
|
||||||
# sleep(10)
|
# # sleep(10)
|
||||||
tdDnodes[i+mnodeNums].starttaosd()
|
# tdDnodes[i+mnodeNums].starttaosd()
|
||||||
# sleep(10)
|
# # sleep(10)
|
||||||
elif stopRole == "dnode":
|
# elif stopRole == "dnode":
|
||||||
for i in range(dnodeNumbers):
|
# for i in range(dnodeNumbers):
|
||||||
tdDnodes[i].stoptaosd()
|
# tdDnodes[i].stoptaosd()
|
||||||
# sleep(10)
|
# # sleep(10)
|
||||||
tdDnodes[i].starttaosd()
|
# tdDnodes[i].starttaosd()
|
||||||
# sleep(10)
|
# # sleep(10)
|
||||||
|
|
||||||
# dnodeNumbers don't include database of schema
|
# # dnodeNumbers don't include database of schema
|
||||||
if clusterComCheck.checkDnodes(dnodeNumbers):
|
# if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||||
tdLog.info("check dnodes status is ready")
|
# tdLog.info("check dnodes status is ready")
|
||||||
else:
|
# else:
|
||||||
tdLog.info("check dnodes status is not ready")
|
# tdLog.info("check dnodes status is not ready")
|
||||||
self.stopThread(threads)
|
# self.stopThread(threads)
|
||||||
tdLog.exit("one or more of dnodes failed to start ")
|
# tdLog.exit("one or more of dnodes failed to start ")
|
||||||
# self.check3mnode()
|
# # self.check3mnode()
|
||||||
stopcount+=1
|
# stopcount+=1
|
||||||
|
|
||||||
for tr in threads:
|
for tr in threads:
|
||||||
tr.join()
|
tr.join()
|
||||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||||
clusterComCheck.checkDbRows(allDbNumbers)
|
tdSql.query("show databases")
|
||||||
for i in range(restartNumbers):
|
tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers))
|
||||||
clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
|
|
||||||
|
# # tdLog.info("check DB Rows:")
|
||||||
|
# clusterComCheck.checkDbRows(allDbNumbers)
|
||||||
|
# # tdLog.info("check DB Status on by on")
|
||||||
|
# for i in range(restartNumbers):
|
||||||
|
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# print(self.master_dnode.cfgDict)
|
# print(self.master_dnode.cfgDict)
|
||||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='vnode')
|
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=15,stopRole='vnode')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class ClusterComCheck:
|
||||||
# print(query_status)
|
# print(query_status)
|
||||||
count+=1
|
count+=1
|
||||||
if query_status == dbNumbers:
|
if query_status == dbNumbers:
|
||||||
tdLog.success("we find cluster with %d dnode and check all databases are ready within 5s! " %dbNumbers)
|
tdLog.success(" check %d database and all databases are ready within 5s! " %dbNumbers)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
tdLog.debug(tdSql.queryResult)
|
tdLog.debug(tdSql.queryResult)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ class ClusterComCreate:
|
||||||
for i in range(dbNumbers):
|
for i in range(dbNumbers):
|
||||||
if dropFlag == 1:
|
if dropFlag == 1:
|
||||||
tsql.execute("drop database if exists %s_%d"%(dbNameIndex,i))
|
tsql.execute("drop database if exists %s_%d"%(dbNameIndex,i))
|
||||||
|
tdLog.debug("create database if not exists %s_%d vgroups %d replica %d"%(dbNameIndex,i, vgroups, replica))
|
||||||
tsql.execute("create database if not exists %s_%d vgroups %d replica %d"%(dbNameIndex,i, vgroups, replica))
|
tsql.execute("create database if not exists %s_%d vgroups %d replica %d"%(dbNameIndex,i, vgroups, replica))
|
||||||
tdLog.debug("complete to create database %s_%d"%(dbNameIndex,i))
|
tdLog.debug("complete to create database %s_%d"%(dbNameIndex,i))
|
||||||
return
|
return
|
||||||
|
|
@ -138,6 +139,7 @@ class ClusterComCreate:
|
||||||
|
|
||||||
def create_stables(self,tsql,dbNameIndex,stbNameIndex,stbNumbers):
|
def create_stables(self,tsql,dbNameIndex,stbNameIndex,stbNumbers):
|
||||||
for i in range(stbNumbers):
|
for i in range(stbNumbers):
|
||||||
|
tdLog.debug("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
|
||||||
tsql.execute("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
|
tsql.execute("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
|
||||||
tdLog.debug("complete to create %s.%s_%d" %(dbNameIndex, stbNameIndex,i))
|
tdLog.debug("complete to create %s.%s_%d" %(dbNameIndex, stbNameIndex,i))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -1,260 +0,0 @@
|
||||||
|
|
||||||
import taos
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
import socket
|
|
||||||
import os
|
|
||||||
import threading
|
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
from util.log import *
|
|
||||||
from util.sql import *
|
|
||||||
from util.cases import *
|
|
||||||
from util.dnodes import *
|
|
||||||
sys.path.append("./7-tmq")
|
|
||||||
from tmqCommon import *
|
|
||||||
|
|
||||||
class TDTestCase:
|
|
||||||
def __init__(self):
|
|
||||||
self.snapshot = 0
|
|
||||||
self.vgroups = 4
|
|
||||||
self.ctbNum = 1
|
|
||||||
self.rowsPerTbl = 10000
|
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
|
||||||
tdSql.init(conn.cursor(), False)
|
|
||||||
|
|
||||||
def prepareTestEnv(self):
|
|
||||||
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
|
|
||||||
paraDict = {'dbName': 'dbt',
|
|
||||||
'dropFlag': 1,
|
|
||||||
'event': '',
|
|
||||||
'vgroups': 4,
|
|
||||||
'stbName': 'stb',
|
|
||||||
'colPrefix': 'c',
|
|
||||||
'tagPrefix': 't',
|
|
||||||
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
|
||||||
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
|
||||||
'ctbPrefix': 'ctb',
|
|
||||||
'ctbStartIdx': 0,
|
|
||||||
'ctbNum': 1,
|
|
||||||
'rowsPerTbl': 100000,
|
|
||||||
'batchNum': 1200,
|
|
||||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
|
||||||
'pollDelay': 3,
|
|
||||||
'showMsg': 1,
|
|
||||||
'showRow': 1,
|
|
||||||
'snapshot': 0}
|
|
||||||
|
|
||||||
paraDict['vgroups'] = self.vgroups
|
|
||||||
paraDict['ctbNum'] = self.ctbNum
|
|
||||||
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
|
||||||
|
|
||||||
tmqCom.initConsumerTable()
|
|
||||||
tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1)
|
|
||||||
tdLog.info("create stb")
|
|
||||||
tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"])
|
|
||||||
tdLog.info("create ctb")
|
|
||||||
tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'],
|
|
||||||
ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
tdLog.info("insert data")
|
|
||||||
tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],
|
|
||||||
ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
|
||||||
startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
# tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx",
|
|
||||||
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
|
||||||
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
|
|
||||||
# tdLog.info("restart taosd to ensure that the data falls into the disk")
|
|
||||||
# tdSql.query("flush database %s"%(paraDict['dbName']))
|
|
||||||
return
|
|
||||||
|
|
||||||
def tmqCase1(self):
|
|
||||||
tdLog.printNoPrefix("======== test case 1: ")
|
|
||||||
paraDict = {'dbName': 'dbt',
|
|
||||||
'dropFlag': 1,
|
|
||||||
'event': '',
|
|
||||||
'vgroups': 4,
|
|
||||||
'stbName': 'stb',
|
|
||||||
'colPrefix': 'c',
|
|
||||||
'tagPrefix': 't',
|
|
||||||
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
|
||||||
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
|
||||||
'ctbPrefix': 'ctb',
|
|
||||||
'ctbStartIdx': 0,
|
|
||||||
'ctbNum': 1,
|
|
||||||
'rowsPerTbl': 100000,
|
|
||||||
'batchNum': 3000,
|
|
||||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
|
||||||
'pollDelay': 5,
|
|
||||||
'showMsg': 1,
|
|
||||||
'showRow': 1,
|
|
||||||
'snapshot': 0}
|
|
||||||
paraDict['snapshot'] = self.snapshot
|
|
||||||
paraDict['vgroups'] = self.vgroups
|
|
||||||
paraDict['ctbNum'] = self.ctbNum
|
|
||||||
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
|
||||||
|
|
||||||
# update to half tables
|
|
||||||
# paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2)
|
|
||||||
# tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx",
|
|
||||||
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
|
||||||
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
# tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],
|
|
||||||
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
|
||||||
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
|
|
||||||
tdLog.info("create topics from stb1")
|
|
||||||
topicFromStb1 = 'topic_stb1'
|
|
||||||
queryString = "select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
|
|
||||||
# queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
|
|
||||||
sqlString = "create topic %s as %s" %(topicFromStb1, queryString)
|
|
||||||
tdLog.info("create topic sql: %s"%sqlString)
|
|
||||||
tdSql.execute(sqlString)
|
|
||||||
|
|
||||||
# paraDict['ctbNum'] = self.ctbNum
|
|
||||||
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
|
||||||
consumerId = 0
|
|
||||||
expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2)
|
|
||||||
topicList = topicFromStb1
|
|
||||||
ifcheckdata = 1
|
|
||||||
ifManualCommit = 1
|
|
||||||
keyList = 'group.id:cgrp1,\
|
|
||||||
enable.auto.commit:true,\
|
|
||||||
auto.commit.interval.ms:1000,\
|
|
||||||
auto.offset.reset:earliest'
|
|
||||||
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
|
||||||
|
|
||||||
tdLog.info("start consume processor")
|
|
||||||
tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
|
|
||||||
|
|
||||||
tdLog.info("insert process end, and start to check consume result")
|
|
||||||
expectRows = 1
|
|
||||||
resultList = tmqCom.selectConsumeResult(expectRows)
|
|
||||||
totalConsumeRows = 0
|
|
||||||
for i in range(expectRows):
|
|
||||||
totalConsumeRows += resultList[i]
|
|
||||||
|
|
||||||
tdLog.info("run select sql from db")
|
|
||||||
tdSql.query(queryString)
|
|
||||||
expectrowcnt = tdSql.getRows()
|
|
||||||
|
|
||||||
tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt))
|
|
||||||
if totalConsumeRows != expectrowcnt:
|
|
||||||
tdLog.exit("tmq consume rows error!")
|
|
||||||
|
|
||||||
tmqCom.checkFileContent(consumerId, queryString)
|
|
||||||
|
|
||||||
tdSql.query("drop topic %s"%topicFromStb1)
|
|
||||||
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
|
||||||
|
|
||||||
def tmqCase2(self):
|
|
||||||
tdLog.printNoPrefix("======== test case 2: ")
|
|
||||||
paraDict = {'dbName': 'dbt',
|
|
||||||
'dropFlag': 1,
|
|
||||||
'event': '',
|
|
||||||
'vgroups': 4,
|
|
||||||
'stbName': 'stb',
|
|
||||||
'colPrefix': 'c',
|
|
||||||
'tagPrefix': 't',
|
|
||||||
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
|
||||||
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
|
||||||
'ctbPrefix': 'ctb',
|
|
||||||
'ctbStartIdx': 0,
|
|
||||||
'ctbNum': 1,
|
|
||||||
'rowsPerTbl': 10000,
|
|
||||||
'batchNum': 5000,
|
|
||||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
|
||||||
'pollDelay': 5,
|
|
||||||
'showMsg': 1,
|
|
||||||
'showRow': 1,
|
|
||||||
'snapshot': 0}
|
|
||||||
|
|
||||||
paraDict['snapshot'] = self.snapshot
|
|
||||||
paraDict['vgroups'] = self.vgroups
|
|
||||||
paraDict['ctbNum'] = self.ctbNum
|
|
||||||
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
|
||||||
|
|
||||||
tdLog.info("restart taosd to ensure that the data falls into the disk")
|
|
||||||
tdSql.query("flush database %s"%(paraDict['dbName']))
|
|
||||||
|
|
||||||
# update to half tables
|
|
||||||
paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl / 2)
|
|
||||||
paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2)
|
|
||||||
tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"],
|
|
||||||
ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
|
||||||
startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
# tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],
|
|
||||||
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
|
||||||
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
|
||||||
|
|
||||||
tmqCom.initConsumerTable()
|
|
||||||
tdLog.info("create topics from stb1")
|
|
||||||
topicFromStb1 = 'topic_stb1'
|
|
||||||
queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName'])
|
|
||||||
sqlString = "create topic %s as %s" %(topicFromStb1, queryString)
|
|
||||||
tdLog.info("create topic sql: %s"%sqlString)
|
|
||||||
tdSql.execute(sqlString)
|
|
||||||
|
|
||||||
# paraDict['ctbNum'] = self.ctbNum
|
|
||||||
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
|
||||||
consumerId = 1
|
|
||||||
expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2)
|
|
||||||
topicList = topicFromStb1
|
|
||||||
ifcheckdata = 1
|
|
||||||
ifManualCommit = 1
|
|
||||||
keyList = 'group.id:cgrp1,\
|
|
||||||
enable.auto.commit:true,\
|
|
||||||
auto.commit.interval.ms:1000,\
|
|
||||||
auto.offset.reset:earliest'
|
|
||||||
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
|
||||||
|
|
||||||
tdLog.info("start consume processor")
|
|
||||||
tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
|
|
||||||
|
|
||||||
tdLog.info("insert process end, and start to check consume result")
|
|
||||||
expectRows = 1
|
|
||||||
resultList = tmqCom.selectConsumeResult(expectRows)
|
|
||||||
totalConsumeRows = 0
|
|
||||||
for i in range(expectRows):
|
|
||||||
totalConsumeRows += resultList[i]
|
|
||||||
|
|
||||||
tdSql.query(queryString)
|
|
||||||
totalRowsInserted = tdSql.getRows()
|
|
||||||
|
|
||||||
tdLog.info("act consume rows: %d, act insert rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsInserted, expectrowcnt))
|
|
||||||
|
|
||||||
if totalConsumeRows != expectrowcnt:
|
|
||||||
tdLog.exit("tmq consume rows error!")
|
|
||||||
|
|
||||||
# tmqCom.checkFileContent(consumerId, queryString)
|
|
||||||
|
|
||||||
tdSql.query("drop topic %s"%topicFromStb1)
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("======== test case 2 end ...... ")
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
tdSql.prepare()
|
|
||||||
self.prepareTestEnv()
|
|
||||||
tdLog.printNoPrefix("=============================================")
|
|
||||||
tdLog.printNoPrefix("======== snapshot is 0: only consume from wal")
|
|
||||||
self.tmqCase1()
|
|
||||||
# self.tmqCase2()
|
|
||||||
|
|
||||||
# self.prepareTestEnv()
|
|
||||||
# tdLog.printNoPrefix("====================================================================")
|
|
||||||
# tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal")
|
|
||||||
# self.snapshot = 1
|
|
||||||
# self.tmqCase1()
|
|
||||||
# self.tmqCase2()
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
tdSql.close()
|
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
|
||||||
|
|
||||||
event = threading.Event()
|
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
|
||||||
|
|
@ -137,7 +137,7 @@ python3 ./test.py -f 6-cluster/5dnode1mnode.py
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3
|
python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3
|
||||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3
|
# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue