merge 3.0
This commit is contained in:
commit
e5e82f0cf2
19
README-CN.md
19
README-CN.md
|
@ -50,19 +50,12 @@ TDengine 目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后
|
||||||
|
|
||||||
## 安装工具
|
## 安装工具
|
||||||
|
|
||||||
### Ubuntu 16.04 及以上版本 & Debian:
|
### Ubuntu 18.04 及以上版本 & Debian:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Ubuntu 14.04:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt-get install -y gcc cmake3 build-essential git binutils-2.26
|
|
||||||
export PATH=/usr/lib/binutils-2.26/bin:$PATH
|
|
||||||
```
|
|
||||||
|
|
||||||
编译或打包 JDBC 驱动源码,需安装 Java JDK 8 或以上版本和 Apache Maven 2.7 或以上版本。
|
编译或打包 JDBC 驱动源码,需安装 Java JDK 8 或以上版本和 Apache Maven 2.7 或以上版本。
|
||||||
|
|
||||||
安装 OpenJDK 8:
|
安装 OpenJDK 8:
|
||||||
|
@ -89,7 +82,7 @@ taosTools 是用于 TDengine 的辅助工具软件集合。目前它包含 taosB
|
||||||
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS 7:
|
### CentOS 7.9:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo yum install -y gcc gcc-c++ make cmake git openssl-devel
|
sudo yum install -y gcc gcc-c++ make cmake git openssl-devel
|
||||||
|
@ -161,12 +154,7 @@ git clone https://github.com/taosdata/TDengine.git
|
||||||
cd TDengine
|
cd TDengine
|
||||||
```
|
```
|
||||||
|
|
||||||
Go 连接器和 Grafana 插件在其他独立仓库,如果安装它们的话,需要在 TDengine 目录下通过此命令安装:
|
Go 连接器和 Grafana 插件已移到其他独立仓库。
|
||||||
|
|
||||||
```bash
|
|
||||||
git submodule update --init --recursive
|
|
||||||
```
|
|
||||||
|
|
||||||
如果使用 https 协议下载比较慢,可以通过修改 ~/.gitconfig 文件添加以下两行设置使用 ssh 协议下载。需要首先上传 ssh 密钥到 GitHub,详细方法请参考 GitHub 官方文档。
|
如果使用 https 协议下载比较慢,可以通过修改 ~/.gitconfig 文件添加以下两行设置使用 ssh 协议下载。需要首先上传 ssh 密钥到 GitHub,详细方法请参考 GitHub 官方文档。
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -187,7 +175,6 @@ git submodule update --init --recursive
|
||||||
这个脚本等价于执行如下命令:
|
这个脚本等价于执行如下命令:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git submodule update --init --recursive
|
|
||||||
mkdir debug
|
mkdir debug
|
||||||
cd debug
|
cd debug
|
||||||
cmake .. -DBUILD_TOOLS=true
|
cmake .. -DBUILD_TOOLS=true
|
||||||
|
|
19
README.md
19
README.md
|
@ -53,19 +53,12 @@ To build TDengine, use [CMake](https://cmake.org/) 3.0.2 or higher versions in t
|
||||||
|
|
||||||
## Install build dependencies
|
## Install build dependencies
|
||||||
|
|
||||||
### Ubuntu 16.04 and above or Debian
|
### Ubuntu 18.04 and above or Debian
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Ubuntu 14.04
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt-get install -y gcc cmake3 build-essential git binutils-2.26
|
|
||||||
export PATH=/usr/lib/binutils-2.26/bin:$PATH
|
|
||||||
```
|
|
||||||
|
|
||||||
To compile and package the JDBC driver source code, you should have a Java jdk-8 or higher and Apache Maven 2.7 or higher installed.
|
To compile and package the JDBC driver source code, you should have a Java jdk-8 or higher and Apache Maven 2.7 or higher installed.
|
||||||
|
|
||||||
To install openjdk-8:
|
To install openjdk-8:
|
||||||
|
@ -91,7 +84,7 @@ To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debia
|
||||||
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config
|
||||||
```
|
```
|
||||||
|
|
||||||
### CentOS 7
|
### CentOS 7.9
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo yum install epel-release
|
sudo yum install epel-release
|
||||||
|
@ -164,12 +157,7 @@ git clone https://github.com/taosdata/TDengine.git
|
||||||
cd TDengine
|
cd TDengine
|
||||||
```
|
```
|
||||||
|
|
||||||
The connectors for go & Grafana and some tools have been moved to separated repositories,
|
The connectors for go & Grafana and some tools have been moved to separated repositories.
|
||||||
so you should run this command in the TDengine directory to install them:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git submodule update --init --recursive
|
|
||||||
```
|
|
||||||
|
|
||||||
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
|
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
|
||||||
|
|
||||||
|
@ -191,7 +179,6 @@ You can run the bash script `build.sh` to build both TDengine and taosTools incl
|
||||||
It equals to execute following commands:
|
It equals to execute following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git submodule update --init --recursive
|
|
||||||
mkdir debug
|
mkdir debug
|
||||||
cd debug
|
cd debug
|
||||||
cmake .. -DBUILD_TOOLS=true
|
cmake .. -DBUILD_TOOLS=true
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -d debug ]; then
|
||||||
|
mkdir debug || echo -e "failed to make directory for build"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd debug && cmake .. -DBUILD_TOOLS=true && make
|
||||||
|
|
|
@ -115,9 +115,7 @@ ELSE ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
IF (TD_INTEL_64 OR TD_INTEL_32)
|
||||||
ADD_DEFINITIONS("-D_TD_ARM_")
|
|
||||||
ELSE ()
|
|
||||||
ADD_DEFINITIONS("-msse4.2")
|
ADD_DEFINITIONS("-msse4.2")
|
||||||
IF("${FMA_SUPPORT}" MATCHES "true")
|
IF("${FMA_SUPPORT}" MATCHES "true")
|
||||||
MESSAGE(STATUS "turn fma function support on")
|
MESSAGE(STATUS "turn fma function support on")
|
||||||
|
|
|
@ -10,7 +10,9 @@ ELSEIF (TD_WINDOWS)
|
||||||
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector)
|
||||||
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
||||||
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg DESTINATION cfg)
|
INSTALL(CODE "IF (NOT EXISTS ${CMAKE_INSTALL_PREFIX}/cfg/taos.cfg)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg ${CMAKE_INSTALL_PREFIX}/cfg/taos.cfg)
|
||||||
|
ENDIF ()")
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/include/client/taos.h DESTINATION include)
|
INSTALL(FILES ${TD_SOURCE_DIR}/include/client/taos.h DESTINATION include)
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/include/util/taoserror.h DESTINATION include)
|
INSTALL(FILES ${TD_SOURCE_DIR}/include/util/taoserror.h DESTINATION include)
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/include/libs/function/taosudf.h DESTINATION include)
|
INSTALL(FILES ${TD_SOURCE_DIR}/include/libs/function/taosudf.h DESTINATION include)
|
||||||
|
@ -20,6 +22,7 @@ ELSEIF (TD_WINDOWS)
|
||||||
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
|
||||||
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosd.exe DESTINATION .)
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosd.exe DESTINATION .)
|
||||||
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/udfd.exe DESTINATION .)
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/udfd.exe DESTINATION .)
|
||||||
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosBenchmark.exe DESTINATION .)
|
||||||
|
|
||||||
IF (TD_MVN_INSTALLED)
|
IF (TD_MVN_INSTALLED)
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
|
||||||
|
|
|
@ -85,26 +85,36 @@ IF ("${CPUTYPE}" STREQUAL "")
|
||||||
MESSAGE(STATUS "The current platform is aarch32")
|
MESSAGE(STATUS "The current platform is aarch32")
|
||||||
SET(PLATFORM_ARCH_STR "arm")
|
SET(PLATFORM_ARCH_STR "arm")
|
||||||
SET(TD_ARM_32 TRUE)
|
SET(TD_ARM_32 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_32")
|
||||||
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||||
MESSAGE(STATUS "The current platform is aarch64")
|
MESSAGE(STATUS "The current platform is aarch64")
|
||||||
SET(PLATFORM_ARCH_STR "arm64")
|
SET(PLATFORM_ARCH_STR "arm64")
|
||||||
SET(TD_ARM_64 TRUE)
|
SET(TD_ARM_64 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_64")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ELSE ()
|
ELSE ()
|
||||||
# if generate ARM version:
|
# if generate ARM version:
|
||||||
# cmake -DCPUTYPE=aarch32 .. or cmake -DCPUTYPE=aarch64
|
# cmake -DCPUTYPE=aarch32 .. or cmake -DCPUTYPE=aarch64
|
||||||
IF (${CPUTYPE} MATCHES "aarch32")
|
IF (${CPUTYPE} MATCHES "aarch32" OR ${CPUTYPE} MATCHES "arm32")
|
||||||
SET(PLATFORM_ARCH_STR "arm")
|
SET(PLATFORM_ARCH_STR "arm")
|
||||||
MESSAGE(STATUS "input cpuType: aarch32")
|
MESSAGE(STATUS "input cpuType: aarch32")
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_32")
|
||||||
SET(TD_ARM_32 TRUE)
|
SET(TD_ARM_32 TRUE)
|
||||||
ELSEIF (${CPUTYPE} MATCHES "aarch64")
|
ELSEIF (${CPUTYPE} MATCHES "aarch64" OR ${CPUTYPE} MATCHES "arm64")
|
||||||
SET(PLATFORM_ARCH_STR "arm64")
|
SET(PLATFORM_ARCH_STR "arm64")
|
||||||
MESSAGE(STATUS "input cpuType: aarch64")
|
MESSAGE(STATUS "input cpuType: aarch64")
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_ARM_64")
|
||||||
SET(TD_ARM_64 TRUE)
|
SET(TD_ARM_64 TRUE)
|
||||||
ELSEIF (${CPUTYPE} MATCHES "mips64")
|
ELSEIF (${CPUTYPE} MATCHES "mips64")
|
||||||
SET(PLATFORM_ARCH_STR "mips")
|
SET(PLATFORM_ARCH_STR "mips")
|
||||||
MESSAGE(STATUS "input cpuType: mips64")
|
MESSAGE(STATUS "input cpuType: mips64")
|
||||||
SET(TD_MIPS_64 TRUE)
|
SET(TD_MIPS_64 TRUE)
|
||||||
|
ADD_DEFINITIONS("-D_TD_MIPS_")
|
||||||
|
ADD_DEFINITIONS("-D_TD_MIPS_64")
|
||||||
ELSEIF (${CPUTYPE} MATCHES "x64")
|
ELSEIF (${CPUTYPE} MATCHES "x64")
|
||||||
SET(PLATFORM_ARCH_STR "amd64")
|
SET(PLATFORM_ARCH_STR "amd64")
|
||||||
MESSAGE(STATUS "input cpuType: x64")
|
MESSAGE(STATUS "input cpuType: x64")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG 3c7dafe
|
GIT_TAG 2d68404
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
# taosws-rs
|
# taosws-rs
|
||||||
ExternalProject_Add(taosws-rs
|
ExternalProject_Add(taosws-rs
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
||||||
GIT_TAG 29424d5
|
GIT_TAG 97c4bac
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -27,6 +27,10 @@ else ()
|
||||||
cat("${TD_SUPPORT_DIR}/taosadapter_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/taosadapter_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||||
|
cat("${TD_SUPPORT_DIR}/jemalloc_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
# pthread
|
# pthread
|
||||||
if(${BUILD_PTHREAD})
|
if(${BUILD_PTHREAD})
|
||||||
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
@ -392,6 +396,19 @@ if(${BUILD_WITH_SQLITE})
|
||||||
endif(NOT TD_WINDOWS)
|
endif(NOT TD_WINDOWS)
|
||||||
endif(${BUILD_WITH_SQLITE})
|
endif(${BUILD_WITH_SQLITE})
|
||||||
|
|
||||||
|
# jemalloc
|
||||||
|
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||||
|
include(ExternalProject)
|
||||||
|
ExternalProject_Add(jemalloc
|
||||||
|
PREFIX "jemalloc"
|
||||||
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc
|
||||||
|
BUILD_IN_SOURCE 1
|
||||||
|
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/
|
||||||
|
BUILD_COMMAND ${MAKE}
|
||||||
|
)
|
||||||
|
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
# addr2line
|
# addr2line
|
||||||
if(${BUILD_ADDR2LINE})
|
if(${BUILD_ADDR2LINE})
|
||||||
if(NOT ${TD_WINDOWS})
|
if(NOT ${TD_WINDOWS})
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 500 105" style="enable-background:new 0 0 1000 210;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#18499D;}
|
||||||
|
.st1{fill-rule:evenodd;clip-rule:evenodd;fill:#18499D;}
|
||||||
|
</style>
|
||||||
|
<g>
|
||||||
|
<path class="st0" d="M153.2,27.1h-16v49h-11.1v-49h-15.9v-9.7h43L153.2,27.1z"/>
|
||||||
|
<path class="st0" d="M180.6,17.4c17.1,0,28.5,4.9,28.5,29.4c0,22.7-11.4,29.4-28.5,29.4h-19V17.4H180.6z M180.1,66.5
|
||||||
|
c11.3,0,17.6-4.3,17.6-19.8c0-16.3-6.5-20-17.6-20h-7.4v39.8L180.1,66.5z"/>
|
||||||
|
<path class="st0" d="M259.4,55.3l-30,2c0.2,7.7,4,11.2,13.1,11.2c5.1-0.1,10.2-1.1,14.9-3.1V74c-2.7,1.6-9.3,3-16.8,3
|
||||||
|
c-13.9,0-21.9-5.2-21.9-23.7s8-23.7,21.9-23.7c15.8,0,19.1,9,19.1,19.7C259.8,51.3,259.7,53.3,259.4,55.3z M250,48.2
|
||||||
|
c0-5.7-1.2-10.5-9.3-10.5c-8.5,0-11,4.1-11.3,12L250,48.2z"/>
|
||||||
|
<path class="st0" d="M310.8,44.8v31.3h-10.6V47.8c0-6.4-1.4-9.4-7.9-9.4c-5.4,0-9.2,1.5-11.2,7.3v30.5h-10.6V30.4h10.6v5.8
|
||||||
|
c2.6-4.7,8-6.6,14.4-6.6C307.1,29.6,310.8,35.1,310.8,44.8z"/>
|
||||||
|
<path class="st0" d="M364.8,30.4v42.2c0,12.6-6.5,20.4-24.3,20.4c-4.1,0-8.3-0.4-12.4-1.1v-8.5c3.9,0.9,7.8,1.3,11.8,1.3
|
||||||
|
c10.1,0,14.4-3.3,14.4-12.5v-3.2c-2,4.5-5.7,7.2-14.1,7.2c-15,0-18.7-9.4-18.7-23.3c0-12.6,3.7-23.3,18.7-23.3
|
||||||
|
c8.6,0,12.4,3.1,14.1,7.5v-6.7H364.8z M354.7,52.8c0-9.2-2-15.1-11.9-15.1c-9.4,0-10.4,7.3-10.4,15.1c0,8.5,1.3,15.3,10.4,15.3
|
||||||
|
C352.7,68.2,354.7,62.6,354.7,52.8z"/>
|
||||||
|
<path class="st0" d="M377.3,17.6c0-5.2,1.3-5.7,6-5.7s6,0.5,6,5.7s-1.3,5.8-6,5.8S377.3,22.7,377.3,17.6z M378,30.4h10.6v45.7H378
|
||||||
|
L378,30.4z"/>
|
||||||
|
<path class="st0" d="M442,44.8v31.3h-10.5V47.8c0-6.4-1.4-9.4-7.9-9.4c-5.4,0-9.2,1.5-11.2,7.3v30.5h-10.6V30.4h10.6v5.8
|
||||||
|
c2.6-4.7,8-6.6,14.4-6.6C438.3,29.6,442,35.1,442,44.8z"/>
|
||||||
|
<path class="st0" d="M493.3,55.3l-30,2c0.3,7.7,4,11.2,13.1,11.2c5.1-0.1,10.2-1.1,14.9-3.1V74c-2.7,1.6-9.3,3-16.8,3
|
||||||
|
c-13.9,0-21.9-5.2-21.9-23.7s8-23.7,21.9-23.7c15.8,0,19.1,9,19.1,19.7C493.8,51.3,493.6,53.3,493.3,55.3z M483.9,48.2
|
||||||
|
c0-5.7-1.2-10.5-9.3-10.5c-8.5,0-11,4.1-11.3,12L483.9,48.2z"/>
|
||||||
|
<path class="st1" d="M48.8,11.8c3.1,0,5.6,2.5,5.6,5.6c0,3.1-2.5,5.6-5.6,5.6s-5.6-2.5-5.6-5.6c0,0,0,0,0,0
|
||||||
|
C43.3,14.3,45.7,11.8,48.8,11.8z M11.8,38.5c3.1,0,5.6,2.5,5.6,5.6c0,3.1-2.5,5.6-5.6,5.6s-5.6-2.5-5.6-5.6
|
||||||
|
C6.3,41,8.8,38.5,11.8,38.5z M26.3,82.1c3.1,0,5.6,2.5,5.6,5.6s-2.5,5.6-5.6,5.6c-3.1,0-5.6-2.5-5.6-5.6
|
||||||
|
C20.7,84.6,23.2,82.1,26.3,82.1z M71.3,82.1c3.1,0,5.6,2.5,5.6,5.6s-2.5,5.6-5.6,5.6s-5.6-2.5-5.6-5.6
|
||||||
|
C65.7,84.6,68.2,82.1,71.3,82.1z M57,44.9H40.6l-5,15.5l13.2,9.6L62,60.5L57,44.9L57,44.9z M41.1,43.6L46.8,26
|
||||||
|
c-0.4-0.1-0.9-0.2-1.3-0.4l-5.8,18h-19c0,0.2,0,0.3,0,0.5c0,0.3,0,0.6,0,0.8h18.5l-4.8,14.7l-15-10.9c-0.2,0.4-0.5,0.7-0.8,1.1
|
||||||
|
l12.8,9.3l0,0l2.6,1.9l-0.9,2.5l0,0l-5,15.5c0.4,0.1,0.9,0.2,1.3,0.4l5.7-17.5l12.5,9.1L32.9,81.7c0.3,0.3,0.6,0.7,0.8,1l15.1-11
|
||||||
|
l15.1,11c0.2-0.4,0.5-0.7,0.8-1L49.9,70.9l12.5-9.1l0.6,1.7l0,0l5.2,15.9c0.4-0.2,0.8-0.3,1.3-0.4l-5.8-18l2.6-1.9L79,49.8
|
||||||
|
c-0.3-0.3-0.5-0.7-0.8-1.1l-12.4,9L65.4,58l-2.3,1.6l-4.8-14.7h18.5c0-0.3,0-0.6,0-0.9c0-0.2,0-0.3,0-0.5h-19l-5.8-18
|
||||||
|
c-0.4,0.2-0.8,0.3-1.3,0.4l5.7,17.6L41.1,43.6z M18.9,38.6l22.5-16.4c0.2,0.4,0.5,0.7,0.8,1L19.6,39.7C19.4,39.3,19.1,39,18.9,38.6
|
||||||
|
L18.9,38.6z M22.9,79.4l-8.7-26.8c0.4-0.1,0.8-0.3,1.2-0.4L24.2,79C23.7,79.1,23.3,79.3,22.9,79.4L22.9,79.4z M62.5,88H35.2
|
||||||
|
c0-0.1,0-0.2,0-0.4c0-0.3,0-0.6,0-1h27.3c0,0.3,0,0.6,0,1C62.4,87.8,62.4,87.9,62.5,88L62.5,88z M83.5,52.7l-8.7,26.8
|
||||||
|
c-0.4-0.2-0.8-0.3-1.2-0.4l8.7-26.8C82.6,52.4,83,52.6,83.5,52.7z M56.3,22.2l22.5,16.4c-0.3,0.3-0.5,0.7-0.7,1.1L55.4,23.3
|
||||||
|
C55.7,22.9,56,22.6,56.3,22.2z M85.8,38.5c3.1,0,5.6,2.5,5.6,5.6c0,3.1-2.5,5.6-5.6,5.6s-5.6-2.5-5.6-5.6
|
||||||
|
C80.2,41,82.7,38.5,85.8,38.5z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.7 KiB |
|
@ -31,6 +31,6 @@ func main() {
|
||||||
log.Fatalln("scan error:\n", err)
|
log.Fatalln("scan error:\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Fatalln(r.ts, r.current)
|
log.Println(r.ts, r.current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
const conn = taos.connect({ host: "localhost", database: "power" });
|
const conn = taos.connect({ host: "localhost", database: "power" });
|
||||||
const cursor = conn.cursor();
|
const cursor = conn.cursor();
|
||||||
|
|
||||||
|
@ -18,4 +18,3 @@ try {
|
||||||
conn.close();
|
conn.close();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
// bug here: jira 14506
|
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
const taos = require("td2.0-connector");
|
const { options, connect } = require("@tdengine/rest");
|
||||||
|
|
||||||
var conn = taos.connect({
|
async function test() {
|
||||||
host: "localhost",
|
options.path = "/rest/sql";
|
||||||
port: 6030,
|
options.host = "localhost";
|
||||||
user: "root",
|
let conn = connect(options);
|
||||||
password: "taosdata",
|
let cursor = conn.cursor();
|
||||||
});
|
try {
|
||||||
conn.close();
|
let res = await cursor.query("SELECT server_version()");
|
||||||
|
res.toString();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test();
|
||||||
|
|
||||||
// run with: node connect.js
|
|
||||||
// output:
|
// output:
|
||||||
// Successfully connected to TDengine
|
// server_version() |
|
||||||
|
// ===================
|
||||||
|
// 3.0.0.0 |
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({
|
const conn = taos.connect({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({
|
const conn = taos.connect({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
@ -11,11 +11,11 @@ try {
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"
|
"CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"
|
||||||
);
|
);
|
||||||
var sql = `INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)
|
var sql = `INSERT INTO power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)
|
||||||
power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)
|
power.d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)
|
||||||
power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)
|
power.d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)
|
||||||
power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)`;
|
power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)`;
|
||||||
cursor.execute(sql);
|
cursor.execute(sql,{'quiet':false});
|
||||||
} finally {
|
} finally {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
conn.close();
|
conn.close();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({
|
const conn = taos.connect({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
@ -24,10 +24,10 @@ function insertData() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// bind table name and tags
|
// bind table name and tags
|
||||||
let tagBind = new taos.TaosBind(2);
|
let tagBind = new taos.TaosMultiBindArr(2);
|
||||||
tagBind.bindBinary("California.SanFrancisco");
|
tagBind.multiBindBinary(["California.SanFrancisco"]);
|
||||||
tagBind.bindInt(2);
|
tagBind.multiBindInt([2]);
|
||||||
cursor.stmtSetTbnameTags("d1001", tagBind.getBind());
|
cursor.stmtSetTbnameTags("d1001", tagBind.getMultiBindArr());
|
||||||
|
|
||||||
// bind values
|
// bind values
|
||||||
let valueBind = new taos.TaosMultiBindArr(4);
|
let valueBind = new taos.TaosMultiBindArr(4);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({
|
const conn = taos.connect({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({
|
const conn = taos.connect({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({
|
const conn = taos.connect({
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
|
@ -23,25 +23,22 @@ function insertData() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// bind table name and tags
|
// bind table name and tags
|
||||||
let tagBind = new taos.TaosBind(2);
|
let tagBind = new taos.TaosMultiBindArr(2);
|
||||||
tagBind.bindBinary("California.SanFrancisco");
|
tagBind.multiBindBinary(["California.SanFrancisco"]);
|
||||||
tagBind.bindInt(2);
|
tagBind.multiBindInt([2]);
|
||||||
cursor.stmtSetTbnameTags("d1001", tagBind.getBind());
|
cursor.stmtSetTbnameTags("d1001", tagBind.getMultiBindArr());
|
||||||
|
|
||||||
// bind values
|
// bind values
|
||||||
let rows = [
|
let rows = [[1648432611249, 1648432611749], [10.3, 12.6], [219, 218], [0.31, 0.33]];
|
||||||
[1648432611249, 10.3, 219, 0.31],
|
|
||||||
[1648432611749, 12.6, 218, 0.33],
|
let valueBind = new taos.TaosMultiBindArr(4);
|
||||||
];
|
valueBind.multiBindTimestamp(rows[0]);
|
||||||
for (let row of rows) {
|
valueBind.multiBindFloat(rows[1]);
|
||||||
let valueBind = new taos.TaosBind(4);
|
valueBind.multiBindInt(rows[2]);
|
||||||
valueBind.bindTimestamp(row[0]);
|
valueBind.multiBindFloat(rows[3]);
|
||||||
valueBind.bindFloat(row[1]);
|
cursor.stmtBindParamBatch(valueBind.getMultiBindArr());
|
||||||
valueBind.bindInt(row[2]);
|
cursor.stmtAddBatch();
|
||||||
valueBind.bindFloat(row[3]);
|
|
||||||
cursor.stmtBindParam(valueBind.getBind());
|
|
||||||
cursor.stmtAddBatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// execute
|
// execute
|
||||||
cursor.stmtExecute();
|
cursor.stmtExecute();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({ host: "localhost", database: "power" });
|
const conn = taos.connect({ host: "localhost", database: "power" });
|
||||||
const cursor = conn.cursor();
|
const cursor = conn.cursor();
|
||||||
|
@ -9,8 +9,6 @@ query.execute().then(function (result) {
|
||||||
|
|
||||||
// output:
|
// output:
|
||||||
// Successfully connected to TDengine
|
// Successfully connected to TDengine
|
||||||
// Query OK, 2 row(s) in set (0.00317767s)
|
|
||||||
|
|
||||||
// ts | current |
|
// ts | current |
|
||||||
// =======================================================
|
// =======================================================
|
||||||
// 2018-10-03 14:38:05.000 | 10.3 |
|
// 2018-10-03 14:38:05.000 | 10.3 |
|
||||||
|
|
|
@ -1,4 +1,51 @@
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
|
|
||||||
const conn = taos.connect({ host: "localhost", database: "power" });
|
const conn = taos.connect({ host: "localhost", database: "power" });
|
||||||
// 未完成
|
var cursor = conn.cursor();
|
||||||
|
|
||||||
|
function runConsumer() {
|
||||||
|
|
||||||
|
// create topic
|
||||||
|
cursor.execute("create topic topic_name_example as select * from meters");
|
||||||
|
|
||||||
|
let consumer = taos.consumer({
|
||||||
|
'group.id': 'tg2',
|
||||||
|
'td.connect.user': 'root',
|
||||||
|
'td.connect.pass': 'taosdata',
|
||||||
|
'msg.with.table.name': 'true',
|
||||||
|
'enable.auto.commit': 'true'
|
||||||
|
});
|
||||||
|
|
||||||
|
// subscribe the topic just created.
|
||||||
|
consumer.subscribe("topic_name_example");
|
||||||
|
|
||||||
|
// get subscribe topic list
|
||||||
|
let topicList = consumer.subscription();
|
||||||
|
console.log(topicList);
|
||||||
|
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
let msg = consumer.consume(100);
|
||||||
|
console.log(msg.topicPartition);
|
||||||
|
console.log(msg.block);
|
||||||
|
console.log(msg.fields)
|
||||||
|
consumer.commit(msg);
|
||||||
|
console.log(`=======consumer ${i} done`)
|
||||||
|
}
|
||||||
|
|
||||||
|
consumer.unsubscribe();
|
||||||
|
consumer.close();
|
||||||
|
|
||||||
|
// drop topic
|
||||||
|
cursor.execute("drop topic topic_name_example");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
runConsumer();
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
cursor.close();
|
||||||
|
conn.close();
|
||||||
|
}, 2000);
|
||||||
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"td2.0-connector": "^2.0.12",
|
"@tdengine/client": "^3.0.0",
|
||||||
"td2.0-rest-connector": "^1.0.0"
|
"@tdengine/rest": "^3.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { options, connect } = require("td2.0-rest-connector");
|
const { options, connect } = require("@tdengine/rest");
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
options.path = "/rest/sqlt";
|
options.path = "/rest/sqlt";
|
||||||
|
@ -17,4 +17,4 @@ test();
|
||||||
// output:
|
// output:
|
||||||
// server_version() |
|
// server_version() |
|
||||||
// ===================
|
// ===================
|
||||||
// 2.4.0.12 |
|
// 3.0.0.0 |
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import taos
|
import taos
|
||||||
|
|
||||||
lines = ["d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,California.SanFrancisco,2",
|
lines = ["d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,'California.SanFrancisco',2",
|
||||||
"d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,California.LosAngeles,3",
|
"d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,'California.LosAngeles',3",
|
||||||
"d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,California.LosAngeles,2",
|
"d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,'California.LosAngeles',2",
|
||||||
"d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,California.LosAngeles,3",
|
"d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,'California.LosAngeles',3",
|
||||||
"d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,California.SanFrancisco,3",
|
"d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,'California.SanFrancisco',3",
|
||||||
"d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,California.SanFrancisco,2",
|
"d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,'California.SanFrancisco',2",
|
||||||
"d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,California.SanFrancisco,2",
|
"d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,'California.SanFrancisco',2",
|
||||||
"d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,California.LosAngeles,2"]
|
"d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,'California.LosAngeles',2"]
|
||||||
|
|
||||||
|
|
||||||
def get_connection() -> taos.TaosConnection:
|
def get_connection() -> taos.TaosConnection:
|
||||||
|
|
|
@ -10,9 +10,11 @@ title: 通过 Docker 快速体验 TDengine
|
||||||
如果已经安装了 docker, 只需执行下面的命令。
|
如果已经安装了 docker, 只需执行下面的命令。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
|
docker run -d -p 6030:6030 -p 6041/6041 -p 6043-6049/6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
|
||||||
```
|
```
|
||||||
|
|
||||||
|
注意:TDengine 3.0 服务端仅使用 6030 TCP 端口。6041 为 taosAdapter 所使用提供 REST 服务端口。6043-6049 为 taosAdapter 提供第三方应用接入所使用端口,可根据需要选择是否打开。
|
||||||
|
|
||||||
确定该容器已经启动并且在正常运行
|
确定该容器已经启动并且在正常运行
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -51,35 +53,16 @@ $ taos
|
||||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||||
|
|
||||||
Server is Enterprise trial Edition, ver:3.0.0.0 and will expire at 2022-09-24 15:29:46.
|
Server is Community Edition.
|
||||||
|
|
||||||
taos>
|
taos>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 启动 REST 服务
|
|
||||||
|
|
||||||
taosAdapter 是 TDengine 中提供 REST 服务的组件。下面这条命令会在容器中同时启动 `taosd` 和 `taosadapter` 两个服务组件。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d --name tdengine-all -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
|
|
||||||
```
|
|
||||||
|
|
||||||
如果想只启动 `taosadapter`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d --name tdengine-taosa -p 6041-6049:6041-6049 -p 6041-6049:6041-6049/udp -e TAOS_FIRST_EP=tdengine-all tdengine/tdengine:3.0.0.0 taosadapter
|
|
||||||
```
|
|
||||||
|
|
||||||
如果想只启动 `taosd`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-6042/udp -e TAOS_DISABLE_ADAPTER=true tdengine/tdengine:3.0.0.0
|
|
||||||
```
|
|
||||||
|
|
||||||
## 访问 REST 接口
|
## 访问 REST 接口
|
||||||
|
|
||||||
|
taosAdapter 是 TDengine 中提供 REST 服务的组件。下面这条命令会在容器中同时启动 `taosd` 和 `taosadapter` 两个服务组件。默认 Docker 镜像同时启动 TDengine 后台服务 taosd 和 taosAdatper。
|
||||||
|
|
||||||
可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。
|
可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -96,6 +79,22 @@ curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql
|
||||||
|
|
||||||
TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。
|
TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。
|
||||||
|
|
||||||
|
## 单独启动 REST 服务
|
||||||
|
|
||||||
|
如果想只启动 `taosadapter`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --network=host --name tdengine-taosa -e TAOS_FIRST_EP=tdengine-taosd tdengine/tdengine:3.0.0.0 taosadapter
|
||||||
|
```
|
||||||
|
|
||||||
|
只启动 `taosd`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d --network=host --name tdengine-taosd -e TAOS_DISABLE_ADAPTER=true tdengine/tdengine:3.0.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
注意以上为容器使用 host 方式网络配置进行单独部署 taosAdapter 的命令行参数。其他网络访问方式请设置 hostname、 DNS 等必要的网络配置。
|
||||||
|
|
||||||
## 写入数据
|
## 写入数据
|
||||||
|
|
||||||
可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入。
|
可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入。
|
||||||
|
@ -107,7 +106,7 @@ TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
该命令将在数据库 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"。
|
该命令将在数据库 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 被设置为 "San Francisco" 或者 "Los Angeles"等城市名称。
|
||||||
|
|
||||||
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能。
|
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能。
|
||||||
|
|
||||||
|
@ -129,10 +128,10 @@ taos> select count(*) from test.meters;
|
||||||
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
||||||
```
|
```
|
||||||
|
|
||||||
查询 location="California.SanFrancisco" 的记录总条数:
|
查询 location="San Francisco" 的记录总条数:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
taos> select count(*) from test.meters where location="California.SanFrancisco";
|
taos> select count(*) from test.meters where location="San Francisco";
|
||||||
```
|
```
|
||||||
|
|
||||||
查询 groupId=10 的所有记录的平均值、最大值、最小值等:
|
查询 groupId=10 的所有记录的平均值、最大值、最小值等:
|
||||||
|
@ -145,4 +144,4 @@ taos> select avg(current), max(voltage), min(phase) from test.meters where group
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||||
```
|
```
|
||||||
|
|
|
@ -11,7 +11,7 @@ import TabItem from "@theme/TabItem";
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包。
|
TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包。也支持通过 `apt-get` 工具从线上进行安装。
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
|
@ -46,114 +46,122 @@ apt-get 方式只适用于 Debian 或 Ubuntu 系统
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem label="Deb 安装" value="debinst">
|
<TabItem label="Deb 安装" value="debinst">
|
||||||
|
|
||||||
1、从官网下载获得 deb 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.deb;
|
1、从官网下载获得 deb 安装包,例如 TDengine-server-3.0.0.10002-Linux-x64.deb;
|
||||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
2、进入到 TDengine-server-3.0.0.10002-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb
|
$ sudo dpkg -i TDengine-server-3.0.0.10002-Linux-x64.deb
|
||||||
(Reading database ... 137504 files and directories currently installed.)
|
Selecting previously unselected package tdengine.
|
||||||
Preparing to unpack TDengine-server-2.4.0.7-Linux-x64.deb ...
|
(Reading database ... 119653 files and directories currently installed.)
|
||||||
TDengine is removed successfully!
|
Preparing to unpack TDengine-server-3.0.0.10002-Linux-x64.deb ...
|
||||||
Unpacking tdengine (2.4.0.7) over (2.4.0.7) ...
|
Unpacking tdengine (3.0.0.10002) ...
|
||||||
Setting up tdengine (2.4.0.7) ...
|
Setting up tdengine (3.0.0.10002) ...
|
||||||
Start to install TDengine...
|
Start to install TDengine...
|
||||||
|
|
||||||
System hostname is: ubuntu-1804
|
System hostname is: v3cluster-0002
|
||||||
|
|
||||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||||
OR leave it blank to build one:
|
OR leave it blank to build one:
|
||||||
|
|
||||||
Enter your email address for priority support or enter empty to skip:
|
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.
|
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 configure TDengine : edit /etc/taos/taos.cfg
|
||||||
To start TDengine : sudo systemctl start taosd
|
To start TDengine : sudo systemctl start taosd
|
||||||
To access TDengine : taos -h ubuntu-1804 to login into TDengine server
|
To access TDengine : taos -h v3cluster-0002 to login into TDengine server
|
||||||
|
|
||||||
|
|
||||||
TDengine is installed successfully!
|
TDengine is installed successfully!
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem label="RPM 安装" value="rpminst">
|
<TabItem label="RPM 安装" value="rpminst">
|
||||||
|
|
||||||
1、从官网下载获得 rpm 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.rpm;
|
1、从官网下载获得 rpm 安装包,例如 TDengine-server-3.0.0.10002-Linux-x64.rpm;
|
||||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
2、进入到 TDengine-server-3.0.0.10002-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm
|
$ sudo rpm -ivh TDengine-server-3.0.0.10002-Linux-x64.rpm
|
||||||
Preparing... ################################# [100%]
|
Preparing... ################################# [100%]
|
||||||
|
Stop taosd service success!
|
||||||
Updating / installing...
|
Updating / installing...
|
||||||
1:tdengine-2.4.0.7-3 ################################# [100%]
|
1:tdengine-3.0.0.10002-3 ################################# [100%]
|
||||||
Start to install TDengine...
|
Start to install TDengine...
|
||||||
|
|
||||||
System hostname is: centos7
|
System hostname is: chenhaoran01
|
||||||
|
|
||||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||||
OR leave it blank to build one:
|
OR leave it blank to build one:
|
||||||
|
|
||||||
Enter your email address for priority support or enter empty to skip:
|
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.
|
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 configure TDengine : edit /etc/taos/taos.cfg
|
||||||
To start TDengine : sudo systemctl start taosd
|
To start TDengine : sudo systemctl start taosd
|
||||||
To access TDengine : taos -h centos7 to login into TDengine server
|
To access TDengine : taos -h chenhaoran01 to login into TDengine server
|
||||||
|
|
||||||
|
|
||||||
TDengine is installed successfully!
|
TDengine is installed successfully!
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<TabItem label="tar.gz 安装" value="tarinst">
|
<TabItem label="tar.gz 安装" value="tarinst">
|
||||||
|
|
||||||
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.tar.gz;
|
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-3.0.0.10002-Linux-x64.tar.gz;
|
||||||
2、进入到 TDengine-server-2.4.0.7-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
2、进入到 TDengine-server-3.0.0.10002-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ tar xvzf TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
|
$ tar -zxvf TDengine-server-3.0.0.10002-Linux-x64.tar.gz
|
||||||
TDengine-enterprise-server-2.4.0.7/
|
TDengine-server-3.0.0.10002/
|
||||||
TDengine-enterprise-server-2.4.0.7/driver/
|
TDengine-server-3.0.0.10002/driver/
|
||||||
TDengine-enterprise-server-2.4.0.7/driver/vercomp.txt
|
TDengine-server-3.0.0.10002/driver/libtaos.so.3.0.0.10002
|
||||||
TDengine-enterprise-server-2.4.0.7/driver/libtaos.so.2.4.0.7
|
TDengine-server-3.0.0.10002/driver/vercomp.txt
|
||||||
TDengine-enterprise-server-2.4.0.7/install.sh
|
TDengine-server-3.0.0.10002/release_note
|
||||||
TDengine-enterprise-server-2.4.0.7/examples/
|
TDengine-server-3.0.0.10002/taos.tar.gz
|
||||||
|
TDengine-server-3.0.0.10002/install.sh
|
||||||
...
|
...
|
||||||
|
|
||||||
$ ll
|
$ ll
|
||||||
total 43816
|
total 56832
|
||||||
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ./
|
drwxr-xr-x 3 root root 4096 Aug 8 10:29 ./
|
||||||
drwxr-xr-x 20 ubuntu ubuntu 4096 Feb 22 09:30 ../
|
drwxrwxrwx 6 root root 4096 Aug 5 16:45 ../
|
||||||
drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 TDengine-enterprise-server-2.4.0.7/
|
drwxr-xr-x 4 root root 4096 Aug 4 18:03 TDengine-server-3.0.0.10002/
|
||||||
-rw-rw-r-- 1 ubuntu ubuntu 44852544 Feb 22 09:31 TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
|
-rwxr-xr-x 1 root root 58183066 Aug 8 10:28 TDengine-server-3.0.0.10002-Linux-x64.tar.gz*
|
||||||
|
|
||||||
$ cd TDengine-enterprise-server-2.4.0.7/
|
$ cd TDengine-server-3.0.0.10002/
|
||||||
|
|
||||||
$ ll
|
$ ll
|
||||||
total 40784
|
total 51612
|
||||||
drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 ./
|
drwxr-xr-x 4 root root 4096 Aug 4 18:03 ./
|
||||||
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ../
|
drwxr-xr-x 3 root root 4096 Aug 8 10:29 ../
|
||||||
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 22 09:30 driver/
|
drwxr-xr-x 2 root root 4096 Aug 4 18:03 driver/
|
||||||
drwxrwxr-x 10 ubuntu ubuntu 4096 Feb 22 09:30 examples/
|
drwxr-xr-x 11 root root 4096 Aug 4 18:03 examples/
|
||||||
-rwxrwxr-x 1 ubuntu ubuntu 33294 Feb 22 09:30 install.sh*
|
-rwxr-xr-x 1 root root 30980 Aug 4 18:03 install.sh*
|
||||||
-rw-rw-r-- 1 ubuntu ubuntu 41704288 Feb 22 09:30 taos.tar.gz
|
-rw-r--r-- 1 root root 6724 Aug 4 18:03 release_note
|
||||||
|
-rw-r--r-- 1 root root 52793079 Aug 4 18:03 taos.tar.gz
|
||||||
|
|
||||||
$ sudo ./install.sh
|
$ sudo ./install.sh
|
||||||
|
|
||||||
Start to update TDengine...
|
Start to install TDengine...
|
||||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||||
Nginx for TDengine is updated successfully!
|
|
||||||
|
System hostname is: v3cluster-0002
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
To configure TDengine : edit /etc/taos/taos.cfg
|
To configure TDengine : edit /etc/taos/taos.cfg
|
||||||
To configure Taos Adapter (if has) : edit /etc/taos/taosadapter.toml
|
To configure taosadapter (if has) : edit /etc/taos/taosadapter.toml
|
||||||
To start TDengine : sudo systemctl start taosd
|
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
|
To access TDengine : taos -h v3cluster-0002 to login into TDengine server
|
||||||
|
|
||||||
TDengine is updated successfully!
|
TDengine is installed successfully!
|
||||||
Install taoskeeper as a standalone service
|
|
||||||
taoskeeper is installed, enable it by `systemctl enable taoskeeper`
|
|
||||||
```
|
```
|
||||||
|
|
||||||
:::info
|
:::info
|
||||||
|
@ -293,4 +301,4 @@ taos> select avg(current), max(voltage), min(phase) from test.meters where group
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||||
```
|
```
|
||||||
|
|
|
@ -25,6 +25,7 @@ TDengine 采用 SQL 作为查询语言。应用程序可以通过 REST API 或
|
||||||
- 单列、多列数据查询
|
- 单列、多列数据查询
|
||||||
- 标签和数值的多种过滤条件:>, <, =, <\>, like 等
|
- 标签和数值的多种过滤条件:>, <, =, <\>, like 等
|
||||||
- 聚合结果的分组(Group by)、排序(Order by)、约束输出(Limit/Offset)
|
- 聚合结果的分组(Group by)、排序(Order by)、约束输出(Limit/Offset)
|
||||||
|
- 时间窗口(Interval)、会话窗口(Session)和状态窗口(State_window)等窗口切分聚合查询
|
||||||
- 数值列及聚合结果的四则运算
|
- 数值列及聚合结果的四则运算
|
||||||
- 时间戳对齐的连接查询(Join Query: 隐式连接)操作
|
- 时间戳对齐的连接查询(Join Query: 隐式连接)操作
|
||||||
- 多种聚合/计算函数: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff 等
|
- 多种聚合/计算函数: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff 等
|
||||||
|
@ -40,7 +41,7 @@ taos> select * from d1001 where voltage > 215 order by ts desc limit 2;
|
||||||
Query OK, 2 row(s) in set (0.001100s)
|
Query OK, 2 row(s) in set (0.001100s)
|
||||||
```
|
```
|
||||||
|
|
||||||
为满足物联网场景的需求,TDengine 支持几个特殊的函数,比如 twa(时间加权平均),spread (最大值与最小值的差),last_row(最后一条记录)等,更多与物联网场景相关的函数将添加进来。TDengine 还支持连续查询。
|
为满足物联网场景的需求,TDengine 支持几个特殊的函数,比如 twa(时间加权平均),spread (最大值与最小值的差),last_row(最后一条记录)等,更多与物联网场景相关的函数将添加进来。
|
||||||
|
|
||||||
具体的查询语法请看 [TAOS SQL 的数据查询](/taos-sql/select) 章节。
|
具体的查询语法请看 [TAOS SQL 的数据查询](/taos-sql/select) 章节。
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now -
|
||||||
Query OK, 1 row(s) in set (0.002136s)
|
Query OK, 1 row(s) in set (0.002136s)
|
||||||
```
|
```
|
||||||
|
|
||||||
TDengine 仅容许对属于同一个超级表的表之间进行聚合查询,不同超级表之间的聚合查询不支持。在 [TAOS SQL 的数据查询](/taos-sql/select) 一章,查询类操作都会注明是否支持超级表。
|
在 [TAOS SQL 的数据查询](/taos-sql/select) 一章,查询类操作都会注明是否支持超级表。
|
||||||
|
|
||||||
## 降采样查询、插值
|
## 降采样查询、插值
|
||||||
|
|
||||||
|
|
|
@ -6,56 +6,144 @@ description: "支持用户编码的聚合函数和标量函数,在查询中嵌
|
||||||
|
|
||||||
在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。
|
在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。
|
||||||
|
|
||||||
从 2.2.0.0 版本开始,TDengine 支持通过 C/C++ 语言进行 UDF 定义。接下来结合示例讲解 UDF 的使用方法。
|
TDengine 支持通过 C/C++ 语言进行 UDF 定义。接下来结合示例讲解 UDF 的使用方法。
|
||||||
|
|
||||||
用户可以通过 UDF 实现两类函数: 标量函数 和 聚合函数。
|
用户可以通过 UDF 实现两类函数: 标量函数和聚合函数。标量函数对每行数据返回一个值,如求绝对值 abs,正弦函数 sin,字符串拼接函数 concat 等。聚合函数对多行数据进行返回一个值,如求平均数 avg,最大值 max 等。
|
||||||
|
|
||||||
## 用 C/C++ 语言来定义 UDF
|
实现 UDF 时,需要实现规定的接口函数
|
||||||
|
- 标量函数需要实现标量接口函数 scalarfn 。
|
||||||
|
- 聚合函数需要实现聚合接口函数 aggfn_start , aggfn , aggfn_finish。
|
||||||
|
- 如果需要初始化,实现 udf_init;如果需要清理工作,实现udf_destroy。
|
||||||
|
|
||||||
### 标量函数
|
接口函数的名称是 UDF 名称,或者是 UDF 名称和特定后缀(_start, _finish, _init, _destroy)的连接。列表中的scalarfn,aggfn, udf需要替换成udf函数名。
|
||||||
|
|
||||||
用户可以按照下列函数模板定义自己的标量计算函数
|
## 实现标量函数
|
||||||
|
标量函数实现模板如下
|
||||||
|
```c
|
||||||
|
#include "taos.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
#include "taosudf.h"
|
||||||
|
|
||||||
`int32_t udf(SUdfDataBlock* inputDataBlock, SUdfColumn *resultColumn)`
|
// initialization function. if no initialization, we can skip definition of it. The initialization function shall be concatenation of the udf name and _init suffix
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t scalarfn_init() {
|
||||||
|
// initialization.
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scalar function main computation function
|
||||||
|
// @param inputDataBlock, input data block composed of multiple columns with each column defined by SUdfColumn
|
||||||
|
// @param resultColumn, output column
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t scalarfn(SUdfDataBlock* inputDataBlock, SUdfColumn* resultColumn) {
|
||||||
|
// read data from inputDataBlock and process, then output to resultColumn.
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup function. if no cleanup related processing, we can skip definition of it. The destroy function shall be concatenation of the udf name and _destroy suffix.
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t scalarfn_destroy() {
|
||||||
|
// clean up
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
scalarfn 为函数名的占位符,需要替换成函数名,如bit_and。
|
||||||
|
|
||||||
|
## 实现聚合函数
|
||||||
|
|
||||||
|
聚合函数的实现模板如下
|
||||||
|
```c
|
||||||
|
#include "taos.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
#include "taosudf.h"
|
||||||
|
|
||||||
|
// Initialization function. if no initialization, we can skip definition of it. The initialization function shall be concatenation of the udf name and _init suffix
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t aggfn_init() {
|
||||||
|
// initialization.
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggregate start function. The intermediate value or the state(@interBuf) is initialized in this function. The function name shall be concatenation of udf name and _start suffix
|
||||||
|
// @param interbuf intermediate value to intialize
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t aggfn_start(SUdfInterBuf* interBuf) {
|
||||||
|
// initialize intermediate value in interBuf
|
||||||
|
return TSDB_CODE_SUCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggregate reduce function. This function aggregate old state(@interbuf) and one data bock(inputBlock) and output a new state(@newInterBuf).
|
||||||
|
// @param inputBlock input data block
|
||||||
|
// @param interBuf old state
|
||||||
|
// @param newInterBuf new state
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t aggfn(SUdfDataBlock* inputBlock, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
||||||
|
// read from inputBlock and interBuf and output to newInterBuf
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggregate function finish function. This function transforms the intermediate value(@interBuf) into the final output(@result). The function name must be concatenation of aggfn and _finish suffix.
|
||||||
|
// @interBuf : intermediate value
|
||||||
|
// @result: final result
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t int32_t aggfn_finish(SUdfInterBuf* interBuf, SUdfInterBuf *result) {
|
||||||
|
// read data from inputDataBlock and process, then output to result
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup function. if no cleanup related processing, we can skip definition of it. The destroy function shall be concatenation of the udf name and _destroy suffix.
|
||||||
|
// @return error number defined in taoserror.h
|
||||||
|
int32_t aggfn_destroy() {
|
||||||
|
// clean up
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
aggfn为函数名的占位符,需要修改为自己的函数名,如l2norm。
|
||||||
|
|
||||||
|
## 接口函数定义
|
||||||
|
|
||||||
|
接口函数的名称是 udf 名称,或者是 udf 名称和特定后缀(_start, _finish, _init, _destroy)的连接。以下描述中函数名称中的 scalarfn,aggfn, udf 需要替换成udf函数名。
|
||||||
|
|
||||||
|
接口函数返回值表示是否成功,如果错误返回错误代码,错误代码见taoserror.h。
|
||||||
|
|
||||||
|
接口函数参数类型见数据结构定义。
|
||||||
|
|
||||||
|
### 标量接口函数
|
||||||
|
|
||||||
|
`int32_t scalarfn(SUdfDataBlock* inputDataBlock, SUdfColumn *resultColumn)`
|
||||||
|
|
||||||
其中 udf 是函数名的占位符,以上述模板实现的函数对行数据块进行标量计算。
|
其中 scalarFn 是函数名的占位符。这个函数对数据块进行标量计算,通过设置resultColumn结构体中的变量设置值
|
||||||
|
|
||||||
- scalarFunction 中各参数的具体含义是:
|
参数的具体含义是:
|
||||||
- inputDataBlock: 输入的数据块
|
- inputDataBlock: 输入的数据块
|
||||||
- resultColumn: 输出列
|
- resultColumn: 输出列。输出列
|
||||||
|
|
||||||
### 聚合函数
|
### 聚合接口函数
|
||||||
|
|
||||||
用户可以按照如下函数模板定义自己的聚合函数。
|
`int32_t aggfn_start(SUdfInterBuf *interBuf)`
|
||||||
|
|
||||||
`int32_t udf_start(SUdfInterBuf *interBuf)`
|
`int32_t aggfn(SUdfDataBlock* inputBlock, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf)`
|
||||||
|
|
||||||
`int32_t udf(SUdfDataBlock* inputBlock, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf)`
|
`int32_t aggfn_finish(SUdfInterBuf* interBuf, SUdfInterBuf *result)`
|
||||||
|
|
||||||
`int32_t udf_finish(SUdfInterBuf* interBuf, SUdfInterBuf *result)`
|
其中 aggfn 是函数名的占位符。首先调用aggfn_start生成结果buffer,然后相关的数据会被分为多个行数据块,对每个数据块调用 aggfn 用数据块更新中间结果,最后再调用 aggfn_finish 从中间结果产生最终结果,最终结果只能含 0 或 1 条结果数据。
|
||||||
其中 udf 是函数名的占位符。其中各参数的具体含义是:
|
|
||||||
|
|
||||||
|
参数的具体含义是:
|
||||||
- interBuf:中间结果 buffer。
|
- interBuf:中间结果 buffer。
|
||||||
- inputBlock:输入的数据块。
|
- inputBlock:输入的数据块。
|
||||||
- newInterBuf:新的中间结果buffer。
|
- newInterBuf:新的中间结果buffer。
|
||||||
- result:最终结果。
|
- result:最终结果。
|
||||||
|
|
||||||
|
|
||||||
其计算过程为:首先调用udf_start生成结果buffer,然后相关的数据会被分为多个行数据块,对每个行数据块调用 udf 用数据块更新中间结果,最后再调用 udf_finish 从中间结果产生最终结果,最终结果只能含 0 或 1 条结果数据。
|
|
||||||
|
|
||||||
### UDF 初始化和销毁
|
### UDF 初始化和销毁
|
||||||
`int32_t udf_init()`
|
`int32_t udf_init()`
|
||||||
|
|
||||||
`int32_t udf_destroy()`
|
`int32_t udf_destroy()`
|
||||||
|
|
||||||
其中 udf 是函数名的占位符。udf_init 完成初始化工作。 udf_destroy 完成清理工作。
|
其中 udf 是函数名的占位符。udf_init 完成初始化工作。 udf_destroy 完成清理工作。如果没有初始化工作,无需定义udf_init函数。如果没有清理工作,无需定义udf_destroy函数。
|
||||||
|
|
||||||
:::note
|
|
||||||
如果对应的函数不需要具体的功能,也需要实现一个空函数。
|
|
||||||
|
|
||||||
:::
|
## UDF 数据结构
|
||||||
|
|
||||||
### UDF 数据结构
|
|
||||||
```c
|
```c
|
||||||
typedef struct SUdfColumnMeta {
|
typedef struct SUdfColumnMeta {
|
||||||
int16_t type;
|
int16_t type;
|
||||||
|
@ -103,6 +191,13 @@ typedef struct SUdfInterBuf {
|
||||||
int8_t numOfResult; //zero or one
|
int8_t numOfResult; //zero or one
|
||||||
} SUdfInterBuf;
|
} SUdfInterBuf;
|
||||||
```
|
```
|
||||||
|
数据结构说明如下:
|
||||||
|
|
||||||
|
- SUdfDataBlock 数据块包含行数 numOfRows 和列数 numCols。udfCols[i] (0 <= i <= numCols-1)表示每一列数据,类型为SUdfColumn*。
|
||||||
|
- SUdfColumn 包含列的数据类型定义 colMeta 和列的数据 colData。
|
||||||
|
- SUdfColumnMeta 成员定义同 taos.h 数据类型定义。
|
||||||
|
- SUdfColumnData 数据可以变长,varLenCol 定义变长数据,fixLenCol 定义定长数据。
|
||||||
|
- SUdfInterBuf 定义中间结构 buffer,以及 buffer 中结果个数 numOfResult
|
||||||
|
|
||||||
为了更好的操作以上数据结构,提供了一些便利函数,定义在 taosudf.h。
|
为了更好的操作以上数据结构,提供了一些便利函数,定义在 taosudf.h。
|
||||||
|
|
||||||
|
@ -118,75 +213,15 @@ gcc -g -O0 -fPIC -shared add_one.c -o add_one.so
|
||||||
|
|
||||||
这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。
|
这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。
|
||||||
|
|
||||||
## 在系统中管理和使用 UDF
|
## 管理和使用UDF
|
||||||
|
关于如何管理和使用UDF,参见[UDF使用说明](../12-taos-sql/26-udf.md)
|
||||||
### 创建 UDF
|
|
||||||
|
|
||||||
用户可以通过 SQL 指令在系统中加载客户端所在主机上的 UDF 函数库(不能通过 RESTful 接口或 HTTP 管理界面来进行这一过程)。一旦创建成功,则当前 TDengine 集群的所有用户都可以在 SQL 指令中使用这些函数。UDF 存储在系统的 MNode 节点上,因此即使重启 TDengine 系统,已经创建的 UDF 也仍然可用。
|
|
||||||
|
|
||||||
在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。
|
|
||||||
|
|
||||||
- 创建标量函数
|
|
||||||
```sql
|
|
||||||
CREATE FUNCTION function_name AS library_path OUTPUTTYPE output_type;
|
|
||||||
```
|
|
||||||
|
|
||||||
- function_name:标量函数未来在 SQL 中被调用时的函数名,必须与函数实现中 udf 的实际名称一致;
|
|
||||||
- library_path:包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
|
|
||||||
- output_type:此函数计算结果的数据类型名称;
|
|
||||||
|
|
||||||
例如,如下语句可以把 libbitand.so 创建为系统中可用的 UDF:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
CREATE FUNCTION bit_and AS "/home/taos/udf_example/libbitand.so" OUTPUTTYPE INT;
|
|
||||||
```
|
|
||||||
|
|
||||||
- 创建聚合函数:
|
|
||||||
```sql
|
|
||||||
CREATE AGGREGATE FUNCTION function_name AS library_path OUTPUTTYPE output_type [ BUFSIZE buffer_size ];
|
|
||||||
```
|
|
||||||
|
|
||||||
- function_name:聚合函数未来在 SQL 中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致;
|
|
||||||
- library_path:包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
|
|
||||||
- output_type:此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可;
|
|
||||||
- buffer_size:中间计算结果的缓冲区大小,单位是字节。如果不使用可以不设置。
|
|
||||||
|
|
||||||
例如,如下语句可以把 libsqrsum.so 创建为系统中可用的 UDF:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
CREATE AGGREGATE FUNCTION sqr_sum AS "/home/taos/udf_example/libsqrsum.so" OUTPUTTYPE DOUBLE bufsize 8;
|
|
||||||
```
|
|
||||||
|
|
||||||
### 管理 UDF
|
|
||||||
|
|
||||||
- 删除指定名称的用户定义函数:
|
|
||||||
```
|
|
||||||
DROP FUNCTION function_name;
|
|
||||||
```
|
|
||||||
|
|
||||||
- function_name:此参数的含义与 CREATE 指令中的 function_name 参数一致,也即要删除的函数的名字,例如
|
|
||||||
```sql
|
|
||||||
DROP FUNCTION bit_and;
|
|
||||||
```
|
|
||||||
- 显示系统中当前可用的所有 UDF:
|
|
||||||
```sql
|
|
||||||
SHOW FUNCTIONS;
|
|
||||||
```
|
|
||||||
|
|
||||||
### 调用 UDF
|
|
||||||
|
|
||||||
在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如:
|
|
||||||
```sql
|
|
||||||
SELECT X(c1,c2) FROM table/stable;
|
|
||||||
```
|
|
||||||
|
|
||||||
表示对名为 c1, c2 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。
|
|
||||||
|
|
||||||
|
|
||||||
## 示例代码
|
## 示例代码
|
||||||
|
|
||||||
### 标量函数示例 [bit_and](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/bit_and.c)
|
### 标量函数示例 [bit_and](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/bit_and.c)
|
||||||
|
|
||||||
|
bit_add 实现多列的按位与功能。如果只有一列,返回这一列。bit_add 忽略空值。
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>bit_and.c</summary>
|
<summary>bit_and.c</summary>
|
||||||
|
|
||||||
|
@ -196,13 +231,15 @@ SELECT X(c1,c2) FROM table/stable;
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### 聚合函数示例 [sqr_sum](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/sqr_sum.c)
|
### 聚合函数示例 [l2norm](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/l2norm.c)
|
||||||
|
|
||||||
|
l2norm 实现了输入列的所有数据的二阶范数,即对每个数据先平方,再累加求和,最后开方。
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>sqr_sum.c</summary>
|
<summary>l2norm.c</summary>
|
||||||
|
|
||||||
```c
|
```c
|
||||||
{{#include tests/script/sh/sqr_sum.c}}
|
{{#include tests/script/sh/l2norm.c}}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
@ -3,27 +3,11 @@ sidebar_label: Kubernetes
|
||||||
title: 在 Kubernetes 上部署 TDengine 集群
|
title: 在 Kubernetes 上部署 TDengine 集群
|
||||||
---
|
---
|
||||||
|
|
||||||
## 配置 ConfigMap
|
以下配置文件可以从 [GitHub 仓库](https://github.com/taosdata/TDengine-Operator/tree/3.0/src/tdengine) 下载。
|
||||||
|
|
||||||
为 TDengine 创建 `taoscfg.yaml`,此文件中的配置将作为环境变量传入 TDengine 镜像,更新此配置将导致所有 TDengine POD 重启。
|
## 配置 Service 服务
|
||||||
|
|
||||||
```yaml
|
创建一个 Service 配置文件:`taosd-service.yaml`,服务名称 `metadata.name` (此处为 "taosd") 将在下一步中使用到。添加 TDengine 所用到的所有端口:
|
||||||
---
|
|
||||||
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
|
```yaml
|
||||||
---
|
---
|
||||||
|
@ -38,45 +22,9 @@ spec:
|
||||||
- name: tcp6030
|
- name: tcp6030
|
||||||
protocol: "TCP"
|
protocol: "TCP"
|
||||||
port: 6030
|
port: 6030
|
||||||
- name: tcp6035
|
|
||||||
protocol: "TCP"
|
|
||||||
port: 6035
|
|
||||||
- name: tcp6041
|
- name: tcp6041
|
||||||
protocol: "TCP"
|
protocol: "TCP"
|
||||||
port: 6041
|
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:
|
selector:
|
||||||
app: "tdengine"
|
app: "tdengine"
|
||||||
```
|
```
|
||||||
|
@ -109,7 +57,7 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: "tdengine"
|
- name: "tdengine"
|
||||||
image: "zitsen/taosd:develop"
|
image: "tdengine/tdengine:3.0.0.0"
|
||||||
imagePullPolicy: "Always"
|
imagePullPolicy: "Always"
|
||||||
envFrom:
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
|
@ -118,45 +66,9 @@ spec:
|
||||||
- name: tcp6030
|
- name: tcp6030
|
||||||
protocol: "TCP"
|
protocol: "TCP"
|
||||||
containerPort: 6030
|
containerPort: 6030
|
||||||
- name: tcp6035
|
|
||||||
protocol: "TCP"
|
|
||||||
containerPort: 6035
|
|
||||||
- name: tcp6041
|
- name: tcp6041
|
||||||
protocol: "TCP"
|
protocol: "TCP"
|
||||||
containerPort: 6041
|
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:
|
env:
|
||||||
# POD_NAME for FQDN config
|
# POD_NAME for FQDN config
|
||||||
- name: POD_NAME
|
- name: POD_NAME
|
||||||
|
@ -190,14 +102,13 @@ spec:
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
- taos
|
- taos-check
|
||||||
- -s
|
|
||||||
- "show mnodes"
|
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
timeoutSeconds: 5000
|
timeoutSeconds: 5000
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
tcpSocket:
|
exec:
|
||||||
port: 6030
|
command:
|
||||||
|
- taos-check
|
||||||
initialDelaySeconds: 15
|
initialDelaySeconds: 15
|
||||||
periodSeconds: 20
|
periodSeconds: 20
|
||||||
volumeClaimTemplates:
|
volumeClaimTemplates:
|
||||||
|
@ -206,44 +117,78 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- "ReadWriteOnce"
|
- "ReadWriteOnce"
|
||||||
storageClassName: "csi-rbd-sc"
|
storageClassName: "standard"
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: "10Gi"
|
storage: "10Gi"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 启动集群
|
## 使用 kubectl 命令部署 TDengine 集群
|
||||||
|
|
||||||
将前述三个文件添加到 Kubernetes 集群中:
|
顺序执行以下命令。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl apply -f taoscfg.yaml
|
|
||||||
kubectl apply -f taosd-service.yaml
|
kubectl apply -f taosd-service.yaml
|
||||||
kubectl apply -f tdengine.yaml
|
kubectl apply -f tdengine.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
上面的配置将生成一个两节点的 TDengine 集群,dnode 是自动配置的,可以使用 `show dnodes` 命令查看当前集群的节点:
|
上面的配置将生成一个三节点的 TDengine 集群,dnode 是自动配置的,可以使用 show dnodes 命令查看当前集群的节点:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
|
kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
|
||||||
kubectl exec -i -t tdengine-1 -- taos -s "show dnodes"
|
kubectl exec -i -t tdengine-1 -- taos -s "show dnodes"
|
||||||
|
kubectl exec -i -t tdengine-2 -- taos -s "show dnodes"
|
||||||
```
|
```
|
||||||
|
|
||||||
输出如下:
|
输出如下:
|
||||||
|
|
||||||
```
|
```
|
||||||
Welcome to the TDengine shell from Linux, Client Version:2.1.1.0
|
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||||
|
|
||||||
taos> show dnodes
|
taos> show dnodes
|
||||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||||
======================================================================================================================================
|
============================================================================================================================================
|
||||||
1 | tdengine-0.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 17:13:24.181 | |
|
1 | tdengine-0.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:14:57.285 | |
|
||||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 17:14:09.257 | |
|
2 | tdengine-1.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:11.302 | |
|
||||||
Query OK, 2 row(s) in set (0.000997s)
|
3 | tdengine-2.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:23.290 | |
|
||||||
|
Query OK, 3 rows in database (0.003655s)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 使能端口转发
|
||||||
|
|
||||||
|
利用 kubectl 端口转发功能可以使应用可以访问 Kubernetes 环境运行的 TDengine 集群。
|
||||||
|
|
||||||
|
```
|
||||||
|
kubectl port-forward tdengine-0 6041:6041 &
|
||||||
|
```
|
||||||
|
|
||||||
|
使用 curl 命令验证 TDengine REST API 使用的 6041 接口。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql
|
||||||
|
Handling connection for 6041
|
||||||
|
{"code":0,"column_meta":[["name","VARCHAR",64],["create_time","TIMESTAMP",8],["vgroups","SMALLINT",2],["ntables","BIGINT",8],["replica","TINYINT",1],["strict","VARCHAR",4],["duration","VARCHAR",10],["keep","VARCHAR",32],["buffer","INT",4],["pagesize","INT",4],["pages","INT",4],["minrows","INT",4],["maxrows","INT",4],["comp","TINYINT",1],["precision","VARCHAR",2],["status","VARCHAR",10],["retention","VARCHAR",60],["single_stable","BOOL",1],["cachemodel","VARCHAR",11],["cachesize","INT",4],["wal_level","TINYINT",1],["wal_fsync_period","INT",4],["wal_retention_period","INT",4],["wal_retention_size","BIGINT",8],["wal_roll_period","INT",4],["wal_segment_size","BIGINT",8]],"data":[["information_schema",null,null,16,null,null,null,null,null,null,null,null,null,null,null,"ready",null,null,null,null,null,null,null,null,null,null],["performance_schema",null,null,10,null,null,null,null,null,null,null,null,null,null,null,"ready",null,null,null,null,null,null,null,null,null,null]],"rows":2}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 使用 dashboard 进行图形化管理
|
||||||
|
|
||||||
|
minikube 提供 dashboard 命令支持图形化管理界面。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ minikube dashboard
|
||||||
|
* Verifying dashboard health ...
|
||||||
|
* Launching proxy ...
|
||||||
|
* Verifying proxy health ...
|
||||||
|
* Opening http://127.0.0.1:46617/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
|
||||||
|
http://127.0.0.1:46617/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
|
||||||
|
```
|
||||||
|
|
||||||
|
对于某些公有云环境,minikube 绑定在 127.0.0.1 IP 地址上无法通过远程访问,需要使用 kubectl proxy 命令将端口映射到 0.0.0.0 IP 地址上,再通过浏览器访问虚拟机公网 IP 和端口以及相同的 dashboard URL 路径即可远程访问 dashboard。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ kubectl proxy --accept-hosts='^.*$' --address='0.0.0.0'
|
||||||
```
|
```
|
||||||
|
|
||||||
## 集群扩容
|
## 集群扩容
|
||||||
|
@ -252,14 +197,12 @@ TDengine 集群支持自动扩容:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl scale statefulsets tdengine --replicas=4
|
kubectl scale statefulsets tdengine --replicas=4
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
上面命令行中参数 `--replica=4` 表示要将 TDengine 集群扩容到 4 个节点,执行后首先检查 POD 的状态:
|
上面命令行中参数 `--replica=4` 表示要将 TDengine 集群扩容到 4 个节点,执行后首先检查 POD 的状态:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl get pods -l app=tdengine
|
kubectl get pods -l app=tdengine
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
输出如下:
|
输出如下:
|
||||||
|
@ -270,102 +213,112 @@ tdengine-0 1/1 Running 0 161m
|
||||||
tdengine-1 1/1 Running 0 161m
|
tdengine-1 1/1 Running 0 161m
|
||||||
tdengine-2 1/1 Running 0 32m
|
tdengine-2 1/1 Running 0 32m
|
||||||
tdengine-3 1/1 Running 0 32m
|
tdengine-3 1/1 Running 0 32m
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
此时 POD 的状态仍然是 Running,TDengine 集群中的 dnode 状态要等 POD 状态为 `ready` 之后才能看到:
|
此时 POD 的状态仍然是 Running,TDengine 集群中的 dnode 状态要等 POD 状态为 `ready` 之后才能看到:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
|
kubectl exec -i -t tdengine-3 -- taos -s "show dnodes"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
扩容后的四节点 TDengine 集群的 dnode 列表:
|
扩容后的四节点 TDengine 集群的 dnode 列表:
|
||||||
|
|
||||||
```
|
```
|
||||||
Welcome to the TDengine shell from Linux, Client Version:2.1.1.0
|
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||||
|
|
||||||
taos> show dnodes
|
taos> show dnodes
|
||||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||||
======================================================================================================================================
|
============================================================================================================================================
|
||||||
1 | tdengine-0.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:12.915 | |
|
1 | tdengine-0.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:14:57.285 | |
|
||||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:33.127 | |
|
2 | tdengine-1.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:11.302 | |
|
||||||
3 | tdengine-2.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 14:07:27.078 | |
|
3 | tdengine-2.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:23.290 | |
|
||||||
4 | tdengine-3.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 14:07:48.362 | |
|
4 | tdengine-3.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:33:16.039 | |
|
||||||
Query OK, 4 row(s) in set (0.001293s)
|
Query OK, 4 rows in database (0.008377s)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 集群缩容
|
## 集群缩容
|
||||||
|
|
||||||
TDengine 的缩容并没有自动化,我们尝试将一个三节点集群缩容到两节点。
|
由于 TDengine 集群在扩缩容时会对数据进行节点间迁移,使用 kubectl 命令进行缩容需要首先使用 "drop dnodes" 命令,节点删除完成后再进行 Kubernetes 集群缩容。
|
||||||
|
|
||||||
首先,确认一个三节点 TDengine 集群正常工作,在 TDengine CLI 中查看 dnode 的状态:
|
注意:由于 Kubernetes Statefulset 中 Pod 的只能按创建顺序逆序移除,所以 TDengine drop dnode 也需要按照创建顺序逆序移除,否则会导致 Pod 处于错误状态。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ kubectl exec -i -t tdengine-0 -- taos -s "drop dnode 4"
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
|
||||||
|
|
||||||
|
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||||
|
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||||
|
|
||||||
taos> show dnodes
|
taos> show dnodes
|
||||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||||
======================================================================================================================================
|
============================================================================================================================================
|
||||||
1 | tdengine-0.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 16:27:24.852 | |
|
1 | tdengine-0.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:14:57.285 | |
|
||||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:27:53.339 | |
|
2 | tdengine-1.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:11.302 | |
|
||||||
3 | tdengine-2.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:28:49.787 | |
|
3 | tdengine-2.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:23.290 | |
|
||||||
Query OK, 3 row(s) in set (0.001101s)
|
Query OK, 3 rows in database (0.004861s)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
想要安全的缩容,首先需要将节点从 dnode 列表中移除,也即从集群中移除:
|
确认移除成功后(使用 kubectl exec -i -t tdengine-0 -- taos -s "show dnodes" 查看和确认 dnode 列表),使用 kubectl 命令移除 POD:
|
||||||
|
|
||||||
|
```
|
||||||
|
kubectl scale statefulsets tdengine --replicas=3
|
||||||
|
```
|
||||||
|
|
||||||
|
最后一个 POD 将会被删除。使用命令 kubectl get pods -l app=tdengine 查看POD状态:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ kubectl get pods -l app=tdengine
|
||||||
|
NAME READY STATUS RESTARTS AGE
|
||||||
|
tdengine-0 1/1 Running 0 4m7s
|
||||||
|
tdengine-1 1/1 Running 0 3m55s
|
||||||
|
tdengine-2 1/1 Running 0 2m28s
|
||||||
|
```
|
||||||
|
|
||||||
|
POD删除后,需要手动删除PVC,否则下次扩容时会继续使用以前的数据导致无法正常加入集群。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -i -t tdengine-0 -- taos -s "drop dnode 'tdengine-2.taosd.default.svc.cluster.local:6030'"
|
$ kubectl delete pvc taosdata-tdengine-3
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
通过 `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
|
```bash
|
||||||
kubectl scale statefulsets tdengine --replicas=3
|
$ kubectl scale statefulsets tdengine --replicas=4
|
||||||
|
statefulset.apps/tdengine scaled
|
||||||
|
it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl get pods -l app=tdengine
|
||||||
|
NAME READY STATUS RESTARTS AGE
|
||||||
|
tdengine-0 1/1 Running 0 35m
|
||||||
|
tdengine-1 1/1 Running 0 34m
|
||||||
|
tdengine-2 1/1 Running 0 12m
|
||||||
|
tdengine-3 0/1 ContainerCreating 0 4s
|
||||||
|
it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl get pods -l app=tdengine
|
||||||
|
NAME READY STATUS RESTARTS AGE
|
||||||
|
tdengine-0 1/1 Running 0 35m
|
||||||
|
tdengine-1 1/1 Running 0 34m
|
||||||
|
tdengine-2 1/1 Running 0 12m
|
||||||
|
tdengine-3 0/1 Running 0 7s
|
||||||
|
it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
|
||||||
|
|
||||||
|
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||||
|
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||||
|
|
||||||
|
Server is Community Edition.
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
`show dnodes` 输出如下:
|
|
||||||
|
|
||||||
```
|
|
||||||
taos> show dnodes
|
taos> show dnodes
|
||||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
id | endpoint | vnodes | support_vnodes | status | create_time | offline reason |
|
||||||
======================================================================================================================================
|
======================================================================================================================================
|
||||||
1 | tdengine-0.taosd.default.sv... | 1 | 40 | ready | any | 2021-06-01 16:27:24.852 | |
|
1 | tdengine-0.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 17:38:49.012 | |
|
||||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:27:53.339 | |
|
2 | tdengine-1.taosd.default.sv... | 1 | 4 | ready | 2022-07-25 17:39:01.517 | |
|
||||||
4 | tdengine-2.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 16:40:49.177 | |
|
5 | tdengine-2.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 18:01:36.479 | |
|
||||||
|
6 | tdengine-3.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 18:13:54.411 | |
|
||||||
|
Query OK, 4 row(s) in set (0.001348s)
|
||||||
```
|
```
|
||||||
|
|
||||||
## 删除集群
|
## 清理 TDengine 集群
|
||||||
|
|
||||||
完整移除 TDengine 集群,需要分别清理 statefulset、svc、configmap、pvc。
|
完整移除 TDengine 集群,需要分别清理 statefulset、svc、configmap、pvc。
|
||||||
|
|
||||||
|
@ -381,26 +334,26 @@ kubectl delete configmap taoscfg
|
||||||
|
|
||||||
### 错误一
|
### 错误一
|
||||||
|
|
||||||
扩容到四节点之后缩容到两节点,删除的 POD 会进入 offline 状态:
|
未进行 "drop dnode" 直接进行缩容,由于 TDengine 尚未删除节点,缩容 pod 导致 TDengine 集群中部分节点处于 offline 状态。
|
||||||
|
|
||||||
```
|
```
|
||||||
Welcome to the TDengine shell from Linux, Client Version:2.1.1.0
|
$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
|
||||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
|
||||||
|
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||||
|
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||||
|
|
||||||
|
Server is Community Edition.
|
||||||
|
|
||||||
taos> show dnodes
|
taos> show dnodes
|
||||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
id | endpoint | vnodes | support_vnodes | status | create_time | offline reason |
|
||||||
======================================================================================================================================
|
======================================================================================================================================
|
||||||
1 | tdengine-0.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:12.915 | |
|
1 | tdengine-0.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 17:38:49.012 | |
|
||||||
2 | tdengine-1.taosd.default.sv... | 0 | 40 | ready | any | 2021-06-01 11:58:33.127 | |
|
2 | tdengine-1.taosd.default.sv... | 1 | 4 | ready | 2022-07-25 17:39:01.517 | |
|
||||||
3 | tdengine-2.taosd.default.sv... | 0 | 40 | offline | any | 2021-06-01 14:07:27.078 | status msg timeout |
|
5 | tdengine-2.taosd.default.sv... | 0 | 4 | offline | 2022-07-25 18:01:36.479 | status msg timeout |
|
||||||
4 | tdengine-3.taosd.default.sv... | 1 | 40 | offline | any | 2021-06-01 14:07:48.362 | status msg timeout |
|
6 | tdengine-3.taosd.default.sv... | 0 | 4 | offline | 2022-07-25 18:13:54.411 | status msg timeout |
|
||||||
Query OK, 4 row(s) in set (0.001236s)
|
Query OK, 4 row(s) in set (0.001323s)
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
但 `drop dnode` 的行为按不会按照预期进行,且下次集群重启后,所有的 dnode 节点将无法启动 dropping 状态无法退出。
|
|
||||||
|
|
||||||
### 错误二
|
### 错误二
|
||||||
|
|
||||||
TDengine 集群会持有 replica 参数,如果缩容后的节点数小于这个值,集群将无法使用:
|
TDengine 集群会持有 replica 参数,如果缩容后的节点数小于这个值,集群将无法使用:
|
||||||
|
|
|
@ -4,34 +4,65 @@ title: 用户自定义函数
|
||||||
---
|
---
|
||||||
|
|
||||||
除了 TDengine 的内置函数以外,用户还可以编写自己的函数逻辑并加入TDengine系统中。
|
除了 TDengine 的内置函数以外,用户还可以编写自己的函数逻辑并加入TDengine系统中。
|
||||||
|
## 创建 UDF
|
||||||
|
|
||||||
## 创建函数
|
用户可以通过 SQL 指令在系统中加载客户端所在主机上的 UDF 函数库(不能通过 RESTful 接口或 HTTP 管理界面来进行这一过程)。一旦创建成功,则当前 TDengine 集群的所有用户都可以在 SQL 指令中使用这些函数。UDF 存储在系统的 MNode 节点上,因此即使重启 TDengine 系统,已经创建的 UDF 也仍然可用。
|
||||||
|
|
||||||
|
在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。
|
||||||
|
|
||||||
|
- 创建标量函数
|
||||||
```sql
|
```sql
|
||||||
CREATE [AGGREGATE] FUNCTION func_name AS library_path OUTPUTTYPE type_name [BUFSIZE buffer_size]
|
CREATE FUNCTION function_name AS library_path OUTPUTTYPE output_type;
|
||||||
```
|
```
|
||||||
|
|
||||||
语法说明:
|
- function_name:标量函数未来在 SQL 中被调用时的函数名,必须与函数实现中 udf 的实际名称一致;
|
||||||
|
- library_path:包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
|
||||||
|
- output_type:此函数计算结果的数据类型名称;
|
||||||
|
|
||||||
AGGREGATE:标识此函数是标量函数还是聚集函数。
|
例如,如下语句可以把 libbitand.so 创建为系统中可用的 UDF:
|
||||||
func_name:函数名,必须与函数实现中 udf 的实际名称一致。
|
|
||||||
library_path:包含UDF函数实现的动态链接库的绝对路径,是在客户端侧主机上的绝对路径。
|
|
||||||
type_name:标识此函数的返回类型。
|
|
||||||
buffer_size:中间结果的缓冲区大小,单位是字节。不设置则默认为0。
|
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE FUNCTION bit_and AS "/home/taos/udf_example/libbitand.so" OUTPUTTYPE INT;
|
||||||
|
```
|
||||||
|
|
||||||
|
- 创建聚合函数:
|
||||||
|
```sql
|
||||||
|
CREATE AGGREGATE FUNCTION function_name AS library_path OUTPUTTYPE output_type [ BUFSIZE buffer_size ];
|
||||||
|
```
|
||||||
|
|
||||||
|
- function_name:聚合函数未来在 SQL 中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致;
|
||||||
|
- library_path:包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来;
|
||||||
|
- output_type:此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可;
|
||||||
|
- buffer_size:中间计算结果的缓冲区大小,单位是字节。如果不使用可以不设置。
|
||||||
|
|
||||||
|
例如,如下语句可以把 libl2norm.so 创建为系统中可用的 UDF:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE AGGREGATE FUNCTION l2norm AS "/home/taos/udf_example/libl2norm.so" OUTPUTTYPE DOUBLE bufsize 8;
|
||||||
|
```
|
||||||
关于如何开发自定义函数,请参考 [UDF使用说明](../../develop/udf)。
|
关于如何开发自定义函数,请参考 [UDF使用说明](../../develop/udf)。
|
||||||
|
|
||||||
## 删除自定义函数
|
## 管理 UDF
|
||||||
|
|
||||||
|
- 删除指定名称的用户定义函数:
|
||||||
```
|
```
|
||||||
DROP FUNCTION function_name;
|
DROP FUNCTION function_name;
|
||||||
```
|
```
|
||||||
|
|
||||||
- function_name:此参数的含义与 CREATE 指令中的 function_name 参数一致,也即要删除的函数的名字,例如
|
- function_name:此参数的含义与 CREATE 指令中的 function_name 参数一致,也即要删除的函数的名字,例如bit_and, l2norm
|
||||||
|
|
||||||
|
|
||||||
## 显示 UDF
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SHOW FUNCTION;
|
DROP FUNCTION bit_and;
|
||||||
```
|
```
|
||||||
|
- 显示系统中当前可用的所有 UDF:
|
||||||
|
```sql
|
||||||
|
SHOW FUNCTIONS;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 调用 UDF
|
||||||
|
|
||||||
|
在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如:
|
||||||
|
```sql
|
||||||
|
SELECT X(c1,c2) FROM table/stable;
|
||||||
|
```
|
||||||
|
|
||||||
|
表示对名为 c1, c2 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。
|
||||||
|
|
|
@ -5,11 +5,12 @@ description: "TAOS SQL 支持的语法规则、主要查询功能、支持的 SQ
|
||||||
|
|
||||||
本文档说明 TAOS SQL 支持的语法规则、主要查询功能、支持的 SQL 查询函数,以及常用技巧等内容。阅读本文档需要读者具有基本的 SQL 语言的基础。
|
本文档说明 TAOS SQL 支持的语法规则、主要查询功能、支持的 SQL 查询函数,以及常用技巧等内容。阅读本文档需要读者具有基本的 SQL 语言的基础。
|
||||||
|
|
||||||
TAOS SQL 是用户对 TDengine 进行数据写入和查询的主要工具。TAOS SQL 为了便于用户快速上手,在一定程度上提供与标准 SQL 类似的风格和模式。严格意义上,TAOS SQL 并不是也不试图提供标准的 SQL 语法。此外,由于 TDengine 针对的时序性结构化数据不提供删除功能,因此在 TAO SQL 中不提供数据删除的相关功能。
|
TAOS SQL 是用户对 TDengine 进行数据写入和查询的主要工具。TAOS SQL 提供标准的 SQL 语法,并针对时序数据和业务的特点优化和新增了许多语法和功能。TAOS SQL 语句的最大长度为 1M。TAOS SQL 不支持关键字的缩写,例如 DELETE 不能缩写为 DEL。
|
||||||
|
|
||||||
本章节 SQL 语法遵循如下约定:
|
本章节 SQL 语法遵循如下约定:
|
||||||
|
|
||||||
- <\> 里的内容是用户需要输入的,但不要输入 <\> 本身
|
- 用大写字母表示关键字,但 SQL 本身并不区分关键字和标识符的大小写
|
||||||
|
- 用小写字母表示需要用户输入的内容
|
||||||
- \[ \] 表示内容为可选项,但不能输入 [] 本身
|
- \[ \] 表示内容为可选项,但不能输入 [] 本身
|
||||||
- | 表示多选一,选择其中一个即可,但不能输入 | 本身
|
- | 表示多选一,选择其中一个即可,但不能输入 | 本身
|
||||||
- … 表示前面的项可重复多个
|
- … 表示前面的项可重复多个
|
||||||
|
|
|
@ -279,7 +279,7 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多
|
||||||
2. 调用 `taos_stmt_prepare()` 解析 INSERT 语句;
|
2. 调用 `taos_stmt_prepare()` 解析 INSERT 语句;
|
||||||
3. 如果 INSERT 语句中预留了表名但没有预留 TAGS,那么调用 `taos_stmt_set_tbname()` 来设置表名;
|
3. 如果 INSERT 语句中预留了表名但没有预留 TAGS,那么调用 `taos_stmt_set_tbname()` 来设置表名;
|
||||||
4. 如果 INSERT 语句中既预留了表名又预留了 TAGS(例如 INSERT 语句采取的是自动建表的方式),那么调用 `taos_stmt_set_tbname_tags()` 来设置表名和 TAGS 的值;
|
4. 如果 INSERT 语句中既预留了表名又预留了 TAGS(例如 INSERT 语句采取的是自动建表的方式),那么调用 `taos_stmt_set_tbname_tags()` 来设置表名和 TAGS 的值;
|
||||||
5. 调用 `taos_stmt_bind_param_batch()` 以多列的方式设置 VALUES 的值,或者调用 `taos_stmt_bind_param()` 以单行的方式设置 VALUES 的值;
|
5. 调用 `taos_stmt_bind_param_batch()` 以多行的方式设置 VALUES 的值,或者调用 `taos_stmt_bind_param()` 以单行的方式设置 VALUES 的值;
|
||||||
6. 调用 `taos_stmt_add_batch()` 把当前绑定的参数加入批处理;
|
6. 调用 `taos_stmt_add_batch()` 把当前绑定的参数加入批处理;
|
||||||
7. 可以重复第 3 ~ 6 步,为批处理加入更多的数据行;
|
7. 可以重复第 3 ~ 6 步,为批处理加入更多的数据行;
|
||||||
8. 调用 `taos_stmt_execute()` 执行已经准备好的批处理指令;
|
8. 调用 `taos_stmt_execute()` 执行已经准备好的批处理指令;
|
||||||
|
|
|
@ -9,7 +9,7 @@ description: TDengine Java 连接器基于标准 JDBC API 实现, 并提供原
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
`taos-jdbcdriver` 是 TDengine 的官方 Java 语言连接器,Java 开发人员可以通过它开发存取 TDengine 数据库的应用软件。`taos-jdbcdriver` 实现了 JDBC driver 标准的接口,并提供两种形式的连接器。一种是通过 TDengine 客户端驱动程序(taosc)原生连接 TDengine 实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能,一种是通过 taosAdapter 提供的 REST 接口连接 TDengine 实例(2.4.0.0 及更高版本)。REST 连接实现的功能集合和原生连接有少量不同。
|
`taos-jdbcdriver` 是 TDengine 的官方 Java 语言连接器,Java 开发人员可以通过它开发存取 TDengine 数据库的应用软件。`taos-jdbcdriver` 实现了 JDBC driver 标准的接口,并提供两种形式的连接器。一种是通过 TDengine 客户端驱动程序(taosc)原生连接 TDengine 实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能,一种是通过 taosAdapter 提供的 REST 接口连接 TDengine 实例。REST 连接实现的功能集合和原生连接有少量不同。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -41,19 +41,19 @@ REST 连接支持所有能运行 Java 的平台。
|
||||||
|
|
||||||
TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下:
|
TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下:
|
||||||
|
|
||||||
| TDengine DataType | JDBCType (driver 版本 < 2.0.24) | JDBCType (driver 版本 >= 2.0.24) |
|
| TDengine DataType | JDBCType |
|
||||||
| ----------------- | --------------------------------- | ---------------------------------- |
|
| ----------------- | ---------------------------------- |
|
||||||
| TIMESTAMP | java.lang.Long | java.sql.Timestamp |
|
| TIMESTAMP | java.sql.Timestamp |
|
||||||
| INT | java.lang.Integer | java.lang.Integer |
|
| INT | java.lang.Integer |
|
||||||
| BIGINT | java.lang.Long | java.lang.Long |
|
| BIGINT | java.lang.Long |
|
||||||
| FLOAT | java.lang.Float | java.lang.Float |
|
| FLOAT | java.lang.Float |
|
||||||
| DOUBLE | java.lang.Double | java.lang.Double |
|
| DOUBLE | java.lang.Double |
|
||||||
| SMALLINT | java.lang.Short | java.lang.Short |
|
| SMALLINT | java.lang.Short |
|
||||||
| TINYINT | java.lang.Byte | java.lang.Byte |
|
| TINYINT | java.lang.Byte |
|
||||||
| BOOL | java.lang.Boolean | java.lang.Boolean |
|
| BOOL | java.lang.Boolean |
|
||||||
| BINARY | java.lang.String | byte array |
|
| BINARY | byte array |
|
||||||
| NCHAR | java.lang.String | java.lang.String |
|
| NCHAR | java.lang.String |
|
||||||
| JSON | - | java.lang.String |
|
| JSON | java.lang.String |
|
||||||
|
|
||||||
**注意**:JSON 类型仅在 tag 中支持。
|
**注意**:JSON 类型仅在 tag 中支持。
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ url 中的配置参数如下:
|
||||||
|
|
||||||
- user:登录 TDengine 用户名,默认值 'root'。
|
- user:登录 TDengine 用户名,默认值 'root'。
|
||||||
- password:用户登录密码,默认值 'taosdata'。
|
- password:用户登录密码,默认值 'taosdata'。
|
||||||
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
||||||
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
||||||
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
||||||
- httpConnectTimeout: 连接超时时间,单位 ms, 默认值为 5000。
|
- httpConnectTimeout: 连接超时时间,单位 ms, 默认值为 5000。
|
||||||
|
@ -216,7 +216,7 @@ url 中的配置参数如下:
|
||||||
INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('California.SanFrancisco') VALUES(now, 24.6);
|
INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('California.SanFrancisco') VALUES(now, 24.6);
|
||||||
```
|
```
|
||||||
|
|
||||||
- 从 taos-jdbcdriver-2.0.36 和 TDengine 2.2.0.0 版本开始,如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 restful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperature) tags('California.SanFrancisco') values(now, 24.6);
|
- 从 taos-jdbcdriver-2.0.36 开始,如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 restful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperature) tags('California.SanFrancisco') values(now, 24.6);
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
@ -358,11 +358,11 @@ JDBC 连接器可能报错的错误码包括 3 种:JDBC driver 本身的报错
|
||||||
具体的错误码请参考:
|
具体的错误码请参考:
|
||||||
|
|
||||||
- [TDengine Java Connector](https://github.com/taosdata/taos-connector-jdbc/blob/main/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java)
|
- [TDengine Java Connector](https://github.com/taosdata/taos-connector-jdbc/blob/main/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java)
|
||||||
- [TDengine_ERROR_CODE](https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h)
|
- [TDengine_ERROR_CODE](../error-code)
|
||||||
|
|
||||||
### 通过参数绑定写入数据
|
### 通过参数绑定写入数据
|
||||||
|
|
||||||
从 2.1.2.0 版本开始,TDengine 的 JDBC 原生连接实现大幅改进了参数绑定方式对数据写入(INSERT)场景的支持。采用这种方式写入数据时,能避免 SQL 语法解析的资源消耗,从而在很多情况下显著提升写入性能。
|
TDengine 的 JDBC 原生连接实现大幅改进了参数绑定方式对数据写入(INSERT)场景的支持。采用这种方式写入数据时,能避免 SQL 语法解析的资源消耗,从而在很多情况下显著提升写入性能。
|
||||||
|
|
||||||
**注意**:
|
**注意**:
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ public void setNString(int columnIndex, ArrayList<String> list, int size) throws
|
||||||
|
|
||||||
### 无模式写入
|
### 无模式写入
|
||||||
|
|
||||||
从 2.2.0.0 版本开始,TDengine 增加了对无模式写入功能。无模式写入兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议和 OpenTSDB 的 JSON 格式协议。详情请参见[无模式写入](/reference/schemaless/)。
|
TDengine 支持无模式写入功能。无模式写入兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议和 OpenTSDB 的 JSON 格式协议。详情请参见[无模式写入](../../schemaless)。
|
||||||
|
|
||||||
**注意**:
|
**注意**:
|
||||||
|
|
||||||
|
@ -670,55 +670,127 @@ public class SchemalessInsertTest {
|
||||||
|
|
||||||
TDengine Java 连接器支持订阅功能,应用 API 如下:
|
TDengine Java 连接器支持订阅功能,应用 API 如下:
|
||||||
|
|
||||||
#### 创建订阅
|
#### 创建 Topic
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from meters", false);
|
Connection connection = DriverManager.getConnection(url, properties);
|
||||||
|
Statement statement = connection.createStatement();
|
||||||
|
statement.executeUpdate("create topic if not exists topic_speed as select ts, speed from speed_table");
|
||||||
```
|
```
|
||||||
|
|
||||||
`subscribe` 方法的三个参数含义如下:
|
`subscribe` 方法的三个参数含义如下:
|
||||||
|
|
||||||
- topic:订阅的主题(即名称),此参数是订阅的唯一标识
|
- topic_speed:订阅的主题(即名称),此参数是订阅的唯一标识。
|
||||||
- sql:订阅的查询语句,此语句只能是 `select` 语句,只应查询原始数据,只能按时间正序查询数据
|
- sql:订阅的查询语句,此语句只能是 `select` 语句,只应查询原始数据,只能按时间正序查询数据。
|
||||||
- restart:如果订阅已经存在,是重新开始,还是继续之前的订阅
|
|
||||||
|
|
||||||
如上面的例子将使用 SQL 语句 `select * from meters` 创建一个名为 `topic` 的订阅,如果这个订阅已经存在,将继续之前的查询进度,而不是从头开始消费所有的数据。
|
如上面的例子将使用 SQL 语句 `select ts, speed from speed_table` 创建一个名为 `topic_speed` 的订阅。
|
||||||
|
|
||||||
|
#### 创建 Consumer
|
||||||
|
|
||||||
|
```java
|
||||||
|
Properties config = new Properties();
|
||||||
|
config.setProperty("enable.auto.commit", "true");
|
||||||
|
config.setProperty("group.id", "group1");
|
||||||
|
config.setProperty("value.deserializer", "com.taosdata.jdbc.tmq.ConsumerTest.ResultDeserializer");
|
||||||
|
|
||||||
|
TaosConsumer consumer = new TaosConsumer<>(config);
|
||||||
|
```
|
||||||
|
|
||||||
|
- enable.auto.commit: 是否允许自动提交。
|
||||||
|
- group.id: consumer: 所在的 group。
|
||||||
|
- value.deserializer: 结果集反序列化方法,可以继承 `com.taosdata.jdbc.tmq.ReferenceDeserializer`,并指定结果集 bean,实现反序列化。也可以继承 `com.taosdata.jdbc.tmq.Deserializer`,根据 SQL 的 resultSet 自定义反序列化方式。
|
||||||
|
- 其他参数请参考:[Consumer 参数列表](../../../develop/tmq#创建-consumer-以及consumer-group)
|
||||||
|
|
||||||
#### 订阅消费数据
|
#### 订阅消费数据
|
||||||
|
|
||||||
```java
|
```java
|
||||||
int total = 0;
|
|
||||||
while(true) {
|
while(true) {
|
||||||
TSDBResultSet rs = sub.consume();
|
ConsumerRecords<ResultBean> records = consumer.poll(Duration.ofMillis(100));
|
||||||
int count = 0;
|
for (ResultBean record : records) {
|
||||||
while(rs.next()) {
|
process(record);
|
||||||
count++;
|
}
|
||||||
}
|
|
||||||
total += count;
|
|
||||||
System.out.printf("%d rows consumed, total %d\n", count, total);
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`consume` 方法返回一个结果集,其中包含从上次 `consume` 到目前为止的所有新数据。请务必按需选择合理的调用 `consume` 的频率(如例子中的 `Thread.sleep(1000)`),否则会给服务端造成不必要的压力。
|
`poll` 方法返回一个结果集,其中包含从上次 `poll` 到目前为止的所有新数据。请务必按需选择合理的调用 `poll` 的频率(如例子中的 `Duration.ofMillis(100)`),否则会给服务端造成不必要的压力。
|
||||||
|
|
||||||
#### 关闭订阅
|
#### 关闭订阅
|
||||||
|
|
||||||
```java
|
```java
|
||||||
sub.close(true);
|
consumer.close()
|
||||||
```
|
```
|
||||||
|
|
||||||
`close` 方法关闭一个订阅。如果其参数为 `true` 表示保留订阅进度信息,后续可以创建同名订阅继续消费数据;如为 `false` 则不保留订阅进度。
|
### 使用示例如下:
|
||||||
|
|
||||||
### 关闭资源
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
resultSet.close();
|
public abstract class ConsumerLoop {
|
||||||
stmt.close();
|
private final TaosConsumer<ResultBean> consumer;
|
||||||
conn.close();
|
private final List<String> topics;
|
||||||
```
|
private final AtomicBoolean shutdown;
|
||||||
|
private final CountDownLatch shutdownLatch;
|
||||||
|
|
||||||
> `注意务必要将 connection 进行关闭`,否则会出现连接泄露。
|
public ConsumerLoop() throws SQLException {
|
||||||
|
Properties config = new Properties();
|
||||||
|
config.setProperty("msg.with.table.name", "true");
|
||||||
|
config.setProperty("enable.auto.commit", "true");
|
||||||
|
config.setProperty("group.id", "group1");
|
||||||
|
config.setProperty("value.deserializer", "com.taosdata.jdbc.tmq.ConsumerTest.ResultDeserializer");
|
||||||
|
|
||||||
|
this.consumer = new TaosConsumer<>(config);
|
||||||
|
this.topics = Collections.singletonList("topic_speed");
|
||||||
|
this.shutdown = new AtomicBoolean(false);
|
||||||
|
this.shutdownLatch = new CountDownLatch(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void process(ResultBean result);
|
||||||
|
|
||||||
|
public void pollData() throws SQLException {
|
||||||
|
try {
|
||||||
|
consumer.subscribe(topics);
|
||||||
|
|
||||||
|
while (!shutdown.get()) {
|
||||||
|
ConsumerRecords<ResultBean> records = consumer.poll(Duration.ofMillis(100));
|
||||||
|
for (ResultBean record : records) {
|
||||||
|
process(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
consumer.close();
|
||||||
|
shutdownLatch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() throws InterruptedException {
|
||||||
|
shutdown.set(true);
|
||||||
|
shutdownLatch.await();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ResultDeserializer extends ReferenceDeserializer<ResultBean> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ResultBean {
|
||||||
|
private Timestamp ts;
|
||||||
|
private int speed;
|
||||||
|
|
||||||
|
public Timestamp getTs() {
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTs(Timestamp ts) {
|
||||||
|
this.ts = ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeed(int speed) {
|
||||||
|
this.speed = speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### 与连接池使用
|
### 与连接池使用
|
||||||
|
|
||||||
|
@ -787,20 +859,6 @@ public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
> 更多 druid 使用问题请查看[官方说明](https://github.com/alibaba/druid)。
|
> 更多 druid 使用问题请查看[官方说明](https://github.com/alibaba/druid)。
|
||||||
|
|
||||||
**注意事项:**
|
|
||||||
|
|
||||||
- TDengine `v1.6.4.1` 版本开始提供了一个专门用于心跳检测的函数 `select server_status()`,所以在使用连接池时推荐使用 `select server_status()` 进行 Validation Query。
|
|
||||||
|
|
||||||
如下所示,`select server_status()` 执行成功会返回 `1`。
|
|
||||||
|
|
||||||
```sql
|
|
||||||
taos> select server_status();
|
|
||||||
server_status()|
|
|
||||||
================
|
|
||||||
1 |
|
|
||||||
Query OK, 1 row(s) in set (0.000141s)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 更多示例程序
|
### 更多示例程序
|
||||||
|
|
||||||
示例程序源码位于 `TDengine/examples/JDBC` 下:
|
示例程序源码位于 `TDengine/examples/JDBC` 下:
|
||||||
|
@ -811,7 +869,7 @@ Query OK, 1 row(s) in set (0.000141s)
|
||||||
- SpringJdbcTemplate:Spring JdbcTemplate 中使用 taos-jdbcdriver。
|
- SpringJdbcTemplate:Spring JdbcTemplate 中使用 taos-jdbcdriver。
|
||||||
- mybatisplus-demo:Springboot + Mybatis 中使用 taos-jdbcdriver。
|
- mybatisplus-demo:Springboot + Mybatis 中使用 taos-jdbcdriver。
|
||||||
|
|
||||||
请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC)
|
请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/3.0/examples/JDBC)
|
||||||
|
|
||||||
## 最近更新记录
|
## 最近更新记录
|
||||||
|
|
||||||
|
@ -842,7 +900,7 @@ Query OK, 1 row(s) in set (0.000141s)
|
||||||
|
|
||||||
**解决方法**:重新安装 64 位 JDK。
|
**解决方法**:重新安装 64 位 JDK。
|
||||||
|
|
||||||
4. 其它问题请参考 [FAQ](/train-faq/faq)
|
4. 其它问题请参考 [FAQ](../../../train-faq/faq)
|
||||||
|
|
||||||
## API 参考
|
## API 参考
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import NodeOpenTSDBTelnet from "../../07-develop/03-insert-data/_js_opts_telnet.
|
||||||
import NodeOpenTSDBJson from "../../07-develop/03-insert-data/_js_opts_json.mdx";
|
import NodeOpenTSDBJson from "../../07-develop/03-insert-data/_js_opts_json.mdx";
|
||||||
import NodeQuery from "../../07-develop/04-query-data/_js.mdx";
|
import NodeQuery from "../../07-develop/04-query-data/_js.mdx";
|
||||||
|
|
||||||
`td2.0-connector` 和 `td2.0-rest-connector` 是 TDengine 的官方 Node.js 语言连接器。Node.js 开发人员可以通过它开发可以存取 TDengine 集群数据的应用软件。
|
`@tdengine/client` 和 `@tdengine/rest` 是 TDengine 的官方 Node.js 语言连接器。 Node.js 开发人员可以通过它开发可以存取 TDengine 集群数据的应用软件。注意:从 TDengine 3.0 开始 Node.js 原生连接器的包名由 `td2.0-connector` 改名为 `@tdengine/client` 而 rest 连接器的包名由 `td2.0-rest-connector` 改为 `@tdengine/rest`。并且不与 TDengine 2.x 兼容。
|
||||||
|
|
||||||
`td2.0-connector` 是**原生连接器**,它通过 TDengine 客户端驱动程序(taosc)连接 TDengine 运行实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能。`td2.0-rest-connector` 是 **REST 连接器**,它通过 taosAdapter 提供的 REST 接口连接 TDengine 的运行实例。REST 连接器可以在任何平台运行,但性能略为下降,接口实现的功能特性集合和原生接口有少量不同。
|
`@tdengine/client` 是**原生连接器**,它通过 TDengine 客户端驱动程序(taosc)连接 TDengine 运行实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能。`@tdengine/rest` 是 **REST 连接器**,它通过 taosAdapter 提供的 REST 接口连接 TDengine 的运行实例。REST 连接器可以在任何平台运行,但性能略为下降,接口实现的功能特性集合和原生接口有少量不同。
|
||||||
|
|
||||||
Node.js 连接器源码托管在 [GitHub](https://github.com/taosdata/taos-connector-node)。
|
Node.js 连接器源码托管在 [GitHub](https://github.com/taosdata/taos-connector-node/tree/3.0)。
|
||||||
|
|
||||||
## 支持的平台
|
## 支持的平台
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ REST 连接器支持所有能运行 Node.js 的平台。
|
||||||
<TabItem value="Linux" label="Linux 系统安装依赖工具">
|
<TabItem value="Linux" label="Linux 系统安装依赖工具">
|
||||||
|
|
||||||
- `python` (建议`v2.7` , `v3.x.x` 目前还不支持)
|
- `python` (建议`v2.7` , `v3.x.x` 目前还不支持)
|
||||||
- `td2.0-connector` 2.0.6 支持 Node.js LTS v10.9.0 或更高版本, Node.js LTS v12.8.0 或更高版本;2.0.5 及更早版本支持 Node.js LTS v10.x 版本。其他版本可能存在包兼容性的问题
|
- `@tdengine/client` 3.0.0 支持 Node.js LTS v10.9.0 或更高版本, Node.js LTS v12.8.0 或更高版本;其他版本可能存在包兼容性的问题
|
||||||
- `make`
|
- `make`
|
||||||
- C 语言编译器,[GCC](https://gcc.gnu.org) v4.8.5 或更高版本
|
- C 语言编译器,[GCC](https://gcc.gnu.org) v4.8.5 或更高版本
|
||||||
|
|
||||||
|
@ -90,14 +90,14 @@ REST 连接器支持所有能运行 Node.js 的平台。
|
||||||
<TabItem value="install_native" label="安装原生连接器">
|
<TabItem value="install_native" label="安装原生连接器">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install td2.0-connector
|
npm install @tdengine/client
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="install_rest" label="安装 REST 连接器">
|
<TabItem value="install_rest" label="安装 REST 连接器">
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i td2.0-rest-connector
|
npm install @tdengine/rest
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
@ -109,13 +109,13 @@ npm i td2.0-rest-connector
|
||||||
|
|
||||||
验证方法:
|
验证方法:
|
||||||
|
|
||||||
- 新建安装验证目录,例如:`~/tdengine-test`,下载 GitHub 上 [nodejsChecker.js 源代码](https://github.com/taosdata/TDengine/tree/develop/examples/nodejs/nodejsChecker.js)到本地。
|
- 新建安装验证目录,例如:`~/tdengine-test`,下载 GitHub 上 [nodejsChecker.js 源代码](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/nodejsChecker.js)到本地。
|
||||||
|
|
||||||
- 在命令行中执行以下命令。
|
- 在命令行中执行以下命令。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm init -y
|
npm init -y
|
||||||
npm install td2.0-connector
|
npm install @tdengine/client
|
||||||
node nodejsChecker.js host=localhost
|
node nodejsChecker.js host=localhost
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -128,11 +128,11 @@ node nodejsChecker.js host=localhost
|
||||||
<Tabs defaultValue="native">
|
<Tabs defaultValue="native">
|
||||||
<TabItem value="native" label="原生连接">
|
<TabItem value="native" label="原生连接">
|
||||||
|
|
||||||
安装并引用 `td2.0-connector` 包。
|
安装并引用 `@tdengine/client` 包。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
|
//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
|
||||||
const taos = require("td2.0-connector");
|
const taos = require("@tdengine/client");
|
||||||
var conn = taos.connect({
|
var conn = taos.connect({
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
user: "root",
|
user: "root",
|
||||||
|
@ -149,12 +149,12 @@ conn.close();
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="rest" label="REST 连接">
|
<TabItem value="rest" label="REST 连接">
|
||||||
|
|
||||||
安装并引用 `td2.0-rest-connector` 包。
|
安装并引用 `@tdengine/rest` 包。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
|
//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
|
||||||
import { options, connect } from "td2.0-rest-connector";
|
import { options, connect } from "@tdengine/rest";
|
||||||
options.path = "/rest/sqlt";
|
options.path = "/rest/sql";
|
||||||
// set host
|
// set host
|
||||||
options.host = "localhost";
|
options.host = "localhost";
|
||||||
// set other options like user/passwd
|
// set other options like user/passwd
|
||||||
|
@ -190,26 +190,23 @@ let cursor = conn.cursor();
|
||||||
|
|
||||||
<NodeQuery />
|
<NodeQuery />
|
||||||
|
|
||||||
|
|
||||||
## 更多示例程序
|
## 更多示例程序
|
||||||
|
|
||||||
| 示例程序 | 示例程序描述 |
|
| 示例程序 | 示例程序描述 |
|
||||||
| ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- |
|
| ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- |
|
||||||
| [connection](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/cursorClose.js) | 建立连接的示例。 |
|
| [basicUse](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/queryExample.js) | 基本的使用如如建立连接,执行 SQL 等操作。 |
|
||||||
| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamBatchSample.js) | 绑定多行参数插入的示例。 |
|
| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/bindParamBatch.js) | 绑定多行参数插入的示例。 | |
|
||||||
| [stmtBind](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamSample.js) | 一行一行绑定参数插入的示例。 |
|
| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/bindSingleParamBatch.js) | 按列绑定参数插入的示例。 |
|
||||||
| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindSingleParamBatchSample.js) | 按列绑定参数插入的示例。 |
|
| [stmtQuery](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/stmtQuery.js) | 绑定参数查询的示例。 |
|
||||||
| [stmtUseResult](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtUseResultSample.js) | 绑定参数查询的示例。 |
|
| [schemless insert](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/schemaless.js) | schemless 插入的示例。 |
|
||||||
| [json tag](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testJsonTag.js) | Json tag 的使用示例。 |
|
| [TMQ](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/tmq.js) | 订阅的使用示例。 |
|
||||||
| [Nanosecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testNanoseconds.js) | 时间戳为纳秒精度的使用的示例。 |
|
| [asyncQuery](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/asyncQueryExample.js) | 异步查询的使用示例。 |
|
||||||
| [Microsecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testMicroseconds.js) | 时间戳为微秒精度的使用的示例。 |
|
| [REST](https://github.com/taosdata/taos-connector-node/blob/3.0/typescript-rest/example/example.ts) | 使用 REST 连接的 TypeScript 使用示例。 |
|
||||||
| [schemless insert](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSchemalessInsert.js) | schemless 插入的示例。 |
|
|
||||||
| [subscribe](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSubscribe.js) | 订阅的使用示例。 |
|
|
||||||
| [asyncQuery](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/tset.js) | 异步查询的使用示例。 |
|
|
||||||
| [REST](https://github.com/taosdata/taos-connector-node/blob/develop/typescript-rest/example/example.ts) | 使用 REST 连接的 TypeScript 使用示例。 |
|
|
||||||
|
|
||||||
## 使用限制
|
## 使用限制
|
||||||
|
|
||||||
Node.js 连接器 >= v2.0.6 目前支持 node 的版本为:支持 >=v12.8.0 <= v12.9.1 || >=v10.20.0 <= v10.9.0 ;2.0.5 及更早版本支持 v10.x 版本,其他版本可能存在包兼容性的问题。
|
native 连接器(`@tdengine/client`) >= v3.0.0 目前支持 node 的版本为:支持 >=v12.8.0 <= v12.9.1 || >=v10.20.0 <= v10.9.0 ;2.0.5 及更早版本支持 v10.x 版本,其他版本可能存在包兼容性的问题。
|
||||||
|
|
||||||
## 其他说明
|
## 其他说明
|
||||||
|
|
||||||
|
@ -225,7 +222,7 @@ Node.js 连接器的使用参见[视频教程](https://www.taosdata.com/blog/202
|
||||||
|
|
||||||
2. Node.js 版本
|
2. Node.js 版本
|
||||||
|
|
||||||
连接器 >v2.0.6 目前兼容的 Node.js 版本为:>=v10.20.0 <= v10.9.0 || >=v12.8.0 <= v12.9.1
|
原生连接器 `@tdengine/client` 目前兼容的 Node.js 版本为:>=v10.20.0 <= v10.9.0 || >=v12.8.0 <= v12.9.1
|
||||||
|
|
||||||
3. "Unable to establish connection","Unable to resolve FQDN"
|
3. "Unable to establish connection","Unable to resolve FQDN"
|
||||||
|
|
||||||
|
@ -235,18 +232,22 @@ Node.js 连接器的使用参见[视频教程](https://www.taosdata.com/blog/202
|
||||||
|
|
||||||
### 原生连接器
|
### 原生连接器
|
||||||
|
|
||||||
| td2.0-connector 版本 | 说明 |
|
| package name | version | TDengine version | 说明 |
|
||||||
| -------------------- | ---------------------------------------------------------------- |
|
|------------------|---------|---------------------|------------------------------------------------------------------|
|
||||||
| 2.0.12 | 修复 cursor.close() 报错的 bug。 |
|
| @tdengine/client | 3.0.0 | 3.0.0 | 支持TDengine 3.0 且不与2.x 兼容。 |
|
||||||
| 2.0.11 | 支持绑定参数、json tag、schemaless 接口等功能。 |
|
| td2.0-connector | 2.0.12 | 2.4.x;2.5.x;2.6.x | 修复 cursor.close() 报错的 bug。 |
|
||||||
| 2.0.10 | 支持连接管理,普通查询、连续查询、获取系统信息、订阅功能等功能。 |
|
| td2.0-connector | 2.0.11 | 2.4.x;2.5.x;2.6.x | 支持绑定参数、json tag、schemaless 接口等功能。 |
|
||||||
|
| td2.0-connector | 2.0.10 | 2.4.x;2.5.x;2.6.x | 支持连接管理,普通查询、连续查询、获取系统信息、订阅功能等功能。 |
|
||||||
### REST 连接器
|
### REST 连接器
|
||||||
|
|
||||||
| td2.0-rest-connector 版本 | 说明 |
|
| package name | version | TDengine version | 说明 |
|
||||||
| ------------------------- | ---------------------------------------------------------------- |
|
|----------------------|---------|---------------------|---------------------------------------------------------------------------|
|
||||||
| 1.0.3 | 支持连接管理、普通查询、获取系统信息、错误信息、连续查询等功能。 |
|
| @tdengine/rest | 3.0.0 | 3.0.0 | 支持 TDegnine 3.0,且不与2.x 兼容。 |
|
||||||
|
| td2.0-rest-connector | 1.0.7 | 2.4.x;2.5.x;2.6.x | 移除默认端口 6041。 |
|
||||||
|
| td2.0-rest-connector | 1.0.6 | 2.4.x;2.5.x;2.6.x | 修复create,insert,update,alter 等SQL 执行返回的 affectRows 错误的bug。 |
|
||||||
|
| td2.0-rest-connector | 1.0.5 | 2.4.x;2.5.x;2.6.x | 支持云服务 cloud Token; |
|
||||||
|
| td2.0-rest-connector | 1.0.3 | 2.4.x;2.5.x;2.6.x | 支持连接管理、普通查询、获取系统信息、错误信息、连续查询等功能。 |
|
||||||
|
|
||||||
## API 参考
|
## API 参考
|
||||||
|
|
||||||
[API 参考](https://docs.taosdata.com/api/td2.0-connector/)
|
[API 参考](https://docs.taosdata.com/api/td2.0-connector/)
|
|
@ -306,8 +306,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
|
||||||
| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | 参数绑定,一次绑定一行 |
|
| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | 参数绑定,一次绑定一行 |
|
||||||
| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB 行协议写入 |
|
| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB 行协议写入 |
|
||||||
| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | 使用 JSON 类型的标签 |
|
| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | 使用 JSON 类型的标签 |
|
||||||
| [subscribe-async.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-async.py) | 异步订阅 |
|
| [tmq.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/tmq.py) | tmq 订阅 |
|
||||||
| [subscribe-sync.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-sync.py) | 同步订阅 |
|
|
||||||
|
|
||||||
## 其它说明
|
## 其它说明
|
||||||
|
|
||||||
|
@ -326,23 +325,15 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
|
||||||
1. https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds
|
1. https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds
|
||||||
2. https://www.python.org/dev/peps/pep-0564/
|
2. https://www.python.org/dev/peps/pep-0564/
|
||||||
|
|
||||||
|
|
||||||
## 常见问题
|
|
||||||
|
|
||||||
欢迎[提问或报告问题](https://github.com/taosdata/taos-connector-python/issues)。
|
|
||||||
|
|
||||||
## 重要更新
|
## 重要更新
|
||||||
|
|
||||||
| 连接器版本 | 重要更新 | 发布日期 |
|
|
||||||
| ---------- | --------------------------------------------------------------------------------- | ---------- |
|
|
||||||
| 2.3.1 | 1. support TDengine REST API <br/> 2. remove support for Python version below 3.6 | 2022-04-28 |
|
|
||||||
| 2.2.5 | support timezone option when connect | 2022-04-13 |
|
|
||||||
| 2.2.2 | support sqlalchemy dialect plugin | 2022-03-28 |
|
|
||||||
|
|
||||||
|
|
||||||
[**Release Notes**](https://github.com/taosdata/taos-connector-python/releases)
|
[**Release Notes**](https://github.com/taosdata/taos-connector-python/releases)
|
||||||
|
|
||||||
## API 参考
|
## API 参考
|
||||||
|
|
||||||
- [taos](https://docs.taosdata.com/api/taospy/taos/)
|
- [taos](https://docs.taosdata.com/api/taospy/taos/)
|
||||||
- [taosrest](https://docs.taosdata.com/api/taospy/taosrest)
|
- [taosrest](https://docs.taosdata.com/api/taospy/taosrest)
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
欢迎[提问或报告问题](https://github.com/taosdata/taos-connector-python/issues)。
|
||||||
|
|
|
@ -56,8 +56,8 @@ lrwxrwxrwx 1 root root 13 Feb 22 09:34 log -> /var/log/taos/
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo dpkg -r tdengine
|
$ sudo dpkg -r tdengine
|
||||||
(Reading database ... 137504 files and directories currently installed.)
|
(Reading database ... 120119 files and directories currently installed.)
|
||||||
Removing tdengine (2.4.0.7) ...
|
Removing tdengine (3.0.0.10002) ...
|
||||||
TDengine is removed successfully!
|
TDengine is removed successfully!
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -81,10 +81,7 @@ TDengine is removed successfully!
|
||||||
|
|
||||||
```
|
```
|
||||||
$ rmtaos
|
$ rmtaos
|
||||||
Nginx for TDengine is running, stopping it...
|
|
||||||
TDengine is removed successfully!
|
TDengine is removed successfully!
|
||||||
|
|
||||||
taosKeeper is removed successfully!
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
|
@ -1,241 +1,200 @@
|
||||||
---
|
---
|
||||||
title: 常见问题及反馈
|
title: 常见问题及反馈
|
||||||
---
|
---
|
||||||
|
|
||||||
## 问题反馈
|
## 问题反馈
|
||||||
|
|
||||||
如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包:
|
如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包:
|
||||||
|
|
||||||
1. /var/log/taos (如果没有修改过默认路径)
|
1. /var/log/taos (如果没有修改过默认路径)
|
||||||
2. /etc/taos
|
2. /etc/taos(如果没有指定其他配置文件路径)
|
||||||
|
|
||||||
附上必要的问题描述,包括使用的 TDengine 版本信息、平台环境信息、发生该问题的执行操作、出现问题的表征及大概的时间,在 [GitHub](https://github.com/taosdata/TDengine) 提交 issue。
|
附上必要的问题描述,包括使用的 TDengine 版本信息、平台环境信息、发生该问题的执行操作、出现问题的表征及大概的时间,在 [GitHub](https://github.com/taosdata/TDengine) 提交 issue。
|
||||||
|
|
||||||
为了保证有足够的 debug 信息,如果问题能够重复,请修改/etc/taos/taos.cfg 文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启 taosd, 重复问题,然后再递交。也可以通过如下 SQL 语句,临时设置 taosd 的日志级别。
|
为了保证有足够的 debug 信息,如果问题能够重复,请修改/etc/taos/taos.cfg 文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启 taosd, 重复问题,然后再递交。也可以通过如下 SQL 语句,临时设置 taosd 的日志级别。
|
||||||
|
|
||||||
```
|
```
|
||||||
alter dnode <dnode_id> debugFlag 135;
|
alter dnode <dnode_id> 'debugFlag' '135';
|
||||||
```
|
```
|
||||||
|
|
||||||
但系统正常运行时,请一定将 debugFlag 设置为 131,否则会产生大量的日志信息,降低系统效率。
|
其中 dnode_id 请从 show dnodes; 命令输出中获取。
|
||||||
|
|
||||||
## 常见问题列表
|
但系统正常运行时,请一定将 debugFlag 设置为 131,否则会产生大量的日志信息,降低系统效率。
|
||||||
|
|
||||||
### 1. TDengine2.0 之前的版本升级到 2.0 及以上的版本应该注意什么?☆☆☆
|
## 常见问题列表
|
||||||
|
|
||||||
2.0 版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作:
|
### 1. TDengine3.0 之前的版本升级到 3.0 及以上的版本应该注意什么?
|
||||||
|
|
||||||
1. 删除配置文件,执行 `sudo rm -rf /etc/taos/taos.cfg`
|
3.0 版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作:
|
||||||
2. 删除日志文件,执行 `sudo rm -rf /var/log/taos/`
|
|
||||||
3. 确保数据已经不再需要的前提下,删除数据文件,执行 `sudo rm -rf /var/lib/taos/`
|
1. 删除配置文件,执行 `sudo rm -rf /etc/taos/taos.cfg`
|
||||||
4. 安装最新稳定版本的 TDengine
|
2. 删除日志文件,执行 `sudo rm -rf /var/log/taos/`
|
||||||
5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决
|
3. 确保数据已经不再需要的前提下,删除数据文件,执行 `sudo rm -rf /var/lib/taos/`
|
||||||
|
4. 安装最新3.0稳定版本的 TDengine
|
||||||
### 2. Windows 平台下 JDBCDriver 找不到动态链接库,怎么办?
|
5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决
|
||||||
|
|
||||||
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2019/12/03/950.html)。
|
### 2. Windows 平台下 JDBCDriver 找不到动态链接库,怎么办?
|
||||||
|
|
||||||
### 3. 创建数据表时提示 more dnodes are needed
|
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2019/12/03/950.html)。
|
||||||
|
|
||||||
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2019/12/03/965.html)。
|
### 3. 如何让 TDengine crash 时生成 core 文件?
|
||||||
|
|
||||||
### 4. 如何让 TDengine crash 时生成 core 文件?
|
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2019/12/06/974.html)。
|
||||||
|
|
||||||
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2019/12/06/974.html)。
|
### 4. 遇到错误“Unable to establish connection” 怎么办?
|
||||||
|
|
||||||
### 5. 遇到错误“Unable to establish connection” 怎么办?
|
客户端遇到连接故障,请按照下面的步骤进行检查:
|
||||||
|
|
||||||
客户端遇到连接故障,请按照下面的步骤进行检查:
|
1. 检查网络环境
|
||||||
|
|
||||||
1. 检查网络环境
|
- 云服务器:检查云服务器的安全组是否打开 TCP/UDP 端口 6030/6041 的访问权限
|
||||||
|
- 本地虚拟机:检查网络能否 ping 通,尽量避免使用`localhost` 作为 hostname
|
||||||
- 云服务器:检查云服务器的安全组是否打开 TCP/UDP 端口 6030-6042 的访问权限
|
- 公司服务器:如果为 NAT 网络环境,请务必检查服务器能否将消息返回值客户端
|
||||||
- 本地虚拟机:检查网络能否 ping 通,尽量避免使用`localhost` 作为 hostname
|
|
||||||
- 公司服务器:如果为 NAT 网络环境,请务必检查服务器能否将消息返回值客户端
|
2. 确保客户端与服务端版本号是完全一致的,开源社区版和企业版也不能混用
|
||||||
|
|
||||||
2. 确保客户端与服务端版本号是完全一致的,开源社区版和企业版也不能混用
|
3. 在服务器,执行 `systemctl status taosd` 检查*taosd*运行状态。如果没有运行,启动*taosd*
|
||||||
|
|
||||||
3. 在服务器,执行 `systemctl status taosd` 检查*taosd*运行状态。如果没有运行,启动*taosd*
|
4. 确认客户端连接时指定了正确的服务器 FQDN (Fully Qualified Domain Name —— 可在服务器上执行 Linux 命令 hostname -f 获得),FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。
|
||||||
|
|
||||||
4. 确认客户端连接时指定了正确的服务器 FQDN (Fully Qualified Domain Name —— 可在服务器上执行 Linux 命令 hostname -f 获得),FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。
|
5. ping 服务器 FQDN,如果没有反应,请检查你的网络,DNS 设置,或客户端所在计算机的系统 hosts 文件。如果部署的是 TDengine 集群,客户端需要能 ping 通所有集群节点的 FQDN。
|
||||||
|
|
||||||
5. ping 服务器 FQDN,如果没有反应,请检查你的网络,DNS 设置,或客户端所在计算机的系统 hosts 文件。如果部署的是 TDengine 集群,客户端需要能 ping 通所有集群节点的 FQDN。
|
6. 检查防火墙设置(Ubuntu 使用 ufw status,CentOS 使用 firewall-cmd --list-port),确保集群中所有主机在端口 6030/6041 上的 TCP/UDP 协议能够互通。
|
||||||
|
|
||||||
6. 检查防火墙设置(Ubuntu 使用 ufw status,CentOS 使用 firewall-cmd --list-port),确保集群中所有主机在端口 6030-6042 上的 TCP/UDP 协议能够互通。
|
7. 对于 Linux 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH*里
|
||||||
|
|
||||||
7. 对于 Linux 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH*里
|
8. 对于 Windows 上的 JDBC, ODBC, Python, Go 等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 _C:\Windows\System32_)
|
||||||
|
|
||||||
8. 对于 Windows 上的 JDBC, ODBC, Python, Go 等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 _C:\Windows\System32_)
|
9. 如果仍不能排除连接故障
|
||||||
|
|
||||||
9. 如果仍不能排除连接故障
|
- Linux 系统请使用命令行工具 nc 来分别判断指定端口的 TCP 和 UDP 连接是否通畅
|
||||||
|
检查 UDP 端口连接是否工作:`nc -vuz {hostIP} {port} `
|
||||||
- Linux 系统请使用命令行工具 nc 来分别判断指定端口的 TCP 和 UDP 连接是否通畅
|
检查服务器侧 TCP 端口连接是否工作:`nc -l {port}`
|
||||||
检查 UDP 端口连接是否工作:`nc -vuz {hostIP} {port} `
|
检查客户端侧 TCP 端口连接是否工作:`nc {hostIP} {port}`
|
||||||
检查服务器侧 TCP 端口连接是否工作:`nc -l {port}`
|
|
||||||
检查客户端侧 TCP 端口连接是否工作:`nc {hostIP} {port}`
|
- Windows 系统请使用 PowerShell 命令 Test-NetConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问
|
||||||
|
|
||||||
- Windows 系统请使用 PowerShell 命令 Test-NetConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问
|
10. 也可以使用 taos 程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅:[诊断及其他](https://docs.taosdata.com/3.0-preview/operation/diagnose/)。
|
||||||
|
|
||||||
10. 也可以使用 taos 程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括 TCP 和 UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)。
|
### 5. 遇到错误 Unable to resolve FQDN” 怎么办?
|
||||||
|
|
||||||
### 6. 遇到错误 “Unexpected generic error in RPC”或者“Unable to resolve FQDN” 怎么办?
|
产生这个错误,是由于客户端或数据节点无法解析 FQDN(Fully Qualified Domain Name)导致。对于 TAOS Shell 或客户端应用,请做如下检查:
|
||||||
|
|
||||||
产生这个错误,是由于客户端或数据节点无法解析 FQDN(Fully Qualified Domain Name)导致。对于 TAOS Shell 或客户端应用,请做如下检查:
|
1. 请检查连接的服务器的 FQDN 是否正确,FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)
|
||||||
|
2. 如果网络配置有 DNS server,请检查是否正常工作
|
||||||
1. 请检查连接的服务器的 FQDN 是否正确,FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)
|
3. 如果网络没有配置 DNS server,请检查客户端所在机器的 hosts 文件,查看该 FQDN 是否配置,并是否有正确的 IP 地址
|
||||||
2. 如果网络配置有 DNS server,请检查是否正常工作
|
4. 如果网络配置 OK,从客户端所在机器,你需要能 Ping 该连接的 FQDN,否则客户端是无法连接服务器的
|
||||||
3. 如果网络没有配置 DNS server,请检查客户端所在机器的 hosts 文件,查看该 FQDN 是否配置,并是否有正确的 IP 地址
|
5. 如果服务器曾经使用过 TDengine,且更改过 hostname,建议检查 data 目录的 dnode.json 是否符合当前配置的 EP,路径默认为/var/lib/taos/dnode。正常情况下,建议更换新的数据目录或者备份后删除以前的数据目录,这样可以避免该问题。
|
||||||
4. 如果网络配置 OK,从客户端所在机器,你需要能 Ping 该连接的 FQDN,否则客户端是无法连接服务器的
|
6. 检查/etc/hosts 和/etc/hostname 是否是预配置的 FQDN
|
||||||
5. 如果服务器曾经使用过 TDengine,且更改过 hostname,建议检查 data 目录的 dnodeEps.json 是否符合当前配置的 EP,路径默认为/var/lib/taos/dnode。正常情况下,建议更换新的数据目录或者备份后删除以前的数据目录,这样可以避免该问题。
|
|
||||||
6. 检查/etc/hosts 和/etc/hostname 是否是预配置的 FQDN
|
### 6. 最有效的写入数据的方法是什么?
|
||||||
|
|
||||||
### 7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误?
|
批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。
|
||||||
|
|
||||||
如果你确认语法正确,2.0 之前版本,请检查 SQL 语句长度是否超过 64K。如果超过,也会返回这个错误。
|
### 7. Windows 系统下插入的 nchar 类数据中的汉字被解析成了乱码如何解决?
|
||||||
|
|
||||||
### 8. 是否支持 validation queries?
|
Windows 下插入 nchar 类的数据中如果有中文,请先确认系统的地区设置成了中国(在 Control Panel 里可以设置),这时 cmd 中的`taos`客户端应该已经可以正常工作了;如果是在 IDE 里开发 Java 应用,比如 Eclipse, IntelliJ,请确认 IDE 里的文件编码为 GBK(这是 Java 默认的编码类型),然后在生成 Connection 时,初始化客户端的配置,具体语句如下:
|
||||||
|
|
||||||
TDengine 还没有一组专用的 validation queries。然而建议你使用系统监测的数据库”log"来做。
|
```JAVA
|
||||||
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
<a class="anchor" id="update"></a>
|
Properties properties = new Properties();
|
||||||
|
properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
|
||||||
### 9. 我可以删除或更新一条记录吗?
|
Connection = DriverManager.getConnection(url, properties);
|
||||||
|
```
|
||||||
TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。
|
|
||||||
|
### 8. Windows 系统下客户端无法正常显示中文字符?
|
||||||
从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。
|
|
||||||
|
Windows 系统中一般是采用 GBK/GB18030 存储中文字符,而 TDengine 的默认字符集为 UTF-8 ,在 Windows 系统中使用 TDengine 客户端时,客户端驱动会将字符统一转换为 UTF-8 编码后发送到服务端存储,因此在应用开发过程中,调用接口时正确配置当前的中文字符集即可。
|
||||||
另需注意,在 UPDATE 设置为 0 时,后发送的相同时间戳的数据会被直接丢弃,但并不会报错,而且仍然会被计入 affected rows (所以不能利用 INSERT 指令的返回信息进行时间戳查重)。这样设计的主要原因是,TDengine 把写入的数据看做一个数据流,无论时间戳是否出现冲突,TDengine 都认为产生数据的原始设备真实地产生了这样的数据。UPDATE 参数只是控制这样的流数据在进行持久化时要怎样处理——UPDATE 为 0 时,表示先写入的数据覆盖后写入的数据;而 UPDATE 为 1 时,表示后写入的数据覆盖先写入的数据。这种覆盖关系如何选择,取决于对数据的后续使用和统计中,希望以先还是后生成的数据为准。
|
|
||||||
|
在 Windows 10 环境下运行 TDengine 客户端命令行工具 taos 时,若无法正常输入、显示中文,可以对客户端 taos.cfg 做如下配置:
|
||||||
此外,从 2.1.7.0 版本开始,支持将 UPDATE 参数设为 2,表示“支持部分列更新”。也即,当 UPDATE 设为 1 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL;而当 UPDATE 设为 2 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值。
|
|
||||||
|
```
|
||||||
### 10. 我怎么创建超过 1024 列的表?
|
locale C
|
||||||
|
charset UTF-8
|
||||||
使用 2.0 及其以上版本,默认支持 1024 列;2.0 之前的版本,TDengine 最大允许创建 250 列的表。但是如果确实超过限值,建议按照数据特性,逻辑地将这个宽表分解成几个小表。(从 2.1.7.0 版本开始,表的最大列数增加到了 4096 列。)
|
```
|
||||||
|
|
||||||
### 11. 最有效的写入数据的方法是什么?
|
### 9. 表名显示不全
|
||||||
|
|
||||||
批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。
|
由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用 \G 参数来调整结果的显示方式。
|
||||||
|
|
||||||
### 12. Windows 系统下插入的 nchar 类数据中的汉字被解析成了乱码如何解决?
|
### 10. 如何进行数据迁移?
|
||||||
|
|
||||||
Windows 下插入 nchar 类的数据中如果有中文,请先确认系统的地区设置成了中国(在 Control Panel 里可以设置),这时 cmd 中的`taos`客户端应该已经可以正常工作了;如果是在 IDE 里开发 Java 应用,比如 Eclipse, IntelliJ,请确认 IDE 里的文件编码为 GBK(这是 Java 默认的编码类型),然后在生成 Connection 时,初始化客户端的配置,具体语句如下:
|
TDengine 是根据 hostname 唯一标志一台机器的,对于3.0版本,将数据文件从机器 A 移动机器 B 时,需要重新配置机器 B 的 hostname 为机器 A 的 hostname。
|
||||||
|
|
||||||
```JAVA
|
注:3.x 和 之前的1.x、2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
|
||||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
|
||||||
Properties properties = new Properties();
|
### 11. 如何在命令行程序 taos 中临时调整日志级别
|
||||||
properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
|
|
||||||
Connection = DriverManager.getConnection(url, properties);
|
为了调试方便,命令行程序 taos 新增了与日志记录相关的指令:
|
||||||
```
|
|
||||||
|
```sql
|
||||||
### 13. Windows 系统下客户端无法正常显示中文字符?
|
ALTER LOCAL local_option
|
||||||
|
|
||||||
Windows 系统中一般是采用 GBK/GB18030 存储中文字符,而 TDengine 的默认字符集为 UTF-8 ,在 Windows 系统中使用 TDengine 客户端时,客户端驱动会将字符统一转换为 UTF-8 编码后发送到服务端存储,因此在应用开发过程中,调用接口时正确配置当前的中文字符集即可。
|
local_option: {
|
||||||
|
'resetLog'
|
||||||
【 v2.2.1.5以后版本 】在 Windows 10 环境下运行 TDengine 客户端命令行工具 taos 时,若无法正常输入、显示中文,可以对客户端 taos.cfg 做如下配置:
|
| 'rpcDebugFlag' value
|
||||||
|
| 'tmrDebugFlag' value
|
||||||
```
|
| 'cDebugFlag' value
|
||||||
locale C
|
| 'uDebugFlag' value
|
||||||
charset UTF-8
|
| 'debugFlag' value
|
||||||
```
|
}
|
||||||
|
```
|
||||||
### 14. JDBC 报错: the executed SQL is not a DML or a DDL?
|
|
||||||
|
其含义是,在当前的命令行程序下,清空本机所有客户端生成的日志文件(resetLog),或修改一个特定模块的日志记录级别(只对当前命令行程序有效,如果 taos 命令行程序重启,则需要重新设置):
|
||||||
请更新至最新的 JDBC 驱动,参考 [Java 连接器](/reference/connector/java)
|
|
||||||
|
- value 的取值可以是:131(输出错误和警告日志),135( 输出错误、警告和调试日志),143( 输出错误、警告、调试和跟踪日志)。
|
||||||
### 15. taos connect failed, reason: invalid timestamp
|
|
||||||
|
### 12. go 语言编写组件编译失败怎样解决?
|
||||||
常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。
|
|
||||||
|
TDengine 3.0版本包含一个使用 go 语言开发的 taosAdapter 独立组件,需要单独运行,提供restful接入功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD 等)的数据接入功能。
|
||||||
### 16. 表名显示不全
|
使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。
|
||||||
|
|
||||||
由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用 \G 参数来调整结果的显示方式。
|
go 语言版本要求 1.14 以上,如果发生 go 编译错误,往往是国内访问 go mod 问题,可以通过设置 go 环境变量来解决:
|
||||||
|
|
||||||
### 17. 如何进行数据迁移?
|
```sh
|
||||||
|
go env -w GO111MODULE=on
|
||||||
TDengine 是根据 hostname 唯一标志一台机器的,在数据文件从机器 A 移动机器 B 时,注意如下两件事:
|
go env -w GOPROXY=https://goproxy.cn,direct
|
||||||
|
```
|
||||||
- 2.0.0.0 至 2.0.6.x 的版本,重新配置机器 B 的 hostname 为机器 A 的 hostname。
|
|
||||||
- 2.0.7.0 及以后的版本,到/var/lib/taos/dnode 下,修复 dnodeEps.json 的 dnodeId 对应的 FQDN,重启。确保机器内所有机器的此文件是完全相同的。
|
### 13. 如何查询数据占用的存储空间大小?
|
||||||
- 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
|
|
||||||
|
默认情况下,TDengine 的数据文件存储在 /var/lib/taos ,日志文件存储在 /var/log/taos 。
|
||||||
### 18. 如何在命令行程序 taos 中临时调整日志级别
|
|
||||||
|
若想查看所有数据文件占用的具体大小,可以执行 Shell 指令:`du -sh /var/lib/taos/vnode --exclude='wal'` 来查看。此处排除了 WAL 目录,因为在持续写入的情况下,这里大小几乎是固定的,并且每当正常关闭 TDengine 让数据落盘后,WAL 目录都会清空。
|
||||||
为了调试方便,从 2.0.16 版本开始,命令行程序 taos 新增了与日志记录相关的两条指令:
|
|
||||||
|
若想查看单个数据库占用的大小,可在命令行程序 taos 内指定要查看的数据库后执行 `show vgroups;` ,通过得到的 VGroup id 去 /var/lib/taos/vnode 下查看包含的文件夹大小。
|
||||||
```sql
|
|
||||||
ALTER LOCAL flag_name flag_value;
|
### 14. 客户端连接串如何保证高可用?
|
||||||
```
|
|
||||||
|
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2021/04/16/2287.html)
|
||||||
其含义是,在当前的命令行程序下,修改一个特定模块的日志记录级别(只对当前命令行程序有效,如果 taos 命令行程序重启,则需要重新设置):
|
|
||||||
|
### 15. 时间戳的时区信息是怎样处理的?
|
||||||
- flag_name 的取值可以是:debugFlag,cDebugFlag,tmrDebugFlag,uDebugFlag,rpcDebugFlag
|
|
||||||
- flag_value 的取值可以是:131(输出错误和警告日志),135( 输出错误、警告和调试日志),143( 输出错误、警告、调试和跟踪日志)
|
TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。
|
||||||
|
|
||||||
```sql
|
客户端在处理时间戳字符串时,会采取如下逻辑:
|
||||||
ALTER LOCAL RESETLOG;
|
|
||||||
```
|
1. 在未做特殊设置的情况下,客户端默认使用所在操作系统的时区设置。
|
||||||
|
2. 如果在 taos.cfg 中设置了 timezone 参数,则客户端会以这个配置文件中的设置为准。
|
||||||
其含义是,清空本机所有由客户端生成的日志文件。
|
3. 如果在 C/C++/Java/Python 等各种编程语言的 Connector Driver 中,在建立数据库连接时显式指定了 timezone,那么会以这个指定的时区设置为准。例如 Java Connector 的 JDBC URL 中就有 timezone 参数。
|
||||||
|
4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。
|
||||||
<a class="anchor" id="timezone"></a>
|
|
||||||
|
### 16. TDengine 3.0 都会用到哪些网络端口?
|
||||||
### 19. go 语言编写组件编译失败怎样解决?
|
|
||||||
|
使用到的网络端口请看文档:[serverport](../../reference/config/#serverport)
|
||||||
TDengine 2.3.0.0 及之后的版本包含一个使用 go 语言开发的 taosAdapter 独立组件,需要单独运行,取代之前 taosd 内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD 等)的数据接入功能。
|
|
||||||
使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。
|
需要注意,文档上列举的端口号都是以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么列举的端口都会随之出现变化,管理员可以参考上述的信息调整防火墙设置。
|
||||||
|
|
||||||
目前编译方式默认自动编译 taosAdapter。go 语言版本要求 1.14 以上,如果发生 go 编译错误,往往是国内访问 go mod 问题,可以通过设置 go 环境变量来解决:
|
### 17. 为什么 RESTful 接口无响应、Grafana 无法添加 TDengine 为数据源、TDengineGUI 选了 6041 端口还是无法连接成功?
|
||||||
|
|
||||||
```sh
|
taosAdapter 从 TDengine 2.4.0.0 版本开始成为 TDengine 服务端软件的组成部分,是 TDengine 集群和应用程序之间的桥梁和适配器。在此之前 RESTful 接口等功能是由 taosd 内置的 HTTP 服务提供的,而如今要实现上述功能需要执行:```systemctl start taosadapter``` 命令来启动 taosAdapter 服务。
|
||||||
go env -w GO111MODULE=on
|
|
||||||
go env -w GOPROXY=https://goproxy.cn,direct
|
需要说明的是,taosAdapter 的日志路径 path 需要单独配置,默认路径是 /var/log/taos ;日志等级 logLevel 有 8 个等级,默认等级是 info ,配置成 panic 可关闭日志输出。请注意操作系统 / 目录的空间大小,可通过命令行参数、环境变量或配置文件来修改配置,默认配置文件是 /etc/taos/taosadapter.toml 。
|
||||||
```
|
|
||||||
|
有关 taosAdapter 组件的详细介绍请看文档:[taosAdapter](../../reference/taosadapter/)
|
||||||
如果希望继续使用之前的内置 httpd,可以关闭 taosAdapter 编译,使用
|
|
||||||
`cmake .. -DBUILD_HTTP=true` 使用原来内置的 httpd。
|
### 18. 发生了 OOM 怎么办?
|
||||||
|
|
||||||
### 20. 如何查询数据占用的存储空间大小?
|
OOM 是操作系统的保护机制,当操作系统内存(包括 SWAP )不足时,会杀掉某些进程,从而保证操作系统的稳定运行。通常内存不足主要是如下两个原因导致,一是剩余内存小于 vm.min_free_kbytes ;二是程序请求的内存大于剩余内存。还有一种情况是内存充足但程序占用了特殊的内存地址,也会触发 OOM 。
|
||||||
|
|
||||||
默认情况下,TDengine 的数据文件存储在 /var/lib/taos ,日志文件存储在 /var/log/taos 。
|
TDengine 会预先为每个 VNode 分配好内存,每个 Database 的 VNode 个数受 建库时的vgroups参数影响,每个 VNode 占用的内存大小受 buffer参数 影响。要防止 OOM,需要在项目建设之初合理规划内存,并合理设置 SWAP ,除此之外查询过量的数据也有可能导致内存暴涨,这取决于具体的查询语句。TDengine 企业版对内存管理做了优化,采用了新的内存分配器,对稳定性有更高要求的用户可以考虑选择企业版。
|
||||||
|
|
||||||
若想查看所有数据文件占用的具体大小,可以执行 Shell 指令:`du -sh /var/lib/taos/vnode --exclude='wal'` 来查看。此处排除了 WAL 目录,因为在持续写入的情况下,这里大小几乎是固定的,并且每当正常关闭 TDengine 让数据落盘后,WAL 目录都会清空。
|
|
||||||
|
|
||||||
若想查看单个数据库占用的大小,可在命令行程序 taos 内指定要查看的数据库后执行 `show vgroups;` ,通过得到的 VGroup id 去 /var/lib/taos/vnode 下查看包含的文件夹大小。
|
|
||||||
|
|
||||||
若仅仅想查看指定(超级)表的数据块分布及大小,可查看[_block_dist 函数](https://docs.taosdata.com/taos-sql/select/#_block_dist-%E5%87%BD%E6%95%B0)
|
|
||||||
|
|
||||||
### 21. 客户端连接串如何保证高可用?
|
|
||||||
|
|
||||||
请看为此问题撰写的 [技术博客](https://www.taosdata.com/blog/2021/04/16/2287.html)
|
|
||||||
|
|
||||||
### 22. 时间戳的时区信息是怎样处理的?
|
|
||||||
|
|
||||||
TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。
|
|
||||||
|
|
||||||
客户端在处理时间戳字符串时,会采取如下逻辑:
|
|
||||||
|
|
||||||
1. 在未做特殊设置的情况下,客户端默认使用所在操作系统的时区设置。
|
|
||||||
2. 如果在 taos.cfg 中设置了 timezone 参数,则客户端会以这个配置文件中的设置为准。
|
|
||||||
3. 如果在 C/C++/Java/Python 等各种编程语言的 Connector Driver 中,在建立数据库连接时显式指定了 timezone,那么会以这个指定的时区设置为准。例如 Java Connector 的 JDBC URL 中就有 timezone 参数。
|
|
||||||
4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。
|
|
||||||
|
|
||||||
### 23. TDengine 2.0 都会用到哪些网络端口?
|
|
||||||
|
|
||||||
使用到的网络端口请看文档:[serverport](/reference/config/#serverport)
|
|
||||||
|
|
||||||
需要注意,文档上列举的端口号都是以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么列举的端口都会随之出现变化,管理员可以参考上述的信息调整防火墙设置。
|
|
||||||
|
|
||||||
### 24. 为什么 RESTful 接口无响应、Grafana 无法添加 TDengine 为数据源、TDengineGUI 选了 6041 端口还是无法连接成功??
|
|
||||||
|
|
||||||
taosAdapter 从 TDengine 2.4.0.0 版本开始成为 TDengine 服务端软件的组成部分,是 TDengine 集群和应用程序之间的桥梁和适配器。在此之前 RESTful 接口等功能是由 taosd 内置的 HTTP 服务提供的,而如今要实现上述功能需要执行:```systemctl start taosadapter``` 命令来启动 taosAdapter 服务。
|
|
||||||
|
|
||||||
需要说明的是,taosAdapter 的日志路径 path 需要单独配置,默认路径是 /var/log/taos ;日志等级 logLevel 有 8 个等级,默认等级是 info ,配置成 panic 可关闭日志输出。请注意操作系统 / 目录的空间大小,可通过命令行参数、环境变量或配置文件来修改配置,默认配置文件是 /etc/taos/taosadapter.toml 。
|
|
||||||
|
|
||||||
有关 taosAdapter 组件的详细介绍请看文档:[taosAdapter](https://docs.taosdata.com/reference/taosadapter/)
|
|
||||||
|
|
||||||
### 25. 发生了 OOM 怎么办?
|
|
||||||
|
|
||||||
OOM 是操作系统的保护机制,当操作系统内存(包括 SWAP )不足时,会杀掉某些进程,从而保证操作系统的稳定运行。通常内存不足主要是如下两个原因导致,一是剩余内存小于 vm.min_free_kbytes ;二是程序请求的内存大于剩余内存。还有一种情况是内存充足但程序占用了特殊的内存地址,也会触发 OOM 。
|
|
||||||
|
|
||||||
TDengine 会预先为每个 VNode 分配好内存,每个 Database 的 VNode 个数受 maxVgroupsPerDb 影响,每个 VNode 占用的内存大小受 Blocks 和 Cache 影响。要防止 OOM,需要在项目建设之初合理规划内存,并合理设置 SWAP ,除此之外查询过量的数据也有可能导致内存暴涨,这取决于具体的查询语句。TDengine 企业版对内存管理做了优化,采用了新的内存分配器,对稳定性有更高要求的用户可以考虑选择企业版。
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 7ed7a97715388fa144718764d6bf20f9bfc29a12
|
|
@ -246,7 +246,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag);
|
||||||
// for debug
|
// for debug
|
||||||
char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf);
|
char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf);
|
||||||
|
|
||||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
||||||
tb_uid_t suid);
|
tb_uid_t suid);
|
||||||
|
|
||||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||||
|
|
|
@ -2657,6 +2657,31 @@ typedef struct {
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
} SVgEpSet;
|
} SVgEpSet;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t suid;
|
||||||
|
int8_t level;
|
||||||
|
} SRSmaFetchMsg;
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tEncodeSRSmaFetchMsg(SEncoder* pCoder, const SRSmaFetchMsg* pReq) {
|
||||||
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI64(pCoder, pReq->suid) < 0) return -1;
|
||||||
|
if (tEncodeI8(pCoder, pReq->level) < 0) return -1;
|
||||||
|
|
||||||
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tDecodeSRSmaFetchMsg(SDecoder* pCoder, SRSmaFetchMsg* pReq) {
|
||||||
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1;
|
||||||
|
if (tDecodeI8(pCoder, &pReq->level) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t version; // for compatibility(default 0)
|
int8_t version; // for compatibility(default 0)
|
||||||
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
||||||
|
|
|
@ -200,6 +200,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_FETCH_RSMA, "vnode-fetch-rsma", SRSmaFetchMsg, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
||||||
|
|
|
@ -354,8 +354,6 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type);
|
||||||
void *getDataMin(int32_t type);
|
void *getDataMin(int32_t type);
|
||||||
void *getDataMax(int32_t type);
|
void *getDataMax(int32_t type);
|
||||||
|
|
||||||
#define SET_DOUBLE_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_DOUBLE_NULL)
|
|
||||||
#define SET_BIGINT_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_BIGINT_NULL)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef struct SResultRowEntryInfo {
|
||||||
bool initialized:1; // output buffer has been initialized
|
bool initialized:1; // output buffer has been initialized
|
||||||
bool complete:1; // query has completed
|
bool complete:1; // query has completed
|
||||||
uint8_t isNullRes:6; // the result is null
|
uint8_t isNullRes:6; // the result is null
|
||||||
uint16_t numOfRes; // num of output result in current buffer
|
uint16_t numOfRes; // num of output result in current buffer. NOT NULL RESULT
|
||||||
} SResultRowEntryInfo;
|
} SResultRowEntryInfo;
|
||||||
|
|
||||||
// determine the real data need to calculated the result
|
// determine the real data need to calculated the result
|
||||||
|
|
|
@ -202,7 +202,7 @@ bool fmIsForbidStreamFunc(int32_t funcId);
|
||||||
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
||||||
bool fmIsInterpFunc(int32_t funcId);
|
bool fmIsInterpFunc(int32_t funcId);
|
||||||
bool fmIsLastRowFunc(int32_t funcId);
|
bool fmIsLastRowFunc(int32_t funcId);
|
||||||
bool fmIsReturnNotNullFunc(int32_t funcId);
|
bool fmIsNotNullOutputFunc(int32_t funcId);
|
||||||
bool fmIsSelectValueFunc(int32_t funcId);
|
bool fmIsSelectValueFunc(int32_t funcId);
|
||||||
bool fmIsSystemInfoFunc(int32_t funcId);
|
bool fmIsSystemInfoFunc(int32_t funcId);
|
||||||
bool fmIsImplicitTsFunc(int32_t funcId);
|
bool fmIsImplicitTsFunc(int32_t funcId);
|
||||||
|
|
|
@ -121,6 +121,7 @@ typedef struct SProjectLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
SNodeList* pProjections;
|
SNodeList* pProjections;
|
||||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||||
|
bool ignoreGroupId;
|
||||||
} SProjectLogicNode;
|
} SProjectLogicNode;
|
||||||
|
|
||||||
typedef struct SIndefRowsFuncLogicNode {
|
typedef struct SIndefRowsFuncLogicNode {
|
||||||
|
@ -344,6 +345,7 @@ typedef struct SProjectPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pProjections;
|
SNodeList* pProjections;
|
||||||
bool mergeDataBlock;
|
bool mergeDataBlock;
|
||||||
|
bool ignoreGroupId;
|
||||||
} SProjectPhysiNode;
|
} SProjectPhysiNode;
|
||||||
|
|
||||||
typedef struct SIndefRowsFuncPhysiNode {
|
typedef struct SIndefRowsFuncPhysiNode {
|
||||||
|
|
|
@ -47,6 +47,8 @@ bool updateInfoIgnore(SUpdateInfo *pInfo, STimeWindow* pWin, uint64_t groupId, u
|
||||||
void updateInfoDestroy(SUpdateInfo *pInfo);
|
void updateInfoDestroy(SUpdateInfo *pInfo);
|
||||||
void updateInfoAddCloseWindowSBF(SUpdateInfo *pInfo);
|
void updateInfoAddCloseWindowSBF(SUpdateInfo *pInfo);
|
||||||
void updateInfoDestoryColseWinSBF(SUpdateInfo *pInfo);
|
void updateInfoDestoryColseWinSBF(SUpdateInfo *pInfo);
|
||||||
|
int32_t updateInfoSerialize(void *buf, int32_t bufLen, const SUpdateInfo *pInfo);
|
||||||
|
int32_t updateInfoDeserialize(void *buf, int32_t bufLen, SUpdateInfo *pInfo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,10 @@ extern "C" {
|
||||||
|
|
||||||
extern bool gRaftDetailLog;
|
extern bool gRaftDetailLog;
|
||||||
|
|
||||||
#define SYNC_RESP_TTL_MS 10000000
|
#define SYNC_RESP_TTL_MS 10000000
|
||||||
|
#define SYNC_SPEED_UP_HB_TIMER 400
|
||||||
|
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
|
||||||
|
#define SYNC_SLOW_DOWN_RANGE 100
|
||||||
|
|
||||||
#define SYNC_MAX_BATCH_SIZE 1
|
#define SYNC_MAX_BATCH_SIZE 1
|
||||||
#define SYNC_INDEX_BEGIN 0
|
#define SYNC_INDEX_BEGIN 0
|
||||||
|
@ -205,6 +208,7 @@ int32_t syncSetStandby(int64_t rid);
|
||||||
ESyncState syncGetMyRole(int64_t rid);
|
ESyncState syncGetMyRole(int64_t rid);
|
||||||
bool syncIsReady(int64_t rid);
|
bool syncIsReady(int64_t rid);
|
||||||
const char* syncGetMyRoleStr(int64_t rid);
|
const char* syncGetMyRoleStr(int64_t rid);
|
||||||
|
bool syncRestoreFinish(int64_t rid);
|
||||||
SyncTerm syncGetMyTerm(int64_t rid);
|
SyncTerm syncGetMyTerm(int64_t rid);
|
||||||
SyncGroupId syncGetVgId(int64_t rid);
|
SyncGroupId syncGetVgId(int64_t rid);
|
||||||
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
|
|
|
@ -47,8 +47,6 @@ typedef struct SRpcHandleInfo {
|
||||||
int8_t persistHandle; // persist handle or not
|
int8_t persistHandle; // persist handle or not
|
||||||
int8_t hasEpSet;
|
int8_t hasEpSet;
|
||||||
|
|
||||||
STraceId traceId;
|
|
||||||
|
|
||||||
// app info
|
// app info
|
||||||
void *ahandle; // app handle set by client
|
void *ahandle; // app handle set by client
|
||||||
void *wrapper; // wrapper handle
|
void *wrapper; // wrapper handle
|
||||||
|
@ -58,7 +56,8 @@ typedef struct SRpcHandleInfo {
|
||||||
void *rsp;
|
void *rsp;
|
||||||
int32_t rspLen;
|
int32_t rspLen;
|
||||||
|
|
||||||
// conn info
|
STraceId traceId;
|
||||||
|
|
||||||
SRpcConnInfo conn;
|
SRpcConnInfo conn;
|
||||||
} SRpcHandleInfo;
|
} SRpcHandleInfo;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ extern "C" {
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
char *stpcpy (char *dest, const char *src);
|
char *stpcpy (char *dest, const char *src);
|
||||||
char *stpncpy (char *dest, const char *src, size_t n);
|
char *stpncpy (char *dest, const char *src, int n);
|
||||||
|
|
||||||
// specific
|
// specific
|
||||||
#ifndef __COMPAR_FN_T
|
#ifndef __COMPAR_FN_T
|
||||||
|
@ -77,7 +77,7 @@ extern "C" {
|
||||||
|
|
||||||
char * strsep(char **stringp, const char *delim);
|
char * strsep(char **stringp, const char *delim);
|
||||||
char * getpass(const char *prefix);
|
char * getpass(const char *prefix);
|
||||||
char * strndup(const char *s, size_t n);
|
char * strndup(const char *s, int n);
|
||||||
|
|
||||||
// for send function in tsocket.c
|
// for send function in tsocket.c
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
|
|
|
@ -32,6 +32,7 @@ extern "C" {
|
||||||
typedef struct TdCmd *TdCmdPtr;
|
typedef struct TdCmd *TdCmdPtr;
|
||||||
|
|
||||||
TdCmdPtr taosOpenCmd(const char* cmd);
|
TdCmdPtr taosOpenCmd(const char* cmd);
|
||||||
|
int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf);
|
||||||
int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf);
|
int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf);
|
||||||
int32_t taosEOFCmd(TdCmdPtr pCmd);
|
int32_t taosEOFCmd(TdCmdPtr pCmd);
|
||||||
int64_t taosCloseCmd(TdCmdPtr* ppCmd);
|
int64_t taosCloseCmd(TdCmdPtr* ppCmd);
|
||||||
|
|
|
@ -610,6 +610,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
|
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
|
||||||
#define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153)
|
#define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153)
|
||||||
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
|
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
|
||||||
|
#define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155)
|
||||||
|
#define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156)
|
||||||
|
|
||||||
//index
|
//index
|
||||||
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
|
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define _TD_UTIL_BLOOMFILTER_H_
|
#define _TD_UTIL_BLOOMFILTER_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tencode.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -42,6 +43,8 @@ int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf,
|
||||||
void tBloomFilterDestroy(SBloomFilter *pBF);
|
void tBloomFilterDestroy(SBloomFilter *pBF);
|
||||||
void tBloomFilterDump(const SBloomFilter *pBF);
|
void tBloomFilterDump(const SBloomFilter *pBF);
|
||||||
bool tBloomFilterIsFull(const SBloomFilter *pBF);
|
bool tBloomFilterIsFull(const SBloomFilter *pBF);
|
||||||
|
int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder* pEncoder);
|
||||||
|
SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,11 +359,11 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
||||||
|
|
||||||
#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1
|
#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1
|
||||||
#define TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD 0
|
#define TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD (24 * 60 * 60 * 2)
|
||||||
#define TSDB_DB_MIN_WAL_RETENTION_SIZE -1
|
#define TSDB_DB_MIN_WAL_RETENTION_SIZE -1
|
||||||
#define TSDB_DEFAULT_DB_WAL_RETENTION_SIZE 0
|
#define TSDB_DEFAULT_DB_WAL_RETENTION_SIZE -1
|
||||||
#define TSDB_DB_MIN_WAL_ROLL_PERIOD 0
|
#define TSDB_DB_MIN_WAL_ROLL_PERIOD 0
|
||||||
#define TSDB_DEFAULT_DB_WAL_ROLL_PERIOD 0
|
#define TSDB_DEFAULT_DB_WAL_ROLL_PERIOD (24 * 60 * 60 * 1)
|
||||||
#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0
|
#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0
|
||||||
#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0
|
#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ typedef enum ELogicConditionType {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#define TSDB_MAX_RPC_THREADS 4 // windows pipe only support 4 connections.
|
#define TSDB_MAX_RPC_THREADS 4 // windows pipe only support 4 connections.
|
||||||
#else
|
#else
|
||||||
#define TSDB_MAX_RPC_THREADS 5
|
#define TSDB_MAX_RPC_THREADS 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
|
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
|
||||||
|
|
|
@ -25,9 +25,9 @@ extern "C" {
|
||||||
// reference counting
|
// reference counting
|
||||||
typedef void (*_ref_fn_t)(const void *pObj);
|
typedef void (*_ref_fn_t)(const void *pObj);
|
||||||
|
|
||||||
#define T_REF_DECLARE() \
|
#define T_REF_DECLARE() \
|
||||||
struct { \
|
struct { \
|
||||||
int32_t val; \
|
volatile int32_t val; \
|
||||||
} _ref;
|
} _ref;
|
||||||
|
|
||||||
#define T_REF_REGISTER_FUNC(s, e) \
|
#define T_REF_REGISTER_FUNC(s, e) \
|
||||||
|
|
|
@ -33,7 +33,8 @@ int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len);
|
||||||
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf,
|
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf,
|
||||||
uint32_t len);
|
uint32_t len);
|
||||||
void tScalableBfDestroy(SScalableBf *pSBf);
|
void tScalableBfDestroy(SScalableBf *pSBf);
|
||||||
void tScalableBfDump(const SScalableBf *pSBf);
|
int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder* pEncoder);
|
||||||
|
SScalableBf* tScalableBfDecode(SDecoder* pDecoder);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ cp ${compile_dir}/../packaging/tools/set_core.sh ${pkg_dir}${install_home_pat
|
||||||
cp ${compile_dir}/../packaging/tools/taosd-dump-cfg.gdb ${pkg_dir}${install_home_path}/bin
|
cp ${compile_dir}/../packaging/tools/taosd-dump-cfg.gdb ${pkg_dir}${install_home_path}/bin
|
||||||
|
|
||||||
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
|
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
|
||||||
#cp ${compile_dir}/build/bin/taosBenchmark ${pkg_dir}${install_home_path}/bin
|
cp ${compile_dir}/build/bin/taosBenchmark ${pkg_dir}${install_home_path}/bin
|
||||||
|
|
||||||
if [ -f "${compile_dir}/build/bin/taosadapter" ]; then
|
if [ -f "${compile_dir}/build/bin/taosadapter" ]; then
|
||||||
cp ${compile_dir}/build/bin/taosadapter ${pkg_dir}${install_home_path}/bin ||:
|
cp ${compile_dir}/build/bin/taosadapter ${pkg_dir}${install_home_path}/bin ||:
|
||||||
|
|
|
@ -2,61 +2,78 @@
|
||||||
|
|
||||||
set internal_dir=%~dp0\..\..\
|
set internal_dir=%~dp0\..\..\
|
||||||
set community_dir=%~dp0\..
|
set community_dir=%~dp0\..
|
||||||
cd %community_dir%
|
set package_dir=%cd%
|
||||||
git checkout -- .
|
|
||||||
cd %community_dir%\packaging
|
|
||||||
|
|
||||||
:: %1 name %2 version
|
:: %1 name %2 version
|
||||||
if !%1==! GOTO USAGE
|
if !%1==! GOTO USAGE
|
||||||
if !%2==! GOTO USAGE
|
if !%2==! GOTO USAGE
|
||||||
if %1 == taos GOTO TAOS
|
|
||||||
if %1 == power GOTO POWER
|
|
||||||
if %1 == tq GOTO TQ
|
|
||||||
if %1 == pro GOTO PRO
|
|
||||||
if %1 == kh GOTO KH
|
|
||||||
if %1 == jh GOTO JH
|
|
||||||
GOTO USAGE
|
|
||||||
|
|
||||||
:TAOS
|
if "%1" == "cluster" (
|
||||||
goto RELEASE
|
set work_dir=%internal_dir%
|
||||||
|
set packagServerName_x64=TDengine-enterprise-server-%2-beta-Windows-x64
|
||||||
:POWER
|
@REM set packagServerName_x86=TDengine-enterprise-server-%2-beta-Windows-x86
|
||||||
call sed_power.bat %community_dir%
|
set packagClientName_x64=TDengine-enterprise-client-%2-beta-Windows-x64
|
||||||
goto RELEASE
|
set packagClientName_x86=TDengine-enterprise-client-%2-beta-Windows-x86
|
||||||
|
|
||||||
:TQ
|
|
||||||
call sed_tq.bat %community_dir%
|
|
||||||
goto RELEASE
|
|
||||||
|
|
||||||
:PRO
|
|
||||||
call sed_pro.bat %community_dir%
|
|
||||||
goto RELEASE
|
|
||||||
|
|
||||||
:KH
|
|
||||||
call sed_kh.bat %community_dir%
|
|
||||||
goto RELEASE
|
|
||||||
|
|
||||||
:JH
|
|
||||||
call sed_jh.bat %community_dir%
|
|
||||||
goto RELEASE
|
|
||||||
|
|
||||||
:RELEASE
|
|
||||||
echo release windows-client-64 for %1, version: %2
|
|
||||||
if not exist %internal_dir%\debug\ver-%2-64bit-%1 (
|
|
||||||
md %internal_dir%\debug\ver-%2-64bit-%1
|
|
||||||
) else (
|
) else (
|
||||||
rd /S /Q %internal_dir%\debug\ver-%2-64bit-%1
|
set work_dir=%community_dir%
|
||||||
md %internal_dir%\debug\ver-%2-64bit-%1
|
set packagServerName_x64=TDengine-server-%2-Windows-x64
|
||||||
|
@REM set packagServerName_x86=TDengine-server-%2-Windows-x86
|
||||||
|
set packagClientName_x64=TDengine-client-%2-Windows-x64
|
||||||
|
set packagClientName_x86=TDengine-client-%2-Windows-x86
|
||||||
)
|
)
|
||||||
cd %internal_dir%\debug\ver-%2-64bit-%1
|
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
echo release windows-client for %1, version: %2
|
||||||
cmake ../../ -G "NMake Makefiles" -DVERNUMBER=%2 -DCPUTYPE=x64
|
if not exist %work_dir%\debug (
|
||||||
set CL=/MP4
|
md %work_dir%\debug
|
||||||
nmake install
|
)
|
||||||
|
if not exist %work_dir%\debug\ver-%2-x64 (
|
||||||
|
md %work_dir%\debug\ver-%2-x64
|
||||||
|
) else (
|
||||||
|
rd /S /Q %work_dir%\debug\ver-%2-x64
|
||||||
|
md %work_dir%\debug\ver-%2-x64
|
||||||
|
)
|
||||||
|
if not exist %work_dir%\debug\ver-%2-x86 (
|
||||||
|
md %work_dir%\debug\ver-%2-x86
|
||||||
|
) else (
|
||||||
|
rd /S /Q %work_dir%\debug\ver-%2-x86
|
||||||
|
md %work_dir%\debug\ver-%2-x86
|
||||||
|
)
|
||||||
|
cd %work_dir%\debug\ver-%2-x64
|
||||||
|
call vcvarsall.bat x64
|
||||||
|
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DBUILD_HTTP=false -DVERNUMBER=%2 -DCPUTYPE=x64
|
||||||
|
cmake --build .
|
||||||
|
rd /s /Q C:\TDengine
|
||||||
|
cmake --install .
|
||||||
|
if not %errorlevel% == 0 ( call :RUNFAILED build x64 failed & exit /b 1)
|
||||||
|
cd %package_dir%
|
||||||
|
iscc /DMyAppInstallName="%packagServerName_x64%" /DMyAppVersion="%2" /DMyAppExcludeSource="" tools\tdengine.iss /O..\release
|
||||||
|
if not %errorlevel% == 0 ( call :RUNFAILED package %packagServerName_x64% failed & exit /b 1)
|
||||||
|
iscc /DMyAppInstallName="%packagClientName_x64%" /DMyAppVersion="%2" /DMyAppExcludeSource="taosd.exe" tools\tdengine.iss /O..\release
|
||||||
|
if not %errorlevel% == 0 ( call :RUNFAILED package %packagClientName_x64% failed & exit /b 1)
|
||||||
|
|
||||||
|
cd %work_dir%\debug\ver-%2-x86
|
||||||
|
call vcvarsall.bat x86
|
||||||
|
cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DBUILD_HTTP=false -DVERNUMBER=%2 -DCPUTYPE=x86
|
||||||
|
cmake --build .
|
||||||
|
rd /s /Q C:\TDengine
|
||||||
|
cmake --install .
|
||||||
|
if not %errorlevel% == 0 ( call :RUNFAILED build x86 failed & exit /b 1)
|
||||||
|
cd %package_dir%
|
||||||
|
@REM iscc /DMyAppInstallName="%packagServerName_x86%" /DMyAppVersion="%2" /DMyAppExcludeSource="" tools\tdengine.iss /O..\release
|
||||||
|
@REM if not %errorlevel% == 0 ( call :RUNFAILED package %packagServerName_x86% failed & exit /b 1)
|
||||||
|
iscc /DMyAppInstallName="%packagClientName_x86%" /DMyAppVersion="%2" /DMyAppExcludeSource="taosd.exe" tools\tdengine.iss /O..\release
|
||||||
|
if not %errorlevel% == 0 ( call :RUNFAILED package %packagClientName_x86% failed & exit /b 1)
|
||||||
|
|
||||||
goto EXIT0
|
goto EXIT0
|
||||||
|
|
||||||
:USAGE
|
:USAGE
|
||||||
echo Usage: release.bat $productName $version
|
echo Usage: release.bat $verMode $version
|
||||||
goto EXIT0
|
goto EXIT0
|
||||||
|
|
||||||
:EXIT0
|
:EXIT0
|
||||||
|
exit /b
|
||||||
|
|
||||||
|
:RUNFAILED
|
||||||
|
echo %*
|
||||||
|
cd %package_dir%
|
||||||
|
goto :eof
|
|
@ -26,7 +26,7 @@ soMode=dynamic # [static | dynamic]
|
||||||
dbName=taos # [taos | ...]
|
dbName=taos # [taos | ...]
|
||||||
allocator=glibc # [glibc | jemalloc]
|
allocator=glibc # [glibc | jemalloc]
|
||||||
verNumber=""
|
verNumber=""
|
||||||
verNumberComp="2.0.0.0"
|
verNumberComp="3.0.0.0"
|
||||||
httpdBuild=false
|
httpdBuild=false
|
||||||
|
|
||||||
while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; do
|
while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; do
|
||||||
|
@ -216,7 +216,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check support cpu type
|
# check support cpu type
|
||||||
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]]; then
|
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]]; then
|
||||||
if [ "$verMode" != "cluster" ]; then
|
if [ "$verMode" != "cluster" ]; then
|
||||||
# community-version compile
|
# community-version compile
|
||||||
cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||||
|
|
|
@ -69,7 +69,7 @@ cp %{_compiledir}/../packaging/tools/set_core.sh %{buildroot}%{homepath}/bin
|
||||||
cp %{_compiledir}/../packaging/tools/taosd-dump-cfg.gdb %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/../packaging/tools/taosd-dump-cfg.gdb %{buildroot}%{homepath}/bin
|
||||||
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
|
||||||
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
|
||||||
#cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
|
||||||
|
|
||||||
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
|
if [ -f %{_compiledir}/build/bin/taosadapter ]; then
|
||||||
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
|
cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||:
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -30,7 +30,6 @@ configDir="/etc/taos"
|
||||||
installDir="/usr/local/taos"
|
installDir="/usr/local/taos"
|
||||||
adapterName="taosadapter"
|
adapterName="taosadapter"
|
||||||
benchmarkName="taosBenchmark"
|
benchmarkName="taosBenchmark"
|
||||||
tmqName="tmq_sim"
|
|
||||||
dumpName="taosdump"
|
dumpName="taosdump"
|
||||||
demoName="taosdemo"
|
demoName="taosdemo"
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ if [ "$pagMode" == "lite" ]; then
|
||||||
strip ${build_dir}/bin/${serverName}
|
strip ${build_dir}/bin/${serverName}
|
||||||
strip ${build_dir}/bin/${clientName}
|
strip ${build_dir}/bin/${clientName}
|
||||||
# lite version doesn't include taosadapter, which will lead to no restful interface
|
# lite version doesn't include taosadapter, which will lead to no restful interface
|
||||||
bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/taosBenchmark ${build_dir}/bin/tmq_sim"
|
bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/taosBenchmark "
|
||||||
taostools_bin_files=""
|
taostools_bin_files=""
|
||||||
else
|
else
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ else
|
||||||
|
|
||||||
taostools_bin_files=" ${build_dir}/bin/taosdump \
|
taostools_bin_files=" ${build_dir}/bin/taosdump \
|
||||||
${build_dir}/bin/taosBenchmark \
|
${build_dir}/bin/taosBenchmark \
|
||||||
${build_dir}/bin/tmq_sim \
|
|
||||||
${build_dir}/bin/TDinsight.sh \
|
${build_dir}/bin/TDinsight.sh \
|
||||||
$tdinsight_caches"
|
$tdinsight_caches"
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@ function install_bin() {
|
||||||
[ -x ${bin_dir}/taosd ] && ${csudo}ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || :
|
[ -x ${bin_dir}/taosd ] && ${csudo}ln -s ${bin_dir}/taosd ${bin_link_dir}/taosd || :
|
||||||
[ -x ${bin_dir}/taosadapter ] && ${csudo}ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter || :
|
[ -x ${bin_dir}/taosadapter ] && ${csudo}ln -s ${bin_dir}/taosadapter ${bin_link_dir}/taosadapter || :
|
||||||
[ -x ${bin_dir}/taosBenchmark ] && ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosdemo || :
|
[ -x ${bin_dir}/taosBenchmark ] && ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosdemo || :
|
||||||
|
[ -x ${bin_dir}/taosBenchmark ] && ${csudo}ln -sf ${bin_dir}/taosBenchmark ${bin_link_dir}/taosBenchmark || :
|
||||||
[ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
|
[ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
|
||||||
[ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
|
[ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
|
||||||
[ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || :
|
[ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || :
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
@echo off
|
||||||
|
cd C:\TDengine
|
||||||
|
if not "%1" == "" (
|
||||||
|
%1 --help
|
||||||
|
@cmd /k
|
||||||
|
)
|
|
@ -0,0 +1,81 @@
|
||||||
|
#define MyAppName "TDengine"
|
||||||
|
#define MyAppPublisher "taosdata"
|
||||||
|
#define MyAppURL "http://www.taosdata.com/"
|
||||||
|
#define MyAppBeforeInstallTxt "windows_before_install.txt"
|
||||||
|
#define MyAppIco "favicon.ico"
|
||||||
|
#define MyAppInstallDir "C:\TDengine"
|
||||||
|
#define MyAppOutputDir "./"
|
||||||
|
#define MyAppSourceDir "C:\TDengine"
|
||||||
|
;#define MyAppAllFile "\*"
|
||||||
|
#define MyAppCfgName "\cfg\*"
|
||||||
|
#define MyAppDriverName "\driver\*"
|
||||||
|
#define MyAppConnectorName "\connector\*"
|
||||||
|
#define MyAppExamplesName "\examples\*"
|
||||||
|
#define MyAppIncludeName "\include\*"
|
||||||
|
#define MyAppExeName "\*.exe"
|
||||||
|
#define MyAppTaosExeName "\taos.bat"
|
||||||
|
#define MyAppTaosdemoExeName "\taosBenchmark.exe"
|
||||||
|
#define MyAppDLLName "\driver\taos.dll"
|
||||||
|
;#define MyAppVersion "3.0"
|
||||||
|
;#define MyAppInstallName "TDengine"
|
||||||
|
|
||||||
|
[Setup]
|
||||||
|
VersionInfoVersion={#MyAppVersion}
|
||||||
|
AppId={{A0F7A93C-79C4-485D-B2B8-F0D03DF42FAB}
|
||||||
|
AppName={#MyAppName}
|
||||||
|
AppVersion={#MyAppVersion}
|
||||||
|
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||||
|
AppPublisher={#MyAppPublisher}
|
||||||
|
AppPublisherURL={#MyAppURL}
|
||||||
|
AppSupportURL={#MyAppURL}
|
||||||
|
AppUpdatesURL={#MyAppURL}
|
||||||
|
DefaultDirName={#MyAppInstallDir}
|
||||||
|
DefaultGroupName={#MyAppName}
|
||||||
|
DisableProgramGroupPage=yes
|
||||||
|
InfoBeforeFile={#MyAppBeforeInstallTxt}
|
||||||
|
OutputDir={#MyAppOutputDir}
|
||||||
|
OutputBaseFilename={#MyAppInstallName}
|
||||||
|
SetupIconFile={#MyAppIco}
|
||||||
|
Compression=lzma
|
||||||
|
SolidCompression=yes
|
||||||
|
DisableDirPage=yes
|
||||||
|
Uninstallable=yes
|
||||||
|
|
||||||
|
[Languages]
|
||||||
|
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
|
||||||
|
;Name: "english"; MessagesFile: "compiler:Languages\English.isl"
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
;Source: {#MyAppSourceDir}{#MyAppAllFile}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
Source: taos.bat; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||||
|
;Source: taosdemo.png; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||||
|
;Source: taosShell.png; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||||
|
Source: favicon.ico; DestDir: "{app}\include"; Flags: igNoreversion;
|
||||||
|
Source: {#MyAppSourceDir}{#MyAppDLLName}; DestDir: "{win}\System32"; Flags: igNoreversion;
|
||||||
|
Source: {#MyAppSourceDir}{#MyAppCfgName}; DestDir: "{app}\cfg"; Flags: igNoreversion recursesubdirs createallsubdirs onlyifdoesntexist uninsneveruninstall
|
||||||
|
Source: {#MyAppSourceDir}{#MyAppDriverName}; DestDir: "{app}\driver"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
;Source: {#MyAppSourceDir}{#MyAppConnectorName}; DestDir: "{app}\connector"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
;Source: {#MyAppSourceDir}{#MyAppExamplesName}; DestDir: "{app}\examples"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
Source: {#MyAppSourceDir}{#MyAppIncludeName}; DestDir: "{app}\include"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
Source: {#MyAppSourceDir}{#MyAppExeName}; DestDir: "{app}"; Excludes: {#MyAppExcludeSource} ; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||||
|
|
||||||
|
[UninstallDelete]
|
||||||
|
Name: {app}\driver; Type: filesandordirs
|
||||||
|
Name: {app}\connector; Type: filesandordirs
|
||||||
|
Name: {app}\examples; Type: filesandordirs
|
||||||
|
Name: {app}\include; Type: filesandordirs
|
||||||
|
|
||||||
|
[Tasks]
|
||||||
|
Name: "desktopicon";Description: "{cm:CreateDesktopIcon}"; GroupDescription:"{cm:AdditionalIcons}"; Flags: checkablealone
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
Name:"{group}\Taos Shell"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taos.exe" ; IconFilename: "{app}\include\{#MyAppIco}"
|
||||||
|
Name:"{group}\Open TDengine Directory"; Filename: "{app}\"
|
||||||
|
Name:"{group}\Taosdemo"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taosdemo.exe" ; IconFilename: "{app}\include\{#MyAppIco}"
|
||||||
|
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" ; IconFilename: "{app}\include\{#MyAppIco}"
|
||||||
|
Name:"{commondesktop}\Taos Shell"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taos.exe" ; Tasks: desktopicon; WorkingDir: "{app}" ; IconFilename: "{app}\include\{#MyAppIco}"
|
||||||
|
|
||||||
|
|
||||||
|
[Messages]
|
||||||
|
ConfirmUninstall=Do you really want to uninstall TDengine from your computer?%n%nPress [Y] to completely delete %1 and all its components;%nPress [N] to keep the software on your computer.
|
|
@ -0,0 +1,3 @@
|
||||||
|
TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data.
|
||||||
|
|
||||||
|
TDengine will be installed under C:\TDengine, users can modify configuration file C:\TDengine\cfg\taos.cfg, set the log file path or other parameters.
|
|
@ -757,7 +757,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J
|
||||||
int32_t code = taos_stmt_prepare(pStmt, str, len);
|
int32_t code = taos_stmt_prepare(pStmt, str, len);
|
||||||
taosMemoryFreeClear(str);
|
taosMemoryFreeClear(str);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("prepareStmt jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setBindTableNameI
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||||
|
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
|
jniError("bindTableName jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +860,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
||||||
(*env)->ReleaseStringUTFChars(env, tableName, name);
|
(*env)->ReleaseStringUTFChars(env, tableName, name);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
|
jniError("tableNameTags jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
return JNI_SUCCESS;
|
return JNI_SUCCESS;
|
||||||
|
@ -926,7 +926,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(
|
||||||
taosMemoryFreeClear(b);
|
taosMemoryFreeClear(b);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("bindColData jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,7 +949,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_addBatchImp(JNIEn
|
||||||
|
|
||||||
int32_t code = taos_stmt_add_batch(pStmt);
|
int32_t code = taos_stmt_add_batch(pStmt);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("add batch jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeBatchImp(J
|
||||||
|
|
||||||
int32_t code = taos_stmt_execute(pStmt);
|
int32_t code = taos_stmt_execute(pStmt);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("excute batch jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,7 +997,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeStmt(JNIEnv
|
||||||
|
|
||||||
int32_t code = taos_stmt_close(pStmt);
|
int32_t code = taos_stmt_close(pStmt);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
jniError("close stmt jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
|
||||||
return JNI_TDENGINE_ERROR;
|
return JNI_TDENGINE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||||
rpcInit.numOfThreads = numOfThread;
|
rpcInit.numOfThreads = numOfThread;
|
||||||
rpcInit.cfp = processMsgFromServer;
|
rpcInit.cfp = processMsgFromServer;
|
||||||
rpcInit.rfp = clientRpcRfp;
|
rpcInit.rfp = clientRpcRfp;
|
||||||
rpcInit.tfp = clientRpcTfp;
|
// rpcInit.tfp = clientRpcTfp;
|
||||||
rpcInit.sessions = 1024;
|
rpcInit.sessions = 1024;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.user = (char *)user;
|
rpcInit.user = (char *)user;
|
||||||
|
|
|
@ -286,6 +286,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
if (pInst == NULL || NULL == *pInst) {
|
if (pInst == NULL || NULL == *pInst) {
|
||||||
taosThreadMutexUnlock(&appInfo.mutex);
|
taosThreadMutexUnlock(&appInfo.mutex);
|
||||||
tscError("cluster not exist, key:%s", key);
|
tscError("cluster not exist, key:%s", key);
|
||||||
|
taosMemoryFree(pMsg->pData);
|
||||||
tFreeClientHbBatchRsp(&pRsp);
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +327,13 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
||||||
while (pIter != NULL) {
|
while (pIter != NULL) {
|
||||||
int64_t *rid = pIter;
|
int64_t *rid = pIter;
|
||||||
SRequestObj *pRequest = acquireRequest(*rid);
|
SRequestObj *pRequest = acquireRequest(*rid);
|
||||||
if (NULL == pRequest || pRequest->killed) {
|
if (NULL == pRequest) {
|
||||||
|
pIter = taosHashIterate(pObj->pRequests, pIter);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pRequest->killed) {
|
||||||
|
releaseRequest(*rid);
|
||||||
pIter = taosHashIterate(pObj->pRequests, pIter);
|
pIter = taosHashIterate(pObj->pRequests, pIter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
|
|
||||||
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, false);
|
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||||
|
|
|
@ -182,6 +182,7 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
|
|
||||||
if (TD_RES_QUERY(res)) {
|
if (TD_RES_QUERY(res)) {
|
||||||
SRequestObj *pRequest = (SRequestObj *)res;
|
SRequestObj *pRequest = (SRequestObj *)res;
|
||||||
|
tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId);
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
} else if (TD_RES_TMQ(res)) {
|
} else if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||||
|
@ -482,7 +483,7 @@ void taos_stop_query(TAOS_RES *res) {
|
||||||
int32_t numOfFields = taos_num_fields(pRequest);
|
int32_t numOfFields = taos_num_fields(pRequest);
|
||||||
// It is not a query, no need to stop.
|
// It is not a query, no need to stop.
|
||||||
if (numOfFields == 0) {
|
if (numOfFields == 0) {
|
||||||
tscDebug("request %" PRIx64 " no need to be killed since not query", pRequest->requestId);
|
tscDebug("request 0x%" PRIx64 " no need to be killed since not query", pRequest->requestId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,12 +658,17 @@ typedef struct SqlParseWrapper {
|
||||||
SQuery *pQuery;
|
SQuery *pQuery;
|
||||||
} SqlParseWrapper;
|
} SqlParseWrapper;
|
||||||
|
|
||||||
|
static void destoryTablesReq(void *p) {
|
||||||
|
STablesReq *pRes = (STablesReq *)p;
|
||||||
|
taosArrayDestroy(pRes->pTables);
|
||||||
|
}
|
||||||
|
|
||||||
static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) {
|
static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) {
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pDbVgroup);
|
taosArrayDestroy(pWrapper->catalogReq.pDbVgroup);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pDbCfg);
|
taosArrayDestroy(pWrapper->catalogReq.pDbCfg);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pDbInfo);
|
taosArrayDestroy(pWrapper->catalogReq.pDbInfo);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pTableMeta);
|
taosArrayDestroyEx(pWrapper->catalogReq.pTableMeta, destoryTablesReq);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pTableHash);
|
taosArrayDestroyEx(pWrapper->catalogReq.pTableHash, destoryTablesReq);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pUdf);
|
taosArrayDestroy(pWrapper->catalogReq.pUdf);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pIndex);
|
taosArrayDestroy(pWrapper->catalogReq.pIndex);
|
||||||
taosArrayDestroy(pWrapper->catalogReq.pUser);
|
taosArrayDestroy(pWrapper->catalogReq.pUser);
|
||||||
|
@ -847,7 +853,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->code =
|
pRequest->code =
|
||||||
setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp *)pResultInfo->pData, pResultInfo->convertUcs4, false);
|
setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp *)pResultInfo->pData, pResultInfo->convertUcs4, true);
|
||||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
|
|
@ -389,7 +389,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
code = buildShowVariablesRsp(rsp.variables, &pRes);
|
code = buildShowVariablesRsp(rsp.variables, &pRes);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, false);
|
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
tFreeSShowVariablesRsp(&rsp);
|
tFreeSShowVariablesRsp(&rsp);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
static const SSysDbTableSchema dnodesSchema[] = {
|
static const SSysDbTableSchema dnodesSchema[] = {
|
||||||
{.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
{.name = "support_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "support_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||||
|
@ -66,7 +66,7 @@ static const SSysDbTableSchema bnodesSchema[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema clusterSchema[] = {
|
static const SSysDbTableSchema clusterSchema[] = {
|
||||||
{.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,7 @@ static const SSysDbTableSchema clusterSchema[] = {
|
||||||
static const SSysDbTableSchema userDBSchema[] = {
|
static const SSysDbTableSchema userDBSchema[] = {
|
||||||
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
{.name = "vgroups", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "replica", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
{.name = "replica", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
{.name = "strict", .bytes = TSDB_DB_STRICT_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "strict", .bytes = TSDB_DB_STRICT_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
@ -97,7 +97,7 @@ static const SSysDbTableSchema userDBSchema[] = {
|
||||||
{.name = "wal_retention_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "wal_retention_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "wal_retention_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "wal_retention_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "wal_seg_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "wal_segment_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema userFuncSchema[] = {
|
static const SSysDbTableSchema userFuncSchema[] = {
|
||||||
|
@ -284,7 +284,7 @@ static const SSysDbTableSchema consumerSchema[] = {
|
||||||
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
/*{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},*/
|
||||||
{.name = "up_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "up_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "subscribe_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "subscribe_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
|
@ -353,11 +353,19 @@ static const SSysTableMeta perfsMeta[] = {
|
||||||
{TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema)}};
|
{TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema)}};
|
||||||
|
|
||||||
void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size) {
|
void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size) {
|
||||||
*pInfosTableMeta = infosMeta;
|
if (pInfosTableMeta) {
|
||||||
*size = tListLen(infosMeta);
|
*pInfosTableMeta = infosMeta;
|
||||||
|
}
|
||||||
|
if (size) {
|
||||||
|
*size = tListLen(infosMeta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size) {
|
void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size) {
|
||||||
*pPerfsTableMeta = perfsMeta;
|
if (pPerfsTableMeta) {
|
||||||
*size = tListLen(perfsMeta);
|
*pPerfsTableMeta = perfsMeta;
|
||||||
|
}
|
||||||
|
if (size) {
|
||||||
|
*size = tListLen(perfsMeta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1874,21 +1874,20 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
||||||
* @brief TODO: Assume that the final generated result it less than 3M
|
* @brief TODO: Assume that the final generated result it less than 3M
|
||||||
*
|
*
|
||||||
* @param pReq
|
* @param pReq
|
||||||
* @param pDataBlocks
|
* @param pDataBlock
|
||||||
* @param vgId
|
* @param vgId
|
||||||
* @param suid // TODO: check with Liao whether suid response is reasonable
|
* @param suid
|
||||||
*
|
*
|
||||||
* TODO: colId should be set
|
|
||||||
*/
|
*/
|
||||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlock, STSchema* pTSchema, int32_t vgId,
|
||||||
tb_uid_t suid) {
|
tb_uid_t suid) {
|
||||||
int32_t sz = taosArrayGetSize(pDataBlocks);
|
|
||||||
int32_t bufSize = sizeof(SSubmitReq);
|
int32_t bufSize = sizeof(SSubmitReq);
|
||||||
|
int32_t sz = 1;
|
||||||
for (int32_t i = 0; i < sz; ++i) {
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
SDataBlockInfo* pBlkInfo = &((SSDataBlock*)taosArrayGet(pDataBlocks, i))->info;
|
const SDataBlockInfo* pBlkInfo = &pDataBlock->info;
|
||||||
|
|
||||||
int32_t numOfCols = taosArrayGetSize(pDataBlocks);
|
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(numOfCols));
|
bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(colNum));
|
||||||
bufSize += sizeof(SSubmitBlk);
|
bufSize += sizeof(SSubmitBlk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1905,7 +1904,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
tdSRowInit(&rb, pTSchema->version);
|
tdSRowInit(&rb, pTSchema->version);
|
||||||
|
|
||||||
for (int32_t i = 0; i < sz; ++i) {
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i);
|
|
||||||
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
// int32_t rowSize = pDataBlock->info.rowSize;
|
// int32_t rowSize = pDataBlock->info.rowSize;
|
||||||
|
|
|
@ -355,7 +355,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
|
||||||
static int32_t taosAddServerCfg(SConfig *pCfg) {
|
static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddDir(pCfg, "dataDir", tsDataDir, 0) != 0) return -1;
|
if (cfgAddDir(pCfg, "dataDir", tsDataDir, 0) != 0) return -1;
|
||||||
if (cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0) != 0) return -1;
|
if (cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0) != 0) return -1;
|
||||||
|
|
||||||
|
tsNumOfSupportVnodes = tsNumOfCores * 2;
|
||||||
|
tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2);
|
||||||
if (cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, 0) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddInt32(pCfg, "maxShellConns", tsMaxShellConns, 10, 50000000, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxShellConns", tsMaxShellConns, 10, 50000000, 0) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, 0) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 10, 1000000, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 10, 1000000, 0) != 0) return -1;
|
||||||
|
@ -401,7 +405,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1);
|
tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1);
|
||||||
if (cfgAddInt32(pCfg, "numOfVnodeWriteThreads", tsNumOfVnodeWriteThreads, 1, 1024, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfVnodeWriteThreads", tsNumOfVnodeWriteThreads, 1, 1024, 0) != 0) return -1;
|
||||||
|
|
||||||
tsNumOfVnodeSyncThreads = tsNumOfCores;
|
// tsNumOfVnodeSyncThreads = tsNumOfCores;
|
||||||
|
tsNumOfVnodeSyncThreads = 32;
|
||||||
tsNumOfVnodeSyncThreads = TMAX(tsNumOfVnodeSyncThreads, 1);
|
tsNumOfVnodeSyncThreads = TMAX(tsNumOfVnodeSyncThreads, 1);
|
||||||
if (cfgAddInt32(pCfg, "numOfVnodeSyncThreads", tsNumOfVnodeSyncThreads, 1, 1024, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfVnodeSyncThreads", tsNumOfVnodeSyncThreads, 1, 1024, 0) != 0) return -1;
|
||||||
|
|
||||||
|
@ -422,7 +427,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 2, 1024, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 2, 1024, 0) != 0) return -1;
|
||||||
|
|
||||||
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, TSDB_MAX_MSG_SIZE * 10000L);
|
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -347,6 +347,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_RSMA, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -28,6 +28,7 @@ SDbObj *mndAcquireDb(SMnode *pMnode, const char *db);
|
||||||
void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
void mndReleaseDb(SMnode *pMnode, SDbObj *pDb);
|
||||||
int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen);
|
||||||
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||||
|
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb);
|
||||||
|
|
||||||
const char *mndGetDbStr(const char *src);
|
const char *mndGetDbStr(const char *src);
|
||||||
|
|
||||||
|
|
|
@ -162,8 +162,9 @@ typedef struct {
|
||||||
int64_t lastExecTime;
|
int64_t lastExecTime;
|
||||||
int32_t lastAction;
|
int32_t lastAction;
|
||||||
int32_t lastErrorNo;
|
int32_t lastErrorNo;
|
||||||
tmsg_t lastMsgType;
|
|
||||||
SEpSet lastEpset;
|
SEpSet lastEpset;
|
||||||
|
tmsg_t lastMsgType;
|
||||||
|
tmsg_t originRpcType;
|
||||||
char dbname1[TSDB_TABLE_FNAME_LEN];
|
char dbname1[TSDB_TABLE_FNAME_LEN];
|
||||||
char dbname2[TSDB_TABLE_FNAME_LEN];
|
char dbname2[TSDB_TABLE_FNAME_LEN];
|
||||||
int32_t startFunc;
|
int32_t startFunc;
|
||||||
|
|
|
@ -942,8 +942,8 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
||||||
}
|
}
|
||||||
|
|
||||||
// end point
|
// end point
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
/*pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);*/
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pConsumer->ep, true);
|
/*colDataAppend(pColInfo, numOfRows, (const char *)&pConsumer->ep, true);*/
|
||||||
|
|
||||||
// up time
|
// up time
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
|
@ -1495,8 +1495,34 @@ static const char *getCacheModelStr(int8_t cacheModel) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables,
|
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) {
|
||||||
bool sysDb, ESdbStatus objStatus, bool sysinfo) {
|
if (pDb->cfg.replications == 1) return true;
|
||||||
|
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
void *pIter = NULL;
|
||||||
|
bool isReady = true;
|
||||||
|
while (1) {
|
||||||
|
SVgObj *pVgroup = NULL;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (pVgroup->dbUid == pDb->uid && pVgroup->replica > 1) {
|
||||||
|
bool hasLeader = false;
|
||||||
|
for (int32_t i = 0; i < pVgroup->replica; ++i) {
|
||||||
|
if (pVgroup->vnodeGid[i].role == TAOS_SYNC_STATE_LEADER) {
|
||||||
|
hasLeader = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasLeader) isReady = false;
|
||||||
|
}
|
||||||
|
sdbRelease(pSdb, pVgroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows,
|
||||||
|
int64_t numOfTables, bool sysDb, ESdbStatus objStatus, bool sysinfo) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
||||||
char *buf = taosMemoryMalloc(bytes);
|
char *buf = taosMemoryMalloc(bytes);
|
||||||
|
@ -1509,8 +1535,16 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
||||||
}
|
}
|
||||||
|
|
||||||
char *statusStr = "ready";
|
char *statusStr = "ready";
|
||||||
if (objStatus == SDB_STATUS_CREATING) statusStr = "creating";
|
if (objStatus == SDB_STATUS_CREATING) {
|
||||||
if (objStatus == SDB_STATUS_DROPPING) statusStr = "dropping";
|
statusStr = "creating";
|
||||||
|
} else if (objStatus == SDB_STATUS_DROPPING) {
|
||||||
|
statusStr = "dropping";
|
||||||
|
} else {
|
||||||
|
if (!sysDb && !mndIsDbReady(pMnode, pDb)) {
|
||||||
|
statusStr = "unsynced";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char statusVstr[24] = {0};
|
char statusVstr[24] = {0};
|
||||||
STR_WITH_SIZE_TO_VARSTR(statusVstr, statusStr, strlen(statusStr));
|
STR_WITH_SIZE_TO_VARSTR(statusVstr, statusStr, strlen(statusStr));
|
||||||
|
|
||||||
|
@ -1672,7 +1706,10 @@ static void setPerfSchemaDbCfg(SDbObj *pDbObj) {
|
||||||
static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
||||||
SVgObj *pVgroup = pObj;
|
SVgObj *pVgroup = pObj;
|
||||||
int32_t *numOfTables = p1;
|
int32_t *numOfTables = p1;
|
||||||
*numOfTables += pVgroup->numOfTables;
|
int64_t uid = *(int64_t*)p2;
|
||||||
|
if (pVgroup->dbUid == uid) {
|
||||||
|
*numOfTables += pVgroup->numOfTables;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1691,13 +1728,17 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
if (!pShow->sysDbRsp) {
|
if (!pShow->sysDbRsp) {
|
||||||
SDbObj infoschemaDb = {0};
|
SDbObj infoschemaDb = {0};
|
||||||
setInformationSchemaDbCfg(&infoschemaDb);
|
setInformationSchemaDbCfg(&infoschemaDb);
|
||||||
dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true, 0, 1);
|
size_t numOfTables = 0;
|
||||||
|
getInfosDbMeta(NULL, &numOfTables);
|
||||||
|
mndDumpDbInfoData(pMnode, pBlock, &infoschemaDb, pShow, numOfRows, numOfTables, true, 0, 1);
|
||||||
|
|
||||||
numOfRows += 1;
|
numOfRows += 1;
|
||||||
|
|
||||||
SDbObj perfschemaDb = {0};
|
SDbObj perfschemaDb = {0};
|
||||||
setPerfSchemaDbCfg(&perfschemaDb);
|
setPerfSchemaDbCfg(&perfschemaDb);
|
||||||
dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true, 0, 1);
|
numOfTables = 0;
|
||||||
|
getPerfDbMeta(NULL, &numOfTables);
|
||||||
|
mndDumpDbInfoData(pMnode, pBlock, &perfschemaDb, pShow, numOfRows, numOfTables, true, 0, 1);
|
||||||
|
|
||||||
numOfRows += 1;
|
numOfRows += 1;
|
||||||
pShow->sysDbRsp = true;
|
pShow->sysDbRsp = true;
|
||||||
|
@ -1709,8 +1750,8 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
|
|
||||||
if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_READ_OR_WRITE_DB, pDb) == 0) {
|
if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_READ_OR_WRITE_DB, pDb) == 0) {
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL);
|
sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, &pDb->uid, NULL);
|
||||||
dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false, objStatus, sysinfo);
|
mndDumpDbInfoData(pMnode, pBlock, pDb, pShow, numOfRows, numOfTables, false, objStatus, sysinfo);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
smaObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
smaObj.uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||||
ASSERT(smaObj.uid != 0);
|
ASSERT(smaObj.uid != 0);
|
||||||
char resultTbName[TSDB_TABLE_FNAME_LEN + 16] = {0};
|
char resultTbName[TSDB_TABLE_FNAME_LEN + 16] = {0};
|
||||||
snprintf(resultTbName, TSDB_TABLE_FNAME_LEN + 16, "td.tsma.rst.tb.%s", pCreate->name);
|
snprintf(resultTbName, TSDB_TABLE_FNAME_LEN + 16, "%s_td_tsma_rst_tb",pCreate->name);
|
||||||
memcpy(smaObj.dstTbName, resultTbName, TSDB_TABLE_FNAME_LEN);
|
memcpy(smaObj.dstTbName, resultTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
smaObj.dstTbUid = mndGenerateUid(smaObj.dstTbName, TSDB_TABLE_FNAME_LEN);
|
smaObj.dstTbUid = mndGenerateUid(smaObj.dstTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
smaObj.stbUid = pStb->uid;
|
smaObj.stbUid = pStb->uid;
|
||||||
|
@ -603,6 +603,9 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
if (mndPersistStream(pMnode, pTrans, &streamObj) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
|
mDebug("mndSma: create sma index %s %" PRIi64 " on stb:%" PRIi64 ", dstSuid:%" PRIi64 " dstTb:%s dstVg:%d",
|
||||||
|
pCreate->name, smaObj.uid, smaObj.stbUid, smaObj.dstTbUid, smaObj.dstTbName, smaObj.dstVgId);
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
|
@ -124,8 +124,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
SDB_SET_INT8(pRaw, dataPos, pTrans->exec, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pTrans->exec, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pTrans->oper, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pTrans->oper, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pTrans->originRpcType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, 0, _OVER)
|
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER)
|
||||||
|
@ -282,13 +281,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &exec, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &exec, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &oper, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &oper, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
|
||||||
SDB_GET_INT8(pRaw, dataPos, &reserved, _OVER)
|
|
||||||
pTrans->stage = stage;
|
pTrans->stage = stage;
|
||||||
pTrans->policy = policy;
|
pTrans->policy = policy;
|
||||||
pTrans->conflict = conflict;
|
pTrans->conflict = conflict;
|
||||||
pTrans->exec = exec;
|
pTrans->exec = exec;
|
||||||
pTrans->oper = oper;
|
pTrans->oper = oper;
|
||||||
|
SDB_GET_INT16(pRaw, dataPos, &pTrans->originRpcType, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER)
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER)
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER)
|
||||||
|
@ -611,6 +609,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
||||||
|
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
taosArrayPush(pTrans->pRpcArray, &pReq->info);
|
taosArrayPush(pTrans->pRpcArray, &pReq->info);
|
||||||
|
pTrans->originRpcType = pReq->msgType;
|
||||||
}
|
}
|
||||||
mTrace("trans:%d, local object is created, data:%p", pTrans->id, pTrans);
|
mTrace("trans:%d, local object is created, data:%p", pTrans->id, pTrans);
|
||||||
return pTrans;
|
return pTrans;
|
||||||
|
@ -910,6 +909,23 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pTrans->originRpcType == TDMT_MND_CREATE_DB) {
|
||||||
|
mDebug("trans:%d, origin msgtype:%s", pTrans->id, TMSG_INFO(pTrans->originRpcType));
|
||||||
|
SDbObj *pDb = mndAcquireDb(pMnode, pTrans->dbname1);
|
||||||
|
if (pDb != NULL) {
|
||||||
|
for (int32_t j = 0; j < 12; j++) {
|
||||||
|
bool ready = mndIsDbReady(pMnode, pDb);
|
||||||
|
if (!ready) {
|
||||||
|
mDebug("trans:%d, db:%s not ready yet, wait %d times", pTrans->id, pTrans->dbname1, j);
|
||||||
|
taosMsleep(1000);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
}
|
||||||
|
|
||||||
tmsgSendRsp(&rspMsg);
|
tmsgSendRsp(&rspMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,24 +115,29 @@ struct SSmaStat {
|
||||||
#define RSMA_FS_LOCK(r) (&(r)->lock)
|
#define RSMA_FS_LOCK(r) (&(r)->lock)
|
||||||
|
|
||||||
struct SRSmaInfoItem {
|
struct SRSmaInfoItem {
|
||||||
void *taskInfo; // qTaskInfo_t
|
|
||||||
int64_t refId;
|
|
||||||
tmr_h tmrId;
|
|
||||||
int32_t maxDelay;
|
|
||||||
int8_t level;
|
int8_t level;
|
||||||
int8_t triggerStat;
|
int8_t triggerStat;
|
||||||
|
int32_t maxDelay;
|
||||||
|
tmr_h tmrId;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SRSmaInfo {
|
struct SRSmaInfo {
|
||||||
STSchema *pTSchema;
|
STSchema *pTSchema;
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
|
int64_t refId; // refId of SRSmaStat
|
||||||
int8_t delFlag;
|
int8_t delFlag;
|
||||||
T_REF_DECLARE()
|
T_REF_DECLARE()
|
||||||
SRSmaInfoItem items[TSDB_RETENTION_L2];
|
SRSmaInfoItem items[TSDB_RETENTION_L2];
|
||||||
|
void *taskInfo[TSDB_RETENTION_L2]; // qTaskInfo_t
|
||||||
|
void *iTaskInfo[TSDB_RETENTION_L2]; // immutable
|
||||||
};
|
};
|
||||||
#define RSMA_INFO_HEAD_LEN 24
|
|
||||||
#define RSMA_INFO_IS_DEL(r) ((r)->delFlag == 1)
|
#define RSMA_INFO_HEAD_LEN 32
|
||||||
#define RSMA_INFO_SET_DEL(r) ((r)->delFlag = 1)
|
#define RSMA_INFO_IS_DEL(r) ((r)->delFlag == 1)
|
||||||
|
#define RSMA_INFO_SET_DEL(r) ((r)->delFlag = 1)
|
||||||
|
#define RSMA_INFO_QTASK(r, i) ((r)->taskInfo[i])
|
||||||
|
#define RSMA_INFO_IQTASK(r, i) ((r)->iTaskInfo[i])
|
||||||
|
#define RSMA_INFO_ITEM(r, i) (&(r)->items[i])
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TASK_TRIGGER_STAT_INIT = 0,
|
TASK_TRIGGER_STAT_INIT = 0,
|
||||||
|
@ -168,8 +173,8 @@ int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat);
|
||||||
int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo);
|
int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo);
|
||||||
int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo);
|
int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo);
|
||||||
|
|
||||||
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln);
|
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId);
|
||||||
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln);
|
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId);
|
||||||
|
|
||||||
int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType);
|
int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType);
|
||||||
|
|
||||||
|
@ -223,12 +228,11 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
|
||||||
|
|
||||||
void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName);
|
void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName);
|
||||||
void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName);
|
void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName);
|
||||||
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pDest, SRSmaInfo *pSrc);
|
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo **pDest, SRSmaInfo *pSrc);
|
||||||
void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
|
void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
|
||||||
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||||
void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
|
void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||||
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree);
|
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree);
|
||||||
void tdRemoveRSmaInfoBySuid(SSma *pSma, int64_t suid);
|
|
||||||
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
|
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
|
||||||
|
|
||||||
int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
|
int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
|
||||||
|
|
|
@ -97,7 +97,7 @@ typedef struct STbUidStore STbUidStore;
|
||||||
|
|
||||||
int metaOpen(SVnode* pVnode, SMeta** ppMeta);
|
int metaOpen(SVnode* pVnode, SMeta** ppMeta);
|
||||||
int metaClose(SMeta* pMeta);
|
int metaClose(SMeta* pMeta);
|
||||||
int metaBegin(SMeta* pMeta);
|
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
||||||
int metaCommit(SMeta* pMeta);
|
int metaCommit(SMeta* pMeta);
|
||||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
|
@ -187,6 +187,7 @@ int32_t smaAsyncPreCommit(SSma* pSma);
|
||||||
int32_t smaAsyncCommit(SSma* pSma);
|
int32_t smaAsyncCommit(SSma* pSma);
|
||||||
int32_t smaAsyncPostCommit(SSma* pSma);
|
int32_t smaAsyncPostCommit(SSma* pSma);
|
||||||
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
||||||
|
int32_t smaProcessFetch(SSma* pSma, void* pMsg);
|
||||||
|
|
||||||
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg);
|
||||||
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg);
|
||||||
|
|
|
@ -19,9 +19,12 @@ static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) { return vnodeBuf
|
||||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||||
|
|
||||||
// begin a meta txn
|
// begin a meta txn
|
||||||
int metaBegin(SMeta *pMeta) {
|
int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
||||||
tdbTxnOpen(&pMeta->txn, 0, metaMalloc, metaFree, pMeta->pVnode->inUse, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
if (fromSys) {
|
||||||
|
tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||||
|
} else {
|
||||||
|
tdbTxnOpen(&pMeta->txn, 0, metaMalloc, metaFree, pMeta->pVnode->inUse, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||||
|
}
|
||||||
if (tdbBegin(pMeta->pEnv, &pMeta->txn) < 0) {
|
if (tdbBegin(pMeta->pEnv, &pMeta->txn) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,7 +481,7 @@ int64_t metaGetTbNum(SMeta *pMeta) {
|
||||||
/* int64_t num = 0; */
|
/* int64_t num = 0; */
|
||||||
/* vnodeGetAllCtbNum(pMeta->pVnode, &num); */
|
/* vnodeGetAllCtbNum(pMeta->pVnode, &num); */
|
||||||
|
|
||||||
return pMeta->pVnode->config.vndStats.numOfCTables;
|
return pMeta->pVnode->config.vndStats.numOfCTables + pMeta->pVnode->config.vndStats.numOfNTables;
|
||||||
}
|
}
|
||||||
|
|
||||||
// N.B. Called by statusReq per second
|
// N.B. Called by statusReq per second
|
||||||
|
|
|
@ -145,7 +145,7 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
metaBegin(pMeta);
|
metaBegin(pMeta, 1);
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -381,6 +381,8 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
||||||
terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
|
terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||||
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
|
|
|
@ -308,12 +308,12 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||||
if (!pSmaEnv) {
|
if (!pEnv) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
// step 1: set rsma stat
|
// step 1: set rsma stat
|
||||||
|
@ -337,18 +337,26 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 3: swap rsmaInfoHash and iRsmaInfoHash
|
// step 3: swap rsmaInfoHash and iRsmaInfoHash
|
||||||
ASSERT(!RSMA_IMU_INFO_HASH(pRSmaStat));
|
// lock
|
||||||
|
taosWLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
|
||||||
ASSERT(RSMA_INFO_HASH(pRSmaStat));
|
ASSERT(RSMA_INFO_HASH(pRSmaStat));
|
||||||
|
ASSERT(!RSMA_IMU_INFO_HASH(pRSmaStat));
|
||||||
|
|
||||||
RSMA_IMU_INFO_HASH(pRSmaStat) = RSMA_INFO_HASH(pRSmaStat);
|
RSMA_IMU_INFO_HASH(pRSmaStat) = RSMA_INFO_HASH(pRSmaStat);
|
||||||
RSMA_INFO_HASH(pRSmaStat) =
|
RSMA_INFO_HASH(pRSmaStat) =
|
||||||
taosHashInit(RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
taosHashInit(RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||||
|
|
||||||
if (!RSMA_INFO_HASH(pRSmaStat)) {
|
if (!RSMA_INFO_HASH(pRSmaStat)) {
|
||||||
|
// unlock
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
smaError("vgId:%d, rsma async commit failed since %s", SMA_VID(pSma), terrstr());
|
smaError("vgId:%d, rsma async commit failed since %s", SMA_VID(pSma), terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unlock
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
|
||||||
// step 4: others
|
// step 4: others
|
||||||
pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
|
pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
|
||||||
|
|
||||||
|
@ -383,26 +391,52 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
|
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
|
||||||
SSmaEnv *pSmaEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||||
if (!pSmaEnv) {
|
if (!pEnv) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
// step 1: merge rsmaInfoHash and iRsmaInfoHash
|
// step 1: merge rsmaInfoHash and iRsmaInfoHash
|
||||||
taosWLockLatch(SMA_ENV_LOCK(pSmaEnv));
|
// lock
|
||||||
|
taosWLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
#if 0
|
||||||
if (taosHashGetSize(RSMA_INFO_HASH(pRSmaStat)) <= 0) {
|
if (taosHashGetSize(RSMA_INFO_HASH(pRSmaStat)) <= 0) {
|
||||||
// TODO: optimization - just switch the hash pointer if rsmaInfoHash is empty
|
// just switch the hash pointer if rsmaInfoHash is empty
|
||||||
}
|
if (taosHashGetSize(RSMA_IMU_INFO_HASH(pRSmaStat)) > 0) {
|
||||||
|
SHashObj *infoHash = RSMA_INFO_HASH(pRSmaStat);
|
||||||
|
RSMA_INFO_HASH(pRSmaStat) = RSMA_IMU_INFO_HASH(pRSmaStat);
|
||||||
|
RSMA_IMU_INFO_HASH(pRSmaStat) = infoHash;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
void *pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), NULL);
|
void *pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
tb_uid_t *pSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
tb_uid_t *pSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
||||||
|
|
||||||
if (!taosHashGet(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t))) {
|
if (!taosHashGet(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t))) {
|
||||||
|
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)pIter;
|
||||||
|
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
||||||
|
int32_t refVal = T_REF_VAL_GET(pRSmaInfo);
|
||||||
|
if (refVal == 0) {
|
||||||
|
tdFreeRSmaInfo(pSma, pRSmaInfo, true);
|
||||||
|
smaDebug(
|
||||||
|
"vgId:%d, rsma async post commit, free rsma info since already deleted and ref is 0 for "
|
||||||
|
"table:%" PRIi64,
|
||||||
|
SMA_VID(pSma), *pSuid);
|
||||||
|
} else {
|
||||||
|
smaDebug(
|
||||||
|
"vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
|
||||||
|
"table:%" PRIi64,
|
||||||
|
SMA_VID(pSma), refVal, *pSuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), pIter);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
taosHashPut(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t), pIter, sizeof(pIter));
|
taosHashPut(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t), pIter, sizeof(pIter));
|
||||||
smaDebug("vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%" PRIi64, SMA_VID(pSma),
|
smaDebug("vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%" PRIi64, SMA_VID(pSma),
|
||||||
*pSuid);
|
*pSuid);
|
||||||
|
@ -416,11 +450,14 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
|
||||||
|
|
||||||
pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), pIter);
|
pIter = taosHashIterate(RSMA_IMU_INFO_HASH(pRSmaStat), pIter);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
// }
|
||||||
|
|
||||||
taosHashCleanup(RSMA_IMU_INFO_HASH(pRSmaStat));
|
taosHashCleanup(RSMA_IMU_INFO_HASH(pRSmaStat));
|
||||||
RSMA_IMU_INFO_HASH(pRSmaStat) = NULL;
|
RSMA_IMU_INFO_HASH(pRSmaStat) = NULL;
|
||||||
|
|
||||||
taosWUnLockLatch(SMA_ENV_LOCK(pSmaEnv));
|
// unlock
|
||||||
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
|
||||||
// step 2: cleanup outdated qtaskinfo files
|
// step 2: cleanup outdated qtaskinfo files
|
||||||
tdCleanupQTaskInfoFiles(pSma, pRSmaStat);
|
tdCleanupQTaskInfoFiles(pSma, pRSmaStat);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
typedef struct SSmaStat SSmaStat;
|
typedef struct SSmaStat SSmaStat;
|
||||||
|
|
||||||
#define SMA_MGMT_REF_NUM 10240
|
#define SMA_MGMT_REF_NUM 10240
|
||||||
|
|
||||||
extern SSmaMgmt smaMgmt;
|
extern SSmaMgmt smaMgmt;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
|
||||||
|
|
||||||
int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
|
int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
|
||||||
if (!pRSmaInfo) return 0;
|
if (!pRSmaInfo) return 0;
|
||||||
|
|
||||||
int ref = T_REF_INC(pRSmaInfo);
|
int ref = T_REF_INC(pRSmaInfo);
|
||||||
smaDebug("vgId:%d, ref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
|
smaDebug("vgId:%d, ref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -183,9 +183,6 @@ int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
|
||||||
int ref = T_REF_DEC(pRSmaInfo);
|
int ref = T_REF_DEC(pRSmaInfo);
|
||||||
smaDebug("vgId:%d, unref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
|
smaDebug("vgId:%d, unref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
|
||||||
|
|
||||||
if (ref == 0) {
|
|
||||||
tdRemoveRSmaInfoBySuid(pSma, pRSmaInfo->suid);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,21 +32,21 @@ static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *ui
|
||||||
static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids);
|
static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids);
|
||||||
static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo,
|
static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo,
|
||||||
int8_t idx);
|
int8_t idx);
|
||||||
static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *rsmaItem,
|
static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfo *pInfo, tb_uid_t suid,
|
||||||
STSchema *pTSchema, tb_uid_t suid, int8_t level);
|
int8_t level);
|
||||||
static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid);
|
static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid);
|
||||||
static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid, SRSmaStat *pStat,
|
static void tdReleaseRSmaInfo(SSma *pSma, SRSmaInfo *pInfo);
|
||||||
int8_t blkType);
|
static int32_t tdRSmaFetchAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSmaInfoItem *pItem, STSchema *pTSchema,
|
||||||
|
int64_t suid, int8_t blkType);
|
||||||
static void tdRSmaFetchTrigger(void *param, void *tmrId);
|
static void tdRSmaFetchTrigger(void *param, void *tmrId);
|
||||||
|
static int32_t tdRSmaFetchSend(SSma *pSma, SRSmaInfo *pInfo, int8_t level);
|
||||||
static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile);
|
static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile);
|
||||||
static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish);
|
static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish);
|
||||||
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter);
|
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter);
|
||||||
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem);
|
static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem);
|
||||||
|
static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
|
||||||
static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
|
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer);
|
||||||
static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTaskFileVer);
|
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma);
|
||||||
static int32_t tdRSmaRestoreTSDataReload(SSma *pSma);
|
|
||||||
|
|
||||||
static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) {
|
static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) {
|
||||||
// adapt accordingly if definition of SRSmaInfo update
|
// adapt accordingly if definition of SRSmaInfo update
|
||||||
|
@ -115,17 +115,26 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) {
|
||||||
if (pInfo) {
|
if (pInfo) {
|
||||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
SRSmaInfoItem *pItem = &pInfo->items[i];
|
SRSmaInfoItem *pItem = &pInfo->items[i];
|
||||||
if (pItem->taskInfo) {
|
|
||||||
if (isDeepFree && pItem->tmrId) {
|
if (isDeepFree && pItem->tmrId) {
|
||||||
smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pInfo->suid,
|
smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pInfo->suid,
|
||||||
pItem->tmrId, i + 1);
|
pItem->tmrId, i + 1);
|
||||||
taosTmrStopA(&pItem->tmrId);
|
taosTmrStopA(&pItem->tmrId);
|
||||||
}
|
}
|
||||||
tdFreeQTaskInfo(&pItem->taskInfo, SMA_VID(pSma), i + 1);
|
|
||||||
|
if (isDeepFree && pInfo->taskInfo[i]) {
|
||||||
|
tdFreeQTaskInfo(&pInfo->taskInfo[i], SMA_VID(pSma), i + 1);
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma),
|
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma),
|
||||||
pInfo->suid, i + 1);
|
pInfo->suid, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pInfo->iTaskInfo[i]) {
|
||||||
|
tdFreeQTaskInfo(&pInfo->iTaskInfo[i], SMA_VID(pSma), i + 1);
|
||||||
|
} else {
|
||||||
|
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty iTaskInfo",
|
||||||
|
SMA_VID(pSma), pInfo->suid, i + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isDeepFree) {
|
if (isDeepFree) {
|
||||||
taosMemoryFreeClear(pInfo->pTSchema);
|
taosMemoryFreeClear(pInfo->pTSchema);
|
||||||
|
@ -155,7 +164,12 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRSmaInfo = tdGetRSmaInfoBySuid(pSma, *suid);
|
if (!taosArrayGetSize(tbUids)) {
|
||||||
|
smaDebug("vgId:%d, no need to update tbUidList for suid:%" PRIi64 " since Empty tbUids", SMA_VID(pSma), *suid);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, *suid);
|
||||||
|
|
||||||
if (!pRSmaInfo) {
|
if (!pRSmaInfo) {
|
||||||
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64, SMA_VID(pSma), *suid);
|
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64, SMA_VID(pSma), *suid);
|
||||||
|
@ -163,26 +177,21 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRSmaInfo->items[0].taskInfo) {
|
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
if ((qUpdateQualifiedTableId(pRSmaInfo->items[0].taskInfo, tbUids, true) < 0)) {
|
if (pRSmaInfo->taskInfo[i]) {
|
||||||
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr());
|
if ((qUpdateQualifiedTableId(pRSmaInfo->taskInfo[i], tbUids, true) < 0)) {
|
||||||
return TSDB_CODE_FAILED;
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
} else {
|
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " level %d since %s", SMA_VID(pSma), *suid, i,
|
||||||
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma),
|
terrstr());
|
||||||
pRSmaInfo->items[0].taskInfo, *suid, *(int64_t *)taosArrayGet(tbUids, 0));
|
return TSDB_CODE_FAILED;
|
||||||
}
|
} else {
|
||||||
}
|
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 " uid:%" PRIi64 " level %d",
|
||||||
|
SMA_VID(pSma), pRSmaInfo->taskInfo[0], *suid, *(int64_t *)taosArrayGet(tbUids, 0), i);
|
||||||
if (pRSmaInfo->items[1].taskInfo) {
|
}
|
||||||
if ((qUpdateQualifiedTableId(pRSmaInfo->items[1].taskInfo, tbUids, true) < 0)) {
|
|
||||||
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr());
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
} else {
|
|
||||||
smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma),
|
|
||||||
pRSmaInfo->items[1].taskInfo, *suid, *(int64_t *)taosArrayGet(tbUids, 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,13 +276,12 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
||||||
.initTqReader = 1,
|
.initTqReader = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]);
|
pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
|
||||||
pItem->refId = RSMA_REF_ID(pStat);
|
if (!pRSmaInfo->taskInfo[idx]) {
|
||||||
pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
|
|
||||||
if (!pItem->taskInfo) {
|
|
||||||
terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
|
terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]);
|
||||||
pItem->triggerStat = TASK_TRIGGER_STAT_INACTIVE;
|
pItem->triggerStat = TASK_TRIGGER_STAT_INACTIVE;
|
||||||
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
||||||
int64_t msInterval =
|
int64_t msInterval =
|
||||||
|
@ -342,6 +350,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
|
||||||
}
|
}
|
||||||
pRSmaInfo->pTSchema = pTSchema;
|
pRSmaInfo->pTSchema = pTSchema;
|
||||||
pRSmaInfo->suid = suid;
|
pRSmaInfo->suid = suid;
|
||||||
|
pRSmaInfo->refId = RSMA_REF_ID(pStat);
|
||||||
T_REF_INIT_VAL(pRSmaInfo, 1);
|
T_REF_INIT_VAL(pRSmaInfo, 1);
|
||||||
|
|
||||||
if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, 0) < 0) {
|
if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, 0) < 0) {
|
||||||
|
@ -411,7 +420,7 @@ int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) {
|
||||||
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
SSmaStat *pStat = SMA_ENV_STAT(pSmaEnv);
|
||||||
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pStat);
|
||||||
|
|
||||||
SRSmaInfo *pRSmaInfo = tdGetRSmaInfoBySuid(pSma, pReq->suid);
|
SRSmaInfo *pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pReq->suid);
|
||||||
|
|
||||||
if (!pRSmaInfo) {
|
if (!pRSmaInfo) {
|
||||||
smaWarn("vgId:%d, drop rsma for stable %s %" PRIi64 " failed no rsma in hash", TD_VID(pVnode), pReq->name,
|
smaWarn("vgId:%d, drop rsma for stable %s %" PRIi64 " failed no rsma in hash", TD_VID(pVnode), pReq->name,
|
||||||
|
@ -423,8 +432,10 @@ int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) {
|
||||||
RSMA_INFO_SET_DEL(pRSmaInfo);
|
RSMA_INFO_SET_DEL(pRSmaInfo);
|
||||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
||||||
|
|
||||||
// save to file
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
|
|
||||||
|
// save to file
|
||||||
|
// TODO
|
||||||
smaDebug("vgId:%d, drop rsma for table %" PRIi64 " succeed", TD_VID(pVnode), pReq->suid);
|
smaDebug("vgId:%d, drop rsma for table %" PRIi64 " succeed", TD_VID(pVnode), pReq->suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -567,45 +578,56 @@ static void tdDestroySDataBlockArray(SArray *pArray) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid, SRSmaStat *pStat,
|
/**
|
||||||
int8_t blkType) {
|
* @brief retention of rsma1/rsma2
|
||||||
SArray *pResult = NULL;
|
*
|
||||||
SSma *pSma = pStat->pSma;
|
* @param pSma
|
||||||
|
* @param now
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t smaDoRetention(SSma *pSma, int64_t now) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if (VND_IS_RSMA(pSma->pVnode)) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
|
if (pSma->pRSmaTsdb[i]) {
|
||||||
|
code = tsdbDoRetention(pSma->pRSmaTsdb[i], now);
|
||||||
|
if (code) goto _end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tdRSmaFetchAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSmaInfoItem *pItem, STSchema *pTSchema,
|
||||||
|
int64_t suid, int8_t blkType) {
|
||||||
while (1) {
|
while (1) {
|
||||||
SSDataBlock *output = NULL;
|
SSDataBlock *output = NULL;
|
||||||
uint64_t ts;
|
uint64_t ts;
|
||||||
|
|
||||||
int32_t code = qExecTask(pItem->taskInfo, &output, &ts);
|
int32_t code = qExecTask(taskInfo, &output, &ts);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
||||||
pItem->level, terrstr(code));
|
pItem->level, terrstr(code));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
if (!output) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pResult) {
|
if (output) {
|
||||||
pResult = taosArrayInit(1, sizeof(SSDataBlock));
|
#if 0
|
||||||
if (!pResult) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayPush(pResult, output);
|
|
||||||
|
|
||||||
if (taosArrayGetSize(pResult) > 0) {
|
|
||||||
#if 1
|
|
||||||
char flag[10] = {0};
|
char flag[10] = {0};
|
||||||
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
||||||
|
SArray *pResult = taosArrayInit(1, sizeof(SSDataBlock));
|
||||||
|
taosArrayPush(pResult, output);
|
||||||
blockDebugShowDataBlocks(pResult, flag);
|
blockDebugShowDataBlocks(pResult, flag);
|
||||||
|
taosArrayDestroy(pResult);
|
||||||
#endif
|
#endif
|
||||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||||
SSubmitReq *pReq = NULL;
|
SSubmitReq *pReq = NULL;
|
||||||
// TODO: the schema update should be handled later(TD-17965)
|
// TODO: the schema update should be handled later(TD-17965)
|
||||||
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) {
|
if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, SMA_VID(pSma), suid) < 0) {
|
||||||
smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s",
|
smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s",
|
||||||
SMA_VID(pSma), suid, pItem->level, terrstr());
|
SMA_VID(pSma), suid, pItem->level, terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -622,44 +644,44 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
||||||
SMA_VID(pSma), suid, pItem->level, output->info.version);
|
SMA_VID(pSma), suid, pItem->level, output->info.version);
|
||||||
|
|
||||||
taosMemoryFreeClear(pReq);
|
taosMemoryFreeClear(pReq);
|
||||||
taosArrayClear(pResult);
|
|
||||||
} else if (terrno == 0) {
|
} else if (terrno == 0) {
|
||||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
|
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr());
|
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr());
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tdDestroySDataBlockArray(pResult);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
tdDestroySDataBlockArray(pResult);
|
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem,
|
static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfo *pInfo, tb_uid_t suid,
|
||||||
STSchema *pTSchema, tb_uid_t suid, int8_t level) {
|
int8_t level) {
|
||||||
if (!pItem || !pItem->taskInfo) {
|
int32_t idx = level - 1;
|
||||||
|
if (!pInfo || !RSMA_INFO_QTASK(pInfo, idx)) {
|
||||||
smaDebug("vgId:%d, no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid);
|
smaDebug("vgId:%d, no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
if (!pTSchema) {
|
if (!pInfo->pTSchema) {
|
||||||
smaWarn("vgId:%d, no schema to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid);
|
smaWarn("vgId:%d, no schema to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level,
|
smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level,
|
||||||
pItem->taskInfo, suid);
|
RSMA_INFO_QTASK(pInfo, idx), suid);
|
||||||
|
|
||||||
if (qSetMultiStreamInput(pItem->taskInfo, pMsg, 1, inputType) < 0) { // INPUT__DATA_SUBMIT
|
if (qSetMultiStreamInput(RSMA_INFO_QTASK(pInfo, idx), pMsg, 1, inputType) < 0) { // INPUT__DATA_SUBMIT
|
||||||
smaError("vgId:%d, rsma %" PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno));
|
smaError("vgId:%d, rsma %" PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno));
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pInfo, idx);
|
||||||
SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat);
|
|
||||||
|
|
||||||
tdRSmaFetchAndSubmitResult(pItem, pTSchema, suid, pStat, STREAM_INPUT__DATA_SUBMIT);
|
tdRSmaFetchAndSubmitResult(pSma, RSMA_INFO_QTASK(pInfo, idx), pItem, pInfo->pTSchema, suid,
|
||||||
|
STREAM_INPUT__DATA_SUBMIT);
|
||||||
atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
||||||
|
|
||||||
if (smaMgmt.tmrHandle) {
|
if (smaMgmt.tmrHandle) {
|
||||||
|
@ -678,108 +700,102 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
|
||||||
* @param suid
|
* @param suid
|
||||||
* @return SRSmaInfo*
|
* @return SRSmaInfo*
|
||||||
*/
|
*/
|
||||||
static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
||||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||||
SRSmaStat *pStat = NULL;
|
SRSmaStat *pStat = NULL;
|
||||||
SRSmaInfo *pRSmaInfo = NULL;
|
SRSmaInfo *pRSmaInfo = NULL;
|
||||||
|
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
|
terrno = TSDB_CODE_RSMA_INVALID_ENV;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv);
|
pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv);
|
||||||
if (!pStat || !RSMA_INFO_HASH(pStat)) {
|
if (!pStat || !RSMA_INFO_HASH(pStat)) {
|
||||||
|
terrno = TSDB_CODE_RSMA_INVALID_STAT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosRLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
||||||
if (pRSmaInfo && (pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
if (pRSmaInfo && (pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
||||||
|
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
||||||
|
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
tdRefRSmaInfo(pSma, pRSmaInfo);
|
||||||
|
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
return pRSmaInfo;
|
return pRSmaInfo;
|
||||||
}
|
}
|
||||||
|
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
|
||||||
if (RSMA_COMMIT_STAT(pStat) == 0) {
|
if (RSMA_COMMIT_STAT(pStat) == 0) { // return NULL if not in committing stat
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// clone the SRSmaInfo from iRsmaInfoHash to rsmaInfoHash if in committing stat
|
// clone the SRSmaInfo from iRsmaInfoHash to rsmaInfoHash if in committing stat
|
||||||
SRSmaInfo *pCowRSmaInfo = NULL;
|
SRSmaInfo *pCowRSmaInfo = NULL;
|
||||||
// lock
|
// lock
|
||||||
taosWLockLatch(SMA_ENV_LOCK(pEnv));
|
taosWLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
if (!taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t))) { // 2-phase lock
|
if (!(pCowRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)))) { // 2-phase lock
|
||||||
void *iRSmaInfo = taosHashGet(RSMA_IMU_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
void *iRSmaInfo = taosHashGet(RSMA_IMU_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
||||||
if (iRSmaInfo) {
|
if (iRSmaInfo) {
|
||||||
SRSmaInfo *pIRSmaInfo = *(SRSmaInfo **)iRSmaInfo;
|
SRSmaInfo *pIRSmaInfo = *(SRSmaInfo **)iRSmaInfo;
|
||||||
if (pIRSmaInfo) {
|
if (pIRSmaInfo && !RSMA_INFO_IS_DEL(pIRSmaInfo)) {
|
||||||
if (tdCloneRSmaInfo(pSma, pCowRSmaInfo, pIRSmaInfo) < 0) {
|
if (tdCloneRSmaInfo(pSma, &pCowRSmaInfo, pIRSmaInfo) < 0) {
|
||||||
|
// unlock
|
||||||
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
smaError("vgId:%d, clone rsma info failed for suid:%" PRIu64 " since %s", SMA_VID(pSma), suid, terrstr());
|
smaError("vgId:%d, clone rsma info failed for suid:%" PRIu64 " since %s", SMA_VID(pSma), suid, terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
smaDebug("vgId:%d, clone rsma info succeed for suid:%" PRIu64, SMA_VID(pSma), suid);
|
smaDebug("vgId:%d, clone rsma info succeed for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||||
if (taosHashPut(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t), &pCowRSmaInfo, sizeof(pCowRSmaInfo)) < 0) {
|
if (taosHashPut(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t), &pCowRSmaInfo, sizeof(pCowRSmaInfo)) < 0) {
|
||||||
|
// unlock
|
||||||
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
|
smaError("vgId:%d, clone rsma info failed for suid:%" PRIu64 " since %s", SMA_VID(pSma), suid, terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pCowRSmaInfo = *(SRSmaInfo **)pCowRSmaInfo;
|
||||||
|
ASSERT(!pCowRSmaInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pCowRSmaInfo) {
|
||||||
|
tdRefRSmaInfo(pSma, pCowRSmaInfo);
|
||||||
}
|
}
|
||||||
// unlock
|
// unlock
|
||||||
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||||
return pCowRSmaInfo;
|
return pCowRSmaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static FORCE_INLINE void tdReleaseRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
|
||||||
* @brief During the drop procedure, only need to delete the object in rsmaInfoHash.
|
if (pInfo) {
|
||||||
*
|
tdUnRefRSmaInfo(pSma, pInfo);
|
||||||
* @param pSma
|
|
||||||
* @param suid
|
|
||||||
* @return SRSmaInfo*
|
|
||||||
*/
|
|
||||||
void tdRemoveRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
|
||||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
|
||||||
SRSmaStat *pStat = NULL;
|
|
||||||
SRSmaInfo *pRSmaInfo = NULL;
|
|
||||||
|
|
||||||
if (!pEnv) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv);
|
|
||||||
if (!pStat || !RSMA_INFO_HASH(pStat)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
|
||||||
if (pRSmaInfo) {
|
|
||||||
if ((pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
|
||||||
tdFreeRSmaInfo(pSma, pRSmaInfo, true);
|
|
||||||
}
|
|
||||||
taosHashRemove(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
|
||||||
smaDebug("vgId:%d, remove from infoHash for table:%" PRIu64 " succeed", SMA_VID(pSma), suid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) {
|
static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) {
|
||||||
SRSmaInfo *pRSmaInfo = tdGetRSmaInfoBySuid(pSma, suid);
|
SRSmaInfo *pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, suid);
|
||||||
if (!pRSmaInfo) {
|
if (!pRSmaInfo) {
|
||||||
smaDebug("vgId:%d, execute rsma, no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid);
|
smaDebug("vgId:%d, execute rsma, no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pRSmaInfo->items[0].taskInfo) {
|
if (!RSMA_INFO_QTASK(pRSmaInfo, 0)) {
|
||||||
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
smaDebug("vgId:%d, execute rsma, no rsma qTaskInfo for suid:%" PRIu64, SMA_VID(pSma), suid);
|
smaDebug("vgId:%d, execute rsma, no rsma qTaskInfo for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputType == STREAM_INPUT__DATA_SUBMIT) {
|
if (inputType == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
tdRefRSmaInfo(pSma, pRSmaInfo);
|
tdExecuteRSmaImpl(pSma, pMsg, inputType, pRSmaInfo, suid, TSDB_RETENTION_L1);
|
||||||
|
tdExecuteRSmaImpl(pSma, pMsg, inputType, pRSmaInfo, suid, TSDB_RETENTION_L2);
|
||||||
tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[0], pRSmaInfo->pTSchema, suid, TSDB_RETENTION_L1);
|
|
||||||
tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[1], pRSmaInfo->pTSchema, suid, TSDB_RETENTION_L2);
|
|
||||||
|
|
||||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,26 +1006,28 @@ static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *
|
||||||
SRSmaInfo *pRSmaInfo = NULL;
|
SRSmaInfo *pRSmaInfo = NULL;
|
||||||
void *qTaskInfo = NULL;
|
void *qTaskInfo = NULL;
|
||||||
|
|
||||||
pRSmaInfo = tdGetRSmaInfoBySuid(pSma, pItem->suid);
|
pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pItem->suid);
|
||||||
if (!pRSmaInfo) {
|
if (!pRSmaInfo) {
|
||||||
smaDebug("vgId:%d, no restore as no rsma info for table:%" PRIu64, SMA_VID(pSma), pItem->suid);
|
smaDebug("vgId:%d, no restore as no rsma info for table:%" PRIu64, SMA_VID(pSma), pItem->suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pItem->type == TSDB_RETENTION_L1) {
|
if (pItem->type == TSDB_RETENTION_L1) {
|
||||||
qTaskInfo = pRSmaInfo->items[0].taskInfo;
|
qTaskInfo = RSMA_INFO_QTASK(pRSmaInfo, 0);
|
||||||
} else if (pItem->type == TSDB_RETENTION_L2) {
|
} else if (pItem->type == TSDB_RETENTION_L2) {
|
||||||
qTaskInfo = pRSmaInfo->items[1].taskInfo;
|
qTaskInfo = RSMA_INFO_QTASK(pRSmaInfo, 1);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qTaskInfo) {
|
if (!qTaskInfo) {
|
||||||
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
smaDebug("vgId:%d, no restore as NULL rsma qTaskInfo for table:%" PRIu64, SMA_VID(pSma), pItem->suid);
|
smaDebug("vgId:%d, no restore as NULL rsma qTaskInfo for table:%" PRIu64, SMA_VID(pSma), pItem->suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qDeserializeTaskStatus(qTaskInfo, pItem->qTaskInfo, pItem->len) < 0) {
|
if (qDeserializeTaskStatus(qTaskInfo, pItem->qTaskInfo, pItem->len) < 0) {
|
||||||
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
smaError("vgId:%d, restore rsma task failed for table:%" PRIi64 " level %d since %s", SMA_VID(pSma), pItem->suid,
|
smaError("vgId:%d, restore rsma task failed for table:%" PRIi64 " level %d since %s", SMA_VID(pSma), pItem->suid,
|
||||||
pItem->type, terrstr());
|
pItem->type, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
@ -1017,6 +1035,7 @@ static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *
|
||||||
smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid,
|
smaDebug("vgId:%d, restore rsma task success for table:%" PRIi64 " level %d", SMA_VID(pSma), pItem->suid,
|
||||||
pItem->type);
|
pItem->type);
|
||||||
|
|
||||||
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,8 +1214,14 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
|
||||||
|
|
||||||
while (infoHash) {
|
while (infoHash) {
|
||||||
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash;
|
SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash;
|
||||||
|
|
||||||
|
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
||||||
|
infoHash = taosHashIterate(pInfoHash, infoHash);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
qTaskInfo_t taskInfo = pRSmaInfo->items[i].taskInfo;
|
qTaskInfo_t taskInfo = RSMA_INFO_QTASK(pRSmaInfo, i);
|
||||||
if (!taskInfo) {
|
if (!taskInfo) {
|
||||||
smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1);
|
smaDebug("vgId:%d, rsma, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1282,7 +1307,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief trigger to get rsma result
|
* @brief trigger to get rsma result in async mode
|
||||||
*
|
*
|
||||||
* @param param
|
* @param param
|
||||||
* @param tmrId
|
* @param tmrId
|
||||||
|
@ -1290,11 +1315,17 @@ _err:
|
||||||
static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
SRSmaInfoItem *pItem = param;
|
SRSmaInfoItem *pItem = param;
|
||||||
SSma *pSma = NULL;
|
SSma *pSma = NULL;
|
||||||
SRSmaStat *pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
SRSmaInfo *pRSmaInfo = tdGetRSmaInfoByItem(pItem);
|
||||||
|
|
||||||
|
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRSmaStat *pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
|
||||||
|
|
||||||
if (!pStat) {
|
if (!pStat) {
|
||||||
smaDebug("rsma fetch task not start since already destroyed, rsetId rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
|
smaDebug("rsma fetch task not start since already destroyed, rsetId rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
|
||||||
pItem->refId);
|
pRSmaInfo->refId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1305,13 +1336,12 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
switch (rsmaTriggerStat) {
|
switch (rsmaTriggerStat) {
|
||||||
case TASK_TRIGGER_STAT_PAUSED:
|
case TASK_TRIGGER_STAT_PAUSED:
|
||||||
case TASK_TRIGGER_STAT_CANCELLED: {
|
case TASK_TRIGGER_STAT_CANCELLED: {
|
||||||
tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
|
||||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64
|
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64
|
||||||
" refId:%d",
|
" refId:%d",
|
||||||
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pItem->refId);
|
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaInfo->refId);
|
||||||
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
|
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
|
||||||
taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay > 5000 ? 5000 : pItem->maxDelay, pItem, smaMgmt.tmrHandle,
|
taosTmrReset(tdRSmaFetchTrigger, 5000, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||||
&pItem->tmrId);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1319,29 +1349,14 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRSmaInfo *pRSmaInfo = tdGetRSmaInfoByItem(pItem);
|
|
||||||
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
|
||||||
goto _end;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t fetchTriggerStat =
|
int8_t fetchTriggerStat =
|
||||||
atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE);
|
atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE);
|
||||||
switch (fetchTriggerStat) {
|
switch (fetchTriggerStat) {
|
||||||
case TASK_TRIGGER_STAT_ACTIVE: {
|
case TASK_TRIGGER_STAT_ACTIVE: {
|
||||||
smaDebug("vgId:%d, fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is active", SMA_VID(pSma),
|
smaDebug("vgId:%d, fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is active", SMA_VID(pSma),
|
||||||
pItem->level, pRSmaInfo->suid);
|
pItem->level, pRSmaInfo->suid);
|
||||||
|
// async process
|
||||||
// sync procedure => async process
|
tdRSmaFetchSend(pSma, pRSmaInfo, pItem->level);
|
||||||
tdRefRSmaInfo(pSma, pRSmaInfo);
|
|
||||||
|
|
||||||
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
|
|
||||||
qSetMultiStreamInput(pItem->taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK);
|
|
||||||
tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK);
|
|
||||||
tdCleanupStreamInputDataBlock(pItem->taskInfo);
|
|
||||||
|
|
||||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
|
||||||
// atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
|
||||||
// taosTmrReset(tdRSmaFetchTrigger, 5000, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
|
||||||
} break;
|
} break;
|
||||||
case TASK_TRIGGER_STAT_PAUSED: {
|
case TASK_TRIGGER_STAT_PAUSED: {
|
||||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is paused",
|
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is paused",
|
||||||
|
@ -1362,22 +1377,120 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smaDoRetention(SSma *pSma, int64_t now) {
|
/**
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
* @brief put rsma fetch msg to fetch queue
|
||||||
if (VND_IS_RSMA(pSma->pVnode)) {
|
*
|
||||||
return code;
|
* @param pSma
|
||||||
|
* @param pInfo
|
||||||
|
* @param level
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t tdRSmaFetchSend(SSma *pSma, SRSmaInfo *pInfo, int8_t level) {
|
||||||
|
SRSmaFetchMsg fetchMsg = { .suid = pInfo->suid, .level = level};
|
||||||
|
int32_t ret = 0;
|
||||||
|
int32_t contLen = 0;
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncodeSize(tEncodeSRSmaFetchMsg, &fetchMsg, contLen, ret);
|
||||||
|
if (ret < 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
void *pBuf = rpcMallocCont(contLen + sizeof(SMsgHead));
|
||||||
if (pSma->pRSmaTsdb[i]) {
|
tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), contLen);
|
||||||
code = tsdbDoRetention(pSma->pRSmaTsdb[i], now);
|
if (tEncodeSRSmaFetchMsg(&encoder, &fetchMsg) < 0) {
|
||||||
if (code) goto _end;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
((SMsgHead *)pBuf)->vgId = SMA_VID(pSma);
|
||||||
|
((SMsgHead *)pBuf)->contLen = contLen + sizeof(SMsgHead);
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.code = 0,
|
||||||
|
.msgType = TDMT_VND_FETCH_RSMA,
|
||||||
|
.pCont = pBuf,
|
||||||
|
.contLen = contLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((terrno = tmsgPutToQueue(&pSma->pVnode->msgCb, FETCH_QUEUE, &rpcMsg)) != 0) {
|
||||||
|
smaError("vgId:%d, failed to put rsma fetch msg into fetch-queue for suid:%" PRIi64 " level:%" PRIi8 " since %s",
|
||||||
|
SMA_VID(pSma), pInfo->suid, level, terrstr());
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
smaDebug("vgId:%d, success to put rsma fetch msg into fetch-queue for suid:%" PRIi64 " level:%" PRIi8, SMA_VID(pSma),
|
||||||
|
pInfo->suid, level);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_err:
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief fetch rsma data of level 2/3 and submit
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @param pMsg
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t smaProcessFetch(SSma *pSma, void *pMsg) {
|
||||||
|
SRpcMsg *pRpcMsg = (SRpcMsg *)pMsg;
|
||||||
|
SRSmaFetchMsg req = {0};
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
void *pBuf = NULL;
|
||||||
|
SRSmaInfo *pInfo = NULL;
|
||||||
|
SRSmaInfoItem *pItem = NULL;
|
||||||
|
|
||||||
|
if (!pRpcMsg || pRpcMsg->contLen < sizeof(SMsgHead)) {
|
||||||
|
terrno = TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pBuf = POINTER_SHIFT(pRpcMsg->pCont, sizeof(SMsgHead));
|
||||||
|
|
||||||
|
tDecoderInit(&decoder, pBuf, pRpcMsg->contLen);
|
||||||
|
if (tDecodeSRSmaFetchMsg(&decoder, &req) < 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo = tdAcquireRSmaInfoBySuid(pSma, req.suid);
|
||||||
|
if (!pInfo) {
|
||||||
|
if (terrno == TSDB_CODE_SUCCESS) {
|
||||||
|
terrno = TSDB_CODE_RSMA_EMPTY_INFO;
|
||||||
}
|
}
|
||||||
|
smaWarn("vgId:%d, failed to process rsma fetch msg for suid:%" PRIi64 " level:%" PRIi8 " since %s", SMA_VID(pSma),
|
||||||
|
req.suid, req.level, terrstr());
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
pItem = RSMA_INFO_ITEM(pInfo, req.level - 1);
|
||||||
return code;
|
|
||||||
}
|
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
|
||||||
|
qTaskInfo_t taskInfo = RSMA_INFO_QTASK(pInfo, req.level - 1);
|
||||||
|
if ((terrno = qSetMultiStreamInput(taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK)) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
if (tdRSmaFetchAndSubmitResult(pSma, taskInfo, pItem, pInfo->pTSchema, pInfo->suid, STREAM_INPUT__DATA_BLOCK) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
tdCleanupStreamInputDataBlock(taskInfo);
|
||||||
|
|
||||||
|
tdReleaseRSmaInfo(pSma, pInfo);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
smaDebug("vgId:%d, success to process rsma fetch msg for suid:%" PRIi64 " level:%" PRIi8, SMA_VID(pSma), req.suid,
|
||||||
|
req.level);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_err:
|
||||||
|
tdReleaseRSmaInfo(pSma, pInfo);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
smaError("vgId:%d, failed to process rsma fetch msg since %s", SMA_VID(pSma), terrstr());
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
|
@ -116,8 +116,10 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create stable to save tsma result in dstVgId
|
// create stable to save tsma result in dstVgId
|
||||||
|
SName stbFullName = {0};
|
||||||
|
tNameFromString(&stbFullName, pCfg->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
SVCreateStbReq pReq = {0};
|
SVCreateStbReq pReq = {0};
|
||||||
pReq.name = pCfg->dstTbName;
|
pReq.name = (char*)tNameGetTableName(&stbFullName);
|
||||||
pReq.suid = pCfg->dstTbUid;
|
pReq.suid = pCfg->dstTbUid;
|
||||||
pReq.schemaRow = pCfg->schemaRow;
|
pReq.schemaRow = pCfg->schemaRow;
|
||||||
pReq.schemaTag = pCfg->schemaTag;
|
pReq.schemaTag = pCfg->schemaTag;
|
||||||
|
@ -125,6 +127,12 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
|
||||||
if (metaCreateSTable(SMA_META(pSma), version, &pReq) < 0) {
|
if (metaCreateSTable(SMA_META(pSma), version, &pReq) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smaDebug("vgId:%d, success to create sma index %s %" PRIi64 " on stb:%" PRIi64 ", dstSuid:%" PRIi64
|
||||||
|
" dstTb:%s dstVg:%d",
|
||||||
|
SMA_VID(pSma), pCfg->indexName, pCfg->indexUid, pCfg->tableUid, pCfg->dstTbUid, pReq.name, pCfg->dstVgId);
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -287,22 +287,22 @@ int32_t tdRemoveTFile(STFile *pTFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// smaXXXUtil ================
|
// smaXXXUtil ================
|
||||||
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln) {
|
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) {
|
||||||
void *pResult = taosAcquireRef(rsetId, refId);
|
void *pResult = taosAcquireRef(rsetId, refId);
|
||||||
if (!pResult) {
|
if (!pResult) {
|
||||||
smaWarn("%s:%d taosAcquireRef for rsetId:%" PRIi64 " refId:%d failed since %s", tags, ln, rsetId, refId, terrstr());
|
smaWarn("rsma acquire ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr());
|
||||||
} else {
|
} else {
|
||||||
smaDebug("%s:%d taosAcquireRef for rsetId:%" PRIi64 " refId:%d success", tags, ln, rsetId, refId);
|
smaDebug("rsma acquire ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId);
|
||||||
}
|
}
|
||||||
return pResult;
|
return pResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln) {
|
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
|
||||||
if (taosReleaseRef(rsetId, refId) < 0) {
|
if (taosReleaseRef(rsetId, refId) < 0) {
|
||||||
smaWarn("%s:%d taosReleaseRef for rsetId:%" PRIi64 " refId:%d failed since %s", tags, ln, rsetId, refId, terrstr());
|
smaWarn("rsma release ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
smaDebug("%s:%d taosReleaseRef for rsetId:%" PRIi64 " refId:%d success", tags, ln, rsetId, refId);
|
smaDebug("rsma release ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t
|
||||||
char *pOutput = NULL;
|
char *pOutput = NULL;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
|
||||||
if (qSerializeTaskStatus(srcTaskInfo, &pOutput, &len) < 0) {
|
if ((terrno = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len)) < 0) {
|
||||||
smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid,
|
smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid,
|
||||||
terrstr());
|
terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -337,41 +337,34 @@ static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid);
|
smaDebug("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid);
|
||||||
|
|
||||||
taosMemoryFreeClear(pOutput);
|
taosMemoryFreeClear(pOutput);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
taosMemoryFreeClear(pOutput);
|
taosMemoryFreeClear(pOutput);
|
||||||
tdFreeQTaskInfo(dstTaskInfo, TD_VID(pVnode), idx + 1);
|
tdFreeQTaskInfo(dstTaskInfo, TD_VID(pVnode), idx + 1);
|
||||||
|
smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid,
|
||||||
|
terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief pTSchema is shared
|
* @brief pTSchema is shared
|
||||||
*
|
*
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @param pDest
|
* @param pDest
|
||||||
* @param pSrc
|
* @param pSrc
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pDest, SRSmaInfo *pSrc) {
|
int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo **pDest, SRSmaInfo *pSrc) {
|
||||||
SVnode *pVnode = pSma->pVnode;
|
SVnode *pVnode = pSma->pVnode;
|
||||||
SRSmaParam *param = NULL;
|
SRSmaParam *param = NULL;
|
||||||
if (!pSrc) {
|
if (!pSrc) {
|
||||||
|
*pDest = NULL;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pDest) {
|
|
||||||
pDest = taosMemoryCalloc(1, sizeof(SRSmaInfo));
|
|
||||||
if (!pDest) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(pDest, pSrc, sizeof(SRSmaInfo));
|
|
||||||
|
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderInit(&mr, SMA_META(pSma), 0);
|
metaReaderInit(&mr, SMA_META(pSma), 0);
|
||||||
smaDebug("vgId:%d, rsma clone, suid is %" PRIi64, TD_VID(pVnode), pSrc->suid);
|
smaDebug("vgId:%d, rsma clone, suid is %" PRIi64, TD_VID(pVnode), pSrc->suid);
|
||||||
|
@ -384,21 +377,22 @@ int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pDest, SRSmaInfo *pSrc) {
|
||||||
ASSERT(mr.me.uid == pSrc->suid);
|
ASSERT(mr.me.uid == pSrc->suid);
|
||||||
if (TABLE_IS_ROLLUP(mr.me.flags)) {
|
if (TABLE_IS_ROLLUP(mr.me.flags)) {
|
||||||
param = &mr.me.stbEntry.rsmaParam;
|
param = &mr.me.stbEntry.rsmaParam;
|
||||||
for (int i = 0; i < TSDB_RETENTION_L2; ++i) {
|
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||||
SRSmaInfoItem *pItem = &pSrc->items[i];
|
if (tdCloneQTaskInfo(pSma, pSrc->iTaskInfo[i], pSrc->taskInfo[i], param, pSrc->suid, i) < 0) {
|
||||||
if (pItem->taskInfo) {
|
goto _err;
|
||||||
tdCloneQTaskInfo(pSma, pDest->items[i].taskInfo, pItem->taskInfo, param, pSrc->suid, i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
smaDebug("vgId:%d, rsma clone env success for %" PRIi64, TD_VID(pVnode), pSrc->suid);
|
smaDebug("vgId:%d, rsma clone env success for %" PRIi64, TD_VID(pVnode), pSrc->suid);
|
||||||
}
|
}
|
||||||
|
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
|
*pDest = pSrc; // pointer copy
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
|
*pDest = NULL;
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
tdFreeRSmaInfo(pSma, pDest, false);
|
smaError("vgId:%d, rsma clone env failed for %" PRIi64 " since %s", TD_VID(pVnode), pSrc->suid, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
|
|
@ -115,12 +115,19 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
TSDBROW row = tsdbRowFromBlockData(&pReader->oBlockData, iRow);
|
TSDBROW row = tsdbRowFromBlockData(&pReader->oBlockData, iRow);
|
||||||
int64_t version = TSDBROW_VERSION(&row);
|
int64_t version = TSDBROW_VERSION(&row);
|
||||||
|
|
||||||
|
tsdbTrace("vgId:%d, vnode snapshot tsdb read for %s, %" PRId64 "(%" PRId64 " , %" PRId64 ")",
|
||||||
|
TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path, version, pReader->sver, pReader->ever);
|
||||||
|
|
||||||
if (version < pReader->sver || version > pReader->ever) continue;
|
if (version < pReader->sver || version > pReader->ever) continue;
|
||||||
|
|
||||||
code = tBlockDataAppendRow(&pReader->nBlockData, &row, NULL);
|
code = tBlockDataAppendRow(&pReader->nBlockData, &row, NULL);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pReader->nBlockData.nRow <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// org data
|
// org data
|
||||||
// compress data (todo)
|
// compress data (todo)
|
||||||
int32_t size = sizeof(TABLEID) + tPutBlockData(NULL, &pReader->nBlockData);
|
int32_t size = sizeof(TABLEID) + tPutBlockData(NULL, &pReader->nBlockData);
|
||||||
|
@ -808,7 +815,8 @@ static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tsdbDebug("vgId:%d, vnode snapshot tsdb write data impl for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
|
tsdbDebug("vgId:%d, vnode snapshot tsdb write data impl for %s", TD_VID(pWriter->pTsdb->pVnode),
|
||||||
|
pWriter->pTsdb->path);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
|
@ -42,7 +42,7 @@ int vnodeBegin(SVnode *pVnode) {
|
||||||
|
|
||||||
pVnode->state.commitID++;
|
pVnode->state.commitID++;
|
||||||
// begin meta
|
// begin meta
|
||||||
if (metaBegin(pVnode->pMeta) < 0) {
|
if (metaBegin(pVnode->pMeta, 0) < 0) {
|
||||||
vError("vgId:%d, failed to begin meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d, failed to begin meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,7 +473,7 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
|
||||||
int numOfCols = 0;
|
int numOfCols = 0;
|
||||||
vnodeGetStbColumnNum(pVnode, id, &numOfCols);
|
vnodeGetStbColumnNum(pVnode, id, &numOfCols);
|
||||||
|
|
||||||
*num += ctbNum * numOfCols;
|
*num += ctbNum * (numOfCols - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
metaCloseStbCursor(pCur);
|
metaCloseStbCursor(pCur);
|
||||||
|
|
|
@ -325,6 +325,8 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
return vnodeGetTableCfg(pVnode, pMsg, true);
|
return vnodeGetTableCfg(pVnode, pMsg, true);
|
||||||
case TDMT_VND_BATCH_META:
|
case TDMT_VND_BATCH_META:
|
||||||
return vnodeGetBatchMeta(pVnode, pMsg);
|
return vnodeGetBatchMeta(pVnode, pMsg);
|
||||||
|
case TDMT_VND_FETCH_RSMA:
|
||||||
|
return smaProcessFetch(pVnode->pSma, pMsg);
|
||||||
case TDMT_VND_CONSUME:
|
case TDMT_VND_CONSUME:
|
||||||
return tqProcessPollReq(pVnode->pTq, pMsg);
|
return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||||
case TDMT_STREAM_TASK_RUN:
|
case TDMT_STREAM_TASK_RUN:
|
||||||
|
@ -351,7 +353,6 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
// TODO: remove the function
|
// TODO: remove the function
|
||||||
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
blockDebugShowDataBlocks(data, __func__);
|
blockDebugShowDataBlocks(data, __func__);
|
||||||
tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
||||||
}
|
}
|
||||||
|
@ -852,6 +853,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
||||||
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||||
submitBlkRsp.code = terrno;
|
submitBlkRsp.code = terrno;
|
||||||
|
pRsp->code = terrno;
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
taosArrayDestroy(createTbReq.ctb.tagName);
|
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
|
|
@ -730,10 +730,13 @@ void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); }
|
||||||
|
|
||||||
bool vnodeIsLeader(SVnode *pVnode) {
|
bool vnodeIsLeader(SVnode *pVnode) {
|
||||||
if (!syncIsReady(pVnode->sync)) {
|
if (!syncIsReady(pVnode->sync)) {
|
||||||
|
vDebug("vgId:%d, vnode not ready, state:%s, restore:%d", pVnode->config.vgId, syncGetMyRoleStr(pVnode->sync),
|
||||||
|
syncRestoreFinish(pVnode->sync));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pVnode->restored) {
|
if (!pVnode->restored) {
|
||||||
|
vDebug("vgId:%d, vnode not restored", pVnode->config.vgId);
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,6 +279,7 @@ typedef struct SCtgMsgCtx {
|
||||||
void* lastOut;
|
void* lastOut;
|
||||||
void* out;
|
void* out;
|
||||||
char* target;
|
char* target;
|
||||||
|
SHashObj* pBatchs;
|
||||||
} SCtgMsgCtx;
|
} SCtgMsgCtx;
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,7 +316,6 @@ typedef struct SCtgTask {
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
SArray* pParents;
|
SArray* pParents;
|
||||||
SCtgSubRes subRes;
|
SCtgSubRes subRes;
|
||||||
SHashObj* pBatchs;
|
|
||||||
} SCtgTask;
|
} SCtgTask;
|
||||||
|
|
||||||
typedef struct SCtgTaskReq {
|
typedef struct SCtgTaskReq {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue