Merge branch '3.0' into fix/TD-19223-D
This commit is contained in:
commit
8acfbe00d0
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG c64858f
|
GIT_TAG 9284147
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -945,7 +945,7 @@ MIN(expr)
|
||||||
MODE(expr)
|
MODE(expr)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence.
|
**Description**:The value which has the highest frequency of occurrence. One random value is returned if there are multiple values which have highest frequency of occurrence.
|
||||||
|
|
||||||
**Return value type**: Same as the input data
|
**Return value type**: Same as the input data
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ title: TDengine Go Connector
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
import Preparition from "./_preparation.mdx"
|
|
||||||
import GoInsert from "../../07-develop/03-insert-data/_go_sql.mdx"
|
import GoInsert from "../../07-develop/03-insert-data/_go_sql.mdx"
|
||||||
import GoInfluxLine from "../../07-develop/03-insert-data/_go_line.mdx"
|
import GoInfluxLine from "../../07-develop/03-insert-data/_go_line.mdx"
|
||||||
import GoOpenTSDBTelnet from "../../07-develop/03-insert-data/_go_opts_telnet.mdx"
|
import GoOpenTSDBTelnet from "../../07-develop/03-insert-data/_go_opts_telnet.mdx"
|
||||||
|
@ -176,6 +175,37 @@ func main() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem value="WebSocket" label="WebSocket connection">
|
||||||
|
|
||||||
|
_taosRestful_ implements Go's `database/sql/driver` interface via `http client`. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver (driver-go minimum version 3.0.2).
|
||||||
|
|
||||||
|
Use `taosWS` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName` with the following parameters supported by the DSN.
|
||||||
|
|
||||||
|
* `writeTimeout` The timeout to send data via WebSocket.
|
||||||
|
* `readTimeout` The timeout to receive response data via WebSocket.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
_ "github.com/taosdata/driver-go/v3/taosWS"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var taosUri = "root:taosdata@ws(localhost:6041)/"
|
||||||
|
taos, err := sql.Open("taosWS", taosUri)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to connect TDengine, err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Usage examples
|
## Usage examples
|
||||||
|
@ -331,7 +361,7 @@ Creates consumer group.
|
||||||
|
|
||||||
* `func (c *Consumer) Subscribe(topics []string) error`
|
* `func (c *Consumer) Subscribe(topics []string) error`
|
||||||
|
|
||||||
Subscribes to a topic.
|
Subscribes to topics.
|
||||||
|
|
||||||
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
||||||
|
|
||||||
|
@ -409,6 +439,30 @@ Close consumer.
|
||||||
|
|
||||||
Closes the parameter binding.
|
Closes the parameter binding.
|
||||||
|
|
||||||
|
### Subscribe via WebSocket
|
||||||
|
|
||||||
|
* `func NewConsumer(config *Config) (*Consumer, error)`
|
||||||
|
|
||||||
|
Creates consumer group.
|
||||||
|
|
||||||
|
* `func (c *Consumer) Subscribe(topic []string) error`
|
||||||
|
|
||||||
|
Subscribes to topics.
|
||||||
|
|
||||||
|
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
||||||
|
|
||||||
|
Polling information.
|
||||||
|
|
||||||
|
* `func (c *Consumer) Commit(messageID uint64) error`
|
||||||
|
|
||||||
|
Commit information.
|
||||||
|
|
||||||
|
* `func (c *Consumer) Close() error`
|
||||||
|
|
||||||
|
Close consumer.
|
||||||
|
|
||||||
|
For a complete example see [GitHub sample file](https://github.com/taosdata/driver-go/blob/3.0/examples/tmqoverws/main.go)
|
||||||
|
|
||||||
## API Reference
|
## API Reference
|
||||||
|
|
||||||
Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
|
Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import PkgListV3 from "/components/PkgListV3";
|
||||||
|
|
||||||
1. Download the client installation package
|
1. Download the client installation package
|
||||||
|
|
||||||
<PkgListV3 type={8} sys="MacOS" />
|
<PkgListV3 type={8} sys="macOS" />
|
||||||
|
|
||||||
[All Downloads](../../releases/tdengine)
|
[All Downloads](../../releases/tdengine)
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,37 @@ func main() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem value="WebSocket" label="WebSocket 连接">
|
||||||
|
|
||||||
|
_taosWS_ 通过 `WebSocket` 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动(driver-go 最低版本 3.0.2)就可以使用[`database/sql`](https://golang.org/pkg/database/sql/)的接口。
|
||||||
|
|
||||||
|
使用 `taosWS` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数:
|
||||||
|
|
||||||
|
* `writeTimeout` 通过 WebSocket 发送数据的超时时间。
|
||||||
|
* `readTimeout` 通过 WebSocket 接收响应数据的超时时间。
|
||||||
|
|
||||||
|
示例:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
_ "github.com/taosdata/driver-go/v3/taosWS"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var taosUri = "root:taosdata@ws(localhost:6041)/"
|
||||||
|
taos, err := sql.Open("taosWS", taosUri)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to connect TDengine, err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
@ -410,6 +441,30 @@ func main() {
|
||||||
|
|
||||||
结束参数绑定。
|
结束参数绑定。
|
||||||
|
|
||||||
|
### 通过 WebSocket 订阅
|
||||||
|
|
||||||
|
* `func NewConsumer(config *Config) (*Consumer, error)`
|
||||||
|
|
||||||
|
创建消费者。
|
||||||
|
|
||||||
|
* `func (c *Consumer) Subscribe(topic []string) error`
|
||||||
|
|
||||||
|
订阅主题。
|
||||||
|
|
||||||
|
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
||||||
|
|
||||||
|
轮询消息。
|
||||||
|
|
||||||
|
* `func (c *Consumer) Commit(messageID uint64) error`
|
||||||
|
|
||||||
|
提交消息。
|
||||||
|
|
||||||
|
* `func (c *Consumer) Close() error`
|
||||||
|
|
||||||
|
关闭消费者。
|
||||||
|
|
||||||
|
完整订阅示例参见 [GitHub 示例文件](https://github.com/taosdata/driver-go/blob/3.0/examples/tmqoverws/main.go)
|
||||||
|
|
||||||
## API 参考
|
## API 参考
|
||||||
|
|
||||||
全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
|
全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import PkgListV3 from "/components/PkgListV3";
|
||||||
|
|
||||||
1. 下载客户端安装包
|
1. 下载客户端安装包
|
||||||
|
|
||||||
<PkgListV3 type={8} sys="MacOS" />
|
<PkgListV3 type={8} sys="macOS" />
|
||||||
|
|
||||||
[所有下载](../../releases/tdengine)
|
[所有下载](../../releases/tdengine)
|
||||||
|
|
||||||
|
|
|
@ -946,7 +946,7 @@ MIN(expr)
|
||||||
MODE(expr)
|
MODE(expr)
|
||||||
```
|
```
|
||||||
|
|
||||||
**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。
|
**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,则随机输出其中某个值。
|
||||||
|
|
||||||
**返回数据类型**:与输入数据类型一致。
|
**返回数据类型**:与输入数据类型一致。
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,7 @@ DLL_EXPORT const void *taos_get_raw_block(TAOS_RES *res);
|
||||||
|
|
||||||
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
||||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
||||||
|
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw(TAOS* taos, char* lines, int len, int32_t *totalRows, int protocol, int precision);
|
||||||
|
|
||||||
/* --------------------------TMQ INTERFACE------------------------------- */
|
/* --------------------------TMQ INTERFACE------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -44,12 +44,17 @@ enum {
|
||||||
)
|
)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
typedef struct {
|
typedef struct SWinKey {
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
} SWinKey;
|
} SWinKey;
|
||||||
|
|
||||||
static inline int sWinKeyCmprImpl(const void* pKey1, const void* pKey2) {
|
typedef struct SSessionKey {
|
||||||
|
STimeWindow win;
|
||||||
|
uint64_t groupId;
|
||||||
|
} SSessionKey;
|
||||||
|
|
||||||
|
static inline int winKeyCmprImpl(const void* pKey1, const void* pKey2) {
|
||||||
SWinKey* pWin1 = (SWinKey*)pKey1;
|
SWinKey* pWin1 = (SWinKey*)pKey1;
|
||||||
SWinKey* pWin2 = (SWinKey*)pKey2;
|
SWinKey* pWin2 = (SWinKey*)pKey2;
|
||||||
|
|
||||||
|
@ -69,7 +74,7 @@ static inline int sWinKeyCmprImpl(const void* pKey1, const void* pKey2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int winKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
static inline int winKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||||
return sWinKeyCmprImpl(pKey1, pKey2);
|
return winKeyCmprImpl(pKey1, pKey2);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -25,6 +25,8 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct SStreamTask SStreamTask;
|
typedef struct SStreamTask SStreamTask;
|
||||||
|
|
||||||
|
typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2);
|
||||||
|
|
||||||
// incremental state storage
|
// incremental state storage
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SStreamTask* pOwner;
|
SStreamTask* pOwner;
|
||||||
|
@ -32,6 +34,7 @@ typedef struct {
|
||||||
TTB* pStateDb;
|
TTB* pStateDb;
|
||||||
TTB* pFuncStateDb;
|
TTB* pFuncStateDb;
|
||||||
TTB* pFillStateDb; // todo refactor
|
TTB* pFillStateDb; // todo refactor
|
||||||
|
TTB* pSessionStateDb;
|
||||||
TXN txn;
|
TXN txn;
|
||||||
int32_t number;
|
int32_t number;
|
||||||
} SStreamState;
|
} SStreamState;
|
||||||
|
@ -57,6 +60,19 @@ int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
|
||||||
int32_t streamStateClear(SStreamState* pState);
|
int32_t streamStateClear(SStreamState* pState);
|
||||||
void streamStateSetNumber(SStreamState* pState, int32_t number);
|
void streamStateSetNumber(SStreamState* pState, int32_t number);
|
||||||
|
|
||||||
|
int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen);
|
||||||
|
int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, const void* value, int32_t vLen);
|
||||||
|
int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen);
|
||||||
|
int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key);
|
||||||
|
int32_t streamStateSessionClear(SStreamState* pState);
|
||||||
|
int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, const void** pVal, int32_t* pVLen);
|
||||||
|
int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||||
|
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen);
|
||||||
|
|
||||||
|
SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key);
|
||||||
|
SStreamStateCur* streamStateSessionSeekKeyPrev(SStreamState* pState, const SSessionKey* key);
|
||||||
|
SStreamStateCur* streamStateSessionGetCur(SStreamState* pState, const SSessionKey* key);
|
||||||
|
|
||||||
int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
|
int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
|
||||||
int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||||
int32_t streamStateFillDel(SStreamState* pState, const SWinKey* key);
|
int32_t streamStateFillDel(SStreamState* pState, const SWinKey* key);
|
||||||
|
|
|
@ -498,6 +498,7 @@ enum {
|
||||||
#define MAX_NUM_STR_SIZE 40
|
#define MAX_NUM_STR_SIZE 40
|
||||||
|
|
||||||
#define MAX_META_MSG_IN_BATCH 1048576
|
#define MAX_META_MSG_IN_BATCH 1048576
|
||||||
|
#define MAX_META_BATCH_RSP_SIZE (1 * 1048576 * 1024)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
||||||
if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) {
|
if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) {
|
||||||
if (TSDB_CODE_SUCCESS !=
|
if (TSDB_CODE_SUCCESS !=
|
||||||
nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) {
|
nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) {
|
||||||
tscError("%d failed to create node allocator, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self,
|
tscError("%d failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s", (*pRequest)->self,
|
||||||
(*pRequest)->requestId, pTscObj->id, sql);
|
(*pRequest)->requestId, pTscObj->id, sql);
|
||||||
|
|
||||||
destroyRequest(*pRequest);
|
destroyRequest(*pRequest);
|
||||||
|
@ -955,8 +955,13 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
||||||
switch (pQuery->execMode) {
|
switch (pQuery->execMode) {
|
||||||
case QUERY_EXEC_MODE_LOCAL:
|
case QUERY_EXEC_MODE_LOCAL:
|
||||||
if (!pRequest->validateOnly) {
|
if (!pRequest->validateOnly) {
|
||||||
|
if (NULL == pQuery->pRoot) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
code = terrno;
|
||||||
|
} else {
|
||||||
code = execLocalCmd(pRequest, pQuery);
|
code = execLocalCmd(pRequest, pQuery);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QUERY_EXEC_MODE_RPC:
|
case QUERY_EXEC_MODE_RPC:
|
||||||
if (!pRequest->validateOnly) {
|
if (!pRequest->validateOnly) {
|
||||||
|
@ -997,7 +1002,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
||||||
|
|
||||||
handleQueryExecRsp(pRequest);
|
handleQueryExecRsp(pRequest);
|
||||||
|
|
||||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
pRequest->code = terrno;
|
pRequest->code = terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2254,7 +2259,10 @@ void syncQueryFn(void* param, void* res, int32_t code) {
|
||||||
void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) {
|
void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) {
|
||||||
if (sql == NULL || NULL == fp) {
|
if (sql == NULL || NULL == fp) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
if (fp) {
|
||||||
fp(param, NULL, terrno);
|
fp(param, NULL, terrno);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -944,7 +944,6 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
if (pResultInfo->completed) {
|
if (pResultInfo->completed) {
|
||||||
// it is a local executed query, no need to do async fetch
|
// it is a local executed query, no need to do async fetch
|
||||||
if (QUERY_EXEC_MODE_LOCAL == pRequest->body.execMode) {
|
if (QUERY_EXEC_MODE_LOCAL == pRequest->body.execMode) {
|
||||||
ASSERT(pResultInfo->numOfRows >= 0);
|
|
||||||
if (pResultInfo->localResultFetched) {
|
if (pResultInfo->localResultFetched) {
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
pResultInfo->current = 0;
|
pResultInfo->current = 0;
|
||||||
|
|
|
@ -292,9 +292,11 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp);
|
tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp);
|
||||||
|
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
|
@ -397,6 +399,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||||
size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||||
*pRsp = taosMemoryCalloc(1, rspSize);
|
*pRsp = taosMemoryCalloc(1, rspSize);
|
||||||
if (NULL == *pRsp) {
|
if (NULL == *pRsp) {
|
||||||
|
blockDataDestroy(pBlock);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#define QUOTE '"'
|
#define QUOTE '"'
|
||||||
#define SLASH '\\'
|
#define SLASH '\\'
|
||||||
|
|
||||||
#define JUMP_SPACE(sql) \
|
#define JUMP_SPACE(sql, sqlEnd) \
|
||||||
while (*sql != '\0') { \
|
while (sql < sqlEnd) { \
|
||||||
if (*sql == SPACE) \
|
if (*sql == SPACE) \
|
||||||
sql++; \
|
sql++; \
|
||||||
else \
|
else \
|
||||||
|
@ -917,16 +917,17 @@ static int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSmlMsgBuf *msg) {
|
static int32_t smlParseInfluxString(const char *sql, const char *sqlEnd, SSmlLineInfo *elements, SSmlMsgBuf *msg) {
|
||||||
if (!sql) return TSDB_CODE_SML_INVALID_DATA;
|
if (!sql) return TSDB_CODE_SML_INVALID_DATA;
|
||||||
JUMP_SPACE(sql)
|
JUMP_SPACE(sql, sqlEnd)
|
||||||
if (*sql == COMMA) return TSDB_CODE_SML_INVALID_DATA;
|
if (*sql == COMMA) return TSDB_CODE_SML_INVALID_DATA;
|
||||||
elements->measure = sql;
|
elements->measure = sql;
|
||||||
|
|
||||||
// parse measure
|
// parse measure
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
if ((sql != elements->measure) && IS_SLASH_LETTER(sql)) {
|
if ((sql != elements->measure) && IS_SLASH_LETTER(sql)) {
|
||||||
MOVE_FORWARD_ONE(sql, strlen(sql) + 1);
|
MOVE_FORWARD_ONE(sql, sqlEnd - sql);
|
||||||
|
sqlEnd--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (IS_COMMA(sql)) {
|
if (IS_COMMA(sql)) {
|
||||||
|
@ -950,7 +951,7 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
||||||
} else {
|
} else {
|
||||||
if (*sql == COMMA) sql++;
|
if (*sql == COMMA) sql++;
|
||||||
elements->tags = sql;
|
elements->tags = sql;
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
if (IS_SPACE(sql)) {
|
if (IS_SPACE(sql)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -961,10 +962,10 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
||||||
elements->measureTagsLen = sql - elements->measure;
|
elements->measureTagsLen = sql - elements->measure;
|
||||||
|
|
||||||
// parse cols
|
// parse cols
|
||||||
JUMP_SPACE(sql)
|
JUMP_SPACE(sql, sqlEnd)
|
||||||
elements->cols = sql;
|
elements->cols = sql;
|
||||||
bool isInQuote = false;
|
bool isInQuote = false;
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
if (IS_QUOTE(sql)) {
|
if (IS_QUOTE(sql)) {
|
||||||
isInQuote = !isInQuote;
|
isInQuote = !isInQuote;
|
||||||
}
|
}
|
||||||
|
@ -984,10 +985,10 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse timestamp
|
// parse timestamp
|
||||||
JUMP_SPACE(sql)
|
JUMP_SPACE(sql, sqlEnd)
|
||||||
elements->timestamp = sql;
|
elements->timestamp = sql;
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
if (*sql == SPACE) {
|
if (isspace(*sql)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sql++;
|
sql++;
|
||||||
|
@ -997,8 +998,8 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smlParseTelnetElement(const char **sql, const char **data, int32_t *len) {
|
static void smlParseTelnetElement(const char **sql, const char *sqlEnd, const char **data, int32_t *len) {
|
||||||
while (**sql != '\0') {
|
while (*sql < sqlEnd) {
|
||||||
if (**sql != SPACE && !(*data)) {
|
if (**sql != SPACE && !(*data)) {
|
||||||
*data = *sql;
|
*data = *sql;
|
||||||
} else if (**sql == SPACE && *data) {
|
} else if (**sql == SPACE && *data) {
|
||||||
|
@ -1009,20 +1010,20 @@ static void smlParseTelnetElement(const char **sql, const char **data, int32_t *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTableName, SHashObj *dumplicateKey,
|
static int32_t smlParseTelnetTags(const char *data, const char *sqlEnd, SArray *cols, char *childTableName, SHashObj *dumplicateKey,
|
||||||
SSmlMsgBuf *msg) {
|
SSmlMsgBuf *msg) {
|
||||||
if(!cols) return TSDB_CODE_OUT_OF_MEMORY;
|
if(!cols) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
const char *sql = data;
|
const char *sql = data;
|
||||||
size_t childTableNameLen = strlen(tsSmlChildTableName);
|
size_t childTableNameLen = strlen(tsSmlChildTableName);
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
JUMP_SPACE(sql)
|
JUMP_SPACE(sql, sqlEnd)
|
||||||
if (*sql == '\0') break;
|
if (*sql == '\0') break;
|
||||||
|
|
||||||
const char *key = sql;
|
const char *key = sql;
|
||||||
int32_t keyLen = 0;
|
int32_t keyLen = 0;
|
||||||
|
|
||||||
// parse key
|
// parse key
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
if (*sql == SPACE) {
|
if (*sql == SPACE) {
|
||||||
smlBuildInvalidDataMsg(msg, "invalid data", sql);
|
smlBuildInvalidDataMsg(msg, "invalid data", sql);
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
|
@ -1047,7 +1048,7 @@ static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTab
|
||||||
// parse value
|
// parse value
|
||||||
const char *value = sql;
|
const char *value = sql;
|
||||||
int32_t valueLen = 0;
|
int32_t valueLen = 0;
|
||||||
while (*sql != '\0') {
|
while (sql < sqlEnd) {
|
||||||
// parse value
|
// parse value
|
||||||
if (*sql == SPACE) {
|
if (*sql == SPACE) {
|
||||||
break;
|
break;
|
||||||
|
@ -1092,11 +1093,11 @@ static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTab
|
||||||
}
|
}
|
||||||
|
|
||||||
// format: <metric> <timestamp> <value> <tagk_1>=<tagv_1>[ <tagk_n>=<tagv_n>]
|
// format: <metric> <timestamp> <value> <tagk_1>=<tagv_1>[ <tagk_n>=<tagv_n>]
|
||||||
static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTableInfo *tinfo, SArray *cols) {
|
static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, const char *sqlEnd, SSmlTableInfo *tinfo, SArray *cols) {
|
||||||
if (!sql) return TSDB_CODE_SML_INVALID_DATA;
|
if (!sql) return TSDB_CODE_SML_INVALID_DATA;
|
||||||
|
|
||||||
// parse metric
|
// parse metric
|
||||||
smlParseTelnetElement(&sql, &tinfo->sTableName, &tinfo->sTableNameLen);
|
smlParseTelnetElement(&sql, sqlEnd, &tinfo->sTableName, &tinfo->sTableNameLen);
|
||||||
if (!(tinfo->sTableName) || IS_INVALID_TABLE_LEN(tinfo->sTableNameLen)) {
|
if (!(tinfo->sTableName) || IS_INVALID_TABLE_LEN(tinfo->sTableNameLen)) {
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
||||||
return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||||
|
@ -1105,7 +1106,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTable
|
||||||
// parse timestamp
|
// parse timestamp
|
||||||
const char *timestamp = NULL;
|
const char *timestamp = NULL;
|
||||||
int32_t tLen = 0;
|
int32_t tLen = 0;
|
||||||
smlParseTelnetElement(&sql, ×tamp, &tLen);
|
smlParseTelnetElement(&sql, sqlEnd, ×tamp, &tLen);
|
||||||
if (!timestamp || tLen == 0) {
|
if (!timestamp || tLen == 0) {
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp", sql);
|
smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp", sql);
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
|
@ -1120,7 +1121,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTable
|
||||||
// parse value
|
// parse value
|
||||||
const char *value = NULL;
|
const char *value = NULL;
|
||||||
int32_t valueLen = 0;
|
int32_t valueLen = 0;
|
||||||
smlParseTelnetElement(&sql, &value, &valueLen);
|
smlParseTelnetElement(&sql, sqlEnd, &value, &valueLen);
|
||||||
if (!value || valueLen == 0) {
|
if (!value || valueLen == 0) {
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid value", sql);
|
smlBuildInvalidDataMsg(&info->msgBuf, "invalid value", sql);
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
|
@ -1138,7 +1139,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTable
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse tags
|
// parse tags
|
||||||
ret = smlParseTelnetTags(sql, tinfo->tags, tinfo->childTableName, info->dumplicateKey, &info->msgBuf);
|
ret = smlParseTelnetTags(sql, sqlEnd, tinfo->tags, tinfo->childTableName, info->dumplicateKey, &info->msgBuf);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1371,8 +1372,14 @@ static int32_t smlKvTimeArrayCompare(const void *key1, const void *key2) {
|
||||||
static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) {
|
static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) {
|
||||||
SHashObj *s1 = *(SHashObj **)key1;
|
SHashObj *s1 = *(SHashObj **)key1;
|
||||||
SHashObj *s2 = *(SHashObj **)key2;
|
SHashObj *s2 = *(SHashObj **)key2;
|
||||||
SSmlKv *kv1 = *(SSmlKv **)taosHashGet(s1, TS, TS_LEN);
|
SSmlKv **kv1pp = (SSmlKv **)taosHashGet(s1, TS, TS_LEN);
|
||||||
SSmlKv *kv2 = *(SSmlKv **)taosHashGet(s2, TS, TS_LEN);
|
SSmlKv **kv2pp = (SSmlKv **)taosHashGet(s2, TS, TS_LEN);
|
||||||
|
if(!kv1pp || !kv2pp){
|
||||||
|
uError("smlKvTimeHashCompare kv is null");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
SSmlKv *kv1 = *kv1pp;
|
||||||
|
SSmlKv *kv2 = *kv2pp;
|
||||||
if(!kv1 || kv1->type != TSDB_DATA_TYPE_TIMESTAMP){
|
if(!kv1 || kv1->type != TSDB_DATA_TYPE_TIMESTAMP){
|
||||||
uError("smlKvTimeHashCompare kv1");
|
uError("smlKvTimeHashCompare kv1");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2073,11 +2080,11 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *
|
||||||
}
|
}
|
||||||
/************* TSDB_SML_JSON_PROTOCOL function end **************/
|
/************* TSDB_SML_JSON_PROTOCOL function end **************/
|
||||||
|
|
||||||
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
|
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int len) {
|
||||||
SSmlLineInfo elements = {0};
|
SSmlLineInfo elements = {0};
|
||||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql:%s, hello", info->id, sql);
|
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql:%s, hello", info->id, sql);
|
||||||
|
|
||||||
int ret = smlParseInfluxString(sql, &elements, &info->msgBuf);
|
int ret = smlParseInfluxString(sql, sql + len, &elements, &info->msgBuf);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlParseInfluxLine failed", info->id);
|
uError("SML:0x%" PRIx64 " smlParseInfluxLine failed", info->id);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2184,7 +2191,7 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlParseTelnetLine(SSmlHandle *info, void *data) {
|
static int32_t smlParseTelnetLine(SSmlHandle *info, void *data, const int len) {
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
SSmlTableInfo *tinfo = smlBuildTableInfo();
|
SSmlTableInfo *tinfo = smlBuildTableInfo();
|
||||||
if (!tinfo) {
|
if (!tinfo) {
|
||||||
|
@ -2198,7 +2205,7 @@ static int32_t smlParseTelnetLine(SSmlHandle *info, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
||||||
ret = smlParseTelnetString(info, (const char *)data, tinfo, cols);
|
ret = smlParseTelnetString(info, (const char *)data, (char*)data + len, tinfo, cols);
|
||||||
} else if (info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
} else if (info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
||||||
ret = smlParseJSONString(info, (cJSON *)data, tinfo, cols);
|
ret = smlParseJSONString(info, (cJSON *)data, tinfo, cols);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2289,7 +2296,7 @@ static int32_t smlParseJSON(SSmlHandle *info, char *payload) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < payloadNum; ++i) {
|
for (int32_t i = 0; i < payloadNum; ++i) {
|
||||||
cJSON *dataPoint = (payloadNum == 1 && cJSON_IsObject(root)) ? root : cJSON_GetArrayItem(root, i);
|
cJSON *dataPoint = (payloadNum == 1 && cJSON_IsObject(root)) ? root : cJSON_GetArrayItem(root, i);
|
||||||
ret = smlParseTelnetLine(info, dataPoint);
|
ret = smlParseTelnetLine(info, dataPoint, -1);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " Invalid JSON Payload", info->id);
|
uError("SML:0x%" PRIx64 " Invalid JSON Payload", info->id);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -2378,10 +2385,14 @@ static void smlPrintStatisticInfo(SSmlHandle *info) {
|
||||||
info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime);
|
info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlParseLine(SSmlHandle *info, char *lines[], int numLines) {
|
static int32_t smlParseLine(SSmlHandle *info, char *lines[], char* rawLine, char* rawLineEnd, int numLines) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
if (info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
||||||
|
if(lines){
|
||||||
code = smlParseJSON(info, *lines);
|
code = smlParseJSON(info, *lines);
|
||||||
|
}else if(rawLine){
|
||||||
|
code = smlParseJSON(info, rawLine);
|
||||||
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlParseJSON failed:%s", info->id, *lines);
|
uError("SML:0x%" PRIx64 " smlParseJSON failed:%s", info->id, *lines);
|
||||||
return code;
|
return code;
|
||||||
|
@ -2390,28 +2401,46 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], int numLines) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numLines; ++i) {
|
for (int32_t i = 0; i < numLines; ++i) {
|
||||||
|
char *tmp = NULL;
|
||||||
|
int len = 0;
|
||||||
|
if(lines){
|
||||||
|
tmp = lines[i];
|
||||||
|
len = strlen(tmp);
|
||||||
|
}else if(rawLine){
|
||||||
|
tmp = rawLine;
|
||||||
|
while(rawLine < rawLineEnd){
|
||||||
|
if(*(rawLine++) == '\n'){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
if(info->protocol == TSDB_SML_LINE_PROTOCOL && tmp[0] == '#'){ // this line is comment
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
|
if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
|
||||||
code = smlParseInfluxLine(info, lines[i]);
|
code = smlParseInfluxLine(info, tmp, len);
|
||||||
} else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
} else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
||||||
code = smlParseTelnetLine(info, lines[i]);
|
code = smlParseTelnetLine(info, tmp, len);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, lines[i]);
|
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, tmp);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smlProcess(SSmlHandle *info, char *lines[], int numLines) {
|
static int smlProcess(SSmlHandle *info, char *lines[], char* rawLine, char* rawLineEnd, int numLines) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t retryNum = 0;
|
int32_t retryNum = 0;
|
||||||
|
|
||||||
info->cost.parseTime = taosGetTimestampUs();
|
info->cost.parseTime = taosGetTimestampUs();
|
||||||
|
|
||||||
code = smlParseLine(info, lines, numLines);
|
code = smlParseLine(info, lines, rawLine, rawLineEnd, numLines);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
uError("SML:0x%" PRIx64 " smlParseLine error : %s", info->id, tstrerror(code));
|
uError("SML:0x%" PRIx64 " smlParseLine error : %s", info->id, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
|
@ -2504,39 +2533,8 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
|
||||||
smlDestroyInfo(info);
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* taos_schemaless_insert() parse and insert data points into database according to
|
|
||||||
* different protocol.
|
|
||||||
*
|
|
||||||
* @param $lines input array may contain multiple lines, each line indicates a data point.
|
|
||||||
* If protocol=2 is used input array should contain single JSON
|
|
||||||
* string(e.g. char *lines[] = {"$JSON_string"}). If need to insert
|
|
||||||
* multiple data points in JSON format, should include them in $JSON_string
|
|
||||||
* as a JSON array.
|
|
||||||
* @param $numLines indicates how many data points in $lines.
|
|
||||||
* If protocol = 2 is used this param will be ignored as $lines should
|
|
||||||
* contain single JSON string.
|
|
||||||
* @param $protocol indicates which protocol to use for parsing:
|
|
||||||
* 0 - influxDB line protocol
|
|
||||||
* 1 - OpenTSDB telnet line protocol
|
|
||||||
* 2 - OpenTSDB JSON format protocol
|
|
||||||
* @return return zero for successful insertion. Otherwise return none-zero error code of
|
|
||||||
* failure reason.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
|
||||||
if (NULL == taos) {
|
|
||||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT);
|
|
||||||
if (!request) {
|
|
||||||
uError("SML:taos_schemaless_insert error request is null");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char *rawLine, char *rawLineEnd, int numLines, int protocol, int precision) {
|
||||||
int batchs = 0;
|
int batchs = 0;
|
||||||
STscObj *pTscObj = request->pTscObj;
|
STscObj *pTscObj = request->pTscObj;
|
||||||
|
|
||||||
|
@ -2560,12 +2558,6 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lines) {
|
|
||||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
|
||||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (protocol < TSDB_SML_LINE_PROTOCOL || protocol > TSDB_SML_JSON_PROTOCOL) {
|
if (protocol < TSDB_SML_LINE_PROTOCOL || protocol > TSDB_SML_JSON_PROTOCOL) {
|
||||||
request->code = TSDB_CODE_SML_INVALID_PROTOCOL_TYPE;
|
request->code = TSDB_CODE_SML_INVALID_PROTOCOL_TYPE;
|
||||||
smlBuildInvalidDataMsg(&msg, "protocol invalidate", NULL);
|
smlBuildInvalidDataMsg(&msg, "protocol invalidate", NULL);
|
||||||
|
@ -2616,15 +2608,28 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
||||||
info->affectedRows = perBatch;
|
info->affectedRows = perBatch;
|
||||||
info->pRequest->body.queryFp = smlInsertCallback;
|
info->pRequest->body.queryFp = smlInsertCallback;
|
||||||
info->pRequest->body.param = info;
|
info->pRequest->body.param = info;
|
||||||
int32_t code = smlProcess(info, lines, perBatch);
|
int32_t code = smlProcess(info, lines, rawLine, rawLineEnd, perBatch);
|
||||||
|
if(lines){
|
||||||
lines += perBatch;
|
lines += perBatch;
|
||||||
|
}
|
||||||
|
if(rawLine){
|
||||||
|
int num = 0;
|
||||||
|
while(rawLine < rawLineEnd){
|
||||||
|
if(*(rawLine++) == '\n'){
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
if(num == perBatch){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
info->pRequest->body.queryFp(info, req, code);
|
info->pRequest->body.queryFp(info, req, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tsem_wait(¶ms.sem);
|
tsem_wait(¶ms.sem);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
taosThreadSpinDestroy(¶ms.lock);
|
taosThreadSpinDestroy(¶ms.lock);
|
||||||
tsem_destroy(¶ms.sem);
|
tsem_destroy(¶ms.sem);
|
||||||
// ((STscObj *)taos)->schemalessType = 0;
|
// ((STscObj *)taos)->schemalessType = 0;
|
||||||
|
@ -2632,3 +2637,80 @@ end:
|
||||||
uDebug("resultend:%s", request->msgBuf);
|
uDebug("resultend:%s", request->msgBuf);
|
||||||
return (TAOS_RES *)request;
|
return (TAOS_RES *)request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* taos_schemaless_insert() parse and insert data points into database according to
|
||||||
|
* different protocol.
|
||||||
|
*
|
||||||
|
* @param $lines input array may contain multiple lines, each line indicates a data point.
|
||||||
|
* If protocol=2 is used input array should contain single JSON
|
||||||
|
* string(e.g. char *lines[] = {"$JSON_string"}). If need to insert
|
||||||
|
* multiple data points in JSON format, should include them in $JSON_string
|
||||||
|
* as a JSON array.
|
||||||
|
* @param $numLines indicates how many data points in $lines.
|
||||||
|
* If protocol = 2 is used this param will be ignored as $lines should
|
||||||
|
* contain single JSON string.
|
||||||
|
* @param $protocol indicates which protocol to use for parsing:
|
||||||
|
* 0 - influxDB line protocol
|
||||||
|
* 1 - OpenTSDB telnet line protocol
|
||||||
|
* 2 - OpenTSDB JSON format protocol
|
||||||
|
* @return return zero for successful insertion. Otherwise return none-zero error code of
|
||||||
|
* failure reason.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
||||||
|
if (NULL == taos) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT);
|
||||||
|
if (!request) {
|
||||||
|
uError("SML:taos_schemaless_insert error request is null");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lines) {
|
||||||
|
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||||
|
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||||
|
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||||
|
return (TAOS_RES *)request;
|
||||||
|
}
|
||||||
|
|
||||||
|
return taos_schemaless_insert_inner(request, lines, NULL, NULL, numLines, protocol, precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES *taos_schemaless_insert_raw(TAOS* taos, char* lines, int len, int32_t *totalRows, int protocol, int precision){
|
||||||
|
if (NULL == taos) {
|
||||||
|
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT);
|
||||||
|
if (!request) {
|
||||||
|
uError("SML:taos_schemaless_insert error request is null");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lines || len <= 0) {
|
||||||
|
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||||
|
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||||
|
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||||
|
return (TAOS_RES *)request;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numLines = 0;
|
||||||
|
*totalRows = 0;
|
||||||
|
char *tmp = lines;
|
||||||
|
for(int i = 0; i < len; i++){
|
||||||
|
if(lines[i] == '\n' || i == len - 1){
|
||||||
|
numLines++;
|
||||||
|
if(tmp[0] != '#' || protocol != TSDB_SML_LINE_PROTOCOL){ //ignore comment
|
||||||
|
(*totalRows)++;
|
||||||
|
}
|
||||||
|
tmp = lines + i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return taos_schemaless_insert_inner(request, NULL, lines, lines + len, numLines, protocol, precision);
|
||||||
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
||||||
pStmt->bInfo.tbType = pTableMeta->tableType;
|
pStmt->bInfo.tbType = pTableMeta->tableType;
|
||||||
pStmt->bInfo.boundTags = tags;
|
pStmt->bInfo.boundTags = tags;
|
||||||
pStmt->bInfo.tagsCached = false;
|
pStmt->bInfo.tagsCached = false;
|
||||||
strcpy(pStmt->bInfo.stbFName, sTableName);
|
tstrncpy(pStmt->bInfo.stbFName, sTableName, sizeof(pStmt->bInfo.stbFName));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqCommitCbParamSet* params;
|
SMqCommitCbParamSet* params;
|
||||||
STqOffset* pOffset;
|
STqOffset* pOffset;
|
||||||
|
/*char topicName[TSDB_TOPIC_FNAME_LEN];*/
|
||||||
|
/*int32_t vgId;*/
|
||||||
} SMqCommitCbParam;
|
} SMqCommitCbParam;
|
||||||
|
|
||||||
tmq_conf_t* tmq_conf_new() {
|
tmq_conf_t* tmq_conf_new() {
|
||||||
|
@ -407,6 +409,14 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet) {
|
||||||
|
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||||
|
ASSERT(waitingRspNum >= 0);
|
||||||
|
if (waitingRspNum == 0) {
|
||||||
|
tmqCommitDone(pParamSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) {
|
int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) {
|
||||||
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
||||||
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
||||||
|
@ -420,18 +430,13 @@ int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
taosMemoryFree(pParam->pOffset);
|
taosMemoryFree(pParam->pOffset);
|
||||||
if (pBuf->pData) taosMemoryFree(pBuf->pData);
|
taosMemoryFree(pBuf->pData);
|
||||||
|
|
||||||
/*tscDebug("receive offset commit cb of %s on vgId:%d, offset is %" PRId64, pParam->pOffset->subKey, pParam->->vgId,
|
/*tscDebug("receive offset commit cb of %s on vgId:%d, offset is %" PRId64, pParam->pOffset->subKey, pParam->->vgId,
|
||||||
* pOffset->version);*/
|
* pOffset->version);*/
|
||||||
|
|
||||||
// count down waiting rsp
|
tmqCommitRspCountDown(pParamSet);
|
||||||
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
|
||||||
ASSERT(waitingRspNum >= 0);
|
|
||||||
|
|
||||||
if (waitingRspNum == 0) {
|
|
||||||
tmqCommitDone(pParamSet);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,14 +596,10 @@ FAIL:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb,
|
static int32_t tmqCommitConsumerImpl(tmq_t* tmq, int8_t automatic, int8_t async, tmq_commit_cb* userCb,
|
||||||
void* userParam) {
|
void* userParam) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
if (msg != NULL) {
|
|
||||||
return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet));
|
SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet));
|
||||||
if (pParamSet == NULL) {
|
if (pParamSet == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -646,33 +647,37 @@ int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no request is sent
|
||||||
if (pParamSet->totalRspNum == 0) {
|
if (pParamSet->totalRspNum == 0) {
|
||||||
tsem_destroy(&pParamSet->rspSem);
|
tsem_destroy(&pParamSet->rspSem);
|
||||||
taosMemoryFree(pParamSet);
|
taosMemoryFree(pParamSet);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
// count down since waiting rsp num init as 1
|
||||||
ASSERT(waitingRspNum >= 0);
|
tmqCommitRspCountDown(pParamSet);
|
||||||
if (waitingRspNum == 0) {
|
|
||||||
tmqCommitDone(pParamSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!async) {
|
if (!async) {
|
||||||
tsem_wait(&pParamSet->rspSem);
|
tsem_wait(&pParamSet->rspSem);
|
||||||
code = pParamSet->rspErr;
|
code = pParamSet->rspErr;
|
||||||
tsem_destroy(&pParamSet->rspSem);
|
tsem_destroy(&pParamSet->rspSem);
|
||||||
taosMemoryFree(pParamSet);
|
taosMemoryFree(pParamSet);
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!async) {
|
|
||||||
taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree);
|
taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree);
|
||||||
taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree);
|
taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb,
|
||||||
|
void* userParam) {
|
||||||
|
if (msg) {
|
||||||
|
return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam);
|
||||||
|
} else {
|
||||||
|
return tmqCommitConsumerImpl(tmq, automatic, async, userCb, userParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmqAssignAskEpTask(void* param, void* tmrId) {
|
void tmqAssignAskEpTask(void* param, void* tmrId) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
char *tmp = "\\,st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ,32,c=3";
|
char *tmp = "\\,st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ,32,c=3";
|
||||||
char *sql = (char *)taosMemoryCalloc(256, 1);
|
char *sql = (char *)taosMemoryCalloc(256, 1);
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
int ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
int ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(elements.measure, sql);
|
ASSERT_EQ(elements.measure, sql);
|
||||||
ASSERT_EQ(elements.measureLen, strlen(",st"));
|
ASSERT_EQ(elements.measureLen, strlen(",st"));
|
||||||
|
@ -63,14 +63,14 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
tmp = "st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2,c2=false,c4=4f64 1626006833639000000";
|
tmp = "st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2,c2=false,c4=4f64 1626006833639000000";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
|
|
||||||
// case 3 false
|
// case 3 false
|
||||||
tmp = "st, t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2,c2=false,c4=4f64 1626006833639000000";
|
tmp = "st, t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2,c2=false,c4=4f64 1626006833639000000";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(elements.cols, sql + elements.measureTagsLen + 1);
|
ASSERT_EQ(elements.cols, sql + elements.measureTagsLen + 1);
|
||||||
ASSERT_EQ(elements.colsLen, strlen("t1=3,t2=4,t3=t3"));
|
ASSERT_EQ(elements.colsLen, strlen("t1=3,t2=4,t3=t3"));
|
||||||
|
@ -79,7 +79,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
tmp = "st, c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000";
|
tmp = "st, c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(elements.measure, sql);
|
ASSERT_EQ(elements.measure, sql);
|
||||||
ASSERT_EQ(elements.measureLen, strlen("st"));
|
ASSERT_EQ(elements.measureLen, strlen("st"));
|
||||||
|
@ -98,7 +98,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
tmp = " st c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ";
|
tmp = " st c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(elements.measure, sql + 1);
|
ASSERT_EQ(elements.measure, sql + 1);
|
||||||
ASSERT_EQ(elements.measureLen, strlen("st"));
|
ASSERT_EQ(elements.measureLen, strlen("st"));
|
||||||
|
@ -116,21 +116,21 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
tmp = " st c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 ";
|
tmp = " st c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 ";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
|
||||||
// case 7
|
// case 7
|
||||||
tmp = " st , ";
|
tmp = " st , ";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
|
||||||
// case 8 false
|
// case 8 false
|
||||||
tmp = ", st , ";
|
tmp = ", st , ";
|
||||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
taosMemoryFree(sql);
|
taosMemoryFree(sql);
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
|
||||||
"sys.procs.running 1479496100 42 host= web01",
|
"sys.procs.running 1479496100 42 host= web01",
|
||||||
};
|
};
|
||||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||||
int ret = smlParseTelnetLine(info, (void *)sql[i]);
|
int ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) {
|
||||||
|
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||||
if (ret != TSDB_CODE_SUCCESS) break;
|
if (ret != TSDB_CODE_SUCCESS) break;
|
||||||
}
|
}
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
|
@ -617,7 +617,7 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) {
|
||||||
|
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +653,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) {
|
||||||
|
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||||
if (ret != TSDB_CODE_SUCCESS) break;
|
if (ret != TSDB_CODE_SUCCESS) break;
|
||||||
}
|
}
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
|
@ -688,7 +688,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
|
||||||
};
|
};
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||||
if (ret != TSDB_CODE_SUCCESS) break;
|
if (ret != TSDB_CODE_SUCCESS) break;
|
||||||
}
|
}
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
|
@ -1002,7 +1002,7 @@ TEST(testCase, sml_col_4096_Test) {
|
||||||
|
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||||
ret = smlParseInfluxLine(info, sql[i]);
|
ret = smlParseInfluxLine(info, sql[i], strlen(sql[i]));
|
||||||
if (ret != TSDB_CODE_SUCCESS) break;
|
if (ret != TSDB_CODE_SUCCESS) break;
|
||||||
}
|
}
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
|
|
|
@ -1892,12 +1892,13 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
||||||
|
|
||||||
for (int32_t k = 0; k < colNum; k++) {
|
for (int32_t k = 0; k < colNum; k++) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
|
||||||
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
||||||
if (len >= size - 1) return dumpBuf;
|
if (len >= size - 1) return dumpBuf;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* var = colDataGetData(pColInfoData, j);
|
||||||
switch (pColInfoData->info.type) {
|
switch (pColInfoData->info.type) {
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
memset(pBuf, 0, sizeof(pBuf));
|
memset(pBuf, 0, sizeof(pBuf));
|
||||||
|
@ -1926,8 +1927,8 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
||||||
if (len >= size - 1) return dumpBuf;
|
if (len >= size - 1) return dumpBuf;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15lf |", *(double*)var);
|
// len += snprintf(dumpBuf + len, size - len, " %15lf |", *(double*)var);
|
||||||
if (len >= size - 1) return dumpBuf;
|
// if (len >= size - 1) return dumpBuf;
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
||||||
|
|
|
@ -51,6 +51,7 @@ static int32_t dmInitMonitor() {
|
||||||
|
|
||||||
static bool dmCheckDiskSpace() {
|
static bool dmCheckDiskSpace() {
|
||||||
osUpdate();
|
osUpdate();
|
||||||
|
// sufficiency
|
||||||
if (!osDataSpaceSufficient()) {
|
if (!osDataSpaceSufficient()) {
|
||||||
dWarn("free data disk size: %f GB, not sufficient, expected %f GB at least", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
dWarn("free data disk size: %f GB, not sufficient, expected %f GB at least", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,24 @@ static bool dmCheckDiskSpace() {
|
||||||
if (!osTempSpaceSufficient()) {
|
if (!osTempSpaceSufficient()) {
|
||||||
dWarn("free temp disk size: %f GB, not sufficient, expected %f GB at least", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
dWarn("free temp disk size: %f GB, not sufficient, expected %f GB at least", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||||
}
|
}
|
||||||
return true;
|
// availability
|
||||||
|
bool ret = true;
|
||||||
|
if (!osDataSpaceAvailable()) {
|
||||||
|
dError("data disk space unavailable, i.e. %s", tsDataDir);
|
||||||
|
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
if (!osLogSpaceAvailable()) {
|
||||||
|
dError("log disk space unavailable, i.e. %s", tsLogDir);
|
||||||
|
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
if (!osTempSpaceAvailable()) {
|
||||||
|
dError("temp disk space unavailable, i.e. %s", tsTempDir);
|
||||||
|
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dmCheckDataDirVersion() {
|
static bool dmCheckDataDirVersion() {
|
||||||
|
|
|
@ -43,9 +43,7 @@ void Testbase::InitLog(const char* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Testbase::Init(const char* path, int16_t port) {
|
void Testbase::Init(const char* path, int16_t port) {
|
||||||
#ifdef _TD_DARWIN_64
|
|
||||||
osDefaultInit();
|
osDefaultInit();
|
||||||
#endif
|
|
||||||
tsServerPort = port;
|
tsServerPort = port;
|
||||||
strcpy(tsLocalFqdn, "localhost");
|
strcpy(tsLocalFqdn, "localhost");
|
||||||
snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
|
|
@ -603,22 +603,27 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (mndAcquireRpc(pMsg->info.node) == 0) return 0;
|
if (mndAcquireRpc(pMsg->info.node) == 0) return 0;
|
||||||
|
|
||||||
|
SMnode *pMnode = pMsg->info.node;
|
||||||
|
const char *role = syncGetMyRoleStr(pMnode->syncMgmt.sync);
|
||||||
|
bool restored = syncIsRestoreFinish(pMnode->syncMgmt.sync);
|
||||||
if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
||||||
pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER ||
|
pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER ||
|
||||||
pMsg->msgType == TDMT_MND_UPTIME_TIMER) {
|
pMsg->msgType == TDMT_MND_UPTIME_TIMER) {
|
||||||
|
mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored,
|
||||||
|
pMnode->stopped, restored, role);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
SMnode *pMnode = pMsg->info.node;
|
|
||||||
mndGetMnodeEpSet(pMnode, &epSet);
|
mndGetMnodeEpSet(pMnode, &epSet);
|
||||||
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
|
||||||
mDebug(
|
mDebug(
|
||||||
"msg:%p, failed to check mnode state since %s, mnode restored:%d stopped:%d, sync restored:%d role:%s type:%s "
|
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
||||||
"numOfEps:%d inUse:%d",
|
"role:%s, redirect numOfEps:%d inUse:%d",
|
||||||
pMsg, terrstr(), pMnode->restored, pMnode->stopped, syncIsRestoreFinish(pMnode->syncMgmt.sync),
|
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, restored, role, epSet.numOfEps,
|
||||||
syncGetMyRoleStr(pMnode->syncMgmt.sync), TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse);
|
epSet.inUse);
|
||||||
|
|
||||||
if (epSet.numOfEps > 0) {
|
if (epSet.numOfEps > 0) {
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
|
|
|
@ -394,7 +394,6 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
||||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||||
if (mndTransAppendNullLog(pTrans) != 0) goto _OVER;
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -478,7 +477,6 @@ static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeO
|
||||||
static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
|
static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
int32_t numOfReplicas = 0;
|
|
||||||
SDDropMnodeReq dropReq = {0};
|
SDDropMnodeReq dropReq = {0};
|
||||||
SEpSet dropEpSet = {0};
|
SEpSet dropEpSet = {0};
|
||||||
|
|
||||||
|
@ -505,9 +503,8 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
|
|
||||||
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
||||||
if (pObj == NULL) return 0;
|
if (pObj == NULL) return 0;
|
||||||
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) return -1;
|
|
||||||
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) return -1;
|
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||||
if (mndTransAppendNullLog(pTrans) != 0) return -1;
|
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,7 +712,8 @@ static void mndReloadSyncConfig(SMnode *pMnode) {
|
||||||
SMnodeObj *pObj = NULL;
|
SMnodeObj *pObj = NULL;
|
||||||
ESdbStatus objStatus = 0;
|
ESdbStatus objStatus = 0;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
bool hasUpdatingMnode = false;
|
int32_t updatingMnodes = 0;
|
||||||
|
int32_t readyMnodes = 0;
|
||||||
SSyncCfg cfg = {.myIndex = -1};
|
SSyncCfg cfg = {.myIndex = -1};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -723,7 +721,11 @@ static void mndReloadSyncConfig(SMnode *pMnode) {
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
if (objStatus == SDB_STATUS_CREATING || objStatus == SDB_STATUS_DROPPING) {
|
if (objStatus == SDB_STATUS_CREATING || objStatus == SDB_STATUS_DROPPING) {
|
||||||
mInfo("vgId:1, has updating mnode:%d, status:%s", pObj->id, sdbStatusName(objStatus));
|
mInfo("vgId:1, has updating mnode:%d, status:%s", pObj->id, sdbStatusName(objStatus));
|
||||||
hasUpdatingMnode = true;
|
updatingMnodes++;
|
||||||
|
}
|
||||||
|
if (objStatus == SDB_STATUS_READY) {
|
||||||
|
mInfo("vgId:1, has ready mnode:%d, status:%s", pObj->id, sdbStatusName(objStatus));
|
||||||
|
readyMnodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objStatus == SDB_STATUS_READY || objStatus == SDB_STATUS_CREATING) {
|
if (objStatus == SDB_STATUS_READY || objStatus == SDB_STATUS_CREATING) {
|
||||||
|
@ -739,18 +741,25 @@ static void mndReloadSyncConfig(SMnode *pMnode) {
|
||||||
sdbReleaseLock(pSdb, pObj, false);
|
sdbReleaseLock(pSdb, pObj, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (readyMnodes <= 0 || updatingMnodes <= 0) {
|
||||||
|
mInfo("vgId:1, mnode sync not reconfig since readyMnodes:%d updatingMnodes:%d", readyMnodes, updatingMnodes);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ASSERT(0);
|
||||||
|
|
||||||
if (cfg.myIndex == -1) {
|
if (cfg.myIndex == -1) {
|
||||||
mInfo("vgId:1, mnode not reload since selfIndex is -1");
|
#if 1
|
||||||
|
mInfo("vgId:1, mnode sync not reconfig since selfIndex is -1");
|
||||||
|
#else
|
||||||
|
// cannot reconfig because the leader may fail to elect after reboot
|
||||||
|
mInfo("vgId:1, mnode sync not reconfig since selfIndex is -1, do sync stop oper");
|
||||||
|
syncStop(pMnode->syncMgmt.sync);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mndGetRestored(pMnode)) {
|
if (updatingMnodes > 0) {
|
||||||
mInfo("vgId:1, mnode not reload since restore not finished");
|
mInfo("vgId:1, mnode sync reconfig, replica:%d myIndex:%d", cfg.replicaNum, cfg.myIndex);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasUpdatingMnode) {
|
|
||||||
mInfo("vgId:1, start to reload mnode sync, replica:%d myIndex:%d", cfg.replicaNum, cfg.myIndex);
|
|
||||||
for (int32_t i = 0; i < cfg.replicaNum; ++i) {
|
for (int32_t i = 0; i < cfg.replicaNum; ++i) {
|
||||||
SNodeInfo *pNode = &cfg.nodeInfo[i];
|
SNodeInfo *pNode = &cfg.nodeInfo[i];
|
||||||
mInfo("vgId:1, index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
mInfo("vgId:1, index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
||||||
|
|
|
@ -90,14 +90,39 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < msgNum; ++i) {
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
|
if (offset >= pMsg->contLen) {
|
||||||
|
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||||
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
taosArrayDestroy(batchRsp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||||
offset += sizeof(req.msgIdx);
|
offset += sizeof(req.msgIdx);
|
||||||
|
if (offset >= pMsg->contLen) {
|
||||||
|
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||||
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
taosArrayDestroy(batchRsp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||||
offset += sizeof(req.msgType);
|
offset += sizeof(req.msgType);
|
||||||
|
if (offset >= pMsg->contLen) {
|
||||||
|
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||||
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
taosArrayDestroy(batchRsp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||||
offset += sizeof(req.msgLen);
|
offset += sizeof(req.msgLen);
|
||||||
|
if (offset >= pMsg->contLen) {
|
||||||
|
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||||
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
taosArrayDestroy(batchRsp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
req.msg = (char *)pMsg->pCont + offset;
|
req.msg = (char *)pMsg->pCont + offset;
|
||||||
offset += req.msgLen;
|
offset += req.msgLen;
|
||||||
|
|
|
@ -2553,12 +2553,17 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
|
|
||||||
char rollup[160 + VARSTR_HEADER_SIZE] = {0};
|
char rollup[160 + VARSTR_HEADER_SIZE] = {0};
|
||||||
int32_t rollupNum = (int32_t)taosArrayGetSize(pStb->pFuncs);
|
int32_t rollupNum = (int32_t)taosArrayGetSize(pStb->pFuncs);
|
||||||
|
char *sep = ", ";
|
||||||
|
int32_t sepLen = strlen(sep);
|
||||||
|
int32_t rollupLen = sizeof(rollup) - 2;
|
||||||
for (int32_t i = 0; i < rollupNum; ++i) {
|
for (int32_t i = 0; i < rollupNum; ++i) {
|
||||||
char *funcName = taosArrayGet(pStb->pFuncs, i);
|
char *funcName = taosArrayGet(pStb->pFuncs, i);
|
||||||
if (i) {
|
if (i) {
|
||||||
strcat(varDataVal(rollup), ", ");
|
strncat(varDataVal(rollup), sep, rollupLen);
|
||||||
|
rollupLen -= sepLen;
|
||||||
}
|
}
|
||||||
strcat(varDataVal(rollup), funcName);
|
strncat(varDataVal(rollup), funcName, rollupLen);
|
||||||
|
rollupLen -= strlen(funcName);
|
||||||
}
|
}
|
||||||
varDataSetLen(rollup, strlen(varDataVal(rollup)));
|
varDataSetLen(rollup, strlen(varDataVal(rollup)));
|
||||||
|
|
||||||
|
|
|
@ -293,6 +293,14 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
tsem_wait(&pMgmt->syncSem);
|
tsem_wait(&pMgmt->syncSem);
|
||||||
|
} else if (code > 0) {
|
||||||
|
mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId);
|
||||||
|
taosWLockLatch(&pMgmt->lock);
|
||||||
|
pMgmt->transId = 0;
|
||||||
|
taosWUnLockLatch(&pMgmt->lock);
|
||||||
|
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||||
|
sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID);
|
||||||
|
code = 0;
|
||||||
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
} else if (code == -1 && terrno == TSDB_CODE_SYN_INTERNAL_ERROR) {
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_INTERNAL_ERROR) {
|
||||||
|
|
|
@ -403,6 +403,10 @@ const char *sdbStatusName(ESdbStatus status);
|
||||||
void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper);
|
void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper);
|
||||||
int32_t sdbGetIdFromRaw(SSdb *pSdb, SSdbRaw *pRaw);
|
int32_t sdbGetIdFromRaw(SSdb *pSdb, SSdbRaw *pRaw);
|
||||||
|
|
||||||
|
void sdbWriteLock(SSdb *pSdb, int32_t type);
|
||||||
|
void sdbReadLock(SSdb *pSdb, int32_t type);
|
||||||
|
void sdbUnLock(SSdb *pSdb, int32_t type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -181,3 +181,23 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config
|
||||||
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, *index, *term, *config);
|
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, *index, *term, *config);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sdbWriteLock(SSdb *pSdb, int32_t type) {
|
||||||
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
|
// mTrace("sdb table:%d start write lock:%p", type, pLock);
|
||||||
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
// mTrace("sdb table:%d stop write lock:%p", type, pLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sdbReadLock(SSdb *pSdb, int32_t type) {
|
||||||
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
|
// mTrace("sdb table:%d start read lock:%p", type, pLock);
|
||||||
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
// mTrace("sdb table:%d stop read lock:%p", type, pLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sdbUnLock(SSdb *pSdb, int32_t type) {
|
||||||
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
|
// mTrace("sdb table:%d unlock:%p", type, pLock);
|
||||||
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
}
|
||||||
|
|
|
@ -364,8 +364,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
mInfo("write %s to sdb file, total %d rows", sdbTableName(i), sdbGetSize(pSdb, i));
|
mInfo("write %s to sdb file, total %d rows", sdbTableName(i), sdbGetSize(pSdb, i));
|
||||||
|
|
||||||
SHashObj *hash = pSdb->hashObjs[i];
|
SHashObj *hash = pSdb->hashObjs[i];
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[i];
|
sdbWriteLock(pSdb, i);
|
||||||
taosThreadRwlockWrlock(pLock);
|
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -410,7 +409,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
|
|
@ -133,12 +133,12 @@ static int32_t sdbGetkeySize(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
int32_t type = pRow->type;
|
||||||
taosThreadRwlockWrlock(pLock);
|
sdbWriteLock(pSdb, type);
|
||||||
|
|
||||||
SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
||||||
if (pOldRow != NULL) {
|
if (pOldRow != NULL) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -149,7 +149,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
sdbPrintOper(pSdb, pRow, "insert");
|
sdbPrintOper(pSdb, pRow, "insert");
|
||||||
|
|
||||||
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -164,12 +164,12 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
taosHashRemove(hash, pRow->pObj, keySize);
|
taosHashRemove(hash, pRow->pObj, keySize);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
|
|
||||||
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));
|
||||||
|
@ -183,26 +183,27 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[pNewRow->type];
|
int32_t type = pNewRow->type;
|
||||||
taosThreadRwlockWrlock(pLock);
|
sdbWriteLock(pSdb, type);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow *pOldRow = *ppOldRow;
|
SSdbRow *pOldRow = *ppOldRow;
|
||||||
pOldRow->status = pRaw->status;
|
pOldRow->status = pRaw->status;
|
||||||
sdbPrintOper(pSdb, pOldRow, "update");
|
sdbPrintOper(pSdb, pOldRow, "update");
|
||||||
|
sdbUnLock(pSdb, type);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
SdbUpdateFp updateFp = pSdb->updateFps[type];
|
||||||
if (updateFp != NULL) {
|
if (updateFp != NULL) {
|
||||||
code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj);
|
code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
// sdbUnLock(pSdb, type);
|
||||||
sdbFreeRow(pSdb, pNewRow, false);
|
sdbFreeRow(pSdb, pNewRow, false);
|
||||||
|
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
|
@ -210,12 +211,12 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
int32_t type = pRow->type;
|
||||||
taosThreadRwlockWrlock(pLock);
|
sdbWriteLock(pSdb, type);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -228,7 +229,7 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
|
|
||||||
taosHashRemove(hash, pOldRow->pObj, keySize);
|
taosHashRemove(hash, pOldRow->pObj, keySize);
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
|
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
|
|
||||||
|
@ -282,12 +283,11 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
void *pRet = NULL;
|
void *pRet = NULL;
|
||||||
int32_t keySize = sdbGetkeySize(pSdb, type, pKey);
|
int32_t keySize = sdbGetkeySize(pSdb, type, pKey);
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
sdbReadLock(pSdb, type);
|
||||||
taosThreadRwlockRdlock(pLock);
|
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashGet(hash, pKey, keySize);
|
SSdbRow **ppRow = taosHashGet(hash, pKey, keySize);
|
||||||
if (ppRow == NULL || *ppRow == NULL) {
|
if (ppRow == NULL || *ppRow == NULL) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -310,13 +310,13 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
int32_t type = pRow->type;
|
||||||
taosThreadRwlockWrlock(pLock);
|
sdbWriteLock(pSdb, type);
|
||||||
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
||||||
sdbPrintOper(pSdb, pRow, "check");
|
sdbPrintOper(pSdb, pRow, "check");
|
||||||
|
@ -324,7 +324,7 @@ static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbReleaseLock(SSdb *pSdb, void *pObj, bool lock) {
|
void sdbReleaseLock(SSdb *pSdb, void *pObj, bool lock) {
|
||||||
|
@ -333,9 +333,9 @@ void sdbReleaseLock(SSdb *pSdb, void *pObj, bool lock) {
|
||||||
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
||||||
if (pRow->type >= SDB_MAX) return;
|
if (pRow->type >= SDB_MAX) return;
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
int32_t type = pRow->type;
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadRwlockWrlock(pLock);
|
sdbWriteLock(pSdb, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
||||||
|
@ -345,7 +345,7 @@ void sdbReleaseLock(SSdb *pSdb, void *pObj, bool lock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,8 +357,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return NULL;
|
if (hash == NULL) return NULL;
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
sdbReadLock(pSdb, type);
|
||||||
taosThreadRwlockRdlock(pLock);
|
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -373,7 +372,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
*ppObj = pRow->pObj;
|
*ppObj = pRow->pObj;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
|
|
||||||
return ppRow;
|
return ppRow;
|
||||||
}
|
}
|
||||||
|
@ -384,9 +383,8 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return NULL;
|
if (hash == NULL) return NULL;
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadRwlockRdlock(pLock);
|
sdbReadLock(pSdb, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
||||||
|
@ -404,7 +402,7 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ppRow;
|
return ppRow;
|
||||||
|
@ -416,18 +414,17 @@ void sdbCancelFetch(SSdb *pSdb, void *pIter) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
|
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
|
||||||
if (hash == NULL) return;
|
if (hash == NULL) return;
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
int32_t type = pRow->type;
|
||||||
taosThreadRwlockRdlock(pLock);
|
sdbReadLock(pSdb, type);
|
||||||
taosHashCancelIterate(hash, pIter);
|
taosHashCancelIterate(hash, pIter);
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2, void *p3) {
|
void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2, void *p3) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return;
|
if (hash == NULL) return;
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
sdbReadLock(pSdb, type);
|
||||||
taosThreadRwlockRdlock(pLock);
|
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -443,17 +440,16 @@ void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sdbGetSize(SSdb *pSdb, ESdbType type) {
|
int32_t sdbGetSize(SSdb *pSdb, ESdbType type) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return 0;
|
if (hash == NULL) return 0;
|
||||||
|
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
sdbReadLock(pSdb, type);
|
||||||
taosThreadRwlockRdlock(pLock);
|
|
||||||
int32_t size = taosHashGetSize(hash);
|
int32_t size = taosHashGetSize(hash);
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -465,9 +461,7 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
|
||||||
if (pSdb->keyTypes[type] != SDB_KEY_INT32) return -1;
|
if (pSdb->keyTypes[type] != SDB_KEY_INT32) return -1;
|
||||||
|
|
||||||
int32_t maxId = 0;
|
int32_t maxId = 0;
|
||||||
|
sdbReadLock(pSdb, type);
|
||||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
|
||||||
taosThreadRwlockRdlock(pLock);
|
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -477,8 +471,7 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(pLock);
|
sdbUnLock(pSdb, type);
|
||||||
|
|
||||||
maxId = TMAX(maxId, pSdb->maxId[type]);
|
maxId = TMAX(maxId, pSdb->maxId[type]);
|
||||||
return maxId + 1;
|
return maxId + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,6 +258,7 @@ enum {
|
||||||
TD_FTYPE_RSMA_QTASKINFO = 0,
|
TD_FTYPE_RSMA_QTASKINFO = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
struct STFile {
|
struct STFile {
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
STFInfo info;
|
STFInfo info;
|
||||||
|
@ -287,6 +288,7 @@ int32_t tdUpdateTFileHeader(STFile *pTFile);
|
||||||
void tdUpdateTFileMagic(STFile *pTFile, void *pCksm);
|
void tdUpdateTFileMagic(STFile *pTFile, void *pCksm);
|
||||||
void tdCloseTFile(STFile *pTFile);
|
void tdCloseTFile(STFile *pTFile);
|
||||||
void tdDestroyTFile(STFile *pTFile);
|
void tdDestroyTFile(STFile *pTFile);
|
||||||
|
#endif
|
||||||
|
|
||||||
void tdGetVndFileName(int32_t vgId, const char *pdname, const char *dname, const char *fname, int64_t version,
|
void tdGetVndFileName(int32_t vgId, const char *pdname, const char *dname, const char *fname, int64_t version,
|
||||||
char *outputName);
|
char *outputName);
|
||||||
|
|
|
@ -149,7 +149,7 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle);
|
||||||
int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle);
|
int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle);
|
||||||
|
|
||||||
// tqRead
|
// tqRead
|
||||||
int32_t tqScan(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* offset);
|
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* offset);
|
||||||
int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset);
|
int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset);
|
||||||
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
|
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ int32_t tqOffsetDelete(STqOffsetStore* pStore, const char* subscribeKey)
|
||||||
int32_t tqOffsetCommitFile(STqOffsetStore* pStore);
|
int32_t tqOffsetCommitFile(STqOffsetStore* pStore);
|
||||||
|
|
||||||
// tqSink
|
// tqSink
|
||||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
void tqSinkToTableMerge(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
|
|
||||||
// tqOffset
|
// tqOffset
|
||||||
char* tqOffsetBuildFName(const char* path, int32_t ver);
|
char* tqOffsetBuildFName(const char* path, int32_t ver);
|
||||||
|
|
|
@ -51,7 +51,7 @@ static int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pMetaRsp->tbName, tbName, TSDB_TABLE_NAME_LEN);
|
tstrncpy(pMetaRsp->tbName, tbName, TSDB_TABLE_NAME_LEN);
|
||||||
pMetaRsp->numOfColumns = pSchema->nCols;
|
pMetaRsp->numOfColumns = pSchema->nCols;
|
||||||
pMetaRsp->tableType = TSDB_NORMAL_TABLE;
|
pMetaRsp->tableType = TSDB_NORMAL_TABLE;
|
||||||
pMetaRsp->sversion = pSchema->version;
|
pMetaRsp->sversion = pSchema->version;
|
||||||
|
|
|
@ -17,14 +17,17 @@
|
||||||
|
|
||||||
extern SSmaMgmt smaMgmt;
|
extern SSmaMgmt smaMgmt;
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
|
||||||
|
#endif
|
||||||
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
|
||||||
static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
|
static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/**
|
/**
|
||||||
* @brief Only applicable to Rollup SMA
|
* @brief Only applicable to Rollup SMA
|
||||||
*
|
*
|
||||||
|
@ -48,6 +51,7 @@ int32_t smaSyncCommit(SSma *pSma) { return tdProcessRSmaSyncCommitImpl(pSma); }
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaSyncPostCommit(SSma *pSma) { return tdProcessRSmaSyncPostCommitImpl(pSma); }
|
int32_t smaSyncPostCommit(SSma *pSma) { return tdProcessRSmaSyncPostCommitImpl(pSma); }
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Only applicable to Rollup SMA
|
* @brief Only applicable to Rollup SMA
|
||||||
|
@ -108,6 +112,7 @@ int32_t smaBegin(SSma *pSma) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/**
|
/**
|
||||||
* @brief pre-commit for rollup sma(sync commit).
|
* @brief pre-commit for rollup sma(sync commit).
|
||||||
* 1) set trigger stat of rsma timer TASK_TRIGGER_STAT_PAUSED.
|
* 1) set trigger stat of rsma timer TASK_TRIGGER_STAT_PAUSED.
|
||||||
|
@ -169,6 +174,7 @@ static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma) {
|
||||||
#endif
|
#endif
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// SQTaskFile ======================================================
|
// SQTaskFile ======================================================
|
||||||
|
|
||||||
|
@ -230,6 +236,7 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/**
|
/**
|
||||||
* @brief post-commit for rollup sma
|
* @brief post-commit for rollup sma
|
||||||
* 1) clean up the outdated qtaskinfo files
|
* 1) clean up the outdated qtaskinfo files
|
||||||
|
@ -249,6 +256,7 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Rsma async commit implementation(only do some necessary light weighted task)
|
* @brief Rsma async commit implementation(only do some necessary light weighted task)
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
#include "sma.h"
|
#include "sma.h"
|
||||||
|
|
||||||
#define RSMA_QTASKINFO_BUFSIZE (32768) // size
|
|
||||||
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
|
|
||||||
#define RSMA_QTASKEXEC_SMOOTH_SIZE (100) // cnt
|
#define RSMA_QTASKEXEC_SMOOTH_SIZE (100) // cnt
|
||||||
#define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt
|
#define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt
|
||||||
#define RSMA_FETCH_DELAY_MAX (120000) // ms
|
#define RSMA_FETCH_DELAY_MAX (120000) // ms
|
||||||
|
@ -48,23 +46,10 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SR
|
||||||
static void tdRSmaFetchTrigger(void *param, void *tmrId);
|
static void tdRSmaFetchTrigger(void *param, void *tmrId);
|
||||||
static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo);
|
static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo);
|
||||||
static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
|
static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
|
||||||
static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile);
|
|
||||||
static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish);
|
|
||||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter);
|
|
||||||
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem);
|
|
||||||
static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
|
static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
|
||||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer);
|
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer);
|
||||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma);
|
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma);
|
||||||
|
|
||||||
static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) {
|
|
||||||
// adapt accordingly if definition of SRSmaInfo update
|
|
||||||
SRSmaInfo *pResult = NULL;
|
|
||||||
ASSERT(pItem->level == TSDB_RETENTION_L1 || pItem->level == TSDB_RETENTION_L2);
|
|
||||||
pResult = (SRSmaInfo *)POINTER_SHIFT(pItem, -(sizeof(SRSmaInfoItem) * (pItem->level - 1) + RSMA_INFO_HEAD_LEN));
|
|
||||||
ASSERT(pResult->pTSchema->numOfCols > 1);
|
|
||||||
return pResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SRSmaQTaskInfoItem {
|
struct SRSmaQTaskInfoItem {
|
||||||
int32_t len;
|
int32_t len;
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
@ -104,12 +89,6 @@ void tdRSmaQTaskInfoGetFullPathEx(int32_t vgId, tb_uid_t suid, int8_t level, con
|
||||||
snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi64 "%s%" PRIi8, suid, TD_DIRSEP, level);
|
snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi64 "%s%" PRIi8, suid, TD_DIRSEP, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) {
|
|
||||||
return lenWithHead - RSMA_QTASKINFO_HEAD_LEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) { taosMemoryFreeClear(pIter->pBuf); }
|
|
||||||
|
|
||||||
static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
|
static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
|
||||||
// Note: free/kill may in RC
|
// Note: free/kill may in RC
|
||||||
if (!taskHandle || !(*taskHandle)) return;
|
if (!taskHandle || !(*taskHandle)) return;
|
||||||
|
@ -803,6 +782,7 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, const void *pMsg, int32_t inpu
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int32_t tdRsmaPrintSubmitReq(SSma *pSma, SSubmitReq *pReq) {
|
static int32_t tdRsmaPrintSubmitReq(SSma *pSma, SSubmitReq *pReq) {
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
SSubmitBlkIter blkIter = {0};
|
SSubmitBlkIter blkIter = {0};
|
||||||
|
@ -820,6 +800,7 @@ static int32_t tdRsmaPrintSubmitReq(SSma *pSma, SSubmitReq *pReq) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief sync mode
|
* @brief sync mode
|
||||||
|
@ -1189,65 +1170,6 @@ _err:
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer) {
|
|
||||||
SVnode *pVnode = pSma->pVnode;
|
|
||||||
STFile tFile = {0};
|
|
||||||
char qTaskInfoFName[TSDB_FILENAME_LEN] = {0};
|
|
||||||
|
|
||||||
tdRSmaQTaskInfoGetFileName(TD_VID(pVnode), qTaskFileVer, qTaskInfoFName);
|
|
||||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!taosCheckExistFile(TD_TFILE_FULL_NAME(&tFile))) {
|
|
||||||
if (qTaskFileVer > 0) {
|
|
||||||
smaWarn("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", not start as %s not exist",
|
|
||||||
TD_VID(pVnode), type, qTaskFileVer, TD_TFILE_FULL_NAME(&tFile));
|
|
||||||
} else {
|
|
||||||
smaDebug("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", no need as %s not exist", TD_VID(pVnode),
|
|
||||||
type, qTaskFileVer, TD_TFILE_FULL_NAME(&tFile));
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdOpenTFile(&tFile, TD_FILE_READ) < 0) {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
STFInfo tFileInfo = {0};
|
|
||||||
if (tdLoadTFileHeader(&tFile, &tFileInfo) < 0) {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRSmaQTaskInfoIter fIter = {0};
|
|
||||||
if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) {
|
|
||||||
tdRSmaQTaskInfoIterDestroy(&fIter);
|
|
||||||
tdCloseTFile(&tFile);
|
|
||||||
tdDestroyTFile(&tFile);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdRSmaQTaskInfoRestore(pSma, type, &fIter) < 0) {
|
|
||||||
tdRSmaQTaskInfoIterDestroy(&fIter);
|
|
||||||
tdCloseTFile(&tFile);
|
|
||||||
tdDestroyTFile(&tFile);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
tdRSmaQTaskInfoIterDestroy(&fIter);
|
|
||||||
tdCloseTFile(&tFile);
|
|
||||||
tdDestroyTFile(&tFile);
|
|
||||||
|
|
||||||
// restored successfully from committed or sync
|
|
||||||
smaInfo("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", qtaskinfo reload succeed", TD_VID(pVnode),
|
|
||||||
type, qTaskFileVer);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
_err:
|
|
||||||
smaError("vgId:%d, restore rsma task %" PRIi8 " for version %" PRIi64 ", qtaskinfo reload failed since %s",
|
|
||||||
TD_VID(pVnode), type, qTaskFileVer, terrstr());
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief reload ts data from checkpoint
|
* @brief reload ts data from checkpoint
|
||||||
*
|
*
|
||||||
|
@ -1270,19 +1192,12 @@ int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
// step 2: reload ts data from checkpoint
|
||||||
// step 2: retrieve qtaskinfo items from the persistence file(rsma/qtaskinfo) and restore
|
|
||||||
if (tdRSmaRestoreQTaskInfoReload(pSma, type, qtaskFileVer) < 0) {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// step 3: reload ts data from checkpoint
|
|
||||||
if (tdRSmaRestoreTSDataReload(pSma) < 0) {
|
if (tdRSmaRestoreTSDataReload(pSma) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 4: open SRSmaFS for qTaskFiles
|
// step 3: open SRSmaFS for qTaskFiles
|
||||||
if (tdRSmaFSOpen(pSma, qtaskFileVer) < 0) {
|
if (tdRSmaFSOpen(pSma, qtaskFileVer) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1295,191 +1210,6 @@ _err:
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Restore from SRSmaQTaskInfoItem
|
|
||||||
*
|
|
||||||
* @param pSma
|
|
||||||
* @param pItem
|
|
||||||
* @return int32_t
|
|
||||||
*/
|
|
||||||
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *pItem) {
|
|
||||||
SRSmaInfo *pRSmaInfo = NULL;
|
|
||||||
void *qTaskInfo = NULL;
|
|
||||||
|
|
||||||
pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pItem->suid);
|
|
||||||
if (!pRSmaInfo) {
|
|
||||||
smaDebug("vgId:%d, no restore as no rsma info for table:%" PRIu64, SMA_VID(pSma), pItem->suid);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pItem->type == TSDB_RETENTION_L1) {
|
|
||||||
qTaskInfo = RSMA_INFO_QTASK(pRSmaInfo, 0);
|
|
||||||
} else if (pItem->type == TSDB_RETENTION_L2) {
|
|
||||||
qTaskInfo = RSMA_INFO_QTASK(pRSmaInfo, 1);
|
|
||||||
} else {
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!qTaskInfo) {
|
|
||||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
|
||||||
smaDebug("vgId:%d, no restore as NULL rsma qTaskInfo for table:%" PRIu64, SMA_VID(pSma), pItem->suid);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qDeserializeTaskStatus(qTaskInfo, pItem->qTaskInfo, pItem->len) < 0) {
|
|
||||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
|
||||||
smaError("vgId:%d, restore rsma task failed for table:%" PRIi64 " level %d since %s", SMA_VID(pSma), pItem->suid,
|
|
||||||
pItem->type, terrstr());
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid,
|
|
||||||
pItem->type);
|
|
||||||
|
|
||||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile) {
|
|
||||||
memset(pIter, 0, sizeof(*pIter));
|
|
||||||
pIter->pTFile = pTFile;
|
|
||||||
pIter->offset = TD_FILE_HEAD_SIZE;
|
|
||||||
|
|
||||||
if (tdGetTFileSize(pTFile, &pIter->fsize) < 0) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pIter->fsize - TD_FILE_HEAD_SIZE) < RSMA_QTASKINFO_BUFSIZE) {
|
|
||||||
pIter->nAlloc = pIter->fsize - TD_FILE_HEAD_SIZE;
|
|
||||||
} else {
|
|
||||||
pIter->nAlloc = RSMA_QTASKINFO_BUFSIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pIter->nAlloc < TD_FILE_HEAD_SIZE) {
|
|
||||||
pIter->nAlloc = TD_FILE_HEAD_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
pIter->pBuf = taosMemoryMalloc(pIter->nAlloc);
|
|
||||||
if (!pIter->pBuf) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
pIter->qBuf = pIter->pBuf;
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish) {
|
|
||||||
STFile *pTFile = pIter->pTFile;
|
|
||||||
int64_t nBytes = RSMA_QTASKINFO_BUFSIZE;
|
|
||||||
|
|
||||||
if (pIter->offset >= pIter->fsize) {
|
|
||||||
*isFinish = true;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pIter->fsize - pIter->offset) < RSMA_QTASKINFO_BUFSIZE) {
|
|
||||||
nBytes = pIter->fsize - pIter->offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET) < 0) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdReadTFile(pTFile, pIter->pBuf, nBytes) != nBytes) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t infoLen = 0;
|
|
||||||
taosDecodeFixedI32(pIter->pBuf, &infoLen);
|
|
||||||
if (infoLen > nBytes) {
|
|
||||||
if (infoLen <= RSMA_QTASKINFO_BUFSIZE) {
|
|
||||||
terrno = TSDB_CODE_RSMA_FILE_CORRUPTED;
|
|
||||||
smaError("iterate rsma qtaskinfo file %s failed since %s", TD_TFILE_FULL_NAME(pIter->pTFile), terrstr());
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
if (pIter->nAlloc < infoLen) {
|
|
||||||
pIter->nAlloc = infoLen;
|
|
||||||
void *pBuf = taosMemoryRealloc(pIter->pBuf, infoLen);
|
|
||||||
if (!pBuf) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
pIter->pBuf = pBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
nBytes = infoLen;
|
|
||||||
|
|
||||||
if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET) < 0) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdReadTFile(pTFile, pIter->pBuf, nBytes) != nBytes) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pIter->qBuf = pIter->pBuf;
|
|
||||||
pIter->offset += nBytes;
|
|
||||||
pIter->nBytes = nBytes;
|
|
||||||
pIter->nBufPos = 0;
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter) {
|
|
||||||
while (1) {
|
|
||||||
// block iter
|
|
||||||
bool isFinish = false;
|
|
||||||
if (tdRSmaQTaskInfoIterNextBlock(pIter, &isFinish) < 0) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
if (isFinish) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// consume the block
|
|
||||||
int32_t qTaskInfoLenWithHead = 0;
|
|
||||||
pIter->qBuf = taosDecodeFixedI32(pIter->qBuf, &qTaskInfoLenWithHead);
|
|
||||||
if (qTaskInfoLenWithHead < RSMA_QTASKINFO_HEAD_LEN) {
|
|
||||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
|
||||||
smaError("vgId:%d, restore rsma task %" PRIi8 " from qtaskinfo file %s failed since %s", SMA_VID(pSma), type,
|
|
||||||
TD_TFILE_FULL_NAME(pIter->pTFile), terrstr());
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if ((pIter->nBufPos + qTaskInfoLenWithHead) <= pIter->nBytes) {
|
|
||||||
SRSmaQTaskInfoItem infoItem = {0};
|
|
||||||
pIter->qBuf = taosDecodeFixedI8(pIter->qBuf, &infoItem.type);
|
|
||||||
pIter->qBuf = taosDecodeFixedI64(pIter->qBuf, &infoItem.suid);
|
|
||||||
infoItem.qTaskInfo = pIter->qBuf;
|
|
||||||
infoItem.len = tdRSmaQTaskInfoContLen(qTaskInfoLenWithHead);
|
|
||||||
// do the restore job
|
|
||||||
smaDebug("vgId:%d, restore rsma task %" PRIi8 " from qtaskinfo file %s offset:%" PRIi64 "\n", SMA_VID(pSma),
|
|
||||||
type, TD_TFILE_FULL_NAME(pIter->pTFile), pIter->offset - pIter->nBytes + pIter->nBufPos);
|
|
||||||
tdRSmaQTaskInfoItemRestore(pSma, &infoItem);
|
|
||||||
|
|
||||||
pIter->qBuf = POINTER_SHIFT(pIter->qBuf, infoItem.len);
|
|
||||||
pIter->nBufPos += qTaskInfoLenWithHead;
|
|
||||||
|
|
||||||
if ((pIter->nBufPos + RSMA_QTASKINFO_HEAD_LEN) >= pIter->nBytes) {
|
|
||||||
// prepare and load next block in the file
|
|
||||||
pIter->offset -= (pIter->nBytes - pIter->nBufPos);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pIter->qBuf = taosDecodeFixedI32(pIter->qBuf, &qTaskInfoLenWithHead);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// prepare and load next block in the file
|
|
||||||
pIter->offset -= (pIter->nBytes - pIter->nBufPos);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
||||||
SSma *pSma = pRSmaStat->pSma;
|
SSma *pSma = pRSmaStat->pSma;
|
||||||
SVnode *pVnode = pSma->pVnode;
|
SVnode *pVnode = pSma->pVnode;
|
||||||
|
@ -1523,148 +1253,6 @@ _err:
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
|
||||||
SSma *pSma = pRSmaStat->pSma;
|
|
||||||
SVnode *pVnode = pSma->pVnode;
|
|
||||||
int32_t vid = SMA_VID(pSma);
|
|
||||||
int64_t toffset = 0;
|
|
||||||
bool isFileCreated = false;
|
|
||||||
|
|
||||||
if (taosHashGetSize(pInfoHash) <= 0) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *infoHash = taosHashIterate(pInfoHash, NULL);
|
|
||||||
if (!infoHash) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t fsMaxVer = tdRSmaFSMaxVer(pSma, pRSmaStat);
|
|
||||||
if (pRSmaStat->commitAppliedVer <= fsMaxVer) {
|
|
||||||
smaDebug("vgId:%d, rsma persist, no need as applied %" PRIi64 " not larger than fsMaxVer %" PRIi64, vid,
|
|
||||||
pRSmaStat->commitAppliedVer, fsMaxVer);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
STFile tFile = {0};
|
|
||||||
#if 0
|
|
||||||
if (pRSmaStat->commitAppliedVer > 0) {
|
|
||||||
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
|
||||||
tdRSmaQTaskInfoGetFileName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
|
||||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
|
||||||
smaError("vgId:%d, rsma persist, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
if (tdCreateTFile(&tFile, true, TD_FTYPE_RSMA_QTASKINFO) < 0) {
|
|
||||||
smaError("vgId:%d, rsma persist, create %s failed since %s", vid, TD_TFILE_FULL_NAME(&tFile), terrstr());
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
smaDebug("vgId:%d, rsma, serialize qTaskInfo, file %s created", vid, TD_TFILE_FULL_NAME(&tFile));
|
|
||||||
|
|
||||||
isFileCreated = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (infoHash) {
|
|
||||||
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash;
|
|
||||||
|
|
||||||
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
|
||||||
infoHash = taosHashIterate(pInfoHash, infoHash);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
|
||||||
#if 0
|
|
||||||
qTaskInfo_t taskInfo = RSMA_INFO_IQTASK(pRSmaInfo, i);
|
|
||||||
#endif
|
|
||||||
qTaskInfo_t taskInfo = RSMA_INFO_QTASK(pRSmaInfo, i);
|
|
||||||
if (!taskInfo) {
|
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *pOutput = NULL;
|
|
||||||
int32_t len = 0;
|
|
||||||
int8_t type = (int8_t)(i + 1);
|
|
||||||
if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) {
|
|
||||||
smaError("vgId:%d, rsma, table %" PRIi64 " level %d serialize qTaskInfo failed since %s", vid, pRSmaInfo->suid,
|
|
||||||
i + 1, terrstr());
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
if (!pOutput || len <= 0) {
|
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64
|
|
||||||
" level %d serialize qTaskInfo success but no output(len %d), not persist",
|
|
||||||
vid, pRSmaInfo->suid, i + 1, len);
|
|
||||||
taosMemoryFreeClear(pOutput);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d serialize qTaskInfo success with len %d, need persist", vid,
|
|
||||||
pRSmaInfo->suid, i + 1, len);
|
|
||||||
|
|
||||||
if (!isFileCreated) {
|
|
||||||
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
|
||||||
tdRSmaQTaskInfoGetFileName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
|
||||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
|
||||||
smaError("vgId:%d, rsma persist, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
if (tdCreateTFile(&tFile, true, TD_FTYPE_RSMA_QTASKINFO) < 0) {
|
|
||||||
smaError("vgId:%d, rsma persist, create %s failed since %s", vid, TD_TFILE_FULL_NAME(&tFile), terrstr());
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64 " serialize qTaskInfo, file %s created", vid, pRSmaInfo->suid,
|
|
||||||
TD_TFILE_FULL_NAME(&tFile));
|
|
||||||
|
|
||||||
isFileCreated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
char tmpBuf[RSMA_QTASKINFO_HEAD_LEN] = {0};
|
|
||||||
void *pTmpBuf = &tmpBuf;
|
|
||||||
int32_t headLen = 0;
|
|
||||||
headLen += taosEncodeFixedI32(&pTmpBuf, len + RSMA_QTASKINFO_HEAD_LEN);
|
|
||||||
headLen += taosEncodeFixedI8(&pTmpBuf, type);
|
|
||||||
headLen += taosEncodeFixedI64(&pTmpBuf, pRSmaInfo->suid);
|
|
||||||
|
|
||||||
ASSERT(headLen <= RSMA_QTASKINFO_HEAD_LEN);
|
|
||||||
tdAppendTFile(&tFile, (void *)&tmpBuf, headLen, &toffset);
|
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d head part(len:%d) appended to offset:%" PRIi64, vid,
|
|
||||||
pRSmaInfo->suid, i + 1, headLen, toffset);
|
|
||||||
tdAppendTFile(&tFile, pOutput, len, &toffset);
|
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d body part len:%d appended to offset:%" PRIi64, vid,
|
|
||||||
pRSmaInfo->suid, i + 1, len, toffset);
|
|
||||||
|
|
||||||
taosMemoryFree(pOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
infoHash = taosHashIterate(pInfoHash, infoHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFileCreated) {
|
|
||||||
if (tdUpdateTFileHeader(&tFile) < 0) {
|
|
||||||
smaError("vgId:%d, rsma, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile),
|
|
||||||
tstrerror(terrno));
|
|
||||||
goto _err;
|
|
||||||
} else {
|
|
||||||
smaDebug("vgId:%d, rsma, succeed to update tfile %s header", vid, TD_TFILE_FULL_NAME(&tFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
tdCloseTFile(&tFile);
|
|
||||||
tdDestroyTFile(&tFile);
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
_err:
|
|
||||||
smaError("vgId:%d, rsma persist failed since %s", vid, terrstr());
|
|
||||||
if (isFileCreated) {
|
|
||||||
tdRemoveTFile(&tFile);
|
|
||||||
tdDestroyTFile(&tFile);
|
|
||||||
}
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief trigger to get rsma result in async mode
|
* @brief trigger to get rsma result in async mode
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "sma.h"
|
#include "sma.h"
|
||||||
|
|
||||||
// smaFileUtil ================
|
// smaFileUtil ================
|
||||||
|
#if 0
|
||||||
#define TD_FILE_STATE_OK 0
|
#define TD_FILE_STATE_OK 0
|
||||||
#define TD_FILE_STATE_BAD 1
|
#define TD_FILE_STATE_BAD 1
|
||||||
|
|
||||||
|
@ -182,6 +182,8 @@ void tdCloseTFile(STFile *pTFile) {
|
||||||
|
|
||||||
void tdDestroyTFile(STFile *pTFile) { taosMemoryFreeClear(TD_TFILE_FULL_NAME(pTFile)); }
|
void tdDestroyTFile(STFile *pTFile) { taosMemoryFreeClear(TD_TFILE_FULL_NAME(pTFile)); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void tdGetVndFileName(int32_t vgId, const char *pdname, const char *dname, const char *fname, int64_t version,
|
void tdGetVndFileName(int32_t vgId, const char *pdname, const char *dname, const char *fname, int64_t version,
|
||||||
char *outputName) {
|
char *outputName) {
|
||||||
if (version < 0) {
|
if (version < 0) {
|
||||||
|
@ -221,6 +223,7 @@ void tdGetVndDirName(int32_t vgId, const char *pdname, const char *dname, bool e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t tdInitTFile(STFile *pTFile, const char *dname, const char *fname) {
|
int32_t tdInitTFile(STFile *pTFile, const char *dname, const char *fname) {
|
||||||
TD_TFILE_SET_STATE(pTFile, TD_FILE_STATE_OK);
|
TD_TFILE_SET_STATE(pTFile, TD_FILE_STATE_OK);
|
||||||
TD_TFILE_SET_CLOSED(pTFile);
|
TD_TFILE_SET_CLOSED(pTFile);
|
||||||
|
@ -286,6 +289,8 @@ int32_t tdRemoveTFile(STFile *pTFile) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// smaXXXUtil ================
|
// smaXXXUtil ================
|
||||||
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) {
|
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) {
|
||||||
void *pResult = taosAcquireRef(rsetId, refId);
|
void *pResult = taosAcquireRef(rsetId, refId);
|
||||||
|
|
|
@ -595,7 +595,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
tqInitTaosxRsp(&taosxRsp, pReq);
|
tqInitTaosxRsp(&taosxRsp, pReq);
|
||||||
|
|
||||||
if (fetchOffsetNew.type != TMQ_OFFSET__LOG) {
|
if (fetchOffsetNew.type != TMQ_OFFSET__LOG) {
|
||||||
tqScan(pTq, pHandle, &taosxRsp, &metaRsp, &fetchOffsetNew);
|
tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, &fetchOffsetNew);
|
||||||
|
|
||||||
if (metaRsp.metaRspLen > 0) {
|
if (metaRsp.metaRspLen > 0) {
|
||||||
if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) {
|
if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) {
|
||||||
|
@ -924,7 +924,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
|
||||||
pTask->smaSink.smaSink = smaHandleRes;
|
pTask->smaSink.smaSink = smaHandleRes;
|
||||||
} else if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
} else if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
||||||
pTask->tbSink.vnode = pTq->pVnode;
|
pTask->tbSink.vnode = pTq->pVnode;
|
||||||
pTask->tbSink.tbSinkFunc = tqTableSink1;
|
pTask->tbSink.tbSinkFunc = tqSinkToTablePipeline;
|
||||||
|
|
||||||
ASSERT(pTask->tbSink.pSchemaWrapper);
|
ASSERT(pTask->tbSink.pSchemaWrapper);
|
||||||
ASSERT(pTask->tbSink.pSchemaWrapper->pSchema);
|
ASSERT(pTask->tbSink.pSchemaWrapper->pSchema);
|
||||||
|
|
|
@ -123,7 +123,7 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqScan(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* pOffset) {
|
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* pOffset) {
|
||||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
qTaskInfo_t task = pExec->task;
|
qTaskInfo_t task = pExec->task;
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||||
const SArray* pBlocks = (const SArray*)data;
|
const SArray* pBlocks = (const SArray*)data;
|
||||||
SVnode* pVnode = (SVnode*)vnode;
|
SVnode* pVnode = (SVnode*)vnode;
|
||||||
int64_t suid = pTask->tbSink.stbUid;
|
int64_t suid = pTask->tbSink.stbUid;
|
||||||
|
@ -528,7 +528,7 @@ void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||||
taosArrayDestroy(tagArray);
|
taosArrayDestroy(tagArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
void tqSinkToTableMerge(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||||
const SArray* pRes = (const SArray*)data;
|
const SArray* pRes = (const SArray*)data;
|
||||||
SVnode* pVnode = (SVnode*)vnode;
|
SVnode* pVnode = (SVnode*)vnode;
|
||||||
SBatchDeleteReq deleteReq = {0};
|
SBatchDeleteReq deleteReq = {0};
|
||||||
|
|
|
@ -330,6 +330,11 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
rspSize += sizeof(int32_t);
|
rspSize += sizeof(int32_t);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
if (rspSize > MAX_META_BATCH_RSP_SIZE) {
|
||||||
|
code = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
pRsp = rpcMallocCont(rspSize);
|
pRsp = rpcMallocCont(rspSize);
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -302,8 +302,10 @@ int32_t ctgUpdateTbMeta(SCatalog* pCtg, STableMetaRsp* rspMsg, bool syncOp) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
if (output) {
|
||||||
taosMemoryFreeClear(output->tbMeta);
|
taosMemoryFreeClear(output->tbMeta);
|
||||||
taosMemoryFreeClear(output);
|
taosMemoryFreeClear(output);
|
||||||
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ int32_t ctgInitGetIndexTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
||||||
|
|
||||||
SCtgIndexCtx* ctx = task.taskCtx;
|
SCtgIndexCtx* ctx = task.taskCtx;
|
||||||
|
|
||||||
strcpy(ctx->indexFName, name);
|
tstrncpy(ctx->indexFName, name, sizeof(ctx->indexFName));
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ int32_t ctgInitGetUdfTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
||||||
|
|
||||||
SCtgUdfCtx* ctx = task.taskCtx;
|
SCtgUdfCtx* ctx = task.taskCtx;
|
||||||
|
|
||||||
strcpy(ctx->udfName, name);
|
tstrncpy(ctx->udfName, name, sizeof(ctx->udfName));
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
|
|
|
@ -660,7 +660,7 @@ int32_t ctgDropDbCacheEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
strncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
msg->dbId = dbId;
|
msg->dbId = dbId;
|
||||||
|
|
||||||
op->data = msg;
|
op->data = msg;
|
||||||
|
@ -693,7 +693,7 @@ int32_t ctgDropDbVgroupEnqueue(SCatalog *pCtg, const char *dbFName, bool syncOp)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
strncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
|
|
||||||
op->data = msg;
|
op->data = msg;
|
||||||
|
|
||||||
|
@ -721,8 +721,8 @@ int32_t ctgDropStbMetaEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId,
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
strncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
strncpy(msg->stbName, stbName, sizeof(msg->stbName));
|
tstrncpy(msg->stbName, stbName, sizeof(msg->stbName));
|
||||||
msg->dbId = dbId;
|
msg->dbId = dbId;
|
||||||
msg->suid = suid;
|
msg->suid = suid;
|
||||||
|
|
||||||
|
@ -751,8 +751,8 @@ int32_t ctgDropTbMetaEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId,
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
strncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
strncpy(msg->tbName, tbName, sizeof(msg->tbName));
|
tstrncpy(msg->tbName, tbName, sizeof(msg->tbName));
|
||||||
msg->dbId = dbId;
|
msg->dbId = dbId;
|
||||||
|
|
||||||
op->data = msg;
|
op->data = msg;
|
||||||
|
@ -785,7 +785,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
||||||
dbFName = p + 1;
|
dbFName = p + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
msg->dbId = dbId;
|
msg->dbId = dbId;
|
||||||
msg->dbInfo = dbInfo;
|
msg->dbInfo = dbInfo;
|
||||||
|
@ -817,7 +817,8 @@ int32_t ctgUpdateTbMetaEnqueue(SCatalog *pCtg, STableMetaOutput *output, bool sy
|
||||||
|
|
||||||
char *p = strchr(output->dbFName, '.');
|
char *p = strchr(output->dbFName, '.');
|
||||||
if (p && IS_SYS_DBNAME(p + 1)) {
|
if (p && IS_SYS_DBNAME(p + 1)) {
|
||||||
memmove(output->dbFName, p + 1, strlen(p + 1));
|
int32_t len = strlen(p + 1);
|
||||||
|
memmove(output->dbFName, p + 1, len >= TSDB_DB_FNAME_LEN ? TSDB_DB_FNAME_LEN - 1 : len);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
|
@ -852,7 +853,7 @@ int32_t ctgUpdateVgEpsetEnqueue(SCatalog *pCtg, char *dbFName, int32_t vgId, SEp
|
||||||
}
|
}
|
||||||
|
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
strcpy(msg->dbFName, dbFName);
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
msg->vgId = vgId;
|
msg->vgId = vgId;
|
||||||
msg->epSet = *pEpSet;
|
msg->epSet = *pEpSet;
|
||||||
|
|
||||||
|
@ -1215,7 +1216,7 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
|
||||||
CTG_CACHE_STAT_INC(numOfDb, 1);
|
CTG_CACHE_STAT_INC(numOfDb, 1);
|
||||||
|
|
||||||
SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1};
|
SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1};
|
||||||
strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
||||||
|
|
||||||
ctgDebug("db added to cache, dbFName:%s, dbId:0x%" PRIx64, dbFName, dbId);
|
ctgDebug("db added to cache, dbFName:%s, dbId:0x%" PRIx64, dbFName, dbId);
|
||||||
|
|
||||||
|
@ -1331,8 +1332,8 @@ int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uin
|
||||||
metaRent.smaVer = pCache->pIndex->version;
|
metaRent.smaVer = pCache->pIndex->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(metaRent.dbFName, dbFName);
|
tstrncpy(metaRent.dbFName, dbFName, sizeof(metaRent.dbFName));
|
||||||
strcpy(metaRent.stbName, tbName);
|
tstrncpy(metaRent.stbName, tbName, sizeof(metaRent.stbName));
|
||||||
|
|
||||||
CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableVersion),
|
CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->stbRent, &metaRent, metaRent.suid, sizeof(SSTableVersion),
|
||||||
ctgStbVersionSortCompare, ctgStbVersionSearchCompare));
|
ctgStbVersionSortCompare, ctgStbVersionSearchCompare));
|
||||||
|
@ -1418,7 +1419,9 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
|
||||||
ctgDebug("stb 0x%" PRIx64 " updated to cache, dbFName:%s, tbName:%s, tbType:%d", meta->suid, dbFName, tbName,
|
ctgDebug("stb 0x%" PRIx64 " updated to cache, dbFName:%s, tbName:%s, tbType:%d", meta->suid, dbFName, tbName,
|
||||||
meta->tableType);
|
meta->tableType);
|
||||||
|
|
||||||
|
if (pCache) {
|
||||||
CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbId, meta->suid, pCache));
|
CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbId, meta->suid, pCache));
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1590,7 +1593,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
dbCache = NULL;
|
dbCache = NULL;
|
||||||
|
|
||||||
strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
tstrncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName));
|
||||||
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion),
|
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &vgVersion, vgVersion.dbId, sizeof(SDbVgVersion),
|
||||||
ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare));
|
ctgDbVgVersionSortCompare, ctgDbVgVersionSearchCompare));
|
||||||
|
|
||||||
|
@ -1680,9 +1683,9 @@ int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
if (CTG_IS_META_TABLE(pMeta->metaType) || CTG_IS_META_BOTH(pMeta->metaType)) {
|
if (CTG_IS_META_TABLE(pMeta->metaType) || CTG_IS_META_BOTH(pMeta->metaType)) {
|
||||||
int32_t metaSize = CTG_META_SIZE(pMeta->tbMeta);
|
int32_t metaSize = CTG_META_SIZE(pMeta->tbMeta);
|
||||||
CTG_ERR_JRET(
|
code = ctgWriteTbMetaToCache(pCtg, dbCache, pMeta->dbFName, pMeta->dbId, pMeta->tbName, pMeta->tbMeta, metaSize);
|
||||||
ctgWriteTbMetaToCache(pCtg, dbCache, pMeta->dbFName, pMeta->dbId, pMeta->tbName, pMeta->tbMeta, metaSize));
|
|
||||||
pMeta->tbMeta = NULL;
|
pMeta->tbMeta = NULL;
|
||||||
|
CTG_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CTG_IS_META_CTABLE(pMeta->metaType) || CTG_IS_META_BOTH(pMeta->metaType)) {
|
if (CTG_IS_META_CTABLE(pMeta->metaType) || CTG_IS_META_BOTH(pMeta->metaType)) {
|
||||||
|
@ -1697,10 +1700,8 @@ int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (pMeta) {
|
|
||||||
taosMemoryFreeClear(pMeta->tbMeta);
|
taosMemoryFreeClear(pMeta->tbMeta);
|
||||||
taosMemoryFreeClear(pMeta);
|
taosMemoryFreeClear(pMeta);
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(msg);
|
taosMemoryFreeClear(msg);
|
||||||
|
|
||||||
|
|
|
@ -361,7 +361,12 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
SArray* pTagVals = NULL;
|
SArray* pTagVals = NULL;
|
||||||
STag* pTag = (STag*)pCfg->pTags;
|
STag* pTag = (STag*)pCfg->pTags;
|
||||||
|
|
||||||
if (pCfg->pTags && tTagIsJson(pTag)) {
|
if (NULL == pCfg->pTags || pCfg->numOfTags <= 0) {
|
||||||
|
qError("tag missed in table cfg, pointer:%p, numOfTags:%d", pCfg->pTags, pCfg->numOfTags);
|
||||||
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tTagIsJson(pTag)) {
|
||||||
char* pJson = parseTagDatatoJson(pTag);
|
char* pJson = parseTagDatatoJson(pTag);
|
||||||
if (pJson) {
|
if (pJson) {
|
||||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
|
||||||
|
|
|
@ -53,6 +53,11 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int
|
||||||
|
|
||||||
#define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0)
|
#define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0)
|
||||||
|
|
||||||
|
#define IS_VALID_SESSION_WIN(winInfo) ((winInfo).sessionWin.win.skey > 0)
|
||||||
|
#define SET_SESSION_WIN_INVALID(winInfo) ((winInfo).sessionWin.win.skey = INT64_MIN)
|
||||||
|
#define IS_INVALID_SESSION_WIN_KEY(winKey) ((winKey).win.skey <= 0)
|
||||||
|
#define SET_SESSION_WIN_KEY_INVALID(pWinKey) ((pWinKey)->win.skey = INT64_MIN)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// when this task starts to execute, this status will set
|
// when this task starts to execute, this status will set
|
||||||
TASK_NOT_COMPLETED = 0x1u,
|
TASK_NOT_COMPLETED = 0x1u,
|
||||||
|
@ -434,15 +439,15 @@ typedef struct SCatchSupporter {
|
||||||
} SCatchSupporter;
|
} SCatchSupporter;
|
||||||
|
|
||||||
typedef struct SStreamAggSupporter {
|
typedef struct SStreamAggSupporter {
|
||||||
SHashObj* pResultRows;
|
|
||||||
SArray* pCurWins;
|
|
||||||
int32_t valueSize;
|
|
||||||
int32_t keySize;
|
|
||||||
char* pKeyBuf; // window key buffer
|
|
||||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
|
||||||
int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
|
int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
|
||||||
int32_t currentPageId; // buffer page that is active
|
|
||||||
SSDataBlock* pScanBlock;
|
SSDataBlock* pScanBlock;
|
||||||
|
SStreamState* pState;
|
||||||
|
int64_t gap; // stream session window gap
|
||||||
|
SqlFunctionCtx* pDummyCtx; // for combine
|
||||||
|
SSHashObj* pResultRows;
|
||||||
|
int32_t stateKeySize;
|
||||||
|
int16_t stateKeyType;
|
||||||
|
SDiskbasedBuf* pResultBuf;
|
||||||
} SStreamAggSupporter;
|
} SStreamAggSupporter;
|
||||||
|
|
||||||
typedef struct SWindowSupporter {
|
typedef struct SWindowSupporter {
|
||||||
|
@ -736,16 +741,14 @@ typedef struct SSessionAggOperatorInfo {
|
||||||
} SSessionAggOperatorInfo;
|
} SSessionAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SResultWindowInfo {
|
typedef struct SResultWindowInfo {
|
||||||
SResultRowPosition pos;
|
void* pOutputBuf;
|
||||||
STimeWindow win;
|
SSessionKey sessionWin;
|
||||||
uint64_t groupId;
|
|
||||||
bool isOutput;
|
bool isOutput;
|
||||||
bool isClosed;
|
|
||||||
} SResultWindowInfo;
|
} SResultWindowInfo;
|
||||||
|
|
||||||
typedef struct SStateWindowInfo {
|
typedef struct SStateWindowInfo {
|
||||||
SResultWindowInfo winInfo;
|
SResultWindowInfo winInfo;
|
||||||
SStateKeys stateKey;
|
SStateKeys* pStateKey;
|
||||||
} SStateWindowInfo;
|
} SStateWindowInfo;
|
||||||
|
|
||||||
typedef struct SStreamSessionAggOperatorInfo {
|
typedef struct SStreamSessionAggOperatorInfo {
|
||||||
|
@ -753,17 +756,15 @@ typedef struct SStreamSessionAggOperatorInfo {
|
||||||
SStreamAggSupporter streamAggSup;
|
SStreamAggSupporter streamAggSup;
|
||||||
SExprSupp scalarSupp; // supporter for perform scalar function
|
SExprSupp scalarSupp; // supporter for perform scalar function
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
int64_t gap; // session window gap
|
|
||||||
int32_t primaryTsIndex; // primary timestamp slot id
|
int32_t primaryTsIndex; // primary timestamp slot id
|
||||||
int32_t endTsIndex; // window end timestamp slot id
|
int32_t endTsIndex; // window end timestamp slot id
|
||||||
int32_t order; // current SSDataBlock scan order
|
int32_t order; // current SSDataBlock scan order
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
SSDataBlock* pWinBlock; // window result
|
SSDataBlock* pWinBlock; // window result
|
||||||
SqlFunctionCtx* pDummyCtx; // for combine
|
|
||||||
SSDataBlock* pDelRes; // delete result
|
SSDataBlock* pDelRes; // delete result
|
||||||
SSDataBlock* pUpdateRes; // update window
|
SSDataBlock* pUpdateRes; // update window
|
||||||
bool returnUpdate;
|
bool returnUpdate;
|
||||||
SHashObj* pStDeleted;
|
SSHashObj* pStDeleted;
|
||||||
void* pDelIterator;
|
void* pDelIterator;
|
||||||
SArray* pChildren; // cache for children's result; final stream operator
|
SArray* pChildren; // cache for children's result; final stream operator
|
||||||
SPhysiNode* pPhyNode; // create new child
|
SPhysiNode* pPhyNode; // create new child
|
||||||
|
@ -772,6 +773,22 @@ typedef struct SStreamSessionAggOperatorInfo {
|
||||||
SHashObj* pGroupIdTbNameMap;
|
SHashObj* pGroupIdTbNameMap;
|
||||||
} SStreamSessionAggOperatorInfo;
|
} SStreamSessionAggOperatorInfo;
|
||||||
|
|
||||||
|
typedef struct SStreamStateAggOperatorInfo {
|
||||||
|
SOptrBasicInfo binfo;
|
||||||
|
SStreamAggSupporter streamAggSup;
|
||||||
|
SExprSupp scalarSupp; // supporter for perform scalar function
|
||||||
|
SGroupResInfo groupResInfo;
|
||||||
|
int32_t primaryTsIndex; // primary timestamp slot id
|
||||||
|
STimeWindowAggSupp twAggSup;
|
||||||
|
SColumn stateCol;
|
||||||
|
SSDataBlock* pDelRes;
|
||||||
|
SSHashObj* pSeDeleted;
|
||||||
|
void* pDelIterator;
|
||||||
|
SArray* pChildren; // cache for children's result;
|
||||||
|
bool ignoreExpiredData;
|
||||||
|
SHashObj* pGroupIdTbNameMap;
|
||||||
|
} SStreamStateAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStreamPartitionOperatorInfo {
|
typedef struct SStreamPartitionOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
SPartitionBySupporter partitionSup;
|
SPartitionBySupporter partitionSup;
|
||||||
|
@ -834,24 +851,6 @@ typedef struct SStateWindowOperatorInfo {
|
||||||
const SNode* pCondition;
|
const SNode* pCondition;
|
||||||
} SStateWindowOperatorInfo;
|
} SStateWindowOperatorInfo;
|
||||||
|
|
||||||
typedef struct SStreamStateAggOperatorInfo {
|
|
||||||
SOptrBasicInfo binfo;
|
|
||||||
SStreamAggSupporter streamAggSup;
|
|
||||||
SExprSupp scalarSupp; // supporter for perform scalar function
|
|
||||||
SGroupResInfo groupResInfo;
|
|
||||||
int32_t primaryTsIndex; // primary timestamp slot id
|
|
||||||
int32_t order; // current SSDataBlock scan order
|
|
||||||
STimeWindowAggSupp twAggSup;
|
|
||||||
SColumn stateCol;
|
|
||||||
SqlFunctionCtx* pDummyCtx; // for combine
|
|
||||||
SSDataBlock* pDelRes;
|
|
||||||
SHashObj* pSeDeleted;
|
|
||||||
void* pDelIterator;
|
|
||||||
SArray* pChildren; // cache for children's result;
|
|
||||||
bool ignoreExpiredData;
|
|
||||||
SHashObj* pGroupIdTbNameMap;
|
|
||||||
} SStreamStateAggOperatorInfo;
|
|
||||||
|
|
||||||
typedef struct SSortOperatorInfo {
|
typedef struct SSortOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
uint32_t sortBufSize; // max buffer size for in-memory sort
|
uint32_t sortBufSize; // max buffer size for in-memory sort
|
||||||
|
@ -1064,13 +1063,8 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
|
||||||
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
|
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
|
||||||
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
|
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
|
||||||
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput,
|
|
||||||
int32_t size);
|
|
||||||
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize);
|
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize);
|
||||||
SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId,
|
void getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, SSessionKey* pKey);
|
||||||
int64_t gap, int32_t* pIndex);
|
|
||||||
SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId,
|
|
||||||
int64_t gap, int32_t* pIndex);
|
|
||||||
bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap);
|
bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap);
|
||||||
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
||||||
bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup);
|
bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup);
|
||||||
|
@ -1100,6 +1094,9 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
|
||||||
void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock, SExprSupp* pSup,
|
int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock, SExprSupp* pSup,
|
||||||
SGroupResInfo* pGroupResInfo);
|
SGroupResInfo* pGroupResInfo);
|
||||||
|
int32_t saveSessionDiscBuf(SStreamState* pState, SSessionKey* key, void* buf, int32_t size);
|
||||||
|
int32_t buildSessionResultDataBlock(SExecTaskInfo* pTaskInfo, SStreamState* pState, SSDataBlock* pBlock,
|
||||||
|
SExprSupp* pSup, SGroupResInfo* pGroupResInfo);
|
||||||
int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx,
|
int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx,
|
||||||
int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup);
|
int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup);
|
||||||
int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult);
|
int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult);
|
||||||
|
|
|
@ -143,9 +143,15 @@ static int32_t getStatus(SDataDispatchHandle* pDispatcher) {
|
||||||
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
|
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
|
||||||
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
|
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
|
||||||
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM);
|
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM);
|
||||||
if (NULL == pBuf || !allocBuf(pDispatcher, pInput, pBuf)) {
|
if (NULL == pBuf) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!allocBuf(pDispatcher, pInput, pBuf)) {
|
||||||
|
taosFreeQitem(pBuf);
|
||||||
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
toDataCacheEntry(pDispatcher, pInput, pBuf);
|
toDataCacheEntry(pDispatcher, pInput, pBuf);
|
||||||
taosWriteQitem(pDispatcher->pDataBlocks, pBuf);
|
taosWriteQitem(pDispatcher->pDataBlocks, pBuf);
|
||||||
*pContinue = (DS_BUF_LOW == updateStatus(pDispatcher) ? true : false);
|
*pContinue = (DS_BUF_LOW == updateStatus(pDispatcher) ? true : false);
|
||||||
|
|
|
@ -323,7 +323,7 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
|
||||||
int32_t code =
|
int32_t code =
|
||||||
tsdbGetTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, &inserter->pSchema, &suid);
|
tsdbGetTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, &inserter->pSchema, &suid);
|
||||||
if (code) {
|
if (code) {
|
||||||
destroyDataSinker((SDataSinkHandle*)pInserterNode);
|
destroyDataSinker((SDataSinkHandle*)inserter);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4192,42 +4192,6 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInf
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput,
|
|
||||||
int32_t size) {
|
|
||||||
pSup->currentPageId = -1;
|
|
||||||
pSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
|
||||||
pSup->keySize = sizeof(int64_t) + sizeof(TSKEY);
|
|
||||||
pSup->pKeyBuf = taosMemoryCalloc(1, pSup->keySize);
|
|
||||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
|
||||||
pSup->pResultRows = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
|
|
||||||
if (pSup->pKeyBuf == NULL || pSup->pResultRows == NULL) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
pSup->valueSize = size;
|
|
||||||
|
|
||||||
pSup->pScanBlock = createSpecialDataBlock(STREAM_CLEAR);
|
|
||||||
int32_t pageSize = 4096;
|
|
||||||
while (pageSize < pSup->resultRowSize * 4) {
|
|
||||||
pageSize <<= 1u;
|
|
||||||
}
|
|
||||||
// at least four pages need to be in buffer
|
|
||||||
int32_t bufSize = 4096 * 256;
|
|
||||||
if (bufSize <= pageSize) {
|
|
||||||
bufSize = pageSize * 4;
|
|
||||||
}
|
|
||||||
if (!osTempSpaceAvailable()) {
|
|
||||||
terrno = TSDB_CODE_NO_AVAIL_DISK;
|
|
||||||
qError("Init stream agg supporter failed since %s", terrstr(terrno));
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
int32_t code = createDiskbasedBuf(&pSup->pResultBuf, pageSize, bufSize, pKey, tsTempDir);
|
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
|
||||||
pCtx[i].saveHandle.pBuf = pSup->pResultBuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResult, int64_t tableGroupId,
|
int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResult, int64_t tableGroupId,
|
||||||
SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup) {
|
SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup) {
|
||||||
SWinKey key = {
|
SWinKey key = {
|
||||||
|
@ -4237,7 +4201,6 @@ int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResul
|
||||||
char* value = NULL;
|
char* value = NULL;
|
||||||
int32_t size = pAggSup->resultRowSize;
|
int32_t size = pAggSup->resultRowSize;
|
||||||
|
|
||||||
tSimpleHashPut(pAggSup->pResultRowHashTable, &key, sizeof(SWinKey), NULL, 0);
|
|
||||||
if (streamStateAddIfNotExist(pState, &key, (void**)&value, &size) < 0) {
|
if (streamStateAddIfNotExist(pState, &key, (void**)&value, &size) < 0) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -4342,3 +4305,82 @@ int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pStat
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t saveSessionDiscBuf(SStreamState* pState, SSessionKey* key, void* buf, int32_t size) {
|
||||||
|
streamStateSessionPut(pState, key, (const void*)buf, size);
|
||||||
|
releaseOutputBuf(pState, NULL, (SResultRow*)buf);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t buildSessionResultDataBlock(SExecTaskInfo* pTaskInfo, SStreamState* pState, SSDataBlock* pBlock,
|
||||||
|
SExprSupp* pSup, SGroupResInfo* pGroupResInfo) {
|
||||||
|
SExprInfo* pExprInfo = pSup->pExprInfo;
|
||||||
|
int32_t numOfExprs = pSup->numOfExprs;
|
||||||
|
int32_t* rowEntryOffset = pSup->rowEntryInfoOffset;
|
||||||
|
SqlFunctionCtx* pCtx = pSup->pCtx;
|
||||||
|
|
||||||
|
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
||||||
|
|
||||||
|
for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
|
||||||
|
SSessionKey* pKey = taosArrayGet(pGroupResInfo->pRows, i);
|
||||||
|
int32_t size = 0;
|
||||||
|
void* pVal = NULL;
|
||||||
|
int32_t code = streamStateSessionGet(pState, pKey, &pVal, &size);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
SResultRow* pRow = (SResultRow*)pVal;
|
||||||
|
doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
|
||||||
|
// no results, continue to check the next one
|
||||||
|
if (pRow->numOfRows == 0) {
|
||||||
|
pGroupResInfo->index += 1;
|
||||||
|
releaseOutputBuf(pState, NULL, pRow);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBlock->info.groupId == 0) {
|
||||||
|
pBlock->info.groupId = pKey->groupId;
|
||||||
|
} else {
|
||||||
|
// current value belongs to different group, it can't be packed into one datablock
|
||||||
|
if (pBlock->info.groupId != pKey->groupId) {
|
||||||
|
releaseOutputBuf(pState, NULL, pRow);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
|
||||||
|
ASSERT(pBlock->info.rows > 0);
|
||||||
|
releaseOutputBuf(pState, NULL, pRow);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pGroupResInfo->index += 1;
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||||
|
int32_t slotId = pExprInfo[j].base.resSchema.slotId;
|
||||||
|
|
||||||
|
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
||||||
|
if (pCtx[j].fpSet.finalize) {
|
||||||
|
int32_t code1 = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
|
||||||
|
if (TAOS_FAILED(code1)) {
|
||||||
|
qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code1));
|
||||||
|
T_LONG_JMP(pTaskInfo->env, code1);
|
||||||
|
}
|
||||||
|
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
|
||||||
|
// do nothing, todo refactor
|
||||||
|
} else {
|
||||||
|
// expand the result into multiple rows. E.g., _wstart, top(k, 20)
|
||||||
|
// the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
|
||||||
|
for (int32_t k = 0; k < pRow->numOfRows; ++k) {
|
||||||
|
colDataAppend(pColInfoData, pBlock->info.rows + k, in, pCtx[j].resultInfo->isNullRes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pBlock->info.rows += pRow->numOfRows;
|
||||||
|
// saveSessionDiscBuf(pState, pKey, pVal, size);
|
||||||
|
releaseOutputBuf(pState, NULL, pRow);
|
||||||
|
}
|
||||||
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
|
@ -1190,23 +1190,22 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
|
||||||
SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
int32_t dummy = 0;
|
|
||||||
int64_t version = pSrcBlock->info.version - 1;
|
int64_t version = pSrcBlock->info.version - 1;
|
||||||
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
|
||||||
uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], version);
|
uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], version);
|
||||||
// gap must be 0.
|
// gap must be 0.
|
||||||
SResultWindowInfo* pStartWin =
|
SSessionKey startWin = {0};
|
||||||
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], endData[i], groupId, 0, &dummy);
|
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], endData[i], groupId, &startWin);
|
||||||
if (!pStartWin) {
|
if (IS_INVALID_SESSION_WIN_KEY(startWin)) {
|
||||||
// window has been closed.
|
// window has been closed.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SResultWindowInfo* pEndWin =
|
SSessionKey endWin = {0};
|
||||||
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, endData[i], endData[i], groupId, 0, &dummy);
|
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, endData[i], endData[i], groupId, &endWin);
|
||||||
ASSERT(pEndWin);
|
ASSERT(!IS_INVALID_SESSION_WIN_KEY(endWin));
|
||||||
TSKEY ts = INT64_MIN;
|
colDataAppend(pDestStartCol, i, (const char*)&startWin.win.skey, false);
|
||||||
colDataAppend(pDestStartCol, i, (const char*)&pStartWin->win.skey, false);
|
colDataAppend(pDestEndCol, i, (const char*)&endWin.win.ekey, false);
|
||||||
colDataAppend(pDestEndCol, i, (const char*)&pEndWin->win.ekey, false);
|
|
||||||
colDataAppendNULL(pDestUidCol, i);
|
colDataAppendNULL(pDestUidCol, i);
|
||||||
colDataAppend(pDestGpCol, i, (const char*)&groupId, false);
|
colDataAppend(pDestGpCol, i, (const char*)&groupId, false);
|
||||||
colDataAppendNULL(pDestCalStartTsCol, i);
|
colDataAppendNULL(pDestCalStartTsCol, i);
|
||||||
|
|
|
@ -693,7 +693,7 @@ void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) {
|
||||||
pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols);
|
pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols);
|
||||||
tSimpleHashCleanup(pFillSup->pResMap);
|
tSimpleHashCleanup(pFillSup->pResMap);
|
||||||
pFillSup->pResMap = NULL;
|
pFillSup->pResMap = NULL;
|
||||||
streamStateReleaseBuf(NULL, NULL, pFillSup->cur.pRowVal);
|
releaseOutputBuf(NULL, NULL, (SResultRow*)pFillSup->cur.pRowVal);
|
||||||
pFillSup->cur.pRowVal = NULL;
|
pFillSup->cur.pRowVal = NULL;
|
||||||
|
|
||||||
taosMemoryFree(pFillSup);
|
taosMemoryFree(pFillSup);
|
||||||
|
@ -736,7 +736,7 @@ static void resetFillWindow(SResultRowData* pRowData) {
|
||||||
|
|
||||||
void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, SStreamState* pState) {
|
void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, SStreamState* pState) {
|
||||||
resetFillWindow(&pFillSup->prev);
|
resetFillWindow(&pFillSup->prev);
|
||||||
streamStateReleaseBuf(NULL, NULL, pFillSup->cur.pRowVal);
|
releaseOutputBuf(NULL, NULL, (SResultRow*)pFillSup->cur.pRowVal);
|
||||||
resetFillWindow(&pFillSup->cur);
|
resetFillWindow(&pFillSup->cur);
|
||||||
resetFillWindow(&pFillSup->next);
|
resetFillWindow(&pFillSup->next);
|
||||||
resetFillWindow(&pFillSup->nextNext);
|
resetFillWindow(&pFillSup->nextNext);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2527,6 +2527,8 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
if (pInfo->algo == APERCT_ALGO_TDIGEST) {
|
if (pInfo->algo == APERCT_ALGO_TDIGEST) {
|
||||||
|
buildTDigestInfo(pInfo);
|
||||||
|
tdigestAutoFill(pInfo->pTDigest, COMPRESSION);
|
||||||
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
||||||
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -2540,12 +2542,11 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
tdigestAdd(pInfo->pTDigest, v, w);
|
tdigestAdd(pInfo->pTDigest, v, w);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
|
|
||||||
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
|
||||||
|
|
||||||
// might be a race condition here that pHisto can be overwritten or setup function
|
// might be a race condition here that pHisto can be overwritten or setup function
|
||||||
// has not been called, need to relink the buffer pHisto points to.
|
// has not been called, need to relink the buffer pHisto points to.
|
||||||
buildHistogramInfo(pInfo);
|
buildHistogramInfo(pInfo);
|
||||||
|
qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
|
||||||
|
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||||
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
||||||
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -2579,8 +2580,9 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo*
|
||||||
|
|
||||||
buildTDigestInfo(pOutput);
|
buildTDigestInfo(pOutput);
|
||||||
TDigest* pTDigest = pOutput->pTDigest;
|
TDigest* pTDigest = pOutput->pTDigest;
|
||||||
|
tdigestAutoFill(pTDigest, COMPRESSION);
|
||||||
|
|
||||||
if (pTDigest->num_centroids <= 0) {
|
if (pTDigest->num_centroids <= 0 && pTDigest->num_buffered_pts == 0) {
|
||||||
memcpy(pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION));
|
memcpy(pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION));
|
||||||
tdigestAutoFill(pTDigest, COMPRESSION);
|
tdigestAutoFill(pTDigest, COMPRESSION);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2652,6 +2654,7 @@ int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
if (pInfo->algo == APERCT_ALGO_TDIGEST) {
|
if (pInfo->algo == APERCT_ALGO_TDIGEST) {
|
||||||
buildTDigestInfo(pInfo);
|
buildTDigestInfo(pInfo);
|
||||||
|
tdigestAutoFill(pInfo->pTDigest, COMPRESSION);
|
||||||
if (pInfo->pTDigest->size > 0) {
|
if (pInfo->pTDigest->size > 0) {
|
||||||
pInfo->result = tdigestQuantile(pInfo->pTDigest, pInfo->percent / 100);
|
pInfo->result = tdigestQuantile(pInfo->pTDigest, pInfo->percent / 100);
|
||||||
} else { // no need to free
|
} else { // no need to free
|
||||||
|
@ -5356,16 +5359,14 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t maxCount = 0;
|
int32_t maxCount = 0;
|
||||||
for (int32_t i = 0; i < pInfo->numOfPoints; ++i) {
|
for (int32_t i = 0; i < pInfo->numOfPoints; ++i) {
|
||||||
SModeItem* pItem = (SModeItem*)(pInfo->pItems + i * (sizeof(SModeItem) + pInfo->colBytes));
|
SModeItem* pItem = (SModeItem*)(pInfo->pItems + i * (sizeof(SModeItem) + pInfo->colBytes));
|
||||||
if (pItem->count > maxCount) {
|
if (pItem->count >= maxCount) {
|
||||||
maxCount = pItem->count;
|
maxCount = pItem->count;
|
||||||
resIndex = i;
|
resIndex = i;
|
||||||
} else if (pItem->count == maxCount) {
|
|
||||||
resIndex = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes));
|
SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes));
|
||||||
colDataAppend(pCol, currentRow, pResItem->data, (resIndex == -1) ? true : false);
|
colDataAppend(pCol, currentRow, pResItem->data, (maxCount == 0) ? true : false);
|
||||||
|
|
||||||
return pResInfo->numOfRes;
|
return pResInfo->numOfRes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1520,11 +1520,15 @@ static bool partTagsHasIndefRowsSelectFunc(SNodeList* pFuncs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t partTagsRewriteGroupTagsToFuncs(SNodeList* pGroupTags, SNodeList* pAggFuncs) {
|
static int32_t partTagsRewriteGroupTagsToFuncs(SNodeList* pGroupTags, int32_t start, SNodeList* pAggFuncs) {
|
||||||
bool hasIndefRowsSelectFunc = partTagsHasIndefRowsSelectFunc(pAggFuncs);
|
bool hasIndefRowsSelectFunc = partTagsHasIndefRowsSelectFunc(pAggFuncs);
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t index = 0;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pGroupTags) {
|
FOREACH(pNode, pGroupTags) {
|
||||||
|
if (index++ < start) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (hasIndefRowsSelectFunc) {
|
if (hasIndefRowsSelectFunc) {
|
||||||
code = nodesListStrictAppend(pAggFuncs, partTagsCreateWrapperFunc("_select_value", pNode));
|
code = nodesListStrictAppend(pAggFuncs, partTagsCreateWrapperFunc("_select_value", pNode));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1559,20 +1563,35 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SAggLogicNode* pAgg = (SAggLogicNode*)pNode;
|
SAggLogicNode* pAgg = (SAggLogicNode*)pNode;
|
||||||
|
int32_t start = -1;
|
||||||
SNode* pGroupKey = NULL;
|
SNode* pGroupKey = NULL;
|
||||||
FOREACH(pGroupKey, pAgg->pGroupKeys) {
|
FOREACH(pGroupKey, pAgg->pGroupKeys) {
|
||||||
code = nodesListMakeStrictAppend(
|
SNode* pGroupExpr = nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0);
|
||||||
&pScan->pGroupTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0)));
|
if (NULL != pScan->pGroupTags) {
|
||||||
|
SNode* pGroupTag = NULL;
|
||||||
|
FOREACH(pGroupTag, pScan->pGroupTags) {
|
||||||
|
if (nodesEqualNode(pGroupTag, pGroupExpr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (start < 0) {
|
||||||
|
start = LIST_LENGTH(pScan->pGroupTags);
|
||||||
|
}
|
||||||
|
code = nodesListMakeStrictAppend(&pScan->pGroupTags, nodesCloneNode(pGroupExpr));
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NODES_DESTORY_LIST(pAgg->pGroupKeys);
|
NODES_DESTORY_LIST(pAgg->pGroupKeys);
|
||||||
code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, pAgg->pAggFuncs);
|
if (TSDB_CODE_SUCCESS == code && start >= 0) {
|
||||||
|
code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, start, pAgg->pAggFuncs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = partTagsOptRebuildTbanme(pScan->pGroupTags);
|
code = partTagsOptRebuildTbanme(pScan->pGroupTags);
|
||||||
}
|
}
|
||||||
|
pCxt->optimized = true;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,8 @@ TEST_F(PlanPartitionByTest, withGroupBy) {
|
||||||
run("SELECT COUNT(*) FROM t1 PARTITION BY c1 GROUP BY c2");
|
run("SELECT COUNT(*) FROM t1 PARTITION BY c1 GROUP BY c2");
|
||||||
|
|
||||||
run("SELECT TBNAME, c1 FROM st1 PARTITION BY TBNAME GROUP BY c1");
|
run("SELECT TBNAME, c1 FROM st1 PARTITION BY TBNAME GROUP BY c1");
|
||||||
|
|
||||||
|
run("SELECT COUNT(*) FROM t1 PARTITION BY TBNAME GROUP BY TBNAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanPartitionByTest, withTimeLineFunc) {
|
TEST_F(PlanPartitionByTest, withTimeLineFunc) {
|
||||||
|
|
|
@ -357,8 +357,7 @@ char* parseTagDatatoJson(void* p) {
|
||||||
for (int j = 0; j < nCols; ++j) {
|
for (int j = 0; j < nCols; ++j) {
|
||||||
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
|
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
|
||||||
// json key encode by binary
|
// json key encode by binary
|
||||||
memset(tagJsonKey, 0, sizeof(tagJsonKey));
|
tstrncpy(tagJsonKey, pTagVal->pKey, sizeof(tagJsonKey));
|
||||||
memcpy(tagJsonKey, pTagVal->pKey, strlen(pTagVal->pKey));
|
|
||||||
// json value
|
// json value
|
||||||
char type = pTagVal->type;
|
char type = pTagVal->type;
|
||||||
if (type == TSDB_DATA_TYPE_NULL) {
|
if (type == TSDB_DATA_TYPE_NULL) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
SDbCfgReq dbCfgReq = {0};
|
SDbCfgReq dbCfgReq = {0};
|
||||||
strcpy(dbCfgReq.db, input);
|
strncpy(dbCfgReq.db, input, sizeof(dbCfgReq.db) - 1);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
|
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -191,7 +191,7 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
SUserIndexReq indexReq = {0};
|
SUserIndexReq indexReq = {0};
|
||||||
strcpy(indexReq.indexFName, input);
|
strncpy(indexReq.indexFName, input, sizeof(indexReq.indexFName) - 1);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
|
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -233,7 +233,7 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
SGetUserAuthReq req = {0};
|
SGetUserAuthReq req = {0};
|
||||||
strncpy(req.user, input, sizeof(req.user));
|
strncpy(req.user, input, sizeof(req.user) - 1);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
|
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -251,7 +251,7 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
STableIndexReq indexReq = {0};
|
STableIndexReq indexReq = {0};
|
||||||
strcpy(indexReq.tbFName, input);
|
strncpy(indexReq.tbFName, input, sizeof(indexReq.tbFName) - 1);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
|
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -271,8 +271,8 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
SBuildTableInput *pInput = input;
|
SBuildTableInput *pInput = input;
|
||||||
STableCfgReq cfgReq = {0};
|
STableCfgReq cfgReq = {0};
|
||||||
cfgReq.header.vgId = pInput->vgId;
|
cfgReq.header.vgId = pInput->vgId;
|
||||||
strncpy(cfgReq.dbFName, pInput->dbFName, sizeof(cfgReq.dbFName));
|
strncpy(cfgReq.dbFName, pInput->dbFName, sizeof(cfgReq.dbFName) - 1);
|
||||||
strncpy(cfgReq.tbName, pInput->tbName, sizeof(cfgReq.tbName));
|
strncpy(cfgReq.tbName, pInput->tbName, sizeof(cfgReq.tbName) - 1);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
|
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
|
|
@ -412,7 +412,7 @@ void qwSetHbParam(int64_t refId, SQWHbParam **pParam) {
|
||||||
while (true) {
|
while (true) {
|
||||||
paramIdx = atomic_load_32(&gQwMgmt.paramIdx);
|
paramIdx = atomic_load_32(&gQwMgmt.paramIdx);
|
||||||
if (paramIdx == tListLen(gQwMgmt.param)) {
|
if (paramIdx == tListLen(gQwMgmt.param)) {
|
||||||
newParamIdx = 0;
|
newParamIdx = 1;
|
||||||
} else {
|
} else {
|
||||||
newParamIdx = paramIdx + 1;
|
newParamIdx = paramIdx + 1;
|
||||||
}
|
}
|
||||||
|
@ -422,6 +422,10 @@ void qwSetHbParam(int64_t refId, SQWHbParam **pParam) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paramIdx == tListLen(gQwMgmt.param)) {
|
||||||
|
paramIdx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
gQwMgmt.param[paramIdx].qwrId = gQwMgmt.qwRef;
|
gQwMgmt.param[paramIdx].qwrId = gQwMgmt.qwRef;
|
||||||
gQwMgmt.param[paramIdx].refId = refId;
|
gQwMgmt.param[paramIdx].refId = refId;
|
||||||
|
|
||||||
|
|
|
@ -398,7 +398,6 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
||||||
if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) {
|
if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) {
|
||||||
QW_TASK_ELOG("task already dropped at wrong phase %s", qwPhaseStr(phase));
|
QW_TASK_ELOG("task already dropped at wrong phase %s", qwPhaseStr(phase));
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_TASK_STATUS_ERROR);
|
QW_ERR_JRET(TSDB_CODE_QRY_TASK_STATUS_ERROR);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
||||||
|
|
|
@ -629,6 +629,8 @@ _return:
|
||||||
|
|
||||||
sclFreeParam(pWhen);
|
sclFreeParam(pWhen);
|
||||||
sclFreeParam(pThen);
|
sclFreeParam(pThen);
|
||||||
|
taosMemoryFree(pWhen);
|
||||||
|
taosMemoryFree(pThen);
|
||||||
|
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
@ -664,6 +666,8 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
|
||||||
|
|
||||||
sclFreeParam(pWhen);
|
sclFreeParam(pWhen);
|
||||||
sclFreeParam(pThen);
|
sclFreeParam(pThen);
|
||||||
|
taosMemoryFreeClear(pWhen);
|
||||||
|
taosMemoryFreeClear(pThen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pElse) {
|
if (pElse) {
|
||||||
|
@ -688,6 +692,8 @@ _return:
|
||||||
|
|
||||||
sclFreeParam(pWhen);
|
sclFreeParam(pWhen);
|
||||||
sclFreeParam(pThen);
|
sclFreeParam(pThen);
|
||||||
|
taosMemoryFree(pWhen);
|
||||||
|
taosMemoryFree(pThen);
|
||||||
|
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
@ -929,6 +935,10 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
|
||||||
sclFreeParam(&comp);
|
sclFreeParam(&comp);
|
||||||
sclFreeParam(pWhen);
|
sclFreeParam(pWhen);
|
||||||
sclFreeParam(pThen);
|
sclFreeParam(pThen);
|
||||||
|
taosMemoryFree(pCase);
|
||||||
|
taosMemoryFree(pElse);
|
||||||
|
taosMemoryFree(pWhen);
|
||||||
|
taosMemoryFree(pThen);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -940,6 +950,10 @@ _return:
|
||||||
sclFreeParam(pWhen);
|
sclFreeParam(pWhen);
|
||||||
sclFreeParam(pThen);
|
sclFreeParam(pThen);
|
||||||
sclFreeParam(output);
|
sclFreeParam(output);
|
||||||
|
taosMemoryFree(pCase);
|
||||||
|
taosMemoryFree(pElse);
|
||||||
|
taosMemoryFree(pWhen);
|
||||||
|
taosMemoryFree(pThen);
|
||||||
|
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,7 +654,7 @@ int32_t vectorConvertSingleColImpl(const SScalarParam* pIn, SScalarParam* pOut,
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rstart = startIndex >= 0 ? startIndex : 0;
|
int32_t rstart = (startIndex >= 0 && startIndex < pIn->numOfRows) ? startIndex : 0;
|
||||||
int32_t rend = numOfRows > 0 ? rstart + numOfRows - 1 : rstart + pIn->numOfRows - 1;
|
int32_t rend = numOfRows > 0 ? rstart + numOfRows - 1 : rstart + pIn->numOfRows - 1;
|
||||||
SSclVectorConvCtx cCtx = {pIn, pOut, rstart, rend, pInputCol->info.type, pOutputCol->info.type};
|
SSclVectorConvCtx cCtx = {pIn, pOut, rstart, rend, pInputCol->info.type, pOutputCol->info.type};
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,8 @@ int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
||||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||||
if (NULL == pData->pEpSet) {
|
if (NULL == pData->pEpSet) {
|
||||||
SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode));
|
SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode));
|
||||||
SCH_ERR_JRET(rspCode);
|
code = rspCode;
|
||||||
|
goto _return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,40 @@ typedef struct SStateKey {
|
||||||
int64_t opNum;
|
int64_t opNum;
|
||||||
} SStateKey;
|
} SStateKey;
|
||||||
|
|
||||||
|
typedef struct SStateSessionKey {
|
||||||
|
SSessionKey key;
|
||||||
|
int64_t opNum;
|
||||||
|
} SStateSessionKey;
|
||||||
|
|
||||||
|
static inline int sessionKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pWin2) {
|
||||||
|
if (pWin1->groupId > pWin2->groupId) {
|
||||||
|
return 1;
|
||||||
|
} else if (pWin1->groupId < pWin2->groupId) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pWin1->win.skey > pWin2->win.ekey) {
|
||||||
|
return 1;
|
||||||
|
} else if (pWin1->win.ekey < pWin2->win.skey) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int stateSessionKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||||
|
SStateSessionKey* pWin1 = (SStateSessionKey*)pKey1;
|
||||||
|
SStateSessionKey* pWin2 = (SStateSessionKey*)pKey2;
|
||||||
|
|
||||||
|
if (pWin1->opNum > pWin2->opNum) {
|
||||||
|
return 1;
|
||||||
|
} else if (pWin1->opNum < pWin2->opNum) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sessionKeyCmpr(&pWin1->key, &pWin2->key);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||||
SStateKey* pWin1 = (SStateKey*)pKey1;
|
SStateKey* pWin1 = (SStateKey*)pKey1;
|
||||||
SStateKey* pWin2 = (SStateKey*)pKey2;
|
SStateKey* pWin2 = (SStateKey*)pKey2;
|
||||||
|
@ -79,6 +113,11 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tdbTbOpen("session.state.db", sizeof(SStateSessionKey), -1, stateSessionKeyCmpr, pState->db,
|
||||||
|
&pState->pSessionStateDb) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
if (tdbTbOpen("func.state.db", sizeof(STupleKey), -1, STupleKeyCmpr, pState->db, &pState->pFuncStateDb) < 0) {
|
if (tdbTbOpen("func.state.db", sizeof(STupleKey), -1, STupleKeyCmpr, pState->db, &pState->pFuncStateDb) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +134,7 @@ _err:
|
||||||
tdbTbClose(pState->pStateDb);
|
tdbTbClose(pState->pStateDb);
|
||||||
tdbTbClose(pState->pFuncStateDb);
|
tdbTbClose(pState->pFuncStateDb);
|
||||||
tdbTbClose(pState->pFillStateDb);
|
tdbTbClose(pState->pFillStateDb);
|
||||||
|
tdbTbClose(pState->pSessionStateDb);
|
||||||
tdbClose(pState->db);
|
tdbClose(pState->db);
|
||||||
taosMemoryFree(pState);
|
taosMemoryFree(pState);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -105,6 +145,7 @@ void streamStateClose(SStreamState* pState) {
|
||||||
tdbTbClose(pState->pStateDb);
|
tdbTbClose(pState->pStateDb);
|
||||||
tdbTbClose(pState->pFuncStateDb);
|
tdbTbClose(pState->pFuncStateDb);
|
||||||
tdbTbClose(pState->pFillStateDb);
|
tdbTbClose(pState->pFillStateDb);
|
||||||
|
tdbTbClose(pState->pSessionStateDb);
|
||||||
tdbClose(pState->db);
|
tdbClose(pState->db);
|
||||||
|
|
||||||
taosMemoryFree(pState);
|
taosMemoryFree(pState);
|
||||||
|
@ -241,11 +282,11 @@ SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) {
|
||||||
if (pCur == NULL) return NULL;
|
if (pCur == NULL) return NULL;
|
||||||
tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL);
|
tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL);
|
||||||
|
|
||||||
int32_t c;
|
int32_t c = 0;
|
||||||
SStateKey sKey = {.key = *key, .opNum = pState->number};
|
SStateKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c);
|
tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pCur->number = pState->number;
|
pCur->number = pState->number;
|
||||||
|
@ -257,7 +298,7 @@ SStreamStateCur* streamStateFillGetCur(SStreamState* pState, const SWinKey* key)
|
||||||
if (pCur == NULL) return NULL;
|
if (pCur == NULL) return NULL;
|
||||||
tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL);
|
tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL);
|
||||||
|
|
||||||
int32_t c;
|
int32_t c = 0;
|
||||||
tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c);
|
tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
streamStateFreeCur(pCur);
|
streamStateFreeCur(pCur);
|
||||||
|
@ -348,21 +389,21 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key
|
||||||
}
|
}
|
||||||
pCur->number = pState->number;
|
pCur->number = pState->number;
|
||||||
if (tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL) < 0) {
|
if (tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL) < 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStateKey sKey = {.key = *key, .opNum = pState->number};
|
SStateKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
int32_t c;
|
int32_t c = 0;
|
||||||
if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c) < 0) {
|
if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c) < 0) {
|
||||||
tdbTbcClose(pCur->pCur);
|
tdbTbcClose(pCur->pCur);
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (c > 0) return pCur;
|
if (c > 0) return pCur;
|
||||||
|
|
||||||
if (tdbTbcMoveToNext(pCur->pCur) < 0) {
|
if (tdbTbcMoveToNext(pCur->pCur) < 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,20 +416,20 @@ SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey*
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) {
|
if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t c;
|
int32_t c = 0;
|
||||||
if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) {
|
if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) {
|
||||||
tdbTbcClose(pCur->pCur);
|
tdbTbcClose(pCur->pCur);
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (c > 0) return pCur;
|
if (c > 0) return pCur;
|
||||||
|
|
||||||
if (tdbTbcMoveToNext(pCur->pCur) < 0) {
|
if (tdbTbcMoveToNext(pCur->pCur) < 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,20 +442,20 @@ SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey*
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) {
|
if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t c;
|
int32_t c = 0;
|
||||||
if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) {
|
if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) {
|
||||||
tdbTbcClose(pCur->pCur);
|
tdbTbcClose(pCur->pCur);
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (c < 0) return pCur;
|
if (c < 0) return pCur;
|
||||||
|
|
||||||
if (tdbTbcMoveToPrev(pCur->pCur) < 0) {
|
if (tdbTbcMoveToPrev(pCur->pCur) < 0) {
|
||||||
taosMemoryFree(pCur);
|
streamStateFreeCur(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,3 +486,229 @@ void streamStateFreeCur(SStreamStateCur* pCur) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamFreeVal(void* val) { tdbFree(val); }
|
void streamFreeVal(void* val) { tdbFree(val); }
|
||||||
|
|
||||||
|
int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, const void* value, int32_t vLen) {
|
||||||
|
SStateSessionKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
|
return tdbTbUpsert(pState->pSessionStateDb, &sKey, sizeof(SStateSessionKey), value, vLen, &pState->txn);
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamStateCur* streamStateSessionGetRanomCur(SStreamState* pState, const SSessionKey* key) {
|
||||||
|
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
|
||||||
|
if (pCur == NULL) return NULL;
|
||||||
|
tdbTbcOpen(pState->pSessionStateDb, &pCur->pCur, NULL);
|
||||||
|
|
||||||
|
int32_t c = 0;
|
||||||
|
SStateSessionKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
|
tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c);
|
||||||
|
if (c != 0) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pCur->number = pState->number;
|
||||||
|
return pCur;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen) {
|
||||||
|
SStreamStateCur* pCur = streamStateSessionGetRanomCur(pState, key);
|
||||||
|
void* tmp = NULL;
|
||||||
|
if (streamStateSessionGetKVByCur(pCur, key, (const void**)&tmp, pVLen) == 0) {
|
||||||
|
*pVal = tdbRealloc(NULL, *pVLen);
|
||||||
|
memcpy(*pVal, tmp, *pVLen);
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key) {
|
||||||
|
SStateSessionKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
|
return tdbTbDelete(pState->pSessionStateDb, &sKey, sizeof(SStateSessionKey), &pState->txn);
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamStateCur* streamStateSessionSeekKeyPrev(SStreamState* pState, const SSessionKey* key) {
|
||||||
|
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
|
||||||
|
if (pCur == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pCur->number = pState->number;
|
||||||
|
if (tdbTbcOpen(pState->pSessionStateDb, &pCur->pCur, NULL) < 0) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStateSessionKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
|
int32_t c = 0;
|
||||||
|
if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c) < 0) {
|
||||||
|
tdbTbcClose(pCur->pCur);
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (c > 0) return pCur;
|
||||||
|
|
||||||
|
if (tdbTbcMoveToPrev(pCur->pCur) < 0) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pCur;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key) {
|
||||||
|
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
|
||||||
|
if (pCur == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pCur->number = pState->number;
|
||||||
|
if (tdbTbcOpen(pState->pSessionStateDb, &pCur->pCur, NULL) < 0) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStateSessionKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
|
int32_t c = 0;
|
||||||
|
if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c) < 0) {
|
||||||
|
tdbTbcClose(pCur->pCur);
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (c > 0) return pCur;
|
||||||
|
|
||||||
|
if (tdbTbcMoveToNext(pCur->pCur) < 0) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pCur;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, const void** pVal, int32_t* pVLen) {
|
||||||
|
if (!pCur) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
const SStateSessionKey* pKTmp = NULL;
|
||||||
|
int32_t kLen;
|
||||||
|
if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, pVal, pVLen) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (pKTmp->opNum != pCur->number) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (pKey->groupId != 0 && pKey->groupId != pKTmp->key.groupId) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*pKey = pKTmp->key;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamStateSessionClear(SStreamState* pState) {
|
||||||
|
SSessionKey key = {.win.skey = 0, .win.ekey = 0, .groupId = 0};
|
||||||
|
streamStateSessionPut(pState, &key, NULL, 0);
|
||||||
|
SStreamStateCur* pCur = streamStateSessionSeekKeyNext(pState, &key);
|
||||||
|
while (1) {
|
||||||
|
SSessionKey delKey = {0};
|
||||||
|
void* buf = NULL;
|
||||||
|
int32_t size = 0;
|
||||||
|
int32_t code = streamStateSessionGetKVByCur(pCur, &delKey, buf, &size);
|
||||||
|
if (code == 0) {
|
||||||
|
memset(buf, 0, size);
|
||||||
|
streamStateSessionPut(pState, &delKey, buf, size);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
streamStateCurNext(pState, pCur);
|
||||||
|
}
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
streamStateSessionDel(pState, &key);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamStateCur* streamStateSessionGetCur(SStreamState* pState, const SSessionKey* key) {
|
||||||
|
SStreamStateCur* pCur = streamStateSessionGetRanomCur(pState, key);
|
||||||
|
SSessionKey resKey = *key;
|
||||||
|
while (1) {
|
||||||
|
streamStateCurPrev(pState, pCur);
|
||||||
|
SSessionKey tmpKey = *key;
|
||||||
|
int32_t code = streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0);
|
||||||
|
if (code == TSDB_CODE_SUCCESS && sessionKeyCmpr(key, &tmpKey) == 0) {
|
||||||
|
resKey = tmpKey;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return streamStateSessionGetRanomCur(pState, &resKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen) {
|
||||||
|
// todo refactor
|
||||||
|
SStreamStateCur* pCur = streamStateSessionGetCur(pState, key);
|
||||||
|
int32_t size = *pVLen;
|
||||||
|
void* tmp = NULL;
|
||||||
|
*pVal = tdbRealloc(NULL, size);
|
||||||
|
memset(*pVal, 0, size);
|
||||||
|
if (streamStateSessionGetKVByCur(pCur, key, (const void**)&tmp, pVLen) == 0) {
|
||||||
|
memcpy(*pVal, tmp, *pVLen);
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||||
|
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen) {
|
||||||
|
// todo refactor
|
||||||
|
int32_t res = TSDB_CODE_SUCCESS;
|
||||||
|
SSessionKey tmpKey = *key;
|
||||||
|
int32_t valSize = *pVLen;
|
||||||
|
void* tmp = tdbRealloc(NULL, valSize);
|
||||||
|
if (!tmp) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamStateCur* pCur = streamStateSessionGetRanomCur(pState, key);
|
||||||
|
int32_t code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
memcpy(tmp, *pVal, valSize);
|
||||||
|
*pVal = tmp;
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
|
||||||
|
streamStateSessionPut(pState, key, NULL, 0);
|
||||||
|
pCur = streamStateSessionGetRanomCur(pState, key);
|
||||||
|
streamStateCurPrev(pState, pCur);
|
||||||
|
code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
void* stateKey = (char*)(*pVal) + (valSize - keyDataLen);
|
||||||
|
if (fn(pKeyData, stateKey) == true) {
|
||||||
|
memcpy(tmp, *pVal, valSize);
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
*key = tmpKey;
|
||||||
|
pCur = streamStateSessionSeekKeyNext(pState, key);
|
||||||
|
code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
void* stateKey = (char*)(*pVal) + (valSize - keyDataLen);
|
||||||
|
if (fn(pKeyData, stateKey) == true) {
|
||||||
|
memcpy(tmp, *pVal, valSize);
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*key = tmpKey;
|
||||||
|
res = 1;
|
||||||
|
memset(tmp, 0, valSize);
|
||||||
|
|
||||||
|
_end:
|
||||||
|
|
||||||
|
*pVal = tmp;
|
||||||
|
streamStateSessionDel(pState, &tmpKey);
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
|
@ -98,6 +98,19 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSyncNode->replicaNum == 1) {
|
||||||
|
// only myself, to leader
|
||||||
|
voteGrantedUpdate(pSyncNode->pVotesGranted, pSyncNode);
|
||||||
|
votesRespondUpdate(pSyncNode->pVotesRespond, pSyncNode);
|
||||||
|
|
||||||
|
pSyncNode->quorum = syncUtilQuorum(pSyncNode->pRaftCfg->cfg.replicaNum);
|
||||||
|
|
||||||
|
syncNodeCandidate2Leader(pSyncNode);
|
||||||
|
pSyncNode->pVotesGranted->toLeader = true;
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
switch (pSyncNode->pRaftCfg->snapshotStrategy) {
|
switch (pSyncNode->pRaftCfg->snapshotStrategy) {
|
||||||
case SYNC_STRATEGY_NO_SNAPSHOT:
|
case SYNC_STRATEGY_NO_SNAPSHOT:
|
||||||
ret = syncNodeRequestVotePeers(pSyncNode);
|
ret = syncNodeRequestVotePeers(pSyncNode);
|
||||||
|
|
|
@ -1891,8 +1891,26 @@ inline bool syncNodeInConfig(SSyncNode* pSyncNode, const SSyncCfg* config) {
|
||||||
return b1;
|
return b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool syncIsConfigChanged(const SSyncCfg* pOldCfg, const SSyncCfg* pNewCfg) {
|
||||||
|
if (pOldCfg->replicaNum != pNewCfg->replicaNum) return true;
|
||||||
|
if (pOldCfg->myIndex != pNewCfg->myIndex) return true;
|
||||||
|
for (int32_t i = 0; i < pOldCfg->replicaNum; ++i) {
|
||||||
|
const SNodeInfo* pOldInfo = &pOldCfg->nodeInfo[i];
|
||||||
|
const SNodeInfo* pNewInfo = &pNewCfg->nodeInfo[i];
|
||||||
|
if (strcmp(pOldInfo->nodeFqdn, pNewInfo->nodeFqdn) != 0) return true;
|
||||||
|
if (pOldInfo->nodePort != pNewInfo->nodePort) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) {
|
void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) {
|
||||||
SSyncCfg oldConfig = pSyncNode->pRaftCfg->cfg;
|
SSyncCfg oldConfig = pSyncNode->pRaftCfg->cfg;
|
||||||
|
if (!syncIsConfigChanged(&oldConfig, pNewConfig)) {
|
||||||
|
sInfo("vgId:1, sync not reconfig since not changed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pSyncNode->pRaftCfg->cfg = *pNewConfig;
|
pSyncNode->pRaftCfg->cfg = *pNewConfig;
|
||||||
pSyncNode->pRaftCfg->lastConfigIndex = lastConfigChangeIndex;
|
pSyncNode->pRaftCfg->lastConfigIndex = lastConfigChangeIndex;
|
||||||
|
|
||||||
|
@ -2264,7 +2282,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
|
||||||
|
|
||||||
void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
|
void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
|
||||||
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE);
|
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE);
|
||||||
ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted));
|
//ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted));
|
||||||
syncNodeBecomeLeader(pSyncNode, "candidate to leader");
|
syncNodeBecomeLeader(pSyncNode, "candidate to leader");
|
||||||
|
|
||||||
syncNodeLog2("==state change syncNodeCandidate2Leader==", pSyncNode);
|
syncNodeLog2("==state change syncNodeCandidate2Leader==", pSyncNode);
|
||||||
|
@ -3014,7 +3032,8 @@ static int32_t syncNodeProposeConfigChangeFinish(SSyncNode* ths, SyncReconfigFin
|
||||||
}
|
}
|
||||||
|
|
||||||
bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg) {
|
bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg) {
|
||||||
return (ths->replicaNum == 1 && syncUtilUserCommit(pMsg->msgType) && ths->vgId != 1);
|
return (ths->replicaNum == 1 && syncUtilUserCommit(pMsg->msgType));
|
||||||
|
// return (ths->replicaNum == 1 && syncUtilUserCommit(pMsg->msgType) && ths->vgId != 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) {
|
int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) {
|
||||||
|
@ -3066,7 +3085,8 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
|
||||||
// user commit
|
// user commit
|
||||||
if ((ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType)) {
|
if ((ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType)) {
|
||||||
bool internalExecute = true;
|
bool internalExecute = true;
|
||||||
if ((ths->replicaNum == 1) && ths->restoreFinish && ths->vgId != 1) {
|
if ((ths->replicaNum == 1) && ths->restoreFinish) {
|
||||||
|
// if ((ths->replicaNum == 1) && ths->restoreFinish && ths->vgId != 1) {
|
||||||
internalExecute = false;
|
internalExecute = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1086,6 +1086,7 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
|
||||||
// fetch next ofp, a new ofp and make it dirty
|
// fetch next ofp, a new ofp and make it dirty
|
||||||
ret = tdbFetchOvflPage(&pgno, &nextOfp, pTxn, pBt);
|
ret = tdbFetchOvflPage(&pgno, &nextOfp, pTxn, pBt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
tdbFree(pBuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ int32_t tdbBegin(TDB *pDb, TXN *pTxn) {
|
||||||
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
||||||
ret = tdbPagerBegin(pPager, pTxn);
|
ret = tdbPagerBegin(pPager, pTxn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to begin pager since %s. dbName:%s, txnId:%d", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
tdbError("failed to begin pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ int32_t tdbCommit(TDB *pDb, TXN *pTxn) {
|
||||||
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
||||||
ret = tdbPagerCommit(pPager, pTxn);
|
ret = tdbPagerCommit(pPager, pTxn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to commit pager since %s. dbName:%s, txnId:%d", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
tdbError("failed to commit pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ int32_t tdbAbort(TDB *pDb, TXN *pTxn) {
|
||||||
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
||||||
ret = tdbPagerAbort(pPager, pTxn);
|
ret = tdbPagerAbort(pPager, pTxn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to abort pager since %s. dbName:%s, txnId:%d", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
tdbError("failed to abort pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
|
||||||
// 4. Try a create new page
|
// 4. Try a create new page
|
||||||
if (!pPage) {
|
if (!pPage) {
|
||||||
ret = tdbPageCreate(pCache->szPage, &pPage, pTxn->xMalloc, pTxn->xArg);
|
ret = tdbPageCreate(pCache->szPage, &pPage, pTxn->xMalloc, pTxn->xArg);
|
||||||
if (ret < 0 && pPage != NULL) {
|
if (ret < 0 || pPage == NULL) {
|
||||||
// TODO
|
// TODO
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -541,7 +541,7 @@ static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage) {
|
||||||
|
|
||||||
ret = tdbOsWrite(pPager->jfd, pPage->pData, pPage->pageSize);
|
ret = tdbOsWrite(pPager->jfd, pPage->pData, pPage->pageSize);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to write page data due to %s. file:%s, pageSize:%ld", strerror(errno), pPager->jFileName,
|
tdbError("failed to write page data due to %s. file:%s, pageSize:%d", strerror(errno), pPager->jFileName,
|
||||||
pPage->pageSize);
|
pPage->pageSize);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -570,7 +570,7 @@ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) {
|
||||||
|
|
||||||
ret = tdbOsWrite(pPager->fd, pPage->pData, pPage->pageSize);
|
ret = tdbOsWrite(pPager->fd, pPage->pData, pPage->pageSize);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to write page data due to %s. file:%s, pageSize:%ld", strerror(errno), pPager->dbFileName,
|
tdbError("failed to write page data due to %s. file:%s, pageSize:%d", strerror(errno), pPager->dbFileName,
|
||||||
pPage->pageSize);
|
pPage->pageSize);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -123,8 +123,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
|
||||||
}
|
}
|
||||||
SWalCkHead* logContent = (SWalCkHead*)candidate;
|
SWalCkHead* logContent = (SWalCkHead*)candidate;
|
||||||
if (walValidHeadCksum(logContent) != 0) {
|
if (walValidHeadCksum(logContent) != 0) {
|
||||||
wError("vgId:%d, failed to validate checksum of wal entry header. offset:% %" PRId64 ", file:%s",
|
wWarn("vgId:%d, failed to validate checksum of wal entry header. offset:%" PRId64 ", file:%s", pWal->cfg.vgId,
|
||||||
((char*)(logContent)-buf), fnameStr);
|
offset + ((char*)(logContent)-buf), fnameStr);
|
||||||
haystack = candidate + 1;
|
haystack = candidate + 1;
|
||||||
if (firstTrial) {
|
if (firstTrial) {
|
||||||
break;
|
break;
|
||||||
|
@ -162,8 +162,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
|
||||||
}
|
}
|
||||||
if (walValidBodyCksum(logContent) != 0) {
|
if (walValidBodyCksum(logContent) != 0) {
|
||||||
terrno = TSDB_CODE_WAL_CHKSUM_MISMATCH;
|
terrno = TSDB_CODE_WAL_CHKSUM_MISMATCH;
|
||||||
wError("vgId:%d, failed to validate checksum of wal entry body. offset:% %" PRId64 ", file:%s",
|
wWarn("vgId:%d, failed to validate checksum of wal entry body. offset:%" PRId64 ", file:%s", pWal->cfg.vgId,
|
||||||
((char*)(logContent)-buf), fnameStr);
|
offset + ((char*)(logContent)-buf), fnameStr);
|
||||||
haystack = candidate + 1;
|
haystack = candidate + 1;
|
||||||
if (firstTrial) {
|
if (firstTrial) {
|
||||||
break;
|
break;
|
||||||
|
@ -481,6 +481,10 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offset != (idxEntry.ver - pFileInfo->firstVer) * sizeof(SWalIdxEntry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (walReadLogHead(pLogFile, idxEntry.offset, &ckHead) < 0) {
|
if (walReadLogHead(pLogFile, idxEntry.offset, &ckHead) < 0) {
|
||||||
wWarn("vgId:%d, failed to read log file since %s. file:%s, offset:%" PRId64 ", idx entry ver:%" PRId64 "",
|
wWarn("vgId:%d, failed to read log file since %s. file:%s, offset:%" PRId64 ", idx entry ver:%" PRId64 "",
|
||||||
pWal->cfg.vgId, terrstr(), fLogNameStr, idxEntry.offset, idxEntry.ver);
|
pWal->cfg.vgId, terrstr(), fLogNameStr, idxEntry.offset, idxEntry.ver);
|
||||||
|
@ -493,6 +497,8 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
}
|
}
|
||||||
offset += sizeof(SWalIdxEntry);
|
offset += sizeof(SWalIdxEntry);
|
||||||
|
|
||||||
|
ASSERT(offset == (idxEntry.ver - pFileInfo->firstVer + 1) * sizeof(SWalIdxEntry));
|
||||||
|
|
||||||
// ftruncate idx file
|
// ftruncate idx file
|
||||||
if (offset < fileSize) {
|
if (offset < fileSize) {
|
||||||
if (taosFtruncateFile(pIdxFile, offset) < 0) {
|
if (taosFtruncateFile(pIdxFile, offset) < 0) {
|
||||||
|
|
|
@ -410,25 +410,35 @@ END:
|
||||||
|
|
||||||
static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) {
|
static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) {
|
||||||
SWalIdxEntry entry = {.ver = ver, .offset = offset};
|
SWalIdxEntry entry = {.ver = ver, .offset = offset};
|
||||||
int64_t idxOffset = taosLSeekFile(pWal->pIdxFile, 0, SEEK_END);
|
SWalFileInfo *pFileInfo = walGetCurFileInfo(pWal);
|
||||||
|
ASSERT(pFileInfo != NULL);
|
||||||
|
ASSERT(pFileInfo->firstVer >= 0);
|
||||||
|
int64_t idxOffset = (entry.ver - pFileInfo->firstVer) * sizeof(SWalIdxEntry);
|
||||||
wDebug("vgId:%d, write index, index:%" PRId64 ", offset:%" PRId64 ", at %" PRId64, pWal->cfg.vgId, ver, offset,
|
wDebug("vgId:%d, write index, index:%" PRId64 ", offset:%" PRId64 ", at %" PRId64, pWal->cfg.vgId, ver, offset,
|
||||||
idxOffset);
|
idxOffset);
|
||||||
|
|
||||||
int64_t size = taosWriteFile(pWal->pIdxFile, &entry, sizeof(SWalIdxEntry));
|
int64_t size = taosWriteFile(pWal->pIdxFile, &entry, sizeof(SWalIdxEntry));
|
||||||
if (size != sizeof(SWalIdxEntry)) {
|
if (size != sizeof(SWalIdxEntry)) {
|
||||||
|
wError("vgId:%d, failed to write idx entry due to %s. ver:%lld", pWal->cfg.vgId, strerror(errno), ver);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
// TODO truncate
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(taosLSeekFile(pWal->pIdxFile, 0, SEEK_END) == idxOffset + sizeof(SWalIdxEntry) && "Offset of idx entries misaligned");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO gurantee atomicity by truncate failed writing
|
|
||||||
static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta,
|
static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta,
|
||||||
const void *body, int32_t bodyLen) {
|
const void *body, int32_t bodyLen) {
|
||||||
int64_t code = 0;
|
int64_t code = 0;
|
||||||
|
|
||||||
int64_t offset = walGetCurFileOffset(pWal);
|
int64_t offset = walGetCurFileOffset(pWal);
|
||||||
|
SWalFileInfo *pFileInfo = walGetCurFileInfo(pWal);
|
||||||
|
ASSERT(pFileInfo != NULL);
|
||||||
|
|
||||||
|
if (pFileInfo->firstVer == -1) {
|
||||||
|
pFileInfo->firstVer = index;
|
||||||
|
}
|
||||||
pWal->writeHead.head.version = index;
|
pWal->writeHead.head.version = index;
|
||||||
pWal->writeHead.head.bodyLen = bodyLen;
|
pWal->writeHead.head.bodyLen = bodyLen;
|
||||||
pWal->writeHead.head.msgType = msgType;
|
pWal->writeHead.head.msgType = msgType;
|
||||||
|
@ -439,11 +449,14 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
|
|
||||||
pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead);
|
pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead);
|
||||||
pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen);
|
pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen);
|
||||||
|
|
||||||
wDebug("vgId:%d, wal write log %ld, msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType));
|
wDebug("vgId:%d, wal write log %ld, msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType));
|
||||||
|
|
||||||
|
code = walWriteIndex(pWal, index, offset);
|
||||||
|
if (code < 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
if (taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
||||||
// TODO ftruncate
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
@ -452,7 +465,6 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pWal->pLogFile, (char *)body, bodyLen) != bodyLen) {
|
if (taosWriteFile(pWal->pLogFile, (char *)body, bodyLen) != bodyLen) {
|
||||||
// TODO ftruncate
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
@ -460,24 +472,31 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = walWriteIndex(pWal, index, offset);
|
|
||||||
if (code < 0) {
|
|
||||||
// TODO ftruncate
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set status
|
// set status
|
||||||
if (pWal->vers.firstVer == -1) pWal->vers.firstVer = index;
|
if (pWal->vers.firstVer == -1) pWal->vers.firstVer = index;
|
||||||
pWal->vers.lastVer = index;
|
pWal->vers.lastVer = index;
|
||||||
pWal->totSize += sizeof(SWalCkHead) + bodyLen;
|
pWal->totSize += sizeof(SWalCkHead) + bodyLen;
|
||||||
if (walGetCurFileInfo(pWal)->firstVer == -1) {
|
pFileInfo->lastVer = index;
|
||||||
walGetCurFileInfo(pWal)->firstVer = index;
|
pFileInfo->fileSize += sizeof(SWalCkHead) + bodyLen;
|
||||||
}
|
|
||||||
walGetCurFileInfo(pWal)->lastVer = index;
|
|
||||||
walGetCurFileInfo(pWal)->fileSize += sizeof(SWalCkHead) + bodyLen;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
END:
|
END:
|
||||||
|
// recover in a reverse order
|
||||||
|
if (taosFtruncateFile(pWal->pLogFile, offset) < 0) {
|
||||||
|
wFatal("vgId:%d, failed to ftruncate logfile to offset:%lld during recovery due to %s", pWal->cfg.vgId, offset,
|
||||||
|
strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
ASSERT(0 && "failed to recover from error");
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t idxOffset = (index - pFileInfo->firstVer) * sizeof(SWalIdxEntry);
|
||||||
|
if (taosFtruncateFile(pWal->pIdxFile, idxOffset) < 0) {
|
||||||
|
wFatal("vgId:%d, failed to ftruncate idxfile to offset:%lld during recovery due to %s", pWal->cfg.vgId, idxOffset,
|
||||||
|
strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
ASSERT(0 && "failed to recover from error");
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -443,10 +443,13 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) {
|
||||||
static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *buffer, int32_t len) {
|
static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *buffer, int32_t len) {
|
||||||
if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile != NULL && osLogSpaceAvailable()) {
|
if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile != NULL && osLogSpaceAvailable()) {
|
||||||
taosUpdateLogNums(level);
|
taosUpdateLogNums(level);
|
||||||
if (tsAsyncLog) {
|
if (tsAsyncLog && level != DEBUG_FATAL) {
|
||||||
taosPushLogBuffer(tsLogObj.logHandle, buffer, len);
|
taosPushLogBuffer(tsLogObj.logHandle, buffer, len);
|
||||||
} else {
|
} else {
|
||||||
taosWriteFile(tsLogObj.logHandle->pFile, buffer, len);
|
taosWriteFile(tsLogObj.logHandle->pFile, buffer, len);
|
||||||
|
if (level == DEBUG_FATAL) {
|
||||||
|
taosFsyncFile(tsLogObj.logHandle->pFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsLogObj.maxLines > 0) {
|
if (tsLogObj.maxLines > 0) {
|
||||||
|
|
|
@ -67,9 +67,13 @@ mkdir -p /var/lib/taos
|
||||||
cd $CONTAINER_TESTDIR/tests/$exec_dir
|
cd $CONTAINER_TESTDIR/tests/$exec_dir
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
|
|
||||||
|
md5sum /usr/lib/libtaos.so.1
|
||||||
|
md5sum /home/TDinternal/debug/build/lib/libtaos.so
|
||||||
$TIMEOUT_CMD $cmd
|
$TIMEOUT_CMD $cmd
|
||||||
RET=$?
|
RET=$?
|
||||||
echo "cmd exit code: $RET"
|
echo "cmd exit code: $RET"
|
||||||
|
md5sum /usr/lib/libtaos.so.1
|
||||||
|
md5sum /home/TDinternal/debug/build/lib/libtaos.so
|
||||||
|
|
||||||
if [ $RET -ne 0 ]; then
|
if [ $RET -ne 0 ]; then
|
||||||
pwd
|
pwd
|
||||||
|
|
|
@ -68,12 +68,16 @@ if [ $ent -ne 0 ]; then
|
||||||
CONTAINER_TESTDIR=/home/TDinternal/community
|
CONTAINER_TESTDIR=/home/TDinternal/community
|
||||||
SIM_DIR=/home/TDinternal/sim
|
SIM_DIR=/home/TDinternal/sim
|
||||||
REP_MOUNT_PARAM="$INTERNAL_REPDIR:/home/TDinternal"
|
REP_MOUNT_PARAM="$INTERNAL_REPDIR:/home/TDinternal"
|
||||||
|
REP_MOUNT_LIB="$INTERNAL_REPDIR/debug/build/lib:/home/TDinternal/debug/build/lib:ro"
|
||||||
|
|
||||||
else
|
else
|
||||||
# community edition
|
# community edition
|
||||||
REPDIR=$WORKDIR/TDengine
|
REPDIR=$WORKDIR/TDengine
|
||||||
CONTAINER_TESTDIR=/home/TDengine
|
CONTAINER_TESTDIR=/home/TDengine
|
||||||
SIM_DIR=/home/TDengine/sim
|
SIM_DIR=/home/TDengine/sim
|
||||||
REP_MOUNT_PARAM="$REPDIR:/home/TDengine"
|
REP_MOUNT_PARAM="$REPDIR:/home/TDengine"
|
||||||
|
REP_MOUNT_LIB="$REPDIR/debug/build/lib:/home/TDengine/debug/build/lib:ro"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
|
@ -103,6 +107,7 @@ coredump_dir=`cat /proc/sys/kernel/core_pattern | xargs dirname`
|
||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
-v $REP_MOUNT_PARAM \
|
-v $REP_MOUNT_PARAM \
|
||||||
|
-v $REP_MOUNT_LIB \
|
||||||
-v $MOUNT_DIR \
|
-v $MOUNT_DIR \
|
||||||
-v ${SOURCEDIR}:/usr/local/src/ \
|
-v ${SOURCEDIR}:/usr/local/src/ \
|
||||||
-v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
|
-v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
|
||||||
|
|
|
@ -249,12 +249,18 @@
|
||||||
./test.sh -f tsim/stream/windowClose.sim
|
./test.sh -f tsim/stream/windowClose.sim
|
||||||
./test.sh -f tsim/stream/ignoreExpiredData.sim
|
./test.sh -f tsim/stream/ignoreExpiredData.sim
|
||||||
./test.sh -f tsim/stream/sliding.sim
|
./test.sh -f tsim/stream/sliding.sim
|
||||||
#./test.sh -f tsim/stream/partitionbyColumnInterval.sim
|
./test.sh -f tsim/stream/partitionbyColumnInterval.sim
|
||||||
#./test.sh -f tsim/stream/partitionbyColumnSession.sim
|
#./test.sh -f tsim/stream/partitionbyColumnSession.sim
|
||||||
#./test.sh -f tsim/stream/partitionbyColumnState.sim
|
#./test.sh -f tsim/stream/partitionbyColumnState.sim
|
||||||
#./test.sh -f tsim/stream/deleteInterval.sim
|
#./test.sh -f tsim/stream/deleteInterval.sim
|
||||||
#./test.sh -f tsim/stream/deleteSession.sim
|
#./test.sh -f tsim/stream/deleteSession.sim
|
||||||
#./test.sh -f tsim/stream/deleteState.sim
|
#./test.sh -f tsim/stream/deleteState.sim
|
||||||
|
#./test.sh -f tsim/stream/fillIntervalDelete0.sim
|
||||||
|
#./test.sh -f tsim/stream/fillIntervalDelete1.sim
|
||||||
|
./test.sh -f tsim/stream/fillIntervalLinear.sim
|
||||||
|
#./test.sh -f tsim/stream/fillIntervalPartitionBy.sim
|
||||||
|
./test.sh -f tsim/stream/fillIntervalPrevNext.sim
|
||||||
|
./test.sh -f tsim/stream/fillIntervalValue.sim
|
||||||
|
|
||||||
# ---- transaction ----
|
# ---- transaction ----
|
||||||
./test.sh -f tsim/trans/lossdata1.sim
|
./test.sh -f tsim/trans/lossdata1.sim
|
||||||
|
|
|
@ -17,9 +17,9 @@ sql create table $table1 (ts timestamp, b binary(20))
|
||||||
sql create table $table2 (ts timestamp, b binary(20))
|
sql create table $table2 (ts timestamp, b binary(20))
|
||||||
|
|
||||||
sql insert into $table1 values(now, "table_name")
|
sql insert into $table1 values(now, "table_name")
|
||||||
sql insert into $table1 values(now-1m, "tablexname")
|
sql insert into $table1 values(now-3m, "tablexname")
|
||||||
sql insert into $table1 values(now-2m, "tablexxx")
|
sql insert into $table1 values(now-2m, "tablexxx")
|
||||||
sql insert into $table1 values(now-2m, "table")
|
sql insert into $table1 values(now-1m, "table")
|
||||||
|
|
||||||
sql select b from $table1
|
sql select b from $table1
|
||||||
if $rows != 4 then
|
if $rows != 4 then
|
||||||
|
|
|
@ -216,12 +216,12 @@ if $data02 != 3.274823935 then
|
||||||
goto loop2
|
goto loop2
|
||||||
endi
|
endi
|
||||||
|
|
||||||
if $data03 != 1.800000000 then
|
if $data03 != 1.500000000 then
|
||||||
print ======$data03
|
print ======$data03
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
if $data04 != 3.350000000 then
|
if $data04 != 3.500000000 then
|
||||||
print ======$data04
|
print ======$data04
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
|
@ -5,15 +5,15 @@ sleep 50
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database
|
print =============== create database
|
||||||
sql create database test vgroups 1
|
sql create database test vgroups 1;
|
||||||
sql select * from information_schema.ins_databases
|
sql select * from information_schema.ins_databases;
|
||||||
if $rows != 3 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print $data00 $data01 $data02
|
print $data00 $data01 $data02
|
||||||
|
|
||||||
sql use test
|
sql use test;
|
||||||
|
|
||||||
|
|
||||||
sql create table t1(ts timestamp, a int, b int , c int, d double,id int);
|
sql create table t1(ts timestamp, a int, b int , c int, d double,id int);
|
||||||
|
|
|
@ -349,7 +349,7 @@ endi
|
||||||
|
|
||||||
if $rows != 3 then
|
if $rows != 3 then
|
||||||
print ====loop4=rows=$rows
|
print ====loop4=rows=$rows
|
||||||
# goto loop4
|
goto loop4
|
||||||
endi
|
endi
|
||||||
|
|
||||||
# row 0
|
# row 0
|
||||||
|
|
|
@ -13,7 +13,7 @@ endi
|
||||||
|
|
||||||
print $data00 $data01 $data02
|
print $data00 $data01 $data02
|
||||||
|
|
||||||
sql use test
|
sql use test;
|
||||||
sql create table t2(ts timestamp, a int, b int , c int, d double);
|
sql create table t2(ts timestamp, a int, b int , c int, d double);
|
||||||
sql create stream streams2 trigger window_close into streamt2 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t2 session(ts, 10s);
|
sql create stream streams2 trigger window_close into streamt2 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t2 session(ts, 10s);
|
||||||
|
|
||||||
|
@ -58,16 +58,11 @@ endi
|
||||||
sql insert into t2 values(1648791233002,1,2,3,1.0);
|
sql insert into t2 values(1648791233002,1,2,3,1.0);
|
||||||
sleep 300
|
sleep 300
|
||||||
sql select * from streamt2;
|
sql select * from streamt2;
|
||||||
if $rows != 1 then
|
if $rows != 0 then
|
||||||
print ======$rows
|
print ======$rows
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
if $data01 != 6 then
|
|
||||||
print ======$data01
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql insert into t2 values(1648791253003,1,2,3,1.0);
|
sql insert into t2 values(1648791253003,1,2,3,1.0);
|
||||||
sleep 300
|
sleep 300
|
||||||
sql select * from streamt2;
|
sql select * from streamt2;
|
||||||
|
|
|
@ -101,11 +101,8 @@ void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) {
|
||||||
/* update the values */
|
/* update the values */
|
||||||
cmd->commandSize += size;
|
cmd->commandSize += size;
|
||||||
cmd->cursorOffset += size;
|
cmd->cursorOffset += size;
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
taosMbToWchar(&wc, c + i, size);
|
|
||||||
cmd->screenOffset += taosWcharWidth(wc);
|
cmd->screenOffset += taosWcharWidth(wc);
|
||||||
cmd->endOffset += taosWcharWidth(wc);
|
cmd->endOffset += taosWcharWidth(wc);
|
||||||
}
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#else
|
#else
|
||||||
shellShowOnScreen(cmd);
|
shellShowOnScreen(cmd);
|
||||||
|
|
|
@ -63,6 +63,7 @@ int smlProcess_influx_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +87,8 @@ int smlProcess_telnet_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,32 +102,15 @@ int smlProcess_json1_Test() {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
const char *sql[] = {
|
const char *sql[] = {
|
||||||
"["
|
"[{\"metric\":\"sys.cpu.nice\",\"timestamp\":0,\"value\":18,\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}},{\"metric\":\"sys.cpu.nice\",\"timestamp\":1662344042,\"value\":9,\"tags\":{\"host\":\"web02\",\"dc\":\"lga\"}}]"
|
||||||
" {"
|
};
|
||||||
" \"metric\": \"sys.cpu.nice\","
|
|
||||||
" \"timestamp\": 0,"
|
|
||||||
" \"value\": 18,"
|
|
||||||
" \"tags\": {"
|
|
||||||
" \"host\": \"web01\","
|
|
||||||
" \"id\": \"t1\","
|
|
||||||
" \"dc\": \"lga\""
|
|
||||||
" }"
|
|
||||||
" },"
|
|
||||||
" {"
|
|
||||||
" \"metric\": \"sys.cpu.nice\","
|
|
||||||
" \"timestamp\": 1662344042,"
|
|
||||||
" \"value\": 9,"
|
|
||||||
" \"tags\": {"
|
|
||||||
" \"host\": \"web02\","
|
|
||||||
" \"dc\": \"lga\""
|
|
||||||
" }"
|
|
||||||
" }"
|
|
||||||
"]",};
|
|
||||||
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
||||||
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,33 +124,15 @@ int smlProcess_json2_Test() {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
const char *sql[] = {
|
const char *sql[] = {
|
||||||
"{"
|
"{\"metric\":\"meter_current0\",\"timestamp\":{\"value\":1662344042,\"type\":\"s\"},\"value\":{\"value\":10.3,\"type\":\"i64\"},\"tags\":{\"groupid\":{\"value\":2,\"type\":\"bigint\"},\"location\":{\"value\":\"北京\",\"type\":\"binary\"},\"id\":\"d1001\"}}"
|
||||||
" \"metric\": \"meter_current0\","
|
};
|
||||||
" \"timestamp\": {"
|
|
||||||
" \"value\" : 1662344042,"
|
|
||||||
" \"type\" : \"s\""
|
|
||||||
" },"
|
|
||||||
" \"value\": {"
|
|
||||||
" \"value\" : 10.3,"
|
|
||||||
" \"type\" : \"i64\""
|
|
||||||
" },"
|
|
||||||
" \"tags\": {"
|
|
||||||
" \"groupid\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"bigint\""
|
|
||||||
" },"
|
|
||||||
" \"location\": { "
|
|
||||||
" \"value\" : \"北京\","
|
|
||||||
" \"type\" : \"binary\""
|
|
||||||
" },"
|
|
||||||
" \"id\": \"d1001\""
|
|
||||||
" }"
|
|
||||||
"}",};
|
|
||||||
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
||||||
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,61 +146,14 @@ int smlProcess_json3_Test() {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
const char *sql[] = {
|
const char *sql[] = {
|
||||||
"{"
|
"{\"metric\":\"meter_current1\",\"timestamp\":{\"value\":1662344042,\"type\":\"s\"},\"value\":{\"value\":10.3,\"type\":\"i64\"},\"tags\":{\"t1\":{\"value\":2,\"type\":\"bigint\"},\"t2\":{\"value\":2,\"type\":\"int\"},\"t3\":{\"value\":2,\"type\":\"i16\"},\"t4\":{\"value\":2,\"type\":\"i8\"},\"t5\":{\"value\":2,\"type\":\"f32\"},\"t6\":{\"value\":2,\"type\":\"double\"},\"t7\":{\"value\":\"8323\",\"type\":\"binary\"},\"t8\":{\"value\":\"北京\",\"type\":\"nchar\"},\"t9\":{\"value\":true,\"type\":\"bool\"},\"id\":\"d1001\"}}"};
|
||||||
" \"metric\": \"meter_current1\","
|
|
||||||
" \"timestamp\": {"
|
|
||||||
" \"value\" : 1662344042,"
|
|
||||||
" \"type\" : \"s\""
|
|
||||||
" },"
|
|
||||||
" \"value\": {"
|
|
||||||
" \"value\" : 10.3,"
|
|
||||||
" \"type\" : \"i64\""
|
|
||||||
" },"
|
|
||||||
" \"tags\": {"
|
|
||||||
" \"t1\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"bigint\""
|
|
||||||
" },"
|
|
||||||
" \"t2\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"int\""
|
|
||||||
" },"
|
|
||||||
" \"t3\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"i16\""
|
|
||||||
" },"
|
|
||||||
" \"t4\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"i8\""
|
|
||||||
" },"
|
|
||||||
" \"t5\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"f32\""
|
|
||||||
" },"
|
|
||||||
" \"t6\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"double\""
|
|
||||||
" },"
|
|
||||||
" \"t7\": { "
|
|
||||||
" \"value\" : \"8323\","
|
|
||||||
" \"type\" : \"binary\""
|
|
||||||
" },"
|
|
||||||
" \"t8\": { "
|
|
||||||
" \"value\" : \"北京\","
|
|
||||||
" \"type\" : \"nchar\""
|
|
||||||
" },"
|
|
||||||
" \"t9\": { "
|
|
||||||
" \"value\" : true,"
|
|
||||||
" \"type\" : \"bool\""
|
|
||||||
" },"
|
|
||||||
" \"id\": \"d1001\""
|
|
||||||
" }"
|
|
||||||
"}",};
|
|
||||||
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
||||||
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,52 +167,15 @@ int smlProcess_json4_Test() {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
const char *sql[] = {
|
const char *sql[] = {
|
||||||
"{"
|
"{\"metric\":\"meter_current2\",\"timestamp\":{\"value\":1662344042000,\"type\":\"ms\"},\"value\":\"ni\",\"tags\":{\"t1\":{\"value\":20,\"type\":\"i64\"},\"t2\":{\"value\":25,\"type\":\"i32\"},\"t3\":{\"value\":2,\"type\":\"smallint\"},\"t4\":{\"value\":2,\"type\":\"tinyint\"},\"t5\":{\"value\":2,\"type\":\"float\"},\"t6\":{\"value\":0.2,\"type\":\"f64\"},\"t7\":\"nsj\",\"t8\":{\"value\":\"北京\",\"type\":\"nchar\"},\"t9\":false,\"id\":\"d1001\"}}"
|
||||||
" \"metric\": \"meter_current2\","
|
};
|
||||||
" \"timestamp\": {"
|
|
||||||
" \"value\" : 1662344042000,"
|
|
||||||
" \"type\" : \"ms\""
|
|
||||||
" },"
|
|
||||||
" \"value\": \"ni\","
|
|
||||||
" \"tags\": {"
|
|
||||||
" \"t1\": { "
|
|
||||||
" \"value\" : 20,"
|
|
||||||
" \"type\" : \"i64\""
|
|
||||||
" },"
|
|
||||||
" \"t2\": { "
|
|
||||||
" \"value\" : 25,"
|
|
||||||
" \"type\" : \"i32\""
|
|
||||||
" },"
|
|
||||||
" \"t3\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"smallint\""
|
|
||||||
" },"
|
|
||||||
" \"t4\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"tinyint\""
|
|
||||||
" },"
|
|
||||||
" \"t5\": { "
|
|
||||||
" \"value\" : 2,"
|
|
||||||
" \"type\" : \"float\""
|
|
||||||
" },"
|
|
||||||
" \"t6\": { "
|
|
||||||
" \"value\" : 0.2,"
|
|
||||||
" \"type\" : \"f64\""
|
|
||||||
" },"
|
|
||||||
" \"t7\": \"nsj\","
|
|
||||||
" \"t8\": { "
|
|
||||||
" \"value\" : \"北京\","
|
|
||||||
" \"type\" : \"nchar\""
|
|
||||||
" },"
|
|
||||||
" \"t9\": false,"
|
|
||||||
" \"id\": \"d1001\""
|
|
||||||
" }"
|
|
||||||
"}",};
|
|
||||||
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL,
|
||||||
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +197,8 @@ int sml_TD15662_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +219,8 @@ int sml_TD15742_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,6 +250,8 @@ int sml_16384_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
code = taos_errno(pRes);
|
code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,6 +671,8 @@ int sml_oom_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,6 +717,8 @@ int sml_16368_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,6 +756,8 @@ int sml_dup_time_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,6 +964,8 @@ int sml_16960_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
int code = taos_errno(pRes);
|
int code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,6 +995,7 @@ int sml_add_tag_col_Test() {
|
||||||
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
code = taos_errno(pRes);
|
code = taos_errno(pRes);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1151,6 +1050,36 @@ int smlProcess_18784_Test() {
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sml_19221_Test() {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
|
||||||
|
TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
const char *sql[] = {
|
||||||
|
"qelhxo,id=pnnqhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833639000000\nqelhxo,id=pnnhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833639000000\n#comment\nqelhxo,id=pnqhsa,t0=t,t1=127i8 c11=L\"ncharColValue\",c0=t,c1=127i8 1626006833639000000",
|
||||||
|
};
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
char* tmp = (char*)taosMemoryCalloc(1024, 1);
|
||||||
|
memcpy(tmp, sql[0], strlen(sql[0]));
|
||||||
|
*(char*)(tmp+44) = 0;
|
||||||
|
int32_t totalRows = 0;
|
||||||
|
pRes = taos_schemaless_insert_raw(taos, tmp, strlen(sql[0]), &totalRows, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||||
|
|
||||||
|
ASSERT(totalRows == 3);
|
||||||
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
|
int code = taos_errno(pRes);
|
||||||
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
taosMemoryFree(tmp);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1187,5 +1116,7 @@ int main(int argc, char *argv[]) {
|
||||||
ASSERT(!ret);
|
ASSERT(!ret);
|
||||||
ret = smlProcess_18784_Test();
|
ret = smlProcess_18784_Test();
|
||||||
ASSERT(!ret);
|
ASSERT(!ret);
|
||||||
|
ret = sml_19221_Test();
|
||||||
|
ASSERT(!ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,15 +130,15 @@ void parseArgument(int32_t argc, char* argv[]) {
|
||||||
printHelp();
|
printHelp();
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (strcmp(argv[i], "-d") == 0) {
|
} else if (strcmp(argv[i], "-d") == 0) {
|
||||||
strcpy(g_stConfInfo.dbName, argv[++i]);
|
tstrncpy(g_stConfInfo.dbName, argv[++i], sizeof(g_stConfInfo.dbName));
|
||||||
} else if (strcmp(argv[i], "-c") == 0) {
|
} else if (strcmp(argv[i], "-c") == 0) {
|
||||||
strcpy(configDir, argv[++i]);
|
tstrncpy(configDir, argv[++i], PATH_MAX);
|
||||||
} else if (strcmp(argv[i], "-s") == 0) {
|
} else if (strcmp(argv[i], "-s") == 0) {
|
||||||
strcpy(g_stConfInfo.stbName, argv[++i]);
|
tstrncpy(g_stConfInfo.stbName, argv[++i], sizeof(g_stConfInfo.stbName));
|
||||||
} else if (strcmp(argv[i], "-w") == 0) {
|
} else if (strcmp(argv[i], "-w") == 0) {
|
||||||
strcpy(g_stConfInfo.vnodeWalPath, argv[++i]);
|
tstrncpy(g_stConfInfo.vnodeWalPath, argv[++i], sizeof(g_stConfInfo.vnodeWalPath));
|
||||||
} else if (strcmp(argv[i], "-f") == 0) {
|
} else if (strcmp(argv[i], "-f") == 0) {
|
||||||
strcpy(g_stConfInfo.resultFileName, argv[++i]);
|
tstrncpy(g_stConfInfo.resultFileName, argv[++i], sizeof(g_stConfInfo.resultFileName));
|
||||||
} else if (strcmp(argv[i], "-t") == 0) {
|
} else if (strcmp(argv[i], "-t") == 0) {
|
||||||
g_stConfInfo.numOfThreads = atoi(argv[++i]);
|
g_stConfInfo.numOfThreads = atoi(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-n") == 0) {
|
} else if (strcmp(argv[i], "-n") == 0) {
|
||||||
|
|
|
@ -949,7 +949,7 @@ void parseConsumeInfo() {
|
||||||
token = strtok(g_stConfInfo.stThreads[i].topicString, delim);
|
token = strtok(g_stConfInfo.stThreads[i].topicString, delim);
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
// printf("%s\n", token );
|
// printf("%s\n", token );
|
||||||
strcpy(g_stConfInfo.stThreads[i].topics[g_stConfInfo.stThreads[i].numOfTopic], token);
|
tstrncpy(g_stConfInfo.stThreads[i].topics[g_stConfInfo.stThreads[i].numOfTopic], token, sizeof(g_stConfInfo.stThreads[i].topics[g_stConfInfo.stThreads[i].numOfTopic]));
|
||||||
ltrim(g_stConfInfo.stThreads[i].topics[g_stConfInfo.stThreads[i].numOfTopic]);
|
ltrim(g_stConfInfo.stThreads[i].topics[g_stConfInfo.stThreads[i].numOfTopic]);
|
||||||
// printf("%s\n", g_stConfInfo.topics[g_stConfInfo.numOfTopic]);
|
// printf("%s\n", g_stConfInfo.topics[g_stConfInfo.numOfTopic]);
|
||||||
g_stConfInfo.stThreads[i].numOfTopic++;
|
g_stConfInfo.stThreads[i].numOfTopic++;
|
||||||
|
|
|
@ -37,6 +37,7 @@ void simLogSql(char *sql, bool useSharp) {
|
||||||
taosFsyncFile(pFile);
|
taosFsyncFile(pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
char *simParseArbitratorName(char *varName) {
|
char *simParseArbitratorName(char *varName) {
|
||||||
static char hostName[140];
|
static char hostName[140];
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -47,6 +48,7 @@ char *simParseArbitratorName(char *varName) {
|
||||||
#endif
|
#endif
|
||||||
return hostName;
|
return hostName;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
char *simParseHostName(char *varName) {
|
char *simParseHostName(char *varName) {
|
||||||
static char hostName[140];
|
static char hostName[140];
|
||||||
|
@ -102,9 +104,11 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
|
||||||
return simParseHostName(varName);
|
return simParseHostName(varName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (strncmp(varName, "arbitrator", 10) == 0) {
|
if (strncmp(varName, "arbitrator", 10) == 0) {
|
||||||
return simParseArbitratorName(varName);
|
return simParseArbitratorName(varName);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (strncmp(varName, "error", varLen) == 0) return script->error;
|
if (strncmp(varName, "error", varLen) == 0) return script->error;
|
||||||
|
|
||||||
|
@ -883,6 +887,7 @@ bool simExecuteSqlSlowCmd(SScript *script, char *rest) {
|
||||||
return simExecuteSqlImpCmd(script, rest, isSlow);
|
return simExecuteSqlImpCmd(script, rest, isSlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
|
@ -924,6 +929,7 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
||||||
|
|
||||||
return simExecuteSystemCmd(script, cmd);
|
return simExecuteSystemCmd(script, cmd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
||||||
char buf[3000];
|
char buf[3000];
|
||||||
|
@ -981,6 +987,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool simExecuteLineInsertCmd(SScript *script, char *rest) {
|
bool simExecuteLineInsertCmd(SScript *script, char *rest) {
|
||||||
char buf[TSDB_MAX_BINARY_LEN] = {0};
|
char buf[TSDB_MAX_BINARY_LEN] = {0};
|
||||||
|
|
||||||
|
@ -1037,3 +1044,4 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -501,6 +501,7 @@ bool simParseEndwCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool simParseSwitchCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
bool simParseSwitchCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
char *token;
|
char *token;
|
||||||
int32_t tokenLen;
|
int32_t tokenLen;
|
||||||
|
@ -647,6 +648,7 @@ bool simParseContinueCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
numOfLines++;
|
numOfLines++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool simParsePrintCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
bool simParsePrintCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
int32_t expLen;
|
int32_t expLen;
|
||||||
|
@ -715,6 +717,7 @@ bool simParseSqlErrorCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool simParseSqlSlowCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
bool simParseSqlSlowCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
simParseSqlCmd(rest, pCmd, lineNum);
|
simParseSqlCmd(rest, pCmd, lineNum);
|
||||||
cmdLine[numOfLines - 1].cmdno = SIM_CMD_SQL_SLOW;
|
cmdLine[numOfLines - 1].cmdno = SIM_CMD_SQL_SLOW;
|
||||||
|
@ -726,6 +729,7 @@ bool simParseRestfulCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
cmdLine[numOfLines - 1].cmdno = SIM_CMD_RESTFUL;
|
cmdLine[numOfLines - 1].cmdno = SIM_CMD_RESTFUL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool simParseSystemCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
bool simParseSystemCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
int32_t expLen;
|
int32_t expLen;
|
||||||
|
@ -838,6 +842,7 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool simParseLineInsertCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
bool simParseLineInsertCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
int32_t expLen;
|
int32_t expLen;
|
||||||
|
|
||||||
|
@ -869,6 +874,7 @@ bool simParseLineInsertErrorCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||||
numOfLines++;
|
numOfLines++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void simInitsimCmdList() {
|
void simInitsimCmdList() {
|
||||||
int32_t cmdno;
|
int32_t cmdno;
|
||||||
|
@ -930,6 +936,7 @@ void simInitsimCmdList() {
|
||||||
simCmdList[cmdno].executeCmd = NULL;
|
simCmdList[cmdno].executeCmd = NULL;
|
||||||
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
||||||
|
|
||||||
|
#if 0
|
||||||
cmdno = SIM_CMD_SWITCH;
|
cmdno = SIM_CMD_SWITCH;
|
||||||
simCmdList[cmdno].cmdno = cmdno;
|
simCmdList[cmdno].cmdno = cmdno;
|
||||||
strcpy(simCmdList[cmdno].name, "switch");
|
strcpy(simCmdList[cmdno].name, "switch");
|
||||||
|
@ -977,6 +984,7 @@ void simInitsimCmdList() {
|
||||||
simCmdList[cmdno].parseCmd = simParseEndsCmd;
|
simCmdList[cmdno].parseCmd = simParseEndsCmd;
|
||||||
simCmdList[cmdno].executeCmd = NULL;
|
simCmdList[cmdno].executeCmd = NULL;
|
||||||
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
||||||
|
#endif
|
||||||
|
|
||||||
cmdno = SIM_CMD_SLEEP;
|
cmdno = SIM_CMD_SLEEP;
|
||||||
simCmdList[cmdno].cmdno = cmdno;
|
simCmdList[cmdno].cmdno = cmdno;
|
||||||
|
@ -1050,6 +1058,7 @@ void simInitsimCmdList() {
|
||||||
simCmdList[cmdno].executeCmd = simExecuteSqlErrorCmd;
|
simCmdList[cmdno].executeCmd = simExecuteSqlErrorCmd;
|
||||||
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
||||||
|
|
||||||
|
#if 0
|
||||||
cmdno = SIM_CMD_SQL_SLOW;
|
cmdno = SIM_CMD_SQL_SLOW;
|
||||||
simCmdList[cmdno].cmdno = cmdno;
|
simCmdList[cmdno].cmdno = cmdno;
|
||||||
strcpy(simCmdList[cmdno].name, "sql_slow");
|
strcpy(simCmdList[cmdno].name, "sql_slow");
|
||||||
|
@ -1065,6 +1074,7 @@ void simInitsimCmdList() {
|
||||||
simCmdList[cmdno].parseCmd = simParseRestfulCmd;
|
simCmdList[cmdno].parseCmd = simParseRestfulCmd;
|
||||||
simCmdList[cmdno].executeCmd = simExecuteRestfulCmd;
|
simCmdList[cmdno].executeCmd = simExecuteRestfulCmd;
|
||||||
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* test is only an internal command */
|
/* test is only an internal command */
|
||||||
cmdno = SIM_CMD_TEST;
|
cmdno = SIM_CMD_TEST;
|
||||||
|
@ -1082,6 +1092,7 @@ void simInitsimCmdList() {
|
||||||
simCmdList[cmdno].executeCmd = simExecuteReturnCmd;
|
simCmdList[cmdno].executeCmd = simExecuteReturnCmd;
|
||||||
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
||||||
|
|
||||||
|
#if 0
|
||||||
cmdno = SIM_CMD_LINE_INSERT;
|
cmdno = SIM_CMD_LINE_INSERT;
|
||||||
simCmdList[cmdno].cmdno = cmdno;
|
simCmdList[cmdno].cmdno = cmdno;
|
||||||
strcpy(simCmdList[cmdno].name, "line_insert");
|
strcpy(simCmdList[cmdno].name, "line_insert");
|
||||||
|
@ -1097,4 +1108,5 @@ void simInitsimCmdList() {
|
||||||
simCmdList[cmdno].parseCmd = simParseLineInsertErrorCmd;
|
simCmdList[cmdno].parseCmd = simParseLineInsertErrorCmd;
|
||||||
simCmdList[cmdno].executeCmd = simExecuteLineInsertErrorCmd;
|
simCmdList[cmdno].executeCmd = simExecuteLineInsertErrorCmd;
|
||||||
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
simAddCmdIntoHash(&(simCmdList[cmdno]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue