feat: update taos-tools for 3.0
This commit is contained in:
commit
1d9f88bff0
|
@ -51,6 +51,13 @@ IF(${TD_WINDOWS})
|
|||
"If build unit tests using googletest"
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
TDENGINE_3
|
||||
"TDengine 3.x"
|
||||
ON
|
||||
)
|
||||
|
||||
ELSEIF (TD_DARWIN_64)
|
||||
add_definitions(-DCOMPILER_SUPPORTS_CXX13)
|
||||
option(
|
||||
|
|
|
@ -91,7 +91,7 @@ Add following dependency in the `pom.xml` file of your Maven project:
|
|||
You can build Java connector from source code after cloning the TDengine project:
|
||||
|
||||
```
|
||||
git clone https://github.com/taosdata/taos-connector-jdbc.git
|
||||
git clone https://github.com/taosdata/taos-connector-jdbc.git --branch 2.0
|
||||
cd taos-connector-jdbc
|
||||
mvn clean install -Dmaven.test.skip=true
|
||||
```
|
||||
|
|
|
@ -52,7 +52,7 @@ TDengine的主要功能如下:
|
|||
采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面:
|
||||
|
||||
1. 由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低
|
||||
2. 因为采用 SQL 接口,能与众多第三放软件无缝集成,学习迁移成本大幅下降
|
||||
2. 因为采用 SQL 接口,能与众多第三方软件无缝集成,学习迁移成本大幅下降
|
||||
3. 因为其 All In One 的特性,系统复杂度降低,能降研发成本
|
||||
4. 因为运维维护简单,运营维护成本能大幅降低
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
sidebar_label: Docker
|
||||
title: 通过 Docker 快速体验 TDengine
|
||||
---
|
||||
|
|
@ -0,0 +1,296 @@
|
|||
---
|
||||
sidebar_label: 安装包
|
||||
title: 使用安装包立即开始
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
:::info
|
||||
如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
|
||||
|
||||
:::
|
||||
|
||||
TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包。
|
||||
|
||||
## 安装
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="apt-get" label="apt-get">
|
||||
可以使用 apt-get 工具从官方仓库安装。
|
||||
|
||||
**安装包仓库**
|
||||
|
||||
```
|
||||
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
|
||||
```
|
||||
|
||||
如果安装 Beta 版需要安装包仓库
|
||||
|
||||
```
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
|
||||
```
|
||||
|
||||
**使用 apt-get 命令安装**
|
||||
|
||||
```
|
||||
sudo apt-get update
|
||||
apt-cache policy tdengine
|
||||
sudo apt-get install tdengine
|
||||
```
|
||||
|
||||
:::tip
|
||||
apt-get 方式只适用于 Debian 或 Ubuntu 系统
|
||||
::::
|
||||
</TabItem>
|
||||
<TabItem label="Deb 安装" value="debinst">
|
||||
|
||||
1、从官网下载获得 deb 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.deb;
|
||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```
|
||||
$ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb
|
||||
(Reading database ... 137504 files and directories currently installed.)
|
||||
Preparing to unpack TDengine-server-2.4.0.7-Linux-x64.deb ...
|
||||
TDengine is removed successfully!
|
||||
Unpacking tdengine (2.4.0.7) over (2.4.0.7) ...
|
||||
Setting up tdengine (2.4.0.7) ...
|
||||
Start to install TDengine...
|
||||
|
||||
System hostname is: ubuntu-1804
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h ubuntu-1804 to login into TDengine server
|
||||
|
||||
|
||||
TDengine is installed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="RPM 安装" value="rpminst">
|
||||
|
||||
1、从官网下载获得 rpm 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.rpm;
|
||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```
|
||||
$ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm
|
||||
Preparing... ################################# [100%]
|
||||
Updating / installing...
|
||||
1:tdengine-2.4.0.7-3 ################################# [100%]
|
||||
Start to install TDengine...
|
||||
|
||||
System hostname is: centos7
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
|
||||
Created symlink from /etc/systemd/system/multi-user.target.wants/taosd.service to /etc/systemd/system/taosd.service.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h centos7 to login into TDengine server
|
||||
|
||||
|
||||
TDengine is installed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="tar.gz 安装" value="tarinst">
|
||||
|
||||
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.tar.gz;
|
||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
||||
|
||||
```
|
||||
$ tar xvzf TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
|
||||
TDengine-enterprise-server-2.4.0.7/
|
||||
TDengine-enterprise-server-2.4.0.7/driver/
|
||||
TDengine-enterprise-server-2.4.0.7/driver/vercomp.txt
|
||||
TDengine-enterprise-server-2.4.0.7/driver/libtaos.so.2.4.0.7
|
||||
TDengine-enterprise-server-2.4.0.7/install.sh
|
||||
TDengine-enterprise-server-2.4.0.7/examples/
|
||||
...
|
||||
|
||||
$ ll
|
||||
total 43816
|
||||
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ./
|
||||
drwxr-xr-x 20 ubuntu ubuntu 4096 Feb 22 09:30 ../
|
||||
drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 TDengine-enterprise-server-2.4.0.7/
|
||||
-rw-rw-r-- 1 ubuntu ubuntu 44852544 Feb 22 09:31 TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
|
||||
|
||||
$ cd TDengine-enterprise-server-2.4.0.7/
|
||||
|
||||
$ ll
|
||||
total 40784
|
||||
drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 ./
|
||||
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ../
|
||||
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 22 09:30 driver/
|
||||
drwxrwxr-x 10 ubuntu ubuntu 4096 Feb 22 09:30 examples/
|
||||
-rwxrwxr-x 1 ubuntu ubuntu 33294 Feb 22 09:30 install.sh*
|
||||
-rw-rw-r-- 1 ubuntu ubuntu 41704288 Feb 22 09:30 taos.tar.gz
|
||||
|
||||
$ sudo ./install.sh
|
||||
|
||||
Start to update TDengine...
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||
Nginx for TDengine is updated successfully!
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To configure Taos Adapter (if has) : edit /etc/taos/taosadapter.toml
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : use taos -h ubuntu-1804 in shell OR from http://127.0.0.1:6060
|
||||
|
||||
TDengine is updated successfully!
|
||||
Install taoskeeper as a standalone service
|
||||
taoskeeper is installed, enable it by `systemctl enable taoskeeper`
|
||||
```
|
||||
|
||||
:::info
|
||||
install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。
|
||||
|
||||
:::
|
||||
|
||||
## 启动
|
||||
|
||||
安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。
|
||||
|
||||
```bash
|
||||
systemctl start taosd
|
||||
```
|
||||
|
||||
检查服务是否正常工作:
|
||||
|
||||
```bash
|
||||
systemctl status taosd
|
||||
```
|
||||
|
||||
如果服务进程处于活动状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: active (running)
|
||||
```
|
||||
|
||||
如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: inactive (dead)
|
||||
```
|
||||
|
||||
如果 TDengine 服务正常工作,那么您可以通过 TDengine 的命令行程序 `taos` 来访问并体验 TDengine。
|
||||
|
||||
systemctl 命令汇总:
|
||||
|
||||
- 启动服务进程:`systemctl start taosd`
|
||||
|
||||
- 停止服务进程:`systemctl stop taosd`
|
||||
|
||||
- 重启服务进程:`systemctl restart taosd`
|
||||
|
||||
- 查看服务状态:`systemctl status taosd`
|
||||
|
||||
:::info
|
||||
|
||||
- systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。
|
||||
- `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。
|
||||
- 如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taosd` 方式启动 TDengine 服务。
|
||||
|
||||
:::
|
||||
|
||||
## TDengine 命令行 (CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库 (Database) 的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。
|
||||
|
||||
```bash
|
||||
taos
|
||||
```
|
||||
|
||||
如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下:
|
||||
|
||||
```cmd
|
||||
taos>
|
||||
```
|
||||
|
||||
在 TDengine CLI 中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行数据库(database)插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例:
|
||||
|
||||
```sql
|
||||
create database demo;
|
||||
use demo;
|
||||
create table t (ts timestamp, speed int);
|
||||
insert into t values ('2019-07-15 00:00:00', 10);
|
||||
insert into t values ('2019-07-15 01:00:00', 20);
|
||||
select * from t;
|
||||
ts | speed |
|
||||
========================================
|
||||
2019-07-15 00:00:00.000 | 10 |
|
||||
2019-07-15 01:00:00.000 | 20 |
|
||||
Query OK, 2 row(s) in set (0.003128s)
|
||||
```
|
||||
|
||||
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/)
|
||||
|
||||
## 使用 taosBenchmark 体验写入速度
|
||||
|
||||
启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 `taosdemo`):
|
||||
|
||||
```bash
|
||||
taosBenchmark
|
||||
```
|
||||
|
||||
该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.LosAngeles"。
|
||||
|
||||
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。
|
||||
|
||||
taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。
|
||||
|
||||
## 使用 TDengine CLI 体验查询速度
|
||||
|
||||
使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。
|
||||
|
||||
查询超级表下记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters;
|
||||
```
|
||||
|
||||
查询 1 亿条记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
||||
```
|
||||
|
||||
查询 location="California.SanFrancisco" 的记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters where location="California.SanFrancisco";
|
||||
```
|
||||
|
||||
查询 groupId=10 的所有记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
|
||||
```
|
||||
|
||||
对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||
```
|
|
@ -1,173 +1,14 @@
|
|||
---
|
||||
title: 立即开始
|
||||
description: '从 Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TDengine CLI和工具 taosdemo 快速体验 TDengine 功能'
|
||||
description: '快速设置 TDengine 环境并体验其高效写入和查询'
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
import PkgInstall from "./\_pkg_install.mdx";
|
||||
import AptGetInstall from "./\_apt_get_install.mdx";
|
||||
|
||||
## 安装
|
||||
本章主要介绍如何利用 Docker 或者安装包快速设置 TDengine 环境并体验其高效写入和查询。
|
||||
|
||||
TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件,目前 2.X 版服务端 taosd 和 taosAdapter 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。应用驱动 taosc 与 TDengine CLI 可以在 Windows 或 Linux 上安装和运行。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](/reference/taosadapter) 提供 [RESTful 接口](/reference/rest-api)。但在 2.4 之前的版本中没有 taosAdapter,RESTful 接口是由 taosd 内置的 HTTP 服务提供的。
|
||||
```mdx-code-block
|
||||
import DocCardList from '@theme/DocCardList';
|
||||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
||||
|
||||
TDengine 支持 X64/ARM64/MIPS64/Alpha64 硬件平台,后续将支持 ARM32、RISC-V 等 CPU 架构。
|
||||
|
||||
<Tabs defaultValue="apt-get">
|
||||
<TabItem value="docker" label="Docker">
|
||||
如果已经安装了 docker, 只需执行下面的命令。
|
||||
|
||||
```shell
|
||||
docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
|
||||
```
|
||||
|
||||
确定该容器已经启动并且在正常运行
|
||||
|
||||
```shell
|
||||
docker ps
|
||||
```
|
||||
|
||||
进入该容器并执行 bash
|
||||
|
||||
```shell
|
||||
docker exec -it <container name> bash
|
||||
```
|
||||
|
||||
然后就可以执行相关的 Linux 命令操作和访问 TDengine
|
||||
|
||||
详细操作方法请参照 [通过 Docker 快速体验 TDengine](/train-faq/docker)。
|
||||
|
||||
:::info
|
||||
从 2.4.0.10 开始,除 taosd 以外,Docker 镜像还包含:taos、taosAdapter、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码。启动 Docker 容器时,将同时启动 taosAdapter 和 taosd,实现对 RESTful 的支持。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="apt-get" label="apt-get">
|
||||
<AptGetInstall />
|
||||
</TabItem>
|
||||
<TabItem value="pkg" label="安装包">
|
||||
<PkgInstall />
|
||||
</TabItem>
|
||||
<TabItem value="src" label="源码">
|
||||
|
||||
如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
|
||||
|
||||
下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/cn/all-downloads/)。
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 启动
|
||||
|
||||
安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。
|
||||
|
||||
```bash
|
||||
systemctl start taosd
|
||||
```
|
||||
|
||||
检查服务是否正常工作:
|
||||
|
||||
```bash
|
||||
systemctl status taosd
|
||||
```
|
||||
|
||||
如果 TDengine 服务正常工作,那么您可以通过 TDengine 的命令行程序 `taos` 来访问并体验 TDengine。
|
||||
|
||||
:::info
|
||||
|
||||
- systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。
|
||||
- 为更好的获得产品反馈,改善产品,TDengine 会采集基本的使用信息,但您可以修改系统配置文件 taos.cfg 里的配置参数 telemetryReporting,将其设为 0,就可将其关闭。
|
||||
- TDengine 采用 FQDN(一般就是 hostname)作为节点的 ID,为保证正常运行,需要给运行 taosd 的服务器配置好 FQDN,在 TDengine CLI 或应用运行的机器配置好 DNS 服务或 hosts 文件,保证 FQDN 能够解析。
|
||||
- `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。
|
||||
|
||||
TDengine 支持在使用 [`systemd`](https://en.wikipedia.org/wiki/Systemd) 做进程服务管理的 Linux 系统上安装,用 `which systemctl` 命令来检测系统中是否存在 `systemd` 包:
|
||||
|
||||
```bash
|
||||
which systemctl
|
||||
```
|
||||
|
||||
如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taosd` 方式启动 TDengine 服务。
|
||||
|
||||
:::note
|
||||
|
||||
## TDengine 命令行 (CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库 (Database) 的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。
|
||||
|
||||
```bash
|
||||
taos
|
||||
```
|
||||
|
||||
如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下:
|
||||
|
||||
```cmd
|
||||
taos>
|
||||
```
|
||||
|
||||
在 TDengine CLI 中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行数据库(database)插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例:
|
||||
|
||||
```sql
|
||||
create database demo;
|
||||
use demo;
|
||||
create table t (ts timestamp, speed int);
|
||||
insert into t values ('2019-07-15 00:00:00', 10);
|
||||
insert into t values ('2019-07-15 01:00:00', 20);
|
||||
select * from t;
|
||||
ts | speed |
|
||||
========================================
|
||||
2019-07-15 00:00:00.000 | 10 |
|
||||
2019-07-15 01:00:00.000 | 20 |
|
||||
Query OK, 2 row(s) in set (0.003128s)
|
||||
```
|
||||
|
||||
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/)
|
||||
|
||||
## 使用 taosBenchmark 体验写入速度
|
||||
|
||||
启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 `taosdemo`):
|
||||
|
||||
```bash
|
||||
taosBenchmark
|
||||
```
|
||||
|
||||
该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.LosAngeles"。
|
||||
|
||||
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。
|
||||
|
||||
taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。
|
||||
|
||||
## 使用 TDengine CLI 体验查询速度
|
||||
|
||||
使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。
|
||||
|
||||
查询超级表下记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters;
|
||||
```
|
||||
|
||||
查询 1 亿条记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
||||
```
|
||||
|
||||
查询 location="California.SanFrancisco" 的记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters where location="California.SanFrancisco";
|
||||
```
|
||||
|
||||
查询 groupId=10 的所有记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
|
||||
```
|
||||
|
||||
对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
||||
```
|
|
@ -1,105 +0,0 @@
|
|||
---
|
||||
title: 数据节点管理
|
||||
---
|
||||
|
||||
上面已经介绍如何从零开始搭建集群。集群组建完成后,可以随时查看集群中当前的数据节点的状态,还可以添加新的数据节点进行扩容,删除数据节点,甚至手动进行数据节点之间的负载均衡操作。
|
||||
|
||||
:::note
|
||||
|
||||
以下所有执行命令的操作需要先登陆进 TDengine 系统,必要时请使用 root 权限。
|
||||
|
||||
:::
|
||||
|
||||
## 查看数据节点
|
||||
|
||||
启动 TDengine CLI 程序 taos,然后执行:
|
||||
|
||||
```sql
|
||||
SHOW DNODES;
|
||||
```
|
||||
|
||||
它将列出集群中所有的 dnode,每个 dnode 的 ID,end_point(fqdn:port),状态(ready,offline 等),vnode 数目,还未使用的 vnode 数目等信息。在添加或删除一个数据节点后,可以使用该命令查看。
|
||||
|
||||
输出如下(具体内容仅供参考,取决于实际的集群配置)
|
||||
|
||||
```
|
||||
taos> show dnodes;
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
1 | trd01:6030 | 100 | 1024 | ready | 2022-07-15 16:47:47.726 | |
|
||||
Query OK, 1 rows affected (0.006684s)
|
||||
```
|
||||
|
||||
## 查看虚拟节点组
|
||||
|
||||
为充分利用多核技术,并提供横向扩展能力,数据需要分片处理。因此 TDengine 会将一个 DB 的数据切分成多份,存放在多个 vnode 里。这些 vnode 可能分布在多个数据节点 dnode 里,这样就实现了水平扩展。一个 vnode 仅仅属于一个 DB,但一个 DB 可以有多个 vnode。vnode 所在的数据节点是 mnode 根据当前系统资源的情况,自动进行分配的,无需任何人工干预。
|
||||
|
||||
启动 CLI 程序 taos,然后执行:
|
||||
|
||||
```sql
|
||||
USE SOME_DATABASE;
|
||||
SHOW VGROUPS;
|
||||
```
|
||||
|
||||
输出如下(具体内容仅供参考,取决于实际的集群配置)
|
||||
|
||||
```
|
||||
taos> use db;
|
||||
Database changed.
|
||||
|
||||
taos> show vgroups;
|
||||
vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | status | nfiles | file_size | tsma |
|
||||
================================================================================================================================================================================================
|
||||
2 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
|
||||
3 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
|
||||
4 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
|
||||
Query OK, 8 row(s) in set (0.001154s)
|
||||
```
|
||||
|
||||
## 添加数据节点
|
||||
|
||||
启动 CLI 程序 taos,然后执行:
|
||||
|
||||
```sql
|
||||
CREATE DNODE "fqdn:port";
|
||||
```
|
||||
|
||||
将新数据节点的 End Point 添加进集群的 EP 列表。“fqdn:port“需要用双引号引起来,否则出错。一个数据节点对外服务的 fqdn 和 port 可以通过配置文件 taos.cfg 进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置 FQDN,可能导致生成的数据节点的 End Point 不是所期望的】
|
||||
|
||||
然后启动新加入的数据节点的 taosd 进程,再通过 taos 查看数据节点状态:
|
||||
|
||||
```
|
||||
taos> show dnodes;
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
1 | localhost:6030 | 100 | 1024 | ready | 2022-07-15 16:47:47.726 | |
|
||||
2 | localhost:7030 | 0 | 1024 | ready | 2022-07-15 16:56:13.670 | |
|
||||
Query OK, 2 rows affected (0.007031s)
|
||||
```
|
||||
|
||||
从中可以看到两个 dnode 状态都为 ready
|
||||
|
||||
## 删除数据节点
|
||||
|
||||
先停止要删除的数据节点的 taosd 进程,然后启动 CLI 程序 taos,执行:
|
||||
|
||||
```sql
|
||||
DROP DNODE "fqdn:port";
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```sql
|
||||
DROP DNODE dnodeId;
|
||||
```
|
||||
|
||||
通过 “fqdn:port” 或 dnodeID 来指定一个具体的节点都是可以的。其中 fqdn 是被删除的节点的 FQDN,port 是其对外服务器的端口号;dnodeID 可以通过 SHOW DNODES 获得。
|
||||
|
||||
:::warning
|
||||
|
||||
数据节点一旦被 drop 之后,不能重新加入集群。需要将此节点重新部署(清空数据文件夹)。集群在完成 `drop dnode` 操作之前,会将该 dnode 的数据迁移走。
|
||||
请注意 `drop dnode` 和 停止 taosd 进程是两个不同的概念,不要混淆:因为删除 dnode 之前要执行迁移数据的操作,因此被删除的 dnode 必须保持在线状态。待删除操作结束之后,才能停止 taosd 进程。
|
||||
一个数据节点被 drop 之后,其他节点都会感知到这个 dnodeID 的删除操作,任何集群中的节点都不会再接收此 dnodeID 的请求。
|
||||
dnodeID 是集群自动分配的,不得人工指定。它在生成时是递增的,不会重复。
|
||||
|
||||
:::
|
|
@ -1 +0,0 @@
|
|||
label: 集群管理
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
title: 集群部署
|
||||
sidebar_label: 手动部署
|
||||
title: 集群部署和管理
|
||||
---
|
||||
|
||||
## 准备工作
|
||||
|
@ -54,6 +55,8 @@ fqdn h1.taosdata.com
|
|||
// 配置本数据节点的端口号,缺省是 6030
|
||||
serverPort 6030
|
||||
|
||||
```
|
||||
|
||||
一定要修改的参数是 firstEp 和 fqdn。在每个数据节点,firstEp 需全部配置成一样,但 fqdn 一定要配置成其所在数据节点的值。其他参数可不做任何修改,除非你很清楚为什么要修改。
|
||||
|
||||
加入到集群中的数据节点 dnode,下表中涉及集群相关的参数必须完全相同,否则不能成功加入到集群中。
|
||||
|
@ -67,8 +70,6 @@ serverPort 6030
|
|||
|
||||
## 启动集群
|
||||
|
||||
### 启动第一个数据节点
|
||||
|
||||
按照《立即开始》里的步骤,启动第一个数据节点,例如 h1.taosdata.com,然后执行 taos,启动 taos shell,从 shell 里执行命令“SHOW DNODES”,如下所示:
|
||||
|
||||
```
|
||||
|
@ -78,20 +79,17 @@ Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
|||
Server is Enterprise trial Edition, ver:3.0.0.0 and will never expire.
|
||||
|
||||
taos> show dnodes;
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
1 | h1.taosdata.com:6030 | 0 | 1024 | ready | 2022-07-16 10:50:42.673 | |
|
||||
1 | h1.taosdata.com:6030 | 0 | 1024 | ready | 2022-07-16 10:50:42.673 | |
|
||||
Query OK, 1 rows affected (0.007984s)
|
||||
|
||||
taos>
|
||||
|
||||
taos>
|
||||
|
||||
````
|
||||
```
|
||||
|
||||
上述命令里,可以看到刚启动的数据节点的 End Point 是:h1.taos.com:6030,就是这个新集群的 firstEp。
|
||||
|
||||
### 启动后续数据节点
|
||||
## 添加数据节点
|
||||
|
||||
将后续的数据节点添加到现有集群,具体有以下几步:
|
||||
|
||||
|
@ -125,3 +123,74 @@ firstEp 这个参数仅仅在该数据节点首次加入集群时有作用,加
|
|||
两个没有配置 firstEp 参数的数据节点 dnode 启动后,会独立运行起来。这个时候,无法将其中一个数据节点加入到另外一个数据节点,形成集群。无法将两个独立的集群合并成为新的集群。
|
||||
|
||||
:::
|
||||
|
||||
## 查看数据节点
|
||||
|
||||
启动 TDengine CLI 程序 taos,然后执行:
|
||||
|
||||
```sql
|
||||
SHOW DNODES;
|
||||
```
|
||||
|
||||
它将列出集群中所有的 dnode,每个 dnode 的 ID,end_point(fqdn:port),状态(ready,offline 等),vnode 数目,还未使用的 vnode 数目等信息。在添加或删除一个数据节点后,可以使用该命令查看。
|
||||
|
||||
输出如下(具体内容仅供参考,取决于实际的集群配置)
|
||||
|
||||
```
|
||||
taos> show dnodes;
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
1 | trd01:6030 | 100 | 1024 | ready | 2022-07-15 16:47:47.726 | |
|
||||
Query OK, 1 rows affected (0.006684s)
|
||||
```
|
||||
|
||||
## 查看虚拟节点组
|
||||
|
||||
为充分利用多核技术,并提供横向扩展能力,数据需要分片处理。因此 TDengine 会将一个 DB 的数据切分成多份,存放在多个 vnode 里。这些 vnode 可能分布在多个数据节点 dnode 里,这样就实现了水平扩展。一个 vnode 仅仅属于一个 DB,但一个 DB 可以有多个 vnode。vnode 所在的数据节点是 mnode 根据当前系统资源的情况,自动进行分配的,无需任何人工干预。
|
||||
|
||||
启动 CLI 程序 taos,然后执行:
|
||||
|
||||
```sql
|
||||
USE SOME_DATABASE;
|
||||
SHOW VGROUPS;
|
||||
```
|
||||
|
||||
输出如下(具体内容仅供参考,取决于实际的集群配置)
|
||||
|
||||
```
|
||||
taos> use db;
|
||||
Database changed.
|
||||
|
||||
taos> show vgroups;
|
||||
vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | status | nfiles | file_size | tsma |
|
||||
================================================================================================================================================================================================
|
||||
2 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
|
||||
3 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
|
||||
4 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
|
||||
Query OK, 8 row(s) in set (0.001154s)
|
||||
```
|
||||
|
||||
## 删除数据节点
|
||||
|
||||
先停止要删除的数据节点的 taosd 进程,然后启动 CLI 程序 taos,执行:
|
||||
|
||||
```sql
|
||||
DROP DNODE "fqdn:port";
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```sql
|
||||
DROP DNODE dnodeId;
|
||||
```
|
||||
|
||||
通过 “fqdn:port” 或 dnodeID 来指定一个具体的节点都是可以的。其中 fqdn 是被删除的节点的 FQDN,port 是其对外服务器的端口号;dnodeID 可以通过 SHOW DNODES 获得。
|
||||
|
||||
:::warning
|
||||
|
||||
数据节点一旦被 drop 之后,不能重新加入集群。需要将此节点重新部署(清空数据文件夹)。集群在完成 `drop dnode` 操作之前,会将该 dnode 的数据迁移走。
|
||||
请注意 `drop dnode` 和 停止 taosd 进程是两个不同的概念,不要混淆:因为删除 dnode 之前要执行迁移数据的操作,因此被删除的 dnode 必须保持在线状态。待删除操作结束之后,才能停止 taosd 进程。
|
||||
一个数据节点被 drop 之后,其他节点都会感知到这个 dnodeID 的删除操作,任何集群中的节点都不会再接收此 dnodeID 的请求。
|
||||
dnodeID 是集群自动分配的,不得人工指定。它在生成时是递增的,不会重复。
|
||||
|
||||
:::
|
|
@ -0,0 +1,452 @@
|
|||
---
|
||||
sidebar_label: Kubernetes
|
||||
title: 在 Kubernetes 上部署 TDengine 集群
|
||||
---
|
||||
|
||||
## 配置 ConfigMap
|
||||
|
||||
为 TDengine 创建 `taoscfg.yaml`,此文件中的配置将作为环境变量传入 TDengine 镜像,更新此配置将导致所有 TDengine POD 重启。
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: taoscfg
|
||||
labels:
|
||||
app: tdengine
|
||||
data:
|
||||
CLUSTER: "1"
|
||||
TAOS_KEEP: "3650"
|
||||
TAOS_DEBUG_FLAG: "135"
|
||||
```
|
||||
|
||||
## 配置服务
|
||||
|
||||
创建一个 service 配置文件:`taosd-service.yaml`,服务名称 `metadata.name` (此处为 "taosd") 将在下一步中使用到。添加 TDengine 所用到的所有端口:
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: "taosd"
|
||||
labels:
|
||||
app: "tdengine"
|
||||
spec:
|
||||
ports:
|
||||
- name: tcp6030
|
||||
protocol: "TCP"
|
||||
port: 6030
|
||||
- name: tcp6035
|
||||
protocol: "TCP"
|
||||
port: 6035
|
||||
- name: tcp6041
|
||||
protocol: "TCP"
|
||||
port: 6041
|
||||
- name: udp6030
|
||||
protocol: "UDP"
|
||||
port: 6030
|
||||
- name: udp6031
|
||||
protocol: "UDP"
|
||||
port: 6031
|
||||
- name: udp6032
|
||||
protocol: "UDP"
|
||||
port: 6032
|
||||
- name: udp6033
|
||||
protocol: "UDP"
|
||||
port: 6033
|
||||
- name: udp6034
|
||||
protocol: "UDP"
|
||||
port: 6034
|
||||
- name: udp6035
|
||||
protocol: "UDP"
|
||||
port: 6035
|
||||
- name: udp6036
|
||||
protocol: "UDP"
|
||||
port: 6036
|
||||
- name: udp6037
|
||||
protocol: "UDP"
|
||||
port: 6037
|
||||
- name: udp6038
|
||||
protocol: "UDP"
|
||||
port: 6038
|
||||
- name: udp6039
|
||||
protocol: "UDP"
|
||||
port: 6039
|
||||
- name: udp6040
|
||||
protocol: "UDP"
|
||||
port: 6040
|
||||
selector:
|
||||
app: "tdengine"
|
||||
```
|
||||
|
||||
## 有状态服务 StatefulSet
|
||||
|
||||
根据 Kubernetes 对各类部署的说明,我们将使用 StatefulSet 作为 TDengine 的服务类型,创建文件 `tdengine.yaml`:
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: "tdengine"
|
||||
labels:
|
||||
app: "tdengine"
|
||||
spec:
|
||||
serviceName: "taosd"
|
||||
replicas: 2
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: "tdengine"
|
||||
template:
|
||||
metadata:
|
||||
name: "tdengine"
|
||||
labels:
|
||||
app: "tdengine"
|
||||
spec:
|
||||
containers:
|
||||
- name: "tdengine"
|
||||
image: "zitsen/taosd:develop"
|
||||
imagePullPolicy: "Always"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: taoscfg
|
||||
ports:
|
||||
- name: tcp6030
|
||||
protocol: "TCP"
|
||||
containerPort: 6030
|
||||
- name: tcp6035
|
||||
protocol: "TCP"
|
||||
containerPort: 6035
|
||||
- name: tcp6041
|
||||
protocol: "TCP"
|
||||
containerPort: 6041
|
||||
- name: udp6030
|
||||
protocol: "UDP"
|
||||
containerPort: 6030
|
||||
- name: udp6031
|
||||
protocol: "UDP"
|
||||
containerPort: 6031
|
||||
- name: udp6032
|
||||
protocol: "UDP"
|
||||
containerPort: 6032
|
||||
- name: udp6033
|
||||
protocol: "UDP"
|
||||
containerPort: 6033
|
||||
- name: udp6034
|
||||
protocol: "UDP"
|
||||
containerPort: 6034
|
||||
- name: udp6035
|
||||
protocol: "UDP"
|
||||
containerPort: 6035
|
||||
- name: udp6036
|
||||
protocol: "UDP"
|
||||
containerPort: 6036
|
||||
- name: udp6037
|
||||
protocol: "UDP"
|
||||
containerPort: 6037
|
||||
- name: udp6038
|
||||
protocol: "UDP"
|
||||
containerPort: 6038
|
||||
- name: udp6039
|
||||
protocol: "UDP"
|
||||
containerPort: 6039
|
||||
- name: udp6040
|
||||
protocol: "UDP"
|
||||
containerPort: 6040
|
||||
env:
|
||||
# POD_NAME for FQDN config
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
# SERVICE_NAME and NAMESPACE for fqdn resolve
|
||||
- name: SERVICE_NAME
|
||||
value: "taosd"
|
||||
- name: STS_NAME
|
||||
value: "tdengine"
|
||||
- name: STS_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
# TZ for timezone settings, we recommend to always set it.
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
# TAOS_ prefix will configured in taos.cfg, strip prefix and camelCase.
|
||||
- name: TAOS_SERVER_PORT
|
||||
value: "6030"
|
||||
# Must set if you want a cluster.
|
||||
- name: TAOS_FIRST_EP
|
||||
value: "$(STS_NAME)-0.$(SERVICE_NAME).$(STS_NAMESPACE).svc.cluster.local:$(TAOS_SERVER_PORT)"
|
||||
# TAOS_FQND should always be setted in k8s env.
|
||||
- name: TAOS_FQDN
|
||||
value: "$(POD_NAME).$(SERVICE_NAME).$(STS_NAMESPACE).svc.cluster.local"
|
||||
volumeMounts:
|
||||
- name: taosdata
|
||||
mountPath: /var/lib/taos
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- taos
|
||||
- -s
|
||||
- "show mnodes"
|
||||
initialDelaySeconds: 5
|
||||
timeoutSeconds: 5000
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: 6030
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: taosdata
|
||||
spec:
|
||||
accessModes:
|
||||
- "ReadWriteOnce"
|
||||
storageClassName: "csi-rbd-sc"
|
||||
resources:
|
||||
requests:
|
||||
storage: "10Gi"
|
||||
```
|
||||
|
||||
## 启动集群
|
||||
|
||||
将前述三个文件添加到 Kubernetes 集群中:
|
||||
|
||||
```bash
|
||||
kubectl apply -f taoscfg.yaml
|
||||
kubectl apply -f taosd-service.yaml
|
||||
kubectl apply -f tdengine.yaml
|
||||
|
||||
```
|
||||
|
||||
上面的配置将生成一个两节点的 TDengine 集群,dnode 是自动配置的,可以使用 `show dnodes` 命令查看当前集群的节点:
|
||||
|
||||
```bash
|
||||
kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
|
||||
kubectl exec -i -t tdengine-1 -- taos -s "show dnodes"
|
||||
|
||||
```
|
||||
|
||||
输出如下:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.1.1.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 17:13:24.181 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 17:14:09.257 | |
|
||||
Query OK, 2 row(s) in set (0.000997s)
|
||||
|
||||
```
|
||||
|
||||
## 集群扩容
|
||||
|
||||
TDengine 集群支持自动扩容:
|
||||
|
||||
```bash
|
||||
kubectl scale statefulsets tdengine --replicas=4
|
||||
|
||||
```
|
||||
|
||||
上面命令行中参数 `--replica=4` 表示要将 TDengine 集群扩容到 4 个节点,执行后首先检查 POD 的状态:
|
||||
|
||||
```bash
|
||||
kubectl get pods -l app=tdengine
|
||||
|
||||
```
|
||||
|
||||
输出如下:
|
||||
|
||||
```
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
tdengine-0 1/1 Running 0 161m
|
||||
tdengine-1 1/1 Running 0 161m
|
||||
tdengine-2 1/1 Running 0 32m
|
||||
tdengine-3 1/1 Running 0 32m
|
||||
|
||||
```
|
||||
|
||||
此时 POD 的状态仍然是 Running,TDengine 集群中的 dnode 状态要等 POD 状态为 `ready` 之后才能看到:
|
||||
|
||||
```bash
|
||||
kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
|
||||
|
||||
```
|
||||
|
||||
扩容后的四节点 TDengine 集群的 dnode 列表:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.1.1.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:12.915 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:33.127 | |
|
||||
3 | tdengine-2.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 14:07:27.078 | |
|
||||
4 | tdengine-3.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 14:07:48.362 | |
|
||||
Query OK, 4 row(s) in set (0.001293s)
|
||||
|
||||
```
|
||||
|
||||
## 集群缩容
|
||||
|
||||
TDengine 的缩容并没有自动化,我们尝试将一个三节点集群缩容到两节点。
|
||||
|
||||
首先,确认一个三节点 TDengine 集群正常工作,在 TDengine CLI 中查看 dnode 的状态:
|
||||
|
||||
```bash
|
||||
taos> show dnodes
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 16:27:24.852 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:27:53.339 | |
|
||||
3 | tdengine-2.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:28:49.787 | |
|
||||
Query OK, 3 row(s) in set (0.001101s)
|
||||
|
||||
```
|
||||
|
||||
想要安全的缩容,首先需要将节点从 dnode 列表中移除,也即从集群中移除:
|
||||
|
||||
```bash
|
||||
kubectl exec -i -t tdengine-0 -- taos -s "drop dnode 'tdengine-2.taosd.default.svc.cluster.local:6030'"
|
||||
|
||||
```
|
||||
|
||||
通过 `show dondes` 命令确认移除成功后,移除相应的 POD:
|
||||
|
||||
```bash
|
||||
kubectl scale statefulsets tdengine --replicas=2
|
||||
|
||||
```
|
||||
|
||||
最后一个 POD 会被删除,使用 `kubectl get pods -l app=tdengine` 查看集群状态:
|
||||
|
||||
```
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
tdengine-0 1/1 Running 0 3h40m
|
||||
tdengine-1 1/1 Running 0 3h40m
|
||||
|
||||
```
|
||||
|
||||
POD 删除后,需要手动删除 PVC,否则下次扩容时会继续使用以前的数据导致无法正常加入集群。
|
||||
|
||||
```bash
|
||||
kubectl delete pvc taosdata-tdengine-2
|
||||
|
||||
```
|
||||
|
||||
此时的集群状态是安全的,需要时还可以再次进行扩容:
|
||||
|
||||
```bash
|
||||
kubectl scale statefulsets tdengine --replicas=3
|
||||
|
||||
|
||||
```
|
||||
|
||||
`show dnodes` 输出如下:
|
||||
|
||||
```
|
||||
taos> show dnodes
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 16:27:24.852 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:27:53.339 | |
|
||||
4 | tdengine-2.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:40:49.177 | |
|
||||
|
||||
|
||||
```
|
||||
|
||||
## 删除集群
|
||||
|
||||
完整移除 TDengine 集群,需要分别清理 statefulset、svc、configmap、pvc。
|
||||
|
||||
```bash
|
||||
kubectl delete statefulset -l app=tdengine
|
||||
kubectl delete svc -l app=tdengine
|
||||
kubectl delete pvc -l app=tdengine
|
||||
kubectl delete configmap taoscfg
|
||||
|
||||
```
|
||||
|
||||
## 常见错误
|
||||
|
||||
### 错误一
|
||||
|
||||
扩容到四节点之后缩容到两节点,删除的 POD 会进入 offline 状态:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.1.1.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:12.915 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:33.127 | |
|
||||
3 | tdengine-2.taosd.default.sv... | 0 | 40 | offline | any | 2021-06-01 14:07:27.078 | status msg timeout |
|
||||
4 | tdengine-3.taosd.default.sv... | 1 | 40 | offline | any | 2021-06-01 14:07:48.362 | status msg timeout |
|
||||
Query OK, 4 row(s) in set (0.001236s)
|
||||
|
||||
|
||||
```
|
||||
|
||||
但 `drop dnode` 的行为按不会按照预期进行,且下次集群重启后,所有的 dnode 节点将无法启动 dropping 状态无法退出。
|
||||
|
||||
### 错误二
|
||||
|
||||
TDengine 集群会持有 replica 参数,如果缩容后的节点数小于这个值,集群将无法使用:
|
||||
|
||||
创建一个库使用 replica 参数为 2,插入部分数据:
|
||||
|
||||
```bash
|
||||
kubectl exec -i -t tdengine-0 -- \
|
||||
taos -s \
|
||||
"create database if not exists test replica 2;
|
||||
use test;
|
||||
create table if not exists t1(ts timestamp, n int);
|
||||
insert into t1 values(now, 1)(now+1s, 2);"
|
||||
|
||||
|
||||
```
|
||||
|
||||
缩容到单节点:
|
||||
|
||||
```bash
|
||||
kubectl scale statefulsets tdengine --replicas=1
|
||||
|
||||
```
|
||||
|
||||
在 taos shell 中的所有数据库操作将无法成功。
|
||||
|
||||
```
|
||||
taos> show dnodes;
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 2 | 40 | ready | any | 2021-06-01 15:55:52.562 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 1 | 40 | offline | any | 2021-06-01 15:56:07.212 | status msg timeout |
|
||||
Query OK, 2 row(s) in set (0.000845s)
|
||||
|
||||
taos> show dnodes;
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
1 | tdengine-0.taosd.default.sv... | 2 | 40 | ready | any | 2021-06-01 15:55:52.562 | |
|
||||
2 | tdengine-1.taosd.default.sv... | 1 | 40 | offline | any | 2021-06-01 15:56:07.212 | status msg timeout |
|
||||
Query OK, 2 row(s) in set (0.000837s)
|
||||
|
||||
taos> use test;
|
||||
Database changed.
|
||||
|
||||
taos> insert into t1 values(now, 3);
|
||||
|
||||
DB error: Unable to resolve FQDN (0.013874s)
|
||||
|
||||
```
|
|
@ -0,0 +1,434 @@
|
|||
---
|
||||
sidebar_label: Helm
|
||||
title: 使用 Helm 部署 TDengine 集群
|
||||
---
|
||||
|
||||
Helm 是 Kubernetes 的包管理器,上一节使用 Kubernets 部署 TDengine 集群的操作已经足够简单,但 Helm 依然可以提供更强大的能力。
|
||||
|
||||
## 安装 Helm
|
||||
|
||||
```bash
|
||||
curl -fsSL -o get_helm.sh \
|
||||
https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
|
||||
chmod +x get_helm.sh
|
||||
./get_helm.sh
|
||||
|
||||
```
|
||||
|
||||
Helm 会使用 kubectl 和 kubeconfig 的配置来操作 Kubernetes,可以参考 Rancher 安装 Kubernetes 的配置来进行设置。
|
||||
|
||||
## 安装 TDengine Chart
|
||||
|
||||
TDengine Chart 尚未发布到 Helm 仓库,当前可以从 GitHub 直接下载:
|
||||
|
||||
```bash
|
||||
wget https://github.com/taosdata/TDengine-Operator/raw/main/helm/tdengine-0.3.0.tgz
|
||||
|
||||
```
|
||||
|
||||
获取当前 Kubernetes 的存储类:
|
||||
|
||||
```bash
|
||||
kubectl get storageclass
|
||||
|
||||
```
|
||||
|
||||
在 minikube 默认为 standard.
|
||||
|
||||
之后,使用 helm 命令安装:
|
||||
|
||||
```bash
|
||||
helm install tdengine tdengine-0.3.0.tgz \
|
||||
--set storage.className=<your storage class name>
|
||||
|
||||
```
|
||||
|
||||
在 minikube 环境下,可以设置一个较小的容量避免超出磁盘可用空间:
|
||||
|
||||
```bash
|
||||
helm install tdengine tdengine-0.3.0.tgz \
|
||||
--set storage.className=standard \
|
||||
--set storage.dataSize=2Gi \
|
||||
--set storage.logSize=10Mi
|
||||
|
||||
```
|
||||
|
||||
部署成功后,TDengine Chart 将会输出操作 TDengine 的说明:
|
||||
|
||||
```bash
|
||||
export POD_NAME=$(kubectl get pods --namespace default \
|
||||
-l "app.kubernetes.io/name=tdengine,app.kubernetes.io/instance=tdengine" \
|
||||
-o jsonpath="{.items[0].metadata.name}")
|
||||
kubectl --namespace default exec $POD_NAME -- taos -s "show dnodes; show mnodes"
|
||||
kubectl --namespace default exec -it $POD_NAME -- taos
|
||||
|
||||
```
|
||||
|
||||
可以创建一个表进行测试:
|
||||
|
||||
```bash
|
||||
kubectl --namespace default exec $POD_NAME -- \
|
||||
taos -s "create database test;
|
||||
use test;
|
||||
create table t1 (ts timestamp, n int);
|
||||
insert into t1 values(now, 1)(now + 1s, 2);
|
||||
select * from t1;"
|
||||
|
||||
```
|
||||
|
||||
## 配置 Values
|
||||
|
||||
TDengine 支持 `values.yaml` 自定义。
|
||||
|
||||
通过 helm show values 可以获取 TDengine Chart 支持的全部 values 列表:
|
||||
|
||||
```bash
|
||||
helm show values tdengine-0.3.0.tgz
|
||||
|
||||
```
|
||||
|
||||
你可以将结果保存为 values.yaml,之后可以修改其中的各项参数,如 replica 数量,存储类名称,容量大小,TDengine 配置等,然后使用如下命令安装 TDengine 集群:
|
||||
|
||||
```bash
|
||||
helm install tdengine tdengine-0.3.0.tgz -f values.yaml
|
||||
|
||||
```
|
||||
|
||||
全部参数如下:
|
||||
|
||||
```yaml
|
||||
# Default values for tdengine.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into helm templates.
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
prefix: tdengine/tdengine
|
||||
#pullPolicy: Always
|
||||
# Overrides the image tag whose default is the chart appVersion.
|
||||
#tag: "2.4.0.5"
|
||||
|
||||
service:
|
||||
# ClusterIP is the default service type, use NodeIP only if you know what you are doing.
|
||||
type: ClusterIP
|
||||
ports:
|
||||
# TCP range required
|
||||
tcp:
|
||||
[
|
||||
6030,
|
||||
6031,
|
||||
6032,
|
||||
6033,
|
||||
6034,
|
||||
6035,
|
||||
6036,
|
||||
6037,
|
||||
6038,
|
||||
6039,
|
||||
6040,
|
||||
6041,
|
||||
6042,
|
||||
6043,
|
||||
6044,
|
||||
6045,
|
||||
6060,
|
||||
]
|
||||
# UDP range 6030-6039
|
||||
udp: [6030, 6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039]
|
||||
|
||||
arbitrator: true
|
||||
|
||||
# Set timezone here, not in taoscfg
|
||||
timezone: "Asia/Shanghai"
|
||||
|
||||
resources:
|
||||
# We usually recommend not to specify default resources and to leave this as a conscious
|
||||
# choice for the user. This also increases chances charts run on environments with little
|
||||
# resources, such as Minikube. If you do want to specify resources, uncomment the following
|
||||
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
# requests:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
|
||||
storage:
|
||||
# Set storageClassName for pvc. K8s use default storage class if not set.
|
||||
#
|
||||
className: ""
|
||||
dataSize: "100Gi"
|
||||
logSize: "10Gi"
|
||||
|
||||
nodeSelectors:
|
||||
taosd:
|
||||
# node selectors
|
||||
|
||||
clusterDomainSuffix: ""
|
||||
# Config settings in taos.cfg file.
|
||||
#
|
||||
# The helm/k8s support will use environment variables for taos.cfg,
|
||||
# converting an upper-snake-cased variable like `TAOS_DEBUG_FLAG`,
|
||||
# to a camelCase taos config variable `debugFlag`.
|
||||
#
|
||||
# See the variable list at https://www.taosdata.com/cn/documentation/administrator .
|
||||
#
|
||||
# Note:
|
||||
# 1. firstEp/secondEp: should not be setted here, it's auto generated at scale-up.
|
||||
# 2. serverPort: should not be setted, we'll use the default 6030 in many places.
|
||||
# 3. fqdn: will be auto generated in kubenetes, user should not care about it.
|
||||
# 4. role: currently role is not supported - every node is able to be mnode and vnode.
|
||||
#
|
||||
# Btw, keep quotes "" around the value like below, even the value will be number or not.
|
||||
taoscfg:
|
||||
# number of replications, for cluster only
|
||||
TAOS_REPLICA: "1"
|
||||
|
||||
# number of management nodes in the system
|
||||
TAOS_NUM_OF_MNODES: "1"
|
||||
|
||||
# number of days per DB file
|
||||
# TAOS_DAYS: "10"
|
||||
|
||||
# number of days to keep DB file, default is 10 years.
|
||||
#TAOS_KEEP: "3650"
|
||||
|
||||
# cache block size (Mbyte)
|
||||
#TAOS_CACHE: "16"
|
||||
|
||||
# number of cache blocks per vnode
|
||||
#TAOS_BLOCKS: "6"
|
||||
|
||||
# minimum rows of records in file block
|
||||
#TAOS_MIN_ROWS: "100"
|
||||
|
||||
# maximum rows of records in file block
|
||||
#TAOS_MAX_ROWS: "4096"
|
||||
|
||||
#
|
||||
# TAOS_NUM_OF_THREADS_PER_CORE: number of threads per CPU core
|
||||
#TAOS_NUM_OF_THREADS_PER_CORE: "1.0"
|
||||
|
||||
#
|
||||
# TAOS_NUM_OF_COMMIT_THREADS: number of threads to commit cache data
|
||||
#TAOS_NUM_OF_COMMIT_THREADS: "4"
|
||||
|
||||
#
|
||||
# TAOS_RATIO_OF_QUERY_CORES:
|
||||
# the proportion of total CPU cores available for query processing
|
||||
# 2.0: the query threads will be set to double of the CPU cores.
|
||||
# 1.0: all CPU cores are available for query processing [default].
|
||||
# 0.5: only half of the CPU cores are available for query.
|
||||
# 0.0: only one core available.
|
||||
#TAOS_RATIO_OF_QUERY_CORES: "1.0"
|
||||
|
||||
#
|
||||
# TAOS_KEEP_COLUMN_NAME:
|
||||
# the last_row/first/last aggregator will not change the original column name in the result fields
|
||||
#TAOS_KEEP_COLUMN_NAME: "0"
|
||||
|
||||
# enable/disable backuping vnode directory when removing vnode
|
||||
#TAOS_VNODE_BAK: "1"
|
||||
|
||||
# enable/disable installation / usage report
|
||||
#TAOS_TELEMETRY_REPORTING: "1"
|
||||
|
||||
# enable/disable load balancing
|
||||
#TAOS_BALANCE: "1"
|
||||
|
||||
# max timer control blocks
|
||||
#TAOS_MAX_TMR_CTRL: "512"
|
||||
|
||||
# time interval of system monitor, seconds
|
||||
#TAOS_MONITOR_INTERVAL: "30"
|
||||
|
||||
# number of seconds allowed for a dnode to be offline, for cluster only
|
||||
#TAOS_OFFLINE_THRESHOLD: "8640000"
|
||||
|
||||
# RPC re-try timer, millisecond
|
||||
#TAOS_RPC_TIMER: "1000"
|
||||
|
||||
# RPC maximum time for ack, seconds.
|
||||
#TAOS_RPC_MAX_TIME: "600"
|
||||
|
||||
# time interval of dnode status reporting to mnode, seconds, for cluster only
|
||||
#TAOS_STATUS_INTERVAL: "1"
|
||||
|
||||
# time interval of heart beat from shell to dnode, seconds
|
||||
#TAOS_SHELL_ACTIVITY_TIMER: "3"
|
||||
|
||||
# minimum sliding window time, milli-second
|
||||
#TAOS_MIN_SLIDING_TIME: "10"
|
||||
|
||||
# minimum time window, milli-second
|
||||
#TAOS_MIN_INTERVAL_TIME: "10"
|
||||
|
||||
# maximum delay before launching a stream computation, milli-second
|
||||
#TAOS_MAX_STREAM_COMP_DELAY: "20000"
|
||||
|
||||
# maximum delay before launching a stream computation for the first time, milli-second
|
||||
#TAOS_MAX_FIRST_STREAM_COMP_DELAY: "10000"
|
||||
|
||||
# retry delay when a stream computation fails, milli-second
|
||||
#TAOS_RETRY_STREAM_COMP_DELAY: "10"
|
||||
|
||||
# the delayed time for launching a stream computation, from 0.1(default, 10% of whole computing time window) to 0.9
|
||||
#TAOS_STREAM_COMP_DELAY_RATIO: "0.1"
|
||||
|
||||
# max number of vgroups per db, 0 means configured automatically
|
||||
#TAOS_MAX_VGROUPS_PER_DB: "0"
|
||||
|
||||
# max number of tables per vnode
|
||||
#TAOS_MAX_TABLES_PER_VNODE: "1000000"
|
||||
|
||||
# the number of acknowledgments required for successful data writing
|
||||
#TAOS_QUORUM: "1"
|
||||
|
||||
# enable/disable compression
|
||||
#TAOS_COMP: "2"
|
||||
|
||||
# write ahead log (WAL) level, 0: no wal; 1: write wal, but no fysnc; 2: write wal, and call fsync
|
||||
#TAOS_WAL_LEVEL: "1"
|
||||
|
||||
# if walLevel is set to 2, the cycle of fsync being executed, if set to 0, fsync is called right away
|
||||
#TAOS_FSYNC: "3000"
|
||||
|
||||
# the compressed rpc message, option:
|
||||
# -1 (no compression)
|
||||
# 0 (all message compressed),
|
||||
# > 0 (rpc message body which larger than this value will be compressed)
|
||||
#TAOS_COMPRESS_MSG_SIZE: "-1"
|
||||
|
||||
# max length of an SQL
|
||||
#TAOS_MAX_SQL_LENGTH: "1048576"
|
||||
|
||||
# the maximum number of records allowed for super table time sorting
|
||||
#TAOS_MAX_NUM_OF_ORDERED_RES: "100000"
|
||||
|
||||
# max number of connections allowed in dnode
|
||||
#TAOS_MAX_SHELL_CONNS: "5000"
|
||||
|
||||
# max number of connections allowed in client
|
||||
#TAOS_MAX_CONNECTIONS: "5000"
|
||||
|
||||
# stop writing logs when the disk size of the log folder is less than this value
|
||||
#TAOS_MINIMAL_LOG_DIR_G_B: "0.1"
|
||||
|
||||
# stop writing temporary files when the disk size of the tmp folder is less than this value
|
||||
#TAOS_MINIMAL_TMP_DIR_G_B: "0.1"
|
||||
|
||||
# if disk free space is less than this value, taosd service exit directly within startup process
|
||||
#TAOS_MINIMAL_DATA_DIR_G_B: "0.1"
|
||||
|
||||
# One mnode is equal to the number of vnode consumed
|
||||
#TAOS_MNODE_EQUAL_VNODE_NUM: "4"
|
||||
|
||||
# enbale/disable http service
|
||||
#TAOS_HTTP: "1"
|
||||
|
||||
# enable/disable system monitor
|
||||
#TAOS_MONITOR: "1"
|
||||
|
||||
# enable/disable recording the SQL statements via restful interface
|
||||
#TAOS_HTTP_ENABLE_RECORD_SQL: "0"
|
||||
|
||||
# number of threads used to process http requests
|
||||
#TAOS_HTTP_MAX_THREADS: "2"
|
||||
|
||||
# maximum number of rows returned by the restful interface
|
||||
#TAOS_RESTFUL_ROW_LIMIT: "10240"
|
||||
|
||||
# The following parameter is used to limit the maximum number of lines in log files.
|
||||
# max number of lines per log filters
|
||||
# numOfLogLines 10000000
|
||||
|
||||
# enable/disable async log
|
||||
#TAOS_ASYNC_LOG: "0"
|
||||
|
||||
#
|
||||
# time of keeping log files, days
|
||||
#TAOS_LOG_KEEP_DAYS: "0"
|
||||
|
||||
# The following parameters are used for debug purpose only.
|
||||
# debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
|
||||
# 131: output warning and error
|
||||
# 135: output debug, warning and error
|
||||
# 143: output trace, debug, warning and error to log
|
||||
# 199: output debug, warning and error to both screen and file
|
||||
# 207: output trace, debug, warning and error to both screen and file
|
||||
#
|
||||
# debug flag for all log type, take effect when non-zero value\
|
||||
#TAOS_DEBUG_FLAG: "143"
|
||||
|
||||
# enable/disable recording the SQL in taos client
|
||||
#TAOS_ENABLE_RECORD_SQL: "0"
|
||||
|
||||
# generate core file when service crash
|
||||
#TAOS_ENABLE_CORE_FILE: "1"
|
||||
|
||||
# maximum display width of binary and nchar fields in the shell. The parts exceeding this limit will be hidden
|
||||
#TAOS_MAX_BINARY_DISPLAY_WIDTH: "30"
|
||||
|
||||
# enable/disable stream (continuous query)
|
||||
#TAOS_STREAM: "1"
|
||||
|
||||
# in retrieve blocking model, only in 50% query threads will be used in query processing in dnode
|
||||
#TAOS_RETRIEVE_BLOCKING_MODEL: "0"
|
||||
|
||||
# the maximum allowed query buffer size in MB during query processing for each data node
|
||||
# -1 no limit (default)
|
||||
# 0 no query allowed, queries are disabled
|
||||
#TAOS_QUERY_BUFFER_SIZE: "-1"
|
||||
```
|
||||
|
||||
## 扩容
|
||||
|
||||
关于扩容可参考上一节的说明,有一些额外的操作需要从 helm 的部署中获取。
|
||||
|
||||
首先,从部署中获取 StatefulSet 的名称。
|
||||
|
||||
```bash
|
||||
export STS_NAME=$(kubectl get statefulset \
|
||||
-l "app.kubernetes.io/name=tdengine" \
|
||||
-o jsonpath="{.items[0].metadata.name}")
|
||||
|
||||
```
|
||||
|
||||
扩容操作极其简单,增加 replica 即可。以下命令将 TDengine 扩充到三节点:
|
||||
|
||||
```bash
|
||||
kubectl scale --replicas 3 statefulset/$STS_NAME
|
||||
|
||||
```
|
||||
|
||||
使用命令 `show dnodes` 和 `show mnodes` 检查是否扩容成功。
|
||||
|
||||
## 缩容
|
||||
|
||||
:::warning
|
||||
缩容操作并没有完整测试,可能造成数据风险,请谨慎使用。
|
||||
|
||||
:::
|
||||
|
||||
获取需要缩容的 dnode 列表,并手动 Drop。
|
||||
|
||||
```bash
|
||||
kubectl --namespace default exec $POD_NAME -- \
|
||||
cat /var/lib/taos/dnode/dnodeEps.json \
|
||||
| jq '.dnodeInfos[1:] |map(.dnodeFqdn + ":" + (.dnodePort|tostring)) | .[]' -r
|
||||
kubectl --namespace default exec $POD_NAME -- taos -s "show dnodes"
|
||||
kubectl --namespace default exec $POD_NAME -- taos -s 'drop dnode "<you dnode in list>"'
|
||||
|
||||
```
|
||||
|
||||
## 删除集群
|
||||
|
||||
Helm 管理下,清理操作也变得简单:
|
||||
|
||||
```bash
|
||||
helm uninstall tdengine
|
||||
|
||||
```
|
||||
|
||||
但 Helm 也不会自动移除 PVC,需要手动获取 PVC 然后删除掉。
|
|
@ -0,0 +1 @@
|
|||
label: 部署集群
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
title: 集群管理
|
||||
title: 部署集群
|
||||
---
|
||||
|
||||
TDengine 支持集群,提供水平扩展的能力。如果需要获得更高的处理能力,只需要多增加节点即可。TDengine 采用虚拟节点技术,将一个节点虚拟化为多个虚拟节点,以实现负载均衡。同时,TDengine可以将多个节点上的虚拟节点组成虚拟节点组,通过多副本机制,以保证供系统的高可用。TDengine的集群功能完全开源。
|
||||
|
||||
本章节主要介绍集群的部署、维护,以及如何实现高可用和负载均衡。
|
||||
本章节主要介绍如何在主机上人工部署集群,以及如何使用 Kubernetes 和 Helm部署集群。
|
||||
|
||||
```mdx-code-block
|
||||
import DocCardList from '@theme/DocCardList';
|
|
@ -6,139 +6,50 @@ description: 安装、卸载、启动、停止和升级
|
|||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包。
|
||||
本节将介绍一些关于安装和卸载更深层次的内容,以及升级的注意事项。
|
||||
|
||||
## 安装
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Deb 安装" value="debinst">
|
||||
关于安装,请参考 [使用安装包立即开始](../get-started/package)
|
||||
|
||||
1、从官网下载获得 deb 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.deb;
|
||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
|
||||
## 安装目录说明
|
||||
|
||||
TDengine 成功安装后,主安装目录是 /usr/local/taos,目录内容如下:
|
||||
|
||||
```
|
||||
$ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb
|
||||
(Reading database ... 137504 files and directories currently installed.)
|
||||
Preparing to unpack TDengine-server-2.4.0.7-Linux-x64.deb ...
|
||||
TDengine is removed successfully!
|
||||
Unpacking tdengine (2.4.0.7) over (2.4.0.7) ...
|
||||
Setting up tdengine (2.4.0.7) ...
|
||||
Start to install TDengine...
|
||||
|
||||
System hostname is: ubuntu-1804
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h ubuntu-1804 to login into TDengine server
|
||||
|
||||
|
||||
TDengine is installed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="RPM 安装" value="rpminst">
|
||||
|
||||
1、从官网下载获得 rpm 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.rpm;
|
||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```
|
||||
$ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm
|
||||
Preparing... ################################# [100%]
|
||||
Updating / installing...
|
||||
1:tdengine-2.4.0.7-3 ################################# [100%]
|
||||
Start to install TDengine...
|
||||
|
||||
System hostname is: centos7
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
|
||||
Created symlink from /etc/systemd/system/multi-user.target.wants/taosd.service to /etc/systemd/system/taosd.service.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h centos7 to login into TDengine server
|
||||
|
||||
|
||||
TDengine is installed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="tar.gz 安装" value="tarinst">
|
||||
|
||||
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.tar.gz;
|
||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
||||
|
||||
```
|
||||
$ tar xvzf TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
|
||||
TDengine-enterprise-server-2.4.0.7/
|
||||
TDengine-enterprise-server-2.4.0.7/driver/
|
||||
TDengine-enterprise-server-2.4.0.7/driver/vercomp.txt
|
||||
TDengine-enterprise-server-2.4.0.7/driver/libtaos.so.2.4.0.7
|
||||
TDengine-enterprise-server-2.4.0.7/install.sh
|
||||
TDengine-enterprise-server-2.4.0.7/examples/
|
||||
...
|
||||
|
||||
$ cd /usr/local/taos
|
||||
$ ll
|
||||
total 43816
|
||||
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ./
|
||||
drwxr-xr-x 20 ubuntu ubuntu 4096 Feb 22 09:30 ../
|
||||
drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 TDengine-enterprise-server-2.4.0.7/
|
||||
-rw-rw-r-- 1 ubuntu ubuntu 44852544 Feb 22 09:31 TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
|
||||
|
||||
$ cd TDengine-enterprise-server-2.4.0.7/
|
||||
|
||||
$ ll
|
||||
total 40784
|
||||
drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 ./
|
||||
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ../
|
||||
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 22 09:30 driver/
|
||||
drwxrwxr-x 10 ubuntu ubuntu 4096 Feb 22 09:30 examples/
|
||||
-rwxrwxr-x 1 ubuntu ubuntu 33294 Feb 22 09:30 install.sh*
|
||||
-rw-rw-r-- 1 ubuntu ubuntu 41704288 Feb 22 09:30 taos.tar.gz
|
||||
|
||||
$ sudo ./install.sh
|
||||
|
||||
Start to update TDengine...
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||
Nginx for TDengine is updated successfully!
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To configure Taos Adapter (if has) : edit /etc/taos/taosadapter.toml
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : use taos -h ubuntu-1804 in shell OR from http://127.0.0.1:6060
|
||||
|
||||
TDengine is updated successfully!
|
||||
Install taoskeeper as a standalone service
|
||||
taoskeeper is installed, enable it by `systemctl enable taoskeeper`
|
||||
$ ll
|
||||
total 28
|
||||
drwxr-xr-x 7 root root 4096 Feb 22 09:34 ./
|
||||
drwxr-xr-x 12 root root 4096 Feb 22 09:34 ../
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 bin/
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 cfg/
|
||||
lrwxrwxrwx 1 root root 13 Feb 22 09:34 data -> /var/lib/taos/
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 driver/
|
||||
drwxr-xr-x 10 root root 4096 Feb 22 09:34 examples/
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 include/
|
||||
lrwxrwxrwx 1 root root 13 Feb 22 09:34 log -> /var/log/taos/
|
||||
```
|
||||
|
||||
:::info
|
||||
install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。
|
||||
|
||||
:::
|
||||
- 自动生成配置文件目录、数据库目录、日志目录。
|
||||
- 配置文件缺省目录:/etc/taos/taos.cfg, 软链接到 /usr/local/taos/cfg/taos.cfg;
|
||||
- 数据库缺省目录:/var/lib/taos, 软链接到 /usr/local/taos/data;
|
||||
- 日志缺省目录:/var/log/taos, 软链接到 /usr/local/taos/log;
|
||||
- /usr/local/taos/bin 目录下的可执行文件,会软链接到 /usr/bin 目录下;
|
||||
- /usr/local/taos/driver 目录下的动态库文件,会软链接到 /usr/lib 目录下;
|
||||
- /usr/local/taos/include 目录下的头文件,会软链接到到 /usr/include 目录下;
|
||||
|
||||
## 卸载
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="apt-get 卸载" value="aptremove">
|
||||
|
||||
内容 TBD
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="Deb 卸载" value="debuninst">
|
||||
|
||||
卸载命令如下:
|
||||
|
@ -180,6 +91,7 @@ taosKeeper is removed successfully!
|
|||
</Tabs>
|
||||
|
||||
:::info
|
||||
|
||||
- TDengine 提供了多种安装包,但最好不要在一个系统上同时使用 tar.gz 安装包和 deb 或 rpm 安装包。否则会相互影响,导致在使用时出现问题。
|
||||
|
||||
- 对于 deb 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令:
|
||||
|
@ -200,68 +112,12 @@ taosKeeper is removed successfully!
|
|||
|
||||
:::
|
||||
|
||||
## 安装目录说明
|
||||
|
||||
TDengine 成功安装后,主安装目录是 /usr/local/taos,目录内容如下:
|
||||
|
||||
```
|
||||
$ cd /usr/local/taos
|
||||
$ ll
|
||||
$ ll
|
||||
total 28
|
||||
drwxr-xr-x 7 root root 4096 Feb 22 09:34 ./
|
||||
drwxr-xr-x 12 root root 4096 Feb 22 09:34 ../
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 bin/
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 cfg/
|
||||
lrwxrwxrwx 1 root root 13 Feb 22 09:34 data -> /var/lib/taos/
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 driver/
|
||||
drwxr-xr-x 10 root root 4096 Feb 22 09:34 examples/
|
||||
drwxr-xr-x 2 root root 4096 Feb 22 09:34 include/
|
||||
lrwxrwxrwx 1 root root 13 Feb 22 09:34 log -> /var/log/taos/
|
||||
```
|
||||
|
||||
- 自动生成配置文件目录、数据库目录、日志目录。
|
||||
- 配置文件缺省目录:/etc/taos/taos.cfg, 软链接到 /usr/local/taos/cfg/taos.cfg;
|
||||
- 数据库缺省目录:/var/lib/taos, 软链接到 /usr/local/taos/data;
|
||||
- 日志缺省目录:/var/log/taos, 软链接到 /usr/local/taos/log;
|
||||
- /usr/local/taos/bin 目录下的可执行文件,会软链接到 /usr/bin 目录下;
|
||||
- /usr/local/taos/driver 目录下的动态库文件,会软链接到 /usr/lib 目录下;
|
||||
- /usr/local/taos/include 目录下的头文件,会软链接到到 /usr/include 目录下;
|
||||
|
||||
## 卸载和更新文件说明
|
||||
|
||||
卸载安装包的时候,将保留配置文件、数据库文件和日志文件,即 /etc/taos/taos.cfg 、 /var/lib/taos 、 /var/log/taos 。如果用户确认后不需保留,可以手工删除,但一定要慎重,因为删除后,数据将永久丢失,不可以恢复!
|
||||
|
||||
如果是更新安装,当缺省配置文件( /etc/taos/taos.cfg )存在时,仍然使用已有的配置文件,安装包中携带的配置文件修改为 taos.cfg.orig 保存在 /usr/local/taos/cfg/ 目录,可以作为设置配置参数的参考样例;如果不存在配置文件,就使用安装包中自带的配置文件。
|
||||
|
||||
## 启动和停止
|
||||
|
||||
TDengine 使用 Linux 系统的 systemd/systemctl/service 来管理系统的启动和、停止、重启操作。TDengine 的服务进程是 taosd,默认情况下 TDengine 在系统启动后将自动启动。DBA 可以通过 systemd/systemctl/service 手动操作停止、启动、重新启动服务。
|
||||
|
||||
以 systemctl 为例,命令如下:
|
||||
|
||||
- 启动服务进程:`systemctl start taosd`
|
||||
|
||||
- 停止服务进程:`systemctl stop taosd`
|
||||
|
||||
- 重启服务进程:`systemctl restart taosd`
|
||||
|
||||
- 查看服务状态:`systemctl status taosd`
|
||||
|
||||
注意:TDengine 在 2.4 版本之后包含一个独立组件 taosAdapter 需要使用 systemctl 命令管理 taosAdapter 服务的启动和停止。
|
||||
|
||||
如果服务进程处于活动状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: active (running)
|
||||
```
|
||||
|
||||
如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: inactive (dead)
|
||||
```
|
||||
|
||||
## 升级
|
||||
升级分为两个层面:升级安装包 和 升级运行中的实例。
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ Maven 项目中,在 pom.xml 中添加以下依赖:
|
|||
可以通过下载 TDengine 的源码,自己编译最新版本的 Java connector
|
||||
|
||||
```shell
|
||||
git clone https://github.com/taosdata/taos-connector-jdbc.git
|
||||
git clone https://github.com/taosdata/taos-connector-jdbc.git --branch 2.0
|
||||
cd taos-connector-jdbc
|
||||
mvn clean install -Dmaven.test.skip=true
|
||||
```
|
||||
|
|
|
@ -13,9 +13,15 @@ IF (TD_LINUX)
|
|||
#TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread lua)
|
||||
|
||||
add_executable(tmq "")
|
||||
add_executable(tmq_taosx "")
|
||||
add_executable(stream_demo "")
|
||||
add_executable(demoapi "")
|
||||
|
||||
target_sources(tmq_taosx
|
||||
PRIVATE
|
||||
"tmq_taosx.c"
|
||||
)
|
||||
|
||||
target_sources(tmq
|
||||
PRIVATE
|
||||
"tmq.c"
|
||||
|
@ -35,6 +41,10 @@ IF (TD_LINUX)
|
|||
taos_static
|
||||
)
|
||||
|
||||
target_link_libraries(tmq_taosx
|
||||
taos_static
|
||||
)
|
||||
|
||||
target_link_libraries(stream_demo
|
||||
taos_static
|
||||
)
|
||||
|
@ -47,6 +57,10 @@ IF (TD_LINUX)
|
|||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_include_directories(tmq_taosx
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
target_include_directories(stream_demo
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
|
@ -59,6 +73,7 @@ IF (TD_LINUX)
|
|||
)
|
||||
|
||||
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
||||
SET_TARGET_PROPERTIES(tmq_taosx PROPERTIES OUTPUT_NAME tmq_taosx)
|
||||
SET_TARGET_PROPERTIES(stream_demo PROPERTIES OUTPUT_NAME stream_demo)
|
||||
SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi)
|
||||
ENDIF ()
|
||||
|
|
|
@ -302,7 +302,7 @@ int32_t create_topic() {
|
|||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
/*pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1");*/
|
||||
// pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1");
|
||||
pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from st1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "taos.h"
|
||||
|
||||
static int running = 1;
|
||||
|
||||
static TAOS* use_db(){
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use db_taosx");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||
return NULL;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
return pConn;
|
||||
}
|
||||
|
||||
static void msg_process(TAOS_RES* msg) {
|
||||
/*memset(buf, 0, 1024);*/
|
||||
printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg));
|
||||
printf("db: %s\n", tmq_get_db_name(msg));
|
||||
printf("vg: %d\n", tmq_get_vgroup_id(msg));
|
||||
TAOS *pConn = use_db();
|
||||
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
||||
char* result = tmq_get_json_meta(msg);
|
||||
if (result) {
|
||||
printf("meta result: %s\n", result);
|
||||
}
|
||||
tmq_free_json_meta(result);
|
||||
|
||||
|
||||
tmq_raw_data raw = {0};
|
||||
tmq_get_raw_meta(msg, &raw);
|
||||
int32_t ret = taos_write_raw_meta(pConn, raw);
|
||||
printf("write raw meta: %s\n", tmq_err2str(ret));
|
||||
}
|
||||
|
||||
if(tmq_get_res_type(msg) == TMQ_RES_DATA){
|
||||
int32_t ret =taos_write_raw_data(pConn, msg);
|
||||
printf("write raw data: %s\n", tmq_err2str(ret));
|
||||
}
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
int32_t init_env() {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create database if not exists db_taosx vgroups 4");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "drop database if exists abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in drop db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create database if not exists abc1 vgroups 3");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn,
|
||||
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
|
||||
"nchar(8), t4 bool)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct0 values(now, 1, 2, 'a')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct1 values(now, 3, 4, 'b')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct3 values(now, 5, 6, 'c') ct1 values(now+1s, 2, 3, 'sds') (now+2s, 4, 5, 'ddd') ct0 values(now+1s, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table st1 add column c4 bigint");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct3 values(now+7s, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (now+9s, 51, 62, 'c333', 940)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table st1 add tag t2 binary(64)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table ct3 set tag t1=5000");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to slter child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
// pRes = taos_query(pConn, "drop table ct3 ct1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||
// return -1;
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
//
|
||||
// pRes = taos_query(pConn, "drop table st1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
// return -1;
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 add column c3 bigint");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 modify column c2 nchar(8)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 rename column c3 cc3");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 comment 'hello'");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 drop column c1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
// pRes = taos_query(pConn, "drop table n1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
// return -1;
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table jt1 using jt tags('{\"k1\":1, \"k2\":\"hello\"}')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table jt2 using jt tags('')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
// pRes = taos_query(pConn,
|
||||
// "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
|
||||
// "nchar(8), t4 bool)");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
// return -1;
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
//
|
||||
// pRes = taos_query(pConn, "drop table st1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
// return -1;
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t create_topic() {
|
||||
printf("create topic\n");
|
||||
TAOS_RES* pRes;
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
|
||||
printf("commit %d tmq %p param %p\n", code, tmq, param);
|
||||
}
|
||||
|
||||
tmq_t* build_consumer() {
|
||||
#if 0
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
#endif
|
||||
|
||||
tmq_conf_t* conf = tmq_conf_new();
|
||||
tmq_conf_set(conf, "group.id", "tg2");
|
||||
tmq_conf_set(conf, "client.id", "my app 1");
|
||||
tmq_conf_set(conf, "td.connect.user", "root");
|
||||
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
||||
tmq_conf_set(conf, "msg.with.table.name", "true");
|
||||
tmq_conf_set(conf, "enable.auto.commit", "true");
|
||||
|
||||
/*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/
|
||||
|
||||
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
|
||||
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||
assert(tmq);
|
||||
tmq_conf_destroy(conf);
|
||||
return tmq;
|
||||
}
|
||||
|
||||
tmq_list_t* build_topic_list() {
|
||||
tmq_list_t* topic_list = tmq_list_new();
|
||||
tmq_list_append(topic_list, "topic_ctb_column");
|
||||
/*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/
|
||||
return topic_list;
|
||||
}
|
||||
|
||||
void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||
int32_t code;
|
||||
|
||||
if ((code = tmq_subscribe(tmq, topics))) {
|
||||
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
|
||||
printf("subscribe err\n");
|
||||
return;
|
||||
}
|
||||
int32_t cnt = 0;
|
||||
while (running) {
|
||||
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, -1);
|
||||
if (tmqmessage) {
|
||||
cnt++;
|
||||
msg_process(tmqmessage);
|
||||
/*if (cnt >= 2) break;*/
|
||||
/*printf("get data\n");*/
|
||||
taos_free_result(tmqmessage);
|
||||
/*} else {*/
|
||||
/*break;*/
|
||||
/*tmq_commit_sync(tmq, NULL);*/
|
||||
}
|
||||
}
|
||||
|
||||
code = tmq_consumer_close(tmq);
|
||||
if (code)
|
||||
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
||||
else
|
||||
fprintf(stderr, "%% Consumer closed\n");
|
||||
}
|
||||
|
||||
void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||
static const int MIN_COMMIT_COUNT = 1;
|
||||
|
||||
int msg_count = 0;
|
||||
int32_t code;
|
||||
|
||||
if ((code = tmq_subscribe(tmq, topics))) {
|
||||
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
|
||||
return;
|
||||
}
|
||||
|
||||
tmq_list_t* subList = NULL;
|
||||
tmq_subscription(tmq, &subList);
|
||||
char** subTopics = tmq_list_to_c_array(subList);
|
||||
int32_t sz = tmq_list_get_size(subList);
|
||||
printf("subscribed topics: ");
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
printf("%s, ", subTopics[i]);
|
||||
}
|
||||
printf("\n");
|
||||
tmq_list_destroy(subList);
|
||||
|
||||
while (running) {
|
||||
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||
if (tmqmessage) {
|
||||
msg_process(tmqmessage);
|
||||
taos_free_result(tmqmessage);
|
||||
|
||||
/*tmq_commit_sync(tmq, NULL);*/
|
||||
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
||||
}
|
||||
}
|
||||
|
||||
code = tmq_consumer_close(tmq);
|
||||
if (code)
|
||||
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
||||
else
|
||||
fprintf(stderr, "%% Consumer closed\n");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
printf("env init\n");
|
||||
if (init_env() < 0) {
|
||||
return -1;
|
||||
}
|
||||
create_topic();
|
||||
|
||||
tmq_t* tmq = build_consumer();
|
||||
tmq_list_t* topic_list = build_topic_list();
|
||||
basic_consume_loop(tmq, topic_list);
|
||||
/*sync_consume_loop(tmq, topic_list);*/
|
||||
}
|
|
@ -270,6 +270,7 @@ typedef enum tmq_res_t tmq_res_t;
|
|||
DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res);
|
||||
DLL_EXPORT int32_t tmq_get_raw_meta(TAOS_RES *res, tmq_raw_data *raw_meta);
|
||||
DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data raw_meta);
|
||||
DLL_EXPORT int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *res);
|
||||
DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed by tmq_free_json_meta
|
||||
DLL_EXPORT void tmq_free_json_meta(char* jsonMeta);
|
||||
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||
|
|
|
@ -34,11 +34,10 @@ typedef enum {
|
|||
TSDB_SUPER_TABLE = 1, // super table
|
||||
TSDB_CHILD_TABLE = 2, // table created from super table
|
||||
TSDB_NORMAL_TABLE = 3, // ordinary table
|
||||
TSDB_STREAM_TABLE = 4, // table created from stream computing
|
||||
TSDB_TEMP_TABLE = 5, // temp table created by nest query
|
||||
TSDB_SYSTEM_TABLE = 6,
|
||||
TSDB_TSMA_TABLE = 7, // time-range-wise sma
|
||||
TSDB_TABLE_MAX = 8
|
||||
TSDB_TEMP_TABLE = 4, // temp table created by nest query
|
||||
TSDB_SYSTEM_TABLE = 5,
|
||||
TSDB_TSMA_TABLE = 6, // time-range-wise sma
|
||||
TSDB_TABLE_MAX = 7
|
||||
} ETableType;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -103,6 +103,7 @@ typedef struct SDataBlockInfo {
|
|||
int16_t hasVarCol;
|
||||
uint32_t capacity;
|
||||
// TODO: optimize and remove following
|
||||
int64_t version; // used for stream, and need serialization
|
||||
int32_t childId; // used for stream, do not serialize
|
||||
EStreamType type; // used for stream, do not serialize
|
||||
STimeWindow calWin; // used for stream, do not serialize
|
||||
|
|
|
@ -184,8 +184,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
|
|||
int32_t getJsonValueLen(const char* data);
|
||||
|
||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, uint32_t* capacity,
|
||||
const SColumnInfoData* pSource, uint32_t numOfRow2);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
||||
const SColumnInfoData* pSource, int32_t numOfRow2);
|
||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
|
||||
const SDataBlockInfo* pBlockInfo);
|
||||
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex);
|
||||
|
|
|
@ -21,6 +21,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
|
||||
typedef enum {
|
||||
TSDB_GRANT_ALL,
|
||||
|
|
|
@ -438,7 +438,7 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaW
|
|||
return 0;
|
||||
}
|
||||
|
||||
STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
|
||||
STSchema* tdGetSTSChemaFromSSChema(SSchema* pSchema, int32_t nCols, int32_t sver);
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
|
@ -1359,6 +1359,7 @@ typedef struct {
|
|||
int32_t numOfCols;
|
||||
int64_t skey;
|
||||
int64_t ekey;
|
||||
int64_t version; // for stream
|
||||
char data[];
|
||||
} SRetrieveTableRsp;
|
||||
|
||||
|
@ -1976,6 +1977,7 @@ typedef struct SVCreateTbReq {
|
|||
union {
|
||||
struct {
|
||||
char* name; // super table name
|
||||
uint8_t tagNum;
|
||||
tb_uid_t suid;
|
||||
SArray* tagName;
|
||||
uint8_t* pTag;
|
||||
|
@ -2536,6 +2538,15 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
|
|||
return (void*)buf;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||
int64_t ntbUid;
|
||||
SArray* colIdList; // SArray<int16_t>
|
||||
} SCheckAlterInfo;
|
||||
|
||||
int32_t tEncodeSCheckAlterInfo(SEncoder* pEncoder, const SCheckAlterInfo* pInfo);
|
||||
int32_t tDecodeSCheckAlterInfo(SDecoder* pDecoder, SCheckAlterInfo* pInfo);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
int64_t offset;
|
||||
|
|
|
@ -186,6 +186,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CHECK_ALTER_INFO, "vnode-alter-check-info", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TOPIC, "vnode-alter-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TOPIC, "vnode-drop-topic", NULL, NULL)
|
||||
|
|
|
@ -50,6 +50,7 @@ bool tNameIsValid(const SName* name);
|
|||
const char* tNameGetTableName(const SName* name);
|
||||
|
||||
int32_t tNameGetDbName(const SName* name, char* dst);
|
||||
const char* tNameGetDbNameP(const SName* name);
|
||||
|
||||
int32_t tNameGetFullDbName(const SName* name, char* dst);
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
|||
}
|
||||
|
||||
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||
int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision);
|
||||
|
||||
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision);
|
||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision);
|
||||
|
|
|
@ -64,7 +64,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
|||
* @param SReadHandle
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols);
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols,
|
||||
SSchemaWrapper** pSchema);
|
||||
|
||||
/**
|
||||
* Set the input data block for the stream scan.
|
||||
|
@ -195,6 +196,8 @@ int32_t qStreamInput(qTaskInfo_t tinfo, void* pItem);
|
|||
|
||||
int32_t qStreamPrepareRecover(qTaskInfo_t tinfo, int64_t startVer, int64_t endVer);
|
||||
|
||||
STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -197,6 +197,7 @@ bool fmIsSystemInfoFunc(int32_t funcId);
|
|||
bool fmIsImplicitTsFunc(int32_t funcId);
|
||||
bool fmIsClientPseudoColumnFunc(int32_t funcId);
|
||||
bool fmIsMultiRowsFunc(int32_t funcId);
|
||||
bool fmIsKeepOrderFunc(int32_t funcId);
|
||||
|
||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||
|
||||
|
|
|
@ -29,9 +29,17 @@ extern "C" {
|
|||
typedef enum EDataOrderLevel {
|
||||
DATA_ORDER_LEVEL_NONE = 1,
|
||||
DATA_ORDER_LEVEL_IN_BLOCK,
|
||||
DATA_ORDER_LEVEL_IN_GROUP
|
||||
DATA_ORDER_LEVEL_IN_GROUP,
|
||||
DATA_ORDER_LEVEL_GLOBAL
|
||||
} EDataOrderLevel;
|
||||
|
||||
typedef enum EGroupAction {
|
||||
GROUP_ACTION_NONE = 1,
|
||||
GROUP_ACTION_SET,
|
||||
GROUP_ACTION_KEEP,
|
||||
GROUP_ACTION_CLEAR
|
||||
} EGroupAction;
|
||||
|
||||
typedef struct SLogicNode {
|
||||
ENodeType type;
|
||||
SNodeList* pTargets; // SColumnNode
|
||||
|
@ -44,6 +52,7 @@ typedef struct SLogicNode {
|
|||
SNode* pSlimit;
|
||||
EDataOrderLevel requireDataOrder; // requirements for input data
|
||||
EDataOrderLevel resultDataOrder; // properties of the output data
|
||||
EGroupAction groupAction;
|
||||
} SLogicNode;
|
||||
|
||||
typedef enum EScanType {
|
||||
|
@ -102,6 +111,7 @@ typedef struct SAggLogicNode {
|
|||
SNodeList* pGroupKeys;
|
||||
SNodeList* pAggFuncs;
|
||||
bool hasLastRow;
|
||||
bool hasTimeLineFunc;
|
||||
} SAggLogicNode;
|
||||
|
||||
typedef struct SProjectLogicNode {
|
||||
|
|
|
@ -193,7 +193,7 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code);
|
|||
|
||||
void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
||||
|
||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo,
|
||||
int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, SMsgSendInfo* pInfo,
|
||||
bool persistHandle, void* ctx);
|
||||
|
||||
/**
|
||||
|
@ -205,7 +205,7 @@ int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTra
|
|||
* @param pInfo
|
||||
* @return
|
||||
*/
|
||||
int32_t asyncSendMsgToServer(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, const SMsgSendInfo* pInfo);
|
||||
int32_t asyncSendMsgToServer(void* pTransporter, SEpSet* epSet, int64_t* pTransporterId, SMsgSendInfo* pInfo);
|
||||
|
||||
int32_t queryBuildUseDbOutput(SUseDbOutput* pOut, SUseDbRsp* usedbRsp);
|
||||
|
||||
|
@ -260,6 +260,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
|
||||
#define REQUEST_TOTAL_EXEC_TIMES 2
|
||||
|
||||
#define IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB))))
|
||||
|
||||
#define qFatal(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_FATAL) { \
|
||||
|
|
|
@ -142,6 +142,7 @@ static FORCE_INLINE void* streamQueueNextItem(SStreamQueue* queue) {
|
|||
ASSERT(queue->qItem != NULL);
|
||||
return streamQueueCurItem(queue);
|
||||
} else {
|
||||
queue->qItem = NULL;
|
||||
taosGetQitem(queue->qall, &queue->qItem);
|
||||
if (queue->qItem == NULL) {
|
||||
taosReadAllQitems(queue->queue, queue->qall);
|
||||
|
|
|
@ -33,11 +33,12 @@ typedef struct SUpdateInfo {
|
|||
int64_t watermark;
|
||||
TSKEY minTS;
|
||||
SScalableBf* pCloseWinSBF;
|
||||
SHashObj* pMap;
|
||||
} SUpdateInfo;
|
||||
|
||||
SUpdateInfo *updateInfoInitP(SInterval* pInterval, int64_t watermark);
|
||||
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark);
|
||||
bool updateInfoIsUpdated(SUpdateInfo *pInfo, tb_uid_t tableId, TSKEY ts);
|
||||
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts);
|
||||
void updateInfoDestroy(SUpdateInfo *pInfo);
|
||||
void updateInfoAddCloseWindowSBF(SUpdateInfo *pInfo);
|
||||
void updateInfoDestoryColseWinSBF(SUpdateInfo *pInfo);
|
||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
|||
|
||||
extern bool gRaftDetailLog;
|
||||
|
||||
#define SYNC_RESP_TTL_MS 10000
|
||||
#define SYNC_RESP_TTL_MS 10000000
|
||||
|
||||
#define SYNC_MAX_BATCH_SIZE 500
|
||||
#define SYNC_INDEX_BEGIN 0
|
||||
|
|
|
@ -124,18 +124,16 @@ void *rpcReallocCont(void *ptr, int32_t contLen);
|
|||
// Because taosd supports multi-process mode
|
||||
// These functions should not be used on the server side
|
||||
// Please use tmsg<xx> functions, which are defined in tmsgcb.h
|
||||
void rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||
void rpcSendResponse(const SRpcMsg *pMsg);
|
||||
void rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
||||
void rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock
|
||||
int rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||
int rpcSendResponse(const SRpcMsg *pMsg);
|
||||
int rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
||||
int rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock
|
||||
|
||||
// These functions will not be called in the child process
|
||||
void rpcSendRedirectRsp(void *pConn, const SEpSet *pEpSet);
|
||||
void rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||
int32_t rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
||||
void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||
void rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
||||
void* rpcAllocHandle();
|
||||
int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||
int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||
int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
||||
void *rpcAllocHandle();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -39,10 +39,10 @@ extern "C" {
|
|||
#define WAL_LOG_SUFFIX "log"
|
||||
#define WAL_INDEX_SUFFIX "idx"
|
||||
#define WAL_REFRESH_MS 1000
|
||||
#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalCkHead))
|
||||
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
||||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDULL
|
||||
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
||||
|
||||
typedef enum {
|
||||
TAOS_WAL_WRITE = 1,
|
||||
|
@ -135,6 +135,7 @@ typedef struct {
|
|||
int64_t curVersion;
|
||||
int64_t capacity;
|
||||
int8_t curInvalid;
|
||||
int8_t curStopped;
|
||||
TdThreadMutex mutex;
|
||||
SWalFilterCond cond;
|
||||
SWalCkHead *pHead;
|
||||
|
|
|
@ -44,7 +44,11 @@ extern "C" {
|
|||
#define SIGBREAK 1234
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS
|
||||
typedef BOOL (*FSignalHandler)(DWORD fdwCtrlType);
|
||||
#else
|
||||
typedef void (*FSignalHandler)(int32_t signum, void *sigInfo, void *context);
|
||||
#endif
|
||||
void taosSetSignal(int32_t signum, FSignalHandler sigfp);
|
||||
void taosIgnSignal(int32_t signum);
|
||||
void taosDflSignal(int32_t signum);
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
SDiskSize size;
|
||||
} SDiskSpace;
|
||||
|
||||
bool taosCheckSystemIsSmallEnd();
|
||||
bool taosCheckSystemIsLittleEnd();
|
||||
void taosGetSystemInfo();
|
||||
int32_t taosGetEmail(char *email, int32_t maxLen);
|
||||
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen);
|
||||
|
|
|
@ -29,9 +29,6 @@ extern "C" {
|
|||
#define tcgetattr TCGETATTR_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
#define TAOS_CONSOLE_PROMPT_HEADER "taos> "
|
||||
#define TAOS_CONSOLE_PROMPT_CONTINUE " -> "
|
||||
|
||||
typedef struct TdCmd *TdCmdPtr;
|
||||
|
||||
TdCmdPtr taosOpenCmd(const char* cmd);
|
||||
|
|
|
@ -39,56 +39,57 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_SUCCESS 0
|
||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||
|
||||
//common & util
|
||||
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0003)
|
||||
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0004)
|
||||
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005)
|
||||
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0010)
|
||||
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0011)
|
||||
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0012)
|
||||
#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0013)
|
||||
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0014)
|
||||
#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0015)
|
||||
#define TSDB_CODE_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0016)
|
||||
#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0017)
|
||||
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0018)
|
||||
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0019)
|
||||
#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x001A)
|
||||
#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x001B)
|
||||
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x001C)
|
||||
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x001D)
|
||||
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x001E)
|
||||
#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x001F)
|
||||
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0020)
|
||||
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x0021)
|
||||
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0022)
|
||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0023)
|
||||
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0024)
|
||||
#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0025)
|
||||
#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0026)
|
||||
#define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0027)
|
||||
#define TSDB_CODE_NEED_RETRY TAOS_DEF_ERROR_CODE(0, 0x0028)
|
||||
#define TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE TAOS_DEF_ERROR_CODE(0, 0x0029)
|
||||
#define TSDB_CODE_INVALID_TIMESTAMP TAOS_DEF_ERROR_CODE(0, 0x0030)
|
||||
#define TSDB_CODE_MSG_DECODE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0031)
|
||||
#define TSDB_CODE_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0032)
|
||||
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0033)
|
||||
#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0034)
|
||||
|
||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0040)
|
||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0041)
|
||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0042)
|
||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0043)
|
||||
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0044)
|
||||
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0045)
|
||||
|
||||
// rpc
|
||||
#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0100)
|
||||
#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0101)
|
||||
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0102)
|
||||
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0103)
|
||||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0104)
|
||||
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0105)
|
||||
#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003)
|
||||
#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004)
|
||||
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x000B)
|
||||
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015)
|
||||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017)
|
||||
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018)
|
||||
|
||||
//common & util
|
||||
#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0013)
|
||||
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014)
|
||||
|
||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100)
|
||||
#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0101)
|
||||
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0102)
|
||||
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104)
|
||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105)
|
||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106)
|
||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107)
|
||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108)
|
||||
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0109)
|
||||
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x010A)
|
||||
|
||||
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110)
|
||||
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0111)
|
||||
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0112)
|
||||
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0113)
|
||||
#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0114)
|
||||
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0115)
|
||||
#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0116)
|
||||
#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0117)
|
||||
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0118)
|
||||
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0119)
|
||||
#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x011A)
|
||||
#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x011B)
|
||||
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x011C)
|
||||
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x011D)
|
||||
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x011E)
|
||||
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x011F)
|
||||
|
||||
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0120)
|
||||
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0121)
|
||||
#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0122)
|
||||
#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0123)
|
||||
#define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0124)
|
||||
#define TSDB_CODE_NEED_RETRY TAOS_DEF_ERROR_CODE(0, 0x0125)
|
||||
#define TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE TAOS_DEF_ERROR_CODE(0, 0x0126)
|
||||
#define TSDB_CODE_INVALID_TIMESTAMP TAOS_DEF_ERROR_CODE(0, 0x0127)
|
||||
#define TSDB_CODE_MSG_DECODE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0128)
|
||||
#define TSDB_CODE_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0129)
|
||||
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x012A)
|
||||
|
||||
//client
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||
|
@ -126,152 +127,145 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSC_DUP_NAMES TAOS_DEF_ERROR_CODE(0, 0x0220)
|
||||
#define TSDB_CODE_TSC_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x0221)
|
||||
#define TSDB_CODE_TSC_INVALID_JSON_TYPE TAOS_DEF_ERROR_CODE(0, 0x0222)
|
||||
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0223)
|
||||
#define TSDB_CODE_TSC_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0X0224)
|
||||
#define TSDB_CODE_TSC_STMT_API_ERROR TAOS_DEF_ERROR_CODE(0, 0X0225)
|
||||
#define TSDB_CODE_TSC_STMT_TBNAME_ERROR TAOS_DEF_ERROR_CODE(0, 0X0226)
|
||||
#define TSDB_CODE_TSC_STMT_CLAUSE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0227)
|
||||
#define TSDB_CODE_TSC_QUERY_KILLED TAOS_DEF_ERROR_CODE(0, 0X0228)
|
||||
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X0229)
|
||||
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022a)
|
||||
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224)
|
||||
#define TSDB_CODE_TSC_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0X0229)
|
||||
#define TSDB_CODE_TSC_STMT_API_ERROR TAOS_DEF_ERROR_CODE(0, 0X022A)
|
||||
#define TSDB_CODE_TSC_STMT_TBNAME_ERROR TAOS_DEF_ERROR_CODE(0, 0X022B)
|
||||
#define TSDB_CODE_TSC_STMT_CLAUSE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022C)
|
||||
#define TSDB_CODE_TSC_QUERY_KILLED TAOS_DEF_ERROR_CODE(0, 0X022D)
|
||||
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X022E)
|
||||
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022F)
|
||||
|
||||
// mnode-common
|
||||
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
|
||||
#define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0301)
|
||||
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0302)
|
||||
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0303)
|
||||
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0304)
|
||||
|
||||
// mnode-show
|
||||
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x0310)
|
||||
|
||||
// mnode-profile
|
||||
#define TSDB_CODE_MND_INVALID_QUERY_ID TAOS_DEF_ERROR_CODE(0, 0x0320)
|
||||
#define TSDB_CODE_MND_INVALID_STREAM_ID TAOS_DEF_ERROR_CODE(0, 0x0321)
|
||||
#define TSDB_CODE_MND_INVALID_CONN_ID TAOS_DEF_ERROR_CODE(0, 0x0322)
|
||||
#define TSDB_CODE_MND_MNODE_IS_RUNNING TAOS_DEF_ERROR_CODE(0, 0x0323)
|
||||
#define TSDB_CODE_MND_FAILED_TO_CONFIG_SYNC TAOS_DEF_ERROR_CODE(0, 0x0324)
|
||||
#define TSDB_CODE_MND_FAILED_TO_START_SYNC TAOS_DEF_ERROR_CODE(0, 0x0325)
|
||||
#define TSDB_CODE_MND_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0326)
|
||||
#define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0327)
|
||||
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0303)
|
||||
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304)
|
||||
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0305)
|
||||
#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_STREAM_ID TAOS_DEF_ERROR_CODE(0, 0x030D)
|
||||
#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_FAILED_TO_CONFIG_SYNC TAOS_DEF_ERROR_CODE(0, 0x0311)
|
||||
#define TSDB_CODE_MND_FAILED_TO_START_SYNC TAOS_DEF_ERROR_CODE(0, 0x0312)
|
||||
#define TSDB_CODE_MND_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0313)
|
||||
#define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314)
|
||||
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0315)
|
||||
|
||||
// mnode-sdb
|
||||
#define TSDB_CODE_SDB_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0330)
|
||||
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0331)
|
||||
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0332)
|
||||
#define TSDB_CODE_SDB_OBJ_CREATING TAOS_DEF_ERROR_CODE(0, 0x0333)
|
||||
#define TSDB_CODE_SDB_OBJ_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0334)
|
||||
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0335)
|
||||
#define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0336)
|
||||
#define TSDB_CODE_SDB_INVALID_ACTION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0337)
|
||||
#define TSDB_CODE_SDB_INVALID_STATUS_TYPE TAOS_DEF_ERROR_CODE(0, 0x0338)
|
||||
#define TSDB_CODE_SDB_INVALID_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0339)
|
||||
#define TSDB_CODE_SDB_INVALID_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x033A)
|
||||
#define TSDB_CODE_SDB_INVALID_DATA_CONTENT TAOS_DEF_ERROR_CODE(0, 0x033B)
|
||||
#define TSDB_CODE_SDB_INVALID_WAl_VER TAOS_DEF_ERROR_CODE(0, 0x033C)
|
||||
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0320)
|
||||
#define TSDB_CODE_SDB_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321)
|
||||
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0322)
|
||||
#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_SDB_INVALID_ACTION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326)
|
||||
#define TSDB_CODE_SDB_INVALID_STATUS_TYPE TAOS_DEF_ERROR_CODE(0, 0x0327)
|
||||
#define TSDB_CODE_SDB_INVALID_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0328)
|
||||
#define TSDB_CODE_SDB_INVALID_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0329)
|
||||
#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_OBJ_CREATING TAOS_DEF_ERROR_CODE(0, 0x032C)
|
||||
#define TSDB_CODE_SDB_OBJ_DROPPING TAOS_DEF_ERROR_CODE(0, 0x032D)
|
||||
|
||||
// mnode-dnode
|
||||
#define TSDB_CODE_MND_DNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
||||
#define TSDB_CODE_MND_DNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0341)
|
||||
#define TSDB_CODE_MND_TOO_MANY_DNODES TAOS_DEF_ERROR_CODE(0, 0x0342)
|
||||
#define TSDB_CODE_MND_NO_ENOUGH_DNODES TAOS_DEF_ERROR_CODE(0, 0x0343)
|
||||
#define TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0344)
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_CFG TAOS_DEF_ERROR_CODE(0, 0x0345)
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_ID TAOS_DEF_ERROR_CODE(0, 0x0346)
|
||||
#define TSDB_CODE_MND_INVALID_DNODE_CFG TAOS_DEF_ERROR_CODE(0, 0x0347)
|
||||
#define TSDB_CODE_MND_INVALID_DNODE_EP TAOS_DEF_ERROR_CODE(0, 0x0348)
|
||||
#define TSDB_CODE_MND_INVALID_DNODE_ID TAOS_DEF_ERROR_CODE(0, 0x0349)
|
||||
|
||||
// mnode-node
|
||||
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0350)
|
||||
#define TSDB_CODE_MND_MNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0351)
|
||||
#define TSDB_CODE_MND_QNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0352)
|
||||
#define TSDB_CODE_MND_QNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0353)
|
||||
#define TSDB_CODE_MND_SNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0354)
|
||||
#define TSDB_CODE_MND_SNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0355)
|
||||
#define TSDB_CODE_MND_BNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0356)
|
||||
#define TSDB_CODE_MND_BNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0357)
|
||||
#define TSDB_CODE_MND_TOO_FEW_MNODES TAOS_DEF_ERROR_CODE(0, 0x0358)
|
||||
#define TSDB_CODE_MND_TOO_MANY_MNODES TAOS_DEF_ERROR_CODE(0, 0x0359)
|
||||
#define TSDB_CODE_MND_CANT_DROP_LEADER TAOS_DEF_ERROR_CODE(0, 0x035A)
|
||||
// mnode-dnode-part1
|
||||
#define TSDB_CODE_MND_DNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0330)
|
||||
#define TSDB_CODE_MND_DNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0331)
|
||||
#define TSDB_CODE_MND_VGROUP_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0332)
|
||||
#define TSDB_CODE_MND_CANT_DROP_LEADER TAOS_DEF_ERROR_CODE(0, 0x0333)
|
||||
#define TSDB_CODE_MND_NO_ENOUGH_DNODES TAOS_DEF_ERROR_CODE(0, 0x0334)
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_CFG TAOS_DEF_ERROR_CODE(0, 0x0335)
|
||||
#define TSDB_CODE_MND_VGROUP_NOT_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0338)
|
||||
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0339)
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_ID TAOS_DEF_ERROR_CODE(0, 0x033B)
|
||||
|
||||
// mnode-acct
|
||||
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_ACCT_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0361)
|
||||
#define TSDB_CODE_MND_TOO_MANY_ACCTS TAOS_DEF_ERROR_CODE(0, 0x0362)
|
||||
#define TSDB_CODE_MND_INVALID_ACCT_OPTION TAOS_DEF_ERROR_CODE(0, 0x0363)
|
||||
#define TSDB_CODE_MND_ACCT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0364)
|
||||
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
||||
#define TSDB_CODE_MND_INVALID_ACCT_OPTION TAOS_DEF_ERROR_CODE(0, 0x0342)
|
||||
#define TSDB_CODE_MND_ACCT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0343)
|
||||
#define TSDB_CODE_MND_ACCT_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0344)
|
||||
#define TSDB_CODE_MND_TOO_MANY_ACCTS TAOS_DEF_ERROR_CODE(0, 0x0345)
|
||||
|
||||
// mnode-user
|
||||
#define TSDB_CODE_MND_USER_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0370)
|
||||
#define TSDB_CODE_MND_USER_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0371)
|
||||
#define TSDB_CODE_MND_TOO_MANY_USERS TAOS_DEF_ERROR_CODE(0, 0x0372)
|
||||
#define TSDB_CODE_MND_INVALID_USER_FORMAT TAOS_DEF_ERROR_CODE(0, 0x0373)
|
||||
#define TSDB_CODE_MND_INVALID_PASS_FORMAT TAOS_DEF_ERROR_CODE(0, 0x0374)
|
||||
#define TSDB_CODE_MND_NO_USER_FROM_CONN TAOS_DEF_ERROR_CODE(0, 0x0375)
|
||||
#define TSDB_CODE_MND_INVALID_ALTER_OPER TAOS_DEF_ERROR_CODE(0, 0x0376)
|
||||
#define TSDB_CODE_MND_USER_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0350)
|
||||
#define TSDB_CODE_MND_USER_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0351)
|
||||
#define TSDB_CODE_MND_INVALID_USER_FORMAT TAOS_DEF_ERROR_CODE(0, 0x0352)
|
||||
#define TSDB_CODE_MND_INVALID_PASS_FORMAT TAOS_DEF_ERROR_CODE(0, 0x0353)
|
||||
#define TSDB_CODE_MND_NO_USER_FROM_CONN TAOS_DEF_ERROR_CODE(0, 0x0354)
|
||||
#define TSDB_CODE_MND_TOO_MANY_USERS TAOS_DEF_ERROR_CODE(0, 0x0355)
|
||||
#define TSDB_CODE_MND_INVALID_ALTER_OPER TAOS_DEF_ERROR_CODE(0, 0x0356)
|
||||
|
||||
// mnode-db
|
||||
#define TSDB_CODE_MND_DB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0380)
|
||||
#define TSDB_CODE_MND_DB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0381)
|
||||
#define TSDB_CODE_MND_TOO_MANY_DATABASES TAOS_DEF_ERROR_CODE(0, 0x0382)
|
||||
#define TSDB_CODE_MND_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0383)
|
||||
#define TSDB_CODE_MND_INVALID_DB TAOS_DEF_ERROR_CODE(0, 0x0384)
|
||||
#define TSDB_CODE_MND_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x0385)
|
||||
#define TSDB_CODE_MND_INVALID_DB_ACCT TAOS_DEF_ERROR_CODE(0, 0x0386)
|
||||
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x0387)
|
||||
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0388)
|
||||
|
||||
// mnode-vgroup
|
||||
#define TSDB_CODE_MND_VGROUP_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0390)
|
||||
#define TSDB_CODE_MND_VGROUP_NOT_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0391)
|
||||
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0392)
|
||||
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x0393)
|
||||
#define TSDB_CODE_MND_HAS_OFFLINE_DNODE TAOS_DEF_ERROR_CODE(0, 0x0394)
|
||||
#define TSDB_CODE_MND_INVALID_REPLICA TAOS_DEF_ERROR_CODE(0, 0x0395)
|
||||
|
||||
// mnode-stable
|
||||
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
||||
#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A1)
|
||||
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03A2)
|
||||
#define TSDB_CODE_MND_TOO_MANY_STBS TAOS_DEF_ERROR_CODE(0, 0x03A3)
|
||||
#define TSDB_CODE_MND_INVALID_STB TAOS_DEF_ERROR_CODE(0, 0x03A4)
|
||||
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A5)
|
||||
#define TSDB_CODE_MND_INVALID_STB_ALTER_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A6)
|
||||
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A7)
|
||||
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03A8)
|
||||
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A9)
|
||||
#define TSDB_CODE_MND_TAG_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
|
||||
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
|
||||
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03AC)
|
||||
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AD)
|
||||
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
|
||||
#define TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AF)
|
||||
#define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
||||
#define TSDB_CODE_MND_INVALID_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x03B1)
|
||||
#define TSDB_CODE_MND_STABLE_UID_NOT_MATCH TAOS_DEF_ERROR_CODE(0, 0x03B2)
|
||||
|
||||
// mnode-infoSchema
|
||||
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03BA)
|
||||
// mnode-stable-part1
|
||||
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0362)
|
||||
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x0364)
|
||||
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x0365)
|
||||
#define TSDB_CODE_MND_TAG_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0369)
|
||||
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036A)
|
||||
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x036B)
|
||||
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036C)
|
||||
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x036E)
|
||||
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F)
|
||||
|
||||
// mnode-func
|
||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||
#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C1)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x03C2)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x03C3)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x03C4)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x03C5)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x03C6)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_RETRIEVE TAOS_DEF_ERROR_CODE(0, 0x03C7)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0370)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0372)
|
||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0373)
|
||||
#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0374)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0375)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x0378)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_RETRIEVE TAOS_DEF_ERROR_CODE(0, 0x0379)
|
||||
|
||||
// mnode-db
|
||||
#define TSDB_CODE_MND_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0380)
|
||||
#define TSDB_CODE_MND_DB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0381)
|
||||
#define TSDB_CODE_MND_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x0382)
|
||||
#define TSDB_CODE_MND_INVALID_DB TAOS_DEF_ERROR_CODE(0, 0x0383)
|
||||
#define TSDB_CODE_MND_TOO_MANY_DATABASES TAOS_DEF_ERROR_CODE(0, 0x0385)
|
||||
#define TSDB_CODE_MND_DB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0388)
|
||||
#define TSDB_CODE_MND_INVALID_DB_ACCT TAOS_DEF_ERROR_CODE(0, 0x0389)
|
||||
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A)
|
||||
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
||||
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x039A)
|
||||
|
||||
// mnode-node
|
||||
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
||||
#define TSDB_CODE_MND_MNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A1)
|
||||
#define TSDB_CODE_MND_QNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A2)
|
||||
#define TSDB_CODE_MND_QNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A3)
|
||||
#define TSDB_CODE_MND_SNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A4)
|
||||
#define TSDB_CODE_MND_SNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A5)
|
||||
#define TSDB_CODE_MND_BNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A6)
|
||||
#define TSDB_CODE_MND_BNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A7)
|
||||
#define TSDB_CODE_MND_TOO_FEW_MNODES TAOS_DEF_ERROR_CODE(0, 0x03A8)
|
||||
#define TSDB_CODE_MND_TOO_MANY_MNODES TAOS_DEF_ERROR_CODE(0, 0x03A9)
|
||||
|
||||
// mnode-dnode-part2
|
||||
#define TSDB_CODE_MND_TOO_MANY_DNODES TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
||||
#define TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x03B1)
|
||||
#define TSDB_CODE_MND_INVALID_DNODE_CFG TAOS_DEF_ERROR_CODE(0, 0x03B2)
|
||||
#define TSDB_CODE_MND_INVALID_DNODE_EP TAOS_DEF_ERROR_CODE(0, 0x03B3)
|
||||
#define TSDB_CODE_MND_INVALID_DNODE_ID TAOS_DEF_ERROR_CODE(0, 0x03B4)
|
||||
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x03B5)
|
||||
#define TSDB_CODE_MND_HAS_OFFLINE_DNODE TAOS_DEF_ERROR_CODE(0, 0x03B6)
|
||||
#define TSDB_CODE_MND_INVALID_REPLICA TAOS_DEF_ERROR_CODE(0, 0x03B7)
|
||||
|
||||
// mnode-stable-part2
|
||||
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||
#define TSDB_CODE_MND_TOO_MANY_STBS TAOS_DEF_ERROR_CODE(0, 0x03C1)
|
||||
#define TSDB_CODE_MND_INVALID_STB_ALTER_OPTION TAOS_DEF_ERROR_CODE(0, 0x03C2)
|
||||
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03C3)
|
||||
#define TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C4)
|
||||
#define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03C5)
|
||||
#define TSDB_CODE_MND_INVALID_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x03C6)
|
||||
#define TSDB_CODE_MND_STABLE_UID_NOT_MATCH TAOS_DEF_ERROR_CODE(0, 0x03C7)
|
||||
|
||||
// mnode-trans
|
||||
#define TSDB_CODE_MND_TRANS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D0)
|
||||
#define TSDB_CODE_MND_TRANS_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D1)
|
||||
#define TSDB_CODE_MND_TRANS_INVALID_STAGE TAOS_DEF_ERROR_CODE(0, 0x03D2)
|
||||
#define TSDB_CODE_MND_TRANS_CONFLICT TAOS_DEF_ERROR_CODE(0, 0x03D3)
|
||||
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
||||
#define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D5)
|
||||
#define TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL TAOS_DEF_ERROR_CODE(0, 0x03D6)
|
||||
#define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
||||
#define TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL TAOS_DEF_ERROR_CODE(0, 0x03D5)
|
||||
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF)
|
||||
|
||||
// mnode-mq
|
||||
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
|
||||
|
@ -299,10 +293,9 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482)
|
||||
|
||||
// dnode
|
||||
#define TSDB_CODE_NODE_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0400)
|
||||
#define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0401)
|
||||
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0402)
|
||||
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403)
|
||||
#define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0408)
|
||||
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0409)
|
||||
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040A)
|
||||
|
||||
// vnode
|
||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
||||
|
@ -315,8 +308,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR TAOS_DEF_ERROR_CODE(0, 0x0507)
|
||||
#define TSDB_CODE_VND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0508)
|
||||
#define TSDB_CODE_VND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0509)
|
||||
#define TSDB_CODE_VND_INVALID_CFG_FILE TAOS_DEF_ERROR_CODE(0, 0x050A)
|
||||
#define TSDB_CODE_VND_INVALID_TERM_FILE TAOS_DEF_ERROR_CODE(0, 0x050B)
|
||||
#define TSDB_CODE_VND_IS_FLOWCTRL TAOS_DEF_ERROR_CODE(0, 0x050C)
|
||||
#define TSDB_CODE_VND_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x050D)
|
||||
#define TSDB_CODE_VND_IS_UPDATING TAOS_DEF_ERROR_CODE(0, 0x050E)
|
||||
|
@ -325,43 +316,46 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_VND_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0512)
|
||||
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513)
|
||||
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514)
|
||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515)
|
||||
#define TSDB_CODE_VND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0516)
|
||||
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0517)
|
||||
#define TSDB_CODE_VND_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0518)
|
||||
#define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0519)
|
||||
#define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051a)
|
||||
#define TSDB_CODE_VND_TABLE_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051b)
|
||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0520)
|
||||
#define TSDB_CODE_VND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0521)
|
||||
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0522)
|
||||
#define TSDB_CODE_VND_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0523)
|
||||
#define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0524)
|
||||
#define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0525)
|
||||
#define TSDB_CODE_VND_TABLE_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0526)
|
||||
#define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527)
|
||||
#define TSDB_CODE_VND_INVALID_CFG_FILE TAOS_DEF_ERROR_CODE(0, 0x0528)
|
||||
#define TSDB_CODE_VND_INVALID_TERM_FILE TAOS_DEF_ERROR_CODE(0, 0x0529)
|
||||
|
||||
// tsdb
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601)
|
||||
#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602)
|
||||
#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603)
|
||||
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0605)
|
||||
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0606)
|
||||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0607)
|
||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x060A)
|
||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x060B)
|
||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x060C)
|
||||
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060D)
|
||||
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060E)
|
||||
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060F)
|
||||
#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x0610)
|
||||
#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x0611)
|
||||
#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x0612)
|
||||
#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0613)
|
||||
#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0614)
|
||||
#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||
#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0617)
|
||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605)
|
||||
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606)
|
||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607)
|
||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A)
|
||||
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B)
|
||||
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C)
|
||||
#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x060D)
|
||||
#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x060E)
|
||||
#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x060F)
|
||||
#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0610)
|
||||
#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0611)
|
||||
#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612)
|
||||
#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613)
|
||||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
|
||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C)
|
||||
|
||||
// query
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||
|
@ -377,25 +371,25 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW TAOS_DEF_ERROR_CODE(0, 0x070A)
|
||||
#define TSDB_CODE_QRY_NOT_ENOUGH_BUFFER TAOS_DEF_ERROR_CODE(0, 0x070B)
|
||||
#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C)
|
||||
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D)
|
||||
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E)
|
||||
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070D)
|
||||
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070E)
|
||||
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F)
|
||||
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0710)
|
||||
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0711)
|
||||
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0712)
|
||||
#define TSDB_CODE_QRY_TASK_CTX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0713)
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x0714)
|
||||
#define TSDB_CODE_QRY_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0715)
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLING TAOS_DEF_ERROR_CODE(0, 0x0716)
|
||||
#define TSDB_CODE_QRY_TASK_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0717)
|
||||
#define TSDB_CODE_QRY_DUPLICATTED_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0718)
|
||||
#define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0719)
|
||||
#define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x071A)
|
||||
#define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x071B)
|
||||
#define TSDB_CODE_QRY_JSON_IN_ERROR TAOS_DEF_ERROR_CODE(0, 0x071C)
|
||||
#define TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR TAOS_DEF_ERROR_CODE(0, 0x071D)
|
||||
#define TSDB_CODE_QRY_JSON_IN_GROUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x071E)
|
||||
#define TSDB_CODE_QRY_JOB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x071F)
|
||||
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0720)
|
||||
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0721)
|
||||
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0722)
|
||||
#define TSDB_CODE_QRY_TASK_CTX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0723)
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x0724)
|
||||
#define TSDB_CODE_QRY_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0725)
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLING TAOS_DEF_ERROR_CODE(0, 0x0726)
|
||||
#define TSDB_CODE_QRY_TASK_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0727)
|
||||
#define TSDB_CODE_QRY_DUPLICATTED_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0728)
|
||||
#define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0729)
|
||||
#define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x072A)
|
||||
#define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x072B)
|
||||
#define TSDB_CODE_QRY_JSON_IN_ERROR TAOS_DEF_ERROR_CODE(0, 0x072C)
|
||||
#define TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR TAOS_DEF_ERROR_CODE(0, 0x072D)
|
||||
#define TSDB_CODE_QRY_JSON_IN_GROUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x072E)
|
||||
#define TSDB_CODE_QRY_JOB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x072F)
|
||||
|
||||
// grant
|
||||
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800)
|
||||
|
@ -412,17 +406,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
|
||||
|
||||
// sync
|
||||
#define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900)
|
||||
#define TSDB_CODE_SYN_NOT_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0901)
|
||||
#define TSDB_CODE_SYN_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0902)
|
||||
#define TSDB_CODE_SYN_CONFIRM_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0903)
|
||||
#define TSDB_CODE_SYN_TOO_MANY_FWDINFO TAOS_DEF_ERROR_CODE(0, 0x0904)
|
||||
#define TSDB_CODE_SYN_MISMATCHED_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0905)
|
||||
#define TSDB_CODE_SYN_MISMATCHED_CLUSTERID TAOS_DEF_ERROR_CODE(0, 0x0906)
|
||||
#define TSDB_CODE_SYN_MISMATCHED_SIGNATURE TAOS_DEF_ERROR_CODE(0, 0x0907)
|
||||
#define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908)
|
||||
#define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909)
|
||||
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
|
||||
#define TSDB_CODE_SYN_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0903)
|
||||
#define TSDB_CODE_SYN_IS_LEADER TAOS_DEF_ERROR_CODE(0, 0x090B)
|
||||
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x090C)
|
||||
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x090D)
|
||||
|
@ -432,7 +416,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_SYN_PROPOSE_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0911)
|
||||
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
|
||||
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
|
||||
#define TSDB_CODE_SYN_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0914)
|
||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||
|
||||
// tq
|
||||
|
@ -460,7 +443,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
|
||||
|
||||
// tfs
|
||||
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x2200)
|
||||
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
|
||||
#define TSDB_CODE_FS_TOO_MANY_MOUNT TAOS_DEF_ERROR_CODE(0, 0x2202)
|
||||
#define TSDB_CODE_FS_DUP_PRIMARY TAOS_DEF_ERROR_CODE(0, 0x2203)
|
||||
|
@ -469,9 +451,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_FS_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2206)
|
||||
#define TSDB_CODE_FS_INVLD_LEVEL TAOS_DEF_ERROR_CODE(0, 0x2207)
|
||||
#define TSDB_CODE_FS_NO_VALID_DISK TAOS_DEF_ERROR_CODE(0, 0x2208)
|
||||
|
||||
// monitor
|
||||
#define TSDB_CODE_MON_CONNECTION_INVALID TAOS_DEF_ERROR_CODE(0, 0x2300)
|
||||
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x220F)
|
||||
|
||||
// catalog
|
||||
#define TSDB_CODE_CTG_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2400)
|
||||
|
@ -484,12 +464,12 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_CTG_EXIT TAOS_DEF_ERROR_CODE(0, 0x2407)
|
||||
|
||||
//scheduler&qworker
|
||||
#define TSDB_CODE_QW_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x2550)
|
||||
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501)
|
||||
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502)
|
||||
#define TSDB_CODE_SCH_IGNORE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2503)
|
||||
#define TSDB_CODE_SCH_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x2504)
|
||||
#define TSDB_CODE_SCH_JOB_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x2505)
|
||||
#define TSDB_CODE_QW_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x2550)
|
||||
|
||||
//parser
|
||||
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)
|
||||
|
@ -562,9 +542,9 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_DROP_COL TAOS_DEF_ERROR_CODE(0, 0x2651)
|
||||
#define TSDB_CODE_PAR_INVALID_COL_JSON TAOS_DEF_ERROR_CODE(0, 0x2652)
|
||||
#define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2654)
|
||||
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
|
||||
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
|
||||
|
||||
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
|
||||
#define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658)
|
||||
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
|
||||
|
@ -575,6 +555,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
|
||||
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660)
|
||||
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||
|
||||
//planner
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
@ -600,6 +581,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_UDF_INVALID_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x2909)
|
||||
#define TSDB_CODE_UDF_INVALID_OUTPUT_TYPE TAOS_DEF_ERROR_CODE(0, 0x290A)
|
||||
|
||||
// sml
|
||||
#define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000)
|
||||
#define TSDB_CODE_SML_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x3001)
|
||||
#define TSDB_CODE_SML_INVALID_DATA TAOS_DEF_ERROR_CODE(0, 0x3002)
|
||||
|
@ -616,7 +598,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSMA_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x3106)
|
||||
#define TSDB_CODE_TSMA_NO_INDEX_IN_CACHE TAOS_DEF_ERROR_CODE(0, 0x3107)
|
||||
|
||||
|
||||
//rsma
|
||||
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
|
||||
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
|
||||
|
@ -627,7 +608,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
|
||||
#define TSDB_CODE_INDEX_INVALID_FILE TAOS_DEF_ERROR_CODE(0, 0x3201)
|
||||
|
||||
|
||||
//tmq
|
||||
#define TSDB_CODE_TMQ_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x4000)
|
||||
|
||||
|
|
|
@ -421,7 +421,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
|
||||
#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
|
||||
|
||||
#define TSDB_MAX_WAL_SIZE (1024 * 1024 * 3)
|
||||
#define TSDB_MAX_MSG_SIZE (1024 * 1024 * 10)
|
||||
|
||||
#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ void taosIp2String(uint32_t ip, char *str);
|
|||
void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
||||
|
||||
void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen);
|
||||
char *strDupUnquo(const char *src);
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||
T_MD5_CTX context;
|
||||
|
|
|
@ -72,7 +72,6 @@ typedef struct SStmtBindInfo {
|
|||
typedef struct SStmtExecInfo {
|
||||
int32_t affectedRows;
|
||||
SRequestObj* pRequest;
|
||||
SHashObj* pVgHash;
|
||||
SHashObj* pBlockHash;
|
||||
bool autoCreateTbl;
|
||||
} SStmtExecInfo;
|
||||
|
@ -88,6 +87,7 @@ typedef struct SStmtSQLInfo {
|
|||
SArray* nodeList;
|
||||
SStmtQueryResInfo queryRes;
|
||||
bool autoCreateTbl;
|
||||
SHashObj* pVgHash;
|
||||
} SStmtSQLInfo;
|
||||
|
||||
typedef struct STscStmt {
|
||||
|
|
|
@ -88,7 +88,7 @@ void closeTransporter(SAppInstInfo *pAppInfo) {
|
|||
static bool clientRpcRfp(int32_t code, tmsg_t msgType) {
|
||||
if (NEED_REDIRECT_ERROR(code)) {
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
||||
msgType == TDMT_SCH_MERGE_FETCH) {
|
||||
msgType == TDMT_SCH_MERGE_FETCH || msgType == TDMT_SCH_QUERY_HEARTBEAT || msgType == TDMT_SCH_DROP_TASK) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -244,6 +244,7 @@ void *createRequest(uint64_t connId, int32_t type) {
|
|||
|
||||
STscObj *pTscObj = acquireTscObj(connId);
|
||||
if (pTscObj == NULL) {
|
||||
taosMemoryFree(pRequest);
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -590,6 +590,11 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray
|
|||
return code;
|
||||
}
|
||||
|
||||
void freeVgList(void *list) {
|
||||
SArray* pList = *(SArray**)list;
|
||||
taosArrayDestroy(pList);
|
||||
}
|
||||
|
||||
int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* pMnodeList) {
|
||||
SArray* pDbVgList = NULL;
|
||||
SArray* pQnodeList = NULL;
|
||||
|
@ -641,7 +646,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray*
|
|||
|
||||
_return:
|
||||
|
||||
taosArrayDestroy(pDbVgList);
|
||||
taosArrayDestroyEx(pDbVgList, freeVgList);
|
||||
taosArrayDestroy(pQnodeList);
|
||||
|
||||
return code;
|
||||
|
@ -829,7 +834,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
|
|||
tstrerror(code), pRequest->requestId);
|
||||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code) && pRequest->sqlstr != NULL) {
|
||||
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;
|
||||
|
@ -1745,7 +1750,10 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
|||
char* pStart = p;
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
colLength[i] = htonl(colLength[i]);
|
||||
ASSERT(colLength[i] < dataLen);
|
||||
if (colLength[i] >= dataLen) {
|
||||
tscError("invalid colLength %d, dataLen %d", colLength[i], dataLen);
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||
pResultInfo->pCol[i].offset = (int32_t*)pStart;
|
||||
|
|
|
@ -499,7 +499,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
|
||||
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||
|
||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_INVALID_STB) {
|
||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_STB_NOT_EXIST) {
|
||||
SSchemaAction schemaAction;
|
||||
schemaAction.action = SCHEMA_ACTION_CREATE_STABLE;
|
||||
memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo));
|
||||
|
@ -1489,7 +1489,7 @@ static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLPr
|
|||
}
|
||||
info->id = smlGenId();
|
||||
|
||||
info->pQuery = (SQuery *)taosMemoryCalloc(1, sizeof(SQuery));
|
||||
info->pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == info->pQuery) {
|
||||
uError("SML:0x%" PRIx64 " create info->pQuery error", info->id);
|
||||
goto cleanup;
|
||||
|
|
|
@ -6,11 +6,16 @@
|
|||
#include "clientStmt.h"
|
||||
|
||||
static int32_t stmtCreateRequest(STscStmt* pStmt) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (pStmt->exec.pRequest == NULL) {
|
||||
return buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false, &pStmt->exec.pRequest);
|
||||
} else {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
code = buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false, &pStmt->exec.pRequest);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pStmt->exec.pRequest->syncQuery = true;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
||||
|
@ -155,7 +160,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
|||
int32_t stmtUpdateExecInfo(TAOS_STMT* stmt, SHashObj* pVgHash, SHashObj* pBlockHash, bool autoCreateTbl) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
pStmt->exec.pVgHash = pVgHash;
|
||||
pStmt->sql.pVgHash = pVgHash;
|
||||
pStmt->exec.pBlockHash = pBlockHash;
|
||||
pStmt->exec.autoCreateTbl = autoCreateTbl;
|
||||
|
||||
|
@ -177,7 +182,7 @@ int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char
|
|||
int32_t stmtGetExecInfo(TAOS_STMT* stmt, SHashObj** pVgHash, SHashObj** pBlockHash) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
*pVgHash = pStmt->exec.pVgHash;
|
||||
*pVgHash = pStmt->sql.pVgHash;
|
||||
*pBlockHash = pStmt->exec.pBlockHash;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -308,6 +313,8 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
|||
taosMemoryFree(pStmt->sql.sqlStr);
|
||||
qDestroyQuery(pStmt->sql.pQuery);
|
||||
taosArrayDestroy(pStmt->sql.nodeList);
|
||||
taosHashCleanup(pStmt->sql.pVgHash);
|
||||
pStmt->sql.pVgHash = NULL;
|
||||
|
||||
void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL);
|
||||
while (pIter) {
|
||||
|
@ -340,7 +347,7 @@ int32_t stmtRebuildDataBlock(STscStmt* pStmt, STableDataBlocks* pDataBlock, STab
|
|||
|
||||
STMT_ERR_RET(catalogGetTableHashVgroup(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &vgInfo));
|
||||
STMT_ERR_RET(
|
||||
taosHashPut(pStmt->exec.pVgHash, (const char*)&vgInfo.vgId, sizeof(vgInfo.vgId), (char*)&vgInfo, sizeof(vgInfo)));
|
||||
taosHashPut(pStmt->sql.pVgHash, (const char*)&vgInfo.vgId, sizeof(vgInfo.vgId), (char*)&vgInfo, sizeof(vgInfo)));
|
||||
|
||||
STMT_ERR_RET(qRebuildStmtDataBlock(newBlock, pDataBlock, uid, vgInfo.vgId));
|
||||
|
||||
|
@ -680,6 +687,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
if (pStmt->sql.pQuery->haveResultSet) {
|
||||
setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema,
|
||||
pStmt->sql.pQuery->numOfResCols);
|
||||
taosMemoryFreeClear(pStmt->sql.pQuery->pResSchema);
|
||||
setResPrecision(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->precision);
|
||||
}
|
||||
|
||||
|
@ -804,7 +812,7 @@ int stmtExec(TAOS_STMT* stmt) {
|
|||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
|
||||
} else {
|
||||
STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->exec.pVgHash, pStmt->exec.pBlockHash));
|
||||
STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->exec.pBlockHash));
|
||||
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, (autoCreateTbl ? (void**)&pRsp : NULL));
|
||||
}
|
||||
|
||||
|
@ -847,9 +855,10 @@ _return:
|
|||
int stmtClose(TAOS_STMT* stmt) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_RET(stmtCleanSQLInfo(pStmt));
|
||||
|
||||
stmtCleanSQLInfo(pStmt);
|
||||
taosMemoryFree(stmt);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
const char* stmtErrstr(TAOS_STMT* stmt) {
|
||||
|
|
|
@ -2128,7 +2128,7 @@ _err:
|
|||
return string;
|
||||
}
|
||||
|
||||
static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* tagName, int64_t id) {
|
||||
static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* tagName, int64_t id, uint8_t tagNum) {
|
||||
char* string = NULL;
|
||||
SArray* pTagVals = NULL;
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
|
@ -2148,6 +2148,8 @@ static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray*
|
|||
cJSON_AddItemToObject(json, "tableType", tableType);
|
||||
cJSON* using = cJSON_CreateString(sname);
|
||||
cJSON_AddItemToObject(json, "using", using);
|
||||
cJSON* tagNumJson = cJSON_CreateNumber(tagNum);
|
||||
cJSON_AddItemToObject(json, "tagNum", tagNumJson);
|
||||
// cJSON* version = cJSON_CreateNumber(1);
|
||||
// cJSON_AddItemToObject(json, "version", version);
|
||||
|
||||
|
@ -2236,7 +2238,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) {
|
|||
pCreateReq = req.pReqs + iReq;
|
||||
if (pCreateReq->type == TSDB_CHILD_TABLE) {
|
||||
string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name,
|
||||
pCreateReq->ctb.tagName, pCreateReq->uid);
|
||||
pCreateReq->ctb.tagName, pCreateReq->uid, pCreateReq->ctb.tagNum);
|
||||
} else if (pCreateReq->type == TSDB_NORMAL_TABLE) {
|
||||
string =
|
||||
buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE);
|
||||
|
@ -2952,9 +2954,243 @@ int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data raw_meta){
|
|||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
void tmq_free_raw_meta(tmq_raw_data* rawMeta) {
|
||||
//
|
||||
taosMemoryFreeClear(rawMeta);
|
||||
typedef struct{
|
||||
SVgroupInfo vg;
|
||||
void *data;
|
||||
}VgData;
|
||||
|
||||
static void destroyVgHash(void* data) {
|
||||
VgData* vgData = (VgData*)data;
|
||||
taosMemoryFreeClear(vgData->data);
|
||||
}
|
||||
|
||||
int32_t taos_write_raw_data(TAOS *taos, TAOS_RES *msg){
|
||||
if (!TD_RES_TMQ(msg)) {
|
||||
uError("WriteRaw:msg is not tmq : %d", *(int8_t*)msg);
|
||||
return TSDB_CODE_TMQ_INVALID_MSG;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SHashObj *pVgHash = NULL;
|
||||
SQuery *pQuery = NULL;
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT);
|
||||
if(!pRequest){
|
||||
uError("WriteRaw:createRequest error request is null");
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (!pRequest->pDb) {
|
||||
uError("WriteRaw:not use db");
|
||||
code = TSDB_CODE_PAR_DB_NOT_SPECIFIED;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
taosHashSetFreeFp(pVgHash, destroyVgHash);
|
||||
struct SCatalog *pCatalog = NULL;
|
||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
uError("WriteRaw: get gatlog error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
SRequestConnInfo conn = {0};
|
||||
conn.pTrans = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||
conn.requestId = pRequest->requestId;
|
||||
conn.requestObjRefId = pRequest->self;
|
||||
conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||
SMqRspObj *rspObj = ((SMqRspObj*)msg);
|
||||
printf("raw data block num:%d\n", rspObj->rsp.blockNum);
|
||||
while (++rspObj->resIter < rspObj->rsp.blockNum) {
|
||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj->rsp.blockData, rspObj->resIter);
|
||||
if (!rspObj->rsp.withSchema) {
|
||||
uError("WriteRaw:no schema, iter:%d", rspObj->resIter);
|
||||
goto end;
|
||||
}
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj->rsp.blockSchema, rspObj->resIter);
|
||||
setResSchemaInfo(&rspObj->resInfo, pSW->pSchema, pSW->nCols);
|
||||
|
||||
code = setQueryResultFromRsp(&rspObj->resInfo, pRetrieve, false, false);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
uError("WriteRaw: setQueryResultFromRsp error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
uint16_t fLen = 0;
|
||||
int32_t rowSize = 0;
|
||||
int16_t nVar = 0;
|
||||
for (int i = 0; i < pSW->nCols; i++) {
|
||||
SSchema *schema = pSW->pSchema + i;
|
||||
fLen += TYPE_BYTES[schema->type];
|
||||
rowSize += schema->bytes;
|
||||
if(IS_VAR_DATA_TYPE(schema->type)){
|
||||
nVar ++;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t rows = rspObj->resInfo.numOfRows;
|
||||
int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) +
|
||||
(int32_t)TD_BITMAP_BYTES(pSW->nCols - 1);
|
||||
int32_t schemaLen = 0;
|
||||
int32_t submitLen = sizeof(SSubmitBlk) + schemaLen + rows * extendedRowSize;
|
||||
|
||||
const char* tbName = tmq_get_table_name(msg);
|
||||
if(!tbName){
|
||||
uError("WriteRaw: tbname is null");
|
||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("raw data tbname:%s\n", tbName);
|
||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||
strcpy(pName.dbname, pRequest->pDb);
|
||||
strcpy(pName.tname, tbName);
|
||||
|
||||
VgData vgData = {0};
|
||||
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &(vgData.vg));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbName);
|
||||
goto end;
|
||||
}
|
||||
|
||||
SSubmitReq* subReq = NULL;
|
||||
SSubmitBlk* blk = NULL;
|
||||
void *hData = taosHashGet(pVgHash, &vgData.vg.vgId, sizeof(vgData.vg.vgId));
|
||||
if(hData){
|
||||
vgData = *(VgData*)hData;
|
||||
|
||||
int32_t totalLen = ((SSubmitReq*)(vgData.data))->length + submitLen;
|
||||
void *tmp = taosMemoryRealloc(vgData.data, totalLen);
|
||||
if (tmp == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
vgData.data = tmp;
|
||||
((VgData*)hData)->data = tmp;
|
||||
subReq = (SSubmitReq*)(vgData.data);
|
||||
blk = POINTER_SHIFT(vgData.data, subReq->length);
|
||||
}else{
|
||||
int32_t totalLen = sizeof(SSubmitReq) + submitLen;
|
||||
void *tmp = taosMemoryCalloc(1, totalLen);
|
||||
if (tmp == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
vgData.data = tmp;
|
||||
taosHashPut(pVgHash, (const char *)&vgData.vg.vgId, sizeof(vgData.vg.vgId), (char *)&vgData, sizeof(vgData));
|
||||
subReq = (SSubmitReq*)(vgData.data);
|
||||
subReq->length = sizeof(SSubmitReq);
|
||||
subReq->numOfBlocks = 0;
|
||||
|
||||
blk = POINTER_SHIFT(vgData.data, sizeof(SSubmitReq));
|
||||
}
|
||||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbName);
|
||||
goto end;
|
||||
}
|
||||
uint64_t suid = (TSDB_NORMAL_TABLE == pTableMeta->tableType ? 0 : pTableMeta->suid);
|
||||
uint64_t uid = pTableMeta->uid;
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
|
||||
void* blkSchema = POINTER_SHIFT(blk, sizeof(SSubmitBlk));
|
||||
STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen);
|
||||
|
||||
SRowBuilder rb = {0};
|
||||
tdSRowInit(&rb, pSW->version);
|
||||
tdSRowSetTpInfo(&rb, pSW->nCols, fLen);
|
||||
int32_t dataLen = 0;
|
||||
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
tdSRowResetBuf(&rb, rowData);
|
||||
|
||||
doSetOneRowPtr(&rspObj->resInfo);
|
||||
rspObj->resInfo.current += 1;
|
||||
|
||||
int32_t offset = 0;
|
||||
for (int32_t k = 0; k < pSW->nCols; k++) {
|
||||
const SSchema* pColumn = &pSW->pSchema[k];
|
||||
char *data = rspObj->resInfo.row[k];
|
||||
if (!data) {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
|
||||
} else {
|
||||
if(IS_VAR_DATA_TYPE(pColumn->type)){
|
||||
data -= VARSTR_HEADER_SIZE;
|
||||
}
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, offset, k);
|
||||
}
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
}
|
||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||
rowData = POINTER_SHIFT(rowData, rowLen);
|
||||
dataLen += rowLen;
|
||||
}
|
||||
|
||||
blk->uid = htobe64(uid);
|
||||
blk->suid = htobe64(suid);
|
||||
blk->padding = htonl(blk->padding);
|
||||
blk->sversion = htonl(pSW->version);
|
||||
blk->schemaLen = htonl(schemaLen);
|
||||
blk->numOfRows = htons(rows);
|
||||
blk->dataLen = htonl(dataLen);
|
||||
subReq->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
subReq->numOfBlocks++;
|
||||
}
|
||||
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == pQuery) {
|
||||
uError("create SQuery error");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->haveResultSet = false;
|
||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||
pQuery->pRoot = (SNode *)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT);
|
||||
if (NULL == pQuery->pRoot) {
|
||||
uError("create pQuery->pRoot error");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
SVnodeModifOpStmt *nodeStmt = (SVnodeModifOpStmt *)(pQuery->pRoot);
|
||||
nodeStmt->payloadType = PAYLOAD_TYPE_KV;
|
||||
|
||||
int32_t numOfVg = taosHashGetSize(pVgHash);
|
||||
nodeStmt->pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES);
|
||||
|
||||
VgData *vData = (VgData *)taosHashIterate(pVgHash, NULL);
|
||||
while (vData) {
|
||||
SVgDataBlocks *dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||
if (NULL == dst) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
dst->vg = vData->vg;
|
||||
SSubmitReq* subReq = (SSubmitReq*)(vData->data);
|
||||
dst->numOfTables = subReq->numOfBlocks;
|
||||
dst->size = subReq->length;
|
||||
dst->pData = (char*)subReq;
|
||||
vData->data = NULL; // no need free
|
||||
subReq->header.vgId = htonl(dst->vg.vgId);
|
||||
subReq->version = htonl(1);
|
||||
subReq->header.contLen = htonl(subReq->length);
|
||||
subReq->length = htonl(subReq->length);
|
||||
subReq->numOfBlocks = htonl(subReq->numOfBlocks);
|
||||
taosArrayPush(nodeStmt->pDataBlocks, &dst);
|
||||
vData = (VgData *)taosHashIterate(pVgHash, vData);
|
||||
}
|
||||
|
||||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
end:
|
||||
qDestroyQuery(pQuery);
|
||||
destroyRequest(pRequest);
|
||||
taosHashCleanup(pVgHash);
|
||||
return code;
|
||||
}
|
||||
|
||||
void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) {
|
||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
|||
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
||||
TARGET_LINK_LIBRARIES(
|
||||
clientTest
|
||||
PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom
|
||||
PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom executor
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
|
||||
#include "taos.h"
|
||||
#include "executor.h"
|
||||
|
||||
namespace {
|
||||
void showDB(TAOS* pConn) {
|
||||
|
@ -823,10 +824,21 @@ TEST(testCase, async_api_test) {
|
|||
|
||||
|
||||
TEST(testCase, update_test) {
|
||||
|
||||
SInterval interval = {0};
|
||||
interval.offset = 8000;
|
||||
interval.interval = 10000;
|
||||
interval.sliding = 4000;
|
||||
interval.intervalUnit = 's';
|
||||
interval.offsetUnit = 's';
|
||||
interval.slidingUnit = 's';
|
||||
// STimeWindow w = getAlignQueryTimeWindow(&interval, 0, 1630000000000);
|
||||
STimeWindow w = getAlignQueryTimeWindow(&interval, 0, 1629999999999);
|
||||
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1");
|
||||
TAOS_RES* pRes = taos_query(pConn, "select cast(0 as timestamp)-1y");
|
||||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||
printf("failed to create database, code:%s", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
|
|
|
@ -214,8 +214,8 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
|
|||
}
|
||||
}
|
||||
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, uint32_t* capacity,
|
||||
const SColumnInfoData* pSource, uint32_t numOfRow2) {
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
||||
const SColumnInfoData* pSource, int32_t numOfRow2) {
|
||||
ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type);
|
||||
if (numOfRow2 == 0) {
|
||||
return numOfRow1;
|
||||
|
@ -263,7 +263,8 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
|
|||
pColumnInfoData->varmeta.length = len + oldLen;
|
||||
} else {
|
||||
if (finalNumOfRows > *capacity || (numOfRow1 == 0 && pColumnInfoData->info.bytes != 0)) {
|
||||
ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
|
||||
// all data may be null, when the pColumnInfoData->info.type == 0, bytes == 0;
|
||||
// ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
|
||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||
|
@ -1107,6 +1108,11 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
|||
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock) {
|
||||
pDataBlock->info.rows = 0;
|
||||
pDataBlock->info.groupId = 0;
|
||||
|
||||
pDataBlock->info.window.ekey = 0;
|
||||
pDataBlock->info.window.skey = 0;
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
|
@ -1163,9 +1169,15 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
|||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) {
|
||||
if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
|
||||
pColumn->varmeta.length = 0;
|
||||
if (pColumn->varmeta.offset > 0) {
|
||||
memset(pColumn->varmeta.offset, 0, sizeof(int32_t) * numOfRows);
|
||||
}
|
||||
} else {
|
||||
if (pColumn->nullbitmap != NULL) {
|
||||
memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows));
|
||||
if (pColumn->pData != NULL) {
|
||||
memset(pColumn->pData, 0, pColumn->info.bytes * numOfRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,26 +40,26 @@ bool tsPrintAuth = false;
|
|||
|
||||
// multi process
|
||||
int32_t tsMultiProcess = 0;
|
||||
int32_t tsMnodeShmSize = TSDB_MAX_WAL_SIZE * 2 + 1024;
|
||||
int32_t tsVnodeShmSize = TSDB_MAX_WAL_SIZE * 10 + 1024;
|
||||
int32_t tsQnodeShmSize = TSDB_MAX_WAL_SIZE * 4 + 1024;
|
||||
int32_t tsSnodeShmSize = TSDB_MAX_WAL_SIZE * 4 + 1024;
|
||||
int32_t tsBnodeShmSize = TSDB_MAX_WAL_SIZE * 4 + 1024;
|
||||
int32_t tsMnodeShmSize = TSDB_MAX_MSG_SIZE * 2 + 1024;
|
||||
int32_t tsVnodeShmSize = TSDB_MAX_MSG_SIZE * 10 + 1024;
|
||||
int32_t tsQnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsSnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsBnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsNumOfShmThreads = 1;
|
||||
|
||||
// queue & threads
|
||||
int32_t tsNumOfRpcThreads = 1;
|
||||
int32_t tsNumOfCommitThreads = 2;
|
||||
int32_t tsNumOfTaskQueueThreads = 1;
|
||||
int32_t tsNumOfMnodeQueryThreads = 2;
|
||||
int32_t tsNumOfMnodeQueryThreads = 4;
|
||||
int32_t tsNumOfMnodeFetchThreads = 1;
|
||||
int32_t tsNumOfMnodeReadThreads = 1;
|
||||
int32_t tsNumOfVnodeQueryThreads = 2;
|
||||
int32_t tsNumOfVnodeQueryThreads = 4;
|
||||
int32_t tsNumOfVnodeStreamThreads = 2;
|
||||
int32_t tsNumOfVnodeFetchThreads = 4;
|
||||
int32_t tsNumOfVnodeWriteThreads = 2;
|
||||
int32_t tsNumOfVnodeSyncThreads = 2;
|
||||
int32_t tsNumOfQnodeQueryThreads = 2;
|
||||
int32_t tsNumOfQnodeQueryThreads = 4;
|
||||
int32_t tsNumOfQnodeFetchThreads = 4;
|
||||
int32_t tsNumOfSnodeSharedThreads = 2;
|
||||
int32_t tsNumOfSnodeUniqueThreads = 2;
|
||||
|
@ -183,7 +183,7 @@ bool tsStartUdfd = true;
|
|||
int32_t tsTransPullupInterval = 2;
|
||||
int32_t tsMqRebalanceInterval = 2;
|
||||
int32_t tsTtlUnit = 86400;
|
||||
int32_t tsTtlPushInterval = 60;
|
||||
int32_t tsTtlPushInterval = 86400;
|
||||
int32_t tsGrantHBInterval = 60;
|
||||
|
||||
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) {
|
||||
|
@ -226,9 +226,18 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
|
|||
}
|
||||
|
||||
if (tsDataDir[0] == 0) {
|
||||
if (pItem->str != NULL) {
|
||||
taosAddDataDir(0, pItem->str, 0, 1);
|
||||
tstrncpy(tsDataDir, pItem->str, PATH_MAX);
|
||||
if (taosMulMkDir(tsDataDir) != 0) {
|
||||
uError("failed to create dataDir:%s since %s", tsDataDir, terrstr());
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
uError("datadir not set");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -387,11 +396,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "vnodeShmSize", tsVnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_WAL_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "vnodeShmSize", tsVnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mumOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfRpcThreads = tsNumOfCores / 2;
|
||||
|
@ -402,16 +411,16 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfMnodeQueryThreads = tsNumOfCores / 8;
|
||||
tsNumOfMnodeQueryThreads = TRANGE(tsNumOfMnodeQueryThreads, 1, 4);
|
||||
tsNumOfMnodeQueryThreads = tsNumOfCores * 2;
|
||||
tsNumOfMnodeQueryThreads = TRANGE(tsNumOfMnodeQueryThreads, 4, 8);
|
||||
if (cfgAddInt32(pCfg, "numOfMnodeQueryThreads", tsNumOfMnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfMnodeReadThreads = tsNumOfCores / 8;
|
||||
tsNumOfMnodeReadThreads = TRANGE(tsNumOfMnodeReadThreads, 1, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeQueryThreads = tsNumOfCores / 4;
|
||||
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 2);
|
||||
tsNumOfVnodeQueryThreads = tsNumOfCores * 2;
|
||||
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfVnodeStreamThreads = tsNumOfCores / 4;
|
||||
|
@ -430,8 +439,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeSyncThreads = TMAX(tsNumOfVnodeSyncThreads, 1);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeSyncThreads", tsNumOfVnodeSyncThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfQnodeQueryThreads = tsNumOfCores / 2;
|
||||
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 1);
|
||||
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
|
||||
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
||||
|
@ -447,8 +456,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_WAL_SIZE * 10L, TSDB_MAX_WAL_SIZE * 10000L);
|
||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_WAL_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, TSDB_MAX_MSG_SIZE * 10000L);
|
||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
||||
|
@ -466,7 +475,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mqRebalanceInterval", tsMqRebalanceInterval, 1, 10000, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushInterval, 1, 10000, 1) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushInterval, 1, 100000, 1) != 0) return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1;
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tgrant.h"
|
||||
|
||||
#ifndef _GRANT
|
||||
|
||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
|
||||
#endif
|
|
@ -4941,14 +4941,14 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
STSchema *tdGetSTSChemaFromSSChema(SSchema **pSchema, int32_t nCols) {
|
||||
STSchema *tdGetSTSChemaFromSSChema(SSchema *pSchema, int32_t nCols, int32_t sver) {
|
||||
STSchemaBuilder schemaBuilder = {0};
|
||||
if (tdInitTSchemaBuilder(&schemaBuilder, 1) < 0) {
|
||||
if (tdInitTSchemaBuilder(&schemaBuilder, sver) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nCols; i++) {
|
||||
SSchema *schema = *pSchema + i;
|
||||
SSchema *schema = pSchema + i;
|
||||
if (tdAddColToSchema(&schemaBuilder, schema->type, schema->flags, schema->colId, schema->bytes) < 0) {
|
||||
tdDestroyTSchemaBuilder(&schemaBuilder);
|
||||
return NULL;
|
||||
|
@ -4981,6 +4981,7 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
|
|||
|
||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||
if (tEncodeCStr(pCoder, pReq->ctb.name) < 0) return -1;
|
||||
if (tEncodeU8(pCoder, pReq->ctb.tagNum) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1;
|
||||
if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1;
|
||||
int32_t len = taosArrayGetSize(pReq->ctb.tagName);
|
||||
|
@ -5017,6 +5018,7 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
|
|||
|
||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||
if (tDecodeCStr(pCoder, &pReq->ctb.name) < 0) return -1;
|
||||
if (tDecodeU8(pCoder, &pReq->ctb.tagNum) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1;
|
||||
if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1;
|
||||
int32_t len = 0;
|
||||
|
@ -5349,6 +5351,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
|
|||
|
||||
if (tEncodeCStr(pEncoder, pReq->tbName) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->action) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pReq->colId) < 0) return -1;
|
||||
switch (pReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
||||
|
@ -5399,6 +5402,7 @@ int32_t tDecodeSVAlterTbReq(SDecoder *pDecoder, SVAlterTbReq *pReq) {
|
|||
|
||||
if (tDecodeCStr(pDecoder, &pReq->tbName) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->action) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pReq->colId) < 0) return -1;
|
||||
switch (pReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
||||
|
@ -5621,6 +5625,33 @@ int32_t tDecodeSTqOffset(SDecoder *pDecoder, STqOffset *pOffset) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSCheckAlterInfo(SEncoder *pEncoder, const SCheckAlterInfo *pInfo) {
|
||||
if (tEncodeCStr(pEncoder, pInfo->topic) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pInfo->ntbUid) < 0) return -1;
|
||||
int32_t sz = taosArrayGetSize(pInfo->colIdList);
|
||||
if (tEncodeI32(pEncoder, sz) < 0) return -1;
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int16_t colId = *(int16_t *)taosArrayGet(pInfo->colIdList, i);
|
||||
if (tEncodeI16(pEncoder, colId) < 0) return -1;
|
||||
}
|
||||
return pEncoder->pos;
|
||||
}
|
||||
|
||||
int32_t tDecodeSCheckAlterInfo(SDecoder *pDecoder, SCheckAlterInfo *pInfo) {
|
||||
if (tDecodeCStrTo(pDecoder, pInfo->topic) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pInfo->ntbUid) < 0) return -1;
|
||||
int32_t sz;
|
||||
if (tDecodeI32(pDecoder, &sz) < 0) return -1;
|
||||
pInfo->colIdList = taosArrayInit(sz, sizeof(int16_t));
|
||||
if (pInfo->colIdList == NULL) return -1;
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int16_t colId;
|
||||
if (tDecodeI16(pDecoder, &colId) < 0) return -1;
|
||||
taosArrayPush(pInfo->colIdList, &colId);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) {
|
||||
int32_t nUid = taosArrayGetSize(pRes->uidList);
|
||||
|
||||
|
|
|
@ -190,6 +190,11 @@ int32_t tNameGetDbName(const SName* name, char* dst) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char* tNameGetDbNameP(const SName* name) {
|
||||
return &name->dbname[0];
|
||||
}
|
||||
|
||||
|
||||
int32_t tNameGetFullDbName(const SName* name, char* dst) {
|
||||
assert(name != NULL && dst != NULL);
|
||||
snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
|
|
|
@ -568,6 +568,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
|
|||
int32_t maxVarDataLen = 0;
|
||||
int32_t iColVal = 0;
|
||||
void *varBuf = NULL;
|
||||
bool isAlloc = false;
|
||||
|
||||
ASSERT(nColVal > 1);
|
||||
|
||||
|
@ -585,7 +586,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
|
|||
ASSERT(pTColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||
} else {
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
if (pColVal) {
|
||||
if (pColVal && !pColVal->isNone && !pColVal->isNull) {
|
||||
varDataLen += (pColVal->value.nData + sizeof(VarDataLenT));
|
||||
if (maxVarDataLen < (pColVal->value.nData + sizeof(VarDataLenT))) {
|
||||
maxVarDataLen = pColVal->value.nData + sizeof(VarDataLenT);
|
||||
|
@ -610,8 +611,11 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
|
|||
++iColVal;
|
||||
}
|
||||
|
||||
if (!(*ppRow)) {
|
||||
*ppRow = (STSRow *)taosMemoryCalloc(
|
||||
1, sizeof(STSRow) + pTSchema->flen + varDataLen + TD_BITMAP_BYTES(pTSchema->numOfCols - 1));
|
||||
isAlloc = true;
|
||||
}
|
||||
|
||||
if (!(*ppRow)) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -621,7 +625,9 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
|
|||
if (maxVarDataLen > 0) {
|
||||
varBuf = taosMemoryMalloc(maxVarDataLen);
|
||||
if (!varBuf) {
|
||||
if(isAlloc) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1323,12 +1329,11 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
SCellVal cv;
|
||||
SValue value;
|
||||
|
||||
ASSERT(iCol > 0);
|
||||
ASSERT((pTColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) || (iCol > 0));
|
||||
|
||||
if (TD_IS_TP_ROW(pRow)) {
|
||||
tdSTpRowGetVal(pRow, pTColumn->colId, pTColumn->type, pTSchema->flen, pTColumn->offset, iCol - 1, &cv);
|
||||
} else if (TD_IS_KV_ROW(pRow)) {
|
||||
ASSERT(iCol > 0);
|
||||
tdSKvRowGetVal(pRow, pTColumn->colId, iCol - 1, &cv);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
|
|
|
@ -700,6 +700,8 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
numOfMonth *= 12;
|
||||
}
|
||||
|
||||
int64_t fraction = t % TSDB_TICK_PER_SECOND(precision);
|
||||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
taosLocalTime(&tt, &tm);
|
||||
|
@ -707,35 +709,9 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision) + fraction);
|
||||
}
|
||||
|
||||
int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||
if (duration == 0) {
|
||||
return t;
|
||||
}
|
||||
|
||||
if (unit != 'n' && unit != 'y') {
|
||||
return t - duration;
|
||||
}
|
||||
|
||||
// The following code handles the y/n time duration
|
||||
int64_t numOfMonth = duration;
|
||||
if (unit == 'y') {
|
||||
numOfMonth *= 12;
|
||||
}
|
||||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
taosLocalTime(&tt, &tm);
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon - (int32_t)numOfMonth;
|
||||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
||||
return (int64_t)(taosMktime(&tm) * TSDB_TICK_PER_SECOND(precision));
|
||||
}
|
||||
|
||||
|
||||
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
|
||||
if (ekey < skey) {
|
||||
int64_t tmp = ekey;
|
||||
|
@ -839,17 +815,17 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
|||
|
||||
if (pInterval->offset > 0) {
|
||||
start = taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision);
|
||||
if (start > t) {
|
||||
start = taosTimeAdd(start, -pInterval->interval, pInterval->intervalUnit, precision);
|
||||
} else {
|
||||
|
||||
// try to move current window to the left-hande-side, due to the offset effect.
|
||||
int64_t end = taosTimeAdd(start, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
ASSERT(end >= t);
|
||||
end = taosTimeAdd(end, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
if (end >= t) {
|
||||
start = taosTimeAdd(start, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
}
|
||||
|
||||
int64_t newEnd = end;
|
||||
while (newEnd >= t) {
|
||||
end = newEnd;
|
||||
newEnd = taosTimeAdd(newEnd, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
}
|
||||
|
||||
start = taosTimeAdd(end, -pInterval->interval, pInterval->intervalUnit, precision) + 1;
|
||||
}
|
||||
|
||||
return start;
|
||||
|
|
|
@ -116,7 +116,7 @@ STSchema *genSTSchema(int16_t nCols) {
|
|||
}
|
||||
|
||||
STSchema *pResult = NULL;
|
||||
pResult = tdGetSTSChemaFromSSChema(&pSchema, nCols);
|
||||
pResult = tdGetSTSChemaFromSSChema(pSchema, nCols, 1);
|
||||
|
||||
taosMemoryFree(pSchema);
|
||||
return pResult;
|
||||
|
|
|
@ -158,8 +158,8 @@ static void taosCleanupArgs() {
|
|||
}
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
if (!taosCheckSystemIsSmallEnd()) {
|
||||
printf("failed to start since on non-small-end machines\n");
|
||||
if (!taosCheckSystemIsLittleEnd()) {
|
||||
printf("failed to start since on non-little-end machines\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,6 +224,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CHECK_ALTER_INFO_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -352,6 +352,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CHECK_ALTER_INFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -477,6 +477,10 @@ typedef struct {
|
|||
char* physicalPlan;
|
||||
SSchemaWrapper schema;
|
||||
int64_t stbUid;
|
||||
// forbid condition
|
||||
int64_t ntbUid;
|
||||
SArray* ntbColIds;
|
||||
int64_t ctbStbUid;
|
||||
} SMqTopicObj;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -37,7 +37,7 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]);
|
|||
|
||||
int32_t mndSetTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic);
|
||||
|
||||
int32_t mndCheckColAndTagModifiable(SMnode *pMnode, int64_t suid, col_id_t colId);
|
||||
int32_t mndCheckColAndTagModifiable(SMnode *pMnode, const char* stbname, int64_t suid, col_id_t colId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -190,6 +190,10 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
int32_t code = -1;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_USER)) < 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SFuncObj func = {0};
|
||||
memcpy(func.name, pCreate->name, TSDB_FUNC_NAME_LEN);
|
||||
func.createdTime = taosGetTimestampMs();
|
||||
|
|
|
@ -128,7 +128,6 @@ int32_t mndInitGrant(SMnode *pMnode) {
|
|||
|
||||
void mndCleanupGrant() {}
|
||||
void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
||||
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||
void grantRestore(EGrantType grant, uint64_t value) {}
|
||||
|
|
|
@ -66,7 +66,7 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
|
|||
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
|
||||
if (NULL == pMnode->infosMeta) {
|
||||
terrno = TSDB_CODE_MND_NOT_READY;
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
|
|||
|
||||
int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
|
||||
if (NULL == pMnode->infosMeta) {
|
||||
terrno = TSDB_CODE_MND_NOT_READY;
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) {
|
|||
|
||||
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
|
||||
if (NULL == pMnode->perfsMeta) {
|
||||
terrno = TSDB_CODE_MND_NOT_READY;
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
|
|||
|
||||
int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
|
||||
if (NULL == pMnode->perfsMeta) {
|
||||
terrno = TSDB_CODE_MND_NOT_READY;
|
||||
terrno = TSDB_CODE_APP_NOT_READY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1144,7 +1144,7 @@ static int32_t mndDropSuperTableTag(SMnode *pMnode, const SStbObj *pOld, SStbObj
|
|||
}
|
||||
|
||||
col_id_t colId = pOld->pTags[tag].colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->uid, colId) != 0) {
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1179,7 +1179,7 @@ static int32_t mndAlterStbTagName(SMnode *pMnode, const SStbObj *pOld, SStbObj *
|
|||
}
|
||||
|
||||
col_id_t colId = pOld->pTags[tag].colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->uid, colId) != 0) {
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ static int32_t mndAlterStbTagBytes(SMnode *pMnode, const SStbObj *pOld, SStbObj
|
|||
}
|
||||
|
||||
col_id_t colId = pOld->pTags[tag].colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->uid, colId) != 0) {
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1295,7 +1295,7 @@ static int32_t mndDropSuperTableColumn(SMnode *pMnode, const SStbObj *pOld, SStb
|
|||
}
|
||||
|
||||
col_id_t colId = pOld->pColumns[col].colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->uid, colId) != 0) {
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1329,7 +1329,7 @@ static int32_t mndAlterStbColumnBytes(SMnode *pMnode, const SStbObj *pOld, SStbO
|
|||
}
|
||||
|
||||
col_id_t colId = pOld->pColumns[col].colId;
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->uid, colId) != 0) {
|
||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -868,7 +868,10 @@ int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName)
|
|||
}
|
||||
|
||||
// iter all vnode to delete handle
|
||||
ASSERT(taosHashGetSize(pSub->consumerHash) == 0);
|
||||
if (taosHashGetSize(pSub->consumerHash) != 0) {
|
||||
sdbRelease(pSdb, pSub);
|
||||
return -1;
|
||||
}
|
||||
int32_t sz = taosArrayGetSize(pSub->unassignedVgs);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqVgEp *pVgEp = taosArrayGetP(pSub->unassignedVgs, i);
|
||||
|
|
|
@ -57,6 +57,7 @@ int32_t mndInitTopic(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TOPIC, mndProcessCreateTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndTransProcessRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_CHECK_ALTER_INFO_RSP, mndTransProcessRsp);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic);
|
||||
|
@ -71,14 +72,16 @@ const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]) {
|
|||
return strchr(topic, '.') + 1;
|
||||
}
|
||||
|
||||
int32_t mndCheckColAndTagModifiable(SMnode *pMnode, int64_t suid, col_id_t colId) {
|
||||
int32_t mndCheckColAndTagModifiable(SMnode *pMnode, const char* stbname, int64_t suid, col_id_t colId) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
bool found = false;
|
||||
while (1) {
|
||||
SMqTopicObj *pTopic = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pTopic);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
mDebug("topic:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, subType:%d sql:%s",
|
||||
pTopic->name, stbname, suid, colId, pTopic->subType, pTopic->sql);
|
||||
if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) {
|
||||
sdbRelease(pSdb, pTopic);
|
||||
continue;
|
||||
|
@ -95,21 +98,25 @@ int32_t mndCheckColAndTagModifiable(SMnode *pMnode, int64_t suid, col_id_t colId
|
|||
SNode *pNode = NULL;
|
||||
FOREACH(pNode, pNodeList) {
|
||||
SColumnNode *pCol = (SColumnNode *)pNode;
|
||||
if (pCol->tableId != suid) goto NEXT;
|
||||
if (pCol->colId > 0 && pCol->colId == colId) {
|
||||
found = true;
|
||||
mDebug("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, pCol->tableId, pTopic->ctbStbUid);
|
||||
|
||||
if (pCol->tableId != suid && pTopic->ctbStbUid != suid) {
|
||||
mDebug("topic:%s, check colId:%d passed", pTopic->name, pCol->colId);
|
||||
goto NEXT;
|
||||
}
|
||||
mTrace("topic:%s, colId:%d is used", pTopic->name, pCol->colId);
|
||||
if (pCol->colId > 0 && pCol->colId == colId) {
|
||||
sdbRelease(pSdb, pTopic);
|
||||
nodesDestroyNode(pAst);
|
||||
terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC;
|
||||
mError("topic:%s, check colId:%d conflicted", pTopic->name, pCol->colId);
|
||||
return -1;
|
||||
}
|
||||
mDebug("topic:%s, check colId:%d passed", pTopic->name, pCol->colId);
|
||||
}
|
||||
|
||||
NEXT:
|
||||
sdbRelease(pSdb, pTopic);
|
||||
nodesDestroyNode(pAst);
|
||||
if (found) {
|
||||
terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -127,8 +134,10 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
|||
if (pTopic->schema.nCols) {
|
||||
schemaLen = taosEncodeSSchemaWrapper(NULL, &pTopic->schema);
|
||||
}
|
||||
int32_t size =
|
||||
sizeof(SMqTopicObj) + physicalPlanLen + pTopic->sqlLen + pTopic->astLen + schemaLen + MND_TOPIC_RESERVE_SIZE;
|
||||
int32_t ntbColLen = taosArrayGetSize(pTopic->ntbColIds) * sizeof(int16_t);
|
||||
|
||||
int32_t size = sizeof(SMqTopicObj) + physicalPlanLen + pTopic->sqlLen + pTopic->astLen + schemaLen + ntbColLen +
|
||||
MND_TOPIC_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, MND_TOPIC_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto TOPIC_ENCODE_OVER;
|
||||
|
||||
|
@ -164,6 +173,16 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
|||
taosEncodeSSchemaWrapper(&aswBuf, &pTopic->schema);
|
||||
SDB_SET_BINARY(pRaw, dataPos, swBuf, schemaLen, TOPIC_ENCODE_OVER);
|
||||
}
|
||||
SDB_SET_INT64(pRaw, dataPos, pTopic->ntbUid, TOPIC_ENCODE_OVER);
|
||||
if (pTopic->ntbUid != 0) {
|
||||
int32_t sz = taosArrayGetSize(pTopic->ntbColIds);
|
||||
SDB_SET_INT32(pRaw, dataPos, sz, TOPIC_ENCODE_OVER);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int16_t colId = *(int16_t *)taosArrayGet(pTopic->ntbColIds, i);
|
||||
SDB_SET_INT16(pRaw, dataPos, colId, TOPIC_ENCODE_OVER);
|
||||
}
|
||||
}
|
||||
SDB_SET_INT64(pRaw, dataPos, pTopic->ctbStbUid, TOPIC_ENCODE_OVER);
|
||||
|
||||
SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_DATALEN(pRaw, dataPos, TOPIC_ENCODE_OVER);
|
||||
|
@ -259,6 +278,20 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
|||
pTopic->schema.version = 0;
|
||||
pTopic->schema.pSchema = NULL;
|
||||
}
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->ntbUid, TOPIC_DECODE_OVER);
|
||||
if (pTopic->ntbUid != 0) {
|
||||
int32_t ntbColNum;
|
||||
SDB_GET_INT32(pRaw, dataPos, &ntbColNum, TOPIC_DECODE_OVER);
|
||||
pTopic->ntbColIds = taosArrayInit(ntbColNum, sizeof(int16_t));
|
||||
if (pTopic->ntbColIds == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto TOPIC_DECODE_OVER;
|
||||
}
|
||||
int16_t colId;
|
||||
SDB_GET_INT16(pRaw, dataPos, &colId, TOPIC_DECODE_OVER);
|
||||
taosArrayPush(pTopic->ntbColIds, &colId);
|
||||
}
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->ctbStbUid, TOPIC_DECODE_OVER);
|
||||
|
||||
SDB_GET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE, TOPIC_DECODE_OVER);
|
||||
|
||||
|
@ -346,6 +379,26 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t extractTopicTbInfo(SNode *pAst, SMqTopicObj *pTopic) {
|
||||
SNodeList *pNodeList = NULL;
|
||||
nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList);
|
||||
int64_t suid = ((SRealTableNode *)((SSelectStmt *)pAst)->pFromTable)->pMeta->suid;
|
||||
int8_t tableType = ((SRealTableNode *)((SSelectStmt *)pAst)->pFromTable)->pMeta->tableType;
|
||||
if (tableType == TSDB_CHILD_TABLE) {
|
||||
pTopic->ctbStbUid = suid;
|
||||
} else if (tableType == TSDB_NORMAL_TABLE) {
|
||||
SNode *pNode = NULL;
|
||||
FOREACH(pNode, pNodeList) {
|
||||
SColumnNode *pCol = (SColumnNode *)pNode;
|
||||
if (pCol->tableType == TSDB_NORMAL_TABLE) {
|
||||
pTopic->ntbUid = pCol->tableId;
|
||||
taosArrayPush(pTopic->ntbColIds, &pCol->colId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) {
|
||||
mDebug("topic:%s to create", pCreate->name);
|
||||
SMqTopicObj topicObj = {0};
|
||||
|
@ -386,6 +439,19 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
return -1;
|
||||
}
|
||||
|
||||
int64_t ntbUid;
|
||||
topicObj.ntbColIds = taosArrayInit(0, sizeof(int16_t));
|
||||
if (topicObj.ntbColIds == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
extractTopicTbInfo(pAst, &topicObj);
|
||||
|
||||
if (topicObj.ntbUid == 0) {
|
||||
taosArrayDestroy(topicObj.ntbColIds);
|
||||
topicObj.ntbColIds = NULL;
|
||||
}
|
||||
|
||||
if (qExtractResultSchema(pAst, &topicObj.schema.nCols, &topicObj.schema.pSchema) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
taosMemoryFree(topicObj.ast);
|
||||
|
@ -433,6 +499,60 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
}
|
||||
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
|
||||
if (topicObj.ntbUid != 0) {
|
||||
SCheckAlterInfo info;
|
||||
memcpy(info.topic, topicObj.name, TSDB_TOPIC_FNAME_LEN);
|
||||
info.ntbUid = topicObj.ntbUid;
|
||||
info.colIdList = topicObj.ntbColIds;
|
||||
// broadcast forbid alter info
|
||||
void *pIter = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SVgObj *pVgroup = NULL;
|
||||
while (1) {
|
||||
// iterate vg
|
||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
if (!mndVgroupInDb(pVgroup, topicObj.dbUid)) {
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
// encoder check alter info
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSCheckAlterInfo, &info, len, code);
|
||||
if (code < 0) {
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
mndTransDrop(pTrans);
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len);
|
||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
if (tEncodeSCheckAlterInfo(&encoder, &info) < 0) {
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
tEncoderClear(&encoder);
|
||||
((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId);
|
||||
// add redo action
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + len;
|
||||
action.msgType = TDMT_VND_CHECK_ALTER_INFO;
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
|
@ -442,7 +562,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
|||
|
||||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
||||
|
@ -583,6 +703,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -590,11 +711,17 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
|
||||
if (mndDropOffsetByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||
ASSERT(0);
|
||||
mndTransDrop(pTrans);
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO check if rebalancing
|
||||
if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||
ASSERT(0);
|
||||
/*ASSERT(0);*/
|
||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
snprintf(file, sizeof(file), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
|
||||
mDebug("start to read sdb file:%s", file);
|
||||
|
||||
SSdbRaw *pRaw = taosMemoryMalloc(WAL_MAX_SIZE + 100);
|
||||
SSdbRaw *pRaw = taosMemoryMalloc(TSDB_MAX_MSG_SIZE + 100);
|
||||
if (pRaw == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("failed read sdb file since %s", terrstr());
|
||||
|
@ -556,7 +556,8 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
|
|||
if (term != NULL) *term = commitTerm;
|
||||
if (config != NULL) *config = commitConfig;
|
||||
|
||||
mDebug("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s",
|
||||
mDebug("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64
|
||||
" file:%s",
|
||||
pIter, commitIndex, commitTerm, commitConfig, pIter->name);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include "wal.h"
|
||||
|
||||
#include "tcommon.h"
|
||||
#include "tgrant.h"
|
||||
#include "tfs.h"
|
||||
#include "tgrant.h"
|
||||
#include "tmsg.h"
|
||||
#include "trow.h"
|
||||
|
||||
|
@ -89,6 +89,7 @@ void metaReaderClear(SMetaReader *pReader);
|
|||
int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
||||
int32_t metaReadNext(SMetaReader *pReader);
|
||||
const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *tagVal);
|
||||
int metaGetTableNameByUid(void* meta, uint64_t uid, char* tbName);
|
||||
|
||||
typedef struct SMetaFltParam {
|
||||
tb_uid_t suid;
|
||||
|
@ -100,7 +101,7 @@ typedef struct SMetaFltParam {
|
|||
|
||||
} SMetaFltParam;
|
||||
|
||||
int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *results);
|
||||
int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *results);
|
||||
|
||||
#if 1 // refact APIs below (TODO)
|
||||
typedef SVCreateTbReq STbCfg;
|
||||
|
@ -233,7 +234,6 @@ struct SVnodeCfg {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
TSKEY lastKey;
|
||||
uint64_t uid;
|
||||
uint64_t groupId;
|
||||
} STableKeyInfo;
|
||||
|
|
|
@ -67,8 +67,6 @@ struct STSmaStat {
|
|||
struct SRSmaStat {
|
||||
SSma *pSma;
|
||||
int64_t commitAppliedVer; // vnode applied version for async commit
|
||||
int64_t commitSubmitVer; // rsma submit version for async commit
|
||||
int64_t submitVer; // latest submit version
|
||||
int64_t refId; // shared by fetch tasks
|
||||
int8_t triggerStat; // shared by fetch tasks
|
||||
int8_t commitStat; // 0 not in committing, 1 in committing
|
||||
|
@ -91,7 +89,6 @@ struct SSmaStat {
|
|||
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
|
||||
#define RSMA_COMMIT_STAT(r) (&(r)->commitStat)
|
||||
#define RSMA_REF_ID(r) ((r)->refId)
|
||||
#define RSMA_SUBMIT_VER(r) ((r)->submitVer)
|
||||
|
||||
struct SRSmaInfoItem {
|
||||
void *taskInfo; // qTaskInfo_t
|
||||
|
@ -223,13 +220,6 @@ struct STFInfo {
|
|||
uint32_t ftype;
|
||||
uint32_t fver;
|
||||
int64_t fsize;
|
||||
|
||||
// specific fields
|
||||
union {
|
||||
struct {
|
||||
int64_t submitVer;
|
||||
} qTaskInfo;
|
||||
};
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
char* qmsg;
|
||||
qTaskInfo_t task[5];
|
||||
qTaskInfo_t task;
|
||||
} STqExecCol;
|
||||
|
||||
typedef struct {
|
||||
|
@ -82,13 +82,14 @@ typedef struct {
|
|||
typedef struct {
|
||||
int8_t subType;
|
||||
|
||||
STqReader* pExecReader[5];
|
||||
STqReader* pExecReader;
|
||||
union {
|
||||
STqExecCol execCol;
|
||||
STqExecTb execTb;
|
||||
STqExecDb execDb;
|
||||
};
|
||||
int32_t numOfCols; // number of out pout column, temporarily used
|
||||
SSchemaWrapper* pSchemaWrapper; // columns that are involved in query
|
||||
} STqExecHandle;
|
||||
|
||||
typedef struct {
|
||||
|
@ -108,6 +109,7 @@ typedef struct {
|
|||
|
||||
// exec
|
||||
STqExecHandle execHandle;
|
||||
|
||||
} STqHandle;
|
||||
|
||||
struct STQ {
|
||||
|
@ -115,9 +117,9 @@ struct STQ {
|
|||
SHashObj* pushMgr; // consumerId -> STqHandle*
|
||||
SHashObj* handles; // subKey -> STqHandle
|
||||
SHashObj* pStreamTasks; // taksId -> SStreamTask
|
||||
SHashObj* pAlterInfo; // topic -> SAlterCheckInfo
|
||||
STqOffsetStore* pOffsetStore;
|
||||
SVnode* pVnode;
|
||||
SWal* pWal;
|
||||
TDB* pMetaStore;
|
||||
TTB* pExecStore;
|
||||
};
|
||||
|
@ -134,8 +136,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
|
|||
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
|
||||
|
||||
// tqExec
|
||||
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId);
|
||||
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId);
|
||||
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp);
|
||||
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp);
|
||||
|
||||
// tqMeta
|
||||
|
|
|
@ -40,12 +40,9 @@ typedef struct SDelIdx SDelIdx;
|
|||
typedef struct STbData STbData;
|
||||
typedef struct SMemTable SMemTable;
|
||||
typedef struct STbDataIter STbDataIter;
|
||||
typedef struct STable STable;
|
||||
typedef struct SMapData SMapData;
|
||||
typedef struct SBlockIdx SBlockIdx;
|
||||
typedef struct SBlock SBlock;
|
||||
typedef struct SBlockStatis SBlockStatis;
|
||||
typedef struct SAggrBlkCol SAggrBlkCol;
|
||||
typedef struct SColData SColData;
|
||||
typedef struct SBlockDataHdr SBlockDataHdr;
|
||||
typedef struct SBlockData SBlockData;
|
||||
|
@ -62,8 +59,7 @@ typedef struct SDelFReader SDelFReader;
|
|||
typedef struct SRowIter SRowIter;
|
||||
typedef struct STsdbFS STsdbFS;
|
||||
typedef struct SRowMerger SRowMerger;
|
||||
typedef struct STsdbFSState STsdbFSState;
|
||||
typedef struct STsdbSnapHdr STsdbSnapHdr;
|
||||
typedef struct STsdbReadSnap STsdbReadSnap;
|
||||
|
||||
#define TSDB_MAX_SUBBLOCKS 8
|
||||
#define TSDB_FHDR_SIZE 512
|
||||
|
@ -176,8 +172,6 @@ void tsdbMemTableDestroy(SMemTable *pMemTable);
|
|||
void tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData);
|
||||
void tsdbRefMemTable(SMemTable *pMemTable);
|
||||
void tsdbUnrefMemTable(SMemTable *pMemTable);
|
||||
int32_t tsdbTakeMemSnapshot(STsdb *pTsdb, SMemTable **ppMem, SMemTable **ppIMem);
|
||||
void tsdbUntakeMemSnapshot(STsdb *pTsdb, SMemTable *pMem, SMemTable *pIMem);
|
||||
// STbDataIter
|
||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||
|
@ -188,30 +182,39 @@ bool tsdbTbDataIterNext(STbDataIter *pIter);
|
|||
int32_t tsdbGetNRowsInTbData(STbData *pTbData);
|
||||
// tsdbFile.c ==============================================================================================
|
||||
typedef enum { TSDB_HEAD_FILE = 0, TSDB_DATA_FILE, TSDB_LAST_FILE, TSDB_SMA_FILE } EDataFileT;
|
||||
void tsdbDataFileName(STsdb *pTsdb, SDFileSet *pDFileSet, EDataFileT ftype, char fname[]);
|
||||
bool tsdbFileIsSame(SDFileSet *pDFileSet1, SDFileSet *pDFileSet2, EDataFileT ftype);
|
||||
|
||||
bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2);
|
||||
int32_t tsdbUpdateDFileHdr(TdFilePtr pFD, SDFileSet *pSet, EDataFileT ftype);
|
||||
int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype);
|
||||
int32_t tPutDataFileHdr(uint8_t *p, SDFileSet *pSet, EDataFileT ftype);
|
||||
int32_t tPutHeadFile(uint8_t *p, SHeadFile *pHeadFile);
|
||||
int32_t tPutDataFile(uint8_t *p, SDataFile *pDataFile);
|
||||
int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile);
|
||||
int32_t tPutSmaFile(uint8_t *p, SSmaFile *pSmaFile);
|
||||
int32_t tPutDelFile(uint8_t *p, SDelFile *pDelFile);
|
||||
int32_t tGetDelFile(uint8_t *p, SDelFile *pDelFile);
|
||||
int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet);
|
||||
int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet);
|
||||
|
||||
void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, char fname[]);
|
||||
void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]);
|
||||
void tsdbLastFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SLastFile *pLastF, char fname[]);
|
||||
void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]);
|
||||
// SDelFile
|
||||
void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]);
|
||||
// tsdbFS.c ==============================================================================================
|
||||
int32_t tsdbFSOpen(STsdb *pTsdb, STsdbFS **ppFS);
|
||||
int32_t tsdbFSClose(STsdbFS *pFS);
|
||||
int32_t tsdbFSBegin(STsdbFS *pFS);
|
||||
int32_t tsdbFSCommit(STsdbFS *pFS);
|
||||
int32_t tsdbFSOpen(STsdb *pTsdb);
|
||||
int32_t tsdbFSClose(STsdb *pTsdb);
|
||||
int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS);
|
||||
void tsdbFSDestroy(STsdbFS *pFS);
|
||||
int32_t tDFileSetCmprFn(const void *p1, const void *p2);
|
||||
int32_t tsdbFSCommit1(STsdb *pTsdb, STsdbFS *pFS);
|
||||
int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFS);
|
||||
int32_t tsdbFSRef(STsdb *pTsdb, STsdbFS *pFS);
|
||||
void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS);
|
||||
|
||||
int32_t tsdbFSRollback(STsdbFS *pFS);
|
||||
|
||||
int32_t tsdbFSStateUpsertDelFile(STsdbFSState *pState, SDelFile *pDelFile);
|
||||
int32_t tsdbFSStateUpsertDFileSet(STsdbFSState *pState, SDFileSet *pSet);
|
||||
void tsdbFSStateDeleteDFileSet(STsdbFSState *pState, int32_t fid);
|
||||
SDelFile *tsdbFSStateGetDelFile(STsdbFSState *pState);
|
||||
SDFileSet *tsdbFSStateGetDFileSet(STsdbFSState *pState, int32_t fid, int32_t flag);
|
||||
int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet);
|
||||
int32_t tsdbFSUpsertDelFile(STsdbFS *pFS, SDelFile *pDelFile);
|
||||
// tsdbReaderWriter.c ==============================================================================================
|
||||
// SDataFWriter
|
||||
int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet);
|
||||
|
@ -222,7 +225,6 @@ int32_t tsdbWriteBlock(SDataFWriter *pWriter, SMapData *pMapData, uint8_t **ppBu
|
|||
int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_t **ppBuf1, uint8_t **ppBuf2,
|
||||
SBlockIdx *pBlockIdx, SBlock *pBlock, int8_t cmprAlg);
|
||||
|
||||
SDFileSet *tsdbDataFWriterGetWSet(SDataFWriter *pWriter);
|
||||
int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo);
|
||||
// SDataFReader
|
||||
int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet);
|
||||
|
@ -245,6 +247,9 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
|
|||
int32_t tsdbDelFReaderClose(SDelFReader **ppReader);
|
||||
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData, uint8_t **ppBuf);
|
||||
int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx, uint8_t **ppBuf);
|
||||
// tsdbRead.c ==============================================================================================
|
||||
int32_t tsdbTakeReadSnap(STsdb *pTsdb, STsdbReadSnap **ppSnap);
|
||||
void tsdbUntakeReadSnap(STsdb *pTsdb, STsdbReadSnap *pSnap);
|
||||
|
||||
#define TSDB_CACHE_NO(c) ((c).cacheLast == 0)
|
||||
#define TSDB_CACHE_LAST_ROW(c) (((c).cacheLast & 1) > 0)
|
||||
|
@ -276,6 +281,11 @@ typedef struct {
|
|||
TSKEY minKey;
|
||||
} SRtn;
|
||||
|
||||
struct STsdbFS {
|
||||
SDelFile *pDelFile;
|
||||
SArray *aDFileSet; // SArray<SDFileSet>
|
||||
};
|
||||
|
||||
struct STsdb {
|
||||
char *path;
|
||||
SVnode *pVnode;
|
||||
|
@ -283,7 +293,7 @@ struct STsdb {
|
|||
TdThreadRwlock rwLock;
|
||||
SMemTable *mem;
|
||||
SMemTable *imem;
|
||||
STsdbFS *pFS;
|
||||
STsdbFS fs;
|
||||
SLRUCache *lruCache;
|
||||
};
|
||||
|
||||
|
@ -402,16 +412,6 @@ struct SBlock {
|
|||
SSubBlock aSubBlock[TSDB_MAX_SUBBLOCKS];
|
||||
};
|
||||
|
||||
struct SAggrBlkCol {
|
||||
int16_t colId;
|
||||
int16_t maxIndex;
|
||||
int16_t minIndex;
|
||||
int16_t numOfNull;
|
||||
int64_t sum;
|
||||
int64_t max;
|
||||
int64_t min;
|
||||
};
|
||||
|
||||
struct SColData {
|
||||
int16_t cid;
|
||||
int8_t type;
|
||||
|
@ -465,12 +465,6 @@ struct SDelIdx {
|
|||
int64_t size;
|
||||
};
|
||||
|
||||
struct SDelFile {
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
int64_t offset;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct SBlockDataHdr {
|
||||
uint32_t delimiter;
|
||||
|
@ -479,23 +473,39 @@ struct SBlockDataHdr {
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct SDelFile {
|
||||
volatile int32_t nRef;
|
||||
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
int64_t offset;
|
||||
};
|
||||
|
||||
struct SHeadFile {
|
||||
volatile int32_t nRef;
|
||||
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
int64_t offset;
|
||||
};
|
||||
|
||||
struct SDataFile {
|
||||
volatile int32_t nRef;
|
||||
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
};
|
||||
|
||||
struct SLastFile {
|
||||
volatile int32_t nRef;
|
||||
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
};
|
||||
|
||||
struct SSmaFile {
|
||||
volatile int32_t nRef;
|
||||
|
||||
int64_t commitID;
|
||||
int64_t size;
|
||||
};
|
||||
|
@ -503,10 +513,10 @@ struct SSmaFile {
|
|||
struct SDFileSet {
|
||||
SDiskID diskId;
|
||||
int32_t fid;
|
||||
SHeadFile fHead;
|
||||
SDataFile fData;
|
||||
SLastFile fLast;
|
||||
SSmaFile fSma;
|
||||
SHeadFile *pHeadF;
|
||||
SDataFile *pDataF;
|
||||
SLastFile *pLastF;
|
||||
SSmaFile *pSmaF;
|
||||
};
|
||||
|
||||
struct SRowIter {
|
||||
|
@ -521,26 +531,33 @@ struct SRowMerger {
|
|||
SArray *pArray; // SArray<SColVal>
|
||||
};
|
||||
|
||||
struct STsdbFSState {
|
||||
SDelFile *pDelFile;
|
||||
SArray *aDFileSet; // SArray<aDFileSet>
|
||||
SDelFile delFile;
|
||||
};
|
||||
|
||||
struct STsdbFS {
|
||||
STsdb *pTsdb;
|
||||
TdThreadRwlock lock;
|
||||
int8_t inTxn;
|
||||
STsdbFSState *cState;
|
||||
STsdbFSState *nState;
|
||||
};
|
||||
|
||||
struct SDelFWriter {
|
||||
STsdb *pTsdb;
|
||||
SDelFile fDel;
|
||||
TdFilePtr pWriteH;
|
||||
};
|
||||
|
||||
struct SDataFWriter {
|
||||
STsdb *pTsdb;
|
||||
SDFileSet wSet;
|
||||
|
||||
TdFilePtr pHeadFD;
|
||||
TdFilePtr pDataFD;
|
||||
TdFilePtr pLastFD;
|
||||
TdFilePtr pSmaFD;
|
||||
|
||||
SHeadFile fHead;
|
||||
SDataFile fData;
|
||||
SLastFile fLast;
|
||||
SSmaFile fSma;
|
||||
};
|
||||
|
||||
struct STsdbReadSnap {
|
||||
SMemTable *pMem;
|
||||
SMemTable *pIMem;
|
||||
STsdbFS fs;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -137,15 +137,17 @@ STsdbReader tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableL
|
|||
// tq
|
||||
int tqInit();
|
||||
void tqCleanUp();
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal);
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode);
|
||||
void tqClose(STQ*);
|
||||
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver);
|
||||
int tqCommit(STQ*);
|
||||
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd);
|
||||
int32_t tqCheckColModifiable(STQ* pTq, int64_t tbUid, int32_t colId);
|
||||
int32_t tqProcessCheckAlterInfoReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId);
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data);
|
||||
|
@ -176,7 +178,6 @@ int32_t smaAsyncPostCommit(SSma* pSma);
|
|||
|
||||
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
||||
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
||||
int64_t tdRSmaGetMaxSubmitVer(SSma* pSma, int8_t level);
|
||||
|
||||
int32_t tdProcessRSmaCreate(SSma* pSma, SVCreateStbReq* pReq);
|
||||
int32_t tdProcessRSmaSubmit(SSma* pSma, void* pMsg, int32_t inputType);
|
||||
|
|
|
@ -98,6 +98,17 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
|
|||
return uid;
|
||||
}
|
||||
|
||||
int metaGetTableNameByUid(void* meta, uint64_t uid, char* tbName) {
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, (SMeta*)meta, 0);
|
||||
metaGetTableEntryByUid(&mr, uid);
|
||||
|
||||
STR_TO_VARSTR(tbName, mr.me.name);
|
||||
metaReaderClear(&mr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int metaReadNext(SMetaReader *pReader) {
|
||||
SMeta *pMeta = pReader->pMeta;
|
||||
|
||||
|
@ -754,12 +765,14 @@ typedef struct {
|
|||
int32_t vLen;
|
||||
} SIdxCursor;
|
||||
|
||||
int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
||||
SIdxCursor *pCursor = NULL;
|
||||
int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
||||
int32_t ret = 0;
|
||||
char *buf = NULL;
|
||||
int32_t maxSize = 0;
|
||||
|
||||
int32_t ret = 0, valid = 0;
|
||||
STagIdxKey *pKey = NULL;
|
||||
int32_t nKey = 0;
|
||||
|
||||
SIdxCursor *pCursor = NULL;
|
||||
pCursor = (SIdxCursor *)taosMemoryCalloc(1, sizeof(SIdxCursor));
|
||||
pCursor->pMeta = pMeta;
|
||||
pCursor->suid = param->suid;
|
||||
|
@ -771,9 +784,8 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
|||
if (ret < 0) {
|
||||
goto END;
|
||||
}
|
||||
STagIdxKey *pKey = NULL;
|
||||
int32_t nKey = 0;
|
||||
|
||||
int32_t maxSize = 0;
|
||||
int32_t nTagData = 0;
|
||||
void *tagData = NULL;
|
||||
|
||||
|
@ -811,10 +823,12 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
|||
goto END;
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
int32_t valid = 0;
|
||||
while (1) {
|
||||
void *entryKey = NULL, *entryVal = NULL;
|
||||
int32_t nEntryKey, nEntryVal;
|
||||
bool first = true;
|
||||
while (1) {
|
||||
|
||||
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
||||
if (valid < 0) {
|
||||
break;
|
||||
|
@ -853,10 +867,12 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
END:
|
||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||
taosMemoryFree(buf);
|
||||
taosMemoryFree(pKey);
|
||||
|
||||
taosMemoryFree(pCursor);
|
||||
|
||||
|
|
|
@ -358,6 +358,14 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||
tb_uid_t suid = metaGetTableEntryUidByName(pMeta, pReq->ctb.name);
|
||||
if (suid != pReq->ctb.suid) {
|
||||
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// validate req
|
||||
metaReaderInit(&mr, pMeta, 0);
|
||||
if (metaGetTableEntryByName(&mr, pReq->name) == 0) {
|
||||
|
@ -371,13 +379,6 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
|||
}
|
||||
metaReaderClear(&mr);
|
||||
|
||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||
tb_uid_t suid = metaGetTableEntryUidByName(pMeta, pReq->ctb.name);
|
||||
if (suid == 0) {
|
||||
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// build SMetaEntry
|
||||
me.version = version;
|
||||
me.type = pReq->type;
|
||||
|
@ -438,12 +439,15 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
|||
}
|
||||
|
||||
int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) {
|
||||
metaWLock(pMeta);
|
||||
int ret = metaTtlSmaller(pMeta, ttl, tbUids);
|
||||
if (ret != 0) {
|
||||
metaULock(pMeta);
|
||||
return ret;
|
||||
}
|
||||
if (taosArrayGetSize(tbUids) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
metaWLock(pMeta);
|
||||
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
||||
tb_uid_t *uid = (tb_uid_t *)taosArrayGet(tbUids, i);
|
||||
metaDropTableByUid(pMeta, *uid, NULL);
|
||||
|
@ -637,6 +641,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||
goto _err;
|
||||
}
|
||||
if (tqCheckColModifiable(pMeta->pVnode->pTq, uid, pColumn->colId) != 0) {
|
||||
terrno = TSDB_CODE_VND_COL_SUBSCRIBED;
|
||||
goto _err;
|
||||
}
|
||||
pSchema->version++;
|
||||
tlen = (pSchema->nCols - iCol - 1) * sizeof(SSchema);
|
||||
if (tlen) {
|
||||
|
@ -653,6 +661,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||
goto _err;
|
||||
}
|
||||
if (tqCheckColModifiable(pMeta->pVnode->pTq, uid, pColumn->colId) != 0) {
|
||||
terrno = TSDB_CODE_VND_COL_SUBSCRIBED;
|
||||
goto _err;
|
||||
}
|
||||
pSchema->version++;
|
||||
pColumn->bytes = pAlterTbReq->colModBytes;
|
||||
break;
|
||||
|
@ -661,6 +673,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS;
|
||||
goto _err;
|
||||
}
|
||||
if (tqCheckColModifiable(pMeta->pVnode->pTq, uid, pColumn->colId) != 0) {
|
||||
terrno = TSDB_CODE_VND_COL_SUBSCRIBED;
|
||||
goto _err;
|
||||
}
|
||||
pSchema->version++;
|
||||
strcpy(pColumn->name, pAlterTbReq->colNewName);
|
||||
break;
|
||||
|
@ -796,6 +812,9 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
for (int32_t i = 0; i < pTagSchema->nCols; i++) {
|
||||
SSchema *pCol = &pTagSchema->pSchema[i];
|
||||
if (iCol == i) {
|
||||
if (pAlterTbReq->isNull) {
|
||||
continue;
|
||||
}
|
||||
STagVal val = {0};
|
||||
val.type = pCol->type;
|
||||
val.cid = pCol->colId;
|
||||
|
|
|
@ -146,7 +146,6 @@ static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma) {
|
|||
|
||||
// step 3: perform persist task for qTaskInfo
|
||||
pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
|
||||
pRSmaStat->commitSubmitVer = pRSmaStat->submitVer;
|
||||
tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat));
|
||||
|
||||
smaDebug("vgId:%d, rsma pre commit success", SMA_VID(pSma));
|
||||
|
@ -317,7 +316,6 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
|||
|
||||
// step 4: others
|
||||
pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
|
||||
pRSmaStat->commitSubmitVer = pRSmaStat->submitVer;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -560,17 +560,6 @@ static void tdDestroySDataBlockArray(SArray *pArray) {
|
|||
taosArrayDestroy(pArray);
|
||||
}
|
||||
|
||||
int64_t tdRSmaGetMaxSubmitVer(SSma *pSma, int8_t level) {
|
||||
if (level == TSDB_RETENTION_L0) {
|
||||
return pSma->pVnode->state.applied;
|
||||
}
|
||||
|
||||
SSmaEnv *pRSmaEnv = SMA_RSMA_ENV(pSma);
|
||||
SRSmaStat *pRSmaStat = (SRSmaStat *)(SMA_ENV_STAT(pRSmaEnv));
|
||||
|
||||
return atomic_load_64(&pRSmaStat->submitVer);
|
||||
}
|
||||
|
||||
static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid, SRSmaStat *pStat,
|
||||
int8_t blkType) {
|
||||
SArray *pResult = NULL;
|
||||
|
@ -579,9 +568,11 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
while (1) {
|
||||
SSDataBlock *output = NULL;
|
||||
uint64_t ts;
|
||||
if (qExecTask(pItem->taskInfo, &output, &ts) < 0) {
|
||||
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
||||
pItem->level, terrstr());
|
||||
|
||||
int32_t code = qExecTask(pItem->taskInfo, &output, &ts);
|
||||
if (code < 0) {
|
||||
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
||||
pItem->level, terrstr(code));
|
||||
goto _err;
|
||||
}
|
||||
if (!output) {
|
||||
|
@ -597,7 +588,6 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
}
|
||||
|
||||
taosArrayPush(pResult, output);
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pResult) > 0) {
|
||||
#if 1
|
||||
|
@ -614,19 +604,24 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
goto _err;
|
||||
}
|
||||
|
||||
if (pReq && tdProcessSubmitReq(sinkTsdb, atomic_add_fetch_64(&pStat->submitVer, 1), pReq) < 0) {
|
||||
if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) {
|
||||
taosMemoryFreeClear(pReq);
|
||||
smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma),
|
||||
suid, pItem->level, terrstr());
|
||||
smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s",
|
||||
SMA_VID(pSma), suid, pItem->level, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
|
||||
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%"PRIi64, SMA_VID(pSma),
|
||||
suid, pItem->level, output->info.version);
|
||||
|
||||
taosMemoryFreeClear(pReq);
|
||||
taosArrayClear(pResult);
|
||||
} else if (terrno == 0) {
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
|
||||
} else {
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno));
|
||||
}
|
||||
}
|
||||
|
||||
tdDestroySDataBlockArray(pResult);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -905,12 +900,8 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(tFileInfo.qTaskInfo.submitVer > 0);
|
||||
|
||||
SSmaEnv *pRSmaEnv = pSma->pRSmaEnv;
|
||||
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pRSmaEnv);
|
||||
atomic_store_64(&pRSmaStat->submitVer, tFileInfo.qTaskInfo.submitVer);
|
||||
smaDebug("%s:%d tFileInfo.qTaskInfo.submitVer = %" PRIi64, __func__, __LINE__, tFileInfo.qTaskInfo.submitVer);
|
||||
|
||||
SRSmaQTaskInfoIter fIter = {0};
|
||||
if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) {
|
||||
|
@ -1263,7 +1254,6 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
|||
}
|
||||
|
||||
if (isFileCreated) {
|
||||
tFile.info.qTaskInfo.submitVer = atomic_load_64(&pRSmaStat->commitSubmitVer);
|
||||
if (tdUpdateTFileHeader(&tFile) < 0) {
|
||||
smaError("vgId:%d, rsma, failed to update tfile %s header since %s", vid, TD_TFILE_FULL_NAME(&tFile),
|
||||
tstrerror(terrno));
|
||||
|
@ -1343,6 +1333,8 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK);
|
||||
|
||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
||||
// atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
||||
// taosTmrReset(tdRSmaFetchTrigger, 5000, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_PAUSED: {
|
||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is paused",
|
||||
|
|
|
@ -32,9 +32,6 @@ static int32_t tdEncodeTFInfo(void **buf, STFInfo *pInfo) {
|
|||
tlen += taosEncodeFixedU32(buf, pInfo->ftype);
|
||||
tlen += taosEncodeFixedU32(buf, pInfo->fver);
|
||||
tlen += taosEncodeFixedI64(buf, pInfo->fsize);
|
||||
if (pInfo->ftype == TD_FTYPE_RSMA_QTASKINFO) {
|
||||
tlen += taosEncodeFixedI64(buf, pInfo->qTaskInfo.submitVer);
|
||||
}
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
@ -44,10 +41,6 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) {
|
|||
buf = taosDecodeFixedU32(buf, &(pInfo->ftype));
|
||||
buf = taosDecodeFixedU32(buf, &(pInfo->fver));
|
||||
buf = taosDecodeFixedI64(buf, &(pInfo->fsize));
|
||||
// specific
|
||||
if (pInfo->ftype == TD_FTYPE_RSMA_QTASKINFO) {
|
||||
buf = taosDecodeFixedI64(buf, &(pInfo->qTaskInfo.submitVer));
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ void tqCleanUp() {
|
|||
}
|
||||
}
|
||||
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode) {
|
||||
STQ* pTq = taosMemoryCalloc(1, sizeof(STQ));
|
||||
if (pTq == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
|
@ -59,7 +59,6 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
|||
}
|
||||
pTq->path = strdup(path);
|
||||
pTq->pVnode = pVnode;
|
||||
pTq->pWal = pWal;
|
||||
|
||||
pTq->handles = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
|
||||
|
@ -67,6 +66,8 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
|||
|
||||
pTq->pushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
|
||||
pTq->pAlterInfo = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
|
||||
if (tqMetaOpen(pTq) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -91,6 +92,7 @@ void tqClose(STQ* pTq) {
|
|||
}
|
||||
taosHashCleanup(pTq->pStreamTasks);
|
||||
taosHashCleanup(pTq->pushMgr);
|
||||
taosHashCleanup(pTq->pAlterInfo);
|
||||
taosMemoryFree(pTq->path);
|
||||
tqMetaClose(pTq);
|
||||
taosMemoryFree(pTq);
|
||||
|
@ -136,6 +138,14 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con
|
|||
ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0);
|
||||
}
|
||||
|
||||
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
if (pRsp->blockNum > 0) {
|
||||
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
|
||||
} else {
|
||||
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code);
|
||||
|
@ -208,6 +218,26 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqCheckColModifiable(STQ* pTq, int64_t tbUid, int32_t colId) {
|
||||
void* pIter = NULL;
|
||||
while (1) {
|
||||
pIter = taosHashIterate(pTq->pAlterInfo, pIter);
|
||||
if (pIter == NULL) break;
|
||||
SCheckAlterInfo* pCheck = (SCheckAlterInfo*)pIter;
|
||||
if (pCheck->ntbUid == tbUid) {
|
||||
int32_t sz = taosArrayGetSize(pCheck->colIdList);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int16_t forbidColId = *(int16_t*)taosArrayGet(pCheck->colIdList, i);
|
||||
if (forbidColId == colId) {
|
||||
taosHashCancelIterate(pTq->pAlterInfo, pIter);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t subType) {
|
||||
pRsp->reqOffset = pReq->reqOffset;
|
||||
|
||||
|
@ -242,7 +272,7 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
|
|||
|
||||
static int32_t tqInitMetaRsp(SMqMetaRsp* pRsp, const SMqPollReq* pReq) { return 0; }
|
||||
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SMqPollReq* pReq = pMsg->pCont;
|
||||
int64_t consumerId = pReq->consumerId;
|
||||
int64_t timeout = pReq->timeout;
|
||||
|
@ -250,9 +280,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
int32_t code = 0;
|
||||
STqOffsetVal reqOffset = pReq->reqOffset;
|
||||
STqOffsetVal fetchOffsetNew;
|
||||
|
||||
// todo
|
||||
workerId = 0;
|
||||
SWalCkHead* pCkHead = NULL;
|
||||
|
||||
// 1.find handle
|
||||
STqHandle* pHandle = taosHashGet(pTq->handles, pReq->subKey, strlen(pReq->subKey));
|
||||
|
@ -385,7 +413,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||
SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
|
||||
|
||||
if (tqLogScanExec(pTq, &pHandle->execHandle, pCont, &dataRsp, workerId) < 0) {
|
||||
if (tqLogScanExec(pTq, &pHandle->execHandle, pCont, &dataRsp) < 0) {
|
||||
/*ASSERT(0);*/
|
||||
}
|
||||
// TODO batch optimization:
|
||||
|
@ -442,6 +470,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
}
|
||||
|
||||
OVER:
|
||||
if (pCkHead) taosMemoryFree(pCkHead);
|
||||
// TODO wrap in destroy func
|
||||
taosArrayDestroy(dataRsp.blockDataLen);
|
||||
taosArrayDestroyP(dataRsp.blockData, (FDelete)taosMemoryFree);
|
||||
|
@ -471,6 +500,22 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessCheckAlterInfoReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SCheckAlterInfo info = {0};
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, msg, msgLen);
|
||||
if (tDecodeSCheckAlterInfo(&decoder, &info) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
if (taosHashPut(pTq->pAlterInfo, info.topic, strlen(info.topic), &info, sizeof(SCheckAlterInfo)) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SMqRebVgReq req = {0};
|
||||
tDecodeSMqRebVgReq(msg, &req);
|
||||
|
@ -498,7 +543,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
pHandle->execHandle.execCol.qmsg = req.qmsg;
|
||||
pHandle->snapshotVer = ver;
|
||||
req.qmsg = NULL;
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
SReadHandle handle = {
|
||||
.meta = pTq->pVnode->pMeta,
|
||||
.vnode = pTq->pVnode,
|
||||
|
@ -506,18 +550,17 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
.initTqReader = true,
|
||||
.version = ver,
|
||||
};
|
||||
pHandle->execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols);
|
||||
ASSERT(pHandle->execHandle.execCol.task[i]);
|
||||
pHandle->execHandle.execCol.task =
|
||||
qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols,
|
||||
&pHandle->execHandle.pSchemaWrapper);
|
||||
ASSERT(pHandle->execHandle.execCol.task);
|
||||
void* scanner = NULL;
|
||||
qExtractStreamScanner(pHandle->execHandle.execCol.task[i], &scanner);
|
||||
qExtractStreamScanner(pHandle->execHandle.execCol.task, &scanner);
|
||||
ASSERT(scanner);
|
||||
pHandle->execHandle.pExecReader[i] = qExtractReaderFromStreamScanner(scanner);
|
||||
ASSERT(pHandle->execHandle.pExecReader[i]);
|
||||
}
|
||||
pHandle->execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner);
|
||||
ASSERT(pHandle->execHandle.pExecReader);
|
||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
pHandle->execHandle.pExecReader[i] = tqOpenReader(pTq->pVnode);
|
||||
}
|
||||
pHandle->execHandle.pExecReader = tqOpenReader(pTq->pVnode);
|
||||
pHandle->execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
|
@ -529,15 +572,15 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
||||
tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid);
|
||||
}
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
pHandle->execHandle.pExecReader[i] = tqOpenReader(pTq->pVnode);
|
||||
tqReaderSetTbUidList(pHandle->execHandle.pExecReader[i], tbUidList);
|
||||
}
|
||||
pHandle->execHandle.pExecReader = tqOpenReader(pTq->pVnode);
|
||||
tqReaderSetTbUidList(pHandle->execHandle.pExecReader, tbUidList);
|
||||
taosArrayDestroy(tbUidList);
|
||||
}
|
||||
taosHashPut(pTq->handles, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle));
|
||||
tqDebug("try to persist handle %s consumer %ld", req.subKey, pHandle->consumerId);
|
||||
if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) {
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
}
|
||||
} else {
|
||||
/*ASSERT(pExec->consumerId == req.oldConsumerId);*/
|
||||
|
@ -613,7 +656,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
ASSERT(pTask->tbSink.pSchemaWrapper->pSchema);
|
||||
|
||||
pTask->tbSink.pTSchema =
|
||||
tdGetSTSChemaFromSSChema(&pTask->tbSink.pSchemaWrapper->pSchema, pTask->tbSink.pSchemaWrapper->nCols);
|
||||
tdGetSTSChemaFromSSChema(pTask->tbSink.pSchemaWrapper->pSchema, pTask->tbSink.pSchemaWrapper->nCols, 1);
|
||||
ASSERT(pTask->tbSink.pTSchema);
|
||||
}
|
||||
|
||||
|
@ -679,9 +722,9 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
//
|
||||
SStreamTaskRunReq* pReq = pMsg->pCont;
|
||||
int32_t taskId = pReq->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessRunReq(pTask);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessRunReq(*ppTask);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -697,13 +740,13 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
tDecodeStreamDispatchReq(&decoder, &req);
|
||||
int32_t taskId = req.taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessDispatchReq(pTask, &req, &rsp);
|
||||
streamProcessDispatchReq(*ppTask, &req, &rsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -713,9 +756,9 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
||||
int32_t taskId = pReq->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessRecoverReq(pTask, pReq, pMsg);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessRecoverReq(*ppTask, pReq, pMsg);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -725,9 +768,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t taskId = pRsp->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessDispatchRsp(pTask, pRsp);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessDispatchRsp(*ppTask, pRsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -737,9 +780,9 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
||||
int32_t taskId = pRsp->taskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
streamProcessRecoverRsp(pTask, pRsp);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
streamProcessRecoverRsp(*ppTask, pRsp);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -749,8 +792,9 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg;
|
||||
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
if (pTask) {
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
SStreamTask* pTask = *ppTask;
|
||||
taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
|
||||
atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING);
|
||||
}
|
||||
|
@ -781,15 +825,16 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
tDecodeStreamRetrieveReq(&decoder, &req);
|
||||
int32_t taskId = req.dstTaskId;
|
||||
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) {
|
||||
return 0;
|
||||
}
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
if (ppTask) {
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
.code = 0,
|
||||
};
|
||||
streamProcessRetrieveReq(pTask, &req, &rsp);
|
||||
streamProcessRetrieveReq(*ppTask, &req, &rsp);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerId, SMqDataRsp* pRsp) {
|
||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pExecReader[workerId]->pSchemaWrapper);
|
||||
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, SMqDataRsp* pRsp) {
|
||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pExecReader->pSchemaWrapper);
|
||||
if (pSW == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
|
|||
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
||||
// TODO add reference to gurantee success
|
||||
if (metaGetTableEntryByUid(&mr, uid) < 0) {
|
||||
metaReaderClear(&mr);
|
||||
return -1;
|
||||
}
|
||||
char* tbName = strdup(mr.me.name);
|
||||
|
@ -61,15 +62,17 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
|
|||
|
||||
int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset) {
|
||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||
qTaskInfo_t task = pExec->execCol.task[0];
|
||||
qTaskInfo_t task = pExec->execCol.task;
|
||||
|
||||
if (qStreamPrepareScan(task, pOffset) < 0) {
|
||||
tqDebug("prepare scan failed, return");
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
pRsp->rspOffset = *pOffset;
|
||||
return 0;
|
||||
} else {
|
||||
tqOffsetResetToLog(pOffset, pHandle->snapshotVer);
|
||||
if (qStreamPrepareScan(task, pOffset) < 0) {
|
||||
tqDebug("prepare scan failed, return");
|
||||
pRsp->rspOffset = *pOffset;
|
||||
return 0;
|
||||
}
|
||||
|
@ -89,7 +92,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
|
|||
if (pDataBlock != NULL) {
|
||||
if (pRsp->withTbName) {
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
int64_t uid = pExec->pExecReader[0]->msgIter.uid;
|
||||
int64_t uid = pExec->pExecReader->msgIter.uid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -108,6 +111,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
|
|||
}
|
||||
|
||||
if (pRsp->blockNum == 0 && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||
tqDebug("vgId: %d, tsdb consume over, switch to wal, ver %ld", TD_VID(pTq->pVnode), pHandle->snapshotVer + 1);
|
||||
tqOffsetResetToLog(pOffset, pHandle->snapshotVer);
|
||||
qStreamPrepareScan(task, pOffset);
|
||||
continue;
|
||||
|
@ -124,9 +128,16 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
|
|||
|
||||
ASSERT(pRsp->rspOffset.type != 0);
|
||||
|
||||
#if 0
|
||||
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
ASSERT(pRsp->rspOffset.version + 1 >= pRsp->reqOffset.version);
|
||||
if (pRsp->blockNum > 0) {
|
||||
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
|
||||
} else {
|
||||
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
tqDebug("task exec exited");
|
||||
break;
|
||||
}
|
||||
|
@ -184,12 +195,12 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S
|
|||
}
|
||||
#endif
|
||||
|
||||
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId) {
|
||||
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp) {
|
||||
ASSERT(pExec->subType != TOPIC_SUB_TYPE__COLUMN);
|
||||
|
||||
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
pRsp->withSchema = 1;
|
||||
STqReader* pReader = pExec->pExecReader[workerId];
|
||||
STqReader* pReader = pExec->pExecReader;
|
||||
tqReaderSetDataMsg(pReader, pReq, 0);
|
||||
while (tqNextDataBlock(pReader)) {
|
||||
SSDataBlock block = {0};
|
||||
|
@ -197,18 +208,20 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
|
|||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||
}
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pExecReader[workerId]->msgIter.uid;
|
||||
int64_t uid = pExec->pExecReader->msgIter.uid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||
blockDataFreeRes(&block);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, pRsp, taosArrayGetSize(block.pDataBlock));
|
||||
tqAddBlockSchemaToRsp(pExec, workerId, pRsp);
|
||||
blockDataFreeRes(&block);
|
||||
tqAddBlockSchemaToRsp(pExec, pRsp);
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||
pRsp->withSchema = 1;
|
||||
STqReader* pReader = pExec->pExecReader[workerId];
|
||||
STqReader* pReader = pExec->pExecReader;
|
||||
tqReaderSetDataMsg(pReader, pReq, 0);
|
||||
while (tqNextDataBlockFilterOut(pReader, pExec->execDb.pFilterOutTbUid)) {
|
||||
SSDataBlock block = {0};
|
||||
|
@ -216,13 +229,15 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
|
|||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||
}
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pExecReader[workerId]->msgIter.uid;
|
||||
int64_t uid = pExec->pExecReader->msgIter.uid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) {
|
||||
blockDataFreeRes(&block);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, pRsp, taosArrayGetSize(block.pDataBlock));
|
||||
tqAddBlockSchemaToRsp(pExec, workerId, pRsp);
|
||||
blockDataFreeRes(&block);
|
||||
tqAddBlockSchemaToRsp(pExec, pRsp);
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,16 +43,12 @@ static int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tqExecKeyCompare(const void* pKey1, int32_t kLen1, const void* pKey2, int32_t kLen2) {
|
||||
return strcmp(pKey1, pKey2);
|
||||
}
|
||||
|
||||
int32_t tqMetaOpen(STQ* pTq) {
|
||||
if (tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaStore) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbTbOpen("handles", -1, -1, tqExecKeyCompare, pTq->pMetaStore, &pTq->pExecStore) < 0) {
|
||||
if (tdbTbOpen("handles", -1, -1, 0, pTq->pMetaStore, &pTq->pExecStore) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
@ -67,10 +63,10 @@ int32_t tqMetaOpen(STQ* pTq) {
|
|||
ASSERT(0);
|
||||
}
|
||||
|
||||
void* pKey;
|
||||
int kLen;
|
||||
void* pVal;
|
||||
int vLen;
|
||||
void* pKey = NULL;
|
||||
int kLen = 0;
|
||||
void* pVal = NULL;
|
||||
int vLen = 0;
|
||||
|
||||
tdbTbcMoveToFirst(pCur);
|
||||
SDecoder decoder;
|
||||
|
@ -80,11 +76,7 @@ int32_t tqMetaOpen(STQ* pTq) {
|
|||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
tDecodeSTqHandle(&decoder, &handle);
|
||||
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
||||
/*for (int32_t i = 0; i < 5; i++) {*/
|
||||
/*handle.execHandle.pExecReader[i] = tqOpenReader(pTq->pVnode);*/
|
||||
/*}*/
|
||||
if (handle.execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
SReadHandle reader = {
|
||||
.meta = pTq->pVnode->pMeta,
|
||||
.vnode = pTq->pVnode,
|
||||
|
@ -93,18 +85,19 @@ int32_t tqMetaOpen(STQ* pTq) {
|
|||
.version = handle.snapshotVer,
|
||||
};
|
||||
|
||||
handle.execHandle.execCol.task[i] = qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols);
|
||||
ASSERT(handle.execHandle.execCol.task[i]);
|
||||
handle.execHandle.execCol.task = qCreateQueueExecTaskInfo(
|
||||
handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols, &handle.execHandle.pSchemaWrapper);
|
||||
ASSERT(handle.execHandle.execCol.task);
|
||||
void* scanner = NULL;
|
||||
qExtractStreamScanner(handle.execHandle.execCol.task[i], &scanner);
|
||||
qExtractStreamScanner(handle.execHandle.execCol.task, &scanner);
|
||||
ASSERT(scanner);
|
||||
handle.execHandle.pExecReader[i] = qExtractReaderFromStreamScanner(scanner);
|
||||
ASSERT(handle.execHandle.pExecReader[i]);
|
||||
}
|
||||
handle.execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner);
|
||||
ASSERT(handle.execHandle.pExecReader);
|
||||
} else {
|
||||
handle.execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
}
|
||||
tqDebug("tq restore %s consumer %ld vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode));
|
||||
taosHashPut(pTq->handles, pKey, kLen, &handle, sizeof(STqHandle));
|
||||
}
|
||||
|
||||
|
@ -129,6 +122,9 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
|||
tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code);
|
||||
ASSERT(code == 0);
|
||||
|
||||
tqDebug("tq save %s(%d) consumer %ld vgId:%d", pHandle->subKey, strlen(pHandle->subKey), pHandle->consumerId,
|
||||
TD_VID(pTq->pVnode));
|
||||
|
||||
void* buf = taosMemoryCalloc(1, vlen);
|
||||
if (buf == NULL) {
|
||||
ASSERT(0);
|
||||
|
|
|
@ -249,6 +249,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
|||
return -1;
|
||||
}
|
||||
memcpy(data, msg, msgLen);
|
||||
SSubmitReq* pReq = (SSubmitReq*)data;
|
||||
pReq->version = ver;
|
||||
|
||||
tqProcessStreamTrigger(pTq, data);
|
||||
}
|
||||
|
|
|
@ -132,10 +132,12 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
|||
while (1) {
|
||||
if (!fromProcessedMsg) {
|
||||
if (walNextValidMsg(pReader->pWalReader) < 0) {
|
||||
pReader->ver = pReader->pWalReader->curVersion - pReader->pWalReader->curInvalid;
|
||||
pReader->ver =
|
||||
pReader->pWalReader->curVersion - (pReader->pWalReader->curInvalid | pReader->pWalReader->curStopped);
|
||||
ret->offset.type = TMQ_OFFSET__LOG;
|
||||
ret->offset.version = pReader->ver;
|
||||
ret->fetchType = FETCH_TYPE__NONE;
|
||||
tqDebug("return offset %ld, no more valid", ret->offset.version);
|
||||
ASSERT(ret->offset.version >= 0);
|
||||
return -1;
|
||||
}
|
||||
|
@ -167,6 +169,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
|
|||
ret->offset.version = pReader->ver;
|
||||
ASSERT(pReader->ver >= 0);
|
||||
ret->fetchType = FETCH_TYPE__NONE;
|
||||
tqDebug("return offset %ld, processed finish", ret->offset.version);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -314,6 +317,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
|||
|
||||
pBlock->info.uid = pReader->msgIter.uid;
|
||||
pBlock->info.rows = pReader->msgIter.numOfRows;
|
||||
pBlock->info.version = pReader->pMsg->version;
|
||||
|
||||
while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) {
|
||||
tdSTSRowIterReset(&iter, row);
|
||||
|
@ -339,29 +343,30 @@ FAIL:
|
|||
|
||||
void tqReaderSetColIdList(STqReader* pReadHandle, SArray* pColIdList) { pReadHandle->pColIdList = pColIdList; }
|
||||
|
||||
int tqReaderSetTbUidList(STqReader* pHandle, const SArray* tbUidList) {
|
||||
if (pHandle->tbIdHash) {
|
||||
taosHashClear(pHandle->tbIdHash);
|
||||
int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||
if (pReader->tbIdHash) {
|
||||
taosHashClear(pReader->tbIdHash);
|
||||
} else {
|
||||
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
}
|
||||
|
||||
pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (pHandle->tbIdHash == NULL) {
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
||||
taosHashPut(pHandle->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
||||
taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tqReaderAddTbUidList(STqReader* pHandle, const SArray* tbUidList) {
|
||||
if (pHandle->tbIdHash == NULL) {
|
||||
pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (pHandle->tbIdHash == NULL) {
|
||||
int tqReaderAddTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
@ -369,18 +374,18 @@ int tqReaderAddTbUidList(STqReader* pHandle, const SArray* tbUidList) {
|
|||
|
||||
for (int i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
||||
taosHashPut(pHandle->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
||||
taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tqReaderRemoveTbUidList(STqReader* pHandle, const SArray* tbUidList) {
|
||||
ASSERT(pHandle->tbIdHash != NULL);
|
||||
int tqReaderRemoveTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||
ASSERT(pReader->tbIdHash != NULL);
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
||||
taosHashRemove(pHandle->tbIdHash, pKey, sizeof(int64_t));
|
||||
taosHashRemove(pReader->tbIdHash, pKey, sizeof(int64_t));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -393,10 +398,8 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
|||
if (pIter == NULL) break;
|
||||
STqHandle* pExec = (STqHandle*)pIter;
|
||||
if (pExec->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
for (int32_t i = 0; i < 5; i++) {
|
||||
int32_t code = qUpdateQualifiedTableId(pExec->execHandle.execCol.task[i], tbUidList, isAdd);
|
||||
int32_t code = qUpdateQualifiedTableId(pExec->execHandle.execCol.task, tbUidList, isAdd);
|
||||
ASSERT(code == 0);
|
||||
}
|
||||
} else if (pExec->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||
if (!isAdd) {
|
||||
int32_t sz = taosArrayGetSize(tbUidList);
|
||||
|
|
|
@ -110,7 +110,6 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
|||
// TODO
|
||||
ret = rpcMallocCont(cap);
|
||||
ret->header.vgId = vgId;
|
||||
ret->version = htonl(1);
|
||||
ret->length = sizeof(SSubmitReq);
|
||||
ret->numOfBlocks = htonl(sz);
|
||||
|
||||
|
@ -127,6 +126,8 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
|
|||
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
|
||||
tqDebug("tq sink, convert block %d, rows: %d", i, rows);
|
||||
|
||||
int32_t dataLen = 0;
|
||||
|
||||
void* blkSchema = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk));
|
||||
|
@ -178,11 +179,14 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
|||
const SArray* pRes = (const SArray*)data;
|
||||
SVnode* pVnode = (SVnode*)vnode;
|
||||
|
||||
tqDebug("task write into table, vgId %d, block num: %d", pVnode->config.vgId, (int32_t)pRes->size);
|
||||
tqDebug("vgId:%d, task %d write into table, block num: %d", TD_VID(pVnode), pTask->taskId, (int32_t)pRes->size);
|
||||
|
||||
ASSERT(pTask->tbSink.pTSchema);
|
||||
SSubmitReq* pReq = tdBlockToSubmit(pRes, pTask->tbSink.pTSchema, true, pTask->tbSink.stbUid,
|
||||
pTask->tbSink.stbFullName, pVnode->config.vgId);
|
||||
|
||||
tqDebug("vgId:%d, task %d convert blocks over, put into write-queue", TD_VID(pVnode), pTask->taskId);
|
||||
|
||||
/*tPrintFixedSchemaSubmitReq(pReq, pTask->tbSink.pTSchema);*/
|
||||
// build write msg
|
||||
SRpcMsg msg = {
|
||||
|
|
|
@ -464,7 +464,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
|
|||
|
||||
switch (state->state) {
|
||||
case SFSNEXTROW_FS:
|
||||
state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet;
|
||||
// state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet;
|
||||
state->nFileSet = taosArrayGetSize(state->aDFileSet);
|
||||
state->iFileSet = state->nFileSet;
|
||||
|
||||
|
@ -793,8 +793,9 @@ typedef struct {
|
|||
TSDBROW memRow, imemRow, fsRow;
|
||||
|
||||
TsdbNextRowState input[3];
|
||||
SMemTable *pMemTable;
|
||||
SMemTable *pIMemTable;
|
||||
// SMemTable *pMemTable;
|
||||
// SMemTable *pIMemTable;
|
||||
STsdbReadSnap *pReadSnap;
|
||||
STsdb *pTsdb;
|
||||
} CacheNextRowIter;
|
||||
|
||||
|
@ -803,16 +804,16 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
|||
|
||||
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||
|
||||
tsdbTakeMemSnapshot(pTsdb, &pIter->pMemTable, &pIter->pIMemTable);
|
||||
tsdbTakeReadSnap(pTsdb, &pIter->pReadSnap);
|
||||
|
||||
STbData *pMem = NULL;
|
||||
if (pIter->pMemTable) {
|
||||
tsdbGetTbDataFromMemTable(pIter->pMemTable, suid, uid, &pMem);
|
||||
if (pIter->pReadSnap->pMem) {
|
||||
tsdbGetTbDataFromMemTable(pIter->pReadSnap->pMem, suid, uid, &pMem);
|
||||
}
|
||||
|
||||
STbData *pIMem = NULL;
|
||||
if (pIter->pIMemTable) {
|
||||
tsdbGetTbDataFromMemTable(pIter->pIMemTable, suid, uid, &pIMem);
|
||||
if (pIter->pReadSnap->pIMem) {
|
||||
tsdbGetTbDataFromMemTable(pIter->pReadSnap->pIMem, suid, uid, &pIMem);
|
||||
}
|
||||
|
||||
pIter->pTsdb = pTsdb;
|
||||
|
@ -821,7 +822,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
|||
|
||||
SDelIdx delIdx;
|
||||
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
SDelFile *pDelFile = pIter->pReadSnap->fs.pDelFile;
|
||||
if (pDelFile) {
|
||||
SDelFReader *pDelFReader;
|
||||
|
||||
|
@ -846,6 +847,7 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
|
|||
|
||||
pIter->fsState.state = SFSNEXTROW_FS;
|
||||
pIter->fsState.pTsdb = pTsdb;
|
||||
pIter->fsState.aDFileSet = pIter->pReadSnap->fs.aDFileSet;
|
||||
pIter->fsState.pBlockIdxExp = &pIter->idx;
|
||||
|
||||
pIter->input[0] = (TsdbNextRowState){&pIter->memRow, true, false, &pIter->memState, getNextRowFromMem, NULL};
|
||||
|
@ -885,7 +887,7 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) {
|
|||
taosArrayDestroy(pIter->pSkyline);
|
||||
}
|
||||
|
||||
tsdbUntakeMemSnapshot(pIter->pTsdb, pIter->pMemTable, pIter->pIMemTable);
|
||||
tsdbUntakeReadSnap(pIter->pTsdb, pIter->pReadSnap);
|
||||
|
||||
return code;
|
||||
_err:
|
||||
|
@ -1172,480 +1174,480 @@ _err:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) {
|
||||
int32_t code = 0;
|
||||
SArray *pSkyline = NULL;
|
||||
// static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRow) {
|
||||
// int32_t code = 0;
|
||||
// SArray *pSkyline = NULL;
|
||||
|
||||
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);
|
||||
int16_t nCol = pTSchema->numOfCols;
|
||||
SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
||||
// STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);
|
||||
// int16_t nCol = pTSchema->numOfCols;
|
||||
// SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
||||
|
||||
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||
|
||||
STbData *pMem = NULL;
|
||||
if (pTsdb->mem) {
|
||||
tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
||||
}
|
||||
// STbData *pMem = NULL;
|
||||
// if (pTsdb->mem) {
|
||||
// tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
||||
// }
|
||||
|
||||
STbData *pIMem = NULL;
|
||||
if (pTsdb->imem) {
|
||||
tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
||||
}
|
||||
// STbData *pIMem = NULL;
|
||||
// if (pTsdb->imem) {
|
||||
// tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
||||
// }
|
||||
|
||||
*ppRow = NULL;
|
||||
// *ppRow = NULL;
|
||||
|
||||
pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||
// pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||
|
||||
SDelIdx delIdx;
|
||||
// SDelIdx delIdx;
|
||||
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
if (pDelFile) {
|
||||
SDelFReader *pDelFReader;
|
||||
// SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
// if (pDelFile) {
|
||||
// SDelFReader *pDelFReader;
|
||||
|
||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||
if (code) goto _err;
|
||||
// code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||
// if (code) goto _err;
|
||||
|
||||
code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
|
||||
if (code) goto _err;
|
||||
// code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
|
||||
// if (code) goto _err;
|
||||
|
||||
code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline);
|
||||
if (code) goto _err;
|
||||
// code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline);
|
||||
// if (code) goto _err;
|
||||
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
} else {
|
||||
code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline);
|
||||
if (code) goto _err;
|
||||
}
|
||||
// tsdbDelFReaderClose(&pDelFReader);
|
||||
// } else {
|
||||
// code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline);
|
||||
// if (code) goto _err;
|
||||
// }
|
||||
|
||||
int64_t iSkyline = taosArrayGetSize(pSkyline) - 1;
|
||||
// int64_t iSkyline = taosArrayGetSize(pSkyline) - 1;
|
||||
|
||||
SBlockIdx idx = {.suid = suid, .uid = uid};
|
||||
// SBlockIdx idx = {.suid = suid, .uid = uid};
|
||||
|
||||
SFSNextRowIter fsState = {0};
|
||||
fsState.state = SFSNEXTROW_FS;
|
||||
fsState.pTsdb = pTsdb;
|
||||
fsState.pBlockIdxExp = &idx;
|
||||
// SFSNextRowIter fsState = {0};
|
||||
// fsState.state = SFSNEXTROW_FS;
|
||||
// fsState.pTsdb = pTsdb;
|
||||
// fsState.pBlockIdxExp = &idx;
|
||||
|
||||
SMemNextRowIter memState = {0};
|
||||
SMemNextRowIter imemState = {0};
|
||||
TSDBROW memRow, imemRow, fsRow;
|
||||
// SMemNextRowIter memState = {0};
|
||||
// SMemNextRowIter imemState = {0};
|
||||
// TSDBROW memRow, imemRow, fsRow;
|
||||
|
||||
TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL},
|
||||
{&imemRow, true, false, &imemState, getNextRowFromMem, NULL},
|
||||
{&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}};
|
||||
// TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL},
|
||||
// {&imemRow, true, false, &imemState, getNextRowFromMem, NULL},
|
||||
// {&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}};
|
||||
|
||||
if (pMem) {
|
||||
memState.pMem = pMem;
|
||||
memState.state = SMEMNEXTROW_ENTER;
|
||||
input[0].stop = false;
|
||||
input[0].next = true;
|
||||
}
|
||||
if (pIMem) {
|
||||
imemState.pMem = pIMem;
|
||||
imemState.state = SMEMNEXTROW_ENTER;
|
||||
input[1].stop = false;
|
||||
input[1].next = true;
|
||||
}
|
||||
// if (pMem) {
|
||||
// memState.pMem = pMem;
|
||||
// memState.state = SMEMNEXTROW_ENTER;
|
||||
// input[0].stop = false;
|
||||
// input[0].next = true;
|
||||
// }
|
||||
// if (pIMem) {
|
||||
// imemState.pMem = pIMem;
|
||||
// imemState.state = SMEMNEXTROW_ENTER;
|
||||
// input[1].stop = false;
|
||||
// input[1].next = true;
|
||||
// }
|
||||
|
||||
int16_t nilColCount = nCol - 1; // count of null & none cols
|
||||
int iCol = 0; // index of first nil col index from left to right
|
||||
bool setICol = false;
|
||||
// int16_t nilColCount = nCol - 1; // count of null & none cols
|
||||
// int iCol = 0; // index of first nil col index from left to right
|
||||
// bool setICol = false;
|
||||
|
||||
do {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (input[i].next && !input[i].stop) {
|
||||
if (input[i].pRow == NULL) {
|
||||
code = input[i].nextRowFn(input[i].iter, &input[i].pRow);
|
||||
if (code) goto _err;
|
||||
// do {
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (input[i].next && !input[i].stop) {
|
||||
// if (input[i].pRow == NULL) {
|
||||
// code = input[i].nextRowFn(input[i].iter, &input[i].pRow);
|
||||
// if (code) goto _err;
|
||||
|
||||
if (input[i].pRow == NULL) {
|
||||
input[i].stop = true;
|
||||
input[i].next = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (input[i].pRow == NULL) {
|
||||
// input[i].stop = true;
|
||||
// input[i].next = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (input[0].stop && input[1].stop && input[2].stop) {
|
||||
break;
|
||||
}
|
||||
// if (input[0].stop && input[1].stop && input[2].stop) {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// select maxpoint(s) from mem, imem, fs
|
||||
TSDBROW *max[3] = {0};
|
||||
int iMax[3] = {-1, -1, -1};
|
||||
int nMax = 0;
|
||||
TSKEY maxKey = TSKEY_MIN;
|
||||
// // select maxpoint(s) from mem, imem, fs
|
||||
// TSDBROW *max[3] = {0};
|
||||
// int iMax[3] = {-1, -1, -1};
|
||||
// int nMax = 0;
|
||||
// TSKEY maxKey = TSKEY_MIN;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (!input[i].stop && input[i].pRow != NULL) {
|
||||
TSDBKEY key = TSDBROW_KEY(input[i].pRow);
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (!input[i].stop && input[i].pRow != NULL) {
|
||||
// TSDBKEY key = TSDBROW_KEY(input[i].pRow);
|
||||
|
||||
// merging & deduplicating on client side
|
||||
if (maxKey <= key.ts) {
|
||||
if (maxKey < key.ts) {
|
||||
nMax = 0;
|
||||
maxKey = key.ts;
|
||||
}
|
||||
// // merging & deduplicating on client side
|
||||
// if (maxKey <= key.ts) {
|
||||
// if (maxKey < key.ts) {
|
||||
// nMax = 0;
|
||||
// maxKey = key.ts;
|
||||
// }
|
||||
|
||||
iMax[nMax] = i;
|
||||
max[nMax++] = input[i].pRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
// iMax[nMax] = i;
|
||||
// max[nMax++] = input[i].pRow;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// delete detection
|
||||
TSDBROW *merge[3] = {0};
|
||||
int iMerge[3] = {-1, -1, -1};
|
||||
int nMerge = 0;
|
||||
for (int i = 0; i < nMax; ++i) {
|
||||
TSDBKEY maxKey = TSDBROW_KEY(max[i]);
|
||||
// // delete detection
|
||||
// TSDBROW *merge[3] = {0};
|
||||
// int iMerge[3] = {-1, -1, -1};
|
||||
// int nMerge = 0;
|
||||
// for (int i = 0; i < nMax; ++i) {
|
||||
// TSDBKEY maxKey = TSDBROW_KEY(max[i]);
|
||||
|
||||
bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline);
|
||||
if (!deleted) {
|
||||
iMerge[nMerge] = i;
|
||||
merge[nMerge++] = max[i];
|
||||
}
|
||||
// bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline);
|
||||
// if (!deleted) {
|
||||
// iMerge[nMerge] = i;
|
||||
// merge[nMerge++] = max[i];
|
||||
// }
|
||||
|
||||
input[iMax[i]].next = deleted;
|
||||
}
|
||||
// input[iMax[i]].next = deleted;
|
||||
// }
|
||||
|
||||
// merge if nMerge > 1
|
||||
if (nMerge > 0) {
|
||||
*dup = false;
|
||||
// // merge if nMerge > 1
|
||||
// if (nMerge > 0) {
|
||||
// *dup = false;
|
||||
|
||||
if (nMerge == 1) {
|
||||
code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow);
|
||||
if (code) goto _err;
|
||||
} else {
|
||||
// merge 2 or 3 rows
|
||||
SRowMerger merger = {0};
|
||||
// if (nMerge == 1) {
|
||||
// code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow);
|
||||
// if (code) goto _err;
|
||||
// } else {
|
||||
// // merge 2 or 3 rows
|
||||
// SRowMerger merger = {0};
|
||||
|
||||
tRowMergerInit(&merger, merge[0], pTSchema);
|
||||
for (int i = 1; i < nMerge; ++i) {
|
||||
tRowMerge(&merger, merge[i]);
|
||||
}
|
||||
tRowMergerGetRow(&merger, ppRow);
|
||||
tRowMergerClear(&merger);
|
||||
}
|
||||
}
|
||||
// tRowMergerInit(&merger, merge[0], pTSchema);
|
||||
// for (int i = 1; i < nMerge; ++i) {
|
||||
// tRowMerge(&merger, merge[i]);
|
||||
// }
|
||||
// tRowMergerGetRow(&merger, ppRow);
|
||||
// tRowMergerClear(&merger);
|
||||
// }
|
||||
// }
|
||||
|
||||
} while (1);
|
||||
// } while (1);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (input[i].nextRowClearFn) {
|
||||
input[i].nextRowClearFn(input[i].iter);
|
||||
}
|
||||
}
|
||||
if (pSkyline) {
|
||||
taosArrayDestroy(pSkyline);
|
||||
}
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (input[i].nextRowClearFn) {
|
||||
// input[i].nextRowClearFn(input[i].iter);
|
||||
// }
|
||||
// }
|
||||
// if (pSkyline) {
|
||||
// taosArrayDestroy(pSkyline);
|
||||
// }
|
||||
// taosMemoryFreeClear(pTSchema);
|
||||
|
||||
return code;
|
||||
_err:
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (input[i].nextRowClearFn) {
|
||||
input[i].nextRowClearFn(input[i].iter);
|
||||
}
|
||||
}
|
||||
if (pSkyline) {
|
||||
taosArrayDestroy(pSkyline);
|
||||
}
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
// return code;
|
||||
// _err:
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (input[i].nextRowClearFn) {
|
||||
// input[i].nextRowClearFn(input[i].iter);
|
||||
// }
|
||||
// }
|
||||
// if (pSkyline) {
|
||||
// taosArrayDestroy(pSkyline);
|
||||
// }
|
||||
// taosMemoryFreeClear(pTSchema);
|
||||
// tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
// return code;
|
||||
// }
|
||||
|
||||
// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) {
|
||||
static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||
int32_t code = 0;
|
||||
SArray *pSkyline = NULL;
|
||||
STSRow *pRow = NULL;
|
||||
STSRow **ppRow = &pRow;
|
||||
// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
|
||||
// int32_t code = 0;
|
||||
// SArray *pSkyline = NULL;
|
||||
// STSRow *pRow = NULL;
|
||||
// STSRow **ppRow = &pRow;
|
||||
|
||||
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);
|
||||
int16_t nCol = pTSchema->numOfCols;
|
||||
// SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
||||
SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol));
|
||||
// STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);
|
||||
// int16_t nCol = pTSchema->numOfCols;
|
||||
// // SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
||||
// SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol));
|
||||
|
||||
tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
|
||||
|
||||
STbData *pMem = NULL;
|
||||
if (pTsdb->mem) {
|
||||
tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
||||
}
|
||||
// STbData *pMem = NULL;
|
||||
// if (pTsdb->mem) {
|
||||
// tsdbGetTbDataFromMemTable(pTsdb->mem, suid, uid, &pMem);
|
||||
// }
|
||||
|
||||
STbData *pIMem = NULL;
|
||||
if (pTsdb->imem) {
|
||||
tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
||||
}
|
||||
// STbData *pIMem = NULL;
|
||||
// if (pTsdb->imem) {
|
||||
// tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem);
|
||||
// }
|
||||
|
||||
*ppLastArray = NULL;
|
||||
// *ppLastArray = NULL;
|
||||
|
||||
pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||
// pSkyline = taosArrayInit(32, sizeof(TSDBKEY));
|
||||
|
||||
SDelIdx delIdx;
|
||||
// SDelIdx delIdx;
|
||||
|
||||
SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
if (pDelFile) {
|
||||
SDelFReader *pDelFReader;
|
||||
// SDelFile *pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
// if (pDelFile) {
|
||||
// SDelFReader *pDelFReader;
|
||||
|
||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||
if (code) goto _err;
|
||||
// code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||
// if (code) goto _err;
|
||||
|
||||
code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
|
||||
if (code) goto _err;
|
||||
// code = getTableDelIdx(pDelFReader, suid, uid, &delIdx);
|
||||
// if (code) goto _err;
|
||||
|
||||
code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline);
|
||||
if (code) goto _err;
|
||||
// code = getTableDelSkyline(pMem, pIMem, pDelFReader, &delIdx, pSkyline);
|
||||
// if (code) goto _err;
|
||||
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
} else {
|
||||
code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline);
|
||||
if (code) goto _err;
|
||||
}
|
||||
// tsdbDelFReaderClose(&pDelFReader);
|
||||
// } else {
|
||||
// code = getTableDelSkyline(pMem, pIMem, NULL, NULL, pSkyline);
|
||||
// if (code) goto _err;
|
||||
// }
|
||||
|
||||
int64_t iSkyline = taosArrayGetSize(pSkyline) - 1;
|
||||
// int64_t iSkyline = taosArrayGetSize(pSkyline) - 1;
|
||||
|
||||
SBlockIdx idx = {.suid = suid, .uid = uid};
|
||||
// SBlockIdx idx = {.suid = suid, .uid = uid};
|
||||
|
||||
SFSNextRowIter fsState = {0};
|
||||
fsState.state = SFSNEXTROW_FS;
|
||||
fsState.pTsdb = pTsdb;
|
||||
fsState.pBlockIdxExp = &idx;
|
||||
// SFSNextRowIter fsState = {0};
|
||||
// fsState.state = SFSNEXTROW_FS;
|
||||
// fsState.pTsdb = pTsdb;
|
||||
// fsState.pBlockIdxExp = &idx;
|
||||
|
||||
SMemNextRowIter memState = {0};
|
||||
SMemNextRowIter imemState = {0};
|
||||
TSDBROW memRow, imemRow, fsRow;
|
||||
// SMemNextRowIter memState = {0};
|
||||
// SMemNextRowIter imemState = {0};
|
||||
// TSDBROW memRow, imemRow, fsRow;
|
||||
|
||||
TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL},
|
||||
{&imemRow, true, false, &imemState, getNextRowFromMem, NULL},
|
||||
{&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}};
|
||||
// TsdbNextRowState input[3] = {{&memRow, true, false, &memState, getNextRowFromMem, NULL},
|
||||
// {&imemRow, true, false, &imemState, getNextRowFromMem, NULL},
|
||||
// {&fsRow, false, true, &fsState, getNextRowFromFS, clearNextRowFromFS}};
|
||||
|
||||
if (pMem) {
|
||||
memState.pMem = pMem;
|
||||
memState.state = SMEMNEXTROW_ENTER;
|
||||
input[0].stop = false;
|
||||
input[0].next = true;
|
||||
}
|
||||
if (pIMem) {
|
||||
imemState.pMem = pIMem;
|
||||
imemState.state = SMEMNEXTROW_ENTER;
|
||||
input[1].stop = false;
|
||||
input[1].next = true;
|
||||
}
|
||||
// if (pMem) {
|
||||
// memState.pMem = pMem;
|
||||
// memState.state = SMEMNEXTROW_ENTER;
|
||||
// input[0].stop = false;
|
||||
// input[0].next = true;
|
||||
// }
|
||||
// if (pIMem) {
|
||||
// imemState.pMem = pIMem;
|
||||
// imemState.state = SMEMNEXTROW_ENTER;
|
||||
// input[1].stop = false;
|
||||
// input[1].next = true;
|
||||
// }
|
||||
|
||||
int16_t nilColCount = nCol - 1; // count of null & none cols
|
||||
int iCol = 0; // index of first nil col index from left to right
|
||||
bool setICol = false;
|
||||
// int16_t nilColCount = nCol - 1; // count of null & none cols
|
||||
// int iCol = 0; // index of first nil col index from left to right
|
||||
// bool setICol = false;
|
||||
|
||||
do {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (input[i].next && !input[i].stop) {
|
||||
code = input[i].nextRowFn(input[i].iter, &input[i].pRow);
|
||||
if (code) goto _err;
|
||||
// do {
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (input[i].next && !input[i].stop) {
|
||||
// code = input[i].nextRowFn(input[i].iter, &input[i].pRow);
|
||||
// if (code) goto _err;
|
||||
|
||||
if (input[i].pRow == NULL) {
|
||||
input[i].stop = true;
|
||||
input[i].next = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (input[i].pRow == NULL) {
|
||||
// input[i].stop = true;
|
||||
// input[i].next = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (input[0].stop && input[1].stop && input[2].stop) {
|
||||
break;
|
||||
}
|
||||
// if (input[0].stop && input[1].stop && input[2].stop) {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// select maxpoint(s) from mem, imem, fs
|
||||
TSDBROW *max[3] = {0};
|
||||
int iMax[3] = {-1, -1, -1};
|
||||
int nMax = 0;
|
||||
TSKEY maxKey = TSKEY_MIN;
|
||||
// // select maxpoint(s) from mem, imem, fs
|
||||
// TSDBROW *max[3] = {0};
|
||||
// int iMax[3] = {-1, -1, -1};
|
||||
// int nMax = 0;
|
||||
// TSKEY maxKey = TSKEY_MIN;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (!input[i].stop && input[i].pRow != NULL) {
|
||||
TSDBKEY key = TSDBROW_KEY(input[i].pRow);
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (!input[i].stop && input[i].pRow != NULL) {
|
||||
// TSDBKEY key = TSDBROW_KEY(input[i].pRow);
|
||||
|
||||
// merging & deduplicating on client side
|
||||
if (maxKey <= key.ts) {
|
||||
if (maxKey < key.ts) {
|
||||
nMax = 0;
|
||||
maxKey = key.ts;
|
||||
}
|
||||
// // merging & deduplicating on client side
|
||||
// if (maxKey <= key.ts) {
|
||||
// if (maxKey < key.ts) {
|
||||
// nMax = 0;
|
||||
// maxKey = key.ts;
|
||||
// }
|
||||
|
||||
iMax[nMax] = i;
|
||||
max[nMax++] = input[i].pRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
// iMax[nMax] = i;
|
||||
// max[nMax++] = input[i].pRow;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// delete detection
|
||||
TSDBROW *merge[3] = {0};
|
||||
int iMerge[3] = {-1, -1, -1};
|
||||
int nMerge = 0;
|
||||
for (int i = 0; i < nMax; ++i) {
|
||||
TSDBKEY maxKey = TSDBROW_KEY(max[i]);
|
||||
// // delete detection
|
||||
// TSDBROW *merge[3] = {0};
|
||||
// int iMerge[3] = {-1, -1, -1};
|
||||
// int nMerge = 0;
|
||||
// for (int i = 0; i < nMax; ++i) {
|
||||
// TSDBKEY maxKey = TSDBROW_KEY(max[i]);
|
||||
|
||||
bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline);
|
||||
if (!deleted) {
|
||||
iMerge[nMerge] = iMax[i];
|
||||
merge[nMerge++] = max[i];
|
||||
}
|
||||
// bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline);
|
||||
// if (!deleted) {
|
||||
// iMerge[nMerge] = iMax[i];
|
||||
// merge[nMerge++] = max[i];
|
||||
// }
|
||||
|
||||
input[iMax[i]].next = deleted;
|
||||
}
|
||||
// input[iMax[i]].next = deleted;
|
||||
// }
|
||||
|
||||
// merge if nMerge > 1
|
||||
if (nMerge > 0) {
|
||||
if (nMerge == 1) {
|
||||
code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow);
|
||||
if (code) goto _err;
|
||||
} else {
|
||||
// merge 2 or 3 rows
|
||||
SRowMerger merger = {0};
|
||||
// // merge if nMerge > 1
|
||||
// if (nMerge > 0) {
|
||||
// if (nMerge == 1) {
|
||||
// code = tsRowFromTsdbRow(pTSchema, merge[nMerge - 1], ppRow);
|
||||
// if (code) goto _err;
|
||||
// } else {
|
||||
// // merge 2 or 3 rows
|
||||
// SRowMerger merger = {0};
|
||||
|
||||
tRowMergerInit(&merger, merge[0], pTSchema);
|
||||
for (int i = 1; i < nMerge; ++i) {
|
||||
tRowMerge(&merger, merge[i]);
|
||||
}
|
||||
tRowMergerGetRow(&merger, ppRow);
|
||||
tRowMergerClear(&merger);
|
||||
}
|
||||
} else {
|
||||
/* *ppRow = NULL; */
|
||||
/* return code; */
|
||||
continue;
|
||||
}
|
||||
// tRowMergerInit(&merger, merge[0], pTSchema);
|
||||
// for (int i = 1; i < nMerge; ++i) {
|
||||
// tRowMerge(&merger, merge[i]);
|
||||
// }
|
||||
// tRowMergerGetRow(&merger, ppRow);
|
||||
// tRowMergerClear(&merger);
|
||||
// }
|
||||
// } else {
|
||||
// /* *ppRow = NULL; */
|
||||
// /* return code; */
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (iCol == 0) {
|
||||
STColumn *pTColumn = &pTSchema->columns[0];
|
||||
SColVal *pColVal = &(SColVal){0};
|
||||
// if (iCol == 0) {
|
||||
// STColumn *pTColumn = &pTSchema->columns[0];
|
||||
// SColVal *pColVal = &(SColVal){0};
|
||||
|
||||
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = maxKey});
|
||||
// *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = maxKey});
|
||||
|
||||
// if (taosArrayPush(pColArray, pColVal) == NULL) {
|
||||
if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
// // if (taosArrayPush(pColArray, pColVal) == NULL) {
|
||||
// if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) {
|
||||
// code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
// goto _err;
|
||||
// }
|
||||
|
||||
++iCol;
|
||||
// ++iCol;
|
||||
|
||||
setICol = false;
|
||||
for (int16_t i = iCol; i < nCol; ++i) {
|
||||
// tsdbRowGetColVal(*ppRow, pTSchema, i, pColVal);
|
||||
tTSRowGetVal(*ppRow, pTSchema, i, pColVal);
|
||||
// if (taosArrayPush(pColArray, pColVal) == NULL) {
|
||||
if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
// setICol = false;
|
||||
// for (int16_t i = iCol; i < nCol; ++i) {
|
||||
// // tsdbRowGetColVal(*ppRow, pTSchema, i, pColVal);
|
||||
// tTSRowGetVal(*ppRow, pTSchema, i, pColVal);
|
||||
// // if (taosArrayPush(pColArray, pColVal) == NULL) {
|
||||
// if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) {
|
||||
// code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
// goto _err;
|
||||
// }
|
||||
|
||||
if (pColVal->isNull || pColVal->isNone) {
|
||||
for (int j = 0; j < nMerge; ++j) {
|
||||
SColVal jColVal = {0};
|
||||
tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal);
|
||||
if (jColVal.isNull || jColVal.isNone) {
|
||||
input[iMerge[j]].next = true;
|
||||
}
|
||||
}
|
||||
if (!setICol) {
|
||||
iCol = i;
|
||||
setICol = true;
|
||||
}
|
||||
} else {
|
||||
--nilColCount;
|
||||
}
|
||||
}
|
||||
// if (pColVal->isNull || pColVal->isNone) {
|
||||
// for (int j = 0; j < nMerge; ++j) {
|
||||
// SColVal jColVal = {0};
|
||||
// tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal);
|
||||
// if (jColVal.isNull || jColVal.isNone) {
|
||||
// input[iMerge[j]].next = true;
|
||||
// }
|
||||
// }
|
||||
// if (!setICol) {
|
||||
// iCol = i;
|
||||
// setICol = true;
|
||||
// }
|
||||
// } else {
|
||||
// --nilColCount;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (*ppRow) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
// if (*ppRow) {
|
||||
// taosMemoryFreeClear(*ppRow);
|
||||
// }
|
||||
|
||||
continue;
|
||||
}
|
||||
// continue;
|
||||
// }
|
||||
|
||||
setICol = false;
|
||||
for (int16_t i = iCol; i < nCol; ++i) {
|
||||
SColVal colVal = {0};
|
||||
tTSRowGetVal(*ppRow, pTSchema, i, &colVal);
|
||||
TSKEY rowTs = (*ppRow)->ts;
|
||||
// setICol = false;
|
||||
// for (int16_t i = iCol; i < nCol; ++i) {
|
||||
// SColVal colVal = {0};
|
||||
// tTSRowGetVal(*ppRow, pTSchema, i, &colVal);
|
||||
// TSKEY rowTs = (*ppRow)->ts;
|
||||
|
||||
// SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, i);
|
||||
SLastCol *tTsVal = (SLastCol *)taosArrayGet(pColArray, i);
|
||||
SColVal *tColVal = &tTsVal->colVal;
|
||||
// // SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, i);
|
||||
// SLastCol *tTsVal = (SLastCol *)taosArrayGet(pColArray, i);
|
||||
// SColVal *tColVal = &tTsVal->colVal;
|
||||
|
||||
if (!colVal.isNone && !colVal.isNull) {
|
||||
if (tColVal->isNull || tColVal->isNone) {
|
||||
// taosArraySet(pColArray, i, &colVal);
|
||||
taosArraySet(pColArray, i, &(SLastCol){.ts = rowTs, .colVal = colVal});
|
||||
--nilColCount;
|
||||
}
|
||||
} else {
|
||||
if ((tColVal->isNull || tColVal->isNone) && !setICol) {
|
||||
iCol = i;
|
||||
setICol = true;
|
||||
// if (!colVal.isNone && !colVal.isNull) {
|
||||
// if (tColVal->isNull || tColVal->isNone) {
|
||||
// // taosArraySet(pColArray, i, &colVal);
|
||||
// taosArraySet(pColArray, i, &(SLastCol){.ts = rowTs, .colVal = colVal});
|
||||
// --nilColCount;
|
||||
// }
|
||||
// } else {
|
||||
// if ((tColVal->isNull || tColVal->isNone) && !setICol) {
|
||||
// iCol = i;
|
||||
// setICol = true;
|
||||
|
||||
for (int j = 0; j < nMerge; ++j) {
|
||||
SColVal jColVal = {0};
|
||||
tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal);
|
||||
if (jColVal.isNull || jColVal.isNone) {
|
||||
input[iMerge[j]].next = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (int j = 0; j < nMerge; ++j) {
|
||||
// SColVal jColVal = {0};
|
||||
// tsdbRowGetColVal(merge[j], pTSchema, i, &jColVal);
|
||||
// if (jColVal.isNull || jColVal.isNone) {
|
||||
// input[iMerge[j]].next = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (*ppRow) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
} while (nilColCount > 0);
|
||||
// if (*ppRow) {
|
||||
// taosMemoryFreeClear(*ppRow);
|
||||
// }
|
||||
// } while (nilColCount > 0);
|
||||
|
||||
// if () new ts row from pColArray if non empty
|
||||
/* if (taosArrayGetSize(pColArray) == nCol) { */
|
||||
/* code = tdSTSRowNew(pColArray, pTSchema, ppRow); */
|
||||
/* if (code) goto _err; */
|
||||
/* } */
|
||||
/* taosArrayDestroy(pColArray); */
|
||||
if (taosArrayGetSize(pColArray) <= 0) {
|
||||
*ppLastArray = NULL;
|
||||
taosArrayDestroy(pColArray);
|
||||
} else {
|
||||
*ppLastArray = pColArray;
|
||||
}
|
||||
if (*ppRow) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
// // if () new ts row from pColArray if non empty
|
||||
// /* if (taosArrayGetSize(pColArray) == nCol) { */
|
||||
// /* code = tdSTSRowNew(pColArray, pTSchema, ppRow); */
|
||||
// /* if (code) goto _err; */
|
||||
// /* } */
|
||||
// /* taosArrayDestroy(pColArray); */
|
||||
// if (taosArrayGetSize(pColArray) <= 0) {
|
||||
// *ppLastArray = NULL;
|
||||
// taosArrayDestroy(pColArray);
|
||||
// } else {
|
||||
// *ppLastArray = pColArray;
|
||||
// }
|
||||
// if (*ppRow) {
|
||||
// taosMemoryFreeClear(*ppRow);
|
||||
// }
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (input[i].nextRowClearFn) {
|
||||
input[i].nextRowClearFn(input[i].iter);
|
||||
}
|
||||
}
|
||||
if (pSkyline) {
|
||||
taosArrayDestroy(pSkyline);
|
||||
}
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (input[i].nextRowClearFn) {
|
||||
// input[i].nextRowClearFn(input[i].iter);
|
||||
// }
|
||||
// }
|
||||
// if (pSkyline) {
|
||||
// taosArrayDestroy(pSkyline);
|
||||
// }
|
||||
// taosMemoryFreeClear(pTSchema);
|
||||
|
||||
return code;
|
||||
_err:
|
||||
taosArrayDestroy(pColArray);
|
||||
if (*ppRow) {
|
||||
taosMemoryFreeClear(*ppRow);
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (input[i].nextRowClearFn) {
|
||||
input[i].nextRowClearFn(input[i].iter);
|
||||
}
|
||||
}
|
||||
if (pSkyline) {
|
||||
taosArrayDestroy(pSkyline);
|
||||
}
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
// return code;
|
||||
// _err:
|
||||
// taosArrayDestroy(pColArray);
|
||||
// if (*ppRow) {
|
||||
// taosMemoryFreeClear(*ppRow);
|
||||
// }
|
||||
// for (int i = 0; i < 3; ++i) {
|
||||
// if (input[i].nextRowClearFn) {
|
||||
// input[i].nextRowClearFn(input[i].iter);
|
||||
// }
|
||||
// }
|
||||
// if (pSkyline) {
|
||||
// taosArrayDestroy(pSkyline);
|
||||
// }
|
||||
// taosMemoryFreeClear(pTSchema);
|
||||
// tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
// return code;
|
||||
// }
|
||||
|
||||
int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHandle **handle) {
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct {
|
|||
int32_t minRow;
|
||||
int32_t maxRow;
|
||||
int8_t cmprAlg;
|
||||
STsdbFS fs;
|
||||
// --------------
|
||||
TSKEY nextKey; // reset by each table commit
|
||||
int32_t commitFid;
|
||||
|
@ -119,9 +120,6 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
|||
code = tsdbCommitDel(&commith);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbCommitCache(&commith);
|
||||
if (code) goto _err;
|
||||
|
||||
// end commit
|
||||
code = tsdbEndCommit(&commith, 0);
|
||||
if (code) goto _err;
|
||||
|
@ -158,7 +156,7 @@ static int32_t tsdbCommitDelStart(SCommitter *pCommitter) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
SDelFile *pDelFileR = pTsdb->pFS->nState->pDelFile;
|
||||
SDelFile *pDelFileR = pCommitter->fs.pDelFile;
|
||||
if (pDelFileR) {
|
||||
code = tsdbDelFReaderOpen(&pCommitter->pDelFReader, pDelFileR, pTsdb, NULL);
|
||||
if (code) goto _err;
|
||||
|
@ -247,7 +245,7 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
|
|||
code = tsdbUpdateDelFileHdr(pCommitter->pDelFWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pCommitter->pDelFWriter->fDel);
|
||||
code = tsdbFSUpsertDelFile(&pCommitter->fs, &pCommitter->pDelFWriter->fDel);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbDelFWriterClose(&pCommitter->pDelFWriter, 1);
|
||||
|
@ -273,7 +271,6 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
int32_t code = 0;
|
||||
STsdb *pTsdb = pCommitter->pTsdb;
|
||||
SDFileSet *pRSet = NULL;
|
||||
SDFileSet wSet;
|
||||
|
||||
// memory
|
||||
pCommitter->nextKey = TSKEY_MAX;
|
||||
|
@ -282,7 +279,8 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
taosArrayClear(pCommitter->aBlockIdx);
|
||||
tMapDataReset(&pCommitter->oBlockMap);
|
||||
tBlockDataReset(&pCommitter->oBlockData);
|
||||
pRSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, pCommitter->commitFid, TD_EQ);
|
||||
pRSet = (SDFileSet *)taosArraySearch(pCommitter->fs.aDFileSet, &(SDFileSet){.fid = pCommitter->commitFid},
|
||||
tDFileSetCmprFn, TD_EQ);
|
||||
if (pRSet) {
|
||||
code = tsdbDataFReaderOpen(&pCommitter->pReader, pTsdb, pRSet);
|
||||
if (code) goto _err;
|
||||
|
@ -292,23 +290,29 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
}
|
||||
|
||||
// new
|
||||
SHeadFile fHead;
|
||||
SDataFile fData;
|
||||
SLastFile fLast;
|
||||
SSmaFile fSma;
|
||||
SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma};
|
||||
|
||||
taosArrayClear(pCommitter->aBlockIdxN);
|
||||
tMapDataReset(&pCommitter->nBlockMap);
|
||||
tBlockDataReset(&pCommitter->nBlockData);
|
||||
if (pRSet) {
|
||||
wSet = (SDFileSet){.diskId = pRSet->diskId,
|
||||
.fid = pCommitter->commitFid,
|
||||
.fHead = {.commitID = pCommitter->commitID, .offset = 0, .size = 0},
|
||||
.fData = pRSet->fData,
|
||||
.fLast = {.commitID = pCommitter->commitID, .size = 0},
|
||||
.fSma = pRSet->fSma};
|
||||
wSet.diskId = pRSet->diskId;
|
||||
wSet.fid = pCommitter->commitFid;
|
||||
fHead = (SHeadFile){.commitID = pCommitter->commitID, .offset = 0, .size = 0};
|
||||
fData = *pRSet->pDataF;
|
||||
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0};
|
||||
fSma = *pRSet->pSmaF;
|
||||
} else {
|
||||
wSet = (SDFileSet){.diskId = (SDiskID){.level = 0, .id = 0},
|
||||
.fid = pCommitter->commitFid,
|
||||
.fHead = {.commitID = pCommitter->commitID, .offset = 0, .size = 0},
|
||||
.fData = {.commitID = pCommitter->commitID, .size = 0},
|
||||
.fLast = {.commitID = pCommitter->commitID, .size = 0},
|
||||
.fSma = {.commitID = pCommitter->commitID, .size = 0}};
|
||||
wSet.diskId = (SDiskID){.level = 0, .id = 0};
|
||||
wSet.fid = pCommitter->commitFid;
|
||||
fHead = (SHeadFile){.commitID = pCommitter->commitID, .offset = 0, .size = 0};
|
||||
fData = (SDataFile){.commitID = pCommitter->commitID, .size = 0};
|
||||
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0};
|
||||
fSma = (SSmaFile){.commitID = pCommitter->commitID, .size = 0};
|
||||
}
|
||||
code = tsdbDataFWriterOpen(&pCommitter->pWriter, pTsdb, &wSet);
|
||||
if (code) goto _err;
|
||||
|
@ -855,7 +859,7 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
|
|||
if (code) goto _err;
|
||||
|
||||
// upsert SDFileSet
|
||||
code = tsdbFSStateUpsertDFileSet(pCommitter->pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pCommitter->pWriter));
|
||||
code = tsdbFSUpsertFSet(&pCommitter->fs, &pCommitter->pWriter->wSet);
|
||||
if (code) goto _err;
|
||||
|
||||
// close and sync
|
||||
|
@ -973,7 +977,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
|||
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
||||
|
||||
code = tsdbFSBegin(pTsdb->pFS);
|
||||
code = tsdbFSCopy(pTsdb, &pCommitter->fs);
|
||||
if (code) goto _err;
|
||||
|
||||
return code;
|
||||
|
@ -1142,28 +1146,33 @@ _err:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t tsdbCommitCache(SCommitter *pCommitter) {
|
||||
int32_t code = 0;
|
||||
// TODO
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) {
|
||||
int32_t code = 0;
|
||||
STsdb *pTsdb = pCommitter->pTsdb;
|
||||
SMemTable *pMemTable = pTsdb->imem;
|
||||
|
||||
if (eno == 0) {
|
||||
code = tsdbFSCommit(pTsdb->pFS);
|
||||
} else {
|
||||
code = tsdbFSRollback(pTsdb->pFS);
|
||||
ASSERT(eno == 0);
|
||||
|
||||
code = tsdbFSCommit1(pTsdb, &pCommitter->fs);
|
||||
if (code) goto _err;
|
||||
|
||||
// lock
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
|
||||
// commit or rollback
|
||||
code = tsdbFSCommit2(pTsdb, &pCommitter->fs);
|
||||
if (code) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
pTsdb->imem = NULL;
|
||||
|
||||
// unlock
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
tsdbUnrefMemTable(pMemTable);
|
||||
tsdbFSDestroy(&pCommitter->fs);
|
||||
|
||||
tsdbInfo("vgId:%d tsdb end commit", TD_VID(pTsdb->pVnode));
|
||||
return code;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "tsdb.h"
|
||||
|
||||
static int32_t tPutHeadFile(uint8_t *p, SHeadFile *pHeadFile) {
|
||||
int32_t tPutHeadFile(uint8_t *p, SHeadFile *pHeadFile) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI64v(p ? p + n : p, pHeadFile->commitID);
|
||||
|
@ -35,7 +35,7 @@ static int32_t tGetHeadFile(uint8_t *p, SHeadFile *pHeadFile) {
|
|||
return n;
|
||||
}
|
||||
|
||||
static int32_t tPutDataFile(uint8_t *p, SDataFile *pDataFile) {
|
||||
int32_t tPutDataFile(uint8_t *p, SDataFile *pDataFile) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI64v(p ? p + n : p, pDataFile->commitID);
|
||||
|
@ -53,7 +53,7 @@ static int32_t tGetDataFile(uint8_t *p, SDataFile *pDataFile) {
|
|||
return n;
|
||||
}
|
||||
|
||||
static int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile) {
|
||||
int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI64v(p ? p + n : p, pLastFile->commitID);
|
||||
|
@ -71,7 +71,7 @@ static int32_t tGetLastFile(uint8_t *p, SLastFile *pLastFile) {
|
|||
return n;
|
||||
}
|
||||
|
||||
static int32_t tPutSmaFile(uint8_t *p, SSmaFile *pSmaFile) {
|
||||
int32_t tPutSmaFile(uint8_t *p, SSmaFile *pSmaFile) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI64v(p ? p + n : p, pSmaFile->commitID);
|
||||
|
@ -90,90 +90,53 @@ static int32_t tGetSmaFile(uint8_t *p, SSmaFile *pSmaFile) {
|
|||
}
|
||||
|
||||
// EXPOSED APIS ==================================================
|
||||
void tsdbDataFileName(STsdb *pTsdb, SDFileSet *pDFileSet, EDataFileT ftype, char fname[]) {
|
||||
STfs *pTfs = pTsdb->pVnode->pTfs;
|
||||
|
||||
switch (ftype) {
|
||||
case TSDB_HEAD_FILE:
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTfs, pDFileSet->diskId),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), pDFileSet->fid, pDFileSet->fHead.commitID,
|
||||
".head");
|
||||
break;
|
||||
case TSDB_DATA_FILE:
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTfs, pDFileSet->diskId),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), pDFileSet->fid, pDFileSet->fData.commitID,
|
||||
".data");
|
||||
break;
|
||||
case TSDB_LAST_FILE:
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTfs, pDFileSet->diskId),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), pDFileSet->fid, pDFileSet->fLast.commitID,
|
||||
".last");
|
||||
break;
|
||||
case TSDB_SMA_FILE:
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTfs, pDFileSet->diskId),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), pDFileSet->fid, pDFileSet->fSma.commitID,
|
||||
".sma");
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, char fname[]) {
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pHeadF->commitID, ".head");
|
||||
}
|
||||
|
||||
bool tsdbFileIsSame(SDFileSet *pDFileSet1, SDFileSet *pDFileSet2, EDataFileT ftype) {
|
||||
if (pDFileSet1->diskId.level != pDFileSet2->diskId.level || pDFileSet1->diskId.id != pDFileSet2->diskId.id) {
|
||||
return false;
|
||||
}
|
||||
void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]) {
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pDataF->commitID, ".data");
|
||||
}
|
||||
|
||||
switch (ftype) {
|
||||
case TSDB_HEAD_FILE:
|
||||
return pDFileSet1->fHead.commitID == pDFileSet2->fHead.commitID;
|
||||
case TSDB_DATA_FILE:
|
||||
return pDFileSet1->fData.commitID == pDFileSet2->fData.commitID;
|
||||
case TSDB_LAST_FILE:
|
||||
return pDFileSet1->fLast.commitID == pDFileSet2->fLast.commitID;
|
||||
case TSDB_SMA_FILE:
|
||||
return pDFileSet1->fSma.commitID == pDFileSet2->fSma.commitID;
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
void tsdbLastFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SLastFile *pLastF, char fname[]) {
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pLastF->commitID, ".last");
|
||||
}
|
||||
|
||||
void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]) {
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pSmaF->commitID, ".sma");
|
||||
}
|
||||
|
||||
bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2) { return pDelFile1->commitID == pDelFile2->commitID; }
|
||||
|
||||
int32_t tsdbUpdateDFileHdr(TdFilePtr pFD, SDFileSet *pSet, EDataFileT ftype) {
|
||||
int32_t code = 0;
|
||||
int64_t n;
|
||||
char hdr[TSDB_FHDR_SIZE];
|
||||
|
||||
memset(hdr, 0, TSDB_FHDR_SIZE);
|
||||
tPutDataFileHdr(hdr, pSet, ftype);
|
||||
taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
|
||||
|
||||
n = taosLSeekFile(pFD, 0, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
n = taosWriteFile(pFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype) {
|
||||
int32_t code = 0;
|
||||
int64_t size;
|
||||
int64_t n;
|
||||
TdFilePtr pFD;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
char hdr[TSDB_FHDR_SIZE] = {0};
|
||||
|
||||
tsdbDataFileName(pTsdb, pSet, ftype, fname);
|
||||
// truncate
|
||||
switch (ftype) {
|
||||
case TSDB_DATA_FILE:
|
||||
size = pSet->pDataF->size;
|
||||
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
|
||||
tPutDataFile(hdr, pSet->pDataF);
|
||||
break;
|
||||
case TSDB_SMA_FILE:
|
||||
size = pSet->pSmaF->size;
|
||||
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
|
||||
tPutSmaFile(hdr, pSet->pSmaF);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
|
||||
|
||||
// open
|
||||
pFD = taosOpenFile(fname, TD_FILE_WRITE);
|
||||
|
@ -182,31 +145,24 @@ int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
// truncate
|
||||
switch (ftype) {
|
||||
case TSDB_HEAD_FILE:
|
||||
size = pSet->fHead.size;
|
||||
break;
|
||||
case TSDB_DATA_FILE:
|
||||
size = pSet->fData.size;
|
||||
break;
|
||||
case TSDB_LAST_FILE:
|
||||
size = pSet->fLast.size;
|
||||
break;
|
||||
case TSDB_SMA_FILE:
|
||||
size = pSet->fSma.size;
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
// ftruncate
|
||||
if (taosFtruncateFile(pFD, size) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// update header
|
||||
code = tsdbUpdateDFileHdr(pFD, pSet, ftype);
|
||||
if (code) goto _err;
|
||||
n = taosLSeekFile(pFD, 0, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
n = taosWriteFile(pFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// sync
|
||||
if (taosFsyncFile(pFD) < 0) {
|
||||
|
@ -220,42 +176,20 @@ int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype) {
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d tsdb rollback file failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tPutDataFileHdr(uint8_t *p, SDFileSet *pSet, EDataFileT ftype) {
|
||||
int32_t n = 0;
|
||||
|
||||
switch (ftype) {
|
||||
case TSDB_HEAD_FILE:
|
||||
n += tPutHeadFile(p ? p + n : p, &pSet->fHead);
|
||||
break;
|
||||
case TSDB_DATA_FILE:
|
||||
n += tPutDataFile(p ? p + n : p, &pSet->fData);
|
||||
break;
|
||||
case TSDB_LAST_FILE:
|
||||
n += tPutLastFile(p ? p + n : p, &pSet->fLast);
|
||||
break;
|
||||
case TSDB_SMA_FILE:
|
||||
n += tPutSmaFile(p ? p + n : p, &pSet->fSma);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI32v(p ? p + n : p, pSet->diskId.level);
|
||||
n += tPutI32v(p ? p + n : p, pSet->diskId.id);
|
||||
n += tPutI32v(p ? p + n : p, pSet->fid);
|
||||
n += tPutHeadFile(p ? p + n : p, &pSet->fHead);
|
||||
n += tPutDataFile(p ? p + n : p, &pSet->fData);
|
||||
n += tPutLastFile(p ? p + n : p, &pSet->fLast);
|
||||
n += tPutSmaFile(p ? p + n : p, &pSet->fSma);
|
||||
n += tPutHeadFile(p ? p + n : p, pSet->pHeadF);
|
||||
n += tPutDataFile(p ? p + n : p, pSet->pDataF);
|
||||
n += tPutLastFile(p ? p + n : p, pSet->pLastF);
|
||||
n += tPutSmaFile(p ? p + n : p, pSet->pSmaF);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
@ -266,20 +200,18 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
|
|||
n += tGetI32v(p + n, &pSet->diskId.level);
|
||||
n += tGetI32v(p + n, &pSet->diskId.id);
|
||||
n += tGetI32v(p + n, &pSet->fid);
|
||||
n += tGetHeadFile(p + n, &pSet->fHead);
|
||||
n += tGetDataFile(p + n, &pSet->fData);
|
||||
n += tGetLastFile(p + n, &pSet->fLast);
|
||||
n += tGetSmaFile(p + n, &pSet->fSma);
|
||||
n += tGetHeadFile(p + n, pSet->pHeadF);
|
||||
n += tGetDataFile(p + n, pSet->pDataF);
|
||||
n += tGetLastFile(p + n, pSet->pLastF);
|
||||
n += tGetSmaFile(p + n, pSet->pSmaF);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// SDelFile ===============================================
|
||||
void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]) {
|
||||
STfs *pTfs = pTsdb->pVnode->pTfs;
|
||||
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%dver%" PRId64 "%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, pTsdb->path,
|
||||
TD_DIRSEP, TD_VID(pTsdb->pVnode), pFile->commitID, ".del");
|
||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%dver%" PRId64 "%s", tfsGetPrimaryPath(pTsdb->pVnode->pTfs),
|
||||
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), pFile->commitID, ".del");
|
||||
}
|
||||
|
||||
int32_t tPutDelFile(uint8_t *p, SDelFile *pDelFile) {
|
||||
|
|
|
@ -93,7 +93,11 @@ static int32_t tbDataPCmprFn(const void *p1, const void *p2) {
|
|||
}
|
||||
void tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData) {
|
||||
STbData *pTbData = &(STbData){.suid = suid, .uid = uid};
|
||||
|
||||
taosRLockLatch(&pMemTable->latch);
|
||||
void *p = taosArraySearch(pMemTable->aTbData, &pTbData, tbDataPCmprFn, TD_EQ);
|
||||
taosRUnLockLatch(&pMemTable->latch);
|
||||
|
||||
*ppTbData = p ? *(STbData **)p : NULL;
|
||||
}
|
||||
|
||||
|
@ -363,10 +367,13 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid
|
|||
|
||||
void *p;
|
||||
if (idx < 0) {
|
||||
p = taosArrayPush(pMemTable->aTbData, &pTbData);
|
||||
} else {
|
||||
p = taosArrayInsert(pMemTable->aTbData, idx, &pTbData);
|
||||
idx = taosArrayGetSize(pMemTable->aTbData);
|
||||
}
|
||||
|
||||
taosWLockLatch(&pMemTable->latch);
|
||||
p = taosArrayInsert(pMemTable->aTbData, idx, &pTbData);
|
||||
taosWUnLockLatch(&pMemTable->latch);
|
||||
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
|
@ -605,46 +612,3 @@ void tsdbUnrefMemTable(SMemTable *pMemTable) {
|
|||
tsdbMemTableDestroy(pMemTable);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tsdbTakeMemSnapshot(STsdb *pTsdb, SMemTable **ppMem, SMemTable **ppIMem) {
|
||||
int32_t code = 0;
|
||||
|
||||
// lock
|
||||
code = taosThreadRwlockRdlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// take snapshot
|
||||
*ppMem = pTsdb->mem;
|
||||
*ppIMem = pTsdb->imem;
|
||||
|
||||
if (*ppMem) {
|
||||
tsdbRefMemTable(*ppMem);
|
||||
}
|
||||
|
||||
if (*ppIMem) {
|
||||
tsdbRefMemTable(*ppIMem);
|
||||
}
|
||||
|
||||
// unlock
|
||||
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
void tsdbUntakeMemSnapshot(STsdb *pTsdb, SMemTable *pMem, SMemTable *pIMem) {
|
||||
if (pMem) {
|
||||
tsdbUnrefMemTable(pMem);
|
||||
}
|
||||
|
||||
if (pIMem) {
|
||||
tsdbUnrefMemTable(pIMem);
|
||||
}
|
||||
}
|
|
@ -66,7 +66,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||
|
||||
// open tsdb
|
||||
if (tsdbFSOpen(pTsdb, &pTsdb->pFS) < 0) {
|
||||
if (tsdbFSOpen(pTsdb) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ _err:
|
|||
int tsdbClose(STsdb **pTsdb) {
|
||||
if (*pTsdb) {
|
||||
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||
tsdbFSClose((*pTsdb)->pFS);
|
||||
tsdbFSClose(*pTsdb);
|
||||
tsdbCloseCache((*pTsdb)->lruCache);
|
||||
taosMemoryFreeClear(*pTsdb);
|
||||
}
|
||||
|
|
|
@ -118,8 +118,7 @@ struct STsdbReader {
|
|||
char* idStr; // query info handle, for debug purpose
|
||||
int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
|
||||
SBlockLoadSuppInfo suppInfo;
|
||||
SMemTable* pMem;
|
||||
SMemTable* pIMem;
|
||||
STsdbReadSnap* pReadSnap;
|
||||
|
||||
SIOCostSummary cost;
|
||||
STSchema* pSchema;
|
||||
|
@ -275,20 +274,18 @@ static void limitOutputBufferSize(const SQueryTableDataCond* pCond, int32_t* cap
|
|||
}
|
||||
|
||||
// init file iterator
|
||||
static int32_t initFilesetIterator(SFilesetIter* pIter, const STsdbFSState* pFState, int32_t order, const char* idstr) {
|
||||
size_t numOfFileset = taosArrayGetSize(pFState->aDFileSet);
|
||||
static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, int32_t order, const char* idstr) {
|
||||
size_t numOfFileset = taosArrayGetSize(aDFileSet);
|
||||
|
||||
pIter->index = ASCENDING_TRAVERSE(order) ? -1 : numOfFileset;
|
||||
pIter->order = order;
|
||||
pIter->pFileList = taosArrayDup(pFState->aDFileSet);
|
||||
pIter->pFileList = aDFileSet;
|
||||
pIter->numOfFiles = numOfFileset;
|
||||
|
||||
tsdbDebug("init fileset iterator, total files:%d %s", pIter->numOfFiles, idstr);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void cleanupFilesetIterator(SFilesetIter* pIter) { taosArrayDestroy(pIter->pFileList); }
|
||||
|
||||
static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
|
||||
bool asc = ASCENDING_TRAVERSE(pIter->order);
|
||||
int32_t step = asc ? 1 : -1;
|
||||
|
@ -788,11 +785,11 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo);
|
||||
}
|
||||
colIndex += 1;
|
||||
ASSERT(rowIndex == remain);
|
||||
} else { // the specified column does not exist in file block, fill with null data
|
||||
colDataAppendNNULL(pColData, 0, remain);
|
||||
}
|
||||
|
||||
ASSERT(rowIndex == remain);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -1881,8 +1878,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
|||
int32_t backward = (!ASCENDING_TRAVERSE(pReader->order));
|
||||
|
||||
STbData* d = NULL;
|
||||
if (pReader->pMem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pMem, pReader->suid, pBlockScanInfo->uid, &d);
|
||||
if (pReader->pReadSnap->pMem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid, &d);
|
||||
if (d != NULL) {
|
||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1902,8 +1899,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
|||
}
|
||||
|
||||
STbData* di = NULL;
|
||||
if (pReader->pIMem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pIMem, pReader->suid, pBlockScanInfo->uid, &di);
|
||||
if (pReader->pReadSnap->pIMem != NULL) {
|
||||
tsdbGetTbDataFromMemTable(pReader->pReadSnap->pIMem, pReader->suid, pBlockScanInfo->uid, &di);
|
||||
if (di != NULL) {
|
||||
code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1939,21 +1936,24 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
|
||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||
|
||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->cState);
|
||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||
if (pDelFile) {
|
||||
SDelFReader* pDelFReader = NULL;
|
||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb, NULL);
|
||||
if (code) {
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SArray* aDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
||||
if (aDelIdx == NULL) {
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbReadDelIdx(pDelFReader, aDelIdx, NULL);
|
||||
if (code) {
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(aDelIdx);
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1962,11 +1962,15 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
|
||||
if (pIdx != NULL) {
|
||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData, NULL);
|
||||
}
|
||||
|
||||
taosArrayDestroy(aDelIdx);
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDelData* p = NULL;
|
||||
if (pMemTbData != NULL) {
|
||||
|
@ -2261,10 +2265,6 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
|
|||
SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_t level) {
|
||||
int64_t startVer = (pCond->startVersion == -1) ? 0 : pCond->startVersion;
|
||||
|
||||
if (VND_IS_RSMA(pVnode)) {
|
||||
return (SVersionRange){.minVer = startVer, .maxVer = tdRSmaGetMaxSubmitVer(pVnode->pSma, level)};
|
||||
}
|
||||
|
||||
int64_t endVer = 0;
|
||||
if (pCond->endVersion ==
|
||||
-1) { // user not specified end version, set current maximum version of vnode as the endVersion
|
||||
|
@ -2532,8 +2532,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
|
||||
pDumpInfo->rowIndex =
|
||||
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
||||
|
||||
if (pDumpInfo->rowIndex >= pBlock->nRow) {
|
||||
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
||||
*state = CHECK_FILEBLOCK_CONT;
|
||||
}
|
||||
}
|
||||
|
@ -2576,10 +2575,10 @@ void updateSchema(TSDBROW* pRow, uint64_t uid, STsdbReader* pReader) {
|
|||
int32_t sversion = TSDBROW_SVERSION(pRow);
|
||||
|
||||
if (pReader->pSchema == NULL) {
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, uid, sversion);
|
||||
metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pSchema);
|
||||
} else if (pReader->pSchema->version != sversion) {
|
||||
taosMemoryFreeClear(pReader->pSchema);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, uid, sversion);
|
||||
metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pSchema);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2830,8 +2829,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
|
||||
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
|
||||
|
||||
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||
code = tsdbTakeReadSnap(pReader->pTsdb, &pReader->pReadSnap);
|
||||
if (code) goto _err;
|
||||
|
||||
initFilesetIterator(&pReader->status.fileIter, (*ppReader)->pReadSnap->fs.aDFileSet, pReader->order, pReader->idStr);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
|
||||
// no data in files, let's try buffer in memory
|
||||
|
@ -2844,8 +2845,6 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
|||
}
|
||||
}
|
||||
|
||||
tsdbTakeMemSnapshot(pReader->pTsdb, &pReader->pMem, &pReader->pIMem);
|
||||
|
||||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||
return code;
|
||||
|
||||
|
@ -2861,7 +2860,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
|
||||
tsdbUntakeMemSnapshot(pReader->pTsdb, pReader->pMem, pReader->pIMem);
|
||||
tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap);
|
||||
|
||||
taosMemoryFreeClear(pSupInfo->plist);
|
||||
taosMemoryFree(pSupInfo->colIds);
|
||||
|
@ -2874,7 +2873,6 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
}
|
||||
taosMemoryFree(pSupInfo->buildBuf);
|
||||
|
||||
cleanupFilesetIterator(&pReader->status.fileIter);
|
||||
cleanupDataBlockIterator(&pReader->status.blockIter);
|
||||
destroyBlockScanInfo(pReader->status.pTableMap);
|
||||
blockDataDestroy(pReader->pResBlock);
|
||||
|
@ -3081,8 +3079,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
|||
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
|
||||
STsdbFSState* pFState = pReader->pTsdb->pFS->cState;
|
||||
initFilesetIterator(&pReader->status.fileIter, pFState, pReader->order, pReader->idStr);
|
||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader->order, pReader->idStr);
|
||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||
resetDataBlockScanInfo(pReader->status.pTableMap);
|
||||
|
||||
|
@ -3244,3 +3241,68 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t tsdbTakeReadSnap(STsdb* pTsdb, STsdbReadSnap** ppSnap) {
|
||||
int32_t code = 0;
|
||||
|
||||
// alloc
|
||||
*ppSnap = (STsdbReadSnap*)taosMemoryCalloc(1, sizeof(STsdbReadSnap));
|
||||
if (*ppSnap == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// lock
|
||||
code = taosThreadRwlockRdlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// take snapshot
|
||||
(*ppSnap)->pMem = pTsdb->mem;
|
||||
(*ppSnap)->pIMem = pTsdb->imem;
|
||||
|
||||
if ((*ppSnap)->pMem) {
|
||||
tsdbRefMemTable((*ppSnap)->pMem);
|
||||
}
|
||||
|
||||
if ((*ppSnap)->pIMem) {
|
||||
tsdbRefMemTable((*ppSnap)->pIMem);
|
||||
}
|
||||
|
||||
// fs
|
||||
code = tsdbFSRef(pTsdb, &(*ppSnap)->fs);
|
||||
if (code) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// unlock
|
||||
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
tsdbTrace("vgId:%d take read snapshot", TD_VID(pTsdb->pVnode));
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
void tsdbUntakeReadSnap(STsdb* pTsdb, STsdbReadSnap* pSnap) {
|
||||
if (pSnap) {
|
||||
if (pSnap->pMem) {
|
||||
tsdbUnrefMemTable(pSnap->pMem);
|
||||
}
|
||||
|
||||
if (pSnap->pIMem) {
|
||||
tsdbUnrefMemTable(pSnap->pIMem);
|
||||
}
|
||||
|
||||
tsdbFSUnref(pTsdb, &pSnap->fs);
|
||||
taosMemoryFree(pSnap);
|
||||
}
|
||||
|
||||
tsdbTrace("vgId:%d untake read snapshot", TD_VID(pTsdb->pVnode));
|
||||
}
|
||||
|
|
|
@ -459,7 +459,7 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
|
||||
// open impl
|
||||
// head
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_HEAD_FILE, fname);
|
||||
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
|
||||
pReader->pHeadFD = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pReader->pHeadFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -467,7 +467,7 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
}
|
||||
|
||||
// data
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_DATA_FILE, fname);
|
||||
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
|
||||
pReader->pDataFD = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pReader->pDataFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -475,7 +475,7 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
}
|
||||
|
||||
// last
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_LAST_FILE, fname);
|
||||
tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname);
|
||||
pReader->pLastFD = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pReader->pLastFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -483,7 +483,7 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
|
|||
}
|
||||
|
||||
// sma
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_SMA_FILE, fname);
|
||||
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
|
||||
pReader->pSmaFD = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pReader->pSmaFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -536,8 +536,8 @@ _err:
|
|||
|
||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx, uint8_t **ppBuf) {
|
||||
int32_t code = 0;
|
||||
int64_t offset = pReader->pSet->fHead.offset;
|
||||
int64_t size = pReader->pSet->fHead.size - offset;
|
||||
int64_t offset = pReader->pSet->pHeadF->offset;
|
||||
int64_t size = pReader->pSet->pHeadF->size - offset;
|
||||
uint8_t *pBuf = NULL;
|
||||
int64_t n;
|
||||
uint32_t delimiter;
|
||||
|
@ -1211,17 +1211,6 @@ _err:
|
|||
}
|
||||
|
||||
// SDataFWriter ====================================================
|
||||
struct SDataFWriter {
|
||||
STsdb *pTsdb;
|
||||
SDFileSet wSet;
|
||||
TdFilePtr pHeadFD;
|
||||
TdFilePtr pDataFD;
|
||||
TdFilePtr pLastFD;
|
||||
TdFilePtr pSmaFD;
|
||||
};
|
||||
|
||||
SDFileSet *tsdbDataFWriterGetWSet(SDataFWriter *pWriter) { return &pWriter->wSet; }
|
||||
|
||||
int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet) {
|
||||
int32_t code = 0;
|
||||
int32_t flag;
|
||||
|
@ -1237,12 +1226,20 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
goto _err;
|
||||
}
|
||||
pWriter->pTsdb = pTsdb;
|
||||
pWriter->wSet = *pSet;
|
||||
pSet = &pWriter->wSet;
|
||||
pWriter->wSet = (SDFileSet){.diskId = pSet->diskId,
|
||||
.fid = pSet->fid,
|
||||
.pHeadF = &pWriter->fHead,
|
||||
.pDataF = &pWriter->fData,
|
||||
.pLastF = &pWriter->fLast,
|
||||
.pSmaF = &pWriter->fSma};
|
||||
pWriter->fHead = *pSet->pHeadF;
|
||||
pWriter->fData = *pSet->pDataF;
|
||||
pWriter->fLast = *pSet->pLastF;
|
||||
pWriter->fSma = *pSet->pSmaF;
|
||||
|
||||
// head
|
||||
flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_HEAD_FILE, fname);
|
||||
tsdbHeadFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fHead, fname);
|
||||
pWriter->pHeadFD = taosOpenFile(fname, flag);
|
||||
if (pWriter->pHeadFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -1257,28 +1254,28 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
|
||||
ASSERT(n == TSDB_FHDR_SIZE);
|
||||
|
||||
pSet->fHead.size += TSDB_FHDR_SIZE;
|
||||
pWriter->fHead.size += TSDB_FHDR_SIZE;
|
||||
|
||||
// data
|
||||
if (pSet->fData.size == 0) {
|
||||
if (pWriter->fData.size == 0) {
|
||||
flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
} else {
|
||||
flag = TD_FILE_WRITE;
|
||||
}
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_DATA_FILE, fname);
|
||||
tsdbDataFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fData, fname);
|
||||
pWriter->pDataFD = taosOpenFile(fname, flag);
|
||||
if (pWriter->pDataFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
if (pSet->fData.size == 0) {
|
||||
if (pWriter->fData.size == 0) {
|
||||
n = taosWriteFile(pWriter->pDataFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pSet->fData.size += TSDB_FHDR_SIZE;
|
||||
pWriter->fData.size += TSDB_FHDR_SIZE;
|
||||
} else {
|
||||
n = taosLSeekFile(pWriter->pDataFD, 0, SEEK_END);
|
||||
if (n < 0) {
|
||||
|
@ -1286,29 +1283,29 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(n == pSet->fData.size);
|
||||
ASSERT(n == pWriter->fData.size);
|
||||
}
|
||||
|
||||
// last
|
||||
if (pSet->fLast.size == 0) {
|
||||
if (pWriter->fLast.size == 0) {
|
||||
flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
} else {
|
||||
flag = TD_FILE_WRITE;
|
||||
}
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_LAST_FILE, fname);
|
||||
tsdbLastFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fLast, fname);
|
||||
pWriter->pLastFD = taosOpenFile(fname, flag);
|
||||
if (pWriter->pLastFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
if (pSet->fLast.size == 0) {
|
||||
if (pWriter->fLast.size == 0) {
|
||||
n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pSet->fLast.size += TSDB_FHDR_SIZE;
|
||||
pWriter->fLast.size += TSDB_FHDR_SIZE;
|
||||
} else {
|
||||
n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_END);
|
||||
if (n < 0) {
|
||||
|
@ -1316,29 +1313,29 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(n == pSet->fLast.size);
|
||||
ASSERT(n == pWriter->fLast.size);
|
||||
}
|
||||
|
||||
// sma
|
||||
if (pSet->fSma.size == 0) {
|
||||
if (pWriter->fSma.size == 0) {
|
||||
flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
} else {
|
||||
flag = TD_FILE_WRITE;
|
||||
}
|
||||
tsdbDataFileName(pTsdb, pSet, TSDB_SMA_FILE, fname);
|
||||
tsdbSmaFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fSma, fname);
|
||||
pWriter->pSmaFD = taosOpenFile(fname, flag);
|
||||
if (pWriter->pSmaFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
if (pSet->fSma.size == 0) {
|
||||
if (pWriter->fSma.size == 0) {
|
||||
n = taosWriteFile(pWriter->pSmaFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pSet->fSma.size += TSDB_FHDR_SIZE;
|
||||
pWriter->fSma.size += TSDB_FHDR_SIZE;
|
||||
} else {
|
||||
n = taosLSeekFile(pWriter->pSmaFD, 0, SEEK_END);
|
||||
if (n < 0) {
|
||||
|
@ -1346,7 +1343,7 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
|
|||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(n == pSet->fSma.size);
|
||||
ASSERT(n == pWriter->fSma.size);
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
|
@ -1418,22 +1415,76 @@ _err:
|
|||
|
||||
int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter) {
|
||||
int32_t code = 0;
|
||||
int64_t n;
|
||||
char hdr[TSDB_FHDR_SIZE];
|
||||
|
||||
// head ==============
|
||||
code = tsdbUpdateDFileHdr(pWriter->pHeadFD, &pWriter->wSet, TSDB_HEAD_FILE);
|
||||
if (code) goto _err;
|
||||
memset(hdr, 0, TSDB_FHDR_SIZE);
|
||||
tPutHeadFile(hdr, &pWriter->fHead);
|
||||
taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
|
||||
|
||||
n = taosLSeekFile(pWriter->pHeadFD, 0, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
n = taosWriteFile(pWriter->pHeadFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// data ==============
|
||||
code = tsdbUpdateDFileHdr(pWriter->pHeadFD, &pWriter->wSet, TSDB_DATA_FILE);
|
||||
if (code) goto _err;
|
||||
memset(hdr, 0, TSDB_FHDR_SIZE);
|
||||
tPutDataFile(hdr, &pWriter->fData);
|
||||
taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
|
||||
|
||||
n = taosLSeekFile(pWriter->pDataFD, 0, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
n = taosWriteFile(pWriter->pDataFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// last ==============
|
||||
code = tsdbUpdateDFileHdr(pWriter->pHeadFD, &pWriter->wSet, TSDB_LAST_FILE);
|
||||
if (code) goto _err;
|
||||
memset(hdr, 0, TSDB_FHDR_SIZE);
|
||||
tPutLastFile(hdr, &pWriter->fLast);
|
||||
taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
|
||||
|
||||
n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// sma ==============
|
||||
code = tsdbUpdateDFileHdr(pWriter->pHeadFD, &pWriter->wSet, TSDB_SMA_FILE);
|
||||
if (code) goto _err;
|
||||
memset(hdr, 0, TSDB_FHDR_SIZE);
|
||||
tPutSmaFile(hdr, &pWriter->fSma);
|
||||
taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
|
||||
|
||||
n = taosLSeekFile(pWriter->pSmaFD, 0, SEEK_SET);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
n = taosWriteFile(pWriter->pSmaFD, hdr, TSDB_FHDR_SIZE);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
||||
|
@ -1444,7 +1495,7 @@ _err:
|
|||
|
||||
int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx, uint8_t **ppBuf) {
|
||||
int32_t code = 0;
|
||||
SHeadFile *pHeadFile = &pWriter->wSet.fHead;
|
||||
SHeadFile *pHeadFile = &pWriter->fHead;
|
||||
uint8_t *pBuf = NULL;
|
||||
int64_t size;
|
||||
int64_t n;
|
||||
|
@ -1494,7 +1545,7 @@ _err:
|
|||
|
||||
int32_t tsdbWriteBlock(SDataFWriter *pWriter, SMapData *mBlock, uint8_t **ppBuf, SBlockIdx *pBlockIdx) {
|
||||
int32_t code = 0;
|
||||
SHeadFile *pHeadFile = &pWriter->wSet.fHead;
|
||||
SHeadFile *pHeadFile = &pWriter->fHead;
|
||||
SBlockDataHdr hdr = {.delimiter = TSDB_FILE_DLMT, .suid = pBlockIdx->suid, .uid = pBlockIdx->uid};
|
||||
uint8_t *pBuf = NULL;
|
||||
int64_t size;
|
||||
|
@ -1831,9 +1882,9 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_
|
|||
pSubBlock->nRow = pBlockData->nRow;
|
||||
pSubBlock->cmprAlg = cmprAlg;
|
||||
if (pBlock->last) {
|
||||
pSubBlock->offset = pWriter->wSet.fLast.size;
|
||||
pSubBlock->offset = pWriter->fLast.size;
|
||||
} else {
|
||||
pSubBlock->offset = pWriter->wSet.fData.size;
|
||||
pSubBlock->offset = pWriter->fData.size;
|
||||
}
|
||||
|
||||
// ======================= BLOCK DATA =======================
|
||||
|
@ -1881,9 +1932,9 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_
|
|||
|
||||
pSubBlock->szBlock = pSubBlock->szBlockCol + sizeof(TSCKSUM) + nData;
|
||||
if (pBlock->last) {
|
||||
pWriter->wSet.fLast.size += pSubBlock->szBlock;
|
||||
pWriter->fLast.size += pSubBlock->szBlock;
|
||||
} else {
|
||||
pWriter->wSet.fData.size += pSubBlock->szBlock;
|
||||
pWriter->fData.size += pSubBlock->szBlock;
|
||||
}
|
||||
|
||||
// ======================= BLOCK SMA =======================
|
||||
|
@ -1896,8 +1947,8 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_
|
|||
if (code) goto _err;
|
||||
|
||||
if (pSubBlock->nSma > 0) {
|
||||
pSubBlock->sOffset = pWriter->wSet.fSma.size;
|
||||
pWriter->wSet.fSma.size += (sizeof(SColumnDataAgg) * pSubBlock->nSma + sizeof(TSCKSUM));
|
||||
pSubBlock->sOffset = pWriter->fSma.size;
|
||||
pWriter->fSma.size += (sizeof(SColumnDataAgg) * pSubBlock->nSma + sizeof(TSCKSUM));
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -1924,8 +1975,8 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
char fNameTo[TSDB_FILENAME_LEN];
|
||||
|
||||
// head
|
||||
tsdbDataFileName(pTsdb, pSetFrom, TSDB_HEAD_FILE, fNameFrom);
|
||||
tsdbDataFileName(pTsdb, pSetTo, TSDB_HEAD_FILE, fNameTo);
|
||||
tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom);
|
||||
tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo);
|
||||
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
|
@ -1939,7 +1990,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->fHead.size);
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pHeadF->size);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -1948,8 +1999,8 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
taosCloseFile(&PInFD);
|
||||
|
||||
// data
|
||||
tsdbDataFileName(pTsdb, pSetFrom, TSDB_DATA_FILE, fNameFrom);
|
||||
tsdbDataFileName(pTsdb, pSetTo, TSDB_DATA_FILE, fNameTo);
|
||||
tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom);
|
||||
tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo);
|
||||
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
|
@ -1963,7 +2014,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->fData.size);
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pDataF->size);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -1972,8 +2023,9 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
taosCloseFile(&PInFD);
|
||||
|
||||
// last
|
||||
tsdbDataFileName(pTsdb, pSetFrom, TSDB_LAST_FILE, fNameFrom);
|
||||
tsdbDataFileName(pTsdb, pSetTo, TSDB_LAST_FILE, fNameTo);
|
||||
tsdbLastFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pLastF, fNameFrom);
|
||||
tsdbLastFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pLastF, fNameTo);
|
||||
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -1986,7 +2038,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->fLast.size);
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pLastF->size);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -1995,8 +2047,8 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
taosCloseFile(&PInFD);
|
||||
|
||||
// sma
|
||||
tsdbDataFileName(pTsdb, pSetFrom, TSDB_SMA_FILE, fNameFrom);
|
||||
tsdbDataFileName(pTsdb, pSetTo, TSDB_SMA_FILE, fNameTo);
|
||||
tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom);
|
||||
tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo);
|
||||
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
|
@ -2010,7 +2062,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->fSma.size);
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pSmaF->size);
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
|
|
@ -15,90 +15,99 @@
|
|||
|
||||
#include "tsdb.h"
|
||||
|
||||
static int32_t tsdbDoRetentionImpl(STsdb *pTsdb, int64_t now, int8_t try, int8_t *canDo) {
|
||||
int32_t code = 0;
|
||||
STsdbFSState *pState;
|
||||
|
||||
if (try) {
|
||||
pState = pTsdb->pFS->cState;
|
||||
*canDo = 0;
|
||||
} else {
|
||||
pState = pTsdb->pFS->nState;
|
||||
}
|
||||
|
||||
for (int32_t iSet = 0; iSet < taosArrayGetSize(pState->aDFileSet); iSet++) {
|
||||
SDFileSet *pDFileSet = (SDFileSet *)taosArrayGet(pState->aDFileSet, iSet);
|
||||
int32_t expLevel = tsdbFidLevel(pDFileSet->fid, &pTsdb->keepCfg, now);
|
||||
static bool tsdbShouldDoRetention(STsdb *pTsdb, int64_t now) {
|
||||
for (int32_t iSet = 0; iSet < taosArrayGetSize(pTsdb->fs.aDFileSet); iSet++) {
|
||||
SDFileSet *pSet = (SDFileSet *)taosArrayGet(pTsdb->fs.aDFileSet, iSet);
|
||||
int32_t expLevel = tsdbFidLevel(pSet->fid, &pTsdb->keepCfg, now);
|
||||
SDiskID did;
|
||||
|
||||
// check
|
||||
if (expLevel == pDFileSet->diskId.id) continue;
|
||||
if (expLevel == pSet->diskId.level) continue;
|
||||
|
||||
// delete or move
|
||||
if (expLevel < 0) {
|
||||
if (try) {
|
||||
*canDo = 1;
|
||||
return true;
|
||||
} else {
|
||||
tsdbFSStateDeleteDFileSet(pState, pDFileSet->fid);
|
||||
iSet--;
|
||||
if (tfsAllocDisk(pTsdb->pVnode->pTfs, expLevel, &did) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (did.level == pSet->diskId.level) continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (!tsdbShouldDoRetention(pTsdb, now)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// do retention
|
||||
STsdbFS fs;
|
||||
|
||||
code = tsdbFSCopy(pTsdb, &fs);
|
||||
if (code) goto _err;
|
||||
|
||||
for (int32_t iSet = 0; iSet < taosArrayGetSize(fs.aDFileSet); iSet++) {
|
||||
SDFileSet *pSet = (SDFileSet *)taosArrayGet(pTsdb->fs.aDFileSet, iSet);
|
||||
int32_t expLevel = tsdbFidLevel(pSet->fid, &pTsdb->keepCfg, now);
|
||||
SDiskID did;
|
||||
|
||||
if (expLevel < 0) {
|
||||
taosMemoryFree(pSet->pHeadF);
|
||||
taosMemoryFree(pSet->pDataF);
|
||||
taosMemoryFree(pSet->pLastF);
|
||||
taosMemoryFree(pSet->pSmaF);
|
||||
taosArrayRemove(fs.aDFileSet, iSet);
|
||||
iSet--;
|
||||
} else {
|
||||
// alloc
|
||||
if (tfsAllocDisk(pTsdb->pVnode->pTfs, expLevel, &did) < 0) {
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (did.level == pDFileSet->diskId.level) continue;
|
||||
if (did.level == pSet->diskId.level) continue;
|
||||
|
||||
if (try) {
|
||||
*canDo = 1;
|
||||
} else {
|
||||
// copy the file to new disk
|
||||
// copy file to new disk (todo)
|
||||
SDFileSet fSet = *pSet;
|
||||
fSet.diskId = did;
|
||||
|
||||
SDFileSet nDFileSet = *pDFileSet;
|
||||
nDFileSet.diskId = did;
|
||||
|
||||
tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
|
||||
|
||||
code = tsdbDFileSetCopy(pTsdb, pDFileSet, &nDFileSet);
|
||||
if (code) goto _exit;
|
||||
|
||||
code = tsdbFSStateUpsertDFileSet(pState, &nDFileSet);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
|
||||
int32_t code = 0;
|
||||
int8_t canDo;
|
||||
|
||||
// try
|
||||
tsdbDoRetentionImpl(pTsdb, now, 1, &canDo);
|
||||
if (!canDo) goto _exit;
|
||||
|
||||
// begin
|
||||
code = tsdbFSBegin(pTsdb->pFS);
|
||||
code = tsdbDFileSetCopy(pTsdb, pSet, &fSet);
|
||||
if (code) goto _err;
|
||||
|
||||
// do retention
|
||||
code = tsdbDoRetentionImpl(pTsdb, now, 0, NULL);
|
||||
code = tsdbFSUpsertFSet(&fs, &fSet);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
/* code */
|
||||
}
|
||||
|
||||
// do change fs
|
||||
code = tsdbFSCommit1(pTsdb, &fs);
|
||||
if (code) goto _err;
|
||||
|
||||
// commit
|
||||
code = tsdbFSCommit(pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
|
||||
code = tsdbFSCommit2(pTsdb, &fs);
|
||||
if (code) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
tsdbFSDestroy(&fs);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
tsdbFSRollback(pTsdb->pFS);
|
||||
ASSERT(0);
|
||||
// tsdbFSRollback(pTsdb->pFS);
|
||||
return code;
|
||||
}
|
|
@ -20,6 +20,7 @@ struct STsdbSnapReader {
|
|||
STsdb* pTsdb;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
STsdbFS fs;
|
||||
// for data file
|
||||
int8_t dataDone;
|
||||
int32_t fid;
|
||||
|
@ -45,7 +46,8 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
|||
|
||||
while (true) {
|
||||
if (pReader->pDataFReader == NULL) {
|
||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->cState, pReader->fid, TD_GT);
|
||||
SDFileSet* pSet =
|
||||
taosArraySearch(pReader->fs.aDFileSet, &(SDFileSet){.fid = pReader->fid}, tDFileSetCmprFn, TD_GT);
|
||||
|
||||
if (pSet == NULL) goto _exit;
|
||||
|
||||
|
@ -159,7 +161,7 @@ _err:
|
|||
static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||
int32_t code = 0;
|
||||
STsdb* pTsdb = pReader->pTsdb;
|
||||
SDelFile* pDelFile = pTsdb->pFS->cState->pDelFile;
|
||||
SDelFile* pDelFile = pReader->fs.pDelFile;
|
||||
|
||||
if (pReader->pDelFReader == NULL) {
|
||||
if (pDelFile == NULL) {
|
||||
|
@ -254,6 +256,24 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapRe
|
|||
pReader->sver = sver;
|
||||
pReader->ever = ever;
|
||||
|
||||
code = taosThreadRwlockRdlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbFSRef(pTsdb, &pReader->fs);
|
||||
if (code) {
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
if (code) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pReader->fid = INT32_MIN;
|
||||
pReader->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||
if (pReader->aBlockIdx == NULL) {
|
||||
|
@ -305,6 +325,8 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
|
|||
taosArrayDestroy(pReader->aDelIdx);
|
||||
taosArrayDestroy(pReader->aDelData);
|
||||
|
||||
tsdbFSUnref(pReader->pTsdb, &pReader->fs);
|
||||
|
||||
tsdbInfo("vgId:%d vnode snapshot tsdb reader closed", TD_VID(pReader->pTsdb->pVnode));
|
||||
|
||||
taosMemoryFree(pReader);
|
||||
|
@ -358,6 +380,7 @@ struct STsdbSnapWriter {
|
|||
STsdb* pTsdb;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
STsdbFS fs;
|
||||
|
||||
// config
|
||||
int32_t minutes;
|
||||
|
@ -798,7 +821,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
|
|||
code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW, NULL);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSStateUpsertDFileSet(pTsdb->pFS->nState, tsdbDataFWriterGetWSet(pWriter->pDataFWriter));
|
||||
code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->pDataFWriter->wSet);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
|
||||
|
@ -843,7 +866,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
|
|||
pWriter->fid = fid;
|
||||
|
||||
// read
|
||||
SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->pFS->nState, fid, TD_EQ);
|
||||
SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ);
|
||||
if (pSet) {
|
||||
code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
|
||||
if (code) goto _err;
|
||||
|
@ -863,22 +886,26 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
|
|||
tBlockDataReset(&pWriter->bDataR);
|
||||
|
||||
// write
|
||||
SDFileSet wSet;
|
||||
SHeadFile fHead;
|
||||
SDataFile fData;
|
||||
SLastFile fLast;
|
||||
SSmaFile fSma;
|
||||
SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma};
|
||||
|
||||
if (pSet) {
|
||||
wSet = (SDFileSet){.diskId = pSet->diskId,
|
||||
.fid = fid,
|
||||
.fHead = {.commitID = pWriter->commitID, .offset = 0, .size = 0},
|
||||
.fData = pSet->fData,
|
||||
.fLast = {.commitID = pWriter->commitID, .size = 0},
|
||||
.fSma = pSet->fSma};
|
||||
wSet.diskId = pSet->diskId;
|
||||
wSet.fid = fid;
|
||||
fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0};
|
||||
fData = *pSet->pDataF;
|
||||
fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0};
|
||||
fSma = *pSet->pSmaF;
|
||||
} else {
|
||||
wSet = (SDFileSet){.diskId = (SDiskID){.level = 0, .id = 0},
|
||||
.fid = fid,
|
||||
.fHead = {.commitID = pWriter->commitID, .offset = 0, .size = 0},
|
||||
.fData = {.commitID = pWriter->commitID, .size = 0},
|
||||
.fLast = {.commitID = pWriter->commitID, .size = 0},
|
||||
.fSma = {.commitID = pWriter->commitID, .size = 0}};
|
||||
wSet.diskId = (SDiskID){.level = 0, .id = 0};
|
||||
wSet.fid = fid;
|
||||
fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0};
|
||||
fData = (SDataFile){.commitID = pWriter->commitID, .size = 0};
|
||||
fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0};
|
||||
fSma = (SSmaFile){.commitID = pWriter->commitID, .size = 0};
|
||||
}
|
||||
|
||||
code = tsdbDataFWriterOpen(&pWriter->pDataFWriter, pTsdb, &wSet);
|
||||
|
@ -907,7 +934,7 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
|
|||
STsdb* pTsdb = pWriter->pTsdb;
|
||||
|
||||
if (pWriter->pDelFWriter == NULL) {
|
||||
SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->pFS->nState);
|
||||
SDelFile* pDelFile = pWriter->fs.pDelFile;
|
||||
|
||||
// reader
|
||||
if (pDelFile) {
|
||||
|
@ -1017,7 +1044,7 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
|
|||
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSStateUpsertDelFile(pTsdb->pFS->nState, &pWriter->pDelFWriter->fDel);
|
||||
code = tsdbFSUpsertDelFile(&pWriter->fs, &pWriter->pDelFWriter->fDel);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
|
||||
|
@ -1051,6 +1078,9 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
code = tsdbFSCopy(pTsdb, &pWriter->fs);
|
||||
if (code) goto _err;
|
||||
|
||||
// config
|
||||
pWriter->minutes = pTsdb->keepCfg.days;
|
||||
pWriter->precision = pTsdb->keepCfg.precision;
|
||||
|
@ -1096,9 +1126,6 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
|||
goto _err;
|
||||
}
|
||||
|
||||
code = tsdbFSBegin(pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
||||
|
@ -1113,8 +1140,9 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
|||
STsdbSnapWriter* pWriter = *ppWriter;
|
||||
|
||||
if (rollback) {
|
||||
code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||
if (code) goto _err;
|
||||
ASSERT(0);
|
||||
// code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||
// if (code) goto _err;
|
||||
} else {
|
||||
code = tsdbSnapWriteDataEnd(pWriter);
|
||||
if (code) goto _err;
|
||||
|
@ -1122,7 +1150,10 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
|||
code = tsdbSnapWriteDelEnd(pWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSCommit(pWriter->pTsdb->pFS);
|
||||
code = tsdbFSCommit1(pWriter->pTsdb, &pWriter->fs);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSCommit2(pWriter->pTsdb, &pWriter->fs);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,16 +95,19 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
|||
// save info to a vnode_tmp.json
|
||||
pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
vError("failed to open info file: %s for write: %s", fname, terrstr());
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, data, strlen(data)) < 0) {
|
||||
vError("failed to write info file: %s data: %s", fname, terrstr());
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
vError("failed to fsync info file: %s error: %s", fname, terrstr());
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue