Merge branch '3.0' into fix/use-taos-connector-rust-instead-of-libtaos-rs
This commit is contained in:
commit
d8588aa58e
|
@ -60,7 +60,7 @@ sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||||
为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件:
|
为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS 7.9
|
### CentOS 7.9
|
||||||
|
@ -85,7 +85,7 @@ sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
#### CentOS 8/Rocky Linux
|
#### CentOS 8/Rocky Linux
|
||||||
|
@ -94,7 +94,7 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco
|
||||||
sudo yum install -y epel-release
|
sudo yum install -y epel-release
|
||||||
sudo yum install -y dnf-plugins-core
|
sudo yum install -y dnf-plugins-core
|
||||||
sudo yum config-manager --set-enabled powertools
|
sudo yum config-manager --set-enabled powertools
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
注意:由于 snappy 缺乏 pkg-config 支持(参考 [链接](https://github.com/google/snappy/pull/86)),会导致 cmake 提示无法发现 libsnappy,实际上工作正常。
|
注意:由于 snappy 缺乏 pkg-config 支持(参考 [链接](https://github.com/google/snappy/pull/86)),会导致 cmake 提示无法发现 libsnappy,实际上工作正常。
|
||||||
|
|
|
@ -62,7 +62,7 @@ sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||||
To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed.
|
To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS 7.9
|
### CentOS 7.9
|
||||||
|
@ -85,7 +85,7 @@ sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
|
||||||
#### CentOS 7.9
|
#### CentOS 7.9
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
#### CentOS 8/Rocky Linux
|
#### CentOS 8/Rocky Linux
|
||||||
|
@ -94,7 +94,7 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco
|
||||||
sudo yum install -y epel-release
|
sudo yum install -y epel-release
|
||||||
sudo yum install -y dnf-plugins-core
|
sudo yum install -y dnf-plugins-core
|
||||||
sudo yum config-manager --set-enabled powertools
|
sudo yum config-manager --set-enabled powertools
|
||||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
sudo yum install -y zlib-devel zlib-static xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libatomic-static libstdc++-static openssl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it leads a cmake prompt libsnappy not found. But snappy still works well.
|
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it leads a cmake prompt libsnappy not found. But snappy still works well.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taosadapter
|
# taosadapter
|
||||||
ExternalProject_Add(taosadapter
|
ExternalProject_Add(taosadapter
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||||
GIT_TAG e07f41b
|
GIT_TAG 566540d
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG 823fae5
|
GIT_TAG 4a4027c
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -532,7 +532,12 @@ TIMEDIFF(expr1, expr2 [, time_unit])
|
||||||
#### TIMETRUNCATE
|
#### TIMETRUNCATE
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
TIMETRUNCATE(expr, time_unit)
|
TIMETRUNCATE(expr, time_unit [, ignore_timezone])
|
||||||
|
|
||||||
|
ignore_timezone: {
|
||||||
|
0
|
||||||
|
| 1
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Description**: Truncate the input timestamp with unit specified by `time_unit`
|
**Description**: Truncate the input timestamp with unit specified by `time_unit`
|
||||||
|
@ -548,7 +553,10 @@ TIMETRUNCATE(expr, time_unit)
|
||||||
1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks)
|
1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks)
|
||||||
- The precision of the returned timestamp is same as the precision set for the current data base in use
|
- The precision of the returned timestamp is same as the precision set for the current data base in use
|
||||||
- If the input data is not formatted as a timestamp, the returned value is null.
|
- If the input data is not formatted as a timestamp, the returned value is null.
|
||||||
|
- If `1d` is used as `time_unit` to truncate the timestamp, `ignore_timezone` option can be set to indicate if the returned result is affected by client timezone or not.
|
||||||
|
For example, if client timezone is set to UTC+0800, TIMETRUNCATE('2020-01-01 23:00:00', 1d, 0) will return '2020-01-01 08:00:00'.
|
||||||
|
Otherwise, TIMETRUNCATE('2020-01-01 23:00:00', 1d, 1) will return '2020-01-01 00:00:00'.
|
||||||
|
If `ignore_timezone` option is omitted, the default value is set to 1.
|
||||||
|
|
||||||
#### TIMEZONE
|
#### TIMEZONE
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,10 @@ The different database framework specifications for various programming language
|
||||||
| -------------------------------------- | ------------- | --------------- | ------------- | ------------- | ------------- | ------------- |
|
| -------------------------------------- | ------------- | --------------- | ------------- | ------------- | ------------- | ------------- |
|
||||||
| **Connection Management** | Support | Support | Support | Support | Support | Support |
|
| **Connection Management** | Support | Support | Support | Support | Support | Support |
|
||||||
| **Regular Query** | Support | Support | Support | Support | Support | Support |
|
| **Regular Query** | Support | Support | Support | Support | Support | Support |
|
||||||
| **Parameter Binding** | Not supported | Not supported | Not supported | Support | Not supported | Support |
|
| **Parameter Binding** | Not supported | Not supported | support | Support | Not supported | Support |
|
||||||
| **Subscription (TMQ) ** | Not supported | Not supported | Not supported | Not supported | Not supported | Support |
|
| **Subscription (TMQ) ** | Not supported | Not supported | support | Not supported | Not supported | Support |
|
||||||
| **Schemaless** | Not supported | Not supported | Not supported | Not supported | Not supported | Not supported |
|
| **Schemaless** | Not supported | Not supported | Not supported | Not supported | Not supported | Not supported |
|
||||||
| **Bulk Pulling (based on WebSocket) ** | Support | Support | Not Supported | support | Not Supported | Supported |
|
| **Bulk Pulling (based on WebSocket) ** | Support | Support | Support | support | Support | Support |
|
||||||
| **DataFrame** | Not supported | Support | Not supported | Not supported | Not supported | Not supported |
|
| **DataFrame** | Not supported | Support | Not supported | Not supported | Not supported | Not supported |
|
||||||
|
|
||||||
:::warning
|
:::warning
|
||||||
|
|
|
@ -5,22 +5,24 @@ namespace Examples
|
||||||
{
|
{
|
||||||
public class WSConnExample
|
public class WSConnExample
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
||||||
|
|
||||||
if (wsConn == IntPtr.Zero)
|
if (wsConn == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("get WS connection failed");
|
Console.WriteLine("get WS connection failed");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Establish connect success.");
|
Console.WriteLine("Establish connect success.");
|
||||||
}
|
|
||||||
|
|
||||||
// close connection.
|
// close connection.
|
||||||
LibTaosWS.WSClose(wsConn);
|
LibTaosWS.WSClose(wsConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ namespace Examples
|
||||||
{
|
{
|
||||||
public class WSInsertExample
|
public class WSInsertExample
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
||||||
|
@ -13,7 +13,8 @@ namespace Examples
|
||||||
// Assert if connection is validate
|
// Assert if connection is validate
|
||||||
if (wsConn == IntPtr.Zero)
|
if (wsConn == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("get WS connection failed");
|
Console.WriteLine("get WS connection failed");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,8 @@ namespace Examples
|
||||||
|
|
||||||
// close connection.
|
// close connection.
|
||||||
LibTaosWS.WSClose(wsConn);
|
LibTaosWS.WSClose(wsConn);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ValidInsert(string desc, IntPtr wsRes)
|
static void ValidInsert(string desc, IntPtr wsRes)
|
||||||
|
@ -43,7 +46,7 @@ namespace Examples
|
||||||
int code = LibTaosWS.WSErrorNo(wsRes);
|
int code = LibTaosWS.WSErrorNo(wsRes);
|
||||||
if (code != 0)
|
if (code != 0)
|
||||||
{
|
{
|
||||||
throw new Exception($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}");
|
Console.WriteLine($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,13 +7,14 @@ namespace Examples
|
||||||
{
|
{
|
||||||
public class WSQueryExample
|
public class WSQueryExample
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
||||||
if (wsConn == IntPtr.Zero)
|
if (wsConn == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("get WS connection failed");
|
Console.WriteLine("get WS connection failed");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,7 +29,9 @@ namespace Examples
|
||||||
int code = LibTaosWS.WSErrorNo(wsRes);
|
int code = LibTaosWS.WSErrorNo(wsRes);
|
||||||
if (code != 0)
|
if (code != 0)
|
||||||
{
|
{
|
||||||
throw new Exception($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}");
|
Console.WriteLine($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}");
|
||||||
|
LibTaosWS.WSFreeResult(wsRes);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get meta data
|
// get meta data
|
||||||
|
@ -58,6 +61,8 @@ namespace Examples
|
||||||
|
|
||||||
// close connection.
|
// close connection.
|
||||||
LibTaosWS.WSClose(wsConn);
|
LibTaosWS.WSClose(wsConn);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Examples
|
||||||
{
|
{
|
||||||
public class WSStmtExample
|
public class WSStmtExample
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
const string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
const string DSN = "ws://root:taosdata@127.0.0.1:6041/test";
|
||||||
const string table = "meters";
|
const string table = "meters";
|
||||||
|
@ -21,7 +21,8 @@ namespace Examples
|
||||||
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN);
|
||||||
if (wsConn == IntPtr.Zero)
|
if (wsConn == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception($"get WS connection failed");
|
Console.WriteLine($"get WS connection failed");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -66,18 +67,20 @@ namespace Examples
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception("Init STMT failed...");
|
Console.WriteLine("Init STMT failed...");
|
||||||
}
|
}
|
||||||
|
|
||||||
// close connection.
|
// close connection.
|
||||||
LibTaosWS.WSClose(wsConn);
|
LibTaosWS.WSClose(wsConn);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ValidStmtStep(int code, IntPtr wsStmt, string desc)
|
static void ValidStmtStep(int code, IntPtr wsStmt, string desc)
|
||||||
{
|
{
|
||||||
if (code != 0)
|
if (code != 0)
|
||||||
{
|
{
|
||||||
throw new Exception($"{desc} failed,reason: {LibTaosWS.WSErrorStr(wsStmt)}, code: {code}");
|
Console.WriteLine($"{desc} failed,reason: {LibTaosWS.WSErrorStr(wsStmt)}, code: {code}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,10 +59,10 @@ TDengine 版本更新往往会增加新的功能特性,列表中的连接器
|
||||||
| ------------------------------ | -------- | ---------- | -------- | -------- | ----------- | -------- |
|
| ------------------------------ | -------- | ---------- | -------- | -------- | ----------- | -------- |
|
||||||
| **连接管理** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 |
|
| **连接管理** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 |
|
||||||
| **普通查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 |
|
| **普通查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 |
|
||||||
| **参数绑定** | 暂不支持 | 暂不支持 | 暂不支持 | 支持 | 暂不支持 | 支持 |
|
| **参数绑定** | 暂不支持 | 暂不支持 | 支持 | 支持 | 暂不支持 | 支持 |
|
||||||
| **数据订阅(TMQ)** | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 支持 |
|
| **数据订阅(TMQ)** | 暂不支持 | 暂不支持 | 支持 | 暂不支持 | 暂不支持 | 支持 |
|
||||||
| **Schemaless** | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 |
|
| **Schemaless** | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 |
|
||||||
| **批量拉取(基于 WebSocket)** | 支持 | 支持 | 暂不支持 | 支持 | 暂不支持 | 支持 |
|
| **批量拉取(基于 WebSocket)** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 |
|
||||||
| **DataFrame** | 不支持 | 支持 | 不支持 | 不支持 | 不支持 | 不支持 |
|
| **DataFrame** | 不支持 | 支持 | 不支持 | 不支持 | 不支持 | 不支持 |
|
||||||
|
|
||||||
:::warning
|
:::warning
|
||||||
|
|
|
@ -533,7 +533,12 @@ TIMEDIFF(expr1, expr2 [, time_unit])
|
||||||
#### TIMETRUNCATE
|
#### TIMETRUNCATE
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
TIMETRUNCATE(expr, time_unit)
|
TIMETRUNCATE(expr, time_unit [, ignore_timezone])
|
||||||
|
|
||||||
|
ignore_timezone: {
|
||||||
|
0
|
||||||
|
| 1
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**功能说明**:将时间戳按照指定时间单位 time_unit 进行截断。
|
**功能说明**:将时间戳按照指定时间单位 time_unit 进行截断。
|
||||||
|
@ -549,6 +554,11 @@ TIMETRUNCATE(expr, time_unit)
|
||||||
1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。
|
1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。
|
||||||
- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。
|
- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。
|
||||||
- 输入包含不符合时间日期格式的字符串则返回 NULL。
|
- 输入包含不符合时间日期格式的字符串则返回 NULL。
|
||||||
|
- 当使用 1d 作为时间单位对时间戳进行截断时, 可通过设置 ignore_timezone 参数指定返回结果的显示是否忽略客户端时区的影响。
|
||||||
|
例如客户端所配置时区为 UTC+0800, 则 TIMETRUNCATE('2020-01-01 23:00:00', 1d, 0) 返回结果为 '2020-01-01 08:00:00'。
|
||||||
|
而使用 TIMETRUNCATE('2020-01-01 23:00:00', 1d, 1) 设置忽略时区时,返回结果为 '2020-01-01 00:00:00'
|
||||||
|
ignore_timezone 如果忽略的话,则默认值为 1 。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### TIMEZONE
|
#### TIMEZONE
|
||||||
|
|
|
@ -149,7 +149,7 @@ DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char
|
||||||
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
||||||
DLL_EXPORT void taos_close(TAOS *taos);
|
DLL_EXPORT void taos_close(TAOS *taos);
|
||||||
|
|
||||||
const char *taos_data_type(int type);
|
DLL_EXPORT const char *taos_data_type(int type);
|
||||||
|
|
||||||
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
|
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
|
||||||
DLL_EXPORT TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid);
|
DLL_EXPORT TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid);
|
||||||
|
@ -185,6 +185,7 @@ DLL_EXPORT void taos_kill_query(TAOS *taos);
|
||||||
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||||
|
DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res);
|
||||||
|
|
||||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||||
|
|
|
@ -64,6 +64,11 @@ extern int32_t tsNumOfSnodeStreamThreads;
|
||||||
extern int32_t tsNumOfSnodeWriteThreads;
|
extern int32_t tsNumOfSnodeWriteThreads;
|
||||||
extern int64_t tsRpcQueueMemoryAllowed;
|
extern int64_t tsRpcQueueMemoryAllowed;
|
||||||
|
|
||||||
|
// sync raft
|
||||||
|
extern int32_t tsElectInterval;
|
||||||
|
extern int32_t tsHeartbeatInterval;
|
||||||
|
extern int32_t tsHeartbeatTimeout;
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
extern bool tsEnableMonitor;
|
extern bool tsEnableMonitor;
|
||||||
extern int32_t tsMonitorInterval;
|
extern int32_t tsMonitorInterval;
|
||||||
|
@ -146,7 +151,7 @@ extern int32_t tsUptimeInterval;
|
||||||
extern int32_t tsRpcRetryLimit;
|
extern int32_t tsRpcRetryLimit;
|
||||||
extern int32_t tsRpcRetryInterval;
|
extern int32_t tsRpcRetryInterval;
|
||||||
|
|
||||||
//#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
||||||
|
|
|
@ -66,6 +66,15 @@ extern int32_t tMsgDict[];
|
||||||
|
|
||||||
typedef uint16_t tmsg_t;
|
typedef uint16_t tmsg_t;
|
||||||
|
|
||||||
|
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
||||||
|
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
||||||
|
(type == TDMT_VND_UPDATE_TAG_VAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool syncUtilUserCommit(tmsg_t msgType) {
|
||||||
|
return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------ OTHER DEFINITIONS ------------------------ */
|
/* ------------------------ OTHER DEFINITIONS ------------------------ */
|
||||||
// IE type
|
// IE type
|
||||||
#define TSDB_IE_TYPE_SEC 1
|
#define TSDB_IE_TYPE_SEC 1
|
||||||
|
@ -500,6 +509,8 @@ typedef struct {
|
||||||
char* pComment;
|
char* pComment;
|
||||||
char* pAst1;
|
char* pAst1;
|
||||||
char* pAst2;
|
char* pAst2;
|
||||||
|
int64_t deleteMark1;
|
||||||
|
int64_t deleteMark2;
|
||||||
} SMCreateStbReq;
|
} SMCreateStbReq;
|
||||||
|
|
||||||
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
||||||
|
@ -1403,8 +1414,8 @@ typedef struct {
|
||||||
int8_t streamBlockType;
|
int8_t streamBlockType;
|
||||||
int32_t compLen;
|
int32_t compLen;
|
||||||
int32_t numOfBlocks;
|
int32_t numOfBlocks;
|
||||||
int32_t numOfRows;
|
int64_t numOfRows; // from int32_t change to int64_t
|
||||||
int32_t numOfCols;
|
int64_t numOfCols;
|
||||||
int64_t skey;
|
int64_t skey;
|
||||||
int64_t ekey;
|
int64_t ekey;
|
||||||
int64_t version; // for stream
|
int64_t version; // for stream
|
||||||
|
@ -2013,6 +2024,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t maxdelay[2];
|
int64_t maxdelay[2];
|
||||||
int64_t watermark[2];
|
int64_t watermark[2];
|
||||||
|
int64_t deleteMark[2];
|
||||||
int32_t qmsgLen[2];
|
int32_t qmsgLen[2];
|
||||||
char* qmsg[2]; // pAst:qmsg:SRetention => trigger aggr task1/2
|
char* qmsg[2]; // pAst:qmsg:SRetention => trigger aggr task1/2
|
||||||
} SRSmaParam;
|
} SRSmaParam;
|
||||||
|
@ -2734,6 +2746,7 @@ typedef struct {
|
||||||
char* tagsFilter;
|
char* tagsFilter;
|
||||||
char* sql;
|
char* sql;
|
||||||
char* ast;
|
char* ast;
|
||||||
|
int64_t deleteMark;
|
||||||
} SMCreateSmaReq;
|
} SMCreateSmaReq;
|
||||||
|
|
||||||
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
||||||
|
|
|
@ -147,195 +147,196 @@
|
||||||
#define TK_ROLLUP 129
|
#define TK_ROLLUP 129
|
||||||
#define TK_TTL 130
|
#define TK_TTL 130
|
||||||
#define TK_SMA 131
|
#define TK_SMA 131
|
||||||
#define TK_FIRST 132
|
#define TK_DELETE_MARK 132
|
||||||
#define TK_LAST 133
|
#define TK_FIRST 133
|
||||||
#define TK_SHOW 134
|
#define TK_LAST 134
|
||||||
#define TK_PRIVILEGES 135
|
#define TK_SHOW 135
|
||||||
#define TK_DATABASES 136
|
#define TK_PRIVILEGES 136
|
||||||
#define TK_TABLES 137
|
#define TK_DATABASES 137
|
||||||
#define TK_STABLES 138
|
#define TK_TABLES 138
|
||||||
#define TK_MNODES 139
|
#define TK_STABLES 139
|
||||||
#define TK_QNODES 140
|
#define TK_MNODES 140
|
||||||
#define TK_FUNCTIONS 141
|
#define TK_QNODES 141
|
||||||
#define TK_INDEXES 142
|
#define TK_FUNCTIONS 142
|
||||||
#define TK_ACCOUNTS 143
|
#define TK_INDEXES 143
|
||||||
#define TK_APPS 144
|
#define TK_ACCOUNTS 144
|
||||||
#define TK_CONNECTIONS 145
|
#define TK_APPS 145
|
||||||
#define TK_LICENCES 146
|
#define TK_CONNECTIONS 146
|
||||||
#define TK_GRANTS 147
|
#define TK_LICENCES 147
|
||||||
#define TK_QUERIES 148
|
#define TK_GRANTS 148
|
||||||
#define TK_SCORES 149
|
#define TK_QUERIES 149
|
||||||
#define TK_TOPICS 150
|
#define TK_SCORES 150
|
||||||
#define TK_VARIABLES 151
|
#define TK_TOPICS 151
|
||||||
#define TK_CLUSTER 152
|
#define TK_VARIABLES 152
|
||||||
#define TK_BNODES 153
|
#define TK_CLUSTER 153
|
||||||
#define TK_SNODES 154
|
#define TK_BNODES 154
|
||||||
#define TK_TRANSACTIONS 155
|
#define TK_SNODES 155
|
||||||
#define TK_DISTRIBUTED 156
|
#define TK_TRANSACTIONS 156
|
||||||
#define TK_CONSUMERS 157
|
#define TK_DISTRIBUTED 157
|
||||||
#define TK_SUBSCRIPTIONS 158
|
#define TK_CONSUMERS 158
|
||||||
#define TK_VNODES 159
|
#define TK_SUBSCRIPTIONS 159
|
||||||
#define TK_LIKE 160
|
#define TK_VNODES 160
|
||||||
#define TK_TBNAME 161
|
#define TK_LIKE 161
|
||||||
#define TK_QTAGS 162
|
#define TK_TBNAME 162
|
||||||
#define TK_AS 163
|
#define TK_QTAGS 163
|
||||||
#define TK_INDEX 164
|
#define TK_AS 164
|
||||||
#define TK_FUNCTION 165
|
#define TK_INDEX 165
|
||||||
#define TK_INTERVAL 166
|
#define TK_FUNCTION 166
|
||||||
#define TK_TOPIC 167
|
#define TK_INTERVAL 167
|
||||||
#define TK_WITH 168
|
#define TK_TOPIC 168
|
||||||
#define TK_META 169
|
#define TK_WITH 169
|
||||||
#define TK_CONSUMER 170
|
#define TK_META 170
|
||||||
#define TK_GROUP 171
|
#define TK_CONSUMER 171
|
||||||
#define TK_DESC 172
|
#define TK_GROUP 172
|
||||||
#define TK_DESCRIBE 173
|
#define TK_DESC 173
|
||||||
#define TK_RESET 174
|
#define TK_DESCRIBE 174
|
||||||
#define TK_QUERY 175
|
#define TK_RESET 175
|
||||||
#define TK_CACHE 176
|
#define TK_QUERY 176
|
||||||
#define TK_EXPLAIN 177
|
#define TK_CACHE 177
|
||||||
#define TK_ANALYZE 178
|
#define TK_EXPLAIN 178
|
||||||
#define TK_VERBOSE 179
|
#define TK_ANALYZE 179
|
||||||
#define TK_NK_BOOL 180
|
#define TK_VERBOSE 180
|
||||||
#define TK_RATIO 181
|
#define TK_NK_BOOL 181
|
||||||
#define TK_NK_FLOAT 182
|
#define TK_RATIO 182
|
||||||
#define TK_OUTPUTTYPE 183
|
#define TK_NK_FLOAT 183
|
||||||
#define TK_AGGREGATE 184
|
#define TK_OUTPUTTYPE 184
|
||||||
#define TK_BUFSIZE 185
|
#define TK_AGGREGATE 185
|
||||||
#define TK_STREAM 186
|
#define TK_BUFSIZE 186
|
||||||
#define TK_INTO 187
|
#define TK_STREAM 187
|
||||||
#define TK_TRIGGER 188
|
#define TK_INTO 188
|
||||||
#define TK_AT_ONCE 189
|
#define TK_TRIGGER 189
|
||||||
#define TK_WINDOW_CLOSE 190
|
#define TK_AT_ONCE 190
|
||||||
#define TK_IGNORE 191
|
#define TK_WINDOW_CLOSE 191
|
||||||
#define TK_EXPIRED 192
|
#define TK_IGNORE 192
|
||||||
#define TK_FILL_HISTORY 193
|
#define TK_EXPIRED 193
|
||||||
#define TK_SUBTABLE 194
|
#define TK_FILL_HISTORY 194
|
||||||
#define TK_KILL 195
|
#define TK_SUBTABLE 195
|
||||||
#define TK_CONNECTION 196
|
#define TK_KILL 196
|
||||||
#define TK_TRANSACTION 197
|
#define TK_CONNECTION 197
|
||||||
#define TK_BALANCE 198
|
#define TK_TRANSACTION 198
|
||||||
#define TK_VGROUP 199
|
#define TK_BALANCE 199
|
||||||
#define TK_MERGE 200
|
#define TK_VGROUP 200
|
||||||
#define TK_REDISTRIBUTE 201
|
#define TK_MERGE 201
|
||||||
#define TK_SPLIT 202
|
#define TK_REDISTRIBUTE 202
|
||||||
#define TK_DELETE 203
|
#define TK_SPLIT 203
|
||||||
#define TK_INSERT 204
|
#define TK_DELETE 204
|
||||||
#define TK_NULL 205
|
#define TK_INSERT 205
|
||||||
#define TK_NK_QUESTION 206
|
#define TK_NULL 206
|
||||||
#define TK_NK_ARROW 207
|
#define TK_NK_QUESTION 207
|
||||||
#define TK_ROWTS 208
|
#define TK_NK_ARROW 208
|
||||||
#define TK_QSTART 209
|
#define TK_ROWTS 209
|
||||||
#define TK_QEND 210
|
#define TK_QSTART 210
|
||||||
#define TK_QDURATION 211
|
#define TK_QEND 211
|
||||||
#define TK_WSTART 212
|
#define TK_QDURATION 212
|
||||||
#define TK_WEND 213
|
#define TK_WSTART 213
|
||||||
#define TK_WDURATION 214
|
#define TK_WEND 214
|
||||||
#define TK_IROWTS 215
|
#define TK_WDURATION 215
|
||||||
#define TK_CAST 216
|
#define TK_IROWTS 216
|
||||||
#define TK_NOW 217
|
#define TK_CAST 217
|
||||||
#define TK_TODAY 218
|
#define TK_NOW 218
|
||||||
#define TK_TIMEZONE 219
|
#define TK_TODAY 219
|
||||||
#define TK_CLIENT_VERSION 220
|
#define TK_TIMEZONE 220
|
||||||
#define TK_SERVER_VERSION 221
|
#define TK_CLIENT_VERSION 221
|
||||||
#define TK_SERVER_STATUS 222
|
#define TK_SERVER_VERSION 222
|
||||||
#define TK_CURRENT_USER 223
|
#define TK_SERVER_STATUS 223
|
||||||
#define TK_COUNT 224
|
#define TK_CURRENT_USER 224
|
||||||
#define TK_LAST_ROW 225
|
#define TK_COUNT 225
|
||||||
#define TK_CASE 226
|
#define TK_LAST_ROW 226
|
||||||
#define TK_END 227
|
#define TK_CASE 227
|
||||||
#define TK_WHEN 228
|
#define TK_END 228
|
||||||
#define TK_THEN 229
|
#define TK_WHEN 229
|
||||||
#define TK_ELSE 230
|
#define TK_THEN 230
|
||||||
#define TK_BETWEEN 231
|
#define TK_ELSE 231
|
||||||
#define TK_IS 232
|
#define TK_BETWEEN 232
|
||||||
#define TK_NK_LT 233
|
#define TK_IS 233
|
||||||
#define TK_NK_GT 234
|
#define TK_NK_LT 234
|
||||||
#define TK_NK_LE 235
|
#define TK_NK_GT 235
|
||||||
#define TK_NK_GE 236
|
#define TK_NK_LE 236
|
||||||
#define TK_NK_NE 237
|
#define TK_NK_GE 237
|
||||||
#define TK_MATCH 238
|
#define TK_NK_NE 238
|
||||||
#define TK_NMATCH 239
|
#define TK_MATCH 239
|
||||||
#define TK_CONTAINS 240
|
#define TK_NMATCH 240
|
||||||
#define TK_IN 241
|
#define TK_CONTAINS 241
|
||||||
#define TK_JOIN 242
|
#define TK_IN 242
|
||||||
#define TK_INNER 243
|
#define TK_JOIN 243
|
||||||
#define TK_SELECT 244
|
#define TK_INNER 244
|
||||||
#define TK_DISTINCT 245
|
#define TK_SELECT 245
|
||||||
#define TK_WHERE 246
|
#define TK_DISTINCT 246
|
||||||
#define TK_PARTITION 247
|
#define TK_WHERE 247
|
||||||
#define TK_BY 248
|
#define TK_PARTITION 248
|
||||||
#define TK_SESSION 249
|
#define TK_BY 249
|
||||||
#define TK_STATE_WINDOW 250
|
#define TK_SESSION 250
|
||||||
#define TK_SLIDING 251
|
#define TK_STATE_WINDOW 251
|
||||||
#define TK_FILL 252
|
#define TK_SLIDING 252
|
||||||
#define TK_VALUE 253
|
#define TK_FILL 253
|
||||||
#define TK_NONE 254
|
#define TK_VALUE 254
|
||||||
#define TK_PREV 255
|
#define TK_NONE 255
|
||||||
#define TK_LINEAR 256
|
#define TK_PREV 256
|
||||||
#define TK_NEXT 257
|
#define TK_LINEAR 257
|
||||||
#define TK_HAVING 258
|
#define TK_NEXT 258
|
||||||
#define TK_RANGE 259
|
#define TK_HAVING 259
|
||||||
#define TK_EVERY 260
|
#define TK_RANGE 260
|
||||||
#define TK_ORDER 261
|
#define TK_EVERY 261
|
||||||
#define TK_SLIMIT 262
|
#define TK_ORDER 262
|
||||||
#define TK_SOFFSET 263
|
#define TK_SLIMIT 263
|
||||||
#define TK_LIMIT 264
|
#define TK_SOFFSET 264
|
||||||
#define TK_OFFSET 265
|
#define TK_LIMIT 265
|
||||||
#define TK_ASC 266
|
#define TK_OFFSET 266
|
||||||
#define TK_NULLS 267
|
#define TK_ASC 267
|
||||||
#define TK_ABORT 268
|
#define TK_NULLS 268
|
||||||
#define TK_AFTER 269
|
#define TK_ABORT 269
|
||||||
#define TK_ATTACH 270
|
#define TK_AFTER 270
|
||||||
#define TK_BEFORE 271
|
#define TK_ATTACH 271
|
||||||
#define TK_BEGIN 272
|
#define TK_BEFORE 272
|
||||||
#define TK_BITAND 273
|
#define TK_BEGIN 273
|
||||||
#define TK_BITNOT 274
|
#define TK_BITAND 274
|
||||||
#define TK_BITOR 275
|
#define TK_BITNOT 275
|
||||||
#define TK_BLOCKS 276
|
#define TK_BITOR 276
|
||||||
#define TK_CHANGE 277
|
#define TK_BLOCKS 277
|
||||||
#define TK_COMMA 278
|
#define TK_CHANGE 278
|
||||||
#define TK_COMPACT 279
|
#define TK_COMMA 279
|
||||||
#define TK_CONCAT 280
|
#define TK_COMPACT 280
|
||||||
#define TK_CONFLICT 281
|
#define TK_CONCAT 281
|
||||||
#define TK_COPY 282
|
#define TK_CONFLICT 282
|
||||||
#define TK_DEFERRED 283
|
#define TK_COPY 283
|
||||||
#define TK_DELIMITERS 284
|
#define TK_DEFERRED 284
|
||||||
#define TK_DETACH 285
|
#define TK_DELIMITERS 285
|
||||||
#define TK_DIVIDE 286
|
#define TK_DETACH 286
|
||||||
#define TK_DOT 287
|
#define TK_DIVIDE 287
|
||||||
#define TK_EACH 288
|
#define TK_DOT 288
|
||||||
#define TK_FAIL 289
|
#define TK_EACH 289
|
||||||
#define TK_FILE 290
|
#define TK_FAIL 290
|
||||||
#define TK_FOR 291
|
#define TK_FILE 291
|
||||||
#define TK_GLOB 292
|
#define TK_FOR 292
|
||||||
#define TK_ID 293
|
#define TK_GLOB 293
|
||||||
#define TK_IMMEDIATE 294
|
#define TK_ID 294
|
||||||
#define TK_IMPORT 295
|
#define TK_IMMEDIATE 295
|
||||||
#define TK_INITIALLY 296
|
#define TK_IMPORT 296
|
||||||
#define TK_INSTEAD 297
|
#define TK_INITIALLY 297
|
||||||
#define TK_ISNULL 298
|
#define TK_INSTEAD 298
|
||||||
#define TK_KEY 299
|
#define TK_ISNULL 299
|
||||||
#define TK_MODULES 300
|
#define TK_KEY 300
|
||||||
#define TK_NK_BITNOT 301
|
#define TK_MODULES 301
|
||||||
#define TK_NK_SEMI 302
|
#define TK_NK_BITNOT 302
|
||||||
#define TK_NOTNULL 303
|
#define TK_NK_SEMI 303
|
||||||
#define TK_OF 304
|
#define TK_NOTNULL 304
|
||||||
#define TK_PLUS 305
|
#define TK_OF 305
|
||||||
#define TK_PRIVILEGE 306
|
#define TK_PLUS 306
|
||||||
#define TK_RAISE 307
|
#define TK_PRIVILEGE 307
|
||||||
#define TK_REPLACE 308
|
#define TK_RAISE 308
|
||||||
#define TK_RESTRICT 309
|
#define TK_REPLACE 309
|
||||||
#define TK_ROW 310
|
#define TK_RESTRICT 310
|
||||||
#define TK_SEMI 311
|
#define TK_ROW 311
|
||||||
#define TK_STAR 312
|
#define TK_SEMI 312
|
||||||
#define TK_STATEMENT 313
|
#define TK_STAR 313
|
||||||
#define TK_STRING 314
|
#define TK_STATEMENT 314
|
||||||
#define TK_TIMES 315
|
#define TK_STRING 315
|
||||||
#define TK_UPDATE 316
|
#define TK_TIMES 316
|
||||||
#define TK_VALUES 317
|
#define TK_UPDATE 317
|
||||||
#define TK_VARIABLE 318
|
#define TK_VALUES 318
|
||||||
#define TK_VIEW 319
|
#define TK_VARIABLE 319
|
||||||
#define TK_WAL 320
|
#define TK_VIEW 320
|
||||||
|
#define TK_WAL 321
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
|
|
|
@ -211,6 +211,8 @@ int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, const SName* pTableName, STab
|
||||||
|
|
||||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||||
|
|
||||||
|
int32_t catalogGetCachedTableVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, STableMeta** pTableMeta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force refresh DB's local cached vgroup info.
|
* Force refresh DB's local cached vgroup info.
|
||||||
* @param pCtg (input, got with catalogGetHandle)
|
* @param pCtg (input, got with catalogGetHandle)
|
||||||
|
|
|
@ -68,7 +68,7 @@ typedef struct SInputData {
|
||||||
|
|
||||||
typedef struct SOutputData {
|
typedef struct SOutputData {
|
||||||
int32_t numOfBlocks;
|
int32_t numOfBlocks;
|
||||||
int32_t numOfRows;
|
int64_t numOfRows; // int32_t changed to int64_t
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int8_t compressed;
|
int8_t compressed;
|
||||||
char* pData;
|
char* pData;
|
||||||
|
|
|
@ -228,7 +228,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
||||||
newSize = 8;
|
newSize = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (newSize < data->varLenCol.payloadLen + dataLen) {
|
while (newSize < (uint32_t)(data->varLenCol.payloadLen + dataLen)) {
|
||||||
newSize = newSize * UDF_MEMORY_EXP_GROWTH;
|
newSize = newSize * UDF_MEMORY_EXP_GROWTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
||||||
data->varLenCol.payloadLen += dataLen;
|
data->varLenCol.payloadLen += dataLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow + 1) : data->numOfRows;
|
data->numOfRows = ((int32_t)(currentRow + 1) > data->numOfRows) ? (int32_t)(currentRow + 1) : data->numOfRows;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,9 @@ typedef struct STableOptions {
|
||||||
SNodeList* pWatermark;
|
SNodeList* pWatermark;
|
||||||
int64_t watermark1;
|
int64_t watermark1;
|
||||||
int64_t watermark2;
|
int64_t watermark2;
|
||||||
|
SNodeList* pDeleteMark;
|
||||||
|
int64_t deleteMark1;
|
||||||
|
int64_t deleteMark2;
|
||||||
SNodeList* pRollupFuncs;
|
SNodeList* pRollupFuncs;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
SNodeList* pSma;
|
SNodeList* pSma;
|
||||||
|
@ -383,6 +386,7 @@ typedef struct SStreamOptions {
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
SNode* pDelay;
|
SNode* pDelay;
|
||||||
SNode* pWatermark;
|
SNode* pWatermark;
|
||||||
|
SNode* pDeleteMark;
|
||||||
int8_t fillHistory;
|
int8_t fillHistory;
|
||||||
int8_t ignoreExpired;
|
int8_t ignoreExpired;
|
||||||
} SStreamOptions;
|
} SStreamOptions;
|
||||||
|
|
|
@ -234,7 +234,6 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN,
|
|
||||||
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN,
|
QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG,
|
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG,
|
||||||
|
@ -265,7 +264,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT,
|
QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_DELETE,
|
QUERY_NODE_PHYSICAL_PLAN_DELETE,
|
||||||
QUERY_NODE_PHYSICAL_SUBPLAN,
|
QUERY_NODE_PHYSICAL_SUBPLAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN
|
QUERY_NODE_PHYSICAL_PLAN,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN
|
||||||
} ENodeType;
|
} ENodeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -91,6 +91,7 @@ typedef struct SScanLogicNode {
|
||||||
SNode* pTagIndexCond;
|
SNode* pTagIndexCond;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
SArray* pSmaIndexes;
|
SArray* pSmaIndexes;
|
||||||
SNodeList* pGroupTags;
|
SNodeList* pGroupTags;
|
||||||
|
@ -213,6 +214,7 @@ typedef struct SWindowLogicNode {
|
||||||
SNode* pStateExpr;
|
SNode* pStateExpr;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
EWindowAlgorithm windowAlgo;
|
EWindowAlgorithm windowAlgo;
|
||||||
EOrder inputTsOrder;
|
EOrder inputTsOrder;
|
||||||
|
@ -440,6 +442,7 @@ typedef struct SWinodwPhysiNode {
|
||||||
SNode* pTsEnd; // window end timestamp
|
SNode* pTsEnd; // window end timestamp
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
EOrder inputTsOrder;
|
EOrder inputTsOrder;
|
||||||
EOrder outputTsOrder;
|
EOrder outputTsOrder;
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef struct SPlanContext {
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
|
int64_t deleteMark;
|
||||||
int8_t igExpired;
|
int8_t igExpired;
|
||||||
char* pMsg;
|
char* pMsg;
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
|
|
|
@ -129,6 +129,7 @@ typedef struct SDBVgInfo {
|
||||||
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
|
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
|
||||||
int64_t stateTs;
|
int64_t stateTs;
|
||||||
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
||||||
|
SArray* vgArray;
|
||||||
} SDBVgInfo;
|
} SDBVgInfo;
|
||||||
|
|
||||||
typedef struct SUseDbOutput {
|
typedef struct SUseDbOutput {
|
||||||
|
@ -238,6 +239,7 @@ int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t
|
||||||
char* parseTagDatatoJson(void* p);
|
char* parseTagDatatoJson(void* p);
|
||||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||||
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
||||||
|
void freeVgInfo(SDBVgInfo* vgInfo);
|
||||||
|
|
||||||
extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen,
|
extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen,
|
||||||
void* (*mallocFp)(int64_t));
|
void* (*mallocFp)(int64_t));
|
||||||
|
@ -260,24 +262,23 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
||||||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||||
|
|
||||||
#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR || (_code) == TSDB_CODE_VND_STOPPED)
|
#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR || (_code) == TSDB_CODE_VND_STOPPED || (_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
||||||
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) (false) // used later
|
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
|
||||||
|
|
||||||
|
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||||
|
|
||||||
#define NEED_REDIRECT_ERROR(_code) \
|
#define NEED_REDIRECT_ERROR(_code) \
|
||||||
((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||||
(_code) == TSDB_CODE_MNODE_NOT_FOUND || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code))
|
||||||
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \
|
|
||||||
(_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
|
||||||
|
|
||||||
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
||||||
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
||||||
(_type) == TDMT_MND_DROP_STB)
|
(_type) == TDMT_MND_DROP_STB)
|
||||||
|
|
||||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||||
((_code) == TSDB_CODE_MNODE_NOT_FOUND || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
(SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code))
|
||||||
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \
|
|
||||||
(_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
|
||||||
|
|
||||||
#define REQUEST_TOTAL_EXEC_TIMES 2
|
#define REQUEST_TOTAL_EXEC_TIMES 2
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ typedef struct STdbState {
|
||||||
TTB* pFillStateDb; // todo refactor
|
TTB* pFillStateDb; // todo refactor
|
||||||
TTB* pSessionStateDb;
|
TTB* pSessionStateDb;
|
||||||
TTB* pParNameDb;
|
TTB* pParNameDb;
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
} STdbState;
|
} STdbState;
|
||||||
|
|
||||||
// incremental state storage
|
// incremental state storage
|
||||||
|
|
|
@ -620,7 +620,7 @@ typedef struct SStreamMeta {
|
||||||
SHashObj* pTasks;
|
SHashObj* pTasks;
|
||||||
SHashObj* pRecoverStatus;
|
SHashObj* pRecoverStatus;
|
||||||
void* ahandle;
|
void* ahandle;
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
FTaskExpand* expandFunc;
|
FTaskExpand* expandFunc;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
||||||
#include "tlrucache.h"
|
#include "tlrucache.h"
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
|
|
||||||
#define SYNC_RESP_TTL_MS 10000000
|
#define SYNC_RESP_TTL_MS 30000
|
||||||
#define SYNC_SPEED_UP_HB_TIMER 400
|
#define SYNC_SPEED_UP_HB_TIMER 400
|
||||||
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
||||||
#define SYNC_SLOW_DOWN_RANGE 100
|
#define SYNC_SLOW_DOWN_RANGE 100
|
||||||
|
@ -43,10 +43,11 @@ extern "C" {
|
||||||
#define SYNC_MAX_RETRY_BACKOFF 5
|
#define SYNC_MAX_RETRY_BACKOFF 5
|
||||||
#define SYNC_LOG_REPL_RETRY_WAIT_MS 100
|
#define SYNC_LOG_REPL_RETRY_WAIT_MS 100
|
||||||
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
||||||
#define SYNC_HEART_TIMEOUT_MS 1000 * 8
|
#define SYNC_HEART_TIMEOUT_MS 1000 * 15
|
||||||
|
|
||||||
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
||||||
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
||||||
|
#define SYNC_SNAP_RESEND_MS 1000 * 60
|
||||||
|
|
||||||
#define SYNC_MAX_BATCH_SIZE 1
|
#define SYNC_MAX_BATCH_SIZE 1
|
||||||
#define SYNC_INDEX_BEGIN 0
|
#define SYNC_INDEX_BEGIN 0
|
||||||
|
|
|
@ -72,6 +72,7 @@ typedef struct SRpcMsg {
|
||||||
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
||||||
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
||||||
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
||||||
|
typedef bool (*RpcFFfp)(tmsg_t msgType);
|
||||||
typedef void (*RpcDfp)(void *ahandle);
|
typedef void (*RpcDfp)(void *ahandle);
|
||||||
|
|
||||||
typedef struct SRpcInit {
|
typedef struct SRpcInit {
|
||||||
|
@ -90,6 +91,9 @@ typedef struct SRpcInit {
|
||||||
int32_t retryMaxInterval; // retry max interval
|
int32_t retryMaxInterval; // retry max interval
|
||||||
int64_t retryMaxTimouet;
|
int64_t retryMaxTimouet;
|
||||||
|
|
||||||
|
int32_t failFastThreshold;
|
||||||
|
int32_t failFastInterval;
|
||||||
|
|
||||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||||
int8_t encryption; // encrypt or not
|
int8_t encryption; // encrypt or not
|
||||||
|
|
||||||
|
@ -107,6 +111,8 @@ typedef struct SRpcInit {
|
||||||
|
|
||||||
// destroy client ahandle;
|
// destroy client ahandle;
|
||||||
RpcDfp dfp;
|
RpcDfp dfp;
|
||||||
|
// fail fast fp
|
||||||
|
RpcFFfp ffp;
|
||||||
|
|
||||||
void *parent;
|
void *parent;
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
|
@ -107,6 +107,8 @@ typedef struct SWal {
|
||||||
TdFilePtr pIdxFile;
|
TdFilePtr pIdxFile;
|
||||||
int32_t writeCur;
|
int32_t writeCur;
|
||||||
SArray *fileInfoSet; // SArray<SWalFileInfo>
|
SArray *fileInfoSet; // SArray<SWalFileInfo>
|
||||||
|
// gc
|
||||||
|
SArray *toDeleteFiles; // SArray<SWalFileInfo>
|
||||||
// status
|
// status
|
||||||
int64_t totSize;
|
int64_t totSize;
|
||||||
int64_t lastRollSeq;
|
int64_t lastRollSeq;
|
||||||
|
|
|
@ -27,6 +27,7 @@ extern "C" {
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !defined(WINDOWS)
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <execinfo.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -120,12 +120,6 @@ void syslog(int unused, const char *format, ...);
|
||||||
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
||||||
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2))
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
#define ASSERT(x) assert(x)
|
|
||||||
#else
|
|
||||||
#define ASSERT(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UNUSED
|
#ifndef UNUSED
|
||||||
#define UNUSED(x) ((void)(x))
|
#define UNUSED(x) ((void)(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -62,6 +62,7 @@ int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
|
||||||
bool taosIsDir(const char *dirname);
|
bool taosIsDir(const char *dirname);
|
||||||
char *taosDirName(char *dirname);
|
char *taosDirName(char *dirname);
|
||||||
char *taosDirEntryBaseName(char *dirname);
|
char *taosDirEntryBaseName(char *dirname);
|
||||||
|
void taosGetCwd(char *buf, int32_t len);
|
||||||
|
|
||||||
TdDirPtr taosOpenDir(const char *dirname);
|
TdDirPtr taosOpenDir(const char *dirname);
|
||||||
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
||||||
|
|
|
@ -88,6 +88,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
|
||||||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
||||||
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
||||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
||||||
|
int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t offset);
|
||||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
||||||
|
|
||||||
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf);
|
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf);
|
||||||
|
|
|
@ -62,7 +62,7 @@ typedef int32_t TdUcs4;
|
||||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||||
int64_t taosStr2int64(const char *str);
|
int64_t taosStr2int64(const char *str);
|
||||||
|
|
||||||
void taosConvInit(void);
|
int32_t taosConvInit(void);
|
||||||
void taosConvDestroy();
|
void taosConvDestroy();
|
||||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
||||||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||||
|
|
|
@ -46,6 +46,29 @@ void taosSetTerminalMode();
|
||||||
int32_t taosGetOldTerminalMode();
|
int32_t taosGetOldTerminalMode();
|
||||||
void taosResetTerminalMode();
|
void taosResetTerminalMode();
|
||||||
|
|
||||||
|
#if !defined(WINDOWS)
|
||||||
|
#define taosPrintTrace(flags, level, dflag) \
|
||||||
|
{ \
|
||||||
|
void* array[100]; \
|
||||||
|
int32_t size = backtrace(array, 100); \
|
||||||
|
char** strings = backtrace_symbols(array, size); \
|
||||||
|
if (strings != NULL) { \
|
||||||
|
taosPrintLog(flags, level, dflag, "obtained %d stack frames", size); \
|
||||||
|
for (int32_t i = 0; i < size; i++) { \
|
||||||
|
taosPrintLog(flags, level, dflag, "frame:%d, %s", i, strings[i]); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
taosMemoryFree(strings); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define taosPrintTrace(flags, level, dflag) \
|
||||||
|
{ \
|
||||||
|
taosPrintLog(flags, level, dflag, \
|
||||||
|
"backtrace not implemented on windows, so detailed stack information cannot be printed"); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -72,7 +72,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0102)
|
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0102)
|
||||||
// #define TSDB_CODE_COM_INVALID_CFG_MSG TAOS_DEF_ERROR_CODE(0, 0x0103) // 2.x
|
// #define TSDB_CODE_COM_INVALID_CFG_MSG TAOS_DEF_ERROR_CODE(0, 0x0103) // 2.x
|
||||||
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104) //
|
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104) //
|
||||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105) // internal
|
// #define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105) // 2.x
|
||||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106) // internal
|
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106) // internal
|
||||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107) // internal
|
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107) // internal
|
||||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108) // internal
|
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108) // internal
|
||||||
|
@ -163,7 +163,7 @@ int32_t* taosGetErrno();
|
||||||
// #define TSDB_CODE_MND_ACTION_NEED_REPROCESSEDTAOS_DEF_ERROR_CODE(0, 0x0302) // 2.x
|
// #define TSDB_CODE_MND_ACTION_NEED_REPROCESSEDTAOS_DEF_ERROR_CODE(0, 0x0302) // 2.x
|
||||||
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0303)
|
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0303)
|
||||||
// #define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304) // 2.x
|
// #define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304) // 2.x
|
||||||
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0305)
|
// #define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0305) // 2.x
|
||||||
// #define TSDB_CODE_MND_INVALID_MSG_VERSION TAOS_DEF_ERROR_CODE(0, 0x0306) // 2.x
|
// #define TSDB_CODE_MND_INVALID_MSG_VERSION TAOS_DEF_ERROR_CODE(0, 0x0306) // 2.x
|
||||||
// #define TSDB_CODE_MND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0307) // 2.x
|
// #define TSDB_CODE_MND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0307) // 2.x
|
||||||
// #define TSDB_CODE_MND_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0308) // 2.x
|
// #define TSDB_CODE_MND_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0308) // 2.x
|
||||||
|
@ -171,27 +171,28 @@ int32_t* taosGetErrno();
|
||||||
// #define TSDB_CODE_MND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x030A) // 2.x
|
// #define TSDB_CODE_MND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x030A) // 2.x
|
||||||
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x030B)
|
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x030B)
|
||||||
#define TSDB_CODE_MND_INVALID_QUERY_ID TAOS_DEF_ERROR_CODE(0, 0x030C)
|
#define TSDB_CODE_MND_INVALID_QUERY_ID TAOS_DEF_ERROR_CODE(0, 0x030C)
|
||||||
#define TSDB_CODE_MND_INVALID_STREAM_ID TAOS_DEF_ERROR_CODE(0, 0x030D)
|
// #define TSDB_CODE_MND_INVALID_STREAM_ID TAOS_DEF_ERROR_CODE(0, 0x030D) // 2.x
|
||||||
#define TSDB_CODE_MND_INVALID_CONN_ID TAOS_DEF_ERROR_CODE(0, 0x030E)
|
#define TSDB_CODE_MND_INVALID_CONN_ID TAOS_DEF_ERROR_CODE(0, 0x030E)
|
||||||
#define TSDB_CODE_MND_MNODE_IS_RUNNING TAOS_DEF_ERROR_CODE(0, 0x0310)
|
// #define TSDB_CODE_MND_MNODE_IS_RUNNING TAOS_DEF_ERROR_CODE(0, 0x0310) // 2.x
|
||||||
#define TSDB_CODE_MND_FAILED_TO_CONFIG_SYNC TAOS_DEF_ERROR_CODE(0, 0x0311)
|
// #define TSDB_CODE_MND_FAILED_TO_CONFIG_SYNC TAOS_DEF_ERROR_CODE(0, 0x0311) // 2.x
|
||||||
#define TSDB_CODE_MND_FAILED_TO_START_SYNC TAOS_DEF_ERROR_CODE(0, 0x0312)
|
// #define TSDB_CODE_MND_FAILED_TO_START_SYNC TAOS_DEF_ERROR_CODE(0, 0x0312) // 2.x
|
||||||
#define TSDB_CODE_MND_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0313)
|
// #define TSDB_CODE_MND_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0313) // 2.x
|
||||||
#define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314)
|
// #define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314) // 2.x
|
||||||
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0315)
|
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0315)
|
||||||
|
|
||||||
// mnode-sdb
|
// mnode-sdb
|
||||||
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0320)
|
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0320) // internal
|
||||||
// #define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321) // 2.x
|
// #define TSDB_CODE_MND_SDB_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321) // 2.x
|
||||||
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0322)
|
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0322) // internal
|
||||||
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0323)
|
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0323)
|
||||||
#define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0325)
|
// #define TSDB_CODE_MND_SDB_INVAID_META_ROW TAOS_DEF_ERROR_CODE(0, 0x0324) // 2.x
|
||||||
#define TSDB_CODE_SDB_INVALID_ACTION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326)
|
// #define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0325) // 2.x
|
||||||
#define TSDB_CODE_SDB_INVALID_STATUS_TYPE TAOS_DEF_ERROR_CODE(0, 0x0327)
|
#define TSDB_CODE_SDB_INVALID_ACTION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326) // internal
|
||||||
#define TSDB_CODE_SDB_INVALID_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0328)
|
// #define TSDB_CODE_SDB_INVALID_STATUS_TYPE TAOS_DEF_ERROR_CODE(0, 0x0327) // unused
|
||||||
#define TSDB_CODE_SDB_INVALID_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0329)
|
#define TSDB_CODE_SDB_INVALID_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0328) // internal
|
||||||
|
#define TSDB_CODE_SDB_INVALID_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0329) // internal
|
||||||
#define TSDB_CODE_SDB_INVALID_DATA_CONTENT TAOS_DEF_ERROR_CODE(0, 0x032A)
|
#define TSDB_CODE_SDB_INVALID_DATA_CONTENT TAOS_DEF_ERROR_CODE(0, 0x032A)
|
||||||
#define TSDB_CODE_SDB_INVALID_WAl_VER TAOS_DEF_ERROR_CODE(0, 0x032B)
|
// #define TSDB_CODE_SDB_INVALID_WAl_VER TAOS_DEF_ERROR_CODE(0, 0x032B) // unused
|
||||||
#define TSDB_CODE_SDB_OBJ_CREATING TAOS_DEF_ERROR_CODE(0, 0x032C)
|
#define TSDB_CODE_SDB_OBJ_CREATING TAOS_DEF_ERROR_CODE(0, 0x032C)
|
||||||
#define TSDB_CODE_SDB_OBJ_DROPPING TAOS_DEF_ERROR_CODE(0, 0x032D)
|
#define TSDB_CODE_SDB_OBJ_DROPPING TAOS_DEF_ERROR_CODE(0, 0x032D)
|
||||||
|
|
||||||
|
@ -398,6 +399,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527)
|
#define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527)
|
||||||
#define TSDB_CODE_VND_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528)
|
#define TSDB_CODE_VND_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528)
|
||||||
#define TSDB_CODE_VND_STOPPED TAOS_DEF_ERROR_CODE(0, 0x0529)
|
#define TSDB_CODE_VND_STOPPED TAOS_DEF_ERROR_CODE(0, 0x0529)
|
||||||
|
#define TSDB_CODE_VND_DUP_REQUEST TAOS_DEF_ERROR_CODE(0, 0x0530)
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||||
|
@ -511,7 +513,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
||||||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
||||||
#define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03)
|
#define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03)
|
||||||
#define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04)
|
// #define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04)
|
||||||
// #define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
// #define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
||||||
#define TSDB_CODE_TQ_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0A06)
|
#define TSDB_CODE_TQ_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0A06)
|
||||||
#define TSDB_CODE_TQ_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0A07)
|
#define TSDB_CODE_TQ_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0A07)
|
||||||
|
@ -697,7 +699,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
|
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
|
||||||
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
|
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
|
||||||
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
|
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
|
||||||
#define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153)
|
// #define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153)
|
||||||
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
|
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
|
||||||
#define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155)
|
#define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155)
|
||||||
#define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156)
|
#define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define _TD_UTIL_CODING_H_
|
#define _TD_UTIL_CODING_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -309,6 +309,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440)
|
#define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440)
|
||||||
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
||||||
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
||||||
|
#define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved.
|
||||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||||
#define TSDB_MIN_MINROWS_FBLOCK 10
|
#define TSDB_MIN_MINROWS_FBLOCK 10
|
||||||
#define TSDB_MAX_MINROWS_FBLOCK 1000
|
#define TSDB_MAX_MINROWS_FBLOCK 1000
|
||||||
|
@ -386,6 +387,9 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond
|
#define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond
|
||||||
#define TSDB_MAX_ROLLUP_WATERMARK (15 * 60 * 1000)
|
#define TSDB_MAX_ROLLUP_WATERMARK (15 * 60 * 1000)
|
||||||
#define TSDB_DEFAULT_ROLLUP_WATERMARK 5000
|
#define TSDB_DEFAULT_ROLLUP_WATERMARK 5000
|
||||||
|
#define TSDB_MIN_ROLLUP_DELETE_MARK 0 // unit millisecond
|
||||||
|
#define TSDB_MAX_ROLLUP_DELETE_MARK INT64_MAX
|
||||||
|
#define TSDB_DEFAULT_ROLLUP_DELETE_MARK 900000 // 900s
|
||||||
#define TSDB_MIN_TABLE_TTL 0
|
#define TSDB_MIN_TABLE_TTL 0
|
||||||
#define TSDB_DEFAULT_TABLE_TTL 0
|
#define TSDB_DEFAULT_TABLE_TTL 0
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef void (*LogFp)(int64_t ts, ELogLevel level, const char *content);
|
||||||
|
|
||||||
extern bool tsLogEmbedded;
|
extern bool tsLogEmbedded;
|
||||||
extern bool tsAsyncLog;
|
extern bool tsAsyncLog;
|
||||||
|
extern bool tsAssert;
|
||||||
extern int32_t tsNumOfLogLines;
|
extern int32_t tsNumOfLogLines;
|
||||||
extern int32_t tsLogKeepDays;
|
extern int32_t tsLogKeepDays;
|
||||||
extern LogFp tsLogFp;
|
extern LogFp tsLogFp;
|
||||||
|
@ -82,6 +83,10 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...);
|
||||||
|
#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
|
@ -497,27 +497,27 @@ function install_service_on_systemd() {
|
||||||
|
|
||||||
taosd_service_config="${service_config_dir}/${serverName}.service"
|
taosd_service_config="${service_config_dir}/${serverName}.service"
|
||||||
|
|
||||||
${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}"
|
${csudo}bash -c "echo [Unit] >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Description=${productName} server service' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Description=${productName} server service >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'After=network-online.target' >> ${taosd_service_config}"
|
${csudo}bash -c "echo After=network-online.target >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Wants=network-online.target >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo >> ${taosd_service_config}"
|
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}"
|
${csudo}bash -c "echo [Service] >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Type=simple >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'ExecStart=/usr/bin/${serverName}' >> ${taosd_service_config}"
|
${csudo}bash -c "echo ExecStart=/usr/bin/${serverName} >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'ExecStartPre=${installDir}/bin/startPre.sh' >> ${taosd_service_config}"
|
${csudo}bash -c "echo ExecStartPre=${installDir}/bin/startPre.sh >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}"
|
${csudo}bash -c "echo TimeoutStopSec=1000000s >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}"
|
${csudo}bash -c "echo LimitNOFILE=infinity >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}"
|
${csudo}bash -c "echo LimitNPROC=infinity >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}"
|
${csudo}bash -c "echo LimitCORE=infinity >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}"
|
${csudo}bash -c "echo TimeoutStartSec=0 >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}"
|
${csudo}bash -c "echo StandardOutput=null >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}"
|
${csudo}bash -c "echo Restart=always >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}"
|
${csudo}bash -c "echo StartLimitBurst=3 >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}"
|
${csudo}bash -c "echo StartLimitInterval=60s >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo >> ${taosd_service_config}"
|
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}"
|
${csudo}bash -c "echo [Install] >> ${taosd_service_config}"
|
||||||
${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
|
${csudo}bash -c "echo WantedBy=multi-user.target >> ${taosd_service_config}"
|
||||||
${csudo}systemctl enable ${serverName}
|
${csudo}systemctl enable ${serverName}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,9 +171,9 @@ typedef struct SReqResultInfo {
|
||||||
char** convertBuf;
|
char** convertBuf;
|
||||||
TAOS_ROW row;
|
TAOS_ROW row;
|
||||||
SResultColumn* pCol;
|
SResultColumn* pCol;
|
||||||
uint32_t numOfRows;
|
uint64_t numOfRows; // from int32_t change to int64_t
|
||||||
uint64_t totalRows;
|
uint64_t totalRows;
|
||||||
uint32_t current;
|
uint64_t current;
|
||||||
bool localResultFetched;
|
bool localResultFetched;
|
||||||
bool completed;
|
bool completed;
|
||||||
int32_t precision;
|
int32_t precision;
|
||||||
|
|
|
@ -231,10 +231,9 @@ void destroyTscObj(void *pObj) {
|
||||||
tscDebug("connObj 0x%" PRIx64 " p:%p destroyed, remain inst totalConn:%" PRId64, pTscObj->id, pTscObj,
|
tscDebug("connObj 0x%" PRIx64 " p:%p destroyed, remain inst totalConn:%" PRId64, pTscObj->id, pTscObj,
|
||||||
pTscObj->pAppInfo->numOfConns);
|
pTscObj->pAppInfo->numOfConns);
|
||||||
|
|
||||||
int64_t connNum = atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
// In any cases, we should not free app inst here. Or an race condition rises.
|
||||||
if (0 == connNum) {
|
/*int64_t connNum = */atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||||
destroyAppInst(pTscObj->pAppInfo);
|
|
||||||
}
|
|
||||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||||
taosMemoryFree(pTscObj);
|
taosMemoryFree(pTscObj);
|
||||||
|
|
||||||
|
@ -397,8 +396,8 @@ void taos_init_imp(void) {
|
||||||
deltaToUtcInitOnce();
|
deltaToUtcInitOnce();
|
||||||
|
|
||||||
if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||||
tscInitRes = -1;
|
// ignore create log failed, only print
|
||||||
return;
|
printf(" WARING: Create taoslog failed. configDir=%s\n", configDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||||
|
@ -408,7 +407,9 @@ void taos_init_imp(void) {
|
||||||
|
|
||||||
initQueryModuleMsgHandle();
|
initQueryModuleMsgHandle();
|
||||||
|
|
||||||
taosConvInit();
|
if (taosConvInit() != 0) {
|
||||||
|
ASSERTS(0, "failed to init conv");
|
||||||
|
}
|
||||||
|
|
||||||
rpcInit();
|
rpcInit();
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
} else {
|
} else {
|
||||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||||
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
}
|
}
|
||||||
|
@ -1527,7 +1527,7 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||||
pRequest->self, pResInfo->numOfRows, pResInfo->totalRows, pResInfo->completed, pRequest->requestId);
|
pRequest->self, pResInfo->numOfRows, pResInfo->totalRows, pResInfo->completed, pRequest->requestId);
|
||||||
|
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
|
@ -1941,7 +1941,7 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
|
||||||
|
|
||||||
pResultInfo->pRspMsg = (const char*)pRsp;
|
pResultInfo->pRspMsg = (const char*)pRsp;
|
||||||
pResultInfo->pData = (void*)pRsp->data;
|
pResultInfo->pData = (void*)pRsp->data;
|
||||||
pResultInfo->numOfRows = htonl(pRsp->numOfRows);
|
pResultInfo->numOfRows = htobe64(pRsp->numOfRows);
|
||||||
pResultInfo->current = 0;
|
pResultInfo->current = 0;
|
||||||
pResultInfo->completed = (pRsp->completed == 1);
|
pResultInfo->completed = (pRsp->completed == 1);
|
||||||
pResultInfo->payloadLen = htonl(pRsp->compLen);
|
pResultInfo->payloadLen = htonl(pRsp->compLen);
|
||||||
|
|
|
@ -136,7 +136,7 @@ int32_t check_for_params(jobject jobj, jlong conn, jlong res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((TAOS_RES *)res == NULL) {
|
if ((TAOS_RES *)res == NULL) {
|
||||||
jniError("jobj:%p, conn:%p, res is null", jobj, (TAOS *)conn);
|
jniError("jobj:%p, conn:%p, param res is null", jobj, (TAOS *)conn);
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,9 +393,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_free_result((void *)res);
|
|
||||||
jniDebug("jobj:%p, conn:%p, free resultset:%p", jobj, (TAOS *)con, (void *)res);
|
jniDebug("jobj:%p, conn:%p, free resultset:%p", jobj, (TAOS *)con, (void *)res);
|
||||||
|
taos_free_result((void *)res);
|
||||||
return JNI_SUCCESS;
|
return JNI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +488,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
||||||
numOfFields);
|
numOfFields);
|
||||||
return JNI_FETCH_END;
|
return JNI_FETCH_END;
|
||||||
} else {
|
} else {
|
||||||
jniDebug("jobj:%p, conn:%p, interrupted query", jobj, tscon);
|
jniDebug("jobj:%p, conn:%p, interrupted query. fetch row error code: %d, msg:%s", jobj, tscon, code, taos_errstr(result));
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,7 +583,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI
|
||||||
jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res);
|
jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res);
|
||||||
return JNI_FETCH_END;
|
return JNI_FETCH_END;
|
||||||
} else {
|
} else {
|
||||||
jniError("jobj:%p, conn:%p, query interrupted", jobj, tscon);
|
jniError("jobj:%p, conn:%p, query interrupted. fetch block error code:%d, msg:%s", jobj, tscon, error_code, taos_errstr(tres));
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "tdatablock.h"
|
|
||||||
|
|
||||||
#define TSC_VAR_NOT_RELEASE 1
|
#define TSC_VAR_NOT_RELEASE 1
|
||||||
#define TSC_VAR_RELEASED 0
|
#define TSC_VAR_RELEASED 0
|
||||||
|
@ -178,6 +178,8 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tscDebug("taos free res %p", res);
|
||||||
|
|
||||||
if (TD_RES_QUERY(res)) {
|
if (TD_RES_QUERY(res)) {
|
||||||
SRequestObj *pRequest = (SRequestObj *)res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId);
|
tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId);
|
||||||
|
@ -435,11 +437,23 @@ const char *taos_data_type(int type) {
|
||||||
|
|
||||||
const char *taos_get_client_info() { return version; }
|
const char *taos_get_client_info() { return version; }
|
||||||
|
|
||||||
|
// return int32_t
|
||||||
int taos_affected_rows(TAOS_RES *res) {
|
int taos_affected_rows(TAOS_RES *res) {
|
||||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
|
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||||
|
return (int)pResInfo->numOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return int64_t
|
||||||
|
int64_t taos_affected_rows64(TAOS_RES *res) {
|
||||||
|
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = (SRequestObj *)res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||||
return pResInfo->numOfRows;
|
return pResInfo->numOfRows;
|
||||||
|
@ -784,9 +798,11 @@ static void doAsyncQueryFromParse(SMetaData *pResultMeta, void *param, int32_t c
|
||||||
SQuery *pQuery = pRequest->pQuery;
|
SQuery *pQuery = pRequest->pQuery;
|
||||||
|
|
||||||
pRequest->metric.ctgEnd = taosGetTimestampUs();
|
pRequest->metric.ctgEnd = taosGetTimestampUs();
|
||||||
qDebug("0x%" PRIx64 " start to continue parse, reqId:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
qDebug("0x%" PRIx64 " start to continue parse, reqId:0x%" PRIx64 ", code:%s", pRequest->self, pRequest->requestId,
|
||||||
|
tstrerror(code));
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
//pWrapper->pCatalogReq->forceUpdate = false;
|
||||||
code = qContinueParseSql(pWrapper->pParseCtx, pWrapper->pCatalogReq, pResultMeta, pQuery);
|
code = qContinueParseSql(pWrapper->pParseCtx, pWrapper->pCatalogReq, pResultMeta, pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -867,6 +883,11 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
||||||
|
|
||||||
if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) {
|
if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) {
|
||||||
code = pRequest->prevCode;
|
code = pRequest->prevCode;
|
||||||
|
terrno = code;
|
||||||
|
pRequest->code = code;
|
||||||
|
tscDebug("call sync query cb with code: %s", tstrerror(code));
|
||||||
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -917,6 +938,17 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
||||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
destorySqlCallbackWrapper(pWrapper);
|
destorySqlCallbackWrapper(pWrapper);
|
||||||
|
qDestroyQuery(pRequest->pQuery);
|
||||||
|
pRequest->pQuery = NULL;
|
||||||
|
|
||||||
|
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||||
|
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||||
|
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||||
|
pRequest->prevCode = code;
|
||||||
|
doAsyncQuery(pRequest, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
terrno = code;
|
terrno = code;
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
|
@ -956,7 +988,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
|
||||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
} else {
|
} else {
|
||||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||||
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
|
|
||||||
|
|
|
@ -450,7 +450,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||||
(*pRsp)->precision = 0;
|
(*pRsp)->precision = 0;
|
||||||
(*pRsp)->compressed = 0;
|
(*pRsp)->compressed = 0;
|
||||||
(*pRsp)->compLen = 0;
|
(*pRsp)->compLen = 0;
|
||||||
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
(*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
||||||
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
||||||
|
|
||||||
int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS);
|
int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS);
|
||||||
|
|
|
@ -875,6 +875,7 @@ void tmqFreeImpl(void* handle) {
|
||||||
tmq_t* tmq = (tmq_t*)handle;
|
tmq_t* tmq = (tmq_t*)handle;
|
||||||
|
|
||||||
// TODO stop timer
|
// TODO stop timer
|
||||||
|
tmqClearUnhandleMsg(tmq);
|
||||||
if (tmq->mqueue) taosCloseQueue(tmq->mqueue);
|
if (tmq->mqueue) taosCloseQueue(tmq->mqueue);
|
||||||
if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask);
|
if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask);
|
||||||
if (tmq->qall) taosFreeQall(tmq->qall);
|
if (tmq->qall) taosFreeQall(tmq->qall);
|
||||||
|
@ -884,8 +885,7 @@ void tmqFreeImpl(void* handle) {
|
||||||
int32_t sz = taosArrayGetSize(tmq->clientTopics);
|
int32_t sz = taosArrayGetSize(tmq->clientTopics);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
taosMemoryFreeClear(pTopic->schema.pSchema);
|
||||||
int32_t vgSz = taosArrayGetSize(pTopic->vgs);
|
|
||||||
taosArrayDestroy(pTopic->vgs);
|
taosArrayDestroy(pTopic->vgs);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(tmq->clientTopics);
|
taosArrayDestroy(tmq->clientTopics);
|
||||||
|
@ -1215,6 +1215,8 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
|
|
||||||
|
tscDebug("consumer:%" PRId64 ", put poll res into mqueue %p", tmq->consumerId, pRspWrapper);
|
||||||
|
|
||||||
taosWriteQitem(tmq->mqueue, pRspWrapper);
|
taosWriteQitem(tmq->mqueue, pRspWrapper);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
|
|
||||||
|
@ -1304,7 +1306,6 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) {
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
|
||||||
int32_t vgSz = taosArrayGetSize(pTopic->vgs);
|
|
||||||
taosArrayDestroy(pTopic->vgs);
|
taosArrayDestroy(pTopic->vgs);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(tmq->clientTopics);
|
taosArrayDestroy(tmq->clientTopics);
|
||||||
|
@ -1410,7 +1411,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void* pReq = taosMemoryCalloc(1, tlen);
|
void* pReq = taosMemoryCalloc(1, tlen);
|
||||||
if (tlen < 0) {
|
if (pReq == NULL) {
|
||||||
tscError("failed to malloc askEpReq msg, size:%d", tlen);
|
tscError("failed to malloc askEpReq msg, size:%d", tlen);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1665,6 +1666,8 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tscDebug("consumer:%" PRId64 " handle rsp %p", tmq->consumerId, rspWrapper);
|
||||||
|
|
||||||
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) {
|
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) {
|
||||||
taosFreeQitem(rspWrapper);
|
taosFreeQitem(rspWrapper);
|
||||||
terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
||||||
|
@ -1738,7 +1741,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
return pRsp;
|
return pRsp;
|
||||||
} else {
|
} else {
|
||||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n",
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||||
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp(
|
||||||
jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res);
|
jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res);
|
||||||
return JNI_FETCH_END;
|
return JNI_FETCH_END;
|
||||||
} else {
|
} else {
|
||||||
jniError("jobj:%p, conn:%p, query interrupted", jobj, tscon);
|
jniError("jobj:%p, conn:%p, query interrupted, tmq fetch block error code:%d, msg:%s", jobj, tscon, error_code, taos_errstr(tres));
|
||||||
return JNI_RESULT_SET_NULL;
|
return JNI_RESULT_SET_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define MALLOC_ALIGN_BYTES 32
|
#define MALLOC_ALIGN_BYTES 256
|
||||||
|
|
||||||
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
||||||
ASSERT(pColumnInfoData != NULL);
|
ASSERT(pColumnInfoData != NULL);
|
||||||
|
@ -1191,7 +1191,6 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
||||||
int32_t oldLen = BitmapLen(existedRows);
|
int32_t oldLen = BitmapLen(existedRows);
|
||||||
pColumn->nullbitmap = tmp;
|
pColumn->nullbitmap = tmp;
|
||||||
memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen);
|
memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen);
|
||||||
|
|
||||||
ASSERT(pColumn->info.bytes);
|
ASSERT(pColumn->info.bytes);
|
||||||
|
|
||||||
// make sure the allocated memory is MALLOC_ALIGN_BYTES aligned
|
// make sure the allocated memory is MALLOC_ALIGN_BYTES aligned
|
||||||
|
@ -1207,6 +1206,12 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumn->pData = tmp;
|
pColumn->pData = tmp;
|
||||||
|
|
||||||
|
// todo remove it soon
|
||||||
|
#if defined LINUX
|
||||||
|
ASSERT((((uint64_t)pColumn->pData) & (MALLOC_ALIGN_BYTES - 1)) == 0x0);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (clearPayload) {
|
if (clearPayload) {
|
||||||
memset(tmp + pColumn->info.bytes * existedRows, 0, pColumn->info.bytes * (numOfRows - existedRows));
|
memset(tmp + pColumn->info.bytes * existedRows, 0, pColumn->info.bytes * (numOfRows - existedRows));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,11 @@ int32_t tsNumOfQnodeFetchThreads = 1;
|
||||||
int32_t tsNumOfSnodeStreamThreads = 4;
|
int32_t tsNumOfSnodeStreamThreads = 4;
|
||||||
int32_t tsNumOfSnodeWriteThreads = 1;
|
int32_t tsNumOfSnodeWriteThreads = 1;
|
||||||
|
|
||||||
|
// sync raft
|
||||||
|
int32_t tsElectInterval = 25 * 1000;
|
||||||
|
int32_t tsHeartbeatInterval = 1000;
|
||||||
|
int32_t tsHeartbeatTimeout = 20 * 1000;
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
bool tsEnableMonitor = true;
|
bool tsEnableMonitor = true;
|
||||||
int32_t tsMonitorInterval = 30;
|
int32_t tsMonitorInterval = 30;
|
||||||
|
@ -198,9 +203,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
int32_t taosSetTfsCfg(SConfig *pCfg);
|
int32_t taosSetTfsCfg(SConfig *pCfg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct SConfig *taosGetCfg() {
|
struct SConfig *taosGetCfg() { return tsCfg; }
|
||||||
return tsCfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
||||||
char *apolloUrl) {
|
char *apolloUrl) {
|
||||||
|
@ -330,6 +333,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
|
||||||
if (cfgAddTimezone(pCfg, "timezone", tsTimezoneStr) != 0) return -1;
|
if (cfgAddTimezone(pCfg, "timezone", tsTimezoneStr) != 0) return -1;
|
||||||
if (cfgAddLocale(pCfg, "locale", tsLocale) != 0) return -1;
|
if (cfgAddLocale(pCfg, "locale", tsLocale) != 0) return -1;
|
||||||
if (cfgAddCharset(pCfg, "charset", tsCharset) != 0) return -1;
|
if (cfgAddCharset(pCfg, "charset", tsCharset) != 0) return -1;
|
||||||
|
if (cfgAddBool(pCfg, "assert", 1, 1) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "enableCoreFile", 1, 1) != 0) return -1;
|
if (cfgAddBool(pCfg, "enableCoreFile", 1, 1) != 0) return -1;
|
||||||
if (cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1) != 0) return -1;
|
if (cfgAddFloat(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1) != 0) return -1;
|
||||||
|
|
||||||
|
@ -404,7 +408,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
|
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
|
||||||
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
||||||
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 4, 1024, 0) != 0) return -1;
|
||||||
|
|
||||||
// tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
// tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
||||||
// tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4);
|
// tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4);
|
||||||
|
@ -423,6 +427,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, 0) != 0) return -1;
|
||||||
if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, 0) != 0) return -1;
|
if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, 0) != 0) return -1;
|
||||||
|
@ -686,6 +694,8 @@ static void taosSetSystemCfg(SConfig *pCfg) {
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetCoreDump(enableCore);
|
taosSetCoreDump(enableCore);
|
||||||
|
|
||||||
|
tsAssert = cfgGetItem(pCfg, "assert")->bval;
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
tsVersion = 30000000;
|
tsVersion = 30000000;
|
||||||
}
|
}
|
||||||
|
@ -728,6 +738,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
||||||
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
||||||
|
|
||||||
|
tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32;
|
||||||
|
tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32;
|
||||||
|
tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32;
|
||||||
|
|
||||||
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||||
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
||||||
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
||||||
|
@ -737,6 +751,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
||||||
|
|
||||||
|
tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32;
|
||||||
|
tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32;
|
||||||
|
tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32;
|
||||||
|
|
||||||
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||||
tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs));
|
tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs));
|
||||||
tstrncpy(tsUdfdLdLibPath, cfgGetItem(pCfg, "udfdLdLibPath")->str, sizeof(tsUdfdLdLibPath));
|
tstrncpy(tsUdfdLdLibPath, cfgGetItem(pCfg, "udfdLdLibPath")->str, sizeof(tsUdfdLdLibPath));
|
||||||
|
@ -773,6 +791,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
||||||
case 'a': {
|
case 'a': {
|
||||||
if (strcasecmp("asyncLog", name) == 0) {
|
if (strcasecmp("asyncLog", name) == 0) {
|
||||||
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
||||||
|
} else if (strcasecmp("assert", name) == 0) {
|
||||||
|
tsAssert = cfgGetItem(pCfg, "assert")->bval;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) {
|
||||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
||||||
|
@ -551,6 +553,8 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (pReq->ast2Len > 0) {
|
if (pReq->ast2Len > 0) {
|
||||||
if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1;
|
if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tEncodeI64(&encoder, pReq->deleteMark1) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->deleteMark2) < 0) return -1;
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -644,6 +648,9 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tDecodeI64(&decoder, &pReq->deleteMark1) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->deleteMark2) < 0) return -1;
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -822,6 +829,7 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq
|
||||||
if (pReq->astLen > 0) {
|
if (pReq->astLen > 0) {
|
||||||
if (tEncodeBinary(&encoder, pReq->ast, pReq->astLen) < 0) return -1;
|
if (tEncodeBinary(&encoder, pReq->ast, pReq->astLen) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -870,7 +878,7 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
|
||||||
if (pReq->ast == NULL) return -1;
|
if (pReq->ast == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tDecodeI64(&decoder, &pReq->deleteMark) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "trow.h"
|
#include "trow.h"
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
const uint8_t tdVTypeByte[2][3] = {{
|
const uint8_t tdVTypeByte[2][3] = {{
|
||||||
// 2 bits
|
// 2 bits
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
|
#include "tlog.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mktime64 - Converts date to seconds.
|
* mktime64 - Converts date to seconds.
|
||||||
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
|
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
|
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
|
||||||
|
@ -45,9 +46,30 @@ static struct {
|
||||||
SArray *pArgs; // SConfigPair
|
SArray *pArgs; // SConfigPair
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dmStopDnode(int signum, void *info, void *ctx) { dmStop(); }
|
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetAllDebugFlag(143, true); }
|
||||||
|
static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert = 1; }
|
||||||
|
|
||||||
|
static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
||||||
|
// taosIgnSignal(SIGUSR1);
|
||||||
|
// taosIgnSignal(SIGUSR2);
|
||||||
|
taosIgnSignal(SIGTERM);
|
||||||
|
taosIgnSignal(SIGHUP);
|
||||||
|
taosIgnSignal(SIGINT);
|
||||||
|
taosIgnSignal(SIGABRT);
|
||||||
|
taosIgnSignal(SIGBREAK);
|
||||||
|
|
||||||
|
dInfo("shut down signal is %d", signum);
|
||||||
|
#ifndef WINDOWS
|
||||||
|
dInfo("sender PID:%d cmdline:%s", ((siginfo_t *)sigInfo)->si_pid,
|
||||||
|
taosGetCmdlineByPID(((siginfo_t *)sigInfo)->si_pid));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dmStop();
|
||||||
|
}
|
||||||
|
|
||||||
static void dmSetSignalHandle() {
|
static void dmSetSignalHandle() {
|
||||||
|
taosSetSignal(SIGUSR1, dmSetDebugFlag);
|
||||||
|
taosSetSignal(SIGUSR2, dmSetAssert);
|
||||||
taosSetSignal(SIGTERM, dmStopDnode);
|
taosSetSignal(SIGTERM, dmStopDnode);
|
||||||
taosSetSignal(SIGHUP, dmStopDnode);
|
taosSetSignal(SIGHUP, dmStopDnode);
|
||||||
taosSetSignal(SIGINT, dmStopDnode);
|
taosSetSignal(SIGINT, dmStopDnode);
|
||||||
|
@ -105,6 +127,19 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
||||||
|
char path[1024] = {0};
|
||||||
|
taosGetCwd(path, sizeof(path));
|
||||||
|
|
||||||
|
char args[1024] = {0};
|
||||||
|
int32_t arglen = snprintf(args, sizeof(args), "%s", argv[0]);
|
||||||
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
|
arglen = arglen + snprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("startup path:%s args:%s", path, args);
|
||||||
|
}
|
||||||
|
|
||||||
static void dmGenerateGrant() { mndGenerateMachineCode(); }
|
static void dmGenerateGrant() { mndGenerateMachineCode(); }
|
||||||
|
|
||||||
static void dmPrintVersion() {
|
static void dmPrintVersion() {
|
||||||
|
@ -194,6 +229,8 @@ int mainWindows(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dmPrintArgs(argc, argv);
|
||||||
|
|
||||||
if (taosInitCfg(configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
if (taosInitCfg(configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0) != 0) {
|
||||||
dError("failed to start since read config error");
|
dError("failed to start since read config error");
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
@ -201,7 +238,12 @@ int mainWindows(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosConvInit();
|
if (taosConvInit() != 0) {
|
||||||
|
dError("failed to init conv");
|
||||||
|
taosCloseLog();
|
||||||
|
taosCleanupArgs();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (global.dumpConfig) {
|
if (global.dumpConfig) {
|
||||||
dmDumpCfg();
|
dmDumpCfg();
|
||||||
|
|
|
@ -103,7 +103,12 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
tSerializeSStatusReq(pHead, contLen, &req);
|
tSerializeSStatusReq(pHead, contLen, &req);
|
||||||
tFreeSStatusReq(&req);
|
tFreeSStatusReq(&req);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527};
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
|
.contLen = contLen,
|
||||||
|
.msgType = TDMT_MND_STATUS,
|
||||||
|
.info.ahandle = (void *)0x9527,
|
||||||
|
.info.refId = 0,
|
||||||
|
.info.noResp = 0};
|
||||||
SRpcMsg rpcRsp = {0};
|
SRpcMsg rpcRsp = {0};
|
||||||
|
|
||||||
dTrace("send status req to mnode, dnodeVer:%" PRId64 " statusSeq:%d", req.dnodeVer, req.statusSeq);
|
dTrace("send status req to mnode, dnodeVer:%" PRId64 " statusSeq:%d", req.dnodeVer, req.statusSeq);
|
||||||
|
@ -150,7 +155,8 @@ static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
||||||
SServerStatusRsp statusRsp = {0};
|
SServerStatusRsp statusRsp = {0};
|
||||||
SMonMloadInfo minfo = {0};
|
SMonMloadInfo minfo = {0};
|
||||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||||
if (minfo.isMnode && (minfo.load.syncState == TAOS_SYNC_STATE_ERROR || minfo.load.syncState == TAOS_SYNC_STATE_OFFLINE)) {
|
if (minfo.isMnode &&
|
||||||
|
(minfo.load.syncState == TAOS_SYNC_STATE_ERROR || minfo.load.syncState == TAOS_SYNC_STATE_OFFLINE)) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,6 +21,8 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
int64_t lastTime = taosGetTimestampMs();
|
int64_t lastTime = taosGetTimestampMs();
|
||||||
setThreadName("dnode-status");
|
setThreadName("dnode-status");
|
||||||
|
|
||||||
|
const static int16_t TRIM_FREQ = 30;
|
||||||
|
int32_t trimCount = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
taosMsleep(200);
|
taosMsleep(200);
|
||||||
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
||||||
|
@ -28,9 +30,13 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
int64_t curTime = taosGetTimestampMs();
|
int64_t curTime = taosGetTimestampMs();
|
||||||
float interval = (curTime - lastTime) / 1000.0f;
|
float interval = (curTime - lastTime) / 1000.0f;
|
||||||
if (interval >= tsStatusInterval) {
|
if (interval >= tsStatusInterval) {
|
||||||
taosMemoryTrim(0);
|
|
||||||
dmSendStatusReq(pMgmt);
|
dmSendStatusReq(pMgmt);
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
|
|
||||||
|
trimCount = (trimCount + 1) % TRIM_FREQ;
|
||||||
|
if (trimCount == 0) {
|
||||||
|
taosMemoryTrim(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
|
|
||||||
SSnode *pSnode = pMgmt->pSnode;
|
SSnode *pSnode = pMgmt->pSnode;
|
||||||
if (pSnode == NULL) {
|
if (pSnode == NULL) {
|
||||||
dError("snode: msg:%p failed to put into vnode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
dError("msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
||||||
TMSG_INFO(pMsg->msgType), qtype);
|
TMSG_INFO(pMsg->msgType), qtype);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
|
@ -161,7 +161,8 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
smPutNodeMsgToWriteQueue(pMgmt, pMsg);
|
smPutNodeMsgToWriteQueue(pMgmt, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERTS(0, "msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
||||||
|
TMSG_INFO(pMsg->msgType), qtype);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,11 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
return (*msgFp)(pWrapper->pMgmt, pMsg);
|
return (*msgFp)(pWrapper->pMgmt, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool dmFailFastFp(tmsg_t msgType) {
|
||||||
|
// add more msg type later
|
||||||
|
return msgType == TDMT_SYNC_HEARTBEAT || msgType == TDMT_SYNC_APPEND_ENTRIES;
|
||||||
|
}
|
||||||
|
|
||||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -260,6 +265,10 @@ int32_t dmInitClient(SDnode *pDnode) {
|
||||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||||
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
||||||
|
|
||||||
|
rpcInit.failFastInterval = 1000; // interval threshold(ms)
|
||||||
|
rpcInit.failFastThreshold = 3; // failed threshold
|
||||||
|
rpcInit.ffp = dmFailFastFp;
|
||||||
|
|
||||||
pTrans->clientRpc = rpcOpen(&rpcInit);
|
pTrans->clientRpc = rpcOpen(&rpcInit);
|
||||||
if (pTrans->clientRpc == NULL) {
|
if (pTrans->clientRpc == NULL) {
|
||||||
dError("failed to init dnode rpc client");
|
dError("failed to init dnode rpc client");
|
||||||
|
@ -292,6 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) {
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
|
|
||||||
pTrans->serverRpc = rpcOpen(&rpcInit);
|
pTrans->serverRpc = rpcOpen(&rpcInit);
|
||||||
if (pTrans->serverRpc == NULL) {
|
if (pTrans->serverRpc == NULL) {
|
||||||
|
|
|
@ -473,6 +473,7 @@ void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
char createUser[TSDB_USER_LEN];
|
||||||
int64_t createTime;
|
int64_t createTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
|
@ -644,6 +645,7 @@ typedef struct {
|
||||||
// 3.0.20
|
// 3.0.20
|
||||||
int64_t checkpointFreq; // ms
|
int64_t checkpointFreq; // ms
|
||||||
int64_t currentTick; // do not serialize
|
int64_t currentTick; // do not serialize
|
||||||
|
int64_t deleteMark;
|
||||||
} SStreamObj;
|
} SStreamObj;
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
|
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
|
||||||
|
|
|
@ -28,7 +28,7 @@ void mndCleanupScheduler(SMnode* pMnode);
|
||||||
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub);
|
||||||
|
|
||||||
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
||||||
int64_t watermark);
|
int64_t watermark, int64_t deleteMark);
|
||||||
|
|
||||||
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream);
|
int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream);
|
||||||
|
|
||||||
|
|
|
@ -555,6 +555,12 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckDbPrivilegeByName(pMnode, pMsg->info.conn.user, MND_OPER_READ_DB, pTopic->db) != 0) {
|
if (mndCheckDbPrivilegeByName(pMnode, pMsg->info.conn.user, MND_OPER_READ_DB, pTopic->db) != 0) {
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
goto SUBSCRIBE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckTopicPrivilege(pMnode, pMsg->info.conn.user, MND_OPER_SUBSCRIBE, pTopic) != 0) {
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
goto SUBSCRIBE_OVER;
|
goto SUBSCRIBE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -825,7 +825,13 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
dbObj.cfgVersion++;
|
dbObj.cfgVersion++;
|
||||||
dbObj.updateTime = taosGetTimestampMs();
|
dbObj.updateTime = taosGetTimestampMs();
|
||||||
code = mndAlterDb(pMnode, pReq, pDb, &dbObj);
|
code = mndAlterDb(pMnode, pReq, pDb, &dbObj);
|
||||||
|
|
||||||
|
if (dbObj.cfg.replications != pDb->cfg.replications) {
|
||||||
|
// return quickly, operation executed asynchronously
|
||||||
|
mInfo("db:%s, alter db replica from %d to %d", pDb->name, pDb->cfg.replications, dbObj.cfg.replications);
|
||||||
|
} else {
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
|
|
@ -383,9 +383,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pGid->syncCanRead != pVload->syncCanRead) {
|
pGid->syncCanRead != pVload->syncCanRead) {
|
||||||
mInfo(
|
mInfo(
|
||||||
"vgId:%d, state changed by status msg, old state:%s restored:%d canRead:%d new state:%s restored:%d "
|
"vgId:%d, state changed by status msg, old state:%s restored:%d canRead:%d new state:%s restored:%d "
|
||||||
"canRead:%d",
|
"canRead:%d, dnode:%d",
|
||||||
pVgroup->vgId, syncStr(pGid->syncState), pGid->syncRestore, pGid->syncCanRead,
|
pVgroup->vgId, syncStr(pGid->syncState), pGid->syncRestore, pGid->syncCanRead,
|
||||||
syncStr(pVload->syncState), pVload->syncRestore, pVload->syncCanRead);
|
syncStr(pVload->syncState), pVload->syncRestore, pVload->syncCanRead, pDnode->id);
|
||||||
pGid->syncState = pVload->syncState;
|
pGid->syncState = pVload->syncState;
|
||||||
pGid->syncRestore = pVload->syncRestore;
|
pGid->syncRestore = pVload->syncRestore;
|
||||||
pGid->syncCanRead = pVload->syncCanRead;
|
pGid->syncCanRead = pVload->syncCanRead;
|
||||||
|
|
|
@ -42,7 +42,7 @@ static int32_t mndAddTaskToTaskSet(SArray* pArray, SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType,
|
||||||
int64_t watermark) {
|
int64_t watermark, int64_t deleteMark) {
|
||||||
SNode* pAst = NULL;
|
SNode* pAst = NULL;
|
||||||
SQueryPlan* pPlan = NULL;
|
SQueryPlan* pPlan = NULL;
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
@ -64,6 +64,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
||||||
.rSmaQuery = true,
|
.rSmaQuery = true,
|
||||||
.triggerType = triggerType,
|
.triggerType = triggerType,
|
||||||
.watermark = watermark,
|
.watermark = watermark,
|
||||||
|
.deleteMark = deleteMark,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
|
|
|
@ -198,9 +198,9 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retrieveReq.showId == 0) {
|
if (retrieveReq.showId == 0) {
|
||||||
STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
||||||
if (pMeta == NULL) {
|
if (pMeta == NULL) {
|
||||||
pMeta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
pMeta = taosHashGet(pMnode->perfsMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
||||||
if (pMeta == NULL) {
|
if (pMeta == NULL) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
|
terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME;
|
||||||
mError("failed to process show-retrieve req:%p since %s", pShow, terrstr());
|
mError("failed to process show-retrieve req:%p since %s", pShow, terrstr());
|
||||||
|
|
|
@ -534,6 +534,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
streamObj.sql = strdup(pCreate->sql);
|
streamObj.sql = strdup(pCreate->sql);
|
||||||
streamObj.smaId = smaObj.uid;
|
streamObj.smaId = smaObj.uid;
|
||||||
streamObj.watermark = pCreate->watermark;
|
streamObj.watermark = pCreate->watermark;
|
||||||
|
streamObj.deleteMark = pCreate->deleteMark;
|
||||||
streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
|
streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
|
||||||
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
|
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
|
||||||
streamObj.triggerParam = pCreate->maxDelay;
|
streamObj.triggerParam = pCreate->maxDelay;
|
||||||
|
@ -574,6 +575,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
.streamQuery = true,
|
.streamQuery = true,
|
||||||
.triggerType = streamObj.trigger,
|
.triggerType = streamObj.trigger,
|
||||||
.watermark = streamObj.watermark,
|
.watermark = streamObj.watermark,
|
||||||
|
.deleteMark = streamObj.deleteMark,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) {
|
||||||
|
|
|
@ -450,13 +450,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
req.rsmaParam.watermark[1] = pStb->watermark[1];
|
req.rsmaParam.watermark[1] = pStb->watermark[1];
|
||||||
if (pStb->ast1Len > 0) {
|
if (pStb->ast1Len > 0) {
|
||||||
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[0], &req.rsmaParam.qmsgLen[0], pStb->pAst1, pStb->uid,
|
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[0], &req.rsmaParam.qmsgLen[0], pStb->pAst1, pStb->uid,
|
||||||
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[0]) < 0) {
|
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[0],
|
||||||
|
req.rsmaParam.deleteMark[0]) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pStb->ast2Len > 0) {
|
if (pStb->ast2Len > 0) {
|
||||||
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[1], &req.rsmaParam.qmsgLen[1], pStb->pAst2, pStb->uid,
|
if (mndConvertRsmaTask(&req.rsmaParam.qmsg[1], &req.rsmaParam.qmsgLen[1], pStb->pAst2, pStb->uid,
|
||||||
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[1]) < 0) {
|
STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[1],
|
||||||
|
req.rsmaParam.deleteMark[1]) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,13 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||||
int32_t code = mndProcessWriteMsg(pFsm, pMsg, pMeta);
|
int32_t code = 0;
|
||||||
|
if (!syncUtilUserCommit(pMsg->msgType)) {
|
||||||
|
goto _out;
|
||||||
|
}
|
||||||
|
code = mndProcessWriteMsg(pFsm, pMsg, pMeta);
|
||||||
|
|
||||||
|
_out:
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
pMsg->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
return code;
|
return code;
|
||||||
|
@ -143,9 +149,13 @@ void mndRestoreFinish(const SSyncFSM *pFsm) {
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
|
|
||||||
if (!pMnode->deploy) {
|
if (!pMnode->deploy) {
|
||||||
|
if (!pMnode->restored) {
|
||||||
mInfo("vgId:1, sync restore finished, and will handle outstanding transactions");
|
mInfo("vgId:1, sync restore finished, and will handle outstanding transactions");
|
||||||
mndTransPullup(pMnode);
|
mndTransPullup(pMnode);
|
||||||
mndSetRestored(pMnode, true);
|
mndSetRestored(pMnode, true);
|
||||||
|
} else {
|
||||||
|
mInfo("vgId:1, sync restore finished, repeat call");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mInfo("vgId:1, sync restore finished");
|
mInfo("vgId:1, sync restore finished");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define MND_TOPIC_VER_NUMBER 1
|
#define MND_TOPIC_VER_NUMBER 2
|
||||||
#define MND_TOPIC_RESERVE_SIZE 64
|
#define MND_TOPIC_RESERVE_SIZE 64
|
||||||
|
|
||||||
static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic);
|
static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic);
|
||||||
|
@ -93,6 +93,7 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TOPIC_FNAME_LEN, TOPIC_ENCODE_OVER);
|
SDB_SET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TOPIC_FNAME_LEN, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN, TOPIC_ENCODE_OVER);
|
SDB_SET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN, TOPIC_ENCODE_OVER);
|
||||||
|
SDB_SET_BINARY(pRaw, dataPos, pTopic->createUser, TSDB_USER_LEN, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTopic->createTime, TOPIC_ENCODE_OVER);
|
SDB_SET_INT64(pRaw, dataPos, pTopic->createTime, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime, TOPIC_ENCODE_OVER);
|
SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTopic->uid, TOPIC_ENCODE_OVER);
|
SDB_SET_INT64(pRaw, dataPos, pTopic->uid, TOPIC_ENCODE_OVER);
|
||||||
|
@ -159,7 +160,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
||||||
int8_t sver = 0;
|
int8_t sver = 0;
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TOPIC_DECODE_OVER;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TOPIC_DECODE_OVER;
|
||||||
|
|
||||||
if (sver != MND_TOPIC_VER_NUMBER) {
|
if (sver != 1 && sver != 2) {
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
goto TOPIC_DECODE_OVER;
|
goto TOPIC_DECODE_OVER;
|
||||||
}
|
}
|
||||||
|
@ -174,6 +175,9 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TOPIC_FNAME_LEN, TOPIC_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TOPIC_FNAME_LEN, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN, TOPIC_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN, TOPIC_DECODE_OVER);
|
||||||
|
if (sver >= 2) {
|
||||||
|
SDB_GET_BINARY(pRaw, dataPos, pTopic->createUser, TSDB_USER_LEN, TOPIC_DECODE_OVER);
|
||||||
|
}
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->createTime, TOPIC_DECODE_OVER);
|
SDB_GET_INT64(pRaw, dataPos, &pTopic->createTime, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->updateTime, TOPIC_DECODE_OVER);
|
SDB_GET_INT64(pRaw, dataPos, &pTopic->updateTime, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->uid, TOPIC_DECODE_OVER);
|
SDB_GET_INT64(pRaw, dataPos, &pTopic->uid, TOPIC_DECODE_OVER);
|
||||||
|
@ -358,11 +362,18 @@ static int32_t extractTopicTbInfo(SNode *pAst, SMqTopicObj *pTopic) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) {
|
static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb,
|
||||||
|
const char *userName) {
|
||||||
mInfo("topic:%s to create", pCreate->name);
|
mInfo("topic:%s to create", pCreate->name);
|
||||||
SMqTopicObj topicObj = {0};
|
SMqTopicObj topicObj = {0};
|
||||||
tstrncpy(topicObj.name, pCreate->name, TSDB_TOPIC_FNAME_LEN);
|
tstrncpy(topicObj.name, pCreate->name, TSDB_TOPIC_FNAME_LEN);
|
||||||
tstrncpy(topicObj.db, pDb->name, TSDB_DB_FNAME_LEN);
|
tstrncpy(topicObj.db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
|
tstrncpy(topicObj.createUser, userName, TSDB_USER_LEN);
|
||||||
|
|
||||||
|
if (mndCheckTopicPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_TOPIC, &topicObj) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
topicObj.createTime = taosGetTimestampMs();
|
topicObj.createTime = taosGetTimestampMs();
|
||||||
topicObj.updateTime = topicObj.createTime;
|
topicObj.updateTime = topicObj.createTime;
|
||||||
topicObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
topicObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
||||||
|
@ -574,11 +585,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_TOPIC) != 0) {
|
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb, pReq->info.conn.user);
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb);
|
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -634,7 +641,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_TOPIC) != 0) {
|
if (mndCheckTopicPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_TOPIC, pTopic) != 0) {
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -698,10 +705,6 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_READ_DB, pTopic->db) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
||||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
|
|
|
@ -1126,7 +1126,8 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!force) {
|
if (!force) {
|
||||||
mInfo("vgId:%d, will add 1 vnode", pVgroup->vgId);
|
if (newVg.replica == 1) {
|
||||||
|
mInfo("vgId:%d, will add 1 vnode, replca:1", pVgroup->vgId);
|
||||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||||
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
||||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||||
|
@ -1134,7 +1135,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1]) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
|
||||||
mInfo("vgId:%d, will remove 1 vnode", pVgroup->vgId);
|
mInfo("vgId:%d, will remove 1 vnode, replca:2", pVgroup->vgId);
|
||||||
newVg.replica--;
|
newVg.replica--;
|
||||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||||
|
@ -1154,6 +1155,32 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||||
}
|
}
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
} else { // new replica == 3
|
||||||
|
mInfo("vgId:%d, will add 1 vnode, replca:3", pVgroup->vgId);
|
||||||
|
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||||
|
mInfo("vgId:%d, will remove 1 vnode, replca:4", pVgroup->vgId);
|
||||||
|
newVg.replica--;
|
||||||
|
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||||
|
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||||
|
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||||
|
{
|
||||||
|
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
|
||||||
|
if (pRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendRedolog(pTrans, pRaw) != 0) {
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||||
|
for (int32_t i = 0; i < newVg.replica; ++i) {
|
||||||
|
if (i == vnIndex) continue;
|
||||||
|
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||||
|
}
|
||||||
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[vnIndex]) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
||||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||||
|
|
|
@ -174,7 +174,7 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableL
|
||||||
void tsdbReaderClose(STsdbReader *pReader);
|
void tsdbReaderClose(STsdbReader *pReader);
|
||||||
bool tsdbNextDataBlock(STsdbReader *pReader);
|
bool tsdbNextDataBlock(STsdbReader *pReader);
|
||||||
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
||||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockSMA, bool *allHave);
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock* pDataBlock, bool *allHave);
|
||||||
SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
||||||
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
||||||
|
|
|
@ -70,7 +70,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid);
|
||||||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
||||||
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
||||||
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
||||||
void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t delta);
|
void metaUpdateStbStats(SMeta* pMeta, int64_t uid, int64_t delta);
|
||||||
int32_t metaUidFilterCacheGet(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, LRUHandle** pHandle);
|
int32_t metaUidFilterCacheGet(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, LRUHandle** pHandle);
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
|
@ -79,7 +79,7 @@ struct SMeta {
|
||||||
char* path;
|
char* path;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
TDB* pEnv;
|
TDB* pEnv;
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
TTB* pTbDb;
|
TTB* pTbDb;
|
||||||
TTB* pSkmDb;
|
TTB* pSkmDb;
|
||||||
TTB* pUidIdx;
|
TTB* pUidIdx;
|
||||||
|
|
|
@ -77,7 +77,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
||||||
|
|
||||||
// vnodeQuery.c
|
// vnodeQuery.c
|
||||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||||
void vnodeQueryPreClose(SVnode *pVnode);
|
void vnodeQueryPreClose(SVnode* pVnode);
|
||||||
void vnodeQueryClose(SVnode* pVnode);
|
void vnodeQueryClose(SVnode* pVnode);
|
||||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||||
|
@ -86,7 +86,6 @@ int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
// vnodeCommit.c
|
// vnodeCommit.c
|
||||||
int32_t vnodeBegin(SVnode* pVnode);
|
int32_t vnodeBegin(SVnode* pVnode);
|
||||||
int32_t vnodeShouldCommit(SVnode* pVnode);
|
int32_t vnodeShouldCommit(SVnode* pVnode);
|
||||||
int32_t vnodeCommit(SVnode* pVnode);
|
|
||||||
void vnodeRollback(SVnode* pVnode);
|
void vnodeRollback(SVnode* pVnode);
|
||||||
int32_t vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
int32_t vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
||||||
int32_t vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
int32_t vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
||||||
|
|
|
@ -75,6 +75,7 @@ typedef struct SStreamStateWriter SStreamStateWriter;
|
||||||
typedef struct SRSmaSnapReader SRSmaSnapReader;
|
typedef struct SRSmaSnapReader SRSmaSnapReader;
|
||||||
typedef struct SRSmaSnapWriter SRSmaSnapWriter;
|
typedef struct SRSmaSnapWriter SRSmaSnapWriter;
|
||||||
typedef struct SSnapDataHdr SSnapDataHdr;
|
typedef struct SSnapDataHdr SSnapDataHdr;
|
||||||
|
typedef struct SCommitInfo SCommitInfo;
|
||||||
|
|
||||||
#define VNODE_META_DIR "meta"
|
#define VNODE_META_DIR "meta"
|
||||||
#define VNODE_TSDB_DIR "tsdb"
|
#define VNODE_TSDB_DIR "tsdb"
|
||||||
|
@ -100,8 +101,9 @@ typedef struct STbUidStore STbUidStore;
|
||||||
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
|
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
|
||||||
int metaClose(SMeta* pMeta);
|
int metaClose(SMeta* pMeta);
|
||||||
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
||||||
int metaCommit(SMeta* pMeta);
|
TXN* metaGetTxn(SMeta* pMeta);
|
||||||
int metaFinishCommit(SMeta* pMeta);
|
int metaCommit(SMeta* pMeta, TXN* txn);
|
||||||
|
int metaFinishCommit(SMeta* pMeta, TXN* txn);
|
||||||
int metaPrepareAsyncCommit(SMeta* pMeta);
|
int metaPrepareAsyncCommit(SMeta* pMeta);
|
||||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
|
@ -146,7 +148,8 @@ int32_t metaGetInfo(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo, SMetaReader* pR
|
||||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback);
|
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback);
|
||||||
int tsdbClose(STsdb** pTsdb);
|
int tsdbClose(STsdb** pTsdb);
|
||||||
int32_t tsdbBegin(STsdb* pTsdb);
|
int32_t tsdbBegin(STsdb* pTsdb);
|
||||||
int32_t tsdbCommit(STsdb* pTsdb);
|
int32_t tsdbPrepareCommit(STsdb* pTsdb);
|
||||||
|
int32_t tsdbCommit(STsdb* pTsdb, SCommitInfo* pInfo);
|
||||||
int32_t tsdbFinishCommit(STsdb* pTsdb);
|
int32_t tsdbFinishCommit(STsdb* pTsdb);
|
||||||
int32_t tsdbRollbackCommit(STsdb* pTsdb);
|
int32_t tsdbRollbackCommit(STsdb* pTsdb);
|
||||||
int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now);
|
int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now);
|
||||||
|
@ -203,8 +206,8 @@ int32_t smaBegin(SSma* pSma);
|
||||||
int32_t smaSyncPreCommit(SSma* pSma);
|
int32_t smaSyncPreCommit(SSma* pSma);
|
||||||
int32_t smaSyncCommit(SSma* pSma);
|
int32_t smaSyncCommit(SSma* pSma);
|
||||||
int32_t smaSyncPostCommit(SSma* pSma);
|
int32_t smaSyncPostCommit(SSma* pSma);
|
||||||
int32_t smaPreCommit(SSma* pSma);
|
int32_t smaPrepareAsyncCommit(SSma* pSma);
|
||||||
int32_t smaCommit(SSma* pSma);
|
int32_t smaCommit(SSma* pSma, SCommitInfo* pInfo);
|
||||||
int32_t smaFinishCommit(SSma* pSma);
|
int32_t smaFinishCommit(SSma* pSma);
|
||||||
int32_t smaPostCommit(SSma* pSma);
|
int32_t smaPostCommit(SSma* pSma);
|
||||||
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
||||||
|
@ -406,6 +409,12 @@ struct SSnapDataHdr {
|
||||||
uint8_t data[];
|
uint8_t data[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SCommitInfo {
|
||||||
|
SVnodeInfo info;
|
||||||
|
SVnode* pVnode;
|
||||||
|
TXN* txn;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -454,7 +454,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
||||||
|
|
||||||
SListNode* pNode = NULL;
|
SListNode* pNode = NULL;
|
||||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||||
memcpy(pBuf + sizeof(suid), pNode->data, keyLen);
|
memcpy(&pBuf[1], pNode->data, keyLen);
|
||||||
|
|
||||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
||||||
|
|
|
@ -20,12 +20,19 @@ static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVB
|
||||||
|
|
||||||
// begin a meta txn
|
// begin a meta txn
|
||||||
int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
||||||
|
void *(*xMalloc)(void *, size_t);
|
||||||
|
void (*xFree)(void *, void *);
|
||||||
|
void *xArg = NULL;
|
||||||
|
|
||||||
if (fromSys) {
|
if (fromSys) {
|
||||||
tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
xMalloc = tdbDefaultMalloc;
|
||||||
|
xFree = tdbDefaultFree;
|
||||||
} else {
|
} else {
|
||||||
tdbTxnOpen(&pMeta->txn, 0, metaMalloc, metaFree, pMeta->pVnode->inUse, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
xMalloc = metaMalloc;
|
||||||
|
xFree = metaFree;
|
||||||
|
xArg = pMeta->pVnode->inUse;
|
||||||
}
|
}
|
||||||
if (tdbBegin(pMeta->pEnv, &pMeta->txn) < 0) {
|
if (tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +40,16 @@ int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit the meta txn
|
// commit the meta txn
|
||||||
int metaCommit(SMeta *pMeta) { return tdbCommit(pMeta->pEnv, &pMeta->txn); }
|
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
|
||||||
int metaFinishCommit(SMeta *pMeta) { return tdbPostCommit(pMeta->pEnv, &pMeta->txn); }
|
int metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); }
|
||||||
int metaPrepareAsyncCommit(SMeta *pMeta) { return tdbPrepareAsyncCommit(pMeta->pEnv, &pMeta->txn); }
|
int metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); }
|
||||||
|
int metaPrepareAsyncCommit(SMeta *pMeta) {
|
||||||
|
// return tdbPrepareAsyncCommit(pMeta->pEnv, pMeta->txn);
|
||||||
|
int code = 0;
|
||||||
|
code = tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
// abort the meta txn
|
// abort the meta txn
|
||||||
int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, &pMeta->txn); }
|
int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, pMeta->txn); }
|
||||||
|
|
|
@ -117,7 +117,7 @@ static int metaSaveSmaToDB(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
tEncoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
// write to table.db
|
// write to table.db
|
||||||
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, pMeta->txn) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,17 +131,17 @@ _err:
|
||||||
|
|
||||||
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SUidIdxVal uidIdxVal = {.suid = pME->smaEntry.tsma->indexUid, .version = pME->version, .skmVer = 0};
|
SUidIdxVal uidIdxVal = {.suid = pME->smaEntry.tsma->indexUid, .version = pME->version, .skmVer = 0};
|
||||||
return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), &pMeta->txn);
|
return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn);
|
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateSmaIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateSmaIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SSmaIdxKey smaIdxKey = {.uid = pME->smaEntry.tsma->tableUid, .smaUid = pME->smaEntry.tsma->indexUid};
|
SSmaIdxKey smaIdxKey = {.uid = pME->smaEntry.tsma->tableUid, .smaUid = pME->smaEntry.tsma->indexUid};
|
||||||
|
|
||||||
return tdbTbInsert(pMeta->pSmaIdx, &smaIdxKey, sizeof(smaIdxKey), NULL, 0, &pMeta->txn);
|
return tdbTbInsert(pMeta->pSmaIdx, &smaIdxKey, sizeof(smaIdxKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaHandleSmaEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaHandleSmaEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
|
|
@ -163,9 +163,9 @@ int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) {
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
} else {
|
} else {
|
||||||
code = metaCommit(pWriter->pMeta);
|
code = metaCommit(pWriter->pMeta, pWriter->pMeta->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
code = metaFinishCommit(pWriter->pMeta);
|
code = metaFinishCommit(pWriter->pMeta, pWriter->pMeta->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
|
|
|
@ -261,7 +261,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
||||||
// drop all child tables
|
// drop all child tables
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
||||||
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
|
@ -295,10 +295,10 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
||||||
_drop_super_table:
|
_drop_super_table:
|
||||||
tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData);
|
tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData);
|
||||||
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid},
|
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid},
|
||||||
sizeof(STbDbKey), &pMeta->txn);
|
sizeof(STbDbKey), pMeta->txn);
|
||||||
tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pMeta->txn);
|
tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn);
|
||||||
tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn);
|
tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn);
|
tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
int32_t c = -2;
|
int32_t c = -2;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||||
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
||||||
if (ret < 0 || c) {
|
if (ret < 0 || c) {
|
||||||
tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
|
@ -340,7 +340,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
ASSERT(ret == 0 && c == 0);
|
ASSERT(ret == 0 && c == 0);
|
||||||
|
|
||||||
|
@ -549,8 +549,8 @@ int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
|
static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
|
||||||
int64_t ttlDays;
|
int64_t ttlDays = 0;
|
||||||
int64_t ctime;
|
int64_t ctime = 0;
|
||||||
if (pME->type == TSDB_CHILD_TABLE) {
|
if (pME->type == TSDB_CHILD_TABLE) {
|
||||||
ctime = pME->ctbEntry.ctime;
|
ctime = pME->ctbEntry.ctime;
|
||||||
ttlDays = pME->ctbEntry.ttlDays;
|
ttlDays = pME->ctbEntry.ttlDays;
|
||||||
|
@ -595,7 +595,7 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
STtlIdxKey ttlKey = {0};
|
STtlIdxKey ttlKey = {0};
|
||||||
metaBuildTtlIdxKey(&ttlKey, pME);
|
metaBuildTtlIdxKey(&ttlKey, pME);
|
||||||
if (ttlKey.dtime == 0) return 0;
|
if (ttlKey.dtime == 0) return 0;
|
||||||
return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), &pMeta->txn);
|
return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
|
@ -657,7 +657,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
|
|
||||||
if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid,
|
if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid,
|
||||||
&pTagIdxKey, &nTagIdxKey) == 0) {
|
&pTagIdxKey, &nTagIdxKey) == 0) {
|
||||||
tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, &pMeta->txn);
|
tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn);
|
||||||
}
|
}
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
}
|
}
|
||||||
|
@ -667,9 +667,9 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pMeta->txn);
|
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn);
|
||||||
tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, &pMeta->txn);
|
tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn);
|
||||||
tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), &pMeta->txn);
|
tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn);
|
||||||
|
|
||||||
if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteCtimeIdx(pMeta, &e);
|
if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteCtimeIdx(pMeta, &e);
|
||||||
if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e);
|
if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e);
|
||||||
|
@ -677,7 +677,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
if (e.type != TSDB_SUPER_TABLE) metaDeleteTtlIdx(pMeta, &e);
|
if (e.type != TSDB_SUPER_TABLE) metaDeleteTtlIdx(pMeta, &e);
|
||||||
|
|
||||||
if (e.type == TSDB_CHILD_TABLE) {
|
if (e.type == TSDB_CHILD_TABLE) {
|
||||||
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn);
|
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn);
|
||||||
|
|
||||||
--pMeta->pVnode->config.vndStats.numOfCTables;
|
--pMeta->pVnode->config.vndStats.numOfCTables;
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
--pMeta->pVnode->config.vndStats.numOfNTables;
|
--pMeta->pVnode->config.vndStats.numOfNTables;
|
||||||
pMeta->pVnode->config.vndStats.numOfNTimeSeries -= e.ntbEntry.schemaRow.nCols - 1;
|
pMeta->pVnode->config.vndStats.numOfNTimeSeries -= e.ntbEntry.schemaRow.nCols - 1;
|
||||||
} else if (e.type == TSDB_SUPER_TABLE) {
|
} else if (e.type == TSDB_SUPER_TABLE) {
|
||||||
tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), &pMeta->txn);
|
tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
// drop schema.db (todo)
|
// drop schema.db (todo)
|
||||||
|
|
||||||
metaStatsCacheDrop(pMeta, uid);
|
metaStatsCacheDrop(pMeta, uid);
|
||||||
|
@ -710,7 +710,7 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, &pMeta->txn);
|
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
@ -718,14 +718,14 @@ int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tdbTbDelete(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), &pMeta->txn);
|
return tdbTbDelete(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), pMeta->txn);
|
||||||
}
|
}
|
||||||
int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SNcolIdxKey ncolKey = {0};
|
SNcolIdxKey ncolKey = {0};
|
||||||
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, &pMeta->txn);
|
return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
@ -733,7 +733,7 @@ int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), &pMeta->txn);
|
return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
||||||
|
@ -768,7 +768,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
// search uid index
|
// search uid index
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
|
|
||||||
|
@ -778,7 +778,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
// search table.db
|
// search table.db
|
||||||
TBC *pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
|
@ -959,7 +959,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
// search uid index
|
// search uid index
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
|
|
||||||
|
@ -972,7 +972,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
SDecoder dc2 = {0};
|
SDecoder dc2 = {0};
|
||||||
|
|
||||||
/* get ctbEntry */
|
/* get ctbEntry */
|
||||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
|
@ -1075,7 +1075,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
ASSERT(ctbEntry.ctbEntry.pTags);
|
ASSERT(ctbEntry.ctbEntry.pTags);
|
||||||
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
||||||
tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
||||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, &pMeta->txn);
|
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn);
|
||||||
|
|
||||||
metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid);
|
metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid);
|
||||||
|
|
||||||
|
@ -1125,7 +1125,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
// search uid index
|
// search uid index
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
|
|
||||||
|
@ -1135,7 +1135,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
// search table.db
|
// search table.db
|
||||||
TBC *pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
|
@ -1242,7 +1242,7 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
tEncoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
// write to table.db
|
// write to table.db
|
||||||
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, pMeta->txn) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1265,29 +1265,29 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
|
||||||
SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer};
|
SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer};
|
||||||
|
|
||||||
return tdbTbUpsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), &pMeta->txn);
|
return tdbTbUpsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, &pMeta->txn);
|
return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn);
|
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
STtlIdxKey ttlKey = {0};
|
STtlIdxKey ttlKey = {0};
|
||||||
metaBuildTtlIdxKey(&ttlKey, pME);
|
metaBuildTtlIdxKey(&ttlKey, pME);
|
||||||
if (ttlKey.dtime == 0) return 0;
|
if (ttlKey.dtime == 0) return 0;
|
||||||
return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, &pMeta->txn);
|
return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
||||||
|
|
||||||
return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), pME->ctbEntry.pTags,
|
return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), pME->ctbEntry.pTags,
|
||||||
((STag *)(pME->ctbEntry.pTags))->len, &pMeta->txn);
|
((STag *)(pME->ctbEntry.pTags))->len, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_t nTagData, int8_t type, tb_uid_t uid,
|
int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_t nTagData, int8_t type, tb_uid_t uid,
|
||||||
|
@ -1353,6 +1353,10 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stbEntry.stbEntry.schemaTag.pSchema == NULL) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
||||||
|
|
||||||
STagVal tagVal = {.cid = pTagColumn->colId};
|
STagVal tagVal = {.cid = pTagColumn->colId};
|
||||||
|
@ -1379,7 +1383,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn);
|
tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
|
@ -1426,7 +1430,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
tEncoderInit(&coder, pVal, vLen);
|
tEncoderInit(&coder, pVal, vLen);
|
||||||
tEncodeSSchemaWrapper(&coder, pSW);
|
tEncodeSSchemaWrapper(&coder, pSW);
|
||||||
|
|
||||||
if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, pMeta->txn) < 0) {
|
||||||
rcode = -1;
|
rcode = -1;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
|
||||||
#endif
|
#endif
|
||||||
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
|
||||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo);
|
||||||
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
|
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
|
||||||
static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
|
static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int32_t smaSyncPostCommit(SSma *pSma) { return tdProcessRSmaSyncPostCommitImpl(p
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); }
|
int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief async commit, only applicable to Rollup SMA
|
* @brief async commit, only applicable to Rollup SMA
|
||||||
|
@ -67,7 +67,7 @@ int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma);
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t smaCommit(SSma *pSma) { return tdProcessRSmaAsyncCommitImpl(pSma); }
|
int32_t smaCommit(SSma *pSma, SCommitInfo *pInfo) { return tdProcessRSmaAsyncCommitImpl(pSma, pInfo); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief async commit, only applicable to Rollup SMA
|
* @brief async commit, only applicable to Rollup SMA
|
||||||
|
@ -378,6 +378,11 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// all rsma results are written completely
|
||||||
|
STsdb *pTsdb = NULL;
|
||||||
|
if ((pTsdb = VND_RSMA1(pSma->pVnode))) tsdbPrepareCommit(pTsdb);
|
||||||
|
if ((pTsdb = VND_RSMA2(pSma->pVnode))) tsdbPrepareCommit(pTsdb);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +392,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SVnode *pVnode = pSma->pVnode;
|
SVnode *pVnode = pSma->pVnode;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -399,11 +404,11 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((code = tsdbCommit(VND_RSMA1(pVnode))) < 0) {
|
if ((code = tsdbCommit(VND_RSMA1(pVnode), pInfo)) < 0) {
|
||||||
smaError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
smaError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
if ((code = tsdbCommit(VND_RSMA2(pVnode))) < 0) {
|
if ((code = tsdbCommit(VND_RSMA2(pVnode), pInfo)) < 0) {
|
||||||
smaError("vgId:%d, failed to commit tsdb rsma2 since %s", TD_VID(pVnode), tstrerror(code));
|
smaError("vgId:%d, failed to commit tsdb rsma2 since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t
|
||||||
pRetrieve->precision = precision;
|
pRetrieve->precision = precision;
|
||||||
pRetrieve->compressed = 0;
|
pRetrieve->compressed = 0;
|
||||||
pRetrieve->completed = 1;
|
pRetrieve->completed = 1;
|
||||||
pRetrieve->numOfRows = htonl(pBlock->info.rows);
|
pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
||||||
|
|
||||||
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||||
actualLen += sizeof(SRetrieveTableRsp);
|
actualLen += sizeof(SRetrieveTableRsp);
|
||||||
|
|
|
@ -108,24 +108,22 @@ int32_t tqMetaClose(STQ* pTq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_t vLen) {
|
int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_t vLen) {
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
|
||||||
|
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||||
|
0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, txn) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, &txn) < 0) {
|
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,25 +131,22 @@ int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMetaDeleteCheckInfo(STQ* pTq, const char* key) {
|
int32_t tqMetaDeleteCheckInfo(STQ* pTq, const char* key) {
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
|
|
||||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||||
|
0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
if (tdbTbDelete(pTq->pCheckStore, key, (int)strlen(key), txn) < 0) {
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdbTbDelete(pTq->pCheckStore, key, (int)strlen(key), &txn) < 0) {
|
|
||||||
/*ASSERT(0);*/
|
/*ASSERT(0);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,25 +214,22 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
|
|
||||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||||
|
0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, txn) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, &txn) < 0) {
|
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,25 +239,22 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) {
|
int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) {
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
|
|
||||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||||
|
0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
if (tdbTbDelete(pTq->pExecStore, key, (int)strlen(key), txn) < 0) {
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdbTbDelete(pTq->pExecStore, key, (int)strlen(key), &txn) < 0) {
|
|
||||||
/*ASSERT(0);*/
|
/*ASSERT(0);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ struct STqSnapWriter {
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
int64_t sver;
|
int64_t sver;
|
||||||
int64_t ever;
|
int64_t ever;
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||||
|
@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||||
ASSERT(0);
|
code = -1;
|
||||||
|
taosMemoryFree(pWriter);
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
|
@ -165,11 +167,11 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
tdbAbort(pWriter->pTq->pMetaDB, &pWriter->txn);
|
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
} else {
|
} else {
|
||||||
code = tdbCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ struct STqSnapWriter {
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
int64_t sver;
|
int64_t sver;
|
||||||
int64_t ever;
|
int64_t ever;
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||||
|
@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||||
ASSERT(0);
|
code = -1;
|
||||||
|
taosMemoryFree(pWriter);
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
|
@ -165,11 +167,12 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
|
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
} else {
|
} else {
|
||||||
code = tdbCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ struct STqSnapWriter {
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
int64_t sver;
|
int64_t sver;
|
||||||
int64_t ever;
|
int64_t ever;
|
||||||
TXN txn;
|
TXN* txn;
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||||
|
@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
if (tdbBegin(pTq->pMetaStore, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||||
ASSERT(0);
|
code = -1;
|
||||||
|
taosMemoryFree(pWriter);
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
|
@ -165,11 +167,12 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
|
tdbAbort(pWriter->pTq->pMetaStore, pWriter->txn);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
} else {
|
} else {
|
||||||
code = tdbCommit(pWriter->pTq->pMetaStore, &pWriter->txn);
|
code = tdbCommit(pWriter->pTq->pMetaStore, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
code = tdbPostCommit(pWriter->pTq->pMetaStore, &pWriter->txn);
|
code = tdbPostCommit(pWriter->pTq->pMetaStore, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -952,7 +952,10 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
||||||
SArray *pDelIdxArray = taosArrayInit(32, sizeof(SDelIdx));
|
SArray *pDelIdxArray = taosArrayInit(32, sizeof(SDelIdx));
|
||||||
|
|
||||||
code = tsdbReadDelIdx(pDelFReader, pDelIdxArray);
|
code = tsdbReadDelIdx(pDelFReader, pDelIdxArray);
|
||||||
if (code) goto _err;
|
if (code) {
|
||||||
|
tsdbDelFReaderClose(&pDelFReader);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
SDelIdx *delIdx = taosArraySearch(pDelIdxArray, &(SDelIdx){.suid = suid, .uid = uid}, tCmprDelIdx, TD_EQ);
|
SDelIdx *delIdx = taosArraySearch(pDelIdxArray, &(SDelIdx){.suid = suid, .uid = uid}, tCmprDelIdx, TD_EQ);
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct {
|
||||||
// --------------
|
// --------------
|
||||||
TSKEY nextKey; // reset by each table commit
|
TSKEY nextKey; // reset by each table commit
|
||||||
int32_t commitFid;
|
int32_t commitFid;
|
||||||
|
int32_t expLevel;
|
||||||
TSKEY minKey;
|
TSKEY minKey;
|
||||||
TSKEY maxKey;
|
TSKEY maxKey;
|
||||||
// commit file data
|
// commit file data
|
||||||
|
@ -93,7 +94,7 @@ typedef struct {
|
||||||
SArray *aDelData; // SArray<SDelData>
|
SArray *aDelData; // SArray<SDelData>
|
||||||
} SCommitter;
|
} SCommitter;
|
||||||
|
|
||||||
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter);
|
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter, SCommitInfo *pInfo);
|
||||||
static int32_t tsdbCommitData(SCommitter *pCommitter);
|
static int32_t tsdbCommitData(SCommitter *pCommitter);
|
||||||
static int32_t tsdbCommitDel(SCommitter *pCommitter);
|
static int32_t tsdbCommitDel(SCommitter *pCommitter);
|
||||||
static int32_t tsdbCommitCache(SCommitter *pCommitter);
|
static int32_t tsdbCommitCache(SCommitter *pCommitter);
|
||||||
|
@ -150,18 +151,28 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbCommit(STsdb *pTsdb) {
|
int32_t tsdbPrepareCommit(STsdb *pTsdb) {
|
||||||
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
|
ASSERT(pTsdb->imem == NULL);
|
||||||
|
pTsdb->imem = pTsdb->mem;
|
||||||
|
pTsdb->mem = NULL;
|
||||||
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbCommit(STsdb *pTsdb, SCommitInfo *pInfo) {
|
||||||
if (!pTsdb) return 0;
|
if (!pTsdb) return 0;
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
SCommitter commith;
|
SCommitter commith;
|
||||||
SMemTable *pMemTable = pTsdb->mem;
|
SMemTable *pMemTable = pTsdb->imem;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
||||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
pTsdb->mem = NULL;
|
pTsdb->imem = NULL;
|
||||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
tsdbUnrefMemTable(pMemTable);
|
tsdbUnrefMemTable(pMemTable);
|
||||||
|
@ -169,7 +180,7 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// start commit
|
// start commit
|
||||||
code = tsdbStartCommit(pTsdb, &commith);
|
code = tsdbStartCommit(pTsdb, &commith, pInfo);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// commit impl
|
// commit impl
|
||||||
|
@ -493,6 +504,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision);
|
||||||
|
pCommitter->expLevel = tsdbFidLevel(pCommitter->commitFid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec());
|
||||||
tsdbFidKeyRange(pCommitter->commitFid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
|
tsdbFidKeyRange(pCommitter->commitFid, pCommitter->minutes, pCommitter->precision, &pCommitter->minKey,
|
||||||
&pCommitter->maxKey);
|
&pCommitter->maxKey);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -546,7 +558,10 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SDiskID did = {0};
|
SDiskID did = {0};
|
||||||
tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did);
|
if (tfsAllocDisk(pTsdb->pVnode->pTfs, pCommitter->expLevel, &did) < 0) {
|
||||||
|
code = terrno;
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
|
tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
|
||||||
wSet.diskId = did;
|
wSet.diskId = did;
|
||||||
wSet.nSttF = 1;
|
wSet.nSttF = 1;
|
||||||
|
@ -806,26 +821,21 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter, SCommitInfo *pInfo) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
memset(pCommitter, 0, sizeof(*pCommitter));
|
memset(pCommitter, 0, sizeof(*pCommitter));
|
||||||
ASSERT(pTsdb->mem && pTsdb->imem == NULL && "last tsdb commit incomplete");
|
ASSERT(pTsdb->imem && "last tsdb commit incomplete");
|
||||||
|
|
||||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
|
||||||
pTsdb->imem = pTsdb->mem;
|
|
||||||
pTsdb->mem = NULL;
|
|
||||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
|
||||||
|
|
||||||
pCommitter->pTsdb = pTsdb;
|
pCommitter->pTsdb = pTsdb;
|
||||||
pCommitter->commitID = pTsdb->pVnode->state.commitID;
|
pCommitter->commitID = pInfo->info.state.commitID;
|
||||||
pCommitter->minutes = pTsdb->keepCfg.days;
|
pCommitter->minutes = pTsdb->keepCfg.days;
|
||||||
pCommitter->precision = pTsdb->keepCfg.precision;
|
pCommitter->precision = pTsdb->keepCfg.precision;
|
||||||
pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows;
|
pCommitter->minRow = pInfo->info.config.tsdbCfg.minRows;
|
||||||
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
pCommitter->maxRow = pInfo->info.config.tsdbCfg.maxRows;
|
||||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression;
|
||||||
pCommitter->sttTrigger = pTsdb->pVnode->config.sttTrigger;
|
pCommitter->sttTrigger = pInfo->info.config.sttTrigger;
|
||||||
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
||||||
if (pCommitter->aTbDataP == NULL) {
|
if (pCommitter->aTbDataP == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -962,6 +962,7 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDFileSet->diskId = pSet->diskId;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,9 @@ struct STsdbReader {
|
||||||
SIOCostSummary cost;
|
SIOCostSummary cost;
|
||||||
STSchema* pSchema; // the newest version schema
|
STSchema* pSchema; // the newest version schema
|
||||||
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
||||||
SDataFReader* pFileReader;
|
SDataFReader* pFileReader; // the file reader
|
||||||
|
SDelFReader* pDelFReader; // the del file reader
|
||||||
|
SArray* pDelIdx; // del file block index;
|
||||||
SVersionRange verRange;
|
SVersionRange verRange;
|
||||||
SBlockInfoBuf blockInfoBuf;
|
SBlockInfoBuf blockInfoBuf;
|
||||||
int32_t step;
|
int32_t step;
|
||||||
|
@ -212,6 +214,7 @@ static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader);
|
||||||
static int32_t doBuildDataBlock(STsdbReader* pReader);
|
static int32_t doBuildDataBlock(STsdbReader* pReader);
|
||||||
static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
|
static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
|
||||||
static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo);
|
static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo);
|
||||||
|
static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter);
|
||||||
|
|
||||||
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
||||||
|
|
||||||
|
@ -2475,9 +2478,40 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||||
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
||||||
|
|
||||||
|
int32_t nextIndex = -1;
|
||||||
|
SBlockIndex bIndex = {0};
|
||||||
|
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||||
|
if (!hasNeighbor) { // do nothing
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (overlapWithNeighborBlock(pBlock, &bIndex, pReader->order)) { // load next block
|
||||||
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||||
|
|
||||||
|
// 1. find the next neighbor block in the scan block list
|
||||||
|
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||||
|
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||||
|
|
||||||
|
// 2. remove it from the scan block list
|
||||||
|
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||||
|
|
||||||
|
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||||
|
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. check the data values
|
||||||
|
initBlockDumpInfo(pReader, pBlockIter);
|
||||||
|
} else {
|
||||||
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2531,42 +2565,18 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STsdb* pTsdb = pReader->pTsdb;
|
|
||||||
|
|
||||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
|
ASSERT(pReader->pReadSnap != NULL);
|
||||||
|
|
||||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||||
if (pDelFile) {
|
if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) {
|
||||||
SDelFReader* pDelFReader = NULL;
|
|
||||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SArray* aDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
|
||||||
if (aDelIdx == NULL) {
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: opt the perf of read del index
|
|
||||||
code = tsdbReadDelIdx(pDelFReader, aDelIdx);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
taosArrayDestroy(aDelIdx);
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
||||||
SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
SDelIdx* pIdx = taosArraySearch(pReader->pDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||||
|
|
||||||
if (pIdx != NULL) {
|
if (pIdx != NULL) {
|
||||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData);
|
code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(aDelIdx);
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -2662,6 +2672,30 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pIndexList);
|
taosArrayDestroy(pIndexList);
|
||||||
|
|
||||||
|
if (pReader->pReadSnap != NULL) {
|
||||||
|
|
||||||
|
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||||
|
if (pReader->pDelFReader == NULL && pDelFile != NULL) {
|
||||||
|
int32_t code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pReader->pTsdb);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
pReader->pDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
||||||
|
if (pReader->pDelIdx == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tsdbReadDelIdx(pReader->pDelFReader, pReader->pDelIdx);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosArrayDestroy(pReader->pDelIdx);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2886,7 +2920,7 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the correct start position in case of the first/last file block, according to the query time window
|
// set the correct start position in case of the first/last file block, according to the query time window
|
||||||
static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
|
void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
|
||||||
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
||||||
|
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
@ -3095,7 +3129,7 @@ bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32
|
||||||
return false;
|
return false;
|
||||||
} else if (pKey->ts == last->ts) {
|
} else if (pKey->ts == last->ts) {
|
||||||
TSDBKEY* prev = taosArrayGet(pDelList, num - 2);
|
TSDBKEY* prev = taosArrayGet(pDelList, num - 2);
|
||||||
return (prev->version >= pKey->version);
|
return (prev->version >= pKey->version && prev->version <= pVerRange->maxVer && prev->version >= pVerRange->minVer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TSDBKEY* pCurrent = taosArrayGet(pDelList, *index);
|
TSDBKEY* pCurrent = taosArrayGet(pDelList, *index);
|
||||||
|
@ -3912,6 +3946,15 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
||||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pReader->pDelFReader != NULL) {
|
||||||
|
tsdbDelFReaderClose(&pReader->pDelFReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pReader->pDelIdx != NULL) {
|
||||||
|
taosArrayDestroy(pReader->pDelIdx);
|
||||||
|
pReader->pDelIdx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr);
|
tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr);
|
||||||
|
|
||||||
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
|
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
|
||||||
|
@ -3953,6 +3996,9 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
blockDataCleanup(pBlock);
|
blockDataCleanup(pBlock);
|
||||||
|
|
||||||
SReaderStatus* pStatus = &pReader->status;
|
SReaderStatus* pStatus = &pReader->status;
|
||||||
|
if (taosHashGetSize(pStatus->pTableMap) == 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (pStatus->loadFromFile) {
|
if (pStatus->loadFromFile) {
|
||||||
int32_t code = buildBlockFromFiles(pReader);
|
int32_t code = buildBlockFromFiles(pReader);
|
||||||
|
@ -3970,8 +4016,6 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
buildBlockFromBufferSequentially(pReader);
|
buildBlockFromBufferSequentially(pReader);
|
||||||
return pBlock->info.rows > 0;
|
return pBlock->info.rows > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tsdbNextDataBlock(STsdbReader* pReader) {
|
bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
|
@ -4043,8 +4087,34 @@ void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg ***pBlockSMA, bool* allHave) {
|
|
||||||
|
static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols,
|
||||||
|
SColumnDataAgg* pTsAgg) {
|
||||||
|
// do fill all null column value SMA info
|
||||||
|
int32_t i = 0, j = 0;
|
||||||
|
int32_t size = (int32_t) taosArrayGetSize(pSup->pColAgg);
|
||||||
|
taosArrayInsert(pSup->pColAgg, 0, pTsAgg);
|
||||||
|
|
||||||
|
while (j < numOfCols && i < size) {
|
||||||
|
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||||
|
if (pAgg->colId == pSup->colId[j]) {
|
||||||
|
i += 1;
|
||||||
|
j += 1;
|
||||||
|
} else if (pAgg->colId < pSup->colId[j]) {
|
||||||
|
i += 1;
|
||||||
|
} else if (pSup->colId[j] < pAgg->colId) {
|
||||||
|
if (pSup->colId[j] != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
|
SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = numOfRows};
|
||||||
|
taosArrayInsert(pSup->pColAgg, i ,&nullColAgg);
|
||||||
|
}
|
||||||
|
j += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SColumnDataAgg ***pBlockSMA = &pDataBlock->pBlockAgg;
|
||||||
*allHave = false;
|
*allHave = false;
|
||||||
|
|
||||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||||
|
@ -4092,12 +4162,22 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg ***pBlockS
|
||||||
int32_t i = 0, j = 0;
|
int32_t i = 0, j = 0;
|
||||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||||
|
|
||||||
|
// ensure capacity
|
||||||
|
if(pDataBlock->pDataBlock) {
|
||||||
|
size_t colsNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
|
taosArrayEnsureCap(pSup->pColAgg, colsNum);
|
||||||
|
}
|
||||||
|
|
||||||
SSDataBlock* pResBlock = pReader->pResBlock;
|
SSDataBlock* pResBlock = pReader->pResBlock;
|
||||||
if (pResBlock->pBlockAgg == NULL) {
|
if (pResBlock->pBlockAgg == NULL) {
|
||||||
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
||||||
pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg));
|
pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do fill all null column value SMA info
|
||||||
|
doFillNullColSMA(pSup, pBlock->nRow, numOfCols, pTsAgg);
|
||||||
|
|
||||||
|
i = 0, j = 0;
|
||||||
while (j < numOfCols && i < size) {
|
while (j < numOfCols && i < size) {
|
||||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||||
if (pAgg->colId == pSup->colId[j]) {
|
if (pAgg->colId == pSup->colId[j]) {
|
||||||
|
@ -4107,15 +4187,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg ***pBlockS
|
||||||
} else if (pAgg->colId < pSup->colId[j]) {
|
} else if (pAgg->colId < pSup->colId[j]) {
|
||||||
i += 1;
|
i += 1;
|
||||||
} else if (pSup->colId[j] < pAgg->colId) {
|
} else if (pSup->colId[j] < pAgg->colId) {
|
||||||
if (pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
||||||
} else {
|
|
||||||
// all date in this block are null
|
|
||||||
SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = pBlock->nRow};
|
|
||||||
taosArrayPush(pSup->pColAgg, &nullColAgg);
|
|
||||||
|
|
||||||
pResBlock->pBlockAgg[pSup->slotId[j]] = taosArrayGetLast(pSup->pColAgg);
|
|
||||||
}
|
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -750,7 +750,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
||||||
// head
|
// head
|
||||||
tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom);
|
tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom);
|
||||||
tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo);
|
tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo);
|
||||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||||
if (pOutFD == NULL) {
|
if (pOutFD == NULL) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -771,7 +771,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
||||||
// data
|
// data
|
||||||
tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom);
|
tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom);
|
||||||
tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo);
|
tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo);
|
||||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||||
if (pOutFD == NULL) {
|
if (pOutFD == NULL) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -781,7 +781,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
n = taosFSendFile(pOutFD, PInFD, 0, LOGIC_TO_FILE_OFFSET(pSetFrom->pDataF->size, szPage));
|
n = taosFSendFile(pOutFD, PInFD, 0, tsdbLogicToFileSize(pSetFrom->pDataF->size, szPage));
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -792,7 +792,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
||||||
// sma
|
// sma
|
||||||
tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom);
|
tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom);
|
||||||
tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo);
|
tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo);
|
||||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||||
if (pOutFD == NULL) {
|
if (pOutFD == NULL) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -814,7 +814,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
||||||
for (int8_t iStt = 0; iStt < pSetFrom->nSttF; iStt++) {
|
for (int8_t iStt = 0; iStt < pSetFrom->nSttF; iStt++) {
|
||||||
tsdbSttFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->aSttF[iStt], fNameFrom);
|
tsdbSttFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->aSttF[iStt], fNameFrom);
|
||||||
tsdbSttFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->aSttF[iStt], fNameTo);
|
tsdbSttFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->aSttF[iStt], fNameTo);
|
||||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||||
if (pOutFD == NULL) {
|
if (pOutFD == NULL) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -1477,9 +1477,8 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||||
}
|
}
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
}
|
}
|
||||||
*ppReader = NULL;
|
|
||||||
|
|
||||||
_exit:
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
||||||
|
|
||||||
if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
|
if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
|
||||||
pIter->rInfo.suid = pIter->bData.suid;
|
pIter->rInfo.suid = pIter->bData.suid;
|
||||||
pIter->rInfo.uid = pIter->bData.uid;
|
pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow];
|
||||||
pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
|
pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
|
||||||
goto _add_iter;
|
goto _add_iter;
|
||||||
}
|
}
|
||||||
|
@ -179,16 +179,14 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) { return pReader->pIter ? &pReader->pIter->rInfo : NULL; }
|
|
||||||
|
|
||||||
static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pReader->pIter) {
|
if (pReader->pIter) {
|
||||||
SFDataIter* pIter = pReader->pIter;
|
SFDataIter* pIter = NULL;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
_find_row:
|
_find_row:
|
||||||
|
pIter = pReader->pIter;
|
||||||
for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
|
for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
|
||||||
int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
|
int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
|
||||||
|
|
||||||
|
@ -224,6 +222,7 @@ static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->pIter = NULL;
|
pReader->pIter = NULL;
|
||||||
|
break;
|
||||||
} else if (pIter->type == SNAP_STT_FILE_ITER) {
|
} else if (pIter->type == SNAP_STT_FILE_ITER) {
|
||||||
for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
|
for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
|
||||||
SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
|
SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
|
||||||
|
@ -238,6 +237,7 @@ static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->pIter = NULL;
|
pReader->pIter = NULL;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,20 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) {
|
||||||
|
if (pReader->pIter) {
|
||||||
|
return &pReader->pIter->rInfo;
|
||||||
|
} else {
|
||||||
|
tsdbSnapNextRow(pReader);
|
||||||
|
|
||||||
|
if (pReader->pIter) {
|
||||||
|
return &pReader->pIter->rInfo;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -1356,7 +1370,7 @@ _exit:
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tsdbDebug("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
|
tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
@ -1421,7 +1435,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||||
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
|
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
|
||||||
tFree(pWriter->aBuf[iBuf]);
|
tFree(pWriter->aBuf[iBuf]);
|
||||||
}
|
}
|
||||||
tsdbInfo("vgId:%d, vnode snapshot tsdb writer close for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
|
tsdbInfo("vgId:%d %s done", TD_VID(pWriter->pTsdb->pVnode), __func__);
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
#define VND_INFO_FNAME "vnode.json"
|
#define VND_INFO_FNAME "vnode.json"
|
||||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||||
|
|
||||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo);
|
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo);
|
||||||
static int vnodeCommitImpl(void *arg);
|
static int vnodeCommitImpl(SCommitInfo *pInfo);
|
||||||
static void vnodeWaitCommit(SVnode *pVnode);
|
|
||||||
|
|
||||||
int vnodeBegin(SVnode *pVnode) {
|
int vnodeBegin(SVnode *pVnode) {
|
||||||
// alloc buffer pool
|
// alloc buffer pool
|
||||||
|
@ -107,7 +107,8 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
||||||
// free info binary
|
// free info binary
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
|
|
||||||
vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname, pInfo->config.syncCfg.replicaNum);
|
vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname,
|
||||||
|
pInfo->config.syncCfg.replicaNum);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -185,29 +186,77 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vnodePrepareCommit(SVnode *pVnode) {
|
||||||
|
tsem_wait(&pVnode->canCommit);
|
||||||
|
|
||||||
|
tsdbPrepareCommit(pVnode->pTsdb);
|
||||||
|
metaPrepareAsyncCommit(pVnode->pMeta);
|
||||||
|
smaPrepareAsyncCommit(pVnode->pSma);
|
||||||
|
|
||||||
|
vnodeBufPoolUnRef(pVnode->inUse);
|
||||||
|
pVnode->inUse = NULL;
|
||||||
|
}
|
||||||
|
static int32_t vnodeCommitTask(void *arg) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
SCommitInfo *pInfo = (SCommitInfo *)arg;
|
||||||
|
|
||||||
|
// commit
|
||||||
|
code = vnodeCommitImpl(pInfo);
|
||||||
|
if (code) goto _exit;
|
||||||
|
|
||||||
|
// end commit
|
||||||
|
tsem_post(&pInfo->pVnode->canCommit);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
taosMemoryFree(pInfo);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
int vnodeAsyncCommit(SVnode *pVnode) {
|
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||||
vnodeWaitCommit(pVnode);
|
int32_t code = 0;
|
||||||
|
|
||||||
// vnodeBufPoolSwitch(pVnode);
|
// prepare to commit
|
||||||
// tsdbPrepareCommit(pVnode->pTsdb);
|
vnodePrepareCommit(pVnode);
|
||||||
|
|
||||||
vnodeScheduleTask(vnodeCommitImpl, pVnode);
|
// schedule the task
|
||||||
|
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||||
|
|
||||||
return 0;
|
SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo));
|
||||||
|
if (NULL == pInfo) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
pInfo->info.config = pVnode->config;
|
||||||
|
pInfo->info.state.committed = pVnode->state.applied;
|
||||||
|
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
|
||||||
|
pInfo->info.state.commitID = pVnode->state.commitID;
|
||||||
|
pInfo->pVnode = pVnode;
|
||||||
|
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||||
|
vnodeScheduleTask(vnodeCommitTask, pInfo);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
vError("vgId:%d %s failed since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, tstrerror(code),
|
||||||
|
pVnode->state.commitID);
|
||||||
|
} else {
|
||||||
|
vDebug("vgId:%d %s done", TD_VID(pVnode), __func__);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeSyncCommit(SVnode *pVnode) {
|
int vnodeSyncCommit(SVnode *pVnode) {
|
||||||
vnodeAsyncCommit(pVnode);
|
vnodeAsyncCommit(pVnode);
|
||||||
vnodeWaitCommit(pVnode);
|
tsem_wait(&pVnode->canCommit);
|
||||||
tsem_post(&(pVnode->canCommit));
|
tsem_post(&pVnode->canCommit);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeCommit(SVnode *pVnode) {
|
static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
SVnodeInfo info = {0};
|
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN] = {0};
|
||||||
|
SVnode *pVnode = pInfo->pVnode;
|
||||||
|
|
||||||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
||||||
pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm);
|
pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm);
|
||||||
|
@ -218,19 +267,13 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
|
||||||
|
|
||||||
// save info
|
// save info
|
||||||
info.config = pVnode->config;
|
|
||||||
info.state.committed = pVnode->state.applied;
|
|
||||||
info.state.commitTerm = pVnode->state.applyTerm;
|
|
||||||
info.state.commitID = pVnode->state.commitID;
|
|
||||||
if (pVnode->pTfs) {
|
if (pVnode->pTfs) {
|
||||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||||
} else {
|
} else {
|
||||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||||
}
|
}
|
||||||
if (vnodeSaveInfo(dir, &info) < 0) {
|
if (vnodeSaveInfo(dir, &pInfo->info) < 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
@ -238,23 +281,12 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||||
syncBeginSnapshot(pVnode->sync, pVnode->state.applied);
|
syncBeginSnapshot(pVnode->sync, pVnode->state.applied);
|
||||||
|
|
||||||
code = smaPreCommit(pVnode->pSma);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
|
|
||||||
vnodeBufPoolUnRef(pVnode->inUse);
|
|
||||||
pVnode->inUse = NULL;
|
|
||||||
|
|
||||||
// commit each sub-system
|
// commit each sub-system
|
||||||
if (metaCommit(pVnode->pMeta) < 0) {
|
code = tsdbCommit(pVnode->pTsdb, pInfo);
|
||||||
code = TSDB_CODE_FAILED;
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tsdbCommit(pVnode->pTsdb);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
if (VND_IS_RSMA(pVnode)) {
|
if (VND_IS_RSMA(pVnode)) {
|
||||||
code = smaCommit(pVnode->pSma);
|
code = smaCommit(pVnode->pSma, pInfo);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +296,7 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit info
|
// commit info
|
||||||
if (vnodeCommitInfo(dir, &info) < 0) {
|
if (vnodeCommitInfo(dir, &pInfo->info) < 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
@ -277,19 +309,18 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaFinishCommit(pVnode->pMeta) < 0) {
|
if (metaFinishCommit(pVnode->pMeta, pInfo->txn) < 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->state.committed = info.state.committed;
|
pVnode->state.committed = pInfo->info.state.committed;
|
||||||
|
|
||||||
if (smaPostCommit(pVnode->pSma) < 0) {
|
if (smaPostCommit(pVnode->pSma) < 0) {
|
||||||
vError("vgId:%d, failed to post-commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d, failed to post-commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply the commit (TODO)
|
|
||||||
// walEndSnapshot(pVnode->pWal);
|
// walEndSnapshot(pVnode->pWal);
|
||||||
syncEndSnapshot(pVnode->sync);
|
syncEndSnapshot(pVnode->sync);
|
||||||
|
|
||||||
|
@ -318,20 +349,6 @@ void vnodeRollback(SVnode *pVnode) {
|
||||||
(void)taosRemoveFile(tFName);
|
(void)taosRemoveFile(tFName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeCommitImpl(void *arg) {
|
|
||||||
SVnode *pVnode = (SVnode *)arg;
|
|
||||||
|
|
||||||
// metaCommit(pVnode->pMeta);
|
|
||||||
tqCommit(pVnode->pTq);
|
|
||||||
// tsdbCommit(pVnode->pTsdb, );
|
|
||||||
|
|
||||||
// vnodeBufPoolRecycle(pVnode);
|
|
||||||
tsem_post(&(pVnode->canCommit));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); }
|
|
||||||
|
|
||||||
static int vnodeEncodeState(const void *pObj, SJson *pJson) {
|
static int vnodeEncodeState(const void *pObj, SJson *pJson) {
|
||||||
const SVState *pState = (SVState *)pObj;
|
const SVState *pState = (SVState *)pObj;
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ void vnodePreClose(SVnode *pVnode) {
|
||||||
|
|
||||||
void vnodeClose(SVnode *pVnode) {
|
void vnodeClose(SVnode *pVnode) {
|
||||||
if (pVnode) {
|
if (pVnode) {
|
||||||
vnodeCommit(pVnode);
|
vnodeSyncCommit(pVnode);
|
||||||
vnodeSyncClose(pVnode);
|
vnodeSyncClose(pVnode);
|
||||||
vnodeQueryClose(pVnode);
|
vnodeQueryClose(pVnode);
|
||||||
walClose(pVnode->pWal);
|
walClose(pVnode->pWal);
|
||||||
|
|
|
@ -259,7 +259,7 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
// commit it
|
// commit it
|
||||||
code = vnodeCommit(pVnode);
|
code = vnodeSyncCommit(pVnode);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -181,17 +181,22 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
if (version <= pVnode->state.applied) {
|
if (version <= pVnode->state.applied) {
|
||||||
vError("vgId:%d, duplicate write request. version: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), version,
|
vError("vgId:%d, duplicate write request. version: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), version,
|
||||||
pVnode->state.applied);
|
pVnode->state.applied);
|
||||||
|
terrno = TSDB_CODE_VND_DUP_REQUEST;
|
||||||
pRsp->info.handle = NULL;
|
pRsp->info.handle = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("vgId:%d, start to process write request %s, index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
vDebug("vgId:%d, start to process write request %s, index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
||||||
version);
|
version);
|
||||||
|
|
||||||
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
||||||
|
ASSERT(pVnode->state.applied + 1 == version);
|
||||||
|
|
||||||
pVnode->state.applied = version;
|
pVnode->state.applied = version;
|
||||||
pVnode->state.applyTerm = pMsg->info.conn.applyTerm;
|
pVnode->state.applyTerm = pMsg->info.conn.applyTerm;
|
||||||
|
|
||||||
|
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
||||||
|
|
||||||
// skip header
|
// skip header
|
||||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
len = pMsg->contLen - sizeof(SMsgHead);
|
len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
@ -291,7 +296,9 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
vnodeProcessAlterConfigReq(pVnode, version, pReq, len, pRsp);
|
vnodeProcessAlterConfigReq(pVnode, version, pReq, len, pRsp);
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_COMMIT:
|
case TDMT_VND_COMMIT:
|
||||||
goto _do_commit;
|
vnodeSyncCommit(pVnode);
|
||||||
|
vnodeBegin(pVnode);
|
||||||
|
goto _exit;
|
||||||
default:
|
default:
|
||||||
vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType);
|
vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -309,13 +316,12 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
|
|
||||||
// commit if need
|
// commit if need
|
||||||
if (vnodeShouldCommit(pVnode)) {
|
if (vnodeShouldCommit(pVnode)) {
|
||||||
_do_commit:
|
|
||||||
vInfo("vgId:%d, commit at version %" PRId64, TD_VID(pVnode), version);
|
vInfo("vgId:%d, commit at version %" PRId64, TD_VID(pVnode), version);
|
||||||
// commit current change
|
#if 0
|
||||||
if (vnodeCommit(pVnode) < 0) {
|
vnodeSyncCommit(pVnode);
|
||||||
vError("vgId:%d, failed to commit vnode since %s.", TD_VID(pVnode), tstrerror(terrno));
|
#else
|
||||||
goto _err;
|
vnodeAsyncCommit(pVnode);
|
||||||
}
|
#endif
|
||||||
|
|
||||||
// start a new one
|
// start a new one
|
||||||
if (vnodeBegin(pVnode) < 0) {
|
if (vnodeBegin(pVnode) < 0) {
|
||||||
|
@ -324,6 +330,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
|
@ -18,14 +18,15 @@
|
||||||
|
|
||||||
#define BATCH_ENABLE 0
|
#define BATCH_ENABLE 0
|
||||||
|
|
||||||
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
|
||||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
|
||||||
(type == TDMT_VND_UPDATE_TAG_VAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
||||||
|
|
||||||
static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||||
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
|
vGTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
|
tsem_wait(&pVnode->syncSem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void vnodeWaitBlockMsgOld(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
taosThreadMutexLock(&pVnode->lock);
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
|
@ -115,21 +116,31 @@ static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code)
|
||||||
|
|
||||||
static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) {
|
static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) {
|
||||||
if (*arrSize <= 0) return;
|
if (*arrSize <= 0) return;
|
||||||
|
SRpcMsg *pLastMsg = pMsgArr[*arrSize - 1];
|
||||||
|
|
||||||
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize);
|
int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize);
|
||||||
|
bool wait = (code == 0 && vnodeIsBlockMsg(pLastMsg->msgType));
|
||||||
|
if (wait) {
|
||||||
|
ASSERT(!pVnode->blocked);
|
||||||
|
pVnode->blocked = true;
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pVnode->lock);
|
||||||
|
|
||||||
if (code > 0) {
|
if (code > 0) {
|
||||||
for (int32_t i = 0; i < *arrSize; ++i) {
|
for (int32_t i = 0; i < *arrSize; ++i) {
|
||||||
vnodeHandleWriteMsg(pVnode, pMsgArr[i]);
|
vnodeHandleWriteMsg(pVnode, pMsgArr[i]);
|
||||||
}
|
}
|
||||||
} else if (code == 0) {
|
} else if (code < 0) {
|
||||||
vnodeWaitBlockMsg(pVnode, pMsgArr[*arrSize - 1]);
|
|
||||||
} else {
|
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
for (int32_t i = 0; i < *arrSize; ++i) {
|
for (int32_t i = 0; i < *arrSize; ++i) {
|
||||||
vnodeHandleProposeError(pVnode, pMsgArr[i], code);
|
vnodeHandleProposeError(pVnode, pMsgArr[i], code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wait) vnodeWaitBlockMsg(pVnode, pLastMsg);
|
||||||
|
pLastMsg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < *arrSize; ++i) {
|
for (int32_t i = 0; i < *arrSize; ++i) {
|
||||||
SRpcMsg *pMsg = pMsgArr[i];
|
SRpcMsg *pMsg = pMsgArr[i];
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
|
@ -206,16 +217,23 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) {
|
static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) {
|
||||||
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak);
|
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak);
|
||||||
|
bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType));
|
||||||
|
if (wait) {
|
||||||
|
ASSERT(!pVnode->blocked);
|
||||||
|
pVnode->blocked = true;
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pVnode->lock);
|
||||||
|
|
||||||
if (code > 0) {
|
if (code > 0) {
|
||||||
vnodeHandleWriteMsg(pVnode, pMsg);
|
vnodeHandleWriteMsg(pVnode, pMsg);
|
||||||
} else if (code == 0) {
|
} else if (code < 0) {
|
||||||
vnodeWaitBlockMsg(pVnode, pMsg);
|
|
||||||
} else {
|
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
vnodeHandleProposeError(pVnode, pMsg, code);
|
vnodeHandleProposeError(pVnode, pMsg, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wait) vnodeWaitBlockMsg(pVnode, pMsg);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +292,11 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64, vgId, pMsg,
|
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64, vgId, pMsg,
|
||||||
TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex);
|
TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex);
|
||||||
|
|
||||||
|
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||||
|
vTrace("vgId:%d, blocking msg obtained from apply-queue. index:%" PRId64 ", term: %" PRId64 ", type: %s", vgId,
|
||||||
|
pMsg->info.conn.applyIndex, pMsg->info.conn.applyTerm, TMSG_INFO(pMsg->msgType));
|
||||||
|
}
|
||||||
|
|
||||||
SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info};
|
SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info};
|
||||||
if (rsp.code == 0) {
|
if (rsp.code == 0) {
|
||||||
if (vnodeProcessWriteMsg(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) {
|
if (vnodeProcessWriteMsg(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) {
|
||||||
|
@ -583,16 +606,7 @@ void vnodeSyncPreClose(SVnode *pVnode) {
|
||||||
vInfo("vgId:%d, pre close sync", pVnode->config.vgId);
|
vInfo("vgId:%d, pre close sync", pVnode->config.vgId);
|
||||||
syncLeaderTransfer(pVnode->sync);
|
syncLeaderTransfer(pVnode->sync);
|
||||||
syncPreStop(pVnode->sync);
|
syncPreStop(pVnode->sync);
|
||||||
#if 0
|
|
||||||
while (syncSnapshotRecving(pVnode->sync)) {
|
|
||||||
vInfo("vgId:%d, snapshot is recving", pVnode->config.vgId);
|
|
||||||
taosMsleep(300);
|
|
||||||
}
|
|
||||||
while (syncSnapshotSending(pVnode->sync)) {
|
|
||||||
vInfo("vgId:%d, snapshot is sending", pVnode->config.vgId);
|
|
||||||
taosMsleep(300);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
taosThreadMutexLock(&pVnode->lock);
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
if (pVnode->blocked) {
|
if (pVnode->blocked) {
|
||||||
vInfo("vgId:%d, post block after close sync", pVnode->config.vgId);
|
vInfo("vgId:%d, post block after close sync", pVnode->config.vgId);
|
||||||
|
|
|
@ -547,6 +547,14 @@ typedef struct SCtgOperation {
|
||||||
#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__)
|
#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__)
|
||||||
#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__)
|
#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define ctgTaskFatal(param, ...) qFatal("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskError(param, ...) qError("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskWarn(param, ...) qWarn("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskInfo(param, ...) qInfo("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskDebug(param, ...) qDebug("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
#define ctgTaskTrace(param, ...) qTrace("QID:%" PRIx64 " CTG:%p " param, pTask->pJob->queryId, pCtg, __VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
#define CTG_LOCK_DEBUG(...) \
|
#define CTG_LOCK_DEBUG(...) \
|
||||||
do { \
|
do { \
|
||||||
if (gCTGDebug.lockEnable) { \
|
if (gCTGDebug.lockEnable) { \
|
||||||
|
@ -762,7 +770,6 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput)
|
||||||
int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList);
|
int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList);
|
||||||
void ctgFreeJob(void* job);
|
void ctgFreeJob(void* job);
|
||||||
void ctgFreeHandleImpl(SCatalog* pCtg);
|
void ctgFreeHandleImpl(SCatalog* pCtg);
|
||||||
void ctgFreeVgInfo(SDBVgInfo* vgInfo);
|
|
||||||
int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup);
|
int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup);
|
||||||
int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx,
|
int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx,
|
||||||
char* dbFName, SArray* pNames, bool update);
|
char* dbFName, SArray* pNames, bool update);
|
||||||
|
@ -789,6 +796,11 @@ int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName);
|
||||||
int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||||
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
|
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
|
||||||
int32_t ctgdGetOneHandle(SCatalog **pHandle);
|
int32_t ctgdGetOneHandle(SCatalog **pHandle);
|
||||||
|
int ctgVgInfoComp(const void* lp, const void* rp);
|
||||||
|
int32_t ctgMakeVgArray(SDBVgInfo* dbInfo);
|
||||||
|
int32_t ctgAcquireVgMetaFromCache(SCatalog *pCtg, const char *dbFName, const char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb);
|
||||||
|
int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCtgTbCache **pTb, STableMeta **pTableMeta, char* dbFName);
|
||||||
|
void ctgReleaseVgMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache *pCache);
|
||||||
|
|
||||||
extern SCatalogMgmt gCtgMgmt;
|
extern SCatalogMgmt gCtgMgmt;
|
||||||
extern SCtgDebug gCTGDebug;
|
extern SCtgDebug gCTGDebug;
|
||||||
|
|
|
@ -505,8 +505,7 @@ _return:
|
||||||
taosMemoryFreeClear(tbMeta);
|
taosMemoryFreeClear(tbMeta);
|
||||||
|
|
||||||
if (vgInfo) {
|
if (vgInfo) {
|
||||||
taosHashCleanup(vgInfo->vgHash);
|
freeVgInfo(vgInfo);
|
||||||
taosMemoryFreeClear(vgInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vgList) {
|
if (vgList) {
|
||||||
|
@ -546,13 +545,41 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vgInfo) {
|
if (vgInfo) {
|
||||||
taosHashCleanup(vgInfo->vgHash);
|
freeVgInfo(vgInfo);
|
||||||
taosMemoryFreeClear(vgInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetCachedTbVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, STableMeta** pTableMeta) {
|
||||||
|
int32_t code = 0;
|
||||||
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
|
tNameGetFullDbName(pTableName, db);
|
||||||
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
SCtgTbCache *tbCache = NULL;
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgAcquireVgMetaFromCache(pCtg, db, pTableName->tname, &dbCache, &tbCache));
|
||||||
|
|
||||||
|
if (NULL == dbCache || NULL == tbCache) {
|
||||||
|
*pTableMeta = NULL;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pTableName, pVgroup));
|
||||||
|
|
||||||
|
SCtgTbMetaCtx ctx = {0};
|
||||||
|
ctx.pName = (SName*)pTableName;
|
||||||
|
ctx.flag = CTG_FLAG_UNKNOWN_STB;
|
||||||
|
CTG_ERR_JRET(ctgCopyTbMeta(pCtg, &ctx, &dbCache, &tbCache, pTableMeta, db));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
ctgReleaseVgMetaToCache(pCtg, dbCache, tbCache);
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName) {
|
int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -778,8 +805,7 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vgInfo) {
|
if (vgInfo) {
|
||||||
taosHashCleanup(vgInfo->vgHash);
|
freeVgInfo(vgInfo);
|
||||||
taosMemoryFreeClear(vgInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
|
@ -836,8 +862,7 @@ _return:
|
||||||
ctgRUnlockVgInfo(dbCache);
|
ctgRUnlockVgInfo(dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
} else if (dbInfo) {
|
} else if (dbInfo) {
|
||||||
taosHashCleanup(dbInfo->vgHash);
|
freeVgInfo(dbInfo);
|
||||||
taosMemoryFreeClear(dbInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
|
@ -849,7 +874,7 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == dbFName || NULL == dbInfo) {
|
if (NULL == pCtg || NULL == dbFName || NULL == dbInfo) {
|
||||||
ctgFreeVgInfo(dbInfo);
|
freeVgInfo(dbInfo);
|
||||||
CTG_ERR_JRET(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_ERR_JRET(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,6 +1147,13 @@ int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName,
|
||||||
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, NULL, pTableName, pVgroup, exists));
|
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, NULL, pTableName, pVgroup, exists));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogGetCachedTableVgMeta(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, STableMeta** pTableMeta) {
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
CTG_API_LEAVE(ctgGetCachedTbVgMeta(pCtg, pTableName, pVgroup, pTableMeta));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp) {
|
int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
|
@ -1094,6 +1094,9 @@ _return:
|
||||||
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
ctgTaskError("Get table %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname, tstrerror(code));
|
||||||
|
}
|
||||||
if (pTask->res || code) {
|
if (pTask->res || code) {
|
||||||
ctgHandleTaskEnd(pTask, code);
|
ctgHandleTaskEnd(pTask, code);
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1127,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, pOut->dbVgroup, pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
ctgTaskDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
||||||
|
|
||||||
*vgId = vgInfo.vgId;
|
*vgId = vgInfo.vgId;
|
||||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
||||||
|
@ -1144,7 +1147,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
ctgTaskDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(pName), flag);
|
||||||
|
|
||||||
*vgId = vgInfo.vgId;
|
*vgId = vgInfo.vgId;
|
||||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pName, &vgInfo, NULL, tReq));
|
||||||
|
@ -1162,7 +1165,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgError("no tbmeta got, tbName:%s", tNameGetTableName(pName));
|
ctgTaskError("no tbmeta got, tbName:%s", tNameGetTableName(pName));
|
||||||
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
||||||
|
|
||||||
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
||||||
|
@ -1180,7 +1183,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
|
STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out;
|
||||||
|
|
||||||
if (CTG_IS_META_NULL(pOut->metaType)) {
|
if (CTG_IS_META_NULL(pOut->metaType)) {
|
||||||
ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(pName));
|
ctgTaskError("no tbmeta got, tbNmae:%s", tNameGetTableName(pName));
|
||||||
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
ctgRemoveTbMetaFromCache(pCtg, pName, false);
|
||||||
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
@ -1190,7 +1193,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CTG_IS_META_TABLE(pOut->metaType) && TSDB_SUPER_TABLE == pOut->tbMeta->tableType) {
|
if (CTG_IS_META_TABLE(pOut->metaType) && TSDB_SUPER_TABLE == pOut->tbMeta->tableType) {
|
||||||
ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pName));
|
ctgTaskDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(pName));
|
||||||
|
|
||||||
taosMemoryFreeClear(pOut->tbMeta);
|
taosMemoryFreeClear(pOut->tbMeta);
|
||||||
|
|
||||||
|
@ -1207,11 +1210,11 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
STableMeta* stbMeta = NULL;
|
STableMeta* stbMeta = NULL;
|
||||||
(void)ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
(void)ctgReadTbMetaFromCache(pCtg, &stbCtx, &stbMeta);
|
||||||
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
if (stbMeta && stbMeta->sversion >= pOut->tbMeta->sversion) {
|
||||||
ctgDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgTaskDebug("use cached stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
exist = 1;
|
exist = 1;
|
||||||
taosMemoryFreeClear(stbMeta);
|
taosMemoryFreeClear(stbMeta);
|
||||||
} else {
|
} else {
|
||||||
ctgDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
ctgTaskDebug("need to get/update stb meta, tbName:%s", tNameGetTableName(pName));
|
||||||
taosMemoryFreeClear(pOut->tbMeta);
|
taosMemoryFreeClear(pOut->tbMeta);
|
||||||
taosMemoryFreeClear(stbMeta);
|
taosMemoryFreeClear(stbMeta);
|
||||||
}
|
}
|
||||||
|
@ -1225,7 +1228,7 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ctgError("invalid reqType %d", reqType);
|
ctgTaskError("invalid reqType %d", reqType);
|
||||||
CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
|
CTG_ERR_JRET(TSDB_CODE_INVALID_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,6 +1283,7 @@ _return:
|
||||||
TSWAP(pTask->res, ctx->pResList);
|
TSWAP(pTask->res, ctx->pResList);
|
||||||
taskDone = true;
|
taskDone = true;
|
||||||
}
|
}
|
||||||
|
ctgTaskError("Get table %d.%s.%s meta failed with error %s", pName->acctId, pName->dbname, pName->tname, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->res && taskDone) {
|
if (pTask->res && taskDone) {
|
||||||
|
|
|
@ -130,7 +130,7 @@ void ctgReleaseVgInfoToCache(SCatalog *pCtg, SCtgDBCache *dbCache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgReleaseTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache *pCache) {
|
void ctgReleaseTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache *pCache) {
|
||||||
if (pCache) {
|
if (pCache && dbCache) {
|
||||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||||
taosHashRelease(dbCache->tbCache, pCache);
|
taosHashRelease(dbCache->tbCache, pCache);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +151,18 @@ void ctgReleaseTbIndexToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctgReleaseVgMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache *pCache) {
|
||||||
|
if (pCache && dbCache) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||||
|
taosHashRelease(dbCache->tbCache, pCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbCache) {
|
||||||
|
ctgRUnlockVgInfo(dbCache);
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctgAcquireVgInfoFromCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache) {
|
int32_t ctgAcquireVgInfoFromCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache) {
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||||
|
@ -226,6 +238,76 @@ _return:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgAcquireVgMetaFromCache(SCatalog *pCtg, const char *dbFName, const char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
||||||
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
SCtgTbCache *tbCache = NULL;
|
||||||
|
bool vgInCache = false;
|
||||||
|
|
||||||
|
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||||
|
if (NULL == dbCache) {
|
||||||
|
ctgDebug("db %s not in cache", dbFName);
|
||||||
|
CTG_CACHE_STAT_INC(numOfVgMiss, 1);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgRLockVgInfo(pCtg, dbCache, &vgInCache);
|
||||||
|
if (!vgInCache) {
|
||||||
|
ctgDebug("vgInfo of db %s not in cache", dbFName);
|
||||||
|
CTG_CACHE_STAT_INC(numOfVgMiss, 1);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pDb = dbCache;
|
||||||
|
|
||||||
|
CTG_CACHE_STAT_INC(numOfVgHit, 1);
|
||||||
|
|
||||||
|
ctgDebug("Got db vgInfo from cache, dbFName:%s", dbFName);
|
||||||
|
|
||||||
|
tbCache = taosHashAcquire(dbCache->tbCache, tbName, strlen(tbName));
|
||||||
|
if (NULL == tbCache) {
|
||||||
|
ctgDebug("tb %s not in cache, dbFName:%s", tbName, dbFName);
|
||||||
|
CTG_CACHE_STAT_INC(numOfMetaMiss, 1);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_LOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
if (NULL == tbCache->pMeta) {
|
||||||
|
ctgDebug("tb %s meta not in cache, dbFName:%s", tbName, dbFName);
|
||||||
|
CTG_CACHE_STAT_INC(numOfMetaMiss, 1);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pTb = tbCache;
|
||||||
|
|
||||||
|
ctgDebug("tb %s meta got in cache, dbFName:%s", tbName, dbFName);
|
||||||
|
|
||||||
|
CTG_CACHE_STAT_INC(numOfMetaHit, 1);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
if (tbCache) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
taosHashRelease(dbCache->tbCache, tbCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vgInCache) {
|
||||||
|
ctgRUnlockVgInfo(dbCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dbCache) {
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pDb = NULL;
|
||||||
|
*pTb = NULL;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
SCtgTbCache *pCache = NULL;
|
SCtgTbCache *pCache = NULL;
|
||||||
|
@ -276,6 +358,49 @@ _return:
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int32_t ctgAcquireStbMetaFromCache(SCtgDBCache *dbCache, SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgTbCache **pTb) {
|
||||||
|
SCtgTbCache *pCache = NULL;
|
||||||
|
char *stName = taosHashAcquire(dbCache->stbCache, &suid, sizeof(suid));
|
||||||
|
if (NULL == stName) {
|
||||||
|
ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", suid, dbFName);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pCache = taosHashAcquire(dbCache->tbCache, stName, strlen(stName));
|
||||||
|
if (NULL == pCache) {
|
||||||
|
ctgDebug("stb 0x%" PRIx64 " name %s not in cache, dbFName:%s", suid, stName, dbFName);
|
||||||
|
taosHashRelease(dbCache->stbCache, stName);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashRelease(dbCache->stbCache, stName);
|
||||||
|
|
||||||
|
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||||
|
if (NULL == pCache->pMeta) {
|
||||||
|
ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", suid, dbFName);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pTb = pCache;
|
||||||
|
|
||||||
|
ctgDebug("stb 0x%" PRIx64 " meta got in cache, dbFName:%s", suid, dbFName);
|
||||||
|
|
||||||
|
CTG_CACHE_STAT_INC(numOfMetaHit, 1);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||||
|
|
||||||
|
CTG_CACHE_STAT_INC(numOfMetaMiss, 1);
|
||||||
|
|
||||||
|
*pTb = NULL;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctgAcquireTbIndexFromCache(SCatalog *pCtg, char *dbFName, char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
int32_t ctgAcquireTbIndexFromCache(SCatalog *pCtg, char *dbFName, char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
@ -334,6 +459,78 @@ int32_t ctgTbMetaExistInCache(SCatalog *pCtg, char *dbFName, char *tbName, int32
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCtgTbCache **pTb, STableMeta **pTableMeta, char* dbFName) {
|
||||||
|
SCtgDBCache *dbCache = *pDb;
|
||||||
|
SCtgTbCache *tbCache = *pTb;
|
||||||
|
STableMeta *tbMeta = tbCache->pMeta;
|
||||||
|
ctx->tbInfo.inCache = true;
|
||||||
|
ctx->tbInfo.dbId = dbCache->dbId;
|
||||||
|
ctx->tbInfo.suid = tbMeta->suid;
|
||||||
|
ctx->tbInfo.tbType = tbMeta->tableType;
|
||||||
|
|
||||||
|
if (tbMeta->tableType != TSDB_CHILD_TABLE) {
|
||||||
|
int32_t metaSize = CTG_META_SIZE(tbMeta);
|
||||||
|
*pTableMeta = taosMemoryCalloc(1, metaSize);
|
||||||
|
if (NULL == *pTableMeta) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(*pTableMeta, tbMeta, metaSize);
|
||||||
|
|
||||||
|
ctgDebug("Got tb %s meta from cache, type:%d, dbFName:%s", ctx->pName->tname, tbMeta->tableType, dbFName);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PROCESS FOR CHILD TABLE
|
||||||
|
|
||||||
|
int32_t metaSize = sizeof(SCTableMeta);
|
||||||
|
*pTableMeta = taosMemoryCalloc(1, metaSize);
|
||||||
|
if (NULL == *pTableMeta) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(*pTableMeta, tbMeta, metaSize);
|
||||||
|
|
||||||
|
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||||
|
|
||||||
|
if (tbCache) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
taosHashRelease(dbCache->tbCache, tbCache);
|
||||||
|
*pTb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s", ctx->pName->tname,
|
||||||
|
ctx->tbInfo.tbType, dbFName);
|
||||||
|
|
||||||
|
ctgAcquireStbMetaFromCache(dbCache, pCtg, dbFName, ctx->tbInfo.suid, &tbCache);
|
||||||
|
if (NULL == tbCache) {
|
||||||
|
taosMemoryFreeClear(*pTableMeta);
|
||||||
|
*pDb = NULL;
|
||||||
|
ctgDebug("stb 0x%" PRIx64 " meta not in cache", ctx->tbInfo.suid);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pTb = tbCache;
|
||||||
|
|
||||||
|
STableMeta *stbMeta = tbCache->pMeta;
|
||||||
|
if (stbMeta->suid != ctx->tbInfo.suid) {
|
||||||
|
ctgError("stb suid 0x%" PRIx64 " in stbCache mis-match, expected suid 0x%" PRIx64, stbMeta->suid, ctx->tbInfo.suid);
|
||||||
|
taosMemoryFreeClear(*pTableMeta);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
metaSize = CTG_META_SIZE(stbMeta);
|
||||||
|
*pTableMeta = taosMemoryRealloc(*pTableMeta, metaSize);
|
||||||
|
if (NULL == *pTableMeta) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&(*pTableMeta)->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgReadTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta **pTableMeta) {
|
int32_t ctgReadTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta **pTableMeta) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
@ -353,64 +550,7 @@ int32_t ctgReadTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta **
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMeta *tbMeta = tbCache->pMeta;
|
CTG_ERR_JRET(ctgCopyTbMeta(pCtg, ctx, &dbCache, &tbCache, pTableMeta, dbFName));
|
||||||
ctx->tbInfo.inCache = true;
|
|
||||||
ctx->tbInfo.dbId = dbCache->dbId;
|
|
||||||
ctx->tbInfo.suid = tbMeta->suid;
|
|
||||||
ctx->tbInfo.tbType = tbMeta->tableType;
|
|
||||||
|
|
||||||
if (tbMeta->tableType != TSDB_CHILD_TABLE) {
|
|
||||||
int32_t metaSize = CTG_META_SIZE(tbMeta);
|
|
||||||
*pTableMeta = taosMemoryCalloc(1, metaSize);
|
|
||||||
if (NULL == *pTableMeta) {
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(*pTableMeta, tbMeta, metaSize);
|
|
||||||
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
|
||||||
ctgDebug("Got tb %s meta from cache, type:%d, dbFName:%s", ctx->pName->tname, tbMeta->tableType, dbFName);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PROCESS FOR CHILD TABLE
|
|
||||||
|
|
||||||
int32_t metaSize = sizeof(SCTableMeta);
|
|
||||||
*pTableMeta = taosMemoryCalloc(1, metaSize);
|
|
||||||
if (NULL == *pTableMeta) {
|
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(*pTableMeta, tbMeta, metaSize);
|
|
||||||
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
|
||||||
ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s", ctx->pName->tname,
|
|
||||||
ctx->tbInfo.tbType, dbFName);
|
|
||||||
|
|
||||||
ctgAcquireStbMetaFromCache(pCtg, dbFName, ctx->tbInfo.suid, &dbCache, &tbCache);
|
|
||||||
if (NULL == tbCache) {
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
|
||||||
taosMemoryFreeClear(*pTableMeta);
|
|
||||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache", ctx->tbInfo.suid);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableMeta *stbMeta = tbCache->pMeta;
|
|
||||||
if (stbMeta->suid != ctx->tbInfo.suid) {
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
|
||||||
ctgError("stb suid 0x%" PRIx64 " in stbCache mis-match, expected suid 0x%" PRIx64, stbMeta->suid, ctx->tbInfo.suid);
|
|
||||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
metaSize = CTG_META_SIZE(stbMeta);
|
|
||||||
*pTableMeta = taosMemoryRealloc(*pTableMeta, metaSize);
|
|
||||||
if (NULL == *pTableMeta) {
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&(*pTableMeta)->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
|
|
||||||
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||||
|
|
||||||
|
@ -460,12 +600,17 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver,
|
||||||
|
|
||||||
// PROCESS FOR CHILD TABLE
|
// PROCESS FOR CHILD TABLE
|
||||||
|
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||||
|
if (tbCache) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
taosHashRelease(dbCache->tbCache, tbCache);
|
||||||
|
}
|
||||||
|
|
||||||
ctgDebug("Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s", pTableName->tname, dbFName);
|
ctgDebug("Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s", pTableName->tname, dbFName);
|
||||||
|
|
||||||
ctgAcquireStbMetaFromCache(pCtg, dbFName, *suid, &dbCache, &tbCache);
|
ctgAcquireStbMetaFromCache(dbCache, pCtg, dbFName, *suid, &tbCache);
|
||||||
if (NULL == tbCache) {
|
if (NULL == tbCache) {
|
||||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache", *suid);
|
ctgDebug("stb 0x%" PRIx64 " meta not in cache", *suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -794,7 +939,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateVgMsg));
|
ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateVgMsg));
|
||||||
taosMemoryFree(op);
|
taosMemoryFree(op);
|
||||||
ctgFreeVgInfo(dbInfo);
|
freeVgInfo(dbInfo);
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,6 +948,14 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
||||||
dbFName = p + 1;
|
dbFName = p + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code = ctgMakeVgArray(dbInfo);
|
||||||
|
if (code) {
|
||||||
|
taosMemoryFree(op);
|
||||||
|
taosMemoryFree(msg);
|
||||||
|
freeVgInfo(dbInfo);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
msg->dbId = dbId;
|
msg->dbId = dbId;
|
||||||
|
@ -816,7 +969,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
ctgFreeVgInfo(dbInfo);
|
freeVgInfo(dbInfo);
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1549,6 +1702,20 @@ void ctgFreeAllInstance(void) {
|
||||||
taosHashClear(gCtgMgmt.pCluster);
|
taosHashClear(gCtgMgmt.pCluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgVgInfoIdComp(void const* lp, void const* rp) {
|
||||||
|
int32_t* key = (int32_t*)lp;
|
||||||
|
SVgroupInfo* pVg = (SVgroupInfo*)rp;
|
||||||
|
|
||||||
|
if (*key < pVg->vgId) {
|
||||||
|
return -1;
|
||||||
|
} else if (*key > pVg->vgId) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgUpdateVgMsg *msg = operation->data;
|
SCtgUpdateVgMsg *msg = operation->data;
|
||||||
|
@ -1600,7 +1767,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgFreeVgInfo(vgInfo);
|
freeVgInfo(vgInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
vgCache->vgInfo = dbInfo;
|
vgCache->vgInfo = dbInfo;
|
||||||
|
@ -1621,7 +1788,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
ctgFreeVgInfo(msg->dbInfo);
|
freeVgInfo(msg->dbInfo);
|
||||||
taosMemoryFreeClear(msg);
|
taosMemoryFreeClear(msg);
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
|
@ -1674,7 +1841,7 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgWLockVgInfo(pCtg, dbCache));
|
CTG_ERR_JRET(ctgWLockVgInfo(pCtg, dbCache));
|
||||||
|
|
||||||
ctgFreeVgInfo(dbCache->vgCache.vgInfo);
|
freeVgInfo(dbCache->vgCache.vgInfo);
|
||||||
dbCache->vgCache.vgInfo = NULL;
|
dbCache->vgCache.vgInfo = NULL;
|
||||||
|
|
||||||
ctgDebug("db vgInfo removed, dbFName:%s", msg->dbFName);
|
ctgDebug("db vgInfo removed, dbFName:%s", msg->dbFName);
|
||||||
|
@ -1930,7 +2097,13 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
|
||||||
|
|
||||||
SVgroupInfo *pInfo = taosHashGet(vgInfo->vgHash, &msg->vgId, sizeof(msg->vgId));
|
SVgroupInfo *pInfo = taosHashGet(vgInfo->vgHash, &msg->vgId, sizeof(msg->vgId));
|
||||||
if (NULL == pInfo) {
|
if (NULL == pInfo) {
|
||||||
ctgDebug("no vgroup %d in db %s, ignore epset update", msg->vgId, msg->dbFName);
|
ctgDebug("no vgroup %d in db %s vgHash, ignore epset update", msg->vgId, msg->dbFName);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SVgroupInfo *pInfo2 = taosArraySearch(vgInfo->vgArray, &msg->vgId, ctgVgInfoIdComp, TD_EQ);
|
||||||
|
if (NULL == pInfo2) {
|
||||||
|
ctgDebug("no vgroup %d in db %s vgArray, ignore epset update", msg->vgId, msg->dbFName);
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1941,6 +2114,7 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
|
||||||
msg->epSet.numOfEps, pNewEp->fqdn, pNewEp->port, msg->dbFName);
|
msg->epSet.numOfEps, pNewEp->fqdn, pNewEp->port, msg->dbFName);
|
||||||
|
|
||||||
pInfo->epSet = msg->epSet;
|
pInfo->epSet = msg->epSet;
|
||||||
|
pInfo2->epSet = msg->epSet;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
@ -2057,7 +2231,7 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) {
|
||||||
switch (op->opId) {
|
switch (op->opId) {
|
||||||
case CTG_OP_UPDATE_VGROUP: {
|
case CTG_OP_UPDATE_VGROUP: {
|
||||||
SCtgUpdateVgMsg *msg = op->data;
|
SCtgUpdateVgMsg *msg = op->data;
|
||||||
ctgFreeVgInfo(msg->dbInfo);
|
freeVgInfo(msg->dbInfo);
|
||||||
taosMemoryFreeClear(op->data);
|
taosMemoryFreeClear(op->data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue