Merge branch 'refact/submit_req_marks' of https://github.com/taosdata/TDengine into refact/submit_req_marks
This commit is contained in:
commit
dc69c4daa6
|
@ -60,7 +60,7 @@ sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||||
为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件:
|
为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS 7.9
|
### CentOS 7.9
|
||||||
|
@ -85,7 +85,7 @@ sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
#### CentOS 8/Rocky Linux
|
#### CentOS 8/Rocky Linux
|
||||||
|
@ -94,7 +94,7 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco
|
||||||
sudo yum install -y epel-release
|
sudo yum install -y epel-release
|
||||||
sudo yum install -y dnf-plugins-core
|
sudo yum install -y dnf-plugins-core
|
||||||
sudo yum config-manager --set-enabled powertools
|
sudo yum config-manager --set-enabled powertools
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
注意:由于 snappy 缺乏 pkg-config 支持(参考 [链接](https://github.com/google/snappy/pull/86)),会导致 cmake 提示无法发现 libsnappy,实际上工作正常。
|
注意:由于 snappy 缺乏 pkg-config 支持(参考 [链接](https://github.com/google/snappy/pull/86)),会导致 cmake 提示无法发现 libsnappy,实际上工作正常。
|
||||||
|
|
|
@ -62,7 +62,7 @@ sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||||
To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed.
|
To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS 7.9
|
### CentOS 7.9
|
||||||
|
@ -85,7 +85,7 @@ sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
|
||||||
#### CentOS 7.9
|
#### CentOS 7.9
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
#### CentOS 8/Rocky Linux
|
#### CentOS 8/Rocky Linux
|
||||||
|
@ -94,7 +94,7 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco
|
||||||
sudo yum install -y epel-release
|
sudo yum install -y epel-release
|
||||||
sudo yum install -y dnf-plugins-core
|
sudo yum install -y dnf-plugins-core
|
||||||
sudo yum config-manager --set-enabled powertools
|
sudo yum config-manager --set-enabled powertools
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it leads a cmake prompt libsnappy not found. But snappy still works well.
|
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it leads a cmake prompt libsnappy not found. But snappy still works well.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG e62c5ea
|
GIT_TAG 4a4027c
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -149,7 +149,7 @@ DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char
|
||||||
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
||||||
DLL_EXPORT void taos_close(TAOS *taos);
|
DLL_EXPORT void taos_close(TAOS *taos);
|
||||||
|
|
||||||
const char *taos_data_type(int type);
|
DLL_EXPORT const char *taos_data_type(int type);
|
||||||
|
|
||||||
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
|
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
|
||||||
DLL_EXPORT TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid);
|
DLL_EXPORT TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid);
|
||||||
|
|
|
@ -70,6 +70,11 @@ 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_UPDATE_TAG_VAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool syncUtilUserCommit(tmsg_t msgType) {
|
||||||
|
return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------ OTHER DEFINITIONS ------------------------ */
|
/* ------------------------ OTHER DEFINITIONS ------------------------ */
|
||||||
// IE type
|
// IE type
|
||||||
#define TSDB_IE_TYPE_SEC 1
|
#define TSDB_IE_TYPE_SEC 1
|
||||||
|
@ -502,6 +507,8 @@ typedef struct {
|
||||||
char* pComment;
|
char* pComment;
|
||||||
char* pAst1;
|
char* pAst1;
|
||||||
char* pAst2;
|
char* pAst2;
|
||||||
|
int64_t deleteMark1;
|
||||||
|
int64_t deleteMark2;
|
||||||
} SMCreateStbReq;
|
} SMCreateStbReq;
|
||||||
|
|
||||||
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
||||||
|
@ -2017,6 +2024,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t maxdelay[2];
|
int64_t maxdelay[2];
|
||||||
int64_t watermark[2];
|
int64_t watermark[2];
|
||||||
|
int64_t deleteMark[2];
|
||||||
int32_t qmsgLen[2];
|
int32_t qmsgLen[2];
|
||||||
char* qmsg[2]; // pAst:qmsg:SRetention => trigger aggr task1/2
|
char* qmsg[2]; // pAst:qmsg:SRetention => trigger aggr task1/2
|
||||||
} SRSmaParam;
|
} SRSmaParam;
|
||||||
|
@ -2743,6 +2751,7 @@ typedef struct {
|
||||||
char* tagsFilter;
|
char* tagsFilter;
|
||||||
char* sql;
|
char* sql;
|
||||||
char* ast;
|
char* ast;
|
||||||
|
int64_t deleteMark;
|
||||||
} SMCreateSmaReq;
|
} SMCreateSmaReq;
|
||||||
|
|
||||||
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
||||||
|
@ -3269,6 +3278,17 @@ void tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag);
|
||||||
#define TSDB_MSG_FLG_ENCODE 0x1
|
#define TSDB_MSG_FLG_ENCODE 0x1
|
||||||
#define TSDB_MSG_FLG_DECODE 0x2
|
#define TSDB_MSG_FLG_DECODE 0x2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
void* msgStr;
|
||||||
|
int32_t msgLen;
|
||||||
|
int64_t ver;
|
||||||
|
};
|
||||||
|
void* pDataBlock;
|
||||||
|
};
|
||||||
|
} SPackedData;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -147,195 +147,196 @@
|
||||||
#define TK_ROLLUP 129
|
#define TK_ROLLUP 129
|
||||||
#define TK_TTL 130
|
#define TK_TTL 130
|
||||||
#define TK_SMA 131
|
#define TK_SMA 131
|
||||||
#define TK_FIRST 132
|
#define TK_DELETE_MARK 132
|
||||||
#define TK_LAST 133
|
#define TK_FIRST 133
|
||||||
#define TK_SHOW 134
|
#define TK_LAST 134
|
||||||
#define TK_PRIVILEGES 135
|
#define TK_SHOW 135
|
||||||
#define TK_DATABASES 136
|
#define TK_PRIVILEGES 136
|
||||||
#define TK_TABLES 137
|
#define TK_DATABASES 137
|
||||||
#define TK_STABLES 138
|
#define TK_TABLES 138
|
||||||
#define TK_MNODES 139
|
#define TK_STABLES 139
|
||||||
#define TK_QNODES 140
|
#define TK_MNODES 140
|
||||||
#define TK_FUNCTIONS 141
|
#define TK_QNODES 141
|
||||||
#define TK_INDEXES 142
|
#define TK_FUNCTIONS 142
|
||||||
#define TK_ACCOUNTS 143
|
#define TK_INDEXES 143
|
||||||
#define TK_APPS 144
|
#define TK_ACCOUNTS 144
|
||||||
#define TK_CONNECTIONS 145
|
#define TK_APPS 145
|
||||||
#define TK_LICENCES 146
|
#define TK_CONNECTIONS 146
|
||||||
#define TK_GRANTS 147
|
#define TK_LICENCES 147
|
||||||
#define TK_QUERIES 148
|
#define TK_GRANTS 148
|
||||||
#define TK_SCORES 149
|
#define TK_QUERIES 149
|
||||||
#define TK_TOPICS 150
|
#define TK_SCORES 150
|
||||||
#define TK_VARIABLES 151
|
#define TK_TOPICS 151
|
||||||
#define TK_CLUSTER 152
|
#define TK_VARIABLES 152
|
||||||
#define TK_BNODES 153
|
#define TK_CLUSTER 153
|
||||||
#define TK_SNODES 154
|
#define TK_BNODES 154
|
||||||
#define TK_TRANSACTIONS 155
|
#define TK_SNODES 155
|
||||||
#define TK_DISTRIBUTED 156
|
#define TK_TRANSACTIONS 156
|
||||||
#define TK_CONSUMERS 157
|
#define TK_DISTRIBUTED 157
|
||||||
#define TK_SUBSCRIPTIONS 158
|
#define TK_CONSUMERS 158
|
||||||
#define TK_VNODES 159
|
#define TK_SUBSCRIPTIONS 159
|
||||||
#define TK_LIKE 160
|
#define TK_VNODES 160
|
||||||
#define TK_TBNAME 161
|
#define TK_LIKE 161
|
||||||
#define TK_QTAGS 162
|
#define TK_TBNAME 162
|
||||||
#define TK_AS 163
|
#define TK_QTAGS 163
|
||||||
#define TK_INDEX 164
|
#define TK_AS 164
|
||||||
#define TK_FUNCTION 165
|
#define TK_INDEX 165
|
||||||
#define TK_INTERVAL 166
|
#define TK_FUNCTION 166
|
||||||
#define TK_TOPIC 167
|
#define TK_INTERVAL 167
|
||||||
#define TK_WITH 168
|
#define TK_TOPIC 168
|
||||||
#define TK_META 169
|
#define TK_WITH 169
|
||||||
#define TK_CONSUMER 170
|
#define TK_META 170
|
||||||
#define TK_GROUP 171
|
#define TK_CONSUMER 171
|
||||||
#define TK_DESC 172
|
#define TK_GROUP 172
|
||||||
#define TK_DESCRIBE 173
|
#define TK_DESC 173
|
||||||
#define TK_RESET 174
|
#define TK_DESCRIBE 174
|
||||||
#define TK_QUERY 175
|
#define TK_RESET 175
|
||||||
#define TK_CACHE 176
|
#define TK_QUERY 176
|
||||||
#define TK_EXPLAIN 177
|
#define TK_CACHE 177
|
||||||
#define TK_ANALYZE 178
|
#define TK_EXPLAIN 178
|
||||||
#define TK_VERBOSE 179
|
#define TK_ANALYZE 179
|
||||||
#define TK_NK_BOOL 180
|
#define TK_VERBOSE 180
|
||||||
#define TK_RATIO 181
|
#define TK_NK_BOOL 181
|
||||||
#define TK_NK_FLOAT 182
|
#define TK_RATIO 182
|
||||||
#define TK_OUTPUTTYPE 183
|
#define TK_NK_FLOAT 183
|
||||||
#define TK_AGGREGATE 184
|
#define TK_OUTPUTTYPE 184
|
||||||
#define TK_BUFSIZE 185
|
#define TK_AGGREGATE 185
|
||||||
#define TK_STREAM 186
|
#define TK_BUFSIZE 186
|
||||||
#define TK_INTO 187
|
#define TK_STREAM 187
|
||||||
#define TK_TRIGGER 188
|
#define TK_INTO 188
|
||||||
#define TK_AT_ONCE 189
|
#define TK_TRIGGER 189
|
||||||
#define TK_WINDOW_CLOSE 190
|
#define TK_AT_ONCE 190
|
||||||
#define TK_IGNORE 191
|
#define TK_WINDOW_CLOSE 191
|
||||||
#define TK_EXPIRED 192
|
#define TK_IGNORE 192
|
||||||
#define TK_FILL_HISTORY 193
|
#define TK_EXPIRED 193
|
||||||
#define TK_SUBTABLE 194
|
#define TK_FILL_HISTORY 194
|
||||||
#define TK_KILL 195
|
#define TK_SUBTABLE 195
|
||||||
#define TK_CONNECTION 196
|
#define TK_KILL 196
|
||||||
#define TK_TRANSACTION 197
|
#define TK_CONNECTION 197
|
||||||
#define TK_BALANCE 198
|
#define TK_TRANSACTION 198
|
||||||
#define TK_VGROUP 199
|
#define TK_BALANCE 199
|
||||||
#define TK_MERGE 200
|
#define TK_VGROUP 200
|
||||||
#define TK_REDISTRIBUTE 201
|
#define TK_MERGE 201
|
||||||
#define TK_SPLIT 202
|
#define TK_REDISTRIBUTE 202
|
||||||
#define TK_DELETE 203
|
#define TK_SPLIT 203
|
||||||
#define TK_INSERT 204
|
#define TK_DELETE 204
|
||||||
#define TK_NULL 205
|
#define TK_INSERT 205
|
||||||
#define TK_NK_QUESTION 206
|
#define TK_NULL 206
|
||||||
#define TK_NK_ARROW 207
|
#define TK_NK_QUESTION 207
|
||||||
#define TK_ROWTS 208
|
#define TK_NK_ARROW 208
|
||||||
#define TK_QSTART 209
|
#define TK_ROWTS 209
|
||||||
#define TK_QEND 210
|
#define TK_QSTART 210
|
||||||
#define TK_QDURATION 211
|
#define TK_QEND 211
|
||||||
#define TK_WSTART 212
|
#define TK_QDURATION 212
|
||||||
#define TK_WEND 213
|
#define TK_WSTART 213
|
||||||
#define TK_WDURATION 214
|
#define TK_WEND 214
|
||||||
#define TK_IROWTS 215
|
#define TK_WDURATION 215
|
||||||
#define TK_CAST 216
|
#define TK_IROWTS 216
|
||||||
#define TK_NOW 217
|
#define TK_CAST 217
|
||||||
#define TK_TODAY 218
|
#define TK_NOW 218
|
||||||
#define TK_TIMEZONE 219
|
#define TK_TODAY 219
|
||||||
#define TK_CLIENT_VERSION 220
|
#define TK_TIMEZONE 220
|
||||||
#define TK_SERVER_VERSION 221
|
#define TK_CLIENT_VERSION 221
|
||||||
#define TK_SERVER_STATUS 222
|
#define TK_SERVER_VERSION 222
|
||||||
#define TK_CURRENT_USER 223
|
#define TK_SERVER_STATUS 223
|
||||||
#define TK_COUNT 224
|
#define TK_CURRENT_USER 224
|
||||||
#define TK_LAST_ROW 225
|
#define TK_COUNT 225
|
||||||
#define TK_CASE 226
|
#define TK_LAST_ROW 226
|
||||||
#define TK_END 227
|
#define TK_CASE 227
|
||||||
#define TK_WHEN 228
|
#define TK_END 228
|
||||||
#define TK_THEN 229
|
#define TK_WHEN 229
|
||||||
#define TK_ELSE 230
|
#define TK_THEN 230
|
||||||
#define TK_BETWEEN 231
|
#define TK_ELSE 231
|
||||||
#define TK_IS 232
|
#define TK_BETWEEN 232
|
||||||
#define TK_NK_LT 233
|
#define TK_IS 233
|
||||||
#define TK_NK_GT 234
|
#define TK_NK_LT 234
|
||||||
#define TK_NK_LE 235
|
#define TK_NK_GT 235
|
||||||
#define TK_NK_GE 236
|
#define TK_NK_LE 236
|
||||||
#define TK_NK_NE 237
|
#define TK_NK_GE 237
|
||||||
#define TK_MATCH 238
|
#define TK_NK_NE 238
|
||||||
#define TK_NMATCH 239
|
#define TK_MATCH 239
|
||||||
#define TK_CONTAINS 240
|
#define TK_NMATCH 240
|
||||||
#define TK_IN 241
|
#define TK_CONTAINS 241
|
||||||
#define TK_JOIN 242
|
#define TK_IN 242
|
||||||
#define TK_INNER 243
|
#define TK_JOIN 243
|
||||||
#define TK_SELECT 244
|
#define TK_INNER 244
|
||||||
#define TK_DISTINCT 245
|
#define TK_SELECT 245
|
||||||
#define TK_WHERE 246
|
#define TK_DISTINCT 246
|
||||||
#define TK_PARTITION 247
|
#define TK_WHERE 247
|
||||||
#define TK_BY 248
|
#define TK_PARTITION 248
|
||||||
#define TK_SESSION 249
|
#define TK_BY 249
|
||||||
#define TK_STATE_WINDOW 250
|
#define TK_SESSION 250
|
||||||
#define TK_SLIDING 251
|
#define TK_STATE_WINDOW 251
|
||||||
#define TK_FILL 252
|
#define TK_SLIDING 252
|
||||||
#define TK_VALUE 253
|
#define TK_FILL 253
|
||||||
#define TK_NONE 254
|
#define TK_VALUE 254
|
||||||
#define TK_PREV 255
|
#define TK_NONE 255
|
||||||
#define TK_LINEAR 256
|
#define TK_PREV 256
|
||||||
#define TK_NEXT 257
|
#define TK_LINEAR 257
|
||||||
#define TK_HAVING 258
|
#define TK_NEXT 258
|
||||||
#define TK_RANGE 259
|
#define TK_HAVING 259
|
||||||
#define TK_EVERY 260
|
#define TK_RANGE 260
|
||||||
#define TK_ORDER 261
|
#define TK_EVERY 261
|
||||||
#define TK_SLIMIT 262
|
#define TK_ORDER 262
|
||||||
#define TK_SOFFSET 263
|
#define TK_SLIMIT 263
|
||||||
#define TK_LIMIT 264
|
#define TK_SOFFSET 264
|
||||||
#define TK_OFFSET 265
|
#define TK_LIMIT 265
|
||||||
#define TK_ASC 266
|
#define TK_OFFSET 266
|
||||||
#define TK_NULLS 267
|
#define TK_ASC 267
|
||||||
#define TK_ABORT 268
|
#define TK_NULLS 268
|
||||||
#define TK_AFTER 269
|
#define TK_ABORT 269
|
||||||
#define TK_ATTACH 270
|
#define TK_AFTER 270
|
||||||
#define TK_BEFORE 271
|
#define TK_ATTACH 271
|
||||||
#define TK_BEGIN 272
|
#define TK_BEFORE 272
|
||||||
#define TK_BITAND 273
|
#define TK_BEGIN 273
|
||||||
#define TK_BITNOT 274
|
#define TK_BITAND 274
|
||||||
#define TK_BITOR 275
|
#define TK_BITNOT 275
|
||||||
#define TK_BLOCKS 276
|
#define TK_BITOR 276
|
||||||
#define TK_CHANGE 277
|
#define TK_BLOCKS 277
|
||||||
#define TK_COMMA 278
|
#define TK_CHANGE 278
|
||||||
#define TK_COMPACT 279
|
#define TK_COMMA 279
|
||||||
#define TK_CONCAT 280
|
#define TK_COMPACT 280
|
||||||
#define TK_CONFLICT 281
|
#define TK_CONCAT 281
|
||||||
#define TK_COPY 282
|
#define TK_CONFLICT 282
|
||||||
#define TK_DEFERRED 283
|
#define TK_COPY 283
|
||||||
#define TK_DELIMITERS 284
|
#define TK_DEFERRED 284
|
||||||
#define TK_DETACH 285
|
#define TK_DELIMITERS 285
|
||||||
#define TK_DIVIDE 286
|
#define TK_DETACH 286
|
||||||
#define TK_DOT 287
|
#define TK_DIVIDE 287
|
||||||
#define TK_EACH 288
|
#define TK_DOT 288
|
||||||
#define TK_FAIL 289
|
#define TK_EACH 289
|
||||||
#define TK_FILE 290
|
#define TK_FAIL 290
|
||||||
#define TK_FOR 291
|
#define TK_FILE 291
|
||||||
#define TK_GLOB 292
|
#define TK_FOR 292
|
||||||
#define TK_ID 293
|
#define TK_GLOB 293
|
||||||
#define TK_IMMEDIATE 294
|
#define TK_ID 294
|
||||||
#define TK_IMPORT 295
|
#define TK_IMMEDIATE 295
|
||||||
#define TK_INITIALLY 296
|
#define TK_IMPORT 296
|
||||||
#define TK_INSTEAD 297
|
#define TK_INITIALLY 297
|
||||||
#define TK_ISNULL 298
|
#define TK_INSTEAD 298
|
||||||
#define TK_KEY 299
|
#define TK_ISNULL 299
|
||||||
#define TK_MODULES 300
|
#define TK_KEY 300
|
||||||
#define TK_NK_BITNOT 301
|
#define TK_MODULES 301
|
||||||
#define TK_NK_SEMI 302
|
#define TK_NK_BITNOT 302
|
||||||
#define TK_NOTNULL 303
|
#define TK_NK_SEMI 303
|
||||||
#define TK_OF 304
|
#define TK_NOTNULL 304
|
||||||
#define TK_PLUS 305
|
#define TK_OF 305
|
||||||
#define TK_PRIVILEGE 306
|
#define TK_PLUS 306
|
||||||
#define TK_RAISE 307
|
#define TK_PRIVILEGE 307
|
||||||
#define TK_REPLACE 308
|
#define TK_RAISE 308
|
||||||
#define TK_RESTRICT 309
|
#define TK_REPLACE 309
|
||||||
#define TK_ROW 310
|
#define TK_RESTRICT 310
|
||||||
#define TK_SEMI 311
|
#define TK_ROW 311
|
||||||
#define TK_STAR 312
|
#define TK_SEMI 312
|
||||||
#define TK_STATEMENT 313
|
#define TK_STAR 313
|
||||||
#define TK_STRING 314
|
#define TK_STATEMENT 314
|
||||||
#define TK_TIMES 315
|
#define TK_STRING 315
|
||||||
#define TK_UPDATE 316
|
#define TK_TIMES 316
|
||||||
#define TK_VALUES 317
|
#define TK_UPDATE 317
|
||||||
#define TK_VARIABLE 318
|
#define TK_VALUES 318
|
||||||
#define TK_VIEW 319
|
#define TK_VARIABLE 319
|
||||||
#define TK_WAL 320
|
#define TK_VIEW 320
|
||||||
|
#define TK_WAL 321
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
|
|
|
@ -190,7 +190,9 @@ int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts);
|
||||||
|
|
||||||
int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType);
|
int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType);
|
||||||
|
|
||||||
int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq, int64_t ver);
|
// int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq, int64_t ver);
|
||||||
|
//
|
||||||
|
int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit);
|
||||||
|
|
||||||
int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset);
|
int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset);
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,9 @@ typedef struct STableOptions {
|
||||||
SNodeList* pWatermark;
|
SNodeList* pWatermark;
|
||||||
int64_t watermark1;
|
int64_t watermark1;
|
||||||
int64_t watermark2;
|
int64_t watermark2;
|
||||||
|
SNodeList* pDeleteMark;
|
||||||
|
int64_t deleteMark1;
|
||||||
|
int64_t deleteMark2;
|
||||||
SNodeList* pRollupFuncs;
|
SNodeList* pRollupFuncs;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
SNodeList* pSma;
|
SNodeList* pSma;
|
||||||
|
@ -383,6 +386,7 @@ typedef struct SStreamOptions {
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
SNode* pDelay;
|
SNode* pDelay;
|
||||||
SNode* pWatermark;
|
SNode* pWatermark;
|
||||||
|
SNode* pDeleteMark;
|
||||||
int8_t fillHistory;
|
int8_t fillHistory;
|
||||||
int8_t ignoreExpired;
|
int8_t ignoreExpired;
|
||||||
} SStreamOptions;
|
} SStreamOptions;
|
||||||
|
|
|
@ -234,7 +234,6 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN,
|
|
||||||
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN,
|
QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG,
|
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG,
|
||||||
|
@ -265,7 +264,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT,
|
QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_DELETE,
|
QUERY_NODE_PHYSICAL_PLAN_DELETE,
|
||||||
QUERY_NODE_PHYSICAL_SUBPLAN,
|
QUERY_NODE_PHYSICAL_SUBPLAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN
|
QUERY_NODE_PHYSICAL_PLAN,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN
|
||||||
} ENodeType;
|
} ENodeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -91,6 +91,7 @@ typedef struct SScanLogicNode {
|
||||||
SNode* pTagIndexCond;
|
SNode* pTagIndexCond;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
SArray* pSmaIndexes;
|
SArray* pSmaIndexes;
|
||||||
SNodeList* pGroupTags;
|
SNodeList* pGroupTags;
|
||||||
|
@ -213,6 +214,7 @@ typedef struct SWindowLogicNode {
|
||||||
SNode* pStateExpr;
|
SNode* pStateExpr;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
EWindowAlgorithm windowAlgo;
|
EWindowAlgorithm windowAlgo;
|
||||||
EOrder inputTsOrder;
|
EOrder inputTsOrder;
|
||||||
|
@ -440,6 +442,7 @@ typedef struct SWinodwPhysiNode {
|
||||||
SNode* pTsEnd; // window end timestamp
|
SNode* pTsEnd; // window end timestamp
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
EOrder inputTsOrder;
|
EOrder inputTsOrder;
|
||||||
EOrder outputTsOrder;
|
EOrder outputTsOrder;
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef struct SPlanContext {
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
char* pMsg;
|
char* pMsg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
|
|
|
@ -103,6 +103,7 @@ typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
} SStreamQueueItem;
|
} SStreamQueueItem;
|
||||||
|
|
||||||
|
#if 0
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
|
@ -116,6 +117,21 @@ typedef struct {
|
||||||
SArray* dataRefs; // SArray<int32_t*>
|
SArray* dataRefs; // SArray<int32_t*>
|
||||||
SArray* reqs; // SArray<SSubmitReq*>
|
SArray* reqs; // SArray<SSubmitReq*>
|
||||||
} SStreamMergedSubmit;
|
} SStreamMergedSubmit;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
int64_t ver;
|
||||||
|
int32_t* dataRef;
|
||||||
|
SPackedData submit;
|
||||||
|
} SStreamDataSubmit2;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
int64_t ver;
|
||||||
|
SArray* dataRefs; // SArray<int32_t*>
|
||||||
|
SArray* submits; // SArray<SPackedSubmit>
|
||||||
|
} SStreamMergedSubmit2;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
@ -219,11 +235,11 @@ static FORCE_INLINE void* streamQueueNextItem(SStreamQueue* queue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamDataSubmit* streamDataSubmitNew(SSubmitReq* pReq);
|
SStreamDataSubmit2* streamDataSubmitNew(SPackedData submit);
|
||||||
|
|
||||||
void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit);
|
void streamDataSubmitRefDec(SStreamDataSubmit2* pDataSubmit);
|
||||||
|
|
||||||
SStreamDataSubmit* streamSubmitRefClone(SStreamDataSubmit* pSubmit);
|
SStreamDataSubmit2* streamSubmitRefClone(SStreamDataSubmit2* pSubmit);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* qmsg;
|
char* qmsg;
|
||||||
|
@ -355,14 +371,15 @@ void tFreeSStreamTask(SStreamTask* pTask);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) {
|
static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) {
|
||||||
if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
|
if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
SStreamDataSubmit* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit*)pItem);
|
SStreamDataSubmit2* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit2*)pItem);
|
||||||
if (pSubmitClone == NULL) {
|
if (pSubmitClone == NULL) {
|
||||||
qDebug("task %d %p submit enqueue failed since out of memory", pTask->taskId, pTask);
|
qDebug("task %d %p submit enqueue failed since out of memory", pTask->taskId, pTask);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED);
|
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
qDebug("task %d %p submit enqueue %p %p %p", pTask->taskId, pTask, pItem, pSubmitClone, pSubmitClone->data);
|
qDebug("task %d %p submit enqueue %p %p %p %d %" PRId64, pTask->taskId, pTask, pItem, pSubmitClone,
|
||||||
|
pSubmitClone->submit.msgStr, pSubmitClone->submit.msgLen, pSubmitClone->submit.ver);
|
||||||
taosWriteQitem(pTask->inputQueue->queue, pSubmitClone);
|
taosWriteQitem(pTask->inputQueue->queue, pSubmitClone);
|
||||||
// qStreamInput(pTask->exec.executor, pSubmitClone);
|
// qStreamInput(pTask->exec.executor, pSubmitClone);
|
||||||
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE ||
|
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE ||
|
||||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
||||||
#include "tlrucache.h"
|
#include "tlrucache.h"
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
|
|
||||||
#define SYNC_RESP_TTL_MS 10000000
|
#define SYNC_RESP_TTL_MS 30000
|
||||||
#define SYNC_SPEED_UP_HB_TIMER 400
|
#define SYNC_SPEED_UP_HB_TIMER 400
|
||||||
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
||||||
#define SYNC_SLOW_DOWN_RANGE 100
|
#define SYNC_SLOW_DOWN_RANGE 100
|
||||||
|
@ -47,6 +47,7 @@ extern "C" {
|
||||||
|
|
||||||
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
||||||
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
||||||
|
#define SYNC_SNAP_RESEND_MS 1000 * 60
|
||||||
|
|
||||||
#define SYNC_MAX_BATCH_SIZE 1
|
#define SYNC_MAX_BATCH_SIZE 1
|
||||||
#define SYNC_INDEX_BEGIN 0
|
#define SYNC_INDEX_BEGIN 0
|
||||||
|
|
|
@ -72,6 +72,7 @@ typedef struct SRpcMsg {
|
||||||
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
||||||
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
||||||
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
||||||
|
typedef bool (*RpcFFfp)(tmsg_t msgType);
|
||||||
typedef void (*RpcDfp)(void *ahandle);
|
typedef void (*RpcDfp)(void *ahandle);
|
||||||
|
|
||||||
typedef struct SRpcInit {
|
typedef struct SRpcInit {
|
||||||
|
@ -90,6 +91,9 @@ typedef struct SRpcInit {
|
||||||
int32_t retryMaxInterval; // retry max interval
|
int32_t retryMaxInterval; // retry max interval
|
||||||
int64_t retryMaxTimouet;
|
int64_t retryMaxTimouet;
|
||||||
|
|
||||||
|
int32_t failFastThreshold;
|
||||||
|
int32_t failFastInterval;
|
||||||
|
|
||||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||||
int8_t encryption; // encrypt or not
|
int8_t encryption; // encrypt or not
|
||||||
|
|
||||||
|
@ -107,6 +111,8 @@ typedef struct SRpcInit {
|
||||||
|
|
||||||
// destroy client ahandle;
|
// destroy client ahandle;
|
||||||
RpcDfp dfp;
|
RpcDfp dfp;
|
||||||
|
// fail fast fp
|
||||||
|
RpcFFfp ffp;
|
||||||
|
|
||||||
void *parent;
|
void *parent;
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
|
@ -27,6 +27,7 @@ extern "C" {
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !defined(WINDOWS)
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <execinfo.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -120,12 +120,6 @@ void syslog(int unused, const char *format, ...);
|
||||||
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
||||||
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
#define ASSERT(x) assert(x)
|
|
||||||
#else
|
|
||||||
#define ASSERT(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UNUSED
|
#ifndef UNUSED
|
||||||
#define UNUSED(x) ((void)(x))
|
#define UNUSED(x) ((void)(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -62,6 +62,7 @@ int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
|
||||||
bool taosIsDir(const char *dirname);
|
bool taosIsDir(const char *dirname);
|
||||||
char *taosDirName(char *dirname);
|
char *taosDirName(char *dirname);
|
||||||
char *taosDirEntryBaseName(char *dirname);
|
char *taosDirEntryBaseName(char *dirname);
|
||||||
|
void taosGetCwd(char *buf, int32_t len);
|
||||||
|
|
||||||
TdDirPtr taosOpenDir(const char *dirname);
|
TdDirPtr taosOpenDir(const char *dirname);
|
||||||
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
||||||
|
|
|
@ -62,7 +62,7 @@ typedef int32_t TdUcs4;
|
||||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||||
int64_t taosStr2int64(const char *str);
|
int64_t taosStr2int64(const char *str);
|
||||||
|
|
||||||
void taosConvInit(void);
|
int32_t taosConvInit(void);
|
||||||
void taosConvDestroy();
|
void taosConvDestroy();
|
||||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
||||||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||||
|
|
|
@ -46,6 +46,29 @@ void taosSetTerminalMode();
|
||||||
int32_t taosGetOldTerminalMode();
|
int32_t taosGetOldTerminalMode();
|
||||||
void taosResetTerminalMode();
|
void taosResetTerminalMode();
|
||||||
|
|
||||||
|
#if !defined(WINDOWS)
|
||||||
|
#define taosPrintTrace(flags, level, dflag) \
|
||||||
|
{ \
|
||||||
|
void* array[100]; \
|
||||||
|
int32_t size = backtrace(array, 100); \
|
||||||
|
char** strings = backtrace_symbols(array, size); \
|
||||||
|
if (strings != NULL) { \
|
||||||
|
taosPrintLog(flags, level, dflag, "obtained %d stack frames", size); \
|
||||||
|
for (int32_t i = 0; i < size; i++) { \
|
||||||
|
taosPrintLog(flags, level, dflag, "frame:%d, %s", i, strings[i]); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
taosMemoryFree(strings); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define taosPrintTrace(flags, level, dflag) \
|
||||||
|
{ \
|
||||||
|
taosPrintLog(flags, level, dflag, \
|
||||||
|
"backtrace not implemented on windows, so detailed stack information cannot be printed"); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define _TD_UTIL_CODING_H_
|
#define _TD_UTIL_CODING_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -308,8 +308,9 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MIN_DURATION_PER_FILE 60 // unit minute
|
#define TSDB_MIN_DURATION_PER_FILE 60 // unit minute
|
||||||
#define TSDB_MAX_DURATION_PER_FILE (3650 * 1440)
|
#define TSDB_MAX_DURATION_PER_FILE (3650 * 1440)
|
||||||
#define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440)
|
#define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440)
|
||||||
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
||||||
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
||||||
|
#define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved.
|
||||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||||
#define TSDB_MIN_MINROWS_FBLOCK 10
|
#define TSDB_MIN_MINROWS_FBLOCK 10
|
||||||
#define TSDB_MAX_MINROWS_FBLOCK 1000
|
#define TSDB_MAX_MINROWS_FBLOCK 1000
|
||||||
|
@ -382,13 +383,16 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0
|
#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0
|
||||||
#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0
|
#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0
|
||||||
|
|
||||||
#define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond
|
#define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond
|
||||||
#define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000)
|
#define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000)
|
||||||
#define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond
|
#define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond
|
||||||
#define TSDB_MAX_ROLLUP_WATERMARK (15 * 60 * 1000)
|
#define TSDB_MAX_ROLLUP_WATERMARK (15 * 60 * 1000)
|
||||||
#define TSDB_DEFAULT_ROLLUP_WATERMARK 5000
|
#define TSDB_DEFAULT_ROLLUP_WATERMARK 5000
|
||||||
#define TSDB_MIN_TABLE_TTL 0
|
#define TSDB_MIN_ROLLUP_DELETE_MARK 0 // unit millisecond
|
||||||
#define TSDB_DEFAULT_TABLE_TTL 0
|
#define TSDB_MAX_ROLLUP_DELETE_MARK INT64_MAX
|
||||||
|
#define TSDB_DEFAULT_ROLLUP_DELETE_MARK 900000 // 900s
|
||||||
|
#define TSDB_MIN_TABLE_TTL 0
|
||||||
|
#define TSDB_DEFAULT_TABLE_TTL 0
|
||||||
|
|
||||||
#define TSDB_MIN_EXPLAIN_RATIO 0
|
#define TSDB_MIN_EXPLAIN_RATIO 0
|
||||||
#define TSDB_MAX_EXPLAIN_RATIO 1
|
#define TSDB_MAX_EXPLAIN_RATIO 1
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef void (*LogFp)(int64_t ts, ELogLevel level, const char *content);
|
||||||
|
|
||||||
extern bool tsLogEmbedded;
|
extern bool tsLogEmbedded;
|
||||||
extern bool tsAsyncLog;
|
extern bool tsAsyncLog;
|
||||||
|
extern bool tsAssert;
|
||||||
extern int32_t tsNumOfLogLines;
|
extern int32_t tsNumOfLogLines;
|
||||||
extern int32_t tsLogKeepDays;
|
extern int32_t tsLogKeepDays;
|
||||||
extern LogFp tsLogFp;
|
extern LogFp tsLogFp;
|
||||||
|
@ -82,6 +83,10 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...);
|
||||||
|
#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
|
@ -497,27 +497,27 @@ function install_service_on_systemd() {
|
||||||
|
|
||||||
taosd_service_config="${service_config_dir}/${serverName}.service"
|
taosd_service_config="${service_config_dir}/${serverName}.service"
|
||||||
|
|
||||||
${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}"
|
${csudo}bash -c "echo [Unit] >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Description=${productName} server service' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Description=${productName} server service >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'After=network-online.target' >> ${taosd_service_config}"
|
${csudo}bash -c "echo After=network-online.target >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Wants=network-online.target >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo >> ${taosd_service_config}"
|
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}"
|
${csudo}bash -c "echo [Service] >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Type=simple >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'ExecStart=/usr/bin/${serverName}' >> ${taosd_service_config}"
|
${csudo}bash -c "echo ExecStart=/usr/bin/${serverName} >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'ExecStartPre=${installDir}/bin/startPre.sh' >> ${taosd_service_config}"
|
${csudo}bash -c "echo ExecStartPre=${installDir}/bin/startPre.sh >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}"
|
${csudo}bash -c "echo TimeoutStopSec=1000000s >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}"
|
${csudo}bash -c "echo LimitNOFILE=infinity >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}"
|
${csudo}bash -c "echo LimitNPROC=infinity >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}"
|
${csudo}bash -c "echo LimitCORE=infinity >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}"
|
${csudo}bash -c "echo TimeoutStartSec=0 >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}"
|
${csudo}bash -c "echo StandardOutput=null >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Restart=always >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}"
|
${csudo}bash -c "echo StartLimitBurst=3 >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}"
|
${csudo}bash -c "echo StartLimitInterval=60s >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo >> ${taosd_service_config}"
|
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}"
|
${csudo}bash -c "echo [Install] >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
|
${csudo}bash -c "echo WantedBy=multi-user.target >> ${taosd_service_config}"
|
||||||
${csudo}systemctl enable ${serverName}
|
${csudo}systemctl enable ${serverName}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,10 +238,9 @@ void destroyTscObj(void *pObj) {
|
||||||
tscDebug("connObj 0x%" PRIx64 " p:%p destroyed, remain inst totalConn:%" PRId64, pTscObj->id, pTscObj,
|
tscDebug("connObj 0x%" PRIx64 " p:%p destroyed, remain inst totalConn:%" PRId64, pTscObj->id, pTscObj,
|
||||||
pTscObj->pAppInfo->numOfConns);
|
pTscObj->pAppInfo->numOfConns);
|
||||||
|
|
||||||
int64_t connNum = atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
// In any cases, we should not free app inst here. Or an race condition rises.
|
||||||
if (0 == connNum) {
|
/*int64_t connNum = */atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||||
destroyAppInst(pTscObj->pAppInfo);
|
|
||||||
}
|
|
||||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||||
taosMemoryFree(pTscObj);
|
taosMemoryFree(pTscObj);
|
||||||
|
|
||||||
|
@ -414,7 +413,9 @@ void taos_init_imp(void) {
|
||||||
|
|
||||||
initQueryModuleMsgHandle();
|
initQueryModuleMsgHandle();
|
||||||
|
|
||||||
taosConvInit();
|
if (taosConvInit() != 0) {
|
||||||
|
ASSERTS(0, "failed to init conv");
|
||||||
|
}
|
||||||
|
|
||||||
rpcInit();
|
rpcInit();
|
||||||
|
|
||||||
|
|
|
@ -796,9 +796,10 @@ static void doAsyncQueryFromParse(SMetaData *pResultMeta, void *param, int32_t c
|
||||||
SQuery *pQuery = pRequest->pQuery;
|
SQuery *pQuery = pRequest->pQuery;
|
||||||
|
|
||||||
pRequest->metric.ctgEnd = taosGetTimestampUs();
|
pRequest->metric.ctgEnd = taosGetTimestampUs();
|
||||||
qDebug("0x%" PRIx64 " start to continue parse, reqId:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
qDebug("0x%" PRIx64 " start to continue parse, reqId:0x%" PRIx64 ", code:%s", pRequest->self, pRequest->requestId, tstrerror(code));
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
pWrapper->pCatalogReq->forceUpdate = false;
|
||||||
code = qContinueParseSql(pWrapper->pParseCtx, pWrapper->pCatalogReq, pResultMeta, pQuery);
|
code = qContinueParseSql(pWrapper->pParseCtx, pWrapper->pCatalogReq, pResultMeta, pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -875,6 +875,7 @@ void tmqFreeImpl(void* handle) {
|
||||||
tmq_t* tmq = (tmq_t*)handle;
|
tmq_t* tmq = (tmq_t*)handle;
|
||||||
|
|
||||||
// TODO stop timer
|
// TODO stop timer
|
||||||
|
tmqClearUnhandleMsg(tmq);
|
||||||
if (tmq->mqueue) taosCloseQueue(tmq->mqueue);
|
if (tmq->mqueue) taosCloseQueue(tmq->mqueue);
|
||||||
if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask);
|
if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask);
|
||||||
if (tmq->qall) taosFreeQall(tmq->qall);
|
if (tmq->qall) taosFreeQall(tmq->qall);
|
||||||
|
@ -884,8 +885,7 @@ void tmqFreeImpl(void* handle) {
|
||||||
int32_t sz = taosArrayGetSize(tmq->clientTopics);
|
int32_t sz = taosArrayGetSize(tmq->clientTopics);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
taosMemoryFreeClear(pTopic->schema.pSchema);
|
||||||
int32_t vgSz = taosArrayGetSize(pTopic->vgs);
|
|
||||||
taosArrayDestroy(pTopic->vgs);
|
taosArrayDestroy(pTopic->vgs);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(tmq->clientTopics);
|
taosArrayDestroy(tmq->clientTopics);
|
||||||
|
@ -1304,7 +1304,6 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) {
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
||||||
int32_t vgSz = taosArrayGetSize(pTopic->vgs);
|
|
||||||
taosArrayDestroy(pTopic->vgs);
|
taosArrayDestroy(pTopic->vgs);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(tmq->clientTopics);
|
taosArrayDestroy(tmq->clientTopics);
|
||||||
|
@ -1410,7 +1409,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void* pReq = taosMemoryCalloc(1, tlen);
|
void* pReq = taosMemoryCalloc(1, tlen);
|
||||||
if (tlen < 0) {
|
if (pReq == NULL) {
|
||||||
tscError("failed to malloc askEpReq msg, size:%d", tlen);
|
tscError("failed to malloc askEpReq msg, size:%d", tlen);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1738,7 +1737,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
return pRsp;
|
return pRsp;
|
||||||
} else {
|
} else {
|
||||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n",
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||||
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2246,23 +2246,17 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubmitTbData* pTbData = (SSubmitTbData*)taosMemoryCalloc(1, sizeof(SSubmitTbData));
|
SSubmitTbData tbData = {0};
|
||||||
if (!pTbData) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(pTbData->aRowP = taosArrayInit(rows, sizeof(SRow*)))) {
|
if (!(tbData.aRowP = taosArrayInit(rows, sizeof(SRow*)))) {
|
||||||
taosMemoryFree(pTbData);
|
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
pTbData->suid = suid;
|
tbData.suid = suid;
|
||||||
pTbData->uid = pDataBlock->info.id.groupId;
|
tbData.uid = pDataBlock->info.id.groupId;
|
||||||
pTbData->sver = pTSchema->version;
|
tbData.sver = pTSchema->version;
|
||||||
|
|
||||||
if (!pVals && !(pVals = taosArrayInit(colNum, sizeof(SColVal)))) {
|
if (!pVals && !(pVals = taosArrayInit(colNum, sizeof(SColVal)))) {
|
||||||
taosArrayDestroy(pTbData->aRowP);
|
taosArrayDestroy(tbData.aRowP);
|
||||||
taosMemoryFree(pTbData);
|
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2360,14 +2354,14 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat
|
||||||
}
|
}
|
||||||
SRow* pRow = NULL;
|
SRow* pRow = NULL;
|
||||||
if ((terrno = tRowBuild(pVals, pTSchema, &pRow)) < 0) {
|
if ((terrno = tRowBuild(pVals, pTSchema, &pRow)) < 0) {
|
||||||
tDestroySSubmitTbData(pTbData, TSDB_MSG_FLG_ENCODE);
|
tDestroySSubmitTbData(&tbData, TSDB_MSG_FLG_ENCODE);
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
ASSERT(pRow);
|
ASSERT(pRow);
|
||||||
taosArrayPush(pTbData->aRowP, &pRow);
|
taosArrayPush(tbData.aRowP, &pRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pReq->aSubmitTbData, pTbData);
|
taosArrayPush(pReq->aSubmitTbData, &tbData);
|
||||||
}
|
}
|
||||||
_end:
|
_end:
|
||||||
taosArrayDestroy(pVals);
|
taosArrayDestroy(pVals);
|
||||||
|
|
|
@ -1030,17 +1030,22 @@ static int32_t tRowAppendKVToColData(SRow *pRow, STSchema *pTSchema, SColData *a
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t cid;
|
int16_t cid;
|
||||||
pData += tGetI16(pData, &cid);
|
pData += tGetI16v(pData, &cid);
|
||||||
|
|
||||||
if (TABS(cid) == pTColumn->colId) {
|
if (TABS(cid) == pTColumn->colId) {
|
||||||
if (cid < 0) {
|
if (cid < 0) {
|
||||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
|
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
} else {
|
} else {
|
||||||
uint32_t nData;
|
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||||
pData += tGetU32v(pData, &nData);
|
uint32_t nData;
|
||||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData);
|
pData += tGetU32v(pData, &nData);
|
||||||
if (code) goto _exit;
|
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData);
|
||||||
|
if (code) goto _exit;
|
||||||
|
} else {
|
||||||
|
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, 0);
|
||||||
|
if (code) goto _exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
iCol++;
|
iCol++;
|
||||||
goto _continue;
|
goto _continue;
|
||||||
|
|
|
@ -333,6 +333,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
|
||||||
if (cfgAddTimezone(pCfg, "timezone", tsTimezoneStr) != 0) return -1;
|
if (cfgAddTimezone(pCfg, "timezone", tsTimezoneStr) != 0) return -1;
|
||||||
if (cfgAddLocale(pCfg, "locale", tsLocale) != 0) return -1;
|
if (cfgAddLocale(pCfg, "locale", tsLocale) != 0) return -1;
|
||||||
if (cfgAddCharset(pCfg, "charset", tsCharset) != 0) return -1;
|
if (cfgAddCharset(pCfg, "charset", tsCharset) != 0) return -1;
|
||||||
|
if (cfgAddBool(pCfg, "assert", 1, 1) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "enableCoreFile", 1, 1) != 0) return -1;
|
if (cfgAddBool(pCfg, "enableCoreFile", 1, 1) != 0) return -1;
|
||||||
if (cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1) != 0) return -1;
|
if (cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1) != 0) return -1;
|
||||||
|
|
||||||
|
@ -407,7 +408,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
|
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
|
||||||
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
||||||
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 4, 1024, 0) != 0) return -1;
|
||||||
|
|
||||||
// tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
// tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
||||||
// tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4);
|
// tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4);
|
||||||
|
@ -693,6 +694,8 @@ static void taosSetSystemCfg(SConfig *pCfg) {
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetCoreDump(enableCore);
|
taosSetCoreDump(enableCore);
|
||||||
|
|
||||||
|
tsAssert = cfgGetItem(pCfg, "assert")->bval;
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
tsVersion = 30000000;
|
tsVersion = 30000000;
|
||||||
}
|
}
|
||||||
|
@ -788,6 +791,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
||||||
case 'a': {
|
case 'a': {
|
||||||
if (strcasecmp("asyncLog", name) == 0) {
|
if (strcasecmp("asyncLog", name) == 0) {
|
||||||
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
||||||
|
} else if (strcasecmp("assert", name) == 0) {
|
||||||
|
tsAssert = cfgGetItem(pCfg, "assert")->bval;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) {
|
||||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
||||||
|
@ -551,6 +553,8 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (pReq->ast2Len > 0) {
|
if (pReq->ast2Len > 0) {
|
||||||
if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1;
|
if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tEncodeI64(&encoder, pReq->deleteMark1) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->deleteMark2) < 0) return -1;
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -644,6 +648,9 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tDecodeI64(&decoder, &pReq->deleteMark1) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->deleteMark2) < 0) return -1;
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -822,6 +829,7 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq
|
||||||
if (pReq->astLen > 0) {
|
if (pReq->astLen > 0) {
|
||||||
if (tEncodeBinary(&encoder, pReq->ast, pReq->astLen) < 0) return -1;
|
if (tEncodeBinary(&encoder, pReq->ast, pReq->astLen) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -870,7 +878,7 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
|
||||||
if (pReq->ast == NULL) return -1;
|
if (pReq->ast == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tDecodeI64(&decoder, &pReq->deleteMark) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "trow.h"
|
#include "trow.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
const uint8_t tdVTypeByte[2][3] = {{
|
const uint8_t tdVTypeByte[2][3] = {{
|
||||||
// 2 bits
|
// 2 bits
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mktime64 - Converts date to seconds.
|
* mktime64 - Converts date to seconds.
|
||||||
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
|
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
|
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
|
||||||
|
@ -45,9 +46,30 @@ static struct {
|
||||||
SArray *pArgs; // SConfigPair
|
SArray *pArgs; // SConfigPair
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dmStopDnode(int signum, void *info, void *ctx) { dmStop(); }
|
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetAllDebugFlag(143, true); }
|
||||||
|
static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert = 1; }
|
||||||
|
|
||||||
|
static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
||||||
|
// taosIgnSignal(SIGUSR1);
|
||||||
|
// taosIgnSignal(SIGUSR2);
|
||||||
|
taosIgnSignal(SIGTERM);
|
||||||
|
taosIgnSignal(SIGHUP);
|
||||||
|
taosIgnSignal(SIGINT);
|
||||||
|
taosIgnSignal(SIGABRT);
|
||||||
|
taosIgnSignal(SIGBREAK);
|
||||||
|
|
||||||
|
dInfo("shut down signal is %d", signum);
|
||||||
|
#ifndef WINDOWS
|
||||||
|
dInfo("sender PID:%d cmdline:%s", ((siginfo_t *)sigInfo)->si_pid,
|
||||||
|
taosGetCmdlineByPID(((siginfo_t *)sigInfo)->si_pid));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dmStop();
|
||||||
|
}
|
||||||
|
|
||||||
static void dmSetSignalHandle() {
|
static void dmSetSignalHandle() {
|
||||||
|
taosSetSignal(SIGUSR1, dmSetDebugFlag);
|
||||||
|
taosSetSignal(SIGUSR2, dmSetAssert);
|
||||||
taosSetSignal(SIGTERM, dmStopDnode);
|
taosSetSignal(SIGTERM, dmStopDnode);
|
||||||
taosSetSignal(SIGHUP, dmStopDnode);
|
taosSetSignal(SIGHUP, dmStopDnode);
|
||||||
taosSetSignal(SIGINT, dmStopDnode);
|
taosSetSignal(SIGINT, dmStopDnode);
|
||||||
|
@ -105,6 +127,19 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
||||||
|
char path[1024] = {0};
|
||||||
|
taosGetCwd(path, sizeof(path));
|
||||||
|
|
||||||
|
char args[1024] = {0};
|
||||||
|
int32_t arglen = snprintf(args, sizeof(args), "%s", argv[0]);
|
||||||
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
|
arglen = arglen + snprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("startup path:%s args:%s", path, args);
|
||||||
|
}
|
||||||
|
|
||||||
static void dmGenerateGrant() { mndGenerateMachineCode(); }
|
static void dmGenerateGrant() { mndGenerateMachineCode(); }
|
||||||
|
|
||||||
static void dmPrintVersion() {
|
static void dmPrintVersion() {
|
||||||
|
@ -194,6 +229,8 @@ int mainWindows(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dmPrintArgs(argc, argv);
|
||||||
|
|
||||||
if (taosInitCfg(configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
if (taosInitCfg(configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
||||||
dError("failed to start since read config error");
|
dError("failed to start since read config error");
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
@ -201,7 +238,12 @@ int mainWindows(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosConvInit();
|
if (taosConvInit() != 0) {
|
||||||
|
dError("failed to init conv");
|
||||||
|
taosCloseLog();
|
||||||
|
taosCleanupArgs();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (global.dumpConfig) {
|
if (global.dumpConfig) {
|
||||||
dmDumpCfg();
|
dmDumpCfg();
|
||||||
|
|
|
@ -103,7 +103,12 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
tSerializeSStatusReq(pHead, contLen, &req);
|
tSerializeSStatusReq(pHead, contLen, &req);
|
||||||
tFreeSStatusReq(&req);
|
tFreeSStatusReq(&req);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527};
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
|
.contLen = contLen,
|
||||||
|
.msgType = TDMT_MND_STATUS,
|
||||||
|
.info.ahandle = (void *)0x9527,
|
||||||
|
.info.refId = 0,
|
||||||
|
.info.noResp = 0};
|
||||||
SRpcMsg rpcRsp = {0};
|
SRpcMsg rpcRsp = {0};
|
||||||
|
|
||||||
dTrace("send status req to mnode, dnodeVer:%" PRId64 " statusSeq:%d", req.dnodeVer, req.statusSeq);
|
dTrace("send status req to mnode, dnodeVer:%" PRId64 " statusSeq:%d", req.dnodeVer, req.statusSeq);
|
||||||
|
@ -150,7 +155,8 @@ static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
||||||
SServerStatusRsp statusRsp = {0};
|
SServerStatusRsp statusRsp = {0};
|
||||||
SMonMloadInfo minfo = {0};
|
SMonMloadInfo minfo = {0};
|
||||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||||
if (minfo.isMnode && (minfo.load.syncState == TAOS_SYNC_STATE_ERROR || minfo.load.syncState == TAOS_SYNC_STATE_OFFLINE)) {
|
if (minfo.isMnode &&
|
||||||
|
(minfo.load.syncState == TAOS_SYNC_STATE_ERROR || minfo.load.syncState == TAOS_SYNC_STATE_OFFLINE)) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,6 +21,8 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
int64_t lastTime = taosGetTimestampMs();
|
int64_t lastTime = taosGetTimestampMs();
|
||||||
setThreadName("dnode-status");
|
setThreadName("dnode-status");
|
||||||
|
|
||||||
|
const static int16_t TRIM_FREQ = 30;
|
||||||
|
int32_t trimCount = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
taosMsleep(200);
|
taosMsleep(200);
|
||||||
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
||||||
|
@ -28,9 +30,13 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
int64_t curTime = taosGetTimestampMs();
|
int64_t curTime = taosGetTimestampMs();
|
||||||
float interval = (curTime - lastTime) / 1000.0f;
|
float interval = (curTime - lastTime) / 1000.0f;
|
||||||
if (interval >= tsStatusInterval) {
|
if (interval >= tsStatusInterval) {
|
||||||
taosMemoryTrim(0);
|
|
||||||
dmSendStatusReq(pMgmt);
|
dmSendStatusReq(pMgmt);
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
|
|
||||||
|
trimCount = (trimCount + 1) % TRIM_FREQ;
|
||||||
|
if (trimCount == 0) {
|
||||||
|
taosMemoryTrim(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
|
|
||||||
SSnode *pSnode = pMgmt->pSnode;
|
SSnode *pSnode = pMgmt->pSnode;
|
||||||
if (pSnode == NULL) {
|
if (pSnode == NULL) {
|
||||||
dError("snode: msg:%p failed to put into vnode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
dError("msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
||||||
TMSG_INFO(pMsg->msgType), qtype);
|
TMSG_INFO(pMsg->msgType), qtype);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
|
@ -161,7 +161,8 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
smPutNodeMsgToWriteQueue(pMgmt, pMsg);
|
smPutNodeMsgToWriteQueue(pMgmt, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERTS(0, "msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
||||||
|
TMSG_INFO(pMsg->msgType), qtype);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,11 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
return (*msgFp)(pWrapper->pMgmt, pMsg);
|
return (*msgFp)(pWrapper->pMgmt, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool dmFailFastFp(tmsg_t msgType) {
|
||||||
|
// add more msg type later
|
||||||
|
return msgType == TDMT_SYNC_HEARTBEAT || msgType == TDMT_SYNC_APPEND_ENTRIES;
|
||||||
|
}
|
||||||
|
|
||||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -260,6 +265,10 @@ int32_t dmInitClient(SDnode *pDnode) {
|
||||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||||
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
||||||
|
|
||||||
|
rpcInit.failFastInterval = 1000; // interval threshold(ms)
|
||||||
|
rpcInit.failFastThreshold = 3; // failed threshold
|
||||||
|
rpcInit.ffp = dmFailFastFp;
|
||||||
|
|
||||||
pTrans->clientRpc = rpcOpen(&rpcInit);
|
pTrans->clientRpc = rpcOpen(&rpcInit);
|
||||||
if (pTrans->clientRpc == NULL) {
|
if (pTrans->clientRpc == NULL) {
|
||||||
dError("failed to init dnode rpc client");
|
dError("failed to init dnode rpc client");
|
||||||
|
@ -292,6 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) {
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
|
|
||||||
pTrans->serverRpc = rpcOpen(&rpcInit);
|
pTrans->serverRpc = rpcOpen(&rpcInit);
|
||||||
if (pTrans->serverRpc == NULL) {
|
if (pTrans->serverRpc == NULL) {
|
||||||
|
|
|
@ -645,6 +645,7 @@ typedef struct {
|
||||||
// 3.0.20
|
// 3.0.20
|
||||||
int64_t checkpointFreq; // ms
|
int64_t checkpointFreq; // ms
|
||||||
int64_t currentTick; // do not serialize
|
int64_t currentTick; // do not serialize
|
||||||
|
int64_t deleteMark;
|
||||||
} SStreamObj;
|
} SStreamObj;
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
|
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
|
||||||
|
|
|
@ -28,7 +28,7 @@ void mndCleanupScheduler(SMnode* pMnode);
|
||||||
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
||||||
|
|
||||||
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
||||||
int64_t watermark);
|
int64_t watermark, int64_t deleteMark);
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream);
|
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream);
|
||||||
|
|
||||||
|
|
|
@ -555,6 +555,12 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckDbPrivilegeByName(pMnode, pMsg->info.conn.user, MND_OPER_READ_DB, pTopic->db) != 0) {
|
if (mndCheckDbPrivilegeByName(pMnode, pMsg->info.conn.user, MND_OPER_READ_DB, pTopic->db) != 0) {
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
goto SUBSCRIBE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckTopicPrivilege(pMnode, pMsg->info.conn.user, MND_OPER_SUBSCRIBE, pTopic) != 0) {
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
goto SUBSCRIBE_OVER;
|
goto SUBSCRIBE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -825,7 +825,13 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
dbObj.cfgVersion++;
|
dbObj.cfgVersion++;
|
||||||
dbObj.updateTime = taosGetTimestampMs();
|
dbObj.updateTime = taosGetTimestampMs();
|
||||||
code = mndAlterDb(pMnode, pReq, pDb, &dbObj);
|
code = mndAlterDb(pMnode, pReq, pDb, &dbObj);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
|
||||||
|
if (dbObj.cfg.replications != pDb->cfg.replications) {
|
||||||
|
// return quickly, operation executed asynchronously
|
||||||
|
mInfo("db:%s, alter db replica from %d to %d", pDb->name, pDb->cfg.replications, dbObj.cfg.replications);
|
||||||
|
} else {
|
||||||
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
|
|
@ -383,9 +383,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pGid->syncCanRead != pVload->syncCanRead) {
|
pGid->syncCanRead != pVload->syncCanRead) {
|
||||||
mInfo(
|
mInfo(
|
||||||
"vgId:%d, state changed by status msg, old state:%s restored:%d canRead:%d new state:%s restored:%d "
|
"vgId:%d, state changed by status msg, old state:%s restored:%d canRead:%d new state:%s restored:%d "
|
||||||
"canRead:%d",
|
"canRead:%d, dnode:%d",
|
||||||
pVgroup->vgId, syncStr(pGid->syncState), pGid->syncRestore, pGid->syncCanRead,
|
pVgroup->vgId, syncStr(pGid->syncState), pGid->syncRestore, pGid->syncCanRead,
|
||||||
syncStr(pVload->syncState), pVload->syncRestore, pVload->syncCanRead);
|
syncStr(pVload->syncState), pVload->syncRestore, pVload->syncCanRead, pDnode->id);
|
||||||
pGid->syncState = pVload->syncState;
|
pGid->syncState = pVload->syncState;
|
||||||
pGid->syncRestore = pVload->syncRestore;
|
pGid->syncRestore = pVload->syncRestore;
|
||||||
pGid->syncCanRead = pVload->syncCanRead;
|
pGid->syncCanRead = pVload->syncCanRead;
|
||||||
|
|
|
@ -42,7 +42,7 @@ static int32_t mndAddTaskToTaskSet(SArray* pArray, SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
||||||
int64_t watermark) {
|
int64_t watermark, int64_t deleteMark) {
|
||||||
SNode* pAst = NULL;
|
SNode* pAst = NULL;
|
||||||
SQueryPlan* pPlan = NULL;
|
SQueryPlan* pPlan = NULL;
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
@ -64,6 +64,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
||||||
.rSmaQuery = true,
|
.rSmaQuery = true,
|
||||||
.triggerType = triggerType,
|
.triggerType = triggerType,
|
||||||
.watermark = watermark,
|
.watermark = watermark,
|
||||||
|
.deleteMark = deleteMark,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
|
|
|
@ -534,6 +534,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
streamObj.sql = strdup(pCreate->sql);
|
streamObj.sql = strdup(pCreate->sql);
|
||||||
streamObj.smaId = smaObj.uid;
|
streamObj.smaId = smaObj.uid;
|
||||||
streamObj.watermark = pCreate->watermark;
|
streamObj.watermark = pCreate->watermark;
|
||||||
|
streamObj.deleteMark = pCreate->deleteMark;
|
||||||
streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
|
streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
|
||||||
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
|
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
|
||||||
streamObj.triggerParam = pCreate->maxDelay;
|
streamObj.triggerParam = pCreate->maxDelay;
|
||||||
|
@ -574,6 +575,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
.streamQuery = true,
|
.streamQuery = true,
|
||||||
.triggerType = streamObj.trigger,
|
.triggerType = streamObj.trigger,
|
||||||
.watermark = streamObj.watermark,
|
.watermark = streamObj.watermark,
|
||||||
|
.deleteMark = streamObj.deleteMark,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
|
|
|
@ -450,13 +450,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
req.rsmaParam.watermark[1] = pStb->watermark[1];
|
req.rsmaParam.watermark[1] = pStb->watermark[1];
|
||||||
if (pStb->ast1Len > 0) {
|
if (pStb->ast1Len > 0) {
|
||||||
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[0], &req.rsmaParam.qmsgLen[0], pStb->pAst1, pStb->uid,
|
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[0], &req.rsmaParam.qmsgLen[0], pStb->pAst1, pStb->uid,
|
||||||
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[0]) < 0) {
|
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[0],
|
||||||
|
req.rsmaParam.deleteMark[0]) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pStb->ast2Len > 0) {
|
if (pStb->ast2Len > 0) {
|
||||||
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[1], &req.rsmaParam.qmsgLen[1], pStb->pAst2, pStb->uid,
|
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[1], &req.rsmaParam.qmsgLen[1], pStb->pAst2, pStb->uid,
|
||||||
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[1]) < 0) {
|
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[1],
|
||||||
|
req.rsmaParam.deleteMark[1]) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,13 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||||
int32_t code = mndProcessWriteMsg(pFsm, pMsg, pMeta);
|
int32_t code = 0;
|
||||||
|
if (!syncUtilUserCommit(pMsg->msgType)) {
|
||||||
|
goto _out;
|
||||||
|
}
|
||||||
|
code = mndProcessWriteMsg(pFsm, pMsg, pMeta);
|
||||||
|
|
||||||
|
_out:
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
pMsg->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
return code;
|
return code;
|
||||||
|
@ -143,9 +149,13 @@ void mndRestoreFinish(const SSyncFSM *pFsm) {
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
|
|
||||||
if (!pMnode->deploy) {
|
if (!pMnode->deploy) {
|
||||||
mInfo("vgId:1, sync restore finished, and will handle outstanding transactions");
|
if (!pMnode->restored) {
|
||||||
mndTransPullup(pMnode);
|
mInfo("vgId:1, sync restore finished, and will handle outstanding transactions");
|
||||||
mndSetRestored(pMnode, true);
|
mndTransPullup(pMnode);
|
||||||
|
mndSetRestored(pMnode, true);
|
||||||
|
} else {
|
||||||
|
mInfo("vgId:1, sync restore finished, repeat call");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mInfo("vgId:1, sync restore finished");
|
mInfo("vgId:1, sync restore finished");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1126,34 +1126,61 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!force) {
|
if (!force) {
|
||||||
mInfo("vgId:%d, will add 1 vnode", pVgroup->vgId);
|
if (newVg.replica == 1) {
|
||||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
mInfo("vgId:%d, will add 1 vnode, replca:1", pVgroup->vgId);
|
||||||
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
||||||
}
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
|
||||||
|
|
||||||
mInfo("vgId:%d, will remove 1 vnode", pVgroup->vgId);
|
|
||||||
newVg.replica--;
|
|
||||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
|
||||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
|
||||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
|
||||||
{
|
|
||||||
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
|
||||||
if (pRaw == NULL) return -1;
|
|
||||||
if (mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
|
||||||
sdbFreeRaw(pRaw);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||||
}
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
mInfo("vgId:%d, will remove 1 vnode, replca:2", pVgroup->vgId);
|
||||||
for (int32_t i = 0; i < newVg.replica; ++i) {
|
newVg.replica--;
|
||||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||||
|
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||||
|
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||||
|
{
|
||||||
|
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||||
|
if (pRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||||
|
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||||
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||||
|
}
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
} else { // new replica == 3
|
||||||
|
mInfo("vgId:%d, will add 1 vnode, replca:3", pVgroup->vgId);
|
||||||
|
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||||
|
mInfo("vgId:%d, will remove 1 vnode, replca:4", pVgroup->vgId);
|
||||||
|
newVg.replica--;
|
||||||
|
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||||
|
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||||
|
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||||
|
{
|
||||||
|
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||||
|
if (pRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||||
|
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||||
|
if (i == vnIndex) continue;
|
||||||
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||||
|
}
|
||||||
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[vnIndex]) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
}
|
}
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
|
||||||
} else {
|
} else {
|
||||||
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
||||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||||
|
|
|
@ -174,7 +174,7 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableL
|
||||||
void tsdbReaderClose(STsdbReader *pReader);
|
void tsdbReaderClose(STsdbReader *pReader);
|
||||||
bool tsdbNextDataBlock(STsdbReader *pReader);
|
bool tsdbNextDataBlock(STsdbReader *pReader);
|
||||||
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
||||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockSMA, bool *allHave);
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock* pDataBlock, bool *allHave);
|
||||||
SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
||||||
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
||||||
|
@ -220,22 +220,18 @@ typedef struct SSnapContext {
|
||||||
bool queryMetaOrData; // true-get meta, false-get data
|
bool queryMetaOrData; // true-get meta, false-get data
|
||||||
} SSnapContext;
|
} SSnapContext;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void *msgStr;
|
|
||||||
int32_t msgLen;
|
|
||||||
int64_t ver;
|
|
||||||
} SPackedSubmit;
|
|
||||||
|
|
||||||
typedef struct STqReader {
|
typedef struct STqReader {
|
||||||
const SSubmitReq *pMsg;
|
// const SSubmitReq *pMsg;
|
||||||
// SSubmitBlk *pBlock;
|
// SSubmitBlk *pBlock;
|
||||||
// SSubmitMsgIter msgIter;
|
// SSubmitMsgIter msgIter;
|
||||||
// SSubmitBlkIter blkIter;
|
// SSubmitBlkIter blkIter;
|
||||||
|
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
SPackedSubmit msg2;
|
SPackedData msg2;
|
||||||
SSubmitReq2 *pSubmit;
|
|
||||||
int32_t nextBlk;
|
int8_t setMsg;
|
||||||
|
SSubmitReq2 submit;
|
||||||
|
int32_t nextBlk;
|
||||||
|
|
||||||
int64_t lastBlkUid;
|
int64_t lastBlkUid;
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
|
||||||
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
|
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
|
||||||
|
|
||||||
// tqExec
|
// tqExec
|
||||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedSubmit submit, STaosxRsp* pRsp);
|
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp);
|
||||||
// int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp);
|
// int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp);
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision);
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision);
|
||||||
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp);
|
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp);
|
||||||
|
@ -182,7 +182,8 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore);
|
||||||
|
|
||||||
// tqSink
|
// tqSink
|
||||||
// void tqSinkToTableMerge(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
// void tqSinkToTableMerge(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
// void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
|
void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
|
|
||||||
// tqOffset
|
// tqOffset
|
||||||
char* tqOffsetBuildFName(const char* path, int32_t fVer);
|
char* tqOffsetBuildFName(const char* path, int32_t fVer);
|
||||||
|
|
|
@ -180,7 +180,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msg
|
||||||
int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessStreamTaskCheckRsp(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
int32_t tqProcessStreamTaskCheckRsp(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* data, int64_t ver);
|
int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit);
|
||||||
int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver);
|
int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver);
|
||||||
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec);
|
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec);
|
||||||
|
@ -215,7 +215,7 @@ int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
||||||
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
||||||
|
|
||||||
int32_t tdProcessRSmaCreate(SSma* pSma, SVCreateStbReq* pReq);
|
int32_t tdProcessRSmaCreate(SSma* pSma, SVCreateStbReq* pReq);
|
||||||
int32_t tdProcessRSmaSubmit(SSma* pSma, void* pReq, void* pMsg, int32_t len, int32_t inputType);
|
int32_t tdProcessRSmaSubmit(SSma* pSma, int64_t version, void* pReq, void* pMsg, int32_t len, int32_t inputType);
|
||||||
int32_t tdProcessRSmaDrop(SSma* pSma, SVDropStbReq* pReq);
|
int32_t tdProcessRSmaDrop(SSma* pSma, SVDropStbReq* pReq);
|
||||||
int32_t tdFetchTbUidList(SSma* pSma, STbUidStore** ppStore, tb_uid_t suid, tb_uid_t uid);
|
int32_t tdFetchTbUidList(SSma* pSma, STbUidStore** ppStore, tb_uid_t suid, tb_uid_t uid);
|
||||||
int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore, bool isAdd);
|
int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore, bool isAdd);
|
||||||
|
|
|
@ -454,7 +454,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
||||||
|
|
||||||
SListNode* pNode = NULL;
|
SListNode* pNode = NULL;
|
||||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||||
memcpy(pBuf + sizeof(suid), pNode->data, keyLen);
|
memcpy(&pBuf[1], pNode->data, keyLen);
|
||||||
|
|
||||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
||||||
|
|
|
@ -549,8 +549,8 @@ int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
|
static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
|
||||||
int64_t ttlDays;
|
int64_t ttlDays = 0;
|
||||||
int64_t ctime;
|
int64_t ctime = 0;
|
||||||
if (pME->type == TSDB_CHILD_TABLE) {
|
if (pME->type == TSDB_CHILD_TABLE) {
|
||||||
ctime = pME->ctbEntry.ctime;
|
ctime = pME->ctbEntry.ctime;
|
||||||
ttlDays = pME->ctbEntry.ttlDays;
|
ttlDays = pME->ctbEntry.ttlDays;
|
||||||
|
@ -1353,6 +1353,10 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stbEntry.stbEntry.schemaTag.pSchema == NULL) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
||||||
|
|
||||||
STagVal tagVal = {.cid = pTagColumn->colId};
|
STagVal tagVal = {.cid = pTagColumn->colId};
|
||||||
|
|
|
@ -698,10 +698,10 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
|
||||||
#endif
|
#endif
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) {
|
||||||
SSDataBlock *output = taosArrayGetP(pResList, i);
|
SSDataBlock *output = taosArrayGetP(pResList, i);
|
||||||
smaDebug("result block, uid:%" PRIu64 ", groupid:%" PRIu64 ", rows:%d", output->info.id.uid, output->info.id.groupId,
|
smaDebug("result block, uid:%" PRIu64 ", groupid:%" PRIu64 ", rows:%d", output->info.id.uid,
|
||||||
output->info.rows);
|
output->info.id.groupId, output->info.rows);
|
||||||
|
|
||||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||||
SSubmitReq2 *pReq = NULL;
|
SSubmitReq2 *pReq = NULL;
|
||||||
|
|
||||||
// TODO: the schema update should be handled later(TD-17965)
|
// TODO: the schema update should be handled later(TD-17965)
|
||||||
|
@ -714,6 +714,7 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
|
||||||
|
|
||||||
if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) {
|
if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) {
|
||||||
tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
||||||
|
taosMemoryFree(pReq);
|
||||||
smaError("vgId:%d, process submit req for rsma suid:%" PRIu64 ", uid:%" PRIu64 " level %" PRIi8
|
smaError("vgId:%d, process submit req for rsma suid:%" PRIu64 ", uid:%" PRIu64 " level %" PRIi8
|
||||||
" failed since %s",
|
" failed since %s",
|
||||||
SMA_VID(pSma), suid, output->info.id.groupId, pItem->level, terrstr());
|
SMA_VID(pSma), suid, output->info.id.groupId, pItem->level, terrstr());
|
||||||
|
@ -723,7 +724,10 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
|
||||||
smaDebug("vgId:%d, process submit req for rsma suid:%" PRIu64 ",uid:%" PRIu64 ", level %" PRIi8 " ver %" PRIi64,
|
smaDebug("vgId:%d, process submit req for rsma suid:%" PRIu64 ",uid:%" PRIu64 ", level %" PRIi8 " ver %" PRIi64,
|
||||||
SMA_VID(pSma), suid, output->info.id.groupId, pItem->level, output->info.version);
|
SMA_VID(pSma), suid, output->info.id.groupId, pItem->level, output->info.version);
|
||||||
|
|
||||||
if(pReq) tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
if (pReq) {
|
||||||
|
tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,6 +745,7 @@ _err:
|
||||||
* @brief Copy msg to rsmaQueueBuffer for batch process
|
* @brief Copy msg to rsmaQueueBuffer for batch process
|
||||||
*
|
*
|
||||||
* @param pSma
|
* @param pSma
|
||||||
|
* @param version
|
||||||
* @param pMsg
|
* @param pMsg
|
||||||
* @param len
|
* @param len
|
||||||
* @param inputType
|
* @param inputType
|
||||||
|
@ -748,14 +753,20 @@ _err:
|
||||||
* @param suid
|
* @param suid
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdExecuteRSmaImplAsync(SSma *pSma, const void *pMsg, int32_t len, int32_t inputType, SRSmaInfo *pInfo,
|
static int32_t tdExecuteRSmaImplAsync(SSma *pSma, int64_t version, const void *pMsg, int32_t len, int32_t inputType,
|
||||||
tb_uid_t suid) {
|
SRSmaInfo *pInfo, tb_uid_t suid) {
|
||||||
void *qItem = taosAllocateQitem(len, DEF_QITEM);
|
int32_t size = sizeof(int32_t) + sizeof(int64_t) + len;
|
||||||
|
void *qItem = taosAllocateQitem(size, DEF_QITEM);
|
||||||
if (!qItem) {
|
if (!qItem) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(qItem, pMsg, len);
|
void *pItem = qItem;
|
||||||
|
|
||||||
|
*(int32_t *)pItem = len;
|
||||||
|
pItem = POINTER_SHIFT(pItem, sizeof(int32_t));
|
||||||
|
*(int64_t *)pItem = version;
|
||||||
|
memcpy(POINTER_SHIFT(pItem, sizeof(int64_t)), pMsg, len);
|
||||||
|
|
||||||
taosWriteQitem(pInfo->queue, qItem);
|
taosWriteQitem(pInfo->queue, qItem);
|
||||||
|
|
||||||
|
@ -997,12 +1008,14 @@ static FORCE_INLINE void tdReleaseRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
|
||||||
* @brief async mode
|
* @brief async mode
|
||||||
*
|
*
|
||||||
* @param pSma
|
* @param pSma
|
||||||
|
* @param version
|
||||||
* @param pMsg
|
* @param pMsg
|
||||||
* @param inputType
|
* @param inputType
|
||||||
* @param suid
|
* @param suid
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdExecuteRSmaAsync(SSma *pSma, const void *pMsg, int32_t len, int32_t inputType, tb_uid_t suid) {
|
static int32_t tdExecuteRSmaAsync(SSma *pSma, int64_t version, const void *pMsg, int32_t len, int32_t inputType,
|
||||||
|
tb_uid_t suid) {
|
||||||
SRSmaInfo *pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, suid);
|
SRSmaInfo *pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, suid);
|
||||||
if (!pRSmaInfo) {
|
if (!pRSmaInfo) {
|
||||||
smaDebug("vgId:%d, execute rsma, no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid);
|
smaDebug("vgId:%d, execute rsma, no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||||
|
@ -1010,7 +1023,7 @@ static int32_t tdExecuteRSmaAsync(SSma *pSma, const void *pMsg, int32_t len, int
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputType == STREAM_INPUT__DATA_SUBMIT) {
|
if (inputType == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
if (tdExecuteRSmaImplAsync(pSma, pMsg, len, inputType, pRSmaInfo, suid) < 0) {
|
if (tdExecuteRSmaImplAsync(pSma, version, pMsg, len, inputType, pRSmaInfo, suid) < 0) {
|
||||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1045,7 @@ static int32_t tdExecuteRSmaAsync(SSma *pSma, const void *pMsg, int32_t len, int
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdProcessRSmaSubmit(SSma *pSma, void *pReq, void* pMsg, int32_t len, int32_t inputType) {
|
int32_t tdProcessRSmaSubmit(SSma *pSma, int64_t version, void *pReq, void *pMsg, int32_t len, int32_t inputType) {
|
||||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
// only applicable when rsma env exists
|
// only applicable when rsma env exists
|
||||||
|
@ -1052,7 +1065,7 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pReq, void* pMsg, int32_t len, int
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uidStore.suid != 0) {
|
if (uidStore.suid != 0) {
|
||||||
if (tdExecuteRSmaAsync(pSma, pMsg, len, inputType, uidStore.suid) < 0) {
|
if (tdExecuteRSmaAsync(pSma, version, pMsg, len, inputType, uidStore.suid) < 0) {
|
||||||
smaError("vgId:%d, failed to process rsma submit exec 1 since: %s", SMA_VID(pSma), terrstr());
|
smaError("vgId:%d, failed to process rsma submit exec 1 since: %s", SMA_VID(pSma), terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1060,7 +1073,7 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pReq, void* pMsg, int32_t len, int
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
while ((pIter = taosHashIterate(uidStore.uidHash, pIter))) {
|
while ((pIter = taosHashIterate(uidStore.uidHash, pIter))) {
|
||||||
tb_uid_t *pTbSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
tb_uid_t *pTbSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
||||||
if (tdExecuteRSmaAsync(pSma, pMsg, len, inputType, *pTbSuid) < 0) {
|
if (tdExecuteRSmaAsync(pSma, version, pMsg, len, inputType, *pTbSuid) < 0) {
|
||||||
smaError("vgId:%d, failed to process rsma submit exec 2 since: %s", SMA_VID(pSma), terrstr());
|
smaError("vgId:%d, failed to process rsma submit exec 2 since: %s", SMA_VID(pSma), terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1380,8 @@ _end:
|
||||||
|
|
||||||
static void tdFreeRSmaSubmitItems(SArray *pItems) {
|
static void tdFreeRSmaSubmitItems(SArray *pItems) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pItems); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pItems); ++i) {
|
||||||
taosFreeQitem(*(void **)taosArrayGet(pItems, i));
|
SPackedData *packData = taosArrayGet(pItems, i);
|
||||||
|
taosFreeQitem(POINTER_SHIFT(packData->msgStr, -sizeof(int32_t) - sizeof(int64_t)));
|
||||||
}
|
}
|
||||||
taosArrayClear(pItems);
|
taosArrayClear(pItems);
|
||||||
}
|
}
|
||||||
|
@ -1436,7 +1450,11 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
|
||||||
void *msg = NULL;
|
void *msg = NULL;
|
||||||
taosGetQitem(qall, (void **)&msg);
|
taosGetQitem(qall, (void **)&msg);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
if (!taosArrayPush(pSubmitArr, &msg)) {
|
SPackedData packData = {.msgLen = *(int32_t *)msg,
|
||||||
|
.ver = *(int64_t *)POINTER_SHIFT(msg, sizeof(int32_t)),
|
||||||
|
.msgStr = POINTER_SHIFT(msg, sizeof(int32_t) + sizeof(int64_t))};
|
||||||
|
|
||||||
|
if (!taosArrayPush(pSubmitArr, &packData)) {
|
||||||
tdFreeRSmaSubmitItems(pSubmitArr);
|
tdFreeRSmaSubmitItems(pSubmitArr);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1491,7 +1509,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pSubmitArr =
|
if (!(pSubmitArr =
|
||||||
taosArrayInit(TMIN(RSMA_SUBMIT_BATCH_SIZE, atomic_load_64(&pRSmaStat->nBufItems)), POINTER_BYTES))) {
|
taosArrayInit(TMIN(RSMA_SUBMIT_BATCH_SIZE, atomic_load_64(&pRSmaStat->nBufItems)), sizeof(SPackedData)))) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -673,11 +673,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
req.epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType);
|
req.epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType);
|
||||||
|
|
||||||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||||
SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
|
SPackedData submit = {
|
||||||
|
.msgStr = POINTER_SHIFT(pHead->body, sizeof(SMsgHead)),
|
||||||
SPackedSubmit submit = {
|
.msgLen = pHead->bodyLen - sizeof(SMsgHead),
|
||||||
.msgStr = pCont,
|
|
||||||
.msgLen = pHead->bodyLen,
|
|
||||||
.ver = pHead->version,
|
.ver = pHead->version,
|
||||||
};
|
};
|
||||||
if (tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp) < 0) {
|
if (tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp) < 0) {
|
||||||
|
@ -953,7 +951,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
||||||
pTask->smaSink.smaSink = smaHandleRes;
|
pTask->smaSink.smaSink = smaHandleRes;
|
||||||
} else if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
} else if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
||||||
pTask->tbSink.vnode = pTq->pVnode;
|
pTask->tbSink.vnode = pTq->pVnode;
|
||||||
pTask->tbSink.tbSinkFunc = tqSinkToTablePipeline;
|
pTask->tbSink.tbSinkFunc = tqSinkToTablePipeline2;
|
||||||
|
|
||||||
ASSERT(pTask->tbSink.pSchemaWrapper);
|
ASSERT(pTask->tbSink.pSchemaWrapper);
|
||||||
ASSERT(pTask->tbSink.pSchemaWrapper->pSchema);
|
ASSERT(pTask->tbSink.pSchemaWrapper->pSchema);
|
||||||
|
@ -1334,12 +1332,12 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
|
int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) {
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
SStreamDataSubmit* pSubmit = NULL;
|
SStreamDataSubmit2* pSubmit = NULL;
|
||||||
|
|
||||||
pSubmit = streamDataSubmitNew(pReq);
|
pSubmit = streamDataSubmitNew(submit);
|
||||||
if (pSubmit == NULL) {
|
if (pSubmit == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tqError("failed to create data submit for stream since out of memory");
|
tqError("failed to create data submit for stream since out of memory");
|
||||||
|
@ -1356,7 +1354,7 @@ int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("data submit enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
|
tqDebug("data submit enqueue stream task: %d, ver: %" PRId64, pTask->taskId, submit.ver);
|
||||||
|
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
if (streamTaskInput(pTask, (SStreamQueueItem*)pSubmit) < 0) {
|
if (streamTaskInput(pTask, (SStreamQueueItem*)pSubmit) < 0) {
|
||||||
|
|
|
@ -215,7 +215,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedSubmit submit, STaosxRsp* pRsp) {
|
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp) {
|
||||||
STqExecHandle* pExec = &pHandle->execHandle;
|
STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
ASSERT(pExec->subType != TOPIC_SUB_TYPE__COLUMN);
|
ASSERT(pExec->subType != TOPIC_SUB_TYPE__COLUMN);
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,11 @@ 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));
|
void* pReq = POINTER_SHIFT(msg, sizeof(SMsgHead));
|
||||||
|
int32_t len = msgLen - sizeof(SMsgHead);
|
||||||
|
|
||||||
|
tqDebug("vgId:%d, tq push msg ver %" PRId64 ", type: %s, p head %p, p body %p, len %d", pTq->pVnode->config.vgId, ver,
|
||||||
|
TMSG_INFO(msgType), msg, pReq, len);
|
||||||
|
|
||||||
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
|
||||||
|
@ -222,7 +226,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
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));
|
||||||
void* data = taosMemoryMalloc(msgLen);
|
void* data = taosMemoryMalloc(len);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tqError("failed to copy data for stream since out of memory");
|
tqError("failed to copy data for stream since out of memory");
|
||||||
|
@ -230,9 +234,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
taosArrayDestroy(cachedKeyLens);
|
taosArrayDestroy(cachedKeyLens);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(data, msg, msgLen);
|
memcpy(data, pReq, len);
|
||||||
SSubmitReq* pReq = (SSubmitReq*)data;
|
|
||||||
pReq->version = ver;
|
|
||||||
|
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -256,7 +258,12 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
SMqDataRsp* pRsp = &pPushEntry->dataRsp;
|
SMqDataRsp* pRsp = &pPushEntry->dataRsp;
|
||||||
|
|
||||||
// prepare scan mem data
|
// prepare scan mem data
|
||||||
qStreamScanMemData(task, pReq, ver);
|
SPackedData submit = {
|
||||||
|
.msgStr = data,
|
||||||
|
.msgLen = len,
|
||||||
|
.ver = ver,
|
||||||
|
};
|
||||||
|
qStreamSetScanMemData(task, submit);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -310,17 +317,22 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
if (vnodeIsRoleLeader(pTq->pVnode)) {
|
if (vnodeIsRoleLeader(pTq->pVnode)) {
|
||||||
if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0;
|
if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0;
|
||||||
if (msgType == TDMT_VND_SUBMIT) {
|
if (msgType == TDMT_VND_SUBMIT) {
|
||||||
void* data = taosMemoryMalloc(msgLen);
|
void* data = taosMemoryMalloc(len);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tqError("failed to copy data for stream since out of memory");
|
tqError("failed to copy data for stream since out of memory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(data, msg, msgLen);
|
memcpy(data, pReq, len);
|
||||||
SSubmitReq* pReq = (SSubmitReq*)data;
|
SPackedData submit = {
|
||||||
pReq->version = ver;
|
.msgStr = data,
|
||||||
|
.msgLen = len,
|
||||||
|
.ver = ver,
|
||||||
|
};
|
||||||
|
|
||||||
tqProcessSubmitReq(pTq, data, ver);
|
tqDebug("tq copy write msg %p %d %" PRId64 " from %p", data, len, ver, pReq);
|
||||||
|
|
||||||
|
tqProcessSubmitReq(pTq, submit);
|
||||||
}
|
}
|
||||||
if (msgType == TDMT_VND_DELETE) {
|
if (msgType == TDMT_VND_DELETE) {
|
||||||
tqProcessDelReq(pTq, POINTER_SHIFT(msg, sizeof(SMsgHead)), msgLen - sizeof(SMsgHead), ver);
|
tqProcessDelReq(pTq, POINTER_SHIFT(msg, sizeof(SMsgHead)), msgLen - sizeof(SMsgHead), ver);
|
||||||
|
|
|
@ -252,7 +252,7 @@ END:
|
||||||
}
|
}
|
||||||
|
|
||||||
STqReader* tqOpenReader(SVnode* pVnode) {
|
STqReader* tqOpenReader(SVnode* pVnode) {
|
||||||
STqReader* pReader = taosMemoryMalloc(sizeof(STqReader));
|
STqReader* pReader = taosMemoryCalloc(1, sizeof(STqReader));
|
||||||
if (pReader == NULL) {
|
if (pReader == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ int32_t tqSeekVer(STqReader* pReader, int64_t ver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
||||||
bool fromProcessedMsg = pReader->pMsg != NULL;
|
bool fromProcessedMsg = pReader->msg2.msgStr != NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!fromProcessedMsg) {
|
if (!fromProcessedMsg) {
|
||||||
|
@ -320,8 +320,8 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
||||||
ASSERT(ret->offset.version >= 0);
|
ASSERT(ret->offset.version >= 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void* body = pReader->pWalReader->pHead->head.body;
|
void* body = POINTER_SHIFT(pReader->pWalReader->pHead->head.body, sizeof(SMsgHead));
|
||||||
int32_t bodyLen = pReader->pWalReader->pHead->head.bodyLen;
|
int32_t bodyLen = pReader->pWalReader->pHead->head.bodyLen - sizeof(SMsgHead);
|
||||||
int64_t ver = pReader->pWalReader->pHead->head.version;
|
int64_t ver = pReader->pWalReader->pHead->head.version;
|
||||||
#if 0
|
#if 0
|
||||||
if (pReader->pWalReader->pHead->head.msgType != TDMT_VND_SUBMIT) {
|
if (pReader->pWalReader->pHead->head.msgType != TDMT_VND_SUBMIT) {
|
||||||
|
@ -381,15 +381,24 @@ int32_t tqReaderSetDataMsg(STqReader* pReader, const SSubmitReq* pMsg, int64_t v
|
||||||
|
|
||||||
int32_t tqReaderSetSubmitReq2(STqReader* pReader, void* msgStr, int32_t msgLen, int64_t ver) {
|
int32_t tqReaderSetSubmitReq2(STqReader* pReader, void* msgStr, int32_t msgLen, int64_t ver) {
|
||||||
ASSERT(pReader->msg2.msgStr == NULL);
|
ASSERT(pReader->msg2.msgStr == NULL);
|
||||||
|
ASSERT(msgStr);
|
||||||
|
ASSERT(msgLen);
|
||||||
|
ASSERT(ver >= 0);
|
||||||
pReader->msg2.msgStr = msgStr;
|
pReader->msg2.msgStr = msgStr;
|
||||||
pReader->msg2.msgLen = msgLen;
|
pReader->msg2.msgLen = msgLen;
|
||||||
pReader->msg2.ver = ver;
|
pReader->msg2.ver = ver;
|
||||||
|
pReader->ver = ver;
|
||||||
|
|
||||||
if (pReader->pSubmit == NULL) {
|
tqDebug("tq reader set msg %p %d", msgStr, msgLen);
|
||||||
|
|
||||||
|
if (pReader->setMsg == 0) {
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, pReader->msg2.msgStr, pReader->msg2.msgLen);
|
tDecoderInit(&decoder, pReader->msg2.msgStr, pReader->msg2.msgLen);
|
||||||
tDecodeSSubmitReq2(&decoder, pReader->pSubmit);
|
if (tDecodeSSubmitReq2(&decoder, &pReader->submit) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
pReader->setMsg = 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -422,21 +431,27 @@ bool tqNextDataBlock(STqReader* pReader) {
|
||||||
|
|
||||||
bool tqNextDataBlock2(STqReader* pReader) {
|
bool tqNextDataBlock2(STqReader* pReader) {
|
||||||
if (pReader->msg2.msgStr == NULL) return false;
|
if (pReader->msg2.msgStr == NULL) return false;
|
||||||
ASSERT(pReader->pSubmit != NULL);
|
ASSERT(pReader->setMsg == 1);
|
||||||
|
|
||||||
int32_t blockSz = taosArrayGetSize(pReader->pSubmit->aSubmitTbData);
|
tqDebug("tq reader next data block %p, %d %" PRId64 " %d", pReader->msg2.msgStr, pReader->msg2.msgLen,
|
||||||
|
pReader->msg2.ver, pReader->nextBlk);
|
||||||
|
|
||||||
|
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
||||||
while (pReader->nextBlk < blockSz) {
|
while (pReader->nextBlk < blockSz) {
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->pSubmit->aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
|
ASSERT(pSubmitTbData->uid);
|
||||||
|
|
||||||
if (pReader->tbIdHash == NULL) return true;
|
if (pReader->tbIdHash == NULL) return true;
|
||||||
|
|
||||||
void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
|
void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
pReader->nextBlk++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tDestroySSubmitReq2(pReader->pSubmit, TSDB_MSG_FLG_DECODE);
|
tDestroySSubmitReq2(&pReader->submit, TSDB_MSG_FLG_DECODE);
|
||||||
pReader->pSubmit = NULL;
|
pReader->setMsg = 0;
|
||||||
pReader->nextBlk = 0;
|
pReader->nextBlk = 0;
|
||||||
pReader->msg2.msgStr = NULL;
|
pReader->msg2.msgStr = NULL;
|
||||||
|
|
||||||
|
@ -445,11 +460,11 @@ bool tqNextDataBlock2(STqReader* pReader) {
|
||||||
|
|
||||||
bool tqNextDataBlockFilterOut2(STqReader* pReader, SHashObj* filterOutUids) {
|
bool tqNextDataBlockFilterOut2(STqReader* pReader, SHashObj* filterOutUids) {
|
||||||
if (pReader->msg2.msgStr == NULL) return false;
|
if (pReader->msg2.msgStr == NULL) return false;
|
||||||
ASSERT(pReader->pSubmit != NULL);
|
ASSERT(pReader->setMsg == 1);
|
||||||
|
|
||||||
int32_t blockSz = taosArrayGetSize(pReader->pSubmit->aSubmitTbData);
|
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
||||||
while (pReader->nextBlk < blockSz) {
|
while (pReader->nextBlk < blockSz) {
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->pSubmit->aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
if (pReader->tbIdHash == NULL) return true;
|
if (pReader->tbIdHash == NULL) return true;
|
||||||
|
|
||||||
void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
|
void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
|
||||||
|
@ -458,8 +473,8 @@ bool tqNextDataBlockFilterOut2(STqReader* pReader, SHashObj* filterOutUids) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tDestroySSubmitReq2(pReader->pSubmit, TSDB_MSG_FLG_DECODE);
|
tDestroySSubmitReq2(&pReader->submit, TSDB_MSG_FLG_DECODE);
|
||||||
pReader->pSubmit = NULL;
|
pReader->setMsg = 0;
|
||||||
pReader->nextBlk = 0;
|
pReader->nextBlk = 0;
|
||||||
pReader->msg2.msgStr = NULL;
|
pReader->msg2.msgStr = NULL;
|
||||||
|
|
||||||
|
@ -548,10 +563,12 @@ int32_t tqScanSubmitSplit(SArray* pBlocks, SArray* schemas, STqReader* pReader)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
|
int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
int32_t blockSz = taosArrayGetSize(pReader->pSubmit->aSubmitTbData);
|
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
||||||
ASSERT(pReader->nextBlk < blockSz);
|
ASSERT(pReader->nextBlk < blockSz);
|
||||||
|
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->pSubmit->aSubmitTbData, pReader->nextBlk);
|
tqDebug("tq reader retrieve data block %p, %d", pReader->msg2.msgStr, pReader->nextBlk);
|
||||||
|
|
||||||
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
pReader->nextBlk++;
|
pReader->nextBlk++;
|
||||||
|
|
||||||
int32_t sversion = pSubmitTbData->sver;
|
int32_t sversion = pSubmitTbData->sver;
|
||||||
|
@ -666,15 +683,33 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
} else if (pCol->cid == pColData->info.colId) {
|
} else if (pCol->cid == pColData->info.colId) {
|
||||||
for (int32_t i = 0; i < pCol->nVal; i++) {
|
for (int32_t i = 0; i < pCol->nVal; i++) {
|
||||||
tColDataGetValue(pCol, sourceIdx, &colVal);
|
tColDataGetValue(pCol, sourceIdx, &colVal);
|
||||||
|
#if 0
|
||||||
void* val = NULL;
|
void* val = NULL;
|
||||||
if (IS_STR_DATA_TYPE(colVal.type)) {
|
if (IS_STR_DATA_TYPE(colVal.type)) {
|
||||||
val = colVal.value.pData;
|
val = colVal.value.pData;
|
||||||
} else {
|
} else {
|
||||||
val = &colVal.value.val;
|
val = &colVal.value.val;
|
||||||
}
|
}
|
||||||
if (colDataAppend(pColData, i, val, colVal.type != TD_VTYPE_NORM) < 0) {
|
if (colDataAppend(pColData, i, val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
if (IS_STR_DATA_TYPE(colVal.type)) {
|
||||||
|
if (colVal.value.pData != NULL) {
|
||||||
|
char val[65535 + 2];
|
||||||
|
memcpy(varDataVal(val), colVal.value.pData, colVal.value.nData);
|
||||||
|
varDataSetLen(val, colVal.value.nData);
|
||||||
|
if (colDataAppend(pColData, i, val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
colDataAppendNULL(pColData, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (colDataAppend(pColData, i, (void*)&colVal.value.val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
targetIdx++;
|
targetIdx++;
|
||||||
|
@ -686,14 +721,14 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
SArray* pRows = pSubmitTbData->aRowP;
|
SArray* pRows = pSubmitTbData->aRowP;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; i++) {
|
for (int32_t i = 0; i < numOfRows; i++) {
|
||||||
SRow* pRow = taosArrayGet(pRows, i);
|
SRow* pRow = taosArrayGetP(pRows, i);
|
||||||
int32_t targetIdx = 0;
|
int32_t targetIdx = 0;
|
||||||
int32_t sourceIdx = 0;
|
int32_t sourceIdx = 0;
|
||||||
|
|
||||||
for (int32_t j = 0; j < colActual; j++) {
|
for (int32_t j = 0; j < colActual; j++) {
|
||||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j);
|
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j);
|
||||||
while (1) {
|
while (1) {
|
||||||
ASSERT(sourceIdx < numOfRows);
|
ASSERT(sourceIdx < pTschema->numOfCols);
|
||||||
|
|
||||||
SColVal colVal;
|
SColVal colVal;
|
||||||
tRowGet(pRow, pTschema, sourceIdx, &colVal);
|
tRowGet(pRow, pTschema, sourceIdx, &colVal);
|
||||||
|
@ -701,14 +736,22 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
continue;
|
continue;
|
||||||
} else if (colVal.cid == pColData->info.colId) {
|
} else if (colVal.cid == pColData->info.colId) {
|
||||||
void* val = NULL;
|
|
||||||
if (IS_STR_DATA_TYPE(colVal.type)) {
|
if (IS_STR_DATA_TYPE(colVal.type)) {
|
||||||
val = colVal.value.pData;
|
if (colVal.value.pData != NULL) {
|
||||||
|
char val[65535 + 2];
|
||||||
|
memcpy(varDataVal(val), colVal.value.pData, colVal.value.nData);
|
||||||
|
varDataSetLen(val, colVal.value.nData);
|
||||||
|
if (colDataAppend(pColData, i, val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
colDataAppendNULL(pColData, i);
|
||||||
|
}
|
||||||
|
/*val = colVal.value.pData;*/
|
||||||
} else {
|
} else {
|
||||||
val = &colVal.value.val;
|
if (colDataAppend(pColData, i, (void*)&colVal.value.val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
|
||||||
}
|
goto FAIL;
|
||||||
if (colDataAppend(pColData, i, val, colVal.type != TD_VTYPE_NORM) < 0) {
|
}
|
||||||
goto FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
|
|
|
@ -750,32 +750,26 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||||
const SArray* pBlocks = (const SArray*)data;
|
const SArray* pBlocks = (const SArray*)data;
|
||||||
SVnode* pVnode = (SVnode*)vnode;
|
SVnode* pVnode = (SVnode*)vnode;
|
||||||
int64_t suid = pTask->tbSink.stbUid;
|
int64_t suid = pTask->tbSink.stbUid;
|
||||||
char* stbFullName = pTask->tbSink.stbFullName;
|
char* stbFullName = pTask->tbSink.stbFullName;
|
||||||
STSchema* pTSchema = pTask->tbSink.pTSchema;
|
STSchema* pTSchema = pTask->tbSink.pTSchema;
|
||||||
SSchemaWrapper* pSchemaWrapper = pTask->tbSink.pSchemaWrapper;
|
/*SSchemaWrapper* pSchemaWrapper = pTask->tbSink.pSchemaWrapper;*/
|
||||||
|
|
||||||
int32_t blockSz = taosArrayGetSize(pBlocks);
|
int32_t blockSz = taosArrayGetSize(pBlocks);
|
||||||
|
|
||||||
tqDebug("vgId:%d, task %d write into table, block num: %d", TD_VID(pVnode), pTask->taskId, blockSz);
|
tqDebug("vgId:%d, task %d write into table, block num: %d", TD_VID(pVnode), pTask->taskId, blockSz);
|
||||||
|
|
||||||
void* pBuf = NULL;
|
void* pBuf = NULL;
|
||||||
int32_t len = 0;
|
|
||||||
SSubmitReq2* pReq = NULL;
|
SSubmitReq2* pReq = NULL;
|
||||||
SArray* tagArray = NULL;
|
SArray* tagArray = NULL;
|
||||||
SArray* createTbArray = NULL;
|
|
||||||
SArray* pVals = NULL;
|
SArray* pVals = NULL;
|
||||||
|
|
||||||
if (!(tagArray = taosArrayInit(1, sizeof(STagVal)))) {
|
if (!(tagArray = taosArrayInit(1, sizeof(STagVal)))) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(createTbArray = taosArrayInit(blockSz, POINTER_BYTES))) {
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(pReq = taosMemoryCalloc(1, sizeof(SSubmitReq2)))) {
|
if (!(pReq = taosMemoryCalloc(1, sizeof(SSubmitReq2)))) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _end;
|
goto _end;
|
||||||
|
@ -786,7 +780,6 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < blockSz; i++) {
|
for (int32_t i = 0; i < blockSz; i++) {
|
||||||
bool createTb = true;
|
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||||
if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
|
if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
|
||||||
SBatchDeleteReq deleteReq = {0};
|
SBatchDeleteReq deleteReq = {0};
|
||||||
|
@ -824,94 +817,103 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
||||||
tqDebug("failed to put delete req into write-queue since %s", terrstr());
|
tqDebug("failed to put delete req into write-queue since %s", terrstr());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// create table req
|
SSubmitTbData tbData = {0};
|
||||||
if (createTb) {
|
int32_t rows = pDataBlock->info.rows;
|
||||||
for (int32_t i = 0; i < blockSz; ++i) {
|
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
|
||||||
SVCreateTbReq* pCreateTbReq = NULL;
|
|
||||||
if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
|
|
||||||
taosArrayPush(createTbArray, &pCreateTbReq);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)))) {
|
|
||||||
goto _end;
|
|
||||||
};
|
|
||||||
|
|
||||||
// don't move to the end of loop as to destroy in the end of func when error occur
|
|
||||||
taosArrayPush(createTbArray, &pCreateTbReq);
|
|
||||||
|
|
||||||
// set const
|
|
||||||
pCreateTbReq->flags = 0;
|
|
||||||
pCreateTbReq->type = TSDB_CHILD_TABLE;
|
|
||||||
pCreateTbReq->ctb.suid = suid;
|
|
||||||
|
|
||||||
// set super table name
|
|
||||||
SName name = {0};
|
|
||||||
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
|
||||||
pCreateTbReq->ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
|
|
||||||
|
|
||||||
// set tag content
|
|
||||||
taosArrayClear(tagArray);
|
|
||||||
STagVal tagVal = {
|
|
||||||
.cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1,
|
|
||||||
.type = TSDB_DATA_TYPE_UBIGINT,
|
|
||||||
.i64 = (int64_t)pDataBlock->info.id.groupId,
|
|
||||||
};
|
|
||||||
taosArrayPush(tagArray, &tagVal);
|
|
||||||
pCreateTbReq->ctb.tagNum = taosArrayGetSize(tagArray);
|
|
||||||
|
|
||||||
STag* pTag = NULL;
|
|
||||||
tTagNew(tagArray, 1, false, &pTag);
|
|
||||||
if (pTag == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
pCreateTbReq->ctb.pTag = (uint8_t*)pTag;
|
|
||||||
|
|
||||||
// set tag name
|
|
||||||
SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN);
|
|
||||||
char tagNameStr[TSDB_COL_NAME_LEN] = {0};
|
|
||||||
strcpy(tagNameStr, "group_id");
|
|
||||||
taosArrayPush(tagName, tagNameStr);
|
|
||||||
pCreateTbReq->ctb.tagName = tagName;
|
|
||||||
|
|
||||||
// set table name
|
|
||||||
if (pDataBlock->info.parTbName[0]) {
|
|
||||||
pCreateTbReq->name = strdup(pDataBlock->info.parTbName);
|
|
||||||
} else {
|
|
||||||
pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SSubmitTbData req
|
|
||||||
int32_t rows = pDataBlock->info.rows;
|
|
||||||
|
|
||||||
SSubmitTbData* pTbData = (SSubmitTbData*)taosMemoryCalloc(1, sizeof(SSubmitTbData));
|
|
||||||
if (!pTbData) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(pTbData->aRowP = taosArrayInit(rows, sizeof(SRow*)))) {
|
|
||||||
taosMemoryFree(pTbData);
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
pTbData->suid = suid;
|
|
||||||
pTbData->uid = 0; // uid is assigned by vnode
|
|
||||||
pTbData->sver = pTSchema->version;
|
|
||||||
|
|
||||||
tqDebug("tq sink, convert block1 %d, rows: %d", i, rows);
|
tqDebug("tq sink, convert block1 %d, rows: %d", i, rows);
|
||||||
|
|
||||||
if (createTb) {
|
if (!(tbData.aRowP = taosArrayInit(rows, sizeof(SRow*)))) {
|
||||||
pTbData->pCreateTbReq = taosArrayGetP(createTbArray, i);
|
goto _end;
|
||||||
if (pTbData->pCreateTbReq) pTbData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tbData.suid = suid;
|
||||||
|
tbData.uid = 0; // uid is assigned by vnode
|
||||||
|
tbData.sver = pTSchema->version;
|
||||||
|
|
||||||
|
char* ctbName = NULL;
|
||||||
|
if (pDataBlock->info.parTbName[0]) {
|
||||||
|
ctbName = strdup(pDataBlock->info.parTbName);
|
||||||
|
} else {
|
||||||
|
ctbName = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, pVnode->pMeta, 0);
|
||||||
|
if (metaGetTableEntryByName(&mr, ctbName) < 0) {
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
tqDebug("vgId:%d, stream write into %s, table auto created", TD_VID(pVnode), ctbName);
|
||||||
|
|
||||||
|
SVCreateTbReq* pCreateTbReq = NULL;
|
||||||
|
|
||||||
|
if (!(pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)))) {
|
||||||
|
goto _end;
|
||||||
|
};
|
||||||
|
|
||||||
|
// set const
|
||||||
|
pCreateTbReq->flags = 0;
|
||||||
|
pCreateTbReq->type = TSDB_CHILD_TABLE;
|
||||||
|
pCreateTbReq->ctb.suid = suid;
|
||||||
|
|
||||||
|
// set super table name
|
||||||
|
SName name = {0};
|
||||||
|
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
pCreateTbReq->ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
|
||||||
|
|
||||||
|
// set tag content
|
||||||
|
taosArrayClear(tagArray);
|
||||||
|
STagVal tagVal = {
|
||||||
|
.cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1,
|
||||||
|
.type = TSDB_DATA_TYPE_UBIGINT,
|
||||||
|
.i64 = (int64_t)pDataBlock->info.id.groupId,
|
||||||
|
};
|
||||||
|
taosArrayPush(tagArray, &tagVal);
|
||||||
|
pCreateTbReq->ctb.tagNum = taosArrayGetSize(tagArray);
|
||||||
|
|
||||||
|
STag* pTag = NULL;
|
||||||
|
tTagNew(tagArray, 1, false, &pTag);
|
||||||
|
if (pTag == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
pCreateTbReq->ctb.pTag = (uint8_t*)pTag;
|
||||||
|
|
||||||
|
// set tag name
|
||||||
|
SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN);
|
||||||
|
char tagNameStr[TSDB_COL_NAME_LEN] = {0};
|
||||||
|
strcpy(tagNameStr, "group_id");
|
||||||
|
taosArrayPush(tagName, tagNameStr);
|
||||||
|
pCreateTbReq->ctb.tagName = tagName;
|
||||||
|
|
||||||
|
// set table name
|
||||||
|
pCreateTbReq->name = ctbName;
|
||||||
|
ctbName = NULL;
|
||||||
|
|
||||||
|
tbData.pCreateTbReq = pCreateTbReq;
|
||||||
|
tbData.flags = SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||||
|
} else {
|
||||||
|
if (mr.me.type != TSDB_CHILD_TABLE) {
|
||||||
|
tqError("vgId:%d, failed to write into %s, since table type incorrect, type %d", TD_VID(pVnode), ctbName,
|
||||||
|
mr.me.type);
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
taosMemoryFree(ctbName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mr.me.ctbEntry.suid != suid) {
|
||||||
|
tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid: %" PRId64
|
||||||
|
", actual suid %" PRId64 "",
|
||||||
|
TD_VID(pVnode), ctbName, suid, mr.me.ctbEntry.suid);
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
taosMemoryFree(ctbName);
|
||||||
|
}
|
||||||
|
|
||||||
|
tbData.uid = mr.me.uid;
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
taosMemoryFreeClear(ctbName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// rows
|
||||||
if (!pVals && !(pVals = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)))) {
|
if (!pVals && !(pVals = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)))) {
|
||||||
taosArrayDestroy(pTbData->aRowP);
|
taosArrayDestroy(tbData.aRowP);
|
||||||
taosMemoryFree(pTbData);
|
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,14 +926,15 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
||||||
SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type);
|
SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type);
|
||||||
taosArrayPush(pVals, &cv);
|
taosArrayPush(pVals, &cv);
|
||||||
} else {
|
} else {
|
||||||
void* data = colDataGetData(pColData, j);
|
void* colData = colDataGetData(pColData, j);
|
||||||
if (IS_STR_DATA_TYPE(pCol->type)) {
|
if (IS_STR_DATA_TYPE(pCol->type)) {
|
||||||
SValue sv = (SValue){.nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value
|
SValue sv =
|
||||||
|
(SValue){.nData = varDataLen(colData), .pData = varDataVal(colData)}; // address copy, no value
|
||||||
SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv);
|
SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv);
|
||||||
taosArrayPush(pVals, &cv);
|
taosArrayPush(pVals, &cv);
|
||||||
} else {
|
} else {
|
||||||
SValue sv;
|
SValue sv;
|
||||||
memcpy(&sv.val, data, tDataTypes[pCol->type].bytes);
|
memcpy(&sv.val, colData, tDataTypes[pCol->type].bytes);
|
||||||
SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv);
|
SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv);
|
||||||
taosArrayPush(pVals, &cv);
|
taosArrayPush(pVals, &cv);
|
||||||
}
|
}
|
||||||
|
@ -939,16 +942,17 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
||||||
}
|
}
|
||||||
SRow* pRow = NULL;
|
SRow* pRow = NULL;
|
||||||
if ((terrno = tRowBuild(pVals, (STSchema*)pTSchema, &pRow)) < 0) {
|
if ((terrno = tRowBuild(pVals, (STSchema*)pTSchema, &pRow)) < 0) {
|
||||||
tDestroySSubmitTbData(pTbData, TSDB_MSG_FLG_ENCODE);
|
tDestroySSubmitTbData(&tbData, TSDB_MSG_FLG_ENCODE);
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
ASSERT(pRow);
|
ASSERT(pRow);
|
||||||
taosArrayPush(pTbData->aRowP, &pRow);
|
taosArrayPush(tbData.aRowP, &pRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pReq->aSubmitTbData, pTbData);
|
taosArrayPush(pReq->aSubmitTbData, &tbData);
|
||||||
|
|
||||||
// encode
|
// encode
|
||||||
|
int32_t len;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
tEncodeSize(tEncodeSSubmitReq2, pReq, len, code);
|
tEncodeSize(tEncodeSSubmitReq2, pReq, len, code);
|
||||||
SEncoder encoder;
|
SEncoder encoder;
|
||||||
|
@ -957,19 +961,22 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
||||||
if (NULL == pBuf) {
|
if (NULL == pBuf) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
((SMsgHead*)pBuf)->vgId = htonl(TD_VID(pVnode));
|
((SMsgHead*)pBuf)->vgId = TD_VID(pVnode);
|
||||||
((SMsgHead*)pBuf)->contLen = htonl(len);
|
((SMsgHead*)pBuf)->contLen = htonl(len);
|
||||||
tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len - sizeof(SMsgHead));
|
tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len - sizeof(SMsgHead));
|
||||||
if (tEncodeSSubmitReq2(&encoder, pReq) < 0) {
|
if (tEncodeSSubmitReq2(&encoder, pReq) < 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tqError("failed to encode submit req since %s", terrstr());
|
tqError("failed to encode submit req since %s", terrstr());
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
rpcFreeCont(pBuf);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
SRpcMsg msg = {
|
SRpcMsg msg = {
|
||||||
.msgType = TDMT_VND_SUBMIT,
|
.msgType = TDMT_VND_SUBMIT,
|
||||||
.pCont = pBuf,
|
.pCont = pBuf,
|
||||||
.contLen = ntohl(len),
|
.contLen = len,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) {
|
if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) {
|
||||||
|
@ -982,6 +989,7 @@ _end:
|
||||||
taosArrayDestroy(pVals);
|
taosArrayDestroy(pVals);
|
||||||
// TODO: change
|
// TODO: change
|
||||||
tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
||||||
|
taosMemoryFree(pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -91,12 +91,10 @@ int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosLRUCacheRelease(pCache, h, invalidate);
|
||||||
if (invalidate) {
|
if (invalidate) {
|
||||||
taosLRUCacheRelease(pCache, h, true);
|
taosLRUCacheErase(pCache, key, keyLen);
|
||||||
} else {
|
|
||||||
taosLRUCacheRelease(pCache, h, false);
|
|
||||||
}
|
}
|
||||||
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -124,12 +122,10 @@ int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosLRUCacheRelease(pCache, h, invalidate);
|
||||||
if (invalidate) {
|
if (invalidate) {
|
||||||
taosLRUCacheRelease(pCache, h, true);
|
taosLRUCacheErase(pCache, key, keyLen);
|
||||||
} else {
|
|
||||||
taosLRUCacheRelease(pCache, h, false);
|
|
||||||
}
|
}
|
||||||
// void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -208,6 +204,44 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, TS
|
||||||
int16_t nCol = taosArrayGetSize(pLast);
|
int16_t nCol = taosArrayGetSize(pLast);
|
||||||
int16_t iCol = 0;
|
int16_t iCol = 0;
|
||||||
|
|
||||||
|
if (nCol <= 0) {
|
||||||
|
nCol = pTSchema->numOfCols;
|
||||||
|
|
||||||
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
SColVal tColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = keyTs});
|
||||||
|
if (taosArrayPush(pLast, &(SLastCol){.ts = keyTs, .colVal = tColVal}) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (iCol = 1; iCol < nCol; ++iCol) {
|
||||||
|
SColVal colVal = {0};
|
||||||
|
tsdbRowGetColVal(row, pTSchema, iCol, &colVal);
|
||||||
|
|
||||||
|
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||||
|
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||||
|
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
|
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||||
|
|
||||||
|
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||||
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayPush(pLast, &lastCol) == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
|
||||||
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
if (keyTs > tTsVal->ts) {
|
if (keyTs > tTsVal->ts) {
|
||||||
STColumn *pTColumn = &pTSchema->columns[0];
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
@ -279,6 +313,44 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, TSDBROW *row, STsdb
|
||||||
int16_t nCol = taosArrayGetSize(pLast);
|
int16_t nCol = taosArrayGetSize(pLast);
|
||||||
int16_t iCol = 0;
|
int16_t iCol = 0;
|
||||||
|
|
||||||
|
if (nCol <= 0) {
|
||||||
|
nCol = pTSchema->numOfCols;
|
||||||
|
|
||||||
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
SColVal tColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = keyTs});
|
||||||
|
if (taosArrayPush(pLast, &(SLastCol){.ts = keyTs, .colVal = tColVal}) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (iCol = 1; iCol < nCol; ++iCol) {
|
||||||
|
SColVal colVal = {0};
|
||||||
|
tsdbRowGetColVal(row, pTSchema, iCol, &colVal);
|
||||||
|
|
||||||
|
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||||
|
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||||
|
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
|
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||||
|
|
||||||
|
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||||
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayPush(pLast, &lastCol) == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _invalidate;
|
||||||
|
}
|
||||||
|
|
||||||
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||||
if (keyTs > tTsVal->ts) {
|
if (keyTs > tTsVal->ts) {
|
||||||
STColumn *pTColumn = &pTSchema->columns[0];
|
STColumn *pTColumn = &pTSchema->columns[0];
|
||||||
|
@ -953,7 +1025,10 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
||||||
SArray *pDelIdxArray = taosArrayInit(32, sizeof(SDelIdx));
|
SArray *pDelIdxArray = taosArrayInit(32, sizeof(SDelIdx));
|
||||||
|
|
||||||
code = tsdbReadDelIdx(pDelFReader, pDelIdxArray);
|
code = tsdbReadDelIdx(pDelFReader, pDelIdxArray);
|
||||||
if (code) goto _err;
|
if (code) {
|
||||||
|
tsdbDelFReaderClose(&pDelFReader);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
SDelIdx *delIdx = taosArraySearch(pDelIdxArray, &(SDelIdx){.suid = suid, .uid = uid}, tCmprDelIdx, TD_EQ);
|
SDelIdx *delIdx = taosArraySearch(pDelIdxArray, &(SDelIdx){.suid = suid, .uid = uid}, tCmprDelIdx, TD_EQ);
|
||||||
|
|
||||||
|
@ -1215,12 +1290,12 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
|
||||||
|
|
||||||
// build the result ts row here
|
// build the result ts row here
|
||||||
*dup = false;
|
*dup = false;
|
||||||
if (taosArrayGetSize(pColArray) != nCol) {
|
// if (taosArrayGetSize(pColArray) != nCol) {
|
||||||
*ppColArray = NULL;
|
//*ppColArray = NULL;
|
||||||
taosArrayDestroy(pColArray);
|
// taosArrayDestroy(pColArray);
|
||||||
} else {
|
//} else {
|
||||||
*ppColArray = pColArray;
|
*ppColArray = pColArray;
|
||||||
}
|
//}
|
||||||
|
|
||||||
nextRowIterClose(&iter);
|
nextRowIterClose(&iter);
|
||||||
// taosMemoryFreeClear(pTSchema);
|
// taosMemoryFreeClear(pTSchema);
|
||||||
|
@ -1333,12 +1408,12 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach
|
||||||
}
|
}
|
||||||
} while (setNoneCol);
|
} while (setNoneCol);
|
||||||
|
|
||||||
if (taosArrayGetSize(pColArray) <= 0) {
|
// if (taosArrayGetSize(pColArray) <= 0) {
|
||||||
*ppLastArray = NULL;
|
//*ppLastArray = NULL;
|
||||||
taosArrayDestroy(pColArray);
|
// taosArrayDestroy(pColArray);
|
||||||
} else {
|
//} else {
|
||||||
*ppLastArray = pColArray;
|
*ppLastArray = pColArray;
|
||||||
}
|
//}
|
||||||
|
|
||||||
nextRowIterClose(&iter);
|
nextRowIterClose(&iter);
|
||||||
// taosMemoryFreeClear(pTSchema);
|
// taosMemoryFreeClear(pTSchema);
|
||||||
|
@ -1369,8 +1444,8 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
|
||||||
SArray *pArray = 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, &pArray, pr);
|
code = mergeLastRow(uid, pTsdb, &dup, &pArray, pr);
|
||||||
// if table's empty or error, return code of -1
|
// if table's empty or error, set handle NULL and return
|
||||||
if (code < 0 || pArray == NULL) {
|
if (code < 0 /* || pArray == NULL*/) {
|
||||||
if (!dup && pArray) {
|
if (!dup && pArray) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
@ -1388,20 +1463,14 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
|
||||||
if (status != TAOS_LRU_STATUS_OK) {
|
if (status != TAOS_LRU_STATUS_OK) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
|
|
||||||
// h = taosLRUCacheLookup(pCache, key, keyLen);
|
|
||||||
} // else {
|
|
||||||
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*handle = h;
|
*handle = h;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) {
|
// int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) {
|
||||||
// int32_t code = 0;
|
// int32_t code = 0;
|
||||||
// int16_t nCol = taosArrayGetSize(pLastArray);
|
// int16_t nCol = taosArrayGetSize(pLastArray);
|
||||||
|
@ -1442,8 +1511,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr,
|
||||||
if (!h) {
|
if (!h) {
|
||||||
SArray *pLastArray = NULL;
|
SArray *pLastArray = NULL;
|
||||||
code = mergeLast(uid, pTsdb, &pLastArray, pr);
|
code = mergeLast(uid, pTsdb, &pLastArray, pr);
|
||||||
// if table's empty or error, return code of -1
|
// if table's empty or error, set handle NULL and return
|
||||||
if (code < 0 || pLastArray == NULL) {
|
if (code < 0 /* || pLastArray == NULL*/) {
|
||||||
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
|
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
|
@ -1457,13 +1526,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr,
|
||||||
if (status != TAOS_LRU_STATUS_OK) {
|
if (status != TAOS_LRU_STATUS_OK) {
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// taosThreadMutexUnlock(&pTsdb->lruMutex);
|
|
||||||
|
|
||||||
// h = taosLRUCacheLookup(pCache, key, keyLen);
|
|
||||||
} // else {
|
|
||||||
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*handle = h;
|
*handle = h;
|
||||||
|
|
|
@ -253,6 +253,10 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (taosArrayGetSize(pRow) <= 0) {
|
||||||
|
tsdbCacheRelease(lruCache, h);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
for (int32_t k = 0; k < pr->numOfCols; ++k) {
|
for (int32_t k = 0; k < pr->numOfCols; ++k) {
|
||||||
|
@ -322,6 +326,10 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (taosArrayGetSize(pRow) <= 0) {
|
||||||
|
tsdbCacheRelease(lruCache, h);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
||||||
// TODO reset the pRes
|
// TODO reset the pRes
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct {
|
||||||
// --------------
|
// --------------
|
||||||
TSKEY nextKey; // reset by each table commit
|
TSKEY nextKey; // reset by each table commit
|
||||||
int32_t commitFid;
|
int32_t commitFid;
|
||||||
|
int32_t expLevel;
|
||||||
TSKEY minKey;
|
TSKEY minKey;
|
||||||
TSKEY maxKey;
|
TSKEY maxKey;
|
||||||
// commit file data
|
// commit file data
|
||||||
|
@ -503,6 +504,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
||||||
|
pCommitter->expLevel = tsdbFidLevel(pCommitter->commitFid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec());
|
||||||
tsdbFidKeyRange(pCommitter->commitFid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
|
tsdbFidKeyRange(pCommitter->commitFid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
|
||||||
&pCommitter->maxKey);
|
&pCommitter->maxKey);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -556,7 +558,10 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SDiskID did = {0};
|
SDiskID did = {0};
|
||||||
tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did);
|
if (tfsAllocDisk(pTsdb->pVnode->pTfs, pCommitter->expLevel, &did) < 0) {
|
||||||
|
code = terrno;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
|
tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
|
||||||
wSet.diskId = did;
|
wSet.diskId = did;
|
||||||
wSet.nSttF = 1;
|
wSet.nSttF = 1;
|
||||||
|
|
|
@ -962,6 +962,7 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDFileSet->diskId = pSet->diskId;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,7 +695,7 @@ static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData,
|
||||||
}
|
}
|
||||||
|
|
||||||
while (iRow < nRow) {
|
while (iRow < nRow) {
|
||||||
tRow.pTSRow = aRow[iRow++];
|
tRow.pTSRow = aRow[iRow];
|
||||||
key.ts = tRow.pTSRow->ts;
|
key.ts = tRow.pTSRow->ts;
|
||||||
|
|
||||||
if (SL_NODE_FORWARD(pos[0], 0) != pTbData->sl.pTail) {
|
if (SL_NODE_FORWARD(pos[0], 0) != pTbData->sl.pTail) {
|
||||||
|
|
|
@ -214,6 +214,7 @@ static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader);
|
||||||
static int32_t doBuildDataBlock(STsdbReader* pReader);
|
static int32_t doBuildDataBlock(STsdbReader* pReader);
|
||||||
static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
|
static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
|
||||||
static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo);
|
static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo);
|
||||||
|
static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter);
|
||||||
|
|
||||||
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
||||||
|
|
||||||
|
@ -2477,8 +2478,39 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||||
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
int32_t nextIndex = -1;
|
||||||
break;
|
SBlockIndex bIndex = {0};
|
||||||
|
bool hasNeighbor =
|
||||||
|
getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||||
|
if (!hasNeighbor) { // do nothing
|
||||||
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overlapWithNeighborBlock(pBlock, &bIndex, pReader->order)) { // load next block
|
||||||
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||||
|
|
||||||
|
// 1. find the next neighbor block in the scan block list
|
||||||
|
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||||
|
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||||
|
|
||||||
|
// 2. remove it from the scan block list
|
||||||
|
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||||
|
|
||||||
|
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||||
|
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. check the data values
|
||||||
|
initBlockDumpInfo(pReader, pBlockIter);
|
||||||
|
} else {
|
||||||
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2887,7 +2919,7 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the correct start position in case of the first/last file block, according to the query time window
|
// set the correct start position in case of the first/last file block, according to the query time window
|
||||||
static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
|
void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
|
||||||
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
||||||
|
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
@ -3096,7 +3128,7 @@ bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32
|
||||||
return false;
|
return false;
|
||||||
} else if (pKey->ts == last->ts) {
|
} else if (pKey->ts == last->ts) {
|
||||||
TSDBKEY* prev = taosArrayGet(pDelList, num - 2);
|
TSDBKEY* prev = taosArrayGet(pDelList, num - 2);
|
||||||
return (prev->version >= pKey->version);
|
return (prev->version >= pKey->version && prev->version <= pVerRange->maxVer && prev->version >= pVerRange->minVer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TSDBKEY* pCurrent = taosArrayGet(pDelList, *index);
|
TSDBKEY* pCurrent = taosArrayGet(pDelList, *index);
|
||||||
|
@ -3240,12 +3272,16 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
STSchema* pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, uid);
|
if (pRow->type == TSDBROW_ROW_FMT) {
|
||||||
if (pTSchema == NULL) {
|
STSchema* pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, uid);
|
||||||
return terrno;
|
if (pTSchema == NULL) {
|
||||||
}
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
tsdbRowMergerAdd(pMerger, pRow, pTSchema);
|
tsdbRowMergerAdd(pMerger, pRow, pTSchema);
|
||||||
|
} else { // column format
|
||||||
|
tsdbRowMerge(pMerger, pRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3394,46 +3430,55 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// todo handle the data block merge
|
|
||||||
SRowMerger merge = {0};
|
SRowMerger merge = {0};
|
||||||
|
|
||||||
// get the correct schema for data in memory
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
STSchema* pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(¤t), pReader, uid);
|
int32_t code = 0;
|
||||||
if (pTSchema == NULL) {
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pReader->pSchema == NULL) {
|
// start to merge duplicated rows
|
||||||
pReader->pSchema = pTSchema;
|
if (current.type == TSDBROW_ROW_FMT) {
|
||||||
}
|
// get the correct schema for data in memory
|
||||||
|
STSchema* pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(¤t), pReader, uid);
|
||||||
|
if (pTSchema == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = tsdbRowMergerInit2(&merge, pReader->pSchema, ¤t, pTSchema);
|
if (pReader->pSchema == NULL) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
pReader->pSchema = pTSchema;
|
||||||
return code;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
STSchema* pTSchema1 = doGetSchemaForTSRow(TSDBROW_SVERSION(pNextRow), pReader, uid);
|
code = tsdbRowMergerInit2(&merge, pReader->pSchema, ¤t, pTSchema);
|
||||||
if (pTSchema1 == NULL) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return terrno;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbRowMergerAdd(&merge, pNextRow, pTSchema1);
|
STSchema* pTSchema1 = doGetSchemaForTSRow(TSDBROW_SVERSION(pNextRow), pReader, uid);
|
||||||
|
if (pTSchema1 == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbRowMergerAdd(&merge, pNextRow, pTSchema1);
|
||||||
|
} else { // let's merge rows in file block
|
||||||
|
code = tsdbRowMergerInit(&merge, ¤t, pReader->pSchema);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbRowMerge(&merge, pNextRow);
|
||||||
|
}
|
||||||
|
|
||||||
code = doMergeRowsInBuf(pIter, uid, current.pTSRow->ts, pDelList, &merge, pReader);
|
code = doMergeRowsInBuf(pIter, uid, current.pTSRow->ts, pDelList, &merge, pReader);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbRowMergerGetRow(&merge, pTSRow);
|
code = tsdbRowMergerGetRow(&merge, &pResRow->pTSRow);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pResRow->type = current.type;
|
||||||
tsdbRowMergerClear(&merge);
|
tsdbRowMergerClear(&merge);
|
||||||
*freeTSRow = true;
|
*freeTSRow = true;
|
||||||
#endif
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3910,7 +3955,6 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
||||||
if (pReader->freeBlock) {
|
if (pReader->freeBlock) {
|
||||||
pReader->pResBlock = blockDataDestroy(pReader->pResBlock);
|
pReader->pResBlock = blockDataDestroy(pReader->pResBlock);
|
||||||
}
|
}
|
||||||
tBlockDataDestroy(&pReader->status.fileBlockData);
|
|
||||||
|
|
||||||
taosMemoryFree(pSupInfo->colId);
|
taosMemoryFree(pSupInfo->colId);
|
||||||
tBlockDataDestroy(&pReader->status.fileBlockData);
|
tBlockDataDestroy(&pReader->status.fileBlockData);
|
||||||
|
@ -4067,8 +4111,32 @@ void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockSMA, bool* allHave) {
|
static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols, SColumnDataAgg* pTsAgg) {
|
||||||
|
// do fill all null column value SMA info
|
||||||
|
int32_t i = 0, j = 0;
|
||||||
|
int32_t size = (int32_t)taosArrayGetSize(pSup->pColAgg);
|
||||||
|
taosArrayInsert(pSup->pColAgg, 0, pTsAgg);
|
||||||
|
|
||||||
|
while (j < numOfCols && i < size) {
|
||||||
|
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||||
|
if (pAgg->colId == pSup->colId[j]) {
|
||||||
|
i += 1;
|
||||||
|
j += 1;
|
||||||
|
} else if (pAgg->colId < pSup->colId[j]) {
|
||||||
|
i += 1;
|
||||||
|
} else if (pSup->colId[j] < pAgg->colId) {
|
||||||
|
if (pSup->colId[j] != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
|
SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = numOfRows};
|
||||||
|
taosArrayInsert(pSup->pColAgg, i, &nullColAgg);
|
||||||
|
}
|
||||||
|
j += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SColumnDataAgg ***pBlockSMA = &pDataBlock->pBlockAgg;
|
||||||
*allHave = false;
|
*allHave = false;
|
||||||
|
|
||||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||||
|
@ -4116,12 +4184,22 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
||||||
int32_t i = 0, j = 0;
|
int32_t i = 0, j = 0;
|
||||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||||
|
|
||||||
|
// ensure capacity
|
||||||
|
if(pDataBlock->pDataBlock) {
|
||||||
|
size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
|
taosArrayEnsureCap(pSup->pColAgg, colsNum);
|
||||||
|
}
|
||||||
|
|
||||||
SSDataBlock* pResBlock = pReader->pResBlock;
|
SSDataBlock* pResBlock = pReader->pResBlock;
|
||||||
if (pResBlock->pBlockAgg == NULL) {
|
if (pResBlock->pBlockAgg == NULL) {
|
||||||
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
||||||
pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg));
|
pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do fill all null column value SMA info
|
||||||
|
doFillNullColSMA(pSup, pBlock->nRow, numOfCols, pTsAgg);
|
||||||
|
|
||||||
|
i = 0, j = 0;
|
||||||
while (j < numOfCols && i < size) {
|
while (j < numOfCols && i < size) {
|
||||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||||
if (pAgg->colId == pSup->colId[j]) {
|
if (pAgg->colId == pSup->colId[j]) {
|
||||||
|
|
|
@ -155,7 +155,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
||||||
|
|
||||||
if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
|
if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
|
||||||
pIter->rInfo.suid = pIter->bData.suid;
|
pIter->rInfo.suid = pIter->bData.suid;
|
||||||
pIter->rInfo.uid = pIter->bData.uid;
|
pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow];
|
||||||
pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
|
pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
|
||||||
goto _add_iter;
|
goto _add_iter;
|
||||||
}
|
}
|
||||||
|
@ -179,16 +179,14 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) { return pReader->pIter ? &pReader->pIter->rInfo : NULL; }
|
|
||||||
|
|
||||||
static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pReader->pIter) {
|
if (pReader->pIter) {
|
||||||
SFDataIter* pIter = pReader->pIter;
|
SFDataIter* pIter = NULL;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
_find_row:
|
_find_row:
|
||||||
|
pIter = pReader->pIter;
|
||||||
for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
|
for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
|
||||||
int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
|
int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
|
||||||
|
|
||||||
|
@ -224,6 +222,7 @@ static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->pIter = NULL;
|
pReader->pIter = NULL;
|
||||||
|
break;
|
||||||
} else if (pIter->type == SNAP_STT_FILE_ITER) {
|
} else if (pIter->type == SNAP_STT_FILE_ITER) {
|
||||||
for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
|
for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
|
||||||
SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
|
SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
|
||||||
|
@ -238,6 +237,7 @@ static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->pIter = NULL;
|
pReader->pIter = NULL;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,20 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) {
|
||||||
|
if (pReader->pIter) {
|
||||||
|
return &pReader->pIter->rInfo;
|
||||||
|
} else {
|
||||||
|
tsdbSnapNextRow(pReader);
|
||||||
|
|
||||||
|
if (pReader->pIter) {
|
||||||
|
return &pReader->pIter->rInfo;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -1356,7 +1370,7 @@ _exit:
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tsdbDebug("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
|
tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1421,7 +1435,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||||
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
|
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
|
||||||
tFree(pWriter->aBuf[iBuf]);
|
tFree(pWriter->aBuf[iBuf]);
|
||||||
}
|
}
|
||||||
tsdbInfo("vgId:%d, vnode snapshot tsdb writer close for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
|
tsdbInfo("vgId:%d %s done", TD_VID(pWriter->pTsdb->pVnode), __func__);
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -637,6 +637,7 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
return NULL; // suppress error report by compiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,13 +1106,7 @@ void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColD
|
||||||
int32_t ridx = pBlockData->nColData - 1;
|
int32_t ridx = pBlockData->nColData - 1;
|
||||||
|
|
||||||
while (lidx <= ridx) {
|
while (lidx <= ridx) {
|
||||||
int32_t midx;
|
int32_t midx = (lidx + ridx) >> 1;
|
||||||
if (lidx == ridx) {
|
|
||||||
midx = lidx;
|
|
||||||
} else {
|
|
||||||
midx = lidx + (ridx - lidx) * (cid - pBlockData->aColData[lidx].cid) /
|
|
||||||
(pBlockData->aColData[ridx].cid - pBlockData->aColData[lidx].cid);
|
|
||||||
}
|
|
||||||
SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, midx);
|
SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, midx);
|
||||||
int32_t c = (pColData->cid == cid) ? 0 : ((pColData->cid > cid) ? 1 : -1);
|
int32_t c = (pColData->cid == cid) ? 0 : ((pColData->cid > cid) ? 1 : -1);
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
if (flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||||
|
// SVCreateTbReq
|
||||||
if (tStartDecode(&dc) < 0) {
|
if (tStartDecode(&dc) < 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -126,6 +127,15 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
||||||
|
|
||||||
tEndDecode(&dc);
|
tEndDecode(&dc);
|
||||||
|
|
||||||
|
// SSubmitTbData
|
||||||
|
int64_t suid;
|
||||||
|
if (tDecodeI64(&dc, &suid) < 0) {
|
||||||
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(int64_t *)(dc.data + dc.pos) = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(&dc);
|
tEndDecode(&dc);
|
||||||
|
@ -200,9 +210,13 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
version);
|
version);
|
||||||
|
|
||||||
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
||||||
|
ASSERT(pVnode->state.applied + 1 == version);
|
||||||
|
|
||||||
pVnode->state.applied = version;
|
pVnode->state.applied = version;
|
||||||
pVnode->state.applyTerm = pMsg->info.conn.applyTerm;
|
pVnode->state.applyTerm = pMsg->info.conn.applyTerm;
|
||||||
|
|
||||||
|
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
||||||
|
|
||||||
// skip header
|
// skip header
|
||||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
len = pMsg->contLen - sizeof(SMsgHead);
|
len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
@ -1016,7 +1030,7 @@ _exit:
|
||||||
atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1);
|
atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1);
|
atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1);
|
||||||
tdProcessRSmaSubmit(pVnode->pSma, pSubmitReq, pReq, len, STREAM_INPUT__DATA_SUBMIT);
|
tdProcessRSmaSubmit(pVnode->pSma, version, pSubmitReq, pReq, len, STREAM_INPUT__DATA_SUBMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
|
|
|
@ -547,6 +547,14 @@ typedef struct SCtgOperation {
|
||||||
#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__)
|
#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__)
|
||||||
#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__)
|
#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define ctgTaskFatal(param, ...) qFatal("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskError(param, ...) qError("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskWarn(param, ...) qWarn("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskInfo(param, ...) qInfo("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskDebug(param, ...) qDebug("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskTrace(param, ...) qTrace("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
#define CTG_LOCK_DEBUG(...) \
|
#define CTG_LOCK_DEBUG(...) \
|
||||||
do { \
|
do { \
|
||||||
if (gCTGDebug.lockEnable) { \
|
if (gCTGDebug.lockEnable) { \
|
||||||
|
|
|
@ -1094,6 +1094,9 @@ _return:
|
||||||
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
ctgTaskError("Get table %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname, tstrerror(code));
|
||||||
|
}
|
||||||
if (pTask->res || code) {
|
if (pTask->res || code) {
|
||||||
ctgHandleTaskEnd(pTask, code);
|
ctgHandleTaskEnd(pTask, code);
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1127,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
ctgTaskDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
||||||
|
|
||||||
*vgId = vgInfo.vgId;
|
*vgId = vgInfo.vgId;
|
||||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
||||||
|
@ -1144,7 +1147,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
ctgTaskDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
||||||
|
|
||||||
*vgId = vgInfo.vgId;
|
*vgId = vgInfo.vgId;
|
||||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
||||||
|
@ -1162,7 +1165,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgError("no tbmeta got, tbName:%s", tNameGetTableName(pName));
|
ctgTaskError("no tbmeta got, tbName:%s", tNameGetTableName(pName));
|
||||||
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
||||||
|
|
||||||
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
||||||
|
@ -1180,7 +1183,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
|
STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
|
||||||
|
|
||||||
if (CTG_IS_META_NULL(pOut->metaType)) {
|
if (CTG_IS_META_NULL(pOut->metaType)) {
|
||||||
ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(pName));
|
ctgTaskError("no tbmeta got, tbNmae:%s", tNameGetTableName(pName));
|
||||||
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
||||||
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
@ -1190,7 +1193,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CTG_IS_META_TABLE(pOut->metaType) && TSDB_SUPER_TABLE == pOut->tbMeta->tableType) {
|
if (CTG_IS_META_TABLE(pOut->metaType) && TSDB_SUPER_TABLE == pOut->tbMeta->tableType) {
|
||||||
ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pName));
|
ctgTaskDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pName));
|
||||||
|
|
||||||
taosMemoryFreeClear(pOut->tbMeta);
|
taosMemoryFreeClear(pOut->tbMeta);
|
||||||
|
|
||||||
|
@ -1207,11 +1210,11 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
STableMeta* stbMeta = NULL;
|
STableMeta* stbMeta = NULL;
|
||||||
(void)ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
(void)ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
||||||
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
||||||
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgTaskDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
exist = 1;
|
exist = 1;
|
||||||
taosMemoryFreeClear(stbMeta);
|
taosMemoryFreeClear(stbMeta);
|
||||||
} else {
|
} else {
|
||||||
ctgDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgTaskDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
taosMemoryFreeClear(pOut->tbMeta);
|
taosMemoryFreeClear(pOut->tbMeta);
|
||||||
taosMemoryFreeClear(stbMeta);
|
taosMemoryFreeClear(stbMeta);
|
||||||
}
|
}
|
||||||
|
@ -1225,7 +1228,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ctgError("invalid reqType %d", reqType);
|
ctgTaskError("invalid reqType %d", reqType);
|
||||||
CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
|
CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,6 +1283,7 @@ _return:
|
||||||
TSWAP(pTask->res, ctx->pResList);
|
TSWAP(pTask->res, ctx->pResList);
|
||||||
taskDone = true;
|
taskDone = true;
|
||||||
}
|
}
|
||||||
|
ctgTaskError("Get table %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->res && taskDone) {
|
if (pTask->res && taskDone) {
|
||||||
|
|
|
@ -126,15 +126,14 @@ enum {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO remove prepareStatus
|
// TODO remove prepareStatus
|
||||||
STqOffsetVal prepareStatus; // for tmq
|
STqOffsetVal prepareStatus; // for tmq
|
||||||
STqOffsetVal lastStatus; // for tmq
|
STqOffsetVal lastStatus; // for tmq
|
||||||
SMqMetaRsp metaRsp; // for tmq fetching meta
|
SMqMetaRsp metaRsp; // for tmq fetching meta
|
||||||
int8_t returned;
|
int8_t returned;
|
||||||
int64_t snapshotVer;
|
int64_t snapshotVer;
|
||||||
const SSubmitReq* pReq;
|
// const SSubmitReq* pReq;
|
||||||
int64_t scanVer;
|
|
||||||
|
|
||||||
SPackedSubmit submit;
|
SPackedData submit;
|
||||||
|
|
||||||
SSchemaWrapper* schema;
|
SSchemaWrapper* schema;
|
||||||
char tbName[TSDB_TABLE_NAME_LEN];
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
@ -202,7 +201,7 @@ typedef struct SOperatorFpSet {
|
||||||
__optr_fn_t getNextFn;
|
__optr_fn_t getNextFn;
|
||||||
__optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP
|
__optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP
|
||||||
__optr_close_fn_t closeFn;
|
__optr_close_fn_t closeFn;
|
||||||
__optr_reqBuf_fn_t reqBufFn; // total used buffer for blocking operator
|
__optr_reqBuf_fn_t reqBufFn; // total used buffer for blocking operator
|
||||||
__optr_encode_fn_t encodeResultRow;
|
__optr_encode_fn_t encodeResultRow;
|
||||||
__optr_decode_fn_t decodeResultRow;
|
__optr_decode_fn_t decodeResultRow;
|
||||||
__optr_explain_fn_t getExplainFn;
|
__optr_explain_fn_t getExplainFn;
|
||||||
|
@ -503,8 +502,8 @@ typedef struct STableCountScanOperatorInfo {
|
||||||
|
|
||||||
STableCountScanSupp supp;
|
STableCountScanSupp supp;
|
||||||
|
|
||||||
int32_t currGrpIdx;
|
int32_t currGrpIdx;
|
||||||
SArray* stbUidList; // when group by db_name and/or stable_name
|
SArray* stbUidList; // when group by db_name and/or stable_name
|
||||||
} STableCountScanOperatorInfo;
|
} STableCountScanOperatorInfo;
|
||||||
|
|
||||||
typedef struct SOptrBasicInfo {
|
typedef struct SOptrBasicInfo {
|
||||||
|
|
|
@ -439,7 +439,9 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removeInvalidTable(uidList, tags);
|
if (suid != 0) {
|
||||||
|
removeInvalidTable(uidList, tags);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t rows = taosArrayGetSize(uidList);
|
int32_t rows = taosArrayGetSize(uidList);
|
||||||
if (rows == 0) {
|
if (rows == 0) {
|
||||||
|
@ -1604,7 +1606,7 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
|
||||||
pCond->numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols);
|
pCond->numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols);
|
||||||
|
|
||||||
pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo));
|
pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo));
|
||||||
pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t)*pCond->numOfCols);
|
pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t) * pCond->numOfCols);
|
||||||
if (pCond->colList == NULL || pCond->pSlotList == NULL) {
|
if (pCond->colList == NULL || pCond->pSlotList == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
taosMemoryFreeClear(pCond->colList);
|
taosMemoryFreeClear(pCond->colList);
|
||||||
|
|
|
@ -51,8 +51,8 @@ static int32_t doSetSMABlock(SOperatorInfo* pOperator, void* input, size_t numOf
|
||||||
|
|
||||||
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||||
SSubmitReq* pReq = *(void**)POINTER_SHIFT(input, i * sizeof(void*));
|
SPackedData* pReq = POINTER_SHIFT(input, i * sizeof(SPackedData));
|
||||||
taosArrayPush(pInfo->pBlockLists, &pReq);
|
taosArrayPush(pInfo->pBlockLists, pReq);
|
||||||
}
|
}
|
||||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
|
@ -61,7 +61,10 @@ static int32_t doSetSMABlock(SOperatorInfo* pOperator, void* input, size_t numOf
|
||||||
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||||
taosArrayPush(pInfo->pBlockLists, &pDataBlock);
|
SPackedData tmp = {
|
||||||
|
.pDataBlock = pDataBlock,
|
||||||
|
};
|
||||||
|
taosArrayPush(pInfo->pBlockLists, &tmp);
|
||||||
}
|
}
|
||||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||||
}
|
}
|
||||||
|
@ -115,18 +118,21 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
if (type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||||
// ASSERT(numOfBlocks > 1);
|
// ASSERT(numOfBlocks > 1);
|
||||||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||||
SSubmitReq* pReq = *(void**)POINTER_SHIFT(input, i * sizeof(void*));
|
SPackedData* pReq = POINTER_SHIFT(input, i * sizeof(SPackedData));
|
||||||
taosArrayPush(pInfo->pBlockLists, &pReq);
|
taosArrayPush(pInfo->pBlockLists, pReq);
|
||||||
}
|
}
|
||||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
ASSERT(numOfBlocks == 1);
|
ASSERT(numOfBlocks == 1);
|
||||||
taosArrayPush(pInfo->pBlockLists, &input);
|
taosArrayPush(pInfo->pBlockLists, input);
|
||||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||||
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||||
taosArrayPush(pInfo->pBlockLists, &pDataBlock);
|
SPackedData tmp = {
|
||||||
|
.pDataBlock = pDataBlock,
|
||||||
|
};
|
||||||
|
taosArrayPush(pInfo->pBlockLists, &tmp);
|
||||||
}
|
}
|
||||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1002,6 +1008,7 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq, int64_t scanVer) {
|
int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq, int64_t scanVer) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE);
|
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE);
|
||||||
|
@ -1010,8 +1017,9 @@ int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq, int64_t sc
|
||||||
pTaskInfo->streamInfo.scanVer = scanVer;
|
pTaskInfo->streamInfo.scanVer = scanVer;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedSubmit submit) {
|
int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE);
|
ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE);
|
||||||
ASSERT(pTaskInfo->streamInfo.submit.msgStr == NULL);
|
ASSERT(pTaskInfo->streamInfo.submit.msgStr == NULL);
|
||||||
|
|
|
@ -1580,6 +1580,7 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) {
|
||||||
int32_t optrDefaultBufFn(SOperatorInfo* pOperator) {
|
int32_t optrDefaultBufFn(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->blocking) {
|
if (pOperator->blocking) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "filter.h"
|
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
|
#include "filter.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
||||||
typedef struct SProjectOperatorInfo {
|
typedef struct SProjectOperatorInfo {
|
||||||
|
@ -90,7 +90,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
|
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
pInfo->pFinalRes = createOneDataBlock(pResBlock, false);
|
pInfo->pFinalRes = createOneDataBlock(pResBlock, false);
|
||||||
pInfo->mergeDataBlocks = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM)? false:pProjPhyNode->mergeDataBlock;
|
pInfo->mergeDataBlocks = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) ? false : pProjPhyNode->mergeDataBlock;
|
||||||
|
|
||||||
int32_t numOfRows = 4096;
|
int32_t numOfRows = 4096;
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
|
@ -117,9 +117,10 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
|
|
||||||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doProjectOperation, NULL,
|
pTaskInfo);
|
||||||
destroyProjectOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doProjectOperation, NULL, destroyProjectOperatorInfo,
|
||||||
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -220,7 +221,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
blockDataCleanup(pFinalRes);
|
blockDataCleanup(pFinalRes);
|
||||||
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
if (pTaskInfo->streamInfo.pReq) {
|
if (pTaskInfo->streamInfo.submit.msgStr) {
|
||||||
pOperator->status = OP_OPENED;
|
pOperator->status = OP_OPENED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,8 +415,10 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, optrDefaultBufFn, NULL);
|
pTaskInfo);
|
||||||
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo,
|
||||||
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -224,7 +224,7 @@ static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg** pColsA
|
||||||
|
|
||||||
static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||||
bool allColumnsHaveAgg = true;
|
bool allColumnsHaveAgg = true;
|
||||||
int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, &pBlock->pBlockAgg, &allColumnsHaveAgg);
|
int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, pBlock, &allColumnsHaveAgg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -768,8 +768,8 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num);
|
tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num);
|
||||||
ASSERT(pInfo->base.dataReader == NULL);
|
ASSERT(pInfo->base.dataReader == NULL);
|
||||||
|
|
||||||
int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num,
|
int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock,
|
||||||
pInfo->pResBlock, (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
(STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -986,8 +986,8 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
|
|
||||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
STsdbReader* pReader = NULL;
|
STsdbReader* pReader = NULL;
|
||||||
int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, (STsdbReader**)&pReader,
|
int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock,
|
||||||
GET_TASKID(pTaskInfo));
|
(STsdbReader**)&pReader, GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
@ -995,7 +995,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbNextDataBlock(pReader)) {
|
if (tsdbNextDataBlock(pReader)) {
|
||||||
/*SSDataBlock* p = */tsdbRetrieveDataBlock(pReader, NULL);
|
/*SSDataBlock* p = */ tsdbRetrieveDataBlock(pReader, NULL);
|
||||||
doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows);
|
doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows);
|
||||||
pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid);
|
pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid);
|
||||||
}
|
}
|
||||||
|
@ -1218,27 +1218,56 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
if (rows == 0) {
|
if (rows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SColumnInfoData* pSrcStartTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
|
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
|
||||||
|
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||||
|
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||||
|
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
|
int64_t version = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
|
if (pInfo->partitionSup.needCalc && srcStartTsCol[0] != srcEndTsCol[0]) {
|
||||||
|
uint64_t srcUid = srcUidData[0];
|
||||||
|
TSKEY startTs = srcStartTsCol[0];
|
||||||
|
TSKEY endTs = srcEndTsCol[0];
|
||||||
|
SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, srcUid, startTs, endTs, version);
|
||||||
|
printDataBlock(pPreRes, "pre res");
|
||||||
|
blockDataCleanup(pSrcBlock);
|
||||||
|
int32_t code = blockDataEnsureCapacity(pSrcBlock, pPreRes->info.rows);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumnInfoData* pTsCol = (SColumnInfoData*)taosArrayGet(pPreRes->pDataBlock, pInfo->primaryTsIndex);
|
||||||
|
rows = pPreRes->info.rows;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < rows; i++) {
|
||||||
|
uint64_t groupId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, i);
|
||||||
|
appendOneRowToStreamSpecialBlock(pSrcBlock, ((TSKEY*)pTsCol->pData) + i, ((TSKEY*)pTsCol->pData) + i, &srcUid,
|
||||||
|
&groupId, NULL);
|
||||||
|
}
|
||||||
|
printDataBlock(pSrcBlock, "new delete");
|
||||||
|
}
|
||||||
|
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
||||||
|
srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||||
|
srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
|
srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||||
|
|
||||||
int32_t code = blockDataEnsureCapacity(pDestBlock, rows);
|
int32_t code = blockDataEnsureCapacity(pDestBlock, rows);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnInfoData* pSrcStartTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
|
||||||
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
|
|
||||||
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
|
||||||
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
|
||||||
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
|
|
||||||
ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
|
||||||
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartTsCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pEndTsCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndTsCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pDeUidCol = taosArrayGet(pDestBlock->pDataBlock, UID_COLUMN_INDEX);
|
SColumnInfoData* pDeUidCol = taosArrayGet(pDestBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
int64_t version = pSrcBlock->info.version - 1;
|
|
||||||
for (int32_t i = 0; i < rows;) {
|
for (int32_t i = 0; i < rows;) {
|
||||||
uint64_t srcUid = srcUidData[i];
|
uint64_t srcUid = srcUidData[i];
|
||||||
uint64_t groupId = srcGp[i];
|
uint64_t groupId = srcGp[i];
|
||||||
|
@ -1496,19 +1525,18 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
qDebug("queue scan called");
|
qDebug("queue scan called");
|
||||||
|
|
||||||
if (pTaskInfo->streamInfo.pReq != NULL) {
|
if (pTaskInfo->streamInfo.submit.msgStr != NULL) {
|
||||||
if (pInfo->tqReader->pMsg == NULL) {
|
if (pInfo->tqReader->msg2.msgStr == NULL) {
|
||||||
pInfo->tqReader->pMsg = pTaskInfo->streamInfo.pReq;
|
/*pInfo->tqReader->pMsg = pTaskInfo->streamInfo.pReq;*/
|
||||||
pInfo->tqReader->ver = pTaskInfo->streamInfo.scanVer;
|
|
||||||
|
|
||||||
const SSubmitReq* pSubmit = pInfo->tqReader->pMsg;
|
/*const SSubmitReq* pSubmit = pInfo->tqReader->pMsg;*/
|
||||||
/*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/
|
/*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/
|
||||||
/*void* msgStr = pTaskInfo->streamInfo.*/
|
/*void* msgStr = pTaskInfo->streamInfo.*/
|
||||||
SPackedSubmit submit = pTaskInfo->streamInfo.submit;
|
SPackedData submit = pTaskInfo->streamInfo.submit;
|
||||||
if (tqReaderSetSubmitReq2(pInfo->tqReader, submit.msgStr, submit.msgLen, submit.ver) < 0) {
|
if (tqReaderSetSubmitReq2(pInfo->tqReader, submit.msgStr, submit.msgLen, submit.ver) < 0) {
|
||||||
qError("submit msg messed up when initing stream submit block %p", pSubmit);
|
qError("submit msg messed up when initing stream submit block %p", submit.msgStr);
|
||||||
pInfo->tqReader->pMsg = NULL;
|
pInfo->tqReader->msg2 = (SPackedData){0};
|
||||||
pTaskInfo->streamInfo.pReq = NULL;
|
pInfo->tqReader->setMsg = 0;
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1532,8 +1560,9 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->tqReader->pMsg = NULL;
|
pInfo->tqReader->msg2 = (SPackedData){0};
|
||||||
pTaskInfo->streamInfo.pReq = NULL;
|
pInfo->tqReader->setMsg = 0;
|
||||||
|
pTaskInfo->streamInfo.submit = (SPackedData){0};
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1658,13 +1687,6 @@ static void setBlockGroupIdByUid(SStreamScanInfo* pInfo, SSDataBlock* pBlock) {
|
||||||
uint64_t groupId = getGroupIdByUid(pInfo, uidCol[i]);
|
uint64_t groupId = getGroupIdByUid(pInfo, uidCol[i]);
|
||||||
colDataAppend(pGpCol, i, (const char*)&groupId, false);
|
colDataAppend(pGpCol, i, (const char*)&groupId, false);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, uidCol[i], startTsCol, ts, maxVersion);
|
|
||||||
// if (!pPreRes || pPreRes->info.rows == 0) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
// ASSERT(pPreRes->info.rows == 1);
|
|
||||||
// return calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1769,7 +1791,8 @@ FETCH_NEXT_BLOCK:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t current = pInfo->validBlockIndex++;
|
int32_t current = pInfo->validBlockIndex++;
|
||||||
SSDataBlock* pBlock = taosArrayGetP(pInfo->pBlockLists, current);
|
SPackedData* pPacked = taosArrayGet(pInfo->pBlockLists, current);
|
||||||
|
SSDataBlock* pBlock = pPacked->pDataBlock;
|
||||||
if (pBlock->info.id.groupId && pBlock->info.parTbName[0]) {
|
if (pBlock->info.id.groupId && pBlock->info.parTbName[0]) {
|
||||||
streamStatePutParName(pTaskInfo->streamInfo.pState, pBlock->info.id.groupId, pBlock->info.parTbName);
|
streamStatePutParName(pTaskInfo->streamInfo.pState, pBlock->info.id.groupId, pBlock->info.parTbName);
|
||||||
}
|
}
|
||||||
|
@ -1898,7 +1921,7 @@ FETCH_NEXT_BLOCK:
|
||||||
|
|
||||||
NEXT_SUBMIT_BLK:
|
NEXT_SUBMIT_BLK:
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pInfo->tqReader->pMsg == NULL) {
|
if (pInfo->tqReader->msg2.msgStr == NULL) {
|
||||||
if (pInfo->validBlockIndex >= totBlockNum) {
|
if (pInfo->validBlockIndex >= totBlockNum) {
|
||||||
updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo);
|
updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo);
|
||||||
doClearBufferedBlocks(pInfo);
|
doClearBufferedBlocks(pInfo);
|
||||||
|
@ -1906,13 +1929,12 @@ FETCH_NEXT_BLOCK:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t current = pInfo->validBlockIndex++;
|
int32_t current = pInfo->validBlockIndex++;
|
||||||
SSubmitReq* pSubmit = taosArrayGetP(pInfo->pBlockLists, current);
|
SPackedData* pSubmit = taosArrayGet(pInfo->pBlockLists, current);
|
||||||
/*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/
|
/*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/
|
||||||
if (tqReaderSetSubmitReq2(pInfo->tqReader, pSubmit, 0, 0) < 0) {
|
if (tqReaderSetSubmitReq2(pInfo->tqReader, pSubmit->msgStr, pSubmit->msgLen, pSubmit->ver) < 0) {
|
||||||
qError("submit msg messed up when initing stream submit block %p, current %d, total %d", pSubmit, current,
|
qError("submit msg messed up when initing stream submit block %p, current %d, total %d", pSubmit, current,
|
||||||
totBlockNum);
|
totBlockNum);
|
||||||
pInfo->tqReader->pMsg = NULL;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1963,7 +1985,6 @@ FETCH_NEXT_BLOCK:
|
||||||
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
pInfo->tqReader->pMsg = NULL;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*blockDataCleanup(pInfo->pRes);*/
|
/*blockDataCleanup(pInfo->pRes);*/
|
||||||
|
@ -2244,7 +2265,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pBlockLists = taosArrayInit(4, POINTER_BYTES);
|
pInfo->pBlockLists = taosArrayInit(4, sizeof(SPackedData));
|
||||||
if (pInfo->pBlockLists == NULL) {
|
if (pInfo->pBlockLists == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -2264,7 +2285,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
if (pHandle->initTableReader) {
|
if (pHandle->initTableReader) {
|
||||||
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
||||||
pTSInfo->base.dataReader = NULL;
|
pTSInfo->base.dataReader = NULL;
|
||||||
code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock, &pTSInfo->base.dataReader, NULL);
|
code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock,
|
||||||
|
&pTSInfo->base.dataReader, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
destroyTableScanOperatorInfo(pTableScanOp);
|
destroyTableScanOperatorInfo(pTableScanOp);
|
||||||
|
@ -2334,7 +2356,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||||
|
|
||||||
__optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan;
|
__optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan;
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
@ -2471,7 +2494,8 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(optrDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
@ -2492,11 +2516,12 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
|
||||||
|
|
||||||
SQueryTableDataCond* pQueryCond = taosArrayGet(pInfo->queryConds, readIdx);
|
SQueryTableDataCond* pQueryCond = taosArrayGet(pInfo->queryConds, readIdx);
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex);
|
void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex);
|
||||||
SReadHandle* pHandle = &pInfo->base.readHandle;
|
SReadHandle* pHandle = &pInfo->base.readHandle;
|
||||||
|
|
||||||
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
int32_t code =
|
||||||
|
tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -2894,8 +2919,8 @@ static void buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo*
|
||||||
SSDataBlock* pRes, char* dbName);
|
SSDataBlock* pRes, char* dbName);
|
||||||
static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName);
|
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName);
|
||||||
static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName);
|
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName);
|
||||||
static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||||
STableCountScanSupp* pSupp, SSDataBlock* pRes);
|
STableCountScanSupp* pSupp, SSDataBlock* pRes);
|
||||||
static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||||
|
@ -3020,8 +3045,8 @@ SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* readHandle, STableC
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "TableCountScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, false, OP_NOT_OPENED,
|
setOperatorInfo(pOperator, "TableCountScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, false, OP_NOT_OPENED,
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
@ -3038,8 +3063,10 @@ void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char*
|
||||||
if (pSupp->dbNameSlotId != -1) {
|
if (pSupp->dbNameSlotId != -1) {
|
||||||
ASSERT(strlen(dbName));
|
ASSERT(strlen(dbName));
|
||||||
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
|
||||||
char varDbName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
strncpy(varDataVal(varDbName), dbName, strlen(dbName));
|
char varDbName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
tstrncpy(varDataVal(varDbName), dbName, TSDB_DB_NAME_LEN);
|
||||||
|
|
||||||
varDataSetLen(varDbName, strlen(dbName));
|
varDataSetLen(varDbName, strlen(dbName));
|
||||||
colDataAppend(colInfoData, 0, varDbName, false);
|
colDataAppend(colInfoData, 0, varDbName, false);
|
||||||
}
|
}
|
||||||
|
@ -3048,7 +3075,7 @@ void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char*
|
||||||
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
||||||
if (strlen(stbName) != 0) {
|
if (strlen(stbName) != 0) {
|
||||||
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
strncpy(varDataVal(varStbName), stbName, strlen(stbName));
|
strncpy(varDataVal(varStbName), stbName, TSDB_TABLE_NAME_LEN);
|
||||||
varDataSetLen(varStbName, strlen(stbName));
|
varDataSetLen(varStbName, strlen(stbName));
|
||||||
colDataAppend(colInfoData, 0, varStbName, false);
|
colDataAppend(colInfoData, 0, varStbName, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -95,6 +95,8 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
||||||
// TODO: optimize to ignore null values for linear interpolation.
|
// TODO: optimize to ignore null values for linear interpolation.
|
||||||
if (!pLinearInfo->isStartSet) {
|
if (!pLinearInfo->isStartSet) {
|
||||||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||||
|
ASSERT(IS_MATHABLE_TYPE(pColInfoData->info.type));
|
||||||
|
|
||||||
pLinearInfo->start.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
pLinearInfo->start.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
||||||
memcpy(pLinearInfo->start.val, colDataGetData(pColInfoData, rowIndex), pLinearInfo->bytes);
|
memcpy(pLinearInfo->start.val, colDataGetData(pColInfoData, rowIndex), pLinearInfo->bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -863,19 +863,20 @@ static void removeResults(SArray* pWins, SHashObj* pUpdatedMap) {
|
||||||
|
|
||||||
int32_t compareWinRes(void* pKey, void* data, int32_t index) {
|
int32_t compareWinRes(void* pKey, void* data, int32_t index) {
|
||||||
SArray* res = (SArray*)data;
|
SArray* res = (SArray*)data;
|
||||||
SWinKey* pos = taosArrayGet(res, index);
|
SWinKey* pDataPos = taosArrayGet(res, index);
|
||||||
SResKeyPos* pData = (SResKeyPos*)pKey;
|
SResKeyPos* pRKey = (SResKeyPos*)pKey;
|
||||||
if (*(int64_t*)pData->key == pos->ts) {
|
if (pRKey->groupId > pDataPos->groupId) {
|
||||||
if (pData->groupId > pos->groupId) {
|
|
||||||
return 1;
|
|
||||||
} else if (pData->groupId < pos->groupId) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} else if (*(int64_t*)pData->key > pos->ts) {
|
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (pRKey->groupId < pDataPos->groupId) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
if (*(int64_t*)pRKey->key > pDataPos->ts) {
|
||||||
|
return 1;
|
||||||
|
} else if (*(int64_t*)pRKey->key < pDataPos->ts){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) {
|
static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) {
|
||||||
|
@ -1400,19 +1401,21 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
|
||||||
|
|
||||||
int32_t compareWinKey(void* pKey, void* data, int32_t index) {
|
int32_t compareWinKey(void* pKey, void* data, int32_t index) {
|
||||||
SArray* res = (SArray*)data;
|
SArray* res = (SArray*)data;
|
||||||
SWinKey* pos = taosArrayGet(res, index);
|
SWinKey* pDataPos = taosArrayGet(res, index);
|
||||||
SWinKey* pData = (SWinKey*)pKey;
|
SWinKey* pWKey = (SWinKey*)pKey;
|
||||||
if (pData->ts == pos->ts) {
|
|
||||||
if (pData->groupId > pos->groupId) {
|
if (pWKey->groupId > pDataPos->groupId) {
|
||||||
return 1;
|
|
||||||
} else if (pData->groupId < pos->groupId) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} else if (pData->ts > pos->ts) {
|
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (pWKey->groupId < pDataPos->groupId) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
if (pWKey->ts > pDataPos->ts) {
|
||||||
|
return 1;
|
||||||
|
} else if (pWKey->ts < pDataPos->ts) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t closeStreamIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SInterval* pInterval,
|
static int32_t closeStreamIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SInterval* pInterval,
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
#define LHASH_CAP_RATIO 0.85
|
#define LHASH_CAP_RATIO 0.85
|
||||||
|
|
||||||
|
|
|
@ -504,7 +504,7 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) {
|
||||||
*/
|
*/
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows) {
|
if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows && !IS_VAR_DATA_TYPE(pInputCol->info.type)) {
|
||||||
numOfElem = pInput->numOfRows - pInput->pColumnDataAgg[0]->numOfNull;
|
numOfElem = pInput->numOfRows - pInput->pColumnDataAgg[0]->numOfNull;
|
||||||
ASSERT(numOfElem >= 0);
|
ASSERT(numOfElem >= 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
#include "tpercentile.h"
|
#include "tpercentile.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
#define DEFAULT_NUM_OF_SLOT 1024
|
#define DEFAULT_NUM_OF_SLOT 1024
|
||||||
|
|
||||||
|
@ -367,11 +368,13 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
||||||
pSlot->info.data = NULL;
|
pSlot->info.data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray *pPageIdList = (SArray *)taosHashGet(pBucket->groupPagesMap, &groupId, sizeof(groupId));
|
SArray *pPageIdList;
|
||||||
if (pPageIdList == NULL) {
|
void *p = taosHashGet(pBucket->groupPagesMap, &groupId, sizeof(groupId));
|
||||||
SArray *pList = taosArrayInit(4, sizeof(int32_t));
|
if (p == NULL) {
|
||||||
taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pList, POINTER_BYTES);
|
pPageIdList = taosArrayInit(4, sizeof(int32_t));
|
||||||
pPageIdList = pList;
|
taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pPageIdList, POINTER_BYTES);
|
||||||
|
} else {
|
||||||
|
pPageIdList = *(SArray **)p;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSlot->info.data = getNewBufPage(pBucket->pBuffer, &pageId);
|
pSlot->info.data = getNewBufPage(pBucket->pBuffer, &pageId);
|
||||||
|
|
|
@ -88,11 +88,13 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
if (strlen(path) == 0) {
|
if (strlen(path) == 0) {
|
||||||
strcat(path, "udfd.exe");
|
strcat(path, "C:\\TDengine");
|
||||||
} else {
|
|
||||||
strcat(path, "\\udfd.exe");
|
|
||||||
}
|
}
|
||||||
|
strcat(path, "\\udfd.exe");
|
||||||
#else
|
#else
|
||||||
|
if (strlen(path) == 0) {
|
||||||
|
strcat(path, "/usr/bin");
|
||||||
|
}
|
||||||
strcat(path, "/udfd");
|
strcat(path, "/udfd");
|
||||||
#endif
|
#endif
|
||||||
char *argsUdfd[] = {path, "-c", configDir, NULL};
|
char *argsUdfd[] = {path, "-c", configDir, NULL};
|
||||||
|
|
|
@ -378,6 +378,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
CLONE_NODE_FIELD(pTagIndexCond);
|
CLONE_NODE_FIELD(pTagIndexCond);
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
|
COPY_SCALAR_FIELD(deleteMark);
|
||||||
COPY_SCALAR_FIELD(igExpired);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
CLONE_NODE_LIST_FIELD(pGroupTags);
|
CLONE_NODE_LIST_FIELD(pGroupTags);
|
||||||
COPY_SCALAR_FIELD(groupSort);
|
COPY_SCALAR_FIELD(groupSort);
|
||||||
|
@ -463,6 +464,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p
|
||||||
CLONE_NODE_FIELD(pStateExpr);
|
CLONE_NODE_FIELD(pStateExpr);
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
|
COPY_SCALAR_FIELD(deleteMark);
|
||||||
COPY_SCALAR_FIELD(igExpired);
|
COPY_SCALAR_FIELD(igExpired);
|
||||||
COPY_SCALAR_FIELD(windowAlgo);
|
COPY_SCALAR_FIELD(windowAlgo);
|
||||||
COPY_SCALAR_FIELD(inputTsOrder);
|
COPY_SCALAR_FIELD(inputTsOrder);
|
||||||
|
|
|
@ -819,6 +819,7 @@ static const char* jkWindowLogicPlanTspk = "Tspk";
|
||||||
static const char* jkWindowLogicPlanStateExpr = "StateExpr";
|
static const char* jkWindowLogicPlanStateExpr = "StateExpr";
|
||||||
static const char* jkWindowLogicPlanTriggerType = "TriggerType";
|
static const char* jkWindowLogicPlanTriggerType = "TriggerType";
|
||||||
static const char* jkWindowLogicPlanWatermark = "Watermark";
|
static const char* jkWindowLogicPlanWatermark = "Watermark";
|
||||||
|
static const char* jkWindowLogicPlanDeleteMark = "DeleteMark";
|
||||||
|
|
||||||
static int32_t logicWindowNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SWindowLogicNode* pNode = (const SWindowLogicNode*)pObj;
|
const SWindowLogicNode* pNode = (const SWindowLogicNode*)pObj;
|
||||||
|
@ -860,6 +861,9 @@ static int32_t logicWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanWatermark, pNode->watermark);
|
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanWatermark, pNode->watermark);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkWindowLogicPlanDeleteMark, pNode->deleteMark);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -904,6 +908,9 @@ static int32_t jsonToLogicWindowNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkWindowLogicPlanWatermark, &pNode->watermark);
|
code = tjsonGetBigIntValue(pJson, jkWindowLogicPlanWatermark, &pNode->watermark);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkWindowLogicPlanDeleteMark, &pNode->deleteMark);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2004,6 +2011,7 @@ static const char* jkWindowPhysiPlanTsPk = "TsPk";
|
||||||
static const char* jkWindowPhysiPlanTsEnd = "TsEnd";
|
static const char* jkWindowPhysiPlanTsEnd = "TsEnd";
|
||||||
static const char* jkWindowPhysiPlanTriggerType = "TriggerType";
|
static const char* jkWindowPhysiPlanTriggerType = "TriggerType";
|
||||||
static const char* jkWindowPhysiPlanWatermark = "Watermark";
|
static const char* jkWindowPhysiPlanWatermark = "Watermark";
|
||||||
|
static const char* jkWindowPhysiPlanDeleteMark = "DeleteMark";
|
||||||
static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired";
|
static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired";
|
||||||
static const char* jkWindowPhysiPlanInputTsOrder = "InputTsOrder";
|
static const char* jkWindowPhysiPlanInputTsOrder = "InputTsOrder";
|
||||||
static const char* jkWindowPhysiPlanOutputTsOrder = "outputTsOrder";
|
static const char* jkWindowPhysiPlanOutputTsOrder = "outputTsOrder";
|
||||||
|
@ -2031,6 +2039,9 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanWatermark, pNode->watermark);
|
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanWatermark, pNode->watermark);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanDeleteMark, pNode->deleteMark);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanIgnoreExpired, pNode->igExpired);
|
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanIgnoreExpired, pNode->igExpired);
|
||||||
}
|
}
|
||||||
|
@ -2069,6 +2080,9 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkWindowPhysiPlanWatermark, &pNode->watermark);
|
code = tjsonGetBigIntValue(pJson, jkWindowPhysiPlanWatermark, &pNode->watermark);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkWindowPhysiPlanDeleteMark, &pNode->deleteMark);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanIgnoreExpired, &pNode->igExpired);
|
code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanIgnoreExpired, &pNode->igExpired);
|
||||||
}
|
}
|
||||||
|
@ -3532,6 +3546,18 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToGroupingSetNode(const SJson* pJson, void* pObj) {
|
||||||
|
SGroupingSetNode* pNode = (SGroupingSetNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
tjsonGetNumberValue(pJson, jkGroupingSetType, pNode->groupingSetType, code);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkGroupingSetParameter, &pNode->pParameterList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkOrderByExprExpr = "Expr";
|
static const char* jkOrderByExprExpr = "Expr";
|
||||||
static const char* jkOrderByExprOrder = "Order";
|
static const char* jkOrderByExprOrder = "Order";
|
||||||
static const char* jkOrderByExprNullOrder = "NullOrder";
|
static const char* jkOrderByExprNullOrder = "NullOrder";
|
||||||
|
@ -4729,6 +4755,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToRealTableNode(pJson, pObj);
|
return jsonToRealTableNode(pJson, pObj);
|
||||||
case QUERY_NODE_TEMP_TABLE:
|
case QUERY_NODE_TEMP_TABLE:
|
||||||
return jsonToTempTableNode(pJson, pObj);
|
return jsonToTempTableNode(pJson, pObj);
|
||||||
|
case QUERY_NODE_GROUPING_SET:
|
||||||
|
return jsonToGroupingSetNode(pJson, pObj);
|
||||||
case QUERY_NODE_ORDER_BY_EXPR:
|
case QUERY_NODE_ORDER_BY_EXPR:
|
||||||
return jsonToOrderByExprNode(pJson, pObj);
|
return jsonToOrderByExprNode(pJson, pObj);
|
||||||
case QUERY_NODE_LIMIT:
|
case QUERY_NODE_LIMIT:
|
||||||
|
|
|
@ -2607,6 +2607,7 @@ enum {
|
||||||
PHY_WINDOW_CODE_TS_END,
|
PHY_WINDOW_CODE_TS_END,
|
||||||
PHY_WINDOW_CODE_TRIGGER_TYPE,
|
PHY_WINDOW_CODE_TRIGGER_TYPE,
|
||||||
PHY_WINDOW_CODE_WATERMARK,
|
PHY_WINDOW_CODE_WATERMARK,
|
||||||
|
PHY_WINDOW_CODE_DELETE_MARK,
|
||||||
PHY_WINDOW_CODE_IG_EXPIRED,
|
PHY_WINDOW_CODE_IG_EXPIRED,
|
||||||
PHY_WINDOW_CODE_INPUT_TS_ORDER,
|
PHY_WINDOW_CODE_INPUT_TS_ORDER,
|
||||||
PHY_WINDOW_CODE_OUTPUT_TS_ORDER,
|
PHY_WINDOW_CODE_OUTPUT_TS_ORDER,
|
||||||
|
@ -2635,6 +2636,9 @@ static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeI64(pEncoder, PHY_WINDOW_CODE_WATERMARK, pNode->watermark);
|
code = tlvEncodeI64(pEncoder, PHY_WINDOW_CODE_WATERMARK, pNode->watermark);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tlvEncodeI64(pEncoder, PHY_WINDOW_CODE_DELETE_MARK, pNode->deleteMark);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_IG_EXPIRED, pNode->igExpired);
|
code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_IG_EXPIRED, pNode->igExpired);
|
||||||
}
|
}
|
||||||
|
@ -2679,6 +2683,9 @@ static int32_t msgToPhysiWindowNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
case PHY_WINDOW_CODE_WATERMARK:
|
case PHY_WINDOW_CODE_WATERMARK:
|
||||||
code = tlvDecodeI64(pTlv, &pNode->watermark);
|
code = tlvDecodeI64(pTlv, &pNode->watermark);
|
||||||
break;
|
break;
|
||||||
|
case PHY_WINDOW_CODE_DELETE_MARK:
|
||||||
|
code = tlvDecodeI64(pTlv, &pNode->deleteMark);
|
||||||
|
break;
|
||||||
case PHY_WINDOW_CODE_IG_EXPIRED:
|
case PHY_WINDOW_CODE_IG_EXPIRED:
|
||||||
code = tlvDecodeI8(pTlv, &pNode->igExpired);
|
code = tlvDecodeI8(pTlv, &pNode->igExpired);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -596,6 +596,13 @@ static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) {
|
||||||
nodesDestroyNode(pNode->pTsEnd);
|
nodesDestroyNode(pNode->pTsEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroyPartitionPhysiNode(SPartitionPhysiNode* pNode) {
|
||||||
|
destroyPhysiNode((SPhysiNode*)pNode);
|
||||||
|
nodesDestroyList(pNode->pExprs);
|
||||||
|
nodesDestroyList(pNode->pPartitionKeys);
|
||||||
|
nodesDestroyList(pNode->pTargets);
|
||||||
|
}
|
||||||
|
|
||||||
static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
|
static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
|
||||||
destroyPhysiNode((SPhysiNode*)pNode);
|
destroyPhysiNode((SPhysiNode*)pNode);
|
||||||
nodesDestroyList(pNode->pScanCols);
|
nodesDestroyList(pNode->pScanCols);
|
||||||
|
@ -733,6 +740,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyList(pOptions->pWatermark);
|
nodesDestroyList(pOptions->pWatermark);
|
||||||
nodesDestroyList(pOptions->pRollupFuncs);
|
nodesDestroyList(pOptions->pRollupFuncs);
|
||||||
nodesDestroyList(pOptions->pSma);
|
nodesDestroyList(pOptions->pSma);
|
||||||
|
nodesDestroyList(pOptions->pDeleteMark);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_INDEX_OPTIONS: {
|
case QUERY_NODE_INDEX_OPTIONS: {
|
||||||
|
@ -750,6 +758,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
SStreamOptions* pOptions = (SStreamOptions*)pNode;
|
SStreamOptions* pOptions = (SStreamOptions*)pNode;
|
||||||
nodesDestroyNode(pOptions->pDelay);
|
nodesDestroyNode(pOptions->pDelay);
|
||||||
nodesDestroyNode(pOptions->pWatermark);
|
nodesDestroyNode(pOptions->pWatermark);
|
||||||
|
nodesDestroyNode(pOptions->pDeleteMark);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LEFT_VALUE: // no pointer field
|
case QUERY_NODE_LEFT_VALUE: // no pointer field
|
||||||
|
@ -906,6 +915,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pNode;
|
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pNode;
|
||||||
nodesDestroyNode((SNode*)pStmt->pOptions);
|
nodesDestroyNode((SNode*)pStmt->pOptions);
|
||||||
nodesDestroyNode(pStmt->pQuery);
|
nodesDestroyNode(pStmt->pQuery);
|
||||||
|
nodesDestroyList(pStmt->pTags);
|
||||||
|
nodesDestroyNode(pStmt->pSubtable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_DROP_STREAM_STMT: // no pointer field
|
case QUERY_NODE_DROP_STREAM_STMT: // no pointer field
|
||||||
|
@ -1021,6 +1032,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyNode(pLogicNode->pTagIndexCond);
|
nodesDestroyNode(pLogicNode->pTagIndexCond);
|
||||||
taosArrayDestroyEx(pLogicNode->pSmaIndexes, destroySmaIndex);
|
taosArrayDestroyEx(pLogicNode->pSmaIndexes, destroySmaIndex);
|
||||||
nodesDestroyList(pLogicNode->pGroupTags);
|
nodesDestroyList(pLogicNode->pGroupTags);
|
||||||
|
nodesDestroyList(pLogicNode->pTags);
|
||||||
|
nodesDestroyNode(pLogicNode->pSubtable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_JOIN: {
|
case QUERY_NODE_LOGIC_PLAN_JOIN: {
|
||||||
|
@ -1093,6 +1106,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
SPartitionLogicNode* pLogicNode = (SPartitionLogicNode*)pNode;
|
SPartitionLogicNode* pLogicNode = (SPartitionLogicNode*)pNode;
|
||||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||||
nodesDestroyList(pLogicNode->pPartitionKeys);
|
nodesDestroyList(pLogicNode->pPartitionKeys);
|
||||||
|
nodesDestroyList(pLogicNode->pTags);
|
||||||
|
nodesDestroyNode(pLogicNode->pSubtable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: {
|
case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: {
|
||||||
|
@ -1123,10 +1138,10 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN:
|
|
||||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: {
|
case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: {
|
||||||
SLastRowScanPhysiNode* pPhyNode = (SLastRowScanPhysiNode*)pNode;
|
SLastRowScanPhysiNode* pPhyNode = (SLastRowScanPhysiNode*)pNode;
|
||||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||||
nodesDestroyList(pPhyNode->pGroupTags);
|
nodesDestroyList(pPhyNode->pGroupTags);
|
||||||
|
@ -1140,6 +1155,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
destroyScanPhysiNode((SScanPhysiNode*)pNode);
|
||||||
nodesDestroyList(pPhyNode->pDynamicScanFuncs);
|
nodesDestroyList(pPhyNode->pDynamicScanFuncs);
|
||||||
nodesDestroyList(pPhyNode->pGroupTags);
|
nodesDestroyList(pPhyNode->pGroupTags);
|
||||||
|
nodesDestroyList(pPhyNode->pTags);
|
||||||
|
nodesDestroyNode(pPhyNode->pSubtable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: {
|
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: {
|
||||||
|
@ -1216,13 +1233,15 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
nodesDestroyNode(pPhyNode->pStateKey);
|
nodesDestroyNode(pPhyNode->pStateKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
case QUERY_NODE_PHYSICAL_PLAN_PARTITION: {
|
||||||
|
destroyPartitionPhysiNode((SPartitionPhysiNode*)pNode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: {
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: {
|
||||||
SPartitionPhysiNode* pPhyNode = (SPartitionPhysiNode*)pNode;
|
SStreamPartitionPhysiNode* pPhyNode = (SStreamPartitionPhysiNode*)pNode;
|
||||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
destroyPartitionPhysiNode((SPartitionPhysiNode*)pPhyNode);
|
||||||
nodesDestroyList(pPhyNode->pExprs);
|
nodesDestroyList(pPhyNode->pTags);
|
||||||
nodesDestroyList(pPhyNode->pPartitionKeys);
|
nodesDestroyNode(pPhyNode->pSubtable);
|
||||||
nodesDestroyList(pPhyNode->pTargets);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: {
|
case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: {
|
||||||
|
|
|
@ -72,7 +72,8 @@ typedef enum ETableOptionType {
|
||||||
TABLE_OPTION_WATERMARK,
|
TABLE_OPTION_WATERMARK,
|
||||||
TABLE_OPTION_ROLLUP,
|
TABLE_OPTION_ROLLUP,
|
||||||
TABLE_OPTION_TTL,
|
TABLE_OPTION_TTL,
|
||||||
TABLE_OPTION_SMA
|
TABLE_OPTION_SMA,
|
||||||
|
TABLE_OPTION_DELETE_MARK
|
||||||
} ETableOptionType;
|
} ETableOptionType;
|
||||||
|
|
||||||
typedef struct SAlterOption {
|
typedef struct SAlterOption {
|
||||||
|
|
|
@ -362,6 +362,7 @@ table_options(A) ::= table_options(B) WATERMARK duration_list(C).
|
||||||
table_options(A) ::= table_options(B) ROLLUP NK_LP rollup_func_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
|
table_options(A) ::= table_options(B) ROLLUP NK_LP rollup_func_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
|
||||||
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
|
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
|
||||||
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
|
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
|
||||||
|
table_options(A) ::= table_options(B) DELETE_MARK duration_list(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELETE_MARK, C); }
|
||||||
|
|
||||||
alter_table_options(A) ::= alter_table_option(B). { A = createAlterTableOptions(pCxt); A = setTableOption(pCxt, A, B.type, &B.val); }
|
alter_table_options(A) ::= alter_table_option(B). { A = createAlterTableOptions(pCxt); A = setTableOption(pCxt, A, B.type, &B.val); }
|
||||||
alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableOption(pCxt, B, C.type, &C.val); }
|
alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableOption(pCxt, B, C.type, &C.val); }
|
||||||
|
@ -475,8 +476,9 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
|
||||||
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
||||||
|
|
||||||
sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); }
|
sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); }
|
||||||
sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
sma_stream_opt(A) ::= sma_stream_opt(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
sma_stream_opt(A) ::= sma_stream_opt(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
|
sma_stream_opt(A) ::= sma_stream_opt(B) DELETE_MARK duration_literal(C). { ((SStreamOptions*)B)->pDeleteMark = releaseRawExprNode(pCxt, C); A = B; }
|
||||||
|
|
||||||
/************************************************ create/drop topic ***************************************************/
|
/************************************************ create/drop topic ***************************************************/
|
||||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_or_subquery(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
|
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_or_subquery(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
|
||||||
|
|
|
@ -1124,6 +1124,9 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
|
||||||
case TABLE_OPTION_SMA:
|
case TABLE_OPTION_SMA:
|
||||||
((STableOptions*)pOptions)->pSma = pVal;
|
((STableOptions*)pOptions)->pSma = pVal;
|
||||||
break;
|
break;
|
||||||
|
case TABLE_OPTION_DELETE_MARK:
|
||||||
|
((STableOptions*)pOptions)->pDeleteMark = pVal;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef struct SInsertParseContext {
|
||||||
SBoundColInfo tags; // for stmt
|
SBoundColInfo tags; // for stmt
|
||||||
bool missCache;
|
bool missCache;
|
||||||
bool usingDuplicateTable;
|
bool usingDuplicateTable;
|
||||||
|
bool forceUpdate;
|
||||||
} SInsertParseContext;
|
} SInsertParseContext;
|
||||||
|
|
||||||
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
||||||
|
@ -798,6 +799,11 @@ static int32_t getTableVgroup(SParseContext* pCxt, SVnodeModifOpStmt* pStmt, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) {
|
static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) {
|
||||||
|
if (pCxt->forceUpdate) {
|
||||||
|
pCxt->missCache = true;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
||||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||||
code = getTableMeta(pCxt, &pStmt->targetTableName, false, &pStmt->pTableMeta, &pCxt->missCache);
|
code = getTableMeta(pCxt, &pStmt->targetTableName, false, &pStmt->pTableMeta, &pCxt->missCache);
|
||||||
|
@ -813,6 +819,11 @@ static int32_t preParseUsingTableName(SInsertParseContext* pCxt, SVnodeModifOpSt
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) {
|
static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) {
|
||||||
|
if (pCxt->forceUpdate) {
|
||||||
|
pCxt->missCache = true;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
||||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||||
code = getTableMeta(pCxt, &pStmt->usingTableName, true, &pStmt->pTableMeta, &pCxt->missCache);
|
code = getTableMeta(pCxt, &pStmt->usingTableName, true, &pStmt->pTableMeta, &pCxt->missCache);
|
||||||
|
@ -1086,7 +1097,11 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
|
||||||
if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) {
|
if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
||||||
}
|
}
|
||||||
pVal->value.pData = pToken->z;
|
pVal->value.pData = taosMemoryMalloc(pToken->n);
|
||||||
|
if (NULL == pVal->value.pData) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
memcpy(pVal->value.pData, pToken->z, pToken->n);
|
||||||
pVal->value.nData = pToken->n;
|
pVal->value.nData = pToken->n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1128,11 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
|
||||||
if (pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
if (pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z);
|
return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z);
|
||||||
}
|
}
|
||||||
pVal->value.pData = pToken->z;
|
pVal->value.pData = taosMemoryMalloc(pToken->n);
|
||||||
|
if (NULL == pVal->value.pData) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
memcpy(pVal->value.pData, pToken->z, pToken->n);
|
||||||
pVal->value.nData = pToken->n;
|
pVal->value.nData = pToken->n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1157,7 +1176,7 @@ static void clearColValArray(SArray* pCols) {
|
||||||
int32_t num = taosArrayGetSize(pCols);
|
int32_t num = taosArrayGetSize(pCols);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SColVal* pCol = taosArrayGet(pCols, i);
|
SColVal* pCol = taosArrayGet(pCols, i);
|
||||||
if (TSDB_DATA_TYPE_NCHAR == pCol->type) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
taosMemoryFreeClear(pCol->value.pData);
|
taosMemoryFreeClear(pCol->value.pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1827,12 +1846,11 @@ static int32_t setNextStageInfo(SInsertParseContext* pCxt, SQuery* pQuery, SCata
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatalogReq, const SMetaData* pMetaData) {
|
int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatalogReq, const SMetaData* pMetaData) {
|
||||||
SInsertParseContext context = {
|
SInsertParseContext context = {.pComCxt = pCxt,
|
||||||
.pComCxt = pCxt,
|
.msg = {.buf = pCxt->pMsg, .len = pCxt->msgLen},
|
||||||
.msg = {.buf = pCxt->pMsg, .len = pCxt->msgLen},
|
.missCache = false,
|
||||||
.missCache = false,
|
.usingDuplicateTable = false,
|
||||||
.usingDuplicateTable = false,
|
.forceUpdate = (NULL != pCatalogReq ? pCatalogReq->forceUpdate : false)};
|
||||||
};
|
|
||||||
|
|
||||||
int32_t code = initInsertQuery(&context, pCatalogReq, pMetaData, pQuery);
|
int32_t code = initInsertQuery(&context, pCatalogReq, pMetaData, pQuery);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -1082,11 +1082,20 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void resetColValues(SArray* pValues) {
|
||||||
|
int32_t num = taosArrayGetSize(pValues);
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SColVal* pVal = taosArrayGet(pValues, i);
|
||||||
|
pVal->flag = CV_FLAG_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t insGetTableDataCxt(SHashObj* pHash, void* id, int32_t idLen, STableMeta* pTableMeta,
|
int32_t insGetTableDataCxt(SHashObj* pHash, void* id, int32_t idLen, STableMeta* pTableMeta,
|
||||||
SVCreateTbReq** pCreateTbReq, STableDataCxt** pTableCxt, bool colMode) {
|
SVCreateTbReq** pCreateTbReq, STableDataCxt** pTableCxt, bool colMode) {
|
||||||
STableDataCxt** tmp = (STableDataCxt**)taosHashGet(pHash, id, idLen);
|
STableDataCxt** tmp = (STableDataCxt**)taosHashGet(pHash, id, idLen);
|
||||||
if (NULL != tmp) {
|
if (NULL != tmp) {
|
||||||
*pTableCxt = *tmp;
|
*pTableCxt = *tmp;
|
||||||
|
resetColValues((*pTableCxt)->pValues);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
int32_t code = createTableDataCxt(pTableMeta, pCreateTbReq, pTableCxt, colMode);
|
int32_t code = createTableDataCxt(pTableMeta, pCreateTbReq, pTableCxt, colMode);
|
||||||
|
|
|
@ -74,6 +74,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"DATABASES", TK_DATABASES},
|
{"DATABASES", TK_DATABASES},
|
||||||
{"DBS", TK_DBS},
|
{"DBS", TK_DBS},
|
||||||
{"DELETE", TK_DELETE},
|
{"DELETE", TK_DELETE},
|
||||||
|
{"DELETE_MARK", TK_DELETE_MARK},
|
||||||
{"DESC", TK_DESC},
|
{"DESC", TK_DESC},
|
||||||
{"DESCRIBE", TK_DESCRIBE},
|
{"DESCRIBE", TK_DESCRIBE},
|
||||||
{"DISTINCT", TK_DISTINCT},
|
{"DISTINCT", TK_DISTINCT},
|
||||||
|
|
|
@ -3804,10 +3804,11 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
||||||
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int32_t val, int32_t minVal,
|
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int64_t val, int64_t minVal,
|
||||||
int32_t maxVal) {
|
int64_t maxVal) {
|
||||||
if (val >= 0 && (val < minVal || val > maxVal)) {
|
if (val >= 0 && (val < minVal || val > maxVal)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Invalid option %s: %d valid range: [%d, %d]", pName, val,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code,
|
||||||
|
"Invalid option %s: %" PRId64 " valid range: [%" PRId64 ", %" PRId64 "]", pName, val,
|
||||||
minVal, maxVal);
|
minVal, maxVal);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3818,8 +3819,8 @@ static int32_t checkDbRangeOption(STranslateContext* pCxt, const char* pName, in
|
||||||
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_DB_OPTION, pName, val, minVal, maxVal);
|
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_DB_OPTION, pName, val, minVal, maxVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkTableRangeOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t minVal,
|
static int32_t checkTableRangeOption(STranslateContext* pCxt, const char* pName, int64_t val, int64_t minVal,
|
||||||
int32_t maxVal) {
|
int64_t maxVal) {
|
||||||
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_TABLE_OPTION, pName, val, minVal, maxVal);
|
return checkRangeOption(pCxt, TSDB_CODE_PAR_INVALID_TABLE_OPTION, pName, val, minVal, maxVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3878,12 +3879,17 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
pOptions->keep[2] = getBigintFromValueNode((SValueNode*)nodesListGetNode(pOptions->pKeep, 2));
|
pOptions->keep[2] = getBigintFromValueNode((SValueNode*)nodesListGetNode(pOptions->pKeep, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t tsdbMaxKeep = TSDB_MAX_KEEP;
|
||||||
|
if (pOptions->precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
tsdbMaxKeep = TSDB_MAX_KEEP_NS;
|
||||||
|
}
|
||||||
|
|
||||||
if (pOptions->keep[0] < TSDB_MIN_KEEP || pOptions->keep[1] < TSDB_MIN_KEEP || pOptions->keep[2] < TSDB_MIN_KEEP ||
|
if (pOptions->keep[0] < TSDB_MIN_KEEP || pOptions->keep[1] < TSDB_MIN_KEEP || pOptions->keep[2] < TSDB_MIN_KEEP ||
|
||||||
pOptions->keep[0] > TSDB_MAX_KEEP || pOptions->keep[1] > TSDB_MAX_KEEP || pOptions->keep[2] > TSDB_MAX_KEEP) {
|
pOptions->keep[0] > tsdbMaxKeep || pOptions->keep[1] > tsdbMaxKeep || pOptions->keep[2] > tsdbMaxKeep) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
"Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]",
|
"Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]",
|
||||||
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP,
|
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP,
|
||||||
TSDB_MAX_KEEP);
|
tsdbMaxKeep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
||||||
|
@ -4035,7 +4041,10 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
||||||
TSDB_MAX_MINROWS_FBLOCK);
|
TSDB_MAX_MINROWS_FBLOCK);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbKeepOption(pCxt, pOptions);
|
code = checkDbPrecisionOption(pCxt, pOptions);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkDbKeepOption(pCxt, pOptions); // use precision
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
code = checkDbRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
||||||
|
@ -4048,9 +4057,6 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
||||||
code = checkDbRangeOption(pCxt, "tsdbPagesize", pOptions->tsdbPageSize, TSDB_MIN_TSDB_PAGESIZE,
|
code = checkDbRangeOption(pCxt, "tsdbPagesize", pOptions->tsdbPageSize, TSDB_MIN_TSDB_PAGESIZE,
|
||||||
TSDB_MAX_TSDB_PAGESIZE);
|
TSDB_MAX_TSDB_PAGESIZE);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = checkDbPrecisionOption(pCxt, pOptions);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkDbEnumOption(pCxt, "replications", pOptions->replica, TSDB_MIN_DB_REPLICA, TSDB_MAX_DB_REPLICA);
|
code = checkDbEnumOption(pCxt, "replications", pOptions->replica, TSDB_MIN_DB_REPLICA, TSDB_MAX_DB_REPLICA);
|
||||||
}
|
}
|
||||||
|
@ -4463,6 +4469,37 @@ static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t getTableDeleteMarkOption(STranslateContext* pCxt, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||||
|
return getTableDelayOrWatermarkOption(pCxt, "delete_mark", TSDB_MIN_ROLLUP_DELETE_MARK, TSDB_MAX_ROLLUP_DELETE_MARK,
|
||||||
|
pVal, pMaxDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkTableDeleteMarkOption(STranslateContext* pCxt, STableOptions* pOptions, bool createStable,
|
||||||
|
SDbCfgInfo* pDbCfg) {
|
||||||
|
if (NULL == pOptions->pDeleteMark) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!createStable || NULL == pDbCfg->pRetensions) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION,
|
||||||
|
"Invalid option delete_mark: Only supported for create super table in databases "
|
||||||
|
"configured with the 'RETENTIONS' option");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LIST_LENGTH(pOptions->pDeleteMark) > 2) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "Invalid option delete_mark");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code =
|
||||||
|
getTableDeleteMarkOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pDeleteMark, 0), &pOptions->deleteMark1);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && 2 == LIST_LENGTH(pOptions->pDeleteMark)) {
|
||||||
|
code =
|
||||||
|
getTableDeleteMarkOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pDeleteMark, 1), &pOptions->deleteMark2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, bool createStable) {
|
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, bool createStable) {
|
||||||
if (NULL != strchr(pStmt->tableName, '.')) {
|
if (NULL != strchr(pStmt->tableName, '.')) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME,
|
||||||
|
@ -4482,6 +4519,9 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableWatermarkOption(pCxt, pStmt->pOptions, createStable, &dbCfg);
|
code = checkTableWatermarkOption(pCxt, pStmt->pOptions, createStable, &dbCfg);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkTableDeleteMarkOption(pCxt, pStmt->pOptions, createStable, &dbCfg);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs, createStable, &dbCfg);
|
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs, createStable, &dbCfg);
|
||||||
}
|
}
|
||||||
|
@ -4749,6 +4789,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
|
||||||
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
||||||
pReq->watermark1 = pStmt->pOptions->watermark1;
|
pReq->watermark1 = pStmt->pOptions->watermark1;
|
||||||
pReq->watermark2 = pStmt->pOptions->watermark2;
|
pReq->watermark2 = pStmt->pOptions->watermark2;
|
||||||
|
pReq->deleteMark1 = pStmt->pOptions->deleteMark1;
|
||||||
|
pReq->deleteMark2 = pStmt->pOptions->deleteMark2;
|
||||||
pReq->colVer = 1;
|
pReq->colVer = 1;
|
||||||
pReq->tagVer = 1;
|
pReq->tagVer = 1;
|
||||||
pReq->source = TD_REQ_FROM_APP;
|
pReq->source = TD_REQ_FROM_APP;
|
||||||
|
@ -5144,20 +5186,34 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
|
||||||
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval);
|
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval);
|
||||||
pReq->slidingUnit =
|
pReq->slidingUnit =
|
||||||
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit);
|
(NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit);
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (NULL != pStmt->pOptions->pStreamOptions) {
|
if (NULL != pStmt->pOptions->pStreamOptions) {
|
||||||
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
||||||
pReq->maxDelay = (NULL != pStreamOpt->pDelay ? ((SValueNode*)pStreamOpt->pDelay)->datum.i : -1);
|
if (NULL != pStreamOpt->pDelay) {
|
||||||
pReq->watermark = (NULL != pStreamOpt->pWatermark ? ((SValueNode*)pStreamOpt->pWatermark)->datum.i
|
code = getTableMaxDelayOption(pCxt, (SValueNode*)pStreamOpt->pDelay, &pReq->maxDelay);
|
||||||
: TSDB_DEFAULT_ROLLUP_WATERMARK);
|
} else {
|
||||||
if (pReq->watermark < TSDB_MIN_ROLLUP_WATERMARK) {
|
pReq->maxDelay = -1;
|
||||||
pReq->watermark = TSDB_MIN_ROLLUP_WATERMARK;
|
|
||||||
}
|
}
|
||||||
if (pReq->watermark > TSDB_MAX_ROLLUP_WATERMARK) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pReq->watermark = TSDB_MAX_ROLLUP_WATERMARK;
|
if (NULL != pStreamOpt->pWatermark) {
|
||||||
|
code = getTableWatermarkOption(pCxt, (SValueNode*)pStreamOpt->pWatermark, &pReq->watermark);
|
||||||
|
} else {
|
||||||
|
pReq->watermark = TSDB_DEFAULT_ROLLUP_WATERMARK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
if (NULL != pStreamOpt->pDeleteMark) {
|
||||||
|
code = getTableDeleteMarkOption(pCxt, (SValueNode*)pStreamOpt->pDeleteMark, &pReq->deleteMark);
|
||||||
|
} else {
|
||||||
|
pReq->deleteMark = TSDB_DEFAULT_ROLLUP_DELETE_MARK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = getSmaIndexDstVgId(pCxt, pStmt->dbName, pStmt->tableName, &pReq->dstVgId);
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = getSmaIndexDstVgId(pCxt, pStmt->dbName, pStmt->tableName, &pReq->dstVgId);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = getSmaIndexSql(pCxt, &pReq->sql, &pReq->sqlLen);
|
code = getSmaIndexSql(pCxt, &pReq->sql, &pReq->sqlLen);
|
||||||
}
|
}
|
||||||
|
@ -5185,16 +5241,6 @@ static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pS
|
||||||
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding);
|
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pStreamOptions) {
|
|
||||||
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
|
|
||||||
if (NULL != pStreamOpt->pWatermark) {
|
|
||||||
code = doTranslateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pStreamOpt->pDelay) {
|
|
||||||
code = doTranslateValue(pCxt, (SValueNode*)pStreamOpt->pDelay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -375,9 +375,68 @@ TEST_F(ParserInitialCTest, createFunction) {
|
||||||
TEST_F(ParserInitialCTest, createSmaIndex) {
|
TEST_F(ParserInitialCTest, createSmaIndex) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
SMCreateSmaReq expect = {0};
|
||||||
|
|
||||||
|
auto setCreateSmacReq = [&](const char* pIndexName, const char* pStbName, int64_t interval, int8_t intervalUnit,
|
||||||
|
int64_t offset = 0, int64_t sliding = -1, int8_t slidingUnit = -1, int8_t igExists = 0) {
|
||||||
|
memset(&expect, 0, sizeof(SMCreateSmaReq));
|
||||||
|
strcpy(expect.name, pIndexName);
|
||||||
|
strcpy(expect.stb, pStbName);
|
||||||
|
expect.igExists = igExists;
|
||||||
|
expect.intervalUnit = intervalUnit;
|
||||||
|
expect.slidingUnit = slidingUnit < 0 ? intervalUnit : slidingUnit;
|
||||||
|
expect.timezone = 0;
|
||||||
|
expect.dstVgId = 1;
|
||||||
|
expect.interval = interval;
|
||||||
|
expect.offset = offset;
|
||||||
|
expect.sliding = sliding < 0 ? interval : sliding;
|
||||||
|
expect.maxDelay = -1;
|
||||||
|
expect.watermark = TSDB_DEFAULT_ROLLUP_WATERMARK;
|
||||||
|
expect.deleteMark = TSDB_DEFAULT_ROLLUP_DELETE_MARK;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto setOptionsForCreateSmacReq = [&](int64_t maxDelay, int64_t watermark, int64_t deleteMark) {
|
||||||
|
expect.maxDelay = maxDelay;
|
||||||
|
expect.watermark = watermark;
|
||||||
|
expect.deleteMark = deleteMark;
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_INDEX_STMT);
|
||||||
|
SMCreateSmaReq req = {0};
|
||||||
|
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
|
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
||||||
|
ASSERT_EQ(std::string(req.stb), std::string(expect.stb));
|
||||||
|
ASSERT_EQ(req.igExists, expect.igExists);
|
||||||
|
ASSERT_EQ(req.intervalUnit, expect.intervalUnit);
|
||||||
|
ASSERT_EQ(req.slidingUnit, expect.slidingUnit);
|
||||||
|
ASSERT_EQ(req.timezone, expect.timezone);
|
||||||
|
ASSERT_EQ(req.dstVgId, expect.dstVgId);
|
||||||
|
ASSERT_EQ(req.interval, expect.interval);
|
||||||
|
ASSERT_EQ(req.offset, expect.offset);
|
||||||
|
ASSERT_EQ(req.sliding, expect.sliding);
|
||||||
|
ASSERT_EQ(req.maxDelay, expect.maxDelay);
|
||||||
|
ASSERT_EQ(req.watermark, expect.watermark);
|
||||||
|
ASSERT_EQ(req.deleteMark, expect.deleteMark);
|
||||||
|
ASSERT_GT(req.exprLen, 0);
|
||||||
|
ASSERT_EQ(req.tagsFilterLen, 0);
|
||||||
|
ASSERT_GT(req.sqlLen, 0);
|
||||||
|
ASSERT_GT(req.astLen, 0);
|
||||||
|
ASSERT_NE(req.expr, nullptr);
|
||||||
|
ASSERT_EQ(req.tagsFilter, nullptr);
|
||||||
|
ASSERT_NE(req.sql, nullptr);
|
||||||
|
ASSERT_NE(req.ast, nullptr);
|
||||||
|
tFreeSMCreateSmaReq(&req);
|
||||||
|
});
|
||||||
|
|
||||||
|
setCreateSmacReq("0.test.index1", "0.test.t1", 10 * MILLISECOND_PER_SECOND, 's');
|
||||||
run("CREATE SMA INDEX index1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)");
|
run("CREATE SMA INDEX index1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)");
|
||||||
|
|
||||||
run("CREATE SMA INDEX index2 ON st1 FUNCTION(MAX(c1), MIN(tag1)) INTERVAL(10s)");
|
setCreateSmacReq("0.test.index2", "0.test.st1", 5 * MILLISECOND_PER_SECOND, 's');
|
||||||
|
setOptionsForCreateSmacReq(10 * MILLISECOND_PER_SECOND, 20 * MILLISECOND_PER_SECOND, 1000 * MILLISECOND_PER_SECOND);
|
||||||
|
run("CREATE SMA INDEX index2 ON st1 FUNCTION(MAX(c1), MIN(tag1)) INTERVAL(5s) WATERMARK 20s MAX_DELAY 10s "
|
||||||
|
"DELETE_MARK 1000s");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createMnode) {
|
TEST_F(ParserInitialCTest, createMnode) {
|
||||||
|
@ -408,23 +467,26 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
memset(&expect, 0, sizeof(SMCreateStbReq));
|
memset(&expect, 0, sizeof(SMCreateStbReq));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setCreateStbReqFunc = [&](const char* pDbName, const char* pTbName, int8_t igExists = 0, int64_t delay1 = -1,
|
auto setCreateStbReqFunc =
|
||||||
int64_t delay2 = -1, int64_t watermark1 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
[&](const char* pDbName, const char* pTbName, int8_t igExists = 0, int64_t delay1 = -1, int64_t delay2 = -1,
|
||||||
int64_t watermark2 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
int64_t watermark1 = TSDB_DEFAULT_ROLLUP_WATERMARK, int64_t watermark2 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
||||||
int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) {
|
int64_t deleteMark1 = TSDB_DEFAULT_ROLLUP_DELETE_MARK, int64_t deleteMark2 = TSDB_DEFAULT_ROLLUP_DELETE_MARK,
|
||||||
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.%s.%s", pDbName, pTbName);
|
int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) {
|
||||||
expect.name[len] = '\0';
|
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.%s.%s", pDbName, pTbName);
|
||||||
expect.igExists = igExists;
|
expect.name[len] = '\0';
|
||||||
expect.delay1 = delay1;
|
expect.igExists = igExists;
|
||||||
expect.delay2 = delay2;
|
expect.delay1 = delay1;
|
||||||
expect.watermark1 = watermark1;
|
expect.delay2 = delay2;
|
||||||
expect.watermark2 = watermark2;
|
expect.watermark1 = watermark1;
|
||||||
// expect.ttl = ttl;
|
expect.watermark2 = watermark2;
|
||||||
if (nullptr != pComment) {
|
expect.deleteMark1 = deleteMark1;
|
||||||
expect.pComment = strdup(pComment);
|
expect.deleteMark2 = deleteMark2;
|
||||||
expect.commentLen = strlen(pComment);
|
// expect.ttl = ttl;
|
||||||
}
|
if (nullptr != pComment) {
|
||||||
};
|
expect.pComment = strdup(pComment);
|
||||||
|
expect.commentLen = strlen(pComment);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto addFieldToCreateStbReqFunc = [&](bool col, const char* pFieldName, uint8_t type, int32_t bytes = 0,
|
auto addFieldToCreateStbReqFunc = [&](bool col, const char* pFieldName, uint8_t type, int32_t bytes = 0,
|
||||||
int8_t flags = COL_SMA_ON) {
|
int8_t flags = COL_SMA_ON) {
|
||||||
|
@ -511,7 +573,8 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
clearCreateStbReq();
|
clearCreateStbReq();
|
||||||
|
|
||||||
setCreateStbReqFunc("rollup_db", "t1", 1, 100 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_MINUTE, 10,
|
setCreateStbReqFunc("rollup_db", "t1", 1, 100 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_MINUTE, 10,
|
||||||
1 * MILLISECOND_PER_MINUTE, 100, "test create table");
|
1 * MILLISECOND_PER_MINUTE, 1000 * MILLISECOND_PER_SECOND, 200 * MILLISECOND_PER_MINUTE, 100,
|
||||||
|
"test create table");
|
||||||
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
||||||
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
||||||
addFieldToCreateStbReqFunc(true, "c2", TSDB_DATA_TYPE_UINT);
|
addFieldToCreateStbReqFunc(true, "c2", TSDB_DATA_TYPE_UINT);
|
||||||
|
@ -549,7 +612,8 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
||||||
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
||||||
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) MAX_DELAY 100s,10m WATERMARK 10a,1m");
|
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) MAX_DELAY 100s,10m WATERMARK 10a,1m "
|
||||||
|
"DELETE_MARK 1000s,200m");
|
||||||
clearCreateStbReq();
|
clearCreateStbReq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -702,6 +702,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
||||||
if (pCxt->pPlanCxt->streamQuery) {
|
if (pCxt->pPlanCxt->streamQuery) {
|
||||||
pWindow->triggerType = pCxt->pPlanCxt->triggerType;
|
pWindow->triggerType = pCxt->pPlanCxt->triggerType;
|
||||||
pWindow->watermark = pCxt->pPlanCxt->watermark;
|
pWindow->watermark = pCxt->pPlanCxt->watermark;
|
||||||
|
pWindow->deleteMark = pCxt->pPlanCxt->deleteMark;
|
||||||
pWindow->igExpired = pCxt->pPlanCxt->igExpired;
|
pWindow->igExpired = pCxt->pPlanCxt->igExpired;
|
||||||
}
|
}
|
||||||
pWindow->inputTsOrder = ORDER_ASC;
|
pWindow->inputTsOrder = ORDER_ASC;
|
||||||
|
|
|
@ -330,6 +330,7 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) {
|
||||||
pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit;
|
pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit;
|
||||||
pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType;
|
pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType;
|
||||||
pScan->watermark = ((SWindowLogicNode*)pParent)->watermark;
|
pScan->watermark = ((SWindowLogicNode*)pParent)->watermark;
|
||||||
|
pScan->deleteMark = ((SWindowLogicNode*)pParent)->deleteMark;
|
||||||
pScan->igExpired = ((SWindowLogicNode*)pParent)->igExpired;
|
pScan->igExpired = ((SWindowLogicNode*)pParent)->igExpired;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1139,6 +1139,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
SWindowLogicNode* pWindowLogicNode) {
|
SWindowLogicNode* pWindowLogicNode) {
|
||||||
pWindow->triggerType = pWindowLogicNode->triggerType;
|
pWindow->triggerType = pWindowLogicNode->triggerType;
|
||||||
pWindow->watermark = pWindowLogicNode->watermark;
|
pWindow->watermark = pWindowLogicNode->watermark;
|
||||||
|
pWindow->deleteMark = pWindowLogicNode->deleteMark;
|
||||||
pWindow->igExpired = pWindowLogicNode->igExpired;
|
pWindow->igExpired = pWindowLogicNode->igExpired;
|
||||||
pWindow->inputTsOrder = pWindowLogicNode->inputTsOrder;
|
pWindow->inputTsOrder = pWindowLogicNode->inputTsOrder;
|
||||||
pWindow->outputTsOrder = pWindowLogicNode->outputTsOrder;
|
pWindow->outputTsOrder = pWindowLogicNode->outputTsOrder;
|
||||||
|
|
|
@ -51,7 +51,7 @@ TEST_F(PlanOtherTest, createStreamUseSTable) {
|
||||||
TEST_F(PlanOtherTest, createSmaIndex) {
|
TEST_F(PlanOtherTest, createSmaIndex) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("CREATE SMA INDEX idx1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)");
|
run("CREATE SMA INDEX idx1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s) DELETE_MARK 1000s");
|
||||||
|
|
||||||
run("SELECT SUM(c4) FROM t1 INTERVAL(10s)");
|
run("SELECT SUM(c4) FROM t1 INTERVAL(10s)");
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,7 @@ class PlannerTestBaseImpl {
|
||||||
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
|
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
|
||||||
g_mockCatalogService->createSmaIndex(&req);
|
g_mockCatalogService->createSmaIndex(&req);
|
||||||
nodesStringToNode(req.ast, &pCxt->pAstRoot);
|
nodesStringToNode(req.ast, &pCxt->pAstRoot);
|
||||||
|
pCxt->deleteMark = req.deleteMark;
|
||||||
tFreeSMCreateSmaReq(&req);
|
tFreeSMCreateSmaReq(&req);
|
||||||
nodesDestroyNode(pQuery->pRoot);
|
nodesDestroyNode(pQuery->pRoot);
|
||||||
pQuery->pRoot = pCxt->pAstRoot;
|
pQuery->pRoot = pCxt->pAstRoot;
|
||||||
|
|
|
@ -377,7 +377,7 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
|
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
|
||||||
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||||
#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \
|
#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \
|
||||||
(SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task))))
|
(SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)) || (_task)->redirectCtx.inRedirect))
|
||||||
#define SCH_REDIRECT_MSGTYPE(_msgType) \
|
#define SCH_REDIRECT_MSGTYPE(_msgType) \
|
||||||
((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || \
|
((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || \
|
||||||
(_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH)
|
(_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue