Merge branch '3.0' of https://github.com/taosdata/TDengine into refact/submit_req_marks
This commit is contained in:
commit
d7dce180e4
|
@ -1,6 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE OFF)
|
||||
set(TD_BUILD_TAOSA_INTERNAL FALSE)
|
||||
|
||||
#set output directory
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
|
||||
|
@ -141,13 +142,13 @@ ELSE ()
|
|||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
||||
ENDIF()
|
||||
IF (COMPILER_SUPPORT_FMA)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||
ENDIF()
|
||||
|
||||
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
||||
IF (COMPILER_SUPPORT_AVX)
|
||||
IF (COMPILER_SUPPORT_FMA)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||
ENDIF()
|
||||
IF (COMPILER_SUPPORT_AVX)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||
ENDIF()
|
||||
|
|
|
@ -21,7 +21,7 @@ IF (TD_LINUX)
|
|||
ELSEIF (TD_WINDOWS)
|
||||
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.bat")
|
||||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} :needAdmin ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Windows ${TD_VER_NUMBER})")
|
||||
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} :needAdmin ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Windows ${TD_VER_NUMBER} ${TD_BUILD_TAOSA_INTERNAL})")
|
||||
ELSEIF (TD_DARWIN)
|
||||
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
|
||||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.2.0")
|
||||
SET(TD_VER_NUMBER "3.0.2.1")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG f0c1753
|
||||
GIT_TAG a2e9920
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -30,6 +30,8 @@ database_option: {
|
|||
| WAL_LEVEL {1 | 2}
|
||||
| VGROUPS value
|
||||
| SINGLE_STABLE {0 | 1}
|
||||
| TABLE_PREFIX value
|
||||
| TABLE_SUFFIX value
|
||||
| WAL_RETENTION_PERIOD value
|
||||
| WAL_ROLL_PERIOD value
|
||||
| WAL_RETENTION_SIZE value
|
||||
|
@ -67,6 +69,8 @@ database_option: {
|
|||
- SINGLE_STABLE: specifies whether the database can contain more than one supertable.
|
||||
- 0: The database can contain multiple supertables.
|
||||
- 1: The database can contain only one supertable.
|
||||
- TABLE_PREFIX:The prefix length in the table name that is ignored when distributing table to vnode based on table name.
|
||||
- TABLE_SUFFIX:The suffix length in the table name that is ignored when distributing table to vnode based on table name.
|
||||
- WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription. Enter a time in seconds. The default value of single copy is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted. The default value of multiple copy is 4 days.
|
||||
- WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription. Enter a size in KB. The default value of single copy is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted. The default value of multiple copy is -1.
|
||||
- WAL_ROLL_PERIOD: specifies the time after which WAL files are rotated. After this period elapses, a new WAL file is created. The default value of single copy is 0. A value of 0 indicates that a new WAL file is created only after the previous WAL file was written to disk. The default values of multiple copy is 1 day.
|
||||
|
|
|
@ -17,6 +17,7 @@ The following list shows all reserved keywords:
|
|||
- ADD
|
||||
- AFTER
|
||||
- AGGREGATE
|
||||
- ALIVE
|
||||
- ALL
|
||||
- ALTER
|
||||
- ANALYZE
|
||||
|
|
|
@ -178,76 +178,138 @@ SHOW TABLE DISTRIBUTED table_name;
|
|||
|
||||
Shows how table data is distributed.
|
||||
|
||||
Examples: show table distributed d0\G; Display the block distribution of table `d0` in detailed format.
|
||||
Examples: Below is an example of this command to display the block distribution of table `d0` in detailed format.
|
||||
|
||||
```sql
|
||||
show table distributed d0\G;
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary> Show Example </summary>
|
||||
<pre><code>
|
||||
*************************** 1.row ***************************
|
||||
_block_dist: Total_Blocks=[5] Total_Size=[93.65 Kb] Average_size=[18.73 Kb] Compression_Ratio=[23.98 %]
|
||||
|
||||
Total_Blocks : Table `d0` contains total 5 blocks
|
||||
|
||||
Total_Size: The total size of all the data blocks in table `d0` is 93.65 KB
|
||||
|
||||
Average_size: The average size of each block is 18.73 KB
|
||||
|
||||
Compression_Ratio: The data compression rate is 23.98%
|
||||
|
||||
*************************** 2.row ***************************
|
||||
_block_dist: Total_Rows=[20000] Inmem_Rows=[0] MinRows=[3616] MaxRows=[4096] Average_Rows=[4000]
|
||||
|
||||
Total_Rows: Table `d0` contains 20,000 rows
|
||||
|
||||
Inmem_Rows: The rows still in memory, i.e. not committed in disk, is 0, i.e. none such rows
|
||||
|
||||
MinRows: The minimum number of rows in a block is 3,616
|
||||
|
||||
MaxRows: The maximum number of rows in a block is 4,096B
|
||||
|
||||
Average_Rows: The average number of rows in a block is 4,000
|
||||
|
||||
*************************** 3.row ***************************
|
||||
_block_dist: Total_Tables=[1] Total_Files=[2]
|
||||
|
||||
Total_Tables: The number of child tables, 1 in this example
|
||||
|
||||
Total_Files: The number of files storing the table's data, 2 in this example
|
||||
|
||||
*************************** 4.row ***************************
|
||||
|
||||
_block_dist: --------------------------------------------------------------------------------
|
||||
|
||||
*************************** 5.row ***************************
|
||||
|
||||
_block_dist: 0100 |
|
||||
|
||||
*************************** 6.row ***************************
|
||||
|
||||
_block_dist: 0299 |
|
||||
|
||||
*************************** 7.row ***************************
|
||||
|
||||
_block_dist: 0498 |
|
||||
|
||||
*************************** 8.row ***************************
|
||||
|
||||
_block_dist: 0697 |
|
||||
|
||||
*************************** 9.row ***************************
|
||||
|
||||
_block_dist: 0896 |
|
||||
|
||||
*************************** 10.row ***************************
|
||||
|
||||
_block_dist: 1095 |
|
||||
|
||||
*************************** 11.row ***************************
|
||||
|
||||
_block_dist: 1294 |
|
||||
|
||||
*************************** 12.row ***************************
|
||||
|
||||
_block_dist: 1493 |
|
||||
|
||||
*************************** 13.row ***************************
|
||||
|
||||
_block_dist: 1692 |
|
||||
|
||||
*************************** 14.row ***************************
|
||||
|
||||
_block_dist: 1891 |
|
||||
|
||||
*************************** 15.row ***************************
|
||||
|
||||
_block_dist: 2090 |
|
||||
|
||||
*************************** 16.row ***************************
|
||||
|
||||
_block_dist: 2289 |
|
||||
|
||||
*************************** 17.row ***************************
|
||||
|
||||
_block_dist: 2488 |
|
||||
|
||||
*************************** 18.row ***************************
|
||||
|
||||
_block_dist: 2687 |
|
||||
|
||||
*************************** 19.row ***************************
|
||||
|
||||
_block_dist: 2886 |
|
||||
|
||||
*************************** 20.row ***************************
|
||||
|
||||
_block_dist: 3085 |
|
||||
|
||||
*************************** 21.row ***************************
|
||||
|
||||
_block_dist: 3284 |
|
||||
|
||||
*************************** 22.row ***************************
|
||||
|
||||
_block_dist: 3483 ||||||||||||||||| 1 (20.00%)
|
||||
|
||||
*************************** 23.row ***************************
|
||||
|
||||
_block_dist: 3682 |
|
||||
|
||||
*************************** 24.row ***************************
|
||||
|
||||
_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)
|
||||
|
||||
Query OK, 24 row(s) in set (0.002444s)
|
||||
|
||||
The above show the block distribution percentage according to the number of rows in each block. In the above example, `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681. `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. The number of blocks whose rows fall in other range is zero.
|
||||
</code></pre>
|
||||
</details>
|
||||
|
||||
The above show the block distribution percentage according to the number of rows in each block. In the above example, we can get below information:
|
||||
- `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681.
|
||||
- `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. - The number of blocks whose rows fall in other range is zero.
|
||||
|
||||
## SHOW TAGS
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ taosAdapter provides the following features.
|
|||
- Seamless connection to collectd
|
||||
- Seamless connection to StatsD
|
||||
- Supports Prometheus remote_read and remote_write
|
||||
- Get table's VGroup ID
|
||||
|
||||
## taosAdapter architecture diagram
|
||||
|
||||
|
@ -178,6 +179,7 @@ See [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/bl
|
|||
node_export is an exporter for machine metrics. Please visit [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter) for more information.
|
||||
- Support for Prometheus remote_read and remote_write
|
||||
remote_read and remote_write are interfaces for Prometheus data read and write from/to other data storage solution. Please visit [https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis](https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis) for more information.
|
||||
- Get table's VGroup ID. For more information about VGroup, please refer to [primary-logic-unit](/tdinternal/arch/#primary-logic-unit).
|
||||
|
||||
## Interfaces
|
||||
|
||||
|
@ -199,7 +201,7 @@ Support InfluxDB query parameters as follows.
|
|||
- `precision` The time precision used by TDengine
|
||||
- `u` TDengine user name
|
||||
- `p` TDengine password
|
||||
- `ttl` The time to live of automatically created sub-table. This value cannot be updated. TDengine will use the ttl value of the frist data of sub-table to create sub-table. For more information, please refer [Create Table](/taos-sql/table/#create-table)
|
||||
- `ttl` The time to live of automatically created sub-table. This value cannot be updated. TDengine will use the ttl value of the first data of sub-table to create sub-table. For more information, please refer [Create Table](/taos-sql/table/#create-table)
|
||||
|
||||
Note: InfluxDB token authorization is not supported at present. Only Basic authorization and query parameter validation are supported.
|
||||
Example: curl --request POST http://127.0.0.1:6041/influxdb/v1/write?db=test --user "root:taosdata" --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
|
||||
|
@ -241,6 +243,10 @@ node_export is an exporter of hardware and OS metrics exposed by the \*NIX kerne
|
|||
|
||||
<Prometheus />
|
||||
|
||||
### Get table's VGroup ID
|
||||
|
||||
You can call `http://<fqdn>:6041/rest/vgid?db=<db>&table=<table>` to get table's VGroup ID. For more information about VGroup, please refer to [primary-logic-unit](/tdinternal/arch/#primary-logic-unit).
|
||||
|
||||
## Memory usage optimization methods
|
||||
|
||||
taosAdapter will monitor its memory usage during operation and adjust it with two thresholds. Valid values are integers between 1 to 100, and represent a percentage of the system's physical memory.
|
||||
|
|
|
@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.2.2
|
||||
|
||||
<Release type="tdengine" version="3.0.2.2" />
|
||||
|
||||
## 3.0.2.1
|
||||
|
||||
<Release type="tdengine" version="3.0.2.1" />
|
||||
|
|
|
@ -10,6 +10,10 @@ For other historical version installers, please visit [here](https://www.taosdat
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.4.0
|
||||
|
||||
<Release type="tools" version="2.4.0" />
|
||||
|
||||
## 2.3.3
|
||||
|
||||
<Release type="tools" version="2.3.3" />
|
||||
|
|
|
@ -30,6 +30,8 @@ database_option: {
|
|||
| WAL_LEVEL {1 | 2}
|
||||
| VGROUPS value
|
||||
| SINGLE_STABLE {0 | 1}
|
||||
| TABLE_PREFIX value
|
||||
| TABLE_SUFFIX value
|
||||
| WAL_RETENTION_PERIOD value
|
||||
| WAL_ROLL_PERIOD value
|
||||
| WAL_RETENTION_SIZE value
|
||||
|
@ -67,6 +69,8 @@ database_option: {
|
|||
- SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。
|
||||
- 0:表示可以创建多张超级表。
|
||||
- 1:表示只可以创建一张超级表。
|
||||
- TABLE_PREFIX:内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的前缀的长度。
|
||||
- TABLE_SUFFIX:内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的后缀的长度。
|
||||
- WAL_RETENTION_PERIOD:wal 文件的额外保留策略,用于数据订阅。wal 的保存时长,单位为 s。单副本默认为 0,即落盘后立即删除。-1 表示不删除。多副本默认为 4 天。
|
||||
- WAL_RETENTION_SIZE:wal 文件的额外保留策略,用于数据订阅。wal 的保存的最大上限,单位为 KB。单副本默认为 0,即落盘后立即删除。多副本默认为-1,表示不删除。
|
||||
- WAL_ROLL_PERIOD:wal 文件切换时长,单位为 s。当 wal 文件创建并写入后,经过该时间,会自动创建一个新的 wal 文件。单副本默认为 0,即仅在落盘时创建新文件。多副本默认为 1 天。
|
||||
|
|
|
@ -18,6 +18,7 @@ description: TDengine 保留关键字的详细列表
|
|||
- ADD
|
||||
- AFTER
|
||||
- AGGREGATE
|
||||
- ALIVE
|
||||
- ALL
|
||||
- ALTER
|
||||
- ANALYZE
|
||||
|
|
|
@ -183,6 +183,10 @@ SHOW TABLE DISTRIBUTED table_name;
|
|||
|
||||
语句: show table distributed d0\G; 竖行显示表 d0 的 BLOCK 分布情况
|
||||
|
||||
<details>
|
||||
<summary>显示示例</summary>
|
||||
<pre><code>
|
||||
|
||||
*************************** 1.row ***************************
|
||||
|
||||
_block_dist: Total_Blocks=[5] Total_Size=[93.65 Kb] Average_size=[18.73 Kb] Compression_Ratio=[23.98 %]
|
||||
|
@ -244,6 +248,8 @@ _block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||
|
||||
Query OK, 24 row(s) in set (0.002444s)
|
||||
|
||||
</code></pre>
|
||||
</details>
|
||||
|
||||
上面是块中包含数据行数的块儿分布情况图,这里的 0100 0299 0498 … 表示的是每个块中包含的数据行数,上面的意思就是这个表的 5 个块,分布在 3483 ~3681 行的块有 1 个,占整个块的 20%,分布在 3881 ~ 4096(最大行数)的块数为 4 个,占整个块的 80%, 其它区域内分布块数为 0。
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ description: "TDengine 3.0 版本的语法变更说明"
|
|||
| 9 | SAMPLE | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。
|
||||
| 10 | STATECOUNT | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。
|
||||
| 11 | STATEDURATION | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。
|
||||
| 12 | TIMETRUNCATE | 增强 | 增加ignore_timezone参数,可选是否使用,默认值为1.
|
||||
|
||||
|
||||
## SCHEMALESS 变更
|
||||
|
|
|
@ -21,6 +21,7 @@ taosAdapter 提供以下功能:
|
|||
- 无缝连接到 collectd
|
||||
- 无缝连接到 StatsD
|
||||
- 支持 Prometheus remote_read 和 remote_write
|
||||
- 获取 table 所在的虚拟节点组(VGroup)的 VGroup ID
|
||||
|
||||
## taosAdapter 架构图
|
||||
|
||||
|
@ -178,6 +179,7 @@ AllowWebSockets
|
|||
node_export 是一个机器指标的导出器。请访问 [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter) 了解更多信息。
|
||||
- 支持 Prometheus remote_read 和 remote_write
|
||||
remote_read 和 remote_write 是 Prometheus 数据读写分离的集群方案。请访问[https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis](https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis) 了解更多信息。
|
||||
- 获取 table 所在的虚拟节点组(VGroup)的 VGroup ID。关于虚拟节点组(VGroup)的更多信息,请访问[整体架构文档](/tdinternal/arch/#主要逻辑单元) 。
|
||||
|
||||
## 接口
|
||||
|
||||
|
@ -240,6 +242,10 @@ Prometheus 使用的由 \*NIX 内核暴露的硬件和操作系统指标的输
|
|||
|
||||
<Prometheus />
|
||||
|
||||
### 获取 table 的 VGroup ID
|
||||
|
||||
可以访问 http 接口 `http://<fqdn>:6041/rest/vgid?db=<db>&table=<table>` 获取 table 的 VGroup ID。关于虚拟节点组(VGroup)的更多信息,请访问[整体架构文档](/tdinternal/arch/#主要逻辑单元) 。
|
||||
|
||||
## 内存使用优化方法
|
||||
|
||||
taosAdapter 将监测自身运行过程中内存使用率并通过两个阈值进行调节。有效值范围为 -1 到 100 的整数,单位为系统物理内存的百分比。
|
||||
|
@ -282,7 +288,7 @@ http 返回内容:
|
|||
|
||||
## taosAdapter 监控指标
|
||||
|
||||
taosAdapter 采集 http 相关指标、cpu 百分比和内存百分比。
|
||||
taosAdapter 采集 http 相关指标、CPU 百分比和内存百分比。
|
||||
|
||||
### http 接口
|
||||
|
||||
|
@ -294,13 +300,13 @@ http://<fqdn>:6041/metrics
|
|||
|
||||
### 写入 TDengine
|
||||
|
||||
taosAdapter 支持将 http 监控、cpu 百分比和内存百分比写入 TDengine。
|
||||
taosAdapter 支持将 http 监控、CPU 百分比和内存百分比写入 TDengine。
|
||||
|
||||
有关配置参数
|
||||
|
||||
| **配置项** | **描述** | **默认值** |
|
||||
|-------------------------|--------------------------------------------|----------|
|
||||
| monitor.collectDuration | cpu 和内存采集间隔 | 3s |
|
||||
| monitor.collectDuration | CPU 和内存采集间隔 | 3s |
|
||||
| monitor.identity | 当前taosadapter 的标识符如果不设置将使用 'hostname:port' | |
|
||||
| monitor.incgroup | 是否是 cgroup 中运行(容器中运行设置为 true) | false |
|
||||
| monitor.writeToTD | 是否写入到 TDengine | false |
|
||||
|
|
|
@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.2.2
|
||||
|
||||
<Release type="tdengine" version="3.0.2.2" />
|
||||
|
||||
## 3.0.2.1
|
||||
|
||||
<Release type="tdengine" version="3.0.2.1" />
|
||||
|
|
|
@ -10,6 +10,10 @@ taosTools 各版本安装包下载链接如下:
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.4.0
|
||||
|
||||
<Release type="tools" version="2.4.0" />
|
||||
|
||||
## 2.3.3
|
||||
|
||||
<Release type="tools" version="2.3.3" />
|
||||
|
|
|
@ -30,6 +30,11 @@ typedef int64_t tb_uid_t;
|
|||
#define IS_TSWINDOW_SPECIFIED(win) (((win).skey != INT64_MIN) || ((win).ekey != INT64_MAX))
|
||||
#define TSWINDOW_IS_EQUAL(t1, t2) (((t1).skey == (t2).skey) && ((t1).ekey == (t2).ekey))
|
||||
|
||||
//define show cluster alive and show db.alive
|
||||
#define SHOW_STATUS_NOT_AVAILABLE 0
|
||||
#define SHOW_STATUS_AVAILABLE 1
|
||||
#define SHOW_STATUS_HALF_AVAILABLE 2
|
||||
|
||||
typedef enum {
|
||||
TSDB_SUPER_TABLE = 1, // super table
|
||||
TSDB_CHILD_TABLE = 2, // table created from super table
|
||||
|
|
|
@ -292,6 +292,7 @@ typedef struct STableBlockDistInfo {
|
|||
uint16_t numOfFiles;
|
||||
uint32_t numOfTables;
|
||||
uint32_t numOfBlocks;
|
||||
uint32_t numOfVgroups;
|
||||
uint64_t totalSize;
|
||||
uint64_t totalRows;
|
||||
int32_t maxRows;
|
||||
|
|
|
@ -55,7 +55,7 @@ extern int32_t tsNumOfMnodeQueryThreads;
|
|||
extern int32_t tsNumOfMnodeFetchThreads;
|
||||
extern int32_t tsNumOfMnodeReadThreads;
|
||||
extern int32_t tsNumOfVnodeQueryThreads;
|
||||
extern int32_t tsNumOfVnodeStreamThreads;
|
||||
extern float tsRatioOfVnodeStreamThreads;
|
||||
extern int32_t tsNumOfVnodeFetchThreads;
|
||||
extern int32_t tsNumOfVnodeRsmaThreads;
|
||||
extern int32_t tsNumOfQnodeQueryThreads;
|
||||
|
|
|
@ -1751,6 +1751,8 @@ typedef struct {
|
|||
#define STREAM_FILL_HISTORY_ON 1
|
||||
#define STREAM_FILL_HISTORY_OFF 0
|
||||
#define STREAM_DEFAULT_FILL_HISTORY STREAM_FILL_HISTORY_OFF
|
||||
#define STREAM_CREATE_STABLE_TRUE 1
|
||||
#define STREAM_CREATE_STABLE_FALSE 0
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_STREAM_FNAME_LEN];
|
||||
|
@ -1768,6 +1770,8 @@ typedef struct {
|
|||
SArray* pTags; // array of SField
|
||||
// 3.0.20
|
||||
int64_t checkpointFreq; // ms
|
||||
// 3.0.2.3
|
||||
int8_t createStb;
|
||||
} SCMCreateStreamReq;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -175,171 +175,172 @@
|
|||
#define TK_CONSUMERS 157
|
||||
#define TK_SUBSCRIPTIONS 158
|
||||
#define TK_VNODES 159
|
||||
#define TK_LIKE 160
|
||||
#define TK_TBNAME 161
|
||||
#define TK_QTAGS 162
|
||||
#define TK_AS 163
|
||||
#define TK_INDEX 164
|
||||
#define TK_FUNCTION 165
|
||||
#define TK_INTERVAL 166
|
||||
#define TK_COUNT 167
|
||||
#define TK_LAST_ROW 168
|
||||
#define TK_TOPIC 169
|
||||
#define TK_WITH 170
|
||||
#define TK_META 171
|
||||
#define TK_CONSUMER 172
|
||||
#define TK_GROUP 173
|
||||
#define TK_DESC 174
|
||||
#define TK_DESCRIBE 175
|
||||
#define TK_RESET 176
|
||||
#define TK_QUERY 177
|
||||
#define TK_CACHE 178
|
||||
#define TK_EXPLAIN 179
|
||||
#define TK_ANALYZE 180
|
||||
#define TK_VERBOSE 181
|
||||
#define TK_NK_BOOL 182
|
||||
#define TK_RATIO 183
|
||||
#define TK_NK_FLOAT 184
|
||||
#define TK_OUTPUTTYPE 185
|
||||
#define TK_AGGREGATE 186
|
||||
#define TK_BUFSIZE 187
|
||||
#define TK_STREAM 188
|
||||
#define TK_INTO 189
|
||||
#define TK_TRIGGER 190
|
||||
#define TK_AT_ONCE 191
|
||||
#define TK_WINDOW_CLOSE 192
|
||||
#define TK_IGNORE 193
|
||||
#define TK_EXPIRED 194
|
||||
#define TK_FILL_HISTORY 195
|
||||
#define TK_SUBTABLE 196
|
||||
#define TK_KILL 197
|
||||
#define TK_CONNECTION 198
|
||||
#define TK_TRANSACTION 199
|
||||
#define TK_BALANCE 200
|
||||
#define TK_VGROUP 201
|
||||
#define TK_MERGE 202
|
||||
#define TK_REDISTRIBUTE 203
|
||||
#define TK_SPLIT 204
|
||||
#define TK_DELETE 205
|
||||
#define TK_INSERT 206
|
||||
#define TK_NULL 207
|
||||
#define TK_NK_QUESTION 208
|
||||
#define TK_NK_ARROW 209
|
||||
#define TK_ROWTS 210
|
||||
#define TK_QSTART 211
|
||||
#define TK_QEND 212
|
||||
#define TK_QDURATION 213
|
||||
#define TK_WSTART 214
|
||||
#define TK_WEND 215
|
||||
#define TK_WDURATION 216
|
||||
#define TK_IROWTS 217
|
||||
#define TK_ISFILLED 218
|
||||
#define TK_CAST 219
|
||||
#define TK_NOW 220
|
||||
#define TK_TODAY 221
|
||||
#define TK_TIMEZONE 222
|
||||
#define TK_CLIENT_VERSION 223
|
||||
#define TK_SERVER_VERSION 224
|
||||
#define TK_SERVER_STATUS 225
|
||||
#define TK_CURRENT_USER 226
|
||||
#define TK_CASE 227
|
||||
#define TK_END 228
|
||||
#define TK_WHEN 229
|
||||
#define TK_THEN 230
|
||||
#define TK_ELSE 231
|
||||
#define TK_BETWEEN 232
|
||||
#define TK_IS 233
|
||||
#define TK_NK_LT 234
|
||||
#define TK_NK_GT 235
|
||||
#define TK_NK_LE 236
|
||||
#define TK_NK_GE 237
|
||||
#define TK_NK_NE 238
|
||||
#define TK_MATCH 239
|
||||
#define TK_NMATCH 240
|
||||
#define TK_CONTAINS 241
|
||||
#define TK_IN 242
|
||||
#define TK_JOIN 243
|
||||
#define TK_INNER 244
|
||||
#define TK_SELECT 245
|
||||
#define TK_DISTINCT 246
|
||||
#define TK_WHERE 247
|
||||
#define TK_PARTITION 248
|
||||
#define TK_BY 249
|
||||
#define TK_SESSION 250
|
||||
#define TK_STATE_WINDOW 251
|
||||
#define TK_EVENT_WINDOW 252
|
||||
#define TK_START 253
|
||||
#define TK_SLIDING 254
|
||||
#define TK_FILL 255
|
||||
#define TK_VALUE 256
|
||||
#define TK_NONE 257
|
||||
#define TK_PREV 258
|
||||
#define TK_LINEAR 259
|
||||
#define TK_NEXT 260
|
||||
#define TK_HAVING 261
|
||||
#define TK_RANGE 262
|
||||
#define TK_EVERY 263
|
||||
#define TK_ORDER 264
|
||||
#define TK_SLIMIT 265
|
||||
#define TK_SOFFSET 266
|
||||
#define TK_LIMIT 267
|
||||
#define TK_OFFSET 268
|
||||
#define TK_ASC 269
|
||||
#define TK_NULLS 270
|
||||
#define TK_ABORT 271
|
||||
#define TK_AFTER 272
|
||||
#define TK_ATTACH 273
|
||||
#define TK_BEFORE 274
|
||||
#define TK_BEGIN 275
|
||||
#define TK_BITAND 276
|
||||
#define TK_BITNOT 277
|
||||
#define TK_BITOR 278
|
||||
#define TK_BLOCKS 279
|
||||
#define TK_CHANGE 280
|
||||
#define TK_COMMA 281
|
||||
#define TK_COMPACT 282
|
||||
#define TK_CONCAT 283
|
||||
#define TK_CONFLICT 284
|
||||
#define TK_COPY 285
|
||||
#define TK_DEFERRED 286
|
||||
#define TK_DELIMITERS 287
|
||||
#define TK_DETACH 288
|
||||
#define TK_DIVIDE 289
|
||||
#define TK_DOT 290
|
||||
#define TK_EACH 291
|
||||
#define TK_FAIL 292
|
||||
#define TK_FILE 293
|
||||
#define TK_FOR 294
|
||||
#define TK_GLOB 295
|
||||
#define TK_ID 296
|
||||
#define TK_IMMEDIATE 297
|
||||
#define TK_IMPORT 298
|
||||
#define TK_INITIALLY 299
|
||||
#define TK_INSTEAD 300
|
||||
#define TK_ISNULL 301
|
||||
#define TK_KEY 302
|
||||
#define TK_MODULES 303
|
||||
#define TK_NK_BITNOT 304
|
||||
#define TK_NK_SEMI 305
|
||||
#define TK_NOTNULL 306
|
||||
#define TK_OF 307
|
||||
#define TK_PLUS 308
|
||||
#define TK_PRIVILEGE 309
|
||||
#define TK_RAISE 310
|
||||
#define TK_REPLACE 311
|
||||
#define TK_RESTRICT 312
|
||||
#define TK_ROW 313
|
||||
#define TK_SEMI 314
|
||||
#define TK_STAR 315
|
||||
#define TK_STATEMENT 316
|
||||
#define TK_STRICT 317
|
||||
#define TK_STRING 318
|
||||
#define TK_TIMES 319
|
||||
#define TK_UPDATE 320
|
||||
#define TK_VALUES 321
|
||||
#define TK_VARIABLE 322
|
||||
#define TK_VIEW 323
|
||||
#define TK_WAL 324
|
||||
#define TK_ALIVE 160
|
||||
#define TK_LIKE 161
|
||||
#define TK_TBNAME 162
|
||||
#define TK_QTAGS 163
|
||||
#define TK_AS 164
|
||||
#define TK_INDEX 165
|
||||
#define TK_FUNCTION 166
|
||||
#define TK_INTERVAL 167
|
||||
#define TK_COUNT 168
|
||||
#define TK_LAST_ROW 169
|
||||
#define TK_TOPIC 170
|
||||
#define TK_WITH 171
|
||||
#define TK_META 172
|
||||
#define TK_CONSUMER 173
|
||||
#define TK_GROUP 174
|
||||
#define TK_DESC 175
|
||||
#define TK_DESCRIBE 176
|
||||
#define TK_RESET 177
|
||||
#define TK_QUERY 178
|
||||
#define TK_CACHE 179
|
||||
#define TK_EXPLAIN 180
|
||||
#define TK_ANALYZE 181
|
||||
#define TK_VERBOSE 182
|
||||
#define TK_NK_BOOL 183
|
||||
#define TK_RATIO 184
|
||||
#define TK_NK_FLOAT 185
|
||||
#define TK_OUTPUTTYPE 186
|
||||
#define TK_AGGREGATE 187
|
||||
#define TK_BUFSIZE 188
|
||||
#define TK_STREAM 189
|
||||
#define TK_INTO 190
|
||||
#define TK_TRIGGER 191
|
||||
#define TK_AT_ONCE 192
|
||||
#define TK_WINDOW_CLOSE 193
|
||||
#define TK_IGNORE 194
|
||||
#define TK_EXPIRED 195
|
||||
#define TK_FILL_HISTORY 196
|
||||
#define TK_SUBTABLE 197
|
||||
#define TK_KILL 198
|
||||
#define TK_CONNECTION 199
|
||||
#define TK_TRANSACTION 200
|
||||
#define TK_BALANCE 201
|
||||
#define TK_VGROUP 202
|
||||
#define TK_MERGE 203
|
||||
#define TK_REDISTRIBUTE 204
|
||||
#define TK_SPLIT 205
|
||||
#define TK_DELETE 206
|
||||
#define TK_INSERT 207
|
||||
#define TK_NULL 208
|
||||
#define TK_NK_QUESTION 209
|
||||
#define TK_NK_ARROW 210
|
||||
#define TK_ROWTS 211
|
||||
#define TK_QSTART 212
|
||||
#define TK_QEND 213
|
||||
#define TK_QDURATION 214
|
||||
#define TK_WSTART 215
|
||||
#define TK_WEND 216
|
||||
#define TK_WDURATION 217
|
||||
#define TK_IROWTS 218
|
||||
#define TK_ISFILLED 219
|
||||
#define TK_CAST 220
|
||||
#define TK_NOW 221
|
||||
#define TK_TODAY 222
|
||||
#define TK_TIMEZONE 223
|
||||
#define TK_CLIENT_VERSION 224
|
||||
#define TK_SERVER_VERSION 225
|
||||
#define TK_SERVER_STATUS 226
|
||||
#define TK_CURRENT_USER 227
|
||||
#define TK_CASE 228
|
||||
#define TK_END 229
|
||||
#define TK_WHEN 230
|
||||
#define TK_THEN 231
|
||||
#define TK_ELSE 232
|
||||
#define TK_BETWEEN 233
|
||||
#define TK_IS 234
|
||||
#define TK_NK_LT 235
|
||||
#define TK_NK_GT 236
|
||||
#define TK_NK_LE 237
|
||||
#define TK_NK_GE 238
|
||||
#define TK_NK_NE 239
|
||||
#define TK_MATCH 240
|
||||
#define TK_NMATCH 241
|
||||
#define TK_CONTAINS 242
|
||||
#define TK_IN 243
|
||||
#define TK_JOIN 244
|
||||
#define TK_INNER 245
|
||||
#define TK_SELECT 246
|
||||
#define TK_DISTINCT 247
|
||||
#define TK_WHERE 248
|
||||
#define TK_PARTITION 249
|
||||
#define TK_BY 250
|
||||
#define TK_SESSION 251
|
||||
#define TK_STATE_WINDOW 252
|
||||
#define TK_EVENT_WINDOW 253
|
||||
#define TK_START 254
|
||||
#define TK_SLIDING 255
|
||||
#define TK_FILL 256
|
||||
#define TK_VALUE 257
|
||||
#define TK_NONE 258
|
||||
#define TK_PREV 259
|
||||
#define TK_LINEAR 260
|
||||
#define TK_NEXT 261
|
||||
#define TK_HAVING 262
|
||||
#define TK_RANGE 263
|
||||
#define TK_EVERY 264
|
||||
#define TK_ORDER 265
|
||||
#define TK_SLIMIT 266
|
||||
#define TK_SOFFSET 267
|
||||
#define TK_LIMIT 268
|
||||
#define TK_OFFSET 269
|
||||
#define TK_ASC 270
|
||||
#define TK_NULLS 271
|
||||
#define TK_ABORT 272
|
||||
#define TK_AFTER 273
|
||||
#define TK_ATTACH 274
|
||||
#define TK_BEFORE 275
|
||||
#define TK_BEGIN 276
|
||||
#define TK_BITAND 277
|
||||
#define TK_BITNOT 278
|
||||
#define TK_BITOR 279
|
||||
#define TK_BLOCKS 280
|
||||
#define TK_CHANGE 281
|
||||
#define TK_COMMA 282
|
||||
#define TK_COMPACT 283
|
||||
#define TK_CONCAT 284
|
||||
#define TK_CONFLICT 285
|
||||
#define TK_COPY 286
|
||||
#define TK_DEFERRED 287
|
||||
#define TK_DELIMITERS 288
|
||||
#define TK_DETACH 289
|
||||
#define TK_DIVIDE 290
|
||||
#define TK_DOT 291
|
||||
#define TK_EACH 292
|
||||
#define TK_FAIL 293
|
||||
#define TK_FILE 294
|
||||
#define TK_FOR 295
|
||||
#define TK_GLOB 296
|
||||
#define TK_ID 297
|
||||
#define TK_IMMEDIATE 298
|
||||
#define TK_IMPORT 299
|
||||
#define TK_INITIALLY 300
|
||||
#define TK_INSTEAD 301
|
||||
#define TK_ISNULL 302
|
||||
#define TK_KEY 303
|
||||
#define TK_MODULES 304
|
||||
#define TK_NK_BITNOT 305
|
||||
#define TK_NK_SEMI 306
|
||||
#define TK_NOTNULL 307
|
||||
#define TK_OF 308
|
||||
#define TK_PLUS 309
|
||||
#define TK_PRIVILEGE 310
|
||||
#define TK_RAISE 311
|
||||
#define TK_REPLACE 312
|
||||
#define TK_RESTRICT 313
|
||||
#define TK_ROW 314
|
||||
#define TK_SEMI 315
|
||||
#define TK_STAR 316
|
||||
#define TK_STATEMENT 317
|
||||
#define TK_STRICT 318
|
||||
#define TK_STRING 319
|
||||
#define TK_TIMES 320
|
||||
#define TK_UPDATE 321
|
||||
#define TK_VALUES 322
|
||||
#define TK_VARIABLE 323
|
||||
#define TK_VIEW 324
|
||||
#define TK_WAL 325
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef enum {
|
|||
AUTH_TYPE_READ = 1,
|
||||
AUTH_TYPE_WRITE,
|
||||
AUTH_TYPE_OTHER,
|
||||
AUTH_TYPE_READ_OR_WRITE,
|
||||
} AUTH_TYPE;
|
||||
|
||||
typedef struct SUserAuthInfo {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
typedef struct SExplainCtx SExplainCtx;
|
||||
|
||||
int32_t qExecCommand(bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp);
|
||||
|
||||
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs);
|
||||
|
|
|
@ -215,6 +215,7 @@ int32_t qStreamSourceRecoverStep1(qTaskInfo_t tinfo, int64_t ver);
|
|||
int32_t qStreamSourceRecoverStep2(qTaskInfo_t tinfo, int64_t ver);
|
||||
int32_t qStreamRecoverFinish(qTaskInfo_t tinfo);
|
||||
int32_t qStreamRestoreParam(qTaskInfo_t tinfo);
|
||||
bool qStreamRecoverScanFinished(qTaskInfo_t tinfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
|||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define SHOW_ALIVE_RESULT_COLS 1
|
||||
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
|
||||
|
||||
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
|
||||
|
@ -262,6 +263,11 @@ typedef struct SShowCreateDatabaseStmt {
|
|||
void* pCfg; // SDbCfgInfo
|
||||
} SShowCreateDatabaseStmt;
|
||||
|
||||
typedef struct SShowAliveStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
} SShowAliveStmt;
|
||||
|
||||
typedef struct SShowCreateTableStmt {
|
||||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
|
@ -295,7 +301,7 @@ typedef struct SShowTableTagsStmt {
|
|||
SNodeList* pTags;
|
||||
} SShowTableTagsStmt;
|
||||
|
||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
|
||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
|
||||
|
||||
typedef struct SIndexOptions {
|
||||
ENodeType type;
|
||||
|
@ -401,6 +407,7 @@ typedef struct SCreateStreamStmt {
|
|||
SNode* pQuery;
|
||||
SNodeList* pTags;
|
||||
SNode* pSubtable;
|
||||
SNodeList* pCols;
|
||||
} SCreateStreamStmt;
|
||||
|
||||
typedef struct SDropStreamStmt {
|
||||
|
|
|
@ -208,6 +208,8 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_DELETE_STMT,
|
||||
QUERY_NODE_INSERT_STMT,
|
||||
QUERY_NODE_QUERY,
|
||||
QUERY_NODE_SHOW_DB_ALIVE_STMT,
|
||||
QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef struct SExprNode {
|
|||
char userAlias[TSDB_COL_NAME_LEN];
|
||||
SArray* pAssociation;
|
||||
bool orderAlias;
|
||||
bool asAlias;
|
||||
} SExprNode;
|
||||
|
||||
typedef enum EColumnType {
|
||||
|
@ -127,8 +128,7 @@ typedef struct SLogicConditionNode {
|
|||
} SLogicConditionNode;
|
||||
|
||||
typedef struct SNodeListNode {
|
||||
ENodeType type; // QUERY_NODE_NODE_LIST
|
||||
SDataType dataType;
|
||||
SExprNode node; // QUERY_NODE_NODE_LIST
|
||||
SNodeList* pNodeList;
|
||||
} SNodeListNode;
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
|
||||
|
||||
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED)
|
||||
|
||||
#define NEED_REDIRECT_ERROR(_code) \
|
||||
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||
|
|
|
@ -409,21 +409,6 @@ static FORCE_INLINE void streamTaskInputFail(SStreamTask* pTask) {
|
|||
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__FAILED);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock) {
|
||||
if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
||||
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pBlock->blocks);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||
taosFreeQitem(pBlock);
|
||||
} else if (pTask->outputType == TASK_OUTPUT__SMA) {
|
||||
pTask->smaSink.smaSink(pTask->smaSink.vnode, pTask->smaSink.smaId, pBlock->blocks);
|
||||
taosArrayDestroyEx(pBlock->blocks, (FDelete)blockDataFreeRes);
|
||||
taosFreeQitem(pBlock);
|
||||
} else {
|
||||
taosWriteQitem(pTask->outputQueue->queue, pBlock);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
SMsgHead head;
|
||||
int64_t streamId;
|
||||
|
@ -601,6 +586,7 @@ int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
|
|||
|
||||
int32_t streamTryExec(SStreamTask* pTask);
|
||||
int32_t streamSchedExec(SStreamTask* pTask);
|
||||
int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBlock* pBlock);
|
||||
|
||||
int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz);
|
||||
|
||||
|
|
|
@ -153,10 +153,10 @@ typedef struct SSyncFSM {
|
|||
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
||||
|
||||
int32_t (*FpGetSnapshot)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpGetSnapshotInfo)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||
void (*FpGetSnapshotInfo)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||
|
||||
int32_t (*FpSnapshotStartRead)(const struct SSyncFSM* pFsm, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpSnapshotStopRead)(const struct SSyncFSM* pFsm, void* pReader);
|
||||
void (*FpSnapshotStopRead)(const struct SSyncFSM* pFsm, void* pReader);
|
||||
int32_t (*FpSnapshotDoRead)(const struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||
|
||||
int32_t (*FpSnapshotStartWrite)(const struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
||||
|
|
|
@ -22,12 +22,16 @@ extern "C" {
|
|||
|
||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following sectio
|
||||
#if !defined(WINDOWS)
|
||||
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
#define malloc MALLOC_FUNC_TAOS_FORBID
|
||||
#define calloc CALLOC_FUNC_TAOS_FORBID
|
||||
#define realloc REALLOC_FUNC_TAOS_FORBID
|
||||
#define free FREE_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
#endif // ifndef ALLOW_FORBID_FUNC
|
||||
|
||||
#endif // if !defined(WINDOWS)
|
||||
|
||||
void *taosMemoryMalloc(int64_t size);
|
||||
void *taosMemoryCalloc(int64_t num, int64_t size);
|
||||
|
|
|
@ -70,6 +70,7 @@ typedef struct {
|
|||
|
||||
SysNameInfo taosGetSysNameInfo();
|
||||
bool taosCheckCurrentInDll();
|
||||
int taosGetlocalhostname(char *hostname, size_t maxLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -62,11 +62,38 @@ void taosResetTerminalMode();
|
|||
taosMemoryFree(strings); \
|
||||
}
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#define STACKSIZE 64
|
||||
#define taosPrintTrace(flags, level, dflag) \
|
||||
{ \
|
||||
taosPrintLog(flags, level, dflag, \
|
||||
"backtrace not implemented on windows, so detailed stack information cannot be printed"); \
|
||||
}
|
||||
unsigned int i; \
|
||||
void* stack[STACKSIZE]; \
|
||||
unsigned short frames; \
|
||||
SYMBOL_INFO* symbol; \
|
||||
HANDLE process; \
|
||||
\
|
||||
process = GetCurrentProcess(); \
|
||||
\
|
||||
SymInitialize(process, NULL, TRUE); \
|
||||
\
|
||||
frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
|
||||
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
|
||||
if (symbol != NULL) { \
|
||||
symbol->MaxNameLen = 255; \
|
||||
symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
|
||||
\
|
||||
if (frames > 0) { \
|
||||
taosPrintLog(flags, level, dflag, "obtained %d stack frames", frames); \
|
||||
for (i = 0; i < frames; i++) { \
|
||||
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
|
||||
taosPrintLog(flags, level, dflag, "frame:%i: %s - 0x%0X", frames - i - 1, symbol->Name, symbol->Address); \
|
||||
} \
|
||||
} \
|
||||
free(symbol); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -65,6 +65,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) //
|
||||
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
|
||||
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
|
||||
#define TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED TAOS_DEF_ERROR_CODE(0, 0x0020) // "Vgroup could not be connected"
|
||||
#define TSDB_CODE_RPC_SOMENODE_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0021) //
|
||||
|
||||
//common & util
|
||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
||||
|
@ -204,9 +206,15 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_CANT_DROP_LEADER TAOS_DEF_ERROR_CODE(0, 0x0333)
|
||||
#define TSDB_CODE_MND_NO_ENOUGH_DNODES TAOS_DEF_ERROR_CODE(0, 0x0334)
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_CFG TAOS_DEF_ERROR_CODE(0, 0x0335)
|
||||
// #define TSDB_CODE_MND_INVALID_DNODE_CFG_... TAOS_DEF_ERROR_CODE(0, 0x0336) // 2.x
|
||||
// #define TSDB_CODE_MND_BALANCE_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0337) // 2.x
|
||||
#define TSDB_CODE_MND_VGROUP_NOT_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0338)
|
||||
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0339)
|
||||
// #define TSDB_CODE_MND_DNODE_NOT_FREE TAOS_DEF_ERROR_CODE(0, 0x033A) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_ID TAOS_DEF_ERROR_CODE(0, 0x033B)
|
||||
// #define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x033C) // 2.x
|
||||
// #define TSDB_CODE_MND_DNODE_ID_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033D) // 2.x
|
||||
// #define TSDB_CODE_MND_DNODE_EP_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033E) // 2.x
|
||||
|
||||
// mnode-acct
|
||||
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
||||
|
@ -298,6 +306,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x03B5)
|
||||
#define TSDB_CODE_MND_HAS_OFFLINE_DNODE TAOS_DEF_ERROR_CODE(0, 0x03B6)
|
||||
#define TSDB_CODE_MND_INVALID_REPLICA TAOS_DEF_ERROR_CODE(0, 0x03B7)
|
||||
#define TSDB_CODE_MND_DNODE_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x03B8)
|
||||
#define TSDB_CODE_MND_DNODE_IN_DROPPING TAOS_DEF_ERROR_CODE(0, 0x03B9)
|
||||
|
||||
// mnode-stable-part2
|
||||
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||
|
@ -318,6 +328,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
||||
#define TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL TAOS_DEF_ERROR_CODE(0, 0x03D5)
|
||||
#define TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED TAOS_DEF_ERROR_CODE(0, 0x03D6) //internal
|
||||
#define TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x03D7)
|
||||
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF)
|
||||
|
||||
// mnode-mq
|
||||
|
@ -509,6 +520,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
||||
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
||||
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
|
||||
#define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal
|
||||
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) //
|
||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||
|
||||
// tq
|
||||
|
|
|
@ -255,7 +255,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
||||
#define TSDB_IPv4ADDR_LEN 16
|
||||
#define TSDB_FILENAME_LEN 128
|
||||
#define TSDB_SHOW_SQL_LEN 1024
|
||||
#define TSDB_SHOW_SQL_LEN 2048
|
||||
#define TSDB_SLOW_QUERY_SQL_LEN 512
|
||||
#define TSDB_SHOW_SUBQUERY_LEN 1000
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define _TD_UTIL_WORKER_H_
|
||||
|
||||
#include "tqueue.h"
|
||||
#include "tarray.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -26,10 +27,10 @@ typedef struct SQWorkerPool SQWorkerPool;
|
|||
typedef struct SWWorkerPool SWWorkerPool;
|
||||
|
||||
typedef struct SQWorker {
|
||||
int32_t id; // worker id
|
||||
int64_t pid; // thread pid
|
||||
TdThread thread; // thread id
|
||||
SQWorkerPool *pool;
|
||||
int32_t id; // worker id
|
||||
int64_t pid; // thread pid
|
||||
TdThread thread; // thread id
|
||||
void *pool;
|
||||
} SQWorker;
|
||||
|
||||
typedef struct SQWorkerPool {
|
||||
|
@ -42,6 +43,14 @@ typedef struct SQWorkerPool {
|
|||
TdThreadMutex mutex;
|
||||
} SQWorkerPool;
|
||||
|
||||
typedef struct SAutoQWorkerPool {
|
||||
float ratio;
|
||||
STaosQset *qset;
|
||||
const char *name;
|
||||
SArray *workers;
|
||||
TdThreadMutex mutex;
|
||||
} SAutoQWorkerPool;
|
||||
|
||||
typedef struct SWWorker {
|
||||
int32_t id; // worker id
|
||||
int64_t pid; // thread pid
|
||||
|
@ -65,6 +74,11 @@ void tQWorkerCleanup(SQWorkerPool *pool);
|
|||
STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp);
|
||||
void tQWorkerFreeQueue(SQWorkerPool *pool, STaosQueue *queue);
|
||||
|
||||
int32_t tAutoQWorkerInit(SAutoQWorkerPool *pool);
|
||||
void tAutoQWorkerCleanup(SAutoQWorkerPool *pool);
|
||||
STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem fp);
|
||||
void tAutoQWorkerFreeQueue(SAutoQWorkerPool *pool, STaosQueue *queue);
|
||||
|
||||
int32_t tWWorkerInit(SWWorkerPool *pool);
|
||||
void tWWorkerCleanup(SWWorkerPool *pool);
|
||||
STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp);
|
||||
|
|
|
@ -14,6 +14,7 @@ set binary_dir=%3
|
|||
set binary_dir=%binary_dir:/=\\%
|
||||
set osType=%4
|
||||
set verNumber=%5
|
||||
set Enterprise=%6
|
||||
set target_dir=C:\\TDengine
|
||||
|
||||
if not exist %target_dir% (
|
||||
|
@ -57,7 +58,33 @@ if exist %binary_dir%\\build\\lib\\taosws.dll (
|
|||
if exist %binary_dir%\\build\\bin\\taosdump.exe (
|
||||
copy %binary_dir%\\build\\bin\\taosdump.exe %target_dir% > nul
|
||||
)
|
||||
|
||||
if %Enterprise% == TRUE (
|
||||
if exist %binary_dir%\\build\\bin\\taosx.exe (
|
||||
copy %binary_dir%\\build\\bin\\taosx.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\tmq_sim.exe (
|
||||
copy %binary_dir%\\build\\bin\\tmq_sim.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\tsim.exe (
|
||||
copy %binary_dir%\\build\\bin\\tsim.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\tmq_taosx_ci.exe (
|
||||
copy %binary_dir%\\build\\bin\\tmq_taosx_ci.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\tmq_demo.exe (
|
||||
copy %binary_dir%\\build\\bin\\tmq_demo.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\dumper.exe (
|
||||
copy %binary_dir%\\build\\bin\\dumper.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\runUdf.exe (
|
||||
copy %binary_dir%\\build\\bin\\runUdf.exe %target_dir% > nul
|
||||
)
|
||||
if exist %binary_dir%\\build\\bin\\create_table.exe (
|
||||
copy %binary_dir%\\build\\bin\\create_table.exe %target_dir% > nul
|
||||
)
|
||||
)
|
||||
|
||||
copy %binary_dir%\\build\\bin\\taosd.exe %target_dir% > nul
|
||||
copy %binary_dir%\\build\\bin\\udfd.exe %target_dir% > nul
|
||||
|
||||
|
|
|
@ -348,7 +348,8 @@ cd ${release_dir}
|
|||
# install_dir has been distinguishes cluster from edege, so comments this code
|
||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
|
||||
taostools_pkg_name=${taostools_install_dir}-${osType}-${cpuType}
|
||||
versionCompFirst=$(echo ${versionComp} | awk -F '.' '{print $1}')
|
||||
taostools_pkg_name=${taostools_install_dir}-${osType}-${cpuType}-comp${versionCompFirst}
|
||||
|
||||
# if [ "$verMode" == "cluster" ]; then
|
||||
# pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
|
|
|
@ -122,6 +122,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
|||
|
||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||
|
||||
tscInfo("connecting to server, numOfEps:%d inUse:%d user:%s db:%s key:%s", epSet.epSet.numOfEps, epSet.epSet.inUse,
|
||||
user, db, key);
|
||||
for (int32_t i = 0; i < epSet.epSet.numOfEps; ++i) {
|
||||
tscInfo("ep:%d, %s:%u", i, epSet.epSet.eps[i].fqdn, epSet.epSet.eps[i].port);
|
||||
}
|
||||
|
||||
SAppInstInfo** pInst = NULL;
|
||||
taosThreadMutexLock(&appInfo.mutex);
|
||||
|
||||
|
@ -142,7 +148,7 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
|||
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||
p->instKey = key;
|
||||
key = NULL;
|
||||
tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, ip, port);
|
||||
tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, epSet.epSet.eps[0].fqdn, epSet.epSet.eps[0].port);
|
||||
|
||||
pInst = &p;
|
||||
}
|
||||
|
@ -266,7 +272,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
|
|||
|
||||
int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||
SRetrieveTableRsp* pRsp = NULL;
|
||||
int32_t code = qExecCommand(pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||
}
|
||||
|
@ -304,7 +310,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t code = qExecCommand(pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
int32_t code = qExecCommand(&pRequest->pTscObj->id ,pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||
}
|
||||
|
@ -1397,6 +1403,21 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
|||
memcpy((void*)tEpSet, (void*)pEpSet, sizeof(SEpSet));
|
||||
}
|
||||
|
||||
// pMsg is response msg
|
||||
if (pMsg->msgType == TDMT_MND_CONNECT + 1) {
|
||||
// restore origin code
|
||||
if (pMsg->code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) {
|
||||
pMsg->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
} else if (pMsg->code == TSDB_CODE_RPC_SOMENODE_BROKEN_LINK) {
|
||||
pMsg->code = TSDB_CODE_RPC_BROKEN_LINK;
|
||||
}
|
||||
} else {
|
||||
// uniform to one error code: TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
|
||||
if (pMsg->code == TSDB_CODE_RPC_SOMENODE_BROKEN_LINK) {
|
||||
pMsg->code = TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg));
|
||||
arg->msg = *pMsg;
|
||||
arg->pEpset = tEpSet;
|
||||
|
|
|
@ -179,7 +179,7 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) {
|
|||
}
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
end:
|
||||
end:
|
||||
cJSON_Delete(json);
|
||||
tFreeSMAltertbReq(&req);
|
||||
return string;
|
||||
|
@ -200,7 +200,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE);
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tDecoderClear(&coder);
|
||||
return string;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen);
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tDecoderClear(&coder);
|
||||
return string;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
cJSON_AddItemToArray(tags, tag);
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
cJSON_AddItemToObject(json, "tags", tags);
|
||||
taosArrayDestroy(pTagVals);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosMemoryFreeClear(pCreateReq->comment);
|
||||
|
@ -393,7 +393,7 @@ static char* processAutoCreateTable(STaosxRsp* rsp) {
|
|||
}
|
||||
string = buildCreateCTableJson(pCreateReq, rsp->createTableNum);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
for (int i = 0; i < rsp->createTableNum; i++) {
|
||||
tDecoderClear(&decoder[i]);
|
||||
taosMemoryFreeClear(pCreateReq[i].comment);
|
||||
|
@ -515,7 +515,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&decoder);
|
||||
return string;
|
||||
|
@ -548,11 +548,50 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) {
|
|||
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&decoder);
|
||||
return string;
|
||||
}
|
||||
static char* processDeleteTable(SMqMetaRsp* metaRsp){
|
||||
SDeleteRes req = {0};
|
||||
SDecoder coder = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
cJSON* json = NULL;
|
||||
char* string = NULL;
|
||||
|
||||
// decode and process req
|
||||
void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead));
|
||||
int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead);
|
||||
|
||||
tDecoderInit(&coder, data, len);
|
||||
if (tDecodeDeleteRes(&coder, &req) < 0) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// getTbName(req.tableFName);
|
||||
char sql[256] = {0};
|
||||
snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName,
|
||||
req.tsColName, req.skey, req.tsColName, req.ekey);
|
||||
uDebug("delete sql:%s\n", sql);
|
||||
|
||||
json = cJSON_CreateObject();
|
||||
if (json == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
cJSON* type = cJSON_CreateString("delete");
|
||||
cJSON_AddItemToObject(json, "type", type);
|
||||
cJSON* sqlJson = cJSON_CreateString(sql);
|
||||
cJSON_AddItemToObject(json, "sql", sqlJson);
|
||||
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&coder);
|
||||
return string;
|
||||
}
|
||||
|
||||
static char* processDropTable(SMqMetaRsp* metaRsp) {
|
||||
SDecoder decoder = {0};
|
||||
|
@ -590,7 +629,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) {
|
|||
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&decoder);
|
||||
return string;
|
||||
|
@ -678,7 +717,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = pRequest->code;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
end:
|
||||
end:
|
||||
destroyRequest(pRequest);
|
||||
tFreeSMCreateStbReq(&pReq);
|
||||
tDecoderClear(&coder);
|
||||
|
@ -748,7 +787,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = pRequest->code;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
end:
|
||||
end:
|
||||
destroyRequest(pRequest);
|
||||
tDecoderClear(&coder);
|
||||
return code;
|
||||
|
@ -809,9 +848,9 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch);
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
|
||||
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
||||
// loop to create table
|
||||
|
@ -891,7 +930,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosMemoryFreeClear(pCreateReq->comment);
|
||||
|
@ -961,9 +1000,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch);
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
||||
// loop to create table
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
|
@ -1015,7 +1054,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
taosHashCleanup(pVgroupHashmap);
|
||||
destroyRequest(pRequest);
|
||||
tDecoderClear(&coder);
|
||||
|
@ -1083,7 +1122,7 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
taos_free_result(res);
|
||||
|
||||
end:
|
||||
end:
|
||||
tDecoderClear(&coder);
|
||||
return code;
|
||||
}
|
||||
|
@ -1130,9 +1169,9 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
|
||||
SVgroupInfo pInfo = {0};
|
||||
SName pName = {0};
|
||||
|
@ -1191,7 +1230,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = handleAlterTbExecRes(pRes->res, pCatalog);
|
||||
}
|
||||
}
|
||||
end:
|
||||
end:
|
||||
taosArrayDestroy(pArray);
|
||||
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
||||
taosMemoryFreeClear(pVgData);
|
||||
|
@ -1354,7 +1393,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
qDestroyQuery(pQuery);
|
||||
destroyRequest(pRequest);
|
||||
|
@ -1414,7 +1453,6 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
goto end;
|
||||
}
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
|
||||
uDebug("raw data block num:%d\n", rspObj.rsp.blockNum);
|
||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||
|
@ -1474,7 +1512,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
tDeleteSMqDataRsp(&rspObj.rsp);
|
||||
tDecoderClear(&decoder);
|
||||
qDestroyQuery(pQuery);
|
||||
|
@ -1647,7 +1685,12 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
|||
return processAlterTable(&pMetaRspObj->metaRsp);
|
||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) {
|
||||
return processDropTable(&pMetaRspObj->metaRsp);
|
||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) {
|
||||
return processDropTable(&pMetaRspObj->metaRsp);
|
||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) {
|
||||
return processDeleteTable(&pMetaRspObj->metaRsp);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1902,10 +1902,6 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) {
|
|||
if (TD_RES_TMQ(res)) {
|
||||
return TMQ_RES_DATA;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) {
|
||||
return TMQ_RES_DATA;
|
||||
}
|
||||
return TMQ_RES_TABLE_META;
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
return TMQ_RES_METADATA;
|
||||
|
|
|
@ -1879,7 +1879,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
|||
char pBuf[128] = {0};
|
||||
int32_t sz = taosArrayGetSize(dataBlocks);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGetP(dataBlocks, i);
|
||||
SSDataBlock* pDataBlock = taosArrayGet(dataBlocks, i);
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
|
@ -1891,21 +1891,37 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
|||
for (int32_t k = 0; k < numOfCols; k++) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||
if (k == 0) {
|
||||
printf("cols:%d |", (int32_t)numOfCols);
|
||||
}
|
||||
if (colDataIsNull(pColInfoData, rows, j, NULL)) {
|
||||
printf(" %15s |", "NULL");
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
formatTimestamp(pBuf, *(uint64_t*)var, TSDB_TIME_PRECISION_MILLI);
|
||||
printf(" %25s |", pBuf);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
printf(" %15d |", *(int32_t*)var);
|
||||
printf(" %15" PRIi8 " |", *(int8_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
printf(" %15" PRIi8 " |", *(int8_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
printf(" %15" PRIi16 " |", *(int16_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
printf(" %15d |", *(int32_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
printf(" %15" PRIu8 " |", *(uint8_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
printf(" %15" PRIu16 " |", *(uint16_t*)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
printf(" %15u |", *(uint32_t*)var);
|
||||
break;
|
||||
|
|
|
@ -2091,28 +2091,28 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes,
|
||||
int32_t nRows, char* lengthOrbitmap, char *data) {
|
||||
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
|
||||
char *data) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(type)) { // var-length data type
|
||||
for (int32_t i = 0; i < nRows; ++i) {
|
||||
int32_t offset = *((int32_t*)lengthOrbitmap + i);
|
||||
int32_t offset = *((int32_t *)lengthOrbitmap + i);
|
||||
if (offset == -1) {
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
|
||||
if (code) goto _exit;
|
||||
} else {
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
|
||||
pColData, (uint8_t *)varDataVal(data + offset), varDataLen(data + offset));
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, (uint8_t *)varDataVal(data + offset),
|
||||
varDataLen(data + offset));
|
||||
}
|
||||
}
|
||||
} else { // fixed-length data type
|
||||
bool allValue = true;
|
||||
bool allNull = true;
|
||||
bool allNull = true;
|
||||
for (int32_t i = 0; i < nRows; ++i) {
|
||||
if(!colDataIsNull_f(lengthOrbitmap, i)){
|
||||
if (!colDataIsNull_f(lengthOrbitmap, i)) {
|
||||
allNull = false;
|
||||
}else{
|
||||
} else {
|
||||
allValue = false;
|
||||
}
|
||||
}
|
||||
|
@ -2120,8 +2120,7 @@ int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t byt
|
|||
if (allValue) {
|
||||
// optimize (todo)
|
||||
for (int32_t i = 0; i < nRows; ++i) {
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
|
||||
pColData, (uint8_t *)data + bytes * i, bytes);
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, (uint8_t *)data + bytes * i, bytes);
|
||||
}
|
||||
} else if (allNull) {
|
||||
// optimize (todo)
|
||||
|
@ -2135,14 +2134,13 @@ int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t byt
|
|||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
|
||||
if (code) goto _exit;
|
||||
} else {
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
|
||||
pColData, (uint8_t *)data + bytes * i, bytes);
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, (uint8_t *)data + bytes * i, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -2218,13 +2216,18 @@ static int32_t tColDataSwapValue(SColData *pColData, int32_t i, int32_t j) {
|
|||
if (nData1 > nData2) {
|
||||
memcpy(pData, pColData->pData + pColData->aOffset[i], nData1);
|
||||
memcpy(pColData->pData + pColData->aOffset[i], pColData->pData + pColData->aOffset[j], nData2);
|
||||
memmove(pColData->pData + pColData->aOffset[i] + nData2, pColData->pData + pColData->aOffset[i] + nData1,
|
||||
// memmove(pColData->pData + pColData->aOffset[i] + nData2, pColData->pData + pColData->aOffset[i] + nData1,
|
||||
// pColData->aOffset[j] - pColData->aOffset[i + 1]);
|
||||
memmove(pColData->pData + pColData->aOffset[i] + nData2, pColData->pData + pColData->aOffset[i + 1],
|
||||
pColData->aOffset[j] - pColData->aOffset[i + 1]);
|
||||
memcpy(pColData->pData + pColData->aOffset[j] + nData2 - nData1, pData, nData1);
|
||||
} else {
|
||||
memcpy(pData, pColData->pData + pColData->aOffset[j], nData2);
|
||||
memcpy(pColData->pData + pColData->aOffset[j] + nData2 - nData1, pColData->pData + pColData->aOffset[i], nData1);
|
||||
memmove(pColData->pData + pColData->aOffset[j] + nData2 - nData1, pColData->pData + pColData->aOffset[i] + nData1,
|
||||
// memmove(pColData->pData + pColData->aOffset[j] + nData2 - nData1, pColData->pData + pColData->aOffset[i] +
|
||||
// nData1,
|
||||
// pColData->aOffset[j] - pColData->aOffset[i + 1]);
|
||||
memmove(pColData->pData + pColData->aOffset[i] + nData2, pColData->pData + pColData->aOffset[i + 1],
|
||||
pColData->aOffset[j] - pColData->aOffset[i + 1]);
|
||||
memcpy(pColData->pData + pColData->aOffset[i], pData, nData2);
|
||||
}
|
||||
|
@ -2244,6 +2247,7 @@ static int32_t tColDataSwapValue(SColData *pColData, int32_t i, int32_t j) {
|
|||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
static void tColDataSwap(SColData *pColData, int32_t i, int32_t j) {
|
||||
ASSERT(i < j);
|
||||
ASSERT(j < pColData->nVal);
|
||||
|
@ -2278,9 +2282,174 @@ static void tColDataSwap(SColData *pColData, int32_t i, int32_t j) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
static void tColDataSort(SColData *aColData, int32_t nColData) {
|
||||
if (aColData[0].nVal == 0) return;
|
||||
// TODO
|
||||
|
||||
static int32_t tColDataCopyRowCell(SColData *pFromColData, int32_t iFromRow, SColData *pToColData, int32_t iToRow) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pToColData->type)) {
|
||||
int32_t nData = (iFromRow < pFromColData->nVal - 1)
|
||||
? pFromColData->aOffset[iFromRow + 1] - pFromColData->aOffset[iFromRow]
|
||||
: pFromColData->nData - pFromColData->aOffset[iFromRow];
|
||||
if (iToRow == 0) {
|
||||
pToColData->aOffset[iToRow] = 0;
|
||||
}
|
||||
|
||||
if (iToRow < pToColData->nVal - 1) {
|
||||
pToColData->aOffset[iToRow + 1] = pToColData->aOffset[iToRow] + nData;
|
||||
}
|
||||
|
||||
memcpy(pToColData->pData + pToColData->aOffset[iToRow], pFromColData->pData + pFromColData->aOffset[iFromRow],
|
||||
nData);
|
||||
} else {
|
||||
memcpy(&pToColData->pData[TYPE_BYTES[pToColData->type] * iToRow],
|
||||
&pFromColData->pData[TYPE_BYTES[pToColData->type] * iFromRow], TYPE_BYTES[pToColData->type]);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tColDataCopyRowSingleCol(SColData *pFromColData, int32_t iFromRow, SColData *pToColData,
|
||||
int32_t iToRow) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
switch (pFromColData->flag) {
|
||||
case HAS_NONE:
|
||||
case HAS_NULL:
|
||||
break;
|
||||
case (HAS_NULL | HAS_NONE): {
|
||||
SET_BIT1(pToColData->pBitMap, iToRow, GET_BIT1(pFromColData->pBitMap, iFromRow));
|
||||
} break;
|
||||
case HAS_VALUE: {
|
||||
tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow);
|
||||
} break;
|
||||
case (HAS_VALUE | HAS_NONE):
|
||||
case (HAS_VALUE | HAS_NULL): {
|
||||
SET_BIT1(pToColData->pBitMap, iToRow, GET_BIT1(pFromColData->pBitMap, iFromRow));
|
||||
tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow);
|
||||
} break;
|
||||
case (HAS_VALUE | HAS_NULL | HAS_NONE): {
|
||||
SET_BIT2(pToColData->pBitMap, iToRow, GET_BIT2(pFromColData->pBitMap, iFromRow));
|
||||
tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow);
|
||||
} break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tColDataCopyRow(SColData *aFromColData, int32_t iFromRow, SColData *aToColData, int32_t iToRow,
|
||||
int32_t nColData) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
for (int32_t i = 0; i < nColData; i++) {
|
||||
code = tColDataCopyRowSingleCol(&aFromColData[i], iFromRow, &aToColData[i], iToRow);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tColDataCopyRowAppend(SColData *aFromColData, int32_t iFromRow, SColData *aToColData, int32_t nColData) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
for (int32_t i = 0; i < nColData; i++) {
|
||||
SColVal cv = {0};
|
||||
tColDataGetValue(&aFromColData[i], iFromRow, &cv);
|
||||
code = tColDataAppendValue(&aToColData[i], &cv);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tColDataMergeSortMerge(SColData *aColData, int32_t start, int32_t mid, int32_t end, int32_t nColData) {
|
||||
SColData *aDstColData = NULL;
|
||||
TSKEY *aKey = (TSKEY *)aColData[0].pData;
|
||||
|
||||
int32_t i = start, j = mid + 1, k = 0;
|
||||
|
||||
if (end > start) {
|
||||
aDstColData = taosMemoryCalloc(1, sizeof(SColData) * nColData);
|
||||
for (int c = 0; c < nColData; ++c) {
|
||||
tColDataInit(&aDstColData[c], aColData[c].cid, aColData[c].type, aColData[c].smaOn);
|
||||
}
|
||||
if (aDstColData == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
/*
|
||||
for (int32_t i = 0; i < nColData; i++) {
|
||||
tColDataCopy(&aColData[i], &aDstColData[i], tColDataDefaultMalloc, NULL);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
while (i <= mid && j <= end) {
|
||||
if (aKey[i] <= aKey[j]) {
|
||||
// tColDataCopyRow(aColData, i++, aDstColData, k++);
|
||||
tColDataCopyRowAppend(aColData, i++, aDstColData, nColData);
|
||||
} else {
|
||||
// tColDataCopyRow(aColData, j++, aDstColData, k++);
|
||||
tColDataCopyRowAppend(aColData, j++, aDstColData, nColData);
|
||||
}
|
||||
}
|
||||
|
||||
while (i <= mid) {
|
||||
// tColDataCopyRow(aColData, i++, aDstColData, k++);
|
||||
tColDataCopyRowAppend(aColData, i++, aDstColData, nColData);
|
||||
}
|
||||
|
||||
while (j <= end) {
|
||||
// tColDataCopyRow(aColData, j++, aDstColData, k++);
|
||||
tColDataCopyRowAppend(aColData, j++, aDstColData, nColData);
|
||||
}
|
||||
|
||||
for (i = start, k = 0; i <= end; ++i, ++k) {
|
||||
tColDataCopyRow(aDstColData, k, aColData, i, nColData);
|
||||
}
|
||||
|
||||
if (aDstColData) {
|
||||
for (int32_t i = 0; i < nColData; i++) {
|
||||
tColDataDestroy(&aDstColData[i]);
|
||||
}
|
||||
taosMemoryFree(aDstColData);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t tColDataMergeSort(SColData *aColData, int32_t start, int32_t end, int32_t nColData) {
|
||||
int32_t ret = TSDB_CODE_SUCCESS;
|
||||
int32_t mid;
|
||||
|
||||
if (start >= end) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
mid = (start + end) / 2;
|
||||
|
||||
ret = tColDataMergeSort(aColData, start, mid, nColData);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = tColDataMergeSort(aColData, mid + 1, end, nColData);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return tColDataMergeSortMerge(aColData, start, mid, end, nColData);
|
||||
}
|
||||
|
||||
static int32_t tColDataSort(SColData *aColData, int32_t nColData) {
|
||||
int32_t nVal = aColData[0].nVal;
|
||||
|
||||
if (nVal < 2) return TSDB_CODE_SUCCESS;
|
||||
|
||||
return tColDataMergeSort(aColData, 0, nVal - 1, nColData);
|
||||
}
|
||||
static void tColDataMergeImpl(SColData *pColData, int32_t iStart, int32_t iEnd /* not included */) {
|
||||
switch (pColData->flag) {
|
||||
|
@ -2530,6 +2699,15 @@ void tColDataSortMerge(SArray *colDataArr) {
|
|||
tColDataSort(aColData, nColData);
|
||||
}
|
||||
|
||||
if (doMerge != 1) {
|
||||
for (int32_t iVal = 1; iVal < aColData[0].nVal; ++iVal) {
|
||||
if (aKey[iVal] == aKey[iVal - 1]) {
|
||||
doMerge = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// merge -------
|
||||
if (doMerge) {
|
||||
tColDataMerge(aColData, nColData);
|
||||
|
|
|
@ -47,7 +47,7 @@ int32_t tsNumOfMnodeQueryThreads = 4;
|
|||
int32_t tsNumOfMnodeFetchThreads = 1;
|
||||
int32_t tsNumOfMnodeReadThreads = 1;
|
||||
int32_t tsNumOfVnodeQueryThreads = 4;
|
||||
int32_t tsNumOfVnodeStreamThreads = 2;
|
||||
float tsRatioOfVnodeStreamThreads = 1.0;
|
||||
int32_t tsNumOfVnodeFetchThreads = 4;
|
||||
int32_t tsNumOfVnodeRsmaThreads = 2;
|
||||
int32_t tsNumOfQnodeQueryThreads = 4;
|
||||
|
@ -392,9 +392,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeStreamThreads = tsNumOfCores / 4;
|
||||
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1;
|
||||
if (cfgAddFloat(pCfg, "ratioOfVnodeStreamThreads", tsRatioOfVnodeStreamThreads, 0.01, 100, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeFetchThreads = tsNumOfCores / 4;
|
||||
tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4);
|
||||
|
@ -513,11 +511,9 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
|||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
pItem = cfgGetItem(tsCfg, "numOfVnodeStreamThreads");
|
||||
pItem = cfgGetItem(tsCfg, "ratioOfVnodeStreamThreads");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
tsNumOfVnodeStreamThreads = numOfCores / 4;
|
||||
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
|
||||
pItem->i32 = tsNumOfVnodeStreamThreads;
|
||||
pItem->fval = tsRatioOfVnodeStreamThreads;
|
||||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
|
@ -710,7 +706,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
||||
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
||||
tsNumOfVnodeStreamThreads = cfgGetItem(pCfg, "numOfVnodeStreamThreads")->i32;
|
||||
tsRatioOfVnodeStreamThreads = cfgGetItem(pCfg, "ratioOfVnodeStreamThreads")->fval;
|
||||
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
|
||||
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
||||
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||
|
@ -1316,12 +1312,17 @@ void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal,
|
|||
if (pItem != NULL && (rewrite || pItem->i32 == 0)) {
|
||||
pItem->i32 = flagVal;
|
||||
}
|
||||
*pFlagPtr = flagVal;
|
||||
if (pFlagPtr != NULL) {
|
||||
*pFlagPtr = flagVal;
|
||||
}
|
||||
}
|
||||
|
||||
void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
|
||||
if (flag <= 0) return;
|
||||
|
||||
taosSetDebugFlag(NULL, "debugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(NULL, "simDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(NULL, "tmrDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, rewrite);
|
||||
|
@ -1340,6 +1341,5 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
|
|||
taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, rewrite);
|
||||
taosSetDebugFlag(&metaDebugFlag, "tmrDebugFlag", flag, rewrite);
|
||||
uInfo("all debug flag are set to %d", flag);
|
||||
}
|
||||
|
|
|
@ -5424,6 +5424,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
|||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||
}
|
||||
if (tEncodeI8(&encoder, pReq->createStb) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -5484,6 +5485,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
|||
}
|
||||
}
|
||||
}
|
||||
if (tDecodeI8(&decoder, &pReq->createStb) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
|
@ -6936,6 +6938,8 @@ void tDestroySSubmitTbData(SSubmitTbData *pTbData, int32_t flag) {
|
|||
}
|
||||
|
||||
void tDestroySSubmitReq2(SSubmitReq2 *pReq, int32_t flag) {
|
||||
if (pReq->aSubmitTbData == NULL) return;
|
||||
|
||||
int32_t nSubmitTbData = TARRAY_SIZE(pReq->aSubmitTbData);
|
||||
SSubmitTbData *aSubmitTbData = (SSubmitTbData *)TARRAY_DATA(pReq->aSubmitTbData);
|
||||
|
||||
|
|
|
@ -268,6 +268,11 @@ int mainWindows(int argc, char **argv) {
|
|||
|
||||
if (dmInit() != 0) {
|
||||
dError("failed to init dnode since %s", terrstr());
|
||||
|
||||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
taosConvDestroy();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
|||
pMgmt->statusSeq);
|
||||
pMgmt->pData->dropped = 1;
|
||||
dmWriteEps(pMgmt->pData);
|
||||
dInfo("dnode will exit since it is in the dropped state");
|
||||
raise(SIGINT);
|
||||
}
|
||||
} else {
|
||||
SStatusRsp statusRsp = {0};
|
||||
|
|
|
@ -26,20 +26,20 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct SVnodeMgmt {
|
||||
SDnodeData *pData;
|
||||
SMsgCb msgCb;
|
||||
const char *path;
|
||||
const char *name;
|
||||
SQWorkerPool queryPool;
|
||||
SQWorkerPool streamPool;
|
||||
SWWorkerPool fetchPool;
|
||||
SSingleWorker mgmtWorker;
|
||||
SHashObj *hash;
|
||||
TdThreadRwlock lock;
|
||||
SVnodesStat state;
|
||||
STfs *pTfs;
|
||||
TdThread thread;
|
||||
bool stop;
|
||||
SDnodeData *pData;
|
||||
SMsgCb msgCb;
|
||||
const char *path;
|
||||
const char *name;
|
||||
SQWorkerPool queryPool;
|
||||
SAutoQWorkerPool streamPool;
|
||||
SWWorkerPool fetchPool;
|
||||
SSingleWorker mgmtWorker;
|
||||
SHashObj *hash;
|
||||
TdThreadRwlock lock;
|
||||
SVnodesStat state;
|
||||
STfs *pTfs;
|
||||
TdThread thread;
|
||||
bool stop;
|
||||
} SVnodeMgmt;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -140,6 +140,12 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
|||
|
||||
static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
if (pMsg->contLen < sizeof(SMsgHead)) {
|
||||
dGError("invalid rpc msg with no msg head at pCont. pMsg:%p, type:%s, contLen:%d", pMsg, TMSG_INFO(pMsg->msgType),
|
||||
pMsg->contLen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -233,6 +239,14 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||
if (pRpc->contLen < sizeof(SMsgHead)) {
|
||||
dError("invalid rpc msg with no msg head at pCont. pRpc:%p, type:%s, len:%d", pRpc, TMSG_INFO(pRpc->msgType),
|
||||
pRpc->contLen);
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
pRpc->pCont = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||
if (pMsg == NULL) {
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
|
@ -304,7 +318,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
|||
(void)tMultiWorkerInit(&pVnode->pApplyW, &acfg);
|
||||
|
||||
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
||||
pVnode->pStreamQ = tQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue);
|
||||
pVnode->pStreamQ = tAutoQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue);
|
||||
pVnode->pFetchQ = tWWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItems)vmProcessFetchQueue);
|
||||
|
||||
if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncCtrlW.queue == NULL ||
|
||||
|
@ -330,7 +344,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
|||
|
||||
void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||
tQWorkerFreeQueue(&pMgmt->queryPool, pVnode->pQueryQ);
|
||||
tQWorkerFreeQueue(&pMgmt->streamPool, pVnode->pStreamQ);
|
||||
tAutoQWorkerFreeQueue(&pMgmt->streamPool, pVnode->pStreamQ);
|
||||
tWWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
||||
pVnode->pQueryQ = NULL;
|
||||
pVnode->pStreamQ = NULL;
|
||||
|
@ -345,11 +359,10 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
|||
pQPool->max = tsNumOfVnodeQueryThreads;
|
||||
if (tQWorkerInit(pQPool) != 0) return -1;
|
||||
|
||||
SQWorkerPool *pStreamPool = &pMgmt->streamPool;
|
||||
SAutoQWorkerPool *pStreamPool = &pMgmt->streamPool;
|
||||
pStreamPool->name = "vnode-stream";
|
||||
pStreamPool->min = tsNumOfVnodeStreamThreads;
|
||||
pStreamPool->max = tsNumOfVnodeStreamThreads;
|
||||
if (tQWorkerInit(pStreamPool) != 0) return -1;
|
||||
pStreamPool->ratio = tsRatioOfVnodeStreamThreads;
|
||||
if (tAutoQWorkerInit(pStreamPool) != 0) return -1;
|
||||
|
||||
SWWorkerPool *pFPool = &pMgmt->fetchPool;
|
||||
pFPool->name = "vnode-fetch";
|
||||
|
@ -371,7 +384,7 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
|||
|
||||
void vmStopWorker(SVnodeMgmt *pMgmt) {
|
||||
tQWorkerCleanup(&pMgmt->queryPool);
|
||||
tQWorkerCleanup(&pMgmt->streamPool);
|
||||
tAutoQWorkerCleanup(&pMgmt->streamPool);
|
||||
tWWorkerCleanup(&pMgmt->fetchPool);
|
||||
dDebug("vnode workers are closed");
|
||||
}
|
||||
|
|
|
@ -53,6 +53,15 @@ static bool dmFailFastFp(tmsg_t msgType) {
|
|||
return msgType == TDMT_SYNC_HEARTBEAT || msgType == TDMT_SYNC_APPEND_ENTRIES;
|
||||
}
|
||||
|
||||
static void dmConvertErrCode(tmsg_t msgType) {
|
||||
if (terrno != TSDB_CODE_APP_IS_STOPPING) {
|
||||
return;
|
||||
}
|
||||
if ((msgType > TDMT_VND_MSG && msgType < TDMT_VND_MAX_MSG) ||
|
||||
(msgType > TDMT_SCH_MSG && msgType < TDMT_SCH_MAX_MSG)) {
|
||||
terrno = TSDB_CODE_VND_STOPPED;
|
||||
}
|
||||
}
|
||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
int32_t code = -1;
|
||||
|
@ -102,6 +111,11 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType));
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
goto _OVER;
|
||||
} else if ((pRpc->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || pRpc->code == TSDB_CODE_RPC_BROKEN_LINK) &&
|
||||
(!IsReq(pRpc)) && (pRpc->pCont == NULL)) {
|
||||
dGError("msg:%p, type:%s pCont is NULL, err: %s", pRpc, TMSG_INFO(pRpc->msgType), tstrerror(pRpc->code));
|
||||
terrno = pRpc->code;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (pHandle->defaultNtype == NODE_END) {
|
||||
|
@ -152,6 +166,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
|
||||
_OVER:
|
||||
if (code != 0) {
|
||||
dmConvertErrCode(pRpc->msgType);
|
||||
if (terrno != 0) code = terrno;
|
||||
if (pMsg) {
|
||||
dGTrace("msg:%p, failed to process %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr());
|
||||
|
@ -233,8 +248,9 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcRe
|
|||
|
||||
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED ||
|
||||
code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED || code == TSDB_CODE_SYN_NOT_LEADER ||
|
||||
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED || code == TSDB_CODE_APP_IS_STARTING ||
|
||||
code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
||||
msgType == TDMT_SCH_MERGE_FETCH) {
|
||||
return false;
|
||||
|
|
|
@ -193,6 +193,7 @@ typedef struct {
|
|||
int64_t lastAccessTime;
|
||||
int32_t accessTimes;
|
||||
int32_t numOfVnodes;
|
||||
int32_t numOfOtherNodes;
|
||||
int32_t numOfSupportVnodes;
|
||||
float numOfCores;
|
||||
int64_t memTotal;
|
||||
|
|
|
@ -557,6 +557,8 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
mInfo("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||
|
||||
mndTransSetDbName(pTrans, dbObj.name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
mndTransSetOper(pTrans, MND_OPER_CREATE_DB);
|
||||
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbUndoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
|
@ -776,7 +778,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
|
|||
|
||||
int32_t code = -1;
|
||||
mndTransSetDbName(pTrans, pOld->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetAlterDbRedoLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||
if (mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||
|
@ -1038,7 +1040,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
|
|||
|
||||
mInfo("trans:%d, used to drop db:%s", pTrans->id, pDb->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
if (mndCheckTopicExist(pMnode, pDb) < 0) goto _OVER;
|
||||
|
||||
if (mndSetDropDbRedoLogs(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||
|
|
|
@ -217,8 +217,18 @@ SDnodeObj *mndAcquireDnode(SMnode *pMnode, int32_t dnodeId) {
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
SDnodeObj *pDnode = sdbAcquire(pSdb, SDB_DNODE, &dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
if (terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
} else if (terrno == TSDB_CODE_SDB_OBJ_CREATING) {
|
||||
terrno = TSDB_CODE_MND_DNODE_IN_CREATING;
|
||||
} else if (terrno == TSDB_CODE_SDB_OBJ_DROPPING) {
|
||||
terrno = TSDB_CODE_MND_DNODE_IN_DROPPING;
|
||||
} else {
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
mFatal("dnode:%d, failed to acquire db since %s", dnodeId, terrstr());
|
||||
}
|
||||
}
|
||||
|
||||
return pDnode;
|
||||
}
|
||||
|
||||
|
@ -254,6 +264,27 @@ static SDnodeObj *mndAcquireDnodeByEp(SMnode *pMnode, char *pEpStr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static SDnodeObj *mndAcquireDnodeAllStatusByEp(SMnode *pMnode, char *pEpStr) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
SDnodeObj *pDnode = NULL;
|
||||
ESdbStatus objStatus = 0;
|
||||
pIter = sdbFetchAll(pSdb, SDB_DNODE, pIter, (void **)&pDnode, &objStatus, true);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (strncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
return pDnode;
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t mndGetDnodeSize(SMnode *pMnode) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
return sdbGetSize(pSdb, SDB_DNODE);
|
||||
|
@ -340,12 +371,22 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
} else {
|
||||
pDnode = mndAcquireDnode(pMnode, statusReq.dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
int32_t err = terrno;
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, statusReq.dnodeEp);
|
||||
if (pDnode != NULL) {
|
||||
pDnode->offlineReason = DND_REASON_DNODE_ID_NOT_MATCH;
|
||||
terrno = err;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mError("dnode:%d, %s not exist, code:0x%x", statusReq.dnodeId, statusReq.dnodeEp, err);
|
||||
if (err == TSDB_CODE_MND_DNODE_NOT_EXIST) {
|
||||
terrno = err;
|
||||
goto _OVER;
|
||||
} else {
|
||||
pDnode = mndAcquireDnodeAllStatusByEp(pMnode, statusReq.dnodeEp);
|
||||
if (pDnode == NULL) goto _OVER;
|
||||
}
|
||||
mError("dnode:%d, %s not exist", statusReq.dnodeId, statusReq.dnodeEp);
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,8 +397,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||
bool needCheck = !online || dnodeChanged || reboot;
|
||||
|
||||
pDnode->accessTimes++;
|
||||
pDnode->lastAccessTime = curMs;
|
||||
const STraceId *trace = &pReq->info.traceId;
|
||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||
pDnode->accessTimes, needCheck, online, reboot, dnodeChanged, statusReq.statusSeq);
|
||||
|
@ -493,6 +532,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pReq->info.rsp = pHead;
|
||||
}
|
||||
|
||||
pDnode->accessTimes++;
|
||||
pDnode->lastAccessTime = curMs;
|
||||
code = 0;
|
||||
|
||||
_OVER:
|
||||
|
@ -517,6 +558,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mInfo("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
pRaw = mndDnodeActionEncode(&dnodeObj);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
|
@ -698,6 +740,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop dnode:%d, force:%d", pTrans->id, pDnode->id, force);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
pRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
@ -762,11 +805,12 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
char ep[TSDB_EP_LEN + 1] = {0};
|
||||
int32_t err = terrno;
|
||||
char ep[TSDB_EP_LEN + 1] = {0};
|
||||
snprintf(ep, sizeof(ep), dropReq.fqdn, dropReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode == NULL) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
terrno = err;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
@ -967,11 +1011,12 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
ESdbStatus objStatus = 0;
|
||||
SDnodeObj *pDnode = NULL;
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
|
||||
while (numOfRows < rows) {
|
||||
pShow->pIter = sdbFetch(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode);
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode, &objStatus, true);
|
||||
if (pShow->pIter == NULL) break;
|
||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||
|
||||
|
@ -993,8 +1038,20 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pDnode->numOfSupportVnodes, false);
|
||||
|
||||
const char *status = "ready";
|
||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||
if (!online) {
|
||||
if (objStatus == SDB_STATUS_CREATING)
|
||||
status = "creating*";
|
||||
else if (objStatus == SDB_STATUS_DROPPING)
|
||||
status = "dropping*";
|
||||
else
|
||||
status = "offline";
|
||||
}
|
||||
|
||||
char b1[9] = {0};
|
||||
STR_TO_VARSTR(b1, online ? "ready" : "offline");
|
||||
STR_TO_VARSTR(b1, status);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, b1, false);
|
||||
|
||||
|
|
|
@ -390,6 +390,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||
|
@ -526,6 +527,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pObj, false) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
@ -633,6 +635,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
const char *status = "ready";
|
||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||
if (!mndIsDnodeOnline(pObj->pDnode, curMs)) status = "offline";
|
||||
char b3[9 + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -595,6 +595,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
|||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-sma");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to create sma:%s stream:%s", pTrans->id, pCreate->name, streamObj.name);
|
||||
|
||||
|
@ -809,6 +811,8 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
|||
|
||||
mInfo("trans:%d, used to drop sma:%s", pTrans->id, pSma->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
mndTransSetSerial(pTrans);
|
||||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
|
|
|
@ -823,6 +823,7 @@ _OVER:
|
|||
|
||||
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||
if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||
if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||
if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||
|
@ -1856,6 +1857,7 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbOb
|
|||
|
||||
mInfo("trans:%d, used to alter stb:%s", pTrans->id, pStb->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (needRsp) {
|
||||
void *pCont = NULL;
|
||||
|
@ -2055,6 +2057,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p
|
|||
|
||||
mInfo("trans:%d, used to drop stb:%s", pTrans->id, pStb->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||
if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||
|
|
|
@ -631,11 +631,13 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb);
|
||||
mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name);
|
||||
|
||||
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
// create stb for stream
|
||||
if (mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
||||
if (createStreamReq.createStb == STREAM_CREATE_STABLE_TRUE && mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createStreamReq.name, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
|
@ -781,6 +783,12 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) {
|
|||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "stream-checkpoint");
|
||||
if (pTrans == NULL) return -1;
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosRLockLatch(&pStream->lock);
|
||||
// 1. redo action: broadcast checkpoint source msg for all source vg
|
||||
int32_t totLevel = taosArrayGetSize(pStream->tasks);
|
||||
|
@ -871,11 +879,11 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stream");
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
@ -883,6 +891,13 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
mInfo("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name);
|
||||
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// drop all tasks
|
||||
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
||||
|
|
|
@ -442,7 +442,12 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "tmq-reb");
|
||||
if (pTrans == NULL) return -1;
|
||||
|
||||
mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// make txn:
|
||||
// 1. redo action: action to all vg
|
||||
|
|
|
@ -142,10 +142,9 @@ int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pRe
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
static void mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
sdbGetCommitInfo(pMnode->pSdb, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndRestoreFinish(const SSyncFSM *pFsm) {
|
||||
|
@ -170,10 +169,10 @@ int32_t mndSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void **ppReader
|
|||
return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
static void mndSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
mInfo("stop to read snapshot from sdb");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStopRead(pMnode->pSdb, pReader);
|
||||
sdbStopRead(pMnode->pSdb, pReader);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
|
|
|
@ -701,13 +701,19 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mInfo("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
||||
|
||||
// TODO check if rebalancing
|
||||
|
|
|
@ -957,9 +957,13 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
for (int32_t i = 0; i < size; ++i) {
|
||||
SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i);
|
||||
if (pInfo->handle != NULL) {
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) {
|
||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||
}
|
||||
if (code == TSDB_CODE_SYN_TIMEOUT) {
|
||||
code = TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT;
|
||||
}
|
||||
|
||||
if (i != 0 && code == 0) {
|
||||
code = TSDB_CODE_MNODE_NOT_FOUND;
|
||||
}
|
||||
|
|
|
@ -425,6 +425,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb
|
|||
static bool mndResetDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
||||
SDnodeObj *pDnode = pObj;
|
||||
pDnode->numOfVnodes = 0;
|
||||
pDnode->numOfOtherNodes = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -447,7 +448,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2
|
|||
pDnode->numOfVnodes, pDnode->numOfSupportVnodes, isMnode, online, pDnode->memAvail, pDnode->memUsed);
|
||||
|
||||
if (isMnode) {
|
||||
pDnode->numOfVnodes++;
|
||||
pDnode->numOfOtherNodes++;
|
||||
}
|
||||
|
||||
if (online && pDnode->numOfSupportVnodes > 0) {
|
||||
|
@ -468,14 +469,25 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) {
|
|||
|
||||
sdbTraverse(pSdb, SDB_DNODE, mndResetDnodesArrayFp, NULL, NULL, NULL);
|
||||
sdbTraverse(pSdb, SDB_DNODE, mndBuildDnodesArrayFp, pArray, &exceptDnodeId, NULL);
|
||||
|
||||
mDebug("build %d dnodes array", (int32_t)taosArrayGetSize(pArray));
|
||||
for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
mDebug("dnode:%d, vnodes:%d others:%d", pDnode->id, pDnode->numOfVnodes, pDnode->numOfOtherNodes);
|
||||
}
|
||||
return pArray;
|
||||
}
|
||||
|
||||
static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return *dnode1Id >= *dnode2Id ? 1 : 0; }
|
||||
|
||||
static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float ratio) {
|
||||
float totalDnodes = pDnode->numOfVnodes + (float)pDnode->numOfOtherNodes * ratio + additionDnodes;
|
||||
return totalDnodes / pDnode->numOfSupportVnodes;
|
||||
}
|
||||
|
||||
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
|
||||
float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes;
|
||||
float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes;
|
||||
float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9);
|
||||
float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9);
|
||||
return d1Score >= d2Score ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -494,7 +506,12 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup
|
|||
int32_t allocedVnodes = 0;
|
||||
void *pIter = NULL;
|
||||
|
||||
mDebug("start to sort %d dnodes", (int32_t)taosArrayGetSize(pArray));
|
||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||
for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
mDebug("dnode:%d, score:%f", pDnode->id, mndGetDnodeScore(pDnode, 0, 0.9));
|
||||
}
|
||||
|
||||
int32_t size = taosArrayGetSize(pArray);
|
||||
if (size < pVgroup->replica) {
|
||||
|
@ -875,7 +892,7 @@ static int32_t mndAddVnodeToVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgro
|
|||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
mInfo("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
||||
mInfo("dnode:%d, equivalent vnodes:%d others:%d", pDnode->id, pDnode->numOfVnodes, pDnode->numOfOtherNodes);
|
||||
}
|
||||
|
||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[pVgroup->replica];
|
||||
|
@ -935,7 +952,7 @@ static int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *
|
|||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
mInfo("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
||||
mInfo("dnode:%d, equivalent vnodes:%d others:%d", pDnode->id, pDnode->numOfVnodes, pDnode->numOfOtherNodes);
|
||||
}
|
||||
|
||||
int32_t code = -1;
|
||||
|
@ -1970,16 +1987,16 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) {
|
|||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||
mInfo("dnode:%d, equivalent vnodes:%d support:%d, score:%f", pDnode->id, pDnode->numOfVnodes,
|
||||
pDnode->numOfSupportVnodes, (float)pDnode->numOfVnodes / pDnode->numOfSupportVnodes);
|
||||
mInfo("dnode:%d, equivalent vnodes:%d others:%d support:%d, score:%f", pDnode->id, pDnode->numOfVnodes,
|
||||
pDnode->numOfSupportVnodes, pDnode->numOfOtherNodes, mndGetDnodeScore(pDnode, 0, 1));
|
||||
}
|
||||
|
||||
SDnodeObj *pSrc = taosArrayGet(pArray, taosArrayGetSize(pArray) - 1);
|
||||
SDnodeObj *pDst = taosArrayGet(pArray, 0);
|
||||
|
||||
float srcScore = (float)(pSrc->numOfVnodes - 1) / pSrc->numOfSupportVnodes;
|
||||
float dstScore = (float)(pDst->numOfVnodes + 1) / pDst->numOfSupportVnodes;
|
||||
mInfo("trans:%d, after balance, src dnode:%d score:%f, dst dnode:%d score:%f", pTrans->id, pSrc->id, srcScore,
|
||||
float srcScore = mndGetDnodeScore(pSrc, -1, 1);
|
||||
float dstScore = mndGetDnodeScore(pDst, 1, 1);
|
||||
mInfo("trans:%d, after balance, src dnode:%d score:%f, dst dnode:%d score:%f", pTrans->id, pSrc->id, dstScore,
|
||||
pDst->id, dstScore);
|
||||
|
||||
if (srcScore > dstScore - 0.000001) {
|
||||
|
|
|
@ -392,7 +392,7 @@ void *sdbGetRowObj(SSdbRow *pRow);
|
|||
void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc);
|
||||
|
||||
int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *term, int64_t *config);
|
||||
int32_t sdbStopRead(SSdb *pSdb, SSdbIter *pIter);
|
||||
void sdbStopRead(SSdb *pSdb, SSdbIter *pIter);
|
||||
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len);
|
||||
|
||||
int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter);
|
||||
|
|
|
@ -585,10 +585,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t sdbStopRead(SSdb *pSdb, SSdbIter *pIter) {
|
||||
sdbCloseIter(pIter);
|
||||
return 0;
|
||||
}
|
||||
void sdbStopRead(SSdb *pSdb, SSdbIter *pIter) { sdbCloseIter(pIter); }
|
||||
|
||||
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) {
|
||||
int32_t maxlen = 4096;
|
||||
|
|
|
@ -185,7 +185,7 @@ void *tsdbGetIvtIdx(SMeta *pMeta);
|
|||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||
|
||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
uint64_t suid, void **pReader);
|
||||
uint64_t suid, void **pReader, const char* idstr);
|
||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||
void *tsdbCacherowsReaderClose(void *pReader);
|
||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||
|
@ -275,7 +275,7 @@ int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *
|
|||
|
||||
// SVSnapReader
|
||||
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader);
|
||||
int32_t vnodeSnapReaderClose(SVSnapReader *pReader);
|
||||
void vnodeSnapReaderClose(SVSnapReader *pReader);
|
||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
||||
// SVSnapWriter
|
||||
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
||||
|
|
|
@ -121,6 +121,7 @@ typedef struct {
|
|||
struct STQ {
|
||||
SVnode* pVnode;
|
||||
char* path;
|
||||
int64_t walLogLastVer;
|
||||
|
||||
SRWLatch pushLock;
|
||||
|
||||
|
|
|
@ -726,21 +726,21 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
|
|||
|
||||
// tsdbCache ==============================================================================================
|
||||
typedef struct SCacheRowsReader {
|
||||
SVnode *pVnode;
|
||||
STSchema *pSchema;
|
||||
uint64_t uid;
|
||||
uint64_t suid;
|
||||
char **transferBuf; // todo remove it soon
|
||||
int32_t numOfCols;
|
||||
int32_t type;
|
||||
int32_t tableIndex; // currently returned result tables
|
||||
|
||||
SVnode *pVnode;
|
||||
STSchema *pSchema;
|
||||
uint64_t uid;
|
||||
uint64_t suid;
|
||||
char **transferBuf; // todo remove it soon
|
||||
int32_t numOfCols;
|
||||
int32_t type;
|
||||
int32_t tableIndex; // currently returned result tables
|
||||
STableKeyInfo *pTableList; // table id list
|
||||
int32_t numOfTables;
|
||||
SSttBlockLoadInfo *pLoadInfo;
|
||||
STsdbReadSnap *pReadSnap;
|
||||
SDataFReader *pDataFReader;
|
||||
SDataFReader *pDataFReaderLast;
|
||||
const char *idstr;
|
||||
} SCacheRowsReader;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -90,7 +90,9 @@ typedef struct SCommitInfo SCommitInfo;
|
|||
#define VND_INFO_FNAME "vnode.json"
|
||||
|
||||
// vnd.h
|
||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int32_t size);
|
||||
|
||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||
void* vnodeBufPoolMallocAligned(SVBufPool* pPool, int size);
|
||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||
|
@ -199,6 +201,7 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg);
|
|||
int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqCheckLogInWal(STQ* pTq, int64_t version);
|
||||
|
||||
int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
||||
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
||||
|
|
|
@ -54,9 +54,9 @@ struct SMetaCache {
|
|||
|
||||
// query cache
|
||||
struct STagFilterResCache {
|
||||
TdThreadMutex lock;
|
||||
SHashObj* pTableEntry;
|
||||
SLRUCache* pUidResCache;
|
||||
uint64_t keyBuf[3];
|
||||
} sTagFilterResCache;
|
||||
};
|
||||
|
||||
|
@ -140,6 +140,8 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
|||
}
|
||||
|
||||
taosHashSetFreeFp(pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp);
|
||||
taosThreadMutexInit(&pCache->sTagFilterResCache.lock, NULL);
|
||||
|
||||
pMeta->pCache = pCache;
|
||||
return code;
|
||||
|
||||
|
@ -159,6 +161,8 @@ void metaCacheClose(SMeta* pMeta) {
|
|||
|
||||
taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry);
|
||||
taosLRUCacheCleanup(pMeta->pCache->sTagFilterResCache.pUidResCache);
|
||||
taosThreadMutexDestroy(&pMeta->pCache->sTagFilterResCache.lock);
|
||||
|
||||
taosMemoryFree(pMeta->pCache);
|
||||
pMeta->pCache = NULL;
|
||||
}
|
||||
|
@ -206,7 +210,7 @@ _exit:
|
|||
int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
|
||||
int32_t code = 0;
|
||||
|
||||
// ASSERT(metaIsWLocked(pMeta));
|
||||
// meta is wlocked for calling this func.
|
||||
|
||||
// search
|
||||
SMetaCache* pCache = pMeta->pCache;
|
||||
|
@ -217,7 +221,10 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
|
|||
}
|
||||
|
||||
if (*ppEntry) { // update
|
||||
ASSERT(pInfo->suid == (*ppEntry)->info.suid);
|
||||
if (pInfo->suid != (*ppEntry)->info.suid) {
|
||||
metaError("meta/cache: suid should be same as the one in cache.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (pInfo->version > (*ppEntry)->info.version) {
|
||||
(*ppEntry)->info.version = pInfo->version;
|
||||
(*ppEntry)->info.skmVer = pInfo->skmVer;
|
||||
|
@ -336,7 +343,7 @@ _exit:
|
|||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo) {
|
||||
int32_t code = 0;
|
||||
|
||||
// ASSERT(metaIsWLocked(pMeta));
|
||||
// meta is wlocked for calling this func.
|
||||
|
||||
// search
|
||||
SMetaCache* pCache = pMeta->pCache;
|
||||
|
@ -422,63 +429,82 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) {
|
|||
|
||||
int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1,
|
||||
bool* acquireRes) {
|
||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
||||
|
||||
// generate the composed key for LRU cache
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||
|
||||
pBuf[0] = suid;
|
||||
memcpy(&pBuf[1], pKey, keyLen);
|
||||
uint64_t buf[3] = {0};
|
||||
uint32_t times = 0;
|
||||
|
||||
*acquireRes = 0;
|
||||
buf[0] = suid;
|
||||
memcpy(&buf[1], pKey, keyLen);
|
||||
|
||||
taosThreadMutexLock(pLock);
|
||||
|
||||
int32_t len = keyLen + sizeof(uint64_t);
|
||||
LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
LRUHandle* pHandle = taosLRUCacheLookup(pCache, buf, len);
|
||||
if (pHandle == NULL) {
|
||||
*acquireRes = 0;
|
||||
taosThreadMutexUnlock(pLock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else { // do some book mark work after acquiring the filter result from cache
|
||||
STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t));
|
||||
ASSERT(pEntry != NULL);
|
||||
*acquireRes = 1;
|
||||
}
|
||||
|
||||
const char* p = taosLRUCacheValue(pMeta->pCache->sTagFilterResCache.pUidResCache, pHandle);
|
||||
int32_t size = *(int32_t*)p;
|
||||
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
||||
// do some book mark work after acquiring the filter result from cache
|
||||
STagFilterResEntry** pEntry = taosHashGet(pTableMap, &suid, sizeof(uint64_t));
|
||||
if (NULL == pEntry) {
|
||||
metaError("meta/cache: pEntry should not be NULL.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
(*pEntry)->qTimes += 1;
|
||||
taosLRUCacheRelease(pCache, pHandle, false);
|
||||
*acquireRes = 1;
|
||||
|
||||
// check if scanning all items are necessary or not
|
||||
if ((*pEntry)->qTimes >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) {
|
||||
SArray* pList = taosArrayInit(64, POINTER_BYTES);
|
||||
const char* p = taosLRUCacheValue(pCache, pHandle);
|
||||
int32_t size = *(int32_t*)p;
|
||||
|
||||
SListIter iter = {0};
|
||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||
// set the result into the buffer
|
||||
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
||||
|
||||
SListNode* pNode = NULL;
|
||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||
memcpy(&pBuf[1], pNode->data, keyLen);
|
||||
times = atomic_add_fetch_32(&(*pEntry)->qTimes, 1);
|
||||
taosLRUCacheRelease(pCache, pHandle, false);
|
||||
|
||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
if (pRes == NULL) { // remove the item in the linked list
|
||||
taosArrayPush(pList, &pNode);
|
||||
} else {
|
||||
taosLRUCacheRelease(pCache, pRes, false);
|
||||
}
|
||||
// unlock meta
|
||||
taosThreadMutexUnlock(pLock);
|
||||
|
||||
// check if scanning all items are necessary or not
|
||||
if (times >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) {
|
||||
taosThreadMutexLock(pLock);
|
||||
|
||||
SArray* pInvalidRes = taosArrayInit(64, POINTER_BYTES);
|
||||
|
||||
SListIter iter = {0};
|
||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||
|
||||
SListNode* pNode = NULL;
|
||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||
memcpy(&buf[1], pNode->data, keyLen);
|
||||
|
||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, buf, len);
|
||||
if (pRes == NULL) { // remove the item in the linked list
|
||||
taosArrayPush(pInvalidRes, &pNode);
|
||||
} else {
|
||||
taosLRUCacheRelease(pCache, pRes, false);
|
||||
}
|
||||
|
||||
// remove the keys, of which query uid lists have been replaced already.
|
||||
size_t s = taosArrayGetSize(pList);
|
||||
for (int32_t i = 0; i < s; ++i) {
|
||||
SListNode** p1 = taosArrayGet(pList, i);
|
||||
tdListPopNode(&(*pEntry)->list, *p1);
|
||||
taosMemoryFree(*p1);
|
||||
}
|
||||
|
||||
(*pEntry)->qTimes = 0; // reset the query times
|
||||
|
||||
taosArrayDestroy(pList);
|
||||
}
|
||||
|
||||
// remove the keys, of which query uid lists have been replaced already.
|
||||
size_t s = taosArrayGetSize(pInvalidRes);
|
||||
for (int32_t i = 0; i < s; ++i) {
|
||||
SListNode** p1 = taosArrayGet(pInvalidRes, i);
|
||||
tdListPopNode(&(*pEntry)->list, *p1);
|
||||
taosMemoryFree(*p1);
|
||||
}
|
||||
|
||||
atomic_store_32(&(*pEntry)->qTimes, 0); // reset the query times
|
||||
taosArrayDestroy(pInvalidRes);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -510,8 +536,11 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||
|
||||
taosThreadMutexLock(pLock);
|
||||
|
||||
STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t));
|
||||
if (pEntry == NULL) {
|
||||
|
@ -524,15 +553,21 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
tdListAppend(&(*pEntry)->list, pKey);
|
||||
}
|
||||
|
||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
||||
pBuf[0] = suid;
|
||||
uint64_t buf[3] = {0};
|
||||
buf[0] = suid;
|
||||
|
||||
memcpy(&pBuf[1], pKey, keyLen);
|
||||
ASSERT(sizeof(uint64_t) + keyLen == 24);
|
||||
memcpy(&buf[1], pKey, keyLen);
|
||||
if (sizeof(uint64_t) + keyLen != 24) {
|
||||
metaError("meta/cache: incorrect keyLen:%" PRId32 " length.", keyLen);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// add to cache.
|
||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||
taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
|
||||
metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode), suid,
|
||||
(int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry));
|
||||
|
||||
|
@ -541,15 +576,19 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
|
||||
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
|
||||
int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
|
||||
STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t));
|
||||
if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t keyLen = sizeof(uint64_t) * 3;
|
||||
uint64_t p[3] = {0};
|
||||
p[0] = suid;
|
||||
|
||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||
|
||||
taosThreadMutexLock(pLock);
|
||||
STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t));
|
||||
if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) {
|
||||
taosThreadMutexUnlock(pLock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SListIter iter = {0};
|
||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||
|
||||
|
@ -562,5 +601,6 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
|
|||
(*pEntry)->qTimes = 0;
|
||||
tdListEmpty(&(*pEntry)->list);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
|
||||
#include "meta.h"
|
||||
|
||||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) { return vnodeBufPoolMalloc((SVBufPool *)pPool, size); }
|
||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
|
||||
return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
|
||||
}
|
||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
|
||||
// begin a meta txn
|
||||
int metaBegin(SMeta *pMeta, int8_t heap) {
|
||||
|
|
|
@ -51,7 +51,9 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
|||
} else if (pME->type == TSDB_TSMA_TABLE) {
|
||||
if (tEncodeTSma(pCoder, pME->smaEntry.tsma) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " encode failed.", pME->type);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEndEncode(pCoder);
|
||||
|
@ -99,7 +101,9 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
|||
}
|
||||
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEndDecode(pCoder);
|
||||
|
|
|
@ -358,7 +358,10 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
|
|||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(pTagIdxKey1->type == pTagIdxKey2->type);
|
||||
if (pTagIdxKey1->type != pTagIdxKey2->type) {
|
||||
metaError("meta/open: incorrect tag idx type.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// check NULL, NULL is always the smallest
|
||||
if (pTagIdxKey1->isNull && !pTagIdxKey2->isNull) {
|
||||
|
|
|
@ -19,7 +19,7 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
|
|||
memset(pReader, 0, sizeof(*pReader));
|
||||
pReader->flags = flags;
|
||||
pReader->pMeta = pMeta;
|
||||
if (!(flags & META_READER_NOLOCK)) {
|
||||
if (pReader->pMeta && !(flags & META_READER_NOLOCK)) {
|
||||
metaRLock(pMeta);
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) {
|
|||
}
|
||||
|
||||
int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
|
||||
SMeta *pMeta = pReader->pMeta;
|
||||
SMeta *pMeta = pReader->pMeta;
|
||||
int64_t version1;
|
||||
|
||||
// query uid.idx
|
||||
|
@ -239,7 +239,6 @@ int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid) {
|
||||
int code = 0;
|
||||
SMetaReader mr = {0};
|
||||
|
@ -653,7 +652,11 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
ASSERT(c);
|
||||
if (c == 0) {
|
||||
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (c < 0) {
|
||||
tdbTbcMoveToPrev(pSkmDbC);
|
||||
|
@ -677,7 +680,11 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(sver > 0);
|
||||
if (sver <= 0) {
|
||||
metaError("meta/query: incorrect sver: %" PRId32 ".", sver);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
skmDbKey.uid = suid ? suid : uid;
|
||||
skmDbKey.sver = sver;
|
||||
|
@ -737,9 +744,7 @@ int64_t metaGetTimeSeriesNum(SMeta *pMeta) {
|
|||
return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
||||
}
|
||||
|
||||
int64_t metaGetNtbNum(SMeta *pMeta) {
|
||||
return pMeta->pVnode->config.vndStats.numOfNTables;
|
||||
}
|
||||
int64_t metaGetNtbNum(SMeta *pMeta) { return pMeta->pVnode->config.vndStats.numOfNTables; }
|
||||
|
||||
typedef struct {
|
||||
SMeta *pMeta;
|
||||
|
|
|
@ -100,7 +100,10 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
break;
|
||||
}
|
||||
|
||||
ASSERT(pData && nData);
|
||||
if (!pData || !nData) {
|
||||
metaError("meta/snap: invalide nData: %" PRId32 " meta snap read failed.", nData);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + nData);
|
||||
if (*ppData == NULL) {
|
||||
|
@ -113,8 +116,8 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
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);
|
||||
metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d",
|
||||
TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
@ -356,7 +359,11 @@ int32_t buildSnapContext(SMeta* pMeta, int64_t snapVersion, int64_t suid, int8_t
|
|||
for (int i = 0; i < taosArrayGetSize(ctx->idList); i++) {
|
||||
int64_t* uid = taosArrayGet(ctx->idList, i);
|
||||
SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, uid, sizeof(int64_t));
|
||||
ASSERT(idData);
|
||||
if (!idData) {
|
||||
metaError("meta/snap: null idData");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
idData->index = i;
|
||||
metaDebug("tmqsnap init idVersion uid:%" PRIi64 " version:%" PRIi64 " index:%d", *uid, idData->version,
|
||||
idData->index);
|
||||
|
@ -473,7 +480,10 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||
ctx->index++;
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||
ASSERT(idInfo);
|
||||
if (!idInfo) {
|
||||
metaError("meta/snap: null idInfo");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
*uid = *uidTmp;
|
||||
ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
|
||||
|
@ -507,7 +517,11 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)) {
|
||||
STableInfoForChildTable* data =
|
||||
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
||||
ASSERT(data);
|
||||
if (!data) {
|
||||
metaError("meta/snap: null data");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SVCreateTbReq req = {0};
|
||||
|
||||
req.type = TSDB_CHILD_TABLE;
|
||||
|
@ -528,7 +542,8 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
} else {
|
||||
SArray* pTagVals = NULL;
|
||||
if (tTagToValArray((const STag*)p, &pTagVals) != 0) {
|
||||
ASSERT(0);
|
||||
metaError("meta/snap: tag to val array failed.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
int16_t nCols = taosArrayGetSize(pTagVals);
|
||||
for (int j = 0; j < nCols; ++j) {
|
||||
|
@ -572,7 +587,8 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
ret = buildNormalChildTableInfo(&req, pBuf, contLen);
|
||||
*type = TDMT_VND_CREATE_TABLE;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/snap: invalid topic sub type: %" PRId8 " get meta from snap failed.", ctx->subType);
|
||||
ret = -1;
|
||||
}
|
||||
tDecoderClear(&dc);
|
||||
|
||||
|
@ -593,7 +609,10 @@ SMetaTableInfo getUidfromSnapShot(SSnapContext* ctx) {
|
|||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||
ctx->index++;
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||
ASSERT(idInfo);
|
||||
if (!idInfo) {
|
||||
metaError("meta/snap: null idInfo");
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
|
||||
if (ret != 0) {
|
||||
|
|
|
@ -46,7 +46,7 @@ static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
|||
pInfo->suid = 0;
|
||||
pInfo->skmVer = pEntry->ntbEntry.schemaRow.version;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/table: invalide table type: %" PRId8 " get entry info failed.", pEntry->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,10 +342,18 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(ret == 0 && c == 0);
|
||||
if (!(ret == 0 && c == 0)) {
|
||||
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
ASSERT(ret == 0);
|
||||
if (ret < 0) {
|
||||
tdbTbcClose(pTbDbc);
|
||||
|
||||
terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
oStbEntry.pBuf = taosMemoryMalloc(nData);
|
||||
memcpy(oStbEntry.pBuf, pData, nData);
|
||||
|
@ -558,7 +566,8 @@ static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
|
|||
ctime = pME->ntbEntry.ctime;
|
||||
ttlDays = pME->ntbEntry.ttlDays;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/table: invalide table type: %" PRId8 " build ttl idx key failed.", pME->type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ttlDays <= 0) return;
|
||||
|
@ -710,8 +719,8 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||
return 0;
|
||||
}
|
||||
metaDebug("vgId:%d, start to save ctime:%" PRId64 " uid:%" PRId64 " ct:%" PRId64, TD_VID(pMeta->pVnode), pME->version,
|
||||
pME->uid, ctimeKey.ctime);
|
||||
metaTrace("vgId:%d, start to save version:%" PRId64 " uid:%" PRId64 " ctime:%" PRId64, TD_VID(pMeta->pVnode),
|
||||
pME->version, pME->uid, ctimeKey.ctime);
|
||||
|
||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
@ -773,7 +782,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
@ -783,7 +795,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
||||
// get table entry
|
||||
|
@ -792,7 +808,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
memcpy(entry.pBuf, pData, nData);
|
||||
tDecoderInit(&dc, entry.pBuf, nData);
|
||||
ret = metaDecodeEntry(&dc, &entry);
|
||||
ASSERT(ret == 0);
|
||||
if (ret != 0) {
|
||||
tDecoderClear(&dc);
|
||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (entry.type != TSDB_NORMAL_TABLE) {
|
||||
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||
|
@ -812,7 +832,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
if (iCol >= pSchema->nCols) break;
|
||||
pColumn = &pSchema->pSchema[iCol];
|
||||
|
||||
ASSERT(pAlterTbReq->colName);
|
||||
if (NULL == pAlterTbReq->colName) {
|
||||
metaError("meta/table: null pAlterTbReq->colName");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(pColumn->name, pAlterTbReq->colName) == 0) break;
|
||||
iCol++;
|
||||
}
|
||||
|
@ -964,7 +988,10 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
@ -977,7 +1004,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
/* get ctbEntry */
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
||||
ctbEntry.pBuf = taosMemoryMalloc(nData);
|
||||
|
@ -1075,7 +1106,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
metaUpdateTagIdx(pMeta, &ctbEntry);
|
||||
}
|
||||
|
||||
ASSERT(ctbEntry.ctbEntry.pTags);
|
||||
if (NULL == ctbEntry.ctbEntry.pTags) {
|
||||
metaError("meta/table: null tags, update tag val failed.");
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
||||
tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn);
|
||||
|
@ -1130,7 +1165,10 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
@ -1140,7 +1178,11 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
||||
// get table entry
|
||||
|
@ -1149,7 +1191,11 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
memcpy(entry.pBuf, pData, nData);
|
||||
tDecoderInit(&dc, entry.pBuf, nData);
|
||||
ret = metaDecodeEntry(&dc, &entry);
|
||||
ASSERT(ret == 0);
|
||||
if (ret != 0) {
|
||||
tDecoderClear(&dc);
|
||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry.version = version;
|
||||
metaWLock(pMeta);
|
||||
|
@ -1408,7 +1454,8 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
pSW = &pME->ntbEntry.schemaRow;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/table: invalide table type: %" PRId8 " save skm db failed.", pME->type);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
skmDbKey.uid = pME->uid;
|
||||
|
|
|
@ -241,7 +241,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
|
|||
SRpcMsg submitReqMsg = {
|
||||
.msgType = TDMT_VND_SUBMIT,
|
||||
.pCont = pSubmitReq,
|
||||
.contLen = ntohl(contLen),
|
||||
.contLen = contLen,
|
||||
};
|
||||
|
||||
if (tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) < 0) {
|
||||
|
|
|
@ -80,6 +80,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
|
|||
}
|
||||
pTq->path = strdup(path);
|
||||
pTq->pVnode = pVnode;
|
||||
pTq->walLogLastVer = pVnode->pWal->vers.lastVer;
|
||||
|
||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
|
||||
|
@ -1013,6 +1014,7 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tqError("unable to encode rsp %d", __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void* buf = rpcMallocCont(sizeof(SMsgHead) + len);
|
||||
((SMsgHead*)buf)->vgId = htonl(req.upstreamNodeId);
|
||||
|
||||
|
@ -1542,3 +1544,5 @@ FAIL:
|
|||
taosFreeQitem(pMsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t tqCheckLogInWal(STQ* pTq, int64_t version) { return version <= pTq->walLogLastVer; }
|
||||
|
|
|
@ -426,7 +426,7 @@ int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* p
|
|||
goto _end;
|
||||
}
|
||||
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
for (int32_t j = 0; j < rows; ++j) {
|
||||
taosArrayClear(pVals);
|
||||
for (int32_t k = 0; k < pTSchema->numOfCols; k++) {
|
||||
const STColumn* pCol = &pTSchema->columns[k];
|
||||
|
@ -469,7 +469,7 @@ int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* p
|
|||
if (NULL == pBuf) {
|
||||
goto _end;
|
||||
}
|
||||
((SMsgHead*)pBuf)->vgId = htonl(TD_VID(pVnode));
|
||||
((SMsgHead*)pBuf)->vgId = TD_VID(pVnode);
|
||||
((SMsgHead*)pBuf)->contLen = htonl(len);
|
||||
tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len - sizeof(SMsgHead));
|
||||
if (tEncodeSSubmitReq2(&encoder, pReq) < 0) {
|
||||
|
@ -756,24 +756,14 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
|||
|
||||
tqDebug("vgId:%d, task %d write into table, block num: %d", TD_VID(pVnode), pTask->taskId, blockSz);
|
||||
|
||||
void* pBuf = NULL;
|
||||
SSubmitReq2* pReq = NULL;
|
||||
SArray* tagArray = NULL;
|
||||
SArray* pVals = NULL;
|
||||
void* pBuf = NULL;
|
||||
SArray* tagArray = NULL;
|
||||
SArray* pVals = NULL;
|
||||
|
||||
if (!(tagArray = taosArrayInit(1, sizeof(STagVal)))) {
|
||||
goto _end;
|
||||
}
|
||||
|
||||
if (!(pReq = taosMemoryCalloc(1, sizeof(SSubmitReq2)))) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
if (!(pReq->aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData)))) {
|
||||
goto _end;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < blockSz; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||
if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
|
||||
|
@ -948,13 +938,17 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
|||
taosArrayPush(tbData.aRowP, &pRow);
|
||||
}
|
||||
|
||||
taosArrayClear(pReq->aSubmitTbData);
|
||||
taosArrayPush(pReq->aSubmitTbData, &tbData);
|
||||
SSubmitReq2 submitReq = {0};
|
||||
if (!(submitReq.aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData)))) {
|
||||
goto _end;
|
||||
}
|
||||
|
||||
taosArrayPush(submitReq.aSubmitTbData, &tbData);
|
||||
|
||||
// encode
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSSubmitReq2, pReq, len, code);
|
||||
tEncodeSize(tEncodeSSubmitReq2, &submitReq, len, code);
|
||||
SEncoder encoder;
|
||||
len += sizeof(SMsgHead);
|
||||
pBuf = rpcMallocCont(len);
|
||||
|
@ -964,7 +958,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
|||
((SMsgHead*)pBuf)->vgId = TD_VID(pVnode);
|
||||
((SMsgHead*)pBuf)->contLen = htonl(len);
|
||||
tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len - sizeof(SMsgHead));
|
||||
if (tEncodeSSubmitReq2(&encoder, pReq) < 0) {
|
||||
if (tEncodeSSubmitReq2(&encoder, &submitReq) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tqError("failed to encode submit req since %s", terrstr());
|
||||
tEncoderClear(&encoder);
|
||||
|
@ -972,6 +966,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
|
|||
continue;
|
||||
}
|
||||
tEncoderClear(&encoder);
|
||||
tDestroySSubmitReq2(&submitReq, TSDB_MSG_FLG_ENCODE);
|
||||
|
||||
SRpcMsg msg = {
|
||||
.msgType = TDMT_VND_SUBMIT,
|
||||
|
@ -988,8 +983,6 @@ _end:
|
|||
taosArrayDestroy(tagArray);
|
||||
taosArrayDestroy(pVals);
|
||||
// TODO: change
|
||||
tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE);
|
||||
taosMemoryFree(pReq);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -1473,29 +1473,6 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
|
|||
|
||||
return code;
|
||||
}
|
||||
// int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) {
|
||||
// int32_t code = 0;
|
||||
// int16_t nCol = taosArrayGetSize(pLastArray);
|
||||
// SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
||||
|
||||
// for (int16_t iCol = 0; iCol < nCol; ++iCol) {
|
||||
// SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLastArray, iCol);
|
||||
// SColVal *tColVal = &tTsVal->colVal;
|
||||
// taosArrayPush(pColArray, tColVal);
|
||||
// }
|
||||
|
||||
// code = tdSTSRowNew(pColArray, pTSchema, ppRow);
|
||||
// if (code) goto _err;
|
||||
|
||||
// taosArrayDestroy(pColArray);
|
||||
|
||||
// return code;
|
||||
|
||||
// _err:
|
||||
// taosArrayDestroy(pColArray);
|
||||
|
||||
// return code;
|
||||
// }
|
||||
|
||||
int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **handle) {
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
|
||||
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
||||
|
||||
static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||
void** pRes) {
|
||||
ASSERT(pReader->numOfCols <= taosArrayGetSize(pBlock->pDataBlock));
|
||||
static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||
void** pRes, const char* idStr) {
|
||||
int32_t numOfRows = pBlock->info.rows;
|
||||
|
||||
if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||
|
@ -65,9 +64,7 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
|||
}
|
||||
|
||||
pBlock->info.rows += allNullRow ? 0 : 1;
|
||||
} else {
|
||||
ASSERT(HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW));
|
||||
|
||||
} else if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
|
||||
|
@ -94,11 +91,16 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
|||
}
|
||||
|
||||
pBlock->info.rows += 1;
|
||||
} else {
|
||||
tsdbError("invalid retrieve type:%d, %s", pReader->type, idStr);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
uint64_t suid, void** pReader) {
|
||||
uint64_t suid, void** pReader, const char* idstr) {
|
||||
*pReader = NULL;
|
||||
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
||||
if (p == NULL) {
|
||||
|
@ -142,6 +144,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
p->idstr = taosMemoryStrDup(idstr);
|
||||
|
||||
*pReader = p;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -160,6 +164,7 @@ void* tsdbCacherowsReaderClose(void* pReader) {
|
|||
|
||||
destroyLastBlockLoadInfo(p->pLoadInfo);
|
||||
|
||||
taosMemoryFree((void*) p->idstr);
|
||||
taosMemoryFree(pReader);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -312,7 +317,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
}
|
||||
|
||||
if (hasRes) {
|
||||
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes);
|
||||
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||
}
|
||||
|
||||
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||
|
@ -331,7 +336,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
continue;
|
||||
}
|
||||
|
||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||
// TODO reset the pRes
|
||||
|
||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||
|
|
|
@ -32,13 +32,13 @@ struct SLDataIter {
|
|||
};
|
||||
|
||||
SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols) {
|
||||
SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo));
|
||||
SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_MAX_STT_TRIGGER, sizeof(SSttBlockLoadInfo));
|
||||
if (pLoadInfo == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
pLoadInfo[i].blockIndex[0] = -1;
|
||||
pLoadInfo[i].blockIndex[1] = -1;
|
||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||
|
@ -63,7 +63,7 @@ SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList,
|
|||
}
|
||||
|
||||
void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||
pLoadInfo[i].blockIndex[0] = -1;
|
||||
pLoadInfo[i].blockIndex[1] = -1;
|
||||
|
@ -77,14 +77,14 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
|||
}
|
||||
|
||||
void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el) {
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
*el += pLoadInfo[i].elapsedTime;
|
||||
*blocks += pLoadInfo[i].loadBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||
pLoadInfo[i].blockIndex[0] = -1;
|
||||
pLoadInfo[i].blockIndex[1] = -1;
|
||||
|
@ -158,9 +158,9 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
pBlock, el, idStr);
|
||||
|
||||
pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
|
||||
tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr);
|
||||
|
||||
pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1;
|
||||
|
||||
tsdbDebug("last block index list:%d, %d, rowIndex:%d %s", pInfo->blockIndex[0], pInfo->blockIndex[1], pIter->iRow, idStr);
|
||||
return &pInfo->blockData[pInfo->currentLoadBlockIndex];
|
||||
|
||||
_exit:
|
||||
|
@ -419,6 +419,7 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
|
|||
pBlockData->aUid != NULL) {
|
||||
i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
|
||||
if (i == -1) {
|
||||
tsdbDebug("failed to find the data in pBlockData, uid:%"PRIu64" , %s", pIter->uid, idStr);
|
||||
pIter->iRow = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -500,7 +501,12 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
|||
|
||||
if (iBlockL != pIter->iSttBlk) {
|
||||
pBlockData = loadLastBlock(pIter, idStr);
|
||||
pIter->iRow += step;
|
||||
if (pBlockData == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// set start row index
|
||||
pIter->iRow = pIter->backward? pBlockData->nRow-1:0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,7 +567,6 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
|
|||
|
||||
pMTree->pLoadInfo = pBlockLoadInfo;
|
||||
pMTree->destroyLoadInfo = destroyLoadInfo;
|
||||
ASSERT(pMTree->pLoadInfo != NULL);
|
||||
|
||||
for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file
|
||||
struct SLDataIter *pIter = NULL;
|
||||
|
|
|
@ -244,7 +244,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) {
|
||||
static int32_t updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) {
|
||||
int32_t i = 0, j = 0;
|
||||
|
||||
while (i < pSchema->numOfCols && j < pSupInfo->numOfCols) {
|
||||
|
@ -252,7 +252,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
|
|||
if (pTCol->colId == pSupInfo->colId[j]) {
|
||||
if (!IS_BSMA_ON(pTCol)) {
|
||||
pSupInfo->smaValid = false;
|
||||
return;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
|
@ -261,9 +261,11 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
|
|||
// do nothing
|
||||
i += 1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) {
|
||||
|
@ -398,7 +400,6 @@ static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
|||
}
|
||||
|
||||
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
|
||||
ASSERT(pWindow != NULL);
|
||||
return pWindow->skey > pWindow->ekey;
|
||||
}
|
||||
|
||||
|
@ -582,7 +583,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
}
|
||||
|
||||
if (VND_IS_TSMA(pVnode)) {
|
||||
tsdbDebug("vgId:%d, tsma is selected to query", TD_VID(pVnode));
|
||||
tsdbDebug("vgId:%d, tsma is selected to query, %s", TD_VID(pVnode), idstr);
|
||||
}
|
||||
|
||||
initReaderStatus(&pReader->status);
|
||||
|
@ -597,7 +598,6 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
pReader->type = pCond->type;
|
||||
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
|
||||
pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket
|
||||
ASSERT(pCond->numOfCols > 0);
|
||||
|
||||
if (pReader->pResBlock == NULL) {
|
||||
pReader->freeBlock = true;
|
||||
|
@ -608,6 +608,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
}
|
||||
}
|
||||
|
||||
if (pCond->numOfCols <= 0) {
|
||||
tsdbError("vgId:%d, invalid column number %d in query cond, %s", TD_VID(pVnode), pCond->numOfCols, idstr);
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
// todo refactor.
|
||||
limitOutputBufferSize(pCond, &pReader->capacity);
|
||||
|
||||
|
@ -796,8 +802,9 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_
|
|||
}
|
||||
|
||||
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
|
||||
if (taosArrayGetSize(pBlockIter->blockList) == 0) {
|
||||
ASSERT(pBlockIter->numOfBlocks == taosArrayGetSize(pBlockIter->blockList));
|
||||
size_t num = taosArrayGetSize(pBlockIter->blockList);
|
||||
if (num == 0) {
|
||||
ASSERT(pBlockIter->numOfBlocks == num);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -807,73 +814,6 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
|
|||
|
||||
static SDataBlk* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; }
|
||||
|
||||
int32_t binarySearchForTs(char* pValue, int num, TSKEY key, int order) {
|
||||
int32_t midPos = -1;
|
||||
int32_t numOfRows;
|
||||
|
||||
ASSERT(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC);
|
||||
|
||||
TSKEY* keyList = (TSKEY*)pValue;
|
||||
int32_t firstPos = 0;
|
||||
int32_t lastPos = num - 1;
|
||||
|
||||
if (order == TSDB_ORDER_DESC) {
|
||||
// find the first position which is smaller than the key
|
||||
while (1) {
|
||||
if (key >= keyList[firstPos]) return firstPos;
|
||||
if (key == keyList[lastPos]) return lastPos;
|
||||
|
||||
if (key < keyList[lastPos]) {
|
||||
lastPos += 1;
|
||||
if (lastPos >= num) {
|
||||
return -1;
|
||||
} else {
|
||||
return lastPos;
|
||||
}
|
||||
}
|
||||
|
||||
numOfRows = lastPos - firstPos + 1;
|
||||
midPos = (numOfRows >> 1) + firstPos;
|
||||
|
||||
if (key < keyList[midPos]) {
|
||||
firstPos = midPos + 1;
|
||||
} else if (key > keyList[midPos]) {
|
||||
lastPos = midPos - 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// find the first position which is bigger than the key
|
||||
while (1) {
|
||||
if (key <= keyList[firstPos]) return firstPos;
|
||||
if (key == keyList[lastPos]) return lastPos;
|
||||
|
||||
if (key > keyList[lastPos]) {
|
||||
lastPos = lastPos + 1;
|
||||
if (lastPos >= num)
|
||||
return -1;
|
||||
else
|
||||
return lastPos;
|
||||
}
|
||||
|
||||
numOfRows = lastPos - firstPos + 1;
|
||||
midPos = (numOfRows >> 1u) + firstPos;
|
||||
|
||||
if (key < keyList[midPos]) {
|
||||
lastPos = midPos - 1;
|
||||
} else if (key > keyList[midPos]) {
|
||||
firstPos = midPos + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return midPos;
|
||||
}
|
||||
|
||||
static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int order) {
|
||||
// start end position
|
||||
int s, e;
|
||||
|
@ -974,8 +914,8 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
|
|||
|
||||
int32_t step = asc ? 1 : -1;
|
||||
|
||||
// make sure it is aligned to 8bit
|
||||
ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0);
|
||||
// make sure it is aligned to 8bit, the allocated memory address is aligned to 256bit
|
||||
// ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0);
|
||||
|
||||
// 1. copy data in a batch model
|
||||
memcpy(pColData->pData, p, dumpedRows * tDataTypes[pData->type].bytes);
|
||||
|
@ -1073,11 +1013,20 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
// pDumpInfo->rowIndex = 0;
|
||||
} else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
|
||||
// pDumpInfo->rowIndex = pBlock->nRow - 1;
|
||||
} else {
|
||||
} else { // find the appropriate the start position in current block, and set it to be the current rowIndex
|
||||
int32_t pos = asc ? pBlock->nRow - 1 : 0;
|
||||
int32_t order = asc ? TSDB_ORDER_DESC : TSDB_ORDER_ASC;
|
||||
int64_t key = asc ? pReader->window.skey : pReader->window.ekey;
|
||||
pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, key, order);
|
||||
|
||||
if (pDumpInfo->rowIndex < 0) {
|
||||
tsdbError(
|
||||
"%p failed to locate the start position in current block, global index:%d, table index:%d, brange:%" PRId64
|
||||
"-%" PRId64 ", minVer:%" PRId64 ", maxVer:%" PRId64 " %s",
|
||||
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, pBlock->minVer,
|
||||
pBlock->maxVer, pReader->idStr);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1186,7 +1135,6 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
|
|||
|
||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
ASSERT(pBlockInfo != NULL);
|
||||
|
||||
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
||||
code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData);
|
||||
|
@ -1224,8 +1172,6 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) {
|
|||
}
|
||||
|
||||
static int32_t initBlockOrderSupporter(SBlockOrderSupporter* pSup, int32_t numOfTables) {
|
||||
ASSERT(numOfTables >= 1);
|
||||
|
||||
pSup->numOfBlocksPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables);
|
||||
pSup->indexPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables);
|
||||
pSup->pDataBlockInfo = taosMemoryCalloc(1, POINTER_BYTES * numOfTables);
|
||||
|
@ -1332,7 +1278,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
sup.numOfTables += 1;
|
||||
}
|
||||
|
||||
ASSERT(numOfBlocks == cnt);
|
||||
if (numOfBlocks != cnt && sup.numOfTables != numOfTables) {
|
||||
cleanupBlockOrderSupporter(&sup);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
// since there is only one table qualified, blocks are not sorted
|
||||
if (sup.numOfTables == 1) {
|
||||
|
@ -1354,10 +1303,9 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %s", pReader, cnt, sup.numOfTables,
|
||||
pReader->idStr);
|
||||
|
||||
ASSERT(cnt <= numOfBlocks && sup.numOfTables <= numOfTables);
|
||||
|
||||
SMultiwayMergeTreeInfo* pTree = NULL;
|
||||
uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar);
|
||||
|
||||
uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
cleanupBlockOrderSupporter(&sup);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1435,8 +1383,6 @@ static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBl
|
|||
}
|
||||
|
||||
static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pFBlockInfo) {
|
||||
ASSERT(pBlockIter != NULL && pFBlockInfo != NULL);
|
||||
|
||||
int32_t step = ASCENDING_TRAVERSE(pBlockIter->order) ? 1 : -1;
|
||||
int32_t index = pBlockIter->index;
|
||||
|
||||
|
@ -1449,7 +1395,6 @@ static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlock
|
|||
index += step;
|
||||
}
|
||||
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1928,7 +1873,6 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
|
|||
}
|
||||
|
||||
doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge, &pReader->verRange);
|
||||
ASSERT(mergeBlockData);
|
||||
|
||||
// merge with block data if ts == key
|
||||
if (tsLastBlock == pBlockData->aTSKEY[pDumpInfo->rowIndex]) {
|
||||
|
@ -1994,7 +1938,6 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
|
|||
tsdbRowMergerClear(&merge);
|
||||
return code;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
} else { // desc order
|
||||
|
@ -2015,7 +1958,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
|
||||
TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader);
|
||||
TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader);
|
||||
ASSERT(pRow != NULL && piRow != NULL);
|
||||
|
||||
int64_t tsLast = INT64_MIN;
|
||||
if (hasDataInLastBlock(pLastBlockReader)) {
|
||||
|
@ -2239,7 +2181,6 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
|||
if (pReader->pReadSnap->pMem != NULL) {
|
||||
d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid);
|
||||
if (d != NULL) {
|
||||
ASSERT(pBlockScanInfo->iter.iter == NULL);
|
||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL);
|
||||
|
@ -2353,10 +2294,9 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
|
|||
static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; }
|
||||
|
||||
bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) {
|
||||
if (pBlockData->nRow > 0) {
|
||||
ASSERT(pBlockData->nRow == pDumpInfo->totalRows);
|
||||
if ((pBlockData->nRow > 0) && (pBlockData->nRow != pDumpInfo->totalRows)) {
|
||||
return false; // this is an invalid result.
|
||||
}
|
||||
|
||||
return pBlockData->nRow > 0 && (!pDumpInfo->allDumped);
|
||||
}
|
||||
|
||||
|
@ -2423,6 +2363,46 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pBlockScanInfo,
|
||||
STsdbReader* pReader, bool* loadNeighbor) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||
int32_t nextIndex = -1;
|
||||
SBlockIndex nxtBIndex = {0};
|
||||
|
||||
*loadNeighbor = false;
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
|
||||
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &nxtBIndex);
|
||||
if (!hasNeighbor) { // do nothing
|
||||
return code;
|
||||
}
|
||||
|
||||
if (overlapWithNeighborBlock(pBlock, &nxtBIndex, pReader->order)) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
||||
// 1. find the next neighbor block in the scan block list
|
||||
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||
|
||||
// 2. remove it from the scan block list
|
||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||
|
||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// 4. check the data values
|
||||
initBlockDumpInfo(pReader, pBlockIter);
|
||||
*loadNeighbor = true;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -2481,39 +2461,13 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
||||
SBlockIndex bIndex = {0};
|
||||
int32_t nextIndex = -1;
|
||||
bool hasNeighbor = false;
|
||||
if (pBlockInfo != NULL) {
|
||||
hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||
}
|
||||
pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); // NOTE: get the new block info
|
||||
|
||||
if (!hasNeighbor) { // do nothing
|
||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
break;
|
||||
}
|
||||
|
||||
if (overlapWithNeighborBlock(pBlock, &bIndex, pReader->order)) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
||||
// 1. find the next neighbor block in the scan block list
|
||||
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||
|
||||
// 2. remove it from the scan block list
|
||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||
|
||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
break;
|
||||
}
|
||||
|
||||
// 4. check the data values
|
||||
initBlockDumpInfo(pReader, pBlockIter);
|
||||
} else {
|
||||
// continue check for the next file block if the last ts in the current block
|
||||
// is overlapped with the next neighbor block
|
||||
bool loadNeighbor = false;
|
||||
code = loadNeighborIfOverlap(pBlockInfo, pBlockScanInfo, pReader, &loadNeighbor);
|
||||
if ((!loadNeighbor) || (code != 0)) {
|
||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
break;
|
||||
}
|
||||
|
@ -2573,7 +2527,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
|
||||
int32_t code = 0;
|
||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||
ASSERT(pReader->pReadSnap != NULL);
|
||||
|
||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||
if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) {
|
||||
|
@ -2779,7 +2732,10 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus
|
|||
|
||||
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
|
||||
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
|
||||
ASSERT(pStatus->pTableIter != NULL);
|
||||
if (pStatus->pTableIter == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2854,7 +2810,6 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
|||
TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
|
||||
|
||||
if (pBlockInfo == NULL) { // build data block from last data file
|
||||
ASSERT(pBlockIter->numOfBlocks == 0);
|
||||
code = buildComposedDataBlock(pReader);
|
||||
} else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
|
||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid);
|
||||
|
@ -3124,10 +3079,10 @@ SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_
|
|||
}
|
||||
|
||||
bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order, SVersionRange* pVerRange) {
|
||||
ASSERT(pKey != NULL);
|
||||
if (pDelList == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t num = taosArrayGetSize(pDelList);
|
||||
bool asc = ASCENDING_TRAVERSE(order);
|
||||
int32_t step = asc ? 1 : -1;
|
||||
|
@ -3330,35 +3285,10 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
*state = CHECK_FILEBLOCK_QUIT;
|
||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||
|
||||
int32_t nextIndex = -1;
|
||||
SBlockIndex bIndex = {0};
|
||||
|
||||
bool hasNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||
if (!hasNeighbor) { // do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool overlap = overlapWithNeighborBlock(pBlock, &bIndex, pReader->order);
|
||||
if (overlap) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
||||
// 1. find the next neighbor block in the scan block list
|
||||
SFileDataBlockInfo fb = {.uid = pFBlock->uid, .tbBlockIdx = nextIndex};
|
||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||
|
||||
// 2. remove it from the scan block list
|
||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||
|
||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||
int32_t code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pFBlock->uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// 4. check the data values
|
||||
initBlockDumpInfo(pReader, pBlockIter);
|
||||
bool loadNeighbor = true;
|
||||
int32_t code = loadNeighborIfOverlap(pFBlock, pScanInfo, pReader, &loadNeighbor);
|
||||
|
||||
if (loadNeighbor && (code == TSDB_CODE_SUCCESS)) {
|
||||
pDumpInfo->rowIndex =
|
||||
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
||||
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
||||
|
@ -3366,7 +3296,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
|
||||
|
@ -3552,6 +3482,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
|
|||
}
|
||||
|
||||
int32_t code = tsdbRowMergerGetRow(&merge, pTSRow);
|
||||
tsdbRowMergerClear(&merge);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3744,13 +3675,11 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
|||
}
|
||||
} while (1);
|
||||
|
||||
ASSERT(pBlock->info.rows <= capacity);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO refactor: with createDataBlockScanInfo
|
||||
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||
ASSERT(pReader != NULL);
|
||||
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
||||
|
||||
STableBlockScanInfo** p = NULL;
|
||||
|
@ -3883,15 +3812,16 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
}
|
||||
|
||||
if (pReader->pSchema != NULL) {
|
||||
updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo);
|
||||
code = updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
STsdbReader* p = (pReader->innerReader[0] != NULL) ? pReader->innerReader[0] : pReader;
|
||||
pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables);
|
||||
if (pReader->status.pTableMap == NULL) {
|
||||
tsdbReaderClose(p);
|
||||
*ppReader = NULL;
|
||||
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
@ -4114,7 +4044,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
}
|
||||
|
||||
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||
ASSERT(pReader != NULL);
|
||||
*rows = pReader->pResBlock->info.rows;
|
||||
*uid = pReader->pResBlock->info.id.uid;
|
||||
*pWindow = pReader->pResBlock->info.window;
|
||||
|
@ -4158,25 +4087,27 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_
|
|||
}
|
||||
|
||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) {
|
||||
SColumnDataAgg*** pBlockSMA = &pDataBlock->pBlockAgg;
|
||||
|
||||
int32_t code = 0;
|
||||
SColumnDataAgg ***pBlockSMA = &pDataBlock->pBlockAgg;
|
||||
*allHave = false;
|
||||
*pBlockSMA = NULL;
|
||||
|
||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
*pBlockSMA = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// there is no statistics data for composed block
|
||||
if (pReader->status.composedDataBlock || (!pReader->suppInfo.smaValid)) {
|
||||
*pBlockSMA = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter);
|
||||
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
|
||||
|
||||
ASSERT(pReader->pResBlock->info.id.uid == pFBlock->uid);
|
||||
if (pReader->pResBlock->info.id.uid != pFBlock->uid) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
if (tDataBlkHasSma(pBlock)) {
|
||||
|
@ -4204,13 +4135,10 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
|||
// update the number of NULL data rows
|
||||
size_t numOfCols = pSup->numOfCols;
|
||||
|
||||
int32_t i = 0, j = 0;
|
||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||
|
||||
// ensure capacity
|
||||
if(pDataBlock->pDataBlock) {
|
||||
size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
taosArrayEnsureCap(pSup->pColAgg, colsNum);
|
||||
if (pDataBlock->pDataBlock) {
|
||||
size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
taosArrayEnsureCap(pSup->pColAgg, colsNum);
|
||||
}
|
||||
|
||||
SSDataBlock* pResBlock = pReader->pResBlock;
|
||||
|
@ -4221,8 +4149,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
|||
|
||||
// do fill all null column value SMA info
|
||||
doFillNullColSMA(pSup, pBlock->nRow, numOfCols, pTsAgg);
|
||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||
|
||||
i = 0, j = 0;
|
||||
int32_t i = 0, j = 0;
|
||||
while (j < numOfCols && i < size) {
|
||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||
if (pAgg->colId == pSup->colId[j]) {
|
||||
|
@ -4232,15 +4161,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
|
|||
} else if (pAgg->colId < pSup->colId[j]) {
|
||||
i += 1;
|
||||
} else if (pSup->colId[j] < pAgg->colId) {
|
||||
if (pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
||||
} else {
|
||||
// all date in this block are null
|
||||
SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = pBlock->nRow};
|
||||
taosArrayPush(pSup->pColAgg, &nullColAgg);
|
||||
|
||||
pResBlock->pBlockAgg[pSup->slotId[j]] = taosArrayGetLast(pSup->pColAgg);
|
||||
}
|
||||
// ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
|
@ -4349,6 +4271,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
pTableBlockInfo->totalSize = 0;
|
||||
pTableBlockInfo->totalRows = 0;
|
||||
pTableBlockInfo->numOfVgroups = 1;
|
||||
|
||||
// find the start data block in file
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
|
@ -4393,6 +4316,8 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
|||
pTableBlockInfo->numOfSmallBlocks += 1;
|
||||
}
|
||||
|
||||
pTableBlockInfo->totalSize += pBlock->aSubBlock[0].szBlock;
|
||||
|
||||
int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows);
|
||||
pTableBlockInfo->blockRowsHisto[bucketIndex]++;
|
||||
|
||||
|
@ -4470,9 +4395,12 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
|
|||
return terrno;
|
||||
}
|
||||
sversion = mr.me.stbEntry.schemaRow.version;
|
||||
} else {
|
||||
ASSERT(mr.me.type == TSDB_NORMAL_TABLE);
|
||||
} else if (mr.me.type == TSDB_NORMAL_TABLE) {
|
||||
sversion = mr.me.ntbEntry.schemaRow.version;
|
||||
} else {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
metaReaderClear(&mr);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
metaReaderClear(&mr);
|
||||
|
|
|
@ -123,7 +123,48 @@ void vnodeBufPoolReset(SVBufPool *pPool) {
|
|||
pPool->ptr = pPool->node.data;
|
||||
}
|
||||
|
||||
void *vnodeBufPoolMalloc(SVBufPool *pPool, int32_t size) {
|
||||
|
||||
void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) {
|
||||
SVBufPoolNode *pNode;
|
||||
void *p = NULL;
|
||||
uint8_t *ptr = NULL;
|
||||
int paddingLen = 0;
|
||||
ASSERT(pPool != NULL);
|
||||
|
||||
if (pPool->lock) taosThreadSpinLock(pPool->lock);
|
||||
|
||||
ptr = pPool->ptr;
|
||||
paddingLen = (((long)ptr + 7) & ~7) - (long)ptr;
|
||||
|
||||
if (pPool->node.size >= pPool->ptr - pPool->node.data + size + paddingLen) {
|
||||
// allocate from the anchor node
|
||||
p = pPool->ptr + paddingLen;
|
||||
size += paddingLen;
|
||||
pPool->ptr = pPool->ptr + size;
|
||||
pPool->size += size;
|
||||
} else {
|
||||
// allocate a new node
|
||||
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
|
||||
if (pNode == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = pNode->data;
|
||||
pNode->size = size;
|
||||
pNode->prev = pPool->pTail;
|
||||
pNode->pnext = &pPool->pTail;
|
||||
pPool->pTail->pnext = &pNode->prev;
|
||||
pPool->pTail = pNode;
|
||||
|
||||
pPool->size = pPool->size + sizeof(*pNode) + size;
|
||||
}
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
return p;
|
||||
}
|
||||
|
||||
void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||
SVBufPoolNode *pNode;
|
||||
void *p = NULL;
|
||||
ASSERT(pPool != NULL);
|
||||
|
|
|
@ -184,18 +184,51 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int32_t vnodePrepareCommit(SVnode *pVnode) {
|
||||
static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
|
||||
tsem_wait(&pVnode->canCommit);
|
||||
|
||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||
|
||||
pInfo->info.config = pVnode->config;
|
||||
pInfo->info.state.committed = pVnode->state.applied;
|
||||
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
|
||||
pInfo->info.state.commitID = pVnode->state.commitID;
|
||||
pInfo->pVnode = pVnode;
|
||||
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||
|
||||
// save info
|
||||
if (pVnode->pTfs) {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
} else {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||
}
|
||||
if (vnodeSaveInfo(dir, &pInfo->info) < 0) {
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
tsdbPrepareCommit(pVnode->pTsdb);
|
||||
|
||||
metaPrepareAsyncCommit(pVnode->pMeta);
|
||||
|
||||
code = smaPrepareAsyncCommit(pVnode->pSma);
|
||||
if (code) goto _exit;
|
||||
|
||||
_exit:
|
||||
vnodeBufPoolUnRef(pVnode->inUse);
|
||||
pVnode->inUse = NULL;
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
vError("vgId:%d, %s failed at line %d since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, lino,
|
||||
tstrerror(code), pVnode->state.commitID);
|
||||
} else {
|
||||
vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -217,33 +250,32 @@ _exit:
|
|||
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||
int32_t code = 0;
|
||||
|
||||
// prepare to commit
|
||||
code = vnodePrepareCommit(pVnode);
|
||||
if (code) goto _exit;
|
||||
|
||||
// schedule the task
|
||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||
|
||||
SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo));
|
||||
if (NULL == pInfo) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
pInfo->info.config = pVnode->config;
|
||||
pInfo->info.state.committed = pVnode->state.applied;
|
||||
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
|
||||
pInfo->info.state.commitID = pVnode->state.commitID;
|
||||
pInfo->pVnode = pVnode;
|
||||
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||
|
||||
// prepare to commit
|
||||
code = vnodePrepareCommit(pVnode, pInfo);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// schedule the task
|
||||
code = vnodeScheduleTask(vnodeCommitTask, pInfo);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
if (NULL != pInfo) {
|
||||
taosMemoryFree(pInfo);
|
||||
}
|
||||
tsem_post(&pVnode->canCommit);
|
||||
vError("vgId:%d, %s failed since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, tstrerror(code),
|
||||
pVnode->state.commitID);
|
||||
} else {
|
||||
vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__);
|
||||
vInfo("vgId:%d, vnode async commit done, commitId:%" PRId64 " term:%" PRId64 " applied:%" PRId64, TD_VID(pVnode),
|
||||
pVnode->state.commitID, pVnode->state.applyTerm, pVnode->state.applied);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -262,7 +294,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
SVnode *pVnode = pInfo->pVnode;
|
||||
|
||||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
||||
vInfo("vgId:%d, start to commit, commitId:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
||||
pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm);
|
||||
|
||||
// persist wal before starting
|
||||
|
@ -271,16 +303,11 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// save info
|
||||
if (pVnode->pTfs) {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
} else {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||
}
|
||||
if (vnodeSaveInfo(dir, &pInfo->info) < 0) {
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||
syncBeginSnapshot(pVnode->sync, pVnode->state.applied);
|
||||
|
|
|
@ -67,9 +67,8 @@ _err:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
void vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||
vInfo("vgId:%d, close vnode snapshot reader", TD_VID(pReader->pVnode));
|
||||
if (pReader->pRsmaReader) {
|
||||
rsmaSnapReaderClose(&pReader->pRsmaReader);
|
||||
}
|
||||
|
@ -82,9 +81,7 @@ int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
|||
metaSnapReaderClose(&pReader->pMetaReader);
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, vnode snapshot reader closed", TD_VID(pReader->pVnode));
|
||||
taosMemoryFree(pReader);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
||||
|
@ -260,8 +257,8 @@ _exit:
|
|||
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);
|
||||
vDebug("vgId:%d, vnode snapshot read data, index:%" PRId64 " type:%d blockLen:%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);
|
||||
}
|
||||
|
@ -426,8 +423,8 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
|||
ASSERT(pHdr->index == pWriter->index + 1);
|
||||
pWriter->index = pHdr->index;
|
||||
|
||||
vInfo("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d nData:%d", TD_VID(pVnode), pHdr->index,
|
||||
pHdr->type, nData);
|
||||
vDebug("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d blockLen:%d", TD_VID(pVnode), pHdr->index,
|
||||
pHdr->type, nData);
|
||||
|
||||
switch (pHdr->type) {
|
||||
case SNAP_DATA_CFG: {
|
||||
|
|
|
@ -217,6 +217,10 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
|
||||
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
||||
|
||||
if (pMsg->msgType == TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE || pMsg->msgType == TDMT_STREAM_TASK_CHECK_RSP) {
|
||||
if (tqCheckLogInWal(pVnode->pTq, version)) return 0;
|
||||
}
|
||||
|
||||
// skip header
|
||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
len = pMsg->contLen - sizeof(SMsgHead);
|
||||
|
@ -1352,7 +1356,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void
|
|||
SSingleDeleteReq *pOneReq = taosArrayGet(deleteReq.deleteReqs, i);
|
||||
char *name = pOneReq->tbname;
|
||||
if (metaGetTableEntryByName(&mr, name) < 0) {
|
||||
vDebug("stream delete msg, skip vgId:%d since no table: %s", pVnode->config.vgId, name);
|
||||
vDebug("vgId:%d, stream delete msg, skip since no table: %s", pVnode->config.vgId, name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -380,9 +380,8 @@ static int32_t vnodeSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
static void vnodeSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
vnodeGetSnapshot(pFsm->data, pSnapshot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
|
@ -392,9 +391,9 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
|
|||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||
", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
", weak:%d, code:%d, state:%d %s, type:%s code:0x%x",
|
||||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, pMsg->info.conn.applyIndex, pMeta->isWeak, pMeta->code,
|
||||
pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
||||
pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType), pMsg->code);
|
||||
|
||||
return tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg);
|
||||
}
|
||||
|
@ -424,10 +423,9 @@ static int32_t vnodeSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void *
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
static void vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
int32_t code = vnodeSnapReaderClose(pReader);
|
||||
return code;
|
||||
vnodeSnapReaderClose(pReader);
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
|
@ -467,9 +465,9 @@ static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool
|
|||
|
||||
static int32_t vnodeSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, continue write vnode snapshot, len:%d", pVnode->config.vgId, len);
|
||||
vDebug("vgId:%d, continue write vnode snapshot, blockLen:%d", pVnode->config.vgId, len);
|
||||
int32_t code = vnodeSnapWrite(pWriter, pBuf, len);
|
||||
vDebug("vgId:%d, continue write vnode snapshot finished, len:%d", pVnode->config.vgId, len);
|
||||
vDebug("vgId:%d, continue write vnode snapshot finished, blockLen:%d", pVnode->config.vgId, len);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -539,7 +537,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
|||
pFsm->FpCommitCb = vnodeSyncCommitMsg;
|
||||
pFsm->FpPreCommitCb = vnodeSyncPreCommitMsg;
|
||||
pFsm->FpRollBackCb = vnodeSyncRollBackMsg;
|
||||
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshot;
|
||||
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshotInfo;
|
||||
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
||||
pFsm->FpLeaderTransferCb = NULL;
|
||||
pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty;
|
||||
|
|
|
@ -485,6 +485,9 @@ typedef struct SCtgOperation {
|
|||
ctgOpFunc func;
|
||||
} SCtgOperation;
|
||||
|
||||
#define CTG_AUTH_READ(_t) ((_t) == AUTH_TYPE_READ || (_t) == AUTH_TYPE_READ_OR_WRITE)
|
||||
#define CTG_AUTH_WRITE(_t) ((_t) == AUTH_TYPE_WRITE || (_t) == AUTH_TYPE_READ_OR_WRITE)
|
||||
|
||||
#define CTG_QUEUE_INC() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
|
||||
#define CTG_QUEUE_DEC() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
|
||||
|
||||
|
@ -579,34 +582,34 @@ typedef struct SCtgOperation {
|
|||
#define CTG_LOCK(type, _lock) \
|
||||
do { \
|
||||
if (CTG_READ == (type)) { \
|
||||
assert(atomic_load_32((_lock)) >= 0); \
|
||||
ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value before read lock"); \
|
||||
CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
taosRLockLatch(_lock); \
|
||||
CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
assert(atomic_load_32((_lock)) > 0); \
|
||||
ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value after read lock"); \
|
||||
} else { \
|
||||
assert(atomic_load_32((_lock)) >= 0); \
|
||||
ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value before write lock"); \
|
||||
CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
taosWLockLatch(_lock); \
|
||||
CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
|
||||
ASSERTS(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value after write lock"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CTG_UNLOCK(type, _lock) \
|
||||
do { \
|
||||
if (CTG_READ == (type)) { \
|
||||
assert(atomic_load_32((_lock)) > 0); \
|
||||
ASSERTS(atomic_load_32((_lock)) > 0, "invalid lock value before read unlock"); \
|
||||
CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
taosRUnLockLatch(_lock); \
|
||||
CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
assert(atomic_load_32((_lock)) >= 0); \
|
||||
ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after read unlock"); \
|
||||
} else { \
|
||||
assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
|
||||
ASSERTS(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY, "invalid lock value before write unlock"); \
|
||||
CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
taosWUnLockLatch(_lock); \
|
||||
CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
|
||||
assert(atomic_load_32((_lock)) >= 0); \
|
||||
ASSERTS(atomic_load_32((_lock)) >= 0, "invalid lock value after write unlock"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
|
|
@ -352,9 +352,9 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, co
|
|||
goto _return;
|
||||
}
|
||||
|
||||
if (type == AUTH_TYPE_READ && authRsp.readDbs && taosHashGet(authRsp.readDbs, dbFName, strlen(dbFName))) {
|
||||
if (CTG_AUTH_READ(type) && authRsp.readDbs && taosHashGet(authRsp.readDbs, dbFName, strlen(dbFName))) {
|
||||
*pass = true;
|
||||
} else if (type == AUTH_TYPE_WRITE && authRsp.writeDbs && taosHashGet(authRsp.writeDbs, dbFName, strlen(dbFName))) {
|
||||
} else if (CTG_AUTH_WRITE(type) && authRsp.writeDbs && taosHashGet(authRsp.writeDbs, dbFName, strlen(dbFName))) {
|
||||
*pass = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -471,17 +471,20 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
|
|||
}
|
||||
|
||||
int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) {
|
||||
int32_t code = 0;
|
||||
int32_t tid = atomic_fetch_add_32(&pJob->taskIdx, 1);
|
||||
|
||||
CTG_LOCK(CTG_WRITE, &pJob->taskLock);
|
||||
CTG_ERR_RET((*gCtgAsyncFps[type].initFp)(pJob, tid, param));
|
||||
CTG_UNLOCK(CTG_WRITE, &pJob->taskLock);
|
||||
CTG_ERR_JRET((*gCtgAsyncFps[type].initFp)(pJob, tid, param));
|
||||
|
||||
if (taskId) {
|
||||
*taskId = tid;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_return:
|
||||
CTG_UNLOCK(CTG_WRITE, &pJob->taskLock);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp,
|
||||
|
@ -1549,10 +1552,10 @@ int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf*
|
|||
goto _return;
|
||||
}
|
||||
|
||||
if (ctx->user.type == AUTH_TYPE_READ && pOut->readDbs &&
|
||||
if (CTG_AUTH_READ(ctx->user.type) && pOut->readDbs &&
|
||||
taosHashGet(pOut->readDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) {
|
||||
pass = true;
|
||||
} else if (ctx->user.type == AUTH_TYPE_WRITE && pOut->writeDbs &&
|
||||
} else if (CTG_AUTH_WRITE(ctx->user.type) && pOut->writeDbs &&
|
||||
taosHashGet(pOut->writeDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) {
|
||||
pass = true;
|
||||
}
|
||||
|
|
|
@ -718,11 +718,11 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, char *user, char *dbFName, AUTH_TYPE
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pUser->readDbs && taosHashGet(pUser->readDbs, dbFName, strlen(dbFName)) && type == AUTH_TYPE_READ) {
|
||||
if (pUser->readDbs && taosHashGet(pUser->readDbs, dbFName, strlen(dbFName)) && CTG_AUTH_READ(type)) {
|
||||
*pass = true;
|
||||
}
|
||||
|
||||
if (pUser->writeDbs && taosHashGet(pUser->writeDbs, dbFName, strlen(dbFName)) && type == AUTH_TYPE_WRITE) {
|
||||
if (pUser->writeDbs && taosHashGet(pUser->writeDbs, dbFName, strlen(dbFName)) && CTG_AUTH_WRITE(type)) {
|
||||
*pass = true;
|
||||
}
|
||||
|
||||
|
@ -2500,6 +2500,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
|
|||
|
||||
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||
if (NULL == pCache->pMeta) {
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName);
|
||||
ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag);
|
||||
taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1);
|
||||
|
|
|
@ -22,7 +22,6 @@ extern SCatalogMgmt gCtgMgmt;
|
|||
SCtgDebug gCTGDebug = {0};
|
||||
|
||||
void ctgdUserCallback(SMetaData *pResult, void *param, int32_t code) {
|
||||
ASSERT(*(int32_t *)param == 1);
|
||||
taosMemoryFree(param);
|
||||
|
||||
qDebug("async call result: %s", tstrerror(code));
|
||||
|
|
|
@ -40,7 +40,9 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
msgNum = taosArrayGetSize(batchRsp.pRsps);
|
||||
}
|
||||
|
||||
ASSERT(taskNum == msgNum || 0 == msgNum);
|
||||
if (ASSERTS(taskNum == msgNum || 0 == msgNum, "taskNum %d mis-match msgNum %d", taskNum, msgNum)) {
|
||||
msgNum = 0;
|
||||
}
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId,
|
||||
TMSG_INFO(cbParam->reqType + 1));
|
||||
|
@ -58,11 +60,19 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
if (msgNum > 0) {
|
||||
pRsp = taosArrayGet(batchRsp.pRsps, i);
|
||||
|
||||
taskMsg.msgType = pRsp->reqType;
|
||||
taskMsg.pData = pRsp->msg;
|
||||
taskMsg.len = pRsp->msgLen;
|
||||
|
||||
ASSERT(pRsp->msgIdx == *msgIdx);
|
||||
if (ASSERTS(pRsp->msgIdx == *msgIdx, "rsp msgIdx %d mis-match msgIdx %d", pRsp->msgIdx, *msgIdx)) {
|
||||
pRsp = &rsp;
|
||||
pRsp->msgIdx = *msgIdx;
|
||||
pRsp->reqType = -1;
|
||||
pRsp->rspCode = 0;
|
||||
taskMsg.msgType = -1;
|
||||
taskMsg.pData = NULL;
|
||||
taskMsg.len = 0;
|
||||
} else {
|
||||
taskMsg.msgType = pRsp->reqType;
|
||||
taskMsg.pData = pRsp->msg;
|
||||
taskMsg.len = pRsp->msgLen;
|
||||
}
|
||||
} else {
|
||||
pRsp = &rsp;
|
||||
pRsp->msgIdx = *msgIdx;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tgrant.h"
|
||||
#include "taosdef.h"
|
||||
|
||||
extern SConfig* tsCfg;
|
||||
|
||||
|
@ -40,7 +41,6 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe
|
|||
(*pRsp)->numOfCols = htonl(numOfCols);
|
||||
|
||||
int32_t len = blockEncode(pBlock, (*pRsp)->data, numOfCols);
|
||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -154,6 +154,23 @@ static int32_t buildCreateDBResultDataBlock(SSDataBlock** pOutput) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildAliveResultDataBlock(SSDataBlock** pOutput) {
|
||||
SSDataBlock* pBlock = createDataBlock();
|
||||
if (NULL == pBlock) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SColumnInfoData infoData = createColumnInfoData(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1);
|
||||
int32_t code = blockDataAppendColInfo(pBlock, &infoData);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = pBlock;
|
||||
} else {
|
||||
blockDataDestroy(pBlock);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int64_t getValOfDiffPrecision(int8_t unit, int64_t val) {
|
||||
int64_t v = 0;
|
||||
switch (unit) {
|
||||
|
@ -281,6 +298,108 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S
|
|||
colDataAppend(pCol2, 0, buf2, false);
|
||||
}
|
||||
|
||||
#define CHECK_LEADER(n) (row[n] && (fields[n].type == TSDB_DATA_TYPE_VARCHAR && strncasecmp(row[n], "leader", varDataLen((char *)row[n] - VARSTR_HEADER_SIZE)) == 0))
|
||||
// on this row, if have leader return true else return false
|
||||
bool existLeaderRole(TAOS_ROW row, TAOS_FIELD* fields, int nFields) {
|
||||
// vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | v4_dnode |
|
||||
// v4_status | cacheload | tsma |
|
||||
if (nFields != 13) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check have leader on cloumn v*_status on 4 6 8 10
|
||||
if (CHECK_LEADER(4) || CHECK_LEADER(6) || CHECK_LEADER(8) || CHECK_LEADER(10)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// get db alive status, return 1 is alive else return 0
|
||||
int32_t getAliveStatusFromApi(int64_t* pConnId, char* dbName, int32_t* pStatus) {
|
||||
char sql[128 + TSDB_DB_NAME_LEN] = "select * from information_schema.ins_vgroups";
|
||||
int32_t code;
|
||||
|
||||
// filter with db name
|
||||
if (dbName && dbName[0] != 0) {
|
||||
char str[64 + TSDB_DB_NAME_LEN] = "";
|
||||
// test db name exist
|
||||
sprintf(str, "show create database %s ;", dbName);
|
||||
TAOS_RES* dbRes = taos_query(pConnId, str);
|
||||
code = taos_errno(dbRes);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taos_free_result(dbRes);
|
||||
return code;
|
||||
}
|
||||
taos_free_result(dbRes);
|
||||
|
||||
sprintf(str, " where db_name='%s' ;", dbName);
|
||||
strcat(sql, str);
|
||||
}
|
||||
|
||||
TAOS_RES* res = taos_query(pConnId, sql);
|
||||
code = taos_errno(res);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taos_free_result(res);
|
||||
return code;
|
||||
}
|
||||
|
||||
TAOS_ROW row = NULL;
|
||||
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||
int32_t nFields = taos_num_fields(res);
|
||||
int32_t nAvailble = 0;
|
||||
int32_t nUnAvailble = 0;
|
||||
|
||||
while ((row = taos_fetch_row(res)) != NULL) {
|
||||
if (existLeaderRole(row, fields, nFields)) {
|
||||
nAvailble++;
|
||||
} else {
|
||||
nUnAvailble++;
|
||||
}
|
||||
}
|
||||
taos_free_result(res);
|
||||
|
||||
int32_t status = 0;
|
||||
if (nAvailble + nUnAvailble == 0 || nUnAvailble == 0) {
|
||||
status = SHOW_STATUS_AVAILABLE;
|
||||
} else if (nAvailble > 0 && nUnAvailble > 0) {
|
||||
status = SHOW_STATUS_HALF_AVAILABLE;
|
||||
} else {
|
||||
status = SHOW_STATUS_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (pStatus) {
|
||||
*pStatus = status;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t setAliveResultIntoDataBlock(int64_t* pConnId, SSDataBlock* pBlock, char* dbName) {
|
||||
blockDataEnsureCapacity(pBlock, 1);
|
||||
pBlock->info.rows = 1;
|
||||
|
||||
SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
int32_t status = 0;
|
||||
int32_t code = getAliveStatusFromApi(pConnId, dbName, &status);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
colDataAppend(pCol1, 0, (const char*)&status, false);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t execShowAliveStatus(int64_t* pConnId, SShowAliveStmt* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
SSDataBlock* pBlock = NULL;
|
||||
int32_t code = buildAliveResultDataBlock(&pBlock);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setAliveResultIntoDataBlock(pConnId, pBlock, pStmt->dbName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildRetrieveTableRsp(pBlock, SHOW_ALIVE_RESULT_COLS, pRsp);
|
||||
}
|
||||
blockDataDestroy(pBlock);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
SSDataBlock* pBlock = NULL;
|
||||
int32_t code = buildCreateDBResultDataBlock(&pBlock);
|
||||
|
@ -736,7 +855,7 @@ static int32_t execSelectWithoutFrom(SSelectStmt* pSelect, SRetrieveTableRsp** p
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t qExecCommand(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
||||
switch (nodeType(pStmt)) {
|
||||
case QUERY_NODE_DESCRIBE_STMT:
|
||||
return execDescribe(sysInfoUser, pStmt, pRsp);
|
||||
|
@ -754,6 +873,9 @@ int32_t qExecCommand(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp) {
|
|||
return execShowLocalVariables(pRsp);
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
return execSelectWithoutFrom((SSelectStmt*)pStmt, pRsp);
|
||||
case QUERY_NODE_SHOW_DB_ALIVE_STMT:
|
||||
case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
|
||||
return execShowAliveStatus(pConnId, (SShowAliveStmt*)pStmt, pRsp);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1666,7 +1666,6 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
|||
rsp->numOfRows = htobe64((int64_t)rowNum);
|
||||
|
||||
int32_t len = blockEncode(pBlock, rsp->data, taosArrayGetSize(pBlock->pDataBlock));
|
||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||
|
||||
rsp->compLen = htonl(len);
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ typedef struct {
|
|||
SSchemaWrapper* schema;
|
||||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
int8_t recoverStep;
|
||||
int8_t recoverScanFinished;
|
||||
SQueryTableDataCond tableCond;
|
||||
int64_t fillHistoryVer1;
|
||||
int64_t fillHistoryVer2;
|
||||
|
@ -471,6 +472,11 @@ typedef struct SStreamScanInfo {
|
|||
SNodeList* pGroupTags;
|
||||
SNode* pTagCond;
|
||||
SNode* pTagIndexCond;
|
||||
|
||||
// recover
|
||||
int32_t blockRecoverContiCnt;
|
||||
int32_t blockRecoverTotCnt;
|
||||
|
||||
} SStreamScanInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -659,7 +665,6 @@ typedef struct SStreamFillOperatorInfo {
|
|||
SSDataBlock* pRes;
|
||||
SSDataBlock* pSrcBlock;
|
||||
int32_t srcRowIndex;
|
||||
SSDataBlock* pPrevSrcBlock;
|
||||
SSDataBlock* pSrcDelBlock;
|
||||
int32_t srcDelRowIndex;
|
||||
SSDataBlock* pDelRes;
|
||||
|
|
|
@ -90,7 +90,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
|||
|
||||
uint64_t suid = tableListGetSuid(pTableList);
|
||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader);
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader);
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||
taosArrayClear(pInfo->pUidList);
|
||||
|
||||
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
||||
|
|
|
@ -62,8 +62,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
|
|||
pEntry->numOfCols = taosArrayGetSize(pInput->pData->pDataBlock);
|
||||
pEntry->dataLen = sizeof(SDeleterRes);
|
||||
|
||||
ASSERT(1 == pEntry->numOfRows);
|
||||
ASSERT(3 == pEntry->numOfCols);
|
||||
// ASSERT(1 == pEntry->numOfRows);
|
||||
// ASSERT(3 == pEntry->numOfCols);
|
||||
|
||||
pBuf->useSize = sizeof(SDataCacheEntry);
|
||||
|
||||
|
@ -167,7 +167,6 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
|
|||
|
||||
SDataDeleterBuf* pBuf = NULL;
|
||||
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
|
||||
ASSERT(NULL != pBuf);
|
||||
memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
|
||||
taosFreeQitem(pBuf);
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
|
|||
|
||||
pBuf->useSize = sizeof(SDataCacheEntry);
|
||||
pEntry->dataLen = blockEncode(pInput->pData, pEntry->data, numOfCols);
|
||||
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||
// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||
// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||
|
||||
pBuf->useSize += pEntry->dataLen;
|
||||
|
||||
|
@ -162,15 +162,14 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
|
|||
|
||||
SDataDispatchBuf* pBuf = NULL;
|
||||
taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf);
|
||||
ASSERT(NULL != pBuf);
|
||||
memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf));
|
||||
taosFreeQitem(pBuf);
|
||||
|
||||
SDataCacheEntry* pEntry = (SDataCacheEntry*)pDispatcher->nextOutput.pData;
|
||||
*pLen = pEntry->dataLen;
|
||||
|
||||
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||
// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||
// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||
|
||||
*pQueryEnd = pDispatcher->queryEnd;
|
||||
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen,
|
||||
|
@ -193,8 +192,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
|||
pOutput->numOfCols = pEntry->numOfCols;
|
||||
pOutput->compressed = pEntry->compressed;
|
||||
|
||||
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||
// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
|
||||
// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
|
||||
|
||||
atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen);
|
||||
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue