Merge remote-tracking branch 'origin/3.0' into fix/TD-19712
This commit is contained in:
commit
ac542e9164
|
@ -2,7 +2,7 @@
|
||||||
# taosws-rs
|
# taosws-rs
|
||||||
ExternalProject_Add(taosws-rs
|
ExternalProject_Add(taosws-rs
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
||||||
GIT_TAG 1bdfca3
|
GIT_TAG 0373a70
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -108,11 +108,11 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('202
|
||||||
|
|
||||||
## Insert Rows From A File
|
## Insert Rows From A File
|
||||||
|
|
||||||
Besides using `VALUES` to insert one or multiple rows, the data to be inserted can also be prepared in a CSV file with comma as separator and each field value quoted by single quotes. Table definition is not required in the CSV file. For example, if file "/tmp/csvfile.csv" contains the below data:
|
Besides using `VALUES` to insert one or multiple rows, the data to be inserted can also be prepared in a CSV file with comma as separator and timestamp and string field value quoted by single quotes. Table definition is not required in the CSV file. For example, if file "/tmp/csvfile.csv" contains the below data:
|
||||||
|
|
||||||
```
|
```
|
||||||
'2021-07-13 14:07:34.630', '10.2', '219', '0.32'
|
'2021-07-13 14:07:34.630', 10.2, 219, 0.32
|
||||||
'2021-07-13 14:07:35.779', '10.15', '217', '0.33'
|
'2021-07-13 14:07:35.779', 10.15, 217, 0.33
|
||||||
```
|
```
|
||||||
|
|
||||||
Then data in this file can be inserted by the SQL statement below:
|
Then data in this file can be inserted by the SQL statement below:
|
||||||
|
|
|
@ -64,6 +64,12 @@ dnode_option: {
|
||||||
|
|
||||||
The parameters that you can modify through this statement are the same as those located in the dnode configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the dnode restarts.
|
The parameters that you can modify through this statement are the same as those located in the dnode configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the dnode restarts.
|
||||||
|
|
||||||
|
`value` is the value of the parameter, which needs to be in character format. For example, modify the log output level of dnode 1 to debug:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
ALTER DNODE 1 'debugFlag' '143';
|
||||||
|
```
|
||||||
|
|
||||||
## Add an Mnode
|
## Add an Mnode
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
|
|
@ -109,11 +109,11 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('202
|
||||||
|
|
||||||
## 插入来自文件的数据记录
|
## 插入来自文件的数据记录
|
||||||
|
|
||||||
除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为:
|
除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、时间戳和字符串类型的值需要用英文单引号括住)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为:
|
||||||
|
|
||||||
```
|
```
|
||||||
'2021-07-13 14:07:34.630', '10.2', '219', '0.32'
|
'2021-07-13 14:07:34.630', 10.2, 219, 0.32
|
||||||
'2021-07-13 14:07:35.779', '10.15', '217', '0.33'
|
'2021-07-13 14:07:35.779', 10.15, 217, 0.33
|
||||||
```
|
```
|
||||||
|
|
||||||
那么通过如下指令可以把这个文件中的数据写入子表中:
|
那么通过如下指令可以把这个文件中的数据写入子表中:
|
||||||
|
|
|
@ -65,6 +65,12 @@ dnode_option: {
|
||||||
|
|
||||||
上面语法中的这些可修改配置项其配置方式与 dnode 配置文件中的配置方式相同,区别是修改是动态的立即生效,且不需要重启 dnode。
|
上面语法中的这些可修改配置项其配置方式与 dnode 配置文件中的配置方式相同,区别是修改是动态的立即生效,且不需要重启 dnode。
|
||||||
|
|
||||||
|
value 是参数的值,需要是字符格式。如修改 dnode 1 的日志输出级别为 debug:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
ALTER DNODE 1 'debugFlag' '143';
|
||||||
|
```
|
||||||
|
|
||||||
## 添加管理节点
|
## 添加管理节点
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
|
|
@ -83,6 +83,27 @@ typedef struct {
|
||||||
int32_t exprIdx;
|
int32_t exprIdx;
|
||||||
} STupleKey;
|
} STupleKey;
|
||||||
|
|
||||||
|
typedef struct STuplePos {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
int32_t pageId;
|
||||||
|
int32_t offset;
|
||||||
|
};
|
||||||
|
STupleKey streamTupleKey;
|
||||||
|
};
|
||||||
|
} STuplePos;
|
||||||
|
|
||||||
|
typedef struct SFirstLastRes {
|
||||||
|
bool hasResult;
|
||||||
|
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||||
|
// this attribute is required
|
||||||
|
bool isNull;
|
||||||
|
int32_t bytes;
|
||||||
|
int64_t ts;
|
||||||
|
STuplePos pos;
|
||||||
|
char buf[];
|
||||||
|
} SFirstLastRes;
|
||||||
|
|
||||||
static inline int STupleKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
static inline int STupleKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||||
STupleKey* pTuple1 = (STupleKey*)pKey1;
|
STupleKey* pTuple1 = (STupleKey*)pKey1;
|
||||||
STupleKey* pTuple2 = (STupleKey*)pKey2;
|
STupleKey* pTuple2 = (STupleKey*)pKey2;
|
||||||
|
|
|
@ -1191,7 +1191,6 @@ typedef struct {
|
||||||
int8_t strict;
|
int8_t strict;
|
||||||
int8_t cacheLast;
|
int8_t cacheLast;
|
||||||
int8_t isTsma;
|
int8_t isTsma;
|
||||||
int8_t standby;
|
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
|
@ -1206,6 +1205,7 @@ typedef struct {
|
||||||
int16_t hashPrefix;
|
int16_t hashPrefix;
|
||||||
int16_t hashSuffix;
|
int16_t hashSuffix;
|
||||||
int32_t tsdbPageSize;
|
int32_t tsdbPageSize;
|
||||||
|
int64_t reserved[8];
|
||||||
} SCreateVnodeReq;
|
} SCreateVnodeReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||||
|
@ -1217,6 +1217,7 @@ typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
int64_t reserved[8];
|
||||||
} SDropVnodeReq;
|
} SDropVnodeReq;
|
||||||
|
|
||||||
int32_t tSerializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
|
int32_t tSerializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
|
||||||
|
@ -1225,6 +1226,7 @@ int32_t tDeserializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
int64_t reserved[8];
|
||||||
} SCompactVnodeReq;
|
} SCompactVnodeReq;
|
||||||
|
|
||||||
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
|
||||||
|
@ -1244,13 +1246,23 @@ typedef struct {
|
||||||
int8_t walLevel;
|
int8_t walLevel;
|
||||||
int8_t strict;
|
int8_t strict;
|
||||||
int8_t cacheLast;
|
int8_t cacheLast;
|
||||||
|
int64_t reserved[8];
|
||||||
|
} SAlterVnodeConfigReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
|
||||||
|
int32_t tDeserializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
int8_t strict;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
} SAlterVnodeReq;
|
int64_t reserved[8];
|
||||||
|
} SAlterVnodeReplicaReq;
|
||||||
|
|
||||||
int32_t tSerializeSAlterVnodeReq(void* buf, int32_t bufLen, SAlterVnodeReq* pReq);
|
int32_t tSerializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
|
||||||
int32_t tDeserializeSAlterVnodeReq(void* buf, int32_t bufLen, SAlterVnodeReq* pReq);
|
int32_t tDeserializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead header;
|
SMsgHead header;
|
||||||
|
@ -1503,14 +1515,6 @@ typedef struct {
|
||||||
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||||
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t dnodeId;
|
|
||||||
int8_t standby;
|
|
||||||
} SSetStandbyReq;
|
|
||||||
|
|
||||||
int32_t tSerializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq);
|
|
||||||
int32_t tDeserializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char queryStrId[TSDB_QUERY_ID_LEN];
|
char queryStrId[TSDB_QUERY_ID_LEN];
|
||||||
} SKillQueryReq;
|
} SKillQueryReq;
|
||||||
|
@ -1726,13 +1730,14 @@ typedef struct {
|
||||||
char name[TSDB_STREAM_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
char sourceDB[TSDB_DB_FNAME_LEN];
|
char sourceDB[TSDB_DB_FNAME_LEN];
|
||||||
char targetStbFullName[TSDB_TABLE_FNAME_LEN];
|
char targetStbFullName[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t igExists;
|
|
||||||
char* sql;
|
char* sql;
|
||||||
char* ast;
|
char* ast;
|
||||||
|
int8_t igExists;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
|
int8_t igExpired;
|
||||||
|
int8_t fillHistory; // process data inserted before creating stream
|
||||||
int64_t maxDelay;
|
int64_t maxDelay;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
int8_t igExpired;
|
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
SArray* pTags; // array of SField
|
SArray* pTags; // array of SField
|
||||||
} SCMCreateStreamReq;
|
} SCMCreateStreamReq;
|
||||||
|
|
|
@ -262,8 +262,8 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_SEND, "sync-snapshot-send", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_SEND, "sync-snapshot-send", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_RSP, "sync-snapshot-rsp", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_RSP, "sync-snapshot-rsp", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_MNODE_STANDBY, "set-mnode-standby", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_MNODE_STANDBY, "set-mnode-standby", NULL, NULL) // no longer used
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL) // no longer used
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||||
|
|
|
@ -129,6 +129,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_TO_COLUMN,
|
FUNCTION_TYPE_TO_COLUMN,
|
||||||
FUNCTION_TYPE_GROUP_KEY,
|
FUNCTION_TYPE_GROUP_KEY,
|
||||||
FUNCTION_TYPE_CACHE_LAST_ROW,
|
FUNCTION_TYPE_CACHE_LAST_ROW,
|
||||||
|
FUNCTION_TYPE_CACHE_LAST,
|
||||||
|
|
||||||
// distributed splitting functions
|
// distributed splitting functions
|
||||||
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
||||||
|
@ -216,6 +217,8 @@ bool fmIsKeepOrderFunc(int32_t funcId);
|
||||||
bool fmIsCumulativeFunc(int32_t funcId);
|
bool fmIsCumulativeFunc(int32_t funcId);
|
||||||
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
|
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
|
||||||
|
|
||||||
|
void getLastCacheDataType(SDataType* pType);
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||||
|
|
||||||
typedef enum EFuncDataRequired {
|
typedef enum EFuncDataRequired {
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct SStreamTask SStreamTask;
|
||||||
enum {
|
enum {
|
||||||
STREAM_STATUS__NORMAL = 0,
|
STREAM_STATUS__NORMAL = 0,
|
||||||
STREAM_STATUS__STOP,
|
STREAM_STATUS__STOP,
|
||||||
|
STREAM_STATUS__INIT,
|
||||||
STREAM_STATUS__FAILED,
|
STREAM_STATUS__FAILED,
|
||||||
STREAM_STATUS__RECOVER,
|
STREAM_STATUS__RECOVER,
|
||||||
};
|
};
|
||||||
|
@ -291,6 +292,9 @@ typedef struct SStreamTask {
|
||||||
int64_t recoverSnapVer;
|
int64_t recoverSnapVer;
|
||||||
int64_t startVer;
|
int64_t startVer;
|
||||||
|
|
||||||
|
// fill history
|
||||||
|
int8_t fillHistory;
|
||||||
|
|
||||||
// children info
|
// children info
|
||||||
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
||||||
int32_t nextCheckId;
|
int32_t nextCheckId;
|
||||||
|
@ -534,7 +538,7 @@ typedef struct SStreamMeta {
|
||||||
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc);
|
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc);
|
||||||
void streamMetaClose(SStreamMeta* streamMeta);
|
void streamMetaClose(SStreamMeta* streamMeta);
|
||||||
|
|
||||||
int32_t streamMetaAddTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
// int32_t streamMetaAddTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||||
int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char* msg, int32_t msgLen);
|
int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char* msg, int32_t msgLen);
|
||||||
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
|
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
|
||||||
SStreamTask* streamMetaGetTask(SStreamMeta* pMeta, int32_t taskId);
|
SStreamTask* streamMetaGetTask(SStreamMeta* pMeta, int32_t taskId);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
|
#include "tcommon.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tscalablebf.h"
|
#include "tscalablebf.h"
|
||||||
|
|
||||||
|
@ -24,6 +25,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct SUpdateKey {
|
||||||
|
int64_t tbUid;
|
||||||
|
TSKEY ts;
|
||||||
|
} SUpdateKey;
|
||||||
|
|
||||||
typedef struct SUpdateInfo {
|
typedef struct SUpdateInfo {
|
||||||
SArray *pTsBuckets;
|
SArray *pTsBuckets;
|
||||||
uint64_t numBuckets;
|
uint64_t numBuckets;
|
||||||
|
@ -41,6 +47,7 @@ typedef struct SUpdateInfo {
|
||||||
|
|
||||||
SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark);
|
SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark);
|
||||||
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark);
|
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark);
|
||||||
|
void updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol);
|
||||||
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts);
|
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts);
|
||||||
bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid);
|
bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid);
|
||||||
void updateInfoSetScanRange(SUpdateInfo *pInfo, STimeWindow *pWin, uint64_t groupId, uint64_t version);
|
void updateInfoSetScanRange(SUpdateInfo *pInfo, STimeWindow *pWin, uint64_t groupId, uint64_t version);
|
||||||
|
|
|
@ -50,6 +50,9 @@ uint64_t MurmurHash3_64(const char *key, uint32_t len);
|
||||||
uint32_t taosIntHash_32(const char *key, uint32_t len);
|
uint32_t taosIntHash_32(const char *key, uint32_t len);
|
||||||
uint32_t taosIntHash_64(const char *key, uint32_t len);
|
uint32_t taosIntHash_64(const char *key, uint32_t len);
|
||||||
|
|
||||||
|
uint32_t taosFastHash(const char *key, uint32_t len);
|
||||||
|
uint32_t taosDJB2Hash(const char *key, uint32_t len);
|
||||||
|
|
||||||
_hash_fn_t taosGetDefaultHashFunction(int32_t type);
|
_hash_fn_t taosGetDefaultHashFunction(int32_t type);
|
||||||
_equal_fn_t taosGetDefaultEqualFunction(int32_t type);
|
_equal_fn_t taosGetDefaultEqualFunction(int32_t type);
|
||||||
|
|
||||||
|
|
|
@ -979,6 +979,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
||||||
const SArray* container = &topic_list->container;
|
const SArray* container = &topic_list->container;
|
||||||
int32_t sz = taosArrayGetSize(container);
|
int32_t sz = taosArrayGetSize(container);
|
||||||
void* buf = NULL;
|
void* buf = NULL;
|
||||||
|
SMsgSendInfo* sendInfo = NULL;
|
||||||
SCMSubscribeReq req = {0};
|
SCMSubscribeReq req = {0};
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
|
@ -1016,7 +1017,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
||||||
void* abuf = buf;
|
void* abuf = buf;
|
||||||
tSerializeSCMSubscribeReq(&abuf, &req);
|
tSerializeSCMSubscribeReq(&abuf, &req);
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
if (sendInfo == NULL) goto FAIL;
|
if (sendInfo == NULL) goto FAIL;
|
||||||
|
|
||||||
SMqSubscribeCbParam param = {
|
SMqSubscribeCbParam param = {
|
||||||
|
@ -1046,6 +1047,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
||||||
|
|
||||||
// avoid double free if msg is sent
|
// avoid double free if msg is sent
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
|
sendInfo = NULL;
|
||||||
|
|
||||||
tsem_wait(¶m.rspSem);
|
tsem_wait(¶m.rspSem);
|
||||||
tsem_destroy(¶m.rspSem);
|
tsem_destroy(¶m.rspSem);
|
||||||
|
@ -1078,8 +1080,9 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
FAIL:
|
FAIL:
|
||||||
if (req.topicNames != NULL) taosArrayDestroyP(req.topicNames, taosMemoryFree);
|
taosArrayDestroyP(req.topicNames, taosMemoryFree);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
|
taosMemoryFree(sendInfo);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1616,11 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
if (rspWrapper == NULL) {
|
if (rspWrapper == NULL) {
|
||||||
taosReadAllQitems(tmq->mqueue, tmq->qall);
|
taosReadAllQitems(tmq->mqueue, tmq->qall);
|
||||||
taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||||
if (rspWrapper == NULL) return NULL;
|
|
||||||
|
if (rspWrapper == NULL) {
|
||||||
|
tscDebug("consumer %" PRId64 " mqueue empty", tmq->consumerId);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) {
|
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) {
|
||||||
|
@ -1711,6 +1718,8 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||||
void* rspObj;
|
void* rspObj;
|
||||||
int64_t startTime = taosGetTimestampMs();
|
int64_t startTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
tscDebug("consumer:%" PRId64 ", start poll at %" PRId64, tmq->consumerId, startTime);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
tmqHandleAllDelayedTask(tmq);
|
tmqHandleAllDelayedTask(tmq);
|
||||||
tmqPollImpl(tmq, timeout);
|
tmqPollImpl(tmq, timeout);
|
||||||
|
@ -1745,15 +1754,18 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||||
|
|
||||||
rspObj = tmqHandleAllRsp(tmq, timeout, false);
|
rspObj = tmqHandleAllRsp(tmq, timeout, false);
|
||||||
if (rspObj) {
|
if (rspObj) {
|
||||||
|
tscDebug("consumer:%" PRId64 ", return rsp", tmq->consumerId);
|
||||||
return (TAOS_RES*)rspObj;
|
return (TAOS_RES*)rspObj;
|
||||||
} else if (terrno == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) {
|
} else if (terrno == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) {
|
||||||
|
tscDebug("consumer:%" PRId64 ", return null since no committed offset", tmq->consumerId);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (timeout != -1) {
|
if (timeout != -1) {
|
||||||
int64_t endTime = taosGetTimestampMs();
|
int64_t endTime = taosGetTimestampMs();
|
||||||
int64_t leftTime = endTime - startTime;
|
int64_t leftTime = endTime - startTime;
|
||||||
if (leftTime > timeout) {
|
if (leftTime > timeout) {
|
||||||
tscDebug("consumer:%" PRId64 ", (epoch %d) timeout, no rsp", tmq->consumerId, tmq->epoch);
|
tscDebug("consumer:%" PRId64 ", (epoch %d) timeout, no rsp, start time %" PRId64 ", end time %" PRId64,
|
||||||
|
tmq->consumerId, tmq->epoch, startTime, endTime);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tsem_timewait(&tmq->rspSem, leftTime * 1000);
|
tsem_timewait(&tmq->rspSem, leftTime * 1000);
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
|
|
||||||
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
||||||
pEp->port = 0;
|
pEp->port = 0;
|
||||||
strcpy(pEp->fqdn, ep);
|
memset(pEp->fqdn, 0, TSDB_FQDN_LEN);
|
||||||
|
strncpy(pEp->fqdn, ep, TSDB_FQDN_LEN - 1);
|
||||||
|
|
||||||
char* temp = strchr(pEp->fqdn, ':');
|
char* temp = strchr(pEp->fqdn, ':');
|
||||||
if (temp) {
|
if (temp) {
|
||||||
|
|
|
@ -3766,7 +3766,6 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
||||||
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->standby) < 0) return -1;
|
|
||||||
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1;
|
||||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||||
|
@ -3795,6 +3794,9 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
||||||
if (tEncodeI16(&encoder, pReq->hashPrefix) < 0) return -1;
|
if (tEncodeI16(&encoder, pReq->hashPrefix) < 0) return -1;
|
||||||
if (tEncodeI16(&encoder, pReq->hashSuffix) < 0) return -1;
|
if (tEncodeI16(&encoder, pReq->hashSuffix) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -3832,7 +3834,6 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
||||||
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->standby) < 0) return -1;
|
|
||||||
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1;
|
||||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||||
|
@ -3871,6 +3872,9 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
||||||
if (tDecodeI16(&decoder, &pReq->hashPrefix) < 0) return -1;
|
if (tDecodeI16(&decoder, &pReq->hashPrefix) < 0) return -1;
|
||||||
if (tDecodeI16(&decoder, &pReq->hashSuffix) < 0) return -1;
|
if (tDecodeI16(&decoder, &pReq->hashSuffix) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->tsdbPageSize) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->tsdbPageSize) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -3892,6 +3896,9 @@ int32_t tSerializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq)
|
||||||
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -3908,6 +3915,9 @@ int32_t tDeserializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq
|
||||||
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -3921,6 +3931,9 @@ int32_t tSerializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq *
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -3935,13 +3948,16 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq) {
|
int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
@ -3959,11 +3975,8 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
|
||||||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1;
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
|
||||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
|
||||||
SReplica *pReplica = &pReq->replicas[i];
|
|
||||||
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
|
||||||
}
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -3972,7 +3985,7 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq) {
|
int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
@ -3990,12 +4003,54 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
|
||||||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnodeReplicaReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||||
|
SReplica *pReplica = &pReq->replicas[i];
|
||||||
|
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnodeReplicaReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
|
||||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||||
SReplica *pReplica = &pReq->replicas[i];
|
SReplica *pReplica = &pReq->replicas[i];
|
||||||
if (tDecodeSReplica(&decoder, pReplica) < 0) return -1;
|
if (tDecodeSReplica(&decoder, pReplica) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
for (int32_t i = 0; i < 8; ++i) {
|
||||||
|
if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -4218,33 +4273,6 @@ int32_t tDeserializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSSetStandbyReq(void *buf, int32_t bufLen, SSetStandbyReq *pReq) {
|
|
||||||
SEncoder encoder = {0};
|
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
|
||||||
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
|
||||||
if (tEncodeI8(&encoder, pReq->standby) < 0) return -1;
|
|
||||||
tEndEncode(&encoder);
|
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tDeserializeSSetStandbyReq(void *buf, int32_t bufLen, SSetStandbyReq *pReq) {
|
|
||||||
SDecoder decoder = {0};
|
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
|
||||||
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
|
||||||
if (tDecodeI8(&decoder, &pReq->standby) < 0) return -1;
|
|
||||||
tEndDecode(&decoder);
|
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tSerializeSAuthReq(void *buf, int32_t bufLen, SAuthReq *pReq) {
|
int32_t tSerializeSAuthReq(void *buf, int32_t bufLen, SAuthReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
|
@ -90,8 +90,10 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
||||||
SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) {
|
SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) {
|
||||||
pName->type = TSDB_TABLE_NAME_T;
|
pName->type = TSDB_TABLE_NAME_T;
|
||||||
pName->acctId = acctId;
|
pName->acctId = acctId;
|
||||||
strcpy(pName->dbname, pDbName);
|
memset(pName->dbname, 0, TSDB_DB_NAME_LEN);
|
||||||
strcpy(pName->tname, pTableName);
|
strncpy(pName->dbname, pDbName, TSDB_DB_NAME_LEN - 1);
|
||||||
|
memset(pName->tname, 0, TSDB_TABLE_NAME_LEN);
|
||||||
|
strncpy(pName->tname, pTableName, TSDB_TABLE_NAME_LEN - 1);
|
||||||
return pName;
|
return pName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,10 +196,6 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_MNODE_STANDBY, mmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_MNODE_STANDBY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
SArray *vmGetMsgHandles();
|
SArray *vmGetMsgHandles();
|
||||||
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// vmFile.c
|
// vmFile.c
|
||||||
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
||||||
|
|
|
@ -265,6 +265,62 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
|
SAlterVnodeReplicaReq alterReq = {0};
|
||||||
|
if (tDeserializeSAlterVnodeReplicaReq(pMsg->pCont, pMsg->contLen, &alterReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vgId = alterReq.vgId;
|
||||||
|
dInfo("vgId:%d, start to alter vnode replica", alterReq.vgId);
|
||||||
|
|
||||||
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId);
|
||||||
|
if (pVnode == NULL) {
|
||||||
|
dError("vgId:%d, failed to alter replica since %s", vgId, terrstr());
|
||||||
|
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("vgId:%d, start to close vnode", vgId);
|
||||||
|
SWrapperCfg wrapperCfg = {
|
||||||
|
.dropped = pVnode->dropped,
|
||||||
|
.vgId = pVnode->vgId,
|
||||||
|
.vgVersion = pVnode->vgVersion,
|
||||||
|
};
|
||||||
|
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
|
||||||
|
vmCloseVnode(pMgmt, pVnode);
|
||||||
|
|
||||||
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, vgId);
|
||||||
|
|
||||||
|
dInfo("vgId:%d, start to alter vnode replica at %s", vgId, path);
|
||||||
|
if (vnodeAlter(path, &alterReq, pMgmt->pTfs) < 0) {
|
||||||
|
dError("vgId:%d, failed to alter vnode at %s since %s", vgId, path, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("vgId:%d, start to open vnode", vgId);
|
||||||
|
SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, pMgmt->msgCb);
|
||||||
|
if (pImpl == NULL) {
|
||||||
|
dError("vgId:%d, failed to open vnode at %s since %s", vgId, path, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vmOpenVnode(pMgmt, &wrapperCfg, pImpl) != 0) {
|
||||||
|
dError("vgId:%d, failed to open vnode mgmt since %s", vgId, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vnodeStart(pImpl) != 0) {
|
||||||
|
dError("vgId:%d, failed to start sync since %s", vgId, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("vgId:%d, vnode config is altered", vgId);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SDropVnodeReq dropReq = {0};
|
SDropVnodeReq dropReq = {0};
|
||||||
if (tDeserializeSDropVnodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
if (tDeserializeSDropVnodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||||
|
@ -348,7 +404,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -370,7 +426,6 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
case TDMT_DND_DROP_VNODE:
|
case TDMT_DND_DROP_VNODE:
|
||||||
code = vmProcessDropVnodeReq(pMgmt, pMsg);
|
code = vmProcessDropVnodeReq(pMgmt, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case TDMT_VND_ALTER_REPLICA:
|
||||||
|
code = vmProcessAlterVnodeReq(pMgmt, pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
dGError("msg:%p, not processed in vnode-mgmt queue", pMsg);
|
dGError("msg:%p, not processed in vnode-mgmt queue", pMsg);
|
||||||
|
|
|
@ -70,7 +70,7 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
|
||||||
|
|
||||||
TEST_F(DndTestVnode, 02_Alter_Vnode) {
|
TEST_F(DndTestVnode, 02_Alter_Vnode) {
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
SAlterVnodeReq alterReq = {0};
|
SAlterVnodeConfigReq alterReq = {0};
|
||||||
alterReq.vgVersion = 2;
|
alterReq.vgVersion = 2;
|
||||||
alterReq.daysPerFile = 10;
|
alterReq.daysPerFile = 10;
|
||||||
alterReq.daysToKeep0 = 3650;
|
alterReq.daysToKeep0 = 3650;
|
||||||
|
|
|
@ -613,6 +613,7 @@ typedef struct {
|
||||||
// config
|
// config
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
int8_t trigger;
|
int8_t trigger;
|
||||||
|
int8_t fillHistory;
|
||||||
int64_t triggerParam;
|
int64_t triggerParam;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
// source and target
|
// source and target
|
||||||
|
|
|
@ -38,7 +38,7 @@ int32_t mndAllocSmaVgroup(SMnode *, SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mndAllocVgroup(SMnode *, SDbObj *pDb, SVgObj **ppVgroups);
|
int32_t mndAllocVgroup(SMnode *, SDbObj *pDb, SVgObj **ppVgroups);
|
||||||
int32_t mndAddVnodeToVgroup(SMnode *, SVgObj *pVgroup, SArray *pArray);
|
int32_t mndAddVnodeToVgroup(SMnode *, SVgObj *pVgroup, SArray *pArray);
|
||||||
int32_t mndRemoveVnodeFromVgroup(SMnode *, SVgObj *pVgroup, SArray *pArray, SVnodeGid *pDelVgid);
|
int32_t mndRemoveVnodeFromVgroup(SMnode *, SVgObj *pVgroup, SArray *pArray, SVnodeGid *pDelVgid);
|
||||||
int32_t mndAddCreateVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool standby);
|
int32_t mndAddCreateVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid);
|
||||||
int32_t mndAddAlterVnodeConfirmAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mndAddAlterVnodeConfirmAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mndAddAlterVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType);
|
int32_t mndAddAlterVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType);
|
||||||
int32_t mndAddDropVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool isRedo);
|
int32_t mndAddDropVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool isRedo);
|
||||||
|
@ -47,9 +47,8 @@ int32_t mndSetMoveVgroupsInfoToTrans(SMnode *, STrans *pTrans, int32_t dropDnode
|
||||||
int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup,
|
int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup,
|
||||||
SArray *pArray);
|
SArray *pArray);
|
||||||
|
|
||||||
void *mndBuildCreateVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *cntlen, bool standby);
|
void *mndBuildCreateVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
void *mndBuildDropVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildDropVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
void *mndBuildAlterVnodeReq(SMnode *, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
|
||||||
bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid);
|
bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -447,7 +447,7 @@ static int32_t mndSetCreateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
|
|
||||||
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
||||||
SVnodeGid *pVgid = pVgroup->vnodeGid + vn;
|
SVnodeGid *pVgid = pVgroup->vnodeGid + vn;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pVgid, false) != 0) {
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pVgid) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,29 +631,18 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
||||||
terrno = TSDB_CODE_MND_DB_OPTION_UNCHANGED;
|
terrno = TSDB_CODE_MND_DB_OPTION_UNCHANGED;
|
||||||
|
|
||||||
if (pAlter->buffer > 0 && pAlter->buffer != pDb->cfg.buffer) {
|
if (pAlter->buffer > 0 && pAlter->buffer != pDb->cfg.buffer) {
|
||||||
#if 0
|
|
||||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
|
||||||
return terrno;
|
|
||||||
#else
|
|
||||||
pDb->cfg.buffer = pAlter->buffer;
|
pDb->cfg.buffer = pAlter->buffer;
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pAlter->pages > 0 && pAlter->pages != pDb->cfg.pages) {
|
if (pAlter->pages > 0 && pAlter->pages != pDb->cfg.pages) {
|
||||||
#if 0
|
|
||||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
|
||||||
return terrno;
|
|
||||||
#else
|
|
||||||
pDb->cfg.pages = pAlter->pages;
|
pDb->cfg.pages = pAlter->pages;
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pAlter->pageSize > 0 && pAlter->pageSize != pDb->cfg.pageSize) {
|
if (pAlter->pageSize > 0 && pAlter->pageSize != pDb->cfg.pageSize) {
|
||||||
#if 1
|
#if 1
|
||||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
return terrno;
|
|
||||||
#else
|
#else
|
||||||
pDb->cfg.pageSize = pAlter->pageSize;
|
pDb->cfg.pageSize = pAlter->pageSize;
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -710,13 +699,9 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pAlter->replications > 0 && pAlter->replications != pDb->cfg.replications) {
|
if (pAlter->replications > 0 && pAlter->replications != pDb->cfg.replications) {
|
||||||
#if 1
|
|
||||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
|
||||||
#else
|
|
||||||
pDb->cfg.replications = pAlter->replications;
|
pDb->cfg.replications = pAlter->replications;
|
||||||
pDb->vgVersion++;
|
pDb->vgVersion++;
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return terrno;
|
return terrno;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "mndConsumer.h"
|
#include "mndConsumer.h"
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
|
if (tStartEncode(pEncoder) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
||||||
|
@ -31,6 +32,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
|
|
||||||
if (tEncodeI8(pEncoder, pObj->igExpired) < 0) return -1;
|
if (tEncodeI8(pEncoder, pObj->igExpired) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pObj->fillHistory) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->triggerParam) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->triggerParam) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->watermark) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->watermark) < 0) return -1;
|
||||||
|
|
||||||
|
@ -74,10 +76,12 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
|
|
||||||
if (tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema) < 0) return -1;
|
if (tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema) < 0) return -1;
|
||||||
|
|
||||||
|
tEndEncode(pEncoder);
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
|
if (tStartDecode(pDecoder) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1;
|
||||||
|
|
||||||
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->createTime) < 0) return -1;
|
||||||
|
@ -91,6 +95,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
|
|
||||||
if (tDecodeI8(pDecoder, &pObj->igExpired) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pObj->igExpired) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pObj->fillHistory) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->triggerParam) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->triggerParam) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->watermark) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->watermark) < 0) return -1;
|
||||||
|
|
||||||
|
@ -134,6 +139,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
|
|
||||||
if (tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema) < 0) return -1;
|
if (tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(pDecoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,10 +534,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg);
|
||||||
syncSnapshotRspDestroy(pSyncMsg);
|
syncSnapshotRspDestroy(pSyncMsg);
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
|
||||||
code = syncSetStandby(pMgmt->sync);
|
|
||||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
|
||||||
tmsgSendRsp(&rsp);
|
|
||||||
} else {
|
} else {
|
||||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
code = -1;
|
code = -1;
|
||||||
|
@ -575,10 +571,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
|
||||||
code = syncSetStandby(pMgmt->sync);
|
|
||||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
|
||||||
tmsgSendRsp(&rsp);
|
|
||||||
} else {
|
} else {
|
||||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
code = -1;
|
code = -1;
|
||||||
|
|
|
@ -56,8 +56,6 @@ int32_t mndInitMnode(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_SYNC_SET_MNODE_STANDBY_RSP, mndTransProcessRsp);
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_SYNC_SET_VNODE_STANDBY_RSP, mndTransProcessRsp);
|
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
||||||
|
|
|
@ -239,6 +239,7 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
pTask->fillHistory = pStream->fillHistory;
|
||||||
mndAddTaskToTaskSet(tasks, pTask);
|
mndAddTaskToTaskSet(tasks, pTask);
|
||||||
|
|
||||||
pTask->nodeId = pVgroup->vgId;
|
pTask->nodeId = pVgroup->vgId;
|
||||||
|
@ -270,6 +271,7 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
pTask->fillHistory = pStream->fillHistory;
|
||||||
mndAddTaskToTaskSet(tasks, pTask);
|
mndAddTaskToTaskSet(tasks, pTask);
|
||||||
|
|
||||||
ASSERT(pStream->fixedSinkVg.vgId == pStream->fixedSinkVgId);
|
ASSERT(pStream->fixedSinkVg.vgId == pStream->fixedSinkVgId);
|
||||||
|
@ -356,6 +358,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
pInnerTask->fillHistory = pStream->fillHistory;
|
||||||
mndAddTaskToTaskSet(taskInnerLevel, pInnerTask);
|
mndAddTaskToTaskSet(taskInnerLevel, pInnerTask);
|
||||||
|
|
||||||
pInnerTask->childEpInfo = taosArrayInit(0, sizeof(void*));
|
pInnerTask->childEpInfo = taosArrayInit(0, sizeof(void*));
|
||||||
|
@ -422,6 +425,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
pTask->fillHistory = pStream->fillHistory;
|
||||||
mndAddTaskToTaskSet(taskSourceLevel, pTask);
|
mndAddTaskToTaskSet(taskSourceLevel, pTask);
|
||||||
|
|
||||||
pTask->triggerParam = 0;
|
pTask->triggerParam = 0;
|
||||||
|
|
|
@ -454,7 +454,7 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans,
|
||||||
pVgroup->pTsma = pSmaReq;
|
pVgroup->pTsma = pSmaReq;
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildCreateVnodeReq(pMnode, pDnode, pDb, pVgroup, &contLen, false);
|
void *pReq = mndBuildCreateVnodeReq(pMnode, pDnode, pDb, pVgroup, &contLen);
|
||||||
taosMemoryFreeClear(pSmaReq);
|
taosMemoryFreeClear(pSmaReq);
|
||||||
if (pReq == NULL) return -1;
|
if (pReq == NULL) return -1;
|
||||||
|
|
||||||
|
|
|
@ -143,8 +143,10 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, buf, tlen + 1);
|
tDecoderInit(&decoder, buf, tlen + 1);
|
||||||
if (tDecodeSStreamObj(&decoder, pStream) < 0) {
|
if (tDecodeSStreamObj(&decoder, pStream) < 0) {
|
||||||
|
tDecoderClear(&decoder);
|
||||||
goto STREAM_DECODE_OVER;
|
goto STREAM_DECODE_OVER;
|
||||||
}
|
}
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -280,6 +282,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
||||||
pObj->trigger = pCreate->triggerType;
|
pObj->trigger = pCreate->triggerType;
|
||||||
pObj->triggerParam = pCreate->maxDelay;
|
pObj->triggerParam = pCreate->maxDelay;
|
||||||
pObj->watermark = pCreate->watermark;
|
pObj->watermark = pCreate->watermark;
|
||||||
|
pObj->fillHistory = pCreate->fillHistory;
|
||||||
|
|
||||||
memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN);
|
memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN);
|
||||||
SDbObj *pSourceDb = mndAcquireDb(pMnode, pCreate->sourceDB);
|
SDbObj *pSourceDb = mndAcquireDb(pMnode, pCreate->sourceDB);
|
||||||
|
@ -686,7 +689,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); // hack way
|
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb);
|
||||||
mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name);
|
mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name);
|
||||||
|
|
||||||
// create stb for stream
|
// create stb for stream
|
||||||
|
|
|
@ -323,7 +323,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||||
action.pRaw = taosMemoryMalloc(dataLen);
|
action.pRaw = taosMemoryMalloc(dataLen);
|
||||||
if (action.pRaw == NULL) goto _OVER;
|
if (action.pRaw == NULL) goto _OVER;
|
||||||
mTrace("raw:%p, is created", pData);
|
mTrace("raw:%p, is created", action.pRaw);
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
action.pRaw = NULL;
|
action.pRaw = NULL;
|
||||||
|
|
|
@ -196,8 +196,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen,
|
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
||||||
bool standby) {
|
|
||||||
SCreateVnodeReq createReq = {0};
|
SCreateVnodeReq createReq = {0};
|
||||||
createReq.vgId = pVgroup->vgId;
|
createReq.vgId = pVgroup->vgId;
|
||||||
memcpy(createReq.db, pDb->name, TSDB_DB_FNAME_LEN);
|
memcpy(createReq.db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
|
@ -227,7 +226,6 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
||||||
createReq.hashMethod = pDb->cfg.hashMethod;
|
createReq.hashMethod = pDb->cfg.hashMethod;
|
||||||
createReq.numOfRetensions = pDb->cfg.numOfRetensions;
|
createReq.numOfRetensions = pDb->cfg.numOfRetensions;
|
||||||
createReq.pRetensions = pDb->cfg.pRetensions;
|
createReq.pRetensions = pDb->cfg.pRetensions;
|
||||||
createReq.standby = standby;
|
|
||||||
createReq.isTsma = pVgroup->isTsma;
|
createReq.isTsma = pVgroup->isTsma;
|
||||||
createReq.pTsma = pVgroup->pTsma;
|
createReq.pTsma = pVgroup->pTsma;
|
||||||
createReq.walRetentionPeriod = pDb->cfg.walRetentionPeriod;
|
createReq.walRetentionPeriod = pDb->cfg.walRetentionPeriod;
|
||||||
|
@ -279,8 +277,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
||||||
SAlterVnodeReq alterReq = {0};
|
SAlterVnodeConfigReq alterReq = {0};
|
||||||
alterReq.vgVersion = pVgroup->version;
|
alterReq.vgVersion = pVgroup->version;
|
||||||
alterReq.buffer = pDb->cfg.buffer;
|
alterReq.buffer = pDb->cfg.buffer;
|
||||||
alterReq.pageSize = pDb->cfg.pageSize;
|
alterReq.pageSize = pDb->cfg.pageSize;
|
||||||
|
@ -294,7 +292,37 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_
|
||||||
alterReq.walLevel = pDb->cfg.walLevel;
|
alterReq.walLevel = pDb->cfg.walLevel;
|
||||||
alterReq.strict = pDb->cfg.strict;
|
alterReq.strict = pDb->cfg.strict;
|
||||||
alterReq.cacheLast = pDb->cfg.cacheLast;
|
alterReq.cacheLast = pDb->cfg.cacheLast;
|
||||||
alterReq.replica = pVgroup->replica;
|
|
||||||
|
int32_t contLen = tSerializeSAlterVnodeConfigReq(NULL, 0, &alterReq);
|
||||||
|
if (contLen < 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
contLen += sizeof(SMsgHead);
|
||||||
|
|
||||||
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SMsgHead *pHead = pReq;
|
||||||
|
pHead->contLen = htonl(contLen);
|
||||||
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
|
tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq);
|
||||||
|
*pContLen = contLen;
|
||||||
|
return pReq;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t dnodeId,
|
||||||
|
int32_t *pContLen) {
|
||||||
|
SAlterVnodeReplicaReq alterReq = {
|
||||||
|
alterReq.vgId = pVgroup->vgId,
|
||||||
|
alterReq.strict = pDb->cfg.strict,
|
||||||
|
alterReq.replica = pVgroup->replica,
|
||||||
|
alterReq.selfIndex = -1,
|
||||||
|
};
|
||||||
|
|
||||||
for (int32_t v = 0; v < pVgroup->replica; ++v) {
|
for (int32_t v = 0; v < pVgroup->replica; ++v) {
|
||||||
SReplica *pReplica = &alterReq.replicas[v];
|
SReplica *pReplica = &alterReq.replicas[v];
|
||||||
|
@ -308,14 +336,22 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_
|
||||||
pReplica->port = pVgidDnode->port;
|
pReplica->port = pVgidDnode->port;
|
||||||
memcpy(pReplica->fqdn, pVgidDnode->fqdn, TSDB_FQDN_LEN);
|
memcpy(pReplica->fqdn, pVgidDnode->fqdn, TSDB_FQDN_LEN);
|
||||||
mndReleaseDnode(pMnode, pVgidDnode);
|
mndReleaseDnode(pMnode, pVgidDnode);
|
||||||
|
|
||||||
|
if (dnodeId == pVgid->dnodeId) {
|
||||||
|
alterReq.selfIndex = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterVnodeReq(NULL, 0, &alterReq);
|
if (alterReq.selfIndex == -1) {
|
||||||
|
terrno = TSDB_CODE_MND_APP_ERROR;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSAlterVnodeReplicaReq(NULL, 0, &alterReq);
|
||||||
if (contLen < 0) {
|
if (contLen < 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
contLen += sizeof(SMsgHead);
|
|
||||||
|
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
|
@ -323,38 +359,7 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgHead *pHead = pReq;
|
tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq);
|
||||||
pHead->contLen = htonl(contLen);
|
|
||||||
pHead->vgId = htonl(pVgroup->vgId);
|
|
||||||
|
|
||||||
tSerializeSAlterVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq);
|
|
||||||
*pContLen = contLen;
|
|
||||||
return pReq;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *mndBuildSetVnodeStandbyReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
|
||||||
SSetStandbyReq standbyReq = {0};
|
|
||||||
standbyReq.dnodeId = pDnode->id;
|
|
||||||
standbyReq.standby = 1;
|
|
||||||
|
|
||||||
int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq);
|
|
||||||
if (contLen < 0) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
contLen += sizeof(SMsgHead);
|
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
|
||||||
if (pReq == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tSerializeSSetStandbyReq((char *)pReq + sizeof(SMsgHead), contLen, &standbyReq);
|
|
||||||
SMsgHead *pHead = pReq;
|
|
||||||
pHead->contLen = htonl(contLen);
|
|
||||||
pHead->vgId = htonl(pVgroup->vgId);
|
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
@ -948,8 +953,7 @@ _OVER:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid) {
|
||||||
bool standby) {
|
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||||
|
@ -958,7 +962,7 @@ int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVg
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildCreateVnodeReq(pMnode, pDnode, pDb, pVgroup, &contLen, standby);
|
void *pReq = mndBuildCreateVnodeReq(pMnode, pDnode, pDb, pVgroup, &contLen);
|
||||||
if (pReq == NULL) return -1;
|
if (pReq == NULL) return -1;
|
||||||
|
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
|
@ -1002,17 +1006,19 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType) {
|
int32_t mndAddAlterVnodeHashRangeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) { return 0; }
|
||||||
|
|
||||||
|
int32_t mndAddAlterVnodeConfigAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildAlterVnodeReq(pMnode, pDb, pVgroup, &contLen);
|
void *pReq = mndBuildAlterVnodeConfigReq(pMnode, pDb, pVgroup, &contLen);
|
||||||
if (pReq == NULL) return -1;
|
if (pReq == NULL) return -1;
|
||||||
|
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = msgType;
|
action.msgType = TDMT_VND_ALTER_CONFIG;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
|
@ -1022,37 +1028,26 @@ int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAddSetVnodeStandByAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
|
int32_t mndAddAlterVnodeReplicaAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int32_t dnodeId) {
|
||||||
SVnodeGid *pVgid, bool isRedo) {
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId);
|
||||||
STransAction action = {0};
|
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
|
||||||
if (pDnode == NULL) return -1;
|
if (pDnode == NULL) return -1;
|
||||||
|
|
||||||
|
STransAction action = {0};
|
||||||
action.epSet = mndGetDnodeEpset(pDnode);
|
action.epSet = mndGetDnodeEpset(pDnode);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildSetVnodeStandbyReq(pMnode, pDnode, pDb, pVgroup, &contLen);
|
void *pReq = mndBuildAlterVnodeReplicaReq(pMnode, pDb, pVgroup, dnodeId, &contLen);
|
||||||
if (pReq == NULL) return -1;
|
if (pReq == NULL) return -1;
|
||||||
|
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = TDMT_SYNC_SET_VNODE_STANDBY;
|
action.msgType = TDMT_VND_ALTER_REPLICA;
|
||||||
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
|
||||||
// Keep retrying until the target vnode is not the leader
|
|
||||||
action.retryCode = TSDB_CODE_SYN_IS_LEADER;
|
|
||||||
|
|
||||||
if (isRedo) {
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1102,8 +1097,8 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
|
|
||||||
mInfo("vgId:%d, will add 1 vnodes", pVgroup->vgId);
|
mInfo("vgId:%d, will add 1 vnodes", pVgroup->vgId);
|
||||||
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1], true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, -1) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
|
||||||
mInfo("vgId:%d, will remove 1 vnodes", pVgroup->vgId);
|
mInfo("vgId:%d, will remove 1 vnodes", pVgroup->vgId);
|
||||||
|
@ -1111,8 +1106,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||||
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del, true) != 0) return -1;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, -1) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
|
||||||
|
@ -1185,8 +1179,8 @@ static int32_t mndAddIncVgroupReplicaToTrans(SMnode *pMnode, STrans *pTrans, SDb
|
||||||
pGid->dnodeId = newDnodeId;
|
pGid->dnodeId = newDnodeId;
|
||||||
pGid->syncState = TAOS_SYNC_STATE_ERROR;
|
pGid->syncState = TAOS_SYNC_STATE_ERROR;
|
||||||
|
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pGid, true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pGid) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, pVgroup, -1) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1212,8 +1206,7 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
|
||||||
memcpy(pGid, &pVgroup->vnodeGid[pVgroup->replica], sizeof(SVnodeGid));
|
memcpy(pGid, &pVgroup->vnodeGid[pVgroup->replica], sizeof(SVnodeGid));
|
||||||
memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid));
|
memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid));
|
||||||
|
|
||||||
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, pVgroup, -1) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
||||||
|
|
||||||
|
@ -1573,43 +1566,39 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
||||||
memcpy(&newVgroup, pVgroup, sizeof(SVgObj));
|
memcpy(&newVgroup, pVgroup, sizeof(SVgObj));
|
||||||
|
|
||||||
if (pVgroup->replica <= 0 || pVgroup->replica == pNewDb->cfg.replications) {
|
if (pVgroup->replica <= 0 || pVgroup->replica == pNewDb->cfg.replications) {
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pNewDb, pVgroup, TDMT_VND_ALTER_CONFIG) != 0) return -1;
|
if (mndAddAlterVnodeConfigAction(pMnode, pTrans, pNewDb, pVgroup) != 0) return -1;
|
||||||
if (mndCheckDnodeMemory(pMnode, pOldDb, pNewDb, &newVgroup, pVgroup, pArray) != 0) return -1;
|
if (mndCheckDnodeMemory(pMnode, pOldDb, pNewDb, &newVgroup, pVgroup, pArray) != 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
|
|
||||||
if (newVgroup.replica < pNewDb->cfg.replications) {
|
if (newVgroup.replica == 1 && pNewDb->cfg.replications == 3) {
|
||||||
mInfo("db:%s, vgId:%d, vn:0 dnode:%d, will add 2 vnodes", pVgroup->dbName, pVgroup->vgId,
|
mInfo("db:%s, vgId:%d, will add 2 vnodes, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
||||||
pVgroup->vnodeGid[0].dnodeId);
|
pVgroup->vnodeGid[0].dnodeId);
|
||||||
|
|
||||||
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1], true) != 0) return -1;
|
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
|
||||||
|
|
||||||
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2], true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0)
|
||||||
|
return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
||||||
} else if (newVgroup.replica > pNewDb->cfg.replications) {
|
} else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) {
|
||||||
mInfo("db:%s, vgId:%d, will remove 2 vnodes", pVgroup->dbName, pVgroup->vgId);
|
mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName,
|
||||||
|
pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId);
|
||||||
|
|
||||||
SVnodeGid del1 = {0};
|
SVnodeGid del1 = {0};
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1;
|
|
||||||
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pNewDb, pVgroup, &del1, true) != 0) return -1;
|
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del1, true) != 0) return -1;
|
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
|
||||||
|
|
||||||
SVnodeGid del2 = {0};
|
SVnodeGid del2 = {0};
|
||||||
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1;
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1;
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1;
|
||||||
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pNewDb, pVgroup, &del2, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del1, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del2, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del2, true) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0)
|
||||||
|
return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1660,14 +1649,13 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
||||||
|
|
||||||
if (newVg1.replica == 1) {
|
if (newVg1.replica == 1) {
|
||||||
if (mndAddVnodeToVgroup(pMnode, &newVg1, pArray) != 0) goto _OVER;
|
if (mndAddVnodeToVgroup(pMnode, &newVg1, pArray) != 0) goto _OVER;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg1, &newVg1.vnodeGid[1], true) != 0) goto _OVER;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg1, &newVg1.vnodeGid[1]) != 0) goto _OVER;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, -1) != 0) goto _OVER;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
||||||
} else if (newVg1.replica == 3) {
|
} else if (newVg1.replica == 3) {
|
||||||
SVnodeGid del1 = {0};
|
SVnodeGid del1 = {0};
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER;
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER;
|
||||||
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) goto _OVER;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, -1) != 0) goto _OVER;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER;
|
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1685,8 +1673,8 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
||||||
memcpy(&newVg2.vnodeGid[0], &newVg2.vnodeGid[1], sizeof(SVnodeGid));
|
memcpy(&newVg2.vnodeGid[0], &newVg2.vnodeGid[1], sizeof(SVnodeGid));
|
||||||
memset(&newVg1.vnodeGid[1], 0, sizeof(SVnodeGid));
|
memset(&newVg1.vnodeGid[1], 0, sizeof(SVnodeGid));
|
||||||
|
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_HASHRANGE) != 0) goto _OVER;
|
if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg2, TDMT_VND_ALTER_HASHRANGE) != 0) goto _OVER;
|
if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, pDb, &newVg2) != 0) goto _OVER;
|
||||||
|
|
||||||
// adjust vgroup
|
// adjust vgroup
|
||||||
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER;
|
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER;
|
||||||
|
|
|
@ -50,6 +50,7 @@ extern const SVnodeCfg vnodeCfgDefault;
|
||||||
int32_t vnodeInit(int32_t nthreads);
|
int32_t vnodeInit(int32_t nthreads);
|
||||||
void vnodeCleanup();
|
void vnodeCleanup();
|
||||||
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
||||||
|
int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs);
|
||||||
void vnodeDestroy(const char *path, STfs *pTfs);
|
void vnodeDestroy(const char *path, STfs *pTfs);
|
||||||
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
||||||
void vnodePreClose(SVnode *pVnode);
|
void vnodePreClose(SVnode *pVnode);
|
||||||
|
|
|
@ -299,6 +299,11 @@ int32_t tsdbMerge(STsdb *pTsdb);
|
||||||
#define TSDB_CACHE_LAST(c) (((c).cacheLast & 2) > 0)
|
#define TSDB_CACHE_LAST(c) (((c).cacheLast & 2) > 0)
|
||||||
|
|
||||||
// tsdbCache ==============================================================================================
|
// tsdbCache ==============================================================================================
|
||||||
|
typedef struct {
|
||||||
|
TSKEY ts;
|
||||||
|
SColVal colVal;
|
||||||
|
} SLastCol;
|
||||||
|
|
||||||
int32_t tsdbOpenCache(STsdb *pTsdb);
|
int32_t tsdbOpenCache(STsdb *pTsdb);
|
||||||
void tsdbCloseCache(STsdb *pTsdb);
|
void tsdbCloseCache(STsdb *pTsdb);
|
||||||
int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb *pTsdb);
|
int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb *pTsdb);
|
||||||
|
|
|
@ -211,6 +211,7 @@ int32_t smaSyncCommit(SSma* pSma);
|
||||||
int32_t smaSyncPostCommit(SSma* pSma);
|
int32_t smaSyncPostCommit(SSma* pSma);
|
||||||
int32_t smaPreCommit(SSma* pSma);
|
int32_t smaPreCommit(SSma* pSma);
|
||||||
int32_t smaCommit(SSma* pSma);
|
int32_t smaCommit(SSma* pSma);
|
||||||
|
int32_t smaFinishCommit(SSma* pSma);
|
||||||
int32_t smaPostCommit(SSma* pSma);
|
int32_t smaPostCommit(SSma* pSma);
|
||||||
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ _err2:
|
||||||
_err:
|
_err:
|
||||||
taosMemoryFree(pCache);
|
taosMemoryFree(pCache);
|
||||||
|
|
||||||
metaError("vgId:%d meta open cache failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
metaError("vgId:%d, meta open cache failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,38 +78,69 @@ int32_t smaCommit(SSma *pSma) { return tdProcessRSmaAsyncCommitImpl(pSma); }
|
||||||
int32_t smaPostCommit(SSma *pSma) { return tdProcessRSmaAsyncPostCommitImpl(pSma); }
|
int32_t smaPostCommit(SSma *pSma) { return tdProcessRSmaAsyncPostCommitImpl(pSma); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set rsma trigger stat active
|
* @brief prepare rsma1/2, and set rsma trigger stat active
|
||||||
*
|
*
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaBegin(SSma *pSma) {
|
int32_t smaBegin(SSma *pSma) {
|
||||||
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
int32_t code = 0;
|
||||||
if (!pSmaEnv) {
|
SVnode *pVnode = pSma->pVnode;
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
|
if ((code = tsdbBegin(VND_RSMA1(pVnode))) < 0) {
|
||||||
|
smaError("vgId:%d, failed to begin rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pSmaEnv);
|
if ((code = tsdbBegin(VND_RSMA2(pVnode))) < 0) {
|
||||||
|
smaError("vgId:%d, failed to begin rsma2 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set trigger stat
|
||||||
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
|
if (!pSmaEnv) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pSmaEnv);
|
||||||
int8_t rsmaTriggerStat =
|
int8_t rsmaTriggerStat =
|
||||||
atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED, TASK_TRIGGER_STAT_ACTIVE);
|
atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED, TASK_TRIGGER_STAT_ACTIVE);
|
||||||
switch (rsmaTriggerStat) {
|
switch (rsmaTriggerStat) {
|
||||||
case TASK_TRIGGER_STAT_PAUSED: {
|
case TASK_TRIGGER_STAT_PAUSED: {
|
||||||
smaDebug("vgId:%d, rsma trigger stat from paused to active", SMA_VID(pSma));
|
smaDebug("vgId:%d, rsma trigger stat from paused to active", TD_VID(pVnode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TASK_TRIGGER_STAT_INIT: {
|
case TASK_TRIGGER_STAT_INIT: {
|
||||||
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
||||||
smaDebug("vgId:%d, rsma trigger stat from init to active", SMA_VID(pSma));
|
smaDebug("vgId:%d, rsma trigger stat from init to active", TD_VID(pVnode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
||||||
smaError("vgId:%d, rsma trigger stat %" PRIi8 " is unexpected", SMA_VID(pSma), rsmaTriggerStat);
|
smaWarn("vgId:%d, rsma trigger stat %" PRIi8 " is unexpected", TD_VID(pVnode), rsmaTriggerStat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
_exit:
|
||||||
|
terrno = code;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t smaFinishCommit(SSma *pSma) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SVnode *pVnode = pSma->pVnode;
|
||||||
|
|
||||||
|
if (VND_RSMA1(pVnode) && (code = tsdbFinishCommit(VND_RSMA1(pVnode))) < 0) {
|
||||||
|
smaError("vgId:%d, failed to finish commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
if (VND_RSMA2(pVnode) && (code = tsdbFinishCommit(VND_RSMA2(pVnode))) < 0) {
|
||||||
|
smaError("vgId:%d, failed to finish commit tsdb rsma2 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
_exit:
|
||||||
|
terrno = code;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -309,15 +340,6 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
* 1) This is high cost task and should not put in asyncPreCommit originally.
|
* 1) This is high cost task and should not put in asyncPreCommit originally.
|
||||||
* 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently.
|
* 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently.
|
||||||
*/
|
*/
|
||||||
nLoops = 0;
|
|
||||||
while (atomic_load_64(&pRSmaStat->nBufItems) > 0) {
|
|
||||||
++nLoops;
|
|
||||||
if (nLoops > 1000) {
|
|
||||||
sched_yield();
|
|
||||||
nLoops = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma),
|
smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma),
|
||||||
(void *)taosGetSelfPthreadId());
|
(void *)taosGetSelfPthreadId());
|
||||||
nLoops = 0;
|
nLoops = 0;
|
||||||
|
@ -368,10 +390,6 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SVnode *pVnode = pSma->pVnode;
|
SVnode *pVnode = pSma->pVnode;
|
||||||
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
|
||||||
if (!pSmaEnv) {
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
#if 0
|
#if 0
|
||||||
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pSmaEnv);
|
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pSmaEnv);
|
||||||
|
|
||||||
|
@ -380,10 +398,7 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((code = tsdbCommit(VND_RSMA0(pVnode))) < 0) {
|
|
||||||
smaError("vgId:%d, failed to commit tsdb rsma0 since %s", TD_VID(pVnode), tstrerror(code));
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
if ((code = tsdbCommit(VND_RSMA1(pVnode))) < 0) {
|
if ((code = tsdbCommit(VND_RSMA1(pVnode))) < 0) {
|
||||||
smaError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
smaError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
|
|
@ -213,12 +213,12 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
|
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
|
||||||
tqDebug("vgId:%d tq push msg ver %" PRId64 ", type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType));
|
tqDebug("vgId:%d, tq push msg ver %" PRId64 ", type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType));
|
||||||
|
|
||||||
if (msgType == TDMT_VND_SUBMIT) {
|
if (msgType == TDMT_VND_SUBMIT) {
|
||||||
// lock push mgr to avoid potential msg lost
|
// lock push mgr to avoid potential msg lost
|
||||||
taosWLockLatch(&pTq->pushLock);
|
taosWLockLatch(&pTq->pushLock);
|
||||||
tqDebug("vgId:%d push handle num %d", pTq->pVnode->config.vgId, taosHashGetSize(pTq->pPushMgr));
|
tqDebug("vgId:%d, push handle num %d", pTq->pVnode->config.vgId, taosHashGetSize(pTq->pPushMgr));
|
||||||
if (taosHashGetSize(pTq->pPushMgr) != 0) {
|
if (taosHashGetSize(pTq->pPushMgr) != 0) {
|
||||||
SArray* cachedKeys = taosArrayInit(0, sizeof(void*));
|
SArray* cachedKeys = taosArrayInit(0, sizeof(void*));
|
||||||
SArray* cachedKeyLens = taosArrayInit(0, sizeof(size_t));
|
SArray* cachedKeyLens = taosArrayInit(0, sizeof(size_t));
|
||||||
|
@ -242,11 +242,11 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
|
|
||||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, pPushEntry->subKey, strlen(pPushEntry->subKey));
|
STqHandle* pHandle = taosHashGet(pTq->pHandle, pPushEntry->subKey, strlen(pPushEntry->subKey));
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
tqDebug("vgId:%d cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey);
|
tqDebug("vgId:%d, cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pPushEntry->dataRsp.reqOffset.version >= ver) {
|
if (pPushEntry->dataRsp.reqOffset.version >= ver) {
|
||||||
tqDebug("vgId:%d push entry req version %" PRId64 ", while push version %" PRId64 ", skip",
|
tqDebug("vgId:%d, push entry req version %" PRId64 ", while push version %" PRId64 ", skip",
|
||||||
pTq->pVnode->config.vgId, pPushEntry->dataRsp.reqOffset.version, ver);
|
pTq->pVnode->config.vgId, pPushEntry->dataRsp.reqOffset.version, ver);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
pRsp->blockNum++;
|
pRsp->blockNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("vgId:%d tq handle push, subkey: %s, block num: %d", pTq->pVnode->config.vgId, pPushEntry->subKey,
|
tqDebug("vgId:%d, tq handle push, subkey: %s, block num: %d", pTq->pVnode->config.vgId, pPushEntry->subKey,
|
||||||
pRsp->blockNum);
|
pRsp->blockNum);
|
||||||
if (pRsp->blockNum > 0) {
|
if (pRsp->blockNum > 0) {
|
||||||
// set offset
|
// set offset
|
||||||
|
|
|
@ -52,13 +52,13 @@ int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapReader** p
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqInfo("vgId:%d vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
tqInfo("vgId:%d, vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
*ppReader = pReader;
|
*ppReader = pReader;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -113,14 +113,14 @@ int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||||
pHdr->size = vLen;
|
pHdr->size = vLen;
|
||||||
memcpy(pHdr->data, pVal, vLen);
|
memcpy(pHdr->data, pVal, vLen);
|
||||||
|
|
||||||
tqInfo("vgId:%d vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
tqInfo("vgId:%d, vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
||||||
handle.snapshotVer, handle.subKey, vLen);
|
handle.snapshotVer, handle.subKey, vLen);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,6 @@ int32_t tqSnapWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(pDecoder);
|
tDecoderClear(pDecoder);
|
||||||
tqError("vgId:%d vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,13 +52,13 @@ int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapReader** p
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqInfo("vgId:%d vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
tqInfo("vgId:%d, vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
*ppReader = pReader;
|
*ppReader = pReader;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -113,14 +113,14 @@ int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||||
pHdr->size = vLen;
|
pHdr->size = vLen;
|
||||||
memcpy(pHdr->data, pVal, vLen);
|
memcpy(pHdr->data, pVal, vLen);
|
||||||
|
|
||||||
tqInfo("vgId:%d vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
tqInfo("vgId:%d, vnode snapshot tq read data, version:%" PRId64 " subKey: %s vLen:%d", TD_VID(pReader->pTq->pVnode),
|
||||||
handle.snapshotVer, handle.subKey, vLen);
|
handle.snapshotVer, handle.subKey, vLen);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pWriter->pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,6 @@ int32_t tqSnapWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(pDecoder);
|
tDecoderClear(pDecoder);
|
||||||
tqError("vgId:%d vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode snapshot tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,6 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
TSKEY ts;
|
|
||||||
SColVal colVal;
|
|
||||||
} SLastCol;
|
|
||||||
|
|
||||||
int32_t tsdbOpenCache(STsdb *pTsdb) {
|
int32_t tsdbOpenCache(STsdb *pTsdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SLRUCache *pCache = NULL;
|
SLRUCache *pCache = NULL;
|
||||||
|
@ -61,9 +56,18 @@ static void getTableCacheKey(tb_uid_t uid, int cacheType, char *key, int *len) {
|
||||||
*len = sizeof(uint64_t);
|
*len = sizeof(uint64_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deleteTableCacheLastrow(const void *key, size_t keyLen, void *value) { taosMemoryFree(value); }
|
static void deleteTableCacheLast(const void *key, size_t keyLen, void *value) {
|
||||||
|
SArray *pLastArray = (SArray *)value;
|
||||||
|
int16_t nCol = taosArrayGetSize(pLastArray);
|
||||||
|
for (int16_t iCol = 0; iCol < nCol; ++iCol) {
|
||||||
|
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLastArray, iCol);
|
||||||
|
if (IS_VAR_DATA_TYPE(pLastCol->colVal.type) && pLastCol->colVal.value.nData > 0) {
|
||||||
|
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void deleteTableCacheLast(const void *key, size_t keyLen, void *value) { taosArrayDestroy(value); }
|
taosArrayDestroy(value);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
|
int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -75,13 +79,23 @@ int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
|
||||||
getTableCacheKey(uid, 0, key, &keyLen);
|
getTableCacheKey(uid, 0, key, &keyLen);
|
||||||
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
||||||
if (h) {
|
if (h) {
|
||||||
STSRow *pRow = (STSRow *)taosLRUCacheValue(pCache, h);
|
SArray *pLast = (SArray *)taosLRUCacheValue(pCache, h);
|
||||||
if (pRow->ts <= eKey) {
|
bool invalidate = false;
|
||||||
|
int16_t nCol = taosArrayGetSize(pLast);
|
||||||
|
|
||||||
|
for (int16_t iCol = 0; iCol < nCol; ++iCol) {
|
||||||
|
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
|
if (eKey >= tTsVal->ts) {
|
||||||
|
invalidate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invalidate) {
|
||||||
taosLRUCacheRelease(pCache, h, true);
|
taosLRUCacheRelease(pCache, h, true);
|
||||||
} else {
|
} else {
|
||||||
taosLRUCacheRelease(pCache, h, false);
|
taosLRUCacheRelease(pCache, h, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
|
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,14 +144,23 @@ int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
|
||||||
getTableCacheKey(uid, 0, key, &keyLen);
|
getTableCacheKey(uid, 0, key, &keyLen);
|
||||||
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
||||||
if (h) {
|
if (h) {
|
||||||
STSRow *pRow = (STSRow *)taosLRUCacheValue(pCache, h);
|
SArray *pLast = (SArray *)taosLRUCacheValue(pCache, h);
|
||||||
if (pRow->ts <= eKey) {
|
bool invalidate = false;
|
||||||
|
int16_t nCol = taosArrayGetSize(pLast);
|
||||||
|
|
||||||
|
for (int16_t iCol = 0; iCol < nCol; ++iCol) {
|
||||||
|
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
|
if (eKey >= tTsVal->ts) {
|
||||||
|
invalidate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invalidate) {
|
||||||
taosLRUCacheRelease(pCache, h, true);
|
taosLRUCacheRelease(pCache, h, true);
|
||||||
} else {
|
} else {
|
||||||
taosLRUCacheRelease(pCache, h, false);
|
taosLRUCacheRelease(pCache, h, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTableCacheKey(uid, "l", key, &keyLen);
|
// getTableCacheKey(uid, "l", key, &keyLen);
|
||||||
|
@ -177,6 +200,46 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
|
||||||
getTableCacheKey(uid, 0, key, &keyLen);
|
getTableCacheKey(uid, 0, key, &keyLen);
|
||||||
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
|
||||||
if (h) {
|
if (h) {
|
||||||
|
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1, 1);
|
||||||
|
TSKEY keyTs = row->ts;
|
||||||
|
bool invalidate = false;
|
||||||
|
|
||||||
|
SArray *pLast = (SArray *)taosLRUCacheValue(pCache, h);
|
||||||
|
int16_t nCol = taosArrayGetSize(pLast);
|
||||||
|
int16_t iCol = 0;
|
||||||
|
|
||||||
|
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
|
if (keyTs > tTsVal->ts) {
|
||||||
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
SColVal tColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = keyTs});
|
||||||
|
|
||||||
|
taosArraySet(pLast, iCol, &(SLastCol){.ts = keyTs, .colVal = tColVal});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (++iCol; iCol < nCol; ++iCol) {
|
||||||
|
SLastCol *tTsVal1 = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
|
if (keyTs >= tTsVal1->ts) {
|
||||||
|
SColVal *tColVal = &tTsVal1->colVal;
|
||||||
|
|
||||||
|
SColVal colVal = {0};
|
||||||
|
tTSRowGetVal(row, pTSchema, iCol, &colVal);
|
||||||
|
if (!COL_VAL_IS_NONE(&colVal)) {
|
||||||
|
if (keyTs == tTsVal1->ts && !COL_VAL_IS_NONE(tColVal)) {
|
||||||
|
invalidate = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
taosArraySet(pLast, iCol, &(SLastCol){.ts = keyTs, .colVal = colVal});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_invalidate:
|
||||||
|
taosMemoryFreeClear(pTSchema);
|
||||||
|
|
||||||
|
taosLRUCacheRelease(pCache, h, invalidate);
|
||||||
|
/*
|
||||||
cacheRow = (STSRow *)taosLRUCacheValue(pCache, h);
|
cacheRow = (STSRow *)taosLRUCacheValue(pCache, h);
|
||||||
if (row->ts >= cacheRow->ts) {
|
if (row->ts >= cacheRow->ts) {
|
||||||
if (row->ts == cacheRow->ts) {
|
if (row->ts == cacheRow->ts) {
|
||||||
|
@ -218,9 +281,9 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
|
||||||
if (status != TAOS_LRU_STATUS_OK) {
|
if (status != TAOS_LRU_STATUS_OK) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
/* tsdbCacheInsertLastrow(pCache, uid, row, dup); */
|
// tsdbCacheInsertLastrow(pCache, uid, row, dup);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
} /*else {
|
} /*else {
|
||||||
if (dup) {
|
if (dup) {
|
||||||
cacheRow = tdRowDup(row);
|
cacheRow = tdRowDup(row);
|
||||||
|
@ -456,6 +519,11 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state->pDataFReader != NULL) {
|
||||||
|
tsdbDataFReaderClose(&state->pDataFReader);
|
||||||
|
state->pDataFReader = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
code = tsdbDataFReaderOpen(&state->pDataFReader, state->pTsdb, pFileSet);
|
code = tsdbDataFReaderOpen(&state->pDataFReader, state->pTsdb, pFileSet);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
|
@ -599,6 +667,8 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
||||||
*/
|
*/
|
||||||
state->pBlockIdx = taosArraySearch(state->aBlockIdx, state->pBlockIdxExp, tCmprBlockIdx, TD_EQ);
|
state->pBlockIdx = taosArraySearch(state->aBlockIdx, state->pBlockIdxExp, tCmprBlockIdx, TD_EQ);
|
||||||
if (!state->pBlockIdx) {
|
if (!state->pBlockIdx) {
|
||||||
|
tsdbDataFReaderClose(&state->pDataFReader);
|
||||||
|
state->pDataFReader = NULL;
|
||||||
goto _next_fileset;
|
goto _next_fileset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,7 +1119,7 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) {
|
static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppColArray) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1, 1);
|
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1, 1);
|
||||||
|
@ -1057,7 +1127,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
int16_t iCol = 0;
|
int16_t iCol = 0;
|
||||||
int16_t noneCol = 0;
|
int16_t noneCol = 0;
|
||||||
bool setNoneCol = false;
|
bool setNoneCol = false;
|
||||||
SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol));
|
||||||
SColVal *pColVal = &(SColVal){0};
|
SColVal *pColVal = &(SColVal){0};
|
||||||
|
|
||||||
TSKEY lastRowTs = TSKEY_MAX;
|
TSKEY lastRowTs = TSKEY_MAX;
|
||||||
|
@ -1073,12 +1143,15 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSKEY rowTs = TSDBROW_TS(pRow);
|
||||||
|
|
||||||
if (lastRowTs == TSKEY_MAX) {
|
if (lastRowTs == TSKEY_MAX) {
|
||||||
lastRowTs = TSDBROW_TS(pRow);
|
lastRowTs = rowTs;
|
||||||
STColumn *pTColumn = &pTSchema->columns[0];
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
|
||||||
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = lastRowTs});
|
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = lastRowTs});
|
||||||
if (taosArrayPush(pColArray, pColVal) == NULL) {
|
if (taosArrayPush(pColArray, &(SLastCol){.ts = lastRowTs, .colVal = *pColVal}) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1086,7 +1159,18 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
for (iCol = 1; iCol < nCol; ++iCol) {
|
for (iCol = 1; iCol < nCol; ++iCol) {
|
||||||
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
||||||
|
|
||||||
if (taosArrayPush(pColArray, pColVal) == NULL) {
|
SLastCol lastCol = {.ts = lastRowTs, .colVal = *pColVal};
|
||||||
|
if (IS_VAR_DATA_TYPE(pColVal->type) && pColVal->value.nData > 0) {
|
||||||
|
lastCol.colVal.value.pData = taosMemoryMalloc(lastCol.colVal.value.nData);
|
||||||
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
memcpy(lastCol.colVal.value.pData, pColVal->value.pData, pColVal->value.nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayPush(pColArray, &lastCol) == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1097,15 +1181,15 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!setNoneCol) {
|
if (!setNoneCol) {
|
||||||
// goto build the result ts row
|
// done, goto return pColArray
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((TSDBROW_TS(pRow) < lastRowTs)) {
|
if ((rowTs < lastRowTs)) {
|
||||||
// goto build the result ts row
|
// done, goto return pColArray
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1117,7 +1201,21 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
|
|
||||||
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
||||||
if (COL_VAL_IS_NONE(tColVal) && !COL_VAL_IS_NONE(pColVal)) {
|
if (COL_VAL_IS_NONE(tColVal) && !COL_VAL_IS_NONE(pColVal)) {
|
||||||
taosArraySet(pColArray, iCol, pColVal);
|
SLastCol lastCol = {.ts = rowTs, .colVal = *pColVal};
|
||||||
|
if (IS_VAR_DATA_TYPE(pColVal->type) && pColVal->value.nData > 0) {
|
||||||
|
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol);
|
||||||
|
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||||
|
|
||||||
|
lastCol.colVal.value.pData = taosMemoryMalloc(lastCol.colVal.value.nData);
|
||||||
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
memcpy(lastCol.colVal.value.pData, pColVal->value.pData, pColVal->value.nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArraySet(pColArray, iCol, &lastCol);
|
||||||
} else if (COL_VAL_IS_NONE(tColVal) && COL_VAL_IS_NONE(pColVal) && !setNoneCol) {
|
} else if (COL_VAL_IS_NONE(tColVal) && COL_VAL_IS_NONE(pColVal) && !setNoneCol) {
|
||||||
noneCol = iCol;
|
noneCol = iCol;
|
||||||
setNoneCol = true;
|
setNoneCol = true;
|
||||||
|
@ -1127,15 +1225,14 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
|
||||||
|
|
||||||
// build the result ts row here
|
// build the result ts row here
|
||||||
*dup = false;
|
*dup = false;
|
||||||
if (taosArrayGetSize(pColArray) == nCol) {
|
if (taosArrayGetSize(pColArray) != nCol) {
|
||||||
code = tdSTSRowNew(pColArray, pTSchema, ppRow);
|
*ppColArray = NULL;
|
||||||
if (code) goto _err;
|
taosArrayDestroy(pColArray);
|
||||||
} else {
|
} else {
|
||||||
*ppRow = NULL;
|
*ppColArray = pColArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextRowIterClose(&iter);
|
nextRowIterClose(&iter);
|
||||||
taosArrayDestroy(pColArray);
|
|
||||||
taosMemoryFreeClear(pTSchema);
|
taosMemoryFreeClear(pTSchema);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
@ -1185,7 +1282,18 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||||
for (iCol = 1; iCol < nCol; ++iCol) {
|
for (iCol = 1; iCol < nCol; ++iCol) {
|
||||||
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
||||||
|
|
||||||
if (taosArrayPush(pColArray, &(SLastCol){.ts = lastRowTs, .colVal = *pColVal}) == NULL) {
|
SLastCol lastCol = {.ts = lastRowTs, .colVal = *pColVal};
|
||||||
|
if (IS_VAR_DATA_TYPE(pColVal->type) && pColVal->value.nData > 0) {
|
||||||
|
lastCol.colVal.value.pData = taosMemoryMalloc(lastCol.colVal.value.nData);
|
||||||
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
memcpy(lastCol.colVal.value.pData, pColVal->value.pData, pColVal->value.nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayPush(pColArray, &lastCol) == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1196,7 +1304,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!setNoneCol) {
|
if (!setNoneCol) {
|
||||||
// goto build the result ts row
|
// done, goto return pColArray
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1207,11 +1315,26 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||||
setNoneCol = false;
|
setNoneCol = false;
|
||||||
for (iCol = noneCol; iCol < nCol; ++iCol) {
|
for (iCol = noneCol; iCol < nCol; ++iCol) {
|
||||||
// high version's column value
|
// high version's column value
|
||||||
SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, iCol);
|
SLastCol *lastColVal = (SLastCol *)taosArrayGet(pColArray, iCol);
|
||||||
|
SColVal *tColVal = &lastColVal->colVal;
|
||||||
|
|
||||||
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal);
|
||||||
if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) {
|
if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) {
|
||||||
taosArraySet(pColArray, iCol, &(SLastCol){.ts = rowTs, .colVal = *pColVal});
|
SLastCol lastCol = {.ts = rowTs, .colVal = *pColVal};
|
||||||
|
if (IS_VAR_DATA_TYPE(pColVal->type) && pColVal->value.nData > 0) {
|
||||||
|
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol);
|
||||||
|
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||||
|
|
||||||
|
lastCol.colVal.value.pData = taosMemoryMalloc(lastCol.colVal.value.nData);
|
||||||
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
memcpy(lastCol.colVal.value.pData, pColVal->value.pData, pColVal->value.nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArraySet(pColArray, iCol, &lastCol);
|
||||||
} else if (!COL_VAL_IS_VALUE(tColVal) && !COL_VAL_IS_VALUE(pColVal) && !setNoneCol) {
|
} else if (!COL_VAL_IS_VALUE(tColVal) && !COL_VAL_IS_VALUE(pColVal) && !setNoneCol) {
|
||||||
noneCol = iCol;
|
noneCol = iCol;
|
||||||
setNoneCol = true;
|
setNoneCol = true;
|
||||||
|
@ -1219,7 +1342,6 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||||
}
|
}
|
||||||
} while (setNoneCol);
|
} while (setNoneCol);
|
||||||
|
|
||||||
// build the result ts row here
|
|
||||||
if (taosArrayGetSize(pColArray) <= 0) {
|
if (taosArrayGetSize(pColArray) <= 0) {
|
||||||
*ppLastArray = NULL;
|
*ppLastArray = NULL;
|
||||||
taosArrayDestroy(pColArray);
|
taosArrayDestroy(pColArray);
|
||||||
|
@ -1252,13 +1374,13 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH
|
||||||
|
|
||||||
h = taosLRUCacheLookup(pCache, key, keyLen);
|
h = taosLRUCacheLookup(pCache, key, keyLen);
|
||||||
if (!h) {
|
if (!h) {
|
||||||
STSRow *pRow = NULL;
|
SArray *pArray = NULL;
|
||||||
bool dup = false; // which is always false for now
|
bool dup = false; // which is always false for now
|
||||||
code = mergeLastRow(uid, pTsdb, &dup, &pRow);
|
code = mergeLastRow(uid, pTsdb, &dup, &pArray);
|
||||||
// if table's empty or error, return code of -1
|
// if table's empty or error, return code of -1
|
||||||
if (code < 0 || pRow == NULL) {
|
if (code < 0 || pArray == NULL) {
|
||||||
if (!dup && pRow) {
|
if (!dup && pArray) {
|
||||||
taosMemoryFree(pRow);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
|
@ -1268,9 +1390,9 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_taos_lru_deleter_t deleter = deleteTableCacheLastrow;
|
size_t charge = pArray->capacity * pArray->elemSize + sizeof(*pArray);
|
||||||
LRUStatus status =
|
_taos_lru_deleter_t deleter = deleteTableCacheLast;
|
||||||
taosLRUCacheInsert(pCache, key, keyLen, pRow, TD_ROW_LEN(pRow), deleter, NULL, TAOS_LRU_PRIORITY_LOW);
|
LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, pArray, charge, deleter, NULL, TAOS_LRU_PRIORITY_LOW);
|
||||||
if (status != TAOS_LRU_STATUS_OK) {
|
if (status != TAOS_LRU_STATUS_OK) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
@ -1328,15 +1450,17 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
|
||||||
SArray *pLastArray = NULL;
|
SArray *pLastArray = NULL;
|
||||||
code = mergeLast(uid, pTsdb, &pLastArray);
|
code = mergeLast(uid, pTsdb, &pLastArray);
|
||||||
// if table's empty or error, return code of -1
|
// if table's empty or error, return code of -1
|
||||||
// if (code < 0 || pRow == NULL) {
|
|
||||||
if (code < 0 || pLastArray == NULL) {
|
if (code < 0 || pLastArray == NULL) {
|
||||||
|
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
|
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t charge = pLastArray->capacity * pLastArray->elemSize + sizeof(*pLastArray);
|
||||||
_taos_lru_deleter_t deleter = deleteTableCacheLast;
|
_taos_lru_deleter_t deleter = deleteTableCacheLast;
|
||||||
LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, pLastArray, pLastArray->capacity, deleter, NULL,
|
LRUStatus status =
|
||||||
TAOS_LRU_PRIORITY_LOW);
|
taosLRUCacheInsert(pCache, key, keyLen, pLastArray, charge, deleter, NULL, TAOS_LRU_PRIORITY_LOW);
|
||||||
if (status != TAOS_LRU_STATUS_OK) {
|
if (status != TAOS_LRU_STATUS_OK) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,31 +29,71 @@ typedef struct SCacheRowsReader {
|
||||||
SArray* pTableList; // table id list
|
SArray* pTableList; // table id list
|
||||||
} SCacheRowsReader;
|
} SCacheRowsReader;
|
||||||
|
|
||||||
static void saveOneRow(STSRow* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds) {
|
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
||||||
|
|
||||||
|
static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||||
|
void** pRes) {
|
||||||
ASSERT(pReader->numOfCols <= taosArrayGetSize(pBlock->pDataBlock));
|
ASSERT(pReader->numOfCols <= taosArrayGetSize(pBlock->pDataBlock));
|
||||||
int32_t numOfRows = pBlock->info.rows;
|
int32_t numOfRows = pBlock->info.rows;
|
||||||
|
|
||||||
SColVal colVal = {0};
|
if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||||
|
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
SFirstLastRes* p = (SFirstLastRes*)varDataVal(pRes[i]);
|
||||||
|
|
||||||
|
if (slotIds[i] == -1) { // the primary timestamp
|
||||||
|
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, 0);
|
||||||
|
p->ts = pColVal->ts;
|
||||||
|
p->bytes = TSDB_KEYSIZE;
|
||||||
|
*(int64_t*)p->buf = pColVal->ts;
|
||||||
|
} else {
|
||||||
|
int32_t slotId = slotIds[i];
|
||||||
|
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId);
|
||||||
|
|
||||||
|
p->ts = pColVal->ts;
|
||||||
|
p->isNull = !COL_VAL_IS_VALUE(&pColVal->colVal);
|
||||||
|
if (!p->isNull) {
|
||||||
|
if (IS_VAR_DATA_TYPE(pColVal->colVal.type)) {
|
||||||
|
varDataSetLen(p->buf, pColVal->colVal.value.nData);
|
||||||
|
memcpy(varDataVal(p->buf), pColVal->colVal.value.pData, pColVal->colVal.value.nData);
|
||||||
|
p->bytes = pColVal->colVal.value.nData + VARSTR_HEADER_SIZE; // binary needs to plus the header size
|
||||||
|
} else {
|
||||||
|
memcpy(p->buf, &pColVal->colVal.value, pReader->pSchema->columns[slotId].bytes);
|
||||||
|
p->bytes = pReader->pSchema->columns[slotId].bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pColInfoData->info.bytes includes the VARSTR_HEADER_SIZE, need to substruct it
|
||||||
|
p->hasResult = true;
|
||||||
|
varDataSetLen(pRes[i], pColInfoData->info.bytes - VARSTR_HEADER_SIZE);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (const char*)pRes[i], false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT(HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW));
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
if (slotIds[i] == -1) {
|
if (slotIds[i] == -1) {
|
||||||
colDataAppend(pColInfoData, numOfRows, (const char*)&pRow->ts, false);
|
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, 0);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (const char*)&pColVal->ts, false);
|
||||||
} else {
|
} else {
|
||||||
int32_t slotId = slotIds[i];
|
int32_t slotId = slotIds[i];
|
||||||
|
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId);
|
||||||
|
SColVal* pVal = &pColVal->colVal;
|
||||||
|
|
||||||
tTSRowGetVal(pRow, pReader->pSchema, slotId, &colVal);
|
if (IS_VAR_DATA_TYPE(pColVal->colVal.type)) {
|
||||||
|
if (!COL_VAL_IS_VALUE(&pColVal->colVal)) {
|
||||||
if (IS_VAR_DATA_TYPE(colVal.type)) {
|
|
||||||
if (!COL_VAL_IS_VALUE(&colVal)) {
|
|
||||||
colDataAppendNULL(pColInfoData, numOfRows);
|
colDataAppendNULL(pColInfoData, numOfRows);
|
||||||
} else {
|
} else {
|
||||||
varDataSetLen(pReader->transferBuf[slotId], colVal.value.nData);
|
varDataSetLen(pReader->transferBuf[slotId], pVal->value.nData);
|
||||||
memcpy(varDataVal(pReader->transferBuf[slotId]), colVal.value.pData, colVal.value.nData);
|
memcpy(varDataVal(pReader->transferBuf[slotId]), pVal->value.pData, pVal->value.nData);
|
||||||
colDataAppend(pColInfoData, numOfRows, pReader->transferBuf[slotId], false);
|
colDataAppend(pColInfoData, numOfRows, pReader->transferBuf[slotId], false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pColInfoData, numOfRows, (const char*)&colVal.value, !COL_VAL_IS_VALUE(&colVal));
|
colDataAppend(pColInfoData, numOfRows, (const char*)&pVal->value.val, !COL_VAL_IS_VALUE(pVal));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,35 +158,36 @@ void* tsdbCacherowsReaderClose(void* pReader) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doExtractCacheRow(SCacheRowsReader* pr, SLRUCache* lruCache, uint64_t uid, STSRow** pRow,
|
static int32_t doExtractCacheRow(SCacheRowsReader* pr, SLRUCache* lruCache, uint64_t uid, SArray** pRow,
|
||||||
LRUHandle** h) {
|
LRUHandle** h) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if ((pr->type & CACHESCAN_RETRIEVE_LAST_ROW) == CACHESCAN_RETRIEVE_LAST_ROW) {
|
*pRow = NULL;
|
||||||
code = tsdbCacheGetLastrowH(lruCache, uid, pr->pVnode->pTsdb, h);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
// no data in the table of Uid
|
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||||
if (*h != NULL) {
|
code = tsdbCacheGetLastrowH(lruCache, uid, pr->pVnode->pTsdb, h);
|
||||||
*pRow = (STSRow*)taosLRUCacheValue(lruCache, *h);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
code = tsdbCacheGetLastH(lruCache, uid, pr->pVnode->pTsdb, h);
|
code = tsdbCacheGetLastH(lruCache, uid, pr->pVnode->pTsdb, h);
|
||||||
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no data in the table of Uid
|
// no data in the table of Uid
|
||||||
if (*h != NULL) {
|
if (*h != NULL) {
|
||||||
SArray* pLast = (SArray*)taosLRUCacheValue(lruCache, *h);
|
*pRow = (SArray*)taosLRUCacheValue(lruCache, *h);
|
||||||
tsdbCacheLastArray2Row(pLast, pRow, pr->pSchema);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void freeItem(void* pItem) {
|
||||||
|
SLastCol* pCol = (SLastCol*) pItem;
|
||||||
|
if (IS_VAR_DATA_TYPE(pCol->colVal.type)) {
|
||||||
|
taosMemoryFree(pCol->colVal.value.pData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32_t* slotIds, SArray* pTableUidList) {
|
int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32_t* slotIds, SArray* pTableUidList) {
|
||||||
if (pReader == NULL || pResBlock == NULL) {
|
if (pReader == NULL || pResBlock == NULL) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -157,13 +198,41 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SLRUCache* lruCache = pr->pVnode->pTsdb->lruCache;
|
SLRUCache* lruCache = pr->pVnode->pTsdb->lruCache;
|
||||||
LRUHandle* h = NULL;
|
LRUHandle* h = NULL;
|
||||||
STSRow* pRow = NULL;
|
SArray* pRow = NULL;
|
||||||
size_t numOfTables = taosArrayGetSize(pr->pTableList);
|
size_t numOfTables = taosArrayGetSize(pr->pTableList);
|
||||||
|
bool hasRes = false;
|
||||||
|
SArray* pLastCols = NULL;
|
||||||
|
|
||||||
|
void** pRes = taosMemoryCalloc(pr->numOfCols, POINTER_BYTES);
|
||||||
|
if (pRes == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < pr->numOfCols; ++j) {
|
||||||
|
pRes[j] = taosMemoryCalloc(1, sizeof(SFirstLastRes) + pr->pSchema->columns[slotIds[j]].bytes + VARSTR_HEADER_SIZE);
|
||||||
|
SFirstLastRes* p = (SFirstLastRes*)varDataVal(pRes[j]);
|
||||||
|
p->ts = INT64_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
pLastCols = taosArrayInit(pr->pSchema->numOfCols, sizeof(SLastCol));
|
||||||
|
if (pLastCols == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pr->pSchema->numOfCols; ++i) {
|
||||||
|
struct STColumn* pCol = &pr->pSchema->columns[i];
|
||||||
|
SLastCol p = {.ts = INT64_MIN, .colVal.type = pCol->type};
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
|
p.colVal.value.pData = taosMemoryCalloc(pCol->bytes, sizeof(char));
|
||||||
|
}
|
||||||
|
taosArrayPush(pLastCols, &p);
|
||||||
|
}
|
||||||
|
|
||||||
// retrieve the only one last row of all tables in the uid list.
|
// retrieve the only one last row of all tables in the uid list.
|
||||||
if ((pr->type & CACHESCAN_RETRIEVE_TYPE_SINGLE) == CACHESCAN_RETRIEVE_TYPE_SINGLE) {
|
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_SINGLE)) {
|
||||||
int64_t lastKey = INT64_MIN;
|
|
||||||
bool internalResult = false;
|
|
||||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, i);
|
STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, i);
|
||||||
|
|
||||||
|
@ -176,23 +245,59 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRow->ts > lastKey) {
|
{
|
||||||
// Set result row into the same rowIndex repeatly, so we need to check if the internal result row has already
|
for (int32_t k = 0; k < pr->numOfCols; ++k) {
|
||||||
// appended or not.
|
int32_t slotId = slotIds[k];
|
||||||
if (internalResult) {
|
|
||||||
pResBlock->info.rows -= 1;
|
if (slotId == -1) { // the primary timestamp
|
||||||
taosArrayClear(pTableUidList);
|
SLastCol* p = taosArrayGet(pLastCols, 0);
|
||||||
|
SLastCol* pCol = (SLastCol*)taosArrayGet(pRow, 0);
|
||||||
|
if (pCol->ts > p->ts) {
|
||||||
|
hasRes = true;
|
||||||
|
p->ts = pCol->ts;
|
||||||
|
p->colVal = pCol->colVal;
|
||||||
|
|
||||||
|
// only set value for last row query
|
||||||
|
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||||
|
if (taosArrayGetSize(pTableUidList) == 0) {
|
||||||
|
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||||
|
} else {
|
||||||
|
taosArraySet(pTableUidList, 0, &pKeyInfo->uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SLastCol* p = taosArrayGet(pLastCols, slotId);
|
||||||
|
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId);
|
||||||
|
|
||||||
|
if (pColVal->ts > p->ts) {
|
||||||
|
if (!COL_VAL_IS_VALUE(&pColVal->colVal) && HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
hasRes = true;
|
||||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
p->ts = pColVal->ts;
|
||||||
internalResult = true;
|
|
||||||
lastKey = pRow->ts;
|
uint8_t* px = p->colVal.value.pData;
|
||||||
|
p->colVal = pColVal->colVal;
|
||||||
|
|
||||||
|
if (COL_VAL_IS_VALUE(&pColVal->colVal) && IS_VAR_DATA_TYPE(pColVal->colVal.type)) {
|
||||||
|
p->colVal.value.pData = px;
|
||||||
|
memcpy(px, pColVal->colVal.value.pData, pColVal->colVal.value.nData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbCacheRelease(lruCache, h);
|
tsdbCacheRelease(lruCache, h);
|
||||||
}
|
}
|
||||||
} else if ((pr->type & CACHESCAN_RETRIEVE_TYPE_ALL) == CACHESCAN_RETRIEVE_TYPE_ALL) {
|
|
||||||
|
if (hasRes) {
|
||||||
|
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||||
for (int32_t i = pr->tableIndex; i < numOfTables; ++i) {
|
for (int32_t i = pr->tableIndex; i < numOfTables; ++i) {
|
||||||
STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(pr->pTableList, i);
|
STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(pr->pTableList, i);
|
||||||
code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h);
|
code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h);
|
||||||
|
@ -204,19 +309,27 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
||||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
// TODO reset the pRes
|
||||||
|
|
||||||
|
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||||
tsdbCacheRelease(lruCache, h);
|
tsdbCacheRelease(lruCache, h);
|
||||||
|
|
||||||
pr->tableIndex += 1;
|
pr->tableIndex += 1;
|
||||||
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
||||||
return TSDB_CODE_SUCCESS;
|
goto _end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
_end:
|
||||||
|
for (int32_t j = 0; j < pr->numOfCols; ++j) {
|
||||||
|
taosMemoryFree(pRes[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pRes);
|
||||||
|
taosArrayDestroyEx(pLastCols, freeItem);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ int32_t tsdbBegin(STsdb *pTsdb) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbEndCommit(&commith, code);
|
tsdbEndCommit(&commith, code);
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,7 @@ static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -567,7 +567,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ int32_t tsdbWriteDataBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SMapDa
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ int32_t tsdbWriteSttBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SArray
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -702,7 +702,7 @@ static int32_t tsdbCommitSttBlk(SDataFWriter *pWriter, SDiskDataBuilder *pBuilde
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -738,7 +738,7 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -764,7 +764,7 @@ static int32_t tsdbMoveCommitData(SCommitter *pCommitter, TABLEID toTable) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -791,7 +791,7 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
tsdbDataFReaderClose(&pCommitter->dReader.pReader);
|
tsdbDataFReaderClose(&pCommitter->dReader.pReader);
|
||||||
tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 0);
|
tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 0);
|
||||||
}
|
}
|
||||||
|
@ -829,7 +829,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -886,7 +886,7 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -945,7 +945,7 @@ static int32_t tsdbCommitData(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1031,9 +1031,9 @@ static int32_t tsdbCommitDel(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
tsdbDebug("vgId:%d commit del done, nDel:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nDel);
|
tsdbDebug("vgId:%d, commit del done, nDel:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nDel);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1056,9 +1056,9 @@ _exit:
|
||||||
taosArrayDestroy(pCommitter->aTbDataP);
|
taosArrayDestroy(pCommitter->aTbDataP);
|
||||||
pCommitter->aTbDataP = NULL;
|
pCommitter->aTbDataP = NULL;
|
||||||
if (code || eno) {
|
if (code || eno) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
tsdbInfo("vgId:%d, tsdb end commit", TD_VID(pTsdb->pVnode));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1150,7 +1150,7 @@ static int32_t tsdbNextCommitRow(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1198,7 +1198,7 @@ static int32_t tsdbCommitAheadBlock(SCommitter *pCommitter, SDataBlk *pDataBlk)
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1285,7 +1285,7 @@ static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SDataBlk *pDataBlk)
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1360,7 +1360,7 @@ static int32_t tsdbMergeTableData(SCommitter *pCommitter, TABLEID id) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1409,7 +1409,7 @@ static int32_t tsdbInitSttBlockBuilderIfNeed(SCommitter *pCommitter, TABLEID id)
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1453,7 +1453,7 @@ static int32_t tsdbAppendLastBlock(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1557,7 +1557,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, TABLEID id) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1624,7 +1624,7 @@ static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pCommitter->pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1654,9 +1654,9 @@ int32_t tsdbFinishCommit(STsdb *pTsdb) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
tsdbInfo("vgId:%d tsdb finish commit", TD_VID(pTsdb->pVnode));
|
tsdbInfo("vgId:%d, tsdb finish commit", TD_VID(pTsdb->pVnode));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1670,9 +1670,9 @@ int32_t tsdbRollbackCommit(STsdb *pTsdb) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
tsdbInfo("vgId:%d tsdb rollback commit", TD_VID(pTsdb->pVnode));
|
tsdbInfo("vgId:%d, tsdb rollback commit", TD_VID(pTsdb->pVnode));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -253,7 +253,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s, fid:%d", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code),
|
tsdbError("vgId:%d, %s failed at line %d since %s, fid:%d", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code),
|
||||||
fid);
|
fid);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -428,7 +428,7 @@ static int32_t tsdbNewFileSet(STsdb *pTsdb, SDFileSet *pSetTo, SDFileSet *pSetFr
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ static int32_t tsdbFSApplyChange(STsdb *pTsdb, STsdbFS *pFS) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -731,7 +731,7 @@ int32_t tsdbFSCommit(STsdb *pTsdb) {
|
||||||
_exit:
|
_exit:
|
||||||
tsdbFSDestroy(&fs);
|
tsdbFSDestroy(&fs);
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -746,7 +746,7 @@ int32_t tsdbFSRollback(STsdb *pTsdb) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ int32_t tsdbFSOpen(STsdb *pTsdb, int8_t rollback) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -903,7 +903,7 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ int32_t tsdbFSPrepareCommit(STsdb *pTsdb, STsdbFS *pFSNew) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,6 +536,10 @@ static FORCE_INLINE int32_t tLDataIterCmprFn(const SRBTreeNode *p1, const SRBTre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tLDataIterDescCmprFn(const SRBTreeNode *p1, const SRBTreeNode *p2) {
|
||||||
|
return -1 * tLDataIterCmprFn(p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid,
|
int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid,
|
||||||
STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo,
|
STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo,
|
||||||
bool destroyLoadInfo, const char *idStr) {
|
bool destroyLoadInfo, const char *idStr) {
|
||||||
|
@ -547,8 +551,11 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
|
||||||
}
|
}
|
||||||
|
|
||||||
pMTree->idStr = idStr;
|
pMTree->idStr = idStr;
|
||||||
|
if (!pMTree->backward) { // asc
|
||||||
tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
|
tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
|
||||||
|
} else { // desc
|
||||||
|
tRBTreeCreate(&pMTree->rbt, tLDataIterDescCmprFn);
|
||||||
|
}
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
pMTree->pLoadInfo = pBlockLoadInfo;
|
pMTree->pLoadInfo = pBlockLoadInfo;
|
||||||
|
|
|
@ -415,7 +415,7 @@ int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx) {
|
||||||
pHeadFile->size += size;
|
pHeadFile->size += size;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
// tsdbTrace("vgId:%d write block idx, offset:%" PRId64 " size:%" PRId64 " nBlockIdx:%d",
|
// tsdbTrace("vgId:%d, write block idx, offset:%" PRId64 " size:%" PRId64 " nBlockIdx:%d",
|
||||||
// TD_VID(pWriter->pTsdb->pVnode),
|
// TD_VID(pWriter->pTsdb->pVnode),
|
||||||
// pHeadFile->offset, size, taosArrayGetSize(aBlockIdx));
|
// pHeadFile->offset, size, taosArrayGetSize(aBlockIdx));
|
||||||
return code;
|
return code;
|
||||||
|
@ -498,12 +498,12 @@ int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk) {
|
||||||
pSttFile->size += size;
|
pSttFile->size += size;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tsdbTrace("vgId:%d tsdb write stt block, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
|
tsdbTrace("vgId:%d, tsdb write stt block, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
|
||||||
pSttFile->offset, size);
|
pSttFile->offset, size);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb write blockl failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb write blockl failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ static int32_t tsdbWriteBlockSma(SDataFWriter *pWriter, SBlockData *pBlockData,
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb write block sma failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb write block sma failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,13 +601,13 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tsdbTrace("vgId:%d tsdb write block data, suid:%" PRId64 " uid:%" PRId64 " nRow:%d, offset:%" PRId64 " size:%d",
|
tsdbTrace("vgId:%d, tsdb write block data, suid:%" PRId64 " uid:%" PRId64 " nRow:%d, offset:%" PRId64 " size:%d",
|
||||||
TD_VID(pWriter->pTsdb->pVnode), pBlockData->suid, pBlockData->uid, pBlockData->nRow, pBlkInfo->offset,
|
TD_VID(pWriter->pTsdb->pVnode), pBlockData->suid, pBlockData->uid, pBlockData->nRow, pBlkInfo->offset,
|
||||||
pBlkInfo->szBlock);
|
pBlkInfo->szBlock);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb write block data failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb write block data failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ int32_t tsdbWriteDiskData(SDataFWriter *pWriter, const SDiskData *pDiskData, SBl
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
|
|
||||||
if (pReader) {
|
if (pReader) {
|
||||||
for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) tsdbCloseFile(&pReader->aSttFD[iStt]);
|
for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) tsdbCloseFile(&pReader->aSttFD[iStt]);
|
||||||
|
@ -995,7 +995,7 @@ int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk) {
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d read stt blk failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, read stt blk failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,7 +1058,7 @@ int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pDataBlk, SArray *aCol
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb read block sma failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb read block sma failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,7 +1177,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb read block data impl failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb read block data impl failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,7 +1200,7 @@ int32_t tsdbReadDataBlockEx(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockDat
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb read data block ex failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb read data block ex failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1258,7 +1258,7 @@ int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d tsdb read data block failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
tsdbError("vgId:%d, tsdb read data block failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1271,7 +1271,7 @@ int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk,
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1294,7 +1294,7 @@ int32_t tsdbReadSttBlockEx(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1338,7 +1338,7 @@ _exit:
|
||||||
taosMemoryFree(pDelFWriter);
|
taosMemoryFree(pDelFWriter);
|
||||||
}
|
}
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
|
||||||
} else {
|
} else {
|
||||||
*ppWriter = pDelFWriter;
|
*ppWriter = pDelFWriter;
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1502,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
*ppReader = pDelFReader;
|
*ppReader = pDelFReader;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d vnode snapshot tsdb snap read open file failed since %s", TD_VID(pReader->pTsdb->pVnode),
|
tsdbError("vgId:%d, vnode snapshot tsdb snap read open file failed since %s", TD_VID(pReader->pTsdb->pVnode),
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), __func__, lino,
|
tsdbError("vgId:%d, %s failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), __func__, lino,
|
||||||
tstrerror(code), pTsdb->path);
|
tstrerror(code), pTsdb->path);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
|
|
||||||
|
@ -738,7 +738,7 @@ static int32_t tsdbSnapWriteTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pI
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,7 +991,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,7 +1072,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,7 +1338,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
|
|
||||||
if (pWriter) {
|
if (pWriter) {
|
||||||
|
|
|
@ -174,12 +174,12 @@ void vnodeBufPoolUnRef(SVBufPool *pPool) {
|
||||||
if (pPool->node.size != size) {
|
if (pPool->node.size != size) {
|
||||||
SVBufPool *pPoolT = NULL;
|
SVBufPool *pPoolT = NULL;
|
||||||
if (vnodeBufPoolCreate(pVnode, size, &pPoolT) < 0) {
|
if (vnodeBufPoolCreate(pVnode, size, &pPoolT) < 0) {
|
||||||
vWarn("vgId:%d try to change buf pools size from %" PRId64 " to %" PRId64 " since %s", TD_VID(pVnode),
|
vWarn("vgId:%d, try to change buf pools size from %" PRId64 " to %" PRId64 " since %s", TD_VID(pVnode),
|
||||||
pPool->node.size, size, tstrerror(errno));
|
pPool->node.size, size, tstrerror(errno));
|
||||||
} else {
|
} else {
|
||||||
vnodeBufPoolDestroy(pPool);
|
vnodeBufPoolDestroy(pPool);
|
||||||
pPool = pPoolT;
|
pPool = pPoolT;
|
||||||
vDebug("vgId:%d change buf pools size from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->node.size, size);
|
vDebug("vgId:%d, change buf pools size from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->node.size, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,20 +51,11 @@ int vnodeBegin(SVnode *pVnode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVnode->pSma) {
|
|
||||||
if (VND_RSMA1(pVnode) && tsdbBegin(VND_RSMA1(pVnode)) < 0) {
|
|
||||||
vError("vgId:%d, failed to begin rsma1 since %s", TD_VID(pVnode), tstrerror(terrno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VND_RSMA2(pVnode) && tsdbBegin(VND_RSMA2(pVnode)) < 0) {
|
|
||||||
vError("vgId:%d, failed to begin rsma2 since %s", TD_VID(pVnode), tstrerror(terrno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// begin sma
|
// begin sma
|
||||||
smaBegin(pVnode->pSma); // TODO: refactor to include the rsma1/rsma2 tsdbBegin() after tsdb_refact branch merged
|
if (VND_IS_RSMA(pVnode) && smaBegin(pVnode->pSma) < 0) {
|
||||||
|
vError("vgId:%d, failed to begin sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -239,10 +230,8 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||||
|
|
||||||
if (smaPreCommit(pVnode->pSma) < 0) {
|
code = smaPreCommit(pVnode->pSma);
|
||||||
vError("vgId:%d, failed to pre-commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
vnodeBufPoolUnRef(pVnode->inUse);
|
vnodeBufPoolUnRef(pVnode->inUse);
|
||||||
pVnode->inUse = NULL;
|
pVnode->inUse = NULL;
|
||||||
|
@ -253,14 +242,12 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VND_IS_RSMA(pVnode)) {
|
|
||||||
if (smaCommit(pVnode->pSma) < 0) {
|
|
||||||
vError("vgId:%d, failed to commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
code = tsdbCommit(pVnode->pTsdb);
|
code = tsdbCommit(pVnode->pTsdb);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
if (VND_IS_RSMA(pVnode)) {
|
||||||
|
code = smaCommit(pVnode->pSma);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tqCommit(pVnode->pTq) < 0) {
|
if (tqCommit(pVnode->pTq) < 0) {
|
||||||
|
@ -274,7 +261,13 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbFinishCommit(pVnode->pTsdb);
|
code = tsdbFinishCommit(pVnode->pTsdb);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
if (VND_IS_RSMA(pVnode)) {
|
||||||
|
code = smaFinishCommit(pVnode->pSma);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
if (metaFinishCommit(pVnode->pMeta) < 0) {
|
if (metaFinishCommit(pVnode->pMeta) < 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
@ -293,7 +286,7 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
vError("vgId:%d %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
|
vError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
vInfo("vgId:%d, commit end", TD_VID(pVnode));
|
vInfo("vgId:%d, commit end", TD_VID(pVnode));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,9 @@
|
||||||
|
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
SVnodeInfo info = {0};
|
SVnodeInfo info = {0};
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
// TODO: check if directory exists
|
|
||||||
|
|
||||||
// check config
|
// check config
|
||||||
if (vnodeCheckCfg(pCfg) < 0) {
|
if (vnodeCheckCfg(pCfg) < 0) {
|
||||||
|
@ -56,18 +54,60 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vInfo("vgId:%d, vnode is created", info.config.vgId);
|
vInfo("vgId:%d, vnode is created", info.config.vgId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeDestroy(const char *path, STfs *pTfs) { tfsRmdir(pTfs, path); }
|
int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
|
||||||
|
SVnodeInfo info = {0};
|
||||||
|
char dir[TSDB_FILENAME_LEN] = {0};
|
||||||
|
int32_t ret = 0;
|
||||||
|
|
||||||
|
if (pTfs) {
|
||||||
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
|
||||||
|
} else {
|
||||||
|
snprintf(dir, TSDB_FILENAME_LEN, "%s", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = vnodeLoadInfo(dir, &info);
|
||||||
|
if (ret < 0) {
|
||||||
|
vError("vgId:%d, failed to read vnode config from %s since %s", pReq->vgId, path, tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSyncCfg *pCfg = &info.config.syncCfg;
|
||||||
|
pCfg->myIndex = pReq->selfIndex;
|
||||||
|
pCfg->replicaNum = pReq->replica;
|
||||||
|
memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo));
|
||||||
|
|
||||||
|
vInfo("vgId:%d, save config, replicas:%d selfIndex:%d", pReq->vgId, pCfg->replicaNum, pCfg->myIndex);
|
||||||
|
for (int i = 0; i < pReq->replica; ++i) {
|
||||||
|
SNodeInfo *pNode = &pCfg->nodeInfo[i];
|
||||||
|
pNode->nodePort = pReq->replicas[i].port;
|
||||||
|
tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
||||||
|
vInfo("vgId:%d, save config, replica:%d ep:%s:%u", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = vnodeSaveInfo(dir, &info);
|
||||||
|
if (ret < 0) {
|
||||||
|
vError("vgId:%d, failed to save vnode config since %s", pReq->vgId, tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
vInfo("vgId:%d, vnode config is saved", info.config.vgId);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vnodeDestroy(const char *path, STfs *pTfs) {
|
||||||
|
vInfo("path:%s is removed while destroy vnode", path);
|
||||||
|
tfsRmdir(pTfs, path);
|
||||||
|
}
|
||||||
|
|
||||||
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
SVnode *pVnode = NULL;
|
SVnode *pVnode = NULL;
|
||||||
SVnodeInfo info = {0};
|
SVnodeInfo info = {0};
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN] = {0};
|
||||||
char tdir[TSDB_FILENAME_LEN * 2];
|
char tdir[TSDB_FILENAME_LEN * 2] = {0};
|
||||||
int ret;
|
int32_t ret = 0;
|
||||||
|
|
||||||
if (pTfs) {
|
if (pTfs) {
|
||||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
|
||||||
|
@ -85,7 +125,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create handle
|
// create handle
|
||||||
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
|
pVnode = taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
vError("vgId:%d, failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
vError("vgId:%d, failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
||||||
|
|
|
@ -219,7 +219,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vError("vgId:%d vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
vError("vgId:%d, vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1068,20 +1068,20 @@ static int32_t vnodeProcessAlterHashRangeReq(SVnode *pVnode, int64_t version, vo
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SAlterVnodeReq req = {0};
|
|
||||||
bool walChanged = false;
|
bool walChanged = false;
|
||||||
bool tsdbChanged = false;
|
bool tsdbChanged = false;
|
||||||
|
|
||||||
if (tDeserializeSAlterVnodeReq(pReq, len, &req) != 0) {
|
SAlterVnodeConfigReq req = {0};
|
||||||
|
if (tDeserializeSAlterVnodeConfigReq(pReq, len, &req) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
vInfo("vgId:%d, start to alter vnode config, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64
|
vInfo("vgId:%d, start to alter vnode config, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64
|
||||||
" cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d fsync:%d level:%d strict:%d",
|
" cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d fsync:%d level:%d",
|
||||||
TD_VID(pVnode), req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024,
|
TD_VID(pVnode), req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024,
|
||||||
req.cacheLast, req.cacheLastSize, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
req.cacheLast, req.cacheLastSize, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
||||||
req.walFsyncPeriod, req.walLevel, req.strict);
|
req.walFsyncPeriod, req.walLevel);
|
||||||
|
|
||||||
if (pVnode->config.cacheLastSize != req.cacheLastSize) {
|
if (pVnode->config.cacheLastSize != req.cacheLastSize) {
|
||||||
pVnode->config.cacheLastSize = req.cacheLastSize;
|
pVnode->config.cacheLastSize = req.cacheLastSize;
|
||||||
|
@ -1089,18 +1089,18 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVnode->config.szBuf != req.buffer * 1024LL * 1024LL) {
|
if (pVnode->config.szBuf != req.buffer * 1024LL * 1024LL) {
|
||||||
vInfo("vgId:%d vnode buffer is changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pVnode->config.szBuf,
|
vInfo("vgId:%d, vnode buffer is changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pVnode->config.szBuf,
|
||||||
(uint64_t)(req.buffer * 1024LL * 1024LL));
|
(uint64_t)(req.buffer * 1024LL * 1024LL));
|
||||||
pVnode->config.szBuf = req.buffer * 1024LL * 1024LL;
|
pVnode->config.szBuf = req.buffer * 1024LL * 1024LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVnode->config.szCache != req.pages) {
|
if (pVnode->config.szCache != req.pages) {
|
||||||
if (metaAlterCache(pVnode->pMeta, req.pages) < 0) {
|
if (metaAlterCache(pVnode->pMeta, req.pages) < 0) {
|
||||||
vError("vgId:%d failed to change vnode pages from %d to %d failed since %s", TD_VID(pVnode),
|
vError("vgId:%d, failed to change vnode pages from %d to %d failed since %s", TD_VID(pVnode),
|
||||||
pVnode->config.szCache, req.pages, tstrerror(errno));
|
pVnode->config.szCache, req.pages, tstrerror(errno));
|
||||||
return errno;
|
return errno;
|
||||||
} else {
|
} else {
|
||||||
vInfo("vgId:%d vnode pages is changed from %d to %d", TD_VID(pVnode), pVnode->config.szCache, req.pages);
|
vInfo("vgId:%d, vnode pages is changed from %d to %d", TD_VID(pVnode), pVnode->config.szCache, req.pages);
|
||||||
pVnode->config.szCache = req.pages;
|
pVnode->config.szCache = req.pages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
||||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
||||||
(type == TDMT_VND_UPDATE_TAG_VAL) || (type == TDMT_VND_ALTER_REPLICA);
|
(type == TDMT_VND_UPDATE_TAG_VAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
||||||
|
@ -53,76 +53,6 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSetStandBy(SVnode *pVnode) {
|
|
||||||
vInfo("vgId:%d, start to set standby", TD_VID(pVnode));
|
|
||||||
|
|
||||||
if (syncSetStandby(pVnode->sync) == 0) {
|
|
||||||
vInfo("vgId:%d, set standby success", TD_VID(pVnode));
|
|
||||||
return 0;
|
|
||||||
} else if (terrno != TSDB_CODE_SYN_IS_LEADER) {
|
|
||||||
vError("vgId:%d, failed to set standby since %s", TD_VID(pVnode), terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
vInfo("vgId:%d, start to transfer leader", TD_VID(pVnode));
|
|
||||||
if (syncLeaderTransfer(pVnode->sync) != 0) {
|
|
||||||
vError("vgId:%d, failed to transfer leader since:%s", TD_VID(pVnode), terrstr());
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
vInfo("vgId:%d, transfer leader success", TD_VID(pVnode));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncSetStandby(pVnode->sync) == 0) {
|
|
||||||
vInfo("vgId:%d, set standby success", TD_VID(pVnode));
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
vError("vgId:%d, failed to set standby after leader transfer since %s", TD_VID(pVnode), terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
|
||||||
SAlterVnodeReq req = {0};
|
|
||||||
if (tDeserializeSAlterVnodeReq((char *)pMsg->pCont + sizeof(SMsgHead), pMsg->contLen - sizeof(SMsgHead), &req) != 0) {
|
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
|
||||||
return TSDB_CODE_INVALID_MSG;
|
|
||||||
}
|
|
||||||
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
|
||||||
vGTrace("vgId:%d, start to alter vnode replica to %d, handle:%p", TD_VID(pVnode), req.replica, pMsg->info.handle);
|
|
||||||
|
|
||||||
SSyncCfg cfg = {.replicaNum = req.replica, .myIndex = req.selfIndex};
|
|
||||||
for (int32_t r = 0; r < req.replica; ++r) {
|
|
||||||
SNodeInfo *pNode = &cfg.nodeInfo[r];
|
|
||||||
tstrncpy(pNode->nodeFqdn, req.replicas[r].fqdn, sizeof(pNode->nodeFqdn));
|
|
||||||
pNode->nodePort = req.replicas[r].port;
|
|
||||||
vInfo("vgId:%d, replica:%d %s:%u", TD_VID(pVnode), r, pNode->nodeFqdn, pNode->nodePort);
|
|
||||||
}
|
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.info = pMsg->info};
|
|
||||||
if (syncReconfigBuild(pVnode->sync, &cfg, &rpcMsg) != 0) {
|
|
||||||
vError("vgId:%d, failed to build reconfig msg since %s", TD_VID(pVnode), terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = syncPropose(pVnode->sync, &rpcMsg, false);
|
|
||||||
if (code != 0) {
|
|
||||||
if (terrno != 0) code = terrno;
|
|
||||||
|
|
||||||
vInfo("vgId:%d, failed to propose reconfig msg since %s", TD_VID(pVnode), terrstr());
|
|
||||||
if (terrno == TSDB_CODE_SYN_IS_LEADER) {
|
|
||||||
if (syncLeaderTransfer(pVnode->sync) != 0) {
|
|
||||||
vError("vgId:%d, failed to transfer leader since %s", TD_VID(pVnode), terrstr());
|
|
||||||
} else {
|
|
||||||
vInfo("vgId:%d, transfer leader success", TD_VID(pVnode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
terrno = code;
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
SEpSet newEpSet = {0};
|
SEpSet newEpSet = {0};
|
||||||
syncGetRetryEpSet(pVnode->sync, &newEpSet);
|
syncGetRetryEpSet(pVnode->sync, &newEpSet);
|
||||||
|
@ -169,24 +99,6 @@ static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodeHandleAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
|
||||||
int32_t code = vnodeProcessAlterReplicaReq(pVnode, pMsg);
|
|
||||||
|
|
||||||
if (code > 0) {
|
|
||||||
ASSERT(0);
|
|
||||||
} else if (code == 0) {
|
|
||||||
vnodeWaitBlockMsg(pVnode, pMsg);
|
|
||||||
} else {
|
|
||||||
if (terrno != 0) code = terrno;
|
|
||||||
vnodeHandleProposeError(pVnode, pMsg, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
|
||||||
vGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->config.vgId, pMsg, code);
|
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
taosFreeQitem(pMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) {
|
static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) {
|
||||||
if (*arrSize <= 0) return;
|
if (*arrSize <= 0) return;
|
||||||
|
|
||||||
|
@ -265,11 +177,6 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->msgType == TDMT_VND_ALTER_REPLICA) {
|
|
||||||
vnodeHandleAlterReplicaReq(pVnode, pMsg);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isBlock || BATCH_DISABLE) {
|
if (isBlock || BATCH_DISABLE) {
|
||||||
vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos);
|
vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos);
|
||||||
}
|
}
|
||||||
|
@ -431,11 +338,6 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
ASSERT(pSyncMsg != NULL);
|
ASSERT(pSyncMsg != NULL);
|
||||||
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_SET_VNODE_STANDBY) {
|
|
||||||
code = vnodeSetStandBy(pVnode);
|
|
||||||
if (code != 0 && terrno != 0) code = terrno;
|
|
||||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
|
||||||
tmsgSendRsp(&rsp);
|
|
||||||
} else {
|
} else {
|
||||||
vGError("vgId:%d, msg:%p failed to process since error msg type:%d", pVnode->config.vgId, pMsg, pMsg->msgType);
|
vGError("vgId:%d, msg:%p failed to process since error msg type:%d", pVnode->config.vgId, pMsg, pMsg->msgType);
|
||||||
code = -1;
|
code = -1;
|
||||||
|
@ -496,11 +398,6 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg);
|
||||||
syncSnapshotRspDestroy(pSyncMsg);
|
syncSnapshotRspDestroy(pSyncMsg);
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_SET_VNODE_STANDBY) {
|
|
||||||
code = vnodeSetStandBy(pVnode);
|
|
||||||
if (code != 0 && terrno != 0) code = terrno;
|
|
||||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
|
||||||
tmsgSendRsp(&rsp);
|
|
||||||
} else {
|
} else {
|
||||||
vGError("vgId:%d, msg:%p failed to process since error msg type:%d", pVnode->config.vgId, pMsg, pMsg->msgType);
|
vGError("vgId:%d, msg:%p failed to process since error msg type:%d", pVnode->config.vgId, pMsg, pMsg->msgType);
|
||||||
code = -1;
|
code = -1;
|
||||||
|
@ -543,22 +440,7 @@ static int32_t vnodeSyncGetSnapshot(SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) {
|
static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) {}
|
||||||
SVnode *pVnode = pFsm->data;
|
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
|
||||||
syncGetAndDelRespRpc(pVnode->sync, cbMeta->newCfgSeqNum, &rpcMsg.info);
|
|
||||||
rpcMsg.info.conn.applyIndex = cbMeta->index;
|
|
||||||
|
|
||||||
const STraceId *trace = (STraceId *)&pMsg->info.traceId;
|
|
||||||
vGTrace("vgId:%d, alter vnode replica is confirmed, type:%s contLen:%d seq:%" PRIu64 " handle:%p", TD_VID(pVnode),
|
|
||||||
TMSG_INFO(pMsg->msgType), pMsg->contLen, cbMeta->seqNum, rpcMsg.info.handle);
|
|
||||||
if (rpcMsg.info.handle != NULL) {
|
|
||||||
tmsgSendRsp(&rpcMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
vnodePostBlockMsg(pVnode, pMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
|
||||||
if (cbMeta.isWeak == 0) {
|
if (cbMeta.isWeak == 0) {
|
||||||
|
|
|
@ -162,6 +162,8 @@ typedef struct {
|
||||||
SQueryTableDataCond tableCond;
|
SQueryTableDataCond tableCond;
|
||||||
int64_t recoverStartVer;
|
int64_t recoverStartVer;
|
||||||
int64_t recoverEndVer;
|
int64_t recoverEndVer;
|
||||||
|
int64_t fillHistoryVer1;
|
||||||
|
int64_t fillHistoryVer2;
|
||||||
SStreamState* pState;
|
SStreamState* pState;
|
||||||
} SStreamTaskInfo;
|
} SStreamTaskInfo;
|
||||||
|
|
||||||
|
@ -677,14 +679,12 @@ typedef struct SFillOperatorInfo {
|
||||||
uint64_t curGroupId; // current handled group id
|
uint64_t curGroupId; // current handled group id
|
||||||
SExprInfo* pExprInfo;
|
SExprInfo* pExprInfo;
|
||||||
int32_t numOfExpr;
|
int32_t numOfExpr;
|
||||||
SExprInfo* pNotFillExprInfo;
|
SExprSupp noFillExprSupp;
|
||||||
int32_t numOfNotFillExpr;
|
|
||||||
} SFillOperatorInfo;
|
} SFillOperatorInfo;
|
||||||
|
|
||||||
typedef struct SGroupbyOperatorInfo {
|
typedef struct SGroupbyOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
SAggSupporter aggSup;
|
SAggSupporter aggSup;
|
||||||
|
|
||||||
SArray* pGroupCols; // group by columns, SArray<SColumn>
|
SArray* pGroupCols; // group by columns, SArray<SColumn>
|
||||||
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
||||||
SNode* pCondition;
|
SNode* pCondition;
|
||||||
|
@ -1016,8 +1016,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
||||||
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
||||||
int32_t numOfOutput, SArray* pPseudoList);
|
int32_t numOfOutput, SArray* pPseudoList);
|
||||||
|
|
||||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order,
|
void setInputDataBlock(SExprSupp* pExprSupp, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol);
|
||||||
int32_t scanFlag, bool createDummyCol);
|
|
||||||
|
|
||||||
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||||
int32_t checkForQueryBuf(size_t numOfTables);
|
int32_t checkForQueryBuf(size_t numOfTables);
|
||||||
|
|
|
@ -58,7 +58,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
|
|
||||||
// partition by tbname
|
// partition by tbname
|
||||||
if (taosArrayGetSize(pTableList->pGroupList) == taosArrayGetSize(pTableList->pTableList)) {
|
if (taosArrayGetSize(pTableList->pGroupList) == taosArrayGetSize(pTableList->pTableList)) {
|
||||||
pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL | CACHESCAN_RETRIEVE_LAST_ROW;
|
pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL|(pScanNode->ignoreNull? CACHESCAN_RETRIEVE_LAST:CACHESCAN_RETRIEVE_LAST_ROW);
|
||||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pTableList->pTableList,
|
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pTableList->pTableList,
|
||||||
taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader);
|
taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -68,7 +68,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
pInfo->pBufferredRes = createOneDataBlock(pInfo->pRes, false);
|
pInfo->pBufferredRes = createOneDataBlock(pInfo->pRes, false);
|
||||||
blockDataEnsureCapacity(pInfo->pBufferredRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pBufferredRes, pOperator->resultInfo.capacity);
|
||||||
} else { // by tags
|
} else { // by tags
|
||||||
pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_SINGLE | CACHESCAN_RETRIEVE_LAST_ROW;
|
pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_SINGLE|(pScanNode->ignoreNull? CACHESCAN_RETRIEVE_LAST:CACHESCAN_RETRIEVE_LAST_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pScanNode->scan.pScanPseudoCols != NULL) {
|
if (pScanNode->scan.pScanPseudoCols != NULL) {
|
||||||
|
@ -198,11 +198,14 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->pRes->info.rows > 0) {
|
if (pInfo->pRes->info.rows > 0) {
|
||||||
if (pInfo->pseudoExprSup.numOfExprs > 0) {
|
if (pInfo->pseudoExprSup.numOfExprs > 0) {
|
||||||
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
||||||
pInfo->pRes->info.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, 0);
|
|
||||||
|
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pGroupTableList, 0);
|
STableKeyInfo* pKeyInfo = taosArrayGet(pGroupTableList, 0);
|
||||||
pInfo->pRes->info.groupId = pKeyInfo->groupId;
|
pInfo->pRes->info.groupId = pKeyInfo->groupId;
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pInfo->pUidList) > 0) {
|
||||||
|
ASSERT((pInfo->retrieveType & CACHESCAN_RETRIEVE_LAST_ROW) == CACHESCAN_RETRIEVE_LAST_ROW);
|
||||||
|
|
||||||
|
pInfo->pRes->info.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, 0);
|
||||||
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes,
|
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes,
|
||||||
GET_TASKID(pTaskInfo));
|
GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -210,6 +213,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
|
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
|
||||||
return pInfo->pRes;
|
return pInfo->pRes;
|
||||||
|
|
|
@ -403,25 +403,24 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order,
|
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||||
int32_t scanFlag, bool createDummyCol);
|
bool createDummyCol);
|
||||||
|
|
||||||
static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock,
|
static void doSetInputDataBlockInfo(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order) {
|
||||||
int32_t order) {
|
SqlFunctionCtx* pCtx = pExprSup->pCtx;
|
||||||
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
|
||||||
pCtx[i].order = order;
|
pCtx[i].order = order;
|
||||||
pCtx[i].input.numOfRows = pBlock->info.rows;
|
pCtx[i].input.numOfRows = pBlock->info.rows;
|
||||||
setBlockSMAInfo(&pCtx[i], &pOperator->exprSupp.pExprInfo[i], pBlock);
|
setBlockSMAInfo(&pCtx[i], &pExprSup->pExprInfo[i], pBlock);
|
||||||
pCtx[i].pSrcBlock = pBlock;
|
pCtx[i].pSrcBlock = pBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order,
|
void setInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol) {
|
||||||
int32_t scanFlag, bool createDummyCol) {
|
|
||||||
if (pBlock->pBlockAgg != NULL) {
|
if (pBlock->pBlockAgg != NULL) {
|
||||||
doSetInputDataBlockInfo(pOperator, pCtx, pBlock, order);
|
doSetInputDataBlockInfo(pExprSup, pBlock, order);
|
||||||
} else {
|
} else {
|
||||||
doSetInputDataBlock(pOperator, pCtx, pBlock, order, scanFlag, createDummyCol);
|
doSetInputDataBlock(pExprSup, pBlock, order, scanFlag, createDummyCol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,11 +467,12 @@ static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunc
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order,
|
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||||
int32_t scanFlag, bool createDummyCol) {
|
bool createDummyCol) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
SqlFunctionCtx* pCtx = pExprSup->pCtx;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
|
||||||
pCtx[i].order = order;
|
pCtx[i].order = order;
|
||||||
pCtx[i].input.numOfRows = pBlock->info.rows;
|
pCtx[i].input.numOfRows = pBlock->info.rows;
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
||||||
pInput->uid = pBlock->info.uid;
|
pInput->uid = pBlock->info.uid;
|
||||||
pInput->colDataAggIsSet = false;
|
pInput->colDataAggIsSet = false;
|
||||||
|
|
||||||
SExprInfo* pOneExpr = &pOperator->exprSupp.pExprInfo[i];
|
SExprInfo* pOneExpr = &pExprSup->pExprInfo[i];
|
||||||
for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
|
for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
|
||||||
SFunctParam* pFuncParam = &pOneExpr->base.pParam[j];
|
SFunctParam* pFuncParam = &pOneExpr->base.pParam[j];
|
||||||
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
||||||
|
@ -569,8 +569,10 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pResult != pSrcBlock) {
|
||||||
pResult->info.groupId = pSrcBlock->info.groupId;
|
pResult->info.groupId = pSrcBlock->info.groupId;
|
||||||
memcpy(pResult->info.parTbName, pSrcBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
memcpy(pResult->info.parTbName, pSrcBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
// if the source equals to the destination, it is to create a new column as the result of scalar
|
// if the source equals to the destination, it is to create a new column as the result of scalar
|
||||||
// function or some operators.
|
// function or some operators.
|
||||||
|
@ -2435,7 +2437,7 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.groupId);
|
setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.groupId);
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, true);
|
setInputDataBlock(pSup, pBlock, order, scanFlag, true);
|
||||||
code = doAggregateImpl(pOperator, pSup->pCtx);
|
code = doAggregateImpl(pOperator, pSup->pCtx);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
@ -2734,28 +2736,16 @@ static void doHandleRemainBlockFromNewGroup(SOperatorInfo* pOperator, SFillOpera
|
||||||
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) {
|
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) {
|
||||||
SFillOperatorInfo* pInfo = pOperator->info;
|
SFillOperatorInfo* pInfo = pOperator->info;
|
||||||
SExprSupp* pSup = &pOperator->exprSupp;
|
SExprSupp* pSup = &pOperator->exprSupp;
|
||||||
SSDataBlock* pResBlock = pInfo->pFinalRes;
|
setInputDataBlock(pSup, pBlock, order, scanFlag, false);
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, false);
|
|
||||||
projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs, NULL);
|
projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs, NULL);
|
||||||
|
|
||||||
|
// reset the row value before applying the no-fill functions to the input data block, which is "pBlock" in this case.
|
||||||
|
pInfo->pRes->info.rows = 0;
|
||||||
|
SExprSupp* pNoFillSupp = &pInfo->noFillExprSupp;
|
||||||
|
setInputDataBlock(pNoFillSupp, pBlock, order, scanFlag, false);
|
||||||
|
|
||||||
|
projectApplyFunctions(pNoFillSupp->pExprInfo, pInfo->pRes, pBlock, pNoFillSupp->pCtx, pNoFillSupp->numOfExprs, NULL);
|
||||||
pInfo->pRes->info.groupId = pBlock->info.groupId;
|
pInfo->pRes->info.groupId = pBlock->info.groupId;
|
||||||
|
|
||||||
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pInfo->primaryTsCol);
|
|
||||||
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, pInfo->primarySrcSlotId);
|
|
||||||
colDataAssign(pDst, pSrc, pInfo->pRes->info.rows, &pResBlock->info);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pInfo->numOfNotFillExpr; ++i) {
|
|
||||||
SFillColInfo* pCol = &pInfo->pFillInfo->pFillCol[i + pInfo->numOfExpr];
|
|
||||||
ASSERT(pCol->notFillCol);
|
|
||||||
|
|
||||||
SExprInfo* pExpr = pCol->pExpr;
|
|
||||||
int32_t srcSlotId = pExpr->base.pParam[0].pCol->slotId;
|
|
||||||
int32_t dstSlotId = pExpr->base.resSchema.slotId;
|
|
||||||
|
|
||||||
SColumnInfoData* pDst1 = taosArrayGet(pInfo->pRes->pDataBlock, dstSlotId);
|
|
||||||
SColumnInfoData* pSrc1 = taosArrayGet(pBlock->pDataBlock, srcSlotId);
|
|
||||||
colDataAssign(pDst1, pSrc1, pInfo->pRes->info.rows, &pResBlock->info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
||||||
|
@ -3048,7 +3038,8 @@ void cleanupExprSupp(SExprSupp* pSupp) {
|
||||||
taosMemoryFree(pSupp->rowEntryInfoOffset);
|
taosMemoryFree(pSupp->rowEntryInfoOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode,SExecTaskInfo* pTaskInfo) {
|
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode,
|
||||||
|
SExecTaskInfo* pTaskInfo) {
|
||||||
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
|
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
@ -3143,10 +3134,7 @@ void destroyFillOperatorInfo(void* param) {
|
||||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||||
pInfo->pFinalRes = blockDataDestroy(pInfo->pFinalRes);
|
pInfo->pFinalRes = blockDataDestroy(pInfo->pFinalRes);
|
||||||
|
|
||||||
if (pInfo->pNotFillExprInfo != NULL) {
|
cleanupExprSupp(&pInfo->noFillExprSupp);
|
||||||
destroyExprInfo(pInfo->pNotFillExprInfo, pInfo->numOfNotFillExpr);
|
|
||||||
taosMemoryFree(pInfo->pNotFillExprInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pInfo->p);
|
taosMemoryFreeClear(pInfo->p);
|
||||||
taosArrayDestroy(pInfo->pColMatchColInfo);
|
taosArrayDestroy(pInfo->pColMatchColInfo);
|
||||||
|
@ -3211,11 +3199,12 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isWstartColumnExist(SFillOperatorInfo* pInfo) {
|
static bool isWstartColumnExist(SFillOperatorInfo* pInfo) {
|
||||||
if (pInfo->numOfNotFillExpr == 0) {
|
if (pInfo->noFillExprSupp.numOfExprs == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int32_t i = 0; i < pInfo->numOfNotFillExpr; ++i) {
|
|
||||||
SExprInfo* exprInfo = pInfo->pNotFillExprInfo + i;
|
for (int32_t i = 0; i < pInfo->noFillExprSupp.numOfExprs; ++i) {
|
||||||
|
SExprInfo* exprInfo = pInfo->noFillExprSupp.pExprInfo + i;
|
||||||
if (exprInfo->pExpr->nodeType == QUERY_NODE_COLUMN && exprInfo->base.numOfParams == 1 &&
|
if (exprInfo->pExpr->nodeType == QUERY_NODE_COLUMN && exprInfo->base.numOfParams == 1 &&
|
||||||
exprInfo->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_START) {
|
exprInfo->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_START) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -3224,25 +3213,24 @@ static bool isWstartColumnExist(SFillOperatorInfo* pInfo) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWStartTsAsNotFillExpr(SFillOperatorInfo* pInfo, SFillPhysiNode* pPhyFillNode) {
|
static int32_t createPrimaryTsExprIfNeeded(SFillOperatorInfo* pInfo, SFillPhysiNode* pPhyFillNode, SExprSupp* pExprSupp,
|
||||||
|
const char* idStr) {
|
||||||
bool wstartExist = isWstartColumnExist(pInfo);
|
bool wstartExist = isWstartColumnExist(pInfo);
|
||||||
|
|
||||||
if (wstartExist == false) {
|
if (wstartExist == false) {
|
||||||
if (pPhyFillNode->pWStartTs->type != QUERY_NODE_TARGET) {
|
if (pPhyFillNode->pWStartTs->type != QUERY_NODE_TARGET) {
|
||||||
qError("pWStartTs of fill physical node is not a target node");
|
qError("pWStartTs of fill physical node is not a target node, %s", idStr);
|
||||||
return TSDB_CODE_QRY_SYS_ERROR;
|
return TSDB_CODE_QRY_SYS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SExprInfo* notFillExprs =
|
SExprInfo* pExpr = taosMemoryRealloc(pExprSupp->pExprInfo, (pExprSupp->numOfExprs + 1) * sizeof(SExprInfo));
|
||||||
taosMemoryRealloc(pInfo->pNotFillExprInfo, (pInfo->numOfNotFillExpr + 1) * sizeof(SExprInfo));
|
if (pExpr == NULL) {
|
||||||
if (notFillExprs == NULL) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
createExprFromTargetNode(notFillExprs + pInfo->numOfNotFillExpr, (STargetNode*)pPhyFillNode->pWStartTs);
|
createExprFromTargetNode(&pExpr[pExprSupp->numOfExprs], (STargetNode*)pPhyFillNode->pWStartTs);
|
||||||
|
pExprSupp->numOfExprs += 1;
|
||||||
++pInfo->numOfNotFillExpr;
|
pExprSupp->pExprInfo = pExpr;
|
||||||
pInfo->pNotFillExprInfo = notFillExprs;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3260,8 +3248,14 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
||||||
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &pInfo->numOfExpr);
|
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &pInfo->numOfExpr);
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
|
|
||||||
pInfo->pNotFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &pInfo->numOfNotFillExpr);
|
SExprSupp* pNoFillSupp = &pInfo->noFillExprSupp;
|
||||||
int32_t code = createWStartTsAsNotFillExpr(pInfo, pPhyFillNode);
|
pNoFillSupp->pExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &pNoFillSupp->numOfExprs);
|
||||||
|
int32_t code = createPrimaryTsExprIfNeeded(pInfo, pPhyFillNode, pNoFillSupp, pTaskInfo->id.str);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = initExprSupp(pNoFillSupp, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -3290,7 +3284,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
||||||
pInfo->pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc,
|
pInfo->pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc,
|
||||||
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||||
|
|
||||||
code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pInfo->pNotFillExprInfo, pInfo->numOfNotFillExpr,
|
code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs,
|
||||||
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
|
||||||
pTaskInfo->id.str, pInterval, type, order);
|
pTaskInfo->id.str, pInterval, type, order);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4292,6 +4286,10 @@ int32_t buildSessionResultDataBlock(SOperatorInfo* pOperator, SStreamState* pSta
|
||||||
void* pVal = NULL;
|
void* pVal = NULL;
|
||||||
int32_t code = streamStateSessionGet(pState, pKey, &pVal, &size);
|
int32_t code = streamStateSessionGet(pState, pKey, &pVal, &size);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
if (code == -1) {
|
||||||
|
// coverity scan
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SResultRow* pRow = (SResultRow*)pVal;
|
SResultRow* pRow = (SResultRow*)pVal;
|
||||||
doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
|
doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
|
||||||
// no results, continue to check the next one
|
// no results, continue to check the next one
|
||||||
|
|
|
@ -360,7 +360,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pOperator->exprSupp.pCtx, pBlock, order, scanFlag, true);
|
setInputDataBlock(&pOperator->exprSupp, pBlock, order, scanFlag, true);
|
||||||
|
|
||||||
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
|
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
|
||||||
if (pInfo->scalarSup.pExprInfo != NULL) {
|
if (pInfo->scalarSup.pExprInfo != NULL) {
|
||||||
|
|
|
@ -285,7 +285,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, false);
|
setInputDataBlock(pSup, pBlock, order, scanFlag, false);
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
||||||
|
|
||||||
code = projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs,
|
code = projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs,
|
||||||
|
@ -446,7 +446,7 @@ static void doHandleDataBlock(SOperatorInfo* pOperator, SSDataBlock* pBlock, SOp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, scanFlag, false);
|
setInputDataBlock(pSup, pBlock, order, scanFlag, false);
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
blockDataEnsureCapacity(pInfo->pRes, pInfo->pRes->info.rows + pBlock->info.rows);
|
||||||
|
|
||||||
code = projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs,
|
code = projectApplyFunctions(pSup->pExprInfo, pInfo->pRes, pBlock, pSup->pCtx, pSup->numOfExprs,
|
||||||
|
|
|
@ -284,7 +284,6 @@ static bool doLoadBlockSMA(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||||
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
||||||
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
||||||
|
@ -743,7 +742,8 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
pInfo->pColMatchInfo = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
pInfo->pColMatchInfo =
|
||||||
|
extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1713,9 +1713,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE) {
|
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE) {
|
||||||
STableScanInfo* pTSInfo = pInfo->pTableScanOp->info;
|
STableScanInfo* pTSInfo = pInfo->pTableScanOp->info;
|
||||||
memcpy(&pTSInfo->cond, &pTaskInfo->streamInfo.tableCond, sizeof(SQueryTableDataCond));
|
memcpy(&pTSInfo->cond, &pTaskInfo->streamInfo.tableCond, sizeof(SQueryTableDataCond));
|
||||||
|
pTSInfo->cond.startVersion = -1;
|
||||||
|
pTSInfo->cond.endVersion = pTaskInfo->streamInfo.fillHistoryVer1;
|
||||||
pTSInfo->scanTimes = 0;
|
pTSInfo->scanTimes = 0;
|
||||||
pTSInfo->currentGroupId = -1;
|
pTSInfo->currentGroupId = -1;
|
||||||
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__SCAN;
|
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__SCAN;
|
||||||
|
@ -1724,12 +1727,14 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__SCAN) {
|
if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__SCAN) {
|
||||||
SSDataBlock* pBlock = doTableScan(pInfo->pTableScanOp);
|
SSDataBlock* pBlock = doTableScan(pInfo->pTableScanOp);
|
||||||
if (pBlock != NULL) {
|
if (pBlock != NULL) {
|
||||||
|
calBlockTbName(&pInfo->tbnameCalSup, pBlock);
|
||||||
|
updateInfoFillBlockData(pInfo->pUpdateInfo, pBlock, pInfo->primaryTsIndex);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
// TODO fill in bloom filter
|
|
||||||
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__NONE;
|
pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__NONE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
|
|
|
@ -272,7 +272,17 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray
|
||||||
char* p = colDataGetData(pSrcCol, rowIndex);
|
char* p = colDataGetData(pSrcCol, rowIndex);
|
||||||
saveColData(pRow, i, p, isNull);
|
saveColData(pRow, i, p, isNull);
|
||||||
} else if (type == QUERY_NODE_OPERATOR) {
|
} else if (type == QUERY_NODE_OPERATOR) {
|
||||||
SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, i);
|
int32_t srcSlotId = GET_DEST_SLOT_ID(&pFillInfo->pFillCol[i]);
|
||||||
|
|
||||||
|
SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
|
||||||
|
|
||||||
|
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
||||||
|
char* p = colDataGetData(pSrcCol, rowIndex);
|
||||||
|
saveColData(pRow, i, p, isNull);
|
||||||
|
} else if (type == QUERY_NODE_FUNCTION) {
|
||||||
|
int32_t srcSlotId = GET_DEST_SLOT_ID(&pFillInfo->pFillCol[i]);
|
||||||
|
|
||||||
|
SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
|
||||||
|
|
||||||
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
||||||
char* p = colDataGetData(pSrcCol, rowIndex);
|
char* p = colDataGetData(pSrcCol, rowIndex);
|
||||||
|
@ -621,8 +631,8 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
|
||||||
int64_t getFillInfoStart(struct SFillInfo* pFillInfo) { return pFillInfo->start; }
|
int64_t getFillInfoStart(struct SFillInfo* pFillInfo) { return pFillInfo->start; }
|
||||||
|
|
||||||
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprInfo* pNotFillExpr,
|
||||||
int32_t numOfNotFillExpr, const struct SNodeListNode* pValNode) {
|
int32_t numOfNoFillExpr, const struct SNodeListNode* pValNode) {
|
||||||
SFillColInfo* pFillCol = taosMemoryCalloc(numOfFillExpr + numOfNotFillExpr, sizeof(SFillColInfo));
|
SFillColInfo* pFillCol = taosMemoryCalloc(numOfFillExpr + numOfNoFillExpr, sizeof(SFillColInfo));
|
||||||
if (pFillCol == NULL) {
|
if (pFillCol == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -643,7 +653,7 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfNotFillExpr; ++i) {
|
for (int32_t i = 0; i < numOfNoFillExpr; ++i) {
|
||||||
SExprInfo* pExprInfo = &pNotFillExpr[i];
|
SExprInfo* pExprInfo = &pNotFillExpr[i];
|
||||||
pFillCol[i + numOfFillExpr].pExpr = pExprInfo;
|
pFillCol[i + numOfFillExpr].pExpr = pExprInfo;
|
||||||
pFillCol[i + numOfFillExpr].notFillCol = true;
|
pFillCol[i + numOfFillExpr].notFillCol = true;
|
||||||
|
@ -1403,7 +1413,7 @@ static void doApplyStreamScalarCalculation(SOperatorInfo* pOperator, SSDataBlock
|
||||||
|
|
||||||
blockDataCleanup(pDstBlock);
|
blockDataCleanup(pDstBlock);
|
||||||
blockDataEnsureCapacity(pDstBlock, pSrcBlock->info.rows);
|
blockDataEnsureCapacity(pDstBlock, pSrcBlock->info.rows);
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false);
|
setInputDataBlock(pSup, pSrcBlock, TSDB_ORDER_ASC, MAIN_SCAN, false);
|
||||||
projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL);
|
projectApplyFunctions(pSup->pExprInfo, pDstBlock, pSrcBlock, pSup->pCtx, pSup->numOfExprs, NULL);
|
||||||
pDstBlock->info.groupId = pSrcBlock->info.groupId;
|
pDstBlock->info.groupId = pSrcBlock->info.groupId;
|
||||||
|
|
||||||
|
@ -1553,8 +1563,8 @@ static SStreamFillSupporter* initStreamFillSup(SStreamFillPhysiNode* pPhyFillNod
|
||||||
}
|
}
|
||||||
pFillSup->numOfFillCols = numOfFillCols;
|
pFillSup->numOfFillCols = numOfFillCols;
|
||||||
int32_t numOfNotFillCols = 0;
|
int32_t numOfNotFillCols = 0;
|
||||||
SExprInfo* pNotFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols);
|
SExprInfo* noFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &numOfNotFillCols);
|
||||||
pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, pNotFillExprInfo, numOfNotFillCols,
|
pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, noFillExprInfo, numOfNotFillCols,
|
||||||
(const SNodeListNode*)(pPhyFillNode->pValues));
|
(const SNodeListNode*)(pPhyFillNode->pValues));
|
||||||
pFillSup->type = convertFillType(pPhyFillNode->mode);
|
pFillSup->type = convertFillType(pPhyFillNode->mode);
|
||||||
pFillSup->numOfAllCols = pFillSup->numOfFillCols + numOfNotFillCols;
|
pFillSup->numOfAllCols = pFillSup->numOfFillCols + numOfNotFillCols;
|
||||||
|
|
|
@ -1079,7 +1079,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, scanFlag, true);
|
setInputDataBlock(pSup, pBlock, pInfo->inputOrder, scanFlag, true);
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
||||||
|
|
||||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag);
|
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag);
|
||||||
|
@ -1209,7 +1209,7 @@ static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||||
|
|
||||||
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
|
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
|
||||||
|
@ -1944,7 +1944,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||||
|
|
||||||
doSessionWindowAggImpl(pOperator, pInfo, pBlock);
|
doSessionWindowAggImpl(pOperator, pInfo, pBlock);
|
||||||
|
@ -2295,7 +2295,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
||||||
|
|
||||||
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, pSliceInfo->tsCol.slotId);
|
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, pSliceInfo->tsCol.slotId);
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
||||||
|
@ -3149,6 +3149,7 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
|
||||||
|
|
||||||
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
TSKEY maxTs = INT64_MIN;
|
TSKEY maxTs = INT64_MIN;
|
||||||
|
@ -3191,6 +3192,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
} else {
|
} else {
|
||||||
deleteIntervalDiscBuf(pInfo->pState, pInfo->pPullDataMap, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark,
|
deleteIntervalDiscBuf(pInfo->pState, pInfo->pPullDataMap, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark,
|
||||||
&pInfo->interval, &pInfo->delKey);
|
&pInfo->interval, &pInfo->delKey);
|
||||||
|
streamStateCommit(pTaskInfo->streamInfo.pState);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3268,7 +3270,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SExprSupp* pExprSup = &pInfo->scalarSupp;
|
SExprSupp* pExprSup = &pInfo->scalarSupp;
|
||||||
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
||||||
}
|
}
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
|
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
|
||||||
if (IS_FINAL_OP(pInfo)) {
|
if (IS_FINAL_OP(pInfo)) {
|
||||||
int32_t chIndex = getChildIndex(pBlock);
|
int32_t chIndex = getChildIndex(pBlock);
|
||||||
|
@ -3286,7 +3288,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
|
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
|
||||||
SStreamIntervalOperatorInfo* pChInfo = pChildOp->info;
|
SStreamIntervalOperatorInfo* pChInfo = pChildOp->info;
|
||||||
setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(&pChildOp->exprSupp, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamIntervalAggImpl(pChildOp, pBlock, pBlock->info.groupId, NULL);
|
doStreamIntervalAggImpl(pChildOp, pBlock, pBlock->info.groupId, NULL);
|
||||||
}
|
}
|
||||||
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
||||||
|
@ -3986,7 +3988,8 @@ int32_t closeSessionWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SSHa
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tSimpleHashIterateRemove(pHashMap, &pWinInfo->sessionWin, sizeof(SSessionKey), &pIte, &iter);
|
SSessionKey* pKey = tSimpleHashGetKey(pIte, &keyLen);
|
||||||
|
tSimpleHashIterateRemove(pHashMap, pKey, sizeof(SSessionKey), &pIte, &iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4006,7 +4009,7 @@ int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated) {
|
||||||
void* pIte = NULL;
|
void* pIte = NULL;
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
|
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
|
||||||
SResultWindowInfo* pWinInfo = *(void**)pIte;
|
SResultWindowInfo* pWinInfo = pIte;
|
||||||
saveResult(*pWinInfo, pStUpdated);
|
saveResult(*pWinInfo, pStUpdated);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4120,7 +4123,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
SExprSupp* pExprSup = &pInfo->scalarSupp;
|
SExprSupp* pExprSup = &pInfo->scalarSupp;
|
||||||
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
||||||
}
|
}
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
|
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, IS_FINAL_OP(pInfo));
|
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, IS_FINAL_OP(pInfo));
|
||||||
if (IS_FINAL_OP(pInfo)) {
|
if (IS_FINAL_OP(pInfo)) {
|
||||||
int32_t chIndex = getChildIndex(pBlock);
|
int32_t chIndex = getChildIndex(pBlock);
|
||||||
|
@ -4135,7 +4139,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
taosArrayPush(pInfo->pChildren, &pChildOp);
|
taosArrayPush(pInfo->pChildren, &pChildOp);
|
||||||
}
|
}
|
||||||
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
|
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
|
||||||
setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(&pChildOp->exprSupp, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamSessionAggImpl(pChildOp, pBlock, NULL, NULL, true);
|
doStreamSessionAggImpl(pChildOp, pBlock, NULL, NULL, true);
|
||||||
}
|
}
|
||||||
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
||||||
|
@ -4334,7 +4338,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
||||||
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
||||||
}
|
}
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, NULL, false);
|
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, NULL, false);
|
||||||
maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||||
}
|
}
|
||||||
|
@ -4583,6 +4587,12 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
SSessionKey key = curWin.winInfo.sessionWin;
|
||||||
|
key.win.ekey = key.win.skey;
|
||||||
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4647,7 +4657,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
||||||
}
|
}
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted);
|
doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted);
|
||||||
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
||||||
}
|
}
|
||||||
|
@ -4917,7 +4927,7 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTableScanInfo(pOperator, &pIaInfo->inputOrder, &scanFlag);
|
getTableScanInfo(pOperator, &pIaInfo->inputOrder, &scanFlag);
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pIaInfo->inputOrder, scanFlag, true);
|
setInputDataBlock(pSup, pBlock, pIaInfo->inputOrder, scanFlag, true);
|
||||||
doMergeAlignedIntervalAggImpl(pOperator, &pIaInfo->binfo.resultRowInfo, pBlock, pRes);
|
doMergeAlignedIntervalAggImpl(pOperator, &pIaInfo->binfo.resultRowInfo, pBlock, pRes);
|
||||||
|
|
||||||
doFilter(pMiaInfo->pCondition, pRes, NULL, NULL);
|
doFilter(pMiaInfo->pCondition, pRes, NULL, NULL);
|
||||||
|
@ -4973,8 +4983,6 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SInterval interval = {.interval = pNode->interval,
|
SInterval interval = {.interval = pNode->interval,
|
||||||
.sliding = pNode->sliding,
|
.sliding = pNode->sliding,
|
||||||
.intervalUnit = pNode->intervalUnit,
|
.intervalUnit = pNode->intervalUnit,
|
||||||
|
@ -5246,7 +5254,7 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTableScanInfo(pOperator, &iaInfo->inputOrder, &scanFlag);
|
getTableScanInfo(pOperator, &iaInfo->inputOrder, &scanFlag);
|
||||||
setInputDataBlock(pOperator, pExpSupp->pCtx, pBlock, iaInfo->inputOrder, scanFlag, true);
|
setInputDataBlock(pExpSupp, pBlock, iaInfo->inputOrder, scanFlag, true);
|
||||||
doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
|
doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
|
||||||
|
|
||||||
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
||||||
|
@ -5381,6 +5389,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
deleteIntervalDiscBuf(pInfo->pState, NULL, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark, &pInfo->interval,
|
deleteIntervalDiscBuf(pInfo->pState, NULL, pInfo->twAggSup.maxTs - pInfo->twAggSup.deleteMark, &pInfo->interval,
|
||||||
&pInfo->delKey);
|
&pInfo->delKey);
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
streamStateCommit(pTaskInfo->streamInfo.pState);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5425,7 +5434,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
// The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
|
// The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
|
||||||
// caller. Note that all the time window are not close till now.
|
// caller. Note that all the time window are not close till now.
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
if (pInfo->invertible) {
|
if (pInfo->invertible) {
|
||||||
setInverFunction(pSup->pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.type);
|
setInverFunction(pSup->pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.type);
|
||||||
}
|
}
|
||||||
|
@ -5475,9 +5484,11 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
}
|
}
|
||||||
SStreamIntervalPhysiNode* pIntervalPhyNode = (SStreamIntervalPhysiNode*)pPhyNode;
|
SStreamIntervalPhysiNode* pIntervalPhyNode = (SStreamIntervalPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols);
|
||||||
ASSERT(numOfCols > 0);
|
ASSERT(numOfCols > 0);
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||||
SInterval interval = {
|
SInterval interval = {
|
||||||
.interval = pIntervalPhyNode->interval,
|
.interval = pIntervalPhyNode->interval,
|
||||||
|
@ -5487,6 +5498,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
.offset = pIntervalPhyNode->offset,
|
.offset = pIntervalPhyNode->offset,
|
||||||
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
|
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
|
||||||
};
|
};
|
||||||
|
|
||||||
STimeWindowAggSupp twAggSupp = {
|
STimeWindowAggSupp twAggSupp = {
|
||||||
.waterMark = pIntervalPhyNode->window.watermark,
|
.waterMark = pIntervalPhyNode->window.watermark,
|
||||||
.calTrigger = pIntervalPhyNode->window.triggerType,
|
.calTrigger = pIntervalPhyNode->window.triggerType,
|
||||||
|
@ -5494,6 +5506,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
.minTs = INT64_MAX,
|
.minTs = INT64_MAX,
|
||||||
.deleteMark = INT64_MAX,
|
.deleteMark = INT64_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
ASSERT(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pInfo->interval = interval;
|
pInfo->interval = interval;
|
||||||
|
@ -5501,16 +5514,25 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired;
|
pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired;
|
||||||
pInfo->isFinal = false;
|
pInfo->isFinal = false;
|
||||||
|
|
||||||
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
|
||||||
SExprSupp* pSup = &pOperator->exprSupp;
|
SExprSupp* pSup = &pOperator->exprSupp;
|
||||||
|
|
||||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||||
initStreamFunciton(pSup->pCtx, pSup->numOfExprs);
|
initStreamFunciton(pSup->pCtx, pSup->numOfExprs);
|
||||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||||
|
|
||||||
|
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||||
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
|
||||||
|
if (pIntervalPhyNode->window.pExprs != NULL) {
|
||||||
|
int32_t numOfScalar = 0;
|
||||||
|
SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar);
|
||||||
|
code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
int32_t code = initAggInfo(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
code = initAggInfo(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2405,6 +2405,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.processFunc = cachedLastRowFunction,
|
.processFunc = cachedLastRowFunction,
|
||||||
.finalizeFunc = firstLastFinalize
|
.finalizeFunc = firstLastFinalize
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "_cache_last",
|
||||||
|
.type = FUNCTION_TYPE_CACHE_LAST,
|
||||||
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||||
|
.translateFunc = translateFirstLast,
|
||||||
|
.getEnvFunc = getFirstLastFuncEnv,
|
||||||
|
.initFunc = functionSetup,
|
||||||
|
.processFunc = lastFunctionMerge,
|
||||||
|
.finalizeFunc = firstLastFinalize
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "_last_row_partial",
|
.name = "_last_row_partial",
|
||||||
.type = FUNCTION_TYPE_LAST_PARTIAL,
|
.type = FUNCTION_TYPE_LAST_PARTIAL,
|
||||||
|
|
|
@ -57,16 +57,6 @@ typedef struct SAvgRes {
|
||||||
int16_t type; // store the original input type, used in merge function
|
int16_t type; // store the original input type, used in merge function
|
||||||
} SAvgRes;
|
} SAvgRes;
|
||||||
|
|
||||||
typedef struct STuplePos {
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
int32_t pageId;
|
|
||||||
int32_t offset;
|
|
||||||
};
|
|
||||||
STupleKey streamTupleKey;
|
|
||||||
};
|
|
||||||
} STuplePos;
|
|
||||||
|
|
||||||
typedef struct SMinmaxResInfo {
|
typedef struct SMinmaxResInfo {
|
||||||
bool assign; // assign the first value or not
|
bool assign; // assign the first value or not
|
||||||
int64_t v;
|
int64_t v;
|
||||||
|
@ -93,17 +83,6 @@ typedef struct STopBotRes {
|
||||||
STopBotResItem* pItems;
|
STopBotResItem* pItems;
|
||||||
} STopBotRes;
|
} STopBotRes;
|
||||||
|
|
||||||
typedef struct SFirstLastRes {
|
|
||||||
bool hasResult;
|
|
||||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
|
||||||
// this attribute is required
|
|
||||||
bool isNull;
|
|
||||||
int32_t bytes;
|
|
||||||
int64_t ts;
|
|
||||||
STuplePos pos;
|
|
||||||
char buf[];
|
|
||||||
} SFirstLastRes;
|
|
||||||
|
|
||||||
typedef struct SStddevRes {
|
typedef struct SStddevRes {
|
||||||
double result;
|
double result;
|
||||||
int64_t count;
|
int64_t count;
|
||||||
|
@ -1163,13 +1142,13 @@ static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, c
|
||||||
// the data is loaded, not only the block SMA value
|
// the data is loaded, not only the block SMA value
|
||||||
for (int32_t i = start; i < num + start; ++i) {
|
for (int32_t i = start; i < num + start; ++i) {
|
||||||
char* p = colDataGetData(pCol, i);
|
char* p = colDataGetData(pCol, i);
|
||||||
if (memcpy((void*)tval, p, pCol->info.bytes) == 0) {
|
if (memcmp((void*)tval, p, pCol->info.bytes) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(0);
|
// if reach here means real data of block SMA is not set in pCtx->input.
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
|
@ -1211,8 +1190,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
pBuf->v = *(int64_t*)tval;
|
pBuf->v = *(int64_t*)tval;
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
int64_t prev = 0;
|
int64_t prev = 0;
|
||||||
|
@ -1223,9 +1204,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
*(int64_t*)&pBuf->v = val;
|
*(int64_t*)&pBuf->v = val;
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
uint64_t prev = 0;
|
uint64_t prev = 0;
|
||||||
GET_TYPED_DATA(prev, uint64_t, type, &pBuf->v);
|
GET_TYPED_DATA(prev, uint64_t, type, &pBuf->v);
|
||||||
|
@ -1235,9 +1218,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
*(uint64_t*)&pBuf->v = val;
|
*(uint64_t*)&pBuf->v = val;
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
double prev = 0;
|
double prev = 0;
|
||||||
GET_TYPED_DATA(prev, double, type, &pBuf->v);
|
GET_TYPED_DATA(prev, double, type, &pBuf->v);
|
||||||
|
@ -1247,9 +1232,11 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
*(double*)&pBuf->v = val;
|
*(double*)&pBuf->v = val;
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
float prev = 0;
|
float prev = 0;
|
||||||
GET_TYPED_DATA(prev, float, type, &pBuf->v);
|
GET_TYPED_DATA(prev, float, type, &pBuf->v);
|
||||||
|
@ -1261,10 +1248,12 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||||
|
|
||||||
if (pCtx->subsidiaries.num > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval);
|
||||||
|
if (index >= 0) {
|
||||||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pBuf->assign = true;
|
pBuf->assign = true;
|
||||||
return numOfElems;
|
return numOfElems;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
|
#include "builtinsimpl.h"
|
||||||
#include "functionMgtInt.h"
|
#include "functionMgtInt.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
@ -314,6 +315,11 @@ bool fmIsSameInOutType(int32_t funcId) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getLastCacheDataType(SDataType* pType) {
|
||||||
|
pType->bytes = getFirstLastInfoSize(pType->bytes) + VARSTR_HEADER_SIZE;
|
||||||
|
pType->type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t getFuncInfo(SFunctionNode* pFunc) {
|
static int32_t getFuncInfo(SFunctionNode* pFunc) {
|
||||||
char msg[128] = {0};
|
char msg[128] = {0};
|
||||||
return fmGetFuncInfo(pFunc, msg, sizeof(msg));
|
return fmGetFuncInfo(pFunc, msg, sizeof(msg));
|
||||||
|
|
|
@ -339,10 +339,11 @@ typedef struct SUdfcProxy {
|
||||||
uv_mutex_t udfStubsMutex;
|
uv_mutex_t udfStubsMutex;
|
||||||
SArray *udfStubs; // SUdfcFuncStub
|
SArray *udfStubs; // SUdfcFuncStub
|
||||||
|
|
||||||
|
uv_mutex_t udfcUvMutex;
|
||||||
int8_t initialized;
|
int8_t initialized;
|
||||||
} SUdfcProxy;
|
} SUdfcProxy;
|
||||||
|
|
||||||
SUdfcProxy gUdfdProxy = {0};
|
SUdfcProxy gUdfcProxy = {0};
|
||||||
|
|
||||||
typedef struct SUdfcUvSession {
|
typedef struct SUdfcUvSession {
|
||||||
SUdfcProxy *udfc;
|
SUdfcProxy *udfc;
|
||||||
|
@ -896,73 +897,73 @@ int compareUdfcFuncSub(const void *elem1, const void *elem2) {
|
||||||
|
|
||||||
int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
|
int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
uv_mutex_lock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||||
SUdfcFuncStub key = {0};
|
SUdfcFuncStub key = {0};
|
||||||
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
int32_t stubIndex = taosArraySearchIdx(gUdfdProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
int32_t stubIndex = taosArraySearchIdx(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||||
if (stubIndex != -1) {
|
if (stubIndex != -1) {
|
||||||
SUdfcFuncStub *foundStub = taosArrayGet(gUdfdProxy.udfStubs, stubIndex);
|
SUdfcFuncStub *foundStub = taosArrayGet(gUdfcProxy.udfStubs, stubIndex);
|
||||||
UdfcFuncHandle handle = foundStub->handle;
|
UdfcFuncHandle handle = foundStub->handle;
|
||||||
if (handle != NULL && ((SUdfcUvSession *)handle)->udfUvPipe != NULL) {
|
if (handle != NULL && ((SUdfcUvSession *)handle)->udfUvPipe != NULL) {
|
||||||
*pHandle = foundStub->handle;
|
*pHandle = foundStub->handle;
|
||||||
++foundStub->refCount;
|
++foundStub->refCount;
|
||||||
foundStub->lastRefTime = taosGetTimestampUs();
|
foundStub->lastRefTime = taosGetTimestampUs();
|
||||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_unlock(&gUdfcProxy.udfStubsMutex);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
fnInfo("invalid handle for %s, refCount: %d, last ref time: %" PRId64 ". remove it from cache", udfName,
|
fnInfo("invalid handle for %s, refCount: %d, last ref time: %" PRId64 ". remove it from cache", udfName,
|
||||||
foundStub->refCount, foundStub->lastRefTime);
|
foundStub->refCount, foundStub->lastRefTime);
|
||||||
taosArrayRemove(gUdfdProxy.udfStubs, stubIndex);
|
taosArrayRemove(gUdfcProxy.udfStubs, stubIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pHandle = NULL;
|
*pHandle = NULL;
|
||||||
code = doSetupUdf(udfName, pHandle);
|
code = doSetupUdf(udfName, pHandle);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
SUdfcFuncStub stub = {0};
|
SUdfcFuncStub stub = {0};
|
||||||
strcpy(stub.udfName, udfName);
|
strncpy(stub.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
stub.handle = *pHandle;
|
stub.handle = *pHandle;
|
||||||
++stub.refCount;
|
++stub.refCount;
|
||||||
stub.lastRefTime = taosGetTimestampUs();
|
stub.lastRefTime = taosGetTimestampUs();
|
||||||
taosArrayPush(gUdfdProxy.udfStubs, &stub);
|
taosArrayPush(gUdfcProxy.udfStubs, &stub);
|
||||||
taosArraySort(gUdfdProxy.udfStubs, compareUdfcFuncSub);
|
taosArraySort(gUdfcProxy.udfStubs, compareUdfcFuncSub);
|
||||||
} else {
|
} else {
|
||||||
*pHandle = NULL;
|
*pHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_unlock(&gUdfcProxy.udfStubsMutex);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void releaseUdfFuncHandle(char *udfName) {
|
void releaseUdfFuncHandle(char *udfName) {
|
||||||
uv_mutex_lock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||||
SUdfcFuncStub key = {0};
|
SUdfcFuncStub key = {0};
|
||||||
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
SUdfcFuncStub *foundStub = taosArraySearch(gUdfdProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
SUdfcFuncStub *foundStub = taosArraySearch(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||||
if (!foundStub) {
|
if (!foundStub) {
|
||||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_unlock(&gUdfcProxy.udfStubsMutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (foundStub->refCount > 0) {
|
if (foundStub->refCount > 0) {
|
||||||
--foundStub->refCount;
|
--foundStub->refCount;
|
||||||
}
|
}
|
||||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_unlock(&gUdfcProxy.udfStubsMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cleanUpUdfs() {
|
int32_t cleanUpUdfs() {
|
||||||
int8_t initialized = atomic_load_8(&gUdfdProxy.initialized);
|
int8_t initialized = atomic_load_8(&gUdfcProxy.initialized);
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_mutex_lock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||||
if (gUdfdProxy.udfStubs == NULL || taosArrayGetSize(gUdfdProxy.udfStubs) == 0) {
|
if (gUdfcProxy.udfStubs == NULL || taosArrayGetSize(gUdfcProxy.udfStubs) == 0) {
|
||||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_unlock(&gUdfcProxy.udfStubsMutex);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
SArray *udfStubs = taosArrayInit(16, sizeof(SUdfcFuncStub));
|
SArray *udfStubs = taosArrayInit(16, sizeof(SUdfcFuncStub));
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (i < taosArrayGetSize(gUdfdProxy.udfStubs)) {
|
while (i < taosArrayGetSize(gUdfcProxy.udfStubs)) {
|
||||||
SUdfcFuncStub *stub = taosArrayGet(gUdfdProxy.udfStubs, i);
|
SUdfcFuncStub *stub = taosArrayGet(gUdfcProxy.udfStubs, i);
|
||||||
if (stub->refCount == 0) {
|
if (stub->refCount == 0) {
|
||||||
fnInfo("tear down udf. udf name: %s, handle: %p, ref count: %d", stub->udfName, stub->handle, stub->refCount);
|
fnInfo("tear down udf. udf name: %s, handle: %p, ref count: %d", stub->udfName, stub->handle, stub->refCount);
|
||||||
doTeardownUdf(stub->handle);
|
doTeardownUdf(stub->handle);
|
||||||
|
@ -979,9 +980,9 @@ int32_t cleanUpUdfs() {
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
taosArrayDestroy(gUdfdProxy.udfStubs);
|
taosArrayDestroy(gUdfcProxy.udfStubs);
|
||||||
gUdfdProxy.udfStubs = udfStubs;
|
gUdfcProxy.udfStubs = udfStubs;
|
||||||
uv_mutex_unlock(&gUdfdProxy.udfStubsMutex);
|
uv_mutex_unlock(&gUdfcProxy.udfStubsMutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,9 +1158,11 @@ void onUdfcPipeClose(uv_handle_t *handle) {
|
||||||
QUEUE_REMOVE(&task->procTaskQueue);
|
QUEUE_REMOVE(&task->procTaskQueue);
|
||||||
uv_sem_post(&task->taskSem);
|
uv_sem_post(&task->taskSem);
|
||||||
}
|
}
|
||||||
|
uv_mutex_lock(&gUdfcProxy.udfcUvMutex);
|
||||||
if (conn->session != NULL) {
|
if (conn->session != NULL) {
|
||||||
conn->session->udfUvPipe = NULL;
|
conn->session->udfUvPipe = NULL;
|
||||||
}
|
}
|
||||||
|
uv_mutex_unlock(&gUdfcProxy.udfcUvMutex);
|
||||||
taosMemoryFree(conn->readBuf.buf);
|
taosMemoryFree(conn->readBuf.buf);
|
||||||
taosMemoryFree(conn);
|
taosMemoryFree(conn);
|
||||||
taosMemoryFree((uv_pipe_t *)handle);
|
taosMemoryFree((uv_pipe_t *)handle);
|
||||||
|
@ -1553,11 +1556,11 @@ void constructUdfService(void *argsThread) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udfcOpen() {
|
int32_t udfcOpen() {
|
||||||
int8_t old = atomic_val_compare_exchange_8(&gUdfdProxy.initialized, 0, 1);
|
int8_t old = atomic_val_compare_exchange_8(&gUdfcProxy.initialized, 0, 1);
|
||||||
if (old == 1) {
|
if (old == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SUdfcProxy *proxy = &gUdfdProxy;
|
SUdfcProxy *proxy = &gUdfcProxy;
|
||||||
getUdfdPipeName(proxy->udfdPipeName, sizeof(proxy->udfdPipeName));
|
getUdfdPipeName(proxy->udfdPipeName, sizeof(proxy->udfdPipeName));
|
||||||
proxy->udfcState = UDFC_STATE_STARTNG;
|
proxy->udfcState = UDFC_STATE_STARTNG;
|
||||||
uv_barrier_init(&proxy->initBarrier, 2);
|
uv_barrier_init(&proxy->initBarrier, 2);
|
||||||
|
@ -1567,16 +1570,17 @@ int32_t udfcOpen() {
|
||||||
uv_barrier_wait(&proxy->initBarrier);
|
uv_barrier_wait(&proxy->initBarrier);
|
||||||
uv_mutex_init(&proxy->udfStubsMutex);
|
uv_mutex_init(&proxy->udfStubsMutex);
|
||||||
proxy->udfStubs = taosArrayInit(8, sizeof(SUdfcFuncStub));
|
proxy->udfStubs = taosArrayInit(8, sizeof(SUdfcFuncStub));
|
||||||
|
uv_mutex_init(&proxy->udfcUvMutex);
|
||||||
fnInfo("udfc initialized") return 0;
|
fnInfo("udfc initialized") return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udfcClose() {
|
int32_t udfcClose() {
|
||||||
int8_t old = atomic_val_compare_exchange_8(&gUdfdProxy.initialized, 1, 0);
|
int8_t old = atomic_val_compare_exchange_8(&gUdfcProxy.initialized, 1, 0);
|
||||||
if (old == 0) {
|
if (old == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SUdfcProxy *udfc = &gUdfdProxy;
|
SUdfcProxy *udfc = &gUdfcProxy;
|
||||||
udfc->udfcState = UDFC_STATE_STOPPING;
|
udfc->udfcState = UDFC_STATE_STOPPING;
|
||||||
uv_async_send(&udfc->loopStopAsync);
|
uv_async_send(&udfc->loopStopAsync);
|
||||||
uv_thread_join(&udfc->loopThread);
|
uv_thread_join(&udfc->loopThread);
|
||||||
|
@ -1584,6 +1588,7 @@ int32_t udfcClose() {
|
||||||
uv_barrier_destroy(&udfc->initBarrier);
|
uv_barrier_destroy(&udfc->initBarrier);
|
||||||
taosArrayDestroy(udfc->udfStubs);
|
taosArrayDestroy(udfc->udfStubs);
|
||||||
uv_mutex_destroy(&udfc->udfStubsMutex);
|
uv_mutex_destroy(&udfc->udfStubsMutex);
|
||||||
|
uv_mutex_destroy(&udfc->udfcUvMutex);
|
||||||
udfc->udfcState = UDFC_STATE_INITAL;
|
udfc->udfcState = UDFC_STATE_INITAL;
|
||||||
fnInfo("udfc is cleaned up");
|
fnInfo("udfc is cleaned up");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1611,13 +1616,13 @@ int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
||||||
if (gUdfdProxy.udfcState != UDFC_STATE_READY) {
|
if (gUdfcProxy.udfcState != UDFC_STATE_READY) {
|
||||||
return TSDB_CODE_UDF_INVALID_STATE;
|
return TSDB_CODE_UDF_INVALID_STATE;
|
||||||
}
|
}
|
||||||
SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask));
|
SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask));
|
||||||
task->errCode = 0;
|
task->errCode = 0;
|
||||||
task->session = taosMemoryCalloc(1, sizeof(SUdfcUvSession));
|
task->session = taosMemoryCalloc(1, sizeof(SUdfcUvSession));
|
||||||
task->session->udfc = &gUdfdProxy;
|
task->session->udfc = &gUdfcProxy;
|
||||||
task->type = UDF_TASK_SETUP;
|
task->type = UDF_TASK_SETUP;
|
||||||
|
|
||||||
SUdfSetupRequest *req = &task->_setup.req;
|
SUdfSetupRequest *req = &task->_setup.req;
|
||||||
|
@ -1625,7 +1630,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
||||||
|
|
||||||
int32_t errCode = udfcRunUdfUvTask(task, UV_TASK_CONNECT);
|
int32_t errCode = udfcRunUdfUvTask(task, UV_TASK_CONNECT);
|
||||||
if (errCode != 0) {
|
if (errCode != 0) {
|
||||||
fnError("failed to connect to pipe. udfName: %s, pipe: %s", udfName, (&gUdfdProxy)->udfdPipeName);
|
fnError("failed to connect to pipe. udfName: %s, pipe: %s", udfName, (&gUdfcProxy)->udfdPipeName);
|
||||||
taosMemoryFree(task->session);
|
taosMemoryFree(task->session);
|
||||||
taosMemoryFree(task);
|
taosMemoryFree(task);
|
||||||
return TSDB_CODE_UDF_PIPE_CONNECT_ERR;
|
return TSDB_CODE_UDF_PIPE_CONNECT_ERR;
|
||||||
|
@ -1799,10 +1804,12 @@ int32_t doTeardownUdf(UdfcFuncHandle handle) {
|
||||||
|
|
||||||
fnInfo("tear down udf. udf name: %s, udf func handle: %p", session->udfName, handle);
|
fnInfo("tear down udf. udf name: %s, udf func handle: %p", session->udfName, handle);
|
||||||
// TODO: synchronization refactor between libuv event loop and request thread
|
// TODO: synchronization refactor between libuv event loop and request thread
|
||||||
|
uv_mutex_lock(&gUdfcProxy.udfcUvMutex);
|
||||||
if (session->udfUvPipe != NULL && session->udfUvPipe->data != NULL) {
|
if (session->udfUvPipe != NULL && session->udfUvPipe->data != NULL) {
|
||||||
SClientUvConn *conn = session->udfUvPipe->data;
|
SClientUvConn *conn = session->udfUvPipe->data;
|
||||||
conn->session = NULL;
|
conn->session = NULL;
|
||||||
}
|
}
|
||||||
|
uv_mutex_unlock(&gUdfcProxy.udfcUvMutex);
|
||||||
taosMemoryFree(session);
|
taosMemoryFree(session);
|
||||||
taosMemoryFree(task);
|
taosMemoryFree(task);
|
||||||
|
|
||||||
|
|
|
@ -1969,7 +1969,7 @@ static int32_t msgToPhysiScanNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { PHY_LAST_ROW_SCAN_CODE_SCAN = 1, PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT };
|
enum { PHY_LAST_ROW_SCAN_CODE_SCAN = 1, PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT, PHY_LAST_ROW_SCAN_CODE_IGNULL };
|
||||||
|
|
||||||
static int32_t physiLastRowScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
static int32_t physiLastRowScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
const SLastRowScanPhysiNode* pNode = (const SLastRowScanPhysiNode*)pObj;
|
const SLastRowScanPhysiNode* pNode = (const SLastRowScanPhysiNode*)pObj;
|
||||||
|
@ -1981,6 +1981,9 @@ static int32_t physiLastRowScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeBool(pEncoder, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT, pNode->groupSort);
|
code = tlvEncodeBool(pEncoder, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT, pNode->groupSort);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeBool(pEncoder, PHY_LAST_ROW_SCAN_CODE_IGNULL, pNode->ignoreNull);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2001,6 +2004,9 @@ static int32_t msgToPhysiLastRowScanNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
case PHY_LAST_ROW_SCAN_CODE_GROUP_SORT:
|
case PHY_LAST_ROW_SCAN_CODE_GROUP_SORT:
|
||||||
code = tlvDecodeBool(pTlv, &pNode->groupSort);
|
code = tlvDecodeBool(pTlv, &pNode->groupSort);
|
||||||
break;
|
break;
|
||||||
|
case PHY_LAST_ROW_SCAN_CODE_IGNULL:
|
||||||
|
code = tlvDecodeBool(pTlv, &pNode->ignoreNull);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,8 +224,8 @@ alter_db_option(A) ::= WAL_FSYNC_PERIOD NK_INTEGER(B).
|
||||||
alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
||||||
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
||||||
alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
|
alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
|
||||||
//alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
||||||
//alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
||||||
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||||
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
||||||
|
|
||||||
|
|
|
@ -455,8 +455,13 @@ static int32_t collectMetaKeyFromShowLicence(SCollectMetaKeyCxt* pCxt, SShowStmt
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowVgroups(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowVgroups(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS,
|
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
// just to verify whether the database exists
|
||||||
|
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
|
|
@ -6212,6 +6212,20 @@ static int32_t rewriteShow(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkShowVgroups(STranslateContext* pCxt, SShowStmt* pShow) {
|
||||||
|
// just to verify whether the database exists
|
||||||
|
SDbCfgInfo dbCfg = {0};
|
||||||
|
return getDBCfg(pCxt, ((SValueNode*)pShow->pDbName)->literal, &dbCfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteShowVgroups(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
|
int32_t code = checkShowVgroups(pCxt, (SShowStmt*)pQuery->pRoot);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = rewriteShow(pCxt, pQuery);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static SNode* createTagsFunction() {
|
static SNode* createTagsFunction() {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
if (NULL == pFunc) {
|
if (NULL == pFunc) {
|
||||||
|
@ -7358,7 +7372,6 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_USERS_STMT:
|
case QUERY_NODE_SHOW_USERS_STMT:
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||||
|
@ -7378,6 +7391,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
code = rewriteShow(pCxt, pQuery);
|
code = rewriteShow(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||||
|
code = rewriteShowVgroups(pCxt, pQuery);
|
||||||
|
break;
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
code = rewriteShowStableTags(pCxt, pQuery);
|
code = rewriteShowStableTags(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2139,6 +2139,46 @@ static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
|
||||||
return rewriteUniqueOptimizeImpl(pCxt, pLogicSubplan, pIndef);
|
return rewriteUniqueOptimizeImpl(pCxt, pLogicSubplan, pIndef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SLastRowScanOptLastParaCkCxt {
|
||||||
|
bool hasTag;
|
||||||
|
bool hasCol;
|
||||||
|
} SLastRowScanOptLastParaCkCxt;
|
||||||
|
|
||||||
|
static EDealRes lastRowScanOptLastParaCheckImpl(SNode* pNode, void* pContext) {
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
|
SLastRowScanOptLastParaCkCxt* pCxt = pContext;
|
||||||
|
if (COLUMN_TYPE_TAG == ((SColumnNode*)pNode)->colType || COLUMN_TYPE_TBNAME == ((SColumnNode*)pNode)->colType) {
|
||||||
|
pCxt->hasTag = true;
|
||||||
|
} else {
|
||||||
|
pCxt->hasCol = true;
|
||||||
|
}
|
||||||
|
return DEAL_RES_END;
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool lastRowScanOptLastParaCheck(SNode* pExpr) {
|
||||||
|
SLastRowScanOptLastParaCkCxt cxt = {.hasTag = false, .hasCol = false};
|
||||||
|
nodesWalkExpr(pExpr, lastRowScanOptLastParaCheckImpl, &cxt);
|
||||||
|
return !cxt.hasTag && cxt.hasCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasSuitableCache(int8_t cacheLastMode, bool hasLastRow, bool hasLast) {
|
||||||
|
switch (cacheLastMode) {
|
||||||
|
case TSDB_CACHE_MODEL_NONE:
|
||||||
|
return false;
|
||||||
|
case TSDB_CACHE_MODEL_LAST_ROW:
|
||||||
|
return hasLastRow;
|
||||||
|
case TSDB_CACHE_MODEL_LAST_VALUE:
|
||||||
|
return hasLast;
|
||||||
|
case TSDB_CACHE_MODEL_BOTH:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
|
static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) ||
|
if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) ||
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0))) {
|
QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0))) {
|
||||||
|
@ -2149,16 +2189,27 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0);
|
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0);
|
||||||
// Only one of LAST and LASTROW can appear
|
// Only one of LAST and LASTROW can appear
|
||||||
if (pAgg->hasLastRow == pAgg->hasLast || NULL != pAgg->pGroupKeys || NULL != pScan->node.pConditions ||
|
if (pAgg->hasLastRow == pAgg->hasLast || NULL != pAgg->pGroupKeys || NULL != pScan->node.pConditions ||
|
||||||
0 == pScan->cacheLastMode || IS_TSWINDOW_SPECIFIED(pScan->scanRange)) {
|
!hasSuitableCache(pScan->cacheLastMode, pAgg->hasLastRow, pAgg->hasLast) ||
|
||||||
|
IS_TSWINDOW_SPECIFIED(pScan->scanRange)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasLastFunc = false;
|
||||||
|
bool hasSelectFunc = false;
|
||||||
SNode* pFunc = NULL;
|
SNode* pFunc = NULL;
|
||||||
FOREACH(pFunc, ((SAggLogicNode*)pNode)->pAggFuncs) {
|
FOREACH(pFunc, ((SAggLogicNode*)pNode)->pAggFuncs) {
|
||||||
if (FUNCTION_TYPE_LAST_ROW != ((SFunctionNode*)pFunc)->funcType &&
|
SFunctionNode* pAggFunc = (SFunctionNode*)pFunc;
|
||||||
// FUNCTION_TYPE_LAST != ((SFunctionNode*)pFunc)->funcType &&
|
if (FUNCTION_TYPE_LAST == pAggFunc->funcType) {
|
||||||
FUNCTION_TYPE_SELECT_VALUE != ((SFunctionNode*)pFunc)->funcType &&
|
if (hasSelectFunc || !lastRowScanOptLastParaCheck(nodesListGetNode(pAggFunc->pParameterList, 0))) {
|
||||||
FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pFunc)->funcType) {
|
return false;
|
||||||
|
}
|
||||||
|
hasLastFunc = true;
|
||||||
|
} else if (FUNCTION_TYPE_SELECT_VALUE == pAggFunc->funcType || FUNCTION_TYPE_GROUP_KEY == pAggFunc->funcType) {
|
||||||
|
if (hasLastFunc) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hasSelectFunc = true;
|
||||||
|
} else if (FUNCTION_TYPE_LAST_ROW != pAggFunc->funcType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2166,6 +2217,31 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SLastRowScanOptSetColDataTypeCxt {
|
||||||
|
bool doAgg;
|
||||||
|
SNodeList* pLastCols;
|
||||||
|
} SLastRowScanOptSetColDataTypeCxt;
|
||||||
|
|
||||||
|
static EDealRes lastRowScanOptSetColDataType(SNode* pNode, void* pContext) {
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
|
SLastRowScanOptSetColDataTypeCxt* pCxt = pContext;
|
||||||
|
if (pCxt->doAgg) {
|
||||||
|
nodesListMakeAppend(&pCxt->pLastCols, pNode);
|
||||||
|
getLastCacheDataType(&(((SColumnNode*)pNode)->node.resType));
|
||||||
|
} else {
|
||||||
|
SNode* pCol = NULL;
|
||||||
|
FOREACH(pCol, pCxt->pLastCols) {
|
||||||
|
if (nodesEqualNode(pCol, pNode)) {
|
||||||
|
getLastCacheDataType(&(((SColumnNode*)pNode)->node.resType));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
|
static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
|
||||||
SAggLogicNode* pAgg = (SAggLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, lastRowScanOptMayBeOptimized);
|
SAggLogicNode* pAgg = (SAggLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, lastRowScanOptMayBeOptimized);
|
||||||
|
|
||||||
|
@ -2173,22 +2249,36 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SLastRowScanOptSetColDataTypeCxt cxt = {.doAgg = true, .pLastCols = NULL};
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pAgg->pAggFuncs) {
|
FOREACH(pNode, pAgg->pAggFuncs) {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
if (FUNCTION_TYPE_LAST_ROW == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType) {
|
int32_t funcType = pFunc->funcType;
|
||||||
int32_t len = snprintf(pFunc->functionName, sizeof(pFunc->functionName), "_cache_last_row");
|
if (FUNCTION_TYPE_LAST_ROW == funcType || FUNCTION_TYPE_LAST == funcType) {
|
||||||
|
int32_t len = snprintf(pFunc->functionName, sizeof(pFunc->functionName),
|
||||||
|
FUNCTION_TYPE_LAST_ROW == funcType ? "_cache_last_row" : "_cache_last");
|
||||||
pFunc->functionName[len] = '\0';
|
pFunc->functionName[len] = '\0';
|
||||||
int32_t code = fmGetFuncInfo(pFunc, NULL, 0);
|
int32_t code = fmGetFuncInfo(pFunc, NULL, 0);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
nodesClearList(cxt.pLastCols);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
if (FUNCTION_TYPE_LAST == funcType) {
|
||||||
|
nodesWalkExpr(nodesListGetNode(pFunc->pParameterList, 0), lastRowScanOptSetColDataType, &cxt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0);
|
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0);
|
||||||
pScan->scanType = SCAN_TYPE_LAST_ROW;
|
pScan->scanType = SCAN_TYPE_LAST_ROW;
|
||||||
pScan->igLastNull = pAgg->hasLast ? true : false;
|
pScan->igLastNull = pAgg->hasLast ? true : false;
|
||||||
|
if (NULL != cxt.pLastCols) {
|
||||||
|
cxt.doAgg = false;
|
||||||
|
nodesWalkExprs(pScan->pScanCols, lastRowScanOptSetColDataType, &cxt);
|
||||||
|
nodesWalkExprs(pScan->pScanPseudoCols, lastRowScanOptSetColDataType, &cxt);
|
||||||
|
nodesWalkExprs(pScan->node.pTargets, lastRowScanOptSetColDataType, &cxt);
|
||||||
|
nodesClearList(cxt.pLastCols);
|
||||||
|
}
|
||||||
pAgg->hasLastRow = false;
|
pAgg->hasLastRow = false;
|
||||||
pAgg->hasLast = false;
|
pAgg->hasLast = false;
|
||||||
|
|
||||||
|
|
|
@ -105,24 +105,6 @@ TEST_F(PlanBasicTest, interpFunc) {
|
||||||
run("SELECT _IROWTS, INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)");
|
run("SELECT _IROWTS, INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanBasicTest, lastRowFunc) {
|
|
||||||
useDb("root", "cache_db");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(c1) FROM t1");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(*) FROM t1");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(c1, c2) FROM t1");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(c1), c2 FROM t1");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(c1) FROM st1");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(c1) FROM st1 PARTITION BY TBNAME");
|
|
||||||
|
|
||||||
run("SELECT LAST_ROW(c1), SUM(c3) FROM t1");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(PlanBasicTest, lastRowFuncWithoutCache) {
|
TEST_F(PlanBasicTest, lastRowFuncWithoutCache) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,28 @@ TEST_F(PlanOptimizeTest, mergeProjects) {
|
||||||
|
|
||||||
TEST_F(PlanOptimizeTest, pushDownProjectCond) {
|
TEST_F(PlanOptimizeTest, pushDownProjectCond) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("select 1-abs(c1) from (select unique(c1) c1 from st1s3) where 1-c1>5 order by 1 nulls first");
|
run("select 1-abs(c1) from (select unique(c1) c1 from st1s3) where 1-c1>5 order by 1 nulls first");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanOptimizeTest, LastRowScan) {
|
||||||
|
useDb("root", "cache_db");
|
||||||
|
|
||||||
|
run("SELECT LAST_ROW(c1), c2 FROM t1");
|
||||||
|
|
||||||
|
run("SELECT LAST_ROW(c1), c2, tag1, tbname FROM st1");
|
||||||
|
|
||||||
|
run("SELECT LAST_ROW(c1) FROM st1 PARTITION BY TBNAME");
|
||||||
|
|
||||||
|
run("SELECT LAST_ROW(c1), SUM(c3) FROM t1");
|
||||||
|
|
||||||
|
run("SELECT LAST_ROW(tag1) FROM st1");
|
||||||
|
|
||||||
|
run("SELECT LAST(c1) FROM st1");
|
||||||
|
|
||||||
|
run("SELECT LAST(c1), c2 FROM st1");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlanOptimizeTest, tagScan) {
|
TEST_F(PlanOptimizeTest, tagScan) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
run("select tag1 from st1 group by tag1");
|
run("select tag1 from st1 group by tag1");
|
||||||
|
|
|
@ -94,7 +94,7 @@ int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char*
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||||
if (tDecodeSStreamTask(&decoder, pTask) < 0) {
|
if (tDecodeSStreamTask(&decoder, pTask) < 0) {
|
||||||
ASSERT(0);
|
tDecoderClear(&decoder);
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -113,6 +113,13 @@ int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char*
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pTask->fillHistory) {
|
||||||
|
// pipeline exec
|
||||||
|
// if finished, dispatch a stream-prepare-finished msg to downstream task
|
||||||
|
// set status normal
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FAIL:
|
FAIL:
|
||||||
|
@ -120,6 +127,7 @@ FAIL:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t streamMetaAddTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
int32_t streamMetaAddTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
||||||
void* buf = NULL;
|
void* buf = NULL;
|
||||||
if (pMeta->expandFunc(pMeta->ahandle, pTask) < 0) {
|
if (pMeta->expandFunc(pMeta->ahandle, pTask) < 0) {
|
||||||
|
@ -149,6 +157,7 @@ int32_t streamMetaAddTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SStreamTask* streamMetaGetTask(SStreamMeta* pMeta, int32_t taskId) {
|
SStreamTask* streamMetaGetTask(SStreamMeta* pMeta, int32_t taskId) {
|
||||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t));
|
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t));
|
||||||
|
|
|
@ -656,6 +656,7 @@ int32_t streamStateSessionGetKey(SStreamState* pState, const SSessionKey* key, S
|
||||||
streamStateCurPrev(pState, pCur);
|
streamStateCurPrev(pState, pCur);
|
||||||
}
|
}
|
||||||
*curKey = resKey;
|
*curKey = resKey;
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
/*if (tStartEncode(pEncoder) < 0) return -1;*/
|
if (tStartEncode(pEncoder) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->totalLevel) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->totalLevel) < 0) return -1;
|
||||||
|
@ -64,6 +64,10 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
||||||
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI64(pEncoder, pTask->recoverSnapVer) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pTask->startVer) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pTask->fillHistory) < 0) return -1;
|
||||||
|
|
||||||
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
||||||
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
||||||
for (int32_t i = 0; i < epSz; i++) {
|
for (int32_t i = 0; i < epSz; i++) {
|
||||||
|
@ -93,12 +97,12 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
if (tEncodeI64(pEncoder, pTask->triggerParam) < 0) return -1;
|
if (tEncodeI64(pEncoder, pTask->triggerParam) < 0) return -1;
|
||||||
|
|
||||||
/*tEndEncode(pEncoder);*/
|
tEndEncode(pEncoder);
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
/*if (tStartDecode(pDecoder) < 0) return -1;*/
|
if (tStartDecode(pDecoder) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->totalLevel) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->totalLevel) < 0) return -1;
|
||||||
|
@ -113,6 +117,10 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
||||||
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI64(pDecoder, &pTask->recoverSnapVer) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pTask->startVer) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pTask->fillHistory) < 0) return -1;
|
||||||
|
|
||||||
int32_t epSz;
|
int32_t epSz;
|
||||||
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
||||||
pTask->childEpInfo = taosArrayInit(epSz, sizeof(void*));
|
pTask->childEpInfo = taosArrayInit(epSz, sizeof(void*));
|
||||||
|
@ -150,7 +158,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
if (tDecodeI64(pDecoder, &pTask->triggerParam) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pTask->triggerParam) < 0) return -1;
|
||||||
|
|
||||||
/*tEndDecode(pDecoder);*/
|
tEndDecode(pDecoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
#include "tencode.h"
|
#include "tencode.h"
|
||||||
#include "tstreamUpdate.h"
|
#include "tstreamUpdate.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
@ -162,15 +163,42 @@ bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol) {
|
||||||
|
if (pBlock == NULL || pBlock->info.rows == 0) return;
|
||||||
|
TSKEY maxTs = -1;
|
||||||
|
int64_t tbUid = pBlock->info.uid;
|
||||||
|
|
||||||
|
SColumnInfoData *pColDataInfo = taosArrayGet(pBlock->pDataBlock, primaryTsCol);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
||||||
|
TSKEY ts = ((TSKEY *)pColDataInfo->pData)[i];
|
||||||
|
maxTs = TMAX(maxTs, ts);
|
||||||
|
SScalableBf *pSBf = getSBf(pInfo, ts);
|
||||||
|
if (pSBf) {
|
||||||
|
tScalableBfPut(pSBf, &ts, sizeof(TSKEY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TSKEY *pMaxTs = taosHashGet(pInfo->pMap, &tbUid, sizeof(int64_t));
|
||||||
|
if (pMaxTs == NULL || *pMaxTs > tbUid) {
|
||||||
|
taosHashPut(pInfo->pMap, &tbUid, sizeof(int64_t), &maxTs, sizeof(TSKEY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) {
|
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) {
|
||||||
int32_t res = TSDB_CODE_FAILED;
|
int32_t res = TSDB_CODE_FAILED;
|
||||||
|
|
||||||
|
SUpdateKey updateKey = {
|
||||||
|
.tbUid = tableId,
|
||||||
|
.ts = ts,
|
||||||
|
};
|
||||||
|
|
||||||
TSKEY *pMapMaxTs = taosHashGet(pInfo->pMap, &tableId, sizeof(uint64_t));
|
TSKEY *pMapMaxTs = taosHashGet(pInfo->pMap, &tableId, sizeof(uint64_t));
|
||||||
uint64_t index = ((uint64_t)tableId) % pInfo->numBuckets;
|
uint64_t index = ((uint64_t)tableId) % pInfo->numBuckets;
|
||||||
TSKEY maxTs = *(TSKEY *)taosArrayGet(pInfo->pTsBuckets, index);
|
TSKEY maxTs = *(TSKEY *)taosArrayGet(pInfo->pTsBuckets, index);
|
||||||
if (ts < maxTs - pInfo->watermark) {
|
if (ts < maxTs - pInfo->watermark) {
|
||||||
// this window has been closed.
|
// this window has been closed.
|
||||||
if (pInfo->pCloseWinSBF) {
|
if (pInfo->pCloseWinSBF) {
|
||||||
res = tScalableBfPut(pInfo->pCloseWinSBF, &ts, sizeof(TSKEY));
|
res = tScalableBfPut(pInfo->pCloseWinSBF, &updateKey, sizeof(SUpdateKey));
|
||||||
if (res == TSDB_CODE_SUCCESS) {
|
if (res == TSDB_CODE_SUCCESS) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,7 +211,7 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) {
|
||||||
SScalableBf *pSBf = getSBf(pInfo, ts);
|
SScalableBf *pSBf = getSBf(pInfo, ts);
|
||||||
// pSBf may be a null pointer
|
// pSBf may be a null pointer
|
||||||
if (pSBf) {
|
if (pSBf) {
|
||||||
res = tScalableBfPut(pSBf, &ts, sizeof(TSKEY));
|
res = tScalableBfPut(pSBf, &updateKey, sizeof(SUpdateKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t size = taosHashGetSize(pInfo->pMap);
|
int32_t size = taosHashGetSize(pInfo->pMap);
|
||||||
|
|
|
@ -18,3 +18,8 @@ TARGET_INCLUDE_DIRECTORIES(
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/stream/"
|
||||||
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
PRIVATE "${TD_SOURCE_DIR}/source/libs/stream/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME streamUpdateTest
|
||||||
|
COMMAND streamUpdateTest
|
||||||
|
)
|
|
@ -371,7 +371,7 @@ static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2
|
||||||
}
|
}
|
||||||
return cret;
|
return cret;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
static int tdbBtreeOpenImpl(SBTree *pBt) {
|
static int tdbBtreeOpenImpl(SBTree *pBt) {
|
||||||
// Try to get the root page of the an existing btree
|
// Try to get the root page of the an existing btree
|
||||||
SPgno pgno;
|
SPgno pgno;
|
||||||
|
@ -400,7 +400,7 @@ static int tdbBtreeOpenImpl(SBTree *pBt) {
|
||||||
pBt->root = pgno;
|
pBt->root = pgno;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int tdbBtreeInitPage(SPage *pPage, void *arg, int init) {
|
int tdbBtreeInitPage(SPage *pPage, void *arg, int init) {
|
||||||
SBTree *pBt;
|
SBTree *pBt;
|
||||||
u8 flags;
|
u8 flags;
|
||||||
|
|
|
@ -586,7 +586,7 @@ static inline void setLPageNFree(SPage *pPage, int nFree) {
|
||||||
|
|
||||||
// cell offset
|
// cell offset
|
||||||
static inline int getLPageCellOffset(SPage *pPage, int idx) {
|
static inline int getLPageCellOffset(SPage *pPage, int idx) {
|
||||||
ASSERT(idx >= 0 && idx < getPageCellNum(pPage));
|
ASSERT(idx >= 0 && idx < getLPageCellNum(pPage));
|
||||||
return TDB_GET_U24(pPage->pCellIdx + 3 * idx);
|
return TDB_GET_U24(pPage->pCellIdx + 3 * idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ int tdbPagerClose(SPager *pPager) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate, SBTree *pBt) {
|
int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate, SBTree *pBt) {
|
||||||
SPgno pgno;
|
SPgno pgno;
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
@ -167,7 +167,7 @@ int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate, SBTree *pBt) {
|
||||||
*ppgno = pgno;
|
*ppgno = pgno;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int tdbPagerWrite(SPager *pPager, SPage *pPage) {
|
int tdbPagerWrite(SPager *pPager, SPage *pPage) {
|
||||||
int ret;
|
int ret;
|
||||||
SPage **ppPage;
|
SPage **ppPage;
|
||||||
|
|
|
@ -234,7 +234,15 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
|
||||||
cli->addr = tstrdup(server);
|
cli->addr = tstrdup(server);
|
||||||
cli->port = port;
|
cli->port = port;
|
||||||
|
|
||||||
uv_loop_t* loop = uv_default_loop();
|
uv_loop_t* loop = taosMemoryMalloc(sizeof(uv_loop_t));
|
||||||
|
int err = uv_loop_init(loop);
|
||||||
|
if (err != 0) {
|
||||||
|
uError("http-report failed to init uv_loop, reason: %s", uv_strerror(err));
|
||||||
|
taosMemoryFree(loop);
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(err);
|
||||||
|
destroyHttpClient(cli);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
uv_tcp_init(loop, &cli->tcp);
|
uv_tcp_init(loop, &cli->tcp);
|
||||||
// set up timeout to avoid stuck;
|
// set up timeout to avoid stuck;
|
||||||
int32_t fd = taosCreateSocketWithTimeout(5);
|
int32_t fd = taosCreateSocketWithTimeout(5);
|
||||||
|
@ -258,5 +266,6 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
|
||||||
|
|
||||||
uv_run(loop, UV_RUN_DEFAULT);
|
uv_run(loop, UV_RUN_DEFAULT);
|
||||||
uv_loop_close(loop);
|
uv_loop_close(loop);
|
||||||
|
taosMemoryFree(loop);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -811,7 +811,7 @@ static bool addHandleToAcceptloop(void* arg) {
|
||||||
tError("failed to bind:%s", uv_err_name(err));
|
tError("failed to bind:%s", uv_err_name(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((err = uv_listen((uv_stream_t*)&srv->server, 512, uvOnAcceptCb)) != 0) {
|
if ((err = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) {
|
||||||
tError("failed to listen:%s", uv_err_name(err));
|
tError("failed to listen:%s", uv_err_name(err));
|
||||||
terrno = TSDB_CODE_RPC_PORT_EADDRINUSE;
|
terrno = TSDB_CODE_RPC_PORT_EADDRINUSE;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -528,7 +528,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
idxEntry.offset, fLogNameStr);
|
idxEntry.offset, fLogNameStr);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
wWarn("vgId:%d wal idx append new entry %" PRId64 " %" PRId64, pWal->cfg.vgId, idxEntry.ver, idxEntry.offset);
|
wWarn("vgId:%d, wal idx append new entry %" PRId64 " %" PRId64, pWal->cfg.vgId, idxEntry.ver, idxEntry.offset);
|
||||||
if (taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) {
|
if (taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) {
|
||||||
wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr);
|
wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -812,7 +812,7 @@ int walLoadMeta(SWal* pWal) {
|
||||||
// find existing meta file
|
// find existing meta file
|
||||||
int metaVer = walFindCurMetaVer(pWal);
|
int metaVer = walFindCurMetaVer(pWal);
|
||||||
if (metaVer == -1) {
|
if (metaVer == -1) {
|
||||||
wDebug("vgId:%d wal find meta ver %d", pWal->cfg.vgId, metaVer);
|
wDebug("vgId:%d, wal find meta ver %d", pWal->cfg.vgId, metaVer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char fnameStr[WAL_FILE_LEN];
|
char fnameStr[WAL_FILE_LEN];
|
||||||
|
@ -822,7 +822,7 @@ int walLoadMeta(SWal* pWal) {
|
||||||
taosStatFile(fnameStr, &fileSize, NULL);
|
taosStatFile(fnameStr, &fileSize, NULL);
|
||||||
if (fileSize == 0) {
|
if (fileSize == 0) {
|
||||||
taosRemoveFile(fnameStr);
|
taosRemoveFile(fnameStr);
|
||||||
wDebug("vgId:%d wal find empty meta ver %d", pWal->cfg.vgId, metaVer);
|
wDebug("vgId:%d, wal find empty meta ver %d", pWal->cfg.vgId, metaVer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int size = (int)fileSize;
|
int size = (int)fileSize;
|
||||||
|
|
|
@ -138,12 +138,12 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) {
|
||||||
(void)walLoadMeta(pWal);
|
(void)walLoadMeta(pWal);
|
||||||
|
|
||||||
if (walCheckAndRepairMeta(pWal) < 0) {
|
if (walCheckAndRepairMeta(pWal) < 0) {
|
||||||
wError("vgId:%d cannot open wal since repair meta file failed", pWal->cfg.vgId);
|
wError("vgId:%d, cannot open wal since repair meta file failed", pWal->cfg.vgId);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walCheckAndRepairIdx(pWal) < 0) {
|
if (walCheckAndRepairIdx(pWal) < 0) {
|
||||||
wError("vgId:%d cannot open wal since repair idx file failed", pWal->cfg.vgId);
|
wError("vgId:%d, cannot open wal since repair idx file failed", pWal->cfg.vgId);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,12 +278,12 @@ static int32_t walFetchBodyNew(SWalReader *pRead) {
|
||||||
wDebug("vgId:%d, wal starts to fetch body, index:%" PRId64, pRead->pWal->cfg.vgId, ver);
|
wDebug("vgId:%d, wal starts to fetch body, index:%" PRId64, pRead->pWal->cfg.vgId, ver);
|
||||||
|
|
||||||
if (pRead->capacity < pReadHead->bodyLen) {
|
if (pRead->capacity < pReadHead->bodyLen) {
|
||||||
void *ptr = taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pRead->pHead = (SWalCkHead *)ptr;
|
pRead->pHead = ptr;
|
||||||
pReadHead = &pRead->pHead->head;
|
pReadHead = &pRead->pHead->head;
|
||||||
pRead->capacity = pReadHead->bodyLen;
|
pRead->capacity = pReadHead->bodyLen;
|
||||||
}
|
}
|
||||||
|
@ -398,12 +398,12 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
|
||||||
int64_t ver = pReadHead->version;
|
int64_t ver = pReadHead->version;
|
||||||
|
|
||||||
if (pRead->capacity < pReadHead->bodyLen) {
|
if (pRead->capacity < pReadHead->bodyLen) {
|
||||||
void *ptr = taosMemoryRealloc(*ppHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(*ppHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*ppHead = (SWalCkHead *)ptr;
|
*ppHead = ptr;
|
||||||
pReadHead = &((*ppHead)->head);
|
pReadHead = &((*ppHead)->head);
|
||||||
pRead->capacity = pReadHead->bodyLen;
|
pRead->capacity = pReadHead->bodyLen;
|
||||||
}
|
}
|
||||||
|
@ -493,13 +493,14 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReader->capacity < pReader->pHead->head.bodyLen) {
|
if (pReader->capacity < pReader->pHead->head.bodyLen) {
|
||||||
void *ptr = taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + pReader->pHead->head.bodyLen);
|
SWalCkHead *ptr =
|
||||||
|
(SWalCkHead *)taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + pReader->pHead->head.bodyLen);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_WAL_OUT_OF_MEMORY;
|
||||||
taosThreadMutexUnlock(&pReader->mutex);
|
taosThreadMutexUnlock(&pReader->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pReader->pHead = (SWalCkHead *)ptr;
|
pReader->pHead = ptr;
|
||||||
pReader->capacity = pReader->pHead->head.bodyLen;
|
pReader->capacity = pReader->pHead->head.bodyLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,20 +44,20 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
||||||
walBuildLogName(pWal, pFileInfo->firstVer, fnameStr);
|
walBuildLogName(pWal, pFileInfo->firstVer, fnameStr);
|
||||||
if (taosRemoveFile(fnameStr) < 0) {
|
if (taosRemoveFile(fnameStr) < 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
wError("vgId:%d restore from snapshot, cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
wError("vgId:%d, restore from snapshot, cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
||||||
taosThreadMutexUnlock(&pWal->mutex);
|
taosThreadMutexUnlock(&pWal->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
wInfo("vgId:%d restore from snapshot, remove file %s", pWal->cfg.vgId, fnameStr);
|
wInfo("vgId:%d, restore from snapshot, remove file %s", pWal->cfg.vgId, fnameStr);
|
||||||
|
|
||||||
walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
|
walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
|
||||||
if (taosRemoveFile(fnameStr) < 0) {
|
if (taosRemoveFile(fnameStr) < 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
wError("vgId:%d cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
wError("vgId:%d, cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
||||||
taosThreadMutexUnlock(&pWal->mutex);
|
taosThreadMutexUnlock(&pWal->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
wInfo("vgId:%d restore from snapshot, remove file %s", pWal->cfg.vgId, fnameStr);
|
wInfo("vgId:%d, restore from snapshot, remove file %s", pWal->cfg.vgId, fnameStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
walRemoveMeta(pWal);
|
walRemoveMeta(pWal);
|
||||||
|
@ -424,7 +424,12 @@ static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(taosLSeekFile(pWal->pIdxFile, 0, SEEK_END) == idxOffset + sizeof(SWalIdxEntry) && "Offset of idx entries misaligned");
|
// check alignment of idx entries
|
||||||
|
int64_t endOffset = taosLSeekFile(pWal->pIdxFile, 0, SEEK_END);
|
||||||
|
if (endOffset < 0) {
|
||||||
|
wFatal("vgId:%d, failed to seek end of idxfile due to %s. ver:%" PRId64 "", pWal->cfg.vgId, strerror(errno), ver);
|
||||||
|
}
|
||||||
|
ASSERT(endOffset == idxOffset + sizeof(SWalIdxEntry) && "Offset of idx entries misaligned");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,10 @@ SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate) {
|
||||||
|
|
||||||
// ln(2) = 0.693147180559945
|
// ln(2) = 0.693147180559945
|
||||||
pBF->hashFunctions = (uint32_t)ceil(lnRate / 0.693147180559945);
|
pBF->hashFunctions = (uint32_t)ceil(lnRate / 0.693147180559945);
|
||||||
pBF->hashFn1 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP);
|
/*pBF->hashFn1 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP);*/
|
||||||
pBF->hashFn2 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_NCHAR);
|
/*pBF->hashFn2 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_NCHAR);*/
|
||||||
|
pBF->hashFn1 = taosFastHash;
|
||||||
|
pBF->hashFn2 = taosDJB2Hash;
|
||||||
pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t));
|
pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t));
|
||||||
if (pBF->buffer == NULL) {
|
if (pBF->buffer == NULL) {
|
||||||
tBloomFilterDestroy(pBF);
|
tBloomFilterDestroy(pBF);
|
||||||
|
|
|
@ -32,6 +32,23 @@
|
||||||
(h) ^= (h) >> 16; \
|
(h) ^= (h) >> 16; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
uint32_t taosFastHash(const char *key, uint32_t len) {
|
||||||
|
uint32_t result = 0x55555555;
|
||||||
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
|
result ^= (uint8_t)key[i];
|
||||||
|
result = ROTL32(result, 5);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t taosDJB2Hash(const char *key, uint32_t len) {
|
||||||
|
uint32_t hash = 5381;
|
||||||
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
|
hash = ((hash << 5) + hash) + (uint8_t)key[i]; /* hash * 33 + c */
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t MurmurHash3_32(const char *key, uint32_t len) {
|
uint32_t MurmurHash3_32(const char *key, uint32_t len) {
|
||||||
const uint8_t *data = (const uint8_t *)key;
|
const uint8_t *data = (const uint8_t *)key;
|
||||||
const int32_t nblocks = len >> 2u;
|
const int32_t nblocks = len >> 2u;
|
||||||
|
|
|
@ -216,7 +216,7 @@ void perfTest() {
|
||||||
|
|
||||||
char* name = (char*)taosMemoryCalloc(50000000, 9);
|
char* name = (char*)taosMemoryCalloc(50000000, 9);
|
||||||
for (int64_t i = 0; i < 50000000; ++i) {
|
for (int64_t i = 0; i < 50000000; ++i) {
|
||||||
sprintf(name + i * 9, "t%08d", i);
|
sprintf(name + i * 9, "t%08" PRId64, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int64_t i = 0; i < 50; ++i) {
|
for (int64_t i = 0; i < 50; ++i) {
|
||||||
|
|
|
@ -32,6 +32,26 @@ sql alter dnode 1 'rpcDebugFlag 131'
|
||||||
sql alter dnode 1 'qDebugFlag 131'
|
sql alter dnode 1 'qDebugFlag 131'
|
||||||
sql alter dnode 1 'metaDebugFlag 131'
|
sql alter dnode 1 'metaDebugFlag 131'
|
||||||
|
|
||||||
|
sql alter dnode 1 'debugFlag' '135'
|
||||||
|
sql alter dnode 1 'dDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'vDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'mDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'wDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'sDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'tsdbDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'tqDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'fsDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'udfDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'smaDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'idxDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'tdbDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'tmrDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'uDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'smaDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'rpcDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'qDebugFlag' '131'
|
||||||
|
sql alter dnode 1 'metaDebugFlag' '131'
|
||||||
|
|
||||||
sql_error alter dnode 2 'wDebugFlag 135'
|
sql_error alter dnode 2 'wDebugFlag 135'
|
||||||
sql_error alter dnode 2 'tmrDebugFlag 135'
|
sql_error alter dnode 2 'tmrDebugFlag 135'
|
||||||
sql_error alter dnode 1 'monDebugFlag 131'
|
sql_error alter dnode 1 'monDebugFlag 131'
|
||||||
|
@ -39,6 +59,13 @@ sql_error alter dnode 1 'cqDebugFlag 131'
|
||||||
sql_error alter dnode 1 'httpDebugFlag 131'
|
sql_error alter dnode 1 'httpDebugFlag 131'
|
||||||
sql_error alter dnode 1 'mqttDebugFlag 131'
|
sql_error alter dnode 1 'mqttDebugFlag 131'
|
||||||
|
|
||||||
|
sql_error alter dnode 2 'wDebugFlag' '135'
|
||||||
|
sql_error alter dnode 2 'tmrDebugFlag' '135'
|
||||||
|
sql_error alter dnode 1 'monDebugFlag' '131'
|
||||||
|
sql_error alter dnode 1 'cqDebugFlag' '131'
|
||||||
|
sql_error alter dnode 1 'httpDebugFlag' '131'
|
||||||
|
sql_error alter dnode 1 'mqttDebugFlag' '131'
|
||||||
|
|
||||||
print ======== step3
|
print ======== step3
|
||||||
sql_error alter $hostname1 debugFlag 135
|
sql_error alter $hostname1 debugFlag 135
|
||||||
sql_error alter $hostname1 monDebugFlag 135
|
sql_error alter $hostname1 monDebugFlag 135
|
||||||
|
|
|
@ -134,6 +134,7 @@ if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
return
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
system sh/exec.sh -n dnode3 -s stop -x SIGINT
|
system sh/exec.sh -n dnode3 -s stop -x SIGINT
|
||||||
|
|
|
@ -39,6 +39,7 @@ if $data02 != 5.000000000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data03 != 3 then
|
if $data03 != 3 then
|
||||||
|
print expect 3, actual: $data03
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data04 != @70-01-01 07:59:57.000@ then
|
if $data04 != @70-01-01 07:59:57.000@ then
|
||||||
|
@ -210,7 +211,7 @@ if $data01 != 6 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data02 != 37.000000000 then
|
if $data02 != 37.000000000 then
|
||||||
print $data02
|
print expect 37.000000000 actual: $data02
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data03 != 27 then
|
if $data03 != 27 then
|
||||||
|
@ -233,7 +234,7 @@ if $data01 != 6 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data02 != 37.000000000 then
|
if $data02 != 37.000000000 then
|
||||||
print $data02
|
print expect 37.000000000, acutal: $data02
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data03 != 27 then
|
if $data03 != 27 then
|
||||||
|
|
|
@ -5,7 +5,7 @@ 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
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TDTestCase:
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor(), False)
|
tdSql.init(conn.cursor(), True)
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.row_nums = 20
|
self.row_nums = 20
|
||||||
self.ts = 1434938400000
|
self.ts = 1434938400000
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -214,7 +214,7 @@ class TDTestCase:
|
||||||
resultList = tmqCom.selectConsumeResult(expectRows)
|
resultList = tmqCom.selectConsumeResult(expectRows)
|
||||||
|
|
||||||
actConsumeTotalRows = resultList[0]
|
actConsumeTotalRows = resultList[0]
|
||||||
|
tdLog.info("act consume rows: %d, expect rows range (0, %d)"%(actConsumeTotalRows, totalRowsInserted))
|
||||||
if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted):
|
if not (actConsumeTotalRows > 0 and actConsumeTotalRows < totalRowsInserted):
|
||||||
tdLog.info("act consume rows: %d"%(actConsumeTotalRows))
|
tdLog.info("act consume rows: %d"%(actConsumeTotalRows))
|
||||||
tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted))
|
tdLog.info("and second consume rows should be between 0 and %d"%(totalRowsInserted))
|
||||||
|
|
|
@ -127,7 +127,7 @@ python3 ./test.py -f 2-query/leastsquares.py -R
|
||||||
python3 ./test.py -f 2-query/length.py
|
python3 ./test.py -f 2-query/length.py
|
||||||
python3 ./test.py -f 2-query/length.py -R
|
python3 ./test.py -f 2-query/length.py -R
|
||||||
python3 ./test.py -f 2-query/log.py
|
python3 ./test.py -f 2-query/log.py
|
||||||
# python3 ./test.py -f 2-query/log.py -R
|
python3 ./test.py -f 2-query/log.py -R
|
||||||
python3 ./test.py -f 2-query/lower.py
|
python3 ./test.py -f 2-query/lower.py
|
||||||
python3 ./test.py -f 2-query/lower.py -R
|
python3 ./test.py -f 2-query/lower.py -R
|
||||||
python3 ./test.py -f 2-query/ltrim.py
|
python3 ./test.py -f 2-query/ltrim.py
|
||||||
|
@ -175,7 +175,7 @@ python3 ./test.py -f 2-query/sum.py -R
|
||||||
python3 ./test.py -f 2-query/tail.py
|
python3 ./test.py -f 2-query/tail.py
|
||||||
python3 ./test.py -f 2-query/tail.py -R
|
python3 ./test.py -f 2-query/tail.py -R
|
||||||
python3 ./test.py -f 2-query/tan.py
|
python3 ./test.py -f 2-query/tan.py
|
||||||
# python3 ./test.py -f 2-query/tan.py -R
|
python3 ./test.py -f 2-query/tan.py -R
|
||||||
python3 ./test.py -f 2-query/Timediff.py
|
python3 ./test.py -f 2-query/Timediff.py
|
||||||
python3 ./test.py -f 2-query/Timediff.py -R
|
python3 ./test.py -f 2-query/Timediff.py -R
|
||||||
python3 ./test.py -f 2-query/timetruncate.py
|
python3 ./test.py -f 2-query/timetruncate.py
|
||||||
|
@ -221,6 +221,7 @@ python3 ./test.py -f 2-query/json_tag.py
|
||||||
# TD-15983 subquery output duplicate name column.
|
# TD-15983 subquery output duplicate name column.
|
||||||
# Please Xiangyang Guo modify the following script
|
# Please Xiangyang Guo modify the following script
|
||||||
# python3 ./test.py -f 2-query/nestedQuery_str.py
|
# python3 ./test.py -f 2-query/nestedQuery_str.py
|
||||||
|
python3 ./test.py -f 2-query/stablity.py
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/elapsed.py
|
python3 ./test.py -f 2-query/elapsed.py
|
||||||
python3 ./test.py -f 2-query/csum.py
|
python3 ./test.py -f 2-query/csum.py
|
||||||
|
@ -287,7 +288,7 @@ python3 ./test.py -f 7-tmq/subscribeDb0.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb1.py
|
python3 ./test.py -f 7-tmq/subscribeDb1.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb2.py
|
python3 ./test.py -f 7-tmq/subscribeDb2.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb3.py
|
python3 ./test.py -f 7-tmq/subscribeDb3.py
|
||||||
#python3 ./test.py -f 7-tmq/subscribeDb4.py
|
python3 ./test.py -f 7-tmq/subscribeDb4.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeStb.py
|
python3 ./test.py -f 7-tmq/subscribeStb.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeStb0.py
|
python3 ./test.py -f 7-tmq/subscribeStb0.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeStb1.py
|
python3 ./test.py -f 7-tmq/subscribeStb1.py
|
||||||
|
@ -302,14 +303,14 @@ python3 ./test.py -f 7-tmq/tmqCheckData.py
|
||||||
python3 ./test.py -f 7-tmq/tmqCheckData1.py
|
python3 ./test.py -f 7-tmq/tmqCheckData1.py
|
||||||
#python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5
|
#python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5
|
||||||
python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
|
python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
|
||||||
#python3 ./test.py -f 7-tmq/tmqShow.py
|
python3 ./test.py -f 7-tmq/tmqShow.py
|
||||||
python3 ./test.py -f 7-tmq/tmqAlterSchema.py
|
python3 ./test.py -f 7-tmq/tmqAlterSchema.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py
|
||||||
# python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py
|
||||||
|
|
|
@ -30,6 +30,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||||
void shellGetPrevCharSize(const char* str, int32_t pos, int32_t* size, int32_t* width);
|
void shellGetPrevCharSize(const char* str, int32_t pos, int32_t* size, int32_t* width);
|
||||||
void shellShowOnScreen(SShellCmd* cmd);
|
void shellShowOnScreen(SShellCmd* cmd);
|
||||||
void shellInsertChar(SShellCmd* cmd, char* c, int size);
|
void shellInsertChar(SShellCmd* cmd, char* c, int size);
|
||||||
|
void shellInsertStr(SShellCmd* cmd, char* str, int size);
|
||||||
bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* p, int32_t len);
|
bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* p, int32_t len);
|
||||||
|
|
||||||
typedef struct SAutoPtr {
|
typedef struct SAutoPtr {
|
||||||
|
@ -1099,7 +1100,7 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert new
|
// insert new
|
||||||
shellInsertChar(cmd, (char*)str, strLen);
|
shellInsertStr(cmd, (char*)str, strLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// main key press tab , matched return true else false
|
// main key press tab , matched return true else false
|
||||||
|
@ -1220,7 +1221,7 @@ bool fillWithType(TAOS* con, SShellCmd* cmd, char* pre, int type) {
|
||||||
|
|
||||||
// show
|
// show
|
||||||
int count = strlen(part);
|
int count = strlen(part);
|
||||||
shellInsertChar(cmd, part, count);
|
shellInsertStr(cmd, part, count);
|
||||||
cntDel = count; // next press tab delete current append count
|
cntDel = count; // next press tab delete current append count
|
||||||
|
|
||||||
taosMemoryFree(str);
|
taosMemoryFree(str);
|
||||||
|
@ -1247,7 +1248,7 @@ bool fillTableName(TAOS* con, SShellCmd* cmd, char* pre) {
|
||||||
|
|
||||||
// show
|
// show
|
||||||
int count = strlen(part);
|
int count = strlen(part);
|
||||||
shellInsertChar(cmd, part, count);
|
shellInsertStr(cmd, part, count);
|
||||||
cntDel = count; // next press tab delete current append count
|
cntDel = count; // next press tab delete current append count
|
||||||
|
|
||||||
taosMemoryFree(str);
|
taosMemoryFree(str);
|
||||||
|
@ -1371,7 +1372,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) {
|
||||||
bool fieldEnd = fieldsInputEnd(p);
|
bool fieldEnd = fieldsInputEnd(p);
|
||||||
// check fields input end then insert from keyword
|
// check fields input end then insert from keyword
|
||||||
if (fieldEnd && p[len - 1] == ' ') {
|
if (fieldEnd && p[len - 1] == ' ') {
|
||||||
shellInsertChar(cmd, "from", 4);
|
shellInsertStr(cmd, "from", 4);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1569,7 +1570,7 @@ bool matchOther(TAOS* con, SShellCmd* cmd) {
|
||||||
if (p[len - 1] == '\\') {
|
if (p[len - 1] == '\\') {
|
||||||
// append '\G'
|
// append '\G'
|
||||||
char a[] = "G;";
|
char a[] = "G;";
|
||||||
shellInsertChar(cmd, a, 2);
|
shellInsertStr(cmd, a, 2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||||
void shellShowOnScreen(SShellCmd *cmd);
|
void shellShowOnScreen(SShellCmd *cmd);
|
||||||
void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width);
|
void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width);
|
||||||
void shellInsertChar(SShellCmd *cmd, char *c, int size);
|
void shellInsertChar(SShellCmd *cmd, char *c, int size);
|
||||||
|
void shellInsertString(SShellCmd *cmd, char *str, int size);
|
||||||
|
|
||||||
int32_t shellCountPrefixOnes(uint8_t c) {
|
int32_t shellCountPrefixOnes(uint8_t c) {
|
||||||
uint8_t mask = 127;
|
uint8_t mask = 127;
|
||||||
|
@ -101,11 +102,30 @@ 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);
|
||||||
|
|
||||||
|
// set string end
|
||||||
|
cmd->command[cmd->commandSize] = 0;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#else
|
||||||
|
shellShowOnScreen(cmd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// insert string . count is str char count
|
||||||
|
void shellInsertStr(SShellCmd *cmd, char *str, int32_t size) {
|
||||||
|
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||||
|
/* update the buffer */
|
||||||
|
memmove(cmd->command + cmd->cursorOffset + size, cmd->command + cmd->cursorOffset,
|
||||||
|
cmd->commandSize - cmd->cursorOffset);
|
||||||
|
memcpy(cmd->command + cmd->cursorOffset, str, size);
|
||||||
|
/* update the values */
|
||||||
|
cmd->commandSize += size;
|
||||||
|
cmd->cursorOffset += size;
|
||||||
|
cmd->screenOffset += size;
|
||||||
|
cmd->endOffset += size;
|
||||||
|
|
||||||
// set string end
|
// set string end
|
||||||
cmd->command[cmd->commandSize] = 0;
|
cmd->command[cmd->commandSize] = 0;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -480,9 +500,11 @@ int32_t shellReadCommand(char *command) {
|
||||||
}
|
}
|
||||||
shellInsertChar(&cmd, utf8_array, count);
|
shellInsertChar(&cmd, utf8_array, count);
|
||||||
pressOtherKey(c);
|
pressOtherKey(c);
|
||||||
|
#ifndef WINDOWS
|
||||||
} else if (c == TAB_KEY) {
|
} else if (c == TAB_KEY) {
|
||||||
// press TAB key
|
// press TAB key
|
||||||
pressTabKey(&cmd);
|
pressTabKey(&cmd);
|
||||||
|
#endif
|
||||||
} else if (c < '\033') {
|
} else if (c < '\033') {
|
||||||
pressOtherKey(c);
|
pressOtherKey(c);
|
||||||
// Ctrl keys. TODO: Implement ctrl combinations
|
// Ctrl keys. TODO: Implement ctrl combinations
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue