Merge branch '3.0' into feature/stream
This commit is contained in:
commit
6fb3072b43
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: Limits & Restrictions
|
title: Naming & Restrictions
|
||||||
---
|
---
|
||||||
|
|
||||||
## Naming Rules
|
## Naming Rules
|
||||||
|
@ -16,41 +16,21 @@ The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`.
|
||||||
|
|
||||||
## General Limits
|
## General Limits
|
||||||
|
|
||||||
- Maximum length of database name is 32 bytes.
|
- Maximum length of database name is 32 bytes, and it can't include "." or special characters.
|
||||||
- Maximum length of table name is 192 bytes, excluding the database name prefix and the separator.
|
- Maximum length of table name is 192 bytes, excluding the database name prefix and the separator.
|
||||||
- Maximum length of each data row is 48K bytes since version 2.1.7.0 , before which the limit was 16K bytes. Please note that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type.
|
- Maximum length of each data row is 48K bytes. Please note that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type.
|
||||||
- Maximum length of column name is 64.
|
- Maximum length of column name is 64.
|
||||||
- Maximum number of columns is 4096. There must be at least 2 columns, and the first column must be timestamp.
|
- Maximum number of columns is 4096. There must be at least 2 columns, and the first column must be timestamp.
|
||||||
- Maximum length of tag name is 64.
|
- Maximum length of tag name is 64.
|
||||||
- Maximum number of tags is 128. There must be at least 1 tag. The total length of tag values should not exceed 16K bytes.
|
- Maximum number of tags is 128. There must be at least 1 tag. The total length of tag values should not exceed 16K bytes.
|
||||||
- Maximum length of singe SQL statement is 1048576, i.e. 1 MB. It can be configured in the parameter `maxSQLLength` in the client side, the applicable range is [65480, 1048576].
|
- Maximum length of singe SQL statement is 1048576, i.e. 1 MB. It can be configured in the parameter `maxSQLLength` in the client side, the applicable range is [65480, 1048576].
|
||||||
- At most 4096 columns (or 1024 prior to 2.1.7.0) can be returned by `SELECT`. Functions in the query statement constitute columns. An error is returned if the limit is exceeded.
|
- At most 4096 columns can be returned by `SELECT`. Functions in the query statement constitute columns. An error is returned if the limit is exceeded.
|
||||||
- Maximum numbers of databases, STables, tables are dependent only on the system resources.
|
- Maximum numbers of databases, STables, tables are dependent only on the system resources.
|
||||||
- Maximum of database name is 32 bytes, and it can't include "." or special characters.
|
|
||||||
- Maximum number of replicas for a database is 3.
|
- Maximum number of replicas for a database is 3.
|
||||||
- Maximum length of user name is 23 bytes.
|
- Maximum length of user name is 23 bytes.
|
||||||
- Maximum length of password is 15 bytes.
|
- Maximum length of password is 15 bytes.
|
||||||
- Maximum number of rows depends only on the storage space.
|
- Maximum number of rows depends only on the storage space.
|
||||||
- Maximum number of tables depends only on the number of nodes.
|
- Maximum number of vnodes for a single database is 1024.
|
||||||
- Maximum number of databases depends only on the number of nodes.
|
|
||||||
- Maximum number of vnodes for a single database is 64.
|
|
||||||
|
|
||||||
## Restrictions of `GROUP BY`
|
|
||||||
|
|
||||||
`GROUP BY` can be performed on tags and `TBNAME`. It can be performed on data columns too, with the only restriction being it can only be performed on one data column and the number of unique values in that column is lower than 100,000. Please note that `GROUP BY` cannot be performed on float or double types.
|
|
||||||
|
|
||||||
## Restrictions of `IS NOT NULL`
|
|
||||||
|
|
||||||
`IS NOT NULL` can be used on any data type of columns. The non-empty string evaluation expression, i.e. `< > ""` can only be used on non-numeric data types.
|
|
||||||
|
|
||||||
## Restrictions of `ORDER BY`
|
|
||||||
|
|
||||||
- Only one `order by` is allowed for normal table and subtable.
|
|
||||||
- At most two `order by` are allowed for STable, and the second one must be `ts`.
|
|
||||||
- `order by tag` must be used with `group by tag` on same tag. This rule is also applicable to `tbname`.
|
|
||||||
- `order by column` must be used with `group by column` or `top/bottom` on same column. This rule is applicable to table and STable.
|
|
||||||
- `order by ts` is applicable to table and STable.
|
|
||||||
- If `order by ts` is used with `group by`, the result set is sorted using `ts` in each group.
|
|
||||||
|
|
||||||
## Restrictions of Table/Column Names
|
## Restrictions of Table/Column Names
|
||||||
|
|
||||||
|
@ -71,7 +51,3 @@ For example:
|
||||||
The characters inside escape characters must be printable characters.
|
The characters inside escape characters must be printable characters.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Applicable Versions
|
|
||||||
|
|
||||||
Escape character "\`" is available from version 2.3.0.1.
|
|
||||||
|
|
|
@ -1,37 +1,43 @@
|
||||||
---
|
---
|
||||||
sidebar_label: 边界限制
|
sidebar_label: 命名与边界限制
|
||||||
title: 边界限制
|
title: 命名与边界限制
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 名称命名规则
|
||||||
|
|
||||||
|
1. 合法字符:英文字符、数字和下划线
|
||||||
|
2. 允许英文字符或下划线开头,不允许以数字开头
|
||||||
|
3. 不区分大小写
|
||||||
|
4. 转义后表(列)名规则:
|
||||||
|
为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。
|
||||||
|
转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。
|
||||||
|
|
||||||
|
例如:\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。
|
||||||
|
需要注意的是转义字符中的内容必须是可打印字符。
|
||||||
|
|
||||||
|
## 密码合法字符集
|
||||||
|
|
||||||
|
`[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`
|
||||||
|
|
||||||
|
去掉了 `` ‘“`\ `` (单双引号、撇号、反斜杠、空格)
|
||||||
|
|
||||||
## 一般限制
|
## 一般限制
|
||||||
|
|
||||||
- 数据库名最大长度为 32。
|
- 数据库名最大长度为 32。
|
||||||
- 表名最大长度为 192,不包括数据库名前缀和分隔符
|
- 表名最大长度为 192,不包括数据库名前缀和分隔符
|
||||||
- 每行数据最大长度 48KB (注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。
|
- 每行数据最大长度 48KB (注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。
|
||||||
- 列名最大长度为 64,最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。注:从 2.1.7.0 版本(不含)以前最多允许 4096 列
|
- 列名最大长度为 64
|
||||||
- 标签名最大长度为 64,最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16KB 。
|
- 最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。
|
||||||
|
- 标签名最大长度为 64
|
||||||
|
- 最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16KB 。
|
||||||
- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。
|
- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。
|
||||||
- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。注: 2.1.7.0 版本(不含)之前为最多允许 1024 列
|
- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。
|
||||||
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制。
|
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制。
|
||||||
|
- 数据库的副本数只能设置为 1 或 3
|
||||||
## GROUP BY 的限制
|
- 用户名的最大长度是 23 个字节
|
||||||
|
- 用户密码的最大长度是 15 个字节
|
||||||
TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进行 GROUP BY,前提是:仅限一列且该列的唯一值小于 10 万个。注意:group by 不支持 float,double 类型。
|
- 总数据行数取决于可用资源
|
||||||
|
- 单个数据库的虚拟结点数上限为 1024
|
||||||
## IS NOT NULL 的限制
|
|
||||||
|
|
||||||
IS NOT NULL 与不为空的表达式适用范围。
|
|
||||||
|
|
||||||
IS NOT NULL 支持所有类型的列。不为空的表达式为 <\>"",仅对非数值类型的列适用。
|
|
||||||
|
|
||||||
## ORDER BY 的限制
|
|
||||||
|
|
||||||
- 非超级表只能有一个 order by.
|
|
||||||
- 超级表最多两个 order by, 并且第二个必须为 ts.
|
|
||||||
- order by tag,必须和 group by tag 一起,并且是同一个 tag。 tbname 和 tag 一样逻辑。 只适用于超级表
|
|
||||||
- order by 普通列,必须和 group by 一起或者和 top/bottom 一起,并且是同一个普通列。 适用于超级表和普通表。如果同时存在 group by 和 top/bottom 一起,order by 优先必须和 group by 同一列。
|
|
||||||
- order by ts. 适用于超级表和普通表。
|
|
||||||
- order by ts 同时含有 group by 时 针对 group 内部用 ts 排序
|
|
||||||
|
|
||||||
## 表(列)名合法性说明
|
## 表(列)名合法性说明
|
||||||
|
|
||||||
|
@ -49,6 +55,3 @@ IS NOT NULL 支持所有类型的列。不为空的表达式为 <\>"",仅对
|
||||||
转义字符中的内容必须是可打印字符。
|
转义字符中的内容必须是可打印字符。
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### 支持版本
|
|
||||||
支持转义符的功能从 2.3.0.1 版本开始。
|
|
|
@ -1,46 +1,8 @@
|
||||||
---
|
---
|
||||||
sidebar_label: 参数限制与保留关键字
|
sidebar_label: 保留关键字
|
||||||
title: TDengine 参数限制与保留关键字
|
title: TDengine 保留关键字
|
||||||
---
|
---
|
||||||
|
|
||||||
## 名称命名规则
|
|
||||||
|
|
||||||
1. 合法字符:英文字符、数字和下划线
|
|
||||||
2. 允许英文字符或下划线开头,不允许以数字开头
|
|
||||||
3. 不区分大小写
|
|
||||||
4. 转义后表(列)名规则:
|
|
||||||
为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。
|
|
||||||
转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。
|
|
||||||
|
|
||||||
例如:\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。
|
|
||||||
需要注意的是转义字符中的内容必须是可打印字符。
|
|
||||||
支持转义符的功能从 2.3.0.1 版本开始。
|
|
||||||
|
|
||||||
## 密码合法字符集
|
|
||||||
|
|
||||||
`[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`
|
|
||||||
|
|
||||||
去掉了 `` ‘“`\ `` (单双引号、撇号、反斜杠、空格)
|
|
||||||
|
|
||||||
- 数据库名:不能包含“.”以及特殊字符,不能超过 32 个字符
|
|
||||||
- 表名:不能包含“.”以及特殊字符,与所属数据库名一起,不能超过 192 个字节 ,每行数据最大长度 48KB
|
|
||||||
- 表的列名:不能包含特殊字符,不能超过 64 个字节
|
|
||||||
- 数据库名、表名、列名,都不能以数字开头,合法的可用字符集是“英文字符、数字和下划线”
|
|
||||||
- 表的列数:不能超过 1024 列,最少需要 2 列,第一列必须是时间戳(从 2.1.7.0 版本开始,改为最多支持 4096 列)
|
|
||||||
- 记录的最大长度:包括时间戳 8 字节,不能超过 48KB(每个 BINARY/NCHAR 类型的列还会额外占用 2 个 字节 的存储位置)
|
|
||||||
- 单条 SQL 语句默认最大字符串长度:1048576 字节,但可通过系统配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576 字节
|
|
||||||
- 数据库副本数:不能超过 3
|
|
||||||
- 用户名:不能超过 23 个 字节
|
|
||||||
- 用户密码:不能超过 15 个 字节
|
|
||||||
- 标签(Tags)数量:不能超过 128 个,可以 0 个
|
|
||||||
- 标签的总长度:不能超过 16KB
|
|
||||||
- 记录条数:仅受存储空间限制
|
|
||||||
- 表的个数:仅受节点个数限制
|
|
||||||
- 库的个数:仅受节点个数限制
|
|
||||||
- 单个库上虚拟节点个数:不能超过 64 个
|
|
||||||
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制
|
|
||||||
- SELECT 语句的查询结果,最多允许返回 1024 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。(从 2.1.7.0 版本开始,改为最多允许 4096 列)
|
|
||||||
|
|
||||||
## 保留关键字
|
## 保留关键字
|
||||||
|
|
||||||
目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下:
|
目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下:
|
||||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_USER_INDEXES "user_indexes"
|
#define TSDB_INS_TABLE_USER_INDEXES "user_indexes"
|
||||||
#define TSDB_INS_TABLE_USER_STABLES "user_stables"
|
#define TSDB_INS_TABLE_USER_STABLES "user_stables"
|
||||||
#define TSDB_INS_TABLE_USER_TABLES "user_tables"
|
#define TSDB_INS_TABLE_USER_TABLES "user_tables"
|
||||||
|
#define TSDB_INS_TABLE_USER_TAGS "user_tags"
|
||||||
#define TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED "user_table_distributed"
|
#define TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED "user_table_distributed"
|
||||||
#define TSDB_INS_TABLE_USER_USERS "user_users"
|
#define TSDB_INS_TABLE_USER_USERS "user_users"
|
||||||
#define TSDB_INS_TABLE_LICENCES "grants"
|
#define TSDB_INS_TABLE_LICENCES "grants"
|
||||||
|
|
|
@ -268,6 +268,26 @@ typedef struct SSortExecInfo {
|
||||||
int32_t readBytes; // read io bytes
|
int32_t readBytes; // read io bytes
|
||||||
} SSortExecInfo;
|
} SSortExecInfo;
|
||||||
|
|
||||||
|
//======================================================================================================================
|
||||||
|
// for grant
|
||||||
|
typedef enum {
|
||||||
|
TSDB_GRANT_ALL,
|
||||||
|
TSDB_GRANT_TIME,
|
||||||
|
TSDB_GRANT_USER,
|
||||||
|
TSDB_GRANT_DB,
|
||||||
|
TSDB_GRANT_TIMESERIES,
|
||||||
|
TSDB_GRANT_DNODE,
|
||||||
|
TSDB_GRANT_ACCT,
|
||||||
|
TSDB_GRANT_STORAGE,
|
||||||
|
TSDB_GRANT_SPEED,
|
||||||
|
TSDB_GRANT_QUERY_TIME,
|
||||||
|
TSDB_GRANT_CONNS,
|
||||||
|
TSDB_GRANT_STREAMS,
|
||||||
|
TSDB_GRANT_CPU_CORES,
|
||||||
|
} EGrantType;
|
||||||
|
|
||||||
|
int32_t grantCheck(EGrantType grant);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -139,6 +139,7 @@ extern int32_t tsTransPullupInterval;
|
||||||
extern int32_t tsMqRebalanceInterval;
|
extern int32_t tsMqRebalanceInterval;
|
||||||
extern int32_t tsTtlUnit;
|
extern int32_t tsTtlUnit;
|
||||||
extern int32_t tsTtlPushInterval;
|
extern int32_t tsTtlPushInterval;
|
||||||
|
extern int32_t tsGrantHBInterval;
|
||||||
|
|
||||||
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_STB,
|
TSDB_MGMT_TABLE_STB,
|
||||||
TSDB_MGMT_TABLE_STREAMS,
|
TSDB_MGMT_TABLE_STREAMS,
|
||||||
TSDB_MGMT_TABLE_TABLE,
|
TSDB_MGMT_TABLE_TABLE,
|
||||||
|
TSDB_MGMT_TABLE_TAG,
|
||||||
TSDB_MGMT_TABLE_USER,
|
TSDB_MGMT_TABLE_USER,
|
||||||
TSDB_MGMT_TABLE_GRANTS,
|
TSDB_MGMT_TABLE_GRANTS,
|
||||||
TSDB_MGMT_TABLE_VGROUP,
|
TSDB_MGMT_TABLE_VGROUP,
|
||||||
|
|
|
@ -152,6 +152,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TTL_TIMER, "ttl-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TTL_TIMER, "ttl-tmr", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_GRANT_HB_TIMER, "grant-hb-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_TRANS, "kill-trans", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_KILL_TRANS, "kill-trans", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_QUERY, "kill-query", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_KILL_QUERY, "kill-query", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_CONN, "kill-conn", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_KILL_CONN, "kill-conn", NULL, NULL)
|
||||||
|
|
|
@ -172,13 +172,8 @@ typedef struct tExprNode {
|
||||||
|
|
||||||
void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *));
|
void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *));
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SHOULD_FREE_COLDATA = 0x1, // the newly created column data needs to be destroyed.
|
|
||||||
DELEGATED_MGMT_COLDATA = 0x2, // input column data should not be released.
|
|
||||||
} ECOLDATA_MGMT_TYPE_E;
|
|
||||||
|
|
||||||
struct SScalarParam {
|
struct SScalarParam {
|
||||||
ECOLDATA_MGMT_TYPE_E type;
|
bool colAlloced;
|
||||||
SColumnInfoData *columnData;
|
SColumnInfoData *columnData;
|
||||||
SHashObj *pHashFilter;
|
SHashObj *pHashFilter;
|
||||||
int32_t hashValueType;
|
int32_t hashValueType;
|
||||||
|
|
|
@ -170,6 +170,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_STABLES_STMT,
|
QUERY_NODE_SHOW_STABLES_STMT,
|
||||||
QUERY_NODE_SHOW_STREAMS_STMT,
|
QUERY_NODE_SHOW_STREAMS_STMT,
|
||||||
QUERY_NODE_SHOW_TABLES_STMT,
|
QUERY_NODE_SHOW_TABLES_STMT,
|
||||||
|
QUERY_NODE_SHOW_TAGS_STMT,
|
||||||
QUERY_NODE_SHOW_USERS_STMT,
|
QUERY_NODE_SHOW_USERS_STMT,
|
||||||
QUERY_NODE_SHOW_LICENCE_STMT,
|
QUERY_NODE_SHOW_LICENCE_STMT,
|
||||||
QUERY_NODE_SHOW_VGROUPS_STMT,
|
QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||||
|
|
|
@ -113,6 +113,9 @@ int32_t twaScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
||||||
int32_t mavgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t mavgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t hllScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t hllScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t csumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t csumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t diffScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ typedef struct SSyncFSM {
|
||||||
int32_t (*FpSnapshotDoRead)(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
int32_t (*FpSnapshotDoRead)(struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||||
|
|
||||||
int32_t (*FpSnapshotStartWrite)(struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
int32_t (*FpSnapshotStartWrite)(struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
||||||
int32_t (*FpSnapshotStopWrite)(struct SSyncFSM* pFsm, void* pWriter, bool isApply);
|
int32_t (*FpSnapshotStopWrite)(struct SSyncFSM* pFsm, void* pWriter, bool isApply, SSnapshot* pSnapshot);
|
||||||
int32_t (*FpSnapshotDoWrite)(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_t len);
|
int32_t (*FpSnapshotDoWrite)(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_t len);
|
||||||
|
|
||||||
} SSyncFSM;
|
} SSyncFSM;
|
||||||
|
|
|
@ -135,7 +135,7 @@ void rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg
|
||||||
int32_t rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
int32_t rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
||||||
void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
void rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
void rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
||||||
int64_t rpcAllocHandle();
|
void* rpcAllocHandle();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,6 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0519)
|
#define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0519)
|
||||||
#define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051a)
|
#define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051a)
|
||||||
#define TSDB_CODE_VND_TABLE_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051b)
|
#define TSDB_CODE_VND_TABLE_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051b)
|
||||||
#define TSDB_CODE_VND_READ_END TAOS_DEF_ERROR_CODE(0, 0x051c)
|
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||||
|
|
|
@ -171,6 +171,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
pTscObj->pAppInfo->totalDnodes = pRsp->query->totalDnodes;
|
pTscObj->pAppInfo->totalDnodes = pRsp->query->totalDnodes;
|
||||||
pTscObj->pAppInfo->onlineDnodes = pRsp->query->onlineDnodes;
|
pTscObj->pAppInfo->onlineDnodes = pRsp->query->onlineDnodes;
|
||||||
pTscObj->connId = pRsp->query->connId;
|
pTscObj->connId = pRsp->query->connId;
|
||||||
|
tscTrace("conn %p hb rsp, dnodes %d/%d", pTscObj->connId, pTscObj->pAppInfo->onlineDnodes, pTscObj->pAppInfo->totalDnodes);
|
||||||
|
|
||||||
if (pRsp->query->killRid) {
|
if (pRsp->query->killRid) {
|
||||||
tscDebug("request rid %" PRIx64 " need to be killed now", pRsp->query->killRid);
|
tscDebug("request rid %" PRIx64 " need to be killed now", pRsp->query->killRid);
|
||||||
|
@ -294,6 +295,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
(*pInst)->onlineDnodes = ((*pInst)->totalDnodes ? 0 : -1);
|
||||||
|
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), (*pInst)->onlineDnodes, (*pInst)->totalDnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspNum) {
|
if (rspNum) {
|
||||||
|
|
|
@ -1276,7 +1276,12 @@ int32_t doProcessMsgFromServer(void* param) {
|
||||||
assert(pMsg->info.ahandle != NULL);
|
assert(pMsg->info.ahandle != NULL);
|
||||||
STscObj* pTscObj = NULL;
|
STscObj* pTscObj = NULL;
|
||||||
|
|
||||||
tscDebug("processMsgFromServer message: %s, code: %s", TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code));
|
STraceId* trace = &pMsg->info.traceId;
|
||||||
|
char tbuf[40] = {0};
|
||||||
|
TRACE_TO_STR(trace, tbuf);
|
||||||
|
|
||||||
|
tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code),
|
||||||
|
tbuf);
|
||||||
|
|
||||||
if (pSendInfo->requestObjRefId != 0) {
|
if (pSendInfo->requestObjRefId != 0) {
|
||||||
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
|
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
|
||||||
|
|
|
@ -153,6 +153,15 @@ static const SSysDbTableSchema userTblsSchema[] = {
|
||||||
{.name = "type", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "type", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema userTagsSchema[] = {
|
||||||
|
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
{.name = "tag_name", .bytes = TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
{.name = "tag_type", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
|
{.name = "tag_value", .bytes = TSDB_MAX_TAGS_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema userTblDistSchema[] = {
|
static const SSysDbTableSchema userTblDistSchema[] = {
|
||||||
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
@ -255,6 +264,7 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
||||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
|
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
|
||||||
{TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)},
|
{TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)},
|
||||||
|
{TSDB_INS_TABLE_USER_TAGS, userTagsSchema, tListLen(userTagsSchema)},
|
||||||
// {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
|
// {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
|
||||||
{TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)},
|
{TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)},
|
||||||
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)},
|
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)},
|
||||||
|
|
|
@ -1479,10 +1479,12 @@ static int32_t colDataMoveVarData(SColumnInfoData* pColInfoData, size_t start, s
|
||||||
}
|
}
|
||||||
beigin++;
|
beigin++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataOffset > 0) {
|
if (dataOffset > 0) {
|
||||||
memmove(pColInfoData->pData, pColInfoData->pData + dataOffset, dataLen);
|
memmove(pColInfoData->pData, pColInfoData->pData + dataOffset, dataLen);
|
||||||
memmove(pColInfoData->varmeta.offset, &pColInfoData->varmeta.offset[start], (end - start) * sizeof(int32_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memmove(pColInfoData->varmeta.offset, &pColInfoData->varmeta.offset[start], (end - start) * sizeof(int32_t));
|
||||||
return dataLen;
|
return dataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1752,7 +1754,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
||||||
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
len += snprintf(dumpBuf + len, size - len, "%s |block type %d |child id %d|group id:%" PRIu64 "| uid:%ld|======\n", "dumpBlockData",
|
len += snprintf(dumpBuf + len, size - len, "===stream===%s |block type %d |child id %d|group id:%" PRIu64 "| uid:%ld|\n", flag,
|
||||||
(int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId,
|
(int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId,
|
||||||
pDataBlock->info.uid);
|
pDataBlock->info.uid);
|
||||||
if (len >= size - 1) return dumpBuf;
|
if (len >= size - 1) return dumpBuf;
|
||||||
|
|
|
@ -184,6 +184,7 @@ int32_t tsTransPullupInterval = 2;
|
||||||
int32_t tsMqRebalanceInterval = 2;
|
int32_t tsMqRebalanceInterval = 2;
|
||||||
int32_t tsTtlUnit = 86400;
|
int32_t tsTtlUnit = 86400;
|
||||||
int32_t tsTtlPushInterval = 60;
|
int32_t tsTtlPushInterval = 60;
|
||||||
|
int32_t tsGrantHBInterval = 60;
|
||||||
|
|
||||||
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) {
|
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) {
|
||||||
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
||||||
|
|
|
@ -4919,8 +4919,8 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) {
|
||||||
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1;
|
||||||
if (tDecodeI8(pCoder, &pReq->rollup) < 0) return -1;
|
if (tDecodeI8(pCoder, &pReq->rollup) < 0) return -1;
|
||||||
if (tDecodeSSchemaWrapper(pCoder, &pReq->schemaRow) < 0) return -1;
|
if (tDecodeSSchemaWrapperEx(pCoder, &pReq->schemaRow) < 0) return -1;
|
||||||
if (tDecodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1;
|
if (tDecodeSSchemaWrapperEx(pCoder, &pReq->schemaTag) < 0) return -1;
|
||||||
if (pReq->rollup) {
|
if (pReq->rollup) {
|
||||||
if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1;
|
if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
int32_t dmProcessGrantReq(SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dmWorker.c
|
// dmWorker.c
|
||||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
|
@ -331,7 +331,8 @@ SArray *dmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_SYSTABLE_RETRIEVE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_SYSTABLE_RETRIEVE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
// if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
|
@ -144,6 +144,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
case TDMT_DND_SYSTABLE_RETRIEVE:
|
case TDMT_DND_SYSTABLE_RETRIEVE:
|
||||||
code = dmProcessRetrieve(pMgmt, pMsg);
|
code = dmProcessRetrieve(pMgmt, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case TDMT_MND_GRANT:
|
||||||
|
code = dmProcessGrantReq(pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -206,7 +206,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
// if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -81,6 +81,7 @@ int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
taosWriteQitem(pMgmt->queryWorker.queue, pMsg);
|
taosWriteQitem(pMgmt->queryWorker.queue, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
case READ_QUEUE:
|
case READ_QUEUE:
|
||||||
|
case FETCH_QUEUE:
|
||||||
dTrace("msg:%p, is created and will put into qnode-fetch queue", pMsg);
|
dTrace("msg:%p, is created and will put into qnode-fetch queue", pMsg);
|
||||||
taosWriteQitem(pMgmt->fetchWorker.queue, pMsg);
|
taosWriteQitem(pMgmt->fetchWorker.queue, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -166,6 +166,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
||||||
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case WRITE_QUEUE:
|
case WRITE_QUEUE:
|
||||||
|
|
||||||
dGTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg);
|
dGTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg);
|
||||||
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -26,6 +26,7 @@ int32_t mndInitCluster(SMnode *pMnode);
|
||||||
void mndCleanupCluster(SMnode *pMnode);
|
void mndCleanupCluster(SMnode *pMnode);
|
||||||
int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len);
|
int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len);
|
||||||
int64_t mndGetClusterId(SMnode *pMnode);
|
int64_t mndGetClusterId(SMnode *pMnode);
|
||||||
|
int64_t mndGetClusterCreateTime(SMnode *pMnode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode);
|
||||||
SEpSet mndGetDnodeEpset(SDnodeObj *pDnode);
|
SEpSet mndGetDnodeEpset(SDnodeObj *pDnode);
|
||||||
int32_t mndGetDnodeSize(SMnode *pMnode);
|
int32_t mndGetDnodeSize(SMnode *pMnode);
|
||||||
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs);
|
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs);
|
||||||
|
void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,27 +22,10 @@
|
||||||
|
|
||||||
#include "mndInt.h"
|
#include "mndInt.h"
|
||||||
|
|
||||||
typedef enum {
|
int32_t mndInitGrant(SMnode *pMnode);
|
||||||
TSDB_GRANT_ALL,
|
|
||||||
TSDB_GRANT_TIME,
|
|
||||||
TSDB_GRANT_USER,
|
|
||||||
TSDB_GRANT_DB,
|
|
||||||
TSDB_GRANT_TIMESERIES,
|
|
||||||
TSDB_GRANT_DNODE,
|
|
||||||
TSDB_GRANT_ACCT,
|
|
||||||
TSDB_GRANT_STORAGE,
|
|
||||||
TSDB_GRANT_SPEED,
|
|
||||||
TSDB_GRANT_QUERY_TIME,
|
|
||||||
TSDB_GRANT_CONNS,
|
|
||||||
TSDB_GRANT_STREAMS,
|
|
||||||
TSDB_GRANT_CPU_CORES,
|
|
||||||
} EGrantType;
|
|
||||||
|
|
||||||
int32_t mndInitGrant();
|
|
||||||
void mndCleanupGrant();
|
void mndCleanupGrant();
|
||||||
void grantParseParameter();
|
void grantParseParameter();
|
||||||
int32_t grantCheck(EGrantType grant);
|
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value);
|
||||||
void grantReset(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);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,23 @@ int64_t mndGetClusterId(SMnode *pMnode) {
|
||||||
return clusterId;
|
return clusterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t mndGetClusterCreateTime(SMnode *pMnode) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
void *pIter = NULL;
|
||||||
|
int64_t createTime = INT64_MAX;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
SClusterObj *pCluster = NULL;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pCluster);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
createTime = pCluster->createdTime;
|
||||||
|
sdbRelease(pSdb, pCluster);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
|
|
@ -509,6 +509,12 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
SCreateDbReq createReq = {0};
|
SCreateDbReq createReq = {0};
|
||||||
|
|
||||||
|
// code = grantCheck(TSDB_GRANT_DB);
|
||||||
|
// if (code != 0) {
|
||||||
|
// terrno = code;
|
||||||
|
// goto _OVER;
|
||||||
|
// }
|
||||||
|
|
||||||
if (tDeserializeSCreateDbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -262,7 +262,7 @@ bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps) {
|
void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
||||||
int32_t numOfEps = 0;
|
int32_t numOfEps = 0;
|
||||||
|
@ -621,6 +621,12 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SCreateDnodeReq createReq = {0};
|
SCreateDnodeReq createReq = {0};
|
||||||
|
|
||||||
|
// code = grantCheck(TSDB_GRANT_DNODE);
|
||||||
|
// if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
// terrno = code;
|
||||||
|
// goto _OVER;
|
||||||
|
// }
|
||||||
|
|
||||||
if (tDeserializeSCreateDnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -118,17 +118,21 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndCleanupGrant() {}
|
void mndCleanupGrant() {}
|
||||||
void grantParseParameter() { mError("can't parsed parameter k"); }
|
void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
void grantReset(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) {}
|
||||||
|
int32_t dmProcessGrantReq(SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,16 @@ static void mndPullupTelem(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mndGrantHeartBeat(SMnode *pMnode) {
|
||||||
|
int32_t contLen = 0;
|
||||||
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
|
if (pReq != NULL) {
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = TDMT_MND_GRANT_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9527};
|
||||||
|
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void *mndThreadFp(void *param) {
|
static void *mndThreadFp(void *param) {
|
||||||
SMnode *pMnode = param;
|
SMnode *pMnode = param;
|
||||||
int64_t lastTime = 0;
|
int64_t lastTime = 0;
|
||||||
|
@ -115,6 +125,10 @@ static void *mndThreadFp(void *param) {
|
||||||
if (lastTime % (tsTelemInterval * 10) == 0) {
|
if (lastTime % (tsTelemInterval * 10) == 0) {
|
||||||
mndPullupTelem(pMnode);
|
mndPullupTelem(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastTime % (tsGrantHBInterval * 10) == 0) {
|
||||||
|
mndGrantHeartBeat(pMnode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -402,6 +416,9 @@ int32_t mndStart(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
mndSetRestore(pMnode, true);
|
mndSetRestore(pMnode, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grantReset(pMnode, TSDB_GRANT_ALL, 0);
|
||||||
|
|
||||||
return mndInitTimer(pMnode);
|
return mndInitTimer(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_STB;
|
type = TSDB_MGMT_TABLE_STB;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_TABLE;
|
type = TSDB_MGMT_TABLE_TABLE;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TAGS, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_TAG;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, len) == 0) {
|
||||||
// type = TSDB_MGMT_TABLE_DIST;
|
// type = TSDB_MGMT_TABLE_DIST;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, len) == 0) {
|
||||||
|
|
|
@ -709,7 +709,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("sma:%s, failed to create since %s", createReq.name, terrstr(terrno));
|
mError("sma:%s, failed to create since %s", createReq.name, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
|
|
@ -1689,6 +1689,9 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
||||||
_OVER:
|
_OVER:
|
||||||
taosMemoryFreeClear(stbObj.pTags);
|
taosMemoryFreeClear(stbObj.pTags);
|
||||||
taosMemoryFreeClear(stbObj.pColumns);
|
taosMemoryFreeClear(stbObj.pColumns);
|
||||||
|
if (pAlter->commentLen > 0) {
|
||||||
|
taosMemoryFreeClear(stbObj.comment);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1733,7 +1736,7 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
taosArrayDestroy(alterReq.pFields);
|
tFreeSMAltertbReq(&alterReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ int32_t mndSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWrit
|
||||||
return sdbStartWrite(pMnode->pSdb, (SSdbIter **)ppWriter);
|
return sdbStartWrite(pMnode->pSdb, (SSdbIter **)ppWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) {
|
int32_t mndSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||||
mInfo("stop to apply snapshot to sdb, apply:%d", isApply);
|
mInfo("stop to apply snapshot to sdb, apply:%d", isApply);
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
return sdbStopWrite(pMnode->pSdb, pWriter, isApply);
|
return sdbStopWrite(pMnode->pSdb, pWriter, isApply);
|
||||||
|
|
|
@ -363,6 +363,12 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// code = grantCheck(TSDB_GRANT_USER);
|
||||||
|
// if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
// terrno = code;
|
||||||
|
// goto _OVER;
|
||||||
|
// }
|
||||||
|
|
||||||
code = mndCreateUser(pMnode, pOperUser->acct, &createReq, pReq);
|
code = mndCreateUser(pMnode, pOperUser->acct, &createReq, pReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
|
|
@ -639,6 +639,7 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
||||||
if (pShow->pIter == NULL) break;
|
if (pShow->pIter == NULL) break;
|
||||||
|
|
||||||
if (pDb != NULL && pVgroup->dbUid != pDb->uid) {
|
if (pDb != NULL && pVgroup->dbUid != pDb->uid) {
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,11 +116,11 @@ int32_t metaTbCursorNext(SMTbCursor *pTbCur);
|
||||||
// typedef struct STsdb STsdb;
|
// typedef struct STsdb STsdb;
|
||||||
typedef struct STsdbReader STsdbReader;
|
typedef struct STsdbReader STsdbReader;
|
||||||
|
|
||||||
#define BLOCK_LOAD_OFFSET_ORDER 1
|
#define BLOCK_LOAD_OFFSET_ORDER 1
|
||||||
#define BLOCK_LOAD_TABLESEQ_ORDER 2
|
#define BLOCK_LOAD_TABLESEQ_ORDER 2
|
||||||
#define BLOCK_LOAD_EXTERN_ORDER 3
|
#define BLOCK_LOAD_EXTERN_ORDER 3
|
||||||
|
|
||||||
#define LASTROW_RETRIEVE_TYPE_ALL 0x1
|
#define LASTROW_RETRIEVE_TYPE_ALL 0x1
|
||||||
#define LASTROW_RETRIEVE_TYPE_SINGLE 0x2
|
#define LASTROW_RETRIEVE_TYPE_SINGLE 0x2
|
||||||
|
|
||||||
int32_t tsdbSetTableId(STsdbReader *pReader, int64_t uid);
|
int32_t tsdbSetTableId(STsdbReader *pReader, int64_t uid);
|
||||||
|
@ -138,7 +138,7 @@ void *tsdbGetIdx(SMeta *pMeta);
|
||||||
void *tsdbGetIvtIdx(SMeta *pMeta);
|
void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
|
|
||||||
int32_t tsdbLastRowReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader);
|
int32_t tsdbLastRowReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader);
|
||||||
int32_t tsdbRetrieveLastRow(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray* pTableUids);
|
int32_t tsdbRetrieveLastRow(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||||
int32_t tsdbLastrowReaderClose(void *pReader);
|
int32_t tsdbLastrowReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ int32_t vnodeSnapReaderClose(SVSnapReader *pReader);
|
||||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
||||||
// SVSnapWriter
|
// SVSnapWriter
|
||||||
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
||||||
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback);
|
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot);
|
||||||
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData);
|
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData);
|
||||||
|
|
||||||
// structs
|
// structs
|
||||||
|
@ -237,8 +237,8 @@ typedef struct {
|
||||||
uint64_t groupId;
|
uint64_t groupId;
|
||||||
} STableKeyInfo;
|
} STableKeyInfo;
|
||||||
|
|
||||||
#define TABLE_ROLLUP_ON ((int8_t)0x1)
|
#define TABLE_ROLLUP_ON ((int8_t)0x1)
|
||||||
#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0)
|
#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0)
|
||||||
#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON)
|
#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON)
|
||||||
struct SMetaEntry {
|
struct SMetaEntry {
|
||||||
int64_t version;
|
int64_t version;
|
||||||
|
|
|
@ -32,6 +32,8 @@ extern "C" {
|
||||||
#define smaTrace(...) do { if (smaDebugFlag & DEBUG_TRACE) { taosPrintLog("SMA ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
#define smaTrace(...) do { if (smaDebugFlag & DEBUG_TRACE) { taosPrintLog("SMA ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
#define RSMA_TASK_INFO_HASH_SLOT 8
|
||||||
|
|
||||||
typedef struct SSmaEnv SSmaEnv;
|
typedef struct SSmaEnv SSmaEnv;
|
||||||
typedef struct SSmaStat SSmaStat;
|
typedef struct SSmaStat SSmaStat;
|
||||||
typedef struct STSmaStat STSmaStat;
|
typedef struct STSmaStat STSmaStat;
|
||||||
|
@ -41,7 +43,7 @@ typedef struct SRSmaInfo SRSmaInfo;
|
||||||
typedef struct SRSmaInfoItem SRSmaInfoItem;
|
typedef struct SRSmaInfoItem SRSmaInfoItem;
|
||||||
|
|
||||||
struct SSmaEnv {
|
struct SSmaEnv {
|
||||||
TdThreadRwlock lock;
|
SRWLatch lock;
|
||||||
int8_t type;
|
int8_t type;
|
||||||
SSmaStat *pStat;
|
SSmaStat *pStat;
|
||||||
};
|
};
|
||||||
|
@ -52,7 +54,7 @@ typedef struct {
|
||||||
void *tmrHandle; // shared by all fetch tasks
|
void *tmrHandle; // shared by all fetch tasks
|
||||||
} SSmaMgmt;
|
} SSmaMgmt;
|
||||||
|
|
||||||
#define SMA_ENV_LOCK(env) ((env)->lock)
|
#define SMA_ENV_LOCK(env) (&(env)->lock)
|
||||||
#define SMA_ENV_TYPE(env) ((env)->type)
|
#define SMA_ENV_TYPE(env) ((env)->type)
|
||||||
#define SMA_ENV_STAT(env) ((env)->pStat)
|
#define SMA_ENV_STAT(env) ((env)->pStat)
|
||||||
|
|
||||||
|
@ -64,10 +66,14 @@ struct STSmaStat {
|
||||||
|
|
||||||
struct SRSmaStat {
|
struct SRSmaStat {
|
||||||
SSma *pSma;
|
SSma *pSma;
|
||||||
int64_t submitVer;
|
int64_t commitAppliedVer; // vnode applied version for async commit
|
||||||
int64_t refId; // shared by fetch tasks
|
int64_t commitSubmitVer; // rsma submit version for async commit
|
||||||
int8_t triggerStat; // shared by fetch tasks
|
int64_t submitVer; // latest submit version
|
||||||
SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo;
|
int64_t refId; // shared by fetch tasks
|
||||||
|
int8_t triggerStat; // shared by fetch tasks
|
||||||
|
int8_t commitStat; // 0 not in committing, 1 in committing
|
||||||
|
SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo;
|
||||||
|
SHashObj *iRsmaInfoHash; // key: stbUid, value: SRSmaInfo; immutable rsmaInfoHash
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSmaStat {
|
struct SSmaStat {
|
||||||
|
@ -78,12 +84,29 @@ struct SSmaStat {
|
||||||
T_REF_DECLARE()
|
T_REF_DECLARE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SMA_TSMA_STAT(s) (&(s)->tsmaStat)
|
#define SMA_TSMA_STAT(s) (&(s)->tsmaStat)
|
||||||
#define SMA_RSMA_STAT(s) (&(s)->rsmaStat)
|
#define SMA_RSMA_STAT(s) (&(s)->rsmaStat)
|
||||||
#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash)
|
#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash)
|
||||||
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
|
#define RSMA_IMU_INFO_HASH(r) ((r)->iRsmaInfoHash)
|
||||||
#define RSMA_REF_ID(r) ((r)->refId)
|
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
|
||||||
#define RSMA_SUBMIT_VER(r) ((r)->submitVer)
|
#define RSMA_COMMIT_STAT(r) (&(r)->commitStat)
|
||||||
|
#define RSMA_REF_ID(r) ((r)->refId)
|
||||||
|
#define RSMA_SUBMIT_VER(r) ((r)->submitVer)
|
||||||
|
|
||||||
|
struct SRSmaInfoItem {
|
||||||
|
void *taskInfo; // qTaskInfo_t
|
||||||
|
int64_t refId;
|
||||||
|
tmr_h tmrId;
|
||||||
|
int32_t maxDelay;
|
||||||
|
int8_t level;
|
||||||
|
int8_t triggerStat;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SRSmaInfo {
|
||||||
|
STSchema *pTSchema;
|
||||||
|
int64_t suid;
|
||||||
|
SRSmaInfoItem items[TSDB_RETENTION_L2];
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TASK_TRIGGER_STAT_INIT = 0,
|
TASK_TRIGGER_STAT_INIT = 0,
|
||||||
|
@ -94,6 +117,14 @@ enum {
|
||||||
TASK_TRIGGER_STAT_DROPPED = 5,
|
TASK_TRIGGER_STAT_DROPPED = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RSMA_ROLE_CREATE = 0,
|
||||||
|
RSMA_ROLE_DROP = 1,
|
||||||
|
RSMA_ROLE_FETCH = 2,
|
||||||
|
RSMA_ROLE_SUBMIT = 3,
|
||||||
|
RSMA_ROLE_ITERATE = 4,
|
||||||
|
};
|
||||||
|
|
||||||
void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
|
void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
|
||||||
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
|
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
|
||||||
|
|
||||||
|
@ -112,33 +143,6 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType);
|
||||||
int32_t tdLockSma(SSma *pSma);
|
int32_t tdLockSma(SSma *pSma);
|
||||||
int32_t tdUnLockSma(SSma *pSma);
|
int32_t tdUnLockSma(SSma *pSma);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tdRLockSmaEnv(SSmaEnv *pEnv) {
|
|
||||||
int code = taosThreadRwlockRdlock(&(pEnv->lock));
|
|
||||||
if (code != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tdWLockSmaEnv(SSmaEnv *pEnv) {
|
|
||||||
int code = taosThreadRwlockWrlock(&(pEnv->lock));
|
|
||||||
if (code != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tdUnLockSmaEnv(SSmaEnv *pEnv) {
|
|
||||||
int code = taosThreadRwlockUnlock(&(pEnv->lock));
|
|
||||||
if (code != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int8_t tdSmaStat(STSmaStat *pTStat) {
|
static FORCE_INLINE int8_t tdSmaStat(STSmaStat *pTStat) {
|
||||||
if (pTStat) {
|
if (pTStat) {
|
||||||
return atomic_load_8(&pTStat->state);
|
return atomic_load_8(&pTStat->state);
|
||||||
|
@ -184,10 +188,12 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pDest, SRSmaInfo *pSrc);
|
||||||
|
void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
|
||||||
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||||
void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
|
void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||||
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo);
|
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree);
|
||||||
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat);
|
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
|
||||||
|
|
||||||
int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
|
int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
|
||||||
int32_t tdProcessRSmaRestoreImpl(SSma *pSma);
|
int32_t tdProcessRSmaRestoreImpl(SSma *pSma);
|
||||||
|
|
|
@ -24,12 +24,12 @@ extern "C" {
|
||||||
|
|
||||||
// tsdbDebug ================
|
// tsdbDebug ================
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSD FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
||||||
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSD ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
||||||
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TSDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
|
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TSD WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
|
||||||
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TSDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
|
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TSD ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
|
||||||
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSDB ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSD ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSD ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
typedef struct TSDBROW TSDBROW;
|
typedef struct TSDBROW TSDBROW;
|
||||||
|
@ -115,7 +115,6 @@ int32_t tGetBlock(uint8_t *p, void *ph);
|
||||||
int32_t tBlockCmprFn(const void *p1, const void *p2);
|
int32_t tBlockCmprFn(const void *p1, const void *p2);
|
||||||
bool tBlockHasSma(SBlock *pBlock);
|
bool tBlockHasSma(SBlock *pBlock);
|
||||||
// SBlockIdx
|
// SBlockIdx
|
||||||
void tBlockIdxReset(SBlockIdx *pBlockIdx);
|
|
||||||
int32_t tPutBlockIdx(uint8_t *p, void *ph);
|
int32_t tPutBlockIdx(uint8_t *p, void *ph);
|
||||||
int32_t tGetBlockIdx(uint8_t *p, void *ph);
|
int32_t tGetBlockIdx(uint8_t *p, void *ph);
|
||||||
int32_t tCmprBlockIdx(void const *lhs, void const *rhs);
|
int32_t tCmprBlockIdx(void const *lhs, void const *rhs);
|
||||||
|
@ -126,6 +125,8 @@ void tColDataClear(void *ph);
|
||||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
||||||
int32_t tColDataGetValue(SColData *pColData, int32_t iRow, SColVal *pColVal);
|
int32_t tColDataGetValue(SColData *pColData, int32_t iRow, SColVal *pColVal);
|
||||||
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
||||||
|
int32_t tPutColData(uint8_t *p, SColData *pColData);
|
||||||
|
int32_t tGetColData(uint8_t *p, SColData *pColData);
|
||||||
// SBlockData
|
// SBlockData
|
||||||
#define tBlockDataFirstRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, 0)
|
#define tBlockDataFirstRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, 0)
|
||||||
#define tBlockDataLastRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, (PBLOCKDATA)->nRow - 1)
|
#define tBlockDataLastRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, (PBLOCKDATA)->nRow - 1)
|
||||||
|
@ -134,14 +135,17 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
||||||
int32_t tBlockDataInit(SBlockData *pBlockData);
|
int32_t tBlockDataInit(SBlockData *pBlockData);
|
||||||
void tBlockDataReset(SBlockData *pBlockData);
|
void tBlockDataReset(SBlockData *pBlockData);
|
||||||
int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema);
|
int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema);
|
||||||
|
int32_t tBlockDataCorrectSchema(SBlockData *pBlockData, SBlockData *pBlockDataFrom);
|
||||||
void tBlockDataClearData(SBlockData *pBlockData);
|
void tBlockDataClearData(SBlockData *pBlockData);
|
||||||
void tBlockDataClear(SBlockData *pBlockData);
|
void tBlockDataClear(SBlockData *pBlockData, int8_t deepClear);
|
||||||
int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData **ppColData);
|
int32_t tBlockDataAddColData(SBlockData *pBlockData, int32_t iColData, SColData **ppColData);
|
||||||
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema);
|
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema);
|
||||||
int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlockData *pBlockData);
|
int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlockData *pBlockData);
|
||||||
int32_t tBlockDataCopy(SBlockData *pBlockDataSrc, SBlockData *pBlockDataDest);
|
int32_t tBlockDataCopy(SBlockData *pBlockDataSrc, SBlockData *pBlockDataDest);
|
||||||
SColData *tBlockDataGetColDataByIdx(SBlockData *pBlockData, int32_t idx);
|
SColData *tBlockDataGetColDataByIdx(SBlockData *pBlockData, int32_t idx);
|
||||||
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData);
|
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData);
|
||||||
|
int32_t tPutBlockData(uint8_t *p, SBlockData *pBlockData);
|
||||||
|
int32_t tGetBlockData(uint8_t *p, SBlockData *pBlockData);
|
||||||
// SDelIdx
|
// SDelIdx
|
||||||
int32_t tPutDelIdx(uint8_t *p, void *ph);
|
int32_t tPutDelIdx(uint8_t *p, void *ph);
|
||||||
int32_t tGetDelIdx(uint8_t *p, void *ph);
|
int32_t tGetDelIdx(uint8_t *p, void *ph);
|
||||||
|
@ -202,7 +206,7 @@ int32_t tsdbFSStateUpsertDelFile(STsdbFSState *pState, SDelFile *pDelFile);
|
||||||
int32_t tsdbFSStateUpsertDFileSet(STsdbFSState *pState, SDFileSet *pSet);
|
int32_t tsdbFSStateUpsertDFileSet(STsdbFSState *pState, SDFileSet *pSet);
|
||||||
void tsdbFSStateDeleteDFileSet(STsdbFSState *pState, int32_t fid);
|
void tsdbFSStateDeleteDFileSet(STsdbFSState *pState, int32_t fid);
|
||||||
SDelFile *tsdbFSStateGetDelFile(STsdbFSState *pState);
|
SDelFile *tsdbFSStateGetDelFile(STsdbFSState *pState);
|
||||||
SDFileSet *tsdbFSStateGetDFileSet(STsdbFSState *pState, int32_t fid);
|
SDFileSet *tsdbFSStateGetDFileSet(STsdbFSState *pState, int32_t fid, int32_t flag);
|
||||||
// tsdbReaderWriter.c ==============================================================================================
|
// tsdbReaderWriter.c ==============================================================================================
|
||||||
// SDataFWriter
|
// SDataFWriter
|
||||||
int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet);
|
int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet);
|
||||||
|
@ -357,10 +361,6 @@ struct TSDBROW {
|
||||||
struct SBlockIdx {
|
struct SBlockIdx {
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
TSKEY minKey;
|
|
||||||
TSKEY maxKey;
|
|
||||||
int64_t minVersion;
|
|
||||||
int64_t maxVersion;
|
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
};
|
};
|
||||||
|
|
|
@ -99,7 +99,8 @@ STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
||||||
int32_t metaGetTbTSchemaEx(SMeta* pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema** ppTSchema);
|
int32_t metaGetTbTSchemaEx(SMeta* pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema** ppTSchema);
|
||||||
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
|
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
|
||||||
tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name);
|
tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name);
|
||||||
int metaGetTbNum(SMeta* pMeta);
|
int64_t metaGetTbNum(SMeta* pMeta);
|
||||||
|
int64_t metaGetTimeSeriesNum(SMeta* pMeta);
|
||||||
SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid);
|
SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid);
|
||||||
void metaCloseCtbCursor(SMCtbCursor* pCtbCur);
|
void metaCloseCtbCursor(SMCtbCursor* pCtbCur);
|
||||||
tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur);
|
tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur);
|
||||||
|
@ -164,9 +165,12 @@ void smaCleanUp();
|
||||||
int32_t smaOpen(SVnode* pVnode);
|
int32_t smaOpen(SVnode* pVnode);
|
||||||
int32_t smaClose(SSma* pSma);
|
int32_t smaClose(SSma* pSma);
|
||||||
int32_t smaBegin(SSma* pSma);
|
int32_t smaBegin(SSma* pSma);
|
||||||
int32_t smaPreCommit(SSma* pSma);
|
int32_t smaSyncPreCommit(SSma* pSma);
|
||||||
int32_t smaCommit(SSma* pSma);
|
int32_t smaSyncCommit(SSma* pSma);
|
||||||
int32_t smaPostCommit(SSma* pSma);
|
int32_t smaSyncPostCommit(SSma* pSma);
|
||||||
|
int32_t smaAsyncPreCommit(SSma* pSma);
|
||||||
|
int32_t smaAsyncCommit(SSma* pSma);
|
||||||
|
int32_t smaAsyncPostCommit(SSma* pSma);
|
||||||
|
|
||||||
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
||||||
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
||||||
|
@ -309,6 +313,7 @@ void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||||
|
|
||||||
struct SSnapDataHdr {
|
struct SSnapDataHdr {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
int64_t index;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
uint8_t data[];
|
uint8_t data[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -463,12 +463,18 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaGetTbNum(SMeta *pMeta) {
|
// N.B. Called by statusReq per second
|
||||||
|
int64_t metaGetTbNum(SMeta *pMeta) {
|
||||||
// TODO
|
// TODO
|
||||||
// ASSERT(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// N.B. Called by statusReq per second
|
||||||
|
int64_t metaGetTimeSeriesNum(SMeta *pMeta) {
|
||||||
|
// TODO
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMeta *pMeta;
|
SMeta *pMeta;
|
||||||
TBC *pCur;
|
TBC *pCur;
|
||||||
|
|
|
@ -26,60 +26,72 @@ struct SMetaSnapReader {
|
||||||
int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader) {
|
int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t c = 0;
|
int32_t c = 0;
|
||||||
SMetaSnapReader* pMetaSnapReader = NULL;
|
SMetaSnapReader* pReader = NULL;
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pMetaSnapReader = (SMetaSnapReader*)taosMemoryCalloc(1, sizeof(*pMetaSnapReader));
|
pReader = (SMetaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
|
||||||
if (pMetaSnapReader == NULL) {
|
if (pReader == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
pMetaSnapReader->pMeta = pMeta;
|
pReader->pMeta = pMeta;
|
||||||
pMetaSnapReader->sver = sver;
|
pReader->sver = sver;
|
||||||
pMetaSnapReader->ever = ever;
|
pReader->ever = ever;
|
||||||
|
|
||||||
// impl
|
// impl
|
||||||
code = tdbTbcOpen(pMeta->pTbDb, &pMetaSnapReader->pTbc, NULL);
|
code = tdbTbcOpen(pMeta->pTbDb, &pReader->pTbc, NULL);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
taosMemoryFree(pReader);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tdbTbcMoveTo(pMetaSnapReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c);
|
code = tdbTbcMoveTo(pReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
taosMemoryFree(pReader);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppReader = pMetaSnapReader;
|
metaInfo("vgId:%d vnode snapshot meta reader opened", TD_VID(pMeta->pVnode));
|
||||||
|
|
||||||
|
*ppReader = pReader;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
metaError("vgId:%d meta snap reader open failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
metaError("vgId:%d vnode snapshot meta reader open failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
int32_t metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
tdbTbcClose((*ppReader)->pTbc);
|
tdbTbcClose((*ppReader)->pTbc);
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
return 0;
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
||||||
|
int32_t code = 0;
|
||||||
const void* pKey = NULL;
|
const void* pKey = NULL;
|
||||||
const void* pData = NULL;
|
const void* pData = NULL;
|
||||||
int32_t nKey = 0;
|
int32_t nKey = 0;
|
||||||
int32_t nData = 0;
|
int32_t nData = 0;
|
||||||
int32_t code = 0;
|
STbDbKey key;
|
||||||
|
|
||||||
|
*ppData = NULL;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
code = tdbTbcGet(pReader->pTbc, &pKey, &nKey, &pData, &nData);
|
if (tdbTbcGet(pReader->pTbc, &pKey, &nKey, &pData, &nData)) {
|
||||||
if (code || ((STbDbKey*)pData)->version > pReader->ever) {
|
|
||||||
code = TSDB_CODE_VND_READ_END;
|
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((STbDbKey*)pData)->version < pReader->sver) {
|
key = ((STbDbKey*)pKey)[0];
|
||||||
|
if (key.version > pReader->ever) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key.version < pReader->sver) {
|
||||||
tdbTbcMoveToNext(pReader->pTbc);
|
tdbTbcMoveToNext(pReader->pTbc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -88,17 +100,28 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the data
|
ASSERT(pData && nData);
|
||||||
if (tRealloc(ppData, sizeof(SSnapDataHdr) + nData) < 0) {
|
|
||||||
|
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + nData);
|
||||||
|
if (*ppData == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return code;
|
goto _err;
|
||||||
}
|
}
|
||||||
((SSnapDataHdr*)(*ppData))->type = 0; // TODO: use macro
|
|
||||||
((SSnapDataHdr*)(*ppData))->size = nData;
|
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||||
memcpy(((SSnapDataHdr*)(*ppData))->data, pData, nData);
|
pHdr->type = 0; // TODO: use macro
|
||||||
|
pHdr->size = nData;
|
||||||
|
memcpy(pHdr->data, pData, nData);
|
||||||
|
|
||||||
|
metaInfo("vgId:%d vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " nData:%d",
|
||||||
|
TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
metaError("vgId:%d vnode snapshot meta read data failed since %s", TD_VID(pReader->pMeta->pVnode), tstrerror(code));
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SMetaSnapWriter ========================================
|
// SMetaSnapWriter ========================================
|
||||||
|
@ -108,18 +131,6 @@ struct SMetaSnapWriter {
|
||||||
int64_t ever;
|
int64_t ever;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t metaSnapRollback(SMetaSnapWriter* pWriter) {
|
|
||||||
int32_t code = 0;
|
|
||||||
// TODO
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t metaSnapCommit(SMetaSnapWriter* pWriter) {
|
|
||||||
int32_t code = 0;
|
|
||||||
// TODO
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter) {
|
int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMetaSnapWriter* pWriter;
|
SMetaSnapWriter* pWriter;
|
||||||
|
@ -148,10 +159,9 @@ int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) {
|
||||||
SMetaSnapWriter* pWriter = *ppWriter;
|
SMetaSnapWriter* pWriter = *ppWriter;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
code = metaSnapRollback(pWriter);
|
ASSERT(0);
|
||||||
if (code) goto _err;
|
|
||||||
} else {
|
} else {
|
||||||
code = metaSnapCommit(pWriter);
|
code = metaCommit(pWriter->pMeta);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
|
@ -170,15 +180,16 @@ int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
|
||||||
SMetaEntry metaEntry = {0};
|
SMetaEntry metaEntry = {0};
|
||||||
SDecoder* pDecoder = &(SDecoder){0};
|
SDecoder* pDecoder = &(SDecoder){0};
|
||||||
|
|
||||||
tDecoderInit(pDecoder, pData, nData);
|
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
metaDecodeEntry(pDecoder, &metaEntry);
|
metaDecodeEntry(pDecoder, &metaEntry);
|
||||||
|
|
||||||
code = metaHandleEntry(pMeta, &metaEntry);
|
code = metaHandleEntry(pMeta, &metaEntry);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
|
tDecoderClear(pDecoder);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
metaError("vgId:%d meta snapshot write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
metaError("vgId:%d vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -15,9 +15,13 @@
|
||||||
|
|
||||||
#include "sma.h"
|
#include "sma.h"
|
||||||
|
|
||||||
static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
|
||||||
|
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
|
||||||
|
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma);
|
||||||
|
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
|
||||||
|
static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Only applicable to Rollup SMA
|
* @brief Only applicable to Rollup SMA
|
||||||
|
@ -25,7 +29,7 @@ static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma);
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaPreCommitImpl(pSma); }
|
int32_t smaSyncPreCommit(SSma *pSma) { return tdProcessRSmaSyncPreCommitImpl(pSma); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Only applicable to Rollup SMA
|
* @brief Only applicable to Rollup SMA
|
||||||
|
@ -33,7 +37,7 @@ int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaPreCommitImpl(pSma); }
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaCommit(SSma *pSma) { return tdProcessRSmaCommitImpl(pSma); }
|
int32_t smaSyncCommit(SSma *pSma) { return tdProcessRSmaSyncCommitImpl(pSma); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Only applicable to Rollup SMA
|
* @brief Only applicable to Rollup SMA
|
||||||
|
@ -41,7 +45,31 @@ int32_t smaCommit(SSma *pSma) { return tdProcessRSmaCommitImpl(pSma); }
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaPostCommit(SSma *pSma) { return tdProcessRSmaPostCommitImpl(pSma); }
|
int32_t smaSyncPostCommit(SSma *pSma) { return tdProcessRSmaSyncPostCommitImpl(pSma); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Only applicable to Rollup SMA
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t smaAsyncPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Only applicable to Rollup SMA
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t smaAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncCommitImpl(pSma); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Only applicable to Rollup SMA
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t smaAsyncPostCommit(SSma *pSma) { return tdProcessRSmaAsyncPostCommitImpl(pSma); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set rsma trigger stat active
|
* @brief set rsma trigger stat active
|
||||||
|
@ -62,18 +90,17 @@ int32_t smaBegin(SSma *pSma) {
|
||||||
atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED, TASK_TRIGGER_STAT_ACTIVE);
|
atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED, TASK_TRIGGER_STAT_ACTIVE);
|
||||||
switch (rsmaTriggerStat) {
|
switch (rsmaTriggerStat) {
|
||||||
case TASK_TRIGGER_STAT_PAUSED: {
|
case TASK_TRIGGER_STAT_PAUSED: {
|
||||||
smaDebug("vgId:%d rsma trigger stat from paused to active", SMA_VID(pSma));
|
smaDebug("vgId:%d, rsma trigger stat from paused to active", SMA_VID(pSma));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TASK_TRIGGER_STAT_INIT: {
|
case TASK_TRIGGER_STAT_INIT: {
|
||||||
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
||||||
smaDebug("vgId:%d rsma trigger stat from init to active", SMA_VID(pSma));
|
smaDebug("vgId:%d, rsma trigger stat from init to active", SMA_VID(pSma));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE);
|
||||||
smaWarn("vgId:%d rsma trigger stat %" PRIi8 " is unexpected", SMA_VID(pSma), rsmaTriggerStat);
|
smaError("vgId:%d, rsma trigger stat %" PRIi8 " is unexpected", SMA_VID(pSma), rsmaTriggerStat);
|
||||||
ASSERT(0);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +108,7 @@ int32_t smaBegin(SSma *pSma) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief pre-commit for rollup sma.
|
* @brief pre-commit for rollup sma(sync commit).
|
||||||
* 1) set trigger stat of rsma timer TASK_TRIGGER_STAT_PAUSED.
|
* 1) set trigger stat of rsma timer TASK_TRIGGER_STAT_PAUSED.
|
||||||
* 2) wait all triggered fetch tasks finished
|
* 2) wait all triggered fetch tasks finished
|
||||||
* 3) perform persist task for qTaskInfo
|
* 3) perform persist task for qTaskInfo
|
||||||
|
@ -89,7 +116,7 @@ int32_t smaBegin(SSma *pSma) {
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) {
|
static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma) {
|
||||||
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
if (!pSmaEnv) {
|
if (!pSmaEnv) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -98,8 +125,7 @@ static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) {
|
||||||
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
||||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
|
// step 1: set rsma stat paused
|
||||||
// step 1: set persistence task paused
|
|
||||||
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED);
|
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED);
|
||||||
|
|
||||||
// step 2: wait all triggered fetch tasks finished
|
// step 2: wait all triggered fetch tasks finished
|
||||||
|
@ -119,7 +145,9 @@ static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 3: perform persist task for qTaskInfo
|
// step 3: perform persist task for qTaskInfo
|
||||||
tdRSmaPersistExecImpl(pRSmaStat);
|
pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
|
||||||
|
pRSmaStat->commitSubmitVer = pRSmaStat->submitVer;
|
||||||
|
tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat));
|
||||||
|
|
||||||
smaDebug("vgId:%d, rsma pre commit success", SMA_VID(pSma));
|
smaDebug("vgId:%d, rsma pre commit success", SMA_VID(pSma));
|
||||||
|
|
||||||
|
@ -132,7 +160,7 @@ static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) {
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdProcessRSmaCommitImpl(SSma *pSma) {
|
static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma) {
|
||||||
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
if (!pSmaEnv) {
|
if (!pSmaEnv) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -140,21 +168,9 @@ static int32_t tdProcessRSmaCommitImpl(SSma *pSma) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
|
||||||
* @brief post-commit for rollup sma
|
SVnode *pVnode = pSma->pVnode;
|
||||||
* 1) clean up the outdated qtaskinfo files
|
int64_t committed = pRSmaStat->commitAppliedVer;
|
||||||
*
|
|
||||||
* @param pSma
|
|
||||||
* @return int32_t
|
|
||||||
*/
|
|
||||||
static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma) {
|
|
||||||
SVnode *pVnode = pSma->pVnode;
|
|
||||||
|
|
||||||
if (!VND_IS_RSMA(pVnode)) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t committed = pVnode->state.committed;
|
|
||||||
TdDirPtr pDir = NULL;
|
TdDirPtr pDir = NULL;
|
||||||
TdDirEntryPtr pDirEntry = NULL;
|
TdDirEntryPtr pDirEntry = NULL;
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN];
|
||||||
|
@ -222,5 +238,159 @@ static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma) {
|
||||||
|
|
||||||
taosCloseDir(&pDir);
|
taosCloseDir(&pDir);
|
||||||
regfree(®ex);
|
regfree(®ex);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief post-commit for rollup sma
|
||||||
|
* 1) clean up the outdated qtaskinfo files
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
|
||||||
|
SVnode *pVnode = pSma->pVnode;
|
||||||
|
if (!VND_IS_RSMA(pVnode)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(SMA_ENV_STAT(pSmaEnv));
|
||||||
|
|
||||||
|
// cleanup outdated qtaskinfo files
|
||||||
|
tdCleanupQTaskInfoFiles(pSma, pRSmaStat);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Rsma async commit implementation
|
||||||
|
* 1) set rsma stat TASK_TRIGGER_STAT_PAUSED
|
||||||
|
* 2) Wait all running fetch task finish to fetch and put submitMsg into level 2/3 wQueue(blocking level 1 write)
|
||||||
|
* 3)
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
|
if (!pSmaEnv) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
||||||
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
|
// step 1: set rsma stat
|
||||||
|
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED);
|
||||||
|
atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 1);
|
||||||
|
|
||||||
|
// step 2: wait all triggered fetch tasks finished
|
||||||
|
int32_t nLoops = 0;
|
||||||
|
while (1) {
|
||||||
|
if (T_REF_VAL_GET(pStat) == 0) {
|
||||||
|
smaDebug("vgId:%d, rsma fetch tasks all finished", SMA_VID(pSma));
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
smaDebug("vgId:%d, rsma fetch tasks not all finished yet", SMA_VID(pSma));
|
||||||
|
}
|
||||||
|
++nLoops;
|
||||||
|
if (nLoops > 1000) {
|
||||||
|
sched_yield();
|
||||||
|
nLoops = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 3: swap rsmaInfoHash and iRsmaInfoHash
|
||||||
|
ASSERT(!RSMA_IMU_INFO_HASH(pRSmaStat));
|
||||||
|
ASSERT(RSMA_INFO_HASH(pRSmaStat));
|
||||||
|
|
||||||
|
RSMA_IMU_INFO_HASH(pRSmaStat) = RSMA_INFO_HASH(pRSmaStat);
|
||||||
|
RSMA_INFO_HASH(pRSmaStat) =
|
||||||
|
taosHashInit(RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||||
|
|
||||||
|
if (!RSMA_INFO_HASH(pRSmaStat)) {
|
||||||
|
smaError("vgId:%d, rsma async commit failed since %s", SMA_VID(pSma), terrstr());
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 4: others
|
||||||
|
pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
|
||||||
|
pRSmaStat->commitSubmitVer = pRSmaStat->submitVer;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief commit for rollup sma
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
||||||
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
|
if (!pSmaEnv) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
||||||
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
|
// perform persist task for qTaskInfo
|
||||||
|
tdRSmaPersistExecImpl(pRSmaStat, RSMA_IMU_INFO_HASH(pRSmaStat));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Migrate rsmaInfo from iRsmaInfo to rsmaInfo if rsmaInfoHash not empty.
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
|
||||||
|
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
||||||
|
if (!pSmaEnv) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
||||||
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
|
// step 1: merge rsmaInfoHash and iRsmaInfoHash
|
||||||
|
taosWLockLatch(SMA_ENV_LOCK(pSmaEnv));
|
||||||
|
|
||||||
|
if (taosHashGetSize(RSMA_INFO_HASH(pRSmaStat)) <= 0) {
|
||||||
|
// TODO: optimization - just switch the hash pointer if rsmaInfoHash is empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), NULL);
|
||||||
|
while (pIter) {
|
||||||
|
tb_uid_t *pSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
||||||
|
|
||||||
|
if (!taosHashGet(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t))) {
|
||||||
|
taosHashPut(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t), pIter, sizeof(pIter));
|
||||||
|
smaDebug("vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%" PRIi64, SMA_VID(pSma),
|
||||||
|
*pSuid);
|
||||||
|
} else {
|
||||||
|
// free the resources
|
||||||
|
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)pIter;
|
||||||
|
tdFreeRSmaInfo(pSma, pRSmaInfo, false);
|
||||||
|
smaDebug("vgId:%d, rsma async post commit, free rsma info since already COW for table:%" PRIi64, SMA_VID(pSma),
|
||||||
|
*pSuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(RSMA_IMU_INFO_HASH(pRSmaStat));
|
||||||
|
RSMA_IMU_INFO_HASH(pRSmaStat) = NULL;
|
||||||
|
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pSmaEnv));
|
||||||
|
|
||||||
|
// step 2: cleanup outdated qtaskinfo files
|
||||||
|
tdCleanupQTaskInfoFiles(pSma, pRSmaStat);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
typedef struct SSmaStat SSmaStat;
|
typedef struct SSmaStat SSmaStat;
|
||||||
|
|
||||||
#define RSMA_TASK_INFO_HASH_SLOT 8
|
|
||||||
#define SMA_MGMT_REF_NUM 10240
|
#define SMA_MGMT_REF_NUM 10240
|
||||||
|
|
||||||
extern SSmaMgmt smaMgmt;
|
extern SSmaMgmt smaMgmt;
|
||||||
|
@ -109,12 +108,7 @@ static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path)
|
||||||
|
|
||||||
SMA_ENV_TYPE(pEnv) = smaType;
|
SMA_ENV_TYPE(pEnv) = smaType;
|
||||||
|
|
||||||
int code = taosThreadRwlockInit(&(pEnv->lock), NULL);
|
taosInitRWLatch(&(pEnv->lock));
|
||||||
if (code) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
taosMemoryFree(pEnv);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma) != TSDB_CODE_SUCCESS) {
|
if (tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma) != TSDB_CODE_SUCCESS) {
|
||||||
tdFreeSmaEnv(pEnv);
|
tdFreeSmaEnv(pEnv);
|
||||||
|
@ -148,7 +142,6 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEn
|
||||||
void tdDestroySmaEnv(SSmaEnv *pSmaEnv) {
|
void tdDestroySmaEnv(SSmaEnv *pSmaEnv) {
|
||||||
if (pSmaEnv) {
|
if (pSmaEnv) {
|
||||||
pSmaEnv->pStat = tdFreeSmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv));
|
pSmaEnv->pStat = tdFreeSmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv));
|
||||||
taosThreadRwlockDestroy(&(pSmaEnv->lock));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +253,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
|
||||||
void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL);
|
void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL);
|
||||||
while (infoHash) {
|
while (infoHash) {
|
||||||
SRSmaInfo *pSmaInfo = *(SRSmaInfo **)infoHash;
|
SRSmaInfo *pSmaInfo = *(SRSmaInfo **)infoHash;
|
||||||
tdFreeRSmaInfo(pSma, pSmaInfo);
|
tdFreeRSmaInfo(pSma, pSmaInfo, true);
|
||||||
infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash);
|
infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +304,6 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
||||||
if (taosRemoveRef(smaMgmt.rsetId, RSMA_REF_ID(pRSmaStat)) < 0) {
|
if (taosRemoveRef(smaMgmt.rsetId, RSMA_REF_ID(pRSmaStat)) < 0) {
|
||||||
smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", SMA_VID(pRSmaStat->pSma),
|
smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", SMA_VID(pRSmaStat->pSma),
|
||||||
RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId, terrstr());
|
RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId, terrstr());
|
||||||
ASSERT(0);
|
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " succeed", SMA_VID(pRSmaStat->pSma),
|
smaDebug("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " succeed", SMA_VID(pRSmaStat->pSma),
|
||||||
RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId);
|
RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId);
|
||||||
|
|
|
@ -48,20 +48,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
|
||||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed);
|
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed);
|
||||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed);
|
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed);
|
||||||
|
|
||||||
struct SRSmaInfoItem {
|
|
||||||
void *taskInfo; // qTaskInfo_t
|
|
||||||
int64_t refId;
|
|
||||||
tmr_h tmrId;
|
|
||||||
int32_t maxDelay;
|
|
||||||
int8_t level;
|
|
||||||
int8_t triggerStat;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SRSmaInfo {
|
|
||||||
STSchema *pTSchema;
|
|
||||||
int64_t suid;
|
|
||||||
SRSmaInfoItem items[TSDB_RETENTION_L2];
|
|
||||||
};
|
|
||||||
|
|
||||||
static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) {
|
static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) {
|
||||||
// adapt accordingly if definition of SRSmaInfo update
|
// adapt accordingly if definition of SRSmaInfo update
|
||||||
|
@ -102,8 +89,9 @@ static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) {
|
||||||
|
|
||||||
static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) { taosMemoryFreeClear(pIter->pBuf); }
|
static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) { taosMemoryFreeClear(pIter->pBuf); }
|
||||||
|
|
||||||
static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
|
void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
|
||||||
// Note: free/kill may in RC
|
// Note: free/kill may in RC
|
||||||
|
if (!taskHandle) return;
|
||||||
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
|
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
|
||||||
if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) {
|
if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) {
|
||||||
smaDebug("vgId:%d, free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
smaDebug("vgId:%d, free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
||||||
|
@ -111,25 +99,36 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId,
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, not free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
smaDebug("vgId:%d, not free qTaskInfo_t %p of level %d", vgId, otaskHandle, level);
|
||||||
}
|
}
|
||||||
|
// TODO: clear files related to qTaskInfo?
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
|
/**
|
||||||
|
* @brief general function to free rsmaInfo
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @param pInfo
|
||||||
|
* @param isDeepFree Only stop tmrId and free pTSchema for deep free
|
||||||
|
* @return void*
|
||||||
|
*/
|
||||||
|
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) {
|
||||||
if (pInfo) {
|
if (pInfo) {
|
||||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
SRSmaInfoItem *pItem = &pInfo->items[i];
|
SRSmaInfoItem *pItem = &pInfo->items[i];
|
||||||
if (pItem->taskInfo) {
|
if (pItem->taskInfo) {
|
||||||
if (pItem->tmrId) {
|
if (isDeepFree && pItem->tmrId) {
|
||||||
smaDebug("vgId:%d, table %" PRIi64 " stop fetch timer %p level %d", SMA_VID(pSma), pInfo->suid, pItem->tmrId,
|
smaDebug("vgId:%d, table %" PRIi64 " stop fetch timer %p level %d", SMA_VID(pSma), pInfo->suid, pItem->tmrId,
|
||||||
i + 1);
|
i + 1);
|
||||||
taosTmrStopA(&pItem->tmrId);
|
taosTmrStopA(&pItem->tmrId);
|
||||||
}
|
}
|
||||||
tdFreeTaskHandle(&pItem->taskInfo, SMA_VID(pSma), i + 1);
|
tdFreeQTaskInfo(&pItem->taskInfo, SMA_VID(pSma), i + 1);
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma),
|
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma),
|
||||||
pInfo->suid, i + 1);
|
pInfo->suid, i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(pInfo->pTSchema);
|
if (isDeepFree) {
|
||||||
|
taosMemoryFree(pInfo->pTSchema);
|
||||||
|
}
|
||||||
taosMemoryFree(pInfo);
|
taosMemoryFree(pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +150,7 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
|
||||||
|
|
||||||
if (!suid || !tbUids) {
|
if (!suid || !tbUids) {
|
||||||
terrno = TSDB_CODE_INVALID_PTR;
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno));
|
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +164,7 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
|
||||||
|
|
||||||
if (pRSmaInfo->items[0].taskInfo) {
|
if (pRSmaInfo->items[0].taskInfo) {
|
||||||
if ((qUpdateQualifiedTableId(pRSmaInfo->items[0].taskInfo, tbUids, true) < 0)) {
|
if ((qUpdateQualifiedTableId(pRSmaInfo->items[0].taskInfo, tbUids, true) < 0)) {
|
||||||
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno));
|
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma),
|
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma),
|
||||||
|
@ -175,7 +174,7 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
|
||||||
|
|
||||||
if (pRSmaInfo->items[1].taskInfo) {
|
if (pRSmaInfo->items[1].taskInfo) {
|
||||||
if ((qUpdateQualifiedTableId(pRSmaInfo->items[1].taskInfo, tbUids, true) < 0)) {
|
if ((qUpdateQualifiedTableId(pRSmaInfo->items[1].taskInfo, tbUids, true) < 0)) {
|
||||||
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno));
|
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma),
|
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma),
|
||||||
|
@ -257,22 +256,22 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui
|
||||||
|
|
||||||
static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo,
|
static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo,
|
||||||
int8_t idx) {
|
int8_t idx) {
|
||||||
SRetention *pRetention = SMA_RETENTION(pSma);
|
if ((param->qmsgLen > 0) && param->qmsg[idx]) {
|
||||||
STsdbCfg *pTsdbCfg = SMA_TSDB_CFG(pSma);
|
SRetention *pRetention = SMA_RETENTION(pSma);
|
||||||
|
STsdbCfg *pTsdbCfg = SMA_TSDB_CFG(pSma);
|
||||||
|
SVnode *pVnode = pSma->pVnode;
|
||||||
|
SReadHandle handle = {
|
||||||
|
.meta = pVnode->pMeta,
|
||||||
|
.vnode = pVnode,
|
||||||
|
.initTqReader = 1,
|
||||||
|
};
|
||||||
|
|
||||||
SReadHandle handle = {
|
|
||||||
.meta = pSma->pVnode->pMeta,
|
|
||||||
.vnode = pSma->pVnode,
|
|
||||||
.initTqReader = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (param->qmsg[idx]) {
|
|
||||||
SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]);
|
SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]);
|
||||||
pItem->refId = RSMA_REF_ID(pStat);
|
pItem->refId = RSMA_REF_ID(pStat);
|
||||||
pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
|
pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
|
||||||
if (!pItem->taskInfo) {
|
if (!pItem->taskInfo) {
|
||||||
terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
|
terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
|
||||||
goto _err;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
pItem->triggerStat = TASK_TRIGGER_STAT_INACTIVE;
|
pItem->triggerStat = TASK_TRIGGER_STAT_INACTIVE;
|
||||||
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
||||||
|
@ -286,13 +285,11 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
||||||
pItem->maxDelay = TSDB_MAX_ROLLUP_MAX_DELAY;
|
pItem->maxDelay = TSDB_MAX_ROLLUP_MAX_DELAY;
|
||||||
}
|
}
|
||||||
pItem->level = idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2;
|
pItem->level = idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2;
|
||||||
smaInfo("vgId:%d table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64
|
smaInfo("vgId:%d, table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64
|
||||||
", finally maxdelay:%" PRIi32,
|
", finally maxdelay:%" PRIi32,
|
||||||
SMA_VID(pSma), pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay);
|
TD_VID(pVnode), pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -357,7 +354,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
tdFreeRSmaInfo(pSma, pRSmaInfo);
|
tdFreeRSmaInfo(pSma, pRSmaInfo, true);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +559,9 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
||||||
SSDataBlock *output = NULL;
|
SSDataBlock *output = NULL;
|
||||||
uint64_t ts;
|
uint64_t ts;
|
||||||
if (qExecTask(pItem->taskInfo, &output, &ts) < 0) {
|
if (qExecTask(pItem->taskInfo, &output, &ts) < 0) {
|
||||||
ASSERT(false);
|
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
||||||
|
pItem->level, terrstr());
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
if (!output) {
|
if (!output) {
|
||||||
break;
|
break;
|
||||||
|
@ -572,7 +571,7 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
||||||
pResult = taosArrayInit(1, sizeof(SSDataBlock));
|
pResult = taosArrayInit(1, sizeof(SSDataBlock));
|
||||||
if (!pResult) {
|
if (!pResult) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_FAILED;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,9 +648,18 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief During async commit, the SRSmaInfo object would be COW from iRSmaInfoHash and write lock should be applied.
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @param suid
|
||||||
|
* @return SRSmaInfo*
|
||||||
|
*/
|
||||||
static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
||||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||||
SRSmaStat *pStat = NULL;
|
SRSmaStat *pStat = NULL;
|
||||||
|
SRSmaInfo *pRSmaInfo = NULL;
|
||||||
|
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
// only applicable when rsma env exists
|
// only applicable when rsma env exists
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -662,11 +670,37 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRSmaInfo *pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
||||||
if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
if (pRSmaInfo && (pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
||||||
|
return pRSmaInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RSMA_COMMIT_STAT(pStat) == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return pRSmaInfo;
|
|
||||||
|
// clone the SRSmaInfo from iRsmaInfoHash to rsmaInfoHash if in committing stat
|
||||||
|
SRSmaInfo *pCowRSmaInfo = NULL;
|
||||||
|
// lock
|
||||||
|
taosWLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
void *iRSmaInfo = taosHashGet(RSMA_IMU_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
||||||
|
if (iRSmaInfo) {
|
||||||
|
SRSmaInfo *pIRSmaInfo = *(SRSmaInfo **)iRSmaInfo;
|
||||||
|
if (pIRSmaInfo) {
|
||||||
|
if (tdCloneRSmaInfo(pSma, pCowRSmaInfo, pIRSmaInfo) < 0) {
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
smaError("vgId:%d, clone rsma info failed for suid:%" PRIu64 " since %s", SMA_VID(pSma), suid, terrstr());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (taosHashPut(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t), &pCowRSmaInfo, sizeof(pCowRSmaInfo)) < 0) {
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// unlock
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
return pCowRSmaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) {
|
static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) {
|
||||||
|
@ -891,10 +925,17 @@ int32_t tdProcessRSmaRestoreImpl(SSma *pSma) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
smaError("vgId:%d failed to restore rsma task since %s", SMA_VID(pSma), terrstr());
|
smaError("vgId:%d, failed to restore rsma task since %s", SMA_VID(pSma), terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Restore from SRSmaQTaskInfoItem
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @param pItem
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *pItem) {
|
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *pItem) {
|
||||||
SRSmaInfo *pRSmaInfo = NULL;
|
SRSmaInfo *pRSmaInfo = NULL;
|
||||||
void *qTaskInfo = NULL;
|
void *qTaskInfo = NULL;
|
||||||
|
@ -920,7 +961,7 @@ static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *
|
||||||
|
|
||||||
if (qDeserializeTaskStatus(qTaskInfo, pItem->qTaskInfo, pItem->len) < 0) {
|
if (qDeserializeTaskStatus(qTaskInfo, pItem->qTaskInfo, pItem->len) < 0) {
|
||||||
smaError("vgId:%d, restore rsma task failed for table:%" PRIi64 " level %d since %s", SMA_VID(pSma), pItem->suid,
|
smaError("vgId:%d, restore rsma task failed for table:%" PRIi64 " level %d since %s", SMA_VID(pSma), pItem->suid,
|
||||||
pItem->type, terrstr(terrno));
|
pItem->type, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid,
|
smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid,
|
||||||
|
@ -1067,26 +1108,27 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
|
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
||||||
SSma *pSma = pRSmaStat->pSma;
|
SSma *pSma = pRSmaStat->pSma;
|
||||||
SVnode *pVnode = pSma->pVnode;
|
SVnode *pVnode = pSma->pVnode;
|
||||||
int32_t vid = SMA_VID(pSma);
|
int32_t vid = SMA_VID(pSma);
|
||||||
int64_t toffset = 0;
|
int64_t toffset = 0;
|
||||||
bool isFileCreated = false;
|
bool isFileCreated = false;
|
||||||
|
|
||||||
if (taosHashGetSize(RSMA_INFO_HASH(pRSmaStat)) <= 0) {
|
if (taosHashGetSize(pInfoHash) <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), NULL);
|
void *infoHash = taosHashIterate(pInfoHash, NULL);
|
||||||
if (!infoHash) {
|
if (!infoHash) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STFile tFile = {0};
|
STFile tFile = {0};
|
||||||
if (RSMA_SUBMIT_VER(pRSmaStat) > 0) {
|
#if 0
|
||||||
|
if (pRSmaStat->commitAppliedVer > 0) {
|
||||||
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
||||||
tdRSmaQTaskInfoGetFName(vid, pSma->pVnode->state.applied, qTaskInfoFName);
|
tdRSmaQTaskInfoGetFName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
||||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
||||||
smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -1099,6 +1141,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
|
||||||
|
|
||||||
isFileCreated = true;
|
isFileCreated = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
while (infoHash) {
|
while (infoHash) {
|
||||||
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash;
|
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash;
|
||||||
|
@ -1114,7 +1157,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
|
||||||
int8_t type = (int8_t)(i + 1);
|
int8_t type = (int8_t)(i + 1);
|
||||||
if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) {
|
if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) {
|
||||||
smaError("vgId:%d, rsma, table %" PRIi64 " level %d serialize qTaskInfo failed since %s", vid, pRSmaInfo->suid,
|
smaError("vgId:%d, rsma, table %" PRIi64 " level %d serialize qTaskInfo failed since %s", vid, pRSmaInfo->suid,
|
||||||
i + 1, terrstr(terrno));
|
i + 1, terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (!pOutput || len <= 0) {
|
if (!pOutput || len <= 0) {
|
||||||
|
@ -1130,7 +1173,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
|
||||||
|
|
||||||
if (!isFileCreated) {
|
if (!isFileCreated) {
|
||||||
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
char qTaskInfoFName[TSDB_FILENAME_LEN];
|
||||||
tdRSmaQTaskInfoGetFName(vid, pSma->pVnode->state.applied, qTaskInfoFName);
|
tdRSmaQTaskInfoGetFName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
|
||||||
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
|
||||||
smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -1163,11 +1206,11 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
|
||||||
taosMemoryFree(pOutput);
|
taosMemoryFree(pOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), infoHash);
|
infoHash = taosHashIterate(pInfoHash, infoHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFileCreated) {
|
if (isFileCreated) {
|
||||||
tFile.info.qTaskInfo.submitVer = atomic_load_64(&pRSmaStat->submitVer);
|
tFile.info.qTaskInfo.submitVer = atomic_load_64(&pRSmaStat->commitSubmitVer);
|
||||||
if (tdUpdateTFileHeader(&tFile) < 0) {
|
if (tdUpdateTFileHeader(&tFile) < 0) {
|
||||||
smaError("vgId:%d, rsma, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile),
|
smaError("vgId:%d, rsma, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
|
@ -1217,6 +1260,10 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64
|
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64
|
||||||
" refId:%d",
|
" refId:%d",
|
||||||
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pItem->refId);
|
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pItem->refId);
|
||||||
|
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
|
||||||
|
taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay > 5000 ? 5000 : pItem->maxDelay, pItem, smaMgmt.tmrHandle,
|
||||||
|
&pItem->tmrId);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -313,4 +313,99 @@ int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t srcTaskInfo, SRSmaParam *param,
|
||||||
|
tb_uid_t suid, int8_t idx) {
|
||||||
|
SVnode *pVnode = pSma->pVnode;
|
||||||
|
char *pOutput = NULL;
|
||||||
|
int32_t len = 0;
|
||||||
|
|
||||||
|
if (qSerializeTaskStatus(srcTaskInfo, &pOutput, &len) < 0) {
|
||||||
|
smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid,
|
||||||
|
terrstr());
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
SReadHandle handle = {
|
||||||
|
.meta = pVnode->pMeta,
|
||||||
|
.vnode = pVnode,
|
||||||
|
.initTqReader = 1,
|
||||||
|
};
|
||||||
|
ASSERT(!dstTaskInfo);
|
||||||
|
dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
|
||||||
|
if (!dstTaskInfo) {
|
||||||
|
terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qDeserializeTaskStatus(dstTaskInfo, pOutput, len) < 0) {
|
||||||
|
smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid,
|
||||||
|
terrstr());
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid);
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pOutput);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_err:
|
||||||
|
taosMemoryFreeClear(pOutput);
|
||||||
|
tdFreeQTaskInfo(dstTaskInfo, TD_VID(pVnode), idx + 1);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief pTSchema is shared
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @param pDest
|
||||||
|
* @param pSrc
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pDest, SRSmaInfo *pSrc) {
|
||||||
|
SVnode *pVnode = pSma->pVnode;
|
||||||
|
SRSmaParam *param = NULL;
|
||||||
|
if (!pSrc) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pDest) {
|
||||||
|
pDest = taosMemoryCalloc(1, sizeof(SRSmaInfo));
|
||||||
|
if (!pDest) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(pDest, pSrc, sizeof(SRSmaInfo));
|
||||||
|
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, SMA_META(pSma), 0);
|
||||||
|
smaDebug("vgId:%d, rsma clone, suid is %" PRIi64, TD_VID(pVnode), pSrc->suid);
|
||||||
|
if (metaGetTableEntryByUid(&mr, pSrc->suid) < 0) {
|
||||||
|
smaError("vgId:%d, rsma clone, failed to get table meta for %" PRIi64 " since %s", TD_VID(pVnode), pSrc->suid,
|
||||||
|
terrstr());
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
ASSERT(mr.me.type == TSDB_SUPER_TABLE);
|
||||||
|
ASSERT(mr.me.uid == pSrc->suid);
|
||||||
|
if (TABLE_IS_ROLLUP(mr.me.flags)) {
|
||||||
|
param = &mr.me.stbEntry.rsmaParam;
|
||||||
|
for (int i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
|
SRSmaInfoItem *pItem = &pSrc->items[i];
|
||||||
|
if (pItem->taskInfo) {
|
||||||
|
tdCloneQTaskInfo(pSma, pDest->items[i].taskInfo, pItem->taskInfo, param, pSrc->suid, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
smaDebug("vgId:%d, rsma clone env success for %" PRIi64, TD_VID(pVnode), pSrc->suid);
|
||||||
|
}
|
||||||
|
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_err:
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
tdFreeRSmaInfo(pSma, pDest, false);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
|
@ -476,9 +476,9 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
||||||
if (--state->iFileSet >= 0) {
|
if (--state->iFileSet >= 0) {
|
||||||
pFileSet = (SDFileSet *)taosArrayGet(state->aDFileSet, state->iFileSet);
|
pFileSet = (SDFileSet *)taosArrayGet(state->aDFileSet, state->iFileSet);
|
||||||
} else {
|
} else {
|
||||||
// tBlockDataClear(&state->blockData);
|
// tBlockDataClear(&state->blockData, 1);
|
||||||
if (state->pBlockData) {
|
if (state->pBlockData) {
|
||||||
tBlockDataClear(state->pBlockData);
|
tBlockDataClear(state->pBlockData, 1);
|
||||||
state->pBlockData = NULL;
|
state->pBlockData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,9 +500,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
/* if (state->pBlockIdx) { */
|
/* if (state->pBlockIdx) { */
|
||||||
/* tBlockIdxReset(state->blockIdx); */
|
|
||||||
/* } */
|
/* } */
|
||||||
/* tBlockIdxReset(state->blockIdx); */
|
|
||||||
/* code = tMapDataSearch(&state->blockIdxMap, state->pBlockIdxExp, tGetBlockIdx, tCmprBlockIdx,
|
/* code = tMapDataSearch(&state->blockIdxMap, state->pBlockIdxExp, tGetBlockIdx, tCmprBlockIdx,
|
||||||
* &state->blockIdx);
|
* &state->blockIdx);
|
||||||
*/
|
*/
|
||||||
|
@ -582,8 +580,8 @@ _err:
|
||||||
state->aBlockIdx = NULL;
|
state->aBlockIdx = NULL;
|
||||||
}
|
}
|
||||||
if (state->pBlockData) {
|
if (state->pBlockData) {
|
||||||
// tBlockDataClear(&state->blockData);
|
// tBlockDataClear(&state->blockData, 1);
|
||||||
tBlockDataClear(state->pBlockData);
|
tBlockDataClear(state->pBlockData, 1);
|
||||||
state->pBlockData = NULL;
|
state->pBlockData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,8 +607,8 @@ int32_t clearNextRowFromFS(void *iter) {
|
||||||
state->aBlockIdx = NULL;
|
state->aBlockIdx = NULL;
|
||||||
}
|
}
|
||||||
if (state->pBlockData) {
|
if (state->pBlockData) {
|
||||||
// tBlockDataClear(&state->blockData);
|
// tBlockDataClear(&state->blockData, 1);
|
||||||
tBlockDataClear(state->pBlockData);
|
tBlockDataClear(state->pBlockData, 1);
|
||||||
state->pBlockData = NULL;
|
state->pBlockData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
taosArrayClear(pCommitter->aBlockIdx);
|
taosArrayClear(pCommitter->aBlockIdx);
|
||||||
tMapDataReset(&pCommitter->oBlockMap);
|
tMapDataReset(&pCommitter->oBlockMap);
|
||||||
tBlockDataReset(&pCommitter->oBlockData);
|
tBlockDataReset(&pCommitter->oBlockData);
|
||||||
pRSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, pCommitter->commitFid);
|
pRSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, pCommitter->commitFid, TD_EQ);
|
||||||
if (pRSet) {
|
if (pRSet) {
|
||||||
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
@ -284,16 +284,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
.fLast = {.commitID = pCommitter->commitID, .size = 0},
|
.fLast = {.commitID = pCommitter->commitID, .size = 0},
|
||||||
.fSma = pRSet->fSma};
|
.fSma = pRSet->fSma};
|
||||||
} else {
|
} else {
|
||||||
STfs *pTfs = pTsdb->pVnode->pTfs;
|
wSet = (SDFileSet){.diskId = (SDiskID){.level = 0, .id = 0},
|
||||||
SDiskID did = {.level = 0, .id = 0};
|
|
||||||
|
|
||||||
// TODO: alloc a new disk
|
|
||||||
// tfsAllocDisk(pTfs, 0, &did);
|
|
||||||
|
|
||||||
// create the directory
|
|
||||||
tfsMkdirRecurAt(pTfs, pTsdb->path, did);
|
|
||||||
|
|
||||||
wSet = (SDFileSet){.diskId = did,
|
|
||||||
.fid = pCommitter->commitFid,
|
.fid = pCommitter->commitFid,
|
||||||
.fHead = {.commitID = pCommitter->commitID, .offset = 0, .size = 0},
|
.fHead = {.commitID = pCommitter->commitID, .offset = 0, .size = 0},
|
||||||
.fData = {.commitID = pCommitter->commitID, .size = 0},
|
.fData = {.commitID = pCommitter->commitID, .size = 0},
|
||||||
|
@ -1001,10 +992,10 @@ _exit:
|
||||||
static void tsdbCommitDataEnd(SCommitter *pCommitter) {
|
static void tsdbCommitDataEnd(SCommitter *pCommitter) {
|
||||||
taosArrayDestroy(pCommitter->aBlockIdx);
|
taosArrayDestroy(pCommitter->aBlockIdx);
|
||||||
tMapDataClear(&pCommitter->oBlockMap);
|
tMapDataClear(&pCommitter->oBlockMap);
|
||||||
tBlockDataClear(&pCommitter->oBlockData);
|
tBlockDataClear(&pCommitter->oBlockData, 1);
|
||||||
taosArrayDestroy(pCommitter->aBlockIdxN);
|
taosArrayDestroy(pCommitter->aBlockIdxN);
|
||||||
tMapDataClear(&pCommitter->nBlockMap);
|
tMapDataClear(&pCommitter->nBlockMap);
|
||||||
tBlockDataClear(&pCommitter->nBlockData);
|
tBlockDataClear(&pCommitter->nBlockData, 1);
|
||||||
tTSchemaDestroy(pCommitter->skmTable.pTSchema);
|
tTSchemaDestroy(pCommitter->skmTable.pTSchema);
|
||||||
tTSchemaDestroy(pCommitter->skmRow.pTSchema);
|
tTSchemaDestroy(pCommitter->skmRow.pTSchema);
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,6 +698,6 @@ void tsdbFSStateDeleteDFileSet(STsdbFSState *pState, int32_t fid) {
|
||||||
|
|
||||||
SDelFile *tsdbFSStateGetDelFile(STsdbFSState *pState) { return pState->pDelFile; }
|
SDelFile *tsdbFSStateGetDelFile(STsdbFSState *pState) { return pState->pDelFile; }
|
||||||
|
|
||||||
SDFileSet *tsdbFSStateGetDFileSet(STsdbFSState *pState, int32_t fid) {
|
SDFileSet *tsdbFSStateGetDFileSet(STsdbFSState *pState, int32_t fid, int32_t flag) {
|
||||||
return (SDFileSet *)taosArraySearch(pState->aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ);
|
return (SDFileSet *)taosArraySearch(pState->aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, flag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,10 @@ typedef struct SBlockLoadSuppInfo {
|
||||||
} SBlockLoadSuppInfo;
|
} SBlockLoadSuppInfo;
|
||||||
|
|
||||||
typedef struct SFilesetIter {
|
typedef struct SFilesetIter {
|
||||||
int32_t numOfFiles; // number of total files
|
int32_t numOfFiles; // number of total files
|
||||||
int32_t index; // current accessed index in the list
|
int32_t index; // current accessed index in the list
|
||||||
SArray* pFileList; // data file list
|
SArray* pFileList; // data file list
|
||||||
int32_t order;
|
int32_t order;
|
||||||
} SFilesetIter;
|
} SFilesetIter;
|
||||||
|
|
||||||
typedef struct SFileDataBlockInfo {
|
typedef struct SFileDataBlockInfo {
|
||||||
|
@ -830,8 +830,8 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
|
||||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||||
|
|
||||||
int32_t code = tsdbReadColData(pReader->pFileReader, &pBlockScanInfo->blockIdx, pBlock, pSupInfo->colIds, numOfCols,
|
int32_t code = tsdbReadColData(pReader->pFileReader, &pBlockScanInfo->blockIdx, pBlock, pSupInfo->colIds, numOfCols,
|
||||||
pBlockData, NULL, NULL);
|
pBlockData, NULL, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -1991,7 +1991,7 @@ static TSDBKEY getCurrentKeyInBuf(SDataBlockIter* pBlockIter, STsdbReader* pRead
|
||||||
|
|
||||||
static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
static int32_t moveToNextFile(STsdbReader* pReader, int32_t* numOfBlocks) {
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
SArray* pIndexList = taosArrayInit(4, sizeof(SBlockIdx));
|
SArray* pIndexList = taosArrayInit(4, sizeof(SBlockIdx));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader);
|
bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader);
|
||||||
|
@ -3006,14 +3006,14 @@ SArray* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
|
||||||
|
|
||||||
code = doLoadFileBlockData(pReader, &pStatus->blockIter, pBlockScanInfo, &pStatus->fileBlockData);
|
code = doLoadFileBlockData(pReader, &pStatus->blockIter, pBlockScanInfo, &pStatus->fileBlockData);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tBlockDataClear(&pStatus->fileBlockData);
|
tBlockDataClear(&pStatus->fileBlockData, 1);
|
||||||
|
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
||||||
tBlockDataClear(&pStatus->fileBlockData);
|
tBlockDataClear(&pStatus->fileBlockData, 1);
|
||||||
return pReader->pResBlock->pDataBlock;
|
return pReader->pResBlock->pDataBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3132,8 +3132,8 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
||||||
hasNext = (pBlockIter->numOfBlocks > 0);
|
hasNext = (pBlockIter->numOfBlocks > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %s", pReader, numOfBlocks, numOfTables,
|
// tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %s", pReader, numOfBlocks, numOfTables,
|
||||||
// pReader->pFileGroup->fid, pReader->idStr);
|
// pReader->pFileGroup->fid, pReader->idStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -3186,6 +3186,7 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
|
||||||
*suid = 0;
|
*suid = 0;
|
||||||
|
|
||||||
if (mr.me.type == TSDB_CHILD_TABLE) {
|
if (mr.me.type == TSDB_CHILD_TABLE) {
|
||||||
|
tDecoderClear(&mr.coder);
|
||||||
*suid = mr.me.ctbEntry.suid;
|
*suid = mr.me.ctbEntry.suid;
|
||||||
code = metaGetTableEntryByUid(&mr, *suid);
|
code = metaGetTableEntryByUid(&mr, *suid);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -3204,4 +3205,3 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -979,21 +979,21 @@ int32_t tsdbReadColData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *pBl
|
||||||
|
|
||||||
code = tBlockDataCopy(pBlockData, pBlockData2);
|
code = tBlockDataCopy(pBlockData, pBlockData2);
|
||||||
if (code) {
|
if (code) {
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tBlockDataMerge(pBlockData1, pBlockData2, pBlockData);
|
code = tBlockDataMerge(pBlockData1, pBlockData2, pBlockData);
|
||||||
if (code) {
|
if (code) {
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tFree(pBuf1);
|
tFree(pBuf1);
|
||||||
|
@ -1115,29 +1115,29 @@ int32_t tsdbReadBlockData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *p
|
||||||
for (iSubBlock = 1; iSubBlock < pBlock->nSubBlock; iSubBlock++) {
|
for (iSubBlock = 1; iSubBlock < pBlock->nSubBlock; iSubBlock++) {
|
||||||
code = tsdbReadSubBlockData(pReader, pBlockIdx, pBlock, iSubBlock, pBlockData1, ppBuf1, ppBuf2);
|
code = tsdbReadSubBlockData(pReader, pBlockIdx, pBlock, iSubBlock, pBlockData1, ppBuf1, ppBuf2);
|
||||||
if (code) {
|
if (code) {
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tBlockDataCopy(pBlockData, pBlockData2);
|
code = tBlockDataCopy(pBlockData, pBlockData2);
|
||||||
if (code) {
|
if (code) {
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge two block data
|
// merge two block data
|
||||||
code = tBlockDataMerge(pBlockData1, pBlockData2, pBlockData);
|
code = tBlockDataMerge(pBlockData1, pBlockData2, pBlockData);
|
||||||
if (code) {
|
if (code) {
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tBlockDataClear(pBlockData1);
|
tBlockDataClear(pBlockData1, 1);
|
||||||
tBlockDataClear(pBlockData2);
|
tBlockDataClear(pBlockData2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pBlock->nRow == pBlockData->nRow);
|
ASSERT(pBlock->nRow == pBlockData->nRow);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,15 +36,15 @@ int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(u
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
code = tRealloc((uint8_t **)&pMapData->aOffset, sizeof(int32_t) * pMapData->nItem);
|
code = tRealloc((uint8_t **)&pMapData->aOffset, sizeof(int32_t) * pMapData->nItem);
|
||||||
if (code) goto _err;
|
if (code) goto _exit;
|
||||||
code = tRealloc(&pMapData->pData, pMapData->nData);
|
code = tRealloc(&pMapData->pData, pMapData->nData);
|
||||||
if (code) goto _err;
|
if (code) goto _exit;
|
||||||
|
|
||||||
// put
|
// put
|
||||||
pMapData->aOffset[nItem] = offset;
|
pMapData->aOffset[nItem] = offset;
|
||||||
tPutItemFn(pMapData->pData + offset, pItem);
|
tPutItemFn(pMapData->pData + offset, pItem);
|
||||||
|
|
||||||
_err:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,25 +189,12 @@ static FORCE_INLINE int32_t tGetTSDBKEY(uint8_t *p, TSDBKEY *pKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SBlockIdx ======================================================
|
// SBlockIdx ======================================================
|
||||||
void tBlockIdxReset(SBlockIdx *pBlockIdx) {
|
|
||||||
pBlockIdx->minKey = TSKEY_MAX;
|
|
||||||
pBlockIdx->maxKey = TSKEY_MIN;
|
|
||||||
pBlockIdx->minVersion = VERSION_MAX;
|
|
||||||
pBlockIdx->maxVersion = VERSION_MIN;
|
|
||||||
pBlockIdx->offset = -1;
|
|
||||||
pBlockIdx->size = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tPutBlockIdx(uint8_t *p, void *ph) {
|
int32_t tPutBlockIdx(uint8_t *p, void *ph) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
SBlockIdx *pBlockIdx = (SBlockIdx *)ph;
|
SBlockIdx *pBlockIdx = (SBlockIdx *)ph;
|
||||||
|
|
||||||
n += tPutI64(p ? p + n : p, pBlockIdx->suid);
|
n += tPutI64(p ? p + n : p, pBlockIdx->suid);
|
||||||
n += tPutI64(p ? p + n : p, pBlockIdx->uid);
|
n += tPutI64(p ? p + n : p, pBlockIdx->uid);
|
||||||
n += tPutI64(p ? p + n : p, pBlockIdx->minKey);
|
|
||||||
n += tPutI64(p ? p + n : p, pBlockIdx->maxKey);
|
|
||||||
n += tPutI64v(p ? p + n : p, pBlockIdx->minVersion);
|
|
||||||
n += tPutI64v(p ? p + n : p, pBlockIdx->maxVersion);
|
|
||||||
n += tPutI64v(p ? p + n : p, pBlockIdx->offset);
|
n += tPutI64v(p ? p + n : p, pBlockIdx->offset);
|
||||||
n += tPutI64v(p ? p + n : p, pBlockIdx->size);
|
n += tPutI64v(p ? p + n : p, pBlockIdx->size);
|
||||||
|
|
||||||
|
@ -220,10 +207,6 @@ int32_t tGetBlockIdx(uint8_t *p, void *ph) {
|
||||||
|
|
||||||
n += tGetI64(p + n, &pBlockIdx->suid);
|
n += tGetI64(p + n, &pBlockIdx->suid);
|
||||||
n += tGetI64(p + n, &pBlockIdx->uid);
|
n += tGetI64(p + n, &pBlockIdx->uid);
|
||||||
n += tGetI64(p + n, &pBlockIdx->minKey);
|
|
||||||
n += tGetI64(p + n, &pBlockIdx->maxKey);
|
|
||||||
n += tGetI64v(p + n, &pBlockIdx->minVersion);
|
|
||||||
n += tGetI64v(p + n, &pBlockIdx->maxVersion);
|
|
||||||
n += tGetI64v(p + n, &pBlockIdx->offset);
|
n += tGetI64v(p + n, &pBlockIdx->offset);
|
||||||
n += tGetI64v(p + n, &pBlockIdx->size);
|
n += tGetI64v(p + n, &pBlockIdx->size);
|
||||||
|
|
||||||
|
@ -921,6 +904,76 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tPutColData(uint8_t *p, SColData *pColData) {
|
||||||
|
int32_t n = 0;
|
||||||
|
|
||||||
|
n += tPutI16v(p ? p + n : p, pColData->cid);
|
||||||
|
n += tPutI8(p ? p + n : p, pColData->type);
|
||||||
|
n += tPutI8(p ? p + n : p, pColData->smaOn);
|
||||||
|
n += tPutI32v(p ? p + n : p, pColData->nVal);
|
||||||
|
n += tPutU8(p ? p + n : p, pColData->flag);
|
||||||
|
|
||||||
|
if (pColData->flag == HAS_NONE || pColData->flag == HAS_NULL) goto _exit;
|
||||||
|
if (pColData->flag != HAS_VALUE) {
|
||||||
|
// bitmap
|
||||||
|
|
||||||
|
int32_t size = BIT2_SIZE(pColData->nVal);
|
||||||
|
if (p) {
|
||||||
|
memcpy(p + n, pColData->pBitMap, size);
|
||||||
|
}
|
||||||
|
n += size;
|
||||||
|
}
|
||||||
|
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||||
|
// offset
|
||||||
|
|
||||||
|
int32_t size = sizeof(int32_t) * pColData->nVal;
|
||||||
|
if (p) {
|
||||||
|
memcpy(p + n, pColData->aOffset, size);
|
||||||
|
}
|
||||||
|
n += size;
|
||||||
|
}
|
||||||
|
n += tPutI32v(p ? p + n : p, pColData->nData);
|
||||||
|
if (p) {
|
||||||
|
memcpy(p + n, pColData->pData, pColData->nData);
|
||||||
|
}
|
||||||
|
n += pColData->nData;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tGetColData(uint8_t *p, SColData *pColData) {
|
||||||
|
int32_t n = 0;
|
||||||
|
|
||||||
|
n += tGetI16v(p + n, &pColData->cid);
|
||||||
|
n += tGetI8(p + n, &pColData->type);
|
||||||
|
n += tGetI8(p + n, &pColData->smaOn);
|
||||||
|
n += tGetI32v(p + n, &pColData->nVal);
|
||||||
|
n += tGetU8(p + n, &pColData->flag);
|
||||||
|
|
||||||
|
if (pColData->flag == HAS_NONE || pColData->flag == HAS_NULL) goto _exit;
|
||||||
|
if (pColData->flag != HAS_VALUE) {
|
||||||
|
// bitmap
|
||||||
|
|
||||||
|
int32_t size = BIT2_SIZE(pColData->nVal);
|
||||||
|
pColData->pBitMap = p + n;
|
||||||
|
n += size;
|
||||||
|
}
|
||||||
|
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||||
|
// offset
|
||||||
|
|
||||||
|
int32_t size = sizeof(int32_t) * pColData->nVal;
|
||||||
|
pColData->aOffset = (int32_t *)(p + n);
|
||||||
|
n += size;
|
||||||
|
}
|
||||||
|
n += tGetI32v(p + n, &pColData->nData);
|
||||||
|
pColData->pData = p + n;
|
||||||
|
n += pColData->nData;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tColDataCmprFn(const void *p1, const void *p2) {
|
static FORCE_INLINE int32_t tColDataCmprFn(const void *p1, const void *p2) {
|
||||||
SColData *pColData1 = (SColData *)p1;
|
SColData *pColData1 = (SColData *)p1;
|
||||||
SColData *pColData2 = (SColData *)p2;
|
SColData *pColData2 = (SColData *)p2;
|
||||||
|
@ -962,11 +1015,11 @@ void tBlockDataReset(SBlockData *pBlockData) {
|
||||||
taosArrayClear(pBlockData->aIdx);
|
taosArrayClear(pBlockData->aIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tBlockDataClear(SBlockData *pBlockData) {
|
void tBlockDataClear(SBlockData *pBlockData, int8_t deepClear) {
|
||||||
tFree((uint8_t *)pBlockData->aVersion);
|
tFree((uint8_t *)pBlockData->aVersion);
|
||||||
tFree((uint8_t *)pBlockData->aTSKEY);
|
tFree((uint8_t *)pBlockData->aTSKEY);
|
||||||
taosArrayDestroy(pBlockData->aIdx);
|
taosArrayDestroy(pBlockData->aIdx);
|
||||||
taosArrayDestroyEx(pBlockData->aColData, tColDataClear);
|
taosArrayDestroyEx(pBlockData->aColData, deepClear ? tColDataClear : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema) {
|
int32_t tBlockDataSetSchema(SBlockData *pBlockData, STSchema *pTSchema) {
|
||||||
|
@ -1079,6 +1132,46 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tBlockDataCorrectSchema(SBlockData *pBlockData, SBlockData *pBlockDataFrom) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
int32_t iColData = 0;
|
||||||
|
for (int32_t iColDataFrom = 0; iColDataFrom < taosArrayGetSize(pBlockDataFrom->aIdx); iColDataFrom++) {
|
||||||
|
SColData *pColDataFrom = tBlockDataGetColDataByIdx(pBlockDataFrom, iColDataFrom);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
SColData *pColData;
|
||||||
|
if (iColData < taosArrayGetSize(pBlockData->aIdx)) {
|
||||||
|
pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
|
||||||
|
} else {
|
||||||
|
pColData = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pColData == NULL || pColData->cid > pColDataFrom->cid) {
|
||||||
|
code = tBlockDataAddColData(pBlockData, iColData, &pColData);
|
||||||
|
if (code) goto _exit;
|
||||||
|
|
||||||
|
tColDataInit(pColData, pColDataFrom->cid, pColDataFrom->type, pColDataFrom->smaOn);
|
||||||
|
for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) {
|
||||||
|
code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type));
|
||||||
|
if (code) goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
iColData++;
|
||||||
|
break;
|
||||||
|
} else if (pColData->cid == pColDataFrom->cid) {
|
||||||
|
iColData++;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
iColData++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlockData *pBlockData) {
|
int32_t tBlockDataMerge(SBlockData *pBlockData1, SBlockData *pBlockData2, SBlockData *pBlockData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -1239,6 +1332,52 @@ void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColD
|
||||||
*ppColData = NULL;
|
*ppColData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tPutBlockData(uint8_t *p, SBlockData *pBlockData) {
|
||||||
|
int32_t n = 0;
|
||||||
|
|
||||||
|
n += tPutI32v(p ? p + n : p, pBlockData->nRow);
|
||||||
|
if (p) {
|
||||||
|
memcpy(p + n, pBlockData->aVersion, sizeof(int64_t) * pBlockData->nRow);
|
||||||
|
}
|
||||||
|
n = n + sizeof(int64_t) * pBlockData->nRow;
|
||||||
|
if (p) {
|
||||||
|
memcpy(p + n, pBlockData->aTSKEY, sizeof(TSKEY) * pBlockData->nRow);
|
||||||
|
}
|
||||||
|
n = n + sizeof(TSKEY) * pBlockData->nRow;
|
||||||
|
|
||||||
|
int32_t nCol = taosArrayGetSize(pBlockData->aIdx);
|
||||||
|
n += tPutI32v(p ? p + n : p, nCol);
|
||||||
|
for (int32_t iCol = 0; iCol < nCol; iCol++) {
|
||||||
|
SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iCol);
|
||||||
|
n += tPutColData(p ? p + n : p, pColData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tGetBlockData(uint8_t *p, SBlockData *pBlockData) {
|
||||||
|
int32_t n = 0;
|
||||||
|
|
||||||
|
tBlockDataReset(pBlockData);
|
||||||
|
|
||||||
|
n += tGetI32v(p + n, &pBlockData->nRow);
|
||||||
|
pBlockData->aVersion = (int64_t *)(p + n);
|
||||||
|
n = n + sizeof(int64_t) * pBlockData->nRow;
|
||||||
|
pBlockData->aTSKEY = (TSKEY *)(p + n);
|
||||||
|
n = n + sizeof(TSKEY) * pBlockData->nRow;
|
||||||
|
|
||||||
|
int32_t nCol;
|
||||||
|
n += tGetI32v(p + n, &nCol);
|
||||||
|
for (int32_t iCol = 0; iCol < nCol; iCol++) {
|
||||||
|
SColData *pColData;
|
||||||
|
|
||||||
|
if (tBlockDataAddColData(pBlockData, iCol, &pColData)) return -1;
|
||||||
|
n += tGetColData(p + n, pColData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
// ALGORITHM ==============================
|
// ALGORITHM ==============================
|
||||||
void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) {
|
void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) {
|
||||||
SColVal colVal;
|
SColVal colVal;
|
||||||
|
|
|
@ -233,7 +233,8 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||||
|
|
||||||
// preCommit
|
// preCommit
|
||||||
smaPreCommit(pVnode->pSma);
|
// smaSyncPreCommit(pVnode->pSma);
|
||||||
|
smaAsyncPreCommit(pVnode->pSma);
|
||||||
|
|
||||||
// commit each sub-system
|
// commit each sub-system
|
||||||
if (metaCommit(pVnode->pMeta) < 0) {
|
if (metaCommit(pVnode->pMeta) < 0) {
|
||||||
|
@ -242,6 +243,8 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VND_IS_RSMA(pVnode)) {
|
if (VND_IS_RSMA(pVnode)) {
|
||||||
|
smaAsyncCommit(pVnode->pSma);
|
||||||
|
|
||||||
if (tsdbCommit(VND_RSMA0(pVnode)) < 0) {
|
if (tsdbCommit(VND_RSMA0(pVnode)) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -276,7 +279,8 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
pVnode->state.committed = info.state.committed;
|
pVnode->state.committed = info.state.committed;
|
||||||
|
|
||||||
// postCommit
|
// postCommit
|
||||||
smaPostCommit(pVnode->pSma);
|
// smaSyncPostCommit(pVnode->pSma);
|
||||||
|
smaAsyncPostCommit(pVnode->pSma);
|
||||||
|
|
||||||
// apply the commit (TODO)
|
// apply the commit (TODO)
|
||||||
walEndSnapshot(pVnode->pWal);
|
walEndSnapshot(pVnode->pWal);
|
||||||
|
|
|
@ -239,9 +239,9 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
pLoad->vgId = TD_VID(pVnode);
|
pLoad->vgId = TD_VID(pVnode);
|
||||||
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
||||||
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||||
pLoad->numOfTimeSeries = 400;
|
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta);
|
||||||
pLoad->totalStorage = 300;
|
pLoad->totalStorage = (int64_t)3 * 1073741824;
|
||||||
pLoad->compStorage = 200;
|
pLoad->compStorage = (int64_t)2 * 1073741824;
|
||||||
pLoad->pointsWritten = 100;
|
pLoad->pointsWritten = 100;
|
||||||
pLoad->numOfSelectReqs = 1;
|
pLoad->numOfSelectReqs = 1;
|
||||||
pLoad->numOfInsertReqs = 3;
|
pLoad->numOfInsertReqs = 3;
|
||||||
|
|
|
@ -20,13 +20,13 @@ struct SVSnapReader {
|
||||||
SVnode *pVnode;
|
SVnode *pVnode;
|
||||||
int64_t sver;
|
int64_t sver;
|
||||||
int64_t ever;
|
int64_t ever;
|
||||||
|
int64_t index;
|
||||||
// meta
|
// meta
|
||||||
int8_t metaDone;
|
int8_t metaDone;
|
||||||
SMetaSnapReader *pMetaReader;
|
SMetaSnapReader *pMetaReader;
|
||||||
// tsdb
|
// tsdb
|
||||||
int8_t tsdbDone;
|
int8_t tsdbDone;
|
||||||
STsdbSnapReader *pTsdbReader;
|
STsdbSnapReader *pTsdbReader;
|
||||||
uint8_t *pData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) {
|
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) {
|
||||||
|
@ -42,12 +42,7 @@ int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapRe
|
||||||
pReader->sver = sver;
|
pReader->sver = sver;
|
||||||
pReader->ever = ever;
|
pReader->ever = ever;
|
||||||
|
|
||||||
code = metaSnapReaderOpen(pVnode->pMeta, sver, ever, &pReader->pMetaReader);
|
vInfo("vgId:%d vnode snapshot reader opened, sver:%" PRId64 " ever:%" PRId64, TD_VID(pVnode), sver, ever);
|
||||||
if (code) goto _err;
|
|
||||||
|
|
||||||
code = tsdbSnapReaderOpen(pVnode->pTsdb, sver, ever, &pReader->pTsdbReader);
|
|
||||||
if (code) goto _err;
|
|
||||||
|
|
||||||
*ppReader = pReader;
|
*ppReader = pReader;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
@ -60,54 +55,85 @@ _err:
|
||||||
int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
tFree(pReader->pData);
|
if (pReader->pTsdbReader) {
|
||||||
if (pReader->pTsdbReader) tsdbSnapReaderClose(&pReader->pTsdbReader);
|
tsdbSnapReaderClose(&pReader->pTsdbReader);
|
||||||
if (pReader->pMetaReader) metaSnapReaderClose(&pReader->pMetaReader);
|
}
|
||||||
taosMemoryFree(pReader);
|
|
||||||
|
|
||||||
|
if (pReader->pMetaReader) {
|
||||||
|
metaSnapReaderClose(&pReader->pMetaReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
vInfo("vgId:%d vnode snapshot reader closed", TD_VID(pReader->pVnode));
|
||||||
|
taosMemoryFree(pReader);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
// META ==============
|
||||||
if (!pReader->metaDone) {
|
if (!pReader->metaDone) {
|
||||||
code = metaSnapRead(pReader->pMetaReader, &pReader->pData);
|
// open reader if not
|
||||||
|
if (pReader->pMetaReader == NULL) {
|
||||||
|
code = metaSnapReaderOpen(pReader->pVnode->pMeta, pReader->sver, pReader->ever, &pReader->pMetaReader);
|
||||||
|
if (code) goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = metaSnapRead(pReader->pMetaReader, ppData);
|
||||||
if (code) {
|
if (code) {
|
||||||
if (code == TSDB_CODE_VND_READ_END) {
|
goto _err;
|
||||||
|
} else {
|
||||||
|
if (*ppData) {
|
||||||
|
goto _exit;
|
||||||
|
} else {
|
||||||
pReader->metaDone = 1;
|
pReader->metaDone = 1;
|
||||||
} else {
|
code = metaSnapReaderClose(&pReader->pMetaReader);
|
||||||
goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
*ppData = pReader->pData;
|
|
||||||
*nData = sizeof(SSnapDataHdr) + ((SSnapDataHdr *)pReader->pData)->size;
|
|
||||||
goto _exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TSDB ==============
|
||||||
if (!pReader->tsdbDone) {
|
if (!pReader->tsdbDone) {
|
||||||
code = tsdbSnapRead(pReader->pTsdbReader, &pReader->pData);
|
// open if not
|
||||||
|
if (pReader->pTsdbReader == NULL) {
|
||||||
|
code = tsdbSnapReaderOpen(pReader->pVnode->pTsdb, pReader->sver, pReader->ever, &pReader->pTsdbReader);
|
||||||
|
if (code) goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tsdbSnapRead(pReader->pTsdbReader, ppData);
|
||||||
if (code) {
|
if (code) {
|
||||||
if (code == TSDB_CODE_VND_READ_END) {
|
goto _err;
|
||||||
pReader->tsdbDone = 1;
|
|
||||||
} else {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
*ppData = pReader->pData;
|
if (*ppData) {
|
||||||
*nData = sizeof(SSnapDataHdr) + ((SSnapDataHdr *)pReader->pData)->size;
|
goto _exit;
|
||||||
goto _exit;
|
} else {
|
||||||
|
pReader->tsdbDone = 1;
|
||||||
|
code = tsdbSnapReaderClose(&pReader->pTsdbReader);
|
||||||
|
if (code) goto _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = TSDB_CODE_VND_READ_END;
|
*ppData = NULL;
|
||||||
|
*nData = 0;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
if (*ppData) {
|
||||||
|
SSnapDataHdr *pHdr = (SSnapDataHdr *)(*ppData);
|
||||||
|
|
||||||
|
pReader->index++;
|
||||||
|
*nData = sizeof(SSnapDataHdr) + pHdr->size;
|
||||||
|
pHdr->index = pReader->index;
|
||||||
|
vInfo("vgId:%d vnode snapshot read data,index:%" PRId64 " type:%d nData:%d ", TD_VID(pReader->pVnode),
|
||||||
|
pReader->index, pHdr->type, *nData);
|
||||||
|
} else {
|
||||||
|
vInfo("vgId:%d vnode snapshot read data end, index:%" PRId64, TD_VID(pReader->pVnode), pReader->index);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vError("vgId:% snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
vError("vgId:% vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,24 +142,13 @@ struct SVSnapWriter {
|
||||||
SVnode *pVnode;
|
SVnode *pVnode;
|
||||||
int64_t sver;
|
int64_t sver;
|
||||||
int64_t ever;
|
int64_t ever;
|
||||||
|
int64_t index;
|
||||||
// meta
|
// meta
|
||||||
SMetaSnapWriter *pMetaSnapWriter;
|
SMetaSnapWriter *pMetaSnapWriter;
|
||||||
// tsdb
|
// tsdb
|
||||||
STsdbSnapWriter *pTsdbSnapWriter;
|
STsdbSnapWriter *pTsdbSnapWriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t vnodeSnapRollback(SVSnapWriter *pWriter) {
|
|
||||||
int32_t code = 0;
|
|
||||||
// TODO
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t vnodeSnapCommit(SVSnapWriter *pWriter) {
|
|
||||||
int32_t code = 0;
|
|
||||||
// TODO
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter) {
|
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SVSnapWriter *pWriter = NULL;
|
SVSnapWriter *pWriter = NULL;
|
||||||
|
@ -148,62 +163,102 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
|
vInfo("vgId:%d vnode snapshot writer opened", TD_VID(pVnode));
|
||||||
|
*ppWriter = pWriter;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vError("vgId:%d vnode snapshot writer open failed since %s", TD_VID(pVnode), tstrerror(code));
|
vError("vgId:%d vnode snapshot writer open failed since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
|
*ppWriter = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback) {
|
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SVnode *pVnode = pWriter->pVnode;
|
||||||
|
|
||||||
if (rollback) {
|
if (pWriter->pMetaSnapWriter) {
|
||||||
code = vnodeSnapRollback(pWriter);
|
code = metaSnapWriterClose(&pWriter->pMetaSnapWriter, rollback);
|
||||||
if (code) goto _err;
|
|
||||||
} else {
|
|
||||||
code = vnodeSnapCommit(pWriter);
|
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pWriter->pTsdbSnapWriter) {
|
||||||
|
code = tsdbSnapWriterClose(&pWriter->pTsdbSnapWriter, rollback);
|
||||||
|
if (code) goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rollback) {
|
||||||
|
SVnodeInfo info = {0};
|
||||||
|
char dir[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
|
pVnode->state.committed = pWriter->ever;
|
||||||
|
pVnode->state.applied = pWriter->ever;
|
||||||
|
pVnode->state.applyTerm = pSnapshot->lastApplyTerm;
|
||||||
|
pVnode->state.commitTerm = pSnapshot->lastApplyTerm;
|
||||||
|
|
||||||
|
info.config = pVnode->config;
|
||||||
|
info.state.committed = pVnode->state.applied;
|
||||||
|
info.state.commitTerm = pVnode->state.applyTerm;
|
||||||
|
info.state.commitID = pVnode->state.commitID;
|
||||||
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||||
|
code = vnodeSaveInfo(dir, &info);
|
||||||
|
if (code) goto _err;
|
||||||
|
|
||||||
|
code = vnodeCommitInfo(dir, &info);
|
||||||
|
if (code) goto _err;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
vInfo("vgId:%d vnode snapshot writer closed, rollback:%d", TD_VID(pVnode), rollback);
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vError("vgId:%d vnode snapshow writer close failed since %s", TD_VID(pWriter->pVnode), tstrerror(code));
|
vError("vgId:%d vnode snapshot writer close failed since %s", TD_VID(pWriter->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSnapDataHdr *pSnapDataHdr = (SSnapDataHdr *)pData;
|
SSnapDataHdr *pHdr = (SSnapDataHdr *)pData;
|
||||||
SVnode *pVnode = pWriter->pVnode;
|
SVnode *pVnode = pWriter->pVnode;
|
||||||
|
|
||||||
ASSERT(pSnapDataHdr->size + sizeof(SSnapDataHdr) == nData);
|
ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData);
|
||||||
|
ASSERT(pHdr->index == pWriter->index + 1);
|
||||||
|
pWriter->index = pHdr->index;
|
||||||
|
|
||||||
if (pSnapDataHdr->type == 0) {
|
vInfo("vgId:%d vnode snapshot write data, index:%" PRId64 " type:%d nData:%d", TD_VID(pVnode), pHdr->index,
|
||||||
|
pHdr->type, nData);
|
||||||
|
|
||||||
|
if (pHdr->type == 0) {
|
||||||
// meta
|
// meta
|
||||||
|
|
||||||
if (pWriter->pMetaSnapWriter == NULL) {
|
if (pWriter->pMetaSnapWriter == NULL) {
|
||||||
code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter);
|
code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = metaSnapWrite(pWriter->pMetaSnapWriter, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
code = metaSnapWrite(pWriter->pMetaSnapWriter, pData, nData);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
} else {
|
} else {
|
||||||
// tsdb
|
// tsdb
|
||||||
|
|
||||||
if (pWriter->pTsdbSnapWriter == NULL) {
|
if (pWriter->pTsdbSnapWriter == NULL) {
|
||||||
code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter);
|
code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData, nData);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vError("vgId:%d vnode snapshot write failed since %s", TD_VID(pVnode), tstrerror(code));
|
vError("vgId:%d vnode snapshot write failed since %s, index:%" PRId64 " type:%d nData:%d", TD_VID(pVnode),
|
||||||
|
tstrerror(code), pHdr->index, pHdr->type, nData);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -422,8 +422,8 @@ static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *p
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(req.schemaRow.pSchema);
|
// taosMemoryFree(req.schemaRow.pSchema);
|
||||||
taosMemoryFree(req.schemaTag.pSchema);
|
// taosMemoryFree(req.schemaTag.pSchema);
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -689,6 +689,7 @@ _exit:
|
||||||
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
||||||
tEncodeSVDropTbBatchRsp(&encoder, &rsp);
|
tEncodeSVDropTbBatchRsp(&encoder, &rsp);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
taosArrayDestroy(rsp.pArray);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +901,7 @@ static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
vError("vgId:%d, failed to create tsma %s:%" PRIi64 " version %" PRIi64 "for table %" PRIi64 " since %s",
|
vError("vgId:%d, failed to create tsma %s:%" PRIi64 " version %" PRIi64 "for table %" PRIi64 " since %s",
|
||||||
TD_VID(pVnode), req.indexName, req.indexUid, version, req.tableUid, terrstr(terrno));
|
TD_VID(pVnode), req.indexName, req.indexUid, version, req.tableUid, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,10 +515,10 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) {
|
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply, SSnapshot *pSnapshot) {
|
||||||
#ifdef USE_TSDB_SNAPSHOT
|
#ifdef USE_TSDB_SNAPSHOT
|
||||||
SVnode *pVnode = pFsm->data;
|
SVnode *pVnode = pFsm->data;
|
||||||
int32_t code = vnodeSnapWriterClose(pWriter, !isApply);
|
int32_t code = vnodeSnapWriterClose(pWriter, !isApply, pSnapshot);
|
||||||
return code;
|
return code;
|
||||||
#else
|
#else
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
|
|
|
@ -163,7 +163,7 @@ int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
qDebug("QID:0x%" PRIx64 " the %d task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ int32_t ctgInitGetDnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
qDebug("QID:0x%" PRIx64 " the %d task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ int32_t ctgInitGetSvrVerTask(SCtgJob *pJob, int32_t taskIdx, void* param) {
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
qDebug("QID:0x%" PRIx64 " [%dth] task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ void ctgFreeHandle(SCatalog* pCtg) {
|
||||||
|
|
||||||
taosMemoryFree(pCtg);
|
taosMemoryFree(pCtg);
|
||||||
|
|
||||||
ctgInfo("handle freed, culsterId:0x%" PRIx64, clusterId);
|
ctgInfo("handle freed, clusterId:0x%" PRIx64, clusterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgClearHandle(SCatalog* pCtg) {
|
void ctgClearHandle(SCatalog* pCtg) {
|
||||||
|
@ -303,7 +303,7 @@ void ctgClearHandle(SCatalog* pCtg) {
|
||||||
|
|
||||||
CTG_CACHE_STAT_INC(numOfClear, 1);
|
CTG_CACHE_STAT_INC(numOfClear, 1);
|
||||||
|
|
||||||
ctgInfo("handle cleared, culsterId:0x%" PRIx64, clusterId);
|
ctgInfo("handle cleared, clusterId:0x%" PRIx64, clusterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) {
|
void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) {
|
||||||
|
|
|
@ -247,6 +247,16 @@ typedef struct SLoadRemoteDataInfo {
|
||||||
uint64_t totalElapsed; // total elapsed time
|
uint64_t totalElapsed; // total elapsed time
|
||||||
} SLoadRemoteDataInfo;
|
} SLoadRemoteDataInfo;
|
||||||
|
|
||||||
|
typedef struct SLimitInfo {
|
||||||
|
SLimit limit;
|
||||||
|
SLimit slimit;
|
||||||
|
uint64_t currentGroupId;
|
||||||
|
int64_t remainGroupOffset;
|
||||||
|
int64_t numOfOutputGroups;
|
||||||
|
int64_t remainOffset;
|
||||||
|
int64_t numOfOutputRows;
|
||||||
|
} SLimitInfo;
|
||||||
|
|
||||||
typedef struct SExchangeInfo {
|
typedef struct SExchangeInfo {
|
||||||
SArray* pSources;
|
SArray* pSources;
|
||||||
SArray* pSourceDataInfo;
|
SArray* pSourceDataInfo;
|
||||||
|
@ -257,6 +267,7 @@ typedef struct SExchangeInfo {
|
||||||
int32_t current;
|
int32_t current;
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
uint64_t self;
|
uint64_t self;
|
||||||
|
SLimitInfo limitInfo;
|
||||||
} SExchangeInfo;
|
} SExchangeInfo;
|
||||||
|
|
||||||
typedef struct SColMatchInfo {
|
typedef struct SColMatchInfo {
|
||||||
|
@ -542,15 +553,7 @@ typedef struct SProjectOperatorInfo {
|
||||||
SNode* pFilterNode; // filter info, which is push down by optimizer
|
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||||
SSDataBlock* existDataBlock;
|
SSDataBlock* existDataBlock;
|
||||||
SArray* pPseudoColInfo;
|
SArray* pPseudoColInfo;
|
||||||
SLimit limit;
|
SLimitInfo limitInfo;
|
||||||
SLimit slimit;
|
|
||||||
|
|
||||||
uint64_t groupId;
|
|
||||||
int64_t curSOffset;
|
|
||||||
int64_t curGroupOutput;
|
|
||||||
|
|
||||||
int64_t curOffset;
|
|
||||||
int64_t curOutput;
|
|
||||||
} SProjectOperatorInfo;
|
} SProjectOperatorInfo;
|
||||||
|
|
||||||
typedef struct SIndefOperatorInfo {
|
typedef struct SIndefOperatorInfo {
|
||||||
|
@ -791,6 +794,9 @@ int32_t initAggInfo(SExprSupp *pSup, SAggSupporter* pAggSup, SExprInfo* pExprInf
|
||||||
const char* pkey);
|
const char* pkey);
|
||||||
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
||||||
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf);
|
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf);
|
||||||
|
int32_t handleLimitOffset(SOperatorInfo *pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf);
|
||||||
|
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo);
|
||||||
|
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo);
|
||||||
|
|
||||||
void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset,
|
void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset,
|
||||||
int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order);
|
int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order);
|
||||||
|
@ -837,7 +843,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
|
|
||||||
SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortNode, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
|
@ -90,6 +90,7 @@ _return:
|
||||||
|
|
||||||
tsem_post(&pInserter->ready);
|
tsem_post(&pInserter->ready);
|
||||||
|
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(param);
|
taosMemoryFree(param);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -283,6 +284,8 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) {
|
||||||
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pInserter->cachedSize);
|
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pInserter->cachedSize);
|
||||||
taosArrayDestroy(pInserter->pDataBlocks);
|
taosArrayDestroy(pInserter->pDataBlocks);
|
||||||
taosMemoryFree(pInserter->pSchema);
|
taosMemoryFree(pInserter->pSchema);
|
||||||
|
taosMemoryFree(pInserter->pParam);
|
||||||
|
taosHashCleanup(pInserter->pCols);
|
||||||
taosThreadMutexDestroy(&pInserter->mutex);
|
taosThreadMutexDestroy(&pInserter->mutex);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,9 +115,6 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int
|
||||||
p->groupId = *(uint64_t*)key;
|
p->groupId = *(uint64_t*)key;
|
||||||
p->pos = *(SResultRowPosition*)pData;
|
p->pos = *(SResultRowPosition*)pData;
|
||||||
memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t));
|
memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t));
|
||||||
#ifdef BUF_PAGE_DEBUG
|
|
||||||
qDebug("page_groupRes, groupId:%" PRIu64 ",pageId:%d,offset:%d\n", p->groupId, p->pos.pageId, p->pos.offset);
|
|
||||||
#endif
|
|
||||||
taosArrayPush(pGroupResInfo->pRows, &p);
|
taosArrayPush(pGroupResInfo->pRows, &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,4 +898,23 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
|
||||||
}
|
}
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo) {
|
||||||
|
return (pLimitInfo->limit.limit != -1 || pLimitInfo->limit.offset != -1 || pLimitInfo->slimit.limit != -1 ||
|
||||||
|
pLimitInfo->slimit.offset != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int64_t getLimit(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; }
|
||||||
|
static int64_t getOffset(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; }
|
||||||
|
|
||||||
|
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo) {
|
||||||
|
SLimit limit = {.limit = getLimit(pLimit), .offset = getOffset(pLimit)};
|
||||||
|
SLimit slimit = {.limit = getLimit(pSLimit), .offset = getOffset(pSLimit)};
|
||||||
|
|
||||||
|
pLimitInfo->limit = limit;
|
||||||
|
pLimitInfo->slimit= slimit;
|
||||||
|
pLimitInfo->remainOffset = limit.offset;
|
||||||
|
pLimitInfo->remainGroupOffset = slimit.offset;
|
||||||
}
|
}
|
|
@ -43,6 +43,11 @@
|
||||||
|
|
||||||
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROJECT_RETRIEVE_CONTINUE = 0x1,
|
||||||
|
PROJECT_RETRIEVE_DONE = 0x2,
|
||||||
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
uint32_t v = taosRand();
|
uint32_t v = taosRand();
|
||||||
|
@ -624,7 +629,8 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
||||||
ASSERT(pResult->info.capacity > 0);
|
ASSERT(pResult->info.capacity > 0);
|
||||||
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
||||||
|
colDataDestroy(&idata);
|
||||||
|
|
||||||
numOfRows = dest.numOfRows;
|
numOfRows = dest.numOfRows;
|
||||||
taosArrayDestroy(pBlockList);
|
taosArrayDestroy(pBlockList);
|
||||||
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_FUNCTION) {
|
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_FUNCTION) {
|
||||||
|
@ -679,6 +685,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
||||||
ASSERT(pResult->info.capacity > 0);
|
ASSERT(pResult->info.capacity > 0);
|
||||||
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
||||||
|
colDataDestroy(&idata);
|
||||||
|
|
||||||
numOfRows = dest.numOfRows;
|
numOfRows = dest.numOfRows;
|
||||||
taosArrayDestroy(pBlockList);
|
taosArrayDestroy(pBlockList);
|
||||||
|
@ -1506,15 +1513,11 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI
|
||||||
int32_t numOfExprs) {
|
int32_t numOfExprs) {
|
||||||
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
||||||
int32_t start = pGroupResInfo->index;
|
int32_t start = pGroupResInfo->index;
|
||||||
#ifdef BUF_PAGE_DEBUG
|
|
||||||
qDebug("\npage_copytoblock rows:%d", numOfRows);
|
|
||||||
#endif
|
|
||||||
for (int32_t i = start; i < numOfRows; i += 1) {
|
for (int32_t i = start; i < numOfRows; i += 1) {
|
||||||
SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
|
SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
|
||||||
SFilePage* page = getBufPage(pBuf, pPos->pos.pageId);
|
SFilePage* page = getBufPage(pBuf, pPos->pos.pageId);
|
||||||
#ifdef BUF_PAGE_DEBUG
|
|
||||||
qDebug("page_copytoblock pos pageId:%d, offset:%d", pPos->pos.pageId, pPos->pos.offset);
|
|
||||||
#endif
|
|
||||||
SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset);
|
SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset);
|
||||||
|
|
||||||
doUpdateNumOfRows(pRow, numOfExprs, rowCellOffset);
|
doUpdateNumOfRows(pRow, numOfExprs, rowCellOffset);
|
||||||
|
@ -1980,6 +1983,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
qDebug("%s fetch rsp received, index:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfRows);
|
qDebug("%s fetch rsp received, index:%d, rows:%d", pSourceDataInfo->taskId, index, pRsp->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
pSourceDataInfo->code = code;
|
pSourceDataInfo->code = code;
|
||||||
|
qDebug("%s fetch rsp received, index:%d, error:%d", pSourceDataInfo->taskId, index, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
||||||
|
@ -2221,6 +2225,8 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
if (completed == totalSources) {
|
if (completed == totalSources) {
|
||||||
return setAllSourcesCompleted(pOperator, startTs);
|
return setAllSourcesCompleted(pOperator, startTs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sched_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
|
@ -2342,7 +2348,7 @@ static int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
@ -2368,6 +2374,44 @@ static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
SSDataBlock* pBlock = doLoadRemoteDataImpl(pOperator);
|
||||||
|
if (pBlock == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pBlock == pExchangeInfo->pResult);
|
||||||
|
|
||||||
|
SLimitInfo* pLimitInfo = &pExchangeInfo->limitInfo;
|
||||||
|
if (hasLimitOffsetInfo(pLimitInfo)) {
|
||||||
|
int32_t status = handleLimitOffset(pOperator, pLimitInfo, pExchangeInfo->pResult, false);
|
||||||
|
if (status == PROJECT_RETRIEVE_CONTINUE) {
|
||||||
|
continue;
|
||||||
|
} else if (status == PROJECT_RETRIEVE_DONE) {
|
||||||
|
size_t rows = pExchangeInfo->pResult->info.rows;
|
||||||
|
pExchangeInfo->limitInfo.numOfOutputRows += rows;
|
||||||
|
|
||||||
|
if (rows == 0) {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return pExchangeInfo->pResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return pExchangeInfo->pResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const char* id) {
|
static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo, const char* id) {
|
||||||
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
||||||
if (pInfo->pSourceDataInfo == NULL) {
|
if (pInfo->pSourceDataInfo == NULL) {
|
||||||
|
@ -2407,6 +2451,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
|
||||||
taosArrayPush(pInfo->pSources, pNode);
|
taosArrayPush(pInfo->pSources, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initLimitInfo(pExNode->node.pLimit, pExNode->node.pSlimit, &pInfo->limitInfo);
|
||||||
pInfo->self = taosAddRef(exchangeObjRefPool, pInfo);
|
pInfo->self = taosAddRef(exchangeObjRefPool, pInfo);
|
||||||
|
|
||||||
return initDataSource(numOfSources, pInfo, id);
|
return initDataSource(numOfSources, pInfo, id);
|
||||||
|
@ -3150,68 +3195,60 @@ int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result) {
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf) {
|
||||||
PROJECT_RETRIEVE_CONTINUE = 0x1,
|
if (pLimitInfo->remainGroupOffset > 0) {
|
||||||
PROJECT_RETRIEVE_DONE = 0x2,
|
if (pLimitInfo->currentGroupId == 0) { // it is the first group
|
||||||
};
|
pLimitInfo->currentGroupId = pBlock->info.groupId;
|
||||||
|
blockDataCleanup(pBlock);
|
||||||
static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|
||||||
SProjectOperatorInfo* pProjectInfo = pOperator->info;
|
|
||||||
SOptrBasicInfo* pInfo = &pProjectInfo->binfo;
|
|
||||||
SSDataBlock* pRes = pInfo->pRes;
|
|
||||||
|
|
||||||
if (pProjectInfo->curSOffset > 0) {
|
|
||||||
if (pProjectInfo->groupId == 0) { // it is the first group
|
|
||||||
pProjectInfo->groupId = pBlock->info.groupId;
|
|
||||||
blockDataCleanup(pInfo->pRes);
|
|
||||||
return PROJECT_RETRIEVE_CONTINUE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
} else if (pProjectInfo->groupId != pBlock->info.groupId) {
|
} else if (pLimitInfo->currentGroupId != pBlock->info.groupId) {
|
||||||
pProjectInfo->curSOffset -= 1;
|
// now it is the data from a new group
|
||||||
|
pLimitInfo->remainGroupOffset -= 1;
|
||||||
|
|
||||||
// ignore data block in current group
|
// ignore data block in current group
|
||||||
if (pProjectInfo->curSOffset > 0) {
|
if (pLimitInfo->remainGroupOffset > 0) {
|
||||||
blockDataCleanup(pInfo->pRes);
|
blockDataCleanup(pBlock);
|
||||||
return PROJECT_RETRIEVE_CONTINUE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set current group id of the project operator
|
// set current group id of the project operator
|
||||||
pProjectInfo->groupId = pBlock->info.groupId;
|
pLimitInfo->currentGroupId = pBlock->info.groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pProjectInfo->groupId != 0 && pProjectInfo->groupId != pBlock->info.groupId) {
|
if (pLimitInfo->currentGroupId != 0 && pLimitInfo->currentGroupId != pBlock->info.groupId) {
|
||||||
pProjectInfo->curGroupOutput += 1;
|
pLimitInfo->numOfOutputGroups += 1;
|
||||||
if ((pProjectInfo->slimit.limit > 0) && (pProjectInfo->slimit.limit <= pProjectInfo->curGroupOutput)) {
|
if ((pLimitInfo->slimit.limit > 0) && (pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
blockDataCleanup(pRes);
|
blockDataCleanup(pBlock);
|
||||||
|
|
||||||
return PROJECT_RETRIEVE_DONE;
|
return PROJECT_RETRIEVE_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the value for a new group data
|
// reset the value for a new group data
|
||||||
pProjectInfo->curOffset = 0;
|
pLimitInfo->numOfOutputRows = 0;
|
||||||
pProjectInfo->curOutput = 0;
|
pLimitInfo->remainOffset = pLimitInfo->limit.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// here we reach the start position, according to the limit/offset requirements.
|
// here we reach the start position, according to the limit/offset requirements.
|
||||||
|
|
||||||
// set current group id
|
// set current group id
|
||||||
pProjectInfo->groupId = pBlock->info.groupId;
|
pLimitInfo->currentGroupId = pBlock->info.groupId;
|
||||||
|
|
||||||
if (pProjectInfo->curOffset >= pRes->info.rows) {
|
if (pLimitInfo->remainOffset >= pBlock->info.rows) {
|
||||||
pProjectInfo->curOffset -= pRes->info.rows;
|
pLimitInfo->remainOffset -= pBlock->info.rows;
|
||||||
blockDataCleanup(pRes);
|
blockDataCleanup(pBlock);
|
||||||
return PROJECT_RETRIEVE_CONTINUE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
} else if (pProjectInfo->curOffset < pRes->info.rows && pProjectInfo->curOffset > 0) {
|
} else if (pLimitInfo->remainOffset < pBlock->info.rows && pLimitInfo->remainOffset > 0) {
|
||||||
blockDataTrimFirstNRows(pRes, pProjectInfo->curOffset);
|
blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset);
|
||||||
pProjectInfo->curOffset = 0;
|
pLimitInfo->remainOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for the limitation in each group
|
// check for the limitation in each group
|
||||||
if (pProjectInfo->limit.limit >= 0 && pProjectInfo->curOutput + pRes->info.rows >= pProjectInfo->limit.limit) {
|
if (pLimitInfo->limit.limit >= 0 && pLimitInfo->numOfOutputRows + pBlock->info.rows >= pLimitInfo->limit.limit) {
|
||||||
int32_t keepRows = (int32_t)(pProjectInfo->limit.limit - pProjectInfo->curOutput);
|
int32_t keepRows = (int32_t)(pLimitInfo->limit.limit - pLimitInfo->numOfOutputRows);
|
||||||
blockDataKeepFirstNRows(pRes, keepRows);
|
blockDataKeepFirstNRows(pBlock, keepRows);
|
||||||
if (pProjectInfo->slimit.limit > 0 && pProjectInfo->slimit.limit <= pProjectInfo->curGroupOutput) {
|
if (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3221,8 +3258,8 @@ static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock)
|
||||||
// todo optimize performance
|
// todo optimize performance
|
||||||
// If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the
|
// If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the
|
||||||
// they may not belong to the same group the limit/offset value is not valid in this case.
|
// they may not belong to the same group the limit/offset value is not valid in this case.
|
||||||
if (pRes->info.rows >= pOperator->resultInfo.threshold || pProjectInfo->slimit.offset != -1 ||
|
if ((!holdDataInBuf) || (pBlock->info.rows >= pOperator->resultInfo.threshold) || pLimitInfo->slimit.offset != -1 ||
|
||||||
pProjectInfo->slimit.limit != -1) {
|
pLimitInfo->slimit.limit != -1) {
|
||||||
return PROJECT_RETRIEVE_DONE;
|
return PROJECT_RETRIEVE_DONE;
|
||||||
} else { // not full enough, continue to accumulate the output data in the buffer.
|
} else { // not full enough, continue to accumulate the output data in the buffer.
|
||||||
return PROJECT_RETRIEVE_CONTINUE;
|
return PROJECT_RETRIEVE_CONTINUE;
|
||||||
|
@ -3308,7 +3345,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
longjmp(pTaskInfo->env, code);
|
longjmp(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t status = handleLimitOffset(pOperator, pBlock);
|
int32_t status = handleLimitOffset(pOperator, &pProjectInfo->limitInfo, pInfo->pRes, true);
|
||||||
|
|
||||||
// filter shall be applied after apply functions and limit/offset on the result
|
// filter shall be applied after apply functions and limit/offset on the result
|
||||||
doFilter(pProjectInfo->pFilterNode, pInfo->pRes);
|
doFilter(pProjectInfo->pFilterNode, pInfo->pRes);
|
||||||
|
@ -3320,9 +3357,9 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pProjectInfo->curOutput += pInfo->pRes->info.rows;
|
|
||||||
|
|
||||||
size_t rows = pInfo->pRes->info.rows;
|
size_t rows = pInfo->pRes->info.rows;
|
||||||
|
pProjectInfo->limitInfo.numOfOutputRows += rows;
|
||||||
|
|
||||||
pOperator->resultInfo.totalRows += rows;
|
pOperator->resultInfo.totalRows += rows;
|
||||||
|
|
||||||
if (pOperator->cost.openCost == 0) {
|
if (pOperator->cost.openCost == 0) {
|
||||||
|
@ -3747,7 +3784,7 @@ void doDestroyExchangeOperatorInfo(void* param) {
|
||||||
taosArrayDestroy(pExInfo->pSources);
|
taosArrayDestroy(pExInfo->pSources);
|
||||||
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
||||||
if (pExInfo->pResult != NULL) {
|
if (pExInfo->pResult != NULL) {
|
||||||
blockDataDestroy(pExInfo->pResult);
|
pExInfo->pResult = blockDataDestroy(pExInfo->pResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsem_destroy(&pExInfo->ready);
|
tsem_destroy(&pExInfo->ready);
|
||||||
|
@ -3766,10 +3803,6 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t getLimit(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; }
|
|
||||||
|
|
||||||
static int64_t getOffset(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; }
|
|
||||||
|
|
||||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode,
|
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SExecTaskInfo* pTaskInfo) {
|
||||||
SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo));
|
SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo));
|
||||||
|
@ -3782,13 +3815,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols);
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc);
|
||||||
SLimit limit = {.limit = getLimit(pProjPhyNode->node.pLimit), .offset = getOffset(pProjPhyNode->node.pLimit)};
|
initLimitInfo(pProjPhyNode->node.pLimit, pProjPhyNode->node.pSlimit, &pInfo->limitInfo);
|
||||||
SLimit slimit = {.limit = getLimit(pProjPhyNode->node.pSlimit), .offset = getOffset(pProjPhyNode->node.pSlimit)};
|
|
||||||
|
|
||||||
pInfo->limit = limit;
|
|
||||||
pInfo->slimit = slimit;
|
|
||||||
pInfo->curOffset = limit.offset;
|
|
||||||
pInfo->curSOffset = slimit.offset;
|
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
pInfo->pFilterNode = pProjPhyNode->node.pConditions;
|
pInfo->pFilterNode = pProjPhyNode->node.pConditions;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
static void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInfo** pGroupInfo, int32_t len);
|
static void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInfo** pGroupInfo, int32_t len);
|
||||||
static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity);
|
static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity);
|
||||||
static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
|
static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
|
||||||
int32_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup);
|
uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup);
|
||||||
|
|
||||||
static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) {
|
static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*)param;
|
SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*)param;
|
||||||
|
@ -264,7 +264,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
||||||
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len, 0, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len, pBlock->info.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
||||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len,
|
setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len,
|
||||||
0, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
pBlock->info.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,29 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* buildGroupResultDataBlock(SOperatorInfo* pOperator) {
|
||||||
|
SGroupbyOperatorInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
|
SSDataBlock* pRes = pInfo->binfo.pRes;
|
||||||
|
while(1) {
|
||||||
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
|
doFilter(pInfo->pCondition, pRes);
|
||||||
|
|
||||||
|
bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo);
|
||||||
|
if (!hasRemain) {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pRes->info.rows > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pOperator->resultInfo.totalRows += pRes->info.rows;
|
||||||
|
return (pRes->info.rows == 0)? NULL:pRes;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -304,22 +327,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pRes = pInfo->binfo.pRes;
|
SSDataBlock* pRes = pInfo->binfo.pRes;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
while(1) {
|
return buildGroupResultDataBlock(pOperator);
|
||||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
|
||||||
doFilter(pInfo->pCondition, pRes);
|
|
||||||
|
|
||||||
bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo);
|
|
||||||
if (!hasRemain) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pRes->info.rows > 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pOperator->resultInfo.totalRows += pRes->info.rows;
|
|
||||||
return (pRes->info.rows == 0)? NULL:pRes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
|
@ -373,26 +381,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, 0);
|
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, 0);
|
||||||
|
|
||||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
return buildGroupResultDataBlock(pOperator);
|
||||||
while(1) {
|
|
||||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
|
||||||
doFilter(pInfo->pCondition, pRes);
|
|
||||||
|
|
||||||
bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo);
|
|
||||||
if (!hasRemain) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pRes->info.rows > 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t rows = pRes->info.rows;
|
|
||||||
pOperator->resultInfo.totalRows += rows;
|
|
||||||
|
|
||||||
return (rows == 0)? NULL:pRes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
|
@ -451,19 +440,19 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j);
|
recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j);
|
||||||
int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
|
||||||
|
|
||||||
SDataGroupInfo* pGInfo = NULL;
|
SDataGroupInfo* pGroupInfo = NULL;
|
||||||
void *pPage = getCurrentDataGroupInfo(pInfo, &pGInfo, len);
|
void *pPage = getCurrentDataGroupInfo(pInfo, &pGroupInfo, len);
|
||||||
|
|
||||||
pGInfo->numOfRows += 1;
|
pGroupInfo->numOfRows += 1;
|
||||||
if (pGInfo->groupId == 0) {
|
|
||||||
pGInfo->groupId = calcGroupId(pInfo->keyBuf, len);
|
// group id
|
||||||
|
if (pGroupInfo->groupId == 0) {
|
||||||
|
pGroupInfo->groupId = calcGroupId(pInfo->keyBuf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// number of rows
|
// number of rows
|
||||||
int32_t* rows = (int32_t*) pPage;
|
int32_t* rows = (int32_t*) pPage;
|
||||||
|
|
||||||
// group id
|
|
||||||
|
|
||||||
size_t numOfCols = pOperator->exprSupp.numOfExprs;
|
size_t numOfCols = pOperator->exprSupp.numOfExprs;
|
||||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SExprInfo* pExpr = &pOperator->exprSupp.pExprInfo[i];
|
SExprInfo* pExpr = &pOperator->exprSupp.pExprInfo[i];
|
||||||
|
@ -614,7 +603,13 @@ static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
|
||||||
static int compareDataGroupInfo(const void* group1, const void* group2) {
|
static int compareDataGroupInfo(const void* group1, const void* group2) {
|
||||||
const SDataGroupInfo* pGroupInfo1 = group1;
|
const SDataGroupInfo* pGroupInfo1 = group1;
|
||||||
const SDataGroupInfo* pGroupInfo2 = group2;
|
const SDataGroupInfo* pGroupInfo2 = group2;
|
||||||
return pGroupInfo1->groupId - pGroupInfo2->groupId;
|
|
||||||
|
if (pGroupInfo1->groupId == pGroupInfo2->groupId) {
|
||||||
|
ASSERT(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (pGroupInfo1->groupId < pGroupInfo2->groupId)? -1:1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
|
@ -800,7 +795,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
|
int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
|
||||||
int32_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup) {
|
uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SResultRowInfo* pResultRowInfo = &binfo->resultRowInfo;
|
SResultRowInfo* pResultRowInfo = &binfo->resultRowInfo;
|
||||||
SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx;
|
SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx;
|
||||||
|
|
|
@ -1143,7 +1143,7 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
|
||||||
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[rowId], &pInfo->interval, TSDB_ORDER_ASC);
|
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[rowId], &pInfo->interval, TSDB_ORDER_ASC);
|
||||||
// must check update info first.
|
// must check update info first.
|
||||||
bool update = updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, tsCol[rowId]);
|
bool update = updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, tsCol[rowId]);
|
||||||
if ( (update || (isSignleIntervalWindow(pInfo) && isCloseWindow(&win, &pInfo->twAggSup)) ) && out) {
|
if ((update || (isSignleIntervalWindow(pInfo) && isCloseWindow(&win, &pInfo->twAggSup))) && out) {
|
||||||
taosArrayPush(pInfo->tsArray, &rowId);
|
taosArrayPush(pInfo->tsArray, &rowId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1596,7 +1596,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
pInfo->pUpdateRes = createResDataBlock(pDescNode);
|
pInfo->pUpdateRes = createResDataBlock(pDescNode);
|
||||||
pInfo->pCondition = pScanPhyNode->node.pConditions;
|
pInfo->pCondition = pScanPhyNode->node.pConditions;
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||||
pInfo->sessionSup = (SessionWindowSupporter){.pStreamAggSup = NULL, .gap = -1, .parentType = QUERY_NODE_PHYSICAL_PLAN};
|
pInfo->sessionSup =
|
||||||
|
(SessionWindowSupporter){.pStreamAggSup = NULL, .gap = -1, .parentType = QUERY_NODE_PHYSICAL_PLAN};
|
||||||
pInfo->groupId = 0;
|
pInfo->groupId = 0;
|
||||||
pInfo->pPullDataRes = createPullDataBlock();
|
pInfo->pPullDataRes = createPullDataBlock();
|
||||||
pInfo->pStreamScanOp = pOperator;
|
pInfo->pStreamScanOp = pOperator;
|
||||||
|
@ -1630,7 +1631,8 @@ static void destroySysScanOperator(void* param, int32_t numOfOutput) {
|
||||||
blockDataDestroy(pInfo->pRes);
|
blockDataDestroy(pInfo->pRes);
|
||||||
|
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0 || pInfo->pCur != NULL) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0 ||
|
||||||
|
strncasecmp(name, TSDB_INS_TABLE_USER_TAGS, TSDB_TABLE_FNAME_LEN) == 0 || pInfo->pCur != NULL) {
|
||||||
metaCloseTbCursor(pInfo->pCur);
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
pInfo->pCur = NULL;
|
pInfo->pCur = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1777,14 +1779,14 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
|
||||||
return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes;
|
return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* buildSysTableMetaBlock() {
|
static SSDataBlock* buildInfoSchemaTableMetaBlock(char* tableName) {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
const SSysTableMeta* pMeta = NULL;
|
const SSysTableMeta* pMeta = NULL;
|
||||||
getInfosDbMeta(&pMeta, &size);
|
getInfosDbMeta(&pMeta, &size);
|
||||||
|
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
if (strcmp(pMeta[i].name, TSDB_INS_TABLE_USER_TABLES) == 0) {
|
if (strcmp(pMeta[i].name, tableName) == 0) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1800,185 +1802,340 @@ static SSDataBlock* buildSysTableMetaBlock() {
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pInfo->pCur == NULL) {
|
||||||
|
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
|
const char* db = NULL;
|
||||||
|
int32_t vgId = 0;
|
||||||
|
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||||
|
|
||||||
|
SName sn = {0};
|
||||||
|
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||||
|
|
||||||
|
tNameGetDbName(&sn, varDataVal(dbname));
|
||||||
|
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||||
|
|
||||||
|
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_USER_TAGS);
|
||||||
|
blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
|
int32_t ret = 0;
|
||||||
|
while ((ret = metaTbCursorNext(pInfo->pCur)) == 0) {
|
||||||
|
if (pInfo->pCur->mr.me.type != TSDB_CHILD_TABLE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name);
|
||||||
|
|
||||||
|
SMetaReader smr = {0};
|
||||||
|
metaReaderInit(&smr, pInfo->readHandle.meta, 0);
|
||||||
|
|
||||||
|
uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid;
|
||||||
|
int32_t code = metaGetTableEntryByUid(&smr, suid);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("failed to get super table meta, uid:0x%" PRIx64 ", code:%s, %s", suid, tstrerror(terrno),
|
||||||
|
GET_TASKID(pTaskInfo));
|
||||||
|
metaReaderClear(&smr);
|
||||||
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
longjmp(pTaskInfo->env, terrno);
|
||||||
|
}
|
||||||
|
|
||||||
|
char stableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(stableName, smr.me.name);
|
||||||
|
|
||||||
|
int32_t numOfTags = smr.me.stbEntry.schemaTag.nCols;
|
||||||
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
|
SColumnInfoData* pColInfoData = NULL;
|
||||||
|
|
||||||
|
// table name
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, tableName, false);
|
||||||
|
|
||||||
|
// database name
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 1);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, dbname, false);
|
||||||
|
|
||||||
|
// super table name
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, stableName, false);
|
||||||
|
|
||||||
|
char tagName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(tagName, smr.me.stbEntry.schemaTag.pSchema[i].name);
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, tagName, false);
|
||||||
|
|
||||||
|
int8_t tagType = smr.me.stbEntry.schemaTag.pSchema[i].type;
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&tagType, false);
|
||||||
|
|
||||||
|
STagVal tagVal = {0};
|
||||||
|
tagVal.cid = smr.me.stbEntry.schemaTag.pSchema[i].colId;
|
||||||
|
char* tagData = NULL;
|
||||||
|
uint32_t tagLen = 0;
|
||||||
|
|
||||||
|
if (tagType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
tagData = (char*)pInfo->pCur->mr.me.ctbEntry.pTags;
|
||||||
|
} else {
|
||||||
|
bool exist = tTagGet((STag*)pInfo->pCur->mr.me.ctbEntry.pTags, &tagVal);
|
||||||
|
if (exist) {
|
||||||
|
if (IS_VAR_DATA_TYPE(tagType)) {
|
||||||
|
tagData = (char*)tagVal.pData;
|
||||||
|
tagLen = tagVal.nData;
|
||||||
|
} else {
|
||||||
|
tagData = (char*)&tagVal.i64;
|
||||||
|
tagLen = tDataTypes[tagType].bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char* tagVarChar = NULL;
|
||||||
|
if (tagData != NULL) {
|
||||||
|
if (tagType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
char* tagJson = parseTagDatatoJson(tagData);
|
||||||
|
tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE);
|
||||||
|
memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson));
|
||||||
|
varDataSetLen(tagVarChar, strlen(tagJson));
|
||||||
|
taosMemoryFree(tagJson);
|
||||||
|
} else {
|
||||||
|
int32_t bufSize = IS_VAR_DATA_TYPE(tagType) ? (tagLen + VARSTR_HEADER_SIZE)
|
||||||
|
: (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE);
|
||||||
|
tagVarChar = taosMemoryMalloc(bufSize);
|
||||||
|
int32_t len = -1;
|
||||||
|
dataConverToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
|
||||||
|
varDataSetLen(tagVarChar, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, tagVarChar,
|
||||||
|
(tagData == NULL) || (tagType == TSDB_DATA_TYPE_JSON && tTagIsJsonNull(tagData)));
|
||||||
|
taosMemoryFree(tagVarChar);
|
||||||
|
++numOfRows;
|
||||||
|
}
|
||||||
|
metaReaderClear(&smr);
|
||||||
|
|
||||||
|
if (numOfRows >= pOperator->resultInfo.capacity) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo temporarily free the cursor here, the true reason why the free is not valid needs to be found
|
||||||
|
if (ret != 0) {
|
||||||
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
}
|
||||||
|
|
||||||
|
p->info.rows = numOfRows;
|
||||||
|
pInfo->pRes->info.rows = numOfRows;
|
||||||
|
|
||||||
|
relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false);
|
||||||
|
doFilterResult(pInfo);
|
||||||
|
|
||||||
|
blockDataDestroy(p);
|
||||||
|
|
||||||
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
|
||||||
|
if (pInfo->readHandle.mnd != NULL) {
|
||||||
|
buildSysDbTableInfo(pInfo, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
|
doFilterResult(pInfo);
|
||||||
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
} else {
|
||||||
|
if (pInfo->pCur == NULL) {
|
||||||
|
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
|
const char* db = NULL;
|
||||||
|
int32_t vgId = 0;
|
||||||
|
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||||
|
|
||||||
|
SName sn = {0};
|
||||||
|
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||||
|
|
||||||
|
tNameGetDbName(&sn, varDataVal(dbname));
|
||||||
|
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||||
|
|
||||||
|
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_USER_TABLES);
|
||||||
|
blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
|
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
|
||||||
|
int32_t ret = 0;
|
||||||
|
while ((ret = metaTbCursorNext(pInfo->pCur)) == 0) {
|
||||||
|
STR_TO_VARSTR(n, pInfo->pCur->mr.me.name);
|
||||||
|
|
||||||
|
// table name
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||||
|
|
||||||
|
// database name
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 1);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, dbname, false);
|
||||||
|
|
||||||
|
// vgId
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 6);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&vgId, false);
|
||||||
|
|
||||||
|
int32_t tableType = pInfo->pCur->mr.me.type;
|
||||||
|
if (tableType == TSDB_CHILD_TABLE) {
|
||||||
|
// create time
|
||||||
|
int64_t ts = pInfo->pCur->mr.me.ctbEntry.ctime;
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&ts, false);
|
||||||
|
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
||||||
|
|
||||||
|
uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid;
|
||||||
|
int32_t code = metaGetTableEntryByUid(&mr, suid);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
qError("failed to get super table meta, uid:0x%" PRIx64 ", code:%s, %s", suid, tstrerror(terrno),
|
||||||
|
GET_TASKID(pTaskInfo));
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
longjmp(pTaskInfo->env, terrno);
|
||||||
|
}
|
||||||
|
|
||||||
|
// number of columns
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&mr.me.stbEntry.schemaRow.nCols, false);
|
||||||
|
|
||||||
|
// super table name
|
||||||
|
STR_TO_VARSTR(n, mr.me.name);
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
|
// table comment
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 8);
|
||||||
|
if (pInfo->pCur->mr.me.ctbEntry.commentLen > 0) {
|
||||||
|
char comment[TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(comment, pInfo->pCur->mr.me.ctbEntry.comment);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, comment, false);
|
||||||
|
} else if (pInfo->pCur->mr.me.ctbEntry.commentLen == 0) {
|
||||||
|
char comment[VARSTR_HEADER_SIZE + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(comment, "");
|
||||||
|
colDataAppend(pColInfoData, numOfRows, comment, false);
|
||||||
|
} else {
|
||||||
|
colDataAppendNULL(pColInfoData, numOfRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
// uid
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.uid, false);
|
||||||
|
|
||||||
|
// ttl
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 7);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ctbEntry.ttlDays, false);
|
||||||
|
|
||||||
|
STR_TO_VARSTR(n, "CHILD_TABLE");
|
||||||
|
} else if (tableType == TSDB_NORMAL_TABLE) {
|
||||||
|
// create time
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.ctime, false);
|
||||||
|
|
||||||
|
// number of columns
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.schemaRow.nCols, false);
|
||||||
|
|
||||||
|
// super table name
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
||||||
|
colDataAppendNULL(pColInfoData, numOfRows);
|
||||||
|
|
||||||
|
// table comment
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 8);
|
||||||
|
if (pInfo->pCur->mr.me.ntbEntry.commentLen > 0) {
|
||||||
|
char comment[TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(comment, pInfo->pCur->mr.me.ntbEntry.comment);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, comment, false);
|
||||||
|
} else if (pInfo->pCur->mr.me.ntbEntry.commentLen == 0) {
|
||||||
|
char comment[VARSTR_HEADER_SIZE + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(comment, "");
|
||||||
|
colDataAppend(pColInfoData, numOfRows, comment, false);
|
||||||
|
} else {
|
||||||
|
colDataAppendNULL(pColInfoData, numOfRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
// uid
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.uid, false);
|
||||||
|
|
||||||
|
// ttl
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 7);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.ttlDays, false);
|
||||||
|
|
||||||
|
STR_TO_VARSTR(n, "NORMAL_TABLE");
|
||||||
|
}
|
||||||
|
|
||||||
|
pColInfoData = taosArrayGet(p->pDataBlock, 9);
|
||||||
|
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||||
|
|
||||||
|
if (++numOfRows >= pOperator->resultInfo.capacity) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo temporarily free the cursor here, the true reason why the free is not valid needs to be found
|
||||||
|
if (ret != 0) {
|
||||||
|
metaCloseTbCursor(pInfo->pCur);
|
||||||
|
pInfo->pCur = NULL;
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
|
}
|
||||||
|
|
||||||
|
p->info.rows = numOfRows;
|
||||||
|
pInfo->pRes->info.rows = numOfRows;
|
||||||
|
|
||||||
|
relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false);
|
||||||
|
doFilterResult(pInfo);
|
||||||
|
|
||||||
|
blockDataDestroy(p);
|
||||||
|
|
||||||
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
// build message and send to mnode to fetch the content of system tables.
|
// build message and send to mnode to fetch the content of system tables.
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SSysTableScanInfo* pInfo = pOperator->info;
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
// retrieve local table list info from vnode
|
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
return sysTableScanUserTables(pOperator);
|
||||||
return NULL;
|
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TAGS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
}
|
return sysTableScanUserTags(pOperator);
|
||||||
|
|
||||||
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
|
|
||||||
if (pInfo->readHandle.mnd != NULL) {
|
|
||||||
buildSysDbTableInfo(pInfo, pOperator->resultInfo.capacity);
|
|
||||||
|
|
||||||
doFilterResult(pInfo);
|
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
|
||||||
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
|
||||||
} else {
|
|
||||||
if (pInfo->pCur == NULL) {
|
|
||||||
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
blockDataCleanup(pInfo->pRes);
|
|
||||||
int32_t numOfRows = 0;
|
|
||||||
|
|
||||||
const char* db = NULL;
|
|
||||||
int32_t vgId = 0;
|
|
||||||
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
|
||||||
|
|
||||||
SName sn = {0};
|
|
||||||
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
|
||||||
|
|
||||||
tNameGetDbName(&sn, varDataVal(dbname));
|
|
||||||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
|
||||||
|
|
||||||
SSDataBlock* p = buildSysTableMetaBlock();
|
|
||||||
blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
|
||||||
|
|
||||||
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
|
|
||||||
int32_t ret = 0;
|
|
||||||
while ((ret = metaTbCursorNext(pInfo->pCur)) == 0) {
|
|
||||||
STR_TO_VARSTR(n, pInfo->pCur->mr.me.name);
|
|
||||||
|
|
||||||
// table name
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
|
||||||
|
|
||||||
// database name
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 1);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, dbname, false);
|
|
||||||
|
|
||||||
// vgId
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 6);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&vgId, false);
|
|
||||||
|
|
||||||
int32_t tableType = pInfo->pCur->mr.me.type;
|
|
||||||
if (tableType == TSDB_CHILD_TABLE) {
|
|
||||||
// create time
|
|
||||||
int64_t ts = pInfo->pCur->mr.me.ctbEntry.ctime;
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&ts, false);
|
|
||||||
|
|
||||||
SMetaReader mr = {0};
|
|
||||||
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
|
||||||
|
|
||||||
uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid;
|
|
||||||
int32_t code = metaGetTableEntryByUid(&mr, suid);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
qError("failed to get super table meta, uid:0x%" PRIx64 ", code:%s, %s", suid, tstrerror(terrno),
|
|
||||||
GET_TASKID(pTaskInfo));
|
|
||||||
metaReaderClear(&mr);
|
|
||||||
metaCloseTbCursor(pInfo->pCur);
|
|
||||||
pInfo->pCur = NULL;
|
|
||||||
longjmp(pTaskInfo->env, terrno);
|
|
||||||
}
|
|
||||||
|
|
||||||
// number of columns
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&mr.me.stbEntry.schemaRow.nCols, false);
|
|
||||||
|
|
||||||
// super table name
|
|
||||||
STR_TO_VARSTR(n, mr.me.name);
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
|
||||||
metaReaderClear(&mr);
|
|
||||||
|
|
||||||
// table comment
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 8);
|
|
||||||
if (pInfo->pCur->mr.me.ctbEntry.commentLen > 0) {
|
|
||||||
char comment[TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_TO_VARSTR(comment, pInfo->pCur->mr.me.ctbEntry.comment);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, comment, false);
|
|
||||||
} else if (pInfo->pCur->mr.me.ctbEntry.commentLen == 0) {
|
|
||||||
char comment[VARSTR_HEADER_SIZE + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_TO_VARSTR(comment, "");
|
|
||||||
colDataAppend(pColInfoData, numOfRows, comment, false);
|
|
||||||
} else {
|
|
||||||
colDataAppendNULL(pColInfoData, numOfRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
// uid
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.uid, false);
|
|
||||||
|
|
||||||
// ttl
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 7);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ctbEntry.ttlDays, false);
|
|
||||||
|
|
||||||
STR_TO_VARSTR(n, "CHILD_TABLE");
|
|
||||||
} else if (tableType == TSDB_NORMAL_TABLE) {
|
|
||||||
// create time
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.ctime, false);
|
|
||||||
|
|
||||||
// number of columns
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.schemaRow.nCols, false);
|
|
||||||
|
|
||||||
// super table name
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
|
||||||
colDataAppendNULL(pColInfoData, numOfRows);
|
|
||||||
|
|
||||||
// table comment
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 8);
|
|
||||||
if (pInfo->pCur->mr.me.ntbEntry.commentLen > 0) {
|
|
||||||
char comment[TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_TO_VARSTR(comment, pInfo->pCur->mr.me.ntbEntry.comment);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, comment, false);
|
|
||||||
} else if (pInfo->pCur->mr.me.ntbEntry.commentLen == 0) {
|
|
||||||
char comment[VARSTR_HEADER_SIZE + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_TO_VARSTR(comment, "");
|
|
||||||
colDataAppend(pColInfoData, numOfRows, comment, false);
|
|
||||||
} else {
|
|
||||||
colDataAppendNULL(pColInfoData, numOfRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
// uid
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.uid, false);
|
|
||||||
|
|
||||||
// ttl
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 7);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.ttlDays, false);
|
|
||||||
|
|
||||||
STR_TO_VARSTR(n, "NORMAL_TABLE");
|
|
||||||
}
|
|
||||||
|
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 9);
|
|
||||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
|
||||||
|
|
||||||
if (++numOfRows >= pOperator->resultInfo.capacity) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo temporarily free the cursor here, the true reason why the free is not valid needs to be found
|
|
||||||
if (ret != 0) {
|
|
||||||
metaCloseTbCursor(pInfo->pCur);
|
|
||||||
pInfo->pCur = NULL;
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
}
|
|
||||||
|
|
||||||
p->info.rows = numOfRows;
|
|
||||||
pInfo->pRes->info.rows = numOfRows;
|
|
||||||
|
|
||||||
relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false);
|
|
||||||
doFilterResult(pInfo);
|
|
||||||
|
|
||||||
blockDataDestroy(p);
|
|
||||||
|
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
|
||||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
|
||||||
}
|
|
||||||
} else { // load the meta from mnode of the given epset
|
} else { // load the meta from mnode of the given epset
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2058,7 +2215,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
||||||
SSDataBlock* p = buildSysTableMetaBlock();
|
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_USER_TABLES);
|
||||||
blockDataEnsureCapacity(p, capacity);
|
blockDataEnsureCapacity(p, capacity);
|
||||||
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -2147,7 +2304,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
||||||
tNameAssign(&pInfo->name, &pScanNode->tableName);
|
tNameAssign(&pInfo->name, &pScanNode->tableName);
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
|
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0 ||
|
||||||
|
strncasecmp(name, TSDB_INS_TABLE_USER_TAGS, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
pInfo->readHandle = *(SReadHandle*)readHandle;
|
pInfo->readHandle = *(SReadHandle*)readHandle;
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2941,4 +3099,3 @@ _error:
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,31 +22,31 @@ static int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain
|
||||||
|
|
||||||
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
|
static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
||||||
SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode,
|
// todo add limit/offset impl
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortNode, SExecTaskInfo* pTaskInfo) {
|
||||||
SSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortOperatorInfo));
|
SSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) {
|
if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pSortPhyNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pSortNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pSortNode->pExprs, NULL, &numOfCols);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* pColMatchColInfo =
|
SArray* pColMatchColInfo =
|
||||||
extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||||
|
|
||||||
pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset);
|
pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset);
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
|
|
||||||
initResultSizeInfo(pOperator, 1024);
|
initResultSizeInfo(pOperator, 1024);
|
||||||
|
|
||||||
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
|
pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys);
|
||||||
pInfo->pCondition = pSortPhyNode->node.pConditions;
|
pInfo->pCondition = pSortNode->node.pConditions;
|
||||||
pInfo->pColMatchInfo = pColMatchColInfo;
|
pInfo->pColMatchInfo = pColMatchColInfo;
|
||||||
pOperator->name = "SortOperator";
|
pOperator->name = "SortOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
|
||||||
|
@ -234,9 +234,9 @@ void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
SSortOperatorInfo* pInfo = (SSortOperatorInfo*)param;
|
SSortOperatorInfo* pInfo = (SSortOperatorInfo*)param;
|
||||||
pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes);
|
pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes);
|
||||||
|
|
||||||
|
tsortDestroySortHandle(pInfo->pSortHandle);
|
||||||
taosArrayDestroy(pInfo->pSortInfo);
|
taosArrayDestroy(pInfo->pSortInfo);
|
||||||
taosArrayDestroy(pInfo->pColMatchInfo);
|
taosArrayDestroy(pInfo->pColMatchInfo);
|
||||||
|
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,14 +539,12 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->startTs = taosGetTimestampUs();
|
pInfo->startTs = taosGetTimestampUs();
|
||||||
|
|
||||||
int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize;
|
int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize;
|
||||||
|
|
||||||
pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage,
|
pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage,
|
||||||
pInfo->pInputBlock, pTaskInfo->id.str);
|
pInfo->pInputBlock, pTaskInfo->id.str);
|
||||||
|
|
||||||
tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL);
|
tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL);
|
||||||
|
|
||||||
tsortSetCompareGroupId(pInfo->pSortHandle, pInfo->groupSort);
|
tsortSetCompareGroupId(pInfo->pSortHandle, pInfo->groupSort);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
|
for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
|
||||||
|
@ -556,7 +554,6 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = tsortOpen(pInfo->pSortHandle);
|
int32_t code = tsortOpen(pInfo->pSortHandle);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
longjmp(pTaskInfo->env, terrno);
|
longjmp(pTaskInfo->env, terrno);
|
||||||
}
|
}
|
||||||
|
@ -674,6 +671,7 @@ void destroyMultiwayMergeOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes);
|
pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes);
|
||||||
pInfo->pInputBlock = blockDataDestroy(pInfo->pInputBlock);
|
pInfo->pInputBlock = blockDataDestroy(pInfo->pInputBlock);
|
||||||
|
|
||||||
|
tsortDestroySortHandle(pInfo->pSortHandle);
|
||||||
taosArrayDestroy(pInfo->pSortInfo);
|
taosArrayDestroy(pInfo->pSortInfo);
|
||||||
taosArrayDestroy(pInfo->pColMatchInfo);
|
taosArrayDestroy(pInfo->pColMatchInfo);
|
||||||
|
|
||||||
|
|
|
@ -1353,13 +1353,13 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup,
|
||||||
if (chIds && pPullDataMap) {
|
if (chIds && pPullDataMap) {
|
||||||
SArray* chAy = *(SArray**)chIds;
|
SArray* chAy = *(SArray**)chIds;
|
||||||
int32_t size = taosArrayGetSize(chAy);
|
int32_t size = taosArrayGetSize(chAy);
|
||||||
qDebug("window %" PRId64 " wait child size:%d", win.skey, size);
|
qDebug("===stream===window %" PRId64 " wait child size:%d", win.skey, size);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
qDebug("window %" PRId64 " wait child id:%d", win.skey, *(int32_t*)taosArrayGet(chAy, i));
|
qDebug("===stream===window %" PRId64 " wait child id:%d", win.skey, *(int32_t*)taosArrayGet(chAy, i));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (pPullDataMap) {
|
} else if (pPullDataMap) {
|
||||||
qDebug("close window %" PRId64, win.skey);
|
qDebug("===stream===close window %" PRId64, win.skey);
|
||||||
}
|
}
|
||||||
SResultRowPosition* pPos = (SResultRowPosition*)pIte;
|
SResultRowPosition* pPos = (SResultRowPosition*)pIte;
|
||||||
if (pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
if (pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
@ -2482,7 +2482,9 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
|
||||||
SPullWindowInfo pull = {.window = nextWin, .groupId = tableGroupId};
|
SPullWindowInfo pull = {.window = nextWin, .groupId = tableGroupId};
|
||||||
// add pull data request
|
// add pull data request
|
||||||
taosArrayPush(pInfo->pPullWins, &pull);
|
taosArrayPush(pInfo->pPullWins, &pull);
|
||||||
addPullWindow(pInfo->pPullDataMap, &winRes, taosArrayGetSize(pInfo->pChildren));
|
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
||||||
|
addPullWindow(pInfo->pPullDataMap, &winRes, size);
|
||||||
|
qDebug("===stream===prepare retrive %" PRId64 ", size:%d", winRes.ts, size);
|
||||||
} else {
|
} else {
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
SArray* chArray = NULL;
|
SArray* chArray = NULL;
|
||||||
|
@ -2492,14 +2494,14 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
|
||||||
chId = getChildIndex(pSDataBlock);
|
chId = getChildIndex(pSDataBlock);
|
||||||
index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ);
|
index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ);
|
||||||
}
|
}
|
||||||
if (index != -1 && pSDataBlock->info.type == STREAM_PULL_DATA) {
|
// if (index != -1 && pSDataBlock->info.type == STREAM_PULL_DATA) {
|
||||||
qDebug("======delete child id %d", chId);
|
// qDebug("===stream===delete child id %d", chId);
|
||||||
taosArrayRemove(chArray, index);
|
// taosArrayRemove(chArray, index);
|
||||||
if (taosArrayGetSize(chArray) == 0) {
|
// if (taosArrayGetSize(chArray) == 0) {
|
||||||
// pull data is over
|
// // pull data is over
|
||||||
taosHashRemove(pInfo->pPullDataMap, &winRes, sizeof(SWinRes));
|
// taosHashRemove(pInfo->pPullDataMap, &winRes, sizeof(SWinRes));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (index == -1 || pSDataBlock->info.type == STREAM_PULL_DATA) {
|
if (index == -1 || pSDataBlock->info.type == STREAM_PULL_DATA) {
|
||||||
ignore = false;
|
ignore = false;
|
||||||
}
|
}
|
||||||
|
@ -2623,6 +2625,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) {
|
||||||
SArray* chArray = *(SArray**)chIds;
|
SArray* chArray = *(SArray**)chIds;
|
||||||
int32_t index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ);
|
int32_t index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
qDebug("===stream===window %" PRId64 " delete child id %d", winRes.ts, chId);
|
||||||
taosArrayRemove(chArray, index);
|
taosArrayRemove(chArray, index);
|
||||||
if (taosArrayGetSize(chArray) == 0) {
|
if (taosArrayGetSize(chArray) == 0) {
|
||||||
// pull data is over
|
// pull data is over
|
||||||
|
@ -2641,7 +2644,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
SExprSupp* pSup = &pOperator->exprSupp;
|
SExprSupp* pSup = &pOperator->exprSupp;
|
||||||
|
|
||||||
qDebug("interval status %d %s", pOperator->status, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
qDebug("interval status %d %s", pOperator->status, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2657,18 +2660,18 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
} else {
|
} else {
|
||||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pInfo->binfo.pRes->info.rows != 0) {
|
if (pInfo->binfo.pRes->info.rows != 0) {
|
||||||
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
if (pInfo->pUpdateRes->info.rows != 0 && pInfo->returnUpdate) {
|
if (pInfo->pUpdateRes->info.rows != 0 && pInfo->returnUpdate) {
|
||||||
pInfo->returnUpdate = false;
|
pInfo->returnUpdate = false;
|
||||||
ASSERT(!IS_FINAL_OP(pInfo));
|
ASSERT(!IS_FINAL_OP(pInfo));
|
||||||
printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
return pInfo->pUpdateRes;
|
return pInfo->pUpdateRes;
|
||||||
}
|
}
|
||||||
|
@ -2676,13 +2679,13 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->pPullDataRes->info.rows != 0) {
|
if (pInfo->pPullDataRes->info.rows != 0) {
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
ASSERT(IS_FINAL_OP(pInfo));
|
ASSERT(IS_FINAL_OP(pInfo));
|
||||||
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->pPullDataRes;
|
return pInfo->pPullDataRes;
|
||||||
}
|
}
|
||||||
doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
|
doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
|
||||||
if (pInfo->pDelRes->info.rows != 0) {
|
if (pInfo->pDelRes->info.rows != 0) {
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2693,10 +2696,10 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
clearSpecialDataBlock(pInfo->pUpdateRes);
|
clearSpecialDataBlock(pInfo->pUpdateRes);
|
||||||
removeDeleteResults(pUpdated, pInfo->pDelWins);
|
removeDeleteResults(pUpdated, pInfo->pDelWins);
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
qDebug("%s return data", IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
qDebug("%s return data", IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval Final recv" : "interval Semi recv");
|
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval Final recv" : "interval Semi recv");
|
||||||
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA ||
|
if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA ||
|
||||||
|
@ -2771,6 +2774,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SStreamFinalIntervalOperatorInfo* pTmpInfo = pChildOp->info;
|
SStreamFinalIntervalOperatorInfo* pTmpInfo = pChildOp->info;
|
||||||
pTmpInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE;
|
pTmpInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE;
|
||||||
taosArrayPush(pInfo->pChildren, &pChildOp);
|
taosArrayPush(pInfo->pChildren, &pChildOp);
|
||||||
|
qDebug("===stream===add child, id:%d", chIndex);
|
||||||
}
|
}
|
||||||
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
|
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
|
||||||
SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info;
|
SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info;
|
||||||
|
@ -2795,14 +2799,14 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pInfo->binfo.pRes->info.rows != 0) {
|
if (pInfo->binfo.pRes->info.rows != 0) {
|
||||||
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->pUpdateRes->info.rows != 0 && pInfo->returnUpdate) {
|
if (pInfo->pUpdateRes->info.rows != 0 && pInfo->returnUpdate) {
|
||||||
pInfo->returnUpdate = false;
|
pInfo->returnUpdate = false;
|
||||||
ASSERT(!IS_FINAL_OP(pInfo));
|
ASSERT(!IS_FINAL_OP(pInfo));
|
||||||
printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->pUpdateRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
return pInfo->pUpdateRes;
|
return pInfo->pUpdateRes;
|
||||||
}
|
}
|
||||||
|
@ -2811,14 +2815,14 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->pPullDataRes->info.rows != 0) {
|
if (pInfo->pPullDataRes->info.rows != 0) {
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
ASSERT(IS_FINAL_OP(pInfo));
|
ASSERT(IS_FINAL_OP(pInfo));
|
||||||
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->pPullDataRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->pPullDataRes;
|
return pInfo->pPullDataRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
|
doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
|
||||||
if (pInfo->pDelRes->info.rows != 0) {
|
if (pInfo->pDelRes->info.rows != 0) {
|
||||||
// process the rest of the data
|
// process the rest of the data
|
||||||
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
|
||||||
return pInfo->pDelRes;
|
return pInfo->pDelRes;
|
||||||
}
|
}
|
||||||
// ASSERT(false);
|
// ASSERT(false);
|
||||||
|
|
|
@ -91,7 +91,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
|
||||||
tsortSetComparFp(pSortHandle, msortComparFn);
|
tsortSetComparFp(pSortHandle, msortComparFn);
|
||||||
|
|
||||||
if (idstr != NULL) {
|
if (idstr != NULL) {
|
||||||
pSortHandle->idStr = strdup(idstr);
|
pSortHandle->idStr = strdup(idstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pSortHandle;
|
return pSortHandle;
|
||||||
|
@ -109,6 +109,10 @@ static int32_t sortComparClearup(SMsortComparParam* cmpParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsortDestroySortHandle(SSortHandle* pSortHandle) {
|
void tsortDestroySortHandle(SSortHandle* pSortHandle) {
|
||||||
|
if (pSortHandle == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tsortClose(pSortHandle);
|
tsortClose(pSortHandle);
|
||||||
if (pSortHandle->pMergeTree != NULL) {
|
if (pSortHandle->pMergeTree != NULL) {
|
||||||
tMergeTreeDestroy(pSortHandle->pMergeTree);
|
tMergeTreeDestroy(pSortHandle->pMergeTree);
|
||||||
|
@ -119,7 +123,6 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
|
||||||
blockDataDestroy(pSortHandle->pDataBlock);
|
blockDataDestroy(pSortHandle->pDataBlock);
|
||||||
for (size_t i = 0; i < taosArrayGetSize(pSortHandle->pOrderedSource); i++){
|
for (size_t i = 0; i < taosArrayGetSize(pSortHandle->pOrderedSource); i++){
|
||||||
SSortSource** pSource = taosArrayGet(pSortHandle->pOrderedSource, i);
|
SSortSource** pSource = taosArrayGet(pSortHandle->pOrderedSource, i);
|
||||||
blockDataDestroy((*pSource)->src.pBlock);
|
|
||||||
taosMemoryFreeClear(*pSource);
|
taosMemoryFreeClear(*pSource);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pSortHandle->pOrderedSource);
|
taosArrayDestroy(pSortHandle->pOrderedSource);
|
||||||
|
|
|
@ -1132,9 +1132,9 @@ static bool validateStateOper(const SValueNode* pVal) {
|
||||||
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (0 == strcasecmp(varDataVal(pVal->datum.p), "GT") || 0 == strcasecmp(varDataVal(pVal->datum.p), "GE") ||
|
return (0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
|
||||||
0 == strcasecmp(varDataVal(pVal->datum.p), "LT") || 0 == strcasecmp(varDataVal(pVal->datum.p), "LE") ||
|
0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
|
||||||
0 == strcasecmp(varDataVal(pVal->datum.p), "EQ") || 0 == strcasecmp(varDataVal(pVal->datum.p), "NE"));
|
0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
@ -2408,6 +2408,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getDiffFuncEnv,
|
.getEnvFunc = getDiffFuncEnv,
|
||||||
.initFunc = diffFunctionSetup,
|
.initFunc = diffFunctionSetup,
|
||||||
.processFunc = diffFunction,
|
.processFunc = diffFunction,
|
||||||
|
.sprocessFunc = diffScalarFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2418,6 +2419,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getStateFuncEnv,
|
.getEnvFunc = getStateFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = stateCountFunction,
|
.processFunc = stateCountFunction,
|
||||||
|
.sprocessFunc = stateCountScalarFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2428,6 +2430,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getStateFuncEnv,
|
.getEnvFunc = getStateFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = stateDurationFunction,
|
.processFunc = stateDurationFunction,
|
||||||
|
.sprocessFunc = stateDurationScalarFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -4469,17 +4469,17 @@ bool getStateFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
|
|
||||||
static int8_t getStateOpType(char* opStr) {
|
static int8_t getStateOpType(char* opStr) {
|
||||||
int8_t opType;
|
int8_t opType;
|
||||||
if (strcasecmp(opStr, "LT") == 0) {
|
if (strncasecmp(opStr, "LT", 2) == 0) {
|
||||||
opType = STATE_OPER_LT;
|
opType = STATE_OPER_LT;
|
||||||
} else if (strcasecmp(opStr, "GT") == 0) {
|
} else if (strncasecmp(opStr, "GT", 2) == 0) {
|
||||||
opType = STATE_OPER_GT;
|
opType = STATE_OPER_GT;
|
||||||
} else if (strcasecmp(opStr, "LE") == 0) {
|
} else if (strncasecmp(opStr, "LE", 2) == 0) {
|
||||||
opType = STATE_OPER_LE;
|
opType = STATE_OPER_LE;
|
||||||
} else if (strcasecmp(opStr, "GE") == 0) {
|
} else if (strncasecmp(opStr, "GE", 2) == 0) {
|
||||||
opType = STATE_OPER_GE;
|
opType = STATE_OPER_GE;
|
||||||
} else if (strcasecmp(opStr, "NE") == 0) {
|
} else if (strncasecmp(opStr, "NE", 2) == 0) {
|
||||||
opType = STATE_OPER_NE;
|
opType = STATE_OPER_NE;
|
||||||
} else if (strcasecmp(opStr, "EQ") == 0) {
|
} else if (strncasecmp(opStr, "EQ", 2) == 0) {
|
||||||
opType = STATE_OPER_EQ;
|
opType = STATE_OPER_EQ;
|
||||||
} else {
|
} else {
|
||||||
opType = STATE_OPER_INVALID;
|
opType = STATE_OPER_INVALID;
|
||||||
|
|
|
@ -855,6 +855,7 @@ int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output) {
|
||||||
memcpy(output->columnData,
|
memcpy(output->columnData,
|
||||||
taosArrayGet(input->pDataBlock, 0),
|
taosArrayGet(input->pDataBlock, 0),
|
||||||
sizeof(SColumnInfoData));
|
sizeof(SColumnInfoData));
|
||||||
|
output->colAlloced = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
const static uint32_t STATE_LIMIT = 1000;
|
const static uint32_t STATE_LIMIT = 1000;
|
||||||
|
|
||||||
static int dfaInstsEqual(const void *a, const void *b, size_t size) {
|
static int dfaInstsEqual(const void *a, const void *b, size_t size) {
|
||||||
SArray *ar = (SArray *)a;
|
SArray *ar = *(SArray **)a;
|
||||||
SArray *br = (SArray *)b;
|
SArray *br = *(SArray **)b;
|
||||||
size_t al = ar != NULL ? taosArrayGetSize(ar) : 0;
|
size_t al = ar != NULL ? taosArrayGetSize(ar) : 0;
|
||||||
size_t bl = br != NULL ? taosArrayGetSize(br) : 0;
|
size_t bl = br != NULL ? taosArrayGetSize(br) : 0;
|
||||||
if (al != bl) {
|
if (al != bl) {
|
||||||
|
@ -71,8 +71,8 @@ FstDfa *dfaBuilderBuild(FstDfaBuilder *builder) {
|
||||||
|
|
||||||
dfaAdd(builder->dfa, cur, 0);
|
dfaAdd(builder->dfa, cur, 0);
|
||||||
|
|
||||||
SArray *states = taosArrayInit(0, sizeof(uint32_t));
|
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
SArray *states = taosArrayInit(0, sizeof(uint32_t));
|
||||||
if (dfaBuilderCacheState(builder, cur, &result)) {
|
if (dfaBuilderCacheState(builder, cur, &result)) {
|
||||||
taosArrayPush(states, &result);
|
taosArrayPush(states, &result);
|
||||||
}
|
}
|
||||||
|
@ -146,10 +146,9 @@ bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *r
|
||||||
*result = *v;
|
*result = *v;
|
||||||
taosArrayDestroy(tinsts);
|
taosArrayDestroy(tinsts);
|
||||||
} else {
|
} else {
|
||||||
DfaState st;
|
DfaState st = {.insts = tinsts, .isMatch = isMatch};
|
||||||
st.insts = tinsts;
|
|
||||||
st.isMatch = isMatch;
|
|
||||||
taosArrayPush(builder->dfa->states, &st);
|
taosArrayPush(builder->dfa->states, &st);
|
||||||
|
|
||||||
int32_t sz = taosArrayGetSize(builder->dfa->states) - 1;
|
int32_t sz = taosArrayGetSize(builder->dfa->states) - 1;
|
||||||
taosHashPut(builder->cache, &tinsts, sizeof(POINTER_BYTES), &sz, sizeof(sz));
|
taosHashPut(builder->cache, &tinsts, sizeof(POINTER_BYTES), &sz, sizeof(sz));
|
||||||
*result = sz;
|
*result = sz;
|
||||||
|
|
|
@ -85,11 +85,12 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
|
||||||
blk->blockId = blkId;
|
blk->blockId = blkId;
|
||||||
blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize);
|
blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize);
|
||||||
assert(blk->nread <= kBlockSize);
|
assert(blk->nread <= kBlockSize);
|
||||||
nread = TMIN(blkLeft, len);
|
|
||||||
|
|
||||||
if (blk->nread < kBlockSize && blk->nread < len) {
|
if (blk->nread < kBlockSize && blk->nread < len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nread = TMIN(blkLeft, len);
|
||||||
memcpy(buf + total, blk->buf + blkOffset, nread);
|
memcpy(buf + total, blk->buf + blkOffset, nread);
|
||||||
|
|
||||||
LRUStatus s = taosLRUCacheInsert(ctx->lru, key, strlen(key), blk, cacheMemSize, deleteDataBlockFromLRU, NULL,
|
LRUStatus s = taosLRUCacheInsert(ctx->lru, key, strlen(key), blk, cacheMemSize, deleteDataBlockFromLRU, NULL,
|
||||||
|
|
|
@ -78,8 +78,8 @@ bool sparSetContains(FstSparseSet *ss, int32_t ip) {
|
||||||
if (ip >= ss->cap || ip < 0) {
|
if (ip >= ss->cap || ip < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int32_t i = ss->sparse[ip];
|
|
||||||
|
|
||||||
|
int32_t i = ss->sparse[ip];
|
||||||
if (i >= 0 && i < ss->cap && i < ss->size && ss->dense[i] == ip) {
|
if (i >= 0 && i < ss->cap && i < ss->size && ss->dense[i] == ip) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -952,6 +952,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: {
|
case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: {
|
||||||
SQueryInserterNode* pSink = (SQueryInserterNode*)pNode;
|
SQueryInserterNode* pSink = (SQueryInserterNode*)pNode;
|
||||||
destroyDataSinkNode((SDataSinkNode*)pSink);
|
destroyDataSinkNode((SDataSinkNode*)pSink);
|
||||||
|
nodesDestroyList(pSink->pCols);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
|
case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
|
||||||
|
@ -1543,7 +1544,7 @@ typedef struct SCollectFuncsCxt {
|
||||||
int32_t errCode;
|
int32_t errCode;
|
||||||
FFuncClassifier classifier;
|
FFuncClassifier classifier;
|
||||||
SNodeList* pFuncs;
|
SNodeList* pFuncs;
|
||||||
SHashObj* pAliasName;
|
SHashObj* pFuncsSet;
|
||||||
} SCollectFuncsCxt;
|
} SCollectFuncsCxt;
|
||||||
|
|
||||||
static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
||||||
|
@ -1551,28 +1552,40 @@ static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId) &&
|
if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId) &&
|
||||||
!(((SExprNode*)pNode)->orderAlias)) {
|
!(((SExprNode*)pNode)->orderAlias)) {
|
||||||
SExprNode* pExpr = (SExprNode*)pNode;
|
SExprNode* pExpr = (SExprNode*)pNode;
|
||||||
if (NULL == taosHashGet(pCxt->pAliasName, pExpr->aliasName, strlen(pExpr->aliasName))) {
|
if (NULL == taosHashGet(pCxt->pFuncsSet, &pExpr, POINTER_BYTES)) {
|
||||||
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
|
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
|
||||||
taosHashPut(pCxt->pAliasName, pExpr->aliasName, strlen(pExpr->aliasName), &pExpr, POINTER_BYTES);
|
taosHashPut(pCxt->pFuncsSet, &pExpr, POINTER_BYTES, &pExpr, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t funcNodeHash(const char* pKey, uint32_t len) {
|
||||||
|
SExprNode* pExpr = *(SExprNode**)pKey;
|
||||||
|
return MurmurHash3_32(pExpr->aliasName, strlen(pExpr->aliasName));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t funcNodeEqual(const void* pLeft, const void* pRight, size_t len) {
|
||||||
|
if (0 != strcmp((*(const SExprNode**)pLeft)->aliasName, (*(const SExprNode**)pRight)->aliasName)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return nodesEqualNode(*(const SNode**)pLeft, *(const SNode**)pRight) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, FFuncClassifier classifier, SNodeList** pFuncs) {
|
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, FFuncClassifier classifier, SNodeList** pFuncs) {
|
||||||
if (NULL == pSelect || NULL == pFuncs) {
|
if (NULL == pSelect || NULL == pFuncs) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCollectFuncsCxt cxt = {
|
SCollectFuncsCxt cxt = {.errCode = TSDB_CODE_SUCCESS,
|
||||||
.errCode = TSDB_CODE_SUCCESS,
|
.classifier = classifier,
|
||||||
.classifier = classifier,
|
.pFuncs = (NULL == *pFuncs ? nodesMakeList() : *pFuncs),
|
||||||
.pFuncs = (NULL == *pFuncs ? nodesMakeList() : *pFuncs),
|
.pFuncsSet = taosHashInit(4, funcNodeHash, false, false)};
|
||||||
.pAliasName = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, false)};
|
if (NULL == cxt.pFuncs || NULL == cxt.pFuncsSet) {
|
||||||
if (NULL == cxt.pFuncs) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
taosHashSetEqualFp(cxt.pFuncsSet, funcNodeEqual);
|
||||||
*pFuncs = NULL;
|
*pFuncs = NULL;
|
||||||
nodesWalkSelectStmt(pSelect, clause, collectFuncs, &cxt);
|
nodesWalkSelectStmt(pSelect, clause, collectFuncs, &cxt);
|
||||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||||
|
@ -1584,7 +1597,7 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, FFuncClassifi
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyList(cxt.pFuncs);
|
nodesDestroyList(cxt.pFuncs);
|
||||||
}
|
}
|
||||||
taosHashCleanup(cxt.pAliasName);
|
taosHashCleanup(cxt.pFuncsSet);
|
||||||
|
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,19 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB,
|
||||||
|
TSDB_INS_TABLE_USER_TAGS, pCxt->pMetaCache);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
if (NULL != pStmt->pDbName) {
|
||||||
|
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache);
|
||||||
|
} else {
|
||||||
|
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowUsers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowUsers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_USERS,
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_USERS,
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
|
@ -537,6 +550,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowStreams(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowStreams(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
return collectMetaKeyFromShowTables(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowTables(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
|
return collectMetaKeyFromShowTags(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_USERS_STMT:
|
case QUERY_NODE_SHOW_USERS_STMT:
|
||||||
return collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||||
|
|
|
@ -868,7 +868,8 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) {
|
if (strict && (!IS_VAR_DATA_TYPE(pVal->node.resType.type) ||
|
||||||
|
pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
||||||
|
@ -888,6 +889,9 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
|
if (strict && !IS_VAR_DATA_TYPE(pVal->node.resType.type)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
|
}
|
||||||
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
||||||
if (NULL == pVal->datum.p) {
|
if (NULL == pVal->datum.p) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -1168,7 +1172,7 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
if (isSelectStmt(pCxt->pCurrStmt)) {
|
if (isSelectStmt(pCxt->pCurrStmt)) {
|
||||||
//select percentile() without from clause is also valid
|
// select percentile() without from clause is also valid
|
||||||
if (NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable) {
|
if (NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1681,7 +1685,8 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) {
|
||||||
|
|
||||||
static bool sysTableFromVnode(const char* pTable) {
|
static bool sysTableFromVnode(const char* pTable) {
|
||||||
return (0 == strcmp(pTable, TSDB_INS_TABLE_USER_TABLES)) ||
|
return (0 == strcmp(pTable, TSDB_INS_TABLE_USER_TABLES)) ||
|
||||||
(0 == strcmp(pTable, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED));
|
(0 == strcmp(pTable, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED) ||
|
||||||
|
(0 == strcmp(pTable, TSDB_INS_TABLE_USER_TAGS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); }
|
static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); }
|
||||||
|
@ -1697,7 +1702,7 @@ static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName,
|
||||||
code = getDBVgInfoImpl(pCxt, pName, &vgroupList);
|
code = getDBVgInfoImpl(pCxt, pName, &vgroupList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES)) {
|
||||||
code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &vgroupList);
|
code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &vgroupList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1786,7 +1791,8 @@ static bool isSingleTable(SRealTableNode* pRealTable) {
|
||||||
int8_t tableType = pRealTable->pMeta->tableType;
|
int8_t tableType = pRealTable->pMeta->tableType;
|
||||||
if (TSDB_SYSTEM_TABLE == tableType) {
|
if (TSDB_SYSTEM_TABLE == tableType) {
|
||||||
return 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES) &&
|
return 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES) &&
|
||||||
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED);
|
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED) &&
|
||||||
|
0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TAGS);
|
||||||
}
|
}
|
||||||
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType);
|
return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType);
|
||||||
}
|
}
|
||||||
|
@ -5059,6 +5065,8 @@ static const char* getSysTableName(ENodeType type) {
|
||||||
return TSDB_INS_TABLE_USER_DATABASES;
|
return TSDB_INS_TABLE_USER_DATABASES;
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
return TSDB_INS_TABLE_USER_TABLES;
|
return TSDB_INS_TABLE_USER_TABLES;
|
||||||
|
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||||
|
return TSDB_INS_TABLE_USER_TAGS;
|
||||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||||
return TSDB_INS_TABLE_USER_STABLES;
|
return TSDB_INS_TABLE_USER_STABLES;
|
||||||
case QUERY_NODE_SHOW_USERS_STMT:
|
case QUERY_NODE_SHOW_USERS_STMT:
|
||||||
|
|
|
@ -282,7 +282,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
pScan->hasNormalCols = true;
|
pScan->hasNormalCols = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code && SCAN_TYPE_SYSTEM_TABLE != pScan->scanType) {
|
||||||
code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols);
|
code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1050,8 +1050,11 @@ static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code =
|
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0);
|
||||||
replaceLogicNode(pLogicSubplan, (SLogicNode*)pSort, (SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0));
|
if (NULL == pSort->node.pParent) {
|
||||||
|
TSWAP(pSort->node.pTargets, pChild->pTargets);
|
||||||
|
}
|
||||||
|
int32_t code = replaceLogicNode(pLogicSubplan, (SLogicNode*)pSort, pChild);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
NODES_CLEAR_LIST(pSort->node.pChildren);
|
NODES_CLEAR_LIST(pSort->node.pChildren);
|
||||||
nodesDestroyNode((SNode*)pSort);
|
nodesDestroyNode((SNode*)pSort);
|
||||||
|
@ -1982,11 +1985,15 @@ static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
|
static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || !(((SAggLogicNode*)pNode)->hasLastRow) ||
|
if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) ||
|
||||||
NULL != ((SAggLogicNode*)pNode)->pGroupKeys || 1 != LIST_LENGTH(pNode->pChildren) ||
|
QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0))) {
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0)) ||
|
return false;
|
||||||
NULL != ((SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0))->node.pConditions ||
|
}
|
||||||
0 == ((SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0))->cacheLastMode) {
|
|
||||||
|
SAggLogicNode* pAgg = (SAggLogicNode*)pNode;
|
||||||
|
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0);
|
||||||
|
if (!pAgg->hasLastRow || NULL != pAgg->pGroupKeys || NULL != pScan->node.pConditions || 0 == pScan->cacheLastMode ||
|
||||||
|
IS_TSWINDOW_SPECIFIED(pScan->scanRange)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -570,7 +570,8 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
|
||||||
pScan->showRewrite = pScanLogicNode->showRewrite;
|
pScan->showRewrite = pScanLogicNode->showRewrite;
|
||||||
pScan->accountId = pCxt->pPlanCxt->acctId;
|
pScan->accountId = pCxt->pPlanCxt->acctId;
|
||||||
if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USER_TABLES) ||
|
if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USER_TABLES) ||
|
||||||
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED)) {
|
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED) ||
|
||||||
|
0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_USER_TAGS)) {
|
||||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
} else {
|
} else {
|
||||||
pSubplan->execNode.nodeId = MNODE_HANDLE;
|
pSubplan->execNode.nodeId = MNODE_HANDLE;
|
||||||
|
|
|
@ -45,6 +45,12 @@ TEST_F(PlanJoinTest, withWhere) {
|
||||||
"WHERE t1.c1 > t2.c1 AND t1.c2 = 'abc' AND t2.c2 = 'qwe'");
|
"WHERE t1.c1 > t2.c1 AND t1.c2 = 'abc' AND t2.c2 = 'qwe'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanJoinTest, withAggAndOrderBy) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SELECT t1.ts, TOP(t2.c1, 10) FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts ORDER BY t2.ts");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlanJoinTest, multiJoin) {
|
TEST_F(PlanJoinTest, multiJoin) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,12 @@ TEST_F(PlanOptimizeTest, eliminateProjection) {
|
||||||
// run("select 1-abs(c1) from (select unique(c1) c1 from st1s3) order by 1 nulls first");
|
// run("select 1-abs(c1) from (select unique(c1) c1 from st1s3) order by 1 nulls first");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanOptimizeTest, mergeProjects) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SELECT * FROM (SELECT * FROM t1 WHERE c1 > 10 ORDER BY ts) ORDER BY ts");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlanOptimizeTest, pushDownProjectCond) {
|
TEST_F(PlanOptimizeTest, pushDownProjectCond) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
run("select 1-abs(c1) from (select unique(c1) c1 from st1s3) where 1-c1>5 order by 1 nulls first");
|
run("select 1-abs(c1) from (select unique(c1) c1 from st1s3) where 1-c1>5 order by 1 nulls first");
|
||||||
|
|
|
@ -75,7 +75,9 @@ typedef struct SQWDebug {
|
||||||
bool lockEnable;
|
bool lockEnable;
|
||||||
bool statusEnable;
|
bool statusEnable;
|
||||||
bool dumpEnable;
|
bool dumpEnable;
|
||||||
bool tmp;
|
bool sleepSimulate;
|
||||||
|
bool deadSimulate;
|
||||||
|
bool redirectSimulate;
|
||||||
} SQWDebug;
|
} SQWDebug;
|
||||||
|
|
||||||
extern SQWDebug gQWDebug;
|
extern SQWDebug gQWDebug;
|
||||||
|
@ -130,12 +132,11 @@ typedef struct SQWTaskCtx {
|
||||||
int8_t taskType;
|
int8_t taskType;
|
||||||
int8_t explain;
|
int8_t explain;
|
||||||
int8_t needFetch;
|
int8_t needFetch;
|
||||||
int32_t queryType;
|
int32_t msgType;
|
||||||
int32_t fetchType;
|
int32_t fetchType;
|
||||||
int32_t execId;
|
int32_t execId;
|
||||||
|
|
||||||
bool queryRsped;
|
bool queryRsped;
|
||||||
bool queryFetched;
|
|
||||||
bool queryEnd;
|
bool queryEnd;
|
||||||
bool queryContinue;
|
bool queryContinue;
|
||||||
bool queryInQueue;
|
bool queryInQueue;
|
||||||
|
@ -228,6 +229,7 @@ typedef struct SQWorkerMgmt {
|
||||||
#define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED)
|
#define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED)
|
||||||
|
|
||||||
#define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase)
|
#define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase)
|
||||||
|
#define QW_SET_PHASE(ctx, _value) do { if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { atomic_store_8(&(ctx)->phase, _value); } } while (0)
|
||||||
|
|
||||||
#define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code)
|
#define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code)
|
||||||
#define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code)
|
#define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code)
|
||||||
|
@ -362,7 +364,7 @@ int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx);
|
||||||
int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx);
|
int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx);
|
||||||
int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx);
|
int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx);
|
||||||
void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx);
|
void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx);
|
||||||
int32_t qwKillTaskHandle(QW_FPARAMS_DEF, SQWTaskCtx *ctx);
|
int32_t qwKillTaskHandle(SQWTaskCtx *ctx);
|
||||||
int32_t qwUpdateTaskStatus(QW_FPARAMS_DEF, int8_t status);
|
int32_t qwUpdateTaskStatus(QW_FPARAMS_DEF, int8_t status);
|
||||||
int32_t qwDropTask(QW_FPARAMS_DEF);
|
int32_t qwDropTask(QW_FPARAMS_DEF);
|
||||||
void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx);
|
void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx);
|
||||||
|
@ -372,13 +374,15 @@ int32_t qwUpdateTimeInQueue(SQWorker *mgmt, int64_t ts, EQueueType type);
|
||||||
int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type);
|
int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type);
|
||||||
void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch);
|
void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch);
|
||||||
int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch);
|
int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch);
|
||||||
void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx);
|
void qwFreeTaskCtx(SQWTaskCtx *ctx);
|
||||||
|
|
||||||
void qwDbgDumpMgmtInfo(SQWorker *mgmt);
|
void qwDbgDumpMgmtInfo(SQWorker *mgmt);
|
||||||
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore);
|
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore);
|
||||||
int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet);
|
int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet);
|
||||||
int32_t qwAddTaskCtx(QW_FPARAMS_DEF);
|
int32_t qwAddTaskCtx(QW_FPARAMS_DEF);
|
||||||
int32_t qwDbgResponseRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx);
|
void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped);
|
||||||
|
void qwDbgSimulateSleep(void);
|
||||||
|
void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -40,11 +40,13 @@ void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComple
|
||||||
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
||||||
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx);
|
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx);
|
||||||
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num);
|
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num);
|
||||||
|
int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code);
|
||||||
void qwFreeFetchRsp(void *msg);
|
void qwFreeFetchRsp(void *msg);
|
||||||
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
|
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
|
||||||
int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *rsp, int32_t code);
|
int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *rsp, int32_t code);
|
||||||
int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
||||||
int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo *pConn);
|
int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo *pConn);
|
||||||
|
int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .tmp = false};
|
SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .redirectSimulate = false, .deadSimulate = false, .sleepSimulate = false};
|
||||||
|
|
||||||
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
|
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) {
|
||||||
if (!gQWDebug.statusEnable) {
|
if (!gQWDebug.statusEnable) {
|
||||||
|
@ -147,8 +147,17 @@ int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwDbgResponseRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx) {
|
void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped) {
|
||||||
if (gQWDebug.tmp) {
|
static int32_t ignoreTime = 0;
|
||||||
|
if (*rsped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gQWDebug.redirectSimulate) {
|
||||||
|
if (++ignoreTime <= 10) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TDMT_SCH_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) {
|
if (TDMT_SCH_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) {
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
epSet.inUse = 1;
|
epSet.inUse = 1;
|
||||||
|
@ -162,42 +171,94 @@ int32_t qwDbgResponseRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx) {
|
||||||
|
|
||||||
ctx->phase = QW_PHASE_POST_QUERY;
|
ctx->phase = QW_PHASE_POST_QUERY;
|
||||||
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, &epSet);
|
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, &epSet);
|
||||||
return TSDB_CODE_SUCCESS;
|
*rsped = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TDMT_SCH_MERGE_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) {
|
if (TDMT_SCH_MERGE_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) {
|
||||||
ctx->phase = QW_PHASE_POST_QUERY;
|
QW_SET_PHASE(ctx, QW_PHASE_POST_QUERY);
|
||||||
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL);
|
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL);
|
||||||
return TSDB_CODE_SUCCESS;
|
*rsped = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((TDMT_SCH_FETCH == qwMsg->msgType) && (0 == taosRand() % 9)) {
|
||||||
|
qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL);
|
||||||
|
*rsped = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qwDbgSimulateSleep(void) {
|
||||||
|
if (!gQWDebug.sleepSimulate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t ignoreTime = 0;
|
||||||
|
if (++ignoreTime > 10) {
|
||||||
|
taosSsleep(taosRand() % 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) {
|
||||||
|
if (!gQWDebug.deadSimulate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*rsped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t ignoreTime = 0;
|
||||||
|
|
||||||
|
if (++ignoreTime > 10 && 0 == taosRand() % 9) {
|
||||||
|
SRpcHandleInfo *pConn = ((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo : &ctx->ctrlConnInfo);
|
||||||
|
qwBuildAndSendErrorRsp(ctx->msgType + 1, pConn, TSDB_CODE_RPC_BROKEN_LINK);
|
||||||
|
|
||||||
|
qwBuildAndSendDropMsg(QW_FPARAMS(), pConn);
|
||||||
|
*rsped = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t qwDbgEnableDebug(char *option) {
|
int32_t qwDbgEnableDebug(char *option) {
|
||||||
if (0 == strcasecmp(option, "lock")) {
|
if (0 == strcasecmp(option, "lock")) {
|
||||||
gQWDebug.lockEnable = true;
|
gQWDebug.lockEnable = true;
|
||||||
qDebug("qw lock debug enabled");
|
qError("qw lock debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "status")) {
|
if (0 == strcasecmp(option, "status")) {
|
||||||
gQWDebug.statusEnable = true;
|
gQWDebug.statusEnable = true;
|
||||||
qDebug("qw status debug enabled");
|
qError("qw status debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "dump")) {
|
if (0 == strcasecmp(option, "dump")) {
|
||||||
gQWDebug.dumpEnable = true;
|
gQWDebug.dumpEnable = true;
|
||||||
qDebug("qw dump debug enabled");
|
qError("qw dump debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(option, "tmp")) {
|
if (0 == strcasecmp(option, "sleep")) {
|
||||||
gQWDebug.tmp = true;
|
gQWDebug.sleepSimulate = true;
|
||||||
qDebug("qw tmp debug enabled");
|
qError("qw sleep debug enabled");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcasecmp(option, "dead")) {
|
||||||
|
gQWDebug.sleepSimulate = true;
|
||||||
|
qError("qw dead debug enabled");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcasecmp(option, "redirect")) {
|
||||||
|
gQWDebug.redirectSimulate = true;
|
||||||
|
qError("qw redirect debug enabled");
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,20 @@ void qwFreeFetchRsp(void *msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code) {
|
||||||
|
SRpcMsg rpcRsp = {
|
||||||
|
.msgType = rspType,
|
||||||
|
.pCont = NULL,
|
||||||
|
.contLen = 0,
|
||||||
|
.code = code,
|
||||||
|
.info = *pConn,
|
||||||
|
};
|
||||||
|
|
||||||
|
tmsgSendRsp(&rpcRsp);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx) {
|
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx) {
|
||||||
STbVerInfo* tbInfo = ctx ? &ctx->tbInfo : NULL;
|
STbVerInfo* tbInfo = ctx ? &ctx->tbInfo : NULL;
|
||||||
int64_t affectedRows = ctx ? ctx->affectedRows : 0;
|
int64_t affectedRows = ctx ? ctx->affectedRows : 0;
|
||||||
|
@ -184,7 +198,6 @@ int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
|
||||||
int32_t code = tmsgPutToQueue(&mgmt->msgCb, FETCH_QUEUE, &pNewMsg);
|
int32_t code = tmsgPutToQueue(&mgmt->msgCb, FETCH_QUEUE, &pNewMsg);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
QW_SCH_TASK_ELOG("put drop task msg to queue failed, vgId:%d, code:%s", mgmt->nodeId, tstrerror(code));
|
QW_SCH_TASK_ELOG("put drop task msg to queue failed, vgId:%d, code:%s", mgmt->nodeId, tstrerror(code));
|
||||||
rpcFreeCont(req);
|
|
||||||
QW_ERR_RET(code);
|
QW_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,8 +387,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
||||||
qwMsg.msgInfo.needFetch = msg->needFetch;
|
qwMsg.msgInfo.needFetch = msg->needFetch;
|
||||||
|
|
||||||
char * sql = strndup(msg->msg, msg->sqlLen);
|
char * sql = strndup(msg->msg, msg->sqlLen);
|
||||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, sql:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql);
|
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql);
|
||||||
|
|
||||||
QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
|
QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql));
|
||||||
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
QW_SCH_TASK_DLOG("processQuery end, node:%p", node);
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { return qwAddTask
|
||||||
|
|
||||||
void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx) { taosHashRelease(mgmt->ctxHash, ctx); }
|
void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx) { taosHashRelease(mgmt->ctxHash, ctx); }
|
||||||
|
|
||||||
void qwFreeTaskHandle(QW_FPARAMS_DEF, qTaskInfo_t *taskHandle) {
|
void qwFreeTaskHandle(qTaskInfo_t *taskHandle) {
|
||||||
// Note: free/kill may in RC
|
// Note: free/kill may in RC
|
||||||
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
|
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
|
||||||
if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) {
|
if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) {
|
||||||
|
@ -278,7 +278,7 @@ void qwFreeTaskHandle(QW_FPARAMS_DEF, qTaskInfo_t *taskHandle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwKillTaskHandle(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
int32_t qwKillTaskHandle(SQWTaskCtx *ctx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
// Note: free/kill may in RC
|
// Note: free/kill may in RC
|
||||||
qTaskInfo_t taskHandle = atomic_load_ptr(&ctx->taskHandle);
|
qTaskInfo_t taskHandle = atomic_load_ptr(&ctx->taskHandle);
|
||||||
|
@ -290,7 +290,7 @@ int32_t qwKillTaskHandle(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
void qwFreeTaskCtx(SQWTaskCtx *ctx) {
|
||||||
if (ctx->ctrlConnInfo.handle) {
|
if (ctx->ctrlConnInfo.handle) {
|
||||||
tmsgReleaseHandle(&ctx->ctrlConnInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&ctx->ctrlConnInfo, TAOS_CONN_SERVER);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
|
|
||||||
// NO need to release dataConnInfo
|
// NO need to release dataConnInfo
|
||||||
|
|
||||||
qwFreeTaskHandle(QW_FPARAMS(), &ctx->taskHandle);
|
qwFreeTaskHandle(&ctx->taskHandle);
|
||||||
|
|
||||||
if (ctx->sinkHandle) {
|
if (ctx->sinkHandle) {
|
||||||
dsDestroyDataSinker(ctx->sinkHandle);
|
dsDestroyDataSinker(ctx->sinkHandle);
|
||||||
|
@ -336,7 +336,7 @@ int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST);
|
QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
qwFreeTaskCtx(QW_FPARAMS(), &octx);
|
qwFreeTaskCtx(&octx);
|
||||||
|
|
||||||
QW_TASK_DLOG_E("task ctx dropped");
|
QW_TASK_DLOG_E("task ctx dropped");
|
||||||
|
|
||||||
|
@ -463,13 +463,21 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
mgmt->hbTimer = NULL;
|
mgmt->hbTimer = NULL;
|
||||||
taosTmrCleanUp(mgmt->timer);
|
taosTmrCleanUp(mgmt->timer);
|
||||||
|
|
||||||
// TODO STOP ALL QUERY
|
uint64_t qId, tId;
|
||||||
|
int32_t eId;
|
||||||
// TODO FREE ALL
|
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
|
||||||
|
void *key = taosHashGetKey(pIter, NULL);
|
||||||
|
QW_GET_QTID(key, qId, tId, eId);
|
||||||
|
|
||||||
|
qwFreeTaskCtx(ctx);
|
||||||
|
QW_TASK_DLOG_E("task ctx freed");
|
||||||
|
pIter = taosHashIterate(mgmt->ctxHash, pIter);
|
||||||
|
}
|
||||||
taosHashCleanup(mgmt->ctxHash);
|
taosHashCleanup(mgmt->ctxHash);
|
||||||
|
|
||||||
void *pIter = taosHashIterate(mgmt->schHash, NULL);
|
pIter = taosHashIterate(mgmt->schHash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SQWSchStatus *sch = (SQWSchStatus *)pIter;
|
SQWSchStatus *sch = (SQWSchStatus *)pIter;
|
||||||
qwDestroySchStatus(sch);
|
qwDestroySchStatus(sch);
|
||||||
|
|
|
@ -83,6 +83,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryEnd) {
|
||||||
|
|
||||||
// if *taskHandle is NULL, it's killed right now
|
// if *taskHandle is NULL, it's killed right now
|
||||||
if (taskHandle) {
|
if (taskHandle) {
|
||||||
|
qwDbgSimulateSleep();
|
||||||
code = qExecTask(taskHandle, &pRes, &useconds);
|
code = qExecTask(taskHandle, &pRes, &useconds);
|
||||||
if (code) {
|
if (code) {
|
||||||
if (code != TSDB_CODE_OPS_NOT_SUPPORT) {
|
if (code != TSDB_CODE_OPS_NOT_SUPPORT) {
|
||||||
|
@ -293,11 +294,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
||||||
|
|
||||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||||
|
|
||||||
if (QW_PHASE_PRE_FETCH == phase) {
|
QW_SET_PHASE(ctx, phase);
|
||||||
atomic_store_8((int8_t *)&ctx->queryFetched, true);
|
|
||||||
} else {
|
|
||||||
atomic_store_8(&ctx->phase, phase);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atomic_load_8((int8_t *)&ctx->queryEnd)) {
|
if (atomic_load_8((int8_t *)&ctx->queryEnd)) {
|
||||||
QW_TASK_ELOG_E("query already end");
|
QW_TASK_ELOG_E("query already end");
|
||||||
|
@ -370,6 +367,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
QW_UPDATE_RSP_CODE(ctx, code);
|
QW_UPDATE_RSP_CODE(ctx, code);
|
||||||
|
|
||||||
|
@ -390,7 +388,6 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SQWTaskCtx *ctx = NULL;
|
SQWTaskCtx *ctx = NULL;
|
||||||
SRpcHandleInfo connInfo = {0};
|
SRpcHandleInfo connInfo = {0};
|
||||||
SRpcHandleInfo *rspConnection = NULL;
|
|
||||||
|
|
||||||
QW_TASK_DLOG("start to handle event at phase %s", qwPhaseStr(phase));
|
QW_TASK_DLOG("start to handle event at phase %s", qwPhaseStr(phase));
|
||||||
|
|
||||||
|
@ -403,13 +400,6 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED);
|
QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_PHASE_POST_QUERY == phase) {
|
|
||||||
connInfo = ctx->ctrlConnInfo;
|
|
||||||
rspConnection = &connInfo;
|
|
||||||
|
|
||||||
ctx->queryRsped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
|
||||||
if (QW_PHASE_POST_FETCH == phase) {
|
if (QW_PHASE_POST_FETCH == phase) {
|
||||||
QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase));
|
QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase));
|
||||||
|
@ -437,17 +427,23 @@ _return:
|
||||||
qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_PART_SUCC);
|
qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_PART_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspConnection) {
|
if (QW_PHASE_POST_QUERY == phase && ctx) {
|
||||||
qwBuildAndSendQueryRsp(input->msgType + 1, rspConnection, code, ctx);
|
ctx->queryRsped = true;
|
||||||
QW_TASK_DLOG("query msg rsped, handle:%p, code:%x - %s", rspConnection->handle, code, tstrerror(code));
|
|
||||||
|
bool rsped = false;
|
||||||
|
SQWMsg qwMsg = {.msgType = ctx->msgType, .connInfo = ctx->ctrlConnInfo};
|
||||||
|
qwDbgSimulateRedirect(&qwMsg, ctx, &rsped);
|
||||||
|
qwDbgSimulateDead(QW_FPARAMS(), ctx, &rsped);
|
||||||
|
if (!rsped) {
|
||||||
|
qwBuildAndSendQueryRsp(input->msgType + 1, &ctx->ctrlConnInfo, code, ctx);
|
||||||
|
QW_TASK_DLOG("query msg rsped, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
QW_UPDATE_RSP_CODE(ctx, code);
|
QW_UPDATE_RSP_CODE(ctx, code);
|
||||||
|
|
||||||
if (QW_PHASE_POST_FETCH != phase) {
|
QW_SET_PHASE(ctx, phase);
|
||||||
atomic_store_8(&ctx->phase, phase);
|
|
||||||
}
|
|
||||||
|
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
qwReleaseTaskCtx(mgmt, ctx);
|
qwReleaseTaskCtx(mgmt, ctx);
|
||||||
|
@ -488,8 +484,6 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
|
|
||||||
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT));
|
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT));
|
||||||
|
|
||||||
qwDbgResponseRedirect(qwMsg, ctx);
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
|
@ -517,7 +511,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) {
|
||||||
ctx->taskType = qwMsg->msgInfo.taskType;
|
ctx->taskType = qwMsg->msgInfo.taskType;
|
||||||
ctx->explain = qwMsg->msgInfo.explain;
|
ctx->explain = qwMsg->msgInfo.explain;
|
||||||
ctx->needFetch = qwMsg->msgInfo.needFetch;
|
ctx->needFetch = qwMsg->msgInfo.needFetch;
|
||||||
ctx->queryType = qwMsg->msgType;
|
ctx->msgType = qwMsg->msgType;
|
||||||
|
|
||||||
//QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
|
//QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
|
||||||
|
|
||||||
|
@ -636,8 +630,8 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
|
|
||||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||||
if (queryEnd || code || 0 == atomic_load_8((int8_t *)&ctx->queryContinue)) {
|
if (queryEnd || code || 0 == atomic_load_8((int8_t *)&ctx->queryContinue)) {
|
||||||
// Note: if necessary, fetch need to put cquery to queue again
|
// Note: query is not running anymore
|
||||||
atomic_store_8(&ctx->phase, 0);
|
QW_SET_PHASE(ctx, 0);
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -662,14 +656,13 @@ int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
|
|
||||||
QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx));
|
QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx));
|
||||||
|
|
||||||
ctx->queryType = qwMsg->msgType;
|
ctx->msgType = qwMsg->msgType;
|
||||||
|
ctx->dataConnInfo = qwMsg->connInfo;
|
||||||
|
|
||||||
SOutputData sOutput = {0};
|
SOutputData sOutput = {0};
|
||||||
QW_ERR_JRET(qwGetQueryResFromSink(QW_FPARAMS(), ctx, &dataLen, &rsp, &sOutput));
|
QW_ERR_JRET(qwGetQueryResFromSink(QW_FPARAMS(), ctx, &dataLen, &rsp, &sOutput));
|
||||||
|
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
ctx->dataConnInfo = qwMsg->connInfo;
|
|
||||||
|
|
||||||
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_FETCH);
|
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_FETCH);
|
||||||
} else {
|
} else {
|
||||||
bool qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd);
|
bool qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd);
|
||||||
|
@ -714,9 +707,16 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code || rsp) {
|
if (code || rsp) {
|
||||||
qwBuildAndSendFetchRsp(qwMsg->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code);
|
bool rsped = false;
|
||||||
QW_TASK_DLOG("%s send, handle:%p, code:%x - %s, dataLen:%d", TMSG_INFO(qwMsg->msgType + 1), qwMsg->connInfo.handle, code, tstrerror(code),
|
if (ctx) {
|
||||||
dataLen);
|
qwDbgSimulateRedirect(qwMsg, ctx, &rsped);
|
||||||
|
qwDbgSimulateDead(QW_FPARAMS(), ctx, &rsped);
|
||||||
|
}
|
||||||
|
if (!rsped) {
|
||||||
|
qwBuildAndSendFetchRsp(qwMsg->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code);
|
||||||
|
QW_TASK_DLOG("%s send, handle:%p, code:%x - %s, dataLen:%d", TMSG_INFO(qwMsg->msgType + 1), qwMsg->connInfo.handle, code, tstrerror(code),
|
||||||
|
dataLen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_RET(TSDB_CODE_SUCCESS);
|
QW_RET(TSDB_CODE_SUCCESS);
|
||||||
|
@ -724,7 +724,7 @@ _return:
|
||||||
|
|
||||||
int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
bool rsped = false;
|
bool dropped = false;
|
||||||
SQWTaskCtx *ctx = NULL;
|
SQWTaskCtx *ctx = NULL;
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
|
|
||||||
|
@ -740,18 +740,14 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_QUERY_RUNNING(ctx)) {
|
if (QW_QUERY_RUNNING(ctx)) {
|
||||||
QW_ERR_JRET(qwKillTaskHandle(QW_FPARAMS(), ctx));
|
QW_ERR_JRET(qwKillTaskHandle(ctx));
|
||||||
qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROP);
|
qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROP);
|
||||||
} else if (ctx->phase > 0) {
|
|
||||||
QW_ERR_JRET(qwDropTask(QW_FPARAMS()));
|
|
||||||
rsped = true;
|
|
||||||
} else {
|
} else {
|
||||||
// task not started
|
QW_ERR_JRET(qwDropTask(QW_FPARAMS()));
|
||||||
|
dropped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rsped) {
|
if (!dropped) {
|
||||||
ctx->ctrlConnInfo = qwMsg->connInfo;
|
|
||||||
|
|
||||||
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP);
|
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,7 +950,7 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
qwFreeTaskCtx(QW_FPARAMS(), &ctx);
|
qwFreeTaskCtx(&ctx);
|
||||||
|
|
||||||
QW_RET(TSDB_CODE_SUCCESS);
|
QW_RET(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarPara
|
||||||
}
|
}
|
||||||
|
|
||||||
pParam->columnData = pColumnData;
|
pParam->columnData = pColumnData;
|
||||||
pParam->type = SHOULD_FREE_COLDATA;
|
pParam->colAlloced = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,10 @@ void sclFreeRes(SHashObj *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sclFreeParam(SScalarParam *param) {
|
void sclFreeParam(SScalarParam *param) {
|
||||||
|
if (!param->colAlloced) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (param->columnData != NULL) {
|
if (param->columnData != NULL) {
|
||||||
colDataDestroy(param->columnData);
|
colDataDestroy(param->columnData);
|
||||||
taosMemoryFreeClear(param->columnData);
|
taosMemoryFreeClear(param->columnData);
|
||||||
|
@ -173,6 +177,7 @@ void sclFreeParam(SScalarParam *param) {
|
||||||
|
|
||||||
if (param->pHashFilter != NULL) {
|
if (param->pHashFilter != NULL) {
|
||||||
taosHashCleanup(param->pHashFilter);
|
taosHashCleanup(param->pHashFilter);
|
||||||
|
param->pHashFilter = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +196,19 @@ int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sclFreeParamList(SScalarParam *param, int32_t paramNum) {
|
||||||
|
if (NULL == param) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < paramNum; ++i) {
|
||||||
|
SScalarParam* p = param + i;
|
||||||
|
sclFreeParam(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(param);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t *rowNum) {
|
int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t *rowNum) {
|
||||||
switch (nodeType(node)) {
|
switch (nodeType(node)) {
|
||||||
case QUERY_NODE_LEFT_VALUE: {
|
case QUERY_NODE_LEFT_VALUE: {
|
||||||
|
@ -225,11 +243,14 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
||||||
|
|
||||||
SCL_ERR_RET(scalarGenerateSetFromList((void **)¶m->pHashFilter, node, type));
|
SCL_ERR_RET(scalarGenerateSetFromList((void **)¶m->pHashFilter, node, type));
|
||||||
param->hashValueType = type;
|
param->hashValueType = type;
|
||||||
|
param->colAlloced = true;
|
||||||
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||||
taosHashCleanup(param->pHashFilter);
|
taosHashCleanup(param->pHashFilter);
|
||||||
|
param->pHashFilter = NULL;
|
||||||
sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
param->colAlloced = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_COLUMN: {
|
case QUERY_NODE_COLUMN: {
|
||||||
|
@ -274,6 +295,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
SCL_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
*param = *res;
|
*param = *res;
|
||||||
|
param->colAlloced = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -455,11 +477,7 @@ int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outp
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
for (int32_t i = 0; i < paramNum; ++i) {
|
sclFreeParamList(params, paramNum);
|
||||||
// sclFreeParamNoData(params + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(params);
|
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,11 +551,7 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
for (int32_t i = 0; i < paramNum; ++i) {
|
sclFreeParamList(params, paramNum);
|
||||||
// sclFreeParamNoData(params + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(params);
|
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,14 +587,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
for (int32_t i = 0; i < paramNum; ++i) {
|
|
||||||
if (params[i].type == SHOULD_FREE_COLDATA) {
|
|
||||||
colDataDestroy(params[i].columnData);
|
|
||||||
taosMemoryFreeClear(params[i].columnData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(params);
|
sclFreeParamList(params, paramNum);
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +879,6 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.type = DELEGATED_MGMT_COLDATA;
|
|
||||||
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
|
@ -906,7 +913,6 @@ EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.type = DELEGATED_MGMT_COLDATA;
|
|
||||||
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
|
|
|
@ -2408,6 +2408,10 @@ int32_t irateScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam
|
||||||
return nonCalcScalarFunction(pInput, inputNum, pOutput);
|
return nonCalcScalarFunction(pInput, inputNum, pOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t diffScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
return nonCalcScalarFunction(pInput, inputNum, pOutput);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t twaScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t twaScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
return avgScalarFunction(pInput, inputNum, pOutput);
|
return avgScalarFunction(pInput, inputNum, pOutput);
|
||||||
}
|
}
|
||||||
|
@ -2423,3 +2427,177 @@ int32_t hllScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
||||||
int32_t csumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t csumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
return sumScalarFunction(pInput, inputNum, pOutput);
|
return sumScalarFunction(pInput, inputNum, pOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATE_OPER_INVALID = 0,
|
||||||
|
STATE_OPER_LT,
|
||||||
|
STATE_OPER_GT,
|
||||||
|
STATE_OPER_LE,
|
||||||
|
STATE_OPER_GE,
|
||||||
|
STATE_OPER_NE,
|
||||||
|
STATE_OPER_EQ,
|
||||||
|
} EStateOperType;
|
||||||
|
|
||||||
|
#define STATE_COMP(_op, _lval, _rval, _rtype) STATE_COMP_IMPL(_op, _lval, GET_STATE_VAL(_rval, _rtype))
|
||||||
|
|
||||||
|
#define GET_STATE_VAL(_val, _type) ((_type == TSDB_DATA_TYPE_BIGINT) ? (*(int64_t *)_val) : (*(double *)_val))
|
||||||
|
|
||||||
|
#define STATE_COMP_IMPL(_op, _lval, _rval) \
|
||||||
|
do { \
|
||||||
|
switch (_op) { \
|
||||||
|
case STATE_OPER_LT: \
|
||||||
|
return ((_lval) < (_rval)); \
|
||||||
|
break; \
|
||||||
|
case STATE_OPER_GT: \
|
||||||
|
return ((_lval) > (_rval)); \
|
||||||
|
break; \
|
||||||
|
case STATE_OPER_LE: \
|
||||||
|
return ((_lval) <= (_rval)); \
|
||||||
|
break; \
|
||||||
|
case STATE_OPER_GE: \
|
||||||
|
return ((_lval) >= (_rval)); \
|
||||||
|
break; \
|
||||||
|
case STATE_OPER_NE: \
|
||||||
|
return ((_lval) != (_rval)); \
|
||||||
|
break; \
|
||||||
|
case STATE_OPER_EQ: \
|
||||||
|
return ((_lval) == (_rval)); \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static int8_t getStateOpType(char* opStr) {
|
||||||
|
int8_t opType;
|
||||||
|
if (strncasecmp(opStr, "LT", 2) == 0) {
|
||||||
|
opType = STATE_OPER_LT;
|
||||||
|
} else if (strncasecmp(opStr, "GT", 2) == 0) {
|
||||||
|
opType = STATE_OPER_GT;
|
||||||
|
} else if (strncasecmp(opStr, "LE", 2) == 0) {
|
||||||
|
opType = STATE_OPER_LE;
|
||||||
|
} else if (strncasecmp(opStr, "GE", 2) == 0) {
|
||||||
|
opType = STATE_OPER_GE;
|
||||||
|
} else if (strncasecmp(opStr, "NE", 2) == 0) {
|
||||||
|
opType = STATE_OPER_NE;
|
||||||
|
} else if (strncasecmp(opStr, "EQ", 2) == 0) {
|
||||||
|
opType = STATE_OPER_EQ;
|
||||||
|
} else {
|
||||||
|
opType = STATE_OPER_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return opType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SScalarParam *pCondParam) {
|
||||||
|
char* data = colDataGetData(pCol, index);
|
||||||
|
char* param = pCondParam->columnData->pData;
|
||||||
|
int32_t paramType = GET_PARAM_TYPE(pCondParam);
|
||||||
|
switch (pCol->info.type) {
|
||||||
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
|
int8_t v = *(int8_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT: {
|
||||||
|
uint8_t v = *(uint8_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT: {
|
||||||
|
int16_t v = *(int16_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
|
uint16_t v = *(uint16_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_INT: {
|
||||||
|
int32_t v = *(int32_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_UINT: {
|
||||||
|
uint32_t v = *(uint32_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
|
int64_t v = *(int64_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
|
uint64_t v = *(uint64_t*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
|
float v = *(float*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
|
double v = *(double*)data;
|
||||||
|
STATE_COMP(op, v, param, paramType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
SColumnInfoData *pInputData = pInput->columnData;
|
||||||
|
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||||
|
|
||||||
|
int8_t op = getStateOpType(varDataVal(pInput[1].columnData->pData));
|
||||||
|
int64_t count = 0;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||||
|
if (colDataIsNull_s(pInputData, i)) {
|
||||||
|
colDataAppendNULL(pOutputData, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = checkStateOp(op, pInputData, i, &pInput[2]);
|
||||||
|
int64_t out = -1;
|
||||||
|
if (ret) {
|
||||||
|
out = ++count;
|
||||||
|
} else {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
colDataAppend(pOutputData, i, (char*)&out, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutput->numOfRows = pInput->numOfRows;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
SColumnInfoData *pInputData = pInput->columnData;
|
||||||
|
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||||
|
|
||||||
|
int8_t op = getStateOpType(varDataVal(pInput[1].columnData->pData));
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pInput->numOfRows; ++i) {
|
||||||
|
if (colDataIsNull_s(pInputData, i)) {
|
||||||
|
colDataAppendNULL(pOutputData, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = checkStateOp(op, pInputData, i, &pInput[2]);
|
||||||
|
int64_t out = -1;
|
||||||
|
if (ret) {
|
||||||
|
out = 0;
|
||||||
|
}
|
||||||
|
colDataAppend(pOutputData, i, (char*)&out, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutput->numOfRows = pInput->numOfRows;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||||
|
|
||||||
void initScalarParam(SScalarParam* pParam) {
|
void initScalarParam(SScalarParam* pParam) {
|
||||||
memset(pParam, 0, sizeof(SScalarParam));
|
memset(pParam, 0, sizeof(SScalarParam));
|
||||||
pParam->type = SHOULD_FREE_COLDATA;
|
pParam->colAlloced = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,13 +55,11 @@ typedef enum {
|
||||||
#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000
|
#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000
|
||||||
#define SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM 200 // unit is TSDB_TABLE_NUM_UNIT
|
#define SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM 200 // unit is TSDB_TABLE_NUM_UNIT
|
||||||
#define SCHEDULE_DEFAULT_POLICY SCH_LOAD_SEQ
|
#define SCHEDULE_DEFAULT_POLICY SCH_LOAD_SEQ
|
||||||
|
#define SCHEDULE_DEFAULT_MAX_NODE_NUM 20
|
||||||
|
|
||||||
#define SCH_DEFAULT_TASK_TIMEOUT_USEC 10000000
|
#define SCH_DEFAULT_TASK_TIMEOUT_USEC 10000000
|
||||||
#define SCH_MAX_TASK_TIMEOUT_USEC 60000000
|
#define SCH_MAX_TASK_TIMEOUT_USEC 60000000
|
||||||
#define SCH_MAX_CANDIDATE_EP_NUM TSDB_MAX_REPLICA
|
#define SCH_DEFAULT_MAX_RETRY_NUM 6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct SSchDebug {
|
typedef struct SSchDebug {
|
||||||
bool lockEnable;
|
bool lockEnable;
|
||||||
|
@ -211,6 +209,7 @@ typedef struct SSchTask {
|
||||||
int32_t maxExecTimes; // task max exec times
|
int32_t maxExecTimes; // task max exec times
|
||||||
int32_t maxRetryTimes; // task max retry times
|
int32_t maxRetryTimes; // task max retry times
|
||||||
int32_t retryTimes; // task retry times
|
int32_t retryTimes; // task retry times
|
||||||
|
bool waitRetry; // wait for retry
|
||||||
int32_t execId; // task current execute index
|
int32_t execId; // task current execute index
|
||||||
SSchLevel *level; // level
|
SSchLevel *level; // level
|
||||||
SRWLatch planLock; // task update plan lock
|
SRWLatch planLock; // task update plan lock
|
||||||
|
@ -274,7 +273,8 @@ typedef struct SSchJob {
|
||||||
int32_t errCode;
|
int32_t errCode;
|
||||||
SRWLatch resLock;
|
SRWLatch resLock;
|
||||||
SExecResult execRes;
|
SExecResult execRes;
|
||||||
void *resData; //TODO free it or not
|
void *fetchRes; //TODO free it or not
|
||||||
|
bool fetched;
|
||||||
int32_t resNumOfRows;
|
int32_t resNumOfRows;
|
||||||
SSchResInfo userRes;
|
SSchResInfo userRes;
|
||||||
const char *sql;
|
const char *sql;
|
||||||
|
@ -326,7 +326,7 @@ extern SSchedulerMgmt schMgmt;
|
||||||
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
|
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
|
||||||
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||||
#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task))))
|
#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task))))
|
||||||
#define SCH_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH)
|
#define SCH_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH)
|
||||||
#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) (SCH_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen))))
|
#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) (SCH_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen))))
|
||||||
#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
|
#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
|
||||||
|
|
||||||
|
@ -368,6 +368,8 @@ extern SSchedulerMgmt schMgmt;
|
||||||
qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
#define SCH_TASK_DLOG(param, ...) \
|
#define SCH_TASK_DLOG(param, ...) \
|
||||||
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
|
#define SCH_TASK_TLOG(param, ...) \
|
||||||
|
qTrace("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
#define SCH_TASK_DLOGL(param, ...) \
|
#define SCH_TASK_DLOGL(param, ...) \
|
||||||
qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__)
|
||||||
#define SCH_TASK_WLOG(param, ...) \
|
#define SCH_TASK_WLOG(param, ...) \
|
||||||
|
@ -441,7 +443,7 @@ void schFreeRpcCtx(SRpcCtx *pCtx);
|
||||||
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp);
|
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp);
|
||||||
bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus);
|
bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus);
|
||||||
int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask);
|
int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask);
|
||||||
int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp);
|
int32_t schSaveJobExecRes(SSchJob *pJob, SQueryTableRsp *rsp);
|
||||||
int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp);
|
int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp);
|
||||||
void schProcessOnDataFetched(SSchJob *job);
|
void schProcessOnDataFetched(SSchJob *job);
|
||||||
int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask);
|
int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask);
|
||||||
|
@ -492,7 +494,7 @@ int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask);
|
||||||
void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode);
|
void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode);
|
||||||
int32_t schHandleJobFailure(SSchJob *pJob, int32_t errCode);
|
int32_t schHandleJobFailure(SSchJob *pJob, int32_t errCode);
|
||||||
int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode);
|
int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode);
|
||||||
bool schChkCurrentOp(SSchJob *pJob, int32_t op, bool sync);
|
bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync);
|
||||||
|
|
||||||
extern SSchDebug gSCHDebug;
|
extern SSchDebug gSCHDebug;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) {
|
||||||
break;
|
break;
|
||||||
case JOB_TASK_STATUS_PART_SUCC:
|
case JOB_TASK_STATUS_PART_SUCC:
|
||||||
if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC &&
|
if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC &&
|
||||||
newStatus != JOB_TASK_STATUS_DROP) {
|
newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,13 +389,18 @@ int32_t schDumpJobExecRes(SSchJob* pJob, SExecResult* pRes) {
|
||||||
|
|
||||||
int32_t schDumpJobFetchRes(SSchJob* pJob, void** pData) {
|
int32_t schDumpJobFetchRes(SSchJob* pJob, void** pData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (pJob->resData && ((SRetrieveTableRsp *)pJob->resData)->completed) {
|
|
||||||
SCH_ERR_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_SUCC, NULL));
|
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
|
||||||
|
pJob->fetched = true;
|
||||||
|
|
||||||
|
if (pJob->fetchRes && ((SRetrieveTableRsp *)pJob->fetchRes)->completed) {
|
||||||
|
SCH_ERR_JRET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_SUCC, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
*pData = atomic_load_ptr(&pJob->resData);
|
*pData = atomic_load_ptr(&pJob->fetchRes);
|
||||||
if (*pData != atomic_val_compare_exchange_ptr(&pJob->resData, *pData, NULL)) {
|
if (*pData != atomic_val_compare_exchange_ptr(&pJob->fetchRes, *pData, NULL)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +419,11 @@ int32_t schDumpJobFetchRes(SSchJob* pJob, void** pData) {
|
||||||
|
|
||||||
SCH_JOB_DLOG("fetch done, totalRows:%d", pJob->resNumOfRows);
|
SCH_JOB_DLOG("fetch done, totalRows:%d", pJob->resNumOfRows);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
_return:
|
||||||
|
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schNotifyUserExecRes(SSchJob* pJob) {
|
int32_t schNotifyUserExecRes(SSchJob* pJob) {
|
||||||
|
@ -512,8 +521,12 @@ int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) {
|
int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) {
|
||||||
schPostJobRes(pJob, SCH_OP_EXEC);
|
if (schChkCurrentOp(pJob, SCH_OP_FETCH, -1)) {
|
||||||
|
SCH_ERR_RET(schLaunchFetchTask(pJob));
|
||||||
|
} else {
|
||||||
|
schPostJobRes(pJob, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -526,7 +539,7 @@ int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRs
|
||||||
SCH_TASK_DLOG("got explain rsp, rows:%d, complete:%d", htonl(pRsp->numOfRows), pRsp->completed);
|
SCH_TASK_DLOG("got explain rsp, rows:%d, complete:%d", htonl(pRsp->numOfRows), pRsp->completed);
|
||||||
|
|
||||||
atomic_store_32(&pJob->resNumOfRows, htonl(pRsp->numOfRows));
|
atomic_store_32(&pJob->resNumOfRows, htonl(pRsp->numOfRows));
|
||||||
atomic_store_ptr(&pJob->resData, pRsp);
|
atomic_store_ptr(&pJob->fetchRes, pRsp);
|
||||||
|
|
||||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCC);
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCC);
|
||||||
|
|
||||||
|
@ -561,7 +574,7 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp) {
|
int32_t schSaveJobExecRes(SSchJob *pJob, SQueryTableRsp *rsp) {
|
||||||
if (rsp->tbFName[0]) {
|
if (rsp->tbFName[0]) {
|
||||||
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
|
||||||
|
@ -600,7 +613,7 @@ int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask) {
|
||||||
|
|
||||||
int32_t schLaunchJob(SSchJob *pJob) {
|
int32_t schLaunchJob(SSchJob *pJob) {
|
||||||
if (EXPLAIN_MODE_STATIC == pJob->attr.explainMode) {
|
if (EXPLAIN_MODE_STATIC == pJob->attr.explainMode) {
|
||||||
SCH_ERR_RET(qExecStaticExplain(pJob->pDag, (SRetrieveTableRsp **)&pJob->resData));
|
SCH_ERR_RET(qExecStaticExplain(pJob->pDag, (SRetrieveTableRsp **)&pJob->fetchRes));
|
||||||
SCH_ERR_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
SCH_ERR_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
||||||
} else {
|
} else {
|
||||||
SSchLevel *level = taosArrayGet(pJob->levels, pJob->levelIdx);
|
SSchLevel *level = taosArrayGet(pJob->levels, pJob->levelIdx);
|
||||||
|
@ -661,7 +674,7 @@ void schFreeJobImpl(void *job) {
|
||||||
qDestroyQueryPlan(pJob->pDag);
|
qDestroyQueryPlan(pJob->pDag);
|
||||||
|
|
||||||
taosMemoryFreeClear(pJob->userRes.execRes);
|
taosMemoryFreeClear(pJob->userRes.execRes);
|
||||||
taosMemoryFreeClear(pJob->resData);
|
taosMemoryFreeClear(pJob->fetchRes);
|
||||||
taosMemoryFree(pJob);
|
taosMemoryFree(pJob);
|
||||||
|
|
||||||
int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1);
|
int32_t jobNum = atomic_sub_fetch_32(&schMgmt.jobNum, 1);
|
||||||
|
@ -795,9 +808,14 @@ void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool schChkCurrentOp(SSchJob *pJob, int32_t op, bool sync) {
|
bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync) {
|
||||||
|
bool r = false;
|
||||||
SCH_LOCK(SCH_READ, &pJob->opStatus.lock);
|
SCH_LOCK(SCH_READ, &pJob->opStatus.lock);
|
||||||
bool r = (pJob->opStatus.op == op) && (pJob->opStatus.syncReq == sync);
|
if (sync >= 0) {
|
||||||
|
r = (pJob->opStatus.op == op) && (pJob->opStatus.syncReq == sync);
|
||||||
|
} else {
|
||||||
|
r = (pJob->opStatus.op == op);
|
||||||
|
}
|
||||||
SCH_UNLOCK(SCH_READ, &pJob->opStatus.lock);
|
SCH_UNLOCK(SCH_READ, &pJob->opStatus.lock);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -256,7 +256,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa
|
||||||
|
|
||||||
SCH_ERR_JRET(rsp->code);
|
SCH_ERR_JRET(rsp->code);
|
||||||
|
|
||||||
SCH_ERR_JRET(schSaveJobQueryRes(pJob, rsp));
|
SCH_ERR_JRET(schSaveJobExecRes(pJob, rsp));
|
||||||
|
|
||||||
atomic_add_fetch_32(&pJob->resNumOfRows, rsp->affectedRows);
|
atomic_add_fetch_32(&pJob->resNumOfRows, rsp->affectedRows);
|
||||||
|
|
||||||
|
@ -277,8 +277,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pJob->resData) {
|
if (pJob->fetchRes) {
|
||||||
SCH_TASK_ELOG("explain result is already generated, res:%p", pJob->resData);
|
SCH_TASK_ELOG("explain result is already generated, res:%p", pJob->fetchRes);
|
||||||
SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,13 +325,13 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pJob->resData) {
|
if (pJob->fetchRes) {
|
||||||
SCH_TASK_ELOG("got fetch rsp while res already exists, res:%p", pJob->resData);
|
SCH_TASK_ELOG("got fetch rsp while res already exists, res:%p", pJob->fetchRes);
|
||||||
taosMemoryFreeClear(rsp);
|
taosMemoryFreeClear(rsp);
|
||||||
SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_store_ptr(&pJob->resData, rsp);
|
atomic_store_ptr(&pJob->fetchRes, rsp);
|
||||||
atomic_add_fetch_32(&pJob->resNumOfRows, htonl(rsp->numOfRows));
|
atomic_add_fetch_32(&pJob->resNumOfRows, htonl(rsp->numOfRows));
|
||||||
|
|
||||||
if (rsp->completed) {
|
if (rsp->completed) {
|
||||||
|
@ -1010,6 +1010,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
memcpy(pMsg->msg + len, pTask->msg, pTask->msgLen);
|
memcpy(pMsg->msg + len, pTask->msg, pTask->msgLen);
|
||||||
|
|
||||||
persistHandle = true;
|
persistHandle = true;
|
||||||
|
SCH_SET_TASK_HANDLE(pTask, rpcAllocHandle());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_SCH_FETCH:
|
case TDMT_SCH_FETCH:
|
||||||
|
|
|
@ -47,10 +47,10 @@ void schFreeTask(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
void schInitTaskRetryTimes(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel) {
|
void schInitTaskRetryTimes(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel) {
|
||||||
if (SCH_IS_DATA_BIND_TASK(pTask) || (!SCH_IS_QUERY_JOB(pJob)) || (SCH_ALL != schMgmt.cfg.schPolicy)) {
|
if (SCH_IS_DATA_BIND_TASK(pTask) || (!SCH_IS_QUERY_JOB(pJob)) || (SCH_ALL != schMgmt.cfg.schPolicy)) {
|
||||||
pTask->maxRetryTimes = SCH_MAX_CANDIDATE_EP_NUM;
|
pTask->maxRetryTimes = SCH_DEFAULT_MAX_RETRY_NUM;
|
||||||
} else {
|
} else {
|
||||||
int32_t nodeNum = taosArrayGetSize(pJob->nodeList);
|
int32_t nodeNum = taosArrayGetSize(pJob->nodeList);
|
||||||
pTask->maxRetryTimes = TMAX(nodeNum, SCH_MAX_CANDIDATE_EP_NUM);
|
pTask->maxRetryTimes = TMAX(nodeNum, SCH_DEFAULT_MAX_RETRY_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTask->maxExecTimes = pTask->maxRetryTimes * (pLevel->level + 1);
|
pTask->maxExecTimes = pTask->maxRetryTimes * (pLevel->level + 1);
|
||||||
|
@ -64,11 +64,11 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *
|
||||||
pTask->execId = -1;
|
pTask->execId = -1;
|
||||||
pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||||
pTask->taskId = schGenTaskId();
|
pTask->taskId = schGenTaskId();
|
||||||
pTask->execNodes =
|
|
||||||
taosHashInit(SCH_MAX_CANDIDATE_EP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
|
||||||
|
|
||||||
schInitTaskRetryTimes(pJob, pTask, pLevel);
|
schInitTaskRetryTimes(pJob, pTask, pLevel);
|
||||||
|
|
||||||
|
pTask->execNodes =
|
||||||
|
taosHashInit(pTask->maxExecTimes, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
pTask->profile.execTime = taosArrayInit(pTask->maxExecTimes, sizeof(int64_t));
|
pTask->profile.execTime = taosArrayInit(pTask->maxExecTimes, sizeof(int64_t));
|
||||||
if (NULL == pTask->execNodes || NULL == pTask->profile.execTime) {
|
if (NULL == pTask->execNodes || NULL == pTask->profile.execTime) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
@ -125,8 +125,8 @@ int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_
|
||||||
SCH_TASK_DLOG("execId %d removed from execNodeList", execId);
|
SCH_TASK_DLOG("execId %d removed from execNodeList", execId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execId != pTask->execId) { // ignore it
|
if ((execId != pTask->execId) || pTask->waitRetry) { // ignore it
|
||||||
SCH_TASK_DLOG("execId %d is not current execId %d", execId, pTask->execId);
|
SCH_TASK_DLOG("execId %d is already not current execId %d, waitRetry %d", execId, pTask->execId, pTask->waitRetry);
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,17 @@ int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int3
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((execId != pTask->execId) || pTask->waitRetry) { // ignore it
|
||||||
|
SCH_TASK_DLOG("handle not updated since execId %d is already not current execId %d, waitRetry %d", execId, pTask->execId, pTask->waitRetry);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execId, sizeof(execId));
|
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execId, sizeof(execId));
|
||||||
|
if (NULL == nodeInfo) { // ignore it
|
||||||
|
SCH_TASK_DLOG("handle not updated since execId %d already not exist, current execId %d, waitRetry %d", execId, pTask->execId, pTask->waitRetry);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
nodeInfo->handle = handle;
|
nodeInfo->handle = handle;
|
||||||
|
|
||||||
SCH_TASK_DLOG("handle updated to %p for execId %d", handle, execId);
|
SCH_TASK_DLOG("handle updated to %p for execId %d", handle, execId);
|
||||||
|
@ -335,6 +345,7 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pTask->waitRetry = true;
|
||||||
schDropTaskOnExecNode(pJob, pTask);
|
schDropTaskOnExecNode(pJob, pTask);
|
||||||
taosHashClear(pTask->execNodes);
|
taosHashClear(pTask->execNodes);
|
||||||
SCH_ERR_JRET(schRemoveTaskFromExecList(pJob, pTask));
|
SCH_ERR_JRET(schRemoveTaskFromExecList(pJob, pTask));
|
||||||
|
@ -394,6 +405,18 @@ _return:
|
||||||
int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (JOB_TASK_STATUS_PART_SUCC == pJob->status) {
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
if (pJob->fetched) {
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
SCH_TASK_ELOG("already fetched while got error %s", tstrerror(rspCode));
|
||||||
|
SCH_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
|
||||||
|
schUpdateJobStatus(pJob, JOB_TASK_STATUS_EXEC);
|
||||||
|
}
|
||||||
|
|
||||||
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
if (SCH_IS_DATA_BIND_TASK(pTask)) {
|
||||||
if (NULL == pData->pEpSet) {
|
if (NULL == pData->pEpSet) {
|
||||||
SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode));
|
SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode));
|
||||||
|
@ -591,7 +614,7 @@ int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
if (pJob->nodeList) {
|
if (pJob->nodeList) {
|
||||||
nodeNum = taosArrayGetSize(pJob->nodeList);
|
nodeNum = taosArrayGetSize(pJob->nodeList);
|
||||||
|
|
||||||
for (int32_t i = 0; i < nodeNum && addNum < SCH_MAX_CANDIDATE_EP_NUM; ++i) {
|
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||||
SQueryNodeLoad *nload = taosArrayGet(pJob->nodeList, i);
|
SQueryNodeLoad *nload = taosArrayGet(pJob->nodeList, i);
|
||||||
SQueryNodeAddr *naddr = &nload->addr;
|
SQueryNodeAddr *naddr = &nload->addr;
|
||||||
|
|
||||||
|
@ -600,8 +623,8 @@ int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_TASK_DLOG("set %dth candidate addr, id %d, fqdn:%s, port:%d", i, naddr->nodeId, SCH_GET_CUR_EP(naddr)->fqdn,
|
SCH_TASK_TLOG("set %dth candidate addr, id %d, inUse:%d/%d, fqdn:%s, port:%d", i, naddr->nodeId, naddr->epSet.inUse, naddr->epSet.numOfEps,
|
||||||
SCH_GET_CUR_EP(naddr)->port);
|
SCH_GET_CUR_EP(naddr)->fqdn, SCH_GET_CUR_EP(naddr)->port);
|
||||||
|
|
||||||
++addNum;
|
++addNum;
|
||||||
}
|
}
|
||||||
|
@ -621,9 +644,9 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pTask->candidateIdx = 0;
|
pTask->candidateIdx = 0;
|
||||||
pTask->candidateAddrs = taosArrayInit(SCH_MAX_CANDIDATE_EP_NUM, sizeof(SQueryNodeAddr));
|
pTask->candidateAddrs = taosArrayInit(SCHEDULE_DEFAULT_MAX_NODE_NUM, sizeof(SQueryNodeAddr));
|
||||||
if (NULL == pTask->candidateAddrs) {
|
if (NULL == pTask->candidateAddrs) {
|
||||||
SCH_TASK_ELOG("taosArrayInit %d condidate addrs failed", SCH_MAX_CANDIDATE_EP_NUM);
|
SCH_TASK_ELOG("taosArrayInit %d condidate addrs failed", SCHEDULE_DEFAULT_MAX_NODE_NUM);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,6 +813,7 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
|
||||||
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||||
pTask->execId++;
|
pTask->execId++;
|
||||||
pTask->retryTimes++;
|
pTask->retryTimes++;
|
||||||
|
pTask->waitRetry = false;
|
||||||
|
|
||||||
SCH_TASK_DLOG("start to launch task, execId %d, retry %d", pTask->execId, pTask->retryTimes);
|
SCH_TASK_DLOG("start to launch task, execId %d, retry %d", pTask->execId, pTask->retryTimes);
|
||||||
|
|
||||||
|
@ -885,9 +909,9 @@ void schDropTaskInHashList(SSchJob *pJob, SHashObj *list) {
|
||||||
int32_t schLaunchFetchTask(SSchJob *pJob) {
|
int32_t schLaunchFetchTask(SSchJob *pJob) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
void *resData = atomic_load_ptr(&pJob->resData);
|
void *fetchRes = atomic_load_ptr(&pJob->fetchRes);
|
||||||
if (resData) {
|
if (fetchRes) {
|
||||||
SCH_JOB_DLOG("res already fetched, res:%p", resData);
|
SCH_JOB_DLOG("res already fetched, res:%p", fetchRes);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue