merge 3.0
This commit is contained in:
commit
ea9353b9fd
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
[](https://travis-ci.org/taosdata/TDengine)
|
[](https://travis-ci.org/taosdata/TDengine)
|
||||||
[](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
|
[](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
|
||||||
[](https://coveralls.io/github/taosdata/TDengine?branch=develop)
|
[](https://coveralls.io/github/taosdata/TDengine?branch=3.0)
|
||||||
[](https://bestpractices.coreinfrastructure.org/projects/4201)
|
[](https://bestpractices.coreinfrastructure.org/projects/4201)
|
||||||
|
|
||||||
简体中文 | [English](README.md) | [TDengine 云服务](https://cloud.taosdata.com/?utm_medium=cn&utm_source=github) | 很多职位正在热招中,请看[这里](https://www.taosdata.com/cn/careers/)
|
简体中文 | [English](README.md) | [TDengine 云服务](https://cloud.taosdata.com/?utm_medium=cn&utm_source=github) | 很多职位正在热招中,请看[这里](https://www.taosdata.com/cn/careers/)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
[](https://cloud.drone.io/taosdata/TDengine)
|
[](https://cloud.drone.io/taosdata/TDengine)
|
||||||
[](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
|
[](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
|
||||||
[](https://coveralls.io/github/taosdata/TDengine?branch=develop)
|
[](https://coveralls.io/github/taosdata/TDengine?branch=3.0)
|
||||||
[](https://bestpractices.coreinfrastructure.org/projects/4201)
|
[](https://bestpractices.coreinfrastructure.org/projects/4201)
|
||||||
<br />
|
<br />
|
||||||
[](https://twitter.com/tdenginedb)
|
[](https://twitter.com/tdenginedb)
|
||||||
|
|
|
@ -491,6 +491,8 @@ TO_CHAR(ts, format_str_literal)
|
||||||
|
|
||||||
**Description**: Convert a ts column to string as the format specified
|
**Description**: Convert a ts column to string as the format specified
|
||||||
|
|
||||||
|
**Version**: Since ver-3.2.2.0
|
||||||
|
|
||||||
**Return value type**: VARCHAR
|
**Return value type**: VARCHAR
|
||||||
|
|
||||||
**Applicable column types**: TIMESTAMP
|
**Applicable column types**: TIMESTAMP
|
||||||
|
@ -550,6 +552,8 @@ TO_TIMESTAMP(ts_str_literal, format_str_literal)
|
||||||
|
|
||||||
**Description**: Convert a formated timestamp string to a timestamp
|
**Description**: Convert a formated timestamp string to a timestamp
|
||||||
|
|
||||||
|
**Version**: Since ver-3.2.2.0
|
||||||
|
|
||||||
**Return value type**: TIMESTAMP
|
**Return value type**: TIMESTAMP
|
||||||
|
|
||||||
**Applicable column types**: VARCHAR
|
**Applicable column types**: VARCHAR
|
||||||
|
|
|
@ -7,14 +7,14 @@ description: This document describes the usage of escape characters in TDengine.
|
||||||
|
|
||||||
| Escape Character | **Actual Meaning** |
|
| Escape Character | **Actual Meaning** |
|
||||||
| :--------------: | ------------------------ |
|
| :--------------: | ------------------------ |
|
||||||
| `\'` | Single quote ' |
|
| `\'` | Single quote `'` |
|
||||||
| `\"` | Double quote " |
|
| `\"` | Double quote `"` |
|
||||||
| \n | Line Break |
|
| `\n` | Line Break |
|
||||||
| \r | Carriage Return |
|
| `\r` | Carriage Return |
|
||||||
| \t | tab |
|
| `\t` | tab |
|
||||||
| `\\` | Back Slash \ |
|
| `\\` | Back Slash `\ ` |
|
||||||
| `\%` | % see below for details |
|
| `\%` | `%` see below for details |
|
||||||
| `\_` | \_ see below for details |
|
| `\_` | `_` see below for details |
|
||||||
|
|
||||||
## Restrictions
|
## Restrictions
|
||||||
|
|
||||||
|
@ -22,5 +22,5 @@ description: This document describes the usage of escape characters in TDengine.
|
||||||
- Identifier without ``: Error will be returned because identifier must be constituted of digits, ASCII characters or underscore and can't be started with digits
|
- Identifier without ``: Error will be returned because identifier must be constituted of digits, ASCII characters or underscore and can't be started with digits
|
||||||
- Identifier quoted with ``: Original content is kept, no escaping
|
- Identifier quoted with ``: Original content is kept, no escaping
|
||||||
2. If there are escape characters in values
|
2. If there are escape characters in values
|
||||||
- The escape characters will be escaped as the above table. If the escape character doesn't match any supported one, the escape character "\" will be ignored.
|
- The escape characters will be escaped as the above table. If the escape character doesn't match any supported one, the escape character `\ ` will be ignored(`\x` remaining).
|
||||||
- "%" and "\_" are used as wildcards in `like`. `\%` and `\_` should be used to represent literal "%" and "\_" in `like`,. If `\%` and `\_` are used out of `like` context, the evaluation result is "`\%`"and "`\_`", instead of "%" and "\_".
|
- `%` and `_` are used as wildcards in `like`. `\%` and `\_` should be used to represent literal `%` and `_` in `like`. If `\%` and `\_` are used out of `like` context, the evaluation result is `\%` and `\_`, instead of `%` and `_`.
|
||||||
|
|
|
@ -491,6 +491,8 @@ TO_CHAR(ts, format_str_literal)
|
||||||
|
|
||||||
**功能说明**: 将timestamp类型按照指定格式转换为字符串
|
**功能说明**: 将timestamp类型按照指定格式转换为字符串
|
||||||
|
|
||||||
|
**版本**: ver-3.2.2.0
|
||||||
|
|
||||||
**返回结果数据类型**: VARCHAR
|
**返回结果数据类型**: VARCHAR
|
||||||
|
|
||||||
**应用字段**: TIMESTAMP
|
**应用字段**: TIMESTAMP
|
||||||
|
@ -550,6 +552,8 @@ TO_TIMESTAMP(ts_str_literal, format_str_literal)
|
||||||
|
|
||||||
**功能说明**: 将字符串按照指定格式转化为时间戳.
|
**功能说明**: 将字符串按照指定格式转化为时间戳.
|
||||||
|
|
||||||
|
**版本**: ver-3.2.2.0
|
||||||
|
|
||||||
**返回结果数据类型**: TIMESTAMP
|
**返回结果数据类型**: TIMESTAMP
|
||||||
|
|
||||||
**应用字段**: VARCHAR
|
**应用字段**: VARCHAR
|
||||||
|
|
|
@ -8,16 +8,15 @@ description: TDengine 中使用转义字符的详细规则
|
||||||
|
|
||||||
| 字符序列 | **代表的字符** |
|
| 字符序列 | **代表的字符** |
|
||||||
| :------: | -------------- |
|
| :------: | -------------- |
|
||||||
| `\'` | 单引号' |
|
| `\'` | 单引号`'` |
|
||||||
| `\"` | 双引号" |
|
| `\"` | 双引号`"` |
|
||||||
| \n | 换行符 |
|
| `\n` | 换行符 |
|
||||||
| \r | 回车符 |
|
| `\r` | 回车符 |
|
||||||
| \t | tab 符 |
|
| `\t` | tab 符 |
|
||||||
| `\\` | 斜杠\ |
|
| `\\` | 斜杠 `\ ` |
|
||||||
| `\%` | % 规则见下 |
|
| `\%` | `%` 规则见下 |
|
||||||
| `\_` | \_ 规则见下 |
|
| `\_` | `_` 规则见下 |
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
## 转义字符使用规则
|
## 转义字符使用规则
|
||||||
|
|
||||||
|
@ -25,5 +24,5 @@ description: TDengine 中使用转义字符的详细规则
|
||||||
1. 普通标识符: 直接提示错误的标识符,因为标识符规定必须是数字、字母和下划线,并且不能以数字开头。
|
1. 普通标识符: 直接提示错误的标识符,因为标识符规定必须是数字、字母和下划线,并且不能以数字开头。
|
||||||
2. 反引号``标识符: 保持原样,不转义
|
2. 反引号``标识符: 保持原样,不转义
|
||||||
2. 数据里有转义字符
|
2. 数据里有转义字符
|
||||||
1. 遇到上面定义的转义字符会转义(%和\_见下面说明),如果没有匹配的转义字符会忽略掉转义符\。
|
1. 遇到上面定义的转义字符会转义(`%`和`_`见下面说明),如果没有匹配的转义字符会忽略掉转义符`\ `(`\x`保持原样)。
|
||||||
2. 对于%和\_,因为在 like 里这两个字符是通配符,所以在模式匹配 like 里用`\%`%和`\_`表示字符里本身的%和\_,如果在 like 模式匹配上下文之外使用`\%`或`\_`,则它们的计算结果为字符串`\%`和`\_`,而不是%和\_。
|
2. 对于`%`和`_`,因为在`like`里这两个字符是通配符,所以在模式匹配`like`里用`\%`和`\_`表示字符里本身的`%`和`_`,如果在`like`模式匹配上下文之外使用`\%`或`\_`,则它们的计算结果为字符串`\%`和`\_`,而不是`%`和`_`。
|
||||||
|
|
|
@ -52,6 +52,9 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_VIEWS "ins_views"
|
#define TSDB_INS_TABLE_VIEWS "ins_views"
|
||||||
#define TSDB_INS_TABLE_COMPACTS "ins_compacts"
|
#define TSDB_INS_TABLE_COMPACTS "ins_compacts"
|
||||||
#define TSDB_INS_TABLE_COMPACT_DETAILS "ins_compact_details"
|
#define TSDB_INS_TABLE_COMPACT_DETAILS "ins_compact_details"
|
||||||
|
#define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full"
|
||||||
|
#define TSDB_INS_TABLE_GRANTS_LOGS "ins_grants_logs"
|
||||||
|
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
||||||
|
|
||||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||||
|
|
|
@ -208,6 +208,7 @@ typedef struct SDataBlockInfo {
|
||||||
int16_t hasVarCol;
|
int16_t hasVarCol;
|
||||||
int16_t dataLoad; // denote if the data is loaded or not
|
int16_t dataLoad; // denote if the data is loaded or not
|
||||||
uint8_t scanFlag;
|
uint8_t scanFlag;
|
||||||
|
bool blankFill;
|
||||||
|
|
||||||
// TODO: optimize and remove following
|
// TODO: optimize and remove following
|
||||||
int64_t version; // used for stream, and need serialization
|
int64_t version; // used for stream, and need serialization
|
||||||
|
|
|
@ -22,15 +22,14 @@ extern "C" {
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#ifdef GRANTS_CFG
|
#include "tdef.h"
|
||||||
#include "tgrantCfg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GRANTS_COL_MAX_LEN
|
#ifndef GRANTS_COL_MAX_LEN
|
||||||
#define GRANTS_COL_MAX_LEN 196
|
#define GRANTS_COL_MAX_LEN 196
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GRANT_HEART_BEAT_MIN 2
|
#define GRANT_HEART_BEAT_MIN 2
|
||||||
|
#define GRANT_ACTIVE_CODE "activeCode"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_GRANT_ALL,
|
TSDB_GRANT_ALL,
|
||||||
|
@ -48,13 +47,34 @@ typedef enum {
|
||||||
TSDB_GRANT_CPU_CORES,
|
TSDB_GRANT_CPU_CORES,
|
||||||
TSDB_GRANT_STABLE,
|
TSDB_GRANT_STABLE,
|
||||||
TSDB_GRANT_TABLE,
|
TSDB_GRANT_TABLE,
|
||||||
|
TSDB_GRANT_SUBSCRIPTION,
|
||||||
|
TSDB_GRANT_AUDIT,
|
||||||
|
TSDB_GRANT_CSV,
|
||||||
|
TSDB_GRANT_MULTI_TIER,
|
||||||
|
TSDB_GRANT_BACKUP_RESTORE,
|
||||||
} EGrantType;
|
} EGrantType;
|
||||||
|
|
||||||
int32_t grantCheck(EGrantType grant);
|
int32_t grantCheck(EGrantType grant);
|
||||||
|
char* tGetMachineId();
|
||||||
|
#ifndef TD_UNIQ_GRANT
|
||||||
int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, char* out, int8_t type);
|
int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, char* out, int8_t type);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GRANTS_CFG
|
// #ifndef GRANTS_CFG
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
|
#ifdef TD_UNIQ_GRANT
|
||||||
|
#define GRANTS_SCHEMA \
|
||||||
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
|
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "state", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
}
|
||||||
|
#else
|
||||||
#define GRANTS_SCHEMA \
|
#define GRANTS_SCHEMA \
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
@ -78,33 +98,28 @@ int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, ch
|
||||||
{.name = "influxdb", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "influxdb", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "mqtt", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "mqtt", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define GRANTS_SCHEMA \
|
#define GRANTS_SCHEMA \
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
|
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "storage", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "state", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
{.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||||
{.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#define GRANT_CFG_ADD
|
// #define GRANT_CFG_ADD
|
||||||
#define GRANT_CFG_SET
|
// #define GRANT_CFG_SET
|
||||||
#define GRANT_CFG_GET
|
// #define GRANT_CFG_GET
|
||||||
#define GRANT_CFG_CHECK
|
// #define GRANT_CFG_CHECK
|
||||||
#define GRANT_CFG_SKIP
|
// #define GRANT_CFG_SKIP
|
||||||
#define GRANT_CFG_DECLARE
|
// #define GRANT_CFG_DECLARE
|
||||||
#define GRANT_CFG_EXTERN
|
// #define GRANT_CFG_EXTERN
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,9 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_VIEWS,
|
TSDB_MGMT_TABLE_VIEWS,
|
||||||
TSDB_MGMT_TABLE_COMPACT,
|
TSDB_MGMT_TABLE_COMPACT,
|
||||||
TSDB_MGMT_TABLE_COMPACT_DETAIL,
|
TSDB_MGMT_TABLE_COMPACT_DETAIL,
|
||||||
|
TSDB_MGMT_TABLE_GRANTS_FULL,
|
||||||
|
TSDB_MGMT_TABLE_GRANTS_LOGS,
|
||||||
|
TSDB_MGMT_TABLE_MACHINES,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
|
||||||
|
@ -299,7 +302,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SYNCDB_STMT,
|
QUERY_NODE_SYNCDB_STMT,
|
||||||
QUERY_NODE_GRANT_STMT,
|
QUERY_NODE_GRANT_STMT,
|
||||||
QUERY_NODE_REVOKE_STMT,
|
QUERY_NODE_REVOKE_STMT,
|
||||||
// placeholder for [152, 180]
|
QUERY_NODE_ALTER_CLUSTER_STMT,
|
||||||
|
// placeholder for [153, 180]
|
||||||
QUERY_NODE_SHOW_CREATE_VIEW_STMT = 181,
|
QUERY_NODE_SHOW_CREATE_VIEW_STMT = 181,
|
||||||
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
||||||
|
@ -360,6 +364,9 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_VIEWS_STMT,
|
QUERY_NODE_SHOW_VIEWS_STMT,
|
||||||
QUERY_NODE_SHOW_COMPACTS_STMT,
|
QUERY_NODE_SHOW_COMPACTS_STMT,
|
||||||
QUERY_NODE_SHOW_COMPACT_DETAILS_STMT,
|
QUERY_NODE_SHOW_COMPACT_DETAILS_STMT,
|
||||||
|
QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||||
|
QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
|
||||||
|
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
||||||
|
|
||||||
// logic plan node
|
// logic plan node
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||||
|
@ -1560,9 +1567,11 @@ typedef struct {
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
float numOfCores;
|
float numOfCores;
|
||||||
int32_t numOfSupportVnodes;
|
int32_t numOfSupportVnodes;
|
||||||
|
int32_t numOfDiskCfg;
|
||||||
int64_t memTotal;
|
int64_t memTotal;
|
||||||
int64_t memAvail;
|
int64_t memAvail;
|
||||||
char dnodeEp[TSDB_EP_LEN];
|
char dnodeEp[TSDB_EP_LEN];
|
||||||
|
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||||
SMnodeLoad mload;
|
SMnodeLoad mload;
|
||||||
SQnodeLoad qload;
|
SQnodeLoad qload;
|
||||||
SClusterCfg clusterCfg;
|
SClusterCfg clusterCfg;
|
||||||
|
@ -1603,6 +1612,7 @@ typedef struct {
|
||||||
SEp ep;
|
SEp ep;
|
||||||
char active[TSDB_ACTIVE_KEY_LEN];
|
char active[TSDB_ACTIVE_KEY_LEN];
|
||||||
char connActive[TSDB_CONN_ACTIVE_KEY_LEN];
|
char connActive[TSDB_CONN_ACTIVE_KEY_LEN];
|
||||||
|
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||||
} SDnodeInfo;
|
} SDnodeInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -2034,6 +2044,17 @@ int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
|
||||||
int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
|
int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
|
||||||
void tFreeSExplainRsp(SExplainRsp* pRsp);
|
void tFreeSExplainRsp(SExplainRsp* pRsp);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char config[TSDB_DNODE_CONFIG_LEN];
|
||||||
|
char value[TSDB_CLUSTER_VALUE_LEN];
|
||||||
|
int32_t sqlLen;
|
||||||
|
char* sql;
|
||||||
|
} SMCfgClusterReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMCfgClusterReq(void* buf, int32_t bufLen, SMCfgClusterReq* pReq);
|
||||||
|
int32_t tDeserializeSMCfgClusterReq(void* buf, int32_t bufLen, SMCfgClusterReq* pReq);
|
||||||
|
void tFreeSMCfgClusterReq(SMCfgClusterReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port
|
char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port
|
||||||
int32_t port;
|
int32_t port;
|
||||||
|
@ -2411,6 +2432,11 @@ typedef struct SColLocation {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
} SColLocation;
|
} SColLocation;
|
||||||
|
|
||||||
|
typedef struct SVgroupVer {
|
||||||
|
int32_t vgId;
|
||||||
|
int64_t ver;
|
||||||
|
} SVgroupVer;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_STREAM_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
char sourceDB[TSDB_DB_FNAME_LEN];
|
char sourceDB[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -2434,6 +2460,7 @@ typedef struct {
|
||||||
int64_t deleteMark;
|
int64_t deleteMark;
|
||||||
int8_t igUpdate;
|
int8_t igUpdate;
|
||||||
int64_t lastTs;
|
int64_t lastTs;
|
||||||
|
SArray* pVgroupVerList;
|
||||||
} SCMCreateStreamReq;
|
} SCMCreateStreamReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -3757,7 +3784,12 @@ typedef struct {
|
||||||
} SMqHbReq;
|
} SMqHbReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t reserved;
|
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||||
|
int8_t noPrivilege;
|
||||||
|
} STopicPrivilege;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SArray* topicPrivileges; // SArray<STopicPrivilege>
|
||||||
} SMqHbRsp;
|
} SMqHbRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -3776,18 +3808,6 @@ typedef struct {
|
||||||
SVCreateTbReq cTbReq;
|
SVCreateTbReq cTbReq;
|
||||||
} SVSubmitBlk;
|
} SVSubmitBlk;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t flags;
|
|
||||||
int32_t nBlocks;
|
|
||||||
union {
|
|
||||||
SArray* pArray;
|
|
||||||
SVSubmitBlk* pBlocks;
|
|
||||||
};
|
|
||||||
} SVSubmitReq;
|
|
||||||
|
|
||||||
int32_t tEncodeSVSubmitReq(SEncoder* pCoder, const SVSubmitReq* pReq);
|
|
||||||
int32_t tDecodeSVSubmitReq(SDecoder* pCoder, SVSubmitReq* pReq);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead header;
|
SMsgHead header;
|
||||||
uint64_t sId;
|
uint64_t sId;
|
||||||
|
@ -3896,6 +3916,10 @@ int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
||||||
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
||||||
int32_t tDeatroySMqHbReq(SMqHbReq* pReq);
|
int32_t tDeatroySMqHbReq(SMqHbReq* pReq);
|
||||||
|
|
||||||
|
int32_t tSerializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
|
||||||
|
int32_t tDeserializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
|
||||||
|
int32_t tDeatroySMqHbRsp(SMqHbRsp* pRsp);
|
||||||
|
|
||||||
int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
||||||
int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_COMPACT, "kill-compact", SKillCompactReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_KILL_COMPACT, "kill-compact", SKillCompactReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_REQ_CHKPT, "stream-req-checkpoint", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_REQ_CHKPT, "stream-req-checkpoint", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_CLUSTER, "config-cluster", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
||||||
|
|
||||||
|
@ -337,8 +338,9 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT, "sync-prep-snapshot", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT, "sync-prep-snapshot", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT_REPLY, "sync-prep-snapshot-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT_REPLY, "sync-prep-snapshot-reply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_UNUSED_CODE, "sync-unused", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_SYNC_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_SYNC_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG) //7 << 8
|
TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG) //7 << 8
|
||||||
|
|
|
@ -1,22 +1,3 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_COMMON_TOKEN_H_
|
|
||||||
#define _TD_COMMON_TOKEN_H_
|
|
||||||
|
|
||||||
|
|
||||||
#define TK_OR 1
|
#define TK_OR 1
|
||||||
#define TK_AND 2
|
#define TK_AND 2
|
||||||
#define TK_UNION 3
|
#define TK_UNION 3
|
||||||
|
@ -74,310 +55,296 @@
|
||||||
#define TK_NK_IPTOKEN 55
|
#define TK_NK_IPTOKEN 55
|
||||||
#define TK_FORCE 56
|
#define TK_FORCE 56
|
||||||
#define TK_UNSAFE 57
|
#define TK_UNSAFE 57
|
||||||
#define TK_LOCAL 58
|
#define TK_CLUSTER 58
|
||||||
#define TK_QNODE 59
|
#define TK_LOCAL 59
|
||||||
#define TK_BNODE 60
|
#define TK_QNODE 60
|
||||||
#define TK_SNODE 61
|
#define TK_BNODE 61
|
||||||
#define TK_MNODE 62
|
#define TK_SNODE 62
|
||||||
#define TK_VNODE 63
|
#define TK_MNODE 63
|
||||||
#define TK_DATABASE 64
|
#define TK_VNODE 64
|
||||||
#define TK_USE 65
|
#define TK_DATABASE 65
|
||||||
#define TK_FLUSH 66
|
#define TK_USE 66
|
||||||
#define TK_TRIM 67
|
#define TK_FLUSH 67
|
||||||
#define TK_COMPACT 68
|
#define TK_TRIM 68
|
||||||
#define TK_IF 69
|
#define TK_COMPACT 69
|
||||||
#define TK_NOT 70
|
#define TK_IF 70
|
||||||
#define TK_EXISTS 71
|
#define TK_NOT 71
|
||||||
#define TK_BUFFER 72
|
#define TK_EXISTS 72
|
||||||
#define TK_CACHEMODEL 73
|
#define TK_BUFFER 73
|
||||||
#define TK_CACHESIZE 74
|
#define TK_CACHEMODEL 74
|
||||||
#define TK_COMP 75
|
#define TK_CACHESIZE 75
|
||||||
#define TK_DURATION 76
|
#define TK_COMP 76
|
||||||
#define TK_NK_VARIABLE 77
|
#define TK_DURATION 77
|
||||||
#define TK_MAXROWS 78
|
#define TK_NK_VARIABLE 78
|
||||||
#define TK_MINROWS 79
|
#define TK_MAXROWS 79
|
||||||
#define TK_KEEP 80
|
#define TK_MINROWS 80
|
||||||
#define TK_PAGES 81
|
#define TK_KEEP 81
|
||||||
#define TK_PAGESIZE 82
|
#define TK_PAGES 82
|
||||||
#define TK_TSDB_PAGESIZE 83
|
#define TK_PAGESIZE 83
|
||||||
#define TK_PRECISION 84
|
#define TK_TSDB_PAGESIZE 84
|
||||||
#define TK_REPLICA 85
|
#define TK_PRECISION 85
|
||||||
#define TK_VGROUPS 86
|
#define TK_REPLICA 86
|
||||||
#define TK_SINGLE_STABLE 87
|
#define TK_VGROUPS 87
|
||||||
#define TK_RETENTIONS 88
|
#define TK_SINGLE_STABLE 88
|
||||||
#define TK_SCHEMALESS 89
|
#define TK_RETENTIONS 89
|
||||||
#define TK_WAL_LEVEL 90
|
#define TK_SCHEMALESS 90
|
||||||
#define TK_WAL_FSYNC_PERIOD 91
|
#define TK_WAL_LEVEL 91
|
||||||
#define TK_WAL_RETENTION_PERIOD 92
|
#define TK_WAL_FSYNC_PERIOD 92
|
||||||
#define TK_WAL_RETENTION_SIZE 93
|
#define TK_WAL_RETENTION_PERIOD 93
|
||||||
#define TK_WAL_ROLL_PERIOD 94
|
#define TK_WAL_RETENTION_SIZE 94
|
||||||
#define TK_WAL_SEGMENT_SIZE 95
|
#define TK_WAL_ROLL_PERIOD 95
|
||||||
#define TK_STT_TRIGGER 96
|
#define TK_WAL_SEGMENT_SIZE 96
|
||||||
#define TK_TABLE_PREFIX 97
|
#define TK_STT_TRIGGER 97
|
||||||
#define TK_TABLE_SUFFIX 98
|
#define TK_TABLE_PREFIX 98
|
||||||
#define TK_KEEP_TIME_OFFSET 99
|
#define TK_TABLE_SUFFIX 99
|
||||||
#define TK_NK_COLON 100
|
#define TK_KEEP_TIME_OFFSET 100
|
||||||
#define TK_BWLIMIT 101
|
#define TK_NK_COLON 101
|
||||||
#define TK_START 102
|
#define TK_BWLIMIT 102
|
||||||
#define TK_TIMESTAMP 103
|
#define TK_START 103
|
||||||
#define TK_END 104
|
#define TK_TIMESTAMP 104
|
||||||
#define TK_TABLE 105
|
#define TK_END 105
|
||||||
#define TK_NK_LP 106
|
#define TK_TABLE 106
|
||||||
#define TK_NK_RP 107
|
#define TK_NK_LP 107
|
||||||
#define TK_STABLE 108
|
#define TK_NK_RP 108
|
||||||
#define TK_COLUMN 109
|
#define TK_STABLE 109
|
||||||
#define TK_MODIFY 110
|
#define TK_COLUMN 110
|
||||||
#define TK_RENAME 111
|
#define TK_MODIFY 111
|
||||||
#define TK_TAG 112
|
#define TK_RENAME 112
|
||||||
#define TK_SET 113
|
#define TK_TAG 113
|
||||||
#define TK_NK_EQ 114
|
#define TK_SET 114
|
||||||
#define TK_USING 115
|
#define TK_NK_EQ 115
|
||||||
#define TK_TAGS 116
|
#define TK_USING 116
|
||||||
#define TK_BOOL 117
|
#define TK_TAGS 117
|
||||||
#define TK_TINYINT 118
|
#define TK_BOOL 118
|
||||||
#define TK_SMALLINT 119
|
#define TK_TINYINT 119
|
||||||
#define TK_INT 120
|
#define TK_SMALLINT 120
|
||||||
#define TK_INTEGER 121
|
#define TK_INT 121
|
||||||
#define TK_BIGINT 122
|
#define TK_INTEGER 122
|
||||||
#define TK_FLOAT 123
|
#define TK_BIGINT 123
|
||||||
#define TK_DOUBLE 124
|
#define TK_FLOAT 124
|
||||||
#define TK_BINARY 125
|
#define TK_DOUBLE 125
|
||||||
#define TK_NCHAR 126
|
#define TK_BINARY 126
|
||||||
#define TK_UNSIGNED 127
|
#define TK_NCHAR 127
|
||||||
#define TK_JSON 128
|
#define TK_UNSIGNED 128
|
||||||
#define TK_VARCHAR 129
|
#define TK_JSON 129
|
||||||
#define TK_MEDIUMBLOB 130
|
#define TK_VARCHAR 130
|
||||||
#define TK_BLOB 131
|
#define TK_MEDIUMBLOB 131
|
||||||
#define TK_VARBINARY 132
|
#define TK_BLOB 132
|
||||||
#define TK_GEOMETRY 133
|
#define TK_VARBINARY 133
|
||||||
#define TK_DECIMAL 134
|
#define TK_GEOMETRY 134
|
||||||
#define TK_COMMENT 135
|
#define TK_DECIMAL 135
|
||||||
#define TK_MAX_DELAY 136
|
#define TK_COMMENT 136
|
||||||
#define TK_WATERMARK 137
|
#define TK_MAX_DELAY 137
|
||||||
#define TK_ROLLUP 138
|
#define TK_WATERMARK 138
|
||||||
#define TK_TTL 139
|
#define TK_ROLLUP 139
|
||||||
#define TK_SMA 140
|
#define TK_TTL 140
|
||||||
#define TK_DELETE_MARK 141
|
#define TK_SMA 141
|
||||||
#define TK_FIRST 142
|
#define TK_DELETE_MARK 142
|
||||||
#define TK_LAST 143
|
#define TK_FIRST 143
|
||||||
#define TK_SHOW 144
|
#define TK_LAST 144
|
||||||
#define TK_PRIVILEGES 145
|
#define TK_SHOW 145
|
||||||
#define TK_DATABASES 146
|
#define TK_PRIVILEGES 146
|
||||||
#define TK_TABLES 147
|
#define TK_DATABASES 147
|
||||||
#define TK_STABLES 148
|
#define TK_TABLES 148
|
||||||
#define TK_MNODES 149
|
#define TK_STABLES 149
|
||||||
#define TK_QNODES 150
|
#define TK_MNODES 150
|
||||||
#define TK_FUNCTIONS 151
|
#define TK_QNODES 151
|
||||||
#define TK_INDEXES 152
|
#define TK_FUNCTIONS 152
|
||||||
#define TK_ACCOUNTS 153
|
#define TK_INDEXES 153
|
||||||
#define TK_APPS 154
|
#define TK_ACCOUNTS 154
|
||||||
#define TK_CONNECTIONS 155
|
#define TK_APPS 155
|
||||||
#define TK_LICENCES 156
|
#define TK_CONNECTIONS 156
|
||||||
#define TK_GRANTS 157
|
#define TK_LICENCES 157
|
||||||
#define TK_QUERIES 158
|
#define TK_GRANTS 158
|
||||||
#define TK_SCORES 159
|
#define TK_FULL 159
|
||||||
#define TK_TOPICS 160
|
#define TK_LOGS 160
|
||||||
#define TK_VARIABLES 161
|
#define TK_MACHINES 161
|
||||||
#define TK_CLUSTER 162
|
#define TK_QUERIES 162
|
||||||
#define TK_BNODES 163
|
#define TK_SCORES 163
|
||||||
#define TK_SNODES 164
|
#define TK_TOPICS 164
|
||||||
#define TK_TRANSACTIONS 165
|
#define TK_VARIABLES 165
|
||||||
#define TK_DISTRIBUTED 166
|
#define TK_BNODES 166
|
||||||
#define TK_CONSUMERS 167
|
#define TK_SNODES 167
|
||||||
#define TK_SUBSCRIPTIONS 168
|
#define TK_TRANSACTIONS 168
|
||||||
#define TK_VNODES 169
|
#define TK_DISTRIBUTED 169
|
||||||
#define TK_ALIVE 170
|
#define TK_CONSUMERS 170
|
||||||
#define TK_VIEWS 171
|
#define TK_SUBSCRIPTIONS 171
|
||||||
#define TK_VIEW 172
|
#define TK_VNODES 172
|
||||||
#define TK_COMPACTS 173
|
#define TK_ALIVE 173
|
||||||
#define TK_NORMAL 174
|
#define TK_VIEWS 174
|
||||||
#define TK_CHILD 175
|
#define TK_VIEW 175
|
||||||
#define TK_LIKE 176
|
#define TK_COMPACTS 176
|
||||||
#define TK_TBNAME 177
|
#define TK_NORMAL 177
|
||||||
#define TK_QTAGS 178
|
#define TK_CHILD 178
|
||||||
#define TK_AS 179
|
#define TK_LIKE 179
|
||||||
#define TK_SYSTEM 180
|
#define TK_TBNAME 180
|
||||||
#define TK_INDEX 181
|
#define TK_QTAGS 181
|
||||||
#define TK_FUNCTION 182
|
#define TK_AS 182
|
||||||
#define TK_INTERVAL 183
|
#define TK_SYSTEM 183
|
||||||
#define TK_COUNT 184
|
#define TK_INDEX 184
|
||||||
#define TK_LAST_ROW 185
|
#define TK_FUNCTION 185
|
||||||
#define TK_META 186
|
#define TK_INTERVAL 186
|
||||||
#define TK_ONLY 187
|
#define TK_COUNT 187
|
||||||
#define TK_TOPIC 188
|
#define TK_LAST_ROW 188
|
||||||
#define TK_CONSUMER 189
|
#define TK_META 189
|
||||||
#define TK_GROUP 190
|
#define TK_ONLY 190
|
||||||
#define TK_DESC 191
|
#define TK_TOPIC 191
|
||||||
#define TK_DESCRIBE 192
|
#define TK_CONSUMER 192
|
||||||
#define TK_RESET 193
|
#define TK_GROUP 193
|
||||||
#define TK_QUERY 194
|
#define TK_DESC 194
|
||||||
#define TK_CACHE 195
|
#define TK_DESCRIBE 195
|
||||||
#define TK_EXPLAIN 196
|
#define TK_RESET 196
|
||||||
#define TK_ANALYZE 197
|
#define TK_QUERY 197
|
||||||
#define TK_VERBOSE 198
|
#define TK_CACHE 198
|
||||||
#define TK_NK_BOOL 199
|
#define TK_EXPLAIN 199
|
||||||
#define TK_RATIO 200
|
#define TK_ANALYZE 200
|
||||||
#define TK_NK_FLOAT 201
|
#define TK_VERBOSE 201
|
||||||
#define TK_OUTPUTTYPE 202
|
#define TK_NK_BOOL 202
|
||||||
#define TK_AGGREGATE 203
|
#define TK_RATIO 203
|
||||||
#define TK_BUFSIZE 204
|
#define TK_NK_FLOAT 204
|
||||||
#define TK_LANGUAGE 205
|
#define TK_OUTPUTTYPE 205
|
||||||
#define TK_REPLACE 206
|
#define TK_AGGREGATE 206
|
||||||
#define TK_STREAM 207
|
#define TK_BUFSIZE 207
|
||||||
#define TK_INTO 208
|
#define TK_LANGUAGE 208
|
||||||
#define TK_PAUSE 209
|
#define TK_REPLACE 209
|
||||||
#define TK_RESUME 210
|
#define TK_STREAM 210
|
||||||
#define TK_TRIGGER 211
|
#define TK_INTO 211
|
||||||
#define TK_AT_ONCE 212
|
#define TK_PAUSE 212
|
||||||
#define TK_WINDOW_CLOSE 213
|
#define TK_RESUME 213
|
||||||
#define TK_IGNORE 214
|
#define TK_TRIGGER 214
|
||||||
#define TK_EXPIRED 215
|
#define TK_AT_ONCE 215
|
||||||
#define TK_FILL_HISTORY 216
|
#define TK_WINDOW_CLOSE 216
|
||||||
#define TK_UPDATE 217
|
#define TK_IGNORE 217
|
||||||
#define TK_SUBTABLE 218
|
#define TK_EXPIRED 218
|
||||||
#define TK_UNTREATED 219
|
#define TK_FILL_HISTORY 219
|
||||||
#define TK_KILL 220
|
#define TK_UPDATE 220
|
||||||
#define TK_CONNECTION 221
|
#define TK_SUBTABLE 221
|
||||||
#define TK_TRANSACTION 222
|
#define TK_UNTREATED 222
|
||||||
#define TK_BALANCE 223
|
#define TK_KILL 223
|
||||||
#define TK_VGROUP 224
|
#define TK_CONNECTION 224
|
||||||
#define TK_LEADER 225
|
#define TK_TRANSACTION 225
|
||||||
#define TK_MERGE 226
|
#define TK_BALANCE 226
|
||||||
#define TK_REDISTRIBUTE 227
|
#define TK_VGROUP 227
|
||||||
#define TK_SPLIT 228
|
#define TK_LEADER 228
|
||||||
#define TK_DELETE 229
|
#define TK_MERGE 229
|
||||||
#define TK_INSERT 230
|
#define TK_REDISTRIBUTE 230
|
||||||
#define TK_NULL 231
|
#define TK_SPLIT 231
|
||||||
#define TK_NK_QUESTION 232
|
#define TK_DELETE 232
|
||||||
#define TK_NK_ALIAS 233
|
#define TK_INSERT 233
|
||||||
#define TK_NK_ARROW 234
|
#define TK_NULL 234
|
||||||
#define TK_ROWTS 235
|
#define TK_NK_QUESTION 235
|
||||||
#define TK_QSTART 236
|
#define TK_NK_ALIAS 236
|
||||||
#define TK_QEND 237
|
#define TK_NK_ARROW 237
|
||||||
#define TK_QDURATION 238
|
#define TK_ROWTS 238
|
||||||
#define TK_WSTART 239
|
#define TK_QSTART 239
|
||||||
#define TK_WEND 240
|
#define TK_QEND 240
|
||||||
#define TK_WDURATION 241
|
#define TK_QDURATION 241
|
||||||
#define TK_IROWTS 242
|
#define TK_WSTART 242
|
||||||
#define TK_ISFILLED 243
|
#define TK_WEND 243
|
||||||
#define TK_CAST 244
|
#define TK_WDURATION 244
|
||||||
#define TK_NOW 245
|
#define TK_IROWTS 245
|
||||||
#define TK_TODAY 246
|
#define TK_ISFILLED 246
|
||||||
#define TK_TIMEZONE 247
|
#define TK_CAST 247
|
||||||
#define TK_CLIENT_VERSION 248
|
#define TK_NOW 248
|
||||||
#define TK_SERVER_VERSION 249
|
#define TK_TODAY 249
|
||||||
#define TK_SERVER_STATUS 250
|
#define TK_TIMEZONE 250
|
||||||
#define TK_CURRENT_USER 251
|
#define TK_CLIENT_VERSION 251
|
||||||
#define TK_CASE 252
|
#define TK_SERVER_VERSION 252
|
||||||
#define TK_WHEN 253
|
#define TK_SERVER_STATUS 253
|
||||||
#define TK_THEN 254
|
#define TK_CURRENT_USER 254
|
||||||
#define TK_ELSE 255
|
#define TK_CASE 255
|
||||||
#define TK_BETWEEN 256
|
#define TK_WHEN 256
|
||||||
#define TK_IS 257
|
#define TK_THEN 257
|
||||||
#define TK_NK_LT 258
|
#define TK_ELSE 258
|
||||||
#define TK_NK_GT 259
|
#define TK_BETWEEN 259
|
||||||
#define TK_NK_LE 260
|
#define TK_IS 260
|
||||||
#define TK_NK_GE 261
|
#define TK_NK_LT 261
|
||||||
#define TK_NK_NE 262
|
#define TK_NK_GT 262
|
||||||
#define TK_MATCH 263
|
#define TK_NK_LE 263
|
||||||
#define TK_NMATCH 264
|
#define TK_NK_GE 264
|
||||||
#define TK_CONTAINS 265
|
#define TK_NK_NE 265
|
||||||
#define TK_IN 266
|
#define TK_MATCH 266
|
||||||
#define TK_JOIN 267
|
#define TK_NMATCH 267
|
||||||
#define TK_INNER 268
|
#define TK_CONTAINS 268
|
||||||
#define TK_SELECT 269
|
#define TK_IN 269
|
||||||
#define TK_NK_HINT 270
|
#define TK_JOIN 270
|
||||||
#define TK_DISTINCT 271
|
#define TK_INNER 271
|
||||||
#define TK_WHERE 272
|
#define TK_SELECT 272
|
||||||
#define TK_PARTITION 273
|
#define TK_NK_HINT 273
|
||||||
#define TK_BY 274
|
#define TK_DISTINCT 274
|
||||||
#define TK_SESSION 275
|
#define TK_WHERE 275
|
||||||
#define TK_STATE_WINDOW 276
|
#define TK_PARTITION 276
|
||||||
#define TK_EVENT_WINDOW 277
|
#define TK_BY 277
|
||||||
#define TK_COUNT_WINDOW 278
|
#define TK_SESSION 278
|
||||||
#define TK_SLIDING 279
|
#define TK_STATE_WINDOW 279
|
||||||
#define TK_FILL 280
|
#define TK_EVENT_WINDOW 280
|
||||||
#define TK_VALUE 281
|
#define TK_COUNT_WINDOW 281
|
||||||
#define TK_VALUE_F 282
|
#define TK_SLIDING 282
|
||||||
#define TK_NONE 283
|
#define TK_FILL 283
|
||||||
#define TK_PREV 284
|
#define TK_VALUE 284
|
||||||
#define TK_NULL_F 285
|
#define TK_VALUE_F 285
|
||||||
#define TK_LINEAR 286
|
#define TK_NONE 286
|
||||||
#define TK_NEXT 287
|
#define TK_PREV 287
|
||||||
#define TK_HAVING 288
|
#define TK_NULL_F 288
|
||||||
#define TK_RANGE 289
|
#define TK_LINEAR 289
|
||||||
#define TK_EVERY 290
|
#define TK_NEXT 290
|
||||||
#define TK_ORDER 291
|
#define TK_HAVING 291
|
||||||
#define TK_SLIMIT 292
|
#define TK_RANGE 292
|
||||||
#define TK_SOFFSET 293
|
#define TK_EVERY 293
|
||||||
#define TK_LIMIT 294
|
#define TK_ORDER 294
|
||||||
#define TK_OFFSET 295
|
#define TK_SLIMIT 295
|
||||||
#define TK_ASC 296
|
#define TK_SOFFSET 296
|
||||||
#define TK_NULLS 297
|
#define TK_LIMIT 297
|
||||||
#define TK_ABORT 298
|
#define TK_OFFSET 298
|
||||||
#define TK_AFTER 299
|
#define TK_ASC 299
|
||||||
#define TK_ATTACH 300
|
#define TK_NULLS 300
|
||||||
#define TK_BEFORE 301
|
#define TK_ABORT 301
|
||||||
#define TK_BEGIN 302
|
#define TK_AFTER 302
|
||||||
#define TK_BITAND 303
|
#define TK_ATTACH 303
|
||||||
#define TK_BITNOT 304
|
#define TK_BEFORE 304
|
||||||
#define TK_BITOR 305
|
#define TK_BEGIN 305
|
||||||
#define TK_BLOCKS 306
|
#define TK_BITAND 306
|
||||||
#define TK_CHANGE 307
|
#define TK_BITNOT 307
|
||||||
#define TK_COMMA 308
|
#define TK_BITOR 308
|
||||||
#define TK_CONCAT 309
|
#define TK_BLOCKS 309
|
||||||
#define TK_CONFLICT 310
|
#define TK_CHANGE 310
|
||||||
#define TK_COPY 311
|
#define TK_COMMA 311
|
||||||
#define TK_DEFERRED 312
|
#define TK_CONCAT 312
|
||||||
#define TK_DELIMITERS 313
|
#define TK_CONFLICT 313
|
||||||
#define TK_DETACH 314
|
#define TK_COPY 314
|
||||||
#define TK_DIVIDE 315
|
#define TK_DEFERRED 315
|
||||||
#define TK_DOT 316
|
#define TK_DELIMITERS 316
|
||||||
#define TK_EACH 317
|
#define TK_DETACH 317
|
||||||
#define TK_FAIL 318
|
#define TK_DIVIDE 318
|
||||||
#define TK_FILE 319
|
#define TK_DOT 319
|
||||||
#define TK_FOR 320
|
#define TK_EACH 320
|
||||||
#define TK_GLOB 321
|
#define TK_FAIL 321
|
||||||
#define TK_ID 322
|
#define TK_FILE 322
|
||||||
#define TK_IMMEDIATE 323
|
#define TK_FOR 323
|
||||||
#define TK_IMPORT 324
|
#define TK_GLOB 324
|
||||||
#define TK_INITIALLY 325
|
#define TK_ID 325
|
||||||
#define TK_INSTEAD 326
|
#define TK_IMMEDIATE 326
|
||||||
#define TK_ISNULL 327
|
#define TK_IMPORT 327
|
||||||
#define TK_KEY 328
|
#define TK_INITIALLY 328
|
||||||
#define TK_MODULES 329
|
#define TK_INSTEAD 329
|
||||||
#define TK_NK_BITNOT 330
|
#define TK_ISNULL 330
|
||||||
#define TK_NK_SEMI 331
|
#define TK_KEY 331
|
||||||
#define TK_NOTNULL 332
|
#define TK_MODULES 332
|
||||||
#define TK_OF 333
|
#define TK_NK_BITNOT 333
|
||||||
#define TK_PLUS 334
|
#define TK_NK_SEMI 334
|
||||||
#define TK_PRIVILEGE 335
|
#define TK_NOTNULL 335
|
||||||
#define TK_RAISE 336
|
#define TK_OF 336
|
||||||
#define TK_RESTRICT 337
|
#define TK_PLUS 337
|
||||||
#define TK_ROW 338
|
#define TK_PRIVILEGE 338
|
||||||
#define TK_SEMI 339
|
#define TK_RAISE 339
|
||||||
#define TK_STAR 340
|
#define TK_RESTRICT 340
|
||||||
#define TK_STATEMENT 341
|
#define TK_ROW 341
|
||||||
#define TK_STRICT 342
|
#define TK_SEMI 342
|
||||||
#define TK_STRING 343
|
#define TK_STAR 343
|
||||||
#define TK_TIMES 344
|
#define TK_STATEMENT 344
|
||||||
#define TK_VALUES 345
|
#define TK_STRICT 345
|
||||||
#define TK_VARIABLE 346
|
#define TK_STRING 346
|
||||||
#define TK_WAL 347
|
#define TK_TIMES 347
|
||||||
|
#define TK_VALUES 348
|
||||||
|
#define TK_VARIABLE 349
|
||||||
#define TK_NK_SPACE 600
|
#define TK_WAL 350
|
||||||
#define TK_NK_COMMENT 601
|
|
||||||
#define TK_NK_ILLEGAL 602
|
|
||||||
#define TK_NK_HEX 603 // hex number 0x123
|
|
||||||
#define TK_NK_OCT 604 // oct number
|
|
||||||
#define TK_NK_BIN 605 // bin format data 0b111
|
|
||||||
#define TK_BATCH_SCAN 606
|
|
||||||
#define TK_NO_BATCH_SCAN 607
|
|
||||||
#define TK_SORT_FOR_GROUP 608
|
|
||||||
#define TK_PARTITION_FIRST 609
|
|
||||||
|
|
||||||
|
|
||||||
#define TK_NK_NIL 65535
|
|
||||||
|
|
||||||
#endif /*_TD_COMMON_TOKEN_H_*/
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
// message process
|
// message process
|
||||||
int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart);
|
int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart);
|
||||||
int32_t tqStreamOneTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t streamId, int32_t taskId);
|
int32_t tqStreamStartOneTaskAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t streamId, int32_t taskId);
|
||||||
int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pMsg, bool restored);
|
int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pMsg, bool restored);
|
||||||
int32_t tqStreamTaskProcessDispatchReq(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
int32_t tqStreamTaskProcessDispatchReq(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
int32_t tqStreamTaskProcessDispatchRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
int32_t tqStreamTaskProcessDispatchRsp(SStreamMeta* pMeta, SRpcMsg* pMsg);
|
||||||
|
|
|
@ -362,10 +362,12 @@ typedef struct SStateStore {
|
||||||
int32_t (*streamStateStateAddIfNotExist)(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
int32_t (*streamStateStateAddIfNotExist)(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen);
|
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen);
|
||||||
int32_t (*streamStateSessionGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
int32_t (*streamStateSessionGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||||
|
int32_t (*streamStateCountGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||||
int32_t (*streamStateSessionAllocWinBuffByNextPosition)(SStreamState* pState, SStreamStateCur* pCur,
|
int32_t (*streamStateSessionAllocWinBuffByNextPosition)(SStreamState* pState, SStreamStateCur* pCur,
|
||||||
const SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
const SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
|
|
||||||
int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen);
|
int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen);
|
||||||
|
int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
|
|
||||||
SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp);
|
SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp);
|
||||||
TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol);
|
TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol);
|
||||||
|
@ -384,6 +386,7 @@ typedef struct SStateStore {
|
||||||
int32_t (*updateInfoDeserialize)(void* buf, int32_t bufLen, SUpdateInfo* pInfo);
|
int32_t (*updateInfoDeserialize)(void* buf, int32_t bufLen, SUpdateInfo* pInfo);
|
||||||
|
|
||||||
SStreamStateCur* (*streamStateSessionSeekKeyNext)(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* (*streamStateSessionSeekKeyNext)(SStreamState* pState, const SSessionKey* key);
|
||||||
|
SStreamStateCur* (*streamStateCountSeekKeyPrev)(SStreamState* pState, const SSessionKey* pKey, COUNT_TYPE count);
|
||||||
SStreamStateCur* (*streamStateSessionSeekKeyCurrentPrev)(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* (*streamStateSessionSeekKeyCurrentPrev)(SStreamState* pState, const SSessionKey* key);
|
||||||
SStreamStateCur* (*streamStateSessionSeekKeyCurrentNext)(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* (*streamStateSessionSeekKeyCurrentNext)(SStreamState* pState, const SSessionKey* key);
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ typedef struct SInputColumnInfoData {
|
||||||
int32_t totalRows; // total rows in current columnar data
|
int32_t totalRows; // total rows in current columnar data
|
||||||
int32_t startRowIndex; // handle started row index
|
int32_t startRowIndex; // handle started row index
|
||||||
int64_t numOfRows; // the number of rows needs to be handled
|
int64_t numOfRows; // the number of rows needs to be handled
|
||||||
|
bool blankFill; // fill blank data to block for empty table
|
||||||
int32_t numOfInputCols; // PTS is not included
|
int32_t numOfInputCols; // PTS is not included
|
||||||
bool colDataSMAIsSet; // if agg is set or not
|
bool colDataSMAIsSet; // if agg is set or not
|
||||||
SColumnInfoData *pPTS; // primary timestamp column
|
SColumnInfoData *pPTS; // primary timestamp column
|
||||||
|
|
|
@ -126,6 +126,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_TAGS,
|
FUNCTION_TYPE_TAGS,
|
||||||
FUNCTION_TYPE_TBUID,
|
FUNCTION_TYPE_TBUID,
|
||||||
FUNCTION_TYPE_VGID,
|
FUNCTION_TYPE_VGID,
|
||||||
|
FUNCTION_TYPE_VGVER,
|
||||||
|
|
||||||
// internal function
|
// internal function
|
||||||
FUNCTION_TYPE_SELECT_VALUE = 3750,
|
FUNCTION_TYPE_SELECT_VALUE = 3750,
|
||||||
|
|
|
@ -420,6 +420,12 @@ typedef struct SDropCGroupStmt {
|
||||||
bool ignoreNotExists;
|
bool ignoreNotExists;
|
||||||
} SDropCGroupStmt;
|
} SDropCGroupStmt;
|
||||||
|
|
||||||
|
typedef struct SAlterClusterStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char config[TSDB_DNODE_CONFIG_LEN];
|
||||||
|
char value[TSDB_CLUSTER_VALUE_LEN];
|
||||||
|
} SAlterClusterStmt;
|
||||||
|
|
||||||
typedef struct SAlterLocalStmt {
|
typedef struct SAlterLocalStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char config[TSDB_DNODE_CONFIG_LEN];
|
char config[TSDB_DNODE_CONFIG_LEN];
|
||||||
|
|
|
@ -106,7 +106,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata
|
||||||
const struct SMetaData* pMetaData, SQuery* pQuery);
|
const struct SMetaData* pMetaData, SQuery* pQuery);
|
||||||
int32_t qContinueParseSql(SParseContext* pCxt, struct SCatalogReq* pCatalogReq, const struct SMetaData* pMetaData,
|
int32_t qContinueParseSql(SParseContext* pCxt, struct SCatalogReq* pCatalogReq, const struct SMetaData* pMetaData,
|
||||||
SQuery* pQuery);
|
SQuery* pQuery);
|
||||||
int32_t qContinueParsePostQuery(SParseContext* pCxt, SQuery* pQuery, void** pResRow);
|
int32_t qContinueParsePostQuery(SParseContext* pCxt, SQuery* pQuery, SSDataBlock* pBlock);
|
||||||
|
|
||||||
void qDestroyParseContext(SParseContext* pCxt);
|
void qDestroyParseContext(SParseContext* pCxt);
|
||||||
|
|
||||||
|
|
|
@ -96,9 +96,7 @@ int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
||||||
int32_t qStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t qStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t qEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t qEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t qPseudoTagFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t qTbUidFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
|
||||||
int32_t qVgIdFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
|
||||||
|
|
||||||
/* Aggregation functions */
|
/* Aggregation functions */
|
||||||
int32_t countScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t countScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
|
@ -59,10 +59,12 @@ int32_t streamStateSessionReset(SStreamState* pState, void* pVal);
|
||||||
int32_t streamStateSessionClear(SStreamState* pState);
|
int32_t streamStateSessionClear(SStreamState* pState);
|
||||||
int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||||
|
int32_t streamStateCountGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||||
int32_t streamStateSessionAllocWinBuffByNextPosition(SStreamState* pState, SStreamStateCur* pCur,
|
int32_t streamStateSessionAllocWinBuffByNextPosition(SStreamState* pState, SStreamStateCur* pCur,
|
||||||
const SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
const SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
|
|
||||||
SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key);
|
||||||
|
SStreamStateCur* streamStateCountSeekKeyPrev(SStreamState* pState, const SSessionKey* pKey, COUNT_TYPE count);
|
||||||
SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key);
|
||||||
SStreamStateCur* streamStateSessionSeekKeyCurrentNext(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* streamStateSessionSeekKeyCurrentNext(SStreamState* pState, const SSessionKey* key);
|
||||||
|
|
||||||
|
@ -82,6 +84,7 @@ void streamStateFreeVal(void* val);
|
||||||
|
|
||||||
// count window
|
// count window
|
||||||
int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen);
|
int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen);
|
||||||
|
int32_t streamStateCountWinAdd(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
|
|
||||||
SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key);
|
SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key);
|
||||||
SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key);
|
SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key);
|
||||||
|
|
|
@ -324,12 +324,13 @@ typedef struct SStreamStatus {
|
||||||
int8_t taskStatus;
|
int8_t taskStatus;
|
||||||
int8_t downstreamReady; // downstream tasks are all ready now, if this flag is set
|
int8_t downstreamReady; // downstream tasks are all ready now, if this flag is set
|
||||||
int8_t schedStatus;
|
int8_t schedStatus;
|
||||||
int32_t schedIdleTime; // idle time before invoke again
|
|
||||||
int64_t lastExecTs; // last exec time stamp
|
|
||||||
int8_t statusBackup;
|
int8_t statusBackup;
|
||||||
bool appendTranstateBlock; // has append the transfer state data block already
|
int32_t schedIdleTime; // idle time before invoke again
|
||||||
int32_t timerActive; // timer is active
|
int32_t timerActive; // timer is active
|
||||||
|
int64_t lastExecTs; // last exec time stamp
|
||||||
int32_t inScanHistorySentinel;
|
int32_t inScanHistorySentinel;
|
||||||
|
bool appendTranstateBlock; // has append the transfer state data block already
|
||||||
|
bool supplementaryWalscan; // complete the supplementary wal scan or not
|
||||||
} SStreamStatus;
|
} SStreamStatus;
|
||||||
|
|
||||||
typedef struct SDataRange {
|
typedef struct SDataRange {
|
||||||
|
@ -530,7 +531,7 @@ typedef struct SStreamMeta {
|
||||||
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
||||||
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo);
|
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo);
|
||||||
|
|
||||||
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, bool fillHistory, int64_t triggerParam,
|
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool fillHistory, int64_t triggerParam,
|
||||||
SArray* pTaskList, bool hasFillhistory);
|
SArray* pTaskList, bool hasFillhistory);
|
||||||
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
||||||
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
||||||
|
|
|
@ -41,6 +41,8 @@ typedef int32_t (*_state_file_remove_fn)(SStreamFileState* pFileState, const voi
|
||||||
typedef int32_t (*_state_file_get_fn)(SStreamFileState* pFileState, void* pKey, void* data, int32_t* pDataLen);
|
typedef int32_t (*_state_file_get_fn)(SStreamFileState* pFileState, void* pKey, void* data, int32_t* pDataLen);
|
||||||
typedef int32_t (*_state_file_clear_fn)(SStreamState* pState);
|
typedef int32_t (*_state_file_clear_fn)(SStreamState* pState);
|
||||||
|
|
||||||
|
typedef int32_t (*range_cmpr_fn)(const SSessionKey* pWin1, const SSessionKey* pWin2);
|
||||||
|
|
||||||
SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
|
SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
|
||||||
GetTsFun fp, void* pFile, TSKEY delMark, const char* taskId,
|
GetTsFun fp, void* pFile, TSKEY delMark, const char* taskId,
|
||||||
int64_t checkpointId, int8_t type);
|
int64_t checkpointId, int8_t type);
|
||||||
|
@ -90,9 +92,10 @@ void sessionWinStateCleanup(void* pBuff);
|
||||||
SStreamStateCur* sessionWinStateSeekKeyCurrentPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
SStreamStateCur* sessionWinStateSeekKeyCurrentPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
||||||
SStreamStateCur* sessionWinStateSeekKeyCurrentNext(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
SStreamStateCur* sessionWinStateSeekKeyCurrentNext(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
||||||
SStreamStateCur* sessionWinStateSeekKeyNext(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
SStreamStateCur* sessionWinStateSeekKeyNext(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
||||||
|
SStreamStateCur* countWinStateSeekKeyPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey, COUNT_TYPE count);
|
||||||
int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur);
|
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur);
|
||||||
int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey);
|
int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey, range_cmpr_fn cmpFn);
|
||||||
|
|
||||||
// state window
|
// state window
|
||||||
int32_t getStateWinResultBuff(SStreamFileState* pFileState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
int32_t getStateWinResultBuff(SStreamFileState* pFileState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||||
|
@ -100,6 +103,7 @@ int32_t getStateWinResultBuff(SStreamFileState* pFileState, SSessionKey* key, ch
|
||||||
|
|
||||||
// count window
|
// count window
|
||||||
int32_t getCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal, int32_t* pVLen);
|
int32_t getCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal, int32_t* pVLen);
|
||||||
|
int32_t createCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,10 @@ void syslog(int unused, const char *format, ...);
|
||||||
do { \
|
do { \
|
||||||
prctl(PR_SET_NAME, (name)); \
|
prctl(PR_SET_NAME, (name)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#define getThreadName(name) \
|
||||||
|
do { \
|
||||||
|
prctl(PR_GET_NAME, (name)); \
|
||||||
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// Windows
|
// Windows
|
||||||
|
|
|
@ -414,6 +414,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MNODE_ONLY_TWO_MNODE TAOS_DEF_ERROR_CODE(0, 0x0414) // internal
|
#define TSDB_CODE_MNODE_ONLY_TWO_MNODE TAOS_DEF_ERROR_CODE(0, 0x0414) // internal
|
||||||
#define TSDB_CODE_MNODE_NO_NEED_RESTORE TAOS_DEF_ERROR_CODE(0, 0x0415) // internal
|
#define TSDB_CODE_MNODE_NO_NEED_RESTORE TAOS_DEF_ERROR_CODE(0, 0x0415) // internal
|
||||||
#define TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0416)
|
#define TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0416)
|
||||||
|
#define TSDB_CODE_DNODE_NO_MACHINE_CODE TAOS_DEF_ERROR_CODE(0, 0x0417)
|
||||||
|
|
||||||
// mnode-sma
|
// mnode-sma
|
||||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||||
|
@ -531,7 +532,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_QRY_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0725)
|
#define TSDB_CODE_QRY_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0725)
|
||||||
#define TSDB_CODE_QRY_TASK_CANCELLING TAOS_DEF_ERROR_CODE(0, 0x0726)
|
#define TSDB_CODE_QRY_TASK_CANCELLING TAOS_DEF_ERROR_CODE(0, 0x0726)
|
||||||
#define TSDB_CODE_QRY_TASK_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0727)
|
#define TSDB_CODE_QRY_TASK_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0727)
|
||||||
#define TSDB_CODE_QRY_DUPLICATTED_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0728)
|
#define TSDB_CODE_QRY_DUPLICATED_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0728)
|
||||||
#define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0729)
|
#define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0729)
|
||||||
#define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x072A)
|
#define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x072A)
|
||||||
#define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x072B)
|
#define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x072B)
|
||||||
|
@ -554,7 +555,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_GRANT_STREAM_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0807)
|
#define TSDB_CODE_GRANT_STREAM_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0807)
|
||||||
#define TSDB_CODE_GRANT_SPEED_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0808)
|
#define TSDB_CODE_GRANT_SPEED_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0808)
|
||||||
#define TSDB_CODE_GRANT_STORAGE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0809)
|
#define TSDB_CODE_GRANT_STORAGE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0809)
|
||||||
#define TSDB_CODE_GRANT_QUERYTIME_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080A)
|
#define TSDB_CODE_GRANT_SUBSCRIPTION_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080A)
|
||||||
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
|
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
|
||||||
#define TSDB_CODE_GRANT_STABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080C)
|
#define TSDB_CODE_GRANT_STABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080C)
|
||||||
#define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D)
|
#define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D)
|
||||||
|
@ -563,8 +564,19 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_GRANT_PAR_DEC_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0810)
|
#define TSDB_CODE_GRANT_PAR_DEC_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0810)
|
||||||
#define TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0811)
|
#define TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0811)
|
||||||
#define TSDB_CODE_GRANT_GEN_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0812)
|
#define TSDB_CODE_GRANT_GEN_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0812)
|
||||||
#define TSDB_CODE_GRANT_GEN_APP_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0813)
|
#define TSDB_CODE_GRANT_GEN_ACTIVE_LEN TAOS_DEF_ERROR_CODE(0, 0x0813)
|
||||||
#define TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0814)
|
#define TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0814)
|
||||||
|
#define TSDB_CODE_GRANT_PAR_IVLD_DIST TAOS_DEF_ERROR_CODE(0, 0x0815)
|
||||||
|
#define TSDB_CODE_GRANT_UNLICENSED_CLUSTER TAOS_DEF_ERROR_CODE(0, 0x0816)
|
||||||
|
#define TSDB_CODE_GRANT_LACK_OF_BASIC TAOS_DEF_ERROR_CODE(0, 0x0817)
|
||||||
|
#define TSDB_CODE_GRANT_OBJ_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0818)
|
||||||
|
#define TSDB_CODE_GRANT_LAST_ACTIVE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0819)
|
||||||
|
#define TSDB_CODE_GRANT_MACHINES_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0820)
|
||||||
|
#define TSDB_CODE_GRANT_OPT_EXPIRE_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0821)
|
||||||
|
#define TSDB_CODE_GRANT_DUPLICATED_ACTIVE TAOS_DEF_ERROR_CODE(0, 0x0822)
|
||||||
|
#define TSDB_CODE_GRANT_VIEW_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0823)
|
||||||
|
#define TSDB_CODE_GRANT_CSV_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0824)
|
||||||
|
#define TSDB_CODE_GRANT_AUDIT_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0825)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_UTIL_BASE58_H_
|
||||||
|
#define _TD_UTIL_BASE58_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t *base58_decode(const char *value, size_t inlen, int32_t *outlen);
|
||||||
|
char *base58_encode(const uint8_t *value, int32_t vlen);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_UTIL_BASE58_H_*/
|
|
@ -264,6 +264,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_JOB_STATUS_LEN 32
|
#define TSDB_JOB_STATUS_LEN 32
|
||||||
|
|
||||||
#define TSDB_CLUSTER_ID_LEN 40
|
#define TSDB_CLUSTER_ID_LEN 40
|
||||||
|
#define TSDB_MACHINE_ID_LEN 24
|
||||||
#define TSDB_FQDN_LEN 128
|
#define TSDB_FQDN_LEN 128
|
||||||
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
||||||
#define TSDB_IPv4ADDR_LEN 16
|
#define TSDB_IPv4ADDR_LEN 16
|
||||||
|
@ -285,6 +286,8 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DNODE_CONFIG_LEN 128
|
#define TSDB_DNODE_CONFIG_LEN 128
|
||||||
#define TSDB_DNODE_VALUE_LEN 256
|
#define TSDB_DNODE_VALUE_LEN 256
|
||||||
|
|
||||||
|
#define TSDB_CLUSTER_VALUE_LEN 1000
|
||||||
|
|
||||||
#define TSDB_ACTIVE_KEY_LEN 109
|
#define TSDB_ACTIVE_KEY_LEN 109
|
||||||
#define TSDB_CONN_ACTIVE_KEY_LEN 255
|
#define TSDB_CONN_ACTIVE_KEY_LEN 255
|
||||||
|
|
||||||
|
|
|
@ -880,19 +880,21 @@ static bool incompletaFileParsing(SNode* pStmt) {
|
||||||
return QUERY_NODE_VNODE_MODIFY_STMT != nodeType(pStmt) ? false : ((SVnodeModifyOpStmt*)pStmt)->fileProcessing;
|
return QUERY_NODE_VNODE_MODIFY_STMT != nodeType(pStmt) ? false : ((SVnodeModifyOpStmt*)pStmt)->fileProcessing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void continuePostSubQuery(SRequestObj* pRequest, TAOS_ROW row) {
|
void continuePostSubQuery(SRequestObj* pRequest, SSDataBlock* pBlock) {
|
||||||
SSqlCallbackWrapper* pWrapper = pRequest->pWrapper;
|
SSqlCallbackWrapper* pWrapper = pRequest->pWrapper;
|
||||||
|
|
||||||
int32_t code = nodesAcquireAllocator(pWrapper->pParseCtx->allocatorId);
|
int32_t code = nodesAcquireAllocator(pWrapper->pParseCtx->allocatorId);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
int64_t analyseStart = taosGetTimestampUs();
|
int64_t analyseStart = taosGetTimestampUs();
|
||||||
code = qContinueParsePostQuery(pWrapper->pParseCtx, pRequest->pQuery, (void**)row);
|
code = qContinueParsePostQuery(pWrapper->pParseCtx, pRequest->pQuery, pBlock);
|
||||||
pRequest->metric.analyseCostUs += taosGetTimestampUs() - analyseStart;
|
pRequest->metric.analyseCostUs += taosGetTimestampUs() - analyseStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = qContinuePlanPostQuery(pRequest->pPostPlan);
|
code = qContinuePlanPostQuery(pRequest->pPostPlan);
|
||||||
}
|
}
|
||||||
nodesReleaseAllocator(pWrapper->pParseCtx->allocatorId);
|
|
||||||
|
|
||||||
|
nodesReleaseAllocator(pWrapper->pParseCtx->allocatorId);
|
||||||
handleQueryAnslyseRes(pWrapper, NULL, code);
|
handleQueryAnslyseRes(pWrapper, NULL, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,6 +918,43 @@ void returnToUser(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* createResultBlock(TAOS_RES* pRes, int32_t numOfRows) {
|
||||||
|
int64_t lastTs = 0;
|
||||||
|
|
||||||
|
TAOS_FIELD* pResFields = taos_fetch_fields(pRes);
|
||||||
|
int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
|
||||||
|
SSDataBlock* pBlock = createDataBlock();
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < numOfFields; ++i) {
|
||||||
|
SColumnInfoData colInfoData = createColumnInfoData(pResFields[i].type, pResFields[i].bytes, i + 1);
|
||||||
|
blockDataAppendColInfo(pBlock, &colInfoData);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataEnsureCapacity(pBlock, numOfRows);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
|
TAOS_ROW pRow = taos_fetch_row(pRes);
|
||||||
|
int64_t ts = *(int64_t*)pRow[0];
|
||||||
|
if (lastTs < ts) {
|
||||||
|
lastTs = ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int32_t j = 0; j < numOfFields; ++j) {
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, j);
|
||||||
|
colDataSetVal(pColInfoData, i, pRow[j], false);
|
||||||
|
}
|
||||||
|
|
||||||
|
tscDebug("lastKey:%" PRId64 " vgId:%d, vgVer:%" PRId64, ts, *(int32_t*)pRow[1], *(int64_t*)pRow[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pBlock->info.window.ekey = lastTs;
|
||||||
|
pBlock->info.rows = numOfRows;
|
||||||
|
|
||||||
|
tscDebug("lastKey:%"PRId64" numOfRows:%d from all vgroups", lastTs, numOfRows);
|
||||||
|
return pBlock;
|
||||||
|
}
|
||||||
|
|
||||||
void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
|
void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
|
||||||
SRequestObj* pRequest = (SRequestObj*)res;
|
SRequestObj* pRequest = (SRequestObj*)res;
|
||||||
if (pRequest->code) {
|
if (pRequest->code) {
|
||||||
|
@ -923,19 +962,17 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_ROW row = NULL;
|
SSDataBlock* pBlock = createResultBlock(res, rowNum);
|
||||||
if (rowNum > 0) {
|
|
||||||
row = taos_fetch_row(res); // for single row only now
|
|
||||||
}
|
|
||||||
|
|
||||||
SRequestObj* pNextReq = acquireRequest(pRequest->relation.nextRefId);
|
SRequestObj* pNextReq = acquireRequest(pRequest->relation.nextRefId);
|
||||||
if (pNextReq) {
|
if (pNextReq) {
|
||||||
continuePostSubQuery(pNextReq, row);
|
continuePostSubQuery(pNextReq, pBlock);
|
||||||
releaseRequest(pRequest->relation.nextRefId);
|
releaseRequest(pRequest->relation.nextRefId);
|
||||||
} else {
|
} else {
|
||||||
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self,
|
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self,
|
||||||
pRequest->relation.nextRefId, pRequest->requestId);
|
pRequest->relation.nextRefId, pRequest->requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockDataDestroy(pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handlePostSubQuery(SSqlCallbackWrapper* pWrapper) {
|
void handlePostSubQuery(SSqlCallbackWrapper* pWrapper) {
|
||||||
|
|
|
@ -155,6 +155,7 @@ typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
SArray* vgs; // SArray<SMqClientVg>
|
SArray* vgs; // SArray<SMqClientVg>
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
|
int8_t noPrivilege;
|
||||||
} SMqClientTopic;
|
} SMqClientTopic;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -739,6 +740,30 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
|
||||||
|
|
||||||
int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
|
int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
if (pMsg) {
|
if (pMsg) {
|
||||||
|
SMqHbRsp rsp = {0};
|
||||||
|
tDeserializeSMqHbRsp(pMsg->pData, pMsg->len, &rsp);
|
||||||
|
|
||||||
|
int64_t refId = *(int64_t*)param;
|
||||||
|
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||||
|
if (tmq != NULL) {
|
||||||
|
taosWLockLatch(&tmq->lock);
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(rsp.topicPrivileges); i++){
|
||||||
|
STopicPrivilege* privilege = taosArrayGet(rsp.topicPrivileges, i);
|
||||||
|
if(privilege->noPrivilege == 1){
|
||||||
|
int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics);
|
||||||
|
for (int32_t j = 0; j < topicNumCur; j++) {
|
||||||
|
SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, j);
|
||||||
|
if(strcmp(pTopicCur->topicName, privilege->topic) == 0){
|
||||||
|
tscInfo("consumer:0x%" PRIx64 ", has no privilege, topic:%s", tmq->consumerId, privilege->topic);
|
||||||
|
pTopicCur->noPrivilege = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosWUnLockLatch(&tmq->lock);
|
||||||
|
taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||||
|
}
|
||||||
|
tDeatroySMqHbRsp(&rsp);
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
}
|
}
|
||||||
|
@ -809,7 +834,9 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
||||||
|
|
||||||
sendInfo->requestId = generateRequestId();
|
sendInfo->requestId = generateRequestId();
|
||||||
sendInfo->requestObjRefId = 0;
|
sendInfo->requestObjRefId = 0;
|
||||||
sendInfo->param = NULL;
|
sendInfo->paramFreeFp = taosMemoryFree;
|
||||||
|
sendInfo->param = taosMemoryMalloc(sizeof(int64_t));
|
||||||
|
*(int64_t *)sendInfo->param = refId;
|
||||||
sendInfo->fp = tmqHbCb;
|
sendInfo->fp = tmqHbCb;
|
||||||
sendInfo->msgType = TDMT_MND_TMQ_HB;
|
sendInfo->msgType = TDMT_MND_TMQ_HB;
|
||||||
|
|
||||||
|
@ -1705,7 +1732,10 @@ static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
||||||
for (int i = 0; i < numOfTopics; i++) {
|
for (int i = 0; i < numOfTopics; i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
int32_t numOfVg = taosArrayGetSize(pTopic->vgs);
|
int32_t numOfVg = taosArrayGetSize(pTopic->vgs);
|
||||||
|
if(pTopic->noPrivilege){
|
||||||
|
tscDebug("consumer:0x%" PRIx64 " has no privilegr for topic:%s", tmq->consumerId, pTopic->topicName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int j = 0; j < numOfVg; j++) {
|
for (int j = 0; j < numOfVg; j++) {
|
||||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
||||||
if (taosGetTimestampMs() - pVg->emptyBlockReceiveTs < EMPTY_BLOCK_POLL_IDLE_DURATION) { // less than 10ms
|
if (taosGetTimestampMs() - pVg->emptyBlockReceiveTs < EMPTY_BLOCK_POLL_IDLE_DURATION) { // less than 10ms
|
||||||
|
|
|
@ -829,7 +829,10 @@ TEST(clientCase, projection_query_tables) {
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create stable st2 (ts timestamp, k int, f varchar(4096)) tags(a int)");
|
// TAOS_RES* pRes = taos_query(pConn, "select tbname, last(ts) from abc1.stable_1 group by tbname");
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create stream stream_1 trigger at_once fill_history 1 ignore expired 0 into str_res1 as select _wstart as ts, count(*) from stable_1 interval(10s);");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,7 @@ static const SSysDbTableSchema dnodesSchema[] = {
|
||||||
{.name = "reboot_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
{.name = "reboot_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||||
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
{.name = "active_code", .bytes = TSDB_ACTIVE_KEY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "machine_id", .bytes = TSDB_MACHINE_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "c_active_code", .bytes = TSDB_CONN_ACTIVE_KEY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -349,6 +348,24 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
||||||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema useGrantsFullSchema[] = {
|
||||||
|
{.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "display_name", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "expire", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "limits", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema useGrantsLogsSchema[] = {
|
||||||
|
{.name = "state", .bytes = 1536 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "active", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
{.name = "machine", .bytes = 9088 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema useMachinesSchema[] = {
|
||||||
|
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
{.name = "machine", .bytes = 6016 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
};
|
||||||
|
|
||||||
static const SSysTableMeta infosMeta[] = {
|
static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||||
|
@ -378,6 +395,9 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false},
|
{TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false},
|
||||||
{TSDB_INS_TABLE_COMPACTS, userCompactsSchema, tListLen(userCompactsSchema), false},
|
{TSDB_INS_TABLE_COMPACTS, userCompactsSchema, tListLen(userCompactsSchema), false},
|
||||||
{TSDB_INS_TABLE_COMPACT_DETAILS, userCompactsDetailSchema, tListLen(userCompactsDetailSchema), false},
|
{TSDB_INS_TABLE_COMPACT_DETAILS, userCompactsDetailSchema, tListLen(userCompactsDetailSchema), false},
|
||||||
|
{TSDB_INS_TABLE_GRANTS_FULL, useGrantsFullSchema, tListLen(useGrantsFullSchema), false},
|
||||||
|
{TSDB_INS_TABLE_GRANTS_LOGS, useGrantsLogsSchema, tListLen(useGrantsLogsSchema), false},
|
||||||
|
{TSDB_INS_TABLE_MACHINES, useMachinesSchema, tListLen(useMachinesSchema), false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema connectionsSchema[] = {
|
static const SSysDbTableSchema connectionsSchema[] = {
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "cus_name.h"
|
#include "cus_name.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GRANT_CFG_DECLARE;
|
// GRANT_CFG_DECLARE;
|
||||||
|
|
||||||
SConfig *tsCfg = NULL;
|
SConfig *tsCfg = NULL;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ int32_t tsNumOfMnodeQueryThreads = 4;
|
||||||
int32_t tsNumOfMnodeFetchThreads = 1;
|
int32_t tsNumOfMnodeFetchThreads = 1;
|
||||||
int32_t tsNumOfMnodeReadThreads = 1;
|
int32_t tsNumOfMnodeReadThreads = 1;
|
||||||
int32_t tsNumOfVnodeQueryThreads = 4;
|
int32_t tsNumOfVnodeQueryThreads = 4;
|
||||||
float tsRatioOfVnodeStreamThreads = 1.0;
|
float tsRatioOfVnodeStreamThreads = 0.5F;
|
||||||
int32_t tsNumOfVnodeFetchThreads = 4;
|
int32_t tsNumOfVnodeFetchThreads = 4;
|
||||||
int32_t tsNumOfVnodeRsmaThreads = 2;
|
int32_t tsNumOfVnodeRsmaThreads = 2;
|
||||||
int32_t tsNumOfQnodeQueryThreads = 4;
|
int32_t tsNumOfQnodeQueryThreads = 4;
|
||||||
|
@ -622,7 +622,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
0)
|
0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (cfgAddFloat(pCfg, "ratioOfVnodeStreamThreads", tsRatioOfVnodeStreamThreads, 0.01, 10, CFG_SCOPE_SERVER,
|
if (cfgAddFloat(pCfg, "ratioOfVnodeStreamThreads", tsRatioOfVnodeStreamThreads, 0.01, 4, CFG_SCOPE_SERVER,
|
||||||
CFG_DYN_NONE) != 0)
|
CFG_DYN_NONE) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
if (cfgAddBool(pCfg, "experimental", tsExperimental, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1;
|
if (cfgAddBool(pCfg, "experimental", tsExperimental, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1;
|
||||||
|
|
||||||
GRANT_CFG_ADD;
|
// GRANT_CFG_ADD;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,7 +1229,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsExperimental = cfgGetItem(pCfg, "experimental")->bval;
|
tsExperimental = cfgGetItem(pCfg, "experimental")->bval;
|
||||||
|
|
||||||
GRANT_CFG_GET;
|
// GRANT_CFG_GET;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,6 @@
|
||||||
|
|
||||||
#ifndef _GRANT
|
#ifndef _GRANT
|
||||||
|
|
||||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
int32_t grantCheck(EGrantType grant) {return TSDB_CODE_SUCCESS;}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1163,9 +1163,11 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
if (tEncodeI64(&encoder, pReq->updateTime) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->updateTime) < 0) return -1;
|
||||||
if (tEncodeFloat(&encoder, pReq->numOfCores) < 0) return -1;
|
if (tEncodeFloat(&encoder, pReq->numOfCores) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfSupportVnodes) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfSupportVnodes) < 0) return -1;
|
||||||
|
if (tEncodeI32v(&encoder, pReq->numOfDiskCfg) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->memTotal) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->memTotal) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->memAvail) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->memAvail) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->dnodeEp) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->dnodeEp) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->machineId) < 0) return -1;
|
||||||
|
|
||||||
// cluster cfg
|
// cluster cfg
|
||||||
if (tEncodeI32(&encoder, pReq->clusterCfg.statusInterval) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->clusterCfg.statusInterval) < 0) return -1;
|
||||||
|
@ -1253,9 +1255,11 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
if (tDecodeI64(&decoder, &pReq->updateTime) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->updateTime) < 0) return -1;
|
||||||
if (tDecodeFloat(&decoder, &pReq->numOfCores) < 0) return -1;
|
if (tDecodeFloat(&decoder, &pReq->numOfCores) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfSupportVnodes) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfSupportVnodes) < 0) return -1;
|
||||||
|
if (tDecodeI32v(&decoder, &pReq->numOfDiskCfg) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->memTotal) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->memTotal) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->memAvail) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->memAvail) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->dnodeEp) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->dnodeEp) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->machineId) < 0) return -1;
|
||||||
|
|
||||||
// cluster cfg
|
// cluster cfg
|
||||||
if (tDecodeI32(&decoder, &pReq->clusterCfg.statusInterval) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->clusterCfg.statusInterval) < 0) return -1;
|
||||||
|
@ -2266,6 +2270,37 @@ int32_t tDeserializeSGetUserWhiteListRsp(void *buf, int32_t bufLen, SGetUserWhit
|
||||||
|
|
||||||
void tFreeSGetUserWhiteListRsp(SGetUserWhiteListRsp *pRsp) { taosMemoryFree(pRsp->pWhiteLists); }
|
void tFreeSGetUserWhiteListRsp(SGetUserWhiteListRsp *pRsp) { taosMemoryFree(pRsp->pWhiteLists); }
|
||||||
|
|
||||||
|
int32_t tSerializeSMCfgClusterReq(void *buf, int32_t bufLen, SMCfgClusterReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->config) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->value) < 0) return -1;
|
||||||
|
ENCODESQL();
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCfgClusterReq(void *buf, int32_t bufLen, SMCfgClusterReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->config) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->value) < 0) return -1;
|
||||||
|
DECODESQL();
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSMCfgClusterReq(SMCfgClusterReq *pReq) { FREESQL(); }
|
||||||
|
|
||||||
int32_t tSerializeSCreateDropMQSNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
int32_t tSerializeSCreateDropMQSNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
@ -6139,6 +6174,55 @@ int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tDeatroySMqHbRsp(SMqHbRsp *pRsp) {
|
||||||
|
taosArrayDestroy(pRsp->topicPrivileges);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
|
||||||
|
int32_t sz = taosArrayGetSize(pRsp->topicPrivileges);
|
||||||
|
if (tEncodeI32(&encoder, sz) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
STopicPrivilege *privilege = (STopicPrivilege *)taosArrayGet(pRsp->topicPrivileges, i);
|
||||||
|
if (tEncodeCStr(&encoder, privilege->topic) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, privilege->noPrivilege) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, (char *)buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
|
||||||
|
int32_t sz = 0;
|
||||||
|
if (tDecodeI32(&decoder, &sz) < 0) return -1;
|
||||||
|
if (sz > 0) {
|
||||||
|
pRsp->topicPrivileges = taosArrayInit(sz, sizeof(STopicPrivilege));
|
||||||
|
if (NULL == pRsp->topicPrivileges) return -1;
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
STopicPrivilege *data = taosArrayReserve(pRsp->topicPrivileges, 1);
|
||||||
|
if (tDecodeCStrTo(&decoder, data->topic) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &data->noPrivilege) < 0) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tDeatroySMqHbReq(SMqHbReq *pReq) {
|
int32_t tDeatroySMqHbReq(SMqHbReq *pReq) {
|
||||||
for (int i = 0; i < taosArrayGetSize(pReq->topics); i++) {
|
for (int i = 0; i < taosArrayGetSize(pReq->topics); i++) {
|
||||||
TopicOffsetRows *vgs = taosArrayGet(pReq->topics, i);
|
TopicOffsetRows *vgs = taosArrayGet(pReq->topics, i);
|
||||||
|
@ -6194,7 +6278,7 @@ int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) {
|
||||||
if (NULL == pReq->topics) return -1;
|
if (NULL == pReq->topics) return -1;
|
||||||
for (int32_t i = 0; i < sz; ++i) {
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
TopicOffsetRows *data = taosArrayReserve(pReq->topics, 1);
|
TopicOffsetRows *data = taosArrayReserve(pReq->topics, 1);
|
||||||
tDecodeCStrTo(&decoder, data->topicName);
|
if (tDecodeCStrTo(&decoder, data->topicName) < 0) return -1;
|
||||||
int32_t szVgs = 0;
|
int32_t szVgs = 0;
|
||||||
if (tDecodeI32(&decoder, &szVgs) < 0) return -1;
|
if (tDecodeI32(&decoder, &szVgs) < 0) return -1;
|
||||||
if (szVgs > 0) {
|
if (szVgs > 0) {
|
||||||
|
@ -7168,6 +7252,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
|
|
||||||
if (tEncodeI8(&encoder, pReq->createStb) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->createStb) < 0) return -1;
|
||||||
if (tEncodeU64(&encoder, pReq->targetStbUid) < 0) return -1;
|
if (tEncodeU64(&encoder, pReq->targetStbUid) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeI32(&encoder, taosArrayGetSize(pReq->fillNullCols)) < 0) return -1;
|
if (tEncodeI32(&encoder, taosArrayGetSize(pReq->fillNullCols)) < 0) return -1;
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pReq->fillNullCols); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pReq->fillNullCols); ++i) {
|
||||||
SColLocation *pCol = taosArrayGet(pReq->fillNullCols, i);
|
SColLocation *pCol = taosArrayGet(pReq->fillNullCols, i);
|
||||||
|
@ -7175,10 +7260,19 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
if (tEncodeI16(&encoder, pCol->colId) < 0) return -1;
|
if (tEncodeI16(&encoder, pCol->colId) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pCol->type) < 0) return -1;
|
if (tEncodeI8(&encoder, pCol->type) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->igUpdate) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->igUpdate) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->lastTs) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->lastTs) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI32(&encoder, taosArrayGetSize(pReq->pVgroupVerList)) < 0) return -1;
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pReq->pVgroupVerList); ++i) {
|
||||||
|
SVgroupVer* p = taosArrayGet(pReq->pVgroupVerList, i);
|
||||||
|
if (tEncodeI32(&encoder, p->vgId) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, p->ver) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -7189,6 +7283,8 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStreamReq *pReq) {
|
int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStreamReq *pReq) {
|
||||||
int32_t sqlLen = 0;
|
int32_t sqlLen = 0;
|
||||||
int32_t astLen = 0;
|
int32_t astLen = 0;
|
||||||
|
int32_t numOfFillNullCols = 0;
|
||||||
|
int32_t numOfVgVer = 0;
|
||||||
|
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
@ -7240,7 +7336,6 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
}
|
}
|
||||||
if (tDecodeI8(&decoder, &pReq->createStb) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->createStb) < 0) return -1;
|
||||||
if (tDecodeU64(&decoder, &pReq->targetStbUid) < 0) return -1;
|
if (tDecodeU64(&decoder, &pReq->targetStbUid) < 0) return -1;
|
||||||
int32_t numOfFillNullCols = 0;
|
|
||||||
if (tDecodeI32(&decoder, &numOfFillNullCols) < 0) return -1;
|
if (tDecodeI32(&decoder, &numOfFillNullCols) < 0) return -1;
|
||||||
if (numOfFillNullCols > 0) {
|
if (numOfFillNullCols > 0) {
|
||||||
pReq->fillNullCols = taosArrayInit(numOfFillNullCols, sizeof(SColLocation));
|
pReq->fillNullCols = taosArrayInit(numOfFillNullCols, sizeof(SColLocation));
|
||||||
|
@ -7265,9 +7360,28 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
if (tDecodeI8(&decoder, &pReq->igUpdate) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->igUpdate) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->lastTs) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->lastTs) < 0) return -1;
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
if (tDecodeI32(&decoder, &numOfVgVer) < 0) return -1;
|
||||||
|
if (numOfVgVer > 0) {
|
||||||
|
pReq->pVgroupVerList = taosArrayInit(numOfVgVer, sizeof(SVgroupVer));
|
||||||
|
if (pReq->pVgroupVerList == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfVgVer; ++i) {
|
||||||
|
SVgroupVer v = {0};
|
||||||
|
if (tDecodeI32(&decoder, &v.vgId) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &v.ver) < 0) return -1;
|
||||||
|
if (taosArrayPush(pReq->pVgroupVerList, &v) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7339,10 +7453,11 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
|
||||||
if (NULL == pReq) {
|
if (NULL == pReq) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pReq->pTags);
|
|
||||||
taosMemoryFreeClear(pReq->sql);
|
taosMemoryFreeClear(pReq->sql);
|
||||||
taosMemoryFreeClear(pReq->ast);
|
taosMemoryFreeClear(pReq->ast);
|
||||||
|
taosArrayDestroy(pReq->pTags);
|
||||||
taosArrayDestroy(pReq->fillNullCols);
|
taosArrayDestroy(pReq->fillNullCols);
|
||||||
|
taosArrayDestroy(pReq->pVgroupVerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) {
|
int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) {
|
||||||
|
@ -7753,36 +7868,6 @@ static int32_t tDecodeSVSubmitBlk(SDecoder *pCoder, SVSubmitBlk *pBlock, int32_t
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSVSubmitReq(SEncoder *pCoder, const SVSubmitReq *pReq) {
|
|
||||||
int32_t nBlocks = taosArrayGetSize(pReq->pArray);
|
|
||||||
|
|
||||||
if (tStartEncode(pCoder) < 0) return -1;
|
|
||||||
|
|
||||||
if (tEncodeI32v(pCoder, pReq->flags) < 0) return -1;
|
|
||||||
if (tEncodeI32v(pCoder, nBlocks) < 0) return -1;
|
|
||||||
for (int32_t iBlock = 0; iBlock < nBlocks; iBlock++) {
|
|
||||||
if (tEncodeSVSubmitBlk(pCoder, (SVSubmitBlk *)taosArrayGet(pReq->pArray, iBlock), pReq->flags) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tEndEncode(pCoder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tDecodeSVSubmitReq(SDecoder *pCoder, SVSubmitReq *pReq) {
|
|
||||||
if (tStartDecode(pCoder) < 0) return -1;
|
|
||||||
|
|
||||||
if (tDecodeI32v(pCoder, &pReq->flags) < 0) return -1;
|
|
||||||
if (tDecodeI32v(pCoder, &pReq->nBlocks) < 0) return -1;
|
|
||||||
pReq->pBlocks = tDecoderMalloc(pCoder, sizeof(SVSubmitBlk) * pReq->nBlocks);
|
|
||||||
if (pReq->pBlocks == NULL) return -1;
|
|
||||||
for (int32_t iBlock = 0; iBlock < pReq->nBlocks; iBlock++) {
|
|
||||||
if (tDecodeSVSubmitBlk(pCoder, pReq->pBlocks + iBlock, pReq->flags) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tEndDecode(pCoder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBlock) {
|
static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBlock) {
|
||||||
if (tStartEncode(pEncoder) < 0) return -1;
|
if (tStartEncode(pEncoder) < 0) return -1;
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,15 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
req.updateTime = pMgmt->pData->updateTime;
|
req.updateTime = pMgmt->pData->updateTime;
|
||||||
req.numOfCores = tsNumOfCores;
|
req.numOfCores = tsNumOfCores;
|
||||||
req.numOfSupportVnodes = tsNumOfSupportVnodes;
|
req.numOfSupportVnodes = tsNumOfSupportVnodes;
|
||||||
|
req.numOfDiskCfg = tsDiskCfgNum;
|
||||||
req.memTotal = tsTotalMemoryKB * 1024;
|
req.memTotal = tsTotalMemoryKB * 1024;
|
||||||
req.memAvail = req.memTotal - tsRpcQueueMemoryAllowed - 16 * 1024 * 1024;
|
req.memAvail = req.memTotal - tsRpcQueueMemoryAllowed - 16 * 1024 * 1024;
|
||||||
tstrncpy(req.dnodeEp, tsLocalEp, TSDB_EP_LEN);
|
tstrncpy(req.dnodeEp, tsLocalEp, TSDB_EP_LEN);
|
||||||
|
char *machine = tGetMachineId();
|
||||||
|
if (machine) {
|
||||||
|
tstrncpy(req.machineId, machine, TSDB_MACHINE_ID_LEN + 1);
|
||||||
|
taosMemoryFreeClear(machine);
|
||||||
|
}
|
||||||
|
|
||||||
req.clusterCfg.statusInterval = tsStatusInterval;
|
req.clusterCfg.statusInterval = tsStatusInterval;
|
||||||
req.clusterCfg.checkTime = 0;
|
req.clusterCfg.checkTime = 0;
|
||||||
|
@ -319,7 +325,7 @@ int32_t dmAppendVariablesToBlock(SSDataBlock *pBlock, int32_t dnodeId) {
|
||||||
|
|
||||||
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
||||||
SConfigItem *pItem = taosArrayGet(tsCfg->array, i);
|
SConfigItem *pItem = taosArrayGet(tsCfg->array, i);
|
||||||
GRANT_CFG_SKIP;
|
// GRANT_CFG_SKIP;
|
||||||
|
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||||
colDataSetVal(pColInfo, i, (const char *)&dnodeId, false);
|
colDataSetVal(pColInfo, i, (const char *)&dnodeId, false);
|
||||||
|
|
|
@ -163,7 +163,6 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_PAUSE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_PAUSE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RESUME_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RESUME_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_WHITELIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_WHITELIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -193,6 +192,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_VIEW_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_VIEW_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_CLUSTER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
@ -72,7 +72,6 @@ typedef struct SUdfdData {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
} SUdfdData;
|
} SUdfdData;
|
||||||
|
|
||||||
#ifndef TD_MODULE_OPTIMIZE
|
|
||||||
typedef struct SDnode {
|
typedef struct SDnode {
|
||||||
int8_t once;
|
int8_t once;
|
||||||
bool stop;
|
bool stop;
|
||||||
|
@ -86,21 +85,6 @@ typedef struct SDnode {
|
||||||
SMgmtWrapper wrappers[NODE_END];
|
SMgmtWrapper wrappers[NODE_END];
|
||||||
SDnodeTrans trans;
|
SDnodeTrans trans;
|
||||||
} SDnode;
|
} SDnode;
|
||||||
#else
|
|
||||||
typedef struct SDnode {
|
|
||||||
int8_t once;
|
|
||||||
bool stop;
|
|
||||||
EDndRunStatus status;
|
|
||||||
SStartupInfo startup;
|
|
||||||
SDnodeTrans trans;
|
|
||||||
SUdfdData udfdData;
|
|
||||||
TdThreadMutex mutex;
|
|
||||||
TdFilePtr lockfile;
|
|
||||||
SDnodeData data;
|
|
||||||
STfs *pTfs;
|
|
||||||
SMgmtWrapper wrappers[NODE_END];
|
|
||||||
} SDnode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// dmEnv.c
|
// dmEnv.c
|
||||||
SDnode *dmInstance();
|
SDnode *dmInstance();
|
||||||
|
@ -115,12 +99,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
||||||
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||||
int32_t dmInitVars(SDnode *pDnode);
|
int32_t dmInitVars(SDnode *pDnode);
|
||||||
void dmClearVars(SDnode *pDnode);
|
void dmClearVars(SDnode *pDnode);
|
||||||
#ifdef TD_MODULE_OPTIMIZE
|
|
||||||
int32_t dmInitModule(SDnode *pDnode, SMgmtWrapper *wrappers);
|
|
||||||
bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper);
|
|
||||||
#else
|
|
||||||
int32_t dmInitModule(SDnode *pDnode);
|
int32_t dmInitModule(SDnode *pDnode);
|
||||||
#endif
|
|
||||||
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
|
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper);
|
||||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus stype);
|
||||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
@ -143,11 +122,7 @@ void dmCleanupClient(SDnode *pDnode);
|
||||||
void dmCleanupStatusClient(SDnode *pDnode);
|
void dmCleanupStatusClient(SDnode *pDnode);
|
||||||
void dmCleanupSyncClient(SDnode *pDnode);
|
void dmCleanupSyncClient(SDnode *pDnode);
|
||||||
SMsgCb dmGetMsgcb(SDnode *pDnode);
|
SMsgCb dmGetMsgcb(SDnode *pDnode);
|
||||||
#ifdef TD_MODULE_OPTIMIZE
|
|
||||||
int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers);
|
|
||||||
#else
|
|
||||||
int32_t dmInitMsgHandle(SDnode *pDnode);
|
int32_t dmInitMsgHandle(SDnode *pDnode);
|
||||||
#endif
|
|
||||||
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dmMonitor.c
|
// dmMonitor.c
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TD_MODULE_OPTIMIZE
|
|
||||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||||
|
|
||||||
|
@ -38,7 +37,6 @@ static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||||
|
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t dmInitDnode(SDnode *pDnode) {
|
int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
dDebug("start to create dnode");
|
dDebug("start to create dnode");
|
||||||
|
@ -81,15 +79,9 @@ int32_t dmInitDnode(SDnode *pDnode) {
|
||||||
if (pDnode->lockfile == NULL) {
|
if (pDnode->lockfile == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
#ifdef TD_MODULE_OPTIMIZE
|
|
||||||
if (dmInitModule(pDnode, pDnode->wrappers) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (dmInitModule(pDnode) != 0) {
|
if (dmInitModule(pDnode) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
indexInit(tsNumOfCommitThreads);
|
indexInit(tsNumOfCommitThreads);
|
||||||
streamMetaInit();
|
streamMetaInit();
|
||||||
|
|
|
@ -251,33 +251,6 @@ _OVER:
|
||||||
dmReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TD_MODULE_OPTIMIZE
|
|
||||||
int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) {
|
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
|
||||||
|
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
|
||||||
SMgmtWrapper *pWrapper = wrappers + ntype;
|
|
||||||
SArray *pArray = (*pWrapper->func.getHandlesFp)();
|
|
||||||
if (pArray == NULL) return -1;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
|
||||||
SMgmtHandle *pMgmt = taosArrayGet(pArray, i);
|
|
||||||
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)];
|
|
||||||
if (pMgmt->needCheckVgId) {
|
|
||||||
pHandle->needCheckVgId = pMgmt->needCheckVgId;
|
|
||||||
}
|
|
||||||
if (!pMgmt->needCheckVgId) {
|
|
||||||
pHandle->defaultNtype = ntype;
|
|
||||||
}
|
|
||||||
pWrapper->msgFps[TMSG_INDEX(pMgmt->msgType)] = pMgmt->msgFp;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(pArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int32_t dmInitMsgHandle(SDnode *pDnode) {
|
int32_t dmInitMsgHandle(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
|
||||||
|
@ -303,7 +276,6 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
SDnode *pDnode = dmInstance();
|
SDnode *pDnode = dmInstance();
|
||||||
|
|
|
@ -76,6 +76,7 @@ typedef enum {
|
||||||
MND_OPER_DROP_TOPIC,
|
MND_OPER_DROP_TOPIC,
|
||||||
MND_OPER_CREATE_VIEW,
|
MND_OPER_CREATE_VIEW,
|
||||||
MND_OPER_DROP_VIEW,
|
MND_OPER_DROP_VIEW,
|
||||||
|
MND_OPER_CONFIG_CLUSTER,
|
||||||
} EOperType;
|
} EOperType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -204,6 +205,7 @@ typedef struct {
|
||||||
int32_t numOfVnodes;
|
int32_t numOfVnodes;
|
||||||
int32_t numOfOtherNodes;
|
int32_t numOfOtherNodes;
|
||||||
int32_t numOfSupportVnodes;
|
int32_t numOfSupportVnodes;
|
||||||
|
int32_t numOfDiskCfg;
|
||||||
float numOfCores;
|
float numOfCores;
|
||||||
int64_t memTotal;
|
int64_t memTotal;
|
||||||
int64_t memAvail;
|
int64_t memAvail;
|
||||||
|
@ -214,6 +216,7 @@ typedef struct {
|
||||||
char ep[TSDB_EP_LEN];
|
char ep[TSDB_EP_LEN];
|
||||||
char active[TSDB_ACTIVE_KEY_LEN];
|
char active[TSDB_ACTIVE_KEY_LEN];
|
||||||
char connActive[TSDB_CONN_ACTIVE_KEY_LEN];
|
char connActive[TSDB_CONN_ACTIVE_KEY_LEN];
|
||||||
|
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||||
} SDnodeObj;
|
} SDnodeObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -753,6 +756,77 @@ typedef struct {
|
||||||
SArray* compactDetail;
|
SArray* compactDetail;
|
||||||
} SCompactObj;
|
} SCompactObj;
|
||||||
|
|
||||||
|
// SGrantLogObj
|
||||||
|
typedef enum {
|
||||||
|
GRANT_STATE_INIT = 0,
|
||||||
|
GRANT_STATE_UNGRANTED = 1,
|
||||||
|
GRANT_STATE_GRANTED = 2,
|
||||||
|
GRANT_STATE_EXPIRED = 3,
|
||||||
|
GRANT_STATE_REVOKED = 4,
|
||||||
|
GRANT_STATE_MAX,
|
||||||
|
} EGrantState;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GRANT_STATE_REASON_INIT = 0,
|
||||||
|
GRANT_STATE_REASON_ALTER = 1, // alter activeCode 'revoked' or 'xxx'
|
||||||
|
GRANT_STATE_REASON_MISMATCH = 2, // dnode machine mismatch
|
||||||
|
GRANT_STATE_REASON_EXPIRE = 3, // expire
|
||||||
|
GRANT_STATE_REASON_MAX,
|
||||||
|
} EGrantStateReason;
|
||||||
|
|
||||||
|
#define GRANT_STATE_NUM 30
|
||||||
|
#define GRANT_ACTIVE_NUM 10
|
||||||
|
#define GRANT_ACTIVE_HEAD_LEN 30
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
int64_t u0;
|
||||||
|
struct {
|
||||||
|
int64_t ts : 40;
|
||||||
|
int64_t lastState : 4;
|
||||||
|
int64_t state : 4;
|
||||||
|
int64_t reason : 8;
|
||||||
|
int64_t reserve : 8;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} SGrantState;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
int64_t u0;
|
||||||
|
struct {
|
||||||
|
int64_t ts : 40;
|
||||||
|
int64_t reserve : 24;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
char active[GRANT_ACTIVE_HEAD_LEN + 1];
|
||||||
|
} SGrantActive;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
int64_t u0;
|
||||||
|
struct {
|
||||||
|
int64_t ts : 40;
|
||||||
|
int64_t id : 24;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
char machine[TSDB_MACHINE_ID_LEN + 1];
|
||||||
|
} SGrantMachine;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t id;
|
||||||
|
int8_t nStates;
|
||||||
|
int8_t nActives;
|
||||||
|
int64_t createTime;
|
||||||
|
int64_t updateTime;
|
||||||
|
int64_t upgradeTime;
|
||||||
|
SGrantState states[GRANT_STATE_NUM];
|
||||||
|
SGrantActive actives[GRANT_ACTIVE_NUM];
|
||||||
|
char* active;
|
||||||
|
SArray* pMachines; // SGrantMachine
|
||||||
|
SRWLatch lock;
|
||||||
|
} SGrantLogObj;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TDENGINE_GTANT_H
|
#ifndef _TD_MND_GRANT_H_
|
||||||
#define TDENGINE_GTANT_H
|
#define _TD_MND_GRANT_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
"C" {
|
"C" {
|
||||||
|
@ -29,6 +29,26 @@
|
||||||
void grantAdd(EGrantType grant, uint64_t value);
|
void grantAdd(EGrantType grant, uint64_t value);
|
||||||
void grantRestore(EGrantType grant, uint64_t value);
|
void grantRestore(EGrantType grant, uint64_t value);
|
||||||
|
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
SSdbRaw *mndGrantActionEncode(SGrantLogObj * pGrant);
|
||||||
|
SSdbRow *mndGrantActionDecode(SSdbRaw * pRaw);
|
||||||
|
int32_t mndGrantActionInsert(SSdb * pSdb, SGrantLogObj * pGrant);
|
||||||
|
int32_t mndGrantActionDelete(SSdb * pSdb, SGrantLogObj * pGrant);
|
||||||
|
int32_t mndGrantActionUpdate(SSdb * pSdb, SGrantLogObj * pOldGrant, SGrantLogObj * pNewGrant);
|
||||||
|
|
||||||
|
#ifdef TD_UNIQ_GRANT
|
||||||
|
int32_t grantAlterActiveCode(SMnode * pMnode, SGrantLogObj * pObj, const char *oldActive, const char *newActive,
|
||||||
|
char **mergeActive);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t mndProcessConfigGrantReq(SMnode * pMnode, SRpcMsg * pReq, SMCfgClusterReq * pCfg);
|
||||||
|
int32_t mndProcessUpdGrantLog(SMnode * pMnode, SRpcMsg * pReq, SArray * pMachines, SGrantState * pState);
|
||||||
|
|
||||||
|
int32_t mndGrantGetLastState(SMnode * pMnode, SGrantState * pState);
|
||||||
|
SGrantLogObj *mndAcquireGrant(SMnode * pMnode, void **ppIter);
|
||||||
|
void mndReleaseGrant(SMnode * pMnode, SGrantLogObj * pGrant, void *pIter);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,7 +30,6 @@ int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType
|
||||||
int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname);
|
int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname);
|
||||||
int32_t mndCheckViewPrivilege(SMnode *pMnode, const char *user, EOperType operType, const char *pViewFName);
|
int32_t mndCheckViewPrivilege(SMnode *pMnode, const char *user, EOperType operType, const char *pViewFName);
|
||||||
int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic);
|
int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic);
|
||||||
int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName);
|
|
||||||
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname);
|
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname);
|
||||||
int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
||||||
int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp);
|
int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp);
|
||||||
|
|
|
@ -27,7 +27,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
||||||
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 deleteMark);
|
int64_t watermark, int64_t deleteMark);
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t nextWindowSkey);
|
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t skey, SArray* pVerList);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,17 @@ extern "C" {
|
||||||
#define MND_STREAM_RESERVE_SIZE 64
|
#define MND_STREAM_RESERVE_SIZE 64
|
||||||
#define MND_STREAM_VER_NUMBER 4
|
#define MND_STREAM_VER_NUMBER 4
|
||||||
|
|
||||||
|
#define MND_STREAM_CREATE_NAME "stream-create"
|
||||||
|
#define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint"
|
||||||
|
#define MND_STREAM_PAUSE_NAME "stream-pause"
|
||||||
|
#define MND_STREAM_RESUME_NAME "stream-resume"
|
||||||
|
#define MND_STREAM_DROP_NAME "stream-drop"
|
||||||
|
#define MND_STREAM_TASK_RESET_NAME "stream-task-reset"
|
||||||
|
#define MND_STREAM_TASK_UPDATE_NAME "stream-task-update"
|
||||||
|
|
||||||
typedef struct SStreamTransInfo {
|
typedef struct SStreamTransInfo {
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
int64_t streamUid;
|
int64_t streamId;
|
||||||
const char *name;
|
const char *name;
|
||||||
int32_t transId;
|
int32_t transId;
|
||||||
} SStreamTransInfo;
|
} SStreamTransInfo;
|
||||||
|
@ -41,7 +49,7 @@ typedef struct SVgroupChangeInfo {
|
||||||
// time to generated the checkpoint, if now() - checkpointTs >= tsCheckpointInterval, this checkpoint will be discard
|
// time to generated the checkpoint, if now() - checkpointTs >= tsCheckpointInterval, this checkpoint will be discard
|
||||||
// to avoid too many checkpoints for a taskk in the waiting list
|
// to avoid too many checkpoints for a taskk in the waiting list
|
||||||
typedef struct SCheckpointCandEntry {
|
typedef struct SCheckpointCandEntry {
|
||||||
char * pName;
|
char *pName;
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
int64_t checkpointTs;
|
int64_t checkpointTs;
|
||||||
int64_t checkpointId;
|
int64_t checkpointId;
|
||||||
|
@ -62,6 +70,9 @@ typedef struct SStreamExecInfo {
|
||||||
SHashObj *pTransferStateStreams;
|
SHashObj *pTransferStateStreams;
|
||||||
} SStreamExecInfo;
|
} SStreamExecInfo;
|
||||||
|
|
||||||
|
extern SStreamExecInfo execInfo;
|
||||||
|
typedef struct SStreamTaskIter SStreamTaskIter;
|
||||||
|
|
||||||
typedef struct SNodeEntry {
|
typedef struct SNodeEntry {
|
||||||
int32_t nodeId;
|
int32_t nodeId;
|
||||||
bool stageUpdated; // the stage has been updated due to the leader/follower change or node reboot.
|
bool stageUpdated; // the stage has been updated due to the leader/follower change or node reboot.
|
||||||
|
@ -69,15 +80,11 @@ typedef struct SNodeEntry {
|
||||||
int64_t hbTimestamp; // second
|
int64_t hbTimestamp; // second
|
||||||
} SNodeEntry;
|
} SNodeEntry;
|
||||||
|
|
||||||
#define MND_STREAM_CREATE_NAME "stream-create"
|
typedef struct SOrphanTask {
|
||||||
#define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint"
|
int64_t streamId;
|
||||||
#define MND_STREAM_PAUSE_NAME "stream-pause"
|
int32_t taskId;
|
||||||
#define MND_STREAM_RESUME_NAME "stream-resume"
|
int32_t nodeId;
|
||||||
#define MND_STREAM_DROP_NAME "stream-drop"
|
} SOrphanTask;
|
||||||
#define MND_STREAM_TASK_RESET_NAME "stream-task-reset"
|
|
||||||
#define MND_STREAM_TASK_UPDATE_NAME "stream-task-update"
|
|
||||||
|
|
||||||
extern SStreamExecInfo execInfo;
|
|
||||||
|
|
||||||
int32_t mndInitStream(SMnode *pMnode);
|
int32_t mndInitStream(SMnode *pMnode);
|
||||||
void mndCleanupStream(SMnode *pMnode);
|
void mndCleanupStream(SMnode *pMnode);
|
||||||
|
@ -85,20 +92,11 @@ SStreamObj *mndAcquireStream(SMnode *pMnode, char *streamName);
|
||||||
void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||||
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||||
int32_t mndPersistStream(STrans *pTrans, SStreamObj *pStream);
|
int32_t mndPersistStream(STrans *pTrans, SStreamObj *pStream);
|
||||||
|
int32_t mndStreamRegisterTrans(STrans *pTrans, const char *pTransName, int64_t streamId);
|
||||||
int32_t mndStreamRegisterTrans(STrans* pTrans, const char* pTransName, int64_t streamUid);
|
|
||||||
int32_t mndAddtoCheckpointWaitingList(SStreamObj *pStream, int64_t checkpointId);
|
int32_t mndAddtoCheckpointWaitingList(SStreamObj *pStream, int64_t checkpointId);
|
||||||
bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamUid, const char *pTransName, bool lock);
|
bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock);
|
||||||
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamUid);
|
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId);
|
||||||
|
|
||||||
typedef struct SOrphanTask {
|
|
||||||
int64_t streamId;
|
|
||||||
int32_t taskId;
|
|
||||||
int32_t nodeId;
|
|
||||||
} SOrphanTask;
|
|
||||||
|
|
||||||
// for sma
|
|
||||||
// TODO refactor
|
|
||||||
int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams);
|
int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams);
|
||||||
int32_t mndGetNumOfStreamTasks(const SStreamObj *pStream);
|
int32_t mndGetNumOfStreamTasks(const SStreamObj *pStream);
|
||||||
SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady);
|
SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady);
|
||||||
|
@ -116,10 +114,16 @@ int32_t extractNodeEpset(SMnode *pMnode, SEpSet *pEpSet, bool *hasEpset, int
|
||||||
int32_t mndProcessStreamHb(SRpcMsg *pReq);
|
int32_t mndProcessStreamHb(SRpcMsg *pReq);
|
||||||
void saveStreamTasksInfo(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
void saveStreamTasksInfo(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||||
int32_t initStreamNodeList(SMnode *pMnode);
|
int32_t initStreamNodeList(SMnode *pMnode);
|
||||||
int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj* pStream, int8_t igUntreated);
|
int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj *pStream, int8_t igUntreated);
|
||||||
int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||||
int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||||
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray *pList);
|
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray *pList);
|
||||||
|
int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
|
||||||
|
|
||||||
|
SStreamTaskIter *createStreamTaskIter(SStreamObj *pStream);
|
||||||
|
void destroyStreamTaskIter(SStreamTaskIter *pIter);
|
||||||
|
bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
||||||
|
SStreamTask *streamTaskIterGetCurrent(SStreamTaskIter *pIter);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "audit.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
|
#include "mndGrant.h"
|
||||||
|
#include "mndPrivilege.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
|
||||||
|
@ -31,6 +34,8 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode);
|
||||||
static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter);
|
||||||
static int32_t mndProcessUptimeTimer(SRpcMsg *pReq);
|
static int32_t mndProcessUptimeTimer(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessConfigClusterReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessConfigClusterRsp(SRpcMsg *pReq);
|
||||||
|
|
||||||
int32_t mndInitCluster(SMnode *pMnode) {
|
int32_t mndInitCluster(SMnode *pMnode) {
|
||||||
SSdbTable table = {
|
SSdbTable table = {
|
||||||
|
@ -45,6 +50,8 @@ int32_t mndInitCluster(SMnode *pMnode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_UPTIME_TIMER, mndProcessUptimeTimer);
|
mndSetMsgHandle(pMnode, TDMT_MND_UPTIME_TIMER, mndProcessUptimeTimer);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_CLUSTER, mndProcessConfigClusterReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_CLUSTER_RSP, mndProcessConfigClusterRsp);
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndRetrieveClusters);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndRetrieveClusters);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndCancelGetNextCluster);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CLUSTER, mndCancelGetNextCluster);
|
||||||
|
|
||||||
|
@ -147,6 +154,7 @@ static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pCluster->upTime, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pCluster->upTime, _OVER)
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
|
||||||
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER);
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
|
@ -359,3 +367,62 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SMCfgClusterReq cfgReq = {0};
|
||||||
|
if (tDeserializeSMCfgClusterReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mInfo("cluster: start to config, option:%s, value:%s", cfgReq.config, cfgReq.value);
|
||||||
|
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_CLUSTER) != 0) {
|
||||||
|
code = terrno != 0 ? terrno : TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
SClusterObj clusterObj = {0};
|
||||||
|
void *pIter = NULL;
|
||||||
|
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
||||||
|
if (!pCluster || pCluster->id <= 0) {
|
||||||
|
code = TSDB_CODE_APP_IS_STARTING;
|
||||||
|
if (pCluster) mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||||
|
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
|
|
||||||
|
if (strncmp(cfgReq.config, GRANT_ACTIVE_CODE, TSDB_DNODE_CONFIG_LEN) == 0) {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
if (0 != (code = mndProcessConfigGrantReq(pMnode, pReq, &cfgReq))) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
code = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
|
goto _exit;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // audit
|
||||||
|
auditRecord(pReq, pMnode->clusterId, "alterCluster", "", "", cfgReq.sql, cfgReq.sqlLen);
|
||||||
|
}
|
||||||
|
_exit:
|
||||||
|
tFreeSMCfgClusterReq(&cfgReq);
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = code;
|
||||||
|
mError("cluster: failed to config:%s %s since %s", cfgReq.config, cfgReq.value, terrstr());
|
||||||
|
} else {
|
||||||
|
mInfo("cluster: success to config:%s %s", cfgReq.config, cfgReq.value);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndProcessConfigClusterRsp(SRpcMsg *pRsp) {
|
||||||
|
mInfo("config rsp from cluster");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -599,7 +599,8 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
|
||||||
pDetail->compactId, pDetail->vgId, pDetail->dnodeId, pDetail->numberFileset, pDetail->finished,
|
pDetail->compactId, pDetail->vgId, pDetail->dnodeId, pDetail->numberFileset, pDetail->finished,
|
||||||
pDetail->newNumberFileset, pDetail->newFinished);
|
pDetail->newNumberFileset, pDetail->newFinished);
|
||||||
|
|
||||||
if(pDetail->numberFileset < pDetail->newNumberFileset || pDetail->finished < pDetail->newFinished)
|
//these 2 number will jump back after dnode restart, so < is not used here
|
||||||
|
if(pDetail->numberFileset != pDetail->newNumberFileset || pDetail->finished != pDetail->newFinished)
|
||||||
needSave = true;
|
needSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,13 @@ static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckTopicPrivilege(pMnode, pUser, MND_OPER_SUBSCRIBE, pTopic) != 0) {
|
if (mndCheckTopicPrivilege(pMnode, pUser, MND_OPER_SUBSCRIBE, pTopic) != 0) {
|
||||||
code = -1;
|
code = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) {
|
||||||
|
code = terrno;
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,22 +226,53 @@ FAIL:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRsp *rsp, char* user){
|
||||||
|
rsp->topicPrivileges = taosArrayInit(taosArrayGetSize(pConsumer->currentTopics), sizeof(STopicPrivilege));
|
||||||
|
if(rsp->topicPrivileges == NULL){
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pConsumer->currentTopics); i++){
|
||||||
|
char *topic = taosArrayGetP(pConsumer->currentTopics, i);
|
||||||
|
SMqTopicObj* pTopic = mndAcquireTopic(pMnode, topic);
|
||||||
|
if (pTopic == NULL) { // terrno has been set by callee function
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
||||||
|
strcpy(data->topic, topic);
|
||||||
|
if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 || grantCheck(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
||||||
|
data->noPrivilege = 1;
|
||||||
|
} else{
|
||||||
|
data->noPrivilege = 0;
|
||||||
|
}
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
SMqHbReq req = {0};
|
SMqHbReq req = {0};
|
||||||
|
SMqHbRsp rsp = {0};
|
||||||
|
SMqConsumerObj *pConsumer = NULL;
|
||||||
|
|
||||||
if ((code = tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req)) < 0) {
|
if (tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t consumerId = req.consumerId;
|
int64_t consumerId = req.consumerId;
|
||||||
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
||||||
if (pConsumer == NULL) {
|
if (pConsumer == NULL) {
|
||||||
mError("consumer:0x%" PRIx64 " not exist", consumerId);
|
mError("consumer:0x%" PRIx64 " not exist", consumerId);
|
||||||
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
|
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
|
||||||
code = -1;
|
code = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
code = checkPrivilege(pMnode, pConsumer, &rsp, pMsg->info.conn.user);
|
||||||
|
if(code != 0){
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,9 +317,22 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
||||||
mndReleaseSubscribe(pMnode, pSub);
|
mndReleaseSubscribe(pMnode, pSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseConsumer(pMnode, pConsumer);
|
// encode rsp
|
||||||
|
int32_t tlen = tSerializeSMqHbRsp(NULL, 0, &rsp);
|
||||||
|
void *buf = rpcMallocCont(tlen);
|
||||||
|
if (buf == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerializeSMqHbRsp(buf, tlen, &rsp);
|
||||||
|
pMsg->info.rsp = buf;
|
||||||
|
pMsg->info.rspLen = tlen;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
tDeatroySMqHbRsp(&rsp);
|
||||||
|
mndReleaseConsumer(pMnode, pConsumer);
|
||||||
tDeatroySMqHbReq(&req);
|
tDeatroySMqHbReq(&req);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -499,6 +549,12 @@ static void freeItem(void *param) {
|
||||||
int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
char *msgStr = pMsg->pCont;
|
char *msgStr = pMsg->pCont;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) {
|
||||||
|
code = terrno;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
SCMSubscribeReq subscribe = {0};
|
SCMSubscribeReq subscribe = {0};
|
||||||
tDeserializeSCMSubscribeReq(msgStr, &subscribe);
|
tDeserializeSCMSubscribeReq(msgStr, &subscribe);
|
||||||
|
@ -509,7 +565,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
SMqConsumerObj *pConsumerNew = NULL;
|
SMqConsumerObj *pConsumerNew = NULL;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
|
||||||
int32_t code = -1;
|
|
||||||
SArray *pTopicList = subscribe.topicNames;
|
SArray *pTopicList = subscribe.topicNames;
|
||||||
taosArraySort(pTopicList, taosArrayCompareString);
|
taosArraySort(pTopicList, taosArrayCompareString);
|
||||||
taosArrayRemoveDuplicate(pTopicList, taosArrayCompareString, freeItem);
|
taosArrayRemoveDuplicate(pTopicList, taosArrayCompareString, freeItem);
|
||||||
|
@ -525,7 +581,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check topic existence
|
// check topic existence
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "subscribe");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "subscribe");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
goto _over;
|
goto _over;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,16 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
||||||
tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||||
dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0;
|
dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0;
|
||||||
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", tsLocalFqdn, tsServerPort);
|
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
char *machineId = tGetMachineId();
|
||||||
|
if (machineId) {
|
||||||
|
memcpy(dnodeObj.machineId, machineId, TSDB_MACHINE_ID_LEN);
|
||||||
|
taosMemoryFreeClear(machineId);
|
||||||
|
} else {
|
||||||
|
#ifdef TD_UNIQ_GRANT
|
||||||
|
terrno = TSDB_CODE_DNODE_NO_MACHINE_CODE;
|
||||||
|
goto _OVER;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
@ -402,6 +412,7 @@ void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
||||||
tstrncpy(dInfo.ep.fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
tstrncpy(dInfo.ep.fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||||
tstrncpy(dInfo.active, pDnode->active, TSDB_ACTIVE_KEY_LEN);
|
tstrncpy(dInfo.active, pDnode->active, TSDB_ACTIVE_KEY_LEN);
|
||||||
tstrncpy(dInfo.connActive, pDnode->connActive, TSDB_CONN_ACTIVE_KEY_LEN);
|
tstrncpy(dInfo.connActive, pDnode->connActive, TSDB_CONN_ACTIVE_KEY_LEN);
|
||||||
|
tstrncpy(dInfo.machineId, pDnode->machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||||
sdbRelease(pSdb, pDnode);
|
sdbRelease(pSdb, pDnode);
|
||||||
if (mndIsMnode(pMnode, pDnode->id)) {
|
if (mndIsMnode(pMnode, pDnode->id)) {
|
||||||
dInfo.isMnode = 1;
|
dInfo.isMnode = 1;
|
||||||
|
@ -657,8 +668,12 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pDnode->rebootTime = statusReq.rebootTime;
|
pDnode->rebootTime = statusReq.rebootTime;
|
||||||
pDnode->numOfCores = statusReq.numOfCores;
|
pDnode->numOfCores = statusReq.numOfCores;
|
||||||
pDnode->numOfSupportVnodes = statusReq.numOfSupportVnodes;
|
pDnode->numOfSupportVnodes = statusReq.numOfSupportVnodes;
|
||||||
|
pDnode->numOfDiskCfg = statusReq.numOfDiskCfg;
|
||||||
pDnode->memAvail = statusReq.memAvail;
|
pDnode->memAvail = statusReq.memAvail;
|
||||||
pDnode->memTotal = statusReq.memTotal;
|
pDnode->memTotal = statusReq.memTotal;
|
||||||
|
if (pDnode->machineId[0] == 0 && statusReq.machineId[0] != 0) {
|
||||||
|
tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||||
|
}
|
||||||
|
|
||||||
SStatusRsp statusRsp = {0};
|
SStatusRsp statusRsp = {0};
|
||||||
statusRsp.statusSeq++;
|
statusRsp.statusSeq++;
|
||||||
|
@ -761,109 +776,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfgReq, int8_t action) {
|
|
||||||
SSdbRaw *pRaw = NULL;
|
|
||||||
STrans *pTrans = NULL;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
|
||||||
SArray *failRecord = NULL;
|
|
||||||
bool cfgAll = pCfgReq->dnodeId == -1;
|
|
||||||
int32_t cfgAllErr = 0;
|
|
||||||
int32_t iter = 0;
|
|
||||||
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
|
||||||
void *pIter = NULL;
|
|
||||||
while (1) {
|
|
||||||
if (cfgAll) {
|
|
||||||
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
|
||||||
if (pIter == NULL) break;
|
|
||||||
++iter;
|
|
||||||
} else if (!(pDnode = mndAcquireDnode(pMnode, pCfgReq->dnodeId))) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDnodeObj tmpDnode = *pDnode;
|
|
||||||
if (action == DND_ACTIVE_CODE) {
|
|
||||||
if (grantAlterActiveCode(pDnode->id, pDnode->active, pCfgReq->value, tmpDnode.active, 0) != 0) {
|
|
||||||
if (TSDB_CODE_DUP_KEY != terrno) {
|
|
||||||
mError("dnode:%d, config dnode:%d, app:%p config:%s value:%s failed since %s", pDnode->id, pCfgReq->dnodeId,
|
|
||||||
pReq->info.ahandle, pCfgReq->config, pCfgReq->value, terrstr());
|
|
||||||
if (cfgAll) { // alter all dnodes:
|
|
||||||
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
|
||||||
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
|
||||||
if (0 == cfgAllErr) cfgAllErr = terrno; // output 1st terrno.
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
terrno = 0; // no action for dup active code
|
|
||||||
}
|
|
||||||
if (cfgAll) continue;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
} else if (action == DND_CONN_ACTIVE_CODE) {
|
|
||||||
if (grantAlterActiveCode(pDnode->id, pDnode->connActive, pCfgReq->value, tmpDnode.connActive, 1) != 0) {
|
|
||||||
if (TSDB_CODE_DUP_KEY != terrno) {
|
|
||||||
mError("dnode:%d, config dnode:%d, app:%p config:%s value:%s failed since %s", pDnode->id, pCfgReq->dnodeId,
|
|
||||||
pReq->info.ahandle, pCfgReq->config, pCfgReq->value, terrstr());
|
|
||||||
if (cfgAll) {
|
|
||||||
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
|
||||||
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
|
||||||
if (0 == cfgAllErr) cfgAllErr = terrno;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
terrno = 0;
|
|
||||||
}
|
|
||||||
if (cfgAll) continue;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pTrans) {
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "config-dnode");
|
|
||||||
if (!pTrans) goto _OVER;
|
|
||||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRaw = mndDnodeActionEncode(&tmpDnode);
|
|
||||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
|
||||||
pRaw = NULL;
|
|
||||||
|
|
||||||
mInfo("dnode:%d, config dnode:%d, app:%p config:%s value:%s", pDnode->id, pCfgReq->dnodeId, pReq->info.ahandle,
|
|
||||||
pCfgReq->config, pCfgReq->value);
|
|
||||||
|
|
||||||
if (cfgAll) {
|
|
||||||
sdbRelease(pSdb, pDnode);
|
|
||||||
pDnode = NULL;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pTrans && mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
|
||||||
tsGrantHBInterval = TMIN(TMAX(5, iter / 2), 30);
|
|
||||||
terrno = 0;
|
|
||||||
|
|
||||||
_OVER:
|
|
||||||
if (cfgAll) {
|
|
||||||
sdbRelease(pSdb, pDnode);
|
|
||||||
if (cfgAllErr != 0) terrno = cfgAllErr;
|
|
||||||
int32_t nFail = taosArrayGetSize(failRecord);
|
|
||||||
if (nFail > 0) {
|
|
||||||
mError("config dnode, cfg:%d, app:%p config:%s value:%s. total:%d, fail:%d", pCfgReq->dnodeId, pReq->info.ahandle,
|
|
||||||
pCfgReq->config, pCfgReq->value, iter, nFail);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
|
||||||
}
|
|
||||||
sdbCancelFetch(pSdb, pIter);
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
sdbFreeRaw(pRaw);
|
|
||||||
taosArrayDestroy(failRecord);
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -1013,8 +925,10 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndCreateDnode(pMnode, pReq, &createReq);
|
code = mndCreateDnode(pMnode, pReq, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) {
|
||||||
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
tsGrantHBInterval = 5;
|
tsGrantHBInterval = 5;
|
||||||
|
}
|
||||||
|
|
||||||
char obj[200] = {0};
|
char obj[200] = {0};
|
||||||
sprintf(obj, "%s:%d", createReq.fqdn, createReq.port);
|
sprintf(obj, "%s:%d", createReq.fqdn, createReq.port);
|
||||||
|
@ -1310,34 +1224,6 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
strcpy(dcfgReq.config, "supportvnodes");
|
strcpy(dcfgReq.config, "supportvnodes");
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
} else if (strncasecmp(cfgReq.config, "activeCode", 10) == 0 || strncasecmp(cfgReq.config, "cActiveCode", 11) == 0) {
|
|
||||||
int8_t opt = strncasecmp(cfgReq.config, "a", 1) == 0 ? DND_ACTIVE_CODE : DND_CONN_ACTIVE_CODE;
|
|
||||||
int8_t index = opt == DND_ACTIVE_CODE ? 10 : 11;
|
|
||||||
if (' ' != cfgReq.config[index] && 0 != cfgReq.config[index]) {
|
|
||||||
mError("dnode:%d, failed to config activeCode since invalid conf:%s", cfgReq.dnodeId, cfgReq.config);
|
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
goto _err_out;
|
|
||||||
}
|
|
||||||
int32_t vlen = strlen(cfgReq.value);
|
|
||||||
if (vlen > 0 && ((opt == DND_ACTIVE_CODE && vlen != (TSDB_ACTIVE_KEY_LEN - 1)) ||
|
|
||||||
(opt == DND_CONN_ACTIVE_CODE &&
|
|
||||||
(vlen > (TSDB_CONN_ACTIVE_KEY_LEN - 1) || vlen < (TSDB_ACTIVE_KEY_LEN - 1))))) {
|
|
||||||
mError("dnode:%d, failed to config activeCode since invalid vlen:%d. conf:%s, val:%s", cfgReq.dnodeId, vlen,
|
|
||||||
cfgReq.config, cfgReq.value);
|
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
goto _err_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? "activeCode" : "cActiveCode");
|
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
|
||||||
|
|
||||||
if (mndConfigDnode(pMnode, pReq, &cfgReq, opt) != 0) {
|
|
||||||
mError("dnode:%d, failed to config activeCode since %s", cfgReq.dnodeId, terrstr());
|
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
goto _err_out;
|
|
||||||
}
|
|
||||||
tFreeSMCfgDnodeReq(&cfgReq);
|
|
||||||
return 0;
|
|
||||||
} else if (strncasecmp(cfgReq.config, "s3blocksize", 11) == 0) {
|
} else if (strncasecmp(cfgReq.config, "s3blocksize", 11) == 0) {
|
||||||
int32_t optLen = strlen("s3blocksize");
|
int32_t optLen = strlen("s3blocksize");
|
||||||
int32_t flag = -1;
|
int32_t flag = -1;
|
||||||
|
@ -1497,11 +1383,7 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
taosMemoryFreeClear(b);
|
taosMemoryFreeClear(b);
|
||||||
|
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
STR_TO_VARSTR(buf, pDnode->active);
|
STR_TO_VARSTR(buf, pDnode->machineId);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
|
||||||
|
|
||||||
STR_TO_VARSTR(buf, pDnode->connActive);
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,15 @@
|
||||||
|
|
||||||
#ifndef _GRANT
|
#ifndef _GRANT
|
||||||
|
|
||||||
|
#define GRANT_ITEM_SHOW(display) \
|
||||||
|
do { \
|
||||||
|
cols++; \
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); \
|
||||||
|
src = (display); \
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); \
|
||||||
|
colDataSetVal(pColInfo, numOfRows, tmp, false); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
@ -31,95 +40,32 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||||
|
|
||||||
cols++;
|
GRANT_ITEM_SHOW("unlimited");
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
GRANT_ITEM_SHOW("limited");
|
||||||
src = "unlimited";
|
GRANT_ITEM_SHOW("false");
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
GRANT_ITEM_SHOW("ungranted");
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
GRANT_ITEM_SHOW("unlimited");
|
||||||
|
GRANT_ITEM_SHOW("unlimited");
|
||||||
|
GRANT_ITEM_SHOW("unlimited");
|
||||||
|
|
||||||
cols++;
|
++numOfRows;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "false";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
cols++;
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
|
||||||
src = "unlimited";
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
|
||||||
|
|
||||||
numOfRows++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pShow->numOfRows += numOfRows;
|
pShow->numOfRows += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
|
static int32_t mndRetrieveGrantLogs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
|
static int32_t mndRetrieveMachines(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
|
|
||||||
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
|
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
||||||
int32_t mndInitGrant(SMnode *pMnode) {
|
int32_t mndInitGrant(SMnode *pMnode) {
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOGS, mndRetrieveGrantLogs);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MACHINES, mndRetrieveMachines);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -129,12 +75,15 @@ void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||||
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
||||||
void grantAdd(EGrantType grant, uint64_t value) {}
|
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||||
void grantRestore(EGrantType grant, uint64_t value) {}
|
void grantRestore(EGrantType grant, uint64_t value) {}
|
||||||
|
char *tGetMachineId() { return NULL; };
|
||||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
int32_t grantAlterActiveCode(int32_t did, const char *old, const char *new, char *out, int8_t type) {
|
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
|
||||||
return TSDB_CODE_SUCCESS;
|
#else
|
||||||
}
|
#ifndef TD_UNIQ_GRANT
|
||||||
|
char *tGetMachineId() { return NULL; };
|
||||||
|
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void mndGenerateMachineCode() { grantParseParameter(); }
|
void mndGenerateMachineCode() { grantParseParameter(); }
|
|
@ -193,7 +193,7 @@ static void mndPullupGrant(SMnode *pMnode) {
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.msgType = TDMT_MND_GRANT_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9527};
|
.msgType = TDMT_MND_GRANT_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9527};
|
||||||
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,6 @@ int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType op
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic) { return 0; }
|
int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic) { return 0; }
|
||||||
int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t mndSetUserWhiteListRsp(SMnode *pMnode, SUserObj *pUser, SGetUserWhiteListRsp *pWhiteListRsp) {
|
int32_t mndSetUserWhiteListRsp(SMnode *pMnode, SUserObj *pUser, SGetUserWhiteListRsp *pWhiteListRsp) {
|
||||||
|
|
|
@ -234,36 +234,72 @@ int32_t doAddShuffleSinkTask(SMnode* pMnode, SArray* pTaskList, SStreamObj* pStr
|
||||||
|
|
||||||
int32_t doAddSinkTask(SStreamObj* pStream, SArray* pTaskList, SMnode* pMnode, int32_t vgId, SVgObj* pVgroup,
|
int32_t doAddSinkTask(SStreamObj* pStream, SArray* pTaskList, SMnode* pMnode, int32_t vgId, SVgObj* pVgroup,
|
||||||
SEpSet* pEpset, bool isFillhistory) {
|
SEpSet* pEpset, bool isFillhistory) {
|
||||||
int64_t uid = (isFillhistory)? pStream->hTaskUid:pStream->uid;
|
int64_t uid = (isFillhistory) ? pStream->hTaskUid : pStream->uid;
|
||||||
SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SINK, isFillhistory, 0, pTaskList, pStream->conf.fillHistory);
|
SStreamTask* pTask =
|
||||||
|
tNewStreamTask(uid, TASK_LEVEL__SINK, pEpset, isFillhistory, 0, pTaskList, pStream->conf.fillHistory);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
epsetAssign(&(pTask)->info.mnodeEpset, pEpset);
|
|
||||||
|
|
||||||
pTask->info.nodeId = vgId;
|
pTask->info.nodeId = vgId;
|
||||||
pTask->info.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
pTask->info.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
mndSetSinkTaskInfo(pStream, pTask);
|
mndSetSinkTaskInfo(pStream, pTask);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t getVgroupLastVer(const SArray* pList, int32_t vgId) {
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pList); ++i) {
|
||||||
|
SVgroupVer* pVer = taosArrayGet(pList, i);
|
||||||
|
if (pVer->vgId == vgId) {
|
||||||
|
return pVer->ver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mError("failed to find the vgId:%d for extract last version", vgId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void streamTaskSetDataRange(SStreamTask* pTask, int64_t skey, SArray* pVerList, int32_t vgId) {
|
||||||
|
int64_t latestVer = getVgroupLastVer(pVerList, vgId);
|
||||||
|
if (latestVer < 0) {
|
||||||
|
latestVer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the correct ts, which is the last key of queried table.
|
||||||
|
SDataRange* pRange = &pTask->dataRange;
|
||||||
|
STimeWindow* pWindow = &pRange->window;
|
||||||
|
|
||||||
|
if (pTask->info.fillHistory) {
|
||||||
|
pWindow->skey = INT64_MIN;
|
||||||
|
pWindow->ekey = skey - 1;
|
||||||
|
|
||||||
|
pRange->range.minVer = 0;
|
||||||
|
pRange->range.maxVer = latestVer;
|
||||||
|
mDebug("add fill-history source task 0x%x timeWindow:%" PRId64 "-%" PRId64 " verRange:%" PRId64 "-%" PRId64,
|
||||||
|
pTask->id.taskId, pWindow->skey, pWindow->ekey, pRange->range.minVer, pRange->range.maxVer);
|
||||||
|
} else {
|
||||||
|
pWindow->skey = skey;
|
||||||
|
pWindow->ekey = INT64_MAX;
|
||||||
|
|
||||||
|
pRange->range.minVer = latestVer + 1;
|
||||||
|
pRange->range.maxVer = INT64_MAX;
|
||||||
|
|
||||||
|
mDebug("add source task 0x%x timeWindow:%" PRId64 "-%" PRId64 " verRange:%" PRId64 "-%" PRId64,
|
||||||
|
pTask->id.taskId, pWindow->skey, pWindow->ekey, pRange->range.minVer, pRange->range.maxVer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t addSourceTask(SMnode* pMnode, SVgObj* pVgroup, SArray* pTaskList, SArray* pSinkTaskList,
|
static int32_t addSourceTask(SMnode* pMnode, SVgObj* pVgroup, SArray* pTaskList, SArray* pSinkTaskList,
|
||||||
SStreamObj* pStream, SSubplan* plan, uint64_t uid, SEpSet* pEpset, bool fillHistory,
|
SStreamObj* pStream, SSubplan* plan, uint64_t uid, SEpSet* pEpset, int64_t skey,
|
||||||
bool hasExtraSink, int64_t nextWindowSkey, bool hasFillHistory) {
|
SArray* pVerList, bool fillHistory, bool hasExtraSink, bool hasFillHistory) {
|
||||||
SStreamTask* pTask =
|
int64_t t = pStream->conf.triggerParam;
|
||||||
tNewStreamTask(uid, TASK_LEVEL__SOURCE, fillHistory, pStream->conf.triggerParam, pTaskList, hasFillHistory);
|
SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SOURCE, pEpset, fillHistory, t, pTaskList, hasFillHistory);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
epsetAssign(&pTask->info.mnodeEpset, pEpset);
|
streamTaskSetDataRange(pTask, skey, pVerList, pVgroup->vgId);
|
||||||
STimeWindow* pWindow = &pTask->dataRange.window;
|
|
||||||
|
|
||||||
pWindow->skey = INT64_MIN;
|
|
||||||
pWindow->ekey = nextWindowSkey - 1;
|
|
||||||
mDebug("add source task 0x%x window:%" PRId64 " - %" PRId64, pTask->id.taskId, pWindow->skey, pWindow->ekey);
|
|
||||||
|
|
||||||
// sink or dispatch
|
// sink or dispatch
|
||||||
if (hasExtraSink) {
|
if (hasExtraSink) {
|
||||||
|
@ -308,7 +344,7 @@ static void setHTasksId(SArray* pTaskList, const SArray* pHTaskList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan* pPlan, SStreamObj* pStream,
|
static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan* pPlan, SStreamObj* pStream,
|
||||||
SEpSet* pEpset, bool hasExtraSink, int64_t nextWindowSkey) {
|
SEpSet* pEpset, bool hasExtraSink, int64_t skey, SArray* pVerList) {
|
||||||
// create exec stream task, since only one level, the exec task is also the source task
|
// create exec stream task, since only one level, the exec task is also the source task
|
||||||
SArray* pTaskList = addNewTaskList(pStream->tasks);
|
SArray* pTaskList = addNewTaskList(pStream->tasks);
|
||||||
SSdb* pSdb = pMnode->pSdb;
|
SSdb* pSdb = pMnode->pSdb;
|
||||||
|
@ -345,8 +381,8 @@ static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan*
|
||||||
|
|
||||||
// new stream task
|
// new stream task
|
||||||
SArray** pSinkTaskList = taosArrayGet(pStream->tasks, SINK_NODE_LEVEL);
|
SArray** pSinkTaskList = taosArrayGet(pStream->tasks, SINK_NODE_LEVEL);
|
||||||
int32_t code = addSourceTask(pMnode, pVgroup, pTaskList, *pSinkTaskList, pStream, plan, pStream->uid, pEpset,
|
int32_t code = addSourceTask(pMnode, pVgroup, pTaskList, *pSinkTaskList, pStream, plan, pStream->uid, pEpset, skey,
|
||||||
false, hasExtraSink, nextWindowSkey, pStream->conf.fillHistory);
|
pVerList, false, hasExtraSink, pStream->conf.fillHistory);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -354,8 +390,8 @@ static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan*
|
||||||
|
|
||||||
if (pStream->conf.fillHistory) {
|
if (pStream->conf.fillHistory) {
|
||||||
SArray** pHSinkTaskList = taosArrayGet(pStream->pHTasksList, SINK_NODE_LEVEL);
|
SArray** pHSinkTaskList = taosArrayGet(pStream->pHTasksList, SINK_NODE_LEVEL);
|
||||||
code = addSourceTask(pMnode, pVgroup, pHTaskList, *pHSinkTaskList, pStream, plan, pStream->hTaskUid,
|
code = addSourceTask(pMnode, pVgroup, pHTaskList, *pHSinkTaskList, pStream, plan, pStream->hTaskUid, pEpset, skey,
|
||||||
pEpset, true, hasExtraSink, nextWindowSkey, true);
|
pVerList, true, hasExtraSink, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
@ -371,24 +407,17 @@ static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doAddSourceTask(SArray* pTaskList, bool isFillhistory, int64_t uid, SStreamTask* pDownstreamTask,
|
static int32_t addSourceTaskForMultiLevelStream(SArray* pTaskList, bool isFillhistory, int64_t uid,
|
||||||
SMnode* pMnode, SSubplan* pPlan, SVgObj* pVgroup, SEpSet* pEpset,
|
SStreamTask* pDownstreamTask, SMnode* pMnode, SSubplan* pPlan,
|
||||||
int64_t nextWindowSkey, bool hasFillHistory) {
|
SVgObj* pVgroup, SEpSet* pEpset, int64_t skey, SArray* pVerList,
|
||||||
SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SOURCE, isFillhistory, 0, pTaskList, hasFillHistory);
|
bool hasFillHistory) {
|
||||||
|
SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SOURCE, pEpset, isFillhistory, 0, pTaskList, hasFillHistory);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
epsetAssign(&(pTask)->info.mnodeEpset, pEpset);
|
streamTaskSetDataRange(pTask, skey, pVerList, pVgroup->vgId);
|
||||||
|
|
||||||
// set the correct ts, which is the last key of queried table.
|
|
||||||
STimeWindow* pWindow = &pTask->dataRange.window;
|
|
||||||
pWindow->skey = INT64_MIN;
|
|
||||||
pWindow->ekey = nextWindowSkey - 1;
|
|
||||||
|
|
||||||
mDebug("s-task:0x%x level:%d set time window:%" PRId64 " - %" PRId64, pTask->id.taskId, pTask->info.taskLevel,
|
|
||||||
pWindow->skey, pWindow->ekey);
|
|
||||||
|
|
||||||
// all the source tasks dispatch result to a single agg node.
|
// all the source tasks dispatch result to a single agg node.
|
||||||
streamTaskSetFixedDownstreamInfo(pTask, pDownstreamTask);
|
streamTaskSetFixedDownstreamInfo(pTask, pDownstreamTask);
|
||||||
|
@ -401,14 +430,12 @@ static int32_t doAddSourceTask(SArray* pTaskList, bool isFillhistory, int64_t ui
|
||||||
|
|
||||||
static int32_t doAddAggTask(uint64_t uid, SArray* pTaskList, SArray* pSinkNodeList, SMnode* pMnode, SStreamObj* pStream,
|
static int32_t doAddAggTask(uint64_t uid, SArray* pTaskList, SArray* pSinkNodeList, SMnode* pMnode, SStreamObj* pStream,
|
||||||
SEpSet* pEpset, bool fillHistory, SStreamTask** pAggTask, bool hasFillhistory) {
|
SEpSet* pEpset, bool fillHistory, SStreamTask** pAggTask, bool hasFillhistory) {
|
||||||
*pAggTask = tNewStreamTask(uid, TASK_LEVEL__AGG, fillHistory, pStream->conf.triggerParam, pTaskList, hasFillhistory);
|
*pAggTask = tNewStreamTask(uid, TASK_LEVEL__AGG, pEpset, fillHistory, pStream->conf.triggerParam, pTaskList, hasFillhistory);
|
||||||
if (*pAggTask == NULL) {
|
if (*pAggTask == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
epsetAssign(&(*pAggTask)->info.mnodeEpset, pEpset);
|
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
if (mndAddDispatcherForInternalTask(pMnode, pStream, pSinkNodeList, *pAggTask) < 0) {
|
if (mndAddDispatcherForInternalTask(pMnode, pStream, pSinkNodeList, *pAggTask) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -492,7 +519,7 @@ static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* pPlan
|
||||||
|
|
||||||
static int32_t addSourceTasksForMultiLevelStream(SMnode* pMnode, SQueryPlan* pPlan, SStreamObj* pStream,
|
static int32_t addSourceTasksForMultiLevelStream(SMnode* pMnode, SQueryPlan* pPlan, SStreamObj* pStream,
|
||||||
SStreamTask* pDownstreamTask, SStreamTask* pHDownstreamTask,
|
SStreamTask* pDownstreamTask, SStreamTask* pHDownstreamTask,
|
||||||
SEpSet* pEpset, int64_t nextWindowSkey) {
|
SEpSet* pEpset, int64_t skey, SArray* pVerList) {
|
||||||
SArray* pSourceTaskList = addNewTaskList(pStream->tasks);
|
SArray* pSourceTaskList = addNewTaskList(pStream->tasks);
|
||||||
|
|
||||||
SArray* pHSourceTaskList = NULL;
|
SArray* pHSourceTaskList = NULL;
|
||||||
|
@ -521,8 +548,8 @@ static int32_t addSourceTasksForMultiLevelStream(SMnode* pMnode, SQueryPlan* pPl
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = doAddSourceTask(pSourceTaskList, false, pStream->uid, pDownstreamTask, pMnode, plan, pVgroup, pEpset,
|
int32_t code = addSourceTaskForMultiLevelStream(pSourceTaskList, false, pStream->uid, pDownstreamTask, pMnode, plan, pVgroup, pEpset,
|
||||||
nextWindowSkey, pStream->conf.fillHistory);
|
skey, pVerList, pStream->conf.fillHistory);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
@ -530,8 +557,8 @@ static int32_t addSourceTasksForMultiLevelStream(SMnode* pMnode, SQueryPlan* pPl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStream->conf.fillHistory) {
|
if (pStream->conf.fillHistory) {
|
||||||
code = doAddSourceTask(pHSourceTaskList, true, pStream->hTaskUid, pHDownstreamTask, pMnode, plan, pVgroup, pEpset,
|
code = addSourceTaskForMultiLevelStream(pHSourceTaskList, true, pStream->hTaskUid, pHDownstreamTask, pMnode, plan, pVgroup, pEpset,
|
||||||
nextWindowSkey, pStream->conf.fillHistory);
|
skey, pVerList, pStream->conf.fillHistory);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
return code;
|
return code;
|
||||||
|
@ -580,7 +607,8 @@ static void setSinkTaskUpstreamInfo(SArray* pTasksList, const SStreamTask* pUpst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* pPlan, int64_t nextWindowSkey, SEpSet* pEpset) {
|
static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* pPlan, SEpSet* pEpset, int64_t skey,
|
||||||
|
SArray* pVerList) {
|
||||||
SSdb* pSdb = pMnode->pSdb;
|
SSdb* pSdb = pMnode->pSdb;
|
||||||
int32_t numOfPlanLevel = LIST_LENGTH(pPlan->pSubplans);
|
int32_t numOfPlanLevel = LIST_LENGTH(pPlan->pSubplans);
|
||||||
|
|
||||||
|
@ -637,15 +665,15 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan*
|
||||||
}
|
}
|
||||||
|
|
||||||
// source level
|
// source level
|
||||||
return addSourceTasksForMultiLevelStream(pMnode, pPlan, pStream, pAggTask, pHAggTask, pEpset, nextWindowSkey);
|
return addSourceTasksForMultiLevelStream(pMnode, pPlan, pStream, pAggTask, pHAggTask, pEpset, skey, pVerList);
|
||||||
} else if (numOfPlanLevel == 1) {
|
} else if (numOfPlanLevel == 1) {
|
||||||
return addSourceTasksForOneLevelStream(pMnode, pPlan, pStream, pEpset, hasExtraSink, nextWindowSkey);
|
return addSourceTasksForOneLevelStream(pMnode, pPlan, pStream, pEpset, hasExtraSink, skey, pVerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t nextWindowSkey) {
|
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t skey, SArray* pVgVerList) {
|
||||||
SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan);
|
SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan);
|
||||||
if (pPlan == NULL) {
|
if (pPlan == NULL) {
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
@ -655,7 +683,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t nextWindo
|
||||||
SEpSet mnodeEpset = {0};
|
SEpSet mnodeEpset = {0};
|
||||||
mndGetMnodeEpSet(pMnode, &mnodeEpset);
|
mndGetMnodeEpSet(pMnode, &mnodeEpset);
|
||||||
|
|
||||||
int32_t code = doScheduleStream(pStream, pMnode, pPlan, nextWindowSkey, &mnodeEpset);
|
int32_t code = doScheduleStream(pStream, pMnode, pPlan, &mnodeEpset, skey, pVgVerList);
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -123,6 +123,12 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_COMPACT;
|
type = TSDB_MGMT_TABLE_COMPACT;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
|
type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_GRANTS_FULL;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_GRANTS_LOGS;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_MACHINES;
|
||||||
} else {
|
} else {
|
||||||
mError("invalid show name:%s len:%d", name, len);
|
mError("invalid show name:%s len:%d", name, len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -638,7 +638,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
||||||
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
||||||
if (mndScheduleStream(pMnode, &streamObj, 1685959190000) != 0) goto _OVER;
|
if (mndScheduleStream(pMnode, &streamObj, 1685959190000, NULL) != 0) goto _OVER;
|
||||||
if (mndPersistStream(pTrans, &streamObj) != 0) goto _OVER;
|
if (mndPersistStream(pTrans, &streamObj) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
|
|
|
@ -476,22 +476,20 @@ int32_t mndPersistTaskDeployReq(STrans *pTrans, SStreamTask *pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndPersistStreamTasks(STrans *pTrans, SStreamObj *pStream) {
|
int32_t mndPersistStreamTasks(STrans *pTrans, SStreamObj *pStream) {
|
||||||
int32_t level = taosArrayGetSize(pStream->tasks);
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
for (int32_t i = 0; i < level; i++) {
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t j = 0; j < numOfTasks; j++) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
|
||||||
if (mndPersistTaskDeployReq(pTrans, pTask) < 0) {
|
if (mndPersistTaskDeployReq(pTrans, pTask) < 0) {
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
|
||||||
// persistent stream task for already stored ts data
|
// persistent stream task for already stored ts data
|
||||||
if (pStream->conf.fillHistory) {
|
if (pStream->conf.fillHistory) {
|
||||||
level = taosArrayGetSize(pStream->pHTasksList);
|
int32_t level = taosArrayGetSize(pStream->pHTasksList);
|
||||||
|
|
||||||
for (int32_t i = 0; i < level; i++) {
|
for (int32_t i = 0; i < level; i++) {
|
||||||
SArray *pLevel = taosArrayGetP(pStream->pHTasksList, i);
|
SArray *pLevel = taosArrayGetP(pStream->pHTasksList, i);
|
||||||
|
@ -646,8 +644,12 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
int32_t sqlLen = 0;
|
int32_t sqlLen = 0;
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SCMCreateStreamReq createStreamReq = {0};
|
if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
|
||||||
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createStreamReq) != 0) {
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCMCreateStreamReq createReq = {0};
|
||||||
|
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -656,17 +658,17 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_PLATFORM;
|
terrno = TSDB_CODE_MND_INVALID_PLATFORM;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
#endif
|
#endif
|
||||||
mInfo("stream:%s, start to create, sql:%s", createStreamReq.name, createStreamReq.sql);
|
mInfo("stream:%s, start to create, sql:%s", createReq.name, createReq.sql);
|
||||||
|
|
||||||
if (mndCheckCreateStreamReq(&createStreamReq) != 0) {
|
if (mndCheckCreateStreamReq(&createReq) != 0) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, createStreamReq.name);
|
pStream = mndAcquireStream(pMnode, createReq.name);
|
||||||
if (pStream != NULL) {
|
if (pStream != NULL) {
|
||||||
if (createStreamReq.igExists) {
|
if (createReq.igExists) {
|
||||||
mInfo("stream:%s, already exist, ignore exist is set", createStreamReq.name);
|
mInfo("stream:%s, already exist, ignore exist is set", createReq.name);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
||||||
|
@ -676,16 +678,16 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createStreamReq.sql != NULL) {
|
if (createReq.sql != NULL) {
|
||||||
sqlLen = strlen(createStreamReq.sql);
|
sqlLen = strlen(createReq.sql);
|
||||||
sql = taosMemoryMalloc(sqlLen + 1);
|
sql = taosMemoryMalloc(sqlLen + 1);
|
||||||
memset(sql, 0, sqlLen + 1);
|
memset(sql, 0, sqlLen + 1);
|
||||||
memcpy(sql, createStreamReq.sql, sqlLen);
|
memcpy(sql, createReq.sql, sqlLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build stream obj from request
|
// build stream obj from request
|
||||||
if (mndBuildStreamObjFromCreateReq(pMnode, &streamObj, &createStreamReq) < 0) {
|
if (mndBuildStreamObjFromCreateReq(pMnode, &streamObj, &createReq) < 0) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,23 +701,23 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create stb for stream
|
// create stb for stream
|
||||||
if (createStreamReq.createStb == STREAM_CREATE_STABLE_TRUE &&
|
if (createReq.createStb == STREAM_CREATE_STABLE_TRUE &&
|
||||||
mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
||||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createStreamReq.name, terrstr());
|
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, terrstr());
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// schedule stream task for stream obj
|
// schedule stream task for stream obj
|
||||||
if (mndScheduleStream(pMnode, &streamObj, createStreamReq.lastTs) < 0) {
|
if (mndScheduleStream(pMnode, &streamObj, createReq.lastTs, createReq.pVgroupVerList) < 0) {
|
||||||
mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to schedule since %s", createReq.name, terrstr());
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add stream to trans
|
// add stream to trans
|
||||||
if (mndPersistStream(pTrans, &streamObj) < 0) {
|
if (mndPersistStream(pTrans, &streamObj) < 0) {
|
||||||
mError("stream:%s, failed to schedule since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to schedule since %s", createReq.name, terrstr());
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -746,10 +748,10 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
taosThreadMutexUnlock(&execInfo.lock);
|
taosThreadMutexUnlock(&execInfo.lock);
|
||||||
|
|
||||||
SName dbname = {0};
|
SName dbname = {0};
|
||||||
tNameFromString(&dbname, createStreamReq.sourceDB, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
tNameFromString(&dbname, createReq.sourceDB, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
tNameFromString(&name, createStreamReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
// reuse this function for stream
|
// reuse this function for stream
|
||||||
|
|
||||||
if (sql != NULL && sqlLen > 0) {
|
if (sql != NULL && sqlLen > 0) {
|
||||||
|
@ -762,11 +764,11 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (terrno != TSDB_CODE_SUCCESS && terrno != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (terrno != TSDB_CODE_SUCCESS && terrno != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseStream(pMnode, pStream);
|
mndReleaseStream(pMnode, pStream);
|
||||||
tFreeSCMCreateStreamReq(&createStreamReq);
|
tFreeSCMCreateStreamReq(&createReq);
|
||||||
tFreeStreamObj(&streamObj);
|
tFreeStreamObj(&streamObj);
|
||||||
if (sql != NULL) {
|
if (sql != NULL) {
|
||||||
taosMemoryFreeClear(sql);
|
taosMemoryFreeClear(sql);
|
||||||
|
@ -856,6 +858,32 @@ static int32_t mndBuildStreamCheckpointSourceReq(void **pBuf, int32_t *pLen, int
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t doSetCheckpointAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTask, int64_t checkpointId,
|
||||||
|
int8_t mndTrigger) {
|
||||||
|
void *buf;
|
||||||
|
int32_t tlen;
|
||||||
|
if (mndBuildStreamCheckpointSourceReq(&buf, &tlen, pTask->info.nodeId, checkpointId, pTask->id.streamId,
|
||||||
|
pTask->id.taskId, pTrans->id, mndTrigger) < 0) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SEpSet epset = {0};
|
||||||
|
bool hasEpset = false;
|
||||||
|
int32_t code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = setTransAction(pTrans, buf, tlen, TDMT_VND_STREAM_CHECK_POINT_SOURCE, &epset, TSDB_CODE_SYN_PROPOSE_NOT_READY);
|
||||||
|
if (code != 0) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId,
|
static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId,
|
||||||
int8_t mndTrigger, bool lock) {
|
int8_t mndTrigger, bool lock) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -865,6 +893,7 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
|
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
|
||||||
if (conflict) {
|
if (conflict) {
|
||||||
mndAddtoCheckpointWaitingList(pStream, checkpointId);
|
mndAddtoCheckpointWaitingList(pStream, checkpointId);
|
||||||
|
@ -887,8 +916,8 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
||||||
pStream->currentTick = 1;
|
pStream->currentTick = 1;
|
||||||
|
|
||||||
// 1. redo action: broadcast checkpoint source msg for all source vg
|
// 1. redo action: broadcast checkpoint source msg for all source vg
|
||||||
int32_t totLevel = taosArrayGetSize(pStream->tasks);
|
int32_t totalLevel = taosArrayGetSize(pStream->tasks);
|
||||||
for (int32_t i = 0; i < totLevel; i++) {
|
for (int32_t i = 0; i < totalLevel; i++) {
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
||||||
SStreamTask *p = taosArrayGetP(pLevel, 0);
|
SStreamTask *p = taosArrayGetP(pLevel, 0);
|
||||||
|
|
||||||
|
@ -896,28 +925,9 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
||||||
int32_t sz = taosArrayGetSize(pLevel);
|
int32_t sz = taosArrayGetSize(pLevel);
|
||||||
for (int32_t j = 0; j < sz; j++) {
|
for (int32_t j = 0; j < sz; j++) {
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
||||||
|
code = doSetCheckpointAction(pMnode, pTrans, pTask, checkpointId, mndTrigger);
|
||||||
|
|
||||||
void *buf;
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
int32_t tlen;
|
|
||||||
if (mndBuildStreamCheckpointSourceReq(&buf, &tlen, pTask->info.nodeId, checkpointId, pTask->id.streamId,
|
|
||||||
pTask->id.taskId, pTrans->id, mndTrigger) < 0) {
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
|
||||||
goto _ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
SEpSet epset = {0};
|
|
||||||
bool hasEpset = false;
|
|
||||||
code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
|
||||||
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
|
||||||
taosMemoryFree(buf);
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
|
||||||
goto _ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = setTransAction(pTrans, buf, tlen, TDMT_VND_STREAM_CHECK_POINT_SOURCE, &epset,
|
|
||||||
TSDB_CODE_SYN_PROPOSE_NOT_READY);
|
|
||||||
if (code != 0) {
|
|
||||||
taosMemoryFree(buf);
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
taosWUnLockLatch(&pStream->lock);
|
||||||
goto _ERR;
|
goto _ERR;
|
||||||
}
|
}
|
||||||
|
@ -1500,21 +1510,19 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
// add row for each task
|
// add row for each task
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pStream->tasks); i++) {
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
|
|
||||||
int32_t numOfLevels = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t j = 0; j < numOfLevels; j++) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
|
||||||
int32_t code = setTaskAttrInResBlock(pStream, pTask, pBlock, numOfRows);
|
int32_t code = setTaskAttrInResBlock(pStream, pTask, pBlock, numOfRows);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// unlock
|
destroyStreamTaskIter(pIter);
|
||||||
taosRUnLockLatch(&pStream->lock);
|
taosRUnLockLatch(&pStream->lock);
|
||||||
|
|
||||||
sdbRelease(pSdb, pStream);
|
sdbRelease(pSdb, pStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,21 +1628,26 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
|
||||||
SMResumeStreamReq pauseReq = {0};
|
if(grantCheck(TSDB_GRANT_STREAMS) < 0){
|
||||||
if (tDeserializeSMResumeStreamReq(pReq->pCont, pReq->contLen, &pauseReq) < 0) {
|
terrno = TSDB_CODE_GRANT_EXPIRED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SMResumeStreamReq resumeReq = {0};
|
||||||
|
if (tDeserializeSMResumeStreamReq(pReq->pCont, pReq->contLen, &resumeReq) < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, pauseReq.name);
|
pStream = mndAcquireStream(pMnode, resumeReq.name);
|
||||||
|
|
||||||
if (pStream == NULL) {
|
if (pStream == NULL) {
|
||||||
if (pauseReq.igNotExists) {
|
if (resumeReq.igNotExists) {
|
||||||
mInfo("stream:%s not exist, not resume stream", pauseReq.name);
|
mInfo("stream:%s not exist, not resume stream", resumeReq.name);
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
mError("stream:%s not exist, failed to resume stream", pauseReq.name);
|
mError("stream:%s not exist, failed to resume stream", resumeReq.name);
|
||||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1659,7 +1672,7 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
STrans* pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_RESUME_NAME, "resume the stream");
|
STrans* pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_RESUME_NAME, "resume the stream");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("stream:%s, failed to resume stream since %s", pauseReq.name, terrstr());
|
mError("stream:%s, failed to resume stream since %s", resumeReq.name, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1667,8 +1680,8 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
||||||
int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_RESUME_NAME, pStream->uid);
|
int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_RESUME_NAME, pStream->uid);
|
||||||
|
|
||||||
// set the resume action
|
// set the resume action
|
||||||
if (mndStreamSetResumeAction(pTrans, pMnode, pStream, pauseReq.igUntreated) < 0) {
|
if (mndStreamSetResumeAction(pTrans, pMnode, pStream, resumeReq.igUntreated) < 0) {
|
||||||
mError("stream:%s, failed to drop task since %s", pauseReq.name, terrstr());
|
mError("stream:%s, failed to drop task since %s", resumeReq.name, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1829,6 +1842,11 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no need to build the trans to handle the vgroup upddate
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
@ -1854,22 +1872,19 @@ static SArray *extractNodeListFromStream(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pStream->lock);
|
taosWLockLatch(&pStream->lock);
|
||||||
int32_t numOfLevels = taosArrayGetSize(pStream->tasks);
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfLevels; ++j) {
|
SStreamTaskIter *pTaskIter = createStreamTaskIter(pStream);
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, j);
|
while (streamTaskIterNextTask(pTaskIter)) {
|
||||||
|
SStreamTask *pTask = streamTaskIterGetCurrent(pTaskIter);
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t k = 0; k < numOfTasks; ++k) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, k);
|
|
||||||
|
|
||||||
SNodeEntry entry = {.hbTimestamp = -1, .nodeId = pTask->info.nodeId};
|
SNodeEntry entry = {.hbTimestamp = -1, .nodeId = pTask->info.nodeId};
|
||||||
epsetAssign(&entry.epset, &pTask->info.epSet);
|
epsetAssign(&entry.epset, &pTask->info.epSet);
|
||||||
taosHashPut(pHash, &entry.nodeId, sizeof(entry.nodeId), &entry, sizeof(entry));
|
taosHashPut(pHash, &entry.nodeId, sizeof(entry.nodeId), &entry, sizeof(entry));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
destroyStreamTaskIter(pTaskIter);
|
||||||
taosWUnLockLatch(&pStream->lock);
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
|
||||||
sdbRelease(pSdb, pStream);
|
sdbRelease(pSdb, pStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2055,14 +2070,9 @@ static int32_t mndProcessNodeCheck(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveStreamTasksInfo(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
void saveStreamTasksInfo(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||||
int32_t level = taosArrayGetSize(pStream->tasks);
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
for (int32_t i = 0; i < level; i++) {
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t j = 0; j < numOfTasks; j++) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
|
||||||
|
|
||||||
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
||||||
void *p = taosHashGet(pExecNode->pTaskMap, &id, sizeof(id));
|
void *p = taosHashGet(pExecNode->pTaskMap, &id, sizeof(id));
|
||||||
|
@ -2076,17 +2086,14 @@ void saveStreamTasksInfo(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||||
(int32_t)taosArrayGetSize(pExecNode->pTaskList));
|
(int32_t)taosArrayGetSize(pExecNode->pTaskList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||||
int32_t level = taosArrayGetSize(pStream->tasks);
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
for (int32_t i = 0; i < level; i++) {
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t j = 0; j < numOfTasks; j++) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
|
||||||
|
|
||||||
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
||||||
void *p = taosHashGet(pExecNode->pTaskMap, &id, sizeof(id));
|
void *p = taosHashGet(pExecNode->pTaskMap, &id, sizeof(id));
|
||||||
|
@ -2105,8 +2112,8 @@ void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
ASSERT(taosHashGetSize(pExecNode->pTaskMap) == taosArrayGetSize(pExecNode->pTaskList));
|
ASSERT(taosHashGetSize(pExecNode->pTaskMap) == taosArrayGetSize(pExecNode->pTaskList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2137,7 +2144,6 @@ static void doAddTaskId(SArray* pList, int32_t taskId, int64_t uid, int32_t numO
|
||||||
|
|
||||||
int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
|
||||||
SStreamTaskCheckpointReq req = {0};
|
SStreamTaskCheckpointReq req = {0};
|
||||||
|
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
|
|
|
@ -65,61 +65,24 @@ static void addIntoCheckpointList(SArray* pList, const SFailedCheckpointInfo* pI
|
||||||
taosArrayPush(pList, pInfo);
|
taosArrayPush(pList, pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
|
int32_t createStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, MND_STREAM_TASK_RESET_NAME, " reset from failed checkpoint");
|
STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, MND_STREAM_TASK_RESET_NAME, " reset from failed checkpoint");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int32_t code = */mndStreamRegisterTrans(pTrans, MND_STREAM_TASK_RESET_NAME, pStream->uid);
|
/*int32_t code = */mndStreamRegisterTrans(pTrans, MND_STREAM_TASK_RESET_NAME, pStream->uid);
|
||||||
|
int32_t code = mndStreamSetResetTaskAction(pMnode, pTrans, pStream);
|
||||||
taosWLockLatch(&pStream->lock);
|
|
||||||
int32_t numOfLevels = taosArrayGetSize(pStream->tasks);
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfLevels; ++j) {
|
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, j);
|
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t k = 0; k < numOfTasks; ++k) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, k);
|
|
||||||
|
|
||||||
// todo extract method, with pause stream task
|
|
||||||
SVResetStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVResetStreamTaskReq));
|
|
||||||
if (pReq == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
mError("failed to malloc in reset stream, size:%" PRIzu ", code:%s", sizeof(SVResetStreamTaskReq),
|
|
||||||
tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
pReq->head.vgId = htonl(pTask->info.nodeId);
|
|
||||||
pReq->taskId = pTask->id.taskId;
|
|
||||||
pReq->streamId = pTask->id.streamId;
|
|
||||||
|
|
||||||
SEpSet epset = {0};
|
|
||||||
bool hasEpset = false;
|
|
||||||
int32_t code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
|
||||||
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = setTransAction(pTrans, pReq, sizeof(SVResetStreamTaskReq), TDMT_VND_STREAM_TASK_RESET, &epset, 0);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(pReq);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
taosWUnLockLatch(&pStream->lock);
|
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return terrno;
|
return code;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
code = mndPersistTransLog(pStream, pTrans, SDB_STATUS_READY);
|
||||||
|
|
||||||
int32_t code = mndPersistTransLog(pStream, pTrans, SDB_STATUS_READY);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +182,40 @@ static int32_t mndDropOrphanTasks(SMnode* pMnode, SArray* pList) {
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t suspendAllStreams(SMnode *pMnode, SRpcHandleInfo* info){
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
SStreamObj *pStream = NULL;
|
||||||
|
void* pIter = NULL;
|
||||||
|
while(1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if(pStream->status != STREAM_STATUS__PAUSE){
|
||||||
|
SMPauseStreamReq reqPause = {0};
|
||||||
|
strcpy(reqPause.name, pStream->name);
|
||||||
|
reqPause.igNotExists = 1;
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMPauseStreamReq(NULL, 0, &reqPause);
|
||||||
|
void * pHead = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMPauseStreamReq(pHead, contLen, &reqPause);
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = TDMT_MND_PAUSE_STREAM,
|
||||||
|
.pCont = pHead,
|
||||||
|
.contLen = contLen,
|
||||||
|
.info = *info,
|
||||||
|
};
|
||||||
|
|
||||||
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
mInfo("receive pause stream:%s, %s, %p, because grant expired", pStream->name, reqPause.name, reqPause.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pStream);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +225,12 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
SArray *pFailedTasks = taosArrayInit(4, sizeof(SFailedCheckpointInfo));
|
SArray *pFailedTasks = taosArrayInit(4, sizeof(SFailedCheckpointInfo));
|
||||||
SArray *pOrphanTasks = taosArrayInit(3, sizeof(SOrphanTask));
|
SArray *pOrphanTasks = taosArrayInit(3, sizeof(SOrphanTask));
|
||||||
|
|
||||||
|
if(grantCheck(TSDB_GRANT_STREAMS) < 0){
|
||||||
|
if(suspendAllStreams(pMnode, &pReq->info) < 0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, pReq->pCont, pReq->contLen);
|
tDecoderInit(&decoder, pReq->pCont, pReq->contLen);
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@ typedef struct SKeyInfo {
|
||||||
|
|
||||||
static int32_t clearFinishedTrans(SMnode* pMnode);
|
static int32_t clearFinishedTrans(SMnode* pMnode);
|
||||||
|
|
||||||
int32_t mndStreamRegisterTrans(STrans* pTrans, const char* pTransName, int64_t streamUid) {
|
int32_t mndStreamRegisterTrans(STrans* pTrans, const char* pTransName, int64_t streamId) {
|
||||||
SStreamTransInfo info = {
|
SStreamTransInfo info = {
|
||||||
.transId = pTrans->id, .startTime = taosGetTimestampMs(), .name = pTransName, .streamUid = streamUid};
|
.transId = pTrans->id, .startTime = taosGetTimestampMs(), .name = pTransName, .streamId = streamId};
|
||||||
taosHashPut(execInfo.transMgmt.pDBTrans, &streamUid, sizeof(streamUid), &info, sizeof(SStreamTransInfo));
|
taosHashPut(execInfo.transMgmt.pDBTrans, &streamId, sizeof(streamId), &info, sizeof(SStreamTransInfo));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ int32_t clearFinishedTrans(SMnode* pMnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndStreamTransConflictCheck(SMnode* pMnode, int64_t streamUid, const char* pTransName, bool lock) {
|
bool mndStreamTransConflictCheck(SMnode* pMnode, int64_t streamId, const char* pTransName, bool lock) {
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadMutexLock(&execInfo.lock);
|
taosThreadMutexLock(&execInfo.lock);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ bool mndStreamTransConflictCheck(SMnode* pMnode, int64_t streamUid, const char*
|
||||||
|
|
||||||
clearFinishedTrans(pMnode);
|
clearFinishedTrans(pMnode);
|
||||||
|
|
||||||
SStreamTransInfo *pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamUid, sizeof(streamUid));
|
SStreamTransInfo *pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamId, sizeof(streamId));
|
||||||
if (pEntry != NULL) {
|
if (pEntry != NULL) {
|
||||||
SStreamTransInfo tInfo = *pEntry;
|
SStreamTransInfo tInfo = *pEntry;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ bool mndStreamTransConflictCheck(SMnode* pMnode, int64_t streamUid, const char*
|
||||||
|
|
||||||
if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
||||||
if ((strcmp(pTransName, MND_STREAM_DROP_NAME) != 0) && (strcmp(pTransName, MND_STREAM_TASK_RESET_NAME) != 0)) {
|
if ((strcmp(pTransName, MND_STREAM_DROP_NAME) != 0) && (strcmp(pTransName, MND_STREAM_TASK_RESET_NAME) != 0)) {
|
||||||
mWarn("conflict with other transId:%d streamUid:0x%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamUid,
|
mWarn("conflict with other transId:%d streamUid:0x%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamId,
|
||||||
tInfo.name);
|
tInfo.name);
|
||||||
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||||
return true;
|
return true;
|
||||||
|
@ -99,13 +99,13 @@ bool mndStreamTransConflictCheck(SMnode* pMnode, int64_t streamUid, const char*
|
||||||
}
|
}
|
||||||
} else if ((strcmp(tInfo.name, MND_STREAM_CREATE_NAME) == 0) || (strcmp(tInfo.name, MND_STREAM_DROP_NAME) == 0) ||
|
} else if ((strcmp(tInfo.name, MND_STREAM_CREATE_NAME) == 0) || (strcmp(tInfo.name, MND_STREAM_DROP_NAME) == 0) ||
|
||||||
(strcmp(tInfo.name, MND_STREAM_TASK_RESET_NAME) == 0)) {
|
(strcmp(tInfo.name, MND_STREAM_TASK_RESET_NAME) == 0)) {
|
||||||
mWarn("conflict with other transId:%d streamUid:0x%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamUid,
|
mWarn("conflict with other transId:%d streamUid:0x%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamId,
|
||||||
tInfo.name);
|
tInfo.name);
|
||||||
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mDebug("stream:0x%"PRIx64" no conflict trans existed, continue create trans", streamUid);
|
mDebug("stream:0x%"PRIx64" no conflict trans existed, continue create trans", streamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
|
@ -301,86 +301,4 @@ void killAllCheckpointTrans(SMnode *pMnode, SVgroupChangeInfo *pChangeInfo) {
|
||||||
mDebug("complete clear checkpoints in Dbs");
|
mDebug("complete clear checkpoints in Dbs");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initNodeUpdateMsg(SStreamTaskNodeUpdateMsg *pMsg, const SVgroupChangeInfo *pInfo, SStreamTaskId *pId,
|
|
||||||
int32_t transId) {
|
|
||||||
pMsg->streamId = pId->streamId;
|
|
||||||
pMsg->taskId = pId->taskId;
|
|
||||||
pMsg->transId = transId;
|
|
||||||
pMsg->pNodeList = taosArrayInit(taosArrayGetSize(pInfo->pUpdateNodeList), sizeof(SNodeUpdateInfo));
|
|
||||||
taosArrayAddAll(pMsg->pNodeList, pInfo->pUpdateNodeList);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t doBuildStreamTaskUpdateMsg(void **pBuf, int32_t *pLen, SVgroupChangeInfo *pInfo, int32_t nodeId,
|
|
||||||
SStreamTaskId *pId, int32_t transId) {
|
|
||||||
SStreamTaskNodeUpdateMsg req = {0};
|
|
||||||
initNodeUpdateMsg(&req, pInfo, pId, transId);
|
|
||||||
|
|
||||||
int32_t code = 0;
|
|
||||||
int32_t blen;
|
|
||||||
|
|
||||||
tEncodeSize(tEncodeStreamTaskUpdateMsg, &req, blen, code);
|
|
||||||
if (code < 0) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
taosArrayDestroy(req.pNodeList);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tlen = sizeof(SMsgHead) + blen;
|
|
||||||
|
|
||||||
void *buf = taosMemoryMalloc(tlen);
|
|
||||||
if (buf == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
taosArrayDestroy(req.pNodeList);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
|
||||||
SEncoder encoder;
|
|
||||||
tEncoderInit(&encoder, abuf, tlen);
|
|
||||||
tEncodeStreamTaskUpdateMsg(&encoder, &req);
|
|
||||||
|
|
||||||
SMsgHead *pMsgHead = (SMsgHead *)buf;
|
|
||||||
pMsgHead->contLen = htonl(tlen);
|
|
||||||
pMsgHead->vgId = htonl(nodeId);
|
|
||||||
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
|
|
||||||
*pBuf = buf;
|
|
||||||
*pLen = tlen;
|
|
||||||
|
|
||||||
taosArrayDestroy(req.pNodeList);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo extract method: traverse stream tasks
|
|
||||||
// build trans to update the epset
|
|
||||||
int32_t mndStreamSetUpdateEpsetAction(SStreamObj *pStream, SVgroupChangeInfo *pInfo, STrans *pTrans) {
|
|
||||||
mDebug("stream:0x%" PRIx64 " set tasks epset update action", pStream->uid);
|
|
||||||
|
|
||||||
taosWLockLatch(&pStream->lock);
|
|
||||||
int32_t numOfLevels = taosArrayGetSize(pStream->tasks);
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfLevels; ++j) {
|
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, j);
|
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t k = 0; k < numOfTasks; ++k) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, k);
|
|
||||||
|
|
||||||
void *pBuf = NULL;
|
|
||||||
int32_t len = 0;
|
|
||||||
streamTaskUpdateEpsetInfo(pTask, pInfo->pUpdateNodeList);
|
|
||||||
doBuildStreamTaskUpdateMsg(&pBuf, &len, pInfo, pTask->info.nodeId, &pTask->id, pTrans->id);
|
|
||||||
|
|
||||||
int32_t code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &pTask->info.epSet, 0);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
taosMemoryFree(pBuf);
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -18,15 +18,15 @@
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
|
||||||
typedef struct SStreamTaskIter {
|
struct SStreamTaskIter {
|
||||||
SStreamObj *pStream;
|
SStreamObj *pStream;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
int32_t ordinalIndex;
|
int32_t ordinalIndex;
|
||||||
int32_t totalLevel;
|
int32_t totalLevel;
|
||||||
SStreamTask *pTask;
|
SStreamTask *pTask;
|
||||||
} SStreamTaskIter;
|
};
|
||||||
|
|
||||||
SStreamTaskIter* createTaskIter(SStreamObj* pStream) {
|
SStreamTaskIter* createStreamTaskIter(SStreamObj* pStream) {
|
||||||
SStreamTaskIter* pIter = taosMemoryCalloc(1, sizeof(SStreamTaskIter));
|
SStreamTaskIter* pIter = taosMemoryCalloc(1, sizeof(SStreamTaskIter));
|
||||||
if (pIter == NULL) {
|
if (pIter == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -42,7 +42,7 @@ SStreamTaskIter* createTaskIter(SStreamObj* pStream) {
|
||||||
return pIter;
|
return pIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taskIterNextTask(SStreamTaskIter* pIter) {
|
bool streamTaskIterNextTask(SStreamTaskIter* pIter) {
|
||||||
if (pIter->level >= pIter->totalLevel) {
|
if (pIter->level >= pIter->totalLevel) {
|
||||||
pIter->pTask = NULL;
|
pIter->pTask = NULL;
|
||||||
return false;
|
return false;
|
||||||
|
@ -70,11 +70,11 @@ bool taskIterNextTask(SStreamTaskIter* pIter) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamTask* taskIterGetCurrent(SStreamTaskIter* pIter) {
|
SStreamTask* streamTaskIterGetCurrent(SStreamTaskIter* pIter) {
|
||||||
return pIter->pTask;
|
return pIter->pTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyTaskIter(SStreamTaskIter* pIter) {
|
void destroyStreamTaskIter(SStreamTaskIter* pIter) {
|
||||||
taosMemoryFree(pIter);
|
taosMemoryFree(pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,18 +235,16 @@ static int32_t doSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamTask *pT
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamTask *mndGetStreamTask(STaskId *pId, SStreamObj *pStream) {
|
SStreamTask *mndGetStreamTask(STaskId *pId, SStreamObj *pStream) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pStream->tasks); i++) {
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
SArray *pLevel = taosArrayGetP(pStream->tasks, i);
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
int32_t numOfLevels = taosArrayGetSize(pLevel);
|
|
||||||
for (int32_t j = 0; j < numOfLevels; j++) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pLevel, j);
|
|
||||||
if (pTask->id.taskId == pId->taskId) {
|
if (pTask->id.taskId == pId->taskId) {
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
return pTask;
|
return pTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,13 +259,12 @@ int32_t mndGetNumOfStreamTasks(const SStreamObj *pStream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj *pStream, int8_t igUntreated) {
|
int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj *pStream, int8_t igUntreated) {
|
||||||
int32_t size = taosArrayGetSize(pStream->tasks);
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
|
||||||
SArray *pTasks = taosArrayGetP(pStream->tasks, i);
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
int32_t sz = taosArrayGetSize(pTasks);
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
for (int32_t j = 0; j < sz; j++) {
|
|
||||||
SStreamTask *pTask = taosArrayGetP(pTasks, j);
|
|
||||||
if (doSetResumeAction(pTrans, pMnode, pTask, igUntreated) < 0) {
|
if (doSetResumeAction(pTrans, pMnode, pTask, igUntreated) < 0) {
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +272,7 @@ int32_t mndStreamSetResumeAction(STrans *pTrans, SMnode *pMnode, SStreamObj *pSt
|
||||||
atomic_store_8(&pTask->status.taskStatus, pTask->status.statusBackup);
|
atomic_store_8(&pTask->status.taskStatus, pTask->status.statusBackup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
destroyStreamTaskIter(pIter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,12 +308,12 @@ static int32_t doSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTa
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
SStreamTaskIter *pIter = createTaskIter(pStream);
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
|
|
||||||
while (taskIterNextTask(pIter)) {
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
SStreamTask *pTask = taskIterGetCurrent(pIter);
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
if (doSetPauseAction(pMnode, pTrans, pTask) < 0) {
|
if (doSetPauseAction(pMnode, pTrans, pTask) < 0) {
|
||||||
destroyTaskIter(pIter);
|
destroyStreamTaskIter(pIter);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +323,7 @@ int32_t mndStreamSetPauseAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyTaskIter(pIter);
|
destroyStreamTaskIter(pIter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,16 +357,16 @@ static int32_t doSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTas
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
int32_t mndStreamSetDropAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
SStreamTaskIter *pIter = createTaskIter(pStream);
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
|
|
||||||
while(taskIterNextTask(pIter)) {
|
while(streamTaskIterNextTask(pIter)) {
|
||||||
SStreamTask *pTask = taskIterGetCurrent(pIter);
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
if (doSetDropAction(pMnode, pTrans, pTask) < 0) {
|
if (doSetDropAction(pMnode, pTrans, pTask) < 0) {
|
||||||
destroyTaskIter(pIter);
|
destroyStreamTaskIter(pIter);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
destroyTaskIter(pIter);
|
destroyStreamTaskIter(pIter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,3 +408,138 @@ int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray* p
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void initNodeUpdateMsg(SStreamTaskNodeUpdateMsg *pMsg, const SVgroupChangeInfo *pInfo, SStreamTaskId *pId,
|
||||||
|
int32_t transId) {
|
||||||
|
pMsg->streamId = pId->streamId;
|
||||||
|
pMsg->taskId = pId->taskId;
|
||||||
|
pMsg->transId = transId;
|
||||||
|
pMsg->pNodeList = taosArrayInit(taosArrayGetSize(pInfo->pUpdateNodeList), sizeof(SNodeUpdateInfo));
|
||||||
|
taosArrayAddAll(pMsg->pNodeList, pInfo->pUpdateNodeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t doBuildStreamTaskUpdateMsg(void **pBuf, int32_t *pLen, SVgroupChangeInfo *pInfo, int32_t nodeId,
|
||||||
|
SStreamTaskId *pId, int32_t transId) {
|
||||||
|
SStreamTaskNodeUpdateMsg req = {0};
|
||||||
|
initNodeUpdateMsg(&req, pInfo, pId, transId);
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t blen;
|
||||||
|
|
||||||
|
tEncodeSize(tEncodeStreamTaskUpdateMsg, &req, blen, code);
|
||||||
|
if (code < 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosArrayDestroy(req.pNodeList);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tlen = sizeof(SMsgHead) + blen;
|
||||||
|
|
||||||
|
void *buf = taosMemoryMalloc(tlen);
|
||||||
|
if (buf == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosArrayDestroy(req.pNodeList);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
|
SEncoder encoder;
|
||||||
|
tEncoderInit(&encoder, abuf, tlen);
|
||||||
|
tEncodeStreamTaskUpdateMsg(&encoder, &req);
|
||||||
|
|
||||||
|
SMsgHead *pMsgHead = (SMsgHead *)buf;
|
||||||
|
pMsgHead->contLen = htonl(tlen);
|
||||||
|
pMsgHead->vgId = htonl(nodeId);
|
||||||
|
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
*pBuf = buf;
|
||||||
|
*pLen = tlen;
|
||||||
|
|
||||||
|
taosArrayDestroy(req.pNodeList);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t doSetUpdateTaskAction(STrans *pTrans, SStreamTask *pTask, SVgroupChangeInfo *pInfo) {
|
||||||
|
void *pBuf = NULL;
|
||||||
|
int32_t len = 0;
|
||||||
|
streamTaskUpdateEpsetInfo(pTask, pInfo->pUpdateNodeList);
|
||||||
|
|
||||||
|
doBuildStreamTaskUpdateMsg(&pBuf, &len, pInfo, pTask->info.nodeId, &pTask->id, pTrans->id);
|
||||||
|
|
||||||
|
int32_t code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &pTask->info.epSet, 0);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosMemoryFree(pBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// build trans to update the epset
|
||||||
|
int32_t mndStreamSetUpdateEpsetAction(SStreamObj *pStream, SVgroupChangeInfo *pInfo, STrans *pTrans) {
|
||||||
|
mDebug("stream:0x%" PRIx64 " set tasks epset update action", pStream->uid);
|
||||||
|
taosWLockLatch(&pStream->lock);
|
||||||
|
|
||||||
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
|
int32_t code = doSetUpdateTaskAction(pTrans, pTask, pInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t doSetResetAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTask) {
|
||||||
|
SVResetStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVResetStreamTaskReq));
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
mError("failed to malloc in reset stream, size:%" PRIzu ", code:%s", sizeof(SVResetStreamTaskReq),
|
||||||
|
tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
pReq->head.vgId = htonl(pTask->info.nodeId);
|
||||||
|
pReq->taskId = pTask->id.taskId;
|
||||||
|
pReq->streamId = pTask->id.streamId;
|
||||||
|
|
||||||
|
SEpSet epset = {0};
|
||||||
|
bool hasEpset = false;
|
||||||
|
int32_t code = extractNodeEpset(pMnode, &epset, &hasEpset, pTask->id.taskId, pTask->info.nodeId);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || !hasEpset) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = setTransAction(pTrans, pReq, sizeof(SVResetStreamTaskReq), TDMT_VND_STREAM_TASK_RESET, &epset, 0);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndStreamSetResetTaskAction(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
|
||||||
|
taosWLockLatch(&pStream->lock);
|
||||||
|
|
||||||
|
SStreamTaskIter *pIter = createStreamTaskIter(pStream);
|
||||||
|
while (streamTaskIterNextTask(pIter)) {
|
||||||
|
SStreamTask *pTask = streamTaskIterGetCurrent(pIter);
|
||||||
|
int32_t code = doSetResetAction(pMnode, pTrans, pTask);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyStreamTaskIter(pIter);
|
||||||
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -599,6 +599,8 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
||||||
pTrans->originRpcType = pReq->msgType;
|
pTrans->originRpcType = pReq->msgType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("trans:%d, create transaction:%s, origin:%s", pTrans->id, pTrans->opername, opername);
|
||||||
|
|
||||||
mTrace("trans:%d, local object is created, data:%p", pTrans->id, pTrans);
|
mTrace("trans:%d, local object is created, data:%p", pTrans->id, pTrans);
|
||||||
return pTrans;
|
return pTrans;
|
||||||
}
|
}
|
||||||
|
@ -845,6 +847,8 @@ int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
if(pTrans == NULL) return -1;
|
||||||
|
|
||||||
if (mndTransCheckConflict(pMnode, pTrans) != 0) {
|
if (mndTransCheckConflict(pMnode, pTrans) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1925,6 +1925,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosHashPut(pNewUser->topics, pTopic->name, len, pTopic->name, TSDB_TOPIC_FNAME_LEN);
|
taosHashPut(pNewUser->topics, pTopic->name, len, pTopic->name, TSDB_TOPIC_FNAME_LEN);
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ALTER_USER_DEL_SUBSCRIBE_TOPIC_PRIV(pAlterReq->alterType, pAlterReq->privileges)) {
|
if (ALTER_USER_DEL_SUBSCRIBE_TOPIC_PRIV(pAlterReq->alterType, pAlterReq->privileges)) {
|
||||||
|
@ -1935,6 +1936,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosHashRemove(pNewUser->topics, pAlterReq->objname, len);
|
taosHashRemove(pNewUser->topics, pAlterReq->objname, len);
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -152,7 +152,8 @@ typedef enum {
|
||||||
SDB_STREAM_SEQ = 23,
|
SDB_STREAM_SEQ = 23,
|
||||||
SDB_COMPACT = 24,
|
SDB_COMPACT = 24,
|
||||||
SDB_COMPACT_DETAIL = 25,
|
SDB_COMPACT_DETAIL = 25,
|
||||||
SDB_MAX = 26
|
SDB_GRANT = 26, // grant log
|
||||||
|
SDB_MAX = 27
|
||||||
} ESdbType;
|
} ESdbType;
|
||||||
|
|
||||||
typedef struct SSdbRaw {
|
typedef struct SSdbRaw {
|
||||||
|
|
|
@ -72,9 +72,11 @@ void initStateStoreAPI(SStateStore* pStore) {
|
||||||
pStore->streamStateSessionGetKVByCur = streamStateSessionGetKVByCur;
|
pStore->streamStateSessionGetKVByCur = streamStateSessionGetKVByCur;
|
||||||
pStore->streamStateStateAddIfNotExist = streamStateStateAddIfNotExist;
|
pStore->streamStateStateAddIfNotExist = streamStateStateAddIfNotExist;
|
||||||
pStore->streamStateSessionGetKeyByRange = streamStateSessionGetKeyByRange;
|
pStore->streamStateSessionGetKeyByRange = streamStateSessionGetKeyByRange;
|
||||||
|
pStore->streamStateCountGetKeyByRange = streamStateCountGetKeyByRange;
|
||||||
pStore->streamStateSessionAllocWinBuffByNextPosition = streamStateSessionAllocWinBuffByNextPosition;
|
pStore->streamStateSessionAllocWinBuffByNextPosition = streamStateSessionAllocWinBuffByNextPosition;
|
||||||
|
|
||||||
pStore->streamStateCountWinAddIfNotExist = streamStateCountWinAddIfNotExist;
|
pStore->streamStateCountWinAddIfNotExist = streamStateCountWinAddIfNotExist;
|
||||||
|
pStore->streamStateCountWinAdd = streamStateCountWinAdd;
|
||||||
|
|
||||||
pStore->updateInfoInit = updateInfoInit;
|
pStore->updateInfoInit = updateInfoInit;
|
||||||
pStore->updateInfoFillBlockData = updateInfoFillBlockData;
|
pStore->updateInfoFillBlockData = updateInfoFillBlockData;
|
||||||
|
@ -92,6 +94,7 @@ void initStateStoreAPI(SStateStore* pStore) {
|
||||||
pStore->updateInfoDeserialize = updateInfoDeserialize;
|
pStore->updateInfoDeserialize = updateInfoDeserialize;
|
||||||
|
|
||||||
pStore->streamStateSessionSeekKeyNext = streamStateSessionSeekKeyNext;
|
pStore->streamStateSessionSeekKeyNext = streamStateSessionSeekKeyNext;
|
||||||
|
pStore->streamStateCountSeekKeyPrev = streamStateCountSeekKeyPrev;
|
||||||
pStore->streamStateSessionSeekKeyCurrentPrev = streamStateSessionSeekKeyCurrentPrev;
|
pStore->streamStateSessionSeekKeyCurrentPrev = streamStateSessionSeekKeyCurrentPrev;
|
||||||
pStore->streamStateSessionSeekKeyCurrentNext = streamStateSessionSeekKeyCurrentNext;
|
pStore->streamStateSessionSeekKeyCurrentNext = streamStateSessionSeekKeyCurrentNext;
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ int metaOpenIdx(SMeta *pMeta) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
void metaCloseIdx(SMeta *pMeta) { /* TODO */
|
void metaCloseIdx(SMeta *pMeta) { /* TODO */
|
||||||
#if 0
|
#if 0
|
||||||
if (pMeta->pIdx) {
|
if (pMeta->pIdx) {
|
||||||
|
@ -114,3 +115,4 @@ int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -273,7 +273,9 @@ static void metaCleanup(SMeta **ppMeta) {
|
||||||
if (pMeta) {
|
if (pMeta) {
|
||||||
if (pMeta->pEnv) metaAbort(pMeta);
|
if (pMeta->pEnv) metaAbort(pMeta);
|
||||||
if (pMeta->pCache) metaCacheClose(pMeta);
|
if (pMeta->pCache) metaCacheClose(pMeta);
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||||
|
#endif
|
||||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||||
|
|
|
@ -738,10 +738,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) {
|
||||||
if (pTask->pState == NULL) {
|
if (pTask->pState == NULL) {
|
||||||
tqError("s-task:%s (vgId:%d) failed to open state for task", pTask->id.idStr, vgId);
|
tqError("s-task:%s (vgId:%d) failed to open state for task", pTask->id.idStr, vgId);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
tqDebug("s-task:%s state:%p", pTask->id.idStr, pTask->pState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tqDebug("s-task:%s state:%p", pTask->id.idStr, pTask->pState);
|
||||||
if (pTask->info.fillHistory) {
|
if (pTask->info.fillHistory) {
|
||||||
restoreStreamTaskId(pTask, &taskId);
|
restoreStreamTaskId(pTask, &taskId);
|
||||||
}
|
}
|
||||||
|
@ -835,8 +834,8 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) {
|
||||||
SCheckpointInfo* pChkInfo = &pTask->chkInfo;
|
SCheckpointInfo* pChkInfo = &pTask->chkInfo;
|
||||||
|
|
||||||
// checkpoint ver is the kept version, handled data should be the next version.
|
// checkpoint ver is the kept version, handled data should be the next version.
|
||||||
if (pTask->chkInfo.checkpointId != 0) {
|
if (pChkInfo->checkpointId != 0) {
|
||||||
pTask->chkInfo.nextProcessVer = pTask->chkInfo.checkpointVer + 1;
|
pChkInfo->nextProcessVer = pChkInfo->checkpointVer + 1;
|
||||||
tqInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " currentVer:%" PRId64, pTask->id.idStr,
|
tqInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " currentVer:%" PRId64, pTask->id.idStr,
|
||||||
pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer);
|
pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer);
|
||||||
}
|
}
|
||||||
|
@ -846,17 +845,19 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) {
|
||||||
if (pTask->info.fillHistory) {
|
if (pTask->info.fillHistory) {
|
||||||
tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
||||||
" nextProcessVer:%" PRId64
|
" nextProcessVer:%" PRId64
|
||||||
" child id:%d, level:%d, status:%s fill-history:%d, related stream task:0x%x trigger:%" PRId64 " ms",
|
" child id:%d, level:%d, status:%s fill-history:%d, related stream task:0x%x trigger:%" PRId64
|
||||||
|
" ms, inputVer:%" PRId64,
|
||||||
vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer,
|
vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer,
|
||||||
pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory,
|
pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory,
|
||||||
(int32_t)pTask->streamTaskId.taskId, pTask->info.triggerParam);
|
(int32_t)pTask->streamTaskId.taskId, pTask->info.triggerParam, nextProcessVer);
|
||||||
} else {
|
} else {
|
||||||
tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64
|
||||||
" nextProcessVer:%" PRId64
|
" nextProcessVer:%" PRId64
|
||||||
" child id:%d, level:%d, status:%s fill-history:%d, related fill-task:0x%x trigger:%" PRId64 " ms",
|
" child id:%d, level:%d, status:%s fill-history:%d, related fill-task:0x%x trigger:%" PRId64
|
||||||
|
" ms, inputVer:%" PRId64,
|
||||||
vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer,
|
vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer,
|
||||||
pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory,
|
pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory,
|
||||||
(int32_t)pTask->hTaskInfo.id.taskId, pTask->info.triggerParam);
|
(int32_t)pTask->hTaskInfo.id.taskId, pTask->info.triggerParam, nextProcessVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -878,10 +879,9 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t ms
|
||||||
static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask, STQ* pTq) {
|
static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask, STQ* pTq) {
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
int64_t nextProcessedVer = pStreamTask->hTaskInfo.haltVer;
|
int64_t nextProcessedVer = pStreamTask->hTaskInfo.haltVer;
|
||||||
|
|
||||||
// if it's an source task, extract the last version in wal.
|
|
||||||
SVersionRange* pRange = &pTask->dataRange.range;
|
SVersionRange* pRange = &pTask->dataRange.range;
|
||||||
|
|
||||||
|
// if it's an source task, extract the last version in wal.
|
||||||
bool done = streamHistoryTaskSetVerRangeStep2(pTask, nextProcessedVer);
|
bool done = streamHistoryTaskSetVerRangeStep2(pTask, nextProcessedVer);
|
||||||
pTask->execInfo.step2Start = taosGetTimestampMs();
|
pTask->execInfo.step2Start = taosGetTimestampMs();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqStreamOneTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t streamId, int32_t taskId) {
|
int32_t tqStreamStartOneTaskAsync(SStreamMeta* pMeta, SMsgCb* cb, int64_t streamId, int32_t taskId) {
|
||||||
int32_t vgId = pMeta->vgId;
|
int32_t vgId = pMeta->vgId;
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
||||||
|
@ -547,7 +547,7 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sve
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tqError("failed to add s-task:0x%x into vgId:%d meta, total:%d, code:%s", vgId, taskId, numOfTasks,
|
tqError("failed to add s-task:0x%x into vgId:%d meta, existed:%d, code:%s", vgId, taskId, numOfTasks,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
tFreeStreamTask(pTask);
|
tFreeStreamTask(pTask);
|
||||||
return code;
|
return code;
|
||||||
|
@ -562,9 +562,10 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, SMsgCb* cb, int64_t sve
|
||||||
|
|
||||||
if (restored) {
|
if (restored) {
|
||||||
SStreamTask* p = streamMetaAcquireTask(pMeta, streamId, taskId);
|
SStreamTask* p = streamMetaAcquireTask(pMeta, streamId, taskId);
|
||||||
if (p != NULL && (p->info.fillHistory == 0)) {
|
if ((p != NULL) && (p->info.fillHistory == 0)) {
|
||||||
tqStreamOneTaskStartAsync(pMeta, cb, streamId, taskId);
|
tqStreamStartOneTaskAsync(pMeta, cb, streamId, taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
streamMetaReleaseTask(pMeta, p);
|
streamMetaReleaseTask(pMeta, p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2294,6 +2294,7 @@ void updateComposedBlockInfo(STsdbReader* pReader, double el, STableBlockScanInf
|
||||||
|
|
||||||
pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0;
|
pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0;
|
||||||
pResBlock->info.dataLoad = 1;
|
pResBlock->info.dataLoad = 1;
|
||||||
|
pResBlock->info.version = pReader->info.verRange.maxVer;
|
||||||
blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]);
|
blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]);
|
||||||
setComposedBlockFlag(pReader, true);
|
setComposedBlockFlag(pReader, true);
|
||||||
|
|
||||||
|
@ -2799,6 +2800,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
||||||
pInfo->rows = pBlockInfo->numRow;
|
pInfo->rows = pBlockInfo->numRow;
|
||||||
pInfo->id.uid = pScanInfo->uid;
|
pInfo->id.uid = pScanInfo->uid;
|
||||||
pInfo->dataLoad = 0;
|
pInfo->dataLoad = 0;
|
||||||
|
pInfo->version = pReader->info.verRange.maxVer;
|
||||||
pInfo->window = (STimeWindow){.skey = pBlockInfo->firstKey, .ekey = pBlockInfo->lastKey};
|
pInfo->window = (STimeWindow){.skey = pBlockInfo->firstKey, .ekey = pBlockInfo->lastKey};
|
||||||
setComposedBlockFlag(pReader, false);
|
setComposedBlockFlag(pReader, false);
|
||||||
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlockInfo->lastKey, pReader->info.order);
|
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlockInfo->lastKey, pReader->info.order);
|
||||||
|
|
|
@ -184,9 +184,11 @@ void initStateStoreAPI(SStateStore* pStore) {
|
||||||
pStore->streamStateSessionGetKVByCur = streamStateSessionGetKVByCur;
|
pStore->streamStateSessionGetKVByCur = streamStateSessionGetKVByCur;
|
||||||
pStore->streamStateStateAddIfNotExist = streamStateStateAddIfNotExist;
|
pStore->streamStateStateAddIfNotExist = streamStateStateAddIfNotExist;
|
||||||
pStore->streamStateSessionGetKeyByRange = streamStateSessionGetKeyByRange;
|
pStore->streamStateSessionGetKeyByRange = streamStateSessionGetKeyByRange;
|
||||||
|
pStore->streamStateCountGetKeyByRange = streamStateCountGetKeyByRange;
|
||||||
pStore->streamStateSessionAllocWinBuffByNextPosition = streamStateSessionAllocWinBuffByNextPosition;
|
pStore->streamStateSessionAllocWinBuffByNextPosition = streamStateSessionAllocWinBuffByNextPosition;
|
||||||
|
|
||||||
pStore->streamStateCountWinAddIfNotExist = streamStateCountWinAddIfNotExist;
|
pStore->streamStateCountWinAddIfNotExist = streamStateCountWinAddIfNotExist;
|
||||||
|
pStore->streamStateCountWinAdd = streamStateCountWinAdd;
|
||||||
|
|
||||||
pStore->updateInfoInit = updateInfoInit;
|
pStore->updateInfoInit = updateInfoInit;
|
||||||
pStore->updateInfoFillBlockData = updateInfoFillBlockData;
|
pStore->updateInfoFillBlockData = updateInfoFillBlockData;
|
||||||
|
@ -204,6 +206,7 @@ void initStateStoreAPI(SStateStore* pStore) {
|
||||||
pStore->updateInfoDeserialize = updateInfoDeserialize;
|
pStore->updateInfoDeserialize = updateInfoDeserialize;
|
||||||
|
|
||||||
pStore->streamStateSessionSeekKeyNext = streamStateSessionSeekKeyNext;
|
pStore->streamStateSessionSeekKeyNext = streamStateSessionSeekKeyNext;
|
||||||
|
pStore->streamStateCountSeekKeyPrev = streamStateCountSeekKeyPrev;
|
||||||
pStore->streamStateSessionSeekKeyCurrentPrev = streamStateSessionSeekKeyCurrentPrev;
|
pStore->streamStateSessionSeekKeyCurrentPrev = streamStateSessionSeekKeyCurrentPrev;
|
||||||
pStore->streamStateSessionSeekKeyCurrentNext = streamStateSessionSeekKeyCurrentNext;
|
pStore->streamStateSessionSeekKeyCurrentNext = streamStateSessionSeekKeyCurrentNext;
|
||||||
|
|
||||||
|
|
|
@ -886,7 +886,7 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) {
|
||||||
|
|
||||||
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
||||||
SConfigItem* pItem = taosArrayGet(tsCfg->array, i);
|
SConfigItem* pItem = taosArrayGet(tsCfg->array, i);
|
||||||
GRANT_CFG_SKIP;
|
// GRANT_CFG_SKIP;
|
||||||
|
|
||||||
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
||||||
|
|
|
@ -279,7 +279,6 @@ typedef struct STableScanInfo {
|
||||||
int8_t assignBlockUid;
|
int8_t assignBlockUid;
|
||||||
uint8_t countState; // empty table count state
|
uint8_t countState; // empty table count state
|
||||||
bool hasGroupByTag;
|
bool hasGroupByTag;
|
||||||
bool countOnly;
|
|
||||||
bool filesetDelimited;
|
bool filesetDelimited;
|
||||||
bool needCountEmptyTable;
|
bool needCountEmptyTable;
|
||||||
} STableScanInfo;
|
} STableScanInfo;
|
||||||
|
@ -780,10 +779,12 @@ extern void doDestroyExchangeOperatorInfo(void* param);
|
||||||
|
|
||||||
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
||||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
||||||
int32_t rows, const char* idStr, STableMetaCacheInfo* pCache);
|
int32_t rows, SExecTaskInfo* pTask, STableMetaCacheInfo* pCache);
|
||||||
|
|
||||||
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
||||||
void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, const char* name);
|
void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, const char* name);
|
||||||
|
void setVgIdColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int32_t vgId);
|
||||||
|
void setVgVerColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int64_t vgVer);
|
||||||
|
|
||||||
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset);
|
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset);
|
||||||
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
|
@ -816,6 +817,9 @@ bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, ST
|
||||||
SStateStore* pStore);
|
SStateStore* pStore);
|
||||||
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
||||||
uint64_t* pGp, void* pTbName);
|
uint64_t* pGp, void* pTbName);
|
||||||
|
void appendAllColumnToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs,
|
||||||
|
TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName);
|
||||||
|
|
||||||
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
|
||||||
|
|
||||||
int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
|
int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
|
||||||
|
@ -900,10 +904,15 @@ SSDataBlock* getNextBlockFromDownstreamImpl(struct SOperatorInfo* pOperator, int
|
||||||
void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange);
|
void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange);
|
||||||
bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey);
|
bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey);
|
||||||
|
|
||||||
|
void saveDeleteInfo(SArray* pWins, SSessionKey key);
|
||||||
|
void removeSessionResults(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SArray* pWins);
|
||||||
|
void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted);
|
||||||
|
|
||||||
bool inSlidingWindow(SInterval* pInterval, STimeWindow* pWin, SDataBlockInfo* pBlockInfo);
|
bool inSlidingWindow(SInterval* pInterval, STimeWindow* pWin, SDataBlockInfo* pBlockInfo);
|
||||||
bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType);
|
bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType);
|
||||||
bool compareVal(const char* v, const SStateKeys* pKey);
|
bool compareVal(const char* v, const SStateKeys* pKey);
|
||||||
bool inWinRange(STimeWindow* range, STimeWindow* cur);
|
bool inWinRange(STimeWindow* range, STimeWindow* cur);
|
||||||
|
void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result);
|
||||||
|
|
||||||
int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
||||||
TSKEY* primaryKeys, int32_t prevPosition, int32_t order);
|
TSKEY* primaryKeys, int32_t prevPosition, int32_t order);
|
||||||
|
|
|
@ -250,7 +250,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
||||||
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pRes,
|
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pRes,
|
||||||
pRes->info.rows, GET_TASKID(pTaskInfo), NULL);
|
pRes->info.rows, pTaskInfo, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -313,7 +313,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
if (taosArrayGetSize(pInfo->pUidList) > 0) {
|
if (taosArrayGetSize(pInfo->pUidList) > 0) {
|
||||||
pInfo->pRes->info.id.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, 0);
|
pInfo->pRes->info.id.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, 0);
|
||||||
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes,
|
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes,
|
||||||
pInfo->pRes->info.rows, GET_TASKID(pTaskInfo), NULL);
|
pInfo->pRes->info.rows, pTaskInfo, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -311,6 +311,7 @@ static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int
|
||||||
pInput->totalRows = pBlock->info.rows;
|
pInput->totalRows = pBlock->info.rows;
|
||||||
pInput->numOfRows = pBlock->info.rows;
|
pInput->numOfRows = pBlock->info.rows;
|
||||||
pInput->startRowIndex = 0;
|
pInput->startRowIndex = 0;
|
||||||
|
pInput->blankFill = pBlock->info.blankFill;
|
||||||
|
|
||||||
// NOTE: the last parameter is the primary timestamp column
|
// NOTE: the last parameter is the primary timestamp column
|
||||||
// todo: refactor this
|
// todo: refactor this
|
||||||
|
@ -325,6 +326,7 @@ static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int
|
||||||
pInput->totalRows = pBlock->info.rows;
|
pInput->totalRows = pBlock->info.rows;
|
||||||
pInput->numOfRows = pBlock->info.rows;
|
pInput->numOfRows = pBlock->info.rows;
|
||||||
pInput->startRowIndex = 0;
|
pInput->startRowIndex = 0;
|
||||||
|
pInput->blankFill = pBlock->info.blankFill;
|
||||||
|
|
||||||
code = doCreateConstantValColumnInfo(pInput, pFuncParam, j, pBlock->info.rows);
|
code = doCreateConstantValColumnInfo(pInput, pFuncParam, j, pBlock->info.rows);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -287,7 +287,6 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
uint64_t groupId = 0;
|
|
||||||
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
||||||
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
|
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
|
||||||
if (!pInfo->isInit) {
|
if (!pInfo->isInit) {
|
||||||
|
@ -478,20 +477,6 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
|
||||||
#if 0
|
|
||||||
if(pOperator->fpSet.encodeResultRow){
|
|
||||||
char *result = NULL;
|
|
||||||
int32_t length = 0;
|
|
||||||
pOperator->fpSet.encodeResultRow(pOperator, &result, &length);
|
|
||||||
SAggSupporter* pSup = &pInfo->aggSup;
|
|
||||||
taosHashClear(pSup->pResultRowHashTable);
|
|
||||||
pInfo->binfo.resultRowInfo.size = 0;
|
|
||||||
pOperator->fpSet.decodeResultRow(pOperator, result);
|
|
||||||
if(result){
|
|
||||||
taosMemoryFree(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, 0);
|
// initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, 0);
|
||||||
if (pGroupResInfo->pRows != NULL) {
|
if (pGroupResInfo->pRows != NULL) {
|
||||||
taosArrayDestroy(pGroupResInfo->pRows);
|
taosArrayDestroy(pGroupResInfo->pRows);
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "ttime.h"
|
|
||||||
|
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
|
@ -252,7 +251,7 @@ static void doSetTagColumnData(STableScanBase* pTableScanInfo, SSDataBlock* pBlo
|
||||||
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
||||||
|
|
||||||
int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock, rows,
|
int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock, rows,
|
||||||
GET_TASKID(pTaskInfo), &pTableScanInfo->metaCache);
|
pTaskInfo, &pTableScanInfo->metaCache);
|
||||||
// ignore the table not exists error, since this table may have been dropped during the scan procedure.
|
// ignore the table not exists error, since this table may have been dropped during the scan procedure.
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
@ -482,24 +481,25 @@ static void doSetNullValue(SSDataBlock* pBlock, const SExprInfo* pExpr, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
||||||
int32_t rows, const char* idStr, STableMetaCacheInfo* pCache) {
|
int32_t rows, SExecTaskInfo* pTask, STableMetaCacheInfo* pCache) {
|
||||||
|
int32_t code = 0;
|
||||||
|
bool freeReader = false;
|
||||||
|
LRUHandle* h = NULL;
|
||||||
|
STableCachedVal val = {0};
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
const char* idStr = pTask->id.str;
|
||||||
|
|
||||||
// currently only the tbname pseudo column
|
// currently only the tbname pseudo column
|
||||||
if (numOfExpr <= 0) {
|
if (numOfExpr <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
// todo: opt if only require the vgId and the vgVer;
|
||||||
bool freeReader = false;
|
|
||||||
|
|
||||||
// backup the rows
|
// backup the rows
|
||||||
int32_t backupRows = pBlock->info.rows;
|
int32_t backupRows = pBlock->info.rows;
|
||||||
pBlock->info.rows = rows;
|
pBlock->info.rows = rows;
|
||||||
|
|
||||||
STableCachedVal val = {0};
|
|
||||||
|
|
||||||
SMetaReader mr = {0};
|
|
||||||
LRUHandle* h = NULL;
|
|
||||||
|
|
||||||
// todo refactor: extract method
|
// todo refactor: extract method
|
||||||
// the handling of the null data should be packed in the extracted method
|
// the handling of the null data should be packed in the extracted method
|
||||||
|
|
||||||
|
@ -586,7 +586,14 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
|
||||||
|
|
||||||
// this is to handle the tbname
|
// this is to handle the tbname
|
||||||
if (fmIsScanPseudoColumnFunc(functionId)) {
|
if (fmIsScanPseudoColumnFunc(functionId)) {
|
||||||
|
int32_t fType = pExpr1->pExpr->_function.functionType;
|
||||||
|
if (fType == FUNCTION_TYPE_TBNAME) {
|
||||||
setTbNameColData(pBlock, pColInfoData, functionId, val.pName);
|
setTbNameColData(pBlock, pColInfoData, functionId, val.pName);
|
||||||
|
} else if (fType == FUNCTION_TYPE_VGID) {
|
||||||
|
setVgIdColData(pBlock, pColInfoData, functionId, pTask->id.vgId);
|
||||||
|
} else if (fType == FUNCTION_TYPE_VGVER) {
|
||||||
|
setVgVerColData(pBlock, pColInfoData, functionId, pBlock->info.version);
|
||||||
|
}
|
||||||
} else { // these are tags
|
} else { // these are tags
|
||||||
STagVal tagVal = {0};
|
STagVal tagVal = {0};
|
||||||
tagVal.cid = pExpr1->base.pParam[0].pCol->colId;
|
tagVal.cid = pExpr1->base.pParam[0].pCol->colId;
|
||||||
|
@ -655,6 +662,47 @@ void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData,
|
||||||
colDataDestroy(&infoData);
|
colDataDestroy(&infoData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setVgIdColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int32_t vgId) {
|
||||||
|
struct SScalarFuncExecFuncs fpSet = {0};
|
||||||
|
fmGetScalarFuncExecFuncs(functionId, &fpSet);
|
||||||
|
|
||||||
|
SColumnInfoData infoData = createColumnInfoData(pColInfoData->info.type, pColInfoData->info.bytes, 1);
|
||||||
|
|
||||||
|
colInfoDataEnsureCapacity(&infoData, 1, false);
|
||||||
|
colDataSetVal(&infoData, 0, (const char*)&vgId, false);
|
||||||
|
|
||||||
|
SScalarParam srcParam = {.numOfRows = pBlock->info.rows, .columnData = &infoData};
|
||||||
|
SScalarParam param = {.columnData = pColInfoData};
|
||||||
|
|
||||||
|
if (fpSet.process != NULL) {
|
||||||
|
fpSet.process(&srcParam, 1, ¶m);
|
||||||
|
} else {
|
||||||
|
qError("failed to get the corresponding callback function, functionId:%d", functionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataDestroy(&infoData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVgVerColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, int64_t vgVer) {
|
||||||
|
struct SScalarFuncExecFuncs fpSet = {0};
|
||||||
|
fmGetScalarFuncExecFuncs(functionId, &fpSet);
|
||||||
|
|
||||||
|
SColumnInfoData infoData = createColumnInfoData(pColInfoData->info.type, pColInfoData->info.bytes, 1);
|
||||||
|
|
||||||
|
colInfoDataEnsureCapacity(&infoData, 1, false);
|
||||||
|
colDataSetVal(&infoData, 0, (const char*)&vgVer, false);
|
||||||
|
|
||||||
|
SScalarParam srcParam = {.numOfRows = pBlock->info.rows, .columnData = &infoData};
|
||||||
|
SScalarParam param = {.columnData = pColInfoData};
|
||||||
|
|
||||||
|
if (fpSet.process != NULL) {
|
||||||
|
fpSet.process(&srcParam, 1, ¶m);
|
||||||
|
} else {
|
||||||
|
qError("failed to get the corresponding callback function, functionId:%d", functionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataDestroy(&infoData);
|
||||||
|
}
|
||||||
|
|
||||||
static void initNextGroupScan(STableScanInfo* pInfo, STableKeyInfo** pKeyInfo, int32_t* size) {
|
static void initNextGroupScan(STableScanInfo* pInfo, STableKeyInfo** pKeyInfo, int32_t* size) {
|
||||||
tableListGetGroupList(pInfo->base.pTableListInfo, pInfo->currentGroupId, pKeyInfo, size);
|
tableListGetGroupList(pInfo->base.pTableListInfo, pInfo->currentGroupId, pKeyInfo, size);
|
||||||
|
@ -663,6 +711,8 @@ static void initNextGroupScan(STableScanInfo* pInfo, STableKeyInfo** pKeyInfo, i
|
||||||
|
|
||||||
pInfo->tableEndIndex = (pInfo->tableStartIndex + (*size) - 1);
|
pInfo->tableEndIndex = (pInfo->tableStartIndex + (*size) - 1);
|
||||||
|
|
||||||
|
pInfo->pResBlock->info.blankFill = false;
|
||||||
|
|
||||||
if (!pInfo->needCountEmptyTable) {
|
if (!pInfo->needCountEmptyTable) {
|
||||||
pInfo->countState = TABLE_COUNT_STATE_END;
|
pInfo->countState = TABLE_COUNT_STATE_END;
|
||||||
} else {
|
} else {
|
||||||
|
@ -687,6 +737,7 @@ static SSDataBlock* getOneRowResultBlock(SExecTaskInfo* pTaskInfo, STableScanBas
|
||||||
pBlock->info.rows = 1;
|
pBlock->info.rows = 1;
|
||||||
pBlock->info.id.uid = tbInfo->uid;
|
pBlock->info.id.uid = tbInfo->uid;
|
||||||
pBlock->info.id.groupId = tbInfo->groupId;
|
pBlock->info.id.groupId = tbInfo->groupId;
|
||||||
|
pBlock->info.blankFill = true;
|
||||||
|
|
||||||
// only one row: set all col data to null & hasNull
|
// only one row: set all col data to null & hasNull
|
||||||
int32_t col_num = blockDataGetNumOfCols(pBlock);
|
int32_t col_num = blockDataGetNumOfCols(pBlock);
|
||||||
|
@ -696,7 +747,7 @@ static SSDataBlock* getOneRowResultBlock(SExecTaskInfo* pTaskInfo, STableScanBas
|
||||||
}
|
}
|
||||||
|
|
||||||
// set tag/tbname
|
// set tag/tbname
|
||||||
doSetTagColumnData(pBase, pBlock, pTaskInfo, pBlock->info.rows);
|
doSetTagColumnData(pBase, pBlock, pTaskInfo, 1);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,13 +1014,11 @@ static SSDataBlock* groupSeqTableScan(SOperatorInfo* pOperator) {
|
||||||
STableKeyInfo* pList = NULL;
|
STableKeyInfo* pList = NULL;
|
||||||
|
|
||||||
if (pInfo->currentGroupId == -1) {
|
if (pInfo->currentGroupId == -1) {
|
||||||
int32_t numOfTables = tableListGetSize(pInfo->base.pTableListInfo);
|
|
||||||
if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pInfo->base.pTableListInfo)) {
|
if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pInfo->base.pTableListInfo)) {
|
||||||
setOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initNextGroupScan(pInfo, &pList, &num);
|
initNextGroupScan(pInfo, &pList, &num);
|
||||||
ASSERT(pInfo->base.dataReader == NULL);
|
ASSERT(pInfo->base.dataReader == NULL);
|
||||||
|
|
||||||
|
@ -1172,10 +1221,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanDebug) {
|
|
||||||
pInfo->countOnly = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pInfo->filesetDelimited = pTableScanNode->filesetDelimited;
|
pInfo->filesetDelimited = pTableScanNode->filesetDelimited;
|
||||||
|
|
||||||
taosLRUCacheSetStrictCapacity(pInfo->base.metaCache.pTableMetaEntryCache, false);
|
taosLRUCacheSetStrictCapacity(pInfo->base.metaCache.pTableMetaEntryCache, false);
|
||||||
|
@ -1238,6 +1283,10 @@ static bool isSlidingWindow(SStreamScanInfo* pInfo) {
|
||||||
return isIntervalWindow(pInfo) && pInfo->interval.interval != pInfo->interval.sliding;
|
return isIntervalWindow(pInfo) && pInfo->interval.interval != pInfo->interval.sliding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isCountSlidingWindow(SStreamScanInfo* pInfo) {
|
||||||
|
return pInfo->windowSup.pStreamAggSup->windowCount != pInfo->windowSup.pStreamAggSup->windowSliding;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isCountWindow(SStreamScanInfo* pInfo) {
|
static bool isCountWindow(SStreamScanInfo* pInfo) {
|
||||||
return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT;
|
return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT;
|
||||||
}
|
}
|
||||||
|
@ -1352,7 +1401,7 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
|
||||||
TSKEY* calEndData = (TSKEY*)pCalEndTsCol->pData;
|
TSKEY* calEndData = (TSKEY*)pCalEndTsCol->pData;
|
||||||
|
|
||||||
setGroupId(pInfo, pBlock, GROUPID_COLUMN_INDEX, *pRowIndex);
|
setGroupId(pInfo, pBlock, GROUPID_COLUMN_INDEX, *pRowIndex);
|
||||||
if (isSlidingWindow(pInfo)) {
|
if (isSlidingWindow(pInfo) || isCountSlidingWindow(pInfo)) {
|
||||||
pInfo->updateWin.skey = calStartData[*pRowIndex];
|
pInfo->updateWin.skey = calStartData[*pRowIndex];
|
||||||
pInfo->updateWin.ekey = calEndData[*pRowIndex];
|
pInfo->updateWin.ekey = calEndData[*pRowIndex];
|
||||||
}
|
}
|
||||||
|
@ -1580,8 +1629,8 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB
|
||||||
|
|
||||||
colDataSetNULL(pDestUidCol, i);
|
colDataSetNULL(pDestUidCol, i);
|
||||||
colDataSetVal(pDestGpCol, i, (const char*)&groupId, false);
|
colDataSetVal(pDestGpCol, i, (const char*)&groupId, false);
|
||||||
colDataSetNULL(pDestCalStartTsCol, i);
|
colDataSetVal(pDestCalStartTsCol, i, (const char*)&range.win.skey, false);
|
||||||
colDataSetNULL(pDestCalEndTsCol, i);
|
colDataSetVal(pDestCalEndTsCol, i, (const char*)&range.win.ekey, false);
|
||||||
pDestBlock->info.rows++;
|
pDestBlock->info.rows++;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1743,6 +1792,11 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock,
|
||||||
|
|
||||||
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid,
|
||||||
uint64_t* pGp, void* pTbName) {
|
uint64_t* pGp, void* pTbName) {
|
||||||
|
appendAllColumnToStreamSpecialBlock(pBlock, pStartTs, pEndTs, pStartTs, pEndTs, pUid, pGp, pTbName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendAllColumnToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs,
|
||||||
|
TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName) {
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX);
|
SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
|
@ -1754,8 +1808,8 @@ void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKE
|
||||||
colDataSetVal(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false);
|
colDataSetVal(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false);
|
||||||
colDataSetVal(pUidCol, pBlock->info.rows, (const char*)pUid, false);
|
colDataSetVal(pUidCol, pBlock->info.rows, (const char*)pUid, false);
|
||||||
colDataSetVal(pGpCol, pBlock->info.rows, (const char*)pGp, false);
|
colDataSetVal(pGpCol, pBlock->info.rows, (const char*)pGp, false);
|
||||||
colDataSetVal(pCalStartCol, pBlock->info.rows, (const char*)pStartTs, false);
|
colDataSetVal(pCalStartCol, pBlock->info.rows, (const char*)pCalStartTs, false);
|
||||||
colDataSetVal(pCalEndCol, pBlock->info.rows, (const char*)pEndTs, false);
|
colDataSetVal(pCalEndCol, pBlock->info.rows, (const char*)pCalEndTs, false);
|
||||||
colDataSetVal(pTableCol, pBlock->info.rows, (const char*)pTbName, pTbName == NULL);
|
colDataSetVal(pTableCol, pBlock->info.rows, (const char*)pTbName, pTbName == NULL);
|
||||||
pBlock->info.rows++;
|
pBlock->info.rows++;
|
||||||
}
|
}
|
||||||
|
@ -1948,7 +2002,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
// currently only the tbname pseudo column
|
// currently only the tbname pseudo column
|
||||||
if (pInfo->numOfPseudoExpr > 0) {
|
if (pInfo->numOfPseudoExpr > 0) {
|
||||||
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
|
int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
|
||||||
pBlockInfo->rows, id, &pTableScanInfo->base.metaCache);
|
pBlockInfo->rows, pTaskInfo, &pTableScanInfo->base.metaCache);
|
||||||
// ignore the table not exists error, since this table may have been dropped during the scan procedure.
|
// ignore the table not exists error, since this table may have been dropped during the scan procedure.
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||||
blockDataFreeRes((SSDataBlock*)pBlock);
|
blockDataFreeRes((SSDataBlock*)pBlock);
|
||||||
|
@ -2189,7 +2243,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
pTSInfo->base.cond.endVersion = pStreamInfo->fillHistoryVer.maxVer;
|
pTSInfo->base.cond.endVersion = pStreamInfo->fillHistoryVer.maxVer;
|
||||||
|
|
||||||
pTSInfo->base.cond.twindows = pStreamInfo->fillHistoryWindow;
|
pTSInfo->base.cond.twindows = pStreamInfo->fillHistoryWindow;
|
||||||
qDebug("stream recover step1, verRange:%" PRId64 "-%" PRId64 " window:%"PRId64"-%"PRId64", %s", pTSInfo->base.cond.startVersion,
|
qDebug("stream scan step1, verRange:%" PRId64 "-%" PRId64 " window:%"PRId64"-%"PRId64", %s", pTSInfo->base.cond.startVersion,
|
||||||
pTSInfo->base.cond.endVersion, pTSInfo->base.cond.twindows.skey, pTSInfo->base.cond.twindows.ekey, id);
|
pTSInfo->base.cond.endVersion, pTSInfo->base.cond.twindows.skey, pTSInfo->base.cond.twindows.ekey, id);
|
||||||
pStreamInfo->recoverStep = STREAM_RECOVER_STEP__SCAN1;
|
pStreamInfo->recoverStep = STREAM_RECOVER_STEP__SCAN1;
|
||||||
pStreamInfo->recoverScanFinished = false;
|
pStreamInfo->recoverScanFinished = false;
|
||||||
|
|
|
@ -33,6 +33,17 @@ typedef struct SCountWindowInfo {
|
||||||
COUNT_TYPE* pWindowCount;
|
COUNT_TYPE* pWindowCount;
|
||||||
} SCountWindowInfo;
|
} SCountWindowInfo;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NONE_WINDOW = 0,
|
||||||
|
CREATE_NEW_WINDOW,
|
||||||
|
MOVE_NEXT_WINDOW,
|
||||||
|
} BuffOp;
|
||||||
|
typedef struct SBuffInfo {
|
||||||
|
bool rebuildWindow;
|
||||||
|
BuffOp winBuffOp;
|
||||||
|
SStreamStateCur* pCur;
|
||||||
|
} SBuffInfo;
|
||||||
|
|
||||||
void destroyStreamCountAggOperatorInfo(void* param) {
|
void destroyStreamCountAggOperatorInfo(void* param) {
|
||||||
SStreamCountAggOperatorInfo* pInfo = (SStreamCountAggOperatorInfo*)param;
|
SStreamCountAggOperatorInfo* pInfo = (SStreamCountAggOperatorInfo*)param;
|
||||||
cleanupBasicInfo(&pInfo->binfo);
|
cleanupBasicInfo(&pInfo->binfo);
|
||||||
|
@ -53,28 +64,54 @@ void destroyStreamCountAggOperatorInfo(void* param) {
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isSlidingCountWindow(SStreamAggSupporter* pAggSup) {
|
||||||
|
return pAggSup->windowCount != pAggSup->windowSliding;
|
||||||
|
}
|
||||||
|
|
||||||
void setCountOutputBuf(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, SCountWindowInfo* pCurWin,
|
void setCountOutputBuf(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, SCountWindowInfo* pCurWin,
|
||||||
bool* pRebuild) {
|
SBuffInfo* pBuffInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t size = pAggSup->resultRowSize;
|
int32_t size = pAggSup->resultRowSize;
|
||||||
pCurWin->winInfo.sessionWin.groupId = groupId;
|
pCurWin->winInfo.sessionWin.groupId = groupId;
|
||||||
pCurWin->winInfo.sessionWin.win.skey = ts;
|
pCurWin->winInfo.sessionWin.win.skey = ts;
|
||||||
pCurWin->winInfo.sessionWin.win.ekey = ts;
|
pCurWin->winInfo.sessionWin.win.ekey = ts;
|
||||||
|
|
||||||
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
|
if (pBuffInfo->winBuffOp == CREATE_NEW_WINDOW) {
|
||||||
|
pAggSup->stateStore.streamStateCountWinAdd(pAggSup->pState, &pCurWin->winInfo.sessionWin,
|
||||||
|
(void**)&pCurWin->winInfo.pStatePos, &size);
|
||||||
|
code = TSDB_CODE_FAILED;
|
||||||
|
} else if (pBuffInfo->winBuffOp == MOVE_NEXT_WINDOW) {
|
||||||
|
ASSERT(pBuffInfo->pCur);
|
||||||
|
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pBuffInfo->pCur);
|
||||||
|
code = pAggSup->stateStore.streamStateSessionGetKVByCur(pBuffInfo->pCur, &pCurWin->winInfo.sessionWin,
|
||||||
|
(void**)&pCurWin->winInfo.pStatePos, &size);
|
||||||
|
if (code == TSDB_CODE_FAILED) {
|
||||||
|
pAggSup->stateStore.streamStateCountWinAdd(pAggSup->pState, &pCurWin->winInfo.sessionWin,
|
||||||
|
(void**)&pCurWin->winInfo.pStatePos, &size);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pBuffInfo->pCur = pAggSup->stateStore.streamStateCountSeekKeyPrev(pAggSup->pState, &pCurWin->winInfo.sessionWin, pAggSup->windowCount);
|
||||||
|
code = pAggSup->stateStore.streamStateSessionGetKVByCur(pBuffInfo->pCur, &pCurWin->winInfo.sessionWin,
|
||||||
|
(void**)&pCurWin->winInfo.pStatePos, &size);
|
||||||
|
if (code == TSDB_CODE_FAILED) {
|
||||||
|
pAggSup->stateStore.streamStateCountWinAdd(pAggSup->pState, &pCurWin->winInfo.sessionWin,
|
||||||
|
(void**)&pCurWin->winInfo.pStatePos, &size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
code = pAggSup->stateStore.streamStateCountWinAddIfNotExist(
|
code = pAggSup->stateStore.streamStateCountWinAddIfNotExist(
|
||||||
pAggSup->pState, &pCurWin->winInfo.sessionWin, pAggSup->windowCount, (void**)&pCurWin->winInfo.pStatePos, &size);
|
pAggSup->pState, &pCurWin->winInfo.sessionWin, pAggSup->windowCount, (void**)&pCurWin->winInfo.pStatePos, &size);
|
||||||
// if (code == TSDB_CODE_SUCCESS && inWinRange(&pAggSup->winRange, &pCurWin->winInfo.sessionWin.win)) {
|
}
|
||||||
// pCurWin->pWindowCount=
|
|
||||||
// (COUNT_TYPE*) ((char*)pCurWin->winInfo.pStatePos->pRowBuff + (pAggSup->resultRowSize - sizeof(COUNT_TYPE)));
|
|
||||||
// }
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
pCurWin->winInfo.isOutput = true;
|
pCurWin->winInfo.isOutput = true;
|
||||||
}
|
}
|
||||||
pCurWin->pWindowCount=
|
pCurWin->pWindowCount=
|
||||||
(COUNT_TYPE*) ((char*)pCurWin->winInfo.pStatePos->pRowBuff + (pAggSup->resultRowSize - sizeof(COUNT_TYPE)));
|
(COUNT_TYPE*) ((char*)pCurWin->winInfo.pStatePos->pRowBuff + (pAggSup->resultRowSize - sizeof(COUNT_TYPE)));
|
||||||
|
|
||||||
if (*pCurWin->pWindowCount + 1 > pAggSup->windowCount) {
|
if (*pCurWin->pWindowCount == pAggSup->windowCount) {
|
||||||
*pRebuild = true;
|
pBuffInfo->rebuildWindow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +157,12 @@ int32_t updateCountWindowInfo(SStreamAggSupporter* pAggSup, SCountWindowInfo* pW
|
||||||
|
|
||||||
void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange) {
|
void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange) {
|
||||||
*pDelRange = *pKey;
|
*pDelRange = *pKey;
|
||||||
SStreamStateCur* pCur = pAggSup->stateStore.streamStateSessionSeekKeyCurrentNext(pAggSup->pState, pKey);
|
SStreamStateCur* pCur = NULL;
|
||||||
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
|
pCur = pAggSup->stateStore.streamStateCountSeekKeyPrev(pAggSup->pState, pKey, pAggSup->windowCount);
|
||||||
|
} else {
|
||||||
|
pCur = pAggSup->stateStore.streamStateSessionSeekKeyCurrentNext(pAggSup->pState, pKey);
|
||||||
|
}
|
||||||
SSessionKey tmpKey = {0};
|
SSessionKey tmpKey = {0};
|
||||||
int32_t code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0);
|
int32_t code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -139,11 +181,22 @@ void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, ESt
|
||||||
pAggSup->stateStore.streamStateFreeCur(pCur);
|
pAggSup->stateStore.streamStateFreeCur(pCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getCurSessionWindowByKey(SStreamAggSupporter* pAggSup, const SSessionKey* pRange, SSessionKey* pKey) {
|
static void destroySBuffInfo(SStreamAggSupporter* pAggSup, SBuffInfo* pBuffInfo) {
|
||||||
int32_t code = pAggSup->stateStore.streamStateSessionGetKeyByRange(pAggSup->pState, pRange, pKey);
|
pAggSup->stateStore.streamStateFreeCur(pBuffInfo->pCur);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
}
|
||||||
SET_SESSION_WIN_KEY_INVALID(pKey);
|
|
||||||
|
bool inCountCalSlidingWindow(SStreamAggSupporter* pAggSup, STimeWindow* pWin, TSKEY sKey, TSKEY eKey) {
|
||||||
|
if (pAggSup->windowCount == pAggSup->windowSliding) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (sKey <= pWin->skey && pWin->ekey <= eKey) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool inCountSlidingWindow(SStreamAggSupporter* pAggSup, STimeWindow* pWin, SDataBlockInfo* pBlockInfo) {
|
||||||
|
return inCountCalSlidingWindow(pAggSup, pWin, pBlockInfo->calWin.skey, pBlockInfo->calWin.ekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, SSHashObj* pStUpdated,
|
static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, SSHashObj* pStUpdated,
|
||||||
|
@ -157,6 +210,7 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
int32_t rows = pSDataBlock->info.rows;
|
int32_t rows = pSDataBlock->info.rows;
|
||||||
int32_t winRows = 0;
|
int32_t winRows = 0;
|
||||||
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
||||||
|
SBuffInfo buffInfo = {.rebuildWindow = false, .winBuffOp = NONE_WINDOW, .pCur = NULL};
|
||||||
|
|
||||||
pInfo->dataVersion = TMAX(pInfo->dataVersion, pSDataBlock->info.version);
|
pInfo->dataVersion = TMAX(pInfo->dataVersion, pSDataBlock->info.version);
|
||||||
pAggSup->winRange = pTaskInfo->streamInfo.fillHistoryWindow;
|
pAggSup->winRange = pTaskInfo->streamInfo.fillHistoryWindow;
|
||||||
|
@ -167,6 +221,8 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
SColumnInfoData* pStartTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
SColumnInfoData* pStartTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
TSKEY* startTsCols = (int64_t*)pStartTsCol->pData;
|
TSKEY* startTsCols = (int64_t*)pStartTsCol->pData;
|
||||||
blockDataEnsureCapacity(pAggSup->pScanBlock, rows);
|
blockDataEnsureCapacity(pAggSup->pScanBlock, rows);
|
||||||
|
SStreamStateCur* pCur = NULL;
|
||||||
|
COUNT_TYPE slidingRows = 0;
|
||||||
|
|
||||||
for (int32_t i = 0; i < rows;) {
|
for (int32_t i = 0; i < rows;) {
|
||||||
if (pInfo->ignoreExpiredData &&
|
if (pInfo->ignoreExpiredData &&
|
||||||
|
@ -176,20 +232,28 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SCountWindowInfo curWin = {0};
|
SCountWindowInfo curWin = {0};
|
||||||
bool rebuild = false;
|
buffInfo.rebuildWindow = false;
|
||||||
setCountOutputBuf(pAggSup, startTsCols[i], groupId, &curWin, &rebuild);
|
setCountOutputBuf(pAggSup, startTsCols[i], groupId, &curWin, &buffInfo);
|
||||||
setSessionWinOutputInfo(pStUpdated, &curWin.winInfo);
|
if (!inCountSlidingWindow(pAggSup, &curWin.winInfo.sessionWin.win, &pSDataBlock->info)) {
|
||||||
if (!rebuild) {
|
buffInfo.winBuffOp = MOVE_NEXT_WINDOW;
|
||||||
winRows = updateCountWindowInfo(pAggSup, &curWin, startTsCols, i, rows, pAggSup->windowCount, pStDeleted, &rebuild);
|
continue;
|
||||||
}
|
}
|
||||||
if (rebuild) {
|
setSessionWinOutputInfo(pStUpdated, &curWin.winInfo);
|
||||||
|
slidingRows = *curWin.pWindowCount;
|
||||||
|
if (!buffInfo.rebuildWindow) {
|
||||||
|
winRows = updateCountWindowInfo(pAggSup, &curWin, startTsCols, i, rows, pAggSup->windowCount, pStDeleted, &buffInfo.rebuildWindow);
|
||||||
|
}
|
||||||
|
if (buffInfo.rebuildWindow) {
|
||||||
SSessionKey range = {0};
|
SSessionKey range = {0};
|
||||||
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
|
curWin.winInfo.sessionWin.win.skey = startTsCols[i];
|
||||||
|
curWin.winInfo.sessionWin.win.ekey = startTsCols[i];
|
||||||
|
}
|
||||||
getCountWinRange(pAggSup, &curWin.winInfo.sessionWin, STREAM_DELETE_DATA, &range);
|
getCountWinRange(pAggSup, &curWin.winInfo.sessionWin, STREAM_DELETE_DATA, &range);
|
||||||
range.win.skey = TMIN(startTsCols[i], range.win.skey);
|
range.win.skey = TMIN(startTsCols[i], range.win.skey);
|
||||||
range.win.ekey = TMAX(startTsCols[rows-1], range.win.ekey);
|
range.win.ekey = TMAX(startTsCols[rows-1], range.win.ekey);
|
||||||
uint64_t uid = 0;
|
uint64_t uid = 0;
|
||||||
appendOneRowToStreamSpecialBlock(pAggSup->pScanBlock, &range.win.skey, &range.win.ekey, &uid, &range.groupId,
|
appendOneRowToStreamSpecialBlock(pAggSup->pScanBlock, &range.win.skey, &range.win.ekey, &uid, &range.groupId, NULL);
|
||||||
NULL);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
||||||
|
@ -214,8 +278,22 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
|
if (slidingRows <= pAggSup->windowSliding) {
|
||||||
|
if (slidingRows + winRows > pAggSup->windowSliding) {
|
||||||
|
buffInfo.winBuffOp = CREATE_NEW_WINDOW;
|
||||||
|
winRows = pAggSup->windowSliding - slidingRows;
|
||||||
|
ASSERT(i >= 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buffInfo.winBuffOp = MOVE_NEXT_WINDOW;
|
||||||
|
winRows = 0;
|
||||||
|
}
|
||||||
|
slidingRows = (slidingRows + winRows) % pAggSup->windowSliding;
|
||||||
|
}
|
||||||
i += winRows;
|
i += winRows;
|
||||||
}
|
}
|
||||||
|
destroySBuffInfo(pAggSup, &buffInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* buildCountResult(SOperatorInfo* pOperator) {
|
static SSDataBlock* buildCountResult(SOperatorInfo* pOperator) {
|
||||||
|
@ -328,6 +406,10 @@ void doResetCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock) {
|
||||||
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
|
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
|
||||||
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
TSKEY* endDatas = (TSKEY*)pEndTsCol->pData;
|
TSKEY* endDatas = (TSKEY*)pEndTsCol->pData;
|
||||||
|
SColumnInfoData* pCalStartTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
|
TSKEY* calStartDatas = (TSKEY*)pStartTsCol->pData;
|
||||||
|
SColumnInfoData* pCalEndTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
|
TSKEY* calEndDatas = (TSKEY*)pEndTsCol->pData;
|
||||||
SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
uint64_t* gpDatas = (uint64_t*)pGroupCol->pData;
|
uint64_t* gpDatas = (uint64_t*)pGroupCol->pData;
|
||||||
|
|
||||||
|
@ -335,7 +417,12 @@ void doResetCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock) {
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
||||||
SSessionKey key = {.groupId = gpDatas[i], .win.skey = startDatas[i], .win.ekey = endDatas[i]};
|
SSessionKey key = {.groupId = gpDatas[i], .win.skey = startDatas[i], .win.ekey = endDatas[i]};
|
||||||
SStreamStateCur* pCur = pAggSup->stateStore.streamStateSessionSeekKeyCurrentNext(pAggSup->pState, &key);
|
SStreamStateCur* pCur = NULL;
|
||||||
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
|
pCur = pAggSup->stateStore.streamStateCountSeekKeyPrev(pAggSup->pState, &key, pAggSup->windowCount);
|
||||||
|
} else {
|
||||||
|
pCur = pAggSup->stateStore.streamStateSessionSeekKeyCurrentNext(pAggSup->pState, &key);
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
SSessionKey tmpKey = {0};
|
SSessionKey tmpKey = {0};
|
||||||
int32_t code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, (void **)&pPos, &size);
|
int32_t code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, (void **)&pPos, &size);
|
||||||
|
@ -343,12 +430,56 @@ void doResetCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock) {
|
||||||
pAggSup->stateStore.streamStateFreeCur(pCur);
|
pAggSup->stateStore.streamStateFreeCur(pCur);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!inCountCalSlidingWindow(pAggSup, &tmpKey.win, calStartDatas[i], calEndDatas[i])) {
|
||||||
|
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pAggSup->stateStore.streamStateSessionReset(pAggSup->pState, pPos->pRowBuff);
|
pAggSup->stateStore.streamStateSessionReset(pAggSup->pState, pPos->pRowBuff);
|
||||||
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur);
|
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doDeleteCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result) {
|
||||||
|
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
|
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
|
||||||
|
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
|
TSKEY* endDatas = (TSKEY*)pEndTsCol->pData;
|
||||||
|
SColumnInfoData* pCalStartTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
|
TSKEY* calStartDatas = (TSKEY*)pStartTsCol->pData;
|
||||||
|
SColumnInfoData* pCalEndTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
|
TSKEY* calEndDatas = (TSKEY*)pEndTsCol->pData;
|
||||||
|
SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
uint64_t* gpDatas = (uint64_t*)pGroupCol->pData;
|
||||||
|
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
||||||
|
SSessionKey key = {.win.skey = startDatas[i], .win.ekey = endDatas[i], .groupId = gpDatas[i]};
|
||||||
|
while (1) {
|
||||||
|
SSessionKey curWin = {0};
|
||||||
|
int32_t code = pAggSup->stateStore.streamStateCountGetKeyByRange(pAggSup->pState, &key, &curWin);
|
||||||
|
if (code == TSDB_CODE_FAILED) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
doDeleteSessionWindow(pAggSup, &curWin);
|
||||||
|
if (result) {
|
||||||
|
saveDeleteInfo(result, curWin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void deleteCountWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate,
|
||||||
|
SSHashObj* pMapDelete) {
|
||||||
|
SArray* pWins = taosArrayInit(16, sizeof(SSessionKey));
|
||||||
|
if (isSlidingCountWindow(pAggSup)) {
|
||||||
|
doDeleteCountWindows(pAggSup, pBlock, pWins);
|
||||||
|
} else {
|
||||||
|
doDeleteTimeWindows(pAggSup, pBlock, pWins);
|
||||||
|
}
|
||||||
|
removeSessionResults(pAggSup, pMapUpdate, pWins);
|
||||||
|
copyDeleteWindowInfo(pWins, pMapDelete);
|
||||||
|
taosArrayDestroy(pWins);
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamCountAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamCountAgg(SOperatorInfo* pOperator) {
|
||||||
SExprSupp* pSup = &pOperator->exprSupp;
|
SExprSupp* pSup = &pOperator->exprSupp;
|
||||||
SStreamCountAggOperatorInfo* pInfo = pOperator->info;
|
SStreamCountAggOperatorInfo* pInfo = pOperator->info;
|
||||||
|
@ -395,7 +526,7 @@ static SSDataBlock* doStreamCountAgg(SOperatorInfo* pOperator) {
|
||||||
printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo));
|
printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
|
if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
|
||||||
deleteSessionWinState(&pInfo->streamAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted);
|
deleteCountWinState(&pInfo->streamAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_CLEAR) {
|
} else if (pBlock->info.type == STREAM_CLEAR) {
|
||||||
doResetCountWindows(&pInfo->streamAggSup, pBlock);
|
doResetCountWindows(&pInfo->streamAggSup, pBlock);
|
||||||
|
|
|
@ -2291,7 +2291,7 @@ int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
|
void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
|
||||||
int32_t size = taosArrayGetSize(pResWins);
|
int32_t size = taosArrayGetSize(pResWins);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
SSessionKey* pWinKey = taosArrayGet(pResWins, i);
|
SSessionKey* pWinKey = taosArrayGet(pResWins, i);
|
||||||
|
|
|
@ -1334,7 +1334,6 @@ static bool tsortOpenForBufMergeSort(SSortHandle* pHandle) {
|
||||||
|
|
||||||
int32_t tsortClose(SSortHandle* pHandle) {
|
int32_t tsortClose(SSortHandle* pHandle) {
|
||||||
atomic_val_compare_exchange_8(&pHandle->closed, 0, 1);
|
atomic_val_compare_exchange_8(&pHandle->closed, 0, 1);
|
||||||
taosMsleep(10);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,18 +707,20 @@ static int32_t translateTbnameColumn(SFunctionNode* pFunc, char* pErrBuf, int32_
|
||||||
|
|
||||||
static int32_t translateTbUidColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateTbUidColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// pseudo column do not need to check parameters
|
// pseudo column do not need to check parameters
|
||||||
pFunc->node.resType =
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateVgIdColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateVgIdColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// pseudo column do not need to check parameters
|
// pseudo column do not need to check parameters
|
||||||
pFunc->node.resType =
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes, .type = TSDB_DATA_TYPE_INT};
|
||||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes, .type = TSDB_DATA_TYPE_INT};
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateVgVerColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateTopBot(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateTopBot(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||||
|
@ -3453,7 +3455,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.translateFunc = translateTbnameColumn,
|
.translateFunc = translateTbnameColumn,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = qTbnameFunction,
|
.sprocessFunc = qPseudoTagFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3740,11 +3742,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.translateFunc = translateTbUidColumn,
|
.translateFunc = translateTbUidColumn,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
#ifdef BUILD_NO_CALL
|
.sprocessFunc = qPseudoTagFunction,
|
||||||
.sprocessFunc = qTbUidFunction,
|
|
||||||
#else
|
|
||||||
.sprocessFunc = NULL,
|
|
||||||
#endif
|
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3754,11 +3752,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.translateFunc = translateVgIdColumn,
|
.translateFunc = translateVgIdColumn,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
#ifdef BUILD_NO_CALL
|
.sprocessFunc = qPseudoTagFunction,
|
||||||
.sprocessFunc = qVgIdFunction,
|
|
||||||
#else
|
|
||||||
.sprocessFunc = NULL,
|
|
||||||
#endif
|
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3781,6 +3775,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.sprocessFunc = toCharFunction,
|
.sprocessFunc = toCharFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "_vgver",
|
||||||
|
.type = FUNCTION_TYPE_VGVER,
|
||||||
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||||
|
.translateFunc = translateVgVerColumn,
|
||||||
|
.getEnvFunc = NULL,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = qPseudoTagFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -499,6 +499,9 @@ static int64_t getNumOfElems(SqlFunctionCtx* pCtx) {
|
||||||
*/
|
*/
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
if(1 == pInput->numOfRows && pInput->blankFill) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows) {
|
if (pInput->colDataSMAIsSet && pInput->totalRows == pInput->numOfRows) {
|
||||||
numOfElem = pInput->numOfRows - pInput->pColumnDataAgg[0]->numOfNull;
|
numOfElem = pInput->numOfRows - pInput->pColumnDataAgg[0]->numOfNull;
|
||||||
} else {
|
} else {
|
||||||
|
@ -6022,7 +6025,7 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
||||||
goto _group_key_over;
|
goto _group_key_over;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colDataIsNull_s(pInputCol, startIndex)) {
|
if (pInputCol->pData == NULL || colDataIsNull_s(pInputCol, startIndex)) {
|
||||||
pInfo->isNull = true;
|
pInfo->isNull = true;
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
goto _group_key_over;
|
goto _group_key_over;
|
||||||
|
|
|
@ -195,6 +195,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "GrantStmt";
|
return "GrantStmt";
|
||||||
case QUERY_NODE_REVOKE_STMT:
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
return "RevokeStmt";
|
return "RevokeStmt";
|
||||||
|
case QUERY_NODE_ALTER_CLUSTER_STMT:
|
||||||
|
return "AlterClusterStmt";
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
return "ShowDnodesStmt";
|
return "ShowDnodesStmt";
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
|
@ -265,6 +267,12 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "ShowCompactsStmt";
|
return "ShowCompactsStmt";
|
||||||
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
||||||
return "ShowCompactDetailsStmt";
|
return "ShowCompactDetailsStmt";
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
return "ShowGrantsFullStmt";
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
return "ShowGrantsLogsStmt";
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
|
return "ShowClusterMachinesStmt";
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
return "DeleteStmt";
|
return "DeleteStmt";
|
||||||
case QUERY_NODE_INSERT_STMT:
|
case QUERY_NODE_INSERT_STMT:
|
||||||
|
@ -6228,6 +6236,31 @@ static int32_t jsonToDropConsumerGroupStmt(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkAlterClusterStmtConfig = "Config";
|
||||||
|
static const char* jkAlterClusterStmtValue = "Value";
|
||||||
|
|
||||||
|
static int32_t alterClusterStmtToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SAlterClusterStmt* pNode = (const SAlterClusterStmt*)pObj;
|
||||||
|
|
||||||
|
int32_t code = tjsonAddStringToObject(pJson, jkAlterClusterStmtConfig, pNode->config);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddStringToObject(pJson, jkAlterClusterStmtValue, pNode->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToAlterClusterStmt(const SJson* pJson, void* pObj) {
|
||||||
|
SAlterClusterStmt* pNode = (SAlterClusterStmt*)pObj;
|
||||||
|
|
||||||
|
int32_t code = tjsonGetStringValue(pJson, jkAlterClusterStmtConfig, pNode->config);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetStringValue(pJson, jkAlterClusterStmtValue, pNode->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkAlterLocalStmtConfig = "Config";
|
static const char* jkAlterLocalStmtConfig = "Config";
|
||||||
static const char* jkAlterLocalStmtValue = "Value";
|
static const char* jkAlterLocalStmtValue = "Value";
|
||||||
|
|
||||||
|
@ -6625,6 +6658,18 @@ static int32_t showVariablesStmtToJson(const void* pObj, SJson* pJson) { return
|
||||||
|
|
||||||
static int32_t jsonToShowVariablesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
static int32_t jsonToShowVariablesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
|
static int32_t showGrantsFullStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||||
|
|
||||||
|
static int32_t jsonToShowGrantsFullStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
|
static int32_t showGrantsLogsStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||||
|
|
||||||
|
static int32_t showClusterMachinesStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||||
|
|
||||||
|
static int32_t jsonToShowGrantsLogsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
|
static int32_t jsonToShowClusterMachinesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
|
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
|
||||||
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
|
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
|
||||||
|
|
||||||
|
@ -7082,6 +7127,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return grantStmtToJson(pObj, pJson);
|
return grantStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_REVOKE_STMT:
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
return revokeStmtToJson(pObj, pJson);
|
return revokeStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_ALTER_CLUSTER_STMT:
|
||||||
|
return alterClusterStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
return showDnodesStmtToJson(pObj, pJson);
|
return showDnodesStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
|
@ -7112,6 +7159,12 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return showConsumersStmtToJson(pObj, pJson);
|
return showConsumersStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
return showVariablesStmtToJson(pObj, pJson);
|
return showVariablesStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
return showGrantsFullStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
return showGrantsLogsStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
|
return showClusterMachinesStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return showDnodeVariablesStmtToJson(pObj, pJson);
|
return showDnodeVariablesStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
@ -7410,6 +7463,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToGrantStmt(pJson, pObj);
|
return jsonToGrantStmt(pJson, pObj);
|
||||||
case QUERY_NODE_REVOKE_STMT:
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
return jsonToRevokeStmt(pJson, pObj);
|
return jsonToRevokeStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_ALTER_CLUSTER_STMT:
|
||||||
|
return jsonToAlterClusterStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
return jsonToShowDnodesStmt(pJson, pObj);
|
return jsonToShowDnodesStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
|
@ -7440,6 +7495,12 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToShowConsumersStmt(pJson, pObj);
|
return jsonToShowConsumersStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||||
return jsonToShowVariablesStmt(pJson, pObj);
|
return jsonToShowVariablesStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
return jsonToShowGrantsFullStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
return jsonToShowGrantsLogsStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
|
return jsonToShowClusterMachinesStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return jsonToShowDnodeVariablesStmt(pJson, pObj);
|
return jsonToShowDnodeVariablesStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef struct SNodeMemChunk {
|
||||||
struct SNodeMemChunk* pNext;
|
struct SNodeMemChunk* pNext;
|
||||||
} SNodeMemChunk;
|
} SNodeMemChunk;
|
||||||
|
|
||||||
typedef struct SNodeAllocator {
|
struct SNodeAllocator {
|
||||||
int64_t self;
|
int64_t self;
|
||||||
int64_t queryId;
|
int64_t queryId;
|
||||||
int32_t chunkSize;
|
int32_t chunkSize;
|
||||||
|
@ -39,7 +39,7 @@ typedef struct SNodeAllocator {
|
||||||
SNodeMemChunk* pCurrChunk;
|
SNodeMemChunk* pCurrChunk;
|
||||||
SNodeMemChunk* pChunks;
|
SNodeMemChunk* pChunks;
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
} SNodeAllocator;
|
};
|
||||||
|
|
||||||
static threadlocal SNodeAllocator* g_pNodeAllocator;
|
static threadlocal SNodeAllocator* g_pNodeAllocator;
|
||||||
static int32_t g_allocatorReqRefPool = -1;
|
static int32_t g_allocatorReqRefPool = -1;
|
||||||
|
@ -411,6 +411,8 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SGrantStmt));
|
return makeNode(type, sizeof(SGrantStmt));
|
||||||
case QUERY_NODE_REVOKE_STMT:
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
return makeNode(type, sizeof(SRevokeStmt));
|
return makeNode(type, sizeof(SRevokeStmt));
|
||||||
|
case QUERY_NODE_ALTER_CLUSTER_STMT:
|
||||||
|
return makeNode(type, sizeof(SAlterClusterStmt));
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||||
|
@ -441,6 +443,9 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||||
case QUERY_NODE_SHOW_VIEWS_STMT:
|
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
return makeNode(type, sizeof(SShowTableTagsStmt));
|
return makeNode(type, sizeof(SShowTableTagsStmt));
|
||||||
|
@ -1057,6 +1062,8 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_REVOKE_STMT:
|
case QUERY_NODE_REVOKE_STMT:
|
||||||
nodesDestroyNode(((SRevokeStmt*)pNode)->pTagCond);
|
nodesDestroyNode(((SRevokeStmt*)pNode)->pTagCond);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_ALTER_CLUSTER_STMT: // no pointer field
|
||||||
|
break;
|
||||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||||
|
@ -1086,7 +1093,10 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||||
case QUERY_NODE_SHOW_VIEWS_STMT: {
|
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: {
|
||||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||||
nodesDestroyNode(pStmt->pDbName);
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
nodesDestroyNode(pStmt->pTbName);
|
nodesDestroyNode(pStmt->pTbName);
|
||||||
|
|
|
@ -226,6 +226,7 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists,
|
||||||
int8_t withMeta, SNode* pWhere);
|
int8_t withMeta, SNode* pWhere);
|
||||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName);
|
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName);
|
||||||
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pCGroupId, SToken* pTopicName);
|
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pCGroupId, SToken* pTopicName);
|
||||||
|
SNode* createAlterClusterStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
||||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
||||||
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
||||||
SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal);
|
SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal);
|
||||||
|
|
|
@ -35,8 +35,8 @@ int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache*
|
||||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache);
|
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache);
|
||||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||||
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow);
|
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock);
|
||||||
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow);
|
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock);
|
||||||
int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues);
|
int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues);
|
||||||
int32_t translateTable(STranslateContext* pCxt, SNode** pTable);
|
int32_t translateTable(STranslateContext* pCxt, SNode** pTable);
|
||||||
int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput);
|
int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput);
|
||||||
|
|
|
@ -172,6 +172,10 @@ force_opt(A) ::= FORCE.
|
||||||
%destructor unsafe_opt { }
|
%destructor unsafe_opt { }
|
||||||
unsafe_opt(A) ::= UNSAFE. { A = true; }
|
unsafe_opt(A) ::= UNSAFE. { A = true; }
|
||||||
|
|
||||||
|
/************************************************ alter cluster *********************************************************/
|
||||||
|
cmd ::= ALTER CLUSTER NK_STRING(A). { pCxt->pRootNode = createAlterClusterStmt(pCxt, &A, NULL); }
|
||||||
|
cmd ::= ALTER CLUSTER NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterClusterStmt(pCxt, &A, &B); }
|
||||||
|
|
||||||
/************************************************ alter local *********************************************************/
|
/************************************************ alter local *********************************************************/
|
||||||
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
|
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
|
||||||
cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); }
|
cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); }
|
||||||
|
@ -483,6 +487,9 @@ cmd ::= SHOW APPS.
|
||||||
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
|
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
|
||||||
cmd ::= SHOW LICENCES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
cmd ::= SHOW LICENCES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
||||||
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
||||||
|
cmd ::= SHOW GRANTS FULL. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); }
|
||||||
|
cmd ::= SHOW GRANTS LOGS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); }
|
||||||
|
cmd ::= SHOW CLUSTER MACHINES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); }
|
||||||
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
||||||
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
||||||
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
||||||
|
|
|
@ -2201,6 +2201,17 @@ SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToke
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createAlterClusterStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) {
|
||||||
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
SAlterClusterStmt* pStmt = (SAlterClusterStmt*)nodesMakeNode(QUERY_NODE_ALTER_CLUSTER_STMT);
|
||||||
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
|
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
||||||
|
if (NULL != pValue) {
|
||||||
|
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
||||||
|
}
|
||||||
|
return (SNode*)pStmt;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) {
|
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SAlterLocalStmt* pStmt = (SAlterLocalStmt*)nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT);
|
SAlterLocalStmt* pStmt = (SAlterLocalStmt*)nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT);
|
||||||
|
|
|
@ -619,6 +619,21 @@ static int32_t collectMetaKeyFromShowCompactDetails(SCollectMetaKeyCxt* pCxt, SS
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowGrantsFull(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_GRANTS_FULL,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowGrantsLogs(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_GRANTS_LOGS,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowClusterMachines(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MACHINES,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
||||||
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
@ -839,6 +854,12 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
||||||
return collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
return collectMetaKeyFromShowGrantsFull(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
return collectMetaKeyFromShowGrantsLogs(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
|
return collectMetaKeyFromShowClusterMachines(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
|
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
|
|
@ -349,6 +349,9 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
||||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||||
|
|
|
@ -440,14 +440,14 @@ static int32_t parseVarbinary(SToken* pToken, uint8_t **pData, uint32_t *nData,
|
||||||
return TSDB_CODE_PAR_INVALID_VARBINARY;
|
return TSDB_CODE_PAR_INVALID_VARBINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isHex(pToken->z, pToken->n)){
|
if(isHex(pToken->z + 1, pToken->n - 2)){
|
||||||
if(!isValidateHex(pToken->z, pToken->n)){
|
if(!isValidateHex(pToken->z + 1, pToken->n - 2)){
|
||||||
return TSDB_CODE_PAR_INVALID_VARBINARY;
|
return TSDB_CODE_PAR_INVALID_VARBINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* data = NULL;
|
void* data = NULL;
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
if(taosHex2Ascii(pToken->z, pToken->n, &data, &size) < 0){
|
if(taosHex2Ascii(pToken->z + 1, pToken->n - 2, &data, &size) < 0){
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,11 +458,13 @@ static int32_t parseVarbinary(SToken* pToken, uint8_t **pData, uint32_t *nData,
|
||||||
*pData = data;
|
*pData = data;
|
||||||
*nData = size;
|
*nData = size;
|
||||||
}else{
|
}else{
|
||||||
if (pToken->n + VARSTR_HEADER_SIZE > bytes) {
|
*pData = taosMemoryCalloc(1, pToken->n);
|
||||||
|
int32_t len = trimString(pToken->z, pToken->n, *pData, pToken->n);
|
||||||
|
*nData = len;
|
||||||
|
|
||||||
|
if (*nData + VARSTR_HEADER_SIZE > bytes) {
|
||||||
return TSDB_CODE_PAR_VALUE_TOO_LONG;
|
return TSDB_CODE_PAR_VALUE_TOO_LONG;
|
||||||
}
|
}
|
||||||
*pData = taosStrdup(pToken->z);
|
|
||||||
*nData = pToken->n;
|
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -753,7 +755,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf) {
|
static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) {
|
||||||
if ((pToken->type != TK_NOW && pToken->type != TK_TODAY && pToken->type != TK_NK_INTEGER &&
|
if ((pToken->type != TK_NOW && pToken->type != TK_TODAY && pToken->type != TK_NK_INTEGER &&
|
||||||
pToken->type != TK_NK_STRING && pToken->type != TK_NK_FLOAT && pToken->type != TK_NK_BOOL &&
|
pToken->type != TK_NK_STRING && pToken->type != TK_NK_FLOAT && pToken->type != TK_NK_BOOL &&
|
||||||
pToken->type != TK_NULL && pToken->type != TK_NK_HEX && pToken->type != TK_NK_OCT &&
|
pToken->type != TK_NULL && pToken->type != TK_NK_HEX && pToken->type != TK_NK_OCT &&
|
||||||
|
@ -763,7 +765,7 @@ static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove quotation marks
|
// Remove quotation marks
|
||||||
if (TK_NK_STRING == pToken->type) {
|
if (TK_NK_STRING == pToken->type && type != TSDB_DATA_TYPE_VARBINARY) {
|
||||||
if (pToken->n >= TSDB_MAX_BYTES_PER_ROW) {
|
if (pToken->n >= TSDB_MAX_BYTES_PER_ROW) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "too long string", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "too long string", pToken->z);
|
||||||
}
|
}
|
||||||
|
@ -935,7 +937,7 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
||||||
|
|
||||||
SSchema* pTagSchema = &pSchema[pCxt->tags.pColIndex[i]];
|
SSchema* pTagSchema = &pSchema[pCxt->tags.pColIndex[i]];
|
||||||
isJson = pTagSchema->type == TSDB_DATA_TYPE_JSON;
|
isJson = pTagSchema->type == TSDB_DATA_TYPE_JSON;
|
||||||
code = checkAndTrimValue(&token, pCxt->tmpTokenBuf, &pCxt->msg);
|
code = checkAndTrimValue(&token, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type);
|
||||||
if (TK_NK_VARIABLE == token.type) {
|
if (TK_NK_VARIABLE == token.type) {
|
||||||
code = buildSyntaxErrMsg(&pCxt->msg, "not expected tags values ", token.z);
|
code = buildSyntaxErrMsg(&pCxt->msg, "not expected tags values ", token.z);
|
||||||
}
|
}
|
||||||
|
@ -1631,7 +1633,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
|
||||||
|
|
||||||
static int32_t parseValueToken(SInsertParseContext* pCxt, const char** pSql, SToken* pToken, SSchema* pSchema,
|
static int32_t parseValueToken(SInsertParseContext* pCxt, const char** pSql, SToken* pToken, SSchema* pSchema,
|
||||||
int16_t timePrec, SColVal* pVal) {
|
int16_t timePrec, SColVal* pVal) {
|
||||||
int32_t code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg);
|
int32_t code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pSchema->type);
|
||||||
if (TSDB_CODE_SUCCESS == code && isNullValue(pSchema->type, pToken)) {
|
if (TSDB_CODE_SUCCESS == code && isNullValue(pSchema->type, pToken)) {
|
||||||
if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) {
|
if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "primary timestamp should not be null", pToken->z);
|
return buildSyntaxErrMsg(&pCxt->msg, "primary timestamp should not be null", pToken->z);
|
||||||
|
@ -1691,7 +1693,7 @@ typedef union SRowsDataContext{
|
||||||
|
|
||||||
static int32_t parseTbnameToken(SInsertParseContext* pCxt, SStbRowsDataContext* pStbRowsCxt, SToken* pToken, bool* pFoundCtbName) {
|
static int32_t parseTbnameToken(SInsertParseContext* pCxt, SStbRowsDataContext* pStbRowsCxt, SToken* pToken, bool* pFoundCtbName) {
|
||||||
*pFoundCtbName = false;
|
*pFoundCtbName = false;
|
||||||
int32_t code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg);
|
int32_t code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, TSDB_DATA_TYPE_BINARY);
|
||||||
if (TK_NK_VARIABLE == pToken->type) {
|
if (TK_NK_VARIABLE == pToken->type) {
|
||||||
code = buildInvalidOperationMsg(&pCxt->msg, "not expected tbname");
|
code = buildInvalidOperationMsg(&pCxt->msg, "not expected tbname");
|
||||||
}
|
}
|
||||||
|
@ -1731,7 +1733,7 @@ static int32_t processCtbTagsAfterCtbName(SInsertParseContext* pCxt, SVnodeModif
|
||||||
for (int32_t i = 0; code == TSDB_CODE_SUCCESS && i < numOfTagTokens; ++i) {
|
for (int32_t i = 0; code == TSDB_CODE_SUCCESS && i < numOfTagTokens; ++i) {
|
||||||
SToken* pTagToken = (SToken*)(tagTokens + i);
|
SToken* pTagToken = (SToken*)(tagTokens + i);
|
||||||
SSchema* pTagSchema = tagSchemas[i];
|
SSchema* pTagSchema = tagSchemas[i];
|
||||||
code = checkAndTrimValue(pTagToken, pCxt->tmpTokenBuf, &pCxt->msg);
|
code = checkAndTrimValue(pTagToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type);
|
||||||
if (TK_NK_VARIABLE == pTagToken->type) {
|
if (TK_NK_VARIABLE == pTagToken->type) {
|
||||||
code = buildInvalidOperationMsg(&pCxt->msg, "not expected tag");
|
code = buildInvalidOperationMsg(&pCxt->msg, "not expected tag");
|
||||||
}
|
}
|
||||||
|
@ -1790,7 +1792,7 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
|
||||||
tagSchemas[(*pNumOfTagTokens)] = (SSchema*)pTagSchema;
|
tagSchemas[(*pNumOfTagTokens)] = (SSchema*)pTagSchema;
|
||||||
++(*pNumOfTagTokens);
|
++(*pNumOfTagTokens);
|
||||||
} else {
|
} else {
|
||||||
code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg);
|
code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type);
|
||||||
if (TK_NK_VARIABLE == pToken->type) {
|
if (TK_NK_VARIABLE == pToken->type) {
|
||||||
code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value");
|
code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value");
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,9 @@ static SKeyword keywordTable[] = {
|
||||||
{"GEOMETRY", TK_GEOMETRY},
|
{"GEOMETRY", TK_GEOMETRY},
|
||||||
{"GRANT", TK_GRANT},
|
{"GRANT", TK_GRANT},
|
||||||
{"GRANTS", TK_GRANTS},
|
{"GRANTS", TK_GRANTS},
|
||||||
|
{"FULL", TK_FULL},
|
||||||
|
{"LOGS", TK_LOGS},
|
||||||
|
{"MACHINES", TK_MACHINES},
|
||||||
{"GROUP", TK_GROUP},
|
{"GROUP", TK_GROUP},
|
||||||
{"HAVING", TK_HAVING},
|
{"HAVING", TK_HAVING},
|
||||||
{"HOST", TK_HOST},
|
{"HOST", TK_HOST},
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parTranslater.h"
|
#include "parTranslater.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
@ -269,6 +270,24 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
||||||
.numOfShowCols = 1,
|
.numOfShowCols = 1,
|
||||||
.pShowCols = {"*"}
|
.pShowCols = {"*"}
|
||||||
},
|
},
|
||||||
|
{ .showType = QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||||
|
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||||
|
.pTableName = TSDB_INS_TABLE_GRANTS_FULL,
|
||||||
|
.numOfShowCols = 1,
|
||||||
|
.pShowCols = {"*"}
|
||||||
|
},
|
||||||
|
{ .showType = QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
|
||||||
|
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||||
|
.pTableName = TSDB_INS_TABLE_GRANTS_LOGS,
|
||||||
|
.numOfShowCols = 1,
|
||||||
|
.pShowCols = {"*"}
|
||||||
|
},
|
||||||
|
{ .showType = QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
||||||
|
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||||
|
.pTableName = TSDB_INS_TABLE_MACHINES,
|
||||||
|
.numOfShowCols = 1,
|
||||||
|
.pShowCols = {"*"}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -5600,6 +5619,11 @@ static int32_t fillCmdSql(STranslateContext* pCxt, int16_t msgType, void* pReq)
|
||||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMDropStreamReq, pReq);
|
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMDropStreamReq, pReq);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case TDMT_MND_CONFIG_CLUSTER: {
|
||||||
|
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMCfgClusterReq, pReq);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6819,6 +6843,16 @@ static int32_t translateRestoreDnode(STranslateContext* pCxt, SRestoreComponentN
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateAlterCluster(STranslateContext* pCxt, SAlterClusterStmt* pStmt) {
|
||||||
|
SMCfgClusterReq cfgReq = {0};
|
||||||
|
strcpy(cfgReq.config, pStmt->config);
|
||||||
|
strcpy(cfgReq.value, pStmt->value);
|
||||||
|
|
||||||
|
int32_t code = buildCmdMsg(pCxt, TDMT_MND_CONFIG_CLUSTER, (FSerializeFunc)tSerializeSMCfgClusterReq, &cfgReq);
|
||||||
|
tFreeSMCfgClusterReq(&cfgReq);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
|
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
|
||||||
int32_t* pVgId) {
|
int32_t* pVgId) {
|
||||||
SVgroupInfo vg = {0};
|
SVgroupInfo vg = {0};
|
||||||
|
@ -6968,7 +7002,7 @@ int32_t createIntervalFromCreateSmaIndexStmt(SCreateIndexStmt* pStmt, SInterval*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow) {
|
int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pQuery->pRoot;
|
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pQuery->pRoot;
|
||||||
int64_t lastTs = 0;
|
int64_t lastTs = 0;
|
||||||
|
@ -6978,11 +7012,13 @@ int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, vo
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createIntervalFromCreateSmaIndexStmt(pStmt, &interval);
|
code = createIntervalFromCreateSmaIndexStmt(pStmt, &interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (pResRow && pResRow[0]) {
|
if (pBlock != NULL && pBlock->info.rows >= 1) {
|
||||||
lastTs = *(int64_t*)pResRow[0];
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
lastTs = *(int64_t*)colDataGetData(pColInfo, 0);
|
||||||
} else if (interval.interval > 0) {
|
} else if (interval.interval > 0) {
|
||||||
lastTs = convertTimePrecision(taosGetTimestampMs(), TSDB_TIME_PRECISION_MILLI, interval.precision);
|
lastTs = taosGetTimestamp(interval.precision);
|
||||||
} else {
|
} else {
|
||||||
lastTs = taosGetTimestampMs();
|
lastTs = taosGetTimestampMs();
|
||||||
}
|
}
|
||||||
|
@ -7778,9 +7814,14 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
||||||
"Size of Count window must exceed 1.");
|
"Size of Count window must exceed 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCountWin->windowSliding <= 1) {
|
if (pCountWin->windowSliding <= 0) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
"Size of Count window must exceed 1.");
|
"Size of Count window must exceed 0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pCountWin->windowSliding > pCountWin->windowCount) {
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||||
|
"sliding value no larger than the count value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCountWin->windowCount > INT32_MAX) {
|
if (pCountWin->windowCount > INT32_MAX) {
|
||||||
|
@ -8163,18 +8204,63 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
|
||||||
nodesDestroyList(pParamterList);
|
nodesDestroyList(pParamterList);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = nodesListStrictAppend(pProjectionList, pFunc);
|
code = nodesListStrictAppend(pProjectionList, pFunc);
|
||||||
if (code) {
|
if (code) {
|
||||||
nodesDestroyList(pProjectionList);
|
nodesDestroyList(pProjectionList);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SFunctionNode* pFunc1 = createFunction("_vgid", NULL);
|
||||||
|
if (NULL == pFunc1) {
|
||||||
|
nodesDestroyList(pParamterList);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(pFunc1->node.aliasName, sizeof(pFunc1->node.aliasName), "%s.%p", pFunc1->functionName, pFunc1);
|
||||||
|
code = nodesListStrictAppend(pProjectionList, (SNode*) pFunc1);
|
||||||
|
if (code) {
|
||||||
|
nodesDestroyList(pProjectionList);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
SFunctionNode* pFunc2 = createFunction("_vgver", NULL);
|
||||||
|
if (NULL == pFunc2) {
|
||||||
|
nodesDestroyList(pParamterList);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(pFunc2->node.aliasName, sizeof(pFunc2->node.aliasName), "%s.%p", pFunc2->functionName, pFunc2);
|
||||||
|
code = nodesListStrictAppend(pProjectionList, (SNode*) pFunc2);
|
||||||
|
if (code) {
|
||||||
|
nodesDestroyList(pProjectionList);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
code = createSimpleSelectStmtFromProjList(pDb, pTable, pProjectionList, (SSelectStmt**)pQuery);
|
code = createSimpleSelectStmtFromProjList(pDb, pTable, pProjectionList, (SSelectStmt**)pQuery);
|
||||||
if (code) {
|
if (code) {
|
||||||
nodesDestroyList(pProjectionList);
|
nodesDestroyList(pProjectionList);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo add the group by statement
|
||||||
|
SSelectStmt** pSelect1 = (SSelectStmt**)pQuery;
|
||||||
|
(*pSelect1)->pGroupByList = nodesMakeList();
|
||||||
|
|
||||||
|
SGroupingSetNode* pNode1 = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
|
||||||
|
pNode1->groupingSetType = GP_TYPE_NORMAL;
|
||||||
|
pNode1->pParameterList = nodesMakeList();
|
||||||
|
nodesListAppend(pNode1->pParameterList, (SNode*)pFunc1);
|
||||||
|
|
||||||
|
nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode1);
|
||||||
|
|
||||||
|
SGroupingSetNode* pNode2 = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
|
||||||
|
pNode2->groupingSetType = GP_TYPE_NORMAL;
|
||||||
|
pNode2->pParameterList = nodesMakeList();
|
||||||
|
nodesListAppend(pNode2->pParameterList, (SNode*)pFunc2);
|
||||||
|
|
||||||
|
nodesListAppend((*pSelect1)->pGroupByList, (SNode*)pNode2);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8322,7 +8408,31 @@ static int32_t buildIntervalForCreateStream(SCreateStreamStmt* pStmt, SInterval*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void** pResRow) {
|
// ts, vgroup_id, vgroup_version
|
||||||
|
static int32_t createStreamReqVersionInfo(SSDataBlock* pBlock, SArray** pArray, int64_t* lastTs, SInterval* pInterval) {
|
||||||
|
*pArray = taosArrayInit(pBlock->info.rows, sizeof(SVgroupVer));
|
||||||
|
if (*pArray == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBlock->info.rows > 0) {
|
||||||
|
*lastTs = pBlock->info.window.ekey;
|
||||||
|
SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 1);
|
||||||
|
SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 2);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
||||||
|
SVgroupVer v = {.vgId = *(int32_t*)colDataGetData(pCol1, i), .ver = *(int64_t*)colDataGetData(pCol2, i)};
|
||||||
|
taosArrayPush(*pArray, &v);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int32_t precision = (pInterval->interval > 0)? pInterval->precision:TSDB_TIME_PRECISION_MILLI;
|
||||||
|
*lastTs = taosGetTimestamp(precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock) {
|
||||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pQuery->pRoot;
|
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pQuery->pRoot;
|
||||||
STranslateContext cxt = {0};
|
STranslateContext cxt = {0};
|
||||||
SInterval interval = {0};
|
SInterval interval = {0};
|
||||||
|
@ -8332,15 +8442,11 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = buildIntervalForCreateStream(pStmt, &interval);
|
code = buildIntervalForCreateStream(pStmt, &interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (pResRow && pResRow[0]) {
|
code = createStreamReqVersionInfo(pBlock, &pStmt->pReq->pVgroupVerList, &lastTs, &interval);
|
||||||
lastTs = *(int64_t*)pResRow[0];
|
|
||||||
} else if (interval.interval > 0) {
|
|
||||||
lastTs = convertTimePrecision(taosGetTimestampMs(), TSDB_TIME_PRECISION_MILLI, interval.precision);
|
|
||||||
} else {
|
|
||||||
lastTs = taosGetTimestampMs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (interval.interval > 0) {
|
if (interval.interval > 0) {
|
||||||
pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit, interval.precision);
|
pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit, interval.precision);
|
||||||
|
@ -8349,9 +8455,11 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void
|
||||||
}
|
}
|
||||||
code = buildCmdMsg(&cxt, TDMT_MND_CREATE_STREAM, (FSerializeFunc)tSerializeSCMCreateStreamReq, pStmt->pReq);
|
code = buildCmdMsg(&cxt, TDMT_MND_CREATE_STREAM, (FSerializeFunc)tSerializeSCMCreateStreamReq, pStmt->pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setQuery(&cxt, pQuery);
|
code = setQuery(&cxt, pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRefreshMeta(&cxt, pQuery);
|
setRefreshMeta(&cxt, pQuery);
|
||||||
destroyTranslateContext(&cxt);
|
destroyTranslateContext(&cxt);
|
||||||
|
|
||||||
|
@ -8880,6 +8988,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
case QUERY_NODE_COMPACT_DATABASE_STMT:
|
case QUERY_NODE_COMPACT_DATABASE_STMT:
|
||||||
code = translateCompact(pCxt, (SCompactDatabaseStmt*)pNode);
|
code = translateCompact(pCxt, (SCompactDatabaseStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_ALTER_CLUSTER_STMT:
|
||||||
|
code = translateAlterCluster(pCxt, (SAlterClusterStmt*)pNode);
|
||||||
|
break;
|
||||||
case QUERY_NODE_KILL_CONNECTION_STMT:
|
case QUERY_NODE_KILL_CONNECTION_STMT:
|
||||||
code = translateKillConnection(pCxt, (SKillStmt*)pNode);
|
code = translateKillConnection(pCxt, (SKillStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
@ -10726,6 +10837,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||||
case QUERY_NODE_SHOW_VIEWS_STMT:
|
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
code = rewriteShow(pCxt, pQuery);
|
code = rewriteShow(pCxt, pQuery);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||||
|
|
|
@ -233,14 +233,17 @@ int32_t qContinueParseSql(SParseContext* pCxt, struct SCatalogReq* pCatalogReq,
|
||||||
return parseInsertSql(pCxt, &pQuery, pCatalogReq, pMetaData);
|
return parseInsertSql(pCxt, &pQuery, pCatalogReq, pMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qContinueParsePostQuery(SParseContext* pCxt, SQuery* pQuery, void** pResRow) {
|
int32_t qContinueParsePostQuery(SParseContext* pCxt, SQuery* pQuery, SSDataBlock* pBlock) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
switch (nodeType(pQuery->pRoot)) {
|
switch (nodeType(pQuery->pRoot)) {
|
||||||
case QUERY_NODE_CREATE_STREAM_STMT:
|
case QUERY_NODE_CREATE_STREAM_STMT: {
|
||||||
code = translatePostCreateStream(pCxt, pQuery, pResRow);
|
code = translatePostCreateStream(pCxt, pQuery, pBlock);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
}
|
||||||
code = translatePostCreateSmaIndex(pCxt, pQuery, pResRow);
|
case QUERY_NODE_CREATE_INDEX_STMT: {
|
||||||
|
code = translatePostCreateSmaIndex(pCxt, pQuery, pBlock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1455,28 +1455,25 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
|
||||||
SLogicNode* pLeft = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0);
|
SLogicNode* pLeft = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0);
|
||||||
SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1);
|
SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1);
|
||||||
SScanLogicNode* pScan = NULL;
|
SScanLogicNode* pScan = NULL;
|
||||||
|
SLogicNode* pChild = NULL;
|
||||||
|
SNode** pChildPos = NULL;
|
||||||
|
EOrder targetOrder = 0;
|
||||||
|
SSHashObj* pTables = NULL;
|
||||||
|
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pLeft) && ((SScanLogicNode*)pLeft)->node.outputTsOrder != SCAN_ORDER_BOTH) {
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pLeft) && ((SScanLogicNode*)pLeft)->node.outputTsOrder != SCAN_ORDER_BOTH) {
|
||||||
pScan = (SScanLogicNode*)pLeft;
|
pScan = (SScanLogicNode*)pLeft;
|
||||||
|
pChild = pRight;
|
||||||
|
pChildPos = &pJoin->node.pChildren->pTail->pNode;
|
||||||
|
targetOrder = pScan->node.outputTsOrder;
|
||||||
} else if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pRight) && ((SScanLogicNode*)pRight)->node.outputTsOrder != SCAN_ORDER_BOTH) {
|
} else if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pRight) && ((SScanLogicNode*)pRight)->node.outputTsOrder != SCAN_ORDER_BOTH) {
|
||||||
pScan = (SScanLogicNode*)pRight;
|
pScan = (SScanLogicNode*)pRight;
|
||||||
}
|
pChild = pLeft;
|
||||||
|
pChildPos = &pJoin->node.pChildren->pHead->pNode;
|
||||||
if (NULL != pScan) {
|
targetOrder = pScan->node.outputTsOrder;
|
||||||
switch (pScan->node.outputTsOrder) {
|
} else {
|
||||||
case SCAN_ORDER_ASC:
|
pChild = pRight;
|
||||||
pScan->scanSeq[0] = 0;
|
pChildPos = &pJoin->node.pChildren->pTail->pNode;
|
||||||
pScan->scanSeq[1] = 1;
|
targetOrder = pLeft->outputTsOrder;
|
||||||
pScan->node.outputTsOrder = ORDER_DESC;
|
|
||||||
goto _return;
|
|
||||||
case SCAN_ORDER_DESC:
|
|
||||||
pScan->scanSeq[0] = 1;
|
|
||||||
pScan->scanSeq[1] = 0;
|
|
||||||
pScan->node.outputTsOrder = ORDER_ASC;
|
|
||||||
goto _return;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_OPERATOR != nodeType(pJoin->pPrimKeyEqCond)) {
|
if (QUERY_NODE_OPERATOR != nodeType(pJoin->pPrimKeyEqCond)) {
|
||||||
|
@ -1490,16 +1487,15 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pOrderByNode = NULL;
|
SNode* pOrderByNode = NULL;
|
||||||
SSHashObj* pLeftTables = NULL;
|
|
||||||
collectTableAliasFromNodes(nodesListGetNode(pJoin->node.pChildren, 0), &pLeftTables);
|
|
||||||
|
|
||||||
if (NULL != tSimpleHashGet(pLeftTables, ((SColumnNode*)pOp->pLeft)->tableAlias, strlen(((SColumnNode*)pOp->pLeft)->tableAlias))) {
|
collectTableAliasFromNodes((SNode*)pChild, &pTables);
|
||||||
|
if (NULL != tSimpleHashGet(pTables, ((SColumnNode*)pOp->pLeft)->tableAlias, strlen(((SColumnNode*)pOp->pLeft)->tableAlias))) {
|
||||||
pOrderByNode = pOp->pLeft;
|
pOrderByNode = pOp->pLeft;
|
||||||
} else if (NULL != tSimpleHashGet(pLeftTables, ((SColumnNode*)pOp->pRight)->tableAlias, strlen(((SColumnNode*)pOp->pRight)->tableAlias))) {
|
} else if (NULL != tSimpleHashGet(pTables, ((SColumnNode*)pOp->pRight)->tableAlias, strlen(((SColumnNode*)pOp->pRight)->tableAlias))) {
|
||||||
pOrderByNode = pOp->pRight;
|
pOrderByNode = pOp->pRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
tSimpleHashCleanup(pLeftTables);
|
tSimpleHashCleanup(pTables);
|
||||||
|
|
||||||
if (NULL == pOrderByNode) {
|
if (NULL == pOrderByNode) {
|
||||||
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
return TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||||
|
@ -1510,7 +1506,13 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSort->node.outputTsOrder = (ORDER_ASC == pLeft->outputTsOrder) ? ORDER_DESC : ORDER_ASC;
|
pSort->node.outputTsOrder = targetOrder;
|
||||||
|
pSort->node.pTargets = nodesCloneList(pChild->pTargets);
|
||||||
|
if (NULL == pSort->node.pTargets) {
|
||||||
|
nodesDestroyNode((SNode *)pSort);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
pSort->groupSort = false;
|
pSort->groupSort = false;
|
||||||
SOrderByExprNode* pOrder = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
SOrderByExprNode* pOrder = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||||
if (NULL == pOrder) {
|
if (NULL == pOrder) {
|
||||||
|
@ -1519,7 +1521,7 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
|
||||||
}
|
}
|
||||||
|
|
||||||
nodesListMakeAppend(&pSort->pSortKeys, (SNode*)pOrder);
|
nodesListMakeAppend(&pSort->pSortKeys, (SNode*)pOrder);
|
||||||
pOrder->order = (ORDER_ASC == pLeft->outputTsOrder) ? ORDER_DESC : ORDER_ASC;
|
pOrder->order = targetOrder;
|
||||||
pOrder->pExpr = nodesCloneNode(pOrderByNode);
|
pOrder->pExpr = nodesCloneNode(pOrderByNode);
|
||||||
pOrder->nullOrder = (ORDER_ASC == pOrder->order) ? NULL_ORDER_FIRST : NULL_ORDER_LAST;
|
pOrder->nullOrder = (ORDER_ASC == pOrder->order) ? NULL_ORDER_FIRST : NULL_ORDER_LAST;
|
||||||
if (!pOrder->pExpr) {
|
if (!pOrder->pExpr) {
|
||||||
|
@ -1527,9 +1529,9 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pLeft->pParent = (SLogicNode*)pSort;
|
pChild->pParent = (SLogicNode*)pSort;
|
||||||
nodesListMakeAppend(&pSort->node.pChildren, (SNode*)pLeft);
|
nodesListMakeAppend(&pSort->node.pChildren, (SNode*)pChild);
|
||||||
pJoin->node.pChildren->pHead->pNode = (SNode*)pSort;
|
*pChildPos = (SNode*)pSort;
|
||||||
pSort->node.pParent = (SLogicNode*)pJoin;;
|
pSort->node.pParent = (SLogicNode*)pJoin;;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
|
@ -543,7 +543,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
||||||
|
|
||||||
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) {
|
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) {
|
||||||
QW_TASK_WLOG("last fetch still not processed, phase:%s", qwPhaseStr(phase));
|
QW_TASK_WLOG("last fetch still not processed, phase:%s", qwPhaseStr(phase));
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_DUPLICATTED_OPERATION);
|
QW_ERR_JRET(TSDB_CODE_QRY_DUPLICATED_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->rspCode) {
|
if (ctx->rspCode) {
|
||||||
|
@ -972,7 +972,7 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
|
|
||||||
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
||||||
QW_TASK_WLOG_E("task already dropping");
|
QW_TASK_WLOG_E("task already dropping");
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_DUPLICATTED_OPERATION);
|
QW_ERR_JRET(TSDB_CODE_QRY_DUPLICATED_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_QUERY_RUNNING(ctx)) {
|
if (QW_QUERY_RUNNING(ctx)) {
|
||||||
|
|
|
@ -1815,9 +1815,8 @@ int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t qPseudoTagFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
char* p = colDataGetVarData(pInput->columnData, 0);
|
char *p = colDataGetData(pInput->columnData, 0);
|
||||||
|
|
||||||
int32_t code = colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows, true);
|
int32_t code = colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows, true);
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -1826,31 +1825,6 @@ int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO
|
||||||
pOutput->numOfRows += pInput->numOfRows;
|
pOutput->numOfRows += pInput->numOfRows;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
#ifdef BUILD_NO_CALL
|
|
||||||
int32_t qTbUidFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
|
||||||
char* p = colDataGetNumData(pInput->columnData, 0);
|
|
||||||
|
|
||||||
int32_t code = colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows, true);
|
|
||||||
if (code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOutput->numOfRows += pInput->numOfRows;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t qVgIdFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
|
||||||
char* p = colDataGetNumData(pInput->columnData, 0);
|
|
||||||
|
|
||||||
int32_t code = colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows, true);
|
|
||||||
if (code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOutput->numOfRows += pInput->numOfRows;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Aggregation functions **/
|
/** Aggregation functions **/
|
||||||
int32_t countScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t countScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
|
|
@ -179,7 +179,8 @@ int32_t streamStateSessionDel_rocksdb(SStreamState* pState, const SSessionKey* k
|
||||||
SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pState, const SSessionKey* key);
|
||||||
SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pState, SSessionKey* key);
|
SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pState, SSessionKey* key);
|
||||||
SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, const SSessionKey* key);
|
SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, const SSessionKey* key);
|
||||||
SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState);
|
SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, const SSessionKey* key);
|
||||||
|
SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState, int64_t groupId);
|
||||||
int32_t streamStateSessionCurPrev_rocksdb(SStreamStateCur* pCur);
|
int32_t streamStateSessionCurPrev_rocksdb(SStreamStateCur* pCur);
|
||||||
|
|
||||||
int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||||
|
|
|
@ -123,7 +123,7 @@ int32_t streamTaskInitTokenBucket(STokenBucket* pBucket, int32_t numCap, int32_t
|
||||||
STaskId streamTaskGetTaskId(const SStreamTask* pTask);
|
STaskId streamTaskGetTaskId(const SStreamTask* pTask);
|
||||||
void streamTaskInitForLaunchHTask(SHistoryTaskInfo* pInfo);
|
void streamTaskInitForLaunchHTask(SHistoryTaskInfo* pInfo);
|
||||||
void streamTaskSetRetryInfoForLaunch(SHistoryTaskInfo* pInfo);
|
void streamTaskSetRetryInfoForLaunch(SHistoryTaskInfo* pInfo);
|
||||||
int32_t streamTaskFillHistoryFinished(SStreamTask* pTask);
|
int32_t streamTaskResetTimewindowFilter(SStreamTask* pTask);
|
||||||
|
|
||||||
void streamClearChkptReadyMsg(SStreamTask* pTask);
|
void streamClearChkptReadyMsg(SStreamTask* pTask);
|
||||||
int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInput, int32_t* numOfBlocks,
|
int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInput, int32_t* numOfBlocks,
|
||||||
|
|
|
@ -2883,13 +2883,13 @@ int32_t streamStateSessionDel_rocksdb(SStreamState* pState, const SSessionKey* k
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState) {
|
SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState, int64_t groupId) {
|
||||||
stDebug("streamStateSessionSeekToLast_rocksdb");
|
stDebug("streamStateSessionSeekToLast_rocksdb");
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SSessionKey maxSessionKey = {.groupId = UINT64_MAX, .win = {.skey = INT64_MAX, .ekey = INT64_MAX}};
|
SSessionKey maxSessionKey = {.groupId = groupId, .win = {.skey = INT64_MAX, .ekey = INT64_MAX}};
|
||||||
SStateSessionKey maxKey = {.key = maxSessionKey, .opNum = INT64_MAX};
|
SStateSessionKey maxKey = {.key = maxSessionKey, .opNum = pState->number};
|
||||||
|
|
||||||
STREAM_STATE_PUT_ROCKSDB(pState, "sess", &maxKey, "", 0);
|
STREAM_STATE_PUT_ROCKSDB(pState, "sess", &maxKey, "", 0);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -3048,6 +3048,46 @@ SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, con
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, const SSessionKey* key) {
|
||||||
|
stDebug("streamStateSessionSeekKeyPrev_rocksdb");
|
||||||
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
||||||
|
SStreamStateCur* pCur = createStreamStateCursor();
|
||||||
|
if (pCur == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pCur->db = wrapper->db;
|
||||||
|
pCur->iter = streamStateIterCreate(pState, "sess", (rocksdb_snapshot_t**)&pCur->snapshot,
|
||||||
|
(rocksdb_readoptions_t**)&pCur->readOpt);
|
||||||
|
pCur->number = pState->number;
|
||||||
|
|
||||||
|
SStateSessionKey sKey = {.key = *key, .opNum = pState->number};
|
||||||
|
|
||||||
|
char buf[128] = {0};
|
||||||
|
int len = stateSessionKeyEncode(&sKey, buf);
|
||||||
|
if (!streamStateIterSeekAndValid(pCur->iter, buf, len)) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
while (rocksdb_iter_valid(pCur->iter) && iterValueIsStale(pCur->iter)) rocksdb_iter_prev(pCur->iter);
|
||||||
|
if (!rocksdb_iter_valid(pCur->iter)) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t klen;
|
||||||
|
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||||
|
SStateSessionKey curKey = {0};
|
||||||
|
stateSessionKeyDecode(&curKey, (char*)iKey);
|
||||||
|
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur;
|
||||||
|
|
||||||
|
rocksdb_iter_prev(pCur->iter);
|
||||||
|
if (!rocksdb_iter_valid(pCur->iter)) {
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return pCur;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen) {
|
int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen) {
|
||||||
stDebug("streamStateSessionGetKVByCur_rocksdb");
|
stDebug("streamStateSessionGetKVByCur_rocksdb");
|
||||||
if (!pCur) {
|
if (!pCur) {
|
||||||
|
|
|
@ -116,7 +116,6 @@ static int32_t streamAlignCheckpoint(SStreamTask* pTask) {
|
||||||
return atomic_sub_fetch_32(&pTask->chkInfo.downstreamAlignNum, 1);
|
return atomic_sub_fetch_32(&pTask->chkInfo.downstreamAlignNum, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo handle down the transId of checkpoint to sink/agg tasks.
|
|
||||||
static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType) {
|
static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType) {
|
||||||
SStreamDataBlock* pChkpoint = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SSDataBlock));
|
SStreamDataBlock* pChkpoint = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SSDataBlock));
|
||||||
if (pChkpoint == NULL) {
|
if (pChkpoint == NULL) {
|
||||||
|
@ -133,6 +132,7 @@ static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpoint
|
||||||
|
|
||||||
pBlock->info.type = STREAM_CHECKPOINT;
|
pBlock->info.type = STREAM_CHECKPOINT;
|
||||||
pBlock->info.version = pTask->chkInfo.checkpointingId;
|
pBlock->info.version = pTask->chkInfo.checkpointingId;
|
||||||
|
pBlock->info.window.ekey = pBlock->info.window.skey = pTask->chkInfo.transId; // NOTE: set the transId
|
||||||
pBlock->info.rows = 1;
|
pBlock->info.rows = 1;
|
||||||
pBlock->info.childId = pTask->info.selfChildId;
|
pBlock->info.childId = pTask->info.selfChildId;
|
||||||
|
|
||||||
|
@ -185,17 +185,20 @@ static int32_t continueDispatchCheckpointBlock(SStreamDataBlock* pBlock, SStream
|
||||||
int32_t streamProcessCheckpointBlock(SStreamTask* pTask, SStreamDataBlock* pBlock) {
|
int32_t streamProcessCheckpointBlock(SStreamTask* pTask, SStreamDataBlock* pBlock) {
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pBlock->blocks, 0);
|
SSDataBlock* pDataBlock = taosArrayGet(pBlock->blocks, 0);
|
||||||
int64_t checkpointId = pDataBlock->info.version;
|
int64_t checkpointId = pDataBlock->info.version;
|
||||||
|
int32_t transId = pDataBlock->info.window.skey;
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t vgId = pTask->pMeta->vgId;
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
|
|
||||||
stDebug("s-task:%s vgId:%d start to handle the checkpoint block, checkpointId:%" PRId64 " ver:%" PRId64
|
stDebug("s-task:%s vgId:%d start to handle the checkpoint block, checkpointId:%" PRId64 " ver:%" PRId64
|
||||||
", current checkpointingId:%" PRId64,
|
", transId:%d current checkpointingId:%" PRId64,
|
||||||
id, vgId, pTask->chkInfo.checkpointId, pTask->chkInfo.checkpointVer, checkpointId);
|
id, vgId, pTask->chkInfo.checkpointId, pTask->chkInfo.checkpointVer, transId, checkpointId);
|
||||||
|
|
||||||
// set task status
|
// set task status
|
||||||
if (streamTaskGetStatus(pTask)->state != TASK_STATUS__CK) {
|
if (streamTaskGetStatus(pTask)->state != TASK_STATUS__CK) {
|
||||||
pTask->chkInfo.checkpointingId = checkpointId;
|
pTask->chkInfo.checkpointingId = checkpointId;
|
||||||
|
pTask->chkInfo.transId = transId;
|
||||||
|
|
||||||
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT);
|
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
stError("s-task:%s handle checkpoint-trigger block failed, code:%s", id, tstrerror(code));
|
stError("s-task:%s handle checkpoint-trigger block failed, code:%s", id, tstrerror(code));
|
||||||
|
|
|
@ -388,8 +388,7 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) {
|
||||||
pStreamTask->id.idStr, TASK_LEVEL__SOURCE, pTimeWindow->skey, pTimeWindow->ekey, INT64_MIN,
|
pStreamTask->id.idStr, TASK_LEVEL__SOURCE, pTimeWindow->skey, pTimeWindow->ekey, INT64_MIN,
|
||||||
pTimeWindow->ekey, p, pStreamTask->status.schedStatus);
|
pTimeWindow->ekey, p, pStreamTask->status.schedStatus);
|
||||||
|
|
||||||
pTimeWindow->skey = INT64_MIN;
|
streamTaskResetTimewindowFilter(pStreamTask);
|
||||||
qStreamInfoResetTimewindowFilter(pStreamTask->exec.pExecutor);
|
|
||||||
} else {
|
} else {
|
||||||
stDebug("s-task:%s no need to update/reset filter time window for non-source tasks", pStreamTask->id.idStr);
|
stDebug("s-task:%s no need to update/reset filter time window for non-source tasks", pStreamTask->id.idStr);
|
||||||
}
|
}
|
||||||
|
@ -400,7 +399,6 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) {
|
||||||
|
|
||||||
// 3. send msg to mnode to launch a checkpoint to keep the state for current stream
|
// 3. send msg to mnode to launch a checkpoint to keep the state for current stream
|
||||||
streamTaskSendCheckpointReq(pStreamTask);
|
streamTaskSendCheckpointReq(pStreamTask);
|
||||||
// streamTaskResume(pStreamTask);
|
|
||||||
|
|
||||||
// 4. assign the status to the value that will be kept in disk
|
// 4. assign the status to the value that will be kept in disk
|
||||||
pStreamTask->status.taskStatus = streamTaskGetStatus(pStreamTask)->state;
|
pStreamTask->status.taskStatus = streamTaskGetStatus(pStreamTask)->state;
|
||||||
|
@ -419,10 +417,6 @@ int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
|
||||||
ASSERT(pTask->status.appendTranstateBlock == 1);
|
ASSERT(pTask->status.appendTranstateBlock == 1);
|
||||||
|
|
||||||
int32_t level = pTask->info.taskLevel;
|
int32_t level = pTask->info.taskLevel;
|
||||||
if (level == TASK_LEVEL__SOURCE) {
|
|
||||||
streamTaskFillHistoryFinished(pTask);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (level == TASK_LEVEL__AGG || level == TASK_LEVEL__SOURCE) { // do transfer task operator states.
|
if (level == TASK_LEVEL__AGG || level == TASK_LEVEL__SOURCE) { // do transfer task operator states.
|
||||||
code = streamDoTransferStateToStreamTask(pTask);
|
code = streamDoTransferStateToStreamTask(pTask);
|
||||||
} else { // no state transfer for sink tasks, and drop fill-history task, followed by opening inputQ of sink task.
|
} else { // no state transfer for sink tasks, and drop fill-history task, followed by opening inputQ of sink task.
|
||||||
|
@ -777,6 +771,8 @@ int32_t streamResumeTask(SStreamTask* pTask) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/*int32_t code = */ doStreamExecTask(pTask);
|
/*int32_t code = */ doStreamExecTask(pTask);
|
||||||
|
|
||||||
|
// check if continue
|
||||||
taosThreadMutexLock(&pTask->lock);
|
taosThreadMutexLock(&pTask->lock);
|
||||||
|
|
||||||
int32_t numOfItems = streamQueueGetNumOfItems(pTask->inputq.queue);
|
int32_t numOfItems = streamQueueGetNumOfItems(pTask->inputq.queue);
|
||||||
|
|
|
@ -590,11 +590,6 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->info.fillHistory == 1) {
|
|
||||||
stDebug("s-task:0x%x initial nextProcessVer is set to 1 for fill-history task", pTask->id.taskId);
|
|
||||||
ver = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
||||||
tFreeStreamTask(pTask);
|
tFreeStreamTask(pTask);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1312,28 +1307,28 @@ void streamMetaResetStartInfo(STaskStartInfo* pStartInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamMetaRLock(SStreamMeta* pMeta) {
|
void streamMetaRLock(SStreamMeta* pMeta) {
|
||||||
stTrace("vgId:%d meta-rlock", pMeta->vgId);
|
// stTrace("vgId:%d meta-rlock", pMeta->vgId);
|
||||||
taosThreadRwlockRdlock(&pMeta->lock);
|
taosThreadRwlockRdlock(&pMeta->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamMetaRUnLock(SStreamMeta* pMeta) {
|
void streamMetaRUnLock(SStreamMeta* pMeta) {
|
||||||
stTrace("vgId:%d meta-runlock", pMeta->vgId);
|
// stTrace("vgId:%d meta-runlock", pMeta->vgId);
|
||||||
int32_t code = taosThreadRwlockUnlock(&pMeta->lock);
|
int32_t code = taosThreadRwlockUnlock(&pMeta->lock);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
stError("vgId:%d meta-runlock failed, code:%d", pMeta->vgId, code);
|
stError("vgId:%d meta-runlock failed, code:%d", pMeta->vgId, code);
|
||||||
} else {
|
} else {
|
||||||
stDebug("vgId:%d meta-runlock completed", pMeta->vgId);
|
// stTrace("vgId:%d meta-runlock completed", pMeta->vgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamMetaWLock(SStreamMeta* pMeta) {
|
void streamMetaWLock(SStreamMeta* pMeta) {
|
||||||
stTrace("vgId:%d meta-wlock", pMeta->vgId);
|
// stTrace("vgId:%d meta-wlock", pMeta->vgId);
|
||||||
taosThreadRwlockWrlock(&pMeta->lock);
|
taosThreadRwlockWrlock(&pMeta->lock);
|
||||||
stTrace("vgId:%d meta-wlock completed", pMeta->vgId);
|
// stTrace("vgId:%d meta-wlock completed", pMeta->vgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamMetaWUnLock(SStreamMeta* pMeta) {
|
void streamMetaWUnLock(SStreamMeta* pMeta) {
|
||||||
stTrace("vgId:%d meta-wunlock", pMeta->vgId);
|
// stTrace("vgId:%d meta-wunlock", pMeta->vgId);
|
||||||
taosThreadRwlockUnlock(&pMeta->lock);
|
taosThreadRwlockUnlock(&pMeta->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue