Merge branch '3.0' into fix/TD-19223-D
This commit is contained in:
commit
ada943c518
|
@ -107,7 +107,7 @@ sudo yum config-manager --set-enabled Powertools
|
|||
### macOS
|
||||
|
||||
```
|
||||
sudo brew install argp-standalone pkgconfig
|
||||
brew install argp-standalone pkgconfig
|
||||
```
|
||||
|
||||
### 设置 golang 开发环境
|
||||
|
@ -276,7 +276,7 @@ sudo make install
|
|||
安装成功后,可以在应用程序中双击 TDengine 图标启动服务,或者在终端中启动 TDengine 服务:
|
||||
|
||||
```bash
|
||||
launchctl start taosd
|
||||
launchctl start com.tdengine.taosd
|
||||
```
|
||||
|
||||
用户可以使用 TDengine CLI 来连接 TDengine 服务,在终端中,输入:
|
||||
|
|
|
@ -108,7 +108,7 @@ sudo yum config-manager --set-enabled powertools
|
|||
### macOS
|
||||
|
||||
```
|
||||
sudo brew install argp-standalone pkgconfig
|
||||
brew install argp-standalone pkgconfig
|
||||
```
|
||||
|
||||
### Setup golang environment
|
||||
|
@ -280,7 +280,7 @@ Installing from source code will also configure service management for TDengine.
|
|||
To start the service after installation, double-click the /applications/TDengine to start the program, or in a terminal, use:
|
||||
|
||||
```bash
|
||||
launchctl start taosd
|
||||
launchctl start com.tdengine.taosd
|
||||
```
|
||||
|
||||
Then users can use the TDengine CLI to connect the TDengine server. In a terminal, use:
|
||||
|
|
|
@ -45,10 +45,19 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
|
|||
ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare")
|
||||
|
||||
MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
|
||||
MESSAGE("Current system arch is 64")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
|
||||
MESSAGE("Current system arch is arm64")
|
||||
SET(TD_DARWIN_64 TRUE)
|
||||
SET(TD_DARWIN_ARM64 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_DARWIN_64")
|
||||
ADD_DEFINITIONS("-D_TD_DARWIN_ARM64")
|
||||
ENDIF ()
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
|
||||
MESSAGE("Current system arch is x86_64")
|
||||
SET(TD_DARWIN_64 TRUE)
|
||||
SET(TD_DARWIN_X64 TRUE)
|
||||
ADD_DEFINITIONS("-D_TD_DARWIN_64")
|
||||
ADD_DEFINITIONS("-D_TD_DARWIN_X64")
|
||||
ENDIF ()
|
||||
|
||||
ADD_DEFINITIONS("-DHAVE_UNISTD_H")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG d58230c
|
||||
GIT_TAG 4d02980
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -270,7 +270,7 @@ if(${JEMALLOC_ENABLED})
|
|||
PREFIX "jemalloc"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls
|
||||
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls --with-malloc-conf='background_thread:true,metadata_thp:auto'
|
||||
BUILD_COMMAND ${MAKE}
|
||||
)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include)
|
||||
|
|
|
@ -189,13 +189,13 @@ After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengin
|
|||
|
||||
<TabItem label="macOS" value="macos">
|
||||
|
||||
After the installation is complete, double-click the /applications/TDengine to start the program, or run `launchctl start taosd` to start TDengine Server.
|
||||
After the installation is complete, double-click the /applications/TDengine to start the program, or run `launchctl start com.tdengine.taosd` to start TDengine Server.
|
||||
|
||||
The following `launchctl` commands can help you manage TDengine service:
|
||||
|
||||
- Start TDengine Server: `launchctl start taosd`
|
||||
- Start TDengine Server: `launchctl start com.tdengine.taosd`
|
||||
|
||||
- Stop TDengine Server: `launchctl stop taosd`
|
||||
- Stop TDengine Server: `launchctl stop com.tdengine.taosd`
|
||||
|
||||
- Check TDengine Server status: `launchctl list | grep taosd`
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@ You can use the SHOW CONNECTIONS statement to find the conn_id.
|
|||
## Terminate a Query
|
||||
|
||||
```sql
|
||||
SHOW QUERY query_id;
|
||||
KILL QUERY kill_id;
|
||||
```
|
||||
|
||||
You can use the SHOW QUERIES statement to find the query_id.
|
||||
You can use the SHOW QUERIES statement to find the kill_id.
|
||||
|
||||
## Terminate a Transaction
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ The parameters related to database creation are configured in `dbinfo` in the js
|
|||
|
||||
- **name**: specify the name of the database.
|
||||
|
||||
- **drop**: indicate whether to delete the database before inserting. The default is true.
|
||||
- **drop**: indicate whether to delete the database before inserting. The value can be 'yes' or 'no'. No means do not drop. The default is to drop.
|
||||
|
||||
#### Stream processing related configuration parameters
|
||||
|
||||
|
|
|
@ -675,7 +675,7 @@ To prevent system resource from being exhausted by multiple concurrent streams,
|
|||
| Meaning | Whether to generate core file when server crashes |
|
||||
| Value Range | 0: false, 1: true |
|
||||
| Default Value | 1 |
|
||||
| Note | The core file is generated under root directory `systemctl/launchctl start taosd` is used to start, or under the working directory if `taosd` is started directly on Linux/macOS Shell. |
|
||||
| Note | The core file is generated under root directory `systemctl start taosd`/`launchctl start com.tdengine.taosd` is used to start, or under the working directory if `taosd` is started directly on Linux/macOS Shell. |
|
||||
|
||||
### udf
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ To make full use of the characteristics of time-series data, TDengine splits the
|
|||
|
||||
For time-series data, there is generally a retention policy, which is determined by the system configuration parameter `keep`. Data files exceeding this set number of days will be automatically deleted by the system to free up storage space.
|
||||
|
||||
Given `duration` and `keep` parameters, the total number of data files in a vnode is: keep/duration. The total number of data files should not be too large or too small. 10 to 100 is appropriate. Based on this principle, reasonable `duration` can be set. In the current version, parameter `keep` can be modified, but parameter `duration` cannot be modified once it is set.
|
||||
Given `duration` and `keep` parameters, the total number of data files in a vnode is: round up of (keep/duration+1). The total number of data files should not be too large or too small. 10 to 100 is appropriate. Based on this principle, reasonable `duration` can be set. In the current version, parameter `keep` can be modified, but parameter `duration` cannot be modified once it is set.
|
||||
|
||||
In each data file, the data of a table is stored in blocks. A table can have one or more data file blocks. In a file block, data is stored in columns, occupying a continuous storage space, thus greatly improving the reading speed. The size of file block is determined by the system parameter `maxRows` (the maximum number of records per block), and the default value is 4096. This value should not be too large or too small. If it is too large, data location for queries will take a longer time. If it is too small, the index of data block is too large, and the compression efficiency will be low with slower reading speed.
|
||||
|
||||
|
|
|
@ -1,6 +1,58 @@
|
|||
import taos
|
||||
from taos.tmq import TaosConsumer
|
||||
consumer = TaosConsumer('topic_ctb_column', group_id='vg2')
|
||||
for msg in consumer:
|
||||
for row in msg:
|
||||
print(row)
|
||||
from taos.tmq import *
|
||||
|
||||
conn = taos.connect()
|
||||
|
||||
print("init")
|
||||
conn.execute("drop database if exists py_tmq")
|
||||
conn.execute("create database if not exists py_tmq vgroups 2")
|
||||
conn.select_db("py_tmq")
|
||||
conn.execute(
|
||||
"create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)"
|
||||
)
|
||||
conn.execute("create table if not exists tb1 using stb1 tags(1)")
|
||||
conn.execute("create table if not exists tb2 using stb1 tags(2)")
|
||||
conn.execute("create table if not exists tb3 using stb1 tags(3)")
|
||||
|
||||
print("create topic")
|
||||
conn.execute("drop topic if exists topic_ctb_column")
|
||||
conn.execute(
|
||||
"create topic if not exists topic_ctb_column as select ts, c1, c2, c3 from stb1"
|
||||
)
|
||||
|
||||
print("build consumer")
|
||||
conf = TaosTmqConf()
|
||||
conf.set("group.id", "tg2")
|
||||
conf.set("td.connect.user", "root")
|
||||
conf.set("td.connect.pass", "taosdata")
|
||||
conf.set("enable.auto.commit", "true")
|
||||
|
||||
|
||||
def tmq_commit_cb_print(tmq, resp, offset, param=None):
|
||||
print(f"commit: {resp}, tmq: {tmq}, offset: {offset}, param: {param}")
|
||||
|
||||
|
||||
conf.set_auto_commit_cb(tmq_commit_cb_print, None)
|
||||
tmq = conf.new_consumer()
|
||||
|
||||
print("build topic list")
|
||||
|
||||
topic_list = TaosTmqList()
|
||||
topic_list.append("topic_ctb_column")
|
||||
|
||||
print("basic consume loop")
|
||||
tmq.subscribe(topic_list)
|
||||
|
||||
sub_list = tmq.subscription()
|
||||
|
||||
print("subscribed topics: ", sub_list)
|
||||
|
||||
while 1:
|
||||
res = tmq.poll(1000)
|
||||
if res:
|
||||
topic = res.get_topic_name()
|
||||
vg = res.get_vgroup_id()
|
||||
db = res.get_db_name()
|
||||
print(f"topic: {topic}\nvgroup id: {vg}\ndb: {db}")
|
||||
for row in res:
|
||||
print(row)
|
||||
|
|
|
@ -188,13 +188,13 @@ Active: inactive (dead)
|
|||
|
||||
<TabItem label="macOS 系统" value="macos">
|
||||
|
||||
安装后,在应用程序目录下,双击 TDengine 图标来启动程序,也可以运行 `launchctl start taosd` 来启动 TDengine 服务进程。
|
||||
安装后,在应用程序目录下,双击 TDengine 图标来启动程序,也可以运行 `launchctl start com.tdengine.taosd` 来启动 TDengine 服务进程。
|
||||
|
||||
如下 `launchctl` 命令可以帮助你管理 TDengine 服务:
|
||||
|
||||
- 启动服务进程:`launchctl start taosd`
|
||||
- 启动服务进程:`launchctl start com.tdengine.taosd`
|
||||
|
||||
- 停止服务进程:`launchctl stop taosd`
|
||||
- 停止服务进程:`launchctl stop com.tdengine.taosd`
|
||||
|
||||
- 查看服务状态:`launchctl list | grep taosd`
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ LTRIM(expr)
|
|||
#### RTRIM
|
||||
|
||||
```sql
|
||||
LTRIM(expr)
|
||||
RTRIM(expr)
|
||||
```
|
||||
|
||||
**功能说明**:返回清除右边空格后的字符串。
|
||||
|
|
|
@ -17,10 +17,10 @@ conn_id 可以通过 `SHOW CONNECTIONS` 获取。
|
|||
## 终止查询
|
||||
|
||||
```sql
|
||||
SHOW QUERY query_id;
|
||||
KILL QUERY kill_id;
|
||||
```
|
||||
|
||||
query_id 可以通过 `SHOW QUERIES` 获取。
|
||||
kill_id 可以通过 `SHOW QUERIES` 获取。
|
||||
|
||||
## 终止事务
|
||||
|
||||
|
|
|
@ -94,3 +94,10 @@ description: "TDengine 3.0 版本的语法变更说明"
|
|||
| 9 | SAMPLE | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。
|
||||
| 10 | STATECOUNT | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。
|
||||
| 11 | STATEDURATION | 增强 | 可以直接用于超级表了。没有PARTITION BY时,超级表的数据会被合并成一条时间线。
|
||||
|
||||
|
||||
## SCHEMALESS 变更
|
||||
|
||||
| # | **元素** | **<div style={{width: 60}}>差异性</div>** | **说明** |
|
||||
| - | :------- | :-------- | :------- |
|
||||
| 1 | 主键ts 变更为 _ts | 变更 | schemaless自动建的列名用 _ 开头,不同于2.x。
|
||||
|
|
|
@ -231,7 +231,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
|
|||
|
||||
- **name** : 数据库名。
|
||||
|
||||
- **drop** : 插入前是否删除数据库,默认为 true。
|
||||
- **drop** : 插入前是否删除数据库,可选项为 "yes" 或者 "no", 为 "no" 时不创建。默认删除。
|
||||
|
||||
#### 流式计算相关配置参数
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
|
|||
|
||||
## 数据模式映射规则
|
||||
|
||||
本节将说明行协议的数据如何映射成为具有模式的数据。每个行协议中数据 measurement 映射为
|
||||
本节将说明 InfluxDB 行协议(Line Protocol)的数据如何映射成为具有模式的数据。每个行协议中数据 measurement 映射为
|
||||
超级表名称。tag_set 中的 标签名称为 数据模式中的标签名,field_set 中的名称为列名称。以如下数据为例,说明映射规则:
|
||||
|
||||
```json
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
// C api call sequence demo
|
||||
// to compile: gcc -o apidemo apidemo.c -ltaos
|
||||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -13,23 +25,23 @@
|
|||
#include "taos.h"
|
||||
|
||||
#define debugPrint(fmt, ...) \
|
||||
do { if (g_args.debug_print || g_args.verbose_print) \
|
||||
fprintf(stdout, "DEBG: "fmt, __VA_ARGS__); } while(0)
|
||||
do { if (g_args.debug_print || g_args.verbose_print) {\
|
||||
fprintf(stdout, "DEBG: "fmt, __VA_ARGS__); }} while (0)
|
||||
|
||||
#define warnPrint(fmt, ...) \
|
||||
do { fprintf(stderr, "\033[33m"); \
|
||||
fprintf(stderr, "WARN: "fmt, __VA_ARGS__); \
|
||||
fprintf(stderr, "\033[0m"); } while(0)
|
||||
fprintf(stderr, "\033[0m"); } while (0)
|
||||
|
||||
#define errorPrint(fmt, ...) \
|
||||
do { fprintf(stderr, "\033[31m"); \
|
||||
fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); \
|
||||
fprintf(stderr, "\033[0m"); } while(0)
|
||||
fprintf(stderr, "\033[0m"); } while (0)
|
||||
|
||||
#define okPrint(fmt, ...) \
|
||||
do { fprintf(stderr, "\033[32m"); \
|
||||
fprintf(stderr, "OK: "fmt, __VA_ARGS__); \
|
||||
fprintf(stderr, "\033[0m"); } while(0)
|
||||
fprintf(stderr, "\033[0m"); } while (0)
|
||||
|
||||
int64_t g_num_of_tb = 2;
|
||||
int64_t g_num_of_rec = 3;
|
||||
|
@ -74,10 +86,16 @@ static void prepare_data(TAOS* taos) {
|
|||
res = taos_query(taos, "create database test;");
|
||||
taos_free_result(res);
|
||||
taosMsleep(100);
|
||||
taos_select_db(taos, "test");
|
||||
if (taos_select_db(taos, "test")) {
|
||||
errorPrint("%s() LN%d: taos_select_db() failed\n",
|
||||
__func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
char command[1024] = {0};
|
||||
sprintf(command, "%s", "create table meters(ts timestamp, f float, n int, bin1 binary(20), c nchar(20), bin2 binary(20)) tags(area int, city binary(20), dist nchar(20), street binary(20));");
|
||||
sprintf(command, "%s", "create table meters(ts timestamp, f float, n int, "
|
||||
"bin1 binary(20), c nchar(20), bin2 binary(20)) tags(area int, "
|
||||
"city binary(20), dist nchar(20), street binary(20));");
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
okPrint("%s created\n", "meters");
|
||||
|
@ -117,12 +135,11 @@ static void prepare_data(TAOS* taos) {
|
|||
sprintf(command, "insert into t%"PRId64" "
|
||||
"values(%" PRId64 ", %f, %"PRId64", "
|
||||
"'%c%d', '%s%c%d', '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j,
|
||||
i, 1650000000000+j, j * 1.0, j,
|
||||
'a'+(int)j%25, rand(),
|
||||
// "涛思", 'z' - (int)j%25, rand(),
|
||||
"TAOS", 'z' - (int)j%25, rand(),
|
||||
'b' - (int)j%25, rand()
|
||||
);
|
||||
'b' - (int)j%25, rand());
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
affected = taos_affected_rows(res);
|
||||
|
@ -150,8 +167,7 @@ static void prepare_data(TAOS* taos) {
|
|||
i, 1650000000000+j+1, (float)j, j,
|
||||
'a'+(int)j%25, rand(),
|
||||
"数据", 'z' - (int)j%25, rand(),
|
||||
'b' - (int)j%25, rand()
|
||||
);
|
||||
'b' - (int)j%25, rand());
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
affected = taos_affected_rows(res);
|
||||
|
@ -179,7 +195,8 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
}
|
||||
|
||||
if (block) {
|
||||
warnPrint("%s", "call taos_fetch_block(), don't call taos_fetch_lengths()\n");
|
||||
warnPrint("%s", "call taos_fetch_block(), "
|
||||
"don't call taos_fetch_lengths()\n");
|
||||
int rows = 0;
|
||||
while ((rows = taos_fetch_block(res, &row))) {
|
||||
int *lengths = taos_fetch_lengths(res);
|
||||
|
@ -190,7 +207,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d type is %d, no need get offset\n",
|
||||
f, fields[f].type);
|
||||
for (int64_t c = 0; c < rows; c++) {
|
||||
switch(fields[f].type) {
|
||||
switch (fields[f].type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
if (taos_is_null(res, c, f)) {
|
||||
printf("col%d, row: %"PRId64" "
|
||||
|
@ -199,7 +216,8 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d, row: %"PRId64", "
|
||||
"value: %"PRId64"\n",
|
||||
f, c,
|
||||
*(int64_t*)((char*)(row[f])+c*sizeof(int64_t)));
|
||||
*(int64_t*)((char*)(row[f])
|
||||
+c*sizeof(int64_t)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -211,7 +229,8 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d, row: %"PRId64", "
|
||||
"value: %d\n",
|
||||
f, c,
|
||||
*(int32_t*)((char*)(row[f])+c*sizeof(int32_t)));
|
||||
*(int32_t*)((char*)(row[f])
|
||||
+c*sizeof(int32_t)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -223,7 +242,8 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d, row: %"PRId64", "
|
||||
"value: %f\n",
|
||||
f, c,
|
||||
*(float*)((char*)(row[f])+c*sizeof(float)));
|
||||
*(float*)((char*)(row[f])
|
||||
+c*sizeof(float)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -238,14 +258,18 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
if (offsets) {
|
||||
for (int c = 0; c < rows; c++) {
|
||||
if (offsets[c] != -1) {
|
||||
int length = *(int16_t*)((char*)(row[f]) + offsets[c]);
|
||||
int length = *(int16_t*)((char*)(row[f])
|
||||
+ offsets[c]);
|
||||
char *buf = calloc(1, length + 1);
|
||||
strncpy(buf, (char *)((char*)(row[f]) + offsets[c] + 2), length);
|
||||
printf("row: %d, col: %d, offset: %d, length: %d, content: %s\n",
|
||||
strncpy(buf, (char *)((char*)(row[f])
|
||||
+ offsets[c] + 2), length);
|
||||
printf("row: %d, col: %d, offset: %d, "
|
||||
"length: %d, content: %s\n",
|
||||
c, f, offsets[c], length, buf);
|
||||
free(buf);
|
||||
} else {
|
||||
printf("row: %d, col: %d, offset: -1, means content is NULL\n",
|
||||
printf("row: %d, col: %d, offset: -1, "
|
||||
"means content is NULL\n",
|
||||
c, f);
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +291,8 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
int* lengths = taos_fetch_lengths(res);
|
||||
if (lengths) {
|
||||
for (int c = 0; c < num_fields; c++) {
|
||||
printf("row: %"PRId64", col: %d, is_null: %s, length of column %d is %d\n",
|
||||
printf("row: %"PRId64", col: %d, is_null: %s, "
|
||||
"length of column %d is %d\n",
|
||||
num_rows, c,
|
||||
taos_is_null(res, num_rows, c)?"True":"False",
|
||||
c, lengths[c]);
|
||||
|
@ -277,7 +302,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
__func__, __LINE__, tbname);
|
||||
}
|
||||
|
||||
num_rows ++;
|
||||
num_rows++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +347,8 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||
if (taos == NULL) {
|
||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n",
|
||||
taos_errstr(taos));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in
|
|||
|
||||
// query client
|
||||
extern int32_t tsQueryPolicy;
|
||||
extern int32_t tsQueryRspPolicy;
|
||||
extern int32_t tsQuerySmaOptimize;
|
||||
extern int32_t tsQueryRsmaTolerance;
|
||||
extern bool tsQueryPlannerTrace;
|
||||
|
|
|
@ -1902,7 +1902,7 @@ static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
|
|||
if (pRebInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(pRebInfo->key, key);
|
||||
tstrncpy(pRebInfo->key, key, sizeof(pRebInfo->key));
|
||||
pRebInfo->lostConsumers = taosArrayInit(0, sizeof(int64_t));
|
||||
if (pRebInfo->lostConsumers == NULL) {
|
||||
goto _err;
|
||||
|
|
|
@ -30,9 +30,10 @@ typedef struct SMnode SMnode;
|
|||
|
||||
typedef struct {
|
||||
int32_t dnodeId;
|
||||
bool standby;
|
||||
bool deploy;
|
||||
SReplica replica;
|
||||
int8_t selfIndex;
|
||||
int8_t numOfReplicas;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
SMsgCb msgCb;
|
||||
} SMnodeOpt;
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ typedef enum {
|
|||
#define QUERY_POLICY_QNODE 3
|
||||
#define QUERY_POLICY_CLIENT 4
|
||||
|
||||
#define QUERY_RSP_POLICY_DELAY 0
|
||||
#define QUERY_RSP_POLICY_QUICK 1
|
||||
|
||||
typedef struct STableComInfo {
|
||||
uint8_t numOfTags; // the number of tags in schema
|
||||
uint8_t precision; // the number of precision
|
||||
|
@ -230,7 +233,7 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
|||
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
||||
|
||||
extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen,
|
||||
void* (*mallocFp)(int32_t));
|
||||
void* (*mallocFp)(int64_t));
|
||||
extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t msgSize);
|
||||
|
||||
#define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE
|
||||
|
|
|
@ -43,7 +43,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type);
|
|||
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
|
||||
|
||||
int32_t vectorGetConvertType(int32_t type1, int32_t type2);
|
||||
int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow);
|
||||
int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow, int32_t startIndex, int32_t numOfRows);
|
||||
|
||||
/* Math functions */
|
||||
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
|
|
@ -211,7 +211,7 @@ typedef struct SSyncInfo {
|
|||
|
||||
int32_t syncInit();
|
||||
void syncCleanUp();
|
||||
int64_t syncOpen(const SSyncInfo* pSyncInfo);
|
||||
int64_t syncOpen(SSyncInfo* pSyncInfo);
|
||||
void syncStart(int64_t rid);
|
||||
void syncStop(int64_t rid);
|
||||
int32_t syncSetStandby(int64_t rid);
|
||||
|
@ -233,7 +233,7 @@ const char* syncStr(ESyncState state);
|
|||
bool syncIsRestoreFinish(int64_t rid);
|
||||
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot);
|
||||
|
||||
int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg);
|
||||
int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg);
|
||||
|
||||
// build SRpcMsg, need to call syncPropose with SRpcMsg
|
||||
int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg);
|
||||
|
|
|
@ -123,9 +123,9 @@ void rpcCleanup();
|
|||
void *rpcOpen(const SRpcInit *pRpc);
|
||||
void rpcClose(void *);
|
||||
void rpcCloseImpl(void *);
|
||||
void *rpcMallocCont(int32_t contLen);
|
||||
void *rpcMallocCont(int64_t contLen);
|
||||
void rpcFreeCont(void *pCont);
|
||||
void *rpcReallocCont(void *ptr, int32_t contLen);
|
||||
void *rpcReallocCont(void *ptr, int64_t contLen);
|
||||
|
||||
// Because taosd supports multi-process mode
|
||||
// These functions should not be used on the server side
|
||||
|
|
|
@ -43,6 +43,7 @@ extern "C" {
|
|||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL
|
||||
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
||||
#define WAL_RECOV_SIZE_LIMIT (100 * WAL_SCAN_BUF_SIZE)
|
||||
|
||||
typedef enum {
|
||||
TAOS_WAL_WRITE = 1,
|
||||
|
|
|
@ -49,9 +49,15 @@ extern SDiskSpace tsTempSpace;
|
|||
void osDefaultInit();
|
||||
void osUpdate();
|
||||
void osCleanup();
|
||||
|
||||
bool osLogSpaceAvailable();
|
||||
bool osDataSpaceAvailable();
|
||||
bool osTempSpaceAvailable();
|
||||
|
||||
bool osLogSpaceSufficient();
|
||||
bool osDataSpaceSufficient();
|
||||
bool osTempSpaceSufficient();
|
||||
|
||||
void osSetTimezone(const char *timezone);
|
||||
void osSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
|
||||
|
@ -59,4 +65,4 @@ void osSetSystemLocale(const char *inLocale, const char *inCharSet);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_OS_ENV_H_*/
|
||||
#endif /*_TD_OS_ENV_H_*/
|
||||
|
|
|
@ -29,12 +29,12 @@ extern "C" {
|
|||
#define free FREE_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
void *taosMemoryMalloc(int32_t size);
|
||||
void *taosMemoryCalloc(int32_t num, int32_t size);
|
||||
void *taosMemoryRealloc(void *ptr, int32_t size);
|
||||
void *taosMemoryMalloc(int64_t size);
|
||||
void *taosMemoryCalloc(int64_t num, int64_t size);
|
||||
void *taosMemoryRealloc(void *ptr, int64_t size);
|
||||
void *taosMemoryStrDup(const char *ptr);
|
||||
void taosMemoryFree(void *ptr);
|
||||
int32_t taosMemorySize(void *ptr);
|
||||
int64_t taosMemorySize(void *ptr);
|
||||
void taosPrintBackTrace();
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
|
|
|
@ -450,6 +450,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003)
|
||||
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
|
||||
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
|
||||
#define TSDB_CODE_WAL_CHKSUM_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x1006)
|
||||
|
||||
// tfs
|
||||
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct SRBTree SRBTree;
|
|||
typedef struct SRBTreeNode SRBTreeNode;
|
||||
typedef struct SRBTreeIter SRBTreeIter;
|
||||
|
||||
typedef int32_t (*tRBTreeCmprFn)(const void *, const void *);
|
||||
typedef int32_t (*tRBTreeCmprFn)(const SRBTreeNode *, const SRBTreeNode *);
|
||||
|
||||
// SRBTree =============================================
|
||||
#define tRBTreeMin(T) ((T)->min == ((T)->NIL) ? NULL : (T)->min)
|
||||
|
@ -36,7 +36,7 @@ void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn);
|
|||
SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z);
|
||||
void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z);
|
||||
SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey);
|
||||
SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey);
|
||||
SRBTreeNode *tRBTreeGet(SRBTree *pTree, const SRBTreeNode *pKeyNode);
|
||||
|
||||
// SRBTreeIter =============================================
|
||||
#define tRBTreeIterCreate(tree, ascend) \
|
||||
|
@ -53,8 +53,6 @@ struct SRBTreeNode {
|
|||
SRBTreeNode *right;
|
||||
};
|
||||
|
||||
#define RBTREE_NODE_PAYLOAD(N) ((const void *)&(N)[1])
|
||||
|
||||
struct SRBTree {
|
||||
tRBTreeCmprFn cmprFn;
|
||||
int64_t n;
|
||||
|
|
|
@ -260,7 +260,7 @@ if [ "$osType" != "Darwin" ]; then
|
|||
if [[ "$pagMode" == "full" ]]; then
|
||||
if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
|
||||
cd ${top_dir}/tools/taos-tools/packaging/deb
|
||||
taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}')
|
||||
taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
|
||||
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
|
||||
|
||||
${csudo}./make-taos-tools-deb.sh ${top_dir} \
|
||||
|
@ -285,7 +285,7 @@ if [ "$osType" != "Darwin" ]; then
|
|||
if [[ "$pagMode" == "full" ]]; then
|
||||
if [ -d ${top_dir}/tools/taos-tools/packaging/rpm ]; then
|
||||
cd ${top_dir}/tools/taos-tools/packaging/rpm
|
||||
taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}' | sed -e 's/-/_/g')
|
||||
taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
|
||||
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
|
||||
|
||||
${csudo}./make-taos-tools-rpm.sh ${top_dir} \
|
||||
|
|
|
@ -17,12 +17,12 @@ EOF
|
|||
|
||||
taosd_status=`Launchctl list | grep taosd | head -n 1 | awk '{print $1}'`
|
||||
if [ "$taosd_status"x = "-"x ]; then
|
||||
launchctl start taosd
|
||||
launchctl start com.tdengine.taosd
|
||||
showAlertMessage "Taosd is running!" "TDengine" "ok" "note"
|
||||
else
|
||||
choose_result=`showAlertMessage "Taosd is running!\nDo you want to close it?" "TDengine" "yes,cancel" "stop"`
|
||||
if [ "$choose_result"x = "button returned:yes"x ]; then
|
||||
launchctl stop taosd
|
||||
launchctl stop com.tdengine.taosd
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -0,0 +1,882 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PACKAGES</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>MUST-CLOSE-APPLICATION-ITEMS</key>
|
||||
<array/>
|
||||
<key>MUST-CLOSE-APPLICATIONS</key>
|
||||
<false/>
|
||||
<key>PACKAGE_FILES</key>
|
||||
<dict>
|
||||
<key>DEFAULT_INSTALL_LOCATION</key>
|
||||
<string>/</string>
|
||||
<key>HIERARCHY</key>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Applications</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>509</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Application Support</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Automator</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Documentation</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Extensions</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Filesystems</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Frameworks</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Input Methods</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Internet Plug-Ins</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Keyboard Layouts</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>LaunchAgents</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>LaunchDaemons</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>PreferencePanes</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Preferences</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Printers</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>PrivilegedHelperTools</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>1005</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>QuickLook</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>QuickTime</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Screen Savers</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Scripts</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Services</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Widgets</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Library</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>Shared</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>1023</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Users</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>/</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>PAYLOAD_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PRESERVE_EXTENDED_ATTRIBUTES</key>
|
||||
<false/>
|
||||
<key>SHOW_INVISIBLE</key>
|
||||
<false/>
|
||||
<key>SPLIT_FORKS</key>
|
||||
<true/>
|
||||
<key>TREAT_MISSING_FILES_AS_WARNING</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
<key>PACKAGE_SCRIPTS</key>
|
||||
<dict>
|
||||
<key>POSTINSTALL_PATH</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/opt/taos/TDengine/packaging/tools/post.sh</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>PREINSTALL_PATH</key>
|
||||
<dict>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>RESOURCES</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>0</integer>
|
||||
<key>PATH</key>
|
||||
<string>/opt/tdengine</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>493</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>3</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>PACKAGE_SETTINGS</key>
|
||||
<dict>
|
||||
<key>AUTHENTICATION</key>
|
||||
<integer>1</integer>
|
||||
<key>CONCLUSION_ACTION</key>
|
||||
<integer>0</integer>
|
||||
<key>FOLLOW_SYMBOLIC_LINKS</key>
|
||||
<false/>
|
||||
<key>IDENTIFIER</key>
|
||||
<string>com.taosdata.pkg.pkgtaos</string>
|
||||
<key>LOCATION</key>
|
||||
<integer>0</integer>
|
||||
<key>NAME</key>
|
||||
<string>TDengine</string>
|
||||
<key>OVERWRITE_PERMISSIONS</key>
|
||||
<true/>
|
||||
<key>PAYLOAD_SIZE</key>
|
||||
<integer>-1</integer>
|
||||
<key>REFERENCE_PATH</key>
|
||||
<string></string>
|
||||
<key>RELOCATABLE</key>
|
||||
<false/>
|
||||
<key>USE_HFS+_COMPRESSION</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
<string>3.0.1.4</string>
|
||||
</dict>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>UUID</key>
|
||||
<string>48F6B249-AF56-46E3-B75A-AEED5858A764</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PROJECT</key>
|
||||
<dict>
|
||||
<key>PROJECT_COMMENTS</key>
|
||||
<dict>
|
||||
<key>NOTES</key>
|
||||
<data>
|
||||
</data>
|
||||
</dict>
|
||||
<key>PROJECT_PRESENTATION</key>
|
||||
<dict>
|
||||
<key>BACKGROUND</key>
|
||||
<dict>
|
||||
<key>APPAREANCES</key>
|
||||
<dict>
|
||||
<key>DARK_AQUA</key>
|
||||
<dict/>
|
||||
<key>LIGHT_AQUA</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<key>SHARED_SETTINGS_FOR_ALL_APPAREANCES</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>INSTALLATION TYPE</key>
|
||||
<dict>
|
||||
<key>HIERARCHIES</key>
|
||||
<dict>
|
||||
<key>INSTALLER</key>
|
||||
<dict>
|
||||
<key>LIST</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>DESCRIPTION</key>
|
||||
<array/>
|
||||
<key>OPTIONS</key>
|
||||
<dict>
|
||||
<key>HIDDEN</key>
|
||||
<false/>
|
||||
<key>STATE</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>PACKAGE_UUID</key>
|
||||
<string>48F6B249-AF56-46E3-B75A-AEED5858A764</string>
|
||||
<key>TITLE</key>
|
||||
<array/>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>UUID</key>
|
||||
<string>7ED88D2C-D55C-46FF-99CB-73313ACAD73D</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>REMOVED</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>MODE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>INSTALLATION_STEPS</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewIntroductionController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>Introduction</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewReadMeController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>ReadMe</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewLicenseController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>License</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewDestinationSelectController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>TargetSelect</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewInstallationTypeController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>PackageSelection</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewInstallationController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>Install</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key>
|
||||
<string>ICPresentationViewSummaryController</string>
|
||||
<key>INSTALLER_PLUGIN</key>
|
||||
<string>Summary</string>
|
||||
<key>LIST_TITLE_KEY</key>
|
||||
<string>InstallerSectionTitle</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INTRODUCTION</key>
|
||||
<dict>
|
||||
<key>LOCALIZATIONS</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>LANGUAGE</key>
|
||||
<string>English</string>
|
||||
<key>VALUE</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/opt/taos/TDengine/packaging/tools/mac_before_install.txt</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>LICENSE</key>
|
||||
<dict>
|
||||
<key>LOCALIZATIONS</key>
|
||||
<array/>
|
||||
<key>MODE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>README</key>
|
||||
<dict>
|
||||
<key>LOCALIZATIONS</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>SUMMARY</key>
|
||||
<dict>
|
||||
<key>LOCALIZATIONS</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>TITLE</key>
|
||||
<dict>
|
||||
<key>LOCALIZATIONS</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>LANGUAGE</key>
|
||||
<string>English</string>
|
||||
<key>VALUE</key>
|
||||
<string>TDengine</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>PROJECT_REQUIREMENTS</key>
|
||||
<dict>
|
||||
<key>LIST</key>
|
||||
<array/>
|
||||
<key>RESOURCES</key>
|
||||
<array/>
|
||||
<key>ROOT_VOLUME_ONLY</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>PROJECT_SETTINGS</key>
|
||||
<dict>
|
||||
<key>BUILD_FORMAT</key>
|
||||
<integer>0</integer>
|
||||
<key>BUILD_PATH</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/opt/taos/TDengine/release</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>EXCLUDED_FILES</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>PATTERNS_ARRAY</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.DS_Store</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PROTECTED</key>
|
||||
<true/>
|
||||
<key>PROXY_NAME</key>
|
||||
<string>Remove .DS_Store files</string>
|
||||
<key>PROXY_TOOLTIP</key>
|
||||
<string>Remove ".DS_Store" files created by the Finder.</string>
|
||||
<key>STATE</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PATTERNS_ARRAY</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.pbdevelopment</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PROTECTED</key>
|
||||
<true/>
|
||||
<key>PROXY_NAME</key>
|
||||
<string>Remove .pbdevelopment files</string>
|
||||
<key>PROXY_TOOLTIP</key>
|
||||
<string>Remove ".pbdevelopment" files created by ProjectBuilder or Xcode.</string>
|
||||
<key>STATE</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PATTERNS_ARRAY</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>CVS</string>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.cvsignore</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.cvspass</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.svn</string>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.git</string>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>.gitignore</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PROTECTED</key>
|
||||
<true/>
|
||||
<key>PROXY_NAME</key>
|
||||
<string>Remove SCM metadata</string>
|
||||
<key>PROXY_TOOLTIP</key>
|
||||
<string>Remove helper files and folders used by the CVS, SVN or Git Source Code Management systems.</string>
|
||||
<key>STATE</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PATTERNS_ARRAY</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>classes.nib</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>designable.db</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>info.nib</string>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PROTECTED</key>
|
||||
<true/>
|
||||
<key>PROXY_NAME</key>
|
||||
<string>Optimize nib files</string>
|
||||
<key>PROXY_TOOLTIP</key>
|
||||
<string>Remove "classes.nib", "info.nib" and "designable.nib" files within .nib bundles.</string>
|
||||
<key>STATE</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PATTERNS_ARRAY</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>REGULAR_EXPRESSION</key>
|
||||
<false/>
|
||||
<key>STRING</key>
|
||||
<string>Resources Disabled</string>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PROTECTED</key>
|
||||
<true/>
|
||||
<key>PROXY_NAME</key>
|
||||
<string>Remove Resources Disabled folders</string>
|
||||
<key>PROXY_TOOLTIP</key>
|
||||
<string>Remove "Resources Disabled" folders.</string>
|
||||
<key>STATE</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>SEPARATOR</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NAME</key>
|
||||
<string>TDengine-client-3.0.1.4-macOS-arm64</string>
|
||||
<key>PAYLOAD_ONLY</key>
|
||||
<false/>
|
||||
<key>TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>VERSION</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
</plist>
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>taosd</string>
|
||||
<string>com.tdengine.taosd</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/taosd</string>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start service : launchctl start taosd
|
||||
To start service : launchctl start com.tdengine.taosd
|
||||
To access TDengine : use taos in shell
|
|
@ -615,7 +615,7 @@ function update_TDengine() {
|
|||
if [ "$osType" != "Darwin" ]; then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start service ${NC}: launchctl start ${serverName}${NC}"
|
||||
echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}"
|
||||
fi
|
||||
[ -f ${installDir}/bin/taosadapter ] && \
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
|
||||
|
@ -666,7 +666,7 @@ function install_TDengine() {
|
|||
if [ "$osType" != "Darwin" ]; then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start service ${NC}: launchctl start ${serverName}${NC}"
|
||||
echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}"
|
||||
fi
|
||||
[ -f ${installDir}/bin/taosadapter ] && \
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
|
||||
|
|
|
@ -18,6 +18,7 @@ if [ "$osType" != "Darwin" ]; then
|
|||
script_dir=$(dirname $(readlink -f "$0"))
|
||||
verNumber=""
|
||||
lib_file_ext="so"
|
||||
lib_file_ext_1="so.1"
|
||||
|
||||
bin_link_dir="/usr/bin"
|
||||
lib_link_dir="/usr/lib"
|
||||
|
@ -29,6 +30,7 @@ else
|
|||
script_dir=${source_dir}/packaging/tools
|
||||
verNumber=`ls tdengine/driver | grep -E "libtaos\.[0-9]\.[0-9]" | sed "s/libtaos.//g" | sed "s/.dylib//g" | head -n 1`
|
||||
lib_file_ext="dylib"
|
||||
lib_file_ext_1="1.dylib"
|
||||
|
||||
bin_link_dir="/usr/local/bin"
|
||||
lib_link_dir="/usr/local/lib"
|
||||
|
@ -134,14 +136,14 @@ function install_lib() {
|
|||
[ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
|
||||
|
||||
${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||
${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.${lib_file_ext_1}
|
||||
${csudo}ln -s ${lib_link_dir}/libtaos.${lib_file_ext_1} ${lib_link_dir}/libtaos.${lib_file_ext}
|
||||
|
||||
[ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib_link_dir}/libtaosws.${lib_file_ext} ||:
|
||||
|
||||
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
|
||||
${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
||||
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.${lib_file_ext} ]]; then
|
||||
${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.${lib_file_ext_1} || :
|
||||
${csudo}ln -s ${lib64_link_dir}/libtaos.${lib_file_ext_1} ${lib64_link_dir}/libtaos.${lib_file_ext} || :
|
||||
|
||||
[ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
|
||||
fi
|
||||
|
|
|
@ -117,7 +117,7 @@ function clean_local_bin() {
|
|||
function clean_lib() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
[ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
|
||||
|
|
|
@ -19,6 +19,13 @@ target_link_libraries(
|
|||
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
||||
)
|
||||
|
||||
if(TD_DARWIN_ARM64)
|
||||
target_link_libraries(
|
||||
taos
|
||||
PRIVATE "-arch x86_64"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TD_WINDOWS)
|
||||
INCLUDE_DIRECTORIES(jni/windows)
|
||||
INCLUDE_DIRECTORIES(jni/windows/win32)
|
||||
|
|
|
@ -173,7 +173,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
|||
pTscObj->pAppInfo->totalDnodes = pRsp->query->totalDnodes;
|
||||
pTscObj->pAppInfo->onlineDnodes = pRsp->query->onlineDnodes;
|
||||
pTscObj->connId = pRsp->query->connId;
|
||||
tscTrace("conn %p hb rsp, dnodes %d/%d", pTscObj->connId, pTscObj->pAppInfo->onlineDnodes,
|
||||
tscTrace("conn %u hb rsp, dnodes %d/%d", pTscObj->connId, pTscObj->pAppInfo->onlineDnodes,
|
||||
pTscObj->pAppInfo->totalDnodes);
|
||||
|
||||
if (pRsp->query->killRid) {
|
||||
|
|
|
@ -186,7 +186,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
STscObj* pTscObj = (*pRequest)->pTscObj;
|
||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||
sizeof((*pRequest)->self))) {
|
||||
tscError("%d failed to add to request container, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self,
|
||||
tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s", (*pRequest)->self,
|
||||
(*pRequest)->requestId, pTscObj->id, sql);
|
||||
|
||||
taosMemoryFree(param);
|
||||
|
@ -371,7 +371,7 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
|
|||
pInfo->pQnodeList = taosArrayDup(pNodeList);
|
||||
taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad);
|
||||
tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%d", pInfo->clusterId,
|
||||
taosArrayGetSize(pInfo->pQnodeList));
|
||||
(int)taosArrayGetSize(pInfo->pQnodeList));
|
||||
}
|
||||
taosThreadMutexUnlock(&pInfo->qnodeMutex);
|
||||
|
||||
|
@ -1036,30 +1036,38 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat
|
|||
pRequest->type = pQuery->msgType;
|
||||
|
||||
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
||||
|
||||
SPlanContext cxt = {.queryId = pRequest->requestId,
|
||||
.acctId = pRequest->pTscObj->acctId,
|
||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||
.pAstRoot = pQuery->pRoot,
|
||||
.showRewrite = pQuery->showRewrite,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
.sysInfo = pRequest->pTscObj->sysInfo,
|
||||
.allocatorId = pRequest->allocatorRefId};
|
||||
SQueryPlan* pDag = NULL;
|
||||
int32_t code = qCreateQueryPlan(&cxt, &pDag, pMnodeList);
|
||||
if (code) {
|
||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
pRequest->body.subplanNum = pDag->numOfSubplans;
|
||||
.acctId = pRequest->pTscObj->acctId,
|
||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||
.pAstRoot = pQuery->pRoot,
|
||||
.showRewrite = pQuery->showRewrite,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
.sysInfo = pRequest->pTscObj->sysInfo,
|
||||
.allocatorId = pRequest->allocatorRefId};
|
||||
|
||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||
SQueryPlan* pDag = NULL;
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
int32_t code = qCreateQueryPlan(&cxt, &pDag, pMnodeList);
|
||||
if (code) {
|
||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
pRequest->body.subplanNum = pDag->numOfSubplans;
|
||||
}
|
||||
|
||||
pRequest->metric.planEnd = taosGetTimestampUs();
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
tscDebug("0x%" PRIx64 " create query plan success, elapsed time:%.2f ms, 0x%" PRIx64, pRequest->self,
|
||||
(pRequest->metric.planEnd - st)/1000.0, pRequest->requestId);
|
||||
}
|
||||
|
||||
pRequest->metric.planEnd = taosGetTimestampUs();
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||
SArray* pNodeList = NULL;
|
||||
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
||||
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||
SArray* pNodeList = NULL;
|
||||
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = getAppInfo(pRequest)->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
|
|
|
@ -146,7 +146,7 @@ void taos_close(TAOS *taos) {
|
|||
|
||||
int taos_errno(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||
if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_QRY_NOT_READY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -154,13 +154,12 @@ int taos_errno(TAOS_RES *res) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return ((SRequestObj *)res)->code == TSDB_CODE_RPC_REDIRECT ? TSDB_CODE_RPC_NETWORK_UNAVAIL
|
||||
: ((SRequestObj *)res)->code;
|
||||
return ((SRequestObj *)res)->code == TSDB_CODE_RPC_REDIRECT ? TSDB_CODE_QRY_NOT_READY : ((SRequestObj *)res)->code;
|
||||
}
|
||||
|
||||
const char *taos_errstr(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||
if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_QRY_NOT_READY;
|
||||
return (const char *)tstrerror(terrno);
|
||||
}
|
||||
|
||||
|
@ -172,7 +171,7 @@ const char *taos_errstr(TAOS_RES *res) {
|
|||
if (NULL != pRequest->msgBuf && (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR)) {
|
||||
return pRequest->msgBuf;
|
||||
} else {
|
||||
return pRequest->code == TSDB_CODE_RPC_REDIRECT ? (const char *)tstrerror(TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||
return pRequest->code == TSDB_CODE_RPC_REDIRECT ? (const char *)tstrerror(TSDB_CODE_QRY_NOT_READY)
|
||||
: (const char *)tstrerror(pRequest->code);
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +221,9 @@ void taos_kill_query(TAOS *taos) {
|
|||
|
||||
int64_t rid = *(int64_t *)taos;
|
||||
STscObj *pTscObj = acquireTscObj(rid);
|
||||
stopAllRequests(pTscObj->pRequests);
|
||||
if (pTscObj) {
|
||||
stopAllRequests(pTscObj->pRequests);
|
||||
}
|
||||
releaseTscObj(rid);
|
||||
}
|
||||
|
||||
|
|
|
@ -410,6 +410,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) {
|
|||
SDecoder decoder = {0};
|
||||
SVAlterTbReq vAlterTbReq = {0};
|
||||
char* string = NULL;
|
||||
cJSON* json = NULL;
|
||||
|
||||
// decode
|
||||
void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead));
|
||||
|
@ -419,7 +420,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
json = cJSON_CreateObject();
|
||||
if (json == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -524,6 +525,7 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) {
|
|||
SDecoder decoder = {0};
|
||||
SVDropStbReq req = {0};
|
||||
char* string = NULL;
|
||||
cJSON* json = NULL;
|
||||
|
||||
// decode
|
||||
void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead));
|
||||
|
@ -533,7 +535,7 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
json = cJSON_CreateObject();
|
||||
if (json == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -556,6 +558,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) {
|
|||
SDecoder decoder = {0};
|
||||
SVDropTbBatchReq req = {0};
|
||||
char* string = NULL;
|
||||
cJSON* json = NULL;
|
||||
|
||||
// decode
|
||||
void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead));
|
||||
|
@ -565,7 +568,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
json = cJSON_CreateObject();
|
||||
if (json == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -684,7 +687,7 @@ end:
|
|||
|
||||
static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
||||
SVDropStbReq req = {0};
|
||||
SDecoder coder;
|
||||
SDecoder coder = {0};
|
||||
SMDropStbReq pReq = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SRequestObj* pRequest = NULL;
|
||||
|
@ -1212,6 +1215,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SQuery* pQuery = NULL;
|
||||
SSubmitReq* subReq = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT);
|
||||
if (!pRequest) {
|
||||
|
@ -1228,8 +1232,8 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
}
|
||||
|
||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||
strcpy(pName.dbname, pRequest->pDb);
|
||||
strcpy(pName.tname, tbname);
|
||||
tstrncpy(pName.dbname, pRequest->pDb, sizeof(pName.dbname));
|
||||
tstrncpy(pName.tname, tbname, sizeof(pName.tname));
|
||||
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
|
@ -1278,7 +1282,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
int32_t submitLen = sizeof(SSubmitBlk) + schemaLen + rows * extendedRowSize;
|
||||
|
||||
int32_t totalLen = sizeof(SSubmitReq) + submitLen;
|
||||
SSubmitReq* subReq = taosMemoryCalloc(1, totalLen);
|
||||
subReq = taosMemoryCalloc(1, totalLen);
|
||||
SSubmitBlk* blk = POINTER_SHIFT(subReq, sizeof(SSubmitReq));
|
||||
void* blkSchema = POINTER_SHIFT(blk, sizeof(SSubmitBlk));
|
||||
STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen);
|
||||
|
@ -1352,6 +1356,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
if (NULL == pQuery) {
|
||||
uError("create SQuery error");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(subReq);
|
||||
goto end;
|
||||
}
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
|
@ -1390,6 +1395,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
end:
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
qDestroyQuery(pQuery);
|
||||
taosMemoryFree(subReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -299,6 +299,7 @@ static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool
|
|||
for (; i < taosArrayGetSize(cols); i++) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||
if (taosHashGet(hashTmp, kv->key, kv->keyLen) == NULL) {
|
||||
taosHashCleanup(hashTmp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +431,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
STableMeta *pTableMeta = NULL;
|
||||
|
||||
SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}};
|
||||
strcpy(pName.dbname, info->pRequest->pDb);
|
||||
tstrncpy(pName.dbname, info->pRequest->pDb, sizeof(pName.dbname));
|
||||
|
||||
SRequestConnInfo conn = {0};
|
||||
conn.pTrans = info->taos->pAppInfo->pTransporter;
|
||||
|
@ -874,7 +875,8 @@ static int32_t smlParseTS(SSmlHandle *info, const char *data, int32_t len, SArra
|
|||
kv->i = ts;
|
||||
kv->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
kv->length = (int16_t)tDataTypes[kv->type].bytes;
|
||||
if (cols) taosArrayPush(cols, &kv);
|
||||
taosArrayPush(cols, &kv);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1009,6 +1011,7 @@ static void smlParseTelnetElement(const char **sql, const char **data, int32_t *
|
|||
|
||||
static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTableName, SHashObj *dumplicateKey,
|
||||
SSmlMsgBuf *msg) {
|
||||
if(!cols) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
const char *sql = data;
|
||||
size_t childTableNameLen = strlen(tsSmlChildTableName);
|
||||
while (*sql != '\0') {
|
||||
|
@ -1082,7 +1085,7 @@ static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTab
|
|||
kv->length = valueLen;
|
||||
kv->type = TSDB_DATA_TYPE_NCHAR;
|
||||
|
||||
if (cols) taosArrayPush(cols, &kv);
|
||||
taosArrayPush(cols, &kv);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1370,8 +1373,14 @@ static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) {
|
|||
SHashObj *s2 = *(SHashObj **)key2;
|
||||
SSmlKv *kv1 = *(SSmlKv **)taosHashGet(s1, TS, TS_LEN);
|
||||
SSmlKv *kv2 = *(SSmlKv **)taosHashGet(s2, TS, TS_LEN);
|
||||
ASSERT(kv1->type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
ASSERT(kv2->type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
if(!kv1 || kv1->type != TSDB_DATA_TYPE_TIMESTAMP){
|
||||
uError("smlKvTimeHashCompare kv1");
|
||||
return -1;
|
||||
}
|
||||
if(!kv2 || kv2->type != TSDB_DATA_TYPE_TIMESTAMP){
|
||||
uError("smlKvTimeHashCompare kv2");
|
||||
return -1;
|
||||
}
|
||||
if (kv1->i < kv2->i) {
|
||||
return -1;
|
||||
} else if (kv1->i > kv2->i) {
|
||||
|
@ -1735,7 +1744,7 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
|
|||
kv->i = tsVal;
|
||||
kv->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
kv->length = (int16_t)tDataTypes[kv->type].bytes;
|
||||
if (cols) taosArrayPush(cols, &kv);
|
||||
taosArrayPush(cols, &kv);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1932,6 +1941,7 @@ static int32_t smlParseValueFromJSON(cJSON *root, SSmlKv *kv) {
|
|||
}
|
||||
|
||||
static int32_t smlParseColsFromJSON(cJSON *root, SArray *cols) {
|
||||
if(!cols) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
cJSON *metricVal = cJSON_GetObjectItem(root, "value");
|
||||
if (metricVal == NULL) {
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
|
@ -1941,7 +1951,7 @@ static int32_t smlParseColsFromJSON(cJSON *root, SArray *cols) {
|
|||
if (!kv) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (cols) taosArrayPush(cols, &kv);
|
||||
taosArrayPush(cols, &kv);
|
||||
|
||||
kv->key = VALUE;
|
||||
kv->keyLen = VALUE_LEN;
|
||||
|
@ -1955,7 +1965,9 @@ static int32_t smlParseColsFromJSON(cJSON *root, SArray *cols) {
|
|||
static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableName, SHashObj *dumplicateKey,
|
||||
SSmlMsgBuf *msg) {
|
||||
int32_t ret = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (!pKVs){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
cJSON *tags = cJSON_GetObjectItem(root, "tags");
|
||||
if (tags == NULL || tags->type != cJSON_Object) {
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
|
@ -1985,14 +1997,14 @@ static int32_t smlParseTagsFromJSON(cJSON *root, SArray *pKVs, char *childTableN
|
|||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||
strncpy(childTableName, tag->valuestring, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(childTableName, tag->valuestring, TSDB_TABLE_NAME_LEN);
|
||||
continue;
|
||||
}
|
||||
|
||||
// add kv to SSmlKv
|
||||
SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1);
|
||||
if (!kv) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pKVs) taosArrayPush(pKVs, &kv);
|
||||
taosArrayPush(pKVs, &kv);
|
||||
|
||||
// key
|
||||
kv->keyLen = keyLen;
|
||||
|
@ -2103,6 +2115,8 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
|
|||
if (!oneTable) {
|
||||
tinfo = smlBuildTableInfo();
|
||||
if (!tinfo) {
|
||||
smlDestroyCols(cols);
|
||||
if (info->dataFormat) taosArrayDestroy(cols);
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
taosHashPut(info->childTables, elements.measure, elements.measureTagsLen, &tinfo, POINTER_BYTES);
|
||||
|
@ -2295,7 +2309,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
SSmlTableInfo *tableData = *oneTable;
|
||||
|
||||
SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}};
|
||||
strcpy(pName.dbname, info->pRequest->pDb);
|
||||
tstrncpy(pName.dbname, info->pRequest->pDb, sizeof(pName.dbname));
|
||||
memcpy(pName.tname, tableData->childTableName, strlen(tableData->childTableName));
|
||||
|
||||
SRequestConnInfo conn = {0};
|
||||
|
@ -2477,11 +2491,12 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
|
|||
} else {
|
||||
pParam->request->body.resInfo.numOfRows += info->affectedRows;
|
||||
}
|
||||
// unlock
|
||||
taosThreadSpinUnlock(&pParam->lock);
|
||||
|
||||
if (pParam->cnt == pParam->total) {
|
||||
tsem_post(&pParam->sem);
|
||||
}
|
||||
taosThreadSpinUnlock(&pParam->lock);
|
||||
// unlock
|
||||
uDebug("SML:0x%" PRIx64 " insert finished, code: %d, rows: %d, total: %d", info->id, code, rows, info->affectedRows);
|
||||
info->cost.endTime = taosGetTimestampUs();
|
||||
info->cost.code = code;
|
||||
|
|
|
@ -201,6 +201,9 @@ int32_t stmtCacheBlock(STscStmt* pStmt) {
|
|||
}
|
||||
|
||||
STableDataBlocks** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if(!pSrc){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
STableDataBlocks* pDst = NULL;
|
||||
|
||||
STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc));
|
||||
|
|
|
@ -709,6 +709,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
int64_t refId = *(int64_t*)param;
|
||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||
if (tmq == NULL) {
|
||||
taosMemoryFree(param);
|
||||
return;
|
||||
}
|
||||
int64_t consumerId = tmq->consumerId;
|
||||
|
@ -870,8 +871,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
tmq_t* pTmq = taosMemoryCalloc(1, sizeof(tmq_t));
|
||||
if (pTmq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("consumer %" PRId64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||
pTmq->groupId);
|
||||
tscError("consumer setup failed since %s", terrstr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -939,10 +939,9 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int64_t* pRefId = taosMemoryMalloc(sizeof(int64_t));
|
||||
*pRefId = pTmq->refId;
|
||||
|
||||
if (pTmq->hbBgEnable) {
|
||||
int64_t* pRefId = taosMemoryMalloc(sizeof(int64_t));
|
||||
*pRefId = pTmq->refId;
|
||||
pTmq->hbLiveTimer = taosTmrStart(tmqSendHbReq, 1000, pRefId, tmqMgmt.timer);
|
||||
}
|
||||
|
||||
|
@ -966,6 +965,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
SCMSubscribeReq req = {0};
|
||||
int32_t code = -1;
|
||||
|
||||
tscDebug("call tmq subscribe, consumer: %ld, topic num %d", tmq->consumerId, sz);
|
||||
|
||||
req.consumerId = tmq->consumerId;
|
||||
tstrncpy(req.clientId, tmq->clientId, 256);
|
||||
tstrncpy(req.cgroup, tmq->groupId, TSDB_CGROUP_LEN);
|
||||
|
@ -1297,7 +1298,8 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
pParam->code = code;
|
||||
if (code != 0) {
|
||||
tscError("consumer:%" PRId64 ", get topic endpoint error, not ready, wait:%d", tmq->consumerId, pParam->async);
|
||||
tscError("consumer:%" PRId64 ", get topic endpoint error, not ready, wait:%d, code %x", tmq->consumerId,
|
||||
pParam->async, code);
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,15 +52,15 @@ void printResult(TAOS_RES* pRes) {
|
|||
int32_t n = 0;
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
int32_t* length = taos_fetch_lengths(pRes);
|
||||
for (int32_t i = 0; i < numOfFields; ++i) {
|
||||
printf("(%d):%d ", i, length[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
printf("%s\n", str);
|
||||
memset(str, 0, sizeof(str));
|
||||
// int32_t* length = taos_fetch_lengths(pRes);
|
||||
// for(int32_t i = 0; i < numOfFields; ++i) {
|
||||
// printf("(%d):%d " , i, length[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
//
|
||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
// printf("%s\n", str);
|
||||
// memset(str, 0, sizeof(str));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,17 +102,6 @@ void queryCallback(void* param, void* res, int32_t code) {
|
|||
taos_fetch_raw_block_a(res, fetchCallback, param);
|
||||
}
|
||||
|
||||
void queryCallback1(void* param, void* res, int32_t code) {
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
printf("failed to execute, reason:%s\n", taos_errstr(res));
|
||||
}
|
||||
|
||||
taos_free_result(res);
|
||||
|
||||
printf("exec query:\n");
|
||||
taos_query_a(param, "select * from tm1", queryCallback, param);
|
||||
}
|
||||
|
||||
void createNewTable(TAOS* pConn, int32_t index) {
|
||||
char str[1024] = {0};
|
||||
sprintf(str, "create table tu%d using st2 tags(%d)", index, index);
|
||||
|
@ -123,7 +112,7 @@ void createNewTable(TAOS* pConn, int32_t index) {
|
|||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
for (int32_t i = 0; i < 3280; i += 20) {
|
||||
for(int32_t i = 0; i < 10000; i += 20) {
|
||||
char sql[1024] = {0};
|
||||
sprintf(sql,
|
||||
"insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
||||
|
@ -141,10 +130,49 @@ void createNewTable(TAOS* pConn, int32_t index) {
|
|||
taos_free_result(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *queryThread(void *arg) {
|
||||
TAOS* pConn = taos_connect("192.168.0.209", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
printf("failed to connect to db, reason:%s", taos_errstr(pConn));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int64_t el = 0;
|
||||
|
||||
for (int32_t i = 0; i < 5000000; ++i) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
TAOS_RES* pRes = taos_query(pConn,
|
||||
"SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= 1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed, reason:%s\n", taos_errstr(pRes));
|
||||
} else {
|
||||
printResult(pRes);
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
el += (taosGetTimestampUs() - st);
|
||||
if (i % 1000 == 0 && i != 0) {
|
||||
printf("total:%d, avg time:%.2fms\n", i, el/(double)(i*1000));
|
||||
}
|
||||
}
|
||||
|
||||
taos_close(pConn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t numOfThreads = 1;
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
if (argc > 1) {
|
||||
numOfThreads = atoi(argv[1]);
|
||||
}
|
||||
|
||||
numOfThreads = TMAX(numOfThreads, 1);
|
||||
printf("the runing threads is:%d", numOfThreads);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
|
@ -664,7 +692,6 @@ TEST(testCase, insert_test) {
|
|||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(testCase, projection_query_tables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
@ -676,13 +703,14 @@ TEST(testCase, projection_query_tables) {
|
|||
// }
|
||||
// taos_free_result(pRes);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
TAOS_RES* pRes = taos_query(pConn, "use benchmarkcpu");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create stable st1 (ts timestamp, k int) tags(a int)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create stable st2 (ts timestamp, k int) tags(a int)");
|
||||
|
@ -722,6 +750,16 @@ TEST(testCase, projection_query_tables) {
|
|||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(testCase, tsbs_perf_test) {
|
||||
TdThread qid[20] = {0};
|
||||
|
||||
for(int32_t i = 0; i < numOfThreads; ++i) {
|
||||
taosThreadCreate(&qid[i], NULL, queryThread, NULL);
|
||||
}
|
||||
getchar();
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(testCase, projection_query_stables) {
|
||||
|
|
|
@ -916,6 +916,10 @@ char *tTagValToData(const STagVal *value, bool isJson) {
|
|||
}
|
||||
|
||||
bool tTagGet(const STag *pTag, STagVal *pTagVal) {
|
||||
if(!pTag || !pTagVal){
|
||||
return false;
|
||||
}
|
||||
|
||||
int16_t lidx = 0;
|
||||
int16_t ridx = pTag->nTag - 1;
|
||||
int16_t midx;
|
||||
|
|
|
@ -90,6 +90,7 @@ bool tsSmlDataFormat = false;
|
|||
|
||||
// query
|
||||
int32_t tsQueryPolicy = 1;
|
||||
int32_t tsQueryRspPolicy = 0;
|
||||
int32_t tsQuerySmaOptimize = 0;
|
||||
int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from which level to query rsma data.
|
||||
bool tsQueryPlannerTrace = false;
|
||||
|
@ -350,6 +351,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1;
|
||||
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
|
@ -728,6 +730,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsMonitorPort = (uint16_t)cfgGetItem(pCfg, "monitorPort")->i32;
|
||||
tsMonitorMaxLogs = cfgGetItem(pCfg, "monitorMaxLogs")->i32;
|
||||
tsMonitorComp = cfgGetItem(pCfg, "monitorComp")->bval;
|
||||
tsQueryRspPolicy = cfgGetItem(pCfg, "queryRspPolicy")->i32;
|
||||
|
||||
tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval;
|
||||
tsTelemInterval = cfgGetItem(pCfg, "telemetryInterval")->i32;
|
||||
|
|
|
@ -41,8 +41,8 @@ typedef struct SMnodeMgmt {
|
|||
} SMnodeMgmt;
|
||||
|
||||
// mmFile.c
|
||||
int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed);
|
||||
int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed);
|
||||
int32_t mmReadFile(const char *path, SMnodeOpt *pOption);
|
||||
int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption);
|
||||
|
||||
// mmHandle.c
|
||||
SArray *mmGetMsgHandles();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "mmInt.h"
|
||||
|
||||
int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed) {
|
||||
int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
|
||||
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
int32_t len = 0;
|
||||
int32_t maxLen = 4096;
|
||||
|
@ -25,7 +25,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed) {
|
|||
char file[PATH_MAX] = {0};
|
||||
TdFilePtr pFile = NULL;
|
||||
|
||||
snprintf(file, sizeof(file), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
||||
snprintf(file, sizeof(file), "%s%smnode.json", path, TD_DIRSEP);
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = 0;
|
||||
|
@ -50,38 +50,69 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed) {
|
|||
dError("failed to read %s since deployed not found", file);
|
||||
goto _OVER;
|
||||
}
|
||||
*pDeployed = deployed->valueint;
|
||||
pOption->deploy = deployed->valueint;
|
||||
|
||||
cJSON *id = cJSON_GetObjectItem(root, "id");
|
||||
if (id) {
|
||||
if (id->type != cJSON_Number) {
|
||||
dError("failed to read %s since id not found", file);
|
||||
cJSON *selfIndex = cJSON_GetObjectItem(root, "selfIndex");
|
||||
if (selfIndex) {
|
||||
if (selfIndex->type != cJSON_Number) {
|
||||
dError("failed to read %s since selfIndex not found", file);
|
||||
goto _OVER;
|
||||
}
|
||||
if (pReplica) {
|
||||
pReplica->id = id->valueint;
|
||||
}
|
||||
pOption->selfIndex = selfIndex->valueint;
|
||||
}
|
||||
|
||||
cJSON *fqdn = cJSON_GetObjectItem(root, "fqdn");
|
||||
if (fqdn) {
|
||||
if (fqdn->type != cJSON_String || fqdn->valuestring == NULL) {
|
||||
dError("failed to read %s since fqdn not found", file);
|
||||
cJSON *replicas = cJSON_GetObjectItem(root, "replicas");
|
||||
if (replicas) {
|
||||
if (replicas->type != cJSON_Array) {
|
||||
dError("failed to read %s since replicas not found", file);
|
||||
goto _OVER;
|
||||
}
|
||||
if (pReplica) {
|
||||
tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *port = cJSON_GetObjectItem(root, "port");
|
||||
if (port) {
|
||||
if (port->type != cJSON_Number) {
|
||||
dError("failed to read %s since port not found", file);
|
||||
int32_t numOfReplicas = cJSON_GetArraySize(replicas);
|
||||
if (numOfReplicas <= 0) {
|
||||
dError("failed to read %s since numOfReplicas:%d invalid", file, numOfReplicas);
|
||||
goto _OVER;
|
||||
}
|
||||
if (pReplica) {
|
||||
pReplica->port = (uint16_t)port->valueint;
|
||||
pOption->numOfReplicas = numOfReplicas;
|
||||
|
||||
for (int32_t i = 0; i < numOfReplicas; ++i) {
|
||||
SReplica *pReplica = pOption->replicas + i;
|
||||
|
||||
cJSON *replica = cJSON_GetArrayItem(replicas, i);
|
||||
if (replica == NULL) break;
|
||||
|
||||
cJSON *id = cJSON_GetObjectItem(replica, "id");
|
||||
if (id) {
|
||||
if (id->type != cJSON_Number) {
|
||||
dError("failed to read %s since id not found", file);
|
||||
goto _OVER;
|
||||
}
|
||||
if (pReplica) {
|
||||
pReplica->id = id->valueint;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *fqdn = cJSON_GetObjectItem(replica, "fqdn");
|
||||
if (fqdn) {
|
||||
if (fqdn->type != cJSON_String || fqdn->valuestring == NULL) {
|
||||
dError("failed to read %s since fqdn not found", file);
|
||||
goto _OVER;
|
||||
}
|
||||
if (pReplica) {
|
||||
tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *port = cJSON_GetObjectItem(replica, "port");
|
||||
if (port) {
|
||||
if (port->type != cJSON_Number) {
|
||||
dError("failed to read %s since port not found", file);
|
||||
goto _OVER;
|
||||
}
|
||||
if (pReplica) {
|
||||
pReplica->port = (uint16_t)port->valueint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,18 +123,18 @@ _OVER:
|
|||
if (root != NULL) cJSON_Delete(root);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
if (code == 0) {
|
||||
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
||||
dDebug("succcessed to read file %s, deployed:%d", file, pOption->deploy);
|
||||
}
|
||||
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed) {
|
||||
int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
||||
char file[PATH_MAX] = {0};
|
||||
char realfile[PATH_MAX] = {0};
|
||||
snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP);
|
||||
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
||||
snprintf(file, sizeof(file), "%s%smnode.json.bak", path, TD_DIRSEP);
|
||||
snprintf(realfile, sizeof(realfile), "%s%smnode.json", path, TD_DIRSEP);
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
|
@ -117,12 +148,25 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed)
|
|||
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||
|
||||
len += snprintf(content + len, maxLen - len, "{\n");
|
||||
if (pReplica != NULL && pReplica->id > 0) {
|
||||
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id);
|
||||
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn);
|
||||
len += snprintf(content + len, maxLen - len, " \"port\": %u\n,", pReplica->port);
|
||||
if (pOption->deploy && pOption->numOfReplicas > 0) {
|
||||
len += snprintf(content + len, maxLen - len, " \"selfIndex\": %d,\n", pOption->selfIndex);
|
||||
len += snprintf(content + len, maxLen - len, " \"replicas\": [{\n");
|
||||
|
||||
for (int32_t i = 0; i < pOption->numOfReplicas; ++i) {
|
||||
const SReplica *pReplica = pOption->replicas + i;
|
||||
if (pReplica != NULL && pReplica->id > 0) {
|
||||
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id);
|
||||
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn);
|
||||
len += snprintf(content + len, maxLen - len, " \"port\": %u\n", pReplica->port);
|
||||
}
|
||||
if (i < pOption->numOfReplicas - 1) {
|
||||
len += snprintf(content + len, maxLen - len, " },{\n");
|
||||
} else {
|
||||
len += snprintf(content + len, maxLen - len, " }],\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed);
|
||||
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", pOption->deploy);
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
taosWriteFile(pFile, content, len);
|
||||
|
@ -136,6 +180,6 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed)
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("successed to write %s, deployed:%d", realfile, deployed);
|
||||
dDebug("successed to write %s, deployed:%d", realfile, pOption->deploy);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -80,18 +80,21 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (createReq.replica != 1) {
|
||||
SMnodeOpt option = {.deploy = true, .numOfReplicas = createReq.replica, .selfIndex = -1};
|
||||
memcpy(option.replicas, createReq.replicas, sizeof(createReq.replicas));
|
||||
for (int32_t i = 0; i < option.numOfReplicas; ++i) {
|
||||
if (createReq.replicas[i].id == pInput->pData->dnodeId) {
|
||||
option.selfIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (option.selfIndex == -1) {
|
||||
terrno = TSDB_CODE_INVALID_OPTION;
|
||||
dGError("failed to create mnode since %s", terrstr());
|
||||
dGError("failed to create mnode since %s, selfIndex is -1", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool deployed = true;
|
||||
|
||||
SMnodeMgmt mgmt = {0};
|
||||
mgmt.path = pInput->path;
|
||||
mgmt.name = pInput->name;
|
||||
if (mmWriteFile(&mgmt, &createReq.replicas[0], deployed) != 0) {
|
||||
if (mmWriteFile(pInput->path, &option) != 0) {
|
||||
dGError("failed to write mnode file since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
@ -113,12 +116,8 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool deployed = false;
|
||||
|
||||
SMnodeMgmt mgmt = {0};
|
||||
mgmt.path = pInput->path;
|
||||
mgmt.name = pInput->name;
|
||||
if (mmWriteFile(&mgmt, NULL, deployed) != 0) {
|
||||
SMnodeOpt option = {.deploy = false};
|
||||
if (mmWriteFile(pInput->path, &option) != 0) {
|
||||
dGError("failed to write mnode file since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
@ -207,7 +206,6 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
// if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SHOW_VARIABLES, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SERVER_VERSION, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -25,38 +25,35 @@ static bool mmDeployRequired(const SMgmtInputOpt *pInput) {
|
|||
}
|
||||
|
||||
static int32_t mmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||
SMnodeMgmt mgmt = {0};
|
||||
mgmt.path = pInput->path;
|
||||
if (mmReadFile(&mgmt, NULL, required) != 0) {
|
||||
SMnodeOpt option = {0};
|
||||
if (mmReadFile(pInput->path, &option) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(*required)) {
|
||||
if (!option.deploy) {
|
||||
*required = mmDeployRequired(pInput);
|
||||
} else {
|
||||
*required = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInput, SMnodeOpt *pOption) {
|
||||
pOption->standby = false;
|
||||
pOption->deploy = true;
|
||||
pOption->msgCb = pMgmt->msgCb;
|
||||
pOption->dnodeId = pMgmt->pData->dnodeId;
|
||||
pOption->replica.id = 1;
|
||||
pOption->replica.port = tsServerPort;
|
||||
tstrncpy(pOption->replica.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||
pOption->selfIndex = 0;
|
||||
pOption->numOfReplicas = 1;
|
||||
pOption->replicas[0].id = 1;
|
||||
pOption->replicas[0].port = tsServerPort;
|
||||
tstrncpy(pOption->replicas[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||
}
|
||||
|
||||
static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, const SReplica *pReplica, SMnodeOpt *pOption) {
|
||||
pOption->standby = false;
|
||||
static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
||||
pOption->deploy = false;
|
||||
pOption->msgCb = pMgmt->msgCb;
|
||||
pOption->dnodeId = pMgmt->pData->dnodeId;
|
||||
if (pReplica->id > 0) {
|
||||
pOption->standby = true;
|
||||
pOption->replica = *pReplica;
|
||||
}
|
||||
}
|
||||
|
||||
static void mmClose(SMnodeMgmt *pMgmt) {
|
||||
|
@ -95,22 +92,20 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
pMgmt->msgCb.mgmt = pMgmt;
|
||||
taosThreadRwlockInit(&pMgmt->lock, NULL);
|
||||
|
||||
bool deployed = false;
|
||||
SReplica replica = {0};
|
||||
if (mmReadFile(pMgmt, &replica, &deployed) != 0) {
|
||||
SMnodeOpt option = {0};
|
||||
if (mmReadFile(pMgmt->path, &option) != 0) {
|
||||
dError("failed to read file since %s", terrstr());
|
||||
mmClose(pMgmt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMnodeOpt option = {0};
|
||||
if (!deployed) {
|
||||
if (!option.deploy) {
|
||||
dInfo("mnode start to deploy");
|
||||
pMgmt->pData->dnodeId = 1;
|
||||
mmBuildOptionForDeploy(pMgmt, pInput, &option);
|
||||
} else {
|
||||
dInfo("mnode start to open");
|
||||
mmBuildOptionForOpen(pMgmt, &replica, &option);
|
||||
mmBuildOptionForOpen(pMgmt, &option);
|
||||
}
|
||||
|
||||
pMgmt->pMnode = mndOpen(pMgmt->path, &option);
|
||||
|
@ -128,9 +123,10 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
}
|
||||
tmsgReportStartup("mnode-worker", "initialized");
|
||||
|
||||
if (!deployed || replica.id > 0) {
|
||||
deployed = true;
|
||||
if (mmWriteFile(pMgmt, NULL, deployed) != 0) {
|
||||
if (option.numOfReplicas > 0) {
|
||||
option.deploy = true;
|
||||
option.numOfReplicas = 0;
|
||||
if (mmWriteFile(pMgmt->path, &option) != 0) {
|
||||
dError("failed to write mnode file since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
mndPostProcessQueryMsg(pMsg);
|
||||
}
|
||||
|
||||
dGTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
dGTrace("msg:%p is freed, code:%s", pMsg, tstrerror(code));
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
|
|
@ -51,26 +51,14 @@ static int32_t dmInitMonitor() {
|
|||
|
||||
static bool dmCheckDiskSpace() {
|
||||
osUpdate();
|
||||
if (!osDataSpaceAvailable()) {
|
||||
dError("free disk size: %f GB, too little, require %f GB at least at least , quit",
|
||||
(double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
|
||||
(double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
terrno = TSDB_CODE_NO_AVAIL_DISK;
|
||||
return false;
|
||||
if (!osDataSpaceSufficient()) {
|
||||
dWarn("free data disk size: %f GB, not sufficient, expected %f GB at least", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
if (!osLogSpaceAvailable()) {
|
||||
dError("free disk size: %f GB, too little, require %f GB at least at least, quit",
|
||||
(double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
|
||||
(double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
terrno = TSDB_CODE_NO_AVAIL_DISK;
|
||||
return false;
|
||||
if (!osLogSpaceSufficient()) {
|
||||
dWarn("free log disk size: %f GB, not sufficient, expected %f GB at least", (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
if (!osTempSpaceAvailable()) {
|
||||
dError("free disk size: %f GB, too little, require %f GB at least at least, quit",
|
||||
(double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
|
||||
(double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
terrno = TSDB_CODE_NO_AVAIL_DISK;
|
||||
return false;
|
||||
if (!osTempSpaceSufficient()) {
|
||||
dWarn("free temp disk size: %f GB, not sufficient, expected %f GB at least", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -87,12 +87,13 @@ typedef struct {
|
|||
typedef struct {
|
||||
tsem_t syncSem;
|
||||
int64_t sync;
|
||||
SReplica replica;
|
||||
int32_t errCode;
|
||||
int32_t transId;
|
||||
SRWLatch lock;
|
||||
int8_t standby;
|
||||
int8_t leaderTransferFinish;
|
||||
int8_t selfIndex;
|
||||
int8_t numOfReplicas;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
} SSyncMgmt;
|
||||
|
||||
typedef struct {
|
||||
|
@ -130,11 +131,10 @@ typedef struct SMnode {
|
|||
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
|
||||
int64_t mndGenerateUid(const char *name, int32_t len);
|
||||
|
||||
int32_t mndAcquireRpcRef(SMnode *pMnode);
|
||||
void mndReleaseRpcRef(SMnode *pMnode);
|
||||
void mndSetRestore(SMnode *pMnode, bool restored);
|
||||
void mndSetStop(SMnode *pMnode);
|
||||
bool mndGetStop(SMnode *pMnode);
|
||||
void mndSetRestored(SMnode *pMnode, bool restored);
|
||||
bool mndGetRestored(SMnode *pMnode);
|
||||
void mndSetStop(SMnode *pMnode);
|
||||
bool mndGetStop(SMnode *pMnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ extern "C" {
|
|||
|
||||
int32_t mndInitSync(SMnode *pMnode);
|
||||
void mndCleanupSync(SMnode *pMnode);
|
||||
bool mndIsMaster(SMnode *pMnode);
|
||||
bool mndIsLeader(SMnode *pMnode);
|
||||
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId);
|
||||
void mndSyncStart(SMnode *pMnode);
|
||||
void mndSyncStop(SMnode *pMnode);
|
||||
|
|
|
@ -1809,7 +1809,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
}
|
||||
|
||||
while (numOfRows < rowsCapacity) {
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_DB, pShow->pIter, (void **)&pDb, &objStatus);
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_DB, pShow->pIter, (void **)&pDb, &objStatus, true);
|
||||
if (pShow->pIter == NULL) break;
|
||||
|
||||
if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_READ_OR_WRITE_DB, pDb) == 0) {
|
||||
|
|
|
@ -423,7 +423,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
} else {
|
||||
pDnode->accessTimes++;
|
||||
mTrace("dnode:%d, status received, access times %d", pDnode->id, pDnode->accessTimes);
|
||||
mDebug("dnode:%d, status received, access times %d", pDnode->id, pDnode->accessTimes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,6 +471,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
pDnode->lastAccessTime = curMs;
|
||||
pDnode->accessTimes++;
|
||||
code = 0;
|
||||
|
||||
_OVER:
|
||||
|
|
|
@ -43,6 +43,37 @@
|
|||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
|
||||
static inline int32_t mndAcquireRpc(SMnode *pMnode) {
|
||||
int32_t code = 0;
|
||||
taosThreadRwlockRdlock(&pMnode->lock);
|
||||
if (pMnode->stopped) {
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
code = -1;
|
||||
} else if (!mndIsLeader(pMnode)) {
|
||||
code = -1;
|
||||
} else {
|
||||
#if 1
|
||||
atomic_add_fetch_32(&pMnode->rpcRef, 1);
|
||||
#else
|
||||
int32_t ref = atomic_add_fetch_32(&pMnode->rpcRef, 1);
|
||||
mTrace("mnode rpc is acquired, ref:%d", ref);
|
||||
#endif
|
||||
}
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
return code;
|
||||
}
|
||||
|
||||
static inline void mndReleaseRpc(SMnode *pMnode) {
|
||||
taosThreadRwlockRdlock(&pMnode->lock);
|
||||
#if 1
|
||||
atomic_sub_fetch_32(&pMnode->rpcRef, 1);
|
||||
#else
|
||||
int32_t ref = atomic_sub_fetch_32(&pMnode->rpcRef, 1);
|
||||
mTrace("mnode rpc is released, ref:%d", ref);
|
||||
#endif
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
}
|
||||
|
||||
static void *mndBuildTimerMsg(int32_t *pContLen) {
|
||||
SMTimerReq timerReq = {0};
|
||||
|
||||
|
@ -201,7 +232,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
|
||||
pMnode->pWal = walOpen(path, &cfg);
|
||||
if (pMnode->pWal == NULL) {
|
||||
mError("failed to open wal since %s", terrstr());
|
||||
mError("failed to open wal since %s. wal:%s", terrstr(), path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -338,8 +369,9 @@ static int32_t mndExecSteps(SMnode *pMnode) {
|
|||
static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||
pMnode->msgCb = pOption->msgCb;
|
||||
pMnode->selfDnodeId = pOption->dnodeId;
|
||||
pMnode->syncMgmt.replica = pOption->replica;
|
||||
pMnode->syncMgmt.standby = pOption->standby;
|
||||
pMnode->syncMgmt.selfIndex = pOption->selfIndex;
|
||||
pMnode->syncMgmt.numOfReplicas = pOption->numOfReplicas;
|
||||
memcpy(pMnode->syncMgmt.replicas, pOption->replicas, sizeof(pOption->replicas));
|
||||
}
|
||||
|
||||
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
||||
|
@ -430,7 +462,7 @@ int32_t mndStart(SMnode *pMnode) {
|
|||
mError("failed to deploy sdb while start mnode");
|
||||
return -1;
|
||||
}
|
||||
mndSetRestore(pMnode, true);
|
||||
mndSetRestored(pMnode, true);
|
||||
}
|
||||
|
||||
grantReset(pMnode, TSDB_GRANT_ALL, 0);
|
||||
|
@ -570,23 +602,27 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
|||
pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_SCH_MERGE_FETCH || pMsg->msgType == TDMT_SCH_DROP_TASK) {
|
||||
return 0;
|
||||
}
|
||||
if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0;
|
||||
if (mndAcquireRpc(pMsg->info.node) == 0) return 0;
|
||||
if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER ||
|
||||
pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER ||
|
||||
pMsg->msgType == TDMT_MND_UPTIME_TIMER) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SEpSet epSet = {0};
|
||||
mndGetMnodeEpSet(pMsg->info.node, &epSet);
|
||||
SEpSet epSet = {0};
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
mndGetMnodeEpSet(pMnode, &epSet);
|
||||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
mError("msg:%p, failed to check mnode state since %s, type:%s, numOfMnodes:%d inUse:%d", pMsg, terrstr(),
|
||||
TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse);
|
||||
mDebug(
|
||||
"msg:%p, failed to check mnode state since %s, mnode restored:%d stopped:%d, sync restored:%d role:%s type:%s "
|
||||
"numOfEps:%d inUse:%d",
|
||||
pMsg, terrstr(), pMnode->restored, pMnode->stopped, syncIsRestoreFinish(pMnode->syncMgmt.sync),
|
||||
syncGetMyRoleStr(pMnode->syncMgmt.sync), TMSG_INFO(pMsg->msgType), epSet.numOfEps, epSet.inUse);
|
||||
|
||||
if (epSet.numOfEps > 0) {
|
||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||
mInfo("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||
mDebug("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||
}
|
||||
|
||||
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
||||
|
@ -633,7 +669,7 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) {
|
|||
|
||||
mGTrace("msg:%p, start to process in mnode, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType));
|
||||
int32_t code = (*fp)(pMsg);
|
||||
mndReleaseRpcRef(pMnode);
|
||||
mndReleaseRpc(pMnode);
|
||||
|
||||
if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mGTrace("msg:%p, won't response immediately since in progress", pMsg);
|
||||
|
@ -669,7 +705,7 @@ int64_t mndGenerateUid(const char *name, int32_t len) {
|
|||
|
||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
||||
SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo) {
|
||||
if (mndAcquireRpcRef(pMnode) != 0) return -1;
|
||||
if (mndAcquireRpc(pMnode) != 0) return -1;
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int64_t ms = taosGetTimestampMs();
|
||||
|
@ -680,7 +716,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
pStbInfo->stbs = taosArrayInit(sdbGetSize(pSdb, SDB_STB), sizeof(SMonStbDesc));
|
||||
if (pClusterInfo->dnodes == NULL || pClusterInfo->mnodes == NULL || pVgroupInfo->vgroups == NULL ||
|
||||
pStbInfo->stbs == NULL) {
|
||||
mndReleaseRpcRef(pMnode);
|
||||
mndReleaseRpc(pMnode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -800,7 +836,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
pGrantInfo->timeseries_total = INT32_MAX;
|
||||
}
|
||||
|
||||
mndReleaseRpcRef(pMnode);
|
||||
mndReleaseRpc(pMnode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -810,32 +846,7 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndAcquireRpcRef(SMnode *pMnode) {
|
||||
int32_t code = 0;
|
||||
taosThreadRwlockRdlock(&pMnode->lock);
|
||||
if (pMnode->stopped) {
|
||||
mTrace("mnode not running");
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
code = -1;
|
||||
} else if (!mndIsMaster(pMnode)) {
|
||||
mTrace("mnode not ready, role:%s restored:%d", syncGetMyRoleStr(pMnode->syncMgmt.sync), pMnode->restored);
|
||||
code = -1;
|
||||
} else {
|
||||
int32_t ref = atomic_add_fetch_32(&pMnode->rpcRef, 1);
|
||||
// mTrace("mnode rpc is acquired, ref:%d", ref);
|
||||
}
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
return code;
|
||||
}
|
||||
|
||||
void mndReleaseRpcRef(SMnode *pMnode) {
|
||||
taosThreadRwlockRdlock(&pMnode->lock);
|
||||
int32_t ref = atomic_sub_fetch_32(&pMnode->rpcRef, 1);
|
||||
// mTrace("mnode rpc is released, ref:%d", ref);
|
||||
taosThreadRwlockUnlock(&pMnode->lock);
|
||||
}
|
||||
|
||||
void mndSetRestore(SMnode *pMnode, bool restored) {
|
||||
void mndSetRestored(SMnode *pMnode, bool restored) {
|
||||
if (restored) {
|
||||
taosThreadRwlockWrlock(&pMnode->lock);
|
||||
pMnode->restored = true;
|
||||
|
|
|
@ -36,6 +36,7 @@ static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq);
|
|||
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter);
|
||||
static void mndReloadSyncConfig(SMnode *pMnode);
|
||||
|
||||
int32_t mndInitMnode(SMnode *pMnode) {
|
||||
SSdbTable table = {
|
||||
|
@ -187,6 +188,7 @@ static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) {
|
|||
}
|
||||
|
||||
pObj->state = TAOS_SYNC_STATE_ERROR;
|
||||
mndReloadSyncConfig(pSdb->pMnode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -203,6 +205,8 @@ static int32_t mndMnodeActionDelete(SSdb *pSdb, SMnodeObj *pObj) {
|
|||
static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOld, SMnodeObj *pNew) {
|
||||
mTrace("mnode:%d, perform update action, old row:%p new row:%p", pOld->id, pOld, pNew);
|
||||
pOld->updateTime = pNew->updateTime;
|
||||
mndReloadSyncConfig(pSdb->pMnode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -233,7 +237,7 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
if (pObj->id == pMnode->selfDnodeId) {
|
||||
if (mndIsMaster(pMnode)) {
|
||||
if (mndIsLeader(pMnode)) {
|
||||
pEpSet->inUse = pEpSet->numOfEps;
|
||||
} else {
|
||||
pEpSet->inUse = (pEpSet->numOfEps + 1) % totalMnodes;
|
||||
|
@ -248,6 +252,10 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
|
|||
if (pEpSet->numOfEps == 0) {
|
||||
syncGetRetryEpSet(pMnode->syncMgmt.sync, pEpSet);
|
||||
}
|
||||
|
||||
if (pEpSet->inUse >= pEpSet->numOfEps) {
|
||||
pEpSet->inUse = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t mndSetCreateMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
||||
|
@ -274,13 +282,72 @@ static int32_t mndSetCreateMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnod
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndBuildCreateMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *pCreateReq, SEpSet *pCreateEpSet) {
|
||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pCreateReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSDCreateMnodeReq(pReq, contLen, pCreateReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = *pCreateEpSet,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_DND_CREATE_MNODE,
|
||||
.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndBuildAlterMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *pAlterReq, SEpSet *pAlterEpSet) {
|
||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSDCreateMnodeReq(pReq, contLen, pAlterReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = *pAlterEpSet,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_MND_ALTER_MNODE,
|
||||
.acceptableCode = 0,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndBuildDropMnodeRedoAction(STrans *pTrans, SDDropMnodeReq *pDropReq, SEpSet *pDroprEpSet) {
|
||||
int32_t contLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, pDropReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSCreateDropMQSBNodeReq(pReq, contLen, pDropReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = *pDroprEpSet,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_DND_DROP_MNODE,
|
||||
.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
int32_t numOfReplicas = 0;
|
||||
SDAlterMnodeReq alterReq = {0};
|
||||
SDCreateMnodeReq createReq = {0};
|
||||
SEpSet alterEpset = {0};
|
||||
SEpSet createEpset = {0};
|
||||
|
||||
while (1) {
|
||||
|
@ -288,75 +355,25 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
|
|||
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
alterReq.replicas[numOfReplicas].id = pMObj->id;
|
||||
alterReq.replicas[numOfReplicas].port = pMObj->pDnode->port;
|
||||
memcpy(alterReq.replicas[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
alterEpset.eps[numOfReplicas].port = pMObj->pDnode->port;
|
||||
memcpy(alterEpset.eps[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
if (pMObj->state == TAOS_SYNC_STATE_LEADER) {
|
||||
alterEpset.inUse = numOfReplicas;
|
||||
}
|
||||
createReq.replicas[numOfReplicas].id = pMObj->id;
|
||||
createReq.replicas[numOfReplicas].port = pMObj->pDnode->port;
|
||||
memcpy(createReq.replicas[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
numOfReplicas++;
|
||||
sdbRelease(pSdb, pMObj);
|
||||
}
|
||||
|
||||
alterReq.replica = numOfReplicas + 1;
|
||||
alterReq.replicas[numOfReplicas].id = pDnode->id;
|
||||
alterReq.replicas[numOfReplicas].port = pDnode->port;
|
||||
memcpy(alterReq.replicas[numOfReplicas].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
alterEpset.numOfEps = numOfReplicas + 1;
|
||||
alterEpset.eps[numOfReplicas].port = pDnode->port;
|
||||
memcpy(alterEpset.eps[numOfReplicas].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
createReq.replica = 1;
|
||||
createReq.replicas[0].id = pDnode->id;
|
||||
createReq.replicas[0].port = pDnode->port;
|
||||
memcpy(createReq.replicas[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
createReq.replica = numOfReplicas + 1;
|
||||
createReq.replicas[numOfReplicas].id = pDnode->id;
|
||||
createReq.replicas[numOfReplicas].port = pDnode->port;
|
||||
memcpy(createReq.replicas[numOfReplicas].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
createEpset.inUse = 0;
|
||||
createEpset.numOfEps = 1;
|
||||
createEpset.eps[0].port = pDnode->port;
|
||||
memcpy(createEpset.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
{
|
||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = createEpset,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_DND_CREATE_MNODE,
|
||||
.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = alterEpset,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_MND_ALTER_MNODE,
|
||||
.acceptableCode = 0,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (mndBuildCreateMnodeRedoAction(pTrans, &createReq, &createEpset) != 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -374,9 +391,9 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
|
||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndTransAppendNullLog(pTrans) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
|
@ -459,107 +476,28 @@ static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeO
|
|||
}
|
||||
|
||||
static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
int32_t numOfReplicas = 0;
|
||||
SDAlterMnodeReq alterReq = {0};
|
||||
SDDropMnodeReq dropReq = {0};
|
||||
SSetStandbyReq standbyReq = {0};
|
||||
SEpSet alterEpset = {0};
|
||||
SEpSet dropEpSet = {0};
|
||||
|
||||
while (1) {
|
||||
SMnodeObj *pMObj = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj);
|
||||
if (pIter == NULL) break;
|
||||
if (pMObj->id == pObj->id) {
|
||||
sdbRelease(pSdb, pMObj);
|
||||
continue;
|
||||
}
|
||||
|
||||
alterReq.replicas[numOfReplicas].id = pMObj->id;
|
||||
alterReq.replicas[numOfReplicas].port = pMObj->pDnode->port;
|
||||
memcpy(alterReq.replicas[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
alterEpset.eps[numOfReplicas].port = pMObj->pDnode->port;
|
||||
memcpy(alterEpset.eps[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
if (pMObj->state == TAOS_SYNC_STATE_LEADER) {
|
||||
alterEpset.inUse = numOfReplicas;
|
||||
}
|
||||
|
||||
numOfReplicas++;
|
||||
sdbRelease(pSdb, pMObj);
|
||||
}
|
||||
|
||||
alterReq.replica = numOfReplicas;
|
||||
alterEpset.numOfEps = numOfReplicas;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
int32_t numOfReplicas = 0;
|
||||
SDDropMnodeReq dropReq = {0};
|
||||
SEpSet dropEpSet = {0};
|
||||
|
||||
dropReq.dnodeId = pDnode->id;
|
||||
dropEpSet.numOfEps = 1;
|
||||
dropEpSet.eps[0].port = pDnode->port;
|
||||
memcpy(dropEpSet.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
standbyReq.dnodeId = pDnode->id;
|
||||
standbyReq.standby = 1;
|
||||
|
||||
{
|
||||
int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq) + sizeof(SMsgHead);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSSetStandbyReq((char *)pReq + sizeof(SMsgHead), contLen, &standbyReq);
|
||||
SMsgHead *pHead = pReq;
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(MNODE_HANDLE);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = dropEpSet,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_SYNC_SET_MNODE_STANDBY,
|
||||
.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = alterEpset,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_MND_ALTER_MNODE,
|
||||
.acceptableCode = 0,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int32_t contLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, &dropReq);
|
||||
void *pReq = taosMemoryMalloc(contLen);
|
||||
tSerializeSCreateDropMQSBNodeReq(pReq, contLen, &dropReq);
|
||||
|
||||
STransAction action = {
|
||||
.epSet = dropEpSet,
|
||||
.pCont = pReq,
|
||||
.contLen = contLen,
|
||||
.msgType = TDMT_DND_DROP_MNODE,
|
||||
.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED,
|
||||
};
|
||||
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
|
||||
if (totalMnodes == 2) {
|
||||
mInfo("vgId:1, has %d mnodes, exec redo log first", totalMnodes);
|
||||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
if (mndBuildDropMnodeRedoAction(pTrans, &dropReq, &dropEpSet) != 0) return -1;
|
||||
} else if (totalMnodes == 3) {
|
||||
mInfo("vgId:1, has %d mnodes, exec redo action first", totalMnodes);
|
||||
if (mndBuildDropMnodeRedoAction(pTrans, &dropReq, &dropEpSet) != 0) return -1;
|
||||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -567,7 +505,6 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
|||
|
||||
int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
|
||||
if (pObj == NULL) return 0;
|
||||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) return -1;
|
||||
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) return -1;
|
||||
if (mndTransAppendNullLog(pTrans) != 0) return -1;
|
||||
|
@ -657,7 +594,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
int64_t curMs = taosGetTimestampMs();
|
||||
|
||||
while (numOfRows < rows) {
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_MNODE, pShow->pIter, (void **)&pObj, &objStatus);
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_MNODE, pShow->pIter, (void **)&pObj, &objStatus, true);
|
||||
if (pShow->pIter == NULL) break;
|
||||
|
||||
cols = 0;
|
||||
|
@ -712,6 +649,9 @@ static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) {
|
|||
}
|
||||
|
||||
static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq) {
|
||||
#if 1
|
||||
return 0;
|
||||
#else
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SDAlterMnodeReq alterReq = {0};
|
||||
|
||||
|
@ -720,41 +660,107 @@ static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SMnodeOpt option = {.deploy = true, .numOfReplicas = alterReq.replica, .selfIndex = -1};
|
||||
memcpy(option.replicas, alterReq.replicas, sizeof(alterReq.replicas));
|
||||
for (int32_t i = 0; i < option.numOfReplicas; ++i) {
|
||||
if (alterReq.replicas[i].id == pMnode->selfDnodeId) {
|
||||
option.selfIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (option.selfIndex == -1) {
|
||||
mInfo("alter mnode not processed since selfIndex is -1", terrstr());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mndWriteFile(pMnode->path, &option) != 0) {
|
||||
mError("failed to write mnode file since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSyncCfg cfg = {.replicaNum = alterReq.replica, .myIndex = -1};
|
||||
for (int32_t i = 0; i < alterReq.replica; ++i) {
|
||||
SNodeInfo *pNode = &cfg.nodeInfo[i];
|
||||
tstrncpy(pNode->nodeFqdn, alterReq.replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodePort = alterReq.replicas[i].port;
|
||||
if (alterReq.replicas[i].id == pMnode->selfDnodeId) cfg.myIndex = i;
|
||||
if (alterReq.replicas[i].id == pMnode->selfDnodeId) {
|
||||
cfg.myIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg.myIndex == -1) {
|
||||
mError("failed to alter mnode since myindex is -1");
|
||||
return -1;
|
||||
} else {
|
||||
mInfo("start to alter mnode sync, replica:%d myindex:%d", cfg.replicaNum, cfg.myIndex);
|
||||
mInfo("start to alter mnode sync, replica:%d myIndex:%d", cfg.replicaNum, cfg.myIndex);
|
||||
for (int32_t i = 0; i < alterReq.replica; ++i) {
|
||||
SNodeInfo *pNode = &cfg.nodeInfo[i];
|
||||
mInfo("index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
||||
}
|
||||
}
|
||||
|
||||
mInfo("trans:-1, sync reconfig will be proposed");
|
||||
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
pMgmt->standby = 0;
|
||||
int32_t code = syncReconfig(pMgmt->sync, &cfg);
|
||||
int32_t code = syncReconfig(pMnode->syncMgmt.sync, &cfg);
|
||||
if (code != 0) {
|
||||
mError("trans:-1, failed to propose sync reconfig since %s", terrstr());
|
||||
return code;
|
||||
mError("failed to sync reconfig since %s", terrstr());
|
||||
} else {
|
||||
pMgmt->errCode = 0;
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
pMgmt->transId = -1;
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
tsem_wait(&pMgmt->syncSem);
|
||||
mInfo("alter mnode sync result:0x%x %s", pMgmt->errCode, tstrerror(pMgmt->errCode));
|
||||
terrno = pMgmt->errCode;
|
||||
return pMgmt->errCode;
|
||||
mInfo("alter mnode sync success");
|
||||
}
|
||||
|
||||
return code;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void mndReloadSyncConfig(SMnode *pMnode) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SMnodeObj *pObj = NULL;
|
||||
ESdbStatus objStatus = 0;
|
||||
void *pIter = NULL;
|
||||
bool hasUpdatingMnode = false;
|
||||
SSyncCfg cfg = {.myIndex = -1};
|
||||
|
||||
while (1) {
|
||||
pIter = sdbFetchAll(pSdb, SDB_MNODE, pIter, (void **)&pObj, &objStatus, false);
|
||||
if (pIter == NULL) break;
|
||||
if (objStatus == SDB_STATUS_CREATING || objStatus == SDB_STATUS_DROPPING) {
|
||||
mInfo("vgId:1, has updating mnode:%d, status:%s", pObj->id, sdbStatusName(objStatus));
|
||||
hasUpdatingMnode = true;
|
||||
}
|
||||
|
||||
if (objStatus == SDB_STATUS_READY || objStatus == SDB_STATUS_CREATING) {
|
||||
SNodeInfo *pNode = &cfg.nodeInfo[cfg.replicaNum];
|
||||
tstrncpy(pNode->nodeFqdn, pObj->pDnode->fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodePort = pObj->pDnode->port;
|
||||
if (pObj->pDnode->id == pMnode->selfDnodeId) {
|
||||
cfg.myIndex = cfg.replicaNum;
|
||||
}
|
||||
cfg.replicaNum++;
|
||||
}
|
||||
|
||||
sdbReleaseLock(pSdb, pObj, false);
|
||||
}
|
||||
|
||||
if (cfg.myIndex == -1) {
|
||||
mInfo("vgId:1, mnode not reload since selfIndex is -1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mndGetRestored(pMnode)) {
|
||||
mInfo("vgId:1, mnode not reload since restore not finished");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasUpdatingMnode) {
|
||||
mInfo("vgId:1, start to reload mnode sync, replica:%d myIndex:%d", cfg.replicaNum, cfg.myIndex);
|
||||
for (int32_t i = 0; i < cfg.replicaNum; ++i) {
|
||||
SNodeInfo *pNode = &cfg.nodeInfo[i];
|
||||
mInfo("vgId:1, index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
||||
}
|
||||
|
||||
int32_t code = syncReconfig(pMnode->syncMgmt.sync, &cfg);
|
||||
if (code != 0) {
|
||||
mError("vgId:1, failed to reconfig mnode sync since %s", terrstr());
|
||||
} else {
|
||||
mInfo("vgId:1, reconfig mnode sync success");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -416,7 +416,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
}
|
||||
|
||||
SStreamTask* pTask = tNewSStreamTask(pStream->uid);
|
||||
if (pInnerTask == NULL) {
|
||||
if (pTask == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
qDestroyQueryPlan(pPlan);
|
||||
|
|
|
@ -107,7 +107,7 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
|
|||
if (!pMnode->deploy) {
|
||||
mInfo("vgId:1, sync restore finished, and will handle outstanding transactions");
|
||||
mndTransPullup(pMnode);
|
||||
mndSetRestore(pMnode, true);
|
||||
mndSetRestored(pMnode, true);
|
||||
} else {
|
||||
mInfo("vgId:1, sync restore finished");
|
||||
}
|
||||
|
@ -225,18 +225,17 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s%ssync", pMnode->path, TD_DIRSEP);
|
||||
syncInfo.pWal = pMnode->pWal;
|
||||
syncInfo.pFsm = mndSyncMakeFsm(pMnode);
|
||||
syncInfo.isStandBy = pMgmt->standby;
|
||||
syncInfo.snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT;
|
||||
|
||||
mInfo("vgId:1, start to open sync, standby:%d", pMgmt->standby);
|
||||
if (pMgmt->standby || pMgmt->replica.id > 0) {
|
||||
SSyncCfg *pCfg = &syncInfo.syncCfg;
|
||||
pCfg->replicaNum = 1;
|
||||
pCfg->myIndex = 0;
|
||||
SNodeInfo *pNode = &pCfg->nodeInfo[0];
|
||||
tstrncpy(pNode->nodeFqdn, pMgmt->replica.fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodePort = pMgmt->replica.port;
|
||||
mInfo("vgId:1, ep:%s:%u", pNode->nodeFqdn, pNode->nodePort);
|
||||
mInfo("vgId:1, start to open sync, selfIndex:%d replica:%d", pMgmt->selfIndex, pMgmt->numOfReplicas);
|
||||
SSyncCfg *pCfg = &syncInfo.syncCfg;
|
||||
pCfg->replicaNum = pMgmt->numOfReplicas;
|
||||
pCfg->myIndex = pMgmt->selfIndex;
|
||||
for (int32_t i = 0; i < pMgmt->numOfReplicas; ++i) {
|
||||
SNodeInfo *pNode = &pCfg->nodeInfo[i];
|
||||
tstrncpy(pNode->nodeFqdn, pMgmt->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
||||
pNode->nodePort = pMgmt->replicas[i].port;
|
||||
mInfo("vgId:1, index:%d ep:%s:%u", i, pNode->nodeFqdn, pNode->nodePort);
|
||||
}
|
||||
|
||||
tsem_init(&pMgmt->syncSem, 0, 0);
|
||||
|
@ -250,10 +249,6 @@ int32_t mndInitSync(SMnode *pMnode) {
|
|||
setPingTimerMS(pMgmt->sync, 5000);
|
||||
setElectTimerMS(pMgmt->sync, 3000);
|
||||
setHeartbeatTimerMS(pMgmt->sync, 500);
|
||||
/*
|
||||
setElectTimerMS(pMgmt->sync, 600);
|
||||
setHeartbeatTimerMS(pMgmt->sync, 300);
|
||||
*/
|
||||
|
||||
mInfo("mnode-sync is opened, id:%" PRId64, pMgmt->sync);
|
||||
return 0;
|
||||
|
@ -319,7 +314,7 @@ void mndSyncStart(SMnode *pMnode) {
|
|||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
|
||||
syncStart(pMgmt->sync);
|
||||
mInfo("vgId:1, sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
||||
mInfo("vgId:1, sync started, id:%" PRId64, pMgmt->sync);
|
||||
}
|
||||
|
||||
void mndSyncStop(SMnode *pMnode) {
|
||||
|
@ -331,7 +326,7 @@ void mndSyncStop(SMnode *pMnode) {
|
|||
taosWUnLockLatch(&pMnode->syncMgmt.lock);
|
||||
}
|
||||
|
||||
bool mndIsMaster(SMnode *pMnode) {
|
||||
bool mndIsLeader(SMnode *pMnode) {
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
|
||||
if (!syncIsReady(pMgmt->sync)) {
|
||||
|
@ -340,7 +335,7 @@ bool mndIsMaster(SMnode *pMnode) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!pMnode->restored) {
|
||||
if (!mndGetRestored(pMnode)) {
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ static bool mndTransPerformCommitActionStage(SMnode *pMnode, STrans *pTrans);
|
|||
static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans);
|
||||
static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans);
|
||||
static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans);
|
||||
static bool mndCannotExecuteTransAction(SMnode *pMnode) { return !pMnode->deploy && !mndIsMaster(pMnode); }
|
||||
static bool mndCannotExecuteTransAction(SMnode *pMnode) { return !pMnode->deploy && !mndIsLeader(pMnode); }
|
||||
|
||||
static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
|
||||
static int32_t mndProcessTransTimer(SRpcMsg *pReq);
|
||||
|
|
|
@ -298,6 +298,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey);
|
|||
* @param pObj The object of the row.
|
||||
*/
|
||||
void sdbRelease(SSdb *pSdb, void *pObj);
|
||||
void sdbReleaseLock(SSdb *pSdb, void *pObj, bool lock);
|
||||
|
||||
/**
|
||||
* @brief Traverse a sdb table
|
||||
|
@ -309,7 +310,7 @@ void sdbRelease(SSdb *pSdb, void *pObj);
|
|||
* @return void* The next iterator of the table.
|
||||
*/
|
||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj);
|
||||
void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStatus *status);
|
||||
void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStatus *status, bool lock);
|
||||
|
||||
/**
|
||||
* @brief Cancel a traversal
|
||||
|
|
|
@ -327,14 +327,16 @@ static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
|||
taosThreadRwlockUnlock(pLock);
|
||||
}
|
||||
|
||||
void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||
void sdbReleaseLock(SSdb *pSdb, void *pObj, bool lock) {
|
||||
if (pObj == NULL) return;
|
||||
|
||||
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
||||
if (pRow->type >= SDB_MAX) return;
|
||||
|
||||
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||
taosThreadRwlockWrlock(pLock);
|
||||
if (lock) {
|
||||
taosThreadRwlockWrlock(pLock);
|
||||
}
|
||||
|
||||
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
||||
sdbPrintOper(pSdb, pRow, "release");
|
||||
|
@ -342,9 +344,13 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
|||
sdbFreeRow(pSdb, pRow, true);
|
||||
}
|
||||
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
if (lock) {
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
}
|
||||
}
|
||||
|
||||
void sdbRelease(SSdb *pSdb, void *pObj) { sdbReleaseLock(pSdb, pObj, true); }
|
||||
|
||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||
*ppObj = NULL;
|
||||
|
||||
|
@ -372,14 +378,16 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
|||
return ppRow;
|
||||
}
|
||||
|
||||
void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStatus *status) {
|
||||
void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStatus *status, bool lock) {
|
||||
*ppObj = NULL;
|
||||
|
||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||
if (hash == NULL) return NULL;
|
||||
|
||||
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||
taosThreadRwlockRdlock(pLock);
|
||||
if (lock) {
|
||||
taosThreadRwlockRdlock(pLock);
|
||||
}
|
||||
|
||||
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
||||
while (ppRow != NULL) {
|
||||
|
@ -395,7 +403,9 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat
|
|||
*status = pRow->status;
|
||||
break;
|
||||
}
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
if (lock) {
|
||||
taosThreadRwlockUnlock(pLock);
|
||||
}
|
||||
|
||||
return ppRow;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,6 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
SMqDataRsp dataRsp;
|
||||
SMqRspHead rspHead;
|
||||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
SRpcHandleInfo pInfo;
|
||||
} STqPushEntry;
|
||||
|
@ -183,6 +182,7 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore);
|
|||
|
||||
// tqSink
|
||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||
void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||
|
||||
// tqOffset
|
||||
char* tqOffsetBuildFName(const char* path, int32_t ver);
|
||||
|
|
|
@ -51,7 +51,7 @@ static int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema
|
|||
return -1;
|
||||
}
|
||||
|
||||
strcpy(pMetaRsp->tbName, tbName);
|
||||
strncpy(pMetaRsp->tbName, tbName, TSDB_TABLE_NAME_LEN);
|
||||
pMetaRsp->numOfColumns = pSchema->nCols;
|
||||
pMetaRsp->tableType = TSDB_NORMAL_TABLE;
|
||||
pMetaRsp->sversion = pSchema->version;
|
||||
|
@ -693,6 +693,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
if (iCol >= pSchema->nCols) break;
|
||||
pColumn = &pSchema->pSchema[iCol];
|
||||
|
||||
ASSERT(pAlterTbReq->colName);
|
||||
if (strcmp(pColumn->name, pAlterTbReq->colName) == 0) break;
|
||||
iCol++;
|
||||
}
|
||||
|
@ -816,6 +817,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
const void *pData = NULL;
|
||||
int nData = 0;
|
||||
|
||||
if (pAlterTbReq->tagName == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// search name index
|
||||
ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal);
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -171,11 +171,11 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) {
|
|||
ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0);
|
||||
|
||||
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
if (pRsp->blockNum > 0) {
|
||||
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
|
||||
} else {
|
||||
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
|
||||
}
|
||||
/*if (pRsp->blockNum > 0) {*/
|
||||
/*ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);*/
|
||||
/*} else {*/
|
||||
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
|
||||
/*}*/
|
||||
}
|
||||
|
||||
int32_t len = 0;
|
||||
|
@ -192,7 +192,7 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
memcpy(buf, &pPushEntry->rspHead, sizeof(SMqRspHead));
|
||||
memcpy(buf, &pPushEntry->dataRsp.head, sizeof(SMqRspHead));
|
||||
|
||||
void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
|
||||
|
||||
|
@ -215,7 +215,7 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) {
|
|||
tFormatOffset(buf1, 80, &pRsp->reqOffset);
|
||||
tFormatOffset(buf2, 80, &pRsp->rspOffset);
|
||||
tqDebug("vgId:%d, from consumer:%" PRId64 ", (epoch %d) push rsp, block num: %d, reqOffset:%s, rspOffset:%s",
|
||||
TD_VID(pTq->pVnode), pPushEntry->rspHead.consumerId, pRsp->head.epoch, pRsp->blockNum, buf1, buf2);
|
||||
TD_VID(pTq->pVnode), pRsp->head.consumerId, pRsp->head.epoch, pRsp->blockNum, buf1, buf2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -560,9 +560,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
memcpy(pPushEntry->subKey, pHandle->subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
dataRsp.withTbName = 0;
|
||||
memcpy(&pPushEntry->dataRsp, &dataRsp, sizeof(SMqDataRsp));
|
||||
pPushEntry->rspHead.consumerId = consumerId;
|
||||
pPushEntry->rspHead.epoch = reqEpoch;
|
||||
pPushEntry->rspHead.mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
|
||||
pPushEntry->dataRsp.head.consumerId = consumerId;
|
||||
pPushEntry->dataRsp.head.epoch = reqEpoch;
|
||||
pPushEntry->dataRsp.head.mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
|
||||
taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey) + 1, &pPushEntry, sizeof(void*));
|
||||
tqDebug("tmq poll: consumer %ld, subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey,
|
||||
TD_VID(pTq->pVnode));
|
||||
|
@ -924,7 +924,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
|
|||
pTask->smaSink.smaSink = smaHandleRes;
|
||||
} else if (pTask->outputType == TASK_OUTPUT__TABLE) {
|
||||
pTask->tbSink.vnode = pTq->pVnode;
|
||||
pTask->tbSink.tbSinkFunc = tqTableSink;
|
||||
pTask->tbSink.tbSinkFunc = tqTableSink1;
|
||||
|
||||
ASSERT(pTask->tbSink.pSchemaWrapper);
|
||||
ASSERT(pTask->tbSink.pSchemaWrapper->pSchema);
|
||||
|
@ -1010,16 +1010,21 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
|||
|
||||
if (streamTaskInput(pTask, (SStreamQueueItem*)pRefBlock) < 0) {
|
||||
qError("stream task input del failed, task id %d", pTask->taskId);
|
||||
|
||||
taosFreeQitem(pRefBlock);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (streamSchedExec(pTask) < 0) {
|
||||
qError("stream task launch failed, task id %d", pTask->taskId);
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
streamTaskInputFail(pTask);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ref = atomic_sub_fetch_32(pRef, 1);
|
||||
ASSERT(ref >= 0);
|
||||
if (ref == 0) {
|
||||
|
|
|
@ -245,7 +245,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
|||
tqDebug("vgId:%d cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey);
|
||||
continue;
|
||||
}
|
||||
if (pPushEntry->dataRsp.reqOffset.version > ver) {
|
||||
if (pPushEntry->dataRsp.reqOffset.version >= ver) {
|
||||
tqDebug("vgId:%d push entry req version %ld, while push version %ld, skip", pTq->pVnode->config.vgId,
|
||||
pPushEntry->dataRsp.reqOffset.version, ver);
|
||||
continue;
|
||||
|
|
|
@ -284,6 +284,212 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem
|
|||
return ret;
|
||||
}
|
||||
|
||||
void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||
const SArray* pBlocks = (const SArray*)data;
|
||||
SVnode* pVnode = (SVnode*)vnode;
|
||||
int64_t suid = pTask->tbSink.stbUid;
|
||||
char* stbFullName = pTask->tbSink.stbFullName;
|
||||
STSchema* pTSchema = pTask->tbSink.pTSchema;
|
||||
SSchemaWrapper* pSchemaWrapper = pTask->tbSink.pSchemaWrapper;
|
||||
|
||||
int32_t blockSz = taosArrayGetSize(pBlocks);
|
||||
bool createTb = true;
|
||||
|
||||
SArray* tagArray = taosArrayInit(1, sizeof(STagVal));
|
||||
if (!tagArray) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
tqDebug("vgId:%d, task %d write into table, block num: %d", TD_VID(pVnode), pTask->taskId, blockSz);
|
||||
for (int32_t i = 0; i < blockSz; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||
if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
|
||||
SBatchDeleteReq deleteReq = {0};
|
||||
deleteReq.deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq));
|
||||
deleteReq.suid = suid;
|
||||
tqBuildDeleteReq(pVnode, stbFullName, pDataBlock, &deleteReq);
|
||||
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSBatchDeleteReq, &deleteReq, len, code);
|
||||
if (code < 0) {
|
||||
//
|
||||
ASSERT(0);
|
||||
}
|
||||
SEncoder encoder;
|
||||
void* serializedDeleteReq = rpcMallocCont(len + sizeof(SMsgHead));
|
||||
void* abuf = POINTER_SHIFT(serializedDeleteReq, sizeof(SMsgHead));
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
tEncodeSBatchDeleteReq(&encoder, &deleteReq);
|
||||
tEncoderClear(&encoder);
|
||||
taosArrayDestroy(deleteReq.deleteReqs);
|
||||
|
||||
((SMsgHead*)serializedDeleteReq)->vgId = pVnode->config.vgId;
|
||||
|
||||
SRpcMsg msg = {
|
||||
.msgType = TDMT_VND_BATCH_DEL,
|
||||
.pCont = serializedDeleteReq,
|
||||
.contLen = len + sizeof(SMsgHead),
|
||||
};
|
||||
if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) {
|
||||
rpcFreeCont(serializedDeleteReq);
|
||||
tqDebug("failed to put delete req into write-queue since %s", terrstr());
|
||||
}
|
||||
} else {
|
||||
SVCreateTbReq createTbReq = {0};
|
||||
|
||||
// set const
|
||||
createTbReq.flags = 0;
|
||||
createTbReq.type = TSDB_CHILD_TABLE;
|
||||
createTbReq.ctb.suid = suid;
|
||||
|
||||
// set super table name
|
||||
SName name = {0};
|
||||
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
createTbReq.ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
|
||||
|
||||
// set tag content
|
||||
taosArrayClear(tagArray);
|
||||
STagVal tagVal = {
|
||||
.cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1,
|
||||
.type = TSDB_DATA_TYPE_UBIGINT,
|
||||
.i64 = (int64_t)pDataBlock->info.groupId,
|
||||
};
|
||||
taosArrayPush(tagArray, &tagVal);
|
||||
createTbReq.ctb.tagNum = taosArrayGetSize(tagArray);
|
||||
|
||||
STag* pTag = NULL;
|
||||
tTagNew(tagArray, 1, false, &pTag);
|
||||
if (pTag == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosArrayDestroy(tagArray);
|
||||
tdDestroySVCreateTbReq(&createTbReq);
|
||||
return;
|
||||
}
|
||||
createTbReq.ctb.pTag = (uint8_t*)pTag;
|
||||
|
||||
// set tag name
|
||||
SArray* tagName = taosArrayInit(1, TSDB_COL_NAME_LEN);
|
||||
char tagNameStr[TSDB_COL_NAME_LEN] = {0};
|
||||
strcpy(tagNameStr, "group_id");
|
||||
taosArrayPush(tagName, tagNameStr);
|
||||
createTbReq.ctb.tagName = tagName;
|
||||
|
||||
// set table name
|
||||
if (pDataBlock->info.parTbName[0]) {
|
||||
createTbReq.name = strdup(pDataBlock->info.parTbName);
|
||||
} else {
|
||||
createTbReq.name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||
}
|
||||
|
||||
int32_t schemaLen;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code);
|
||||
if (code < 0) {
|
||||
tdDestroySVCreateTbReq(&createTbReq);
|
||||
taosArrayDestroy(tagArray);
|
||||
return;
|
||||
}
|
||||
|
||||
// save schema str
|
||||
void* schemaStr = taosMemoryMalloc(schemaLen);
|
||||
if (schemaStr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tdDestroySVCreateTbReq(&createTbReq);
|
||||
taosArrayDestroy(tagArray);
|
||||
return;
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, schemaStr, schemaLen);
|
||||
code = tEncodeSVCreateTbReq(&encoder, &createTbReq);
|
||||
if (code < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tdDestroySVCreateTbReq(&createTbReq);
|
||||
taosArrayDestroy(tagArray);
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(schemaStr);
|
||||
return;
|
||||
}
|
||||
tEncoderClear(&encoder);
|
||||
tdDestroySVCreateTbReq(&createTbReq);
|
||||
|
||||
int32_t cap = sizeof(SSubmitReq);
|
||||
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);
|
||||
|
||||
cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen;
|
||||
|
||||
SSubmitReq* ret = rpcMallocCont(cap);
|
||||
ret->header.vgId = pVnode->config.vgId;
|
||||
ret->length = sizeof(SSubmitReq);
|
||||
ret->numOfBlocks = htonl(1);
|
||||
|
||||
SSubmitBlk* blkHead = POINTER_SHIFT(ret, sizeof(SSubmitReq));
|
||||
|
||||
blkHead->numOfRows = htonl(pDataBlock->info.rows);
|
||||
blkHead->sversion = htonl(pTSchema->version);
|
||||
blkHead->suid = htobe64(suid);
|
||||
// uid is assigned by vnode
|
||||
blkHead->uid = 0;
|
||||
blkHead->schemaLen = 0;
|
||||
|
||||
tqDebug("tq sink, convert block %d, rows: %d", i, rows);
|
||||
|
||||
int32_t dataLen = 0;
|
||||
void* blkSchema = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk));
|
||||
STSRow* rowData = blkSchema;
|
||||
if (createTb) {
|
||||
memcpy(blkSchema, schemaStr, schemaLen);
|
||||
blkHead->schemaLen = htonl(schemaLen);
|
||||
rowData = POINTER_SHIFT(blkSchema, schemaLen);
|
||||
}
|
||||
|
||||
taosMemoryFree(schemaStr);
|
||||
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
SRowBuilder rb = {0};
|
||||
tdSRowInit(&rb, pTSchema->version);
|
||||
tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen);
|
||||
tdSRowResetBuf(&rb, rowData);
|
||||
|
||||
for (int32_t k = 0; k < pTSchema->numOfCols; k++) {
|
||||
const STColumn* pColumn = &pTSchema->columns[k];
|
||||
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
if (colDataIsNull_s(pColData, j)) {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k);
|
||||
} else {
|
||||
void* colData = colDataGetData(pColData, j);
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, colData, true, pColumn->offset, k);
|
||||
}
|
||||
}
|
||||
tdSRowEnd(&rb);
|
||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||
rowData = POINTER_SHIFT(rowData, rowLen);
|
||||
dataLen += rowLen;
|
||||
}
|
||||
blkHead->dataLen = htonl(dataLen);
|
||||
|
||||
ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
ret->length = htonl(ret->length);
|
||||
|
||||
SRpcMsg msg = {
|
||||
.msgType = TDMT_VND_SUBMIT,
|
||||
.pCont = ret,
|
||||
.contLen = ntohl(ret->length),
|
||||
};
|
||||
|
||||
if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) {
|
||||
rpcFreeCont(ret);
|
||||
tqDebug("failed to put into write-queue since %s", terrstr());
|
||||
}
|
||||
}
|
||||
}
|
||||
taosArrayDestroy(tagArray);
|
||||
}
|
||||
|
||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||
const SArray* pRes = (const SArray*)data;
|
||||
SVnode* pVnode = (SVnode*)vnode;
|
||||
|
|
|
@ -378,10 +378,10 @@ static int32_t getTableDelSkyline(STbData *pMem, STbData *pIMem, SDelFReader *pD
|
|||
if (code) goto _err;
|
||||
}
|
||||
|
||||
_err:
|
||||
if (aDelData) {
|
||||
taosArrayDestroy(aDelData);
|
||||
}
|
||||
_err:
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -399,14 +399,13 @@ static int32_t getTableDelIdx(SDelFReader *pDelFReader, tb_uid_t suid, tb_uid_t
|
|||
|
||||
// code = tMapDataSearch(&delIdxMap, &idx, tGetDelIdx, tCmprDelIdx, pDelIdx);
|
||||
SDelIdx *pIdx = taosArraySearch(pDelIdxArray, &idx, tCmprDelIdx, TD_EQ);
|
||||
if (code) goto _err;
|
||||
|
||||
*pDelIdx = *pIdx;
|
||||
|
||||
_err:
|
||||
if (pDelIdxArray) {
|
||||
taosArrayDestroy(pDelIdxArray);
|
||||
}
|
||||
_err:
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -429,7 +428,8 @@ typedef struct {
|
|||
SDataFReader *pDataFReader;
|
||||
TSDBROW row;
|
||||
|
||||
SMergeTree mergeTree;
|
||||
SMergeTree mergeTree;
|
||||
SMergeTree *pMergeTree;
|
||||
} SFSLastNextRowIter;
|
||||
|
||||
static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
|
||||
|
@ -444,11 +444,14 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
|
|||
case SFSLASTNEXTROW_FILESET: {
|
||||
SDFileSet *pFileSet = NULL;
|
||||
_next_fileset:
|
||||
if (state->pMergeTree != NULL) {
|
||||
tMergeTreeClose(state->pMergeTree);
|
||||
state->pMergeTree = NULL;
|
||||
}
|
||||
|
||||
if (--state->iFileSet >= 0) {
|
||||
pFileSet = (SDFileSet *)taosArrayGet(state->aDFileSet, state->iFileSet);
|
||||
} else {
|
||||
tMergeTreeClose(&state->mergeTree);
|
||||
|
||||
*ppRow = NULL;
|
||||
return code;
|
||||
}
|
||||
|
@ -460,10 +463,10 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
|
|||
tMergeTreeOpen(&state->mergeTree, 1, state->pDataFReader, state->suid, state->uid,
|
||||
&(STimeWindow){.skey = TSKEY_MIN, .ekey = TSKEY_MAX},
|
||||
&(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, pLoadInfo, true, NULL);
|
||||
state->pMergeTree = &state->mergeTree;
|
||||
bool hasVal = tMergeTreeNext(&state->mergeTree);
|
||||
if (!hasVal) {
|
||||
state->state = SFSLASTNEXTROW_FILESET;
|
||||
tMergeTreeClose(&state->mergeTree);
|
||||
goto _next_fileset;
|
||||
}
|
||||
state->state = SFSLASTNEXTROW_BLOCKROW;
|
||||
|
@ -475,6 +478,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
|
|||
if (!hasVal) {
|
||||
state->state = SFSLASTNEXTROW_FILESET;
|
||||
}
|
||||
|
||||
return code;
|
||||
default:
|
||||
ASSERT(0);
|
||||
|
@ -486,6 +490,11 @@ _err:
|
|||
tsdbDataFReaderClose(&state->pDataFReader);
|
||||
state->pDataFReader = NULL;
|
||||
}
|
||||
if (state->pMergeTree != NULL) {
|
||||
tMergeTreeClose(state->pMergeTree);
|
||||
state->pMergeTree = NULL;
|
||||
}
|
||||
|
||||
*ppRow = NULL;
|
||||
|
||||
return code;
|
||||
|
@ -504,6 +513,11 @@ int32_t clearNextRowFromFSLast(void *iter) {
|
|||
state->pDataFReader = NULL;
|
||||
}
|
||||
|
||||
if (state->pMergeTree != NULL) {
|
||||
tMergeTreeClose(state->pMergeTree);
|
||||
state->pMergeTree = NULL;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -584,8 +598,6 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
|||
* &state->blockIdx);
|
||||
*/
|
||||
state->pBlockIdx = taosArraySearch(state->aBlockIdx, state->pBlockIdxExp, tCmprBlockIdx, TD_EQ);
|
||||
if (code) goto _err;
|
||||
|
||||
if (!state->pBlockIdx) {
|
||||
goto _next_fileset;
|
||||
}
|
||||
|
@ -883,10 +895,16 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
|||
if (code) goto _err;
|
||||
|
||||
code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
|
||||
if (code) goto _err;
|
||||
if (code) {
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pIter->pSkyline);
|
||||
if (code) goto _err;
|
||||
if (code) {
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
} else {
|
||||
|
@ -1216,6 +1234,8 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
|||
_err:
|
||||
nextRowIterClose(&iter);
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
*ppLastArray = NULL;
|
||||
taosArrayDestroy(pColArray);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,12 +396,19 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t tDataIterCmprFn(const SRBTreeNode *n1, const SRBTreeNode *n2) {
|
||||
SDataIter *pIter1 = (SDataIter *)((uint8_t *)n1 - offsetof(SDataIter, n));
|
||||
SDataIter *pIter2 = (SDataIter *)((uint8_t *)n2 - offsetof(SDataIter, n));
|
||||
|
||||
return tRowInfoCmprFn(&pIter1->r, &pIter2->r);
|
||||
}
|
||||
|
||||
static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
pCommitter->pIter = NULL;
|
||||
tRBTreeCreate(&pCommitter->rbt, tRowInfoCmprFn);
|
||||
tRBTreeCreate(&pCommitter->rbt, tDataIterCmprFn);
|
||||
|
||||
// memory
|
||||
TSDBKEY tKey = {.ts = pCommitter->minKey, .version = VERSION_MIN};
|
||||
|
@ -1038,7 +1045,9 @@ static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) {
|
|||
STsdb *pTsdb = pCommitter->pTsdb;
|
||||
SMemTable *pMemTable = pTsdb->imem;
|
||||
|
||||
ASSERT(eno == 0);
|
||||
ASSERT(eno == 0 &&
|
||||
"tsdbCommit failure"
|
||||
"Restart taosd");
|
||||
|
||||
code = tsdbFSCommit1(pTsdb, &pCommitter->fs);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
|
|
@ -610,9 +610,6 @@ int32_t tsdbFSRollback(STsdbFS *pFS) {
|
|||
ASSERT(0);
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFSUpsertDelFile(STsdbFS *pFS, SDelFile *pDelFile) {
|
||||
|
@ -822,7 +819,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
|
|||
nRef = atomic_sub_fetch_32(&fSet.pHeadF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbHeadFileName(pTsdb, pSetOld->diskId, pSetOld->fid, fSet.pHeadF, fname);
|
||||
taosRemoveFile(fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
taosMemoryFree(fSet.pHeadF);
|
||||
}
|
||||
} else {
|
||||
|
@ -866,7 +863,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
|
|||
nRef = atomic_sub_fetch_32(&fSet.pSmaF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSmaFileName(pTsdb, pSetOld->diskId, pSetOld->fid, fSet.pSmaF, fname);
|
||||
taosRemoveFile(fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
taosMemoryFree(fSet.pSmaF);
|
||||
}
|
||||
} else {
|
||||
|
@ -877,7 +874,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
|
|||
// stt
|
||||
if (sameDisk) {
|
||||
if (pSetNew->nSttF > pSetOld->nSttF) {
|
||||
ASSERT(pSetNew->nSttF = pSetOld->nSttF + 1);
|
||||
ASSERT(pSetNew->nSttF == pSetOld->nSttF + 1);
|
||||
pSetOld->aSttF[pSetOld->nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
|
||||
if (pSetOld->aSttF[pSetOld->nSttF] == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -964,7 +961,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
|
|||
nRef = atomic_sub_fetch_32(&pSetOld->pHeadF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbHeadFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->pHeadF, fname);
|
||||
taosRemoveFile(fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
taosMemoryFree(pSetOld->pHeadF);
|
||||
}
|
||||
|
||||
|
@ -1104,7 +1101,7 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
|
|||
ASSERT(nRef >= 0);
|
||||
if (nRef == 0) {
|
||||
tsdbDelFileName(pTsdb, pFS->pDelFile, fname);
|
||||
taosRemoveFile(fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
taosMemoryFree(pFS->pDelFile);
|
||||
}
|
||||
}
|
||||
|
@ -1117,7 +1114,7 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
|
|||
ASSERT(nRef >= 0);
|
||||
if (nRef == 0) {
|
||||
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
|
||||
taosRemoveFile(fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
taosMemoryFree(pSet->pHeadF);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ int32_t tsdbDeleteTableData(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid
|
|||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(pPool != NULL);
|
||||
// do delete
|
||||
SDelData *pDelData = (SDelData *)vnodeBufPoolMalloc(pPool, sizeof(*pDelData));
|
||||
if (pDelData == NULL) {
|
||||
|
@ -353,6 +354,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid
|
|||
SVBufPool *pPool = pMemTable->pTsdb->pVnode->inUse;
|
||||
int8_t maxLevel = pMemTable->pTsdb->pVnode->config.tsdbCfg.slLevel;
|
||||
|
||||
ASSERT(pPool != NULL);
|
||||
pTbData = vnodeBufPoolMalloc(pPool, sizeof(*pTbData) + SL_NODE_SIZE(maxLevel) * 2);
|
||||
if (pTbData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -492,6 +494,7 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN
|
|||
|
||||
// node
|
||||
level = tsdbMemSkipListRandLevel(&pTbData->sl);
|
||||
ASSERT(pPool != NULL);
|
||||
pNode = (SMemSkipListNode *)vnodeBufPoolMalloc(pPool, SL_NODE_SIZE(level) + tPutTSDBRow(NULL, pRow));
|
||||
if (pNode == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -559,6 +562,8 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
|
|||
|
||||
// backward put first data
|
||||
row.pTSRow = tGetSubmitBlkNext(&blkIter);
|
||||
if (row.pTSRow == NULL) return code;
|
||||
|
||||
key.ts = row.pTSRow->ts;
|
||||
nRow++;
|
||||
tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_BACKWARD);
|
||||
|
|
|
@ -101,8 +101,8 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
|||
static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
||||
int32_t code = 0;
|
||||
|
||||
SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo;
|
||||
if (pInfo->blockIndex[0] == pIter->iSttBlk) {
|
||||
SSttBlockLoadInfo *pInfo = pIter->pBlockLoadInfo;
|
||||
if (pInfo->blockIndex[0] == pIter->iSttBlk) {
|
||||
if (pInfo->currentLoadBlockIndex != 0) {
|
||||
tsdbDebug("current load index is set to 0, block index:%d, file index:%d, due to uid:%" PRIu64 ", load data, %s",
|
||||
pIter->iSttBlk, pIter->iStt, pIter->uid, idStr);
|
||||
|
@ -113,7 +113,7 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
|
||||
if (pInfo->blockIndex[1] == pIter->iSttBlk) {
|
||||
if (pInfo->currentLoadBlockIndex != 1) {
|
||||
tsdbDebug("current load index is set to 1, block index:%d, file index:%d, due to uid:%"PRIu64", load data, %s",
|
||||
tsdbDebug("current load index is set to 1, block index:%d, file index:%d, due to uid:%" PRIu64 ", load data, %s",
|
||||
pIter->iSttBlk, pIter->iStt, pIter->uid, idStr);
|
||||
pInfo->currentLoadBlockIndex = 1;
|
||||
}
|
||||
|
@ -133,18 +133,24 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
id.uid = pIter->uid;
|
||||
}
|
||||
|
||||
tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols);
|
||||
code = tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
pInfo->elapsedTime += el;
|
||||
pInfo->loadBlocks += 1;
|
||||
|
||||
tsdbDebug("read last block, total load:%d, trigger by uid:%"PRIu64", last file index:%d, last block index:%d, entry:%d, %p, elapsed time:%.2f ms, %s",
|
||||
pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock, el, idStr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
tsdbDebug("read last block, total load:%d, trigger by uid:%" PRIu64
|
||||
", last file index:%d, last block index:%d, entry:%d, %p, elapsed time:%.2f ms, %s",
|
||||
pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock, el,
|
||||
idStr);
|
||||
|
||||
pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
|
||||
tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr);
|
||||
|
@ -336,7 +342,7 @@ _exit:
|
|||
|
||||
void tLDataIterClose(SLDataIter *pIter) { taosMemoryFree(pIter); }
|
||||
|
||||
void tLDataIterNextBlock(SLDataIter *pIter, const char* idStr) {
|
||||
void tLDataIterNextBlock(SLDataIter *pIter, const char *idStr) {
|
||||
int32_t step = pIter->backward ? -1 : 1;
|
||||
int32_t oldIndex = pIter->iSttBlk;
|
||||
|
||||
|
@ -386,10 +392,10 @@ void tLDataIterNextBlock(SLDataIter *pIter, const char* idStr) {
|
|||
if (index != -1) {
|
||||
pIter->iSttBlk = index;
|
||||
pIter->pSttBlk = (SSttBlk *)taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, pIter->iSttBlk);
|
||||
tsdbDebug("try next last file block:%d from %d, trigger by uid:%"PRIu64", file index:%d, %s", pIter->iSttBlk, oldIndex, pIter->uid, pIter->iStt,
|
||||
idStr);
|
||||
tsdbDebug("try next last file block:%d from %d, trigger by uid:%" PRIu64 ", file index:%d, %s", pIter->iSttBlk,
|
||||
oldIndex, pIter->uid, pIter->iStt, idStr);
|
||||
} else {
|
||||
tsdbDebug("no more last block qualified, uid:%"PRIu64", file index::%d, %s", pIter->uid, oldIndex, idStr);
|
||||
tsdbDebug("no more last block qualified, uid:%" PRIu64 ", file index::%d, %s", pIter->uid, oldIndex, idStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,8 +463,8 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
|
|||
}
|
||||
|
||||
bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
||||
int32_t code = 0;
|
||||
int32_t step = pIter->backward ? -1 : 1;
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
// no qualified last file block in current file, no need to fetch row
|
||||
if (pIter->pSttBlk == NULL) {
|
||||
|
@ -467,6 +473,10 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
|||
|
||||
int32_t iBlockL = pIter->iSttBlk;
|
||||
SBlockData *pBlockData = loadLastBlock(pIter, idStr);
|
||||
if (pBlockData == NULL && terrno != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
pIter->iRow += step;
|
||||
|
||||
while (1) {
|
||||
|
@ -492,19 +502,15 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
|||
pIter->rInfo.row = tsdbRowFromBlockData(pBlockData, pIter->iRow);
|
||||
|
||||
_exit:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
}
|
||||
|
||||
return (code == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL);
|
||||
return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL);
|
||||
}
|
||||
|
||||
SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; }
|
||||
|
||||
// SMergeTree =================================================
|
||||
static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) {
|
||||
SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - sizeof(SRBTreeNode));
|
||||
SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - sizeof(SRBTreeNode));
|
||||
static FORCE_INLINE int32_t tLDataIterCmprFn(const SRBTreeNode *p1, const SRBTreeNode *p2) {
|
||||
SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - offsetof(SLDataIter, node));
|
||||
SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - offsetof(SLDataIter, node));
|
||||
|
||||
TSDBKEY key1 = TSDBROW_KEY(&pIter1->rInfo.row);
|
||||
TSDBKEY key2 = TSDBROW_KEY(&pIter2->rInfo.row);
|
||||
|
@ -541,6 +547,7 @@ 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;
|
||||
|
@ -581,7 +588,7 @@ bool tMergeTreeNext(SMergeTree *pMTree) {
|
|||
// compare with min in RB Tree
|
||||
pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt);
|
||||
if (pMTree->pIter && pIter) {
|
||||
int32_t c = pMTree->rbt.cmprFn(RBTREE_NODE_PAYLOAD(&pMTree->pIter->node), RBTREE_NODE_PAYLOAD(&pIter->node));
|
||||
int32_t c = pMTree->rbt.cmprFn(&pMTree->pIter->node, &pIter->node);
|
||||
if (c > 0) {
|
||||
tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
|
||||
pMTree->pIter = NULL;
|
||||
|
|
|
@ -87,9 +87,13 @@ _err:
|
|||
|
||||
int tsdbClose(STsdb **pTsdb) {
|
||||
if (*pTsdb) {
|
||||
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||
taosThreadRwlockWrlock(&(*pTsdb)->rwLock);
|
||||
tsdbMemTableDestroy((*pTsdb)->mem);
|
||||
(*pTsdb)->mem = NULL;
|
||||
taosThreadRwlockUnlock(&(*pTsdb)->rwLock);
|
||||
|
||||
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||
|
||||
tsdbFSClose(*pTsdb);
|
||||
tsdbCloseCache(*pTsdb);
|
||||
taosMemoryFreeClear(*pTsdb);
|
||||
|
|
|
@ -340,7 +340,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb
|
|||
pIter->pLastBlockReader = taosMemoryCalloc(1, sizeof(struct SLastBlockReader));
|
||||
if (pIter->pLastBlockReader == NULL) {
|
||||
int32_t code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tsdbError("failed to prepare the last block iterator, code:%d %s", tstrerror(code), pReader->idStr);
|
||||
tsdbError("failed to prepare the last block iterator, code:%s %s", tstrerror(code), pReader->idStr);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
|
|||
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
tsdbDebug(
|
||||
"load block of %d tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed "
|
||||
"load block of %"PRIzu" tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed "
|
||||
"time:%.2f ms %s",
|
||||
numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el,
|
||||
pReader->idStr);
|
||||
|
@ -1515,6 +1515,11 @@ static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader*
|
|||
|
||||
taosMemoryFree(pReader->pMemSchema);
|
||||
int32_t code = metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pMemSchema);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pReader->pMemSchema;
|
||||
}
|
||||
|
||||
|
@ -1645,7 +1650,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
|
|||
STSRow* pTSRow = NULL;
|
||||
SRowMerger merge = {0};
|
||||
TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
|
||||
tsdbTrace("fRow ptr:%p, %d, uid:%"PRIu64", %s", fRow.pBlockData, fRow.iRow, pLastBlockReader->uid, pReader->idStr);
|
||||
tsdbTrace("fRow ptr:%p, %d, uid:%" PRIu64 ", %s", fRow.pBlockData, fRow.iRow, pLastBlockReader->uid, pReader->idStr);
|
||||
|
||||
// only last block exists
|
||||
if ((!mergeBlockData) || (tsLastBlock != pBlockData->aTSKEY[pDumpInfo->rowIndex])) {
|
||||
|
@ -2676,9 +2681,9 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
|
|||
int8_t level = 0;
|
||||
int8_t precision = pVnode->config.tsdbCfg.precision;
|
||||
int64_t now = taosGetTimestamp(precision);
|
||||
int64_t offset = tsQueryRsmaTolerance * ((precision == TSDB_TIME_PRECISION_MILLI) ? 1
|
||||
: (precision == TSDB_TIME_PRECISION_MICRO) ? 1000
|
||||
: 1000000);
|
||||
int64_t offset = tsQueryRsmaTolerance * ((precision == TSDB_TIME_PRECISION_MILLI) ? 1L
|
||||
: (precision == TSDB_TIME_PRECISION_MICRO) ? 1000L
|
||||
: 1000000L);
|
||||
|
||||
for (int8_t i = 0; i < TSDB_RETENTION_MAX; ++i) {
|
||||
SRetention* pRetention = retentions + level;
|
||||
|
@ -3085,7 +3090,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
|
|||
doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
|
||||
tRowMerge(&merge, piRow);
|
||||
doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
}
|
||||
|
||||
int32_t code = tRowMergerGetRow(&merge, pTSRow);
|
||||
|
@ -3372,14 +3377,13 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
if (pCond->suid != 0) {
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, -1, 1);
|
||||
if (pReader->pSchema == NULL) {
|
||||
tsdbError("failed to get table schema, suid:%" PRIu64 ", ver:%" PRId64 " , %s", pReader->suid, -1,
|
||||
pReader->idStr);
|
||||
tsdbError("failed to get table schema, suid:%" PRIu64 ", ver:-1, %s", pReader->suid, pReader->idStr);
|
||||
}
|
||||
} else if (taosArrayGetSize(pTableList) > 0) {
|
||||
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, -1, 1);
|
||||
if (pReader->pSchema == NULL) {
|
||||
tsdbError("failed to get table schema, uid:%" PRIu64 ", ver:%" PRId64 " , %s", pKey->uid, -1, pReader->idStr);
|
||||
tsdbError("failed to get table schema, uid:%" PRIu64 ", ver:-1, %s", pKey->uid, pReader->idStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3395,19 +3399,20 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbTakeReadSnap(pReader->pTsdb, &pReader->pReadSnap, pReader->idStr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (pReader->type == TIMEWINDOW_RANGE_CONTAINED) {
|
||||
code = doOpenReaderImpl(pReader);
|
||||
if (numOfTables > 0) {
|
||||
code = tsdbTakeReadSnap(pReader->pTsdb, &pReader->pReadSnap, pReader->idStr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
STsdbReader* pPrevReader = pReader->innerReader[0];
|
||||
STsdbReader* pNextReader = pReader->innerReader[1];
|
||||
|
||||
if (pReader->type == TIMEWINDOW_RANGE_CONTAINED) {
|
||||
code = doOpenReaderImpl(pReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
STsdbReader* pPrevReader = pReader->innerReader[0];
|
||||
STsdbReader* pNextReader = pReader->innerReader[1];
|
||||
|
||||
// we need only one row
|
||||
pPrevReader->capacity = 1;
|
||||
|
@ -3422,19 +3427,20 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
pNextReader->pMemSchema = pReader->pMemSchema;
|
||||
pNextReader->pReadSnap = pReader->pReadSnap;
|
||||
|
||||
code = doOpenReaderImpl(pPrevReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
code = doOpenReaderImpl(pPrevReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
code = doOpenReaderImpl(pNextReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
code = doOpenReaderImpl(pNextReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
code = doOpenReaderImpl(pReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
code = doOpenReaderImpl(pReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3442,7 +3448,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), pReader->idStr);
|
||||
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3513,6 +3519,10 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
taosMemoryFree(pLReader);
|
||||
}
|
||||
|
||||
if (pReader->innerReader[0] != 0) {
|
||||
tsdbUntakeReadSnap(pReader->innerReader[0]->pTsdb, pReader->innerReader[0]->pReadSnap, pReader->idStr);
|
||||
}
|
||||
|
||||
tsdbDebug(
|
||||
"%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
|
||||
" SMA-time:%.2f ms, fileBlocks:%" PRId64
|
||||
|
@ -3727,7 +3737,7 @@ SArray* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
|
|||
}
|
||||
|
||||
int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
||||
if (isEmptyQueryTimeWindow(&pReader->window)) {
|
||||
if (isEmptyQueryTimeWindow(&pReader->window) || pReader->pReadSnap == NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// =============== PAGE-WISE FILE ===============
|
||||
static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD) {
|
||||
int32_t code = 0;
|
||||
STsdbFD *pFD;
|
||||
STsdbFD *pFD = NULL;
|
||||
|
||||
*ppFD = NULL;
|
||||
|
||||
|
@ -35,6 +35,7 @@ static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsd
|
|||
pFD->pFD = taosOpenFile(path, flag);
|
||||
if (pFD->pFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(pFD);
|
||||
goto _exit;
|
||||
}
|
||||
pFD->szPage = szPage;
|
||||
|
@ -42,11 +43,15 @@ static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsd
|
|||
pFD->pBuf = taosMemoryCalloc(1, szPage);
|
||||
if (pFD->pBuf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosCloseFile(&pFD->pFD);
|
||||
taosMemoryFree(pFD);
|
||||
goto _exit;
|
||||
}
|
||||
if (taosStatFile(path, &pFD->szFile, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(pFD->pBuf);
|
||||
taosCloseFile(&pFD->pFD);
|
||||
taosMemoryFree(pFD);
|
||||
goto _exit;
|
||||
}
|
||||
ASSERT(pFD->szFile % szPage == 0);
|
||||
|
@ -59,10 +64,12 @@ _exit:
|
|||
|
||||
static void tsdbCloseFile(STsdbFD **ppFD) {
|
||||
STsdbFD *pFD = *ppFD;
|
||||
taosMemoryFree(pFD->pBuf);
|
||||
taosCloseFile(&pFD->pFD);
|
||||
taosMemoryFree(pFD);
|
||||
*ppFD = NULL;
|
||||
if (pFD) {
|
||||
taosMemoryFree(pFD->pBuf);
|
||||
taosCloseFile(&pFD->pFD);
|
||||
taosMemoryFree(pFD);
|
||||
*ppFD = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
||||
|
@ -117,7 +124,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
|
|||
}
|
||||
|
||||
// check
|
||||
if (!taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {
|
||||
if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -443,7 +450,7 @@ int32_t tsdbWriteDataBlk(SDataFWriter *pWriter, SMapData *mDataBlk, SBlockIdx *p
|
|||
pBlockIdx->size = size;
|
||||
pHeadFile->size += size;
|
||||
|
||||
tsdbTrace("vgId:%d, write block, file ID:%d commit ID:%d suid:%" PRId64 " uid:%" PRId64 " offset:%" PRId64
|
||||
tsdbTrace("vgId:%d, write block, file ID:%d commit ID:%" PRId64 " suid:%" PRId64 " uid:%" PRId64 " offset:%" PRId64
|
||||
" size:%" PRId64 " nItem:%d",
|
||||
TD_VID(pWriter->pTsdb->pVnode), pWriter->wSet.fid, pHeadFile->commitID, pBlockIdx->suid, pBlockIdx->uid,
|
||||
pBlockIdx->offset, pBlockIdx->size, mDataBlk->nItem);
|
||||
|
@ -457,7 +464,7 @@ _err:
|
|||
int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk) {
|
||||
int32_t code = 0;
|
||||
SSttFile *pSttFile = &pWriter->fStt[pWriter->wSet.nSttF - 1];
|
||||
int64_t size;
|
||||
int64_t size = 0;
|
||||
int64_t n;
|
||||
|
||||
// check
|
||||
|
@ -836,7 +843,8 @@ _err:
|
|||
// SDataFReader ====================================================
|
||||
int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet) {
|
||||
int32_t code = 0;
|
||||
SDataFReader *pReader;
|
||||
int32_t lino = 0;
|
||||
SDataFReader *pReader = NULL;
|
||||
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
|
@ -844,7 +852,7 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
pReader = (SDataFReader *)taosMemoryCalloc(1, sizeof(*pReader));
|
||||
if (pReader == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pReader->pTsdb = pTsdb;
|
||||
pReader->pSet = pSet;
|
||||
|
@ -852,31 +860,40 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
// head
|
||||
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pHeadFD);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// data
|
||||
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pDataFD);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// sma
|
||||
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pSmaFD);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// stt
|
||||
for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
|
||||
tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
|
||||
code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->aSttFD[iStt]);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
_exit:
|
||||
if (code) {
|
||||
*ppReader = NULL;
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, tsdb data file reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
if (pReader) {
|
||||
for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) tsdbCloseFile(&pReader->aSttFD[iStt]);
|
||||
tsdbCloseFile(&pReader->pSmaFD);
|
||||
tsdbCloseFile(&pReader->pDataFD);
|
||||
tsdbCloseFile(&pReader->pHeadFD);
|
||||
taosMemoryFree(pReader);
|
||||
}
|
||||
} else {
|
||||
*ppReader = pReader;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -906,10 +923,6 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
|
|||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, data file reader close failed since %s", TD_VID((*ppReader)->pTsdb->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
||||
|
@ -1289,16 +1302,17 @@ _exit:
|
|||
// SDelFWriter ====================================================
|
||||
int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||
SDelFWriter *pDelFWriter;
|
||||
SDelFWriter *pDelFWriter = NULL;
|
||||
int64_t n;
|
||||
|
||||
// alloc
|
||||
pDelFWriter = (SDelFWriter *)taosMemoryCalloc(1, sizeof(*pDelFWriter));
|
||||
if (pDelFWriter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pDelFWriter->pTsdb = pTsdb;
|
||||
pDelFWriter->fDel = *pFile;
|
||||
|
@ -1306,21 +1320,28 @@ int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb
|
|||
tsdbDelFileName(pTsdb, pFile, fname);
|
||||
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE,
|
||||
&pDelFWriter->pWriteH);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// update header
|
||||
code = tsdbWriteFile(pDelFWriter->pWriteH, 0, hdr, TSDB_FHDR_SIZE);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
pDelFWriter->fDel.size = TSDB_FHDR_SIZE;
|
||||
pDelFWriter->fDel.offset = 0;
|
||||
|
||||
*ppWriter = pDelFWriter;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, failed to open del file writer since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
_exit:
|
||||
if (code) {
|
||||
if (pDelFWriter) {
|
||||
taosMemoryFree(pDelFWriter);
|
||||
tsdbCloseFile(&pDelFWriter->pWriteH);
|
||||
}
|
||||
*ppWriter = NULL;
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
|
||||
} else {
|
||||
*ppWriter = pDelFWriter;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1456,15 +1477,15 @@ struct SDelFReader {
|
|||
|
||||
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
SDelFReader *pDelFReader;
|
||||
int64_t n;
|
||||
SDelFReader *pDelFReader = NULL;
|
||||
|
||||
// alloc
|
||||
pDelFReader = (SDelFReader *)taosMemoryCalloc(1, sizeof(*pDelFReader));
|
||||
if (pDelFReader == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// open impl
|
||||
|
@ -1473,14 +1494,18 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
|
|||
|
||||
tsdbDelFileName(pTsdb, pFile, fname);
|
||||
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ, &pDelFReader->pReadH);
|
||||
if (code) goto _err;
|
||||
if (code) {
|
||||
taosMemoryFree(pDelFReader);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*ppReader = pDelFReader;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, del file reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
_exit:
|
||||
if (code) {
|
||||
*ppReader = NULL;
|
||||
tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
} else {
|
||||
*ppReader = pDelFReader;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1573,4 +1598,4 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx) {
|
|||
_err:
|
||||
tsdbError("vgId:%d, read del idx failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,13 @@ extern int32_t tRowInfoCmprFn(const void* p1, const void* p2);
|
|||
extern int32_t tsdbReadDataBlockEx(SDataFReader* pReader, SDataBlk* pDataBlk, SBlockData* pBlockData);
|
||||
extern int32_t tsdbUpdateTableSchema(SMeta* pMeta, int64_t suid, int64_t uid, SSkmInfo* pSkmInfo);
|
||||
|
||||
static int32_t tFDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) {
|
||||
SFDataIter* pIter1 = (SFDataIter*)(((uint8_t*)pNode1) - offsetof(SFDataIter, n));
|
||||
SFDataIter* pIter2 = (SFDataIter*)(((uint8_t*)pNode2) - offsetof(SFDataIter, n));
|
||||
|
||||
return tRowInfoCmprFn(&pIter1->rInfo, &pIter2->rInfo);
|
||||
}
|
||||
|
||||
static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -79,7 +86,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
|||
if (code) goto _err;
|
||||
|
||||
pReader->pIter = NULL;
|
||||
tRBTreeCreate(&pReader->rbt, tRowInfoCmprFn);
|
||||
tRBTreeCreate(&pReader->rbt, tFDataIterCmprFn);
|
||||
|
||||
// .data file
|
||||
SFDataIter* pIter = &pReader->aFDataIter[0];
|
||||
|
@ -421,7 +428,7 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
|||
n += tPutDelData((*ppData) + n, pDelData);
|
||||
}
|
||||
|
||||
tsdbInfo("vgId:%d, vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%d" PRId64 " size:%d",
|
||||
tsdbInfo("vgId:%d, vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%" PRId64 " size:%d",
|
||||
TD_VID(pTsdb->pVnode), pTsdb->path, pDelIdx->suid, pDelIdx->uid, size);
|
||||
|
||||
break;
|
||||
|
@ -431,20 +438,21 @@ _exit:
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, vnode snapshot tsdb read del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->pVnode,
|
||||
tsdbError("vgId:%d, vnode snapshot tsdb read del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
|
||||
tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type, STsdbSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
STsdbSnapReader* pReader = NULL;
|
||||
|
||||
// alloc
|
||||
pReader = (STsdbSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
|
||||
if (pReader == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pReader->pTsdb = pTsdb;
|
||||
pReader->sver = sver;
|
||||
|
@ -454,19 +462,19 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
|
|||
code = taosThreadRwlockRdlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
code = tsdbFSRef(pTsdb, &pReader->fs);
|
||||
if (code) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
// data
|
||||
|
@ -478,43 +486,52 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
|
|||
pIter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||
if (pIter->aBlockIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
} else {
|
||||
pIter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
|
||||
if (pIter->aSttBlk == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
||||
code = tBlockDataCreate(&pIter->bData);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
code = tBlockDataCreate(&pReader->bData);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// del
|
||||
pReader->aDelIdx = taosArrayInit(0, sizeof(SDelIdx));
|
||||
if (pReader->aDelIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pReader->aDelData = taosArrayInit(0, sizeof(SDelData));
|
||||
if (pReader->aDelData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
tsdbInfo("vgId:%d, vnode snapshot tsdb reader opened for %s", TD_VID(pTsdb->pVnode), pTsdb->path);
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), lino, tstrerror(code),
|
||||
pTsdb->path);
|
||||
*ppReader = NULL;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, vnode snapshot tsdb reader open for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
|
||||
tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
if (pReader) {
|
||||
taosArrayDestroy(pReader->aDelData);
|
||||
taosArrayDestroy(pReader->aDelIdx);
|
||||
tBlockDataDestroy(&pReader->bData, 1);
|
||||
tsdbFSDestroy(&pReader->fs);
|
||||
taosMemoryFree(pReader);
|
||||
}
|
||||
} else {
|
||||
*ppReader = pReader;
|
||||
tsdbInfo("vgId:%d, vnode snapshot tsdb reader opened for %s", TD_VID(pTsdb->pVnode), pTsdb->path);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1247,20 +1264,21 @@ _err:
|
|||
// APIs
|
||||
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
STsdbSnapWriter* pWriter = NULL;
|
||||
|
||||
// alloc
|
||||
pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pWriter->pTsdb = pTsdb;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
code = tsdbFSCopy(pTsdb, &pWriter->fs);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// config
|
||||
pWriter->minutes = pTsdb->keepCfg.days;
|
||||
|
@ -1272,7 +1290,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
|||
|
||||
// SNAP_DATA_TSDB
|
||||
code = tBlockDataCreate(&pWriter->bData);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
pWriter->fid = INT32_MIN;
|
||||
pWriter->id = (TABLEID){0};
|
||||
|
@ -1280,53 +1298,67 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
|||
pWriter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||
if (pWriter->dReader.aBlockIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
code = tBlockDataCreate(&pWriter->dReader.bData);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// Writer
|
||||
pWriter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||
if (pWriter->dWriter.aBlockIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pWriter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
|
||||
if (pWriter->dWriter.aSttBlk == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
code = tBlockDataCreate(&pWriter->dWriter.bData);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
code = tBlockDataCreate(&pWriter->dWriter.sData);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// SNAP_DATA_DEL
|
||||
pWriter->aDelIdxR = taosArrayInit(0, sizeof(SDelIdx));
|
||||
if (pWriter->aDelIdxR == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pWriter->aDelData = taosArrayInit(0, sizeof(SDelData));
|
||||
if (pWriter->aDelData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pWriter->aDelIdxW = taosArrayInit(0, sizeof(SDelIdx));
|
||||
if (pWriter->aDelIdxW == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
|
||||
tsdbInfo("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d, tsdb snapshot writer open for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
|
||||
tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
if (pWriter) {
|
||||
if (pWriter->aDelIdxW) taosArrayDestroy(pWriter->aDelIdxW);
|
||||
if (pWriter->aDelData) taosArrayDestroy(pWriter->aDelData);
|
||||
if (pWriter->aDelIdxR) taosArrayDestroy(pWriter->aDelIdxR);
|
||||
tBlockDataDestroy(&pWriter->dWriter.sData, 1);
|
||||
tBlockDataDestroy(&pWriter->dWriter.bData, 1);
|
||||
if (pWriter->dWriter.aSttBlk) taosArrayDestroy(pWriter->dWriter.aSttBlk);
|
||||
if (pWriter->dWriter.aBlockIdx) taosArrayDestroy(pWriter->dWriter.aBlockIdx);
|
||||
tBlockDataDestroy(&pWriter->dReader.bData, 1);
|
||||
if (pWriter->dReader.aBlockIdx) taosArrayDestroy(pWriter->dReader.aBlockIdx);
|
||||
tBlockDataDestroy(&pWriter->bData, 1);
|
||||
tsdbFSDestroy(&pWriter->fs);
|
||||
taosMemoryFree(pWriter);
|
||||
}
|
||||
} else {
|
||||
tsdbDebug("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
|
||||
*ppWriter = pWriter;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
|
|||
}
|
||||
|
||||
// loop to insert
|
||||
tInitSubmitMsgIter(pMsg, &msgIter);
|
||||
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) {
|
||||
return -1;
|
||||
}
|
||||
while (true) {
|
||||
SSubmitBlkRsp r = {0};
|
||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||
|
|
|
@ -112,6 +112,8 @@ void vnodeBufPoolReset(SVBufPool *pPool) {
|
|||
void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||
SVBufPoolNode *pNode;
|
||||
void *p = NULL;
|
||||
ASSERT(pPool != NULL);
|
||||
|
||||
taosThreadSpinLock(&pPool->lock);
|
||||
if (pPool->node.size >= pPool->ptr - pPool->node.data + size) {
|
||||
// allocate from the anchor node
|
||||
|
@ -141,17 +143,17 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
|||
}
|
||||
|
||||
void vnodeBufPoolFree(SVBufPool *pPool, void *p) {
|
||||
uint8_t *ptr = (uint8_t *)p;
|
||||
SVBufPoolNode *pNode;
|
||||
// uint8_t *ptr = (uint8_t *)p;
|
||||
// SVBufPoolNode *pNode;
|
||||
|
||||
if (ptr < pPool->node.data || ptr >= pPool->node.data + pPool->node.size) {
|
||||
pNode = &((SVBufPoolNode *)p)[-1];
|
||||
*pNode->pnext = pNode->prev;
|
||||
pNode->prev->pnext = pNode->pnext;
|
||||
// if (ptr < pPool->node.data || ptr >= pPool->node.data + pPool->node.size) {
|
||||
// pNode = &((SVBufPoolNode *)p)[-1];
|
||||
// *pNode->pnext = pNode->prev;
|
||||
// pNode->prev->pnext = pNode->pnext;
|
||||
|
||||
pPool->size = pPool->size - sizeof(*pNode) - pNode->size;
|
||||
taosMemoryFree(pNode);
|
||||
}
|
||||
// pPool->size = pPool->size - sizeof(*pNode) - pNode->size;
|
||||
// taosMemoryFree(pNode);
|
||||
// }
|
||||
}
|
||||
|
||||
void vnodeBufPoolRef(SVBufPool *pPool) {
|
||||
|
|
|
@ -73,7 +73,7 @@ int vnodeBegin(SVnode *pVnode) {
|
|||
|
||||
int vnodeShouldCommit(SVnode *pVnode) {
|
||||
if (pVnode->inUse) {
|
||||
return pVnode->inUse->size > pVnode->inUse->node.size;
|
||||
return osDataSpaceAvailable() && (pVnode->inUse->size > pVnode->inUse->node.size);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
|||
data = NULL;
|
||||
|
||||
if (vnodeEncodeInfo(pInfo, &data) < 0) {
|
||||
vError("failed to encode json info.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
|||
}
|
||||
|
||||
if (taosWriteFile(pFile, data, strlen(data)) < 0) {
|
||||
vError("failed to write info file:%s data:%s", fname, terrstr());
|
||||
vError("failed to write info file:%s error:%s", fname, terrstr());
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
@ -233,15 +234,15 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||
}
|
||||
if (vnodeSaveInfo(dir, &info) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to save vnode info since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||
|
||||
// preCommit
|
||||
// smaSyncPreCommit(pVnode->pSma);
|
||||
if (smaAsyncPreCommit(pVnode->pSma) < 0) {
|
||||
ASSERT(0);
|
||||
if(smaAsyncPreCommit(pVnode->pSma) < 0){
|
||||
vError("vgId:%d, failed to async pre-commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -250,44 +251,44 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
|
||||
// commit each sub-system
|
||||
if (metaCommit(pVnode->pMeta) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (VND_IS_RSMA(pVnode)) {
|
||||
if (smaAsyncCommit(pVnode->pSma) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to async commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tsdbCommit(VND_RSMA0(pVnode)) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit tsdb rsma0 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
if (tsdbCommit(VND_RSMA1(pVnode)) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
if (tsdbCommit(VND_RSMA2(pVnode)) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit tsdb rsma2 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (tsdbCommit(pVnode->pTsdb) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (tqCommit(pVnode->pTq) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
// walCommit (TODO)
|
||||
|
||||
// commit info
|
||||
if (vnodeCommitInfo(dir, &info) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to commit vnode info since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
// postCommit
|
||||
// smaSyncPostCommit(pVnode->pSma);
|
||||
if (smaAsyncPostCommit(pVnode->pSma) < 0) {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, failed to async post-commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,17 @@ int vnodeInit(int nthreads) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
vnodeGlobal.stop = 0;
|
||||
taosThreadMutexInit(&vnodeGlobal.mutex, NULL);
|
||||
taosThreadCondInit(&vnodeGlobal.hasTask, NULL);
|
||||
|
||||
taosThreadMutexLock(&vnodeGlobal.mutex);
|
||||
|
||||
vnodeGlobal.stop = 0;
|
||||
vnodeGlobal.queue.next = &vnodeGlobal.queue;
|
||||
vnodeGlobal.queue.prev = &vnodeGlobal.queue;
|
||||
|
||||
taosThreadMutexUnlock(&(vnodeGlobal.mutex));
|
||||
|
||||
vnodeGlobal.nthreads = nthreads;
|
||||
vnodeGlobal.threads = taosMemoryCalloc(nthreads, sizeof(TdThread));
|
||||
if (vnodeGlobal.threads == NULL) {
|
||||
|
@ -59,9 +65,6 @@ int vnodeInit(int nthreads) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
taosThreadMutexInit(&vnodeGlobal.mutex, NULL);
|
||||
taosThreadCondInit(&vnodeGlobal.hasTask, NULL);
|
||||
|
||||
for (int i = 0; i < nthreads; i++) {
|
||||
taosThreadCreate(&(vnodeGlobal.threads[i]), NULL, loop, NULL);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
|||
if (taosMkDir(path)) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
strcpy(dir, path);
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", path);
|
||||
}
|
||||
|
||||
if (pCfg) {
|
||||
|
@ -51,7 +51,7 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
|||
info.state.commitID = 0;
|
||||
|
||||
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
|
||||
vError("vgId:%d, failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno));
|
||||
vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
|
||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||
if (pVnode->pWal == NULL) {
|
||||
vError("vgId:%d, failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
vError("vgId:%d, failed to open vnode wal since %s. wal:%s", TD_VID(pVnode), tstrerror(terrno), tdir);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
if (*ppData) {
|
||||
goto _exit;
|
||||
} else {
|
||||
pReader->tqHandleDone = 1;
|
||||
pReader->tqOffsetDone = 1;
|
||||
code = tqOffsetReaderClose(&pReader->pTqOffsetReader);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ _exit:
|
|||
return code;
|
||||
|
||||
_err:
|
||||
vError("vgId:% vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
||||
vError("vgId:%d vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,10 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
|||
|
||||
// commit it
|
||||
code = vnodeCommit(pVnode);
|
||||
if (code) goto _err;
|
||||
if (code) {
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// inc commit ID
|
||||
pVnode->state.commitID++;
|
||||
|
|
|
@ -41,16 +41,28 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
int32_t nReqs;
|
||||
|
||||
tDecoderInit(&dc, (uint8_t *)pMsg->pCont + sizeof(SMsgHead), pMsg->contLen - sizeof(SMsgHead));
|
||||
tStartDecode(&dc);
|
||||
if (tStartDecode(&dc) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
|
||||
tDecodeI32v(&dc, &nReqs);
|
||||
if (tDecodeI32v(&dc, &nReqs) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _err;
|
||||
}
|
||||
for (int32_t iReq = 0; iReq < nReqs; iReq++) {
|
||||
tb_uid_t uid = tGenIdPI64();
|
||||
char *name = NULL;
|
||||
tStartDecode(&dc);
|
||||
|
||||
tDecodeI32v(&dc, NULL);
|
||||
tDecodeCStr(&dc, &name);
|
||||
if (tDecodeI32v(&dc, NULL) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
if (tDecodeCStr(&dc, &name) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
*(int64_t *)(dc.data + dc.pos) = uid;
|
||||
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
||||
|
||||
|
@ -68,7 +80,10 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
int64_t ctime = taosGetTimestampMs();
|
||||
tb_uid_t uid;
|
||||
|
||||
tInitSubmitMsgIter(pSubmitReq, &msgIter);
|
||||
if (tInitSubmitMsgIter(pSubmitReq, &msgIter) < 0) {
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||
|
@ -78,10 +93,19 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
char *name = NULL;
|
||||
|
||||
tDecoderInit(&dc, pBlock->data, msgIter.schemaLen);
|
||||
tStartDecode(&dc);
|
||||
if (tStartDecode(&dc) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
|
||||
tDecodeI32v(&dc, NULL);
|
||||
tDecodeCStr(&dc, &name);
|
||||
if (tDecodeI32v(&dc, NULL) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
if (tDecodeCStr(&dc, &name) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
}
|
||||
|
||||
uid = metaGetTableEntryUidByName(pVnode->pMeta, name);
|
||||
if (uid == 0) {
|
||||
|
@ -145,6 +169,12 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
int32_t len;
|
||||
int32_t ret;
|
||||
|
||||
if (!pVnode->inUse) {
|
||||
terrno = TSDB_CODE_VND_NOT_SYNCED;
|
||||
vError("vgId:%d, not ready to write since %s", TD_VID(pVnode), terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
vDebug("vgId:%d, start to process write request %s, index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
||||
version);
|
||||
|
||||
|
@ -265,10 +295,16 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
_do_commit:
|
||||
vInfo("vgId:%d, commit at version %" PRId64, TD_VID(pVnode), version);
|
||||
// commit current change
|
||||
vnodeCommit(pVnode);
|
||||
if (vnodeCommit(pVnode) < 0) {
|
||||
vError("vgId:%d, failed to commit vnode since %s.", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// start a new one
|
||||
vnodeBegin(pVnode);
|
||||
if (vnodeBegin(pVnode) < 0) {
|
||||
vError("vgId:%d, failed to begin vnode since %s.", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -638,7 +638,7 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_QNODE_LIST;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse);
|
||||
|
||||
|
@ -692,7 +692,7 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_DNODE_LIST;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get dnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse);
|
||||
|
||||
|
@ -743,7 +743,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU
|
|||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_USE_DB;
|
||||
SCtgTask* pTask = tReq ? tReq->pTask : NULL;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db);
|
||||
|
||||
|
@ -795,7 +795,7 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_DB_CFG;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName);
|
||||
|
||||
|
@ -850,7 +850,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_INDEX;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get index from mnode, indexName:%s", indexName);
|
||||
|
||||
|
@ -905,7 +905,7 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(name, tbFName);
|
||||
|
||||
|
@ -962,7 +962,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_RETRIEVE_FUNC;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get udf info from mnode, funcName:%s", funcName);
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_GET_USER_AUTH;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get user auth from mnode, user:%s", user);
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char*
|
|||
int32_t reqType = TDMT_MND_TABLE_META;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
sprintf(tbFName, "%s.%s", dbFName, tbName);
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName);
|
||||
|
||||
|
@ -1140,7 +1140,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
|
|||
int32_t reqType = TDMT_VND_TABLE_META;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
sprintf(tbFName, "%s.%s", dbFName, pTableName->tname);
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse];
|
||||
ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", vgroupInfo->vgId,
|
||||
|
@ -1209,7 +1209,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
|||
int32_t reqType = TDMT_VND_TABLE_CFG;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pTableName, tbFName);
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)pTableName->tname};
|
||||
|
@ -1274,7 +1274,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
|
|||
int32_t reqType = TDMT_MND_TABLE_CFG;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pTableName, tbFName);
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTableName, dbFName);
|
||||
SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = (char*)pTableName->tname};
|
||||
|
@ -1326,7 +1326,7 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou
|
|||
char* msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_SERVER_VERSION;
|
||||
void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont;
|
||||
|
||||
qDebug("try to get svr ver from mnode");
|
||||
|
||||
|
|
|
@ -212,6 +212,7 @@ typedef struct SExprSupp {
|
|||
int32_t numOfExprs; // the number of scalar expression in group operator
|
||||
SqlFunctionCtx* pCtx;
|
||||
int32_t* rowEntryInfoOffset; // offset value for each row result cell info
|
||||
SFilterInfo* pFilterInfo;
|
||||
} SExprSupp;
|
||||
|
||||
typedef struct SOperatorInfo {
|
||||
|
@ -479,6 +480,7 @@ typedef struct SStreamScanInfo {
|
|||
SExprInfo* pPseudoExpr;
|
||||
int32_t numOfPseudoExpr;
|
||||
SExprSupp tbnameCalSup;
|
||||
SExprSupp tagCalSup;
|
||||
int32_t primaryTsIndex; // primary time stamp slot id
|
||||
SReadHandle readHandle;
|
||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
||||
|
@ -775,6 +777,7 @@ typedef struct SStreamPartitionOperatorInfo {
|
|||
SPartitionBySupporter partitionSup;
|
||||
SExprSupp scalarSup;
|
||||
SExprSupp tbnameCalSup;
|
||||
SExprSupp tagCalSup;
|
||||
SHashObj* pPartitions;
|
||||
void* parIte;
|
||||
SSDataBlock* pInputDataBlock;
|
||||
|
@ -924,7 +927,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
|
|||
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz);
|
||||
|
||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo);
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo, SFilterInfo* pFilterInfo);
|
||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr,
|
||||
SSDataBlock* pBlock, const char* idStr);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
pInserter->submitRes.affectedRows += pInserter->submitRes.pRsp->affectedRows;
|
||||
qDebug("submit rsp received, affectedRows:%d, total:%d", pInserter->submitRes.pRsp->affectedRows,
|
||||
qDebug("submit rsp received, affectedRows:%d, total:%"PRId64, pInserter->submitRes.pRsp->affectedRows,
|
||||
pInserter->submitRes.affectedRows);
|
||||
|
||||
tFreeSSubmitRsp(pInserter->submitRes.pRsp);
|
||||
|
|
|
@ -1138,7 +1138,7 @@ static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, i
|
|||
s.bytes = bytes;
|
||||
s.slotId = slotId;
|
||||
s.precision = precision;
|
||||
strncpy(s.name, name, tListLen(s.name));
|
||||
tstrncpy(s.name, name, tListLen(s.name));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -1201,14 +1201,21 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
|||
pExp->base.resSchema =
|
||||
createResSchema(pType->type, pType->bytes, slotId, pType->scale, pType->precision, pFuncNode->node.aliasName);
|
||||
|
||||
pExp->pExpr->_function.functionId = pFuncNode->funcId;
|
||||
pExp->pExpr->_function.pFunctNode = pFuncNode;
|
||||
tExprNode* pExprNode = pExp->pExpr;
|
||||
|
||||
pExprNode->_function.functionId = pFuncNode->funcId;
|
||||
pExprNode->_function.pFunctNode = pFuncNode;
|
||||
|
||||
tstrncpy(pExprNode->_function.functionName, pFuncNode->functionName, tListLen(pExprNode->_function.functionName));
|
||||
|
||||
strncpy(pExp->pExpr->_function.functionName, pFuncNode->functionName,
|
||||
tListLen(pExp->pExpr->_function.functionName));
|
||||
#if 1
|
||||
// todo refactor: add the parameter for tbname function
|
||||
if (!pFuncNode->pParameterList && (strcmp(pExp->pExpr->_function.functionName, "tbname") == 0)) {
|
||||
const char* name = "tbname";
|
||||
int32_t len = strlen(name);
|
||||
|
||||
if (!pFuncNode->pParameterList && (memcmp(pExprNode->_function.functionName, name, len) == 0) &&
|
||||
pExprNode->_function.functionName[len] == 0) {
|
||||
|
||||
pFuncNode->pParameterList = nodesMakeList();
|
||||
ASSERT(LIST_LENGTH(pFuncNode->pParameterList) == 0);
|
||||
SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
|
@ -1250,6 +1257,17 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
|||
pExp->base.resSchema =
|
||||
createResSchema(pType->type, pType->bytes, slotId, pType->scale, pType->precision, pOpNode->node.aliasName);
|
||||
pExp->pExpr->_optrRoot.pRootNode = pNode;
|
||||
} else if (type == QUERY_NODE_CASE_WHEN) {
|
||||
pExp->pExpr->nodeType = QUERY_NODE_OPERATOR;
|
||||
SCaseWhenNode* pCaseNode = (SCaseWhenNode*)pNode;
|
||||
|
||||
pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||
pExp->base.numOfParams = 1;
|
||||
|
||||
SDataType* pType = &pCaseNode->node.resType;
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, slotId, pType->scale,
|
||||
pType->precision, pCaseNode->node.aliasName);
|
||||
pExp->pExpr->_optrRoot.pRootNode = pNode;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -1348,7 +1366,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet);
|
||||
} else {
|
||||
char* udfName = pExpr->pExpr->_function.pFunctNode->functionName;
|
||||
strncpy(pCtx->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
tstrncpy(pCtx->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet);
|
||||
}
|
||||
pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
|
||||
|
|
|
@ -616,7 +616,7 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) {
|
|||
|
||||
int32_t nOptrWithVal = 0;
|
||||
int32_t code = encodeOperator(pTaskInfo->pRoot, pOutput, len, &nOptrWithVal);
|
||||
if ((code == TSDB_CODE_SUCCESS) && (nOptrWithVal = 0)) {
|
||||
if ((code == TSDB_CODE_SUCCESS) && (nOptrWithVal == 0)) {
|
||||
taosMemoryFreeClear(*pOutput);
|
||||
*len = 0;
|
||||
}
|
||||
|
@ -701,10 +701,10 @@ int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo mtInfo) {
|
||||
int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) {
|
||||
memset(pCond, 0, sizeof(SQueryTableDataCond));
|
||||
pCond->order = TSDB_ORDER_ASC;
|
||||
pCond->numOfCols = mtInfo.schema->nCols;
|
||||
pCond->numOfCols = pMtInfo->schema->nCols;
|
||||
pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo));
|
||||
if (pCond->colList == NULL) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
|
@ -712,15 +712,15 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s
|
|||
}
|
||||
|
||||
pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
|
||||
pCond->suid = mtInfo.suid;
|
||||
pCond->suid = pMtInfo->suid;
|
||||
pCond->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||
pCond->startVersion = -1;
|
||||
pCond->endVersion = sContext->snapVersion;
|
||||
|
||||
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||
pCond->colList[i].type = mtInfo.schema->pSchema[i].type;
|
||||
pCond->colList[i].bytes = mtInfo.schema->pSchema[i].bytes;
|
||||
pCond->colList[i].colId = mtInfo.schema->pSchema[i].colId;
|
||||
pCond->colList[i].type = pMtInfo->schema->pSchema[i].type;
|
||||
pCond->colList[i].bytes = pMtInfo->schema->pSchema[i].bytes;
|
||||
pCond->colList[i].colId = pMtInfo->schema->pSchema[i].colId;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -844,7 +844,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
taosArrayDestroy(pTaskInfo->tableqinfoList.pTableList);
|
||||
if (mtInfo.uid == 0) return 0; // no data
|
||||
|
||||
initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, mtInfo);
|
||||
initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
||||
pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts;
|
||||
pTaskInfo->tableqinfoList.pTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
||||
taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &(STableKeyInfo){.uid = mtInfo.uid, .groupId = 0});
|
||||
|
@ -856,15 +856,15 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema);
|
||||
pTaskInfo->streamInfo.schema = mtInfo.schema;
|
||||
|
||||
qDebug("tmqsnap qStreamPrepareScan snapshot data uid %ld ts %ld", mtInfo.uid, pOffset->ts);
|
||||
qDebug("tmqsnap qStreamPrepareScan snapshot data uid %ld ts %"PRId64, mtInfo.uid, pOffset->ts);
|
||||
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||
SStreamRawScanInfo* pInfo = pOperator->info;
|
||||
SSnapContext* sContext = pInfo->sContext;
|
||||
if (setForSnapShot(sContext, pOffset->uid) != 0) {
|
||||
qError("setForSnapShot error. uid:%" PRIi64 " ,version:%" PRIi64, pOffset->uid);
|
||||
qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version);
|
||||
return -1;
|
||||
}
|
||||
qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %ld ts %ld", pOffset->uid);
|
||||
qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %ld ts %"PRId64, pOffset->uid, pOffset->ts);
|
||||
} else if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
SStreamRawScanInfo* pInfo = pOperator->info;
|
||||
tsdbReaderClose(pInfo->dataReader);
|
||||
|
|
|
@ -895,33 +895,6 @@ static bool overlapWithTimeWindow(STaskAttr* pQueryAttr, SDataBlockInfo* pBlockI
|
|||
}
|
||||
#endif
|
||||
|
||||
static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) {
|
||||
#if 0
|
||||
SqlFunctionCtx* pCtx = pTableScanInfo->pCtx;
|
||||
uint32_t status = BLK_DATA_NOT_LOAD;
|
||||
|
||||
int32_t numOfOutput = 0; // pTableScanInfo->numOfOutput;
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
int32_t functionId = pCtx[i].functionId;
|
||||
int32_t colId = pTableScanInfo->pExpr[i].base.pParam[0].pCol->colId;
|
||||
|
||||
// group by + first/last should not apply the first/last block filter
|
||||
if (functionId < 0) {
|
||||
status |= BLK_DATA_DATA_LOAD;
|
||||
return status;
|
||||
} else {
|
||||
// status |= aAggs[functionId].dataReqFunc(&pTableScanInfo->pCtx[i], &pBlock->info.window, colId);
|
||||
// if ((status & BLK_DATA_DATA_LOAD) == BLK_DATA_DATA_LOAD) {
|
||||
// return status;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
||||
uint32_t* status) {
|
||||
*status = BLK_DATA_NOT_LOAD;
|
||||
|
@ -1113,15 +1086,24 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
|||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep,
|
||||
int32_t status);
|
||||
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo) {
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo, SFilterInfo* pFilterInfo) {
|
||||
if (pFilterNode == NULL || pBlock->info.rows == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SFilterInfo* filter = NULL;
|
||||
SFilterInfo* filter = pFilterInfo;
|
||||
int64_t st = taosGetTimestampUs();
|
||||
|
||||
// pError("start filter");
|
||||
|
||||
// todo move to the initialization function
|
||||
int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0);
|
||||
int32_t code = 0;
|
||||
bool needFree = false;
|
||||
if (filter == NULL) {
|
||||
needFree = true;
|
||||
code = filterInitFromNode((SNode*)pFilterNode, &filter, 0);
|
||||
}
|
||||
|
||||
SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
|
||||
code = filterSetDataFromSlotId(filter, ¶m1);
|
||||
|
||||
|
@ -1130,7 +1112,10 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM
|
|||
|
||||
// todo the keep seems never to be True??
|
||||
bool keep = filterExecute(filter, pBlock, &p, NULL, param1.numOfCols, &status);
|
||||
filterFreeInfo(filter);
|
||||
|
||||
if (needFree) {
|
||||
filterFreeInfo(filter);
|
||||
}
|
||||
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, keep, status);
|
||||
|
||||
|
@ -1790,7 +1775,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
} else {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
pSourceDataInfo->code = code;
|
||||
qDebug("%s fetch rsp received, index:%d, error:%d", pSourceDataInfo->taskId, index, tstrerror(code));
|
||||
qDebug("%s fetch rsp received, index:%d, code:%s", pSourceDataInfo->taskId, index, tstrerror(code));
|
||||
}
|
||||
|
||||
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
|
||||
|
@ -1845,6 +1830,7 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
|||
SResFetchReq* pMsg = taosMemoryCalloc(1, sizeof(SResFetchReq));
|
||||
if (NULL == pMsg) {
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pWrapper);
|
||||
return pTaskInfo->code;
|
||||
}
|
||||
|
||||
|
@ -2479,7 +2465,7 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
|
|||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf);
|
||||
doFilter(pAggInfo->pCondition, pInfo->pRes, NULL);
|
||||
doFilter(pAggInfo->pCondition, pInfo->pRes, NULL, NULL);
|
||||
|
||||
if (!hasRemainResults(&pAggInfo->groupResInfo)) {
|
||||
doSetOperatorCompleted(pOperator);
|
||||
|
@ -2803,6 +2789,8 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
|||
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pBlock->info.rows);
|
||||
blockDataEnsureCapacity(pInfo->pFinalRes, pBlock->info.rows);
|
||||
doApplyScalarCalculation(pOperator, pBlock, order, scanFlag);
|
||||
|
||||
if (pInfo->curGroupId == 0 || pInfo->curGroupId == pInfo->pRes->info.groupId) {
|
||||
|
@ -2873,7 +2861,7 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
|
|||
break;
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, fillResult, pInfo->pColMatchColInfo);
|
||||
doFilter(pInfo->pCondition, fillResult, pInfo->pColMatchColInfo, NULL);
|
||||
if (fillResult->info.rows > 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -3049,6 +3037,12 @@ void cleanupExprSupp(SExprSupp* pSupp) {
|
|||
destroyExprInfo(pSupp->pExprInfo, pSupp->numOfExprs);
|
||||
taosMemoryFreeClear(pSupp->pExprInfo);
|
||||
}
|
||||
|
||||
if (pSupp->pFilterInfo != NULL) {
|
||||
filterFreeInfo(pSupp->pFilterInfo);
|
||||
pSupp->pFilterInfo = NULL;
|
||||
}
|
||||
|
||||
taosMemoryFree(pSupp->rowEntryInfoOffset);
|
||||
}
|
||||
|
||||
|
@ -3378,8 +3372,8 @@ SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) {
|
|||
SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++];
|
||||
pSchema->colId = pColNode->colId;
|
||||
pSchema->type = pColNode->node.resType.type;
|
||||
pSchema->type = pColNode->node.resType.bytes;
|
||||
strncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name));
|
||||
pSchema->bytes = pColNode->node.resType.bytes;
|
||||
tstrncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name));
|
||||
}
|
||||
|
||||
// this the tags and pseudo function columns, we only keep the tag columns
|
||||
|
@ -3393,7 +3387,7 @@ SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) {
|
|||
SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++];
|
||||
pSchema->colId = pColNode->colId;
|
||||
pSchema->type = pColNode->node.resType.type;
|
||||
pSchema->type = pColNode->node.resType.bytes;
|
||||
pSchema->bytes = pColNode->node.resType.bytes;
|
||||
strncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ static SSDataBlock* buildGroupResultDataBlock(SOperatorInfo* pOperator) {
|
|||
SSDataBlock* pRes = pInfo->binfo.pRes;
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pInfo->pCondition, pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pRes, NULL, NULL);
|
||||
|
||||
if (!hasRemainResults(&pInfo->groupResInfo)) {
|
||||
doSetOperatorCompleted(pOperator);
|
||||
|
@ -991,6 +991,8 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
|
|||
|
||||
taosMemoryFree(pInfo->partitionSup.keyBuf);
|
||||
cleanupExprSupp(&pInfo->scalarSup);
|
||||
cleanupExprSupp(&pInfo->tbnameCalSup);
|
||||
cleanupExprSupp(&pInfo->tagCalSup);
|
||||
blockDataDestroy(pInfo->pDelRes);
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
@ -1037,6 +1039,19 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
}
|
||||
}
|
||||
|
||||
if (pPartNode->pTags != NULL) {
|
||||
int32_t numOfTags;
|
||||
SExprInfo* pTagExpr = createExprInfo(pPartNode->pTags, NULL, &numOfTags);
|
||||
if (pTagExpr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags) != 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t keyLen = 0;
|
||||
code = initGroupOptrInfo(&pInfo->partitionSup.pGroupColVals, &keyLen, &pInfo->partitionSup.keyBuf,
|
||||
pInfo->partitionSup.pGroupCols);
|
||||
|
|
|
@ -387,7 +387,7 @@ SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator) {
|
|||
break;
|
||||
}
|
||||
if (pJoinInfo->pCondAfterMerge != NULL) {
|
||||
doFilter(pJoinInfo->pCondAfterMerge, pRes, NULL);
|
||||
doFilter(pJoinInfo->pCondAfterMerge, pRes, NULL, NULL);
|
||||
}
|
||||
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
||||
break;
|
||||
|
|
|
@ -315,7 +315,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
// do apply filter
|
||||
doFilter(pProjectInfo->pFilterNode, pFinalRes, NULL);
|
||||
doFilter(pProjectInfo->pFilterNode, pFinalRes, NULL, NULL);
|
||||
|
||||
// when apply the limit/offset for each group, pRes->info.rows may be 0, due to limit constraint.
|
||||
if (pFinalRes->info.rows > 0 || (pOperator->status == OP_EXEC_DONE)) {
|
||||
|
@ -325,7 +325,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
|||
} else {
|
||||
// do apply filter
|
||||
if (pRes->info.rows > 0) {
|
||||
doFilter(pProjectInfo->pFilterNode, pRes, NULL);
|
||||
doFilter(pProjectInfo->pFilterNode, pRes, NULL, NULL);
|
||||
if (pRes->info.rows == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
|
|||
}
|
||||
}
|
||||
|
||||
doFilter(pIndefInfo->pCondition, pInfo->pRes, NULL);
|
||||
doFilter(pIndefInfo->pCondition, pInfo->pRes, NULL, NULL);
|
||||
size_t rows = pInfo->pRes->info.rows;
|
||||
if (rows > 0 || pOperator->status == OP_EXEC_DONE) {
|
||||
break;
|
||||
|
@ -620,7 +620,7 @@ SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
pRes->info.rows = 1;
|
||||
doFilter(pProjectInfo->pFilterNode, pRes, NULL);
|
||||
doFilter(pProjectInfo->pFilterNode, pRes, NULL, NULL);
|
||||
|
||||
/*int32_t status = */ doIngroupLimitOffset(&pProjectInfo->limitInfo, 0, pRes, pOperator);
|
||||
|
||||
|
|
|
@ -284,6 +284,19 @@ static bool doLoadBlockSMA(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
||||
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
||||
|
||||
int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock,
|
||||
GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
||||
uint32_t* status) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
@ -312,8 +325,9 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
|
|||
} else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||
qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
pCost->skipBlocks += 1;
|
||||
|
||||
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo);
|
||||
pCost->skipBlocks += 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
||||
pCost->loadBlockStatis += 1;
|
||||
|
@ -322,6 +336,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
|
|||
if (success) { // failed to load the block sma data, data block statistics does not exist, load data block instead
|
||||
qDebug("%s data block SMA loaded, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
|
||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
qDebug("%s failed to load SMA, since not all columns have SMA", GET_TASKID(pTaskInfo));
|
||||
|
@ -371,21 +386,11 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
|
|||
}
|
||||
|
||||
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols, true);
|
||||
|
||||
// currently only the tbname pseudo column
|
||||
if (pTableScanInfo->pseudoSup.numOfExprs > 0) {
|
||||
SExprSupp* pSup = &pTableScanInfo->pseudoSup;
|
||||
|
||||
int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock,
|
||||
GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
}
|
||||
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo);
|
||||
|
||||
if (pTableScanInfo->pFilterNode != NULL) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo);
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo, pOperator->exprSupp.pFilterInfo);
|
||||
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
pTableScanInfo->readRecorder.filterTime += el;
|
||||
|
@ -754,6 +759,11 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||
pInfo->pResBlock = createResDataBlock(pDescNode);
|
||||
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
|
||||
|
||||
if (pInfo->pFilterNode != NULL) {
|
||||
code = filterInitFromNode((SNode*)pInfo->pFilterNode, &pOperator->exprSupp.pFilterInfo, 0);
|
||||
}
|
||||
|
||||
pInfo->scanFlag = MAIN_SCAN;
|
||||
pInfo->pColMatchInfo = pColList;
|
||||
pInfo->currentGroupId = -1;
|
||||
|
@ -1074,12 +1084,13 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
|
|||
|
||||
static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, uint64_t* gpIdCol, SInterval* pInterval,
|
||||
SDataBlockInfo* pDataBlockInfo, int32_t* pRowIndex, bool hasGroup) {
|
||||
SResultRowInfo dumyInfo;
|
||||
SResultRowInfo dumyInfo = {0};
|
||||
dumyInfo.cur.pageId = -1;
|
||||
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCol[*pRowIndex], pInterval, TSDB_ORDER_ASC);
|
||||
STimeWindow endWin = win;
|
||||
STimeWindow preWin = win;
|
||||
uint64_t groupId = gpIdCol[*pRowIndex];
|
||||
|
||||
while (1) {
|
||||
if (hasGroup) {
|
||||
(*pRowIndex) += 1;
|
||||
|
@ -1123,7 +1134,7 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32
|
|||
return NULL;
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, pResult, NULL);
|
||||
doFilter(pInfo->pCondition, pResult, NULL, NULL);
|
||||
if (pResult->info.rows == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1143,6 +1154,9 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32
|
|||
pResult->info.rows++;
|
||||
}
|
||||
}
|
||||
|
||||
blockDataDestroy(tmpBlock);
|
||||
|
||||
if (pResult->info.rows > 0) {
|
||||
pResult->info.calWin = pInfo->updateWin;
|
||||
return pResult;
|
||||
|
@ -1315,6 +1329,11 @@ static void calBlockTag(SExprSupp* pTagCalSup, SSDataBlock* pBlock, SSDataBlock*
|
|||
ASSERT(pResBlock->info.rows == 1);
|
||||
|
||||
// build tagArray
|
||||
/*SArray* tagArray = taosArrayInit(0, sizeof(void*));*/
|
||||
/*STagVal tagVal = {*/
|
||||
/*.cid = 0,*/
|
||||
/*.type = 0,*/
|
||||
/*};*/
|
||||
// build STag
|
||||
// set STag
|
||||
|
||||
|
@ -1469,7 +1488,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
}
|
||||
|
||||
if (filter) {
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL, NULL);
|
||||
}
|
||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||
blockDataFreeRes((SSDataBlock*)pBlock);
|
||||
|
@ -1533,7 +1552,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
|
|||
tsdbReaderClose(pTSInfo->dataReader);
|
||||
pTSInfo->dataReader = NULL;
|
||||
tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer);
|
||||
qDebug("queue scan tsdb over, switch to wal ver %d", pTaskInfo->streamInfo.snapshotVer + 1);
|
||||
qDebug("queue scan tsdb over, switch to wal ver %"PRId64, pTaskInfo->streamInfo.snapshotVer + 1);
|
||||
if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1891,7 +1910,7 @@ FETCH_NEXT_BLOCK:
|
|||
}
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL, NULL);
|
||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||
|
||||
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
||||
|
@ -2164,6 +2183,19 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
}
|
||||
}
|
||||
|
||||
if (pTableScanNode->pTags != NULL) {
|
||||
int32_t numOfTags;
|
||||
SExprInfo* pTagExpr = createExprInfo(pTableScanNode->pTags, NULL, &numOfTags);
|
||||
if (pTagExpr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags) != 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
pInfo->pBlockLists = taosArrayInit(4, POINTER_BYTES);
|
||||
if (pInfo->pBlockLists == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -2361,7 +2393,7 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
|
|||
return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, NULL, NULL);
|
||||
return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
|
@ -2542,16 +2574,27 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
|
||||
SMetaReader smrChildTable = {0};
|
||||
metaReaderInit(&smrChildTable, pInfo->readHandle.meta, 0);
|
||||
metaGetTableEntryByName(&smrChildTable, condTableName);
|
||||
int32_t code = metaGetTableEntryByName(&smrChildTable, condTableName);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by metaGetTableEntryByName, therefore, return directly
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (smrChildTable.me.type != TSDB_CHILD_TABLE) {
|
||||
metaReaderClear(&smrChildTable);
|
||||
blockDataDestroy(dataBlock);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SMetaReader smrSuperTable = {0};
|
||||
metaReaderInit(&smrSuperTable, pInfo->readHandle.meta, META_READER_NOLOCK);
|
||||
metaGetTableEntryByUid(&smrSuperTable, smrChildTable.me.ctbEntry.suid);
|
||||
code = metaGetTableEntryByUid(&smrSuperTable, smrChildTable.me.ctbEntry.suid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by metaGetTableEntryByUid
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &smrChildTable, dbname, tableName, &numOfRows, dataBlock);
|
||||
metaReaderClear(&smrSuperTable);
|
||||
metaReaderClear(&smrChildTable);
|
||||
|
@ -2958,7 +3001,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
|||
|
||||
while (1) {
|
||||
int64_t startTs = taosGetTimestampUs();
|
||||
strncpy(pInfo->req.tb, tNameGetTableName(&pInfo->name), tListLen(pInfo->req.tb));
|
||||
tstrncpy(pInfo->req.tb, tNameGetTableName(&pInfo->name), tListLen(pInfo->req.tb));
|
||||
strcpy(pInfo->req.user, pInfo->pUser);
|
||||
|
||||
int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &pInfo->req);
|
||||
|
@ -3434,7 +3477,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc
|
|||
|
||||
if (pTableScanInfo->pFilterNode != NULL) {
|
||||
int64_t st = taosGetTimestampMs();
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo);
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo, NULL);
|
||||
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
pTableScanInfo->readRecorder.filterTime += el;
|
||||
|
@ -3769,6 +3812,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
|||
|
||||
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pColList);
|
||||
goto _error;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
doFilter(pInfo->pCondition, pBlock, pInfo->pColMatchInfo);
|
||||
doFilter(pInfo->pCondition, pBlock, pInfo->pColMatchInfo, NULL);
|
||||
if (blockDataGetNumOfRows(pBlock) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
|
|||
|
||||
blockDataDestroy(p);
|
||||
|
||||
qDebug("%s get sorted block, groupId:%0x" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.groupId,
|
||||
qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.groupId,
|
||||
pDataBlock->info.rows);
|
||||
return (pDataBlock->info.rows > 0) ? pDataBlock : NULL;
|
||||
}
|
||||
|
|
|
@ -1501,7 +1501,7 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
doStreamFillImpl(pOperator);
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, pInfo->pColMatchColInfo);
|
||||
doFilter(pInfo->pCondition, pInfo->pRes, pInfo->pColMatchColInfo, NULL);
|
||||
pOperator->resultInfo.totalRows += pInfo->pRes->info.rows;
|
||||
if (pInfo->pRes->info.rows > 0) {
|
||||
break;
|
||||
|
@ -1681,7 +1681,11 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
|||
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
||||
pInfo->pCondition = pPhyFillNode->node.pConditions;
|
||||
pInfo->pColMatchColInfo = pColMatchColInfo;
|
||||
initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols);
|
||||
int32_t code = initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->srcRowIndex = 0;
|
||||
|
||||
pOperator->name = "FillOperator";
|
||||
|
@ -1693,7 +1697,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
|||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, NULL, destroyStreamFillOperatorInfo,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
@ -1702,5 +1706,6 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
|||
_error:
|
||||
destroyStreamFillOperatorInfo(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
pTaskInfo->code = code;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1277,7 +1277,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
|||
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pInfo->pCondition, pBInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pBInfo->pRes, NULL, NULL);
|
||||
|
||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||
if (!hasRemain) {
|
||||
|
@ -1315,7 +1315,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
|
|||
blockDataEnsureCapacity(pBlock, pOperator->resultInfo.capacity);
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pInfo->pCondition, pBlock, NULL);
|
||||
doFilter(pInfo->pCondition, pBlock, NULL, NULL);
|
||||
|
||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||
if (!hasRemain) {
|
||||
|
@ -1420,8 +1420,9 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDa
|
|||
SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||
uint64_t* pGpDatas = (uint64_t*)pGpCol->pData;
|
||||
for (int32_t i = 0; i < pBlock->info.rows; i++) {
|
||||
SResultRowInfo dumyInfo;
|
||||
SResultRowInfo dumyInfo = {0};
|
||||
dumyInfo.cur.pageId = -1;
|
||||
|
||||
STimeWindow win = {0};
|
||||
if (IS_FINAL_OP(pInfo)) {
|
||||
win.skey = startTsCols[i];
|
||||
|
@ -2019,7 +2020,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
|||
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pInfo->pCondition, pBInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pBInfo->pRes, NULL, NULL);
|
||||
|
||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||
if (!hasRemain) {
|
||||
|
@ -2062,7 +2063,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
|||
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pInfo->pCondition, pBInfo->pRes, NULL);
|
||||
doFilter(pInfo->pCondition, pBInfo->pRes, NULL, NULL);
|
||||
|
||||
bool hasRemain = hasRemainResults(&pInfo->groupResInfo);
|
||||
if (!hasRemain) {
|
||||
|
@ -2841,14 +2842,13 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
|
|||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &numOfCols);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pSessionNode->window.node.pOutputDataBlockDesc);
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
|
||||
int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
|
||||
pInfo->twAggSup.waterMark = pSessionNode->window.watermark;
|
||||
pInfo->twAggSup.calTrigger = pSessionNode->window.triggerType;
|
||||
pInfo->gap = pSessionNode->gap;
|
||||
|
@ -4665,7 +4665,6 @@ void destroyStreamStateOperatorInfo(void* param) {
|
|||
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
|
||||
destroyStreamSessionAggOperatorInfo(pChInfo);
|
||||
taosMemoryFreeClear(pChild);
|
||||
taosMemoryFreeClear(pChInfo);
|
||||
}
|
||||
}
|
||||
colDataDestroy(&pInfo->twAggSup.timeWindowData);
|
||||
|
@ -5251,7 +5250,7 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
|
|||
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pIaInfo->inputOrder, scanFlag, true);
|
||||
doMergeAlignedIntervalAggImpl(pOperator, &pIaInfo->binfo.resultRowInfo, pBlock, pRes);
|
||||
|
||||
doFilter(pMiaInfo->pCondition, pRes, NULL);
|
||||
doFilter(pMiaInfo->pCondition, pRes, NULL, NULL);
|
||||
if (pRes->info.rows >= pOperator->resultInfo.capacity) {
|
||||
break;
|
||||
}
|
||||
|
@ -5828,27 +5827,30 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired;
|
||||
pInfo->isFinal = false;
|
||||
|
||||
if (pIntervalPhyNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalar = 0;
|
||||
SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar);
|
||||
int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
initStreamFunciton(pSup->pCtx, pSup->numOfExprs);
|
||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
int32_t code = initAggInfo(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
initBasicInfo(&pInfo->binfo, pResBlock);
|
||||
initStreamFunciton(pSup->pCtx, pSup->numOfExprs);
|
||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||
if (pIntervalPhyNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalar = 0;
|
||||
SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar);
|
||||
code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
pInfo->invertible = allInvertible(pSup->pCtx, numOfCols);
|
||||
pInfo->invertible = false;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue