Merge branch '3.0' into merge/mainto3.0
|
@ -156,6 +156,9 @@ pcre2_grep_test.sh
|
||||||
pcre2_chartables.c
|
pcre2_chartables.c
|
||||||
geos-config
|
geos-config
|
||||||
config.h
|
config.h
|
||||||
|
!contrib/xml2-cmake
|
||||||
|
!contrib/xml2-cmake/linux_x86_64/include/config.h
|
||||||
|
!contrib/xml2-cmake/CMakeLists.txt
|
||||||
pcre2.h
|
pcre2.h
|
||||||
zconf.h
|
zconf.h
|
||||||
version.h
|
version.h
|
||||||
|
|
|
@ -93,7 +93,7 @@ If you want to compile taosAdapter or taosKeeper, you need to install Go 1.18 or
|
||||||
### For Ubuntu 18.04、20.04、22.04
|
### For Ubuntu 18.04、20.04、22.04
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get udpate
|
sudo apt-get update
|
||||||
sudo apt-get install -y gcc cmake build-essential git libjansson-dev \
|
sudo apt-get install -y gcc cmake build-essential git libjansson-dev \
|
||||||
libsnappy-dev liblzma-dev zlib1g-dev pkg-config
|
libsnappy-dev liblzma-dev zlib1g-dev pkg-config
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
ExternalProject_Add(azure
|
ExternalProject_Add(azure
|
||||||
URL https://github.com/Azure/azure-sdk-for-cpp/archive/refs/tags/azure-storage-blobs_12.13.0-beta.1.tar.gz
|
URL https://github.com/Azure/azure-sdk-for-cpp/archive/refs/tags/azure-storage-blobs_12.13.0-beta.1.tar.gz
|
||||||
URL_HASH SHA256=3eca486fd60e3522d0a633025ecd652a71515b1e944799b2e8ee31fd590305a9
|
URL_HASH SHA256=3eca486fd60e3522d0a633025ecd652a71515b1e944799b2e8ee31fd590305a9
|
||||||
|
DEPENDS xml2
|
||||||
DOWNLOAD_NO_PROGRESS 1
|
DOWNLOAD_NO_PROGRESS 1
|
||||||
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||||
SOURCE_DIR "${TD_CONTRIB_DIR}/azure-sdk-for-cpp-azure-storage-blobs_12.13.0-beta.1"
|
SOURCE_DIR "${TD_CONTRIB_DIR}/azure-sdk-for-cpp-azure-storage-blobs_12.13.0-beta.1"
|
||||||
|
|
|
@ -12,7 +12,7 @@ ExternalProject_Add(curl2
|
||||||
BUILD_IN_SOURCE TRUE
|
BUILD_IN_SOURCE TRUE
|
||||||
BUILD_ALWAYS 1
|
BUILD_ALWAYS 1
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
CONFIGURE_COMMAND ${CONTRIB_CONFIG_ENV} ./configure --prefix=$ENV{HOME}/.cos-local.2 --with-ssl=$ENV{HOME}/.cos-local.2 --enable-websockets --enable-shared=no --disable-ldap --disable-ldaps --without-brotli --without-zstd --without-libidn2 --without-nghttp2 --without-libpsl #--enable-debug
|
CONFIGURE_COMMAND ${CONTRIB_CONFIG_ENV} ./configure --prefix=$ENV{HOME}/.cos-local.2 --with-ssl=$ENV{HOME}/.cos-local.2 --enable-websockets --enable-shared=no --disable-ldap --disable-ldaps --without-brotli --without-zstd --without-libidn2 --without-nghttp2 --without-libpsl --without-librtmp #--enable-debug
|
||||||
BUILD_COMMAND make -j
|
BUILD_COMMAND make -j
|
||||||
INSTALL_COMMAND make install
|
INSTALL_COMMAND make install
|
||||||
TEST_COMMAND ""
|
TEST_COMMAND ""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taosadapter
|
# taosadapter
|
||||||
ExternalProject_Add(taosadapter
|
ExternalProject_Add(taosadapter
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||||
GIT_TAG main
|
GIT_TAG 3.0
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taosws-rs
|
# taosws-rs
|
||||||
ExternalProject_Add(taosws-rs
|
ExternalProject_Add(taosws-rs
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
||||||
GIT_TAG main
|
GIT_TAG 3.0
|
||||||
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
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
|
|
||||||
# xml2
|
# xml2
|
||||||
ExternalProject_Add(xml2
|
ExternalProject_Add(xml2
|
||||||
URL https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.5.tar.xz
|
URL https://github.com/GNOME/libxml2/archive/refs/tags/v2.10.4.tar.gz
|
||||||
URL_HASH SHA256=3727b078c360ec69fa869de14bd6f75d7ee8d36987b071e6928d4720a28df3a6
|
URL_HASH SHA256=6f6fb27f91bb65f9d7196e3c616901b3e18a7dea31ccc2ae857940b125faa780
|
||||||
#https://github.com/GNOME/libxml2/archive/refs/tags/v2.11.5.tar.gz
|
|
||||||
#GIT_REPOSITORY https://github.com/GNOME/libxml2
|
|
||||||
#GIT_TAG v2.11.5
|
|
||||||
DOWNLOAD_NO_PROGRESS 1
|
DOWNLOAD_NO_PROGRESS 1
|
||||||
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||||
SOURCE_DIR "${TD_CONTRIB_DIR}/xml2"
|
SOURCE_DIR "${TD_CONTRIB_DIR}/libxml2"
|
||||||
#BINARY_DIR ""
|
#BINARY_DIR ""
|
||||||
BUILD_IN_SOURCE TRUE
|
BUILD_IN_SOURCE TRUE
|
||||||
CONFIGURE_COMMAND ./configure --prefix=$ENV{HOME}/.cos-local.2 --enable-shared=no --enable-static=yes --without-python --without-lzma
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND make -j
|
BUILD_COMMAND ""
|
||||||
INSTALL_COMMAND make install && ln -sf $ENV{HOME}/.cos-local.2/include/libxml2/libxml $ENV{HOME}/.cos-local.2/include/libxml
|
INSTALL_COMMAND ""
|
||||||
TEST_COMMAND ""
|
TEST_COMMAND ""
|
||||||
GIT_SHALLOW true
|
GIT_SHALLOW true
|
||||||
)
|
)
|
||||||
|
|
|
@ -159,7 +159,6 @@ elseif(${BUILD_WITH_COS})
|
||||||
# cat("${TD_SUPPORT_DIR}/mxml_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/mxml_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
# cat("${TD_SUPPORT_DIR}/apr_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/apr_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
# cat("${TD_SUPPORT_DIR}/apr-util_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
# cat("${TD_SUPPORT_DIR}/apr-util_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
# cat("${TD_SUPPORT_DIR}/curl_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
|
||||||
cat("${TD_SUPPORT_DIR}/cos_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/cos_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
add_definitions(-DUSE_COS)
|
add_definitions(-DUSE_COS)
|
||||||
endif()
|
endif()
|
||||||
|
@ -665,7 +664,12 @@ if(${BUILD_PCRE2})
|
||||||
endif(${BUILD_PCRE2})
|
endif(${BUILD_PCRE2})
|
||||||
|
|
||||||
if(${TD_LINUX} AND ${BUILD_WITH_S3})
|
if(${TD_LINUX} AND ${BUILD_WITH_S3})
|
||||||
add_subdirectory(azure-cmake EXCLUDE_FROM_ALL)
|
set(ORIG_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||||
|
string(REPLACE " -Werror " " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
|
add_subdirectory(xml2-cmake)
|
||||||
|
set(CMAKE_C_FLAGS ${ORIG_CMAKE_C_FLAGS})
|
||||||
|
|
||||||
|
add_subdirectory(azure-cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF(TD_LINUX)
|
IF(TD_LINUX)
|
||||||
|
|
|
@ -36,10 +36,6 @@ target_include_directories(
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
find_library(CURL_LIBRARY curl $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
find_library(XML2_LIBRARY xml2 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
|
||||||
|
|
||||||
# find_library(CURL_LIBRARY curl)
|
|
||||||
# find_library(XML2_LIBRARY xml2)
|
|
||||||
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
find_library(SSL_LIBRARY ssl $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
find_library(CRYPTO_LIBRARY crypto $ENV{HOME}/.cos-local.2/lib64 $ENV{HOME}/.cos-local.2/lib NO_DEFAULT_PATH)
|
||||||
|
|
||||||
|
@ -50,9 +46,8 @@ target_link_libraries(
|
||||||
PRIVATE ${CURL_LIBRARY}
|
PRIVATE ${CURL_LIBRARY}
|
||||||
PRIVATE ${SSL_LIBRARY}
|
PRIVATE ${SSL_LIBRARY}
|
||||||
PRIVATE ${CRYPTO_LIBRARY}
|
PRIVATE ${CRYPTO_LIBRARY}
|
||||||
PRIVATE ${XML2_LIBRARY}
|
|
||||||
|
|
||||||
# PRIVATE xml2
|
PRIVATE _libxml2
|
||||||
PRIVATE zlib
|
PRIVATE zlib
|
||||||
|
|
||||||
# PRIVATE ${CoreFoundation_Library}
|
# PRIVATE ${CoreFoundation_Library}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
set(LIBXML2_SOURCE_DIR "${TD_CONTRIB_DIR}/libxml2")
|
||||||
|
|
||||||
|
set(SRCS
|
||||||
|
"${LIBXML2_SOURCE_DIR}/SAX.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/entities.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/encoding.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/error.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/parserInternals.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/parser.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/tree.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/hash.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/list.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlIO.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlmemory.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/uri.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/valid.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xlink.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/HTMLparser.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/HTMLtree.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/debugXML.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xpath.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xpointer.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xinclude.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/nanohttp.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/nanoftp.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/catalog.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/globals.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/threads.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/c14n.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlstring.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/buf.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlregexp.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlschemas.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlschemastypes.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlunicode.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/triostr.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlreader.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/relaxng.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/dict.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/SAX2.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlwriter.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/legacy.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/chvalid.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/pattern.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlsave.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xmlmodule.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/schematron.c"
|
||||||
|
"${LIBXML2_SOURCE_DIR}/xzlib.c"
|
||||||
|
)
|
||||||
|
add_library(_libxml2 ${SRCS})
|
||||||
|
|
||||||
|
#target_link_libraries(_libxml2 PRIVATE td_contrib::zlib)
|
||||||
|
target_link_libraries(_libxml2 PRIVATE zlib)
|
||||||
|
|
||||||
|
target_include_directories(_libxml2 BEFORE PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/include")
|
||||||
|
target_include_directories(_libxml2 BEFORE PUBLIC "${LIBXML2_SOURCE_DIR}/include")
|
||||||
|
|
||||||
|
add_library(td_contrib::libxml2 ALIAS _libxml2)
|
|
@ -0,0 +1,285 @@
|
||||||
|
/* config.h. Generated from config.h.in by configure. */
|
||||||
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
|
/* Type cast for the gethostbyname() argument */
|
||||||
|
#define GETHOSTBYNAME_ARG_CAST /**/
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||||
|
#define HAVE_ARPA_INET_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||||
|
#define HAVE_ARPA_NAMESER_H 1
|
||||||
|
|
||||||
|
/* Whether struct sockaddr::__ss_family exists */
|
||||||
|
/* #undef HAVE_BROKEN_SS_FAMILY */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ctype.h> header file. */
|
||||||
|
#define HAVE_CTYPE_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dirent.h> header file. */
|
||||||
|
#define HAVE_DIRENT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#define HAVE_DLFCN_H 1
|
||||||
|
|
||||||
|
/* Have dlopen based dso */
|
||||||
|
#define HAVE_DLOPEN /**/
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dl.h> header file. */
|
||||||
|
/* #undef HAVE_DL_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <errno.h> header file. */
|
||||||
|
#define HAVE_ERRNO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||||
|
#define HAVE_FCNTL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <float.h> header file. */
|
||||||
|
#define HAVE_FLOAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fprintf' function. */
|
||||||
|
#define HAVE_FPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ftime' function. */
|
||||||
|
#define HAVE_FTIME 1
|
||||||
|
|
||||||
|
/* Define if getaddrinfo is there */
|
||||||
|
#define HAVE_GETADDRINFO /**/
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `gettimeofday' function. */
|
||||||
|
#define HAVE_GETTIMEOFDAY 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `isascii' function. */
|
||||||
|
#define HAVE_ISASCII 1
|
||||||
|
|
||||||
|
/* Define if isinf is there */
|
||||||
|
#define HAVE_ISINF /**/
|
||||||
|
|
||||||
|
/* Define if isnan is there */
|
||||||
|
#define HAVE_ISNAN /**/
|
||||||
|
|
||||||
|
/* Define if history library is there (-lhistory) */
|
||||||
|
/* #undef HAVE_LIBHISTORY */
|
||||||
|
|
||||||
|
/* Define if pthread library is there (-lpthread) */
|
||||||
|
#define HAVE_LIBPTHREAD /**/
|
||||||
|
|
||||||
|
/* Define if readline library is there (-lreadline) */
|
||||||
|
/* #undef HAVE_LIBREADLINE */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
|
#define HAVE_LIMITS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `localtime' function. */
|
||||||
|
#define HAVE_LOCALTIME 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <lzma.h> header file. */
|
||||||
|
/* #undef HAVE_LZMA_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <malloc.h> header file. */
|
||||||
|
#define HAVE_MALLOC_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <math.h> header file. */
|
||||||
|
#define HAVE_MATH_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mmap' function. */
|
||||||
|
#define HAVE_MMAP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `munmap' function. */
|
||||||
|
#define HAVE_MUNMAP 1
|
||||||
|
|
||||||
|
/* mmap() is no good without munmap() */
|
||||||
|
#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
|
||||||
|
# undef /**/ HAVE_MMAP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||||
|
/* #undef HAVE_NDIR_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netdb.h> header file. */
|
||||||
|
#define HAVE_NETDB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||||
|
#define HAVE_NETINET_IN_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <poll.h> header file. */
|
||||||
|
#define HAVE_POLL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `printf' function. */
|
||||||
|
#define HAVE_PRINTF 1
|
||||||
|
|
||||||
|
/* Define if <pthread.h> is there */
|
||||||
|
#define HAVE_PTHREAD_H /**/
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `putenv' function. */
|
||||||
|
#define HAVE_PUTENV 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `rand' function. */
|
||||||
|
#define HAVE_RAND 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `rand_r' function. */
|
||||||
|
#define HAVE_RAND_R 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <resolv.h> header file. */
|
||||||
|
#define HAVE_RESOLV_H 1
|
||||||
|
|
||||||
|
/* Have shl_load based dso */
|
||||||
|
/* #undef HAVE_SHLLOAD */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `signal' function. */
|
||||||
|
#define HAVE_SIGNAL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <signal.h> header file. */
|
||||||
|
#define HAVE_SIGNAL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `snprintf' function. */
|
||||||
|
#define HAVE_SNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sprintf' function. */
|
||||||
|
#define HAVE_SPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `srand' function. */
|
||||||
|
#define HAVE_SRAND 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sscanf' function. */
|
||||||
|
#define HAVE_SSCANF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `stat' function. */
|
||||||
|
#define HAVE_STAT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdarg.h> header file. */
|
||||||
|
#define HAVE_STDARG_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#define HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strftime' function. */
|
||||||
|
#define HAVE_STRFTIME 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#define HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_SYS_DIR_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||||
|
#define HAVE_SYS_MMAN_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_SYS_NDIR_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||||
|
#define HAVE_SYS_SELECT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||||
|
#define HAVE_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#define HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/timeb.h> header file. */
|
||||||
|
#define HAVE_SYS_TIMEB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||||
|
#define HAVE_SYS_TIME_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `time' function. */
|
||||||
|
#define HAVE_TIME 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <time.h> header file. */
|
||||||
|
#define HAVE_TIME_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Whether va_copy() is available */
|
||||||
|
#define HAVE_VA_COPY 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vfprintf' function. */
|
||||||
|
#define HAVE_VFPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
|
#define HAVE_VSNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vsprintf' function. */
|
||||||
|
#define HAVE_VSPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <zlib.h> header file. */
|
||||||
|
/* #undef HAVE_ZLIB_H */
|
||||||
|
|
||||||
|
/* Whether __va_copy() is available */
|
||||||
|
/* #undef HAVE___VA_COPY */
|
||||||
|
|
||||||
|
/* Define as const if the declaration of iconv() needs const. */
|
||||||
|
#define ICONV_CONST
|
||||||
|
|
||||||
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||||
|
#define LT_OBJDIR ".libs/"
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "libxml2"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT ""
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME ""
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING ""
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME ""
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL ""
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION ""
|
||||||
|
|
||||||
|
/* Type cast for the send() function 2nd arg */
|
||||||
|
#define SEND_ARG2_CAST /**/
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Support for IPv6 */
|
||||||
|
#define SUPPORT_IP6 /**/
|
||||||
|
|
||||||
|
/* Define if va_list is an array type */
|
||||||
|
#define VA_LIST_IS_ARRAY 1
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "2.9.8"
|
||||||
|
|
||||||
|
/* Determine what socket length (socklen_t) data type is */
|
||||||
|
#define XML_SOCKLEN_T socklen_t
|
||||||
|
|
||||||
|
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||||
|
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||||
|
#define below would cause a syntax error. */
|
||||||
|
/* #undef _UINT32_T */
|
||||||
|
|
||||||
|
/* ss_family is not defined here, use __ss_family instead */
|
||||||
|
/* #undef ss_family */
|
||||||
|
|
||||||
|
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||||
|
such a type exists and the standard includes do not define it. */
|
||||||
|
/* #undef uint32_t */
|
|
@ -0,0 +1,501 @@
|
||||||
|
/*
|
||||||
|
* Summary: compile-time version information
|
||||||
|
* Description: compile-time version information for the XML library
|
||||||
|
*
|
||||||
|
* Copy: See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Author: Daniel Veillard
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XML_VERSION_H__
|
||||||
|
#define __XML_VERSION_H__
|
||||||
|
|
||||||
|
#include <libxml/xmlexports.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* use those to be sure nothing nasty will happen if
|
||||||
|
* your library and includes mismatch
|
||||||
|
*/
|
||||||
|
#ifndef LIBXML2_COMPILING_MSCCDEF
|
||||||
|
XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
|
#endif /* LIBXML2_COMPILING_MSCCDEF */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_DOTTED_VERSION:
|
||||||
|
*
|
||||||
|
* the version string like "1.2.3"
|
||||||
|
*/
|
||||||
|
#define LIBXML_DOTTED_VERSION "2.10.3"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_VERSION:
|
||||||
|
*
|
||||||
|
* the version number: 1.2.3 value is 10203
|
||||||
|
*/
|
||||||
|
#define LIBXML_VERSION 21003
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_VERSION_STRING:
|
||||||
|
*
|
||||||
|
* the version number string, 1.2.3 value is "10203"
|
||||||
|
*/
|
||||||
|
#define LIBXML_VERSION_STRING "21003"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_VERSION_EXTRA:
|
||||||
|
*
|
||||||
|
* extra version information, used to show a git commit description
|
||||||
|
*/
|
||||||
|
#define LIBXML_VERSION_EXTRA ""
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_TEST_VERSION:
|
||||||
|
*
|
||||||
|
* Macro to check that the libxml version in use is compatible with
|
||||||
|
* the version the software has been compiled against
|
||||||
|
*/
|
||||||
|
#define LIBXML_TEST_VERSION xmlCheckVersion(21003);
|
||||||
|
|
||||||
|
#ifndef VMS
|
||||||
|
#if 0
|
||||||
|
/**
|
||||||
|
* WITH_TRIO:
|
||||||
|
*
|
||||||
|
* defined if the trio support need to be configured in
|
||||||
|
*/
|
||||||
|
#define WITH_TRIO
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* WITHOUT_TRIO:
|
||||||
|
*
|
||||||
|
* defined if the trio support should not be configured in
|
||||||
|
*/
|
||||||
|
#define WITHOUT_TRIO
|
||||||
|
#endif
|
||||||
|
#else /* VMS */
|
||||||
|
/**
|
||||||
|
* WITH_TRIO:
|
||||||
|
*
|
||||||
|
* defined if the trio support need to be configured in
|
||||||
|
*/
|
||||||
|
#define WITH_TRIO 1
|
||||||
|
#endif /* VMS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_THREAD_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the thread support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_THREAD_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_THREAD_ALLOC_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the allocation hooks are per-thread
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_THREAD_ALLOC_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_TREE_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the DOM like tree manipulation API support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_TREE_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_OUTPUT_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the serialization/saving support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_OUTPUT_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_PUSH_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the push parsing interfaces are configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_PUSH_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_READER_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the xmlReader parsing interface is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_READER_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_PATTERN_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the xmlPattern node selection interface is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_PATTERN_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_WRITER_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the xmlWriter saving interface is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_WRITER_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_SAX1_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the older SAX1 interface is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_SAX1_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_FTP_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the FTP support is configured in
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_FTP_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_HTTP_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the HTTP support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_HTTP_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_VALID_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the DTD validation support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_VALID_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_HTML_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the HTML support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_HTML_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_LEGACY_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the deprecated APIs are compiled in for compatibility
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_LEGACY_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_C14N_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Canonicalization support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_C14N_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_CATALOG_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Catalog support is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_CATALOG_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_XPATH_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether XPath is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_XPATH_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_XPTR_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether XPointer is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_XPTR_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_XPTR_LOCS_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether support for XPointer locations is configured in
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_XPTR_LOCS_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_XINCLUDE_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether XInclude is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_XINCLUDE_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_ICONV_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether iconv support is available
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_ICONV_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_ICU_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether icu support is available
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_ICU_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_ISO8859X_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether ISO-8859-* support is made available in case iconv is not
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_ISO8859X_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_DEBUG_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether Debugging module is configured in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_DEBUG_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DEBUG_MEMORY_LOCATION:
|
||||||
|
*
|
||||||
|
* Whether the memory debugging is configured in
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define DEBUG_MEMORY_LOCATION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_DEBUG_RUNTIME:
|
||||||
|
*
|
||||||
|
* Whether the runtime debugging is configured in
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_DEBUG_RUNTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_UNICODE_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Unicode related interfaces are compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_UNICODE_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_REGEXP_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the regular expressions interfaces are compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_REGEXP_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_AUTOMATA_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the automata interfaces are compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_AUTOMATA_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_EXPR_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the formal expressions interfaces are compiled in
|
||||||
|
*
|
||||||
|
* This code is unused and disabled unconditionally for now.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_EXPR_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_SCHEMAS_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Schemas validation interfaces are compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_SCHEMAS_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_SCHEMATRON_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Schematron validation interfaces are compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_SCHEMATRON_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_MODULES_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the module interfaces are compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_MODULES_ENABLED
|
||||||
|
/**
|
||||||
|
* LIBXML_MODULE_EXTENSION:
|
||||||
|
*
|
||||||
|
* the string suffix used by dynamic modules (usually shared libraries)
|
||||||
|
*/
|
||||||
|
#define LIBXML_MODULE_EXTENSION ".so"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_ZLIB_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Zlib support is compiled in
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
|
#define LIBXML_ZLIB_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_LZMA_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Lzma support is compiled in
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_LZMA_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ATTRIBUTE_UNUSED:
|
||||||
|
*
|
||||||
|
* Macro used to signal to GCC unused function parameters
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
|
# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_UNUSED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_ATTR_ALLOC_SIZE:
|
||||||
|
*
|
||||||
|
* Macro used to indicate to GCC this is an allocator function
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBXML_ATTR_ALLOC_SIZE
|
||||||
|
# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))
|
||||||
|
# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
|
||||||
|
# else
|
||||||
|
# define LIBXML_ATTR_ALLOC_SIZE(x)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LIBXML_ATTR_ALLOC_SIZE(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_ATTR_FORMAT:
|
||||||
|
*
|
||||||
|
* Macro used to indicate to GCC the parameter are printf like
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBXML_ATTR_FORMAT
|
||||||
|
# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
|
||||||
|
# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
|
||||||
|
# else
|
||||||
|
# define LIBXML_ATTR_FORMAT(fmt,args)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LIBXML_ATTR_FORMAT(fmt,args)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XML_DEPRECATED
|
||||||
|
# ifdef IN_LIBXML
|
||||||
|
# define XML_DEPRECATED
|
||||||
|
# else
|
||||||
|
/* Available since at least GCC 3.1 */
|
||||||
|
# define XML_DEPRECATED __attribute__((deprecated))
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* ! __GNUC__ */
|
||||||
|
/**
|
||||||
|
* ATTRIBUTE_UNUSED:
|
||||||
|
*
|
||||||
|
* Macro used to signal to GCC unused function parameters
|
||||||
|
*/
|
||||||
|
#define ATTRIBUTE_UNUSED
|
||||||
|
/**
|
||||||
|
* LIBXML_ATTR_ALLOC_SIZE:
|
||||||
|
*
|
||||||
|
* Macro used to indicate to GCC this is an allocator function
|
||||||
|
*/
|
||||||
|
#define LIBXML_ATTR_ALLOC_SIZE(x)
|
||||||
|
/**
|
||||||
|
* LIBXML_ATTR_FORMAT:
|
||||||
|
*
|
||||||
|
* Macro used to indicate to GCC the parameter are printf like
|
||||||
|
*/
|
||||||
|
#define LIBXML_ATTR_FORMAT(fmt,args)
|
||||||
|
/**
|
||||||
|
* XML_DEPRECATED:
|
||||||
|
*
|
||||||
|
* Macro used to indicate that a function, variable, type or struct member
|
||||||
|
* is deprecated.
|
||||||
|
*/
|
||||||
|
#ifndef XML_DEPRECATED
|
||||||
|
#define XML_DEPRECATED
|
||||||
|
#endif
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif
|
|
@ -17,7 +17,9 @@ TDengine is designed for various writing scenarios, and many of these scenarios
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY'];
|
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY'];
|
||||||
SHOW COMPACTS [compact_id];
|
COMPACT [db_name.]VGROUPS IN (vgroup_id1, vgroup_id2, ...) [start with 'XXXX'] [end with 'YYYY'];
|
||||||
|
SHOW COMPACTS;
|
||||||
|
SHOW COMPACT compact_id;
|
||||||
KILL COMPACT compact_id;
|
KILL COMPACT compact_id;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,7 @@ window_clause: {
|
||||||
| COUNT_WINDOW(count_val[, sliding_val])
|
| COUNT_WINDOW(count_val[, sliding_val])
|
||||||
|
|
||||||
interp_clause:
|
interp_clause:
|
||||||
RANGE(ts_val [, ts_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
RANGE(ts_val [, ts_val] [, surrounding_time_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
||||||
| RANGE(ts_val, surrounding_time_val) FILL(fill_mod_and_val)
|
|
||||||
|
|
||||||
partition_by_clause:
|
partition_by_clause:
|
||||||
PARTITION BY partition_by_expr [, partition_by_expr] ...
|
PARTITION BY partition_by_expr [, partition_by_expr] ...
|
||||||
|
|
|
@ -1967,7 +1967,7 @@ ignore_null_values: {
|
||||||
- For queries on tables with composite primary keys, if there are data with the same timestamp, only the data with the smallest composite primary key participates in the calculation.
|
- For queries on tables with composite primary keys, if there are data with the same timestamp, only the data with the smallest composite primary key participates in the calculation.
|
||||||
- INTERP query supports NEAR FILL mode, i.e., when FILL is needed, it uses the data closest to the current time point for interpolation. When the timestamps before and after are equally close to the current time slice, FILL the previous row's value. This mode is not supported in stream computing and window queries. For example: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', '2023-01-01 00:10:00') FILL(NEAR).(Supported from version 3.3.4.9).
|
- INTERP query supports NEAR FILL mode, i.e., when FILL is needed, it uses the data closest to the current time point for interpolation. When the timestamps before and after are equally close to the current time slice, FILL the previous row's value. This mode is not supported in stream computing and window queries. For example: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', '2023-01-01 00:10:00') FILL(NEAR).(Supported from version 3.3.4.9).
|
||||||
- INTERP can only use the pseudocolumn `_irowts_origin` when using FILL PREV/NEXT/NEAR modes. `_irowts_origin` is supported from version 3.3.4.9.
|
- INTERP can only use the pseudocolumn `_irowts_origin` when using FILL PREV/NEXT/NEAR modes. `_irowts_origin` is supported from version 3.3.4.9.
|
||||||
- INTERP `RANGE` clause supports the expansion of the time range (supported from version 3.3.4.9), such as `RANGE('2023-01-01 00:00:00', 10s)` means to find data 10s before and after the time point '2023-01-01 00:00:00' for interpolation, FILL PREV/NEXT/NEAR respectively means to look for data forward/backward/around the time point, if there is no data around the time point, then use the value specified by FILL for interpolation, therefore the FILL clause must specify a value at this time. For example: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', 10s) FILL(PREV, 1). Currently, only the combination of time point and time range is supported, not the combination of time interval and time range, i.e., RANGE('2023-01-01 00:00:00', '2023-02-01 00:00:00', 1h) is not supported. The specified time range rules are similar to EVERY, the unit cannot be year or month, the value cannot be 0, and cannot have quotes. When using this extension, other FILL modes except FILL PREV/NEXT/NEAR are not supported, and the EVERY clause cannot be specified.
|
- INTERP `RANGE` clause supports the expansion of the time range (supported from version 3.3.4.9), For example, `RANGE('2023-01-01 00:00:00', 10s)` means that only data within 10s around the time point '2023-01-01 00:00:00' can be used for interpolation. `FILL PREV/NEXT/NEAR` respectively means to look for data forward/backward/around the time point. If there is no data around the time point, the default value specified by `FILL` is used for interpolation. Therefore the `FILL` clause must specify the default value at the same time. For example: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', 10s) FILL(PREV, 1). Starting from the 3.3.6.0 version, the combination of time period and time range is supported. When interpolating for each point within the time period, the time range requirement must be met. Prior versions only supported single time point and its time range. The available values for time range are similar to `EVERY`, the unit cannot be year or month, the value must be greater than 0, and cannot be in quotes. When using this extension, `FILL` modes other than `PREV/NEXT/NEAR` are not supported.
|
||||||
|
|
||||||
### LAST
|
### LAST
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@ TDengine supports `UNION ALL` and `UNION` operators. UNION ALL combines the resu
|
||||||
| 9 | LIKE | BINARY, NCHAR, and VARCHAR | Matches the specified pattern string with wildcard |
|
| 9 | LIKE | BINARY, NCHAR, and VARCHAR | Matches the specified pattern string with wildcard |
|
||||||
| 10 | NOT LIKE | BINARY, NCHAR, and VARCHAR | Does not match the specified pattern string with wildcard |
|
| 10 | NOT LIKE | BINARY, NCHAR, and VARCHAR | Does not match the specified pattern string with wildcard |
|
||||||
| 11 | MATCH, NMATCH | BINARY, NCHAR, and VARCHAR | Regular expression match |
|
| 11 | MATCH, NMATCH | BINARY, NCHAR, and VARCHAR | Regular expression match |
|
||||||
| 12 | CONTAINS | JSON | Whether a key exists in JSON |
|
| 12 | REGEXP, NOT REGEXP | BINARY, NCHAR, and VARCHAR | Regular expression match |
|
||||||
|
| 13 | CONTAINS | JSON | Whether a key exists in JSON |
|
||||||
|
|
||||||
LIKE conditions use wildcard strings for matching checks, with the following rules:
|
LIKE conditions use wildcard strings for matching checks, with the following rules:
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ LIKE conditions use wildcard strings for matching checks, with the following rul
|
||||||
- If you want to match an underscore character that is originally in the string, you can write it as \_ in the wildcard string, i.e., add a backslash to escape it.
|
- If you want to match an underscore character that is originally in the string, you can write it as \_ in the wildcard string, i.e., add a backslash to escape it.
|
||||||
- The wildcard string cannot exceed 100 bytes in length. It is not recommended to use too long wildcard strings, as it may severely affect the performance of the LIKE operation.
|
- The wildcard string cannot exceed 100 bytes in length. It is not recommended to use too long wildcard strings, as it may severely affect the performance of the LIKE operation.
|
||||||
|
|
||||||
MATCH and NMATCH conditions use regular expressions for matching, with the following rules:
|
MATCH/REGEXP and NMATCH/NOT REGEXP conditions use regular expressions for matching, with the following rules:
|
||||||
|
|
||||||
- Supports regular expressions that comply with the POSIX standard, see Regular Expressions for specific standards.
|
- Supports regular expressions that comply with the POSIX standard, see Regular Expressions for specific standards.
|
||||||
- When MATCH matches a regular expression, it returns TRUE. When NMATCH does not match a regular expression, it returns TRUE.
|
- When MATCH matches a regular expression, it returns TRUE. When NMATCH does not match a regular expression, it returns TRUE.
|
||||||
|
|
|
@ -304,9 +304,10 @@ Displays information about all topics in the current database.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SHOW TRANSACTIONS;
|
SHOW TRANSACTIONS;
|
||||||
|
SHOW TRANSACTION [tranaction_id];
|
||||||
```
|
```
|
||||||
|
|
||||||
Displays information about transactions currently being executed in the system (these transactions are only for metadata level, not for regular tables).
|
Displays information about one of or all transaction(s) currently being executed in the system (these transactions are only for metadata level, not for regular tables).
|
||||||
|
|
||||||
## SHOW USERS
|
## SHOW USERS
|
||||||
|
|
||||||
|
|
|
@ -510,7 +510,6 @@ For the OpenTSDB text protocol, the parsing of timestamps follows its official p
|
||||||
- tmq: [Input] Points to a valid ws_tmq_t structure pointer, which represents a TMQ consumer object.
|
- tmq: [Input] Points to a valid ws_tmq_t structure pointer, which represents a TMQ consumer object.
|
||||||
- timeout: [Input] Polling timeout in milliseconds, a negative number indicates a default timeout of 1 second.
|
- timeout: [Input] Polling timeout in milliseconds, a negative number indicates a default timeout of 1 second.
|
||||||
- **Return Value**: Non-`NULL`: Success, returns a pointer to a WS_RES structure, which contains the received message. `NULL`: indicates no data, the error code can be obtained through ws_errno (NULL), please refer to the reference manual for specific error message. WS_RES results are consistent with taos_query results, and information in WS_RES can be obtained through various query interfaces, such as schema, etc.
|
- **Return Value**: Non-`NULL`: Success, returns a pointer to a WS_RES structure, which contains the received message. `NULL`: indicates no data, the error code can be obtained through ws_errno (NULL), please refer to the reference manual for specific error message. WS_RES results are consistent with taos_query results, and information in WS_RES can be obtained through various query interfaces, such as schema, etc.
|
||||||
|
|
||||||
- `int32_t ws_tmq_consumer_close(ws_tmq_t *tmq)`
|
- `int32_t ws_tmq_consumer_close(ws_tmq_t *tmq)`
|
||||||
- **Interface Description**: Used to close the ws_tmq_t structure. Must be used in conjunction with ws_tmq_consumer_new.
|
- **Interface Description**: Used to close the ws_tmq_t structure. Must be used in conjunction with ws_tmq_consumer_new.
|
||||||
- tmq: [Input] Points to a valid ws_tmq_t structure pointer, which represents a TMQ consumer object.
|
- tmq: [Input] Points to a valid ws_tmq_t structure pointer, which represents a TMQ consumer object.
|
||||||
|
@ -1196,7 +1195,7 @@ In addition to using SQL or parameter binding APIs to insert data, you can also
|
||||||
- tmq: [Input] Points to a valid tmq_t structure pointer, representing a TMQ consumer object.
|
- tmq: [Input] Points to a valid tmq_t structure pointer, representing a TMQ consumer object.
|
||||||
- timeout: [Input] Polling timeout in milliseconds, a negative number indicates a default timeout of 1 second.
|
- timeout: [Input] Polling timeout in milliseconds, a negative number indicates a default timeout of 1 second.
|
||||||
- **Return Value**: Non-`NULL`: Success, returns a pointer to a TAOS_RES structure containing the received messages. `NULL`: indicates no data, the error code can be obtained through taos_errno (NULL), please refer to the reference manual for specific error message. TAOS_RES results are consistent with taos_query results, and information in TAOS_RES can be obtained through various query interfaces, such as schema, etc.
|
- **Return Value**: Non-`NULL`: Success, returns a pointer to a TAOS_RES structure containing the received messages. `NULL`: indicates no data, the error code can be obtained through taos_errno (NULL), please refer to the reference manual for specific error message. TAOS_RES results are consistent with taos_query results, and information in TAOS_RES can be obtained through various query interfaces, such as schema, etc.
|
||||||
|
|
||||||
- `int32_t tmq_consumer_close(tmq_t *tmq)`
|
- `int32_t tmq_consumer_close(tmq_t *tmq)`
|
||||||
- **Interface Description**: Used to close a tmq_t structure. Must be used in conjunction with tmq_consumer_new.
|
- **Interface Description**: Used to close a tmq_t structure. Must be used in conjunction with tmq_consumer_new.
|
||||||
- tmq: [Input] Points to a valid tmq_t structure pointer, which represents a TMQ consumer object.
|
- tmq: [Input] Points to a valid tmq_t structure pointer, which represents a TMQ consumer object.
|
||||||
|
|
|
@ -534,5 +534,6 @@ This document details the server error codes that may be encountered when using
|
||||||
| 0x80004000 | Invalid message | The subscribed data is illegal, generally does not occur | Check the client-side error logs for details |
|
| 0x80004000 | Invalid message | The subscribed data is illegal, generally does not occur | Check the client-side error logs for details |
|
||||||
| 0x80004001 | Consumer mismatch | The vnode requested for subscription and the reassigned vnode are inconsistent, usually occurs when new consumers join the same consumer group | Internal error, not exposed to users |
|
| 0x80004001 | Consumer mismatch | The vnode requested for subscription and the reassigned vnode are inconsistent, usually occurs when new consumers join the same consumer group | Internal error, not exposed to users |
|
||||||
| 0x80004002 | Consumer closed | The consumer no longer exists | Check if it has already been closed |
|
| 0x80004002 | Consumer closed | The consumer no longer exists | Check if it has already been closed |
|
||||||
| 0x80004017 | Invalid status, please subscribe topic first | tmq status invalidate | Without calling subscribe, directly poll data |
|
| 0x80004017 | Invalid status, please subscribe topic first | tmq status invalidate | Without calling subscribe, directly poll data |
|
||||||
| 0x80004100 | Stream task not exist | The stream computing task does not exist | Check the server-side error logs |
|
| 0x80004100 | Stream task not exist | The stream computing task does not exist | Check the server-side error logs |
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,13 @@ static int DemoInsertData() {
|
||||||
taos_cleanup();
|
taos_cleanup();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taos_free_result(result);
|
|
||||||
|
|
||||||
// you can check affectedRows here
|
// you can check affectedRows here
|
||||||
int rows = taos_affected_rows(result);
|
int rows = taos_affected_rows(result);
|
||||||
fprintf(stdout, "Successfully inserted %d rows into power.meters.\n", rows);
|
fprintf(stdout, "Successfully inserted %d rows into power.meters.\n", rows);
|
||||||
|
|
||||||
|
taos_free_result(result);
|
||||||
|
|
||||||
// close & clean
|
// close & clean
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
taos_cleanup();
|
taos_cleanup();
|
||||||
|
|
|
@ -65,6 +65,8 @@ TDengine 可以通过 MQTT 连接器从 MQTT 代理订阅数据并将其写入 T
|
||||||
|
|
||||||
在 **订阅主题及 QoS 配置** 中填写要消费的 Topic 名称和 QoS。使用如下格式设置: `{topic_name}::{qos}`(如:`my_topic::0`)。MQTT 协议 5.0 支持共享订阅,可以通过多个客户端订阅同一个 Topic 实现负载均衡,使用如下格式: `$share/{group_name}/{topic_name}::{qos}`,其中,`$share` 是固定前缀,表示启用共享订阅,`group_name` 是分组名称,类似 kafka 的消费者组。
|
在 **订阅主题及 QoS 配置** 中填写要消费的 Topic 名称和 QoS。使用如下格式设置: `{topic_name}::{qos}`(如:`my_topic::0`)。MQTT 协议 5.0 支持共享订阅,可以通过多个客户端订阅同一个 Topic 实现负载均衡,使用如下格式: `$share/{group_name}/{topic_name}::{qos}`,其中,`$share` 是固定前缀,表示启用共享订阅,`group_name` 是分组名称,类似 kafka 的消费者组。
|
||||||
|
|
||||||
|
在 **主题解析** 中填写 MQTT 主题解析规则,格式与 MQTT Topic 相同,将 MQTT Topic 各层级内容解析为对应变量名,`_` 表示解析时忽略当前层级。例如:MQTT Topic `a/+/c` 对应解析规则如果设置为 `v1/v2/_`,代表将第一层级的 `a` 赋值给变量 `v1`,第二层级的值(这里通配符 `+` 代表任意值)复制给变量 `v2`,第三层级的值 `c` 忽略,不会赋值给任何变量。在下方的 `payload 解析` 中,Topic 解析得到的变量同样可以参与各种转换和计算。
|
||||||
|
|
||||||
在 **数据压缩** 中,配置消息体压缩算法,taosX 在接收到消息后,使用对应的压缩算法对消息体进行解压缩获取原始数据。可选项 none(不压缩), gzip, snappy, lz4 和 zstd,默认为 none。
|
在 **数据压缩** 中,配置消息体压缩算法,taosX 在接收到消息后,使用对应的压缩算法对消息体进行解压缩获取原始数据。可选项 none(不压缩), gzip, snappy, lz4 和 zstd,默认为 none。
|
||||||
|
|
||||||
在 **字符编码** 中,配置消息体编码格式,taosX 在接收到消息后,使用对应的编码格式对消息体进行解码获取原始数据。可选项 UTF_8, GBK, GB18030, BIG5,默认为 UTF_8
|
在 **字符编码** 中,配置消息体编码格式,taosX 在接收到消息后,使用对应的编码格式对消息体进行解码获取原始数据。可选项 UTF_8, GBK, GB18030, BIG5,默认为 UTF_8
|
||||||
|
@ -138,7 +140,11 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
||||||
|
|
||||||
#### 6.4 表映射
|
#### 6.4 表映射
|
||||||
|
|
||||||
在 **目标超级表** 的下拉列表中选择一个目标超级表,也可以先点击右侧的 **创建超级表** 按钮
|
在 **目标超级表** 的下拉列表中选择一个目标超级表,也可以先点击右侧的 **创建超级表** 按钮创建新的超级表。
|
||||||
|
|
||||||
|
当超级表需要根据消息动态生成时,可以选择 **创建模板**。其中,超级表名称,列名,列类型等均可以使用模板变量,当接收到数据后,程序会自动计算模板变量并生成对应的超级表模板,当数据库中超级表不存在时,会使用此模板创建超级表;对于已创建的超级表,如果缺少通过模板变量计算得到的列,也会自动创建对应列。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
在 **映射** 中,填写目标超级表中的子表名称,例如:`t_{id}`。根据需求填写映射规则,其中 mapping 支持设置缺省值。
|
在 **映射** 中,填写目标超级表中的子表名称,例如:`t_{id}`。根据需求填写映射规则,其中 mapping 支持设置缺省值。
|
||||||
|
|
||||||
|
@ -148,6 +154,16 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
如果超级表列为模板变量,在子表映射时会进行 pivot 操作,其中模板变量的值展开为列名,列的值为对应的映射列
|
||||||
|
|
||||||
|
例如:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
预览结果为:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### 7. 高级选项
|
### 7. 高级选项
|
||||||
|
|
||||||
在 **消息等待队列大小** 中填写接收 MQTT 消息的缓存队列大小,当队列满时,新到达的数据会直接丢弃。可设置为 0,即不缓存。
|
在 **消息等待队列大小** 中填写接收 MQTT 消息的缓存队列大小,当队列满时,新到达的数据会直接丢弃。可设置为 0,即不缓存。
|
||||||
|
|
|
@ -152,7 +152,11 @@ let v3 = data["voltage"].split(",");
|
||||||
|
|
||||||
使用 json 规则解析出的电压是字符串表达的带单位形式,最终入库希望能使用 int 类型记录电压值和电流值,便于统计分析,此时就需要对电压进一步拆分;另外日期期望拆分为日期和时间入库。
|
使用 json 规则解析出的电压是字符串表达的带单位形式,最终入库希望能使用 int 类型记录电压值和电流值,便于统计分析,此时就需要对电压进一步拆分;另外日期期望拆分为日期和时间入库。
|
||||||
|
|
||||||
如下图所示可以对源字段`ts`使用 split 规则拆分成日期和时间,对字段`voltage`使用 regex 提取出电压值和电压单位。split 规则需要设置**分隔符**和**拆分数量**,拆分后的字段命名规则为`{原字段名}_{顺序号}`,Regex 规则同解析过程中的一样,使用**命名捕获组**命名提取字段。
|
如下图所示
|
||||||
|
|
||||||
|
* 对字段`ts`使用 split 规则拆分成日期和时间。split 规则需要设置**分隔符**和**拆分数量**,拆分后的字段命名规则为`{原字段名}_{顺序号}`。
|
||||||
|
* 对字段`voltage`使用正则表达式 `^(?<voltage>[0-9]+)(?<voltage_unit>[a-zA-Z]+)$` 提取出电压值和电压单位,Regex 规则同解析过程中的一样,使用**命名捕获组**命名提取字段。
|
||||||
|
* 对字段 `location` 使用 convert 转换,填写一个 JSON map 对象,其中 key 为字段 `current` 的值,`value` 为转换后的值。如图,`location` 字段的值 `"beijing.chaoyang.datun"` 被转换为 `"beijing.chaoyang.datunludong"`。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 170 KiB |
|
@ -17,11 +17,11 @@ TDengine 面向多种写入场景,而很多写入场景下,TDengine 的存
|
||||||
### 语法
|
### 语法
|
||||||
|
|
||||||
```SQL
|
```SQL
|
||||||
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY'];
|
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY'];
|
||||||
COMPACT [db_name.]VGROUPS IN (vgroup_id1, vgroup_id2, ...) [start with 'XXXX'] [end with 'YYYY'];
|
COMPACT [db_name.]VGROUPS IN (vgroup_id1, vgroup_id2, ...) [start with 'XXXX'] [end with 'YYYY'];
|
||||||
SHOW COMPACTS;
|
SHOW COMPACTS;
|
||||||
SHOW COMPACT compact_id;
|
SHOW COMPACT compact_id;
|
||||||
KILL COMPACT compact_id;
|
KILL COMPACT compact_id;
|
||||||
```
|
```
|
||||||
|
|
||||||
### 效果
|
### 效果
|
||||||
|
|
|
@ -14,6 +14,8 @@ sidebar_label: taosX-Agent
|
||||||
- `instanceId`:当前 taosx-agent 服务的实例 ID,如果同一台机器上启动了多个 taosx-agent 实例,必须保证各个实例的实例 ID 互不相同。
|
- `instanceId`:当前 taosx-agent 服务的实例 ID,如果同一台机器上启动了多个 taosx-agent 实例,必须保证各个实例的实例 ID 互不相同。
|
||||||
- `compression`: 非必填,可配置为 `true` 或 `false`, 默认为 `false`。配置为`true`, 则开启 `Agent` 和 `taosX` 通信数据压缩。
|
- `compression`: 非必填,可配置为 `true` 或 `false`, 默认为 `false`。配置为`true`, 则开启 `Agent` 和 `taosX` 通信数据压缩。
|
||||||
- `in_memory_cache_capacity`: 非必填,表示可在内存中缓存的最大消息批次数,可配置为大于 0 的整数。默认为 `64`。
|
- `in_memory_cache_capacity`: 非必填,表示可在内存中缓存的最大消息批次数,可配置为大于 0 的整数。默认为 `64`。
|
||||||
|
- `client_port_range.min`:非必填,取值范围 `[49152-65535]`,默认为 `49152`,当 agent 向 taosx 创建 socket 连接时,socket 客户端会随机监听一个端口,此配置限制了端口范围的最小值。
|
||||||
|
- `client_port_range.max`:非必填,取值范围 `[49152-65535]`,默认为 `65535`,此配置限制了端口范围的最大值。
|
||||||
- `log_level`: 非必填,日志级别,默认为 `info`, 同 `taosX` 一样,支持 `error`,`warn`,`info`,`debug`,`trace` 五级。已弃用,请使用 `log.level` 代替。
|
- `log_level`: 非必填,日志级别,默认为 `info`, 同 `taosX` 一样,支持 `error`,`warn`,`info`,`debug`,`trace` 五级。已弃用,请使用 `log.level` 代替。
|
||||||
- `log_keep_days`:非必填,日志保存天数,默认为 `30` 天。已弃用,请使用 `log.keepDays` 代替。
|
- `log_keep_days`:非必填,日志保存天数,默认为 `30` 天。已弃用,请使用 `log.keepDays` 代替。
|
||||||
- `log.path`:日志文件存放的目录。
|
- `log.path`:日志文件存放的目录。
|
||||||
|
@ -49,6 +51,15 @@ sidebar_label: taosX-Agent
|
||||||
#
|
#
|
||||||
#in_memory_cache_capacity = 64
|
#in_memory_cache_capacity = 64
|
||||||
|
|
||||||
|
[client_port_range]
|
||||||
|
# Minimum boundary of listening port of agent, can not less than 49152
|
||||||
|
#
|
||||||
|
# min = 49152
|
||||||
|
|
||||||
|
# Maximum boundary of listening port of agent, can not greater than 65535
|
||||||
|
#
|
||||||
|
# max = 65535
|
||||||
|
|
||||||
# log configuration
|
# log configuration
|
||||||
[log]
|
[log]
|
||||||
# All log files are stored in this directory
|
# All log files are stored in this directory
|
||||||
|
|
|
@ -62,8 +62,7 @@ window_clause: {
|
||||||
| COUNT_WINDOW(count_val[, sliding_val])
|
| COUNT_WINDOW(count_val[, sliding_val])
|
||||||
|
|
||||||
interp_clause:
|
interp_clause:
|
||||||
RANGE(ts_val [, ts_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
RANGE(ts_val [, ts_val] [, surrounding_time_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
||||||
| RANGE(ts_val, surrounding_time_val) FILL(fill_mod_and_val)
|
|
||||||
|
|
||||||
partition_by_clause:
|
partition_by_clause:
|
||||||
PARTITION BY partition_by_expr [, partition_by_expr] ...
|
PARTITION BY partition_by_expr [, partition_by_expr] ...
|
||||||
|
|
|
@ -45,7 +45,8 @@ TDengine 支持 `UNION ALL` 和 `UNION` 操作符。UNION ALL 将查询返回的
|
||||||
| 9 | LIKE | BINARY、NCHAR 和 VARCHAR | 通配符匹配所指定的模式串 |
|
| 9 | LIKE | BINARY、NCHAR 和 VARCHAR | 通配符匹配所指定的模式串 |
|
||||||
| 10 | NOT LIKE | BINARY、NCHAR 和 VARCHAR | 通配符不匹配所指定的模式串 |
|
| 10 | NOT LIKE | BINARY、NCHAR 和 VARCHAR | 通配符不匹配所指定的模式串 |
|
||||||
| 11 | MATCH, NMATCH | BINARY、NCHAR 和 VARCHAR | 正则表达式匹配 |
|
| 11 | MATCH, NMATCH | BINARY、NCHAR 和 VARCHAR | 正则表达式匹配 |
|
||||||
| 12 | CONTAINS | JSON | JSON 中是否存在某键 |
|
| 12 | REGEXP, NOT REGEXP | BINARY、NCHAR 和 VARCHAR | 正则表达式匹配 |
|
||||||
|
| 13 | CONTAINS | JSON | JSON 中是否存在某键 |
|
||||||
|
|
||||||
LIKE 条件使用通配符字符串进行匹配检查,规则如下:
|
LIKE 条件使用通配符字符串进行匹配检查,规则如下:
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ LIKE 条件使用通配符字符串进行匹配检查,规则如下:
|
||||||
- 如果希望匹配字符串中原本就带有的 \_(下划线)字符,那么可以在通配符字符串中写作 \_,即加一个反斜线来进行转义。
|
- 如果希望匹配字符串中原本就带有的 \_(下划线)字符,那么可以在通配符字符串中写作 \_,即加一个反斜线来进行转义。
|
||||||
- 通配符字符串最长不能超过 100 字节。不建议使用太长的通配符字符串,否则将有可能严重影响 LIKE 操作的执行性能。
|
- 通配符字符串最长不能超过 100 字节。不建议使用太长的通配符字符串,否则将有可能严重影响 LIKE 操作的执行性能。
|
||||||
|
|
||||||
MATCH 条件和 NMATCH 条件使用正则表达式进行匹配,规则如下:
|
MATCH/REGEXP 条件和 NMATCH/NOT REGEXP 条件使用正则表达式进行匹配,规则如下:
|
||||||
|
|
||||||
- 支持符合 POSIX 规范的正则表达式,具体规范内容可参见 Regular Expressions。
|
- 支持符合 POSIX 规范的正则表达式,具体规范内容可参见 Regular Expressions。
|
||||||
- MATCH 和正则表达式匹配时, 返回 TURE. NMATCH 和正则表达式不匹配时, 返回 TRUE.
|
- MATCH 和正则表达式匹配时, 返回 TURE. NMATCH 和正则表达式不匹配时, 返回 TRUE.
|
||||||
|
|
|
@ -306,9 +306,10 @@ SHOW TOPICS;
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SHOW TRANSACTIONS;
|
SHOW TRANSACTIONS;
|
||||||
|
SHOW TRANSACTION [tranaction_id];
|
||||||
```
|
```
|
||||||
|
|
||||||
显示当前系统中正在执行的事务的信息(该事务仅针对除普通表以外的元数据级别)
|
显示当前系统中正在执行的所有或者某一个事务的信息(该事务仅针对除普通表以外的元数据级别)
|
||||||
|
|
||||||
## SHOW USERS
|
## SHOW USERS
|
||||||
|
|
||||||
|
|
|
@ -1184,7 +1184,7 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多
|
||||||
- **接口说明**:用于轮询消费数据,每一个消费者,只能单线程调用该接口。
|
- **接口说明**:用于轮询消费数据,每一个消费者,只能单线程调用该接口。
|
||||||
- tmq:[入参] 指向一个有效的 tmq_t 结构体指针,该结构体代表一个 TMQ 消费者对象。
|
- tmq:[入参] 指向一个有效的 tmq_t 结构体指针,该结构体代表一个 TMQ 消费者对象。
|
||||||
- timeout:[入参] 轮询的超时时间,单位为毫秒,负数表示默认超时1秒。
|
- timeout:[入参] 轮询的超时时间,单位为毫秒,负数表示默认超时1秒。
|
||||||
- **返回值**:非 `NULL`:成功,返回一个指向 TAOS_RES 结构体的指针,该结构体包含了接收到的消息。。`NULL`:失败,表示没有数据。TAOS_RES 结果和 taos_query 返回结果一致,可通过查询的各种接口获取 TAOS_RES 里的信息,比如 schema 等。
|
- **返回值**:非 `NULL`:成功,返回一个指向 TAOS_RES 结构体的指针,该结构体包含了接收到的消息。。`NULL`:表示没有数据,可通过taos_errno(NULL) 获取错误码,具体错误码参见参考手册。TAOS_RES 结果和 taos_query 返回结果一致,可通过查询的各种接口获取 TAOS_RES 里的信息,比如 schema 等。
|
||||||
|
|
||||||
- `int32_t tmq_consumer_close(tmq_t *tmq)`
|
- `int32_t tmq_consumer_close(tmq_t *tmq)`
|
||||||
- **接口说明**:用于关闭 tmq_t 结构体。需与 tmq_consumer_new 配合使用。
|
- **接口说明**:用于关闭 tmq_t 结构体。需与 tmq_consumer_new 配合使用。
|
||||||
|
|
|
@ -554,6 +554,6 @@ description: TDengine 服务端的错误码列表和详细说明
|
||||||
| 0x80004000 | Invalid message | 订阅到的数据非法,一般不会出现 | 具体查看client端的错误日志提示 |
|
| 0x80004000 | Invalid message | 订阅到的数据非法,一般不会出现 | 具体查看client端的错误日志提示 |
|
||||||
| 0x80004001 | Consumer mismatch | 订阅请求的vnode和重新分配的vnode不一致,一般存在于有新消费者加入相同消费者组里时 | 内部错误,不暴露给用户 |
|
| 0x80004001 | Consumer mismatch | 订阅请求的vnode和重新分配的vnode不一致,一般存在于有新消费者加入相同消费者组里时 | 内部错误,不暴露给用户 |
|
||||||
| 0x80004002 | Consumer closed | 消费者已经不存在了 | 查看是否已经close掉了 |
|
| 0x80004002 | Consumer closed | 消费者已经不存在了 | 查看是否已经close掉了 |
|
||||||
| 0x80004017 | Invalid status, please subscribe topic first | 数据订阅状态不对 | 没有调用 subscribe,直接poll数据 |
|
| 0x80004017 | Invalid status, please subscribe topic first | 数据订阅状态不对 | 没有调用 subscribe,直接 poll 数据 |
|
||||||
| 0x80004100 | Stream task not exist | 流计算任务不存在 | 具体查看server端的错误日志 |
|
| 0x80004100 | Stream task not exist | 流计算任务不存在 | 具体查看server端的错误日志 |
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ TDengine 会为 WAL 文件自动创建索引以支持快速随机访问。通过
|
||||||
|
|
||||||
### 消费者
|
### 消费者
|
||||||
|
|
||||||
消费者负责从主题中获取数据。在订阅主题之后,消费者可以消费分配给该消费者的 vnode 中的所有数据。为了实现高效、有序的数据获取,消费者采用了推拉(push 和poll)相结合的方式。
|
消费者负责从主题中获取数据。在订阅主题之后,消费者可以消费分配给该消费者的 vnode 中的所有数据。为了实现高效、有序的数据获取,消费者采用了推拉(push 和 poll)相结合的方式。
|
||||||
|
|
||||||
当 vnode 中存在大量未被消费的数据时,消费者会按照顺序向 vnode 发送推送请求,以便一次性拉取大量数据。同时,消费者会在本地记录每个 vnode 的消费位置,确保所有数据都能被顺序地推送。
|
当 vnode 中存在大量未被消费的数据时,消费者会按照顺序向 vnode 发送推送请求,以便一次性拉取大量数据。同时,消费者会在本地记录每个 vnode 的消费位置,确保所有数据都能被顺序地推送。
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
||||||
#define TSDB_INS_DISK_USAGE "ins_disk_usage"
|
#define TSDB_INS_DISK_USAGE "ins_disk_usage"
|
||||||
#define TSDB_INS_TABLE_FILESETS "ins_filesets"
|
#define TSDB_INS_TABLE_FILESETS "ins_filesets"
|
||||||
|
#define TSDB_INS_TABLE_TRANSACTION_DETAILS "ins_transaction_details"
|
||||||
|
|
||||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||||
|
|
|
@ -160,6 +160,7 @@ typedef enum EStreamType {
|
||||||
STREAM_PARTITION_DELETE_DATA,
|
STREAM_PARTITION_DELETE_DATA,
|
||||||
STREAM_GET_RESULT,
|
STREAM_GET_RESULT,
|
||||||
STREAM_DROP_CHILD_TABLE,
|
STREAM_DROP_CHILD_TABLE,
|
||||||
|
STREAM_NOTIFY_EVENT,
|
||||||
} EStreamType;
|
} EStreamType;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
@ -408,6 +409,9 @@ typedef struct STUidTagInfo {
|
||||||
#define UD_GROUPID_COLUMN_INDEX 1
|
#define UD_GROUPID_COLUMN_INDEX 1
|
||||||
#define UD_TAG_COLUMN_INDEX 2
|
#define UD_TAG_COLUMN_INDEX 2
|
||||||
|
|
||||||
|
// stream notify event block column
|
||||||
|
#define NOTIFY_EVENT_STR_COLUMN_INDEX 0
|
||||||
|
|
||||||
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
|
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
|
||||||
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol);
|
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol);
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,8 @@ bool isAutoTableName(char* ctbName);
|
||||||
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap);
|
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap);
|
||||||
int32_t buildCtbNameByGroupId(const char* stbName, uint64_t groupId, char** pName);
|
int32_t buildCtbNameByGroupId(const char* stbName, uint64_t groupId, char** pName);
|
||||||
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||||
|
int32_t buildSinkDestTableName(char* parTbName, const char* stbFullName, uint64_t gid, bool newSubTableRule,
|
||||||
|
char** dstTableName);
|
||||||
|
|
||||||
int32_t trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
int32_t trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_ANODE_FULL,
|
TSDB_MGMT_TABLE_ANODE_FULL,
|
||||||
TSDB_MGMT_TABLE_USAGE,
|
TSDB_MGMT_TABLE_USAGE,
|
||||||
TSDB_MGMT_TABLE_FILESETS,
|
TSDB_MGMT_TABLE_FILESETS,
|
||||||
|
TSDB_MGMT_TABLE_TRANSACTION_DETAIL,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
|
||||||
|
@ -268,6 +269,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_TSMA_OPTIONS,
|
QUERY_NODE_TSMA_OPTIONS,
|
||||||
QUERY_NODE_ANOMALY_WINDOW,
|
QUERY_NODE_ANOMALY_WINDOW,
|
||||||
QUERY_NODE_RANGE_AROUND,
|
QUERY_NODE_RANGE_AROUND,
|
||||||
|
QUERY_NODE_STREAM_NOTIFY_OPTIONS,
|
||||||
|
|
||||||
// Statement nodes are used in parser and planner module.
|
// Statement nodes are used in parser and planner module.
|
||||||
QUERY_NODE_SET_OPERATOR = 100,
|
QUERY_NODE_SET_OPERATOR = 100,
|
||||||
|
@ -405,6 +407,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
||||||
QUERY_NODE_DROP_TSMA_STMT,
|
QUERY_NODE_DROP_TSMA_STMT,
|
||||||
QUERY_NODE_SHOW_FILESETS_STMT,
|
QUERY_NODE_SHOW_FILESETS_STMT,
|
||||||
|
QUERY_NODE_SHOW_TRANSACTION_DETAILS_STMT,
|
||||||
|
|
||||||
// logic plan node
|
// logic plan node
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||||
|
@ -480,6 +483,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_ANOMALY,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_ANOMALY,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC,
|
QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERP_FUNC,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERP_FUNC,
|
||||||
|
QUERY_NODE_RESET_STREAM_STMT,
|
||||||
} ENodeType;
|
} ENodeType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -2608,6 +2612,8 @@ typedef struct {
|
||||||
int8_t assignedAcked;
|
int8_t assignedAcked;
|
||||||
SMArbUpdateGroupAssigned assignedLeader;
|
SMArbUpdateGroupAssigned assignedLeader;
|
||||||
int64_t version;
|
int64_t version;
|
||||||
|
int32_t code;
|
||||||
|
int64_t updateTimeMs;
|
||||||
} SMArbUpdateGroup;
|
} SMArbUpdateGroup;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -2953,6 +2959,11 @@ typedef struct {
|
||||||
// 3.3.0.0
|
// 3.3.0.0
|
||||||
SArray* pCols; // array of SField
|
SArray* pCols; // array of SField
|
||||||
int64_t smaId;
|
int64_t smaId;
|
||||||
|
// 3.3.6.0
|
||||||
|
SArray* pNotifyAddrUrls;
|
||||||
|
int32_t notifyEventTypes;
|
||||||
|
int32_t notifyErrorHandle;
|
||||||
|
int8_t notifyHistory;
|
||||||
} SCMCreateStreamReq;
|
} SCMCreateStreamReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -3913,6 +3924,15 @@ typedef struct {
|
||||||
int32_t tSerializeSMResumeStreamReq(void* buf, int32_t bufLen, const SMResumeStreamReq* pReq);
|
int32_t tSerializeSMResumeStreamReq(void* buf, int32_t bufLen, const SMResumeStreamReq* pReq);
|
||||||
int32_t tDeserializeSMResumeStreamReq(void* buf, int32_t bufLen, SMResumeStreamReq* pReq);
|
int32_t tDeserializeSMResumeStreamReq(void* buf, int32_t bufLen, SMResumeStreamReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
|
int8_t igNotExists;
|
||||||
|
int8_t igUntreated;
|
||||||
|
} SMResetStreamReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMResetStreamReq(void* buf, int32_t bufLen, const SMResetStreamReq* pReq);
|
||||||
|
int32_t tDeserializeSMResetStreamReq(void* buf, int32_t bufLen, SMResetStreamReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
char stb[TSDB_TABLE_FNAME_LEN];
|
char stb[TSDB_TABLE_FNAME_LEN];
|
||||||
|
|
|
@ -262,6 +262,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_AUDIT, "audit", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_AUDIT, "audit", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG, "init-config", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG, "init-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_SDB, "config-sdb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_SDB, "config-sdb", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_RESET_STREAM, "reset-stream", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
||||||
|
|
|
@ -98,6 +98,9 @@ int32_t qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId);
|
||||||
|
|
||||||
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo);
|
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo);
|
||||||
|
|
||||||
|
int32_t qSetStreamNotifyInfo(qTaskInfo_t tinfo, int32_t eventTypes, const SSchemaWrapper* pSchemaWrapper,
|
||||||
|
const char* stbFullName, bool newSubTableRule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set multiple input data blocks for the stream scan.
|
* Set multiple input data blocks for the stream scan.
|
||||||
* @param tinfo
|
* @param tinfo
|
||||||
|
|
|
@ -440,6 +440,11 @@ typedef struct SShowCompactDetailsStmt {
|
||||||
SNode* pCompactId;
|
SNode* pCompactId;
|
||||||
} SShowCompactDetailsStmt;
|
} SShowCompactDetailsStmt;
|
||||||
|
|
||||||
|
typedef struct SShowTransactionDetailsStmt {
|
||||||
|
ENodeType type;
|
||||||
|
SNode* pTransactionId;
|
||||||
|
} SShowTransactionDetailsStmt;
|
||||||
|
|
||||||
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
|
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
|
||||||
|
|
||||||
typedef struct SIndexOptions {
|
typedef struct SIndexOptions {
|
||||||
|
@ -562,19 +567,44 @@ typedef struct SStreamOptions {
|
||||||
int64_t setFlag;
|
int64_t setFlag;
|
||||||
} SStreamOptions;
|
} SStreamOptions;
|
||||||
|
|
||||||
|
typedef enum EStreamNotifyOptionSetFlag {
|
||||||
|
SNOTIFY_OPT_ERROR_HANDLE_SET = BIT_FLAG_MASK(0),
|
||||||
|
SNOTIFY_OPT_NOTIFY_HISTORY_SET = BIT_FLAG_MASK(1),
|
||||||
|
} EStreamNotifyOptionSetFlag;
|
||||||
|
|
||||||
|
typedef enum EStreamNotifyEventType {
|
||||||
|
SNOTIFY_EVENT_WINDOW_OPEN = BIT_FLAG_MASK(0),
|
||||||
|
SNOTIFY_EVENT_WINDOW_CLOSE = BIT_FLAG_MASK(1),
|
||||||
|
} EStreamNotifyEventType;
|
||||||
|
|
||||||
|
typedef enum EStreamNotifyErrorHandleType {
|
||||||
|
SNOTIFY_ERROR_HANDLE_PAUSE,
|
||||||
|
SNOTIFY_ERROR_HANDLE_DROP,
|
||||||
|
} EStreamNotifyErrorHandleType;
|
||||||
|
|
||||||
|
typedef struct SStreamNotifyOptions {
|
||||||
|
ENodeType type;
|
||||||
|
SNodeList* pAddrUrls;
|
||||||
|
EStreamNotifyEventType eventTypes;
|
||||||
|
EStreamNotifyErrorHandleType errorHandle;
|
||||||
|
bool notifyHistory;
|
||||||
|
EStreamNotifyOptionSetFlag setFlag;
|
||||||
|
} SStreamNotifyOptions;
|
||||||
|
|
||||||
typedef struct SCreateStreamStmt {
|
typedef struct SCreateStreamStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char streamName[TSDB_TABLE_NAME_LEN];
|
char streamName[TSDB_TABLE_NAME_LEN];
|
||||||
char targetDbName[TSDB_DB_NAME_LEN];
|
char targetDbName[TSDB_DB_NAME_LEN];
|
||||||
char targetTabName[TSDB_TABLE_NAME_LEN];
|
char targetTabName[TSDB_TABLE_NAME_LEN];
|
||||||
bool ignoreExists;
|
bool ignoreExists;
|
||||||
SStreamOptions* pOptions;
|
SStreamOptions* pOptions;
|
||||||
SNode* pQuery;
|
SNode* pQuery;
|
||||||
SNode* pPrevQuery;
|
SNode* pPrevQuery;
|
||||||
SNodeList* pTags;
|
SNodeList* pTags;
|
||||||
SNode* pSubtable;
|
SNode* pSubtable;
|
||||||
SNodeList* pCols;
|
SNodeList* pCols;
|
||||||
SCMCreateStreamReq* pReq;
|
SStreamNotifyOptions* pNotifyOptions;
|
||||||
|
SCMCreateStreamReq* pReq;
|
||||||
} SCreateStreamStmt;
|
} SCreateStreamStmt;
|
||||||
|
|
||||||
typedef struct SDropStreamStmt {
|
typedef struct SDropStreamStmt {
|
||||||
|
@ -596,6 +626,12 @@ typedef struct SResumeStreamStmt {
|
||||||
bool ignoreUntreated;
|
bool ignoreUntreated;
|
||||||
} SResumeStreamStmt;
|
} SResumeStreamStmt;
|
||||||
|
|
||||||
|
typedef struct SResetStreamStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char streamName[TSDB_TABLE_NAME_LEN];
|
||||||
|
bool ignoreNotExists;
|
||||||
|
} SResetStreamStmt;
|
||||||
|
|
||||||
typedef struct SCreateFunctionStmt {
|
typedef struct SCreateFunctionStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
bool orReplace;
|
bool orReplace;
|
||||||
|
|
|
@ -420,7 +420,7 @@ typedef struct SWindowOffsetNode {
|
||||||
|
|
||||||
typedef struct SRangeAroundNode {
|
typedef struct SRangeAroundNode {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SNode* pTimepoint;
|
SNode* pRange;
|
||||||
SNode* pInterval;
|
SNode* pInterval;
|
||||||
} SRangeAroundNode;
|
} SRangeAroundNode;
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,14 @@ typedef struct SStreamTaskSM SStreamTaskSM;
|
||||||
typedef struct SStreamQueueItem SStreamQueueItem;
|
typedef struct SStreamQueueItem SStreamQueueItem;
|
||||||
typedef struct SActiveCheckpointInfo SActiveCheckpointInfo;
|
typedef struct SActiveCheckpointInfo SActiveCheckpointInfo;
|
||||||
|
|
||||||
#define SSTREAM_TASK_VER 4
|
#define SSTREAM_TASK_VER 5
|
||||||
#define SSTREAM_TASK_INCOMPATIBLE_VER 1
|
#define SSTREAM_TASK_INCOMPATIBLE_VER 1
|
||||||
#define SSTREAM_TASK_NEED_CONVERT_VER 2
|
#define SSTREAM_TASK_NEED_CONVERT_VER 2
|
||||||
#define SSTREAM_TASK_SUBTABLE_CHANGED_VER 3
|
#define SSTREAM_TASK_SUBTABLE_CHANGED_VER 3 // Append subtable name with groupId
|
||||||
|
#define SSTREAM_TASK_APPEND_STABLE_NAME_VER 4 // Append subtable name with stableName and groupId
|
||||||
|
#define SSTREAM_TASK_ADD_NOTIFY_VER 5 // Support event notification at window open/close
|
||||||
|
|
||||||
|
#define IS_NEW_SUBTB_RULE(_t) (((_t)->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER) && ((_t)->subtableWithoutMd5 != 1))
|
||||||
|
|
||||||
extern int32_t streamMetaRefPool;
|
extern int32_t streamMetaRefPool;
|
||||||
extern int32_t streamTaskRefPool;
|
extern int32_t streamTaskRefPool;
|
||||||
|
@ -427,6 +431,15 @@ typedef struct STaskCheckInfo {
|
||||||
TdThreadMutex checkInfoLock;
|
TdThreadMutex checkInfoLock;
|
||||||
} STaskCheckInfo;
|
} STaskCheckInfo;
|
||||||
|
|
||||||
|
typedef struct SNotifyInfo {
|
||||||
|
SArray* pNotifyAddrUrls;
|
||||||
|
int32_t notifyEventTypes;
|
||||||
|
int32_t notifyErrorHandle;
|
||||||
|
char* streamName;
|
||||||
|
char* stbFullName;
|
||||||
|
SSchemaWrapper* pSchemaWrapper;
|
||||||
|
} SNotifyInfo;
|
||||||
|
|
||||||
struct SStreamTask {
|
struct SStreamTask {
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
SStreamTaskId id;
|
SStreamTaskId id;
|
||||||
|
@ -449,6 +462,7 @@ struct SStreamTask {
|
||||||
SStreamState* pState; // state backend
|
SStreamState* pState; // state backend
|
||||||
SUpstreamInfo upstreamInfo;
|
SUpstreamInfo upstreamInfo;
|
||||||
STaskCheckInfo taskCheckInfo;
|
STaskCheckInfo taskCheckInfo;
|
||||||
|
SNotifyInfo notifyInfo;
|
||||||
|
|
||||||
// the followings attributes don't be serialized
|
// the followings attributes don't be serialized
|
||||||
SScanhistorySchedInfo schedHistoryInfo;
|
SScanhistorySchedInfo schedHistoryInfo;
|
||||||
|
|
|
@ -294,7 +294,7 @@ int32_t syncUpdateArbTerm(int64_t rid, SyncTerm arbTerm);
|
||||||
|
|
||||||
SSyncState syncGetState(int64_t rid);
|
SSyncState syncGetState(int64_t rid);
|
||||||
int32_t syncGetArbToken(int64_t rid, char* outToken);
|
int32_t syncGetArbToken(int64_t rid, char* outToken);
|
||||||
int32_t syncGetAssignedLogSynced(int64_t rid);
|
int32_t syncCheckSynced(int64_t rid);
|
||||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
const char* syncStr(ESyncState state);
|
const char* syncStr(ESyncState state);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,9 @@ int32_t tfsGetLevel(STfs *pTfs);
|
||||||
* @param pDiskId The disk ID after allocation.
|
* @param pDiskId The disk ID after allocation.
|
||||||
* @return int32_t 0 for success, -1 for failure.
|
* @return int32_t 0 for success, -1 for failure.
|
||||||
*/
|
*/
|
||||||
int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, SDiskID *pDiskId);
|
int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, const char *label, SDiskID *pDiskId);
|
||||||
|
|
||||||
|
int32_t tfsAllocDiskAtLevel(STfs *pTfs, int32_t level, const char *label, SDiskID *pDiskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the primary path.
|
* @brief Get the primary path.
|
||||||
|
|
|
@ -412,6 +412,7 @@ int32_t taosGetErrSize();
|
||||||
#define TSDB_CODE_MND_TRANS_CTX_SWITCH TAOS_DEF_ERROR_CODE(0, 0x03D8)
|
#define TSDB_CODE_MND_TRANS_CTX_SWITCH TAOS_DEF_ERROR_CODE(0, 0x03D8)
|
||||||
#define TSDB_CODE_MND_TRANS_CONFLICT_COMPACT TAOS_DEF_ERROR_CODE(0, 0x03D9)
|
#define TSDB_CODE_MND_TRANS_CONFLICT_COMPACT TAOS_DEF_ERROR_CODE(0, 0x03D9)
|
||||||
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF)
|
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF)
|
||||||
|
#define TSDB_CODE_MND_TRANS_NOT_ABLE_TO_kILLED TAOS_DEF_ERROR_CODE(0, 0x03D2)
|
||||||
|
|
||||||
// mnode-mq
|
// mnode-mq
|
||||||
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
|
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
|
||||||
|
|
|
@ -160,8 +160,6 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl
|
||||||
SArray *taosGetLocalCfg(SConfig *pCfg);
|
SArray *taosGetLocalCfg(SConfig *pCfg);
|
||||||
SArray *taosGetGlobalCfg(SConfig *pCfg);
|
SArray *taosGetGlobalCfg(SConfig *pCfg);
|
||||||
|
|
||||||
void taosSetLocalCfg(SConfig *pCfg, SArray *pArray);
|
|
||||||
void taosSetGlobalCfg(SConfig *pCfg, SArray *pArray);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -238,6 +238,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_OFFSET_LEN 64 // it is a null-terminated string
|
#define TSDB_OFFSET_LEN 64 // it is a null-terminated string
|
||||||
#define TSDB_USER_CGROUP_LEN (TSDB_USER_LEN + TSDB_CGROUP_LEN) // it is a null-terminated string
|
#define TSDB_USER_CGROUP_LEN (TSDB_USER_LEN + TSDB_CGROUP_LEN) // it is a null-terminated string
|
||||||
#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string
|
#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string
|
||||||
|
#define TSDB_STREAM_NOTIFY_URL_LEN 128 // it includes the terminating '\0'
|
||||||
#define TSDB_DB_NAME_LEN 65
|
#define TSDB_DB_NAME_LEN 65
|
||||||
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
|
||||||
#define TSDB_PRIVILEDGE_CONDITION_LEN 48 * 1024
|
#define TSDB_PRIVILEDGE_CONDITION_LEN 48 * 1024
|
||||||
|
@ -322,7 +323,11 @@ typedef enum ELogicConditionType {
|
||||||
|
|
||||||
#define TSDB_TRANS_STAGE_LEN 12
|
#define TSDB_TRANS_STAGE_LEN 12
|
||||||
#define TSDB_TRANS_TYPE_LEN 16
|
#define TSDB_TRANS_TYPE_LEN 16
|
||||||
#define TSDB_TRANS_ERROR_LEN 512
|
#define TSDB_TRANS_ERROR_LEN 512
|
||||||
|
#define TSDB_TRANS_OBJTYPE_LEN 40
|
||||||
|
#define TSDB_TRANS_RESULT_LEN 100
|
||||||
|
#define TSDB_TRANS_TARGET_LEN 300
|
||||||
|
#define TSDB_TRANS_DETAIL_LEN 100
|
||||||
|
|
||||||
#define TSDB_STEP_NAME_LEN 32
|
#define TSDB_STEP_NAME_LEN 32
|
||||||
#define TSDB_STEP_DESC_LEN 128
|
#define TSDB_STEP_DESC_LEN 128
|
||||||
|
|
|
@ -79,6 +79,9 @@ void taosResetLog();
|
||||||
void taosDumpData(uint8_t *msg, int32_t len);
|
void taosDumpData(uint8_t *msg, int32_t len);
|
||||||
void taosSetNoNewFile();
|
void taosSetNoNewFile();
|
||||||
|
|
||||||
|
// Fast uint64_t to string conversion, equivalent to sprintf(buf, "%lu", val) but with 10x better performance.
|
||||||
|
char *u64toaFastLut(uint64_t val, char *buf);
|
||||||
|
|
||||||
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...)
|
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...)
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__attribute__((format(printf, 4, 5)))
|
__attribute__((format(printf, 4, 5)))
|
||||||
|
|
|
@ -187,6 +187,15 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define TAOS_CHECK_RETURN_SET_CODE(CMD, CODE, ERRNO) \
|
||||||
|
do { \
|
||||||
|
int32_t __c = (CMD); \
|
||||||
|
if (__c != TSDB_CODE_SUCCESS) { \
|
||||||
|
(CODE) = (ERRNO); \
|
||||||
|
TAOS_RETURN(__c); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAOS_CHECK_RETURN_WITH_RELEASE(CMD, PTR1, PTR2) \
|
#define TAOS_CHECK_RETURN_WITH_RELEASE(CMD, PTR1, PTR2) \
|
||||||
do { \
|
do { \
|
||||||
int32_t __c = (CMD); \
|
int32_t __c = (CMD); \
|
||||||
|
@ -225,6 +234,16 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define TAOS_CHECK_EXIT_SET_CODE(CMD, CODE, ERRNO) \
|
||||||
|
do { \
|
||||||
|
code = (CMD); \
|
||||||
|
if (code < TSDB_CODE_SUCCESS) { \
|
||||||
|
(CODE) = (ERRNO); \
|
||||||
|
lino = __LINE__; \
|
||||||
|
goto _exit; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TAOS_UNUSED(expr) (void)(expr)
|
#define TAOS_UNUSED(expr) (void)(expr)
|
||||||
|
|
||||||
bool taosIsBigChar(char c);
|
bool taosIsBigChar(char c);
|
||||||
|
|
|
@ -364,6 +364,9 @@ static int32_t stmtCleanExecInfo(STscStmt2* pStmt, bool keepTable, bool deepClea
|
||||||
pStmt->sql.siInfo.pTableColsIdx = 0;
|
pStmt->sql.siInfo.pTableColsIdx = 0;
|
||||||
stmtResetQueueTableBuf(&pStmt->sql.siInfo.tbBuf, &pStmt->queue);
|
stmtResetQueueTableBuf(&pStmt->sql.siInfo.tbBuf, &pStmt->queue);
|
||||||
}
|
}
|
||||||
|
if (NULL != pStmt->exec.pRequest) {
|
||||||
|
pStmt->exec.pRequest->body.resInfo.numOfRows = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (STMT_TYPE_QUERY != pStmt->sql.type || deepClean) {
|
if (STMT_TYPE_QUERY != pStmt->sql.type || deepClean) {
|
||||||
// if (!pStmt->options.asyncExecFn) {
|
// if (!pStmt->options.asyncExecFn) {
|
||||||
|
|
|
@ -1435,7 +1435,7 @@ static int32_t askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) {
|
||||||
tqDebugC("consumer:0x%" PRIx64 " ask ep from mnode,QID:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId);
|
tqDebugC("consumer:0x%" PRIx64 " ask ep from mnode,QID:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId);
|
||||||
code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo);
|
code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo);
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tqErrorC("%s failed at %d, msg:%s", __func__, lino, tstrerror(code));
|
tqErrorC("%s failed at %d, msg:%s", __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
@ -1645,6 +1645,7 @@ void tmqMgmtClose(void) {
|
||||||
tmqMgmt.rsetId = -1;
|
tmqMgmt.rsetId = -1;
|
||||||
(void)taosThreadMutexUnlock(&tmqMgmt.lock);
|
(void)taosThreadMutexUnlock(&tmqMgmt.lock);
|
||||||
}
|
}
|
||||||
|
(void)taosThreadMutexUnlock(&tmqMgmt.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
|
@ -2266,7 +2267,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
||||||
pVg->seekUpdated = false; // reset this flag.
|
pVg->seekUpdated = false; // reset this flag.
|
||||||
pTmq->pollCnt++;
|
pTmq->pollCnt++;
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (code != 0){
|
if (code != 0){
|
||||||
tqErrorC("%s failed at %d msg:%s", __func__, lino, tstrerror(code));
|
tqErrorC("%s failed at %d msg:%s", __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
@ -2491,7 +2492,7 @@ static SMqRspObj* processMqRsp(tmq_t* tmq, SMqRspWrapper* pRspWrapper){
|
||||||
pRspObj->resType = pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP ? RES_TYPE__TMQ_META : RES_TYPE__TMQ_BATCH_META;
|
pRspObj->resType = pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP ? RES_TYPE__TMQ_META : RES_TYPE__TMQ_BATCH_META;
|
||||||
}
|
}
|
||||||
|
|
||||||
END:
|
END:
|
||||||
terrno = code;
|
terrno = code;
|
||||||
taosWUnLockLatch(&tmq->lock);
|
taosWUnLockLatch(&tmq->lock);
|
||||||
return pRspObj;
|
return pRspObj;
|
||||||
|
@ -2529,7 +2530,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
END:
|
END:
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
@ -2572,7 +2573,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
END:
|
END:
|
||||||
terrno = code;
|
terrno = code;
|
||||||
if (tmq != NULL) {
|
if (tmq != NULL) {
|
||||||
tqErrorC("consumer:0x%" PRIx64 " poll error at line:%d, msg:%s", tmq->consumerId, lino, tstrerror(terrno));
|
tqErrorC("consumer:0x%" PRIx64 " poll error at line:%d, msg:%s", tmq->consumerId, lino, tstrerror(terrno));
|
||||||
|
@ -2641,7 +2642,7 @@ int32_t tmq_unsubscribe(tmq_t* tmq) {
|
||||||
int32_t tmq_consumer_close(tmq_t* tmq) {
|
int32_t tmq_consumer_close(tmq_t* tmq) {
|
||||||
if (tmq == NULL) return TSDB_CODE_INVALID_PARA;
|
if (tmq == NULL) return TSDB_CODE_INVALID_PARA;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
code = taosThreadMutexLock(&tmqMgmt.lock);
|
(void) taosThreadMutexLock(&tmqMgmt.lock);
|
||||||
if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__CLOSED){
|
if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__CLOSED){
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -2655,8 +2656,8 @@ int32_t tmq_consumer_close(tmq_t* tmq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
code = taosThreadMutexUnlock(&tmqMgmt.lock);
|
(void)taosThreadMutexUnlock(&tmqMgmt.lock);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,14 @@ void checkError(TAOS_STMT2* stmt, int code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct AsyncArgs {
|
||||||
|
int async_affected_rows;
|
||||||
|
tsem_t sem;
|
||||||
|
} AsyncArgs;
|
||||||
|
|
||||||
void stmtAsyncQueryCb(void* param, TAOS_RES* pRes, int code) {
|
void stmtAsyncQueryCb(void* param, TAOS_RES* pRes, int code) {
|
||||||
int affected_rows = taos_affected_rows(pRes);
|
((AsyncArgs*)param)->async_affected_rows = taos_affected_rows(pRes);
|
||||||
|
ASSERT_EQ(tsem_post(&((AsyncArgs*)param)->sem), TSDB_CODE_SUCCESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +205,14 @@ void do_stmt(TAOS* taos, TAOS_STMT2_OPTION* option, const char* sql, int CTB_NUM
|
||||||
// exec
|
// exec
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
code = taos_stmt2_exec(stmt, &affected);
|
code = taos_stmt2_exec(stmt, &affected);
|
||||||
total_affected += affected;
|
if (option->asyncExecFn == NULL) {
|
||||||
|
total_affected += affected;
|
||||||
|
} else {
|
||||||
|
AsyncArgs* params = (AsyncArgs*)option->userdata;
|
||||||
|
code = tsem_wait(¶ms->sem);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
total_affected += params->async_affected_rows;
|
||||||
|
}
|
||||||
checkError(stmt, code);
|
checkError(stmt, code);
|
||||||
|
|
||||||
for (int i = 0; i < CTB_NUMS; i++) {
|
for (int i = 0; i < CTB_NUMS; i++) {
|
||||||
|
@ -219,9 +232,7 @@ void do_stmt(TAOS* taos, TAOS_STMT2_OPTION* option, const char* sql, int CTB_NUM
|
||||||
taosMemoryFree(tags);
|
taosMemoryFree(tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (option->asyncExecFn == NULL) {
|
ASSERT_EQ(total_affected, CYC_NUMS * ROW_NUMS * CTB_NUMS);
|
||||||
ASSERT_EQ(total_affected, CYC_NUMS * ROW_NUMS * CTB_NUMS);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < CTB_NUMS; i++) {
|
for (int i = 0; i < CTB_NUMS; i++) {
|
||||||
taosMemoryFree(tbs[i]);
|
taosMemoryFree(tbs[i]);
|
||||||
}
|
}
|
||||||
|
@ -908,7 +919,11 @@ TEST(stmt2Case, stmt2_stb_insert) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// async
|
// async
|
||||||
option = {0, true, true, stmtAsyncQueryCb, NULL};
|
AsyncArgs* aa = (AsyncArgs*)taosMemMalloc(sizeof(AsyncArgs));
|
||||||
|
aa->async_affected_rows = 0;
|
||||||
|
ASSERT_EQ(tsem_init(&aa->sem, 0, 0), TSDB_CODE_SUCCESS);
|
||||||
|
void* param = aa;
|
||||||
|
option = {0, true, true, stmtAsyncQueryCb, param};
|
||||||
{
|
{
|
||||||
do_stmt(taos, &option, "insert into stmt2_testdb_1.stb (ts,b,tbname,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true, true);
|
do_stmt(taos, &option, "insert into stmt2_testdb_1.stb (ts,b,tbname,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true, true);
|
||||||
}
|
}
|
||||||
|
@ -926,12 +941,14 @@ TEST(stmt2Case, stmt2_stb_insert) {
|
||||||
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||||
|
|
||||||
// interlace = 1
|
// interlace = 1
|
||||||
option = {0, true, true, stmtAsyncQueryCb, NULL};
|
option = {0, true, true, stmtAsyncQueryCb, param};
|
||||||
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||||
option = {0, true, true, NULL, NULL};
|
option = {0, true, true, NULL, NULL};
|
||||||
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||||
|
|
||||||
do_query(taos, "drop database if exists stmt2_testdb_1");
|
do_query(taos, "drop database if exists stmt2_testdb_1");
|
||||||
|
(void)tsem_destroy(&aa->sem);
|
||||||
|
taosMemFree(aa);
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ if(${BUILD_S3})
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||||
set(CMAKE_PREFIX_PATH $ENV{HOME}/.cos-local.2)
|
set(CMAKE_PREFIX_PATH $ENV{HOME}/.cos-local.2)
|
||||||
find_library(S3_LIBRARY s3)
|
find_library(S3_LIBRARY s3)
|
||||||
find_library(XML2_LIBRARY xml2)
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
common
|
common
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ if(${BUILD_S3})
|
||||||
PUBLIC ${CURL_LIBRARY}
|
PUBLIC ${CURL_LIBRARY}
|
||||||
PUBLIC ${SSL_LIBRARY}
|
PUBLIC ${SSL_LIBRARY}
|
||||||
PUBLIC ${CRYPTO_LIBRARY}
|
PUBLIC ${CRYPTO_LIBRARY}
|
||||||
PUBLIC ${XML2_LIBRARY}
|
PUBLIC _libxml2
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DUSE_S3)
|
add_definitions(-DUSE_S3)
|
||||||
|
@ -103,7 +102,6 @@ if(${BUILD_S3})
|
||||||
find_library(APR_LIBRARY apr-1 PATHS /usr/local/apr/lib/)
|
find_library(APR_LIBRARY apr-1 PATHS /usr/local/apr/lib/)
|
||||||
find_library(APR_UTIL_LIBRARY aprutil-1 PATHS /usr/local/apr/lib/)
|
find_library(APR_UTIL_LIBRARY aprutil-1 PATHS /usr/local/apr/lib/)
|
||||||
find_library(MINIXML_LIBRARY mxml)
|
find_library(MINIXML_LIBRARY mxml)
|
||||||
find_library(CURL_LIBRARY curl)
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
common
|
common
|
||||||
|
|
||||||
|
|
|
@ -8302,6 +8302,12 @@ int32_t tSerializeSMArbUpdateGroupBatchReq(void *buf, int32_t bufLen, SMArbUpdat
|
||||||
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pGroup->assignedLeader.acked));
|
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pGroup->assignedLeader.acked));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SMArbUpdateGroup *pGroup = taosArrayGet(pReq->updateArray, i);
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pGroup->code));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pGroup->updateTimeMs));
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -8361,6 +8367,14 @@ int32_t tDeserializeSMArbUpdateGroupBatchReq(void *buf, int32_t bufLen, SMArbUpd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SMArbUpdateGroup *pGroup = taosArrayGet(updateArray, i);
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pGroup->code));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pGroup->updateTimeMs));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pReq->updateArray = updateArray;
|
pReq->updateArray = updateArray;
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
@ -9959,6 +9973,16 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->smaId));
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->smaId));
|
||||||
|
|
||||||
|
int32_t addrSize = taosArrayGetSize(pReq->pNotifyAddrUrls);
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, addrSize));
|
||||||
|
for (int32_t i = 0; i < addrSize; ++i) {
|
||||||
|
const char *url = taosArrayGetP(pReq->pNotifyAddrUrls, i);
|
||||||
|
TAOS_CHECK_EXIT((tEncodeCStr(&encoder, url)));
|
||||||
|
}
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->notifyEventTypes));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->notifyErrorHandle));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->notifyHistory));
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -10093,6 +10117,30 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->smaId));
|
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->smaId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
int32_t addrSize = 0;
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &addrSize));
|
||||||
|
pReq->pNotifyAddrUrls = taosArrayInit(addrSize, POINTER_BYTES);
|
||||||
|
if (pReq->pNotifyAddrUrls == NULL) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < addrSize; ++i) {
|
||||||
|
char *url = NULL;
|
||||||
|
TAOS_CHECK_EXIT(tDecodeCStr(&decoder, &url));
|
||||||
|
url = taosStrndup(url, TSDB_STREAM_NOTIFY_URL_LEN);
|
||||||
|
if (url == NULL) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
|
if (taosArrayPush(pReq->pNotifyAddrUrls, &url) == NULL) {
|
||||||
|
taosMemoryFree(url);
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->notifyEventTypes));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->notifyErrorHandle));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->notifyHistory));
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
_exit:
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -10155,6 +10203,7 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
|
||||||
taosArrayDestroy(pReq->fillNullCols);
|
taosArrayDestroy(pReq->fillNullCols);
|
||||||
taosArrayDestroy(pReq->pVgroupVerList);
|
taosArrayDestroy(pReq->pVgroupVerList);
|
||||||
taosArrayDestroy(pReq->pCols);
|
taosArrayDestroy(pReq->pCols);
|
||||||
|
taosArrayDestroyP(pReq->pNotifyAddrUrls, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) {
|
int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) {
|
||||||
|
@ -12017,6 +12066,43 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMResetStreamReq(void *buf, int32_t bufLen, const SMResetStreamReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->name));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igNotExists));
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMResetStreamReq(void *buf, int32_t bufLen, SMResetStreamReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->name));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->igNotExists));
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tEncodeMqSubTopicEp(void **buf, const SMqSubTopicEp *pTopicEp) {
|
int32_t tEncodeMqSubTopicEp(void **buf, const SMqSubTopicEp *pTopicEp) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
tlen += taosEncodeString(buf, pTopicEp->topic);
|
tlen += taosEncodeString(buf, pTopicEp->topic);
|
||||||
|
|
|
@ -73,7 +73,8 @@ static const SSysDbTableSchema arbGroupsSchema[] = {
|
||||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
{.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "is_sync", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "is_sync", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true},
|
||||||
|
{.name = "check_sync_code", .bytes = 100, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "assigned_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "assigned_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
{.name = "assigned_token", .bytes = TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "assigned_token", .bytes = TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "assigned_acked", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
{.name = "assigned_acked", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
|
||||||
|
@ -317,6 +318,8 @@ static const SSysDbTableSchema transSchema[] = {
|
||||||
{.name = "oper", .bytes = TSDB_TRANS_OPER_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "oper", .bytes = TSDB_TRANS_OPER_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "stable", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
{.name = "stable", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
{.name = "killable", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
//{.name = "kill_mnode", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||||
{.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
@ -406,6 +409,15 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
||||||
{.name = "remain_time(s)", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
{.name = "remain_time(s)", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema userTransactionDetailSchema[] = {
|
||||||
|
{.name = "transaction_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
|
{.name = "action", .bytes = 30 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
{.name = "obj_type", .bytes = TSDB_TRANS_OBJTYPE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
{.name = "result", .bytes = TSDB_TRANS_RESULT_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
{.name = "target", .bytes = TSDB_TRANS_TARGET_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
{.name = "detail", .bytes = TSDB_TRANS_DETAIL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||||
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema anodesSchema[] = {
|
static const SSysDbTableSchema anodesSchema[] = {
|
||||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||||
{.name = "url", .bytes = TSDB_ANALYTIC_ANODE_URL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "url", .bytes = TSDB_ANALYTIC_ANODE_URL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
@ -524,6 +536,7 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
|
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
|
||||||
{TSDB_INS_DISK_USAGE, diskUsageSchema, tListLen(diskUsageSchema), false},
|
{TSDB_INS_DISK_USAGE, diskUsageSchema, tListLen(diskUsageSchema), false},
|
||||||
{TSDB_INS_TABLE_FILESETS, filesetsFullSchema, tListLen(filesetsFullSchema), false},
|
{TSDB_INS_TABLE_FILESETS, filesetsFullSchema, tListLen(filesetsFullSchema), false},
|
||||||
|
{TSDB_INS_TABLE_TRANSACTION_DETAILS, userTransactionDetailSchema, tListLen(userTransactionDetailSchema), false},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema connectionsSchema[] = {
|
static const SSysDbTableSchema connectionsSchema[] = {
|
||||||
|
|
|
@ -3061,6 +3061,33 @@ int32_t buildCtbNameByGroupIdImpl(const char* stbFullName, uint64_t groupId, cha
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t buildSinkDestTableName(char* parTbName, const char* stbFullName, uint64_t gid, bool newSubTableRule,
|
||||||
|
char** dstTableName) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
if (parTbName[0]) {
|
||||||
|
if (newSubTableRule && !isAutoTableName(parTbName) && !alreadyAddGroupId(parTbName, gid) && gid != 0 &&
|
||||||
|
stbFullName) {
|
||||||
|
*dstTableName = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
||||||
|
TSDB_CHECK_NULL(*dstTableName, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
tstrncpy(*dstTableName, parTbName, TSDB_TABLE_NAME_LEN);
|
||||||
|
code = buildCtbNameAddGroupId(stbFullName, *dstTableName, gid, TSDB_TABLE_NAME_LEN);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
} else {
|
||||||
|
*dstTableName = taosStrdup(parTbName);
|
||||||
|
TSDB_CHECK_NULL(*dstTableName, code, lino, _end, terrno);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = buildCtbNameByGroupId(stbFullName, gid, dstTableName);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
// return length of encoded data, return -1 if failed
|
// return length of encoded data, return -1 if failed
|
||||||
int32_t blockEncode(const SSDataBlock* pBlock, char* data, size_t dataBuflen, int32_t numOfCols) {
|
int32_t blockEncode(const SSDataBlock* pBlock, char* data, size_t dataBuflen, int32_t numOfCols) {
|
||||||
int32_t code = blockDataCheck(pBlock);
|
int32_t code = blockDataCheck(pBlock);
|
||||||
|
|
|
@ -829,7 +829,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
tsLogBufferMemoryAllowed = TRANGE(tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
tsLogBufferMemoryAllowed = TRANGE(tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
TAOS_CHECK_RETURN(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE, CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_SERVER, CFG_CATEGORY_LOCAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, CFG_SCOPE_SERVER, CFG_DYN_NONE, CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, CFG_SCOPE_SERVER, CFG_DYN_NONE, CFG_CATEGORY_LOCAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER, CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER, CFG_CATEGORY_LOCAL));
|
||||||
|
|
||||||
|
@ -862,9 +862,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeStreamThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeStreamThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeWriteThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeWriteThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * RPC_MEMORY_USAGE_RATIO * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * RPC_MEMORY_USAGE_RATIO * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_LOCAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncSnapReplMaxWaitN", tsSnapReplMaxWaitN, 16, (TSDB_SYNC_SNAP_BUFFER_SIZE >> 2), CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncSnapReplMaxWaitN", tsSnapReplMaxWaitN, 16, (TSDB_SYNC_SNAP_BUFFER_SIZE >> 2), CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "syncLogBufferMemoryAllowed", tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_LOCAL));
|
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "syncLogBufferMemoryAllowed", tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_LOCAL));
|
||||||
|
|
||||||
|
@ -915,7 +915,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "compactPullupInterval", tsCompactPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "compactPullupInterval", tsCompactPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "mqRebalanceInterval", tsMqRebalanceInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "mqRebalanceInterval", tsMqRebalanceInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushIntervalSec, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushIntervalSec, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlBatchDropNum", tsTtlBatchDropNum, 0, INT32_MAX, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlBatchDropNum", tsTtlBatchDropNum, 0, INT32_MAX, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "ttlChangeOnWrite", tsTtlChangeOnWrite, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "ttlChangeOnWrite", tsTtlChangeOnWrite, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
|
@ -923,11 +923,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "trimVDbIntervalSec", tsTrimVDbIntervalSec, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "trimVDbIntervalSec", tsTrimVDbIntervalSec, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "s3MigrateIntervalSec", tsS3MigrateIntervalSec, 600, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "s3MigrateIntervalSec", tsS3MigrateIntervalSec, 600, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "s3MigrateEnabled", tsS3MigrateEnabled, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "s3MigrateEnabled", tsS3MigrateEnabled, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "timeseriesThreshold", tsTimeSeriesThreshold, 0, 2000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "timeseriesThreshold", tsTimeSeriesThreshold, 0, 2000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "udf", tsStartUdfd, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "udf", tsStartUdfd, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||||
|
@ -943,9 +943,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "fPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "fPrecision", tsFPrecision, 0.0f, 100000.0f, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
|
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "dPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddFloat(pCfg, "dPrecision", tsDPrecision, 0.0f, 1000000.0f, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "maxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "maxRange", tsMaxRange, 0, 65536, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "curRange", tsCurRange, 0, 65536, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "curRange", tsCurRange, 0, 65536, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "ifAdtFse", tsIfAdtFse, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "ifAdtFse", tsIfAdtFse, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||||
|
@ -1935,7 +1934,7 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *
|
||||||
|
|
||||||
SConfig *pCfg = NULL;
|
SConfig *pCfg = NULL;
|
||||||
TAOS_CHECK_RETURN(cfgInit(&pCfg));
|
TAOS_CHECK_RETURN(cfgInit(&pCfg));
|
||||||
TAOS_CHECK_GOTO(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE, CFG_CATEGORY_LOCAL), &lino,
|
TAOS_CHECK_GOTO(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_SERVER, CFG_CATEGORY_LOCAL), &lino,
|
||||||
_exit);
|
_exit);
|
||||||
TAOS_CHECK_GOTO(
|
TAOS_CHECK_GOTO(
|
||||||
cfgAddInt32(pCfg, "debugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER, CFG_CATEGORY_LOCAL), &lino,
|
cfgAddInt32(pCfg, "debugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER, CFG_CATEGORY_LOCAL), &lino,
|
||||||
|
|
|
@ -681,6 +681,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
if (tDeserializeSRetrieveTableReq(pMsg->pCont, pMsg->contLen, &retrieveReq) != 0) {
|
if (tDeserializeSRetrieveTableReq(pMsg->pCont, pMsg->contLen, &retrieveReq) != 0) {
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
dInfo("retrieve table:%s, user:%s, compactId:%" PRId64, retrieveReq.tb, retrieveReq.user, retrieveReq.compactId);
|
||||||
#if 0
|
#if 0
|
||||||
if (strcmp(retrieveReq.user, TSDB_DEFAULT_USER) != 0) {
|
if (strcmp(retrieveReq.user, TSDB_DEFAULT_USER) != 0) {
|
||||||
code = TSDB_CODE_MND_NO_RIGHTS;
|
code = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
|
|
@ -185,6 +185,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RESET_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_ANAL_ALGO, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_ANAL_ALGO, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -255,14 +255,8 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
pRpc->info.wrapper = pWrapper;
|
pRpc->info.wrapper = pWrapper;
|
||||||
|
|
||||||
EQItype itype = RPC_QITEM; // rsp msg is not restricted by tsQueueMemoryUsed
|
EQItype itype = RPC_QITEM; // rsp msg is not restricted by tsQueueMemoryUsed
|
||||||
if (IsReq(pRpc)) {
|
if (IsReq(pRpc) && pRpc->msgType != TDMT_SYNC_HEARTBEAT && pRpc->msgType != TDMT_SYNC_HEARTBEAT_REPLY)
|
||||||
if (pRpc->msgType == TDMT_SYNC_HEARTBEAT || pRpc->msgType == TDMT_SYNC_HEARTBEAT_REPLY)
|
itype = RPC_QITEM;
|
||||||
itype = DEF_QITEM;
|
|
||||||
else
|
|
||||||
itype = RPC_QITEM;
|
|
||||||
} else {
|
|
||||||
itype = DEF_QITEM;
|
|
||||||
}
|
|
||||||
code = taosAllocateQitem(sizeof(SRpcMsg), itype, pRpc->contLen, (void **)&pMsg);
|
code = taosAllocateQitem(sizeof(SRpcMsg), itype, pRpc->contLen, (void **)&pMsg);
|
||||||
if (code) goto _OVER;
|
if (code) goto _OVER;
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ int32_t mndSetCreateArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||||
int32_t mndSetDropArbGroupPrepareLogs(STrans *pTrans, SArbGroup *pGroup);
|
int32_t mndSetDropArbGroupPrepareLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||||
int32_t mndSetDropArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup);
|
int32_t mndSetDropArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||||
|
|
||||||
bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId,
|
bool mndCheckArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId,
|
||||||
SArbGroup *pNewGroup);
|
SArbGroup *pNewGroup);
|
||||||
bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0Token, char *member1Token,
|
bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0Token, char *member1Token,
|
||||||
bool newIsSync, SArbGroup *pNewGroup);
|
bool newIsSync, SArbGroup *pNewGroup, int32_t code);
|
||||||
bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char *memberToken, int32_t errcode,
|
bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char *memberToken, int32_t errcode,
|
||||||
SArbGroup *pNewGroup);
|
SArbGroup *pNewGroup);
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,12 @@ typedef enum {
|
||||||
TRN_EXEC_SERIAL = 1,
|
TRN_EXEC_SERIAL = 1,
|
||||||
} ETrnExec;
|
} ETrnExec;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TRN_KILL_MODE_SKIP = 0,
|
||||||
|
TRN_KILL_MODE_INTERUPT = 1,
|
||||||
|
//TRN_KILL_MODE_ROLLBACK = 2,
|
||||||
|
} ETrnKillMode;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DND_REASON_ONLINE = 0,
|
DND_REASON_ONLINE = 0,
|
||||||
DND_REASON_STATUS_MSG_TIMEOUT,
|
DND_REASON_STATUS_MSG_TIMEOUT,
|
||||||
|
@ -201,6 +207,8 @@ typedef struct {
|
||||||
SRWLatch lockRpcArray;
|
SRWLatch lockRpcArray;
|
||||||
int64_t mTraceId;
|
int64_t mTraceId;
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
|
bool ableToBeKilled;
|
||||||
|
ETrnKillMode killMode;
|
||||||
} STrans;
|
} STrans;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -308,6 +316,8 @@ typedef struct {
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
SArbGroupMember members[TSDB_ARB_GROUP_MEMBER_NUM];
|
SArbGroupMember members[TSDB_ARB_GROUP_MEMBER_NUM];
|
||||||
int8_t isSync;
|
int8_t isSync;
|
||||||
|
int32_t code;
|
||||||
|
int64_t updateTimeMs;
|
||||||
SArbAssignedLeader assignedLeader;
|
SArbAssignedLeader assignedLeader;
|
||||||
int64_t version;
|
int64_t version;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,8 @@ typedef struct {
|
||||||
SSdbRaw *pRaw;
|
SSdbRaw *pRaw;
|
||||||
|
|
||||||
int64_t mTraceId;
|
int64_t mTraceId;
|
||||||
|
int64_t startTime;
|
||||||
|
int64_t endTime;
|
||||||
} STransAction;
|
} STransAction;
|
||||||
|
|
||||||
typedef void (*TransCbFp)(SMnode *pMnode, void *param, int32_t paramLen);
|
typedef void (*TransCbFp)(SMnode *pMnode, void *param, int32_t paramLen);
|
||||||
|
@ -80,6 +82,8 @@ void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, voi
|
||||||
void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname);
|
void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname);
|
||||||
void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId);
|
void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId);
|
||||||
void mndTransSetSerial(STrans *pTrans);
|
void mndTransSetSerial(STrans *pTrans);
|
||||||
|
void mndTransSetBeKilled(STrans *pTrans, bool ableToBeKilled);
|
||||||
|
void mndTransSetKillMode(STrans *pTrans, ETrnKillMode killMode);
|
||||||
void mndTransSetParallel(STrans *pTrans);
|
void mndTransSetParallel(STrans *pTrans);
|
||||||
void mndTransSetChangeless(STrans *pTrans);
|
void mndTransSetChangeless(STrans *pTrans);
|
||||||
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
|
||||||
#define ARBGROUP_VER_NUMBER 1
|
#define ARBGROUP_VER_NUMBER 1
|
||||||
#define ARBGROUP_RESERVE_SIZE 63
|
#define ARBGROUP_RESERVE_SIZE 51
|
||||||
|
|
||||||
static SHashObj *arbUpdateHash = NULL;
|
static SHashObj *arbUpdateHash = NULL;
|
||||||
|
|
||||||
|
@ -34,9 +34,8 @@ static void mndArbGroupDupObj(SArbGroup *pGroup, SArbGroup *pNew);
|
||||||
static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index);
|
static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index);
|
||||||
static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup);
|
static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup);
|
||||||
|
|
||||||
static int32_t mndArbGroupUpdateTrans(SMnode *pMnode, SArbGroup *pNew);
|
static int32_t mndUpdateArbGroup(SMnode *pMnode, SArbGroup *pNewGroup);
|
||||||
static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup);
|
static int32_t mndBatchUpdateArbGroup(SMnode *pMnode, SArray *newGroupArray);
|
||||||
static int32_t mndPullupArbUpdateGroupBatch(SMnode *pMnode, SArray *newGroupArray);
|
|
||||||
|
|
||||||
static int32_t mndProcessArbHbTimer(SRpcMsg *pReq);
|
static int32_t mndProcessArbHbTimer(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq);
|
static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq);
|
||||||
|
@ -138,6 +137,8 @@ SSdbRaw *mndArbGroupActionEncode(SArbGroup *pGroup) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pLeader->token, TSDB_ARB_TOKEN_SIZE, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pLeader->token, TSDB_ARB_TOKEN_SIZE, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pGroup->version, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pGroup->version, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pLeader->acked, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pLeader->acked, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pGroup->code, _OVER)
|
||||||
|
SDB_SET_INT64(pRaw, dataPos, pGroup->updateTimeMs, _OVER)
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, ARBGROUP_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, ARBGROUP_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
|
@ -194,6 +195,8 @@ SSdbRow *mndArbGroupActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pLeader->token, TSDB_ARB_TOKEN_SIZE, _OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pLeader->token, TSDB_ARB_TOKEN_SIZE, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pGroup->version, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pGroup->version, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pLeader->acked, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pLeader->acked, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pGroup->code, _OVER)
|
||||||
|
SDB_GET_INT64(pRaw, dataPos, &pGroup->updateTimeMs, _OVER)
|
||||||
|
|
||||||
pGroup->mutexInited = false;
|
pGroup->mutexInited = false;
|
||||||
|
|
||||||
|
@ -249,6 +252,8 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p
|
||||||
tstrncpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
||||||
pOld->version++;
|
pOld->version++;
|
||||||
|
pOld->code = pNew->code;
|
||||||
|
pOld->updateTimeMs = pNew->updateTimeMs;
|
||||||
|
|
||||||
mInfo(
|
mInfo(
|
||||||
"arbgroup:%d, perform update action. members[0].token:%s, members[1].token:%s, isSync:%d, as-dnodeid:%d, "
|
"arbgroup:%d, perform update action. members[0].token:%s, members[1].token:%s, isSync:%d, as-dnodeid:%d, "
|
||||||
|
@ -634,6 +639,7 @@ void mndArbCheckSync(SArbGroup *pArbGroup, int64_t nowMs, ECheckSyncOp *pOp, SAr
|
||||||
mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId,
|
mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId,
|
||||||
pMember->info.dnodeId);
|
pMember->info.dnodeId);
|
||||||
}
|
}
|
||||||
|
//*pOp = CHECK_SYNC_CHECK_SYNC;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,7 +727,7 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(mndPullupArbUpdateGroupBatch(pMnode, pUpdateArray));
|
TAOS_CHECK_EXIT(mndBatchUpdateArbGroup(pMnode, pUpdateArray));
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -761,9 +767,11 @@ static void mndInitArbUpdateGroup(SArbGroup *pGroup, SMArbUpdateGroup *outGroup)
|
||||||
outGroup->assignedLeader.token = pGroup->assignedLeader.token; // just copy the pointer
|
outGroup->assignedLeader.token = pGroup->assignedLeader.token; // just copy the pointer
|
||||||
outGroup->assignedLeader.acked = pGroup->assignedLeader.acked;
|
outGroup->assignedLeader.acked = pGroup->assignedLeader.acked;
|
||||||
outGroup->version = pGroup->version;
|
outGroup->version = pGroup->version;
|
||||||
|
outGroup->code = pGroup->code;
|
||||||
|
outGroup->updateTimeMs = pGroup->updateTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) {
|
static int32_t mndUpdateArbGroup(SMnode *pMnode, SArbGroup *pNewGroup) {
|
||||||
if (taosHashGet(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId)) != NULL) {
|
if (taosHashGet(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId)) != NULL) {
|
||||||
mInfo("vgId:%d, arb skip to pullup arb-update-group request, since it is in process", pNewGroup->vgId);
|
mInfo("vgId:%d, arb skip to pullup arb-update-group request, since it is in process", pNewGroup->vgId);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -796,7 +804,7 @@ _OVER:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndPullupArbUpdateGroupBatch(SMnode *pMnode, SArray *newGroupArray) {
|
static int32_t mndBatchUpdateArbGroup(SMnode *pMnode, SArray *newGroupArray) {
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
|
|
||||||
size_t sz = taosArrayGetSize(newGroupArray);
|
size_t sz = taosArrayGetSize(newGroupArray);
|
||||||
|
@ -857,7 +865,7 @@ static int32_t mndProcessArbUpdateGroupBatchReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_ARBGROUP, NULL, "update-arbgroup");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_ARBGROUP, NULL, "upd-bat-arbgroup");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("failed to update arbgroup in create trans, since %s", terrstr());
|
mError("failed to update arbgroup in create trans, since %s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -879,6 +887,16 @@ static int32_t mndProcessArbUpdateGroupBatchReq(SRpcMsg *pReq) {
|
||||||
tstrncpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
||||||
newGroup.version = pUpdateGroup->version;
|
newGroup.version = pUpdateGroup->version;
|
||||||
|
newGroup.code = pUpdateGroup->code;
|
||||||
|
newGroup.updateTimeMs = pUpdateGroup->updateTimeMs;
|
||||||
|
|
||||||
|
mInfo(
|
||||||
|
"trans:%d, used to update arbgroup:%d, member0:[%d][%s] member1:[%d][%s] isSync:%d assigned:[%d][%s][%d], %d, "
|
||||||
|
"%" PRId64,
|
||||||
|
pTrans->id, newGroup.vgId, newGroup.members[0].info.dnodeId, newGroup.members[0].state.token,
|
||||||
|
newGroup.members[1].info.dnodeId, newGroup.members[1].state.token, newGroup.isSync,
|
||||||
|
newGroup.assignedLeader.dnodeId, newGroup.assignedLeader.token, newGroup.assignedLeader.acked,
|
||||||
|
pUpdateGroup->code, pUpdateGroup->updateTimeMs);
|
||||||
|
|
||||||
SArbGroup *pOldGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &newGroup.vgId);
|
SArbGroup *pOldGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &newGroup.vgId);
|
||||||
if (!pOldGroup) {
|
if (!pOldGroup) {
|
||||||
|
@ -944,41 +962,8 @@ static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup) {
|
||||||
pGroup->assignedLeader.acked = false;
|
pGroup->assignedLeader.acked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndArbGroupUpdateTrans(SMnode *pMnode, SArbGroup *pNew) {
|
bool mndCheckArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId,
|
||||||
int32_t code = -1;
|
SArbGroup *pNewGroup) {
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_ARBGROUP, NULL, "update-arbgroup");
|
|
||||||
if (pTrans == NULL) {
|
|
||||||
mError("failed to update arbgroup in create trans, vgId:%d, since %s", pNew->vgId, terrstr());
|
|
||||||
if (terrno != 0) code = terrno;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
mInfo("trans:%d, used to update arbgroup:%d, member0:[%d][%s] member1:[%d][%s] isSync:%d assigned:[%d][%s][%d]",
|
|
||||||
pTrans->id, pNew->vgId, pNew->members[0].info.dnodeId, pNew->members[0].state.token,
|
|
||||||
pNew->members[1].info.dnodeId, pNew->members[1].state.token, pNew->isSync, pNew->assignedLeader.dnodeId,
|
|
||||||
pNew->assignedLeader.token, pNew->assignedLeader.acked);
|
|
||||||
|
|
||||||
mndTransAddArbGroupId(pTrans, pNew->vgId);
|
|
||||||
if ((code = mndTransCheckConflict(pMnode, pTrans)) != 0) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((code = mndSetCreateArbGroupCommitLogs(pTrans, pNew)) != 0) {
|
|
||||||
mError("failed to update arbgroup in set commit log, vgId:%d, since %s", pNew->vgId, tstrerror(code));
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
|
|
||||||
|
|
||||||
code = 0;
|
|
||||||
|
|
||||||
_OVER:
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId,
|
|
||||||
SArbGroup *pNewGroup) {
|
|
||||||
bool updateToken = false;
|
bool updateToken = false;
|
||||||
SArbGroupMember *pMember = NULL;
|
SArbGroupMember *pMember = NULL;
|
||||||
|
|
||||||
|
@ -1033,7 +1018,7 @@ _OVER:
|
||||||
return updateToken;
|
return updateToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndUpdateArbHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *memberArray) {
|
static int32_t mndUpdateArbGroupsByHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *memberArray) {
|
||||||
int64_t nowMs = taosGetTimestampMs();
|
int64_t nowMs = taosGetTimestampMs();
|
||||||
size_t size = taosArrayGetSize(memberArray);
|
size_t size = taosArrayGetSize(memberArray);
|
||||||
SArray *pUpdateArray = taosArrayInit(size, sizeof(SArbGroup));
|
SArray *pUpdateArray = taosArrayInit(size, sizeof(SArbGroup));
|
||||||
|
@ -1048,7 +1033,7 @@ static int32_t mndUpdateArbHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *me
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateToken = mndUpdateArbGroupByHeartBeat(pGroup, pRspMember, nowMs, dnodeId, &newGroup);
|
bool updateToken = mndCheckArbGroupByHeartBeat(pGroup, pRspMember, nowMs, dnodeId, &newGroup);
|
||||||
if (updateToken) {
|
if (updateToken) {
|
||||||
if (taosArrayPush(pUpdateArray, &newGroup) == NULL) {
|
if (taosArrayPush(pUpdateArray, &newGroup) == NULL) {
|
||||||
mError("failed to push newGroup to updateArray, but continue at this hearbear");
|
mError("failed to push newGroup to updateArray, but continue at this hearbear");
|
||||||
|
@ -1058,14 +1043,14 @@ static int32_t mndUpdateArbHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *me
|
||||||
sdbRelease(pMnode->pSdb, pGroup);
|
sdbRelease(pMnode->pSdb, pGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(mndPullupArbUpdateGroupBatch(pMnode, pUpdateArray));
|
TAOS_CHECK_RETURN(mndBatchUpdateArbGroup(pMnode, pUpdateArray));
|
||||||
|
|
||||||
taosArrayDestroy(pUpdateArray);
|
taosArrayDestroy(pUpdateArray);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0Token, char *member1Token,
|
bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0Token, char *member1Token,
|
||||||
bool newIsSync, SArbGroup *pNewGroup) {
|
bool newIsSync, SArbGroup *pNewGroup, int32_t code) {
|
||||||
bool updateIsSync = false;
|
bool updateIsSync = false;
|
||||||
|
|
||||||
(void)taosThreadMutexLock(&pGroup->mutex);
|
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||||
|
@ -1088,8 +1073,10 @@ bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0
|
||||||
if (pGroup->isSync != newIsSync) {
|
if (pGroup->isSync != newIsSync) {
|
||||||
mndArbGroupDupObj(pGroup, pNewGroup);
|
mndArbGroupDupObj(pGroup, pNewGroup);
|
||||||
pNewGroup->isSync = newIsSync;
|
pNewGroup->isSync = newIsSync;
|
||||||
|
pNewGroup->code = code;
|
||||||
|
pNewGroup->updateTimeMs = taosGetTimestampMs();
|
||||||
|
|
||||||
mInfo("vgId:%d, arb isSync updating, new isSync:%d", vgId, newIsSync);
|
mInfo("vgId:%d, arb isSync updating, new isSync:%d, timeStamp:%" PRId64, vgId, newIsSync, pNewGroup->updateTimeMs);
|
||||||
updateIsSync = true;
|
updateIsSync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,7 +1085,8 @@ _OVER:
|
||||||
return updateIsSync;
|
return updateIsSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndUpdateArbSync(SMnode *pMnode, int32_t vgId, char *member0Token, char *member1Token, bool newIsSync) {
|
static int32_t mndUpdateArbSync(SMnode *pMnode, int32_t vgId, char *member0Token, char *member1Token, bool newIsSync,
|
||||||
|
int32_t rsp_code) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SArbGroup *pGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &vgId);
|
SArbGroup *pGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &vgId);
|
||||||
if (pGroup == NULL) {
|
if (pGroup == NULL) {
|
||||||
|
@ -1109,9 +1097,10 @@ static int32_t mndUpdateArbSync(SMnode *pMnode, int32_t vgId, char *member0Token
|
||||||
}
|
}
|
||||||
|
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
bool updateIsSync = mndUpdateArbGroupByCheckSync(pGroup, vgId, member0Token, member1Token, newIsSync, &newGroup);
|
bool updateIsSync =
|
||||||
|
mndUpdateArbGroupByCheckSync(pGroup, vgId, member0Token, member1Token, newIsSync, &newGroup, rsp_code);
|
||||||
if (updateIsSync) {
|
if (updateIsSync) {
|
||||||
if (mndPullupArbUpdateGroup(pMnode, &newGroup) != 0) {
|
if (mndUpdateArbGroup(pMnode, &newGroup) != 0) {
|
||||||
mInfo("failed to pullup update arb sync, vgId:%d, since %s", vgId, terrstr());
|
mInfo("failed to pullup update arb sync, vgId:%d, since %s", vgId, terrstr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,7 +1139,7 @@ static int32_t mndProcessArbHbRsp(SRpcMsg *pRsp) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(mndUpdateArbHeartBeat(pMnode, arbHbRsp.dnodeId, arbHbRsp.hbMembers), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndUpdateArbGroupsByHeartBeat(pMnode, arbHbRsp.dnodeId, arbHbRsp.hbMembers), NULL, _OVER);
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -1185,6 +1174,7 @@ static int32_t mndProcessArbCheckSyncRsp(SRpcMsg *pRsp) {
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("vgId:%d, vnode-arb-check-sync-rsp received, errCode:%d", syncRsp.vgId, syncRsp.errCode);
|
||||||
if (mndArbCheckToken(arbToken, syncRsp.arbToken) != 0) {
|
if (mndArbCheckToken(arbToken, syncRsp.arbToken) != 0) {
|
||||||
mInfo("skip update arb sync for vgId:%d, arb token mismatch, local:[%s] msg:[%s]", syncRsp.vgId, arbToken,
|
mInfo("skip update arb sync for vgId:%d, arb token mismatch, local:[%s] msg:[%s]", syncRsp.vgId, arbToken,
|
||||||
syncRsp.arbToken);
|
syncRsp.arbToken);
|
||||||
|
@ -1193,7 +1183,8 @@ static int32_t mndProcessArbCheckSyncRsp(SRpcMsg *pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool newIsSync = (syncRsp.errCode == TSDB_CODE_SUCCESS);
|
bool newIsSync = (syncRsp.errCode == TSDB_CODE_SUCCESS);
|
||||||
if ((code = mndUpdateArbSync(pMnode, syncRsp.vgId, syncRsp.member0Token, syncRsp.member1Token, newIsSync)) != 0) {
|
if ((code = mndUpdateArbSync(pMnode, syncRsp.vgId, syncRsp.member0Token, syncRsp.member1Token, newIsSync,
|
||||||
|
syncRsp.errCode)) != 0) {
|
||||||
mInfo("failed to update arb sync for vgId:%d, since:%s", syncRsp.vgId, terrstr());
|
mInfo("failed to update arb sync for vgId:%d, since:%s", syncRsp.vgId, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -1278,7 +1269,7 @@ static int32_t mndProcessArbSetAssignedLeaderRsp(SRpcMsg *pRsp) {
|
||||||
bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(pGroup, setAssignedRsp.vgId, setAssignedRsp.memberToken,
|
bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(pGroup, setAssignedRsp.vgId, setAssignedRsp.memberToken,
|
||||||
pRsp->code, &newGroup);
|
pRsp->code, &newGroup);
|
||||||
if (updateAssigned) {
|
if (updateAssigned) {
|
||||||
if ((code = mndPullupArbUpdateGroup(pMnode, &newGroup)) != 0) {
|
if ((code = mndUpdateArbGroup(pMnode, &newGroup)) != 0) {
|
||||||
mInfo("failed to pullup update arb assigned for vgId:%d, since:%s", setAssignedRsp.vgId, tstrerror(code));
|
mInfo("failed to pullup update arb assigned for vgId:%d, since:%s", setAssignedRsp.vgId, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -1291,6 +1282,35 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *formatTimestamp(char *buf, int64_t val, int precision) {
|
||||||
|
time_t tt;
|
||||||
|
if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
tt = (time_t)(val / 1000000);
|
||||||
|
}
|
||||||
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
tt = (time_t)(val / 1000000000);
|
||||||
|
} else {
|
||||||
|
tt = (time_t)(val / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm;
|
||||||
|
if (taosLocalTime(&tt, &tm, NULL, 0, NULL) == NULL) {
|
||||||
|
mError("failed to get local time");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
size_t pos = taosStrfTime(buf, 32, "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
|
|
||||||
|
if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
sprintf(buf + pos, ".%06d", (int)(val % 1000000));
|
||||||
|
} else if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
sprintf(buf + pos, ".%09d", (int)(val % 1000000000));
|
||||||
|
} else {
|
||||||
|
sprintf(buf + pos, ".%03d", (int)(val % 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -1332,9 +1352,22 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
&lino, _OVER);
|
&lino, _OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("vgId:%d, arb group sync:%d, code:%s, update time:%" PRId64, pGroup->vgId, pGroup->isSync,
|
||||||
|
tstrerror(pGroup->code), pGroup->updateTimeMs);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false), pGroup, &lino, _OVER);
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false), pGroup, &lino, _OVER);
|
||||||
|
|
||||||
|
char strCheckSyncCode[100] = {0};
|
||||||
|
char bufUpdateTime[40] = {0};
|
||||||
|
(void)formatTimestamp(bufUpdateTime, pGroup->updateTimeMs, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
tsnprintf(strCheckSyncCode, 100, "%s(%s)", tstrerror(pGroup->code), bufUpdateTime);
|
||||||
|
|
||||||
|
char checkSyncCode[100 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(checkSyncCode, strCheckSyncCode, 100 + VARSTR_HEADER_SIZE);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)checkSyncCode, false), pGroup, &lino, _OVER);
|
||||||
|
|
||||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false),
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false),
|
||||||
|
|
|
@ -45,6 +45,8 @@ int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
char *sep = NULL;
|
char *sep = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
|
||||||
|
mInfo("retrieve compact detail");
|
||||||
|
|
||||||
if (strlen(pShow->db) > 0) {
|
if (strlen(pShow->db) > 0) {
|
||||||
sep = strchr(pShow->db, '.');
|
sep = strchr(pShow->db, '.');
|
||||||
if (sep &&
|
if (sep &&
|
||||||
|
|
|
@ -1304,6 +1304,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
mInfo("trans:%d, used to alter db:%s", pTrans->id, pOld->name);
|
mInfo("trans:%d, used to alter db:%s", pTrans->id, pOld->name);
|
||||||
|
mInfo("trans:%d, used to alter db, ableToBeKilled:%d, killMode:%d", pTrans->id, pTrans->ableToBeKilled, pTrans->killMode);
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, pOld->name, NULL);
|
mndTransSetDbName(pTrans, pOld->name, NULL);
|
||||||
TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransCheckConflict(pMnode, pTrans), NULL, _OVER);
|
||||||
|
@ -1312,6 +1313,8 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
|
||||||
TAOS_CHECK_GOTO(mndSetAlterDbPrepareLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetAlterDbPrepareLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndSetAlterDbRedoActions(pMnode, pTrans, pOld, pNew), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetAlterDbRedoActions(pMnode, pTrans, pOld, pNew), NULL, _OVER);
|
||||||
|
|
||||||
|
mInfo("trans:%d, used to alter db, ableToBeKilled:%d, killMode:%d", pTrans->id, pTrans->ableToBeKilled, pTrans->killMode);
|
||||||
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_COMPACT;
|
type = TSDB_MGMT_TABLE_COMPACT;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
|
type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_TRANSACTION_DETAILS, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_TRANSACTION_DETAIL;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_GRANTS_FULL;
|
type = TSDB_MGMT_TABLE_GRANTS_FULL;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOGS, len) == 0) {
|
||||||
|
@ -236,7 +238,8 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
SRetrieveTableReq retrieveReq = {0};
|
SRetrieveTableReq retrieveReq = {0};
|
||||||
TAOS_CHECK_RETURN(tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq));
|
TAOS_CHECK_RETURN(tDeserializeSRetrieveTableReq(pReq->pCont, pReq->contLen, &retrieveReq));
|
||||||
|
|
||||||
mDebug("process to retrieve systable req db:%s, tb:%s", retrieveReq.db, retrieveReq.tb);
|
mDebug("process to retrieve systable req db:%s, tb:%s, compactId:%" PRId64, retrieveReq.db, retrieveReq.tb,
|
||||||
|
retrieveReq.compactId);
|
||||||
|
|
||||||
if (retrieveReq.showId == 0) {
|
if (retrieveReq.showId == 0) {
|
||||||
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
||||||
|
|
|
@ -52,6 +52,7 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
static void mndCancelGetNextStreamTask(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextStreamTask(SMnode *pMnode, void *pIter);
|
||||||
static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq);
|
static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq);
|
static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessResetStreamReq(SRpcMsg *pReq);
|
||||||
static int32_t mndBuildStreamCheckpointSourceReq(void **pBuf, int32_t *pLen, int32_t nodeId, int64_t checkpointId,
|
static int32_t mndBuildStreamCheckpointSourceReq(void **pBuf, int32_t *pLen, int32_t nodeId, int64_t checkpointId,
|
||||||
int64_t streamId, int32_t taskId, int32_t transId, int8_t mndTrigger);
|
int64_t streamId, int32_t taskId, int32_t transId, int8_t mndTrigger);
|
||||||
static int32_t mndProcessNodeCheck(SRpcMsg *pReq);
|
static int32_t mndProcessNodeCheck(SRpcMsg *pReq);
|
||||||
|
@ -128,6 +129,7 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_PAUSE_STREAM, mndProcessPauseStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_PAUSE_STREAM, mndProcessPauseStreamReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_RESUME_STREAM, mndProcessResumeStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_RESUME_STREAM, mndProcessResumeStreamReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_RESET_STREAM, mndProcessResetStreamReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream);
|
||||||
|
@ -749,6 +751,77 @@ static int32_t doStreamCheck(SMnode *pMnode, SStreamObj *pStreamObj) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *notifyAddrDup(void *p) { return taosStrdup((char *)p); }
|
||||||
|
|
||||||
|
static int32_t addStreamTaskNotifyInfo(const SCMCreateStreamReq *createReq, const SStreamObj *pStream,
|
||||||
|
SStreamTask *pTask) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(createReq, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(pTask, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
pTask->notifyInfo.pNotifyAddrUrls = taosArrayDup(createReq->pNotifyAddrUrls, notifyAddrDup);
|
||||||
|
TSDB_CHECK_NULL(pTask->notifyInfo.pNotifyAddrUrls, code, lino, _end, terrno);
|
||||||
|
pTask->notifyInfo.notifyEventTypes = createReq->notifyEventTypes;
|
||||||
|
pTask->notifyInfo.notifyErrorHandle = createReq->notifyErrorHandle;
|
||||||
|
pTask->notifyInfo.streamName = taosStrdup(createReq->name);
|
||||||
|
TSDB_CHECK_NULL(pTask->notifyInfo.streamName, code, lino, _end, terrno);
|
||||||
|
pTask->notifyInfo.stbFullName = taosStrdup(createReq->targetStbFullName);
|
||||||
|
TSDB_CHECK_NULL(pTask->notifyInfo.stbFullName, code, lino, _end, terrno);
|
||||||
|
pTask->notifyInfo.pSchemaWrapper = tCloneSSchemaWrapper(&pStream->outputSchema);
|
||||||
|
TSDB_CHECK_NULL(pTask->notifyInfo.pSchemaWrapper, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
mError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t addStreamNotifyInfo(SCMCreateStreamReq *createReq, SStreamObj *pStream) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t level = 0;
|
||||||
|
int32_t nTasks = 0;
|
||||||
|
SArray *pLevel = NULL;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(createReq, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(pStream, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
if (taosArrayGetSize(createReq->pNotifyAddrUrls) == 0) {
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
level = taosArrayGetSize(pStream->tasks);
|
||||||
|
for (int32_t i = 0; i < level; ++i) {
|
||||||
|
pLevel = taosArrayGetP(pStream->tasks, i);
|
||||||
|
nTasks = taosArrayGetSize(pLevel);
|
||||||
|
for (int32_t j = 0; j < nTasks; ++j) {
|
||||||
|
code = addStreamTaskNotifyInfo(createReq, pStream, taosArrayGetP(pLevel, j));
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pStream->conf.fillHistory && createReq->notifyHistory) {
|
||||||
|
level = taosArrayGetSize(pStream->pHTasksList);
|
||||||
|
for (int32_t i = 0; i < level; ++i) {
|
||||||
|
pLevel = taosArrayGetP(pStream->pHTasksList, i);
|
||||||
|
nTasks = taosArrayGetSize(pLevel);
|
||||||
|
for (int32_t j = 0; j < nTasks; ++j) {
|
||||||
|
code = addStreamTaskNotifyInfo(createReq, pStream, taosArrayGetP(pLevel, j));
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
mError("%s for stream %s failed at line %d since %s", __func__, pStream->name, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
@ -853,6 +926,14 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add notify info into all stream tasks
|
||||||
|
code = addStreamNotifyInfo(&createReq, &streamObj);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
mError("stream:%s failed to add stream notify info since %s", createReq.name, tstrerror(code));
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
// add stream to trans
|
// add stream to trans
|
||||||
code = mndPersistStream(pTrans, &streamObj);
|
code = mndPersistStream(pTrans, &streamObj);
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
@ -1877,6 +1958,37 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
||||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessResetStreamReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SStreamObj *pStream = NULL;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
SMResetStreamReq resetReq = {0};
|
||||||
|
if (tDeserializeSMResetStreamReq(pReq->pCont, pReq->contLen, &resetReq) < 0) {
|
||||||
|
TAOS_RETURN(TSDB_CODE_INVALID_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
mDebug("recv reset stream req, stream:%s", resetReq.name);
|
||||||
|
|
||||||
|
code = mndAcquireStream(pMnode, resetReq.name, &pStream);
|
||||||
|
if (pStream == NULL || code != 0) {
|
||||||
|
if (resetReq.igNotExists) {
|
||||||
|
mInfo("stream:%s, not exist, not pause stream", resetReq.name);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
mError("stream:%s not exist, failed to pause stream", resetReq.name);
|
||||||
|
TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo(liao hao jun)
|
||||||
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChangeInfo, bool includeAllNodes) {
|
static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChangeInfo, bool includeAllNodes) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
|
|
@ -14,19 +14,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "mndTrans.h"
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "mndPrivilege.h"
|
#include "mndPrivilege.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndStb.h"
|
#include "mndStb.h"
|
||||||
#include "mndSubscribe.h"
|
#include "mndSubscribe.h"
|
||||||
#include "mndSync.h"
|
#include "mndSync.h"
|
||||||
#include "mndTrans.h"
|
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
|
#include "mndVgroup.h"
|
||||||
|
#include "osTime.h"
|
||||||
|
|
||||||
#define TRANS_VER1_NUMBER 1
|
#define TRANS_VER1_NUMBER 1
|
||||||
#define TRANS_VER2_NUMBER 2
|
#define TRANS_VER2_NUMBER 2
|
||||||
#define TRANS_ARRAY_SIZE 8
|
#define TRANS_ARRAY_SIZE 8
|
||||||
#define TRANS_RESERVE_SIZE 44
|
#define TRANS_RESERVE_SIZE 42
|
||||||
|
|
||||||
static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans);
|
static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans);
|
||||||
static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *OldTrans, STrans *pOld);
|
static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *OldTrans, STrans *pOld);
|
||||||
|
@ -70,7 +72,7 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
||||||
|
static int32_t mndRetrieveTransDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static int32_t tsMaxTransId = 0;
|
static int32_t tsMaxTransId = 0;
|
||||||
|
|
||||||
int32_t mndInitTrans(SMnode *pMnode) {
|
int32_t mndInitTrans(SMnode *pMnode) {
|
||||||
|
@ -89,6 +91,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndCancelGetNextTrans);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndCancelGetNextTrans);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANSACTION_DETAIL, mndRetrieveTransDetail);
|
||||||
return sdbSetTable(pMnode->pSdb, table);
|
return sdbSetTable(pMnode->pSdb, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +159,7 @@ SSdbRaw *mndTransEncode(STrans *pTrans) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
int8_t sver = taosArrayGetSize(pTrans->prepareActions) ? TRANS_VER2_NUMBER : TRANS_VER1_NUMBER;
|
int8_t sver = TRANS_VER2_NUMBER;
|
||||||
|
|
||||||
int32_t rawDataLen = sizeof(STrans) + TRANS_RESERVE_SIZE + pTrans->paramLen;
|
int32_t rawDataLen = sizeof(STrans) + TRANS_RESERVE_SIZE + pTrans->paramLen;
|
||||||
rawDataLen += mndTransGetActionsSize(pTrans->prepareActions);
|
rawDataLen += mndTransGetActionsSize(pTrans->prepareActions);
|
||||||
|
@ -220,6 +223,11 @@ SSdbRaw *mndTransEncode(STrans *pTrans) {
|
||||||
pIter = taosHashIterate(pTrans->arbGroupIds, pIter);
|
pIter = taosHashIterate(pTrans->arbGroupIds, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sver > TRANS_VER1_NUMBER) {
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pTrans->ableToBeKilled, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pTrans->killMode, _OVER)
|
||||||
|
}
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||||
|
|
||||||
|
@ -310,7 +318,7 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) {
|
||||||
|
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||||
|
|
||||||
if (sver != TRANS_VER1_NUMBER && sver != TRANS_VER2_NUMBER) {
|
if (sver > TRANS_VER2_NUMBER) {
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -389,6 +397,13 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) {
|
||||||
if ((terrno = taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0)) != 0) goto _OVER;
|
if ((terrno = taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0)) != 0) goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t ableKill = 0;
|
||||||
|
int8_t killMode = 0;
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &ableKill, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &killMode, _OVER)
|
||||||
|
pTrans->ableToBeKilled = ableKill;
|
||||||
|
pTrans->killMode = killMode;
|
||||||
|
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -430,12 +445,25 @@ static const char *mndTransStr(ETrnStage stage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *mndTransTypeStr(ETrnAct actionType) {
|
||||||
|
switch (actionType) {
|
||||||
|
case TRANS_ACTION_MSG:
|
||||||
|
return "msg";
|
||||||
|
case TRANS_ACTION_RAW:
|
||||||
|
return "sdb";
|
||||||
|
default:
|
||||||
|
return "invalid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void mndSetTransLastAction(STrans *pTrans, STransAction *pAction) {
|
static void mndSetTransLastAction(STrans *pTrans, STransAction *pAction) {
|
||||||
if (pAction != NULL) {
|
if (pAction != NULL) {
|
||||||
pTrans->lastAction = pAction->id;
|
if (pAction->errCode != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
pTrans->lastMsgType = pAction->msgType;
|
pTrans->lastAction = pAction->id;
|
||||||
pTrans->lastEpset = pAction->epSet;
|
pTrans->lastMsgType = pAction->msgType;
|
||||||
pTrans->lastErrorNo = pAction->errCode;
|
pTrans->lastEpset = pAction->epSet;
|
||||||
|
pTrans->lastErrorNo = pAction->errCode;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pTrans->lastAction = 0;
|
pTrans->lastAction = 0;
|
||||||
pTrans->lastMsgType = 0;
|
pTrans->lastMsgType = 0;
|
||||||
|
@ -636,6 +664,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
||||||
pTrans->policy = policy;
|
pTrans->policy = policy;
|
||||||
pTrans->conflict = conflict;
|
pTrans->conflict = conflict;
|
||||||
pTrans->exec = TRN_EXEC_PARALLEL;
|
pTrans->exec = TRN_EXEC_PARALLEL;
|
||||||
|
pTrans->ableToBeKilled = false;
|
||||||
pTrans->createdTime = taosGetTimestampMs();
|
pTrans->createdTime = taosGetTimestampMs();
|
||||||
pTrans->prepareActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
pTrans->prepareActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||||
pTrans->redoActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
pTrans->redoActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||||
|
@ -804,6 +833,13 @@ void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId) {
|
||||||
|
|
||||||
void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; }
|
void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; }
|
||||||
|
|
||||||
|
void mndTransSetBeKilled(STrans *pTrans, bool ableToBeKilled) { pTrans->ableToBeKilled = ableToBeKilled; }
|
||||||
|
|
||||||
|
void mndTransSetKillMode(STrans *pTrans, ETrnKillMode killMode) {
|
||||||
|
pTrans->ableToBeKilled = true;
|
||||||
|
pTrans->killMode = killMode;
|
||||||
|
}
|
||||||
|
|
||||||
void mndTransSetParallel(STrans *pTrans) { pTrans->exec = TRN_EXEC_PARALLEL; }
|
void mndTransSetParallel(STrans *pTrans) { pTrans->exec = TRN_EXEC_PARALLEL; }
|
||||||
|
|
||||||
void mndTransSetChangeless(STrans *pTrans) { pTrans->changeless = true; }
|
void mndTransSetChangeless(STrans *pTrans) { pTrans->changeless = true; }
|
||||||
|
@ -1043,6 +1079,39 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInfo("trans:%d, action list:", pTrans->id);
|
||||||
|
int32_t index = 0;
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->prepareActions); ++i, ++index) {
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->prepareActions, i);
|
||||||
|
mInfo("trans:%d, action:%d, %s:%d sdbType:%s, sdbStatus:%s", pTrans->id, index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->redoActions); ++i, ++index) {
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->redoActions, i);
|
||||||
|
mInfo("trans:%d, action:%d, %s:%d msgType:%s", pTrans->id, index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, TMSG_INFO(pAction->msgType));;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->commitActions); ++i, ++index) {
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->commitActions, i);
|
||||||
|
mInfo("trans:%d, action:%d, %s:%d sdbType:%s, sdbStatus:%s", pTrans->id, index,
|
||||||
|
mndTransStr(pAction->stage), i, sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->undoActions); ++i, ++index) {
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->undoActions, i);
|
||||||
|
if(pAction->actionType == TRANS_ACTION_MSG){
|
||||||
|
mInfo("trans:%d, action:%d, %s:%d msgType:%s", pTrans->id, index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, TMSG_INFO(pAction->msgType));;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mInfo("trans:%d, action:%d, %s:%d sdbType:%s, sdbStatus:%s", pTrans->id, index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(mndTransCheckConflict(pMnode, pTrans));
|
TAOS_CHECK_RETURN(mndTransCheckConflict(pMnode, pTrans));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(mndTransCheckParallelActions(pMnode, pTrans));
|
TAOS_CHECK_RETURN(mndTransCheckParallelActions(pMnode, pTrans));
|
||||||
|
@ -1260,7 +1329,10 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||||
if (pAction != NULL) {
|
if (pAction != NULL) {
|
||||||
pAction->msgReceived = 1;
|
pAction->msgReceived = 1;
|
||||||
pAction->errCode = pRsp->code;
|
pAction->errCode = pRsp->code;
|
||||||
pTrans->lastErrorNo = pRsp->code;
|
pAction->endTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
// pTrans->lastErrorNo = pRsp->code;
|
||||||
|
mndSetTransLastAction(pTrans, pAction);
|
||||||
|
|
||||||
mInfo("trans:%d, %s:%d response is received, received code:0x%x(%s), accept:0x%x(%s) retry:0x%x(%s)", transId,
|
mInfo("trans:%d, %s:%d response is received, received code:0x%x(%s), accept:0x%x(%s) retry:0x%x(%s)", transId,
|
||||||
mndTransStr(pAction->stage), action, pRsp->code, tstrerror(pRsp->code), pAction->acceptableCode,
|
mndTransStr(pAction->stage), action, pRsp->code, tstrerror(pRsp->code), pAction->acceptableCode,
|
||||||
|
@ -1374,6 +1446,8 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
||||||
pAction->msgSent = 1;
|
pAction->msgSent = 1;
|
||||||
// pAction->msgReceived = 0;
|
// pAction->msgReceived = 0;
|
||||||
pAction->errCode = TSDB_CODE_ACTION_IN_PROGRESS;
|
pAction->errCode = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
pAction->startTime = taosGetTimestampMs();
|
||||||
|
pAction->endTime = 0;
|
||||||
mInfo("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail);
|
mInfo("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail);
|
||||||
|
|
||||||
mndSetTransLastAction(pTrans, pAction);
|
mndSetTransLastAction(pTrans, pAction);
|
||||||
|
@ -1527,8 +1601,9 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
|
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
|
||||||
STransAction *pAction = taosArrayGet(pActions, action);
|
STransAction *pAction = taosArrayGet(pActions, action);
|
||||||
|
|
||||||
mInfo("trans:%d, current action:%d, stage:%s, actionType(1:msg,2:log):%d", pTrans->id, pTrans->actionPos,
|
mInfo("trans:%d, current action:%d, stage:%s, actionType(1:msg,2:log):%d, msgSent:%d, msgReceived:%d",
|
||||||
mndTransStr(pAction->stage), pAction->actionType);
|
pTrans->id, pTrans->actionPos, mndTransStr(pAction->stage), pAction->actionType, pAction->msgSent,
|
||||||
|
pAction->msgReceived);
|
||||||
|
|
||||||
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -1924,13 +1999,25 @@ int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) {
|
||||||
TAOS_RETURN(TSDB_CODE_MND_TRANS_INVALID_STAGE);
|
TAOS_RETURN(TSDB_CODE_MND_TRANS_INVALID_STAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
if(pTrans->ableToBeKilled == false){
|
||||||
STransAction *pAction = taosArrayGet(pArray, i);
|
return TSDB_CODE_MND_TRANS_NOT_ABLE_TO_kILLED;
|
||||||
mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id,
|
}
|
||||||
mndTransStr(pAction->stage), i, tstrerror(pAction->errCode));
|
|
||||||
pAction->msgSent = 1;
|
if(pTrans->killMode == TRN_KILL_MODE_SKIP){
|
||||||
pAction->msgReceived = 1;
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
pAction->errCode = 0;
|
STransAction *pAction = taosArrayGet(pArray, i);
|
||||||
|
mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id,
|
||||||
|
mndTransStr(pAction->stage), i, tstrerror(pAction->errCode));
|
||||||
|
pAction->msgSent = 1;
|
||||||
|
pAction->msgReceived = 1;
|
||||||
|
pAction->errCode = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(pTrans->killMode == TRN_KILL_MODE_INTERUPT){
|
||||||
|
pTrans->stage = TRN_STAGE_PRE_FINISH;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return TSDB_CODE_MND_TRANS_NOT_ABLE_TO_kILLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransExecute(pMnode, pTrans);
|
mndTransExecute(pMnode, pTrans);
|
||||||
|
@ -2002,6 +2089,114 @@ void mndTransPullup(SMnode *pMnode) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *formatTimestamp(char *buf, int64_t val, int precision) {
|
||||||
|
time_t tt;
|
||||||
|
if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
tt = (time_t)(val / 1000000);
|
||||||
|
}
|
||||||
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
tt = (time_t)(val / 1000000000);
|
||||||
|
} else {
|
||||||
|
tt = (time_t)(val / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm;
|
||||||
|
if (taosLocalTime(&tt, &tm, NULL, 0, NULL) == NULL) {
|
||||||
|
mError("failed to get local time");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
size_t pos = taosStrfTime(buf, 32, "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
|
|
||||||
|
if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
sprintf(buf + pos, ".%06d", (int)(val % 1000000));
|
||||||
|
} else if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
sprintf(buf + pos, ".%09d", (int)(val % 1000000000));
|
||||||
|
} else {
|
||||||
|
sprintf(buf + pos, ".%03d", (int)(val % 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndTransLogAction(STrans *pTrans) {
|
||||||
|
char detail[512] = {0};
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t index = 0;
|
||||||
|
|
||||||
|
if (pTrans->stage == TRN_STAGE_PREPARE) {
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->prepareActions); ++i, ++index) {
|
||||||
|
len = 0;
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->prepareActions, i);
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "action:%d, %s:%d sdbType:%s, sdbStatus:%s\n", index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, sdbTableName(pAction->pRaw->type),
|
||||||
|
sdbStatusName(pAction->pRaw->status));
|
||||||
|
mDebug("trans:%d, show tran action, detail:%s", pTrans->id, detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTrans->stage == TRN_STAGE_REDO_ACTION) {
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->redoActions); ++i, ++index) {
|
||||||
|
len = 0;
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->redoActions, i);
|
||||||
|
if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
|
char bufStart[40] = {0};
|
||||||
|
(void)formatTimestamp(bufStart, pAction->startTime, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
|
||||||
|
char endStart[40] = {0};
|
||||||
|
(void)formatTimestamp(endStart, pAction->endTime, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len,
|
||||||
|
"action:%d, %s:%d msgType:%s,"
|
||||||
|
"sent:%d, received:%d, startTime:%s, endTime:%s, ",
|
||||||
|
index, mndTransStr(pAction->stage), pAction->id, TMSG_INFO(pAction->msgType), pAction->msgSent,
|
||||||
|
pAction->msgReceived, bufStart, endStart);
|
||||||
|
|
||||||
|
SEpSet epset = pAction->epSet;
|
||||||
|
if (epset.numOfEps > 0) {
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "numOfEps:%d inUse:%d ", epset.numOfEps, epset.inUse);
|
||||||
|
for (int32_t i = 0; i < epset.numOfEps; ++i) {
|
||||||
|
len +=
|
||||||
|
snprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, ", errCode:0x%x(%s)\n", pAction->errCode & 0xFFFF,
|
||||||
|
tstrerror(pAction->errCode));
|
||||||
|
} else {
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "action:%d, %s:%d sdbType:%s, sdbStatus:%s, written:%d\n",
|
||||||
|
index, mndTransStr(pAction->stage), pAction->id, sdbTableName(pAction->pRaw->type),
|
||||||
|
sdbStatusName(pAction->pRaw->status), pAction->rawWritten);
|
||||||
|
}
|
||||||
|
mDebug("trans:%d, show tran action, detail:%s", pTrans->id, detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTrans->stage == TRN_STAGE_COMMIT_ACTION) {
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->commitActions); ++i, ++index) {
|
||||||
|
len = 0;
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->commitActions, i);
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "action:%d, %s:%d sdbType:%s, sdbStatus:%s\n", index,
|
||||||
|
mndTransStr(pAction->stage), i, sdbTableName(pAction->pRaw->type),
|
||||||
|
sdbStatusName(pAction->pRaw->status));
|
||||||
|
mDebug("trans:%d, show tran action, detail:%s", pTrans->id, detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pTrans->undoActions); ++i, ++index) {
|
||||||
|
len = 0;
|
||||||
|
STransAction *pAction = taosArrayGet(pTrans->undoActions, i);
|
||||||
|
if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "action:%d, %s:%d msgType:%s\n", index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, TMSG_INFO(pAction->msgType));
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "action:%d, %s:%d sdbType:%s, sdbStatus:%s\n", index,
|
||||||
|
mndTransStr(pAction->stage), pAction->id, sdbTableName(pAction->pRaw->type),
|
||||||
|
sdbStatusName(pAction->pRaw->status));
|
||||||
|
}
|
||||||
|
mDebug("trans:%d, show tran action, detail:%s", pTrans->id, detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -2044,6 +2239,20 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false), pTrans, &lino, _OVER);
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false), pTrans, &lino, _OVER);
|
||||||
|
|
||||||
|
const char *killableStr = pTrans->ableToBeKilled ? "yes" : "no";
|
||||||
|
char killableVstr[10 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(killableVstr, killableStr, 10 + VARSTR_HEADER_SIZE);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)killableVstr, false), pTrans, &lino, _OVER);
|
||||||
|
|
||||||
|
/*
|
||||||
|
const char *killModeStr = pTrans->killMode == TRN_KILL_MODE_SKIP ? "skip" : "interrupt";
|
||||||
|
char killModeVstr[10 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(killModeVstr, killModeStr, 24);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)killModeVstr, false), pTrans, &lino, _OVER);
|
||||||
|
*/
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false), pTrans, &lino,
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false), pTrans, &lino,
|
||||||
_OVER);
|
_OVER);
|
||||||
|
@ -2061,13 +2270,15 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
len += tsnprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
len += tsnprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
||||||
TMSG_INFO(pTrans->lastMsgType), epset.numOfEps, epset.inUse);
|
TMSG_INFO(pTrans->lastMsgType), epset.numOfEps, epset.inUse);
|
||||||
for (int32_t i = 0; i < pTrans->lastEpset.numOfEps; ++i) {
|
for (int32_t i = 0; i < pTrans->lastEpset.numOfEps; ++i) {
|
||||||
len += tsnprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
len += snprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false), pTrans, &lino, _OVER);
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false), pTrans, &lino, _OVER);
|
||||||
|
|
||||||
|
mndTransLogAction(pTrans);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pTrans);
|
sdbRelease(pSdb, pTrans);
|
||||||
}
|
}
|
||||||
|
@ -2078,6 +2289,239 @@ _OVER:
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndShowTransCommonColumns(SShowObj *pShow, SSDataBlock *pBlock, STransAction *pAction,
|
||||||
|
int32_t transactionId, int32_t curActionId, int32_t numOfRows, int32_t *cols) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t len = 0;
|
||||||
|
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, (*cols)++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&transactionId, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char action[30 + 1] = {0};
|
||||||
|
if (curActionId == pAction->id) {
|
||||||
|
len += snprintf(action + len, sizeof(action) - len, "%s:%d(%s)<-last", mndTransStr(pAction->stage), pAction->id,
|
||||||
|
mndTransTypeStr(pAction->actionType));
|
||||||
|
} else {
|
||||||
|
len += snprintf(action + len, sizeof(action) - len, "%s:%d(%s)", mndTransStr(pAction->stage), pAction->id,
|
||||||
|
mndTransTypeStr(pAction->actionType));
|
||||||
|
}
|
||||||
|
char actionVStr[30 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(actionVStr, action, pShow->pMeta->pSchemas[*cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, (*cols)++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)actionVStr, false), &lino, _OVER);
|
||||||
|
_OVER:
|
||||||
|
if (code != 0) mError("failed to retrieve at line:%d, since %s", lino, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndShowTransAction(SShowObj *pShow, SSDataBlock *pBlock, STransAction *pAction, int32_t transactionId,
|
||||||
|
int32_t curActionId, int32_t rows, int32_t numOfRows) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t cols = 0;
|
||||||
|
|
||||||
|
cols = 0;
|
||||||
|
|
||||||
|
if (mndShowTransCommonColumns(pShow, pBlock, pAction, transactionId, curActionId, numOfRows, &cols) != 0) return;
|
||||||
|
|
||||||
|
if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
|
int32_t len = 0;
|
||||||
|
|
||||||
|
char objType[TSDB_TRANS_OBJTYPE_LEN + 1] = {0};
|
||||||
|
len += snprintf(objType + len, sizeof(objType) - len, "%s(s:%d,r:%d)", TMSG_INFO(pAction->msgType),
|
||||||
|
pAction->msgSent, pAction->msgReceived);
|
||||||
|
char objTypeVStr[TSDB_TRANS_OBJTYPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(objTypeVStr, objType, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)objTypeVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char result[TSDB_TRANS_RESULT_LEN + 1] = {0};
|
||||||
|
len = 0;
|
||||||
|
len += snprintf(result + len, sizeof(result) - len, "errCode:0x%x(%s)", pAction->errCode & 0xFFFF,
|
||||||
|
tstrerror(pAction->errCode));
|
||||||
|
char resultVStr[TSDB_TRANS_RESULT_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(resultVStr, result, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)resultVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char target[TSDB_TRANS_TARGET_LEN] = {0};
|
||||||
|
len = 0;
|
||||||
|
SEpSet epset = pAction->epSet;
|
||||||
|
if (epset.numOfEps > 0) {
|
||||||
|
for (int32_t i = 0; i < epset.numOfEps; ++i) {
|
||||||
|
len += snprintf(target + len, sizeof(target) - len, "ep:%d-%s:%u,", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||||
|
}
|
||||||
|
len += snprintf(target + len, sizeof(target) - len, "(%d:%d) ", epset.numOfEps, epset.inUse);
|
||||||
|
}
|
||||||
|
char targetVStr[TSDB_TRANS_TARGET_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(targetVStr, target, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)targetVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char detail[TSDB_TRANS_DETAIL_LEN] = {0};
|
||||||
|
len = 0;
|
||||||
|
char bufStart[40] = {0};
|
||||||
|
if (pAction->startTime > 0) (void)formatTimestamp(bufStart, pAction->startTime, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
char bufEnd[40] = {0};
|
||||||
|
if (pAction->endTime > 0) (void)formatTimestamp(bufEnd, pAction->endTime, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "startTime:%s, endTime:%s, ", bufStart, bufEnd);
|
||||||
|
char detailVStr[TSDB_TRANS_DETAIL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(detailVStr, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)detailVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int32_t len = 0;
|
||||||
|
|
||||||
|
char objType[TSDB_TRANS_OBJTYPE_LEN + 1] = {0};
|
||||||
|
if (pAction->pRaw->type == SDB_VGROUP) {
|
||||||
|
SSdbRow *pRow = mndVgroupActionDecode(pAction->pRaw);
|
||||||
|
SVgObj *pVgroup = sdbGetRowObj(pRow);
|
||||||
|
len += snprintf(objType + len, sizeof(objType) - len, "%s(%d)", sdbTableName(pAction->pRaw->type), pVgroup->vgId);
|
||||||
|
taosMemoryFreeClear(pRow);
|
||||||
|
} else {
|
||||||
|
strcpy(objType, sdbTableName(pAction->pRaw->type));
|
||||||
|
}
|
||||||
|
char objTypeVStr[TSDB_TRANS_OBJTYPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(objTypeVStr, objType, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)objTypeVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char result[TSDB_TRANS_RESULT_LEN + 1] = {0};
|
||||||
|
len = 0;
|
||||||
|
len += snprintf(result + len, sizeof(result) - len, "rawWritten:%d", pAction->rawWritten);
|
||||||
|
char resultVStr[TSDB_TRANS_RESULT_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(resultVStr, result, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)resultVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char target[TSDB_TRANS_TARGET_LEN] = "";
|
||||||
|
char targetVStr[TSDB_TRANS_TARGET_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(targetVStr, target, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)targetVStr, false), &lino, _OVER);
|
||||||
|
|
||||||
|
char detail[TSDB_TRANS_DETAIL_LEN] = {0};
|
||||||
|
len = 0;
|
||||||
|
len += snprintf(detail + len, sizeof(detail) - len, "sdbStatus:%s", sdbStatusName(pAction->pRaw->status));
|
||||||
|
char detailVStr[TSDB_TRANS_DETAIL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(detailVStr, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)detailVStr, false), &lino, _OVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (code != 0) mError("failed to retrieve at line:%d, since %s", lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
static SArray *mndTransGetAction(STrans *pTrans, ETrnStage stage) {
|
||||||
|
if (stage == TRN_STAGE_PREPARE) {
|
||||||
|
return pTrans->prepareActions;
|
||||||
|
}
|
||||||
|
if (stage == TRN_STAGE_REDO_ACTION) {
|
||||||
|
return pTrans->redoActions;
|
||||||
|
}
|
||||||
|
if (stage == TRN_STAGE_COMMIT_ACTION) {
|
||||||
|
return pTrans->commitActions;
|
||||||
|
}
|
||||||
|
if (stage == TRN_STAGE_UNDO_ACTION) {
|
||||||
|
return pTrans->undoActions;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct STransDetailIter {
|
||||||
|
void *pIter;
|
||||||
|
STrans *pTrans;
|
||||||
|
ETrnStage stage;
|
||||||
|
int32_t num;
|
||||||
|
} STransDetailIter;
|
||||||
|
|
||||||
|
static void mndTransShowActions(SSdb *pSdb, STransDetailIter *pShowIter, SShowObj *pShow, SSDataBlock *pBlock,
|
||||||
|
int32_t rows, int32_t *numOfRows, SArray *pActions, int32_t end, int32_t start) {
|
||||||
|
int32_t actionNum = taosArrayGetSize(pActions);
|
||||||
|
mInfo("stage:%s, Actions num:%d", mndTransStr(pShowIter->stage), actionNum);
|
||||||
|
|
||||||
|
for (int32_t i = start; i < actionNum; ++i) {
|
||||||
|
STransAction *pAction = taosArrayGet(pShowIter->pTrans->redoActions, i);
|
||||||
|
mndShowTransAction(pShow, pBlock, pAction, pShowIter->pTrans->id, pShowIter->pTrans->lastAction, rows, *numOfRows);
|
||||||
|
(*numOfRows)++;
|
||||||
|
if (*numOfRows >= rows) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*numOfRows == end) {
|
||||||
|
sdbRelease(pSdb, pShowIter->pTrans);
|
||||||
|
pShowIter->pTrans = NULL;
|
||||||
|
pShowIter->num = 0;
|
||||||
|
} else {
|
||||||
|
pShowIter->pTrans = pShowIter->pTrans;
|
||||||
|
pShowIter->stage = pShowIter->pTrans->stage;
|
||||||
|
pShowIter->num += (*numOfRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndRetrieveTransDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
mInfo("start to mndRetrieveTransDetail, rows:%d, pShow->numOfRows:%d, pShow->pIter:%p", rows, pShow->numOfRows,
|
||||||
|
pShow->pIter);
|
||||||
|
|
||||||
|
if (pShow->pIter == NULL) {
|
||||||
|
pShow->pIter = taosMemoryMalloc(sizeof(STransDetailIter));
|
||||||
|
if (pShow->pIter == NULL) {
|
||||||
|
mError("failed to malloc for pShow->pIter");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(pShow->pIter, 0, sizeof(STransDetailIter));
|
||||||
|
}
|
||||||
|
|
||||||
|
STransDetailIter *pShowIter = (STransDetailIter *)pShow->pIter;
|
||||||
|
|
||||||
|
while (numOfRows < rows) {
|
||||||
|
if (pShowIter->pTrans == NULL) {
|
||||||
|
pShowIter->pIter = sdbFetch(pSdb, SDB_TRANS, pShowIter->pIter, (void **)&(pShowIter->pTrans));
|
||||||
|
mDebug("retrieve trans detail from fetch, pShow->pIter:%p, pTrans:%p", pShowIter->pIter, pShowIter->pTrans);
|
||||||
|
if (pShowIter->pIter == NULL) break;
|
||||||
|
mInfo("retrieve trans detail from fetch, id:%d, trans stage:%d, IterNum:%d", pShowIter->pTrans->id,
|
||||||
|
pShowIter->pTrans->stage, pShowIter->num);
|
||||||
|
|
||||||
|
SArray *pActions = mndTransGetAction(pShowIter->pTrans, pShowIter->pTrans->stage);
|
||||||
|
|
||||||
|
mndTransShowActions(pSdb, pShowIter, pShow, pBlock, rows, &numOfRows, pActions, taosArrayGetSize(pActions), 0);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
mInfo("retrieve trans detail from iter, id:%d, iterStage:%d, IterNum:%d", pShowIter->pTrans->id, pShowIter->stage,
|
||||||
|
pShowIter->num);
|
||||||
|
SArray *pActions = mndTransGetAction(pShowIter->pTrans, pShowIter->stage);
|
||||||
|
|
||||||
|
mndTransShowActions(pSdb, pShowIter, pShow, pBlock, rows, &numOfRows, pActions,
|
||||||
|
taosArrayGetSize(pActions) - pShowIter->num, pShowIter->num);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
pShow->numOfRows += numOfRows;
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to retrieve at line:%d, since %s", lino, tstrerror(code));
|
||||||
|
} else {
|
||||||
|
mInfo("retrieve trans detail, numOfRows:%d, pShow->numOfRows:%d", numOfRows, pShow->numOfRows)
|
||||||
|
}
|
||||||
|
if (numOfRows == 0) {
|
||||||
|
taosMemoryFree(pShow->pIter);
|
||||||
|
pShow->pIter = NULL;
|
||||||
|
}
|
||||||
|
return numOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter) {
|
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
sdbCancelFetchByType(pSdb, pIter, SDB_TRANS);
|
sdbCancelFetchByType(pSdb, pIter, SDB_TRANS);
|
||||||
|
|
|
@ -2766,12 +2766,14 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
||||||
|
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
|
|
||||||
if (pNewVgroup->replica == 1 && pNewDb->cfg.replications == 3) {
|
if (pNewDb->cfg.replications == 3) {
|
||||||
mInfo("db:%s, vgId:%d, will add 2 vnodes, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
mInfo("db:%s, vgId:%d, will add 2 vnodes, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
||||||
pVgroup->vnodeGid[0].dnodeId);
|
pVgroup->vnodeGid[0].dnodeId);
|
||||||
|
|
||||||
// add second
|
// add second
|
||||||
TAOS_CHECK_RETURN(mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray));
|
if (pNewVgroup->replica == 1){
|
||||||
|
TAOS_CHECK_RETURN(mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray));
|
||||||
|
}
|
||||||
|
|
||||||
// learner stage
|
// learner stage
|
||||||
pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER;
|
pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER;
|
||||||
|
@ -2790,7 +2792,9 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
||||||
TAOS_CHECK_RETURN(mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup));
|
TAOS_CHECK_RETURN(mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup));
|
||||||
|
|
||||||
// add third
|
// add third
|
||||||
TAOS_CHECK_RETURN(mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray));
|
if (pNewVgroup->replica == 2){
|
||||||
|
TAOS_CHECK_RETURN (mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray));
|
||||||
|
}
|
||||||
|
|
||||||
pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER;
|
pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER;
|
||||||
pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER;
|
pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER;
|
||||||
|
@ -2802,7 +2806,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
||||||
TAOS_CHECK_RETURN(mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &pNewVgroup->vnodeGid[2]));
|
TAOS_CHECK_RETURN(mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &pNewVgroup->vnodeGid[2]));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup));
|
TAOS_CHECK_RETURN(mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup));
|
||||||
} else if (pNewVgroup->replica == 3 && pNewDb->cfg.replications == 1) {
|
} else if (pNewDb->cfg.replications == 1) {
|
||||||
mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName,
|
mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName,
|
||||||
pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId);
|
pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId);
|
||||||
|
|
||||||
|
@ -2819,9 +2823,9 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
|
||||||
TAOS_CHECK_RETURN(mndRemoveVnodeFromVgroup(pMnode, pTrans, pNewVgroup, pArray, &del2));
|
TAOS_CHECK_RETURN(mndRemoveVnodeFromVgroup(pMnode, pTrans, pNewVgroup, pArray, &del2));
|
||||||
TAOS_CHECK_RETURN(mndAddDropVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &del2, true));
|
TAOS_CHECK_RETURN(mndAddDropVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &del2, true));
|
||||||
TAOS_CHECK_RETURN(
|
TAOS_CHECK_RETURN(
|
||||||
mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId));
|
mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId));
|
||||||
TAOS_CHECK_RETURN(mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup));
|
TAOS_CHECK_RETURN(mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup));
|
||||||
} else if (pNewVgroup->replica == 1 && pNewDb->cfg.replications == 2) {
|
} else if (pNewDb->cfg.replications == 2) {
|
||||||
mInfo("db:%s, vgId:%d, will add 1 vnode, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
mInfo("db:%s, vgId:%d, will add 1 vnode, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
||||||
pVgroup->vnodeGid[0].dnodeId);
|
pVgroup->vnodeGid[0].dnodeId);
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) {
|
||||||
int32_t nowMs = group.members[0].state.lastHbMs + 10;
|
int32_t nowMs = group.members[0].state.lastHbMs + 10;
|
||||||
|
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup);
|
bool updateToken = mndCheckArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup);
|
||||||
|
|
||||||
ASSERT_EQ(updateToken, false);
|
ASSERT_EQ(updateToken, false);
|
||||||
ASSERT_NE(group.members[0].state.responsedHbSeq, rspMember.hbSeq);
|
ASSERT_NE(group.members[0].state.responsedHbSeq, rspMember.hbSeq);
|
||||||
|
@ -142,7 +142,7 @@ TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) {
|
||||||
int32_t nowMs = group.members[0].state.lastHbMs + 10;
|
int32_t nowMs = group.members[0].state.lastHbMs + 10;
|
||||||
|
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup);
|
bool updateToken = mndCheckArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup);
|
||||||
|
|
||||||
ASSERT_EQ(updateToken, false);
|
ASSERT_EQ(updateToken, false);
|
||||||
ASSERT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq);
|
ASSERT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq);
|
||||||
|
@ -157,7 +157,7 @@ TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) {
|
||||||
int32_t nowMs = group.members[0].state.lastHbMs + 10;
|
int32_t nowMs = group.members[0].state.lastHbMs + 10;
|
||||||
|
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup);
|
bool updateToken = mndCheckArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup);
|
||||||
|
|
||||||
ASSERT_EQ(updateToken, true);
|
ASSERT_EQ(updateToken, true);
|
||||||
ASSERT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq);
|
ASSERT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq);
|
||||||
|
@ -201,7 +201,7 @@ TEST_F(ArbgroupTest, 03_process_check_sync_rsp) {
|
||||||
bool newIsSync = false;
|
bool newIsSync = false;
|
||||||
|
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup);
|
bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup, 0);
|
||||||
|
|
||||||
ASSERT_EQ(updateIsSync, false);
|
ASSERT_EQ(updateIsSync, false);
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ TEST_F(ArbgroupTest, 03_process_check_sync_rsp) {
|
||||||
bool newIsSync = true;
|
bool newIsSync = true;
|
||||||
|
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup);
|
bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup, 0);
|
||||||
|
|
||||||
ASSERT_EQ(updateIsSync, true);
|
ASSERT_EQ(updateIsSync, true);
|
||||||
ASSERT_EQ(newGroup.isSync, true);
|
ASSERT_EQ(newGroup.isSync, true);
|
||||||
|
|
|
@ -75,6 +75,7 @@ set(
|
||||||
"src/tq/tqSnapshot.c"
|
"src/tq/tqSnapshot.c"
|
||||||
"src/tq/tqStreamStateSnap.c"
|
"src/tq/tqStreamStateSnap.c"
|
||||||
"src/tq/tqStreamTaskSnap.c"
|
"src/tq/tqStreamTaskSnap.c"
|
||||||
|
"src/tq/tqStreamNotify.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
aux_source_directory("src/tsdb/" TSDB_SOURCE_FILES)
|
aux_source_directory("src/tsdb/" TSDB_SOURCE_FILES)
|
||||||
|
|
|
@ -159,6 +159,11 @@ int32_t buildAutoCreateTableReq(const char* stbFullName, int64_t suid, int32_t n
|
||||||
SArray* pTagArray, bool newSubTableRule, SVCreateTbReq** pReq);
|
SArray* pTagArray, bool newSubTableRule, SVCreateTbReq** pReq);
|
||||||
int32_t tqExtractDropCtbDataBlock(const void* data, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
int32_t tqExtractDropCtbDataBlock(const void* data, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
||||||
|
|
||||||
|
// tq send notifications
|
||||||
|
int32_t tqInitNotifyHandleMap(SStreamNotifyHandleMap** ppMap);
|
||||||
|
void tqDestroyNotifyHandleMap(SStreamNotifyHandleMap** ppMap);
|
||||||
|
int32_t tqSendAllNotifyEvents(const SArray* pBlocks, SStreamTask* pTask, SVnode* pVnode);
|
||||||
|
|
||||||
#define TQ_ERR_GO_TO_END(c) \
|
#define TQ_ERR_GO_TO_END(c) \
|
||||||
do { \
|
do { \
|
||||||
code = c; \
|
code = c; \
|
||||||
|
|
|
@ -1083,6 +1083,9 @@ void tsdbRemoveFile(const char *path);
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
int32_t tsdbAllocateDisk(STsdb *tsdb, const char *label, int32_t expLevel, SDiskID *diskId);
|
||||||
|
int32_t tsdbAllocateDiskAtLevel(STsdb *tsdb, int32_t level, const char *label, SDiskID *diskId);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,6 +81,8 @@ typedef struct SCommitInfo SCommitInfo;
|
||||||
typedef struct SCompactInfo SCompactInfo;
|
typedef struct SCompactInfo SCompactInfo;
|
||||||
typedef struct SQueryNode SQueryNode;
|
typedef struct SQueryNode SQueryNode;
|
||||||
|
|
||||||
|
typedef struct SStreamNotifyHandleMap SStreamNotifyHandleMap;
|
||||||
|
|
||||||
#define VNODE_META_TMP_DIR "meta.tmp"
|
#define VNODE_META_TMP_DIR "meta.tmp"
|
||||||
#define VNODE_META_BACKUP_DIR "meta.backup"
|
#define VNODE_META_BACKUP_DIR "meta.backup"
|
||||||
|
|
||||||
|
@ -499,6 +501,9 @@ struct SVnode {
|
||||||
int64_t blockSeq;
|
int64_t blockSeq;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
SVMonitorObj monitor;
|
SVMonitorObj monitor;
|
||||||
|
|
||||||
|
// Notification Handles
|
||||||
|
SStreamNotifyHandleMap* pNotifyHandleMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
#define IS_NEW_SUBTB_RULE(_t) (((_t)->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER) && ((_t)->subtableWithoutMd5 != 1))
|
|
||||||
|
|
||||||
typedef struct STableSinkInfo {
|
typedef struct STableSinkInfo {
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
tstr name;
|
tstr name;
|
||||||
|
@ -991,7 +989,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
||||||
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
||||||
if (pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
if (pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||||
code = buildCtbNameAddGroupId(NULL, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
code = buildCtbNameAddGroupId(NULL, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||||
} else if (pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER && stbFullName) {
|
} else if (pTask->ver >= SSTREAM_TASK_APPEND_STABLE_NAME_VER && stbFullName) {
|
||||||
code = buildCtbNameAddGroupId(stbFullName, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
code = buildCtbNameAddGroupId(stbFullName, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||||
}
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1158,6 +1156,12 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code = tqSendAllNotifyEvents(pBlocks, pTask, pVnode);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("vgId: %d, s-task:%s failed to send all event notifications", vgId, id);
|
||||||
|
// continue processing even if notification fails
|
||||||
|
}
|
||||||
|
|
||||||
bool onlySubmitData = hasOnlySubmitData(pBlocks, numOfBlocks);
|
bool onlySubmitData = hasOnlySubmitData(pBlocks, numOfBlocks);
|
||||||
if (!onlySubmitData || pTask->subtableWithoutMd5 == 1) {
|
if (!onlySubmitData || pTask->subtableWithoutMd5 == 1) {
|
||||||
tqDebug("vgId:%d, s-task:%s write %d stream resBlock(s) into table, has delete block, submit one-by-one", vgId, id,
|
tqDebug("vgId:%d, s-task:%s write %d stream resBlock(s) into table, has delete block, submit one-by-one", vgId, id,
|
||||||
|
@ -1181,6 +1185,8 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
continue;
|
continue;
|
||||||
} else if (pDataBlock->info.type == STREAM_DROP_CHILD_TABLE && pTask->subtableWithoutMd5) {
|
} else if (pDataBlock->info.type == STREAM_DROP_CHILD_TABLE && pTask->subtableWithoutMd5) {
|
||||||
code = doBuildAndSendDropTableMsg(pVnode, stbFullName, pDataBlock, pTask, suid);
|
code = doBuildAndSendDropTableMsg(pVnode, stbFullName, pDataBlock, pTask, suid);
|
||||||
|
} else if (pDataBlock->info.type == STREAM_NOTIFY_EVENT) {
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
code = handleResultBlockMsg(pTask, pDataBlock, i, pVnode, earlyTs);
|
code = handleResultBlockMsg(pTask, pDataBlock, i, pVnode, earlyTs);
|
||||||
}
|
}
|
||||||
|
@ -1325,6 +1331,10 @@ void rebuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVno
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pDataBlock->info.type == STREAM_NOTIFY_EVENT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
hasSubmit = true;
|
hasSubmit = true;
|
||||||
pTask->execInfo.sink.numOfBlocks += 1;
|
pTask->execInfo.sink.numOfBlocks += 1;
|
||||||
uint64_t groupId = pDataBlock->info.id.groupId;
|
uint64_t groupId = pDataBlock->info.id.groupId;
|
||||||
|
|
|
@ -0,0 +1,445 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cmdnodes.h"
|
||||||
|
#include "tq.h"
|
||||||
|
|
||||||
|
#ifndef WINDOWS
|
||||||
|
#include "curl/curl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STREAM_EVENT_NOTIFY_RETRY_MS 50 // 50ms
|
||||||
|
|
||||||
|
typedef struct SStreamNotifyHandle {
|
||||||
|
TdThreadMutex mutex;
|
||||||
|
#ifndef WINDOWS
|
||||||
|
CURL* curl;
|
||||||
|
#endif
|
||||||
|
char* url;
|
||||||
|
} SStreamNotifyHandle;
|
||||||
|
|
||||||
|
struct SStreamNotifyHandleMap {
|
||||||
|
TdThreadMutex gMutex;
|
||||||
|
SHashObj* handleMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void stopStreamNotifyConn(SStreamNotifyHandle* pHandle) {
|
||||||
|
#ifndef WINDOWS
|
||||||
|
if (pHandle == NULL || pHandle->curl == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// status code 1000 means normal closure
|
||||||
|
size_t len = 0;
|
||||||
|
uint16_t status = htons(1000);
|
||||||
|
CURLcode res = curl_ws_send(pHandle->curl, &status, sizeof(status), &len, 0, CURLWS_CLOSE);
|
||||||
|
if (res != CURLE_OK) {
|
||||||
|
tqWarn("failed to send ws-close msg to %s for %d", pHandle->url ? pHandle->url : "", res);
|
||||||
|
}
|
||||||
|
// TODO: add wait mechanism for peer connection close response
|
||||||
|
curl_easy_cleanup(pHandle->curl);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void destroyStreamNotifyHandle(void* ptr) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
SStreamNotifyHandle** ppHandle = ptr;
|
||||||
|
|
||||||
|
if (ppHandle == NULL || *ppHandle == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
code = taosThreadMutexDestroy(&(*ppHandle)->mutex);
|
||||||
|
stopStreamNotifyConn(*ppHandle);
|
||||||
|
taosMemoryFreeClear((*ppHandle)->url);
|
||||||
|
taosMemoryFreeClear(*ppHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void releaseStreamNotifyHandle(SStreamNotifyHandle** ppHandle) {
|
||||||
|
if (ppHandle == NULL || *ppHandle == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(void)taosThreadMutexUnlock(&(*ppHandle)->mutex);
|
||||||
|
*ppHandle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t acquireStreamNotifyHandle(SStreamNotifyHandleMap* pMap, const char* url,
|
||||||
|
SStreamNotifyHandle** ppHandle) {
|
||||||
|
#ifndef WINDOWS
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
bool gLocked = false;
|
||||||
|
SStreamNotifyHandle** ppFindHandle = NULL;
|
||||||
|
SStreamNotifyHandle* pNewHandle = NULL;
|
||||||
|
CURL* newCurl = NULL;
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(pMap, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(url, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(ppHandle, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
*ppHandle = NULL;
|
||||||
|
|
||||||
|
code = taosThreadMutexLock(&pMap->gMutex);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
gLocked = true;
|
||||||
|
|
||||||
|
ppFindHandle = taosHashGet(pMap->handleMap, url, strlen(url));
|
||||||
|
if (ppFindHandle == NULL) {
|
||||||
|
pNewHandle = taosMemoryCalloc(1, sizeof(SStreamNotifyHandle));
|
||||||
|
TSDB_CHECK_NULL(pNewHandle, code, lino, _end, terrno);
|
||||||
|
code = taosThreadMutexInit(&pNewHandle->mutex, NULL);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
code = taosHashPut(pMap->handleMap, url, strlen(url), &pNewHandle, POINTER_BYTES);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
*ppHandle = pNewHandle;
|
||||||
|
pNewHandle = NULL;
|
||||||
|
} else {
|
||||||
|
*ppHandle = *ppFindHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = taosThreadMutexLock(&(*ppHandle)->mutex);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
(void)taosThreadMutexUnlock(&pMap->gMutex);
|
||||||
|
gLocked = false;
|
||||||
|
|
||||||
|
if ((*ppHandle)->curl == NULL) {
|
||||||
|
newCurl = curl_easy_init();
|
||||||
|
TSDB_CHECK_NULL(newCurl, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
res = curl_easy_setopt(newCurl, CURLOPT_URL, url);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
res = curl_easy_setopt(newCurl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
res = curl_easy_setopt(newCurl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
res = curl_easy_setopt(newCurl, CURLOPT_TIMEOUT, 3L);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
res = curl_easy_setopt(newCurl, CURLOPT_CONNECT_ONLY, 2L);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
res = curl_easy_perform(newCurl);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
(*ppHandle)->curl = newCurl;
|
||||||
|
newCurl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*ppHandle)->url == NULL) {
|
||||||
|
(*ppHandle)->url = taosStrdup(url);
|
||||||
|
TSDB_CHECK_NULL((*ppHandle)->url, code, lino, _end, terrno);
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("%s failed at line %d since %d, %s", __func__, lino, res, tstrerror(code));
|
||||||
|
if (*ppHandle) {
|
||||||
|
releaseStreamNotifyHandle(ppHandle);
|
||||||
|
}
|
||||||
|
*ppHandle = NULL;
|
||||||
|
}
|
||||||
|
if (newCurl) {
|
||||||
|
curl_easy_cleanup(newCurl);
|
||||||
|
}
|
||||||
|
if (pNewHandle) {
|
||||||
|
destroyStreamNotifyHandle(&pNewHandle);
|
||||||
|
}
|
||||||
|
if (gLocked) {
|
||||||
|
(void)taosThreadMutexUnlock(&pMap->gMutex);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
#else
|
||||||
|
tqError("stream notify events is not supported on windows");
|
||||||
|
return TSDB_CODE_NOT_SUPPORTTED_IN_WINDOWS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqInitNotifyHandleMap(SStreamNotifyHandleMap** ppMap) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
SStreamNotifyHandleMap* pMap = NULL;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(ppMap, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
*ppMap = NULL;
|
||||||
|
pMap = taosMemoryCalloc(1, sizeof(SStreamNotifyHandleMap));
|
||||||
|
TSDB_CHECK_NULL(pMap, code, lino, _end, terrno);
|
||||||
|
code = taosThreadMutexInit(&pMap->gMutex, NULL);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
pMap->handleMap = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
TSDB_CHECK_NULL(pMap->handleMap, code, lino, _end, terrno);
|
||||||
|
taosHashSetFreeFp(pMap->handleMap, destroyStreamNotifyHandle);
|
||||||
|
*ppMap = pMap;
|
||||||
|
pMap = NULL;
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
if (pMap != NULL) {
|
||||||
|
tqDestroyNotifyHandleMap(&pMap);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tqDestroyNotifyHandleMap(SStreamNotifyHandleMap** ppMap) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
if (*ppMap == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taosHashCleanup((*ppMap)->handleMap);
|
||||||
|
code = taosThreadMutexDestroy(&(*ppMap)->gMutex);
|
||||||
|
taosMemoryFreeClear((*ppMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define JSON_CHECK_ADD_ITEM(obj, str, item) \
|
||||||
|
TSDB_CHECK_CONDITION(cJSON_AddItemToObjectCS(obj, str, item), code, lino, _end, TSDB_CODE_OUT_OF_MEMORY)
|
||||||
|
|
||||||
|
static int32_t getStreamNotifyEventHeader(const char* streamName, char** pHeader) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
cJSON* obj = NULL;
|
||||||
|
cJSON* streams = NULL;
|
||||||
|
cJSON* stream = NULL;
|
||||||
|
char msgId[37];
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(streamName, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(pHeader, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
*pHeader = NULL;
|
||||||
|
|
||||||
|
code = taosGetSystemUUIDLimit36(msgId, sizeof(msgId));
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
stream = cJSON_CreateObject();
|
||||||
|
TSDB_CHECK_NULL(stream, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
JSON_CHECK_ADD_ITEM(stream, "streamName", cJSON_CreateStringReference(streamName));
|
||||||
|
JSON_CHECK_ADD_ITEM(stream, "events", cJSON_CreateArray());
|
||||||
|
|
||||||
|
streams = cJSON_CreateArray();
|
||||||
|
TSDB_CHECK_CONDITION(cJSON_AddItemToArray(streams, stream), code, lino, _end, TSDB_CODE_OUT_OF_MEMORY)
|
||||||
|
stream = NULL;
|
||||||
|
|
||||||
|
obj = cJSON_CreateObject();
|
||||||
|
TSDB_CHECK_NULL(obj, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
JSON_CHECK_ADD_ITEM(obj, "messageId", cJSON_CreateStringReference(msgId));
|
||||||
|
JSON_CHECK_ADD_ITEM(obj, "timestamp", cJSON_CreateNumber(taosGetTimestampMs()));
|
||||||
|
JSON_CHECK_ADD_ITEM(obj, "streams", streams);
|
||||||
|
streams = NULL;
|
||||||
|
|
||||||
|
*pHeader = cJSON_PrintUnformatted(obj);
|
||||||
|
TSDB_CHECK_NULL(*pHeader, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
if (stream != NULL) {
|
||||||
|
cJSON_Delete(stream);
|
||||||
|
}
|
||||||
|
if (streams != NULL) {
|
||||||
|
cJSON_Delete(streams);
|
||||||
|
}
|
||||||
|
if (obj != NULL) {
|
||||||
|
cJSON_Delete(obj);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t packupStreamNotifyEvent(const char* streamName, const SArray* pBlocks, char** pMsg,
|
||||||
|
int32_t* nNotifyEvents) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t numOfBlocks = 0;
|
||||||
|
int32_t msgHeaderLen = 0;
|
||||||
|
int32_t msgTailLen = 0;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
char* msgHeader = NULL;
|
||||||
|
const char* msgTail = "]}]}";
|
||||||
|
char* msg = NULL;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(pMsg, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
*pMsg = NULL;
|
||||||
|
numOfBlocks = taosArrayGetSize(pBlocks);
|
||||||
|
*nNotifyEvents = 0;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||||
|
if (pDataBlock == NULL || pDataBlock->info.type != STREAM_NOTIFY_EVENT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumnInfoData* pEventStrCol = taosArrayGet(pDataBlock->pDataBlock, NOTIFY_EVENT_STR_COLUMN_INDEX);
|
||||||
|
for (int32_t j = 0; j < pDataBlock->info.rows; ++j) {
|
||||||
|
char* val = colDataGetVarData(pEventStrCol, j);
|
||||||
|
msgLen += varDataLen(val) + 1;
|
||||||
|
}
|
||||||
|
*nNotifyEvents += pDataBlock->info.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msgLen == 0) {
|
||||||
|
// skip since no notification events found
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = getStreamNotifyEventHeader(streamName, &msgHeader);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
msgHeaderLen = strlen(msgHeader);
|
||||||
|
msgTailLen = strlen(msgTail);
|
||||||
|
msgLen += msgHeaderLen;
|
||||||
|
|
||||||
|
msg = taosMemoryMalloc(msgLen);
|
||||||
|
TSDB_CHECK_NULL(msg, code, lino, _end, terrno);
|
||||||
|
char* p = msg;
|
||||||
|
TAOS_STRNCPY(p, msgHeader, msgHeaderLen);
|
||||||
|
p += msgHeaderLen - msgTailLen;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||||
|
if (pDataBlock == NULL || pDataBlock->info.type != STREAM_NOTIFY_EVENT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumnInfoData* pEventStrCol = taosArrayGet(pDataBlock->pDataBlock, NOTIFY_EVENT_STR_COLUMN_INDEX);
|
||||||
|
for (int32_t j = 0; j < pDataBlock->info.rows; ++j) {
|
||||||
|
char* val = colDataGetVarData(pEventStrCol, j);
|
||||||
|
TAOS_STRNCPY(p, varDataVal(val), varDataLen(val));
|
||||||
|
p += varDataLen(val);
|
||||||
|
*(p++) = ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p -= 1;
|
||||||
|
TAOS_STRNCPY(p, msgTail, msgTailLen);
|
||||||
|
*(p + msgTailLen) = '\0';
|
||||||
|
|
||||||
|
*pMsg = msg;
|
||||||
|
msg = NULL;
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
if (msgHeader != NULL) {
|
||||||
|
cJSON_free(msgHeader);
|
||||||
|
}
|
||||||
|
if (msg != NULL) {
|
||||||
|
taosMemoryFreeClear(msg);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sendSingleStreamNotify(SStreamNotifyHandle* pHandle, char* msg) {
|
||||||
|
#ifndef WINDOWS
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
uint64_t sentLen = 0;
|
||||||
|
uint64_t totalLen = 0;
|
||||||
|
size_t nbytes = 0;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(pHandle, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(pHandle->curl, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
totalLen = strlen(msg);
|
||||||
|
while (sentLen < totalLen) {
|
||||||
|
res = curl_ws_send(pHandle->curl, msg + sentLen, totalLen - sentLen, &nbytes, 0, CURLWS_TEXT);
|
||||||
|
TSDB_CHECK_CONDITION(res == CURLE_OK, code, lino, _end, TSDB_CODE_FAILED);
|
||||||
|
sentLen += nbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("%s failed at line %d since %d, %s", __func__, lino, res, tstrerror(code));
|
||||||
|
stopStreamNotifyConn(pHandle);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
#else
|
||||||
|
tqError("stream notify events is not supported on windows");
|
||||||
|
return TSDB_CODE_NOT_SUPPORTTED_IN_WINDOWS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqSendAllNotifyEvents(const SArray* pBlocks, SStreamTask* pTask, SVnode* pVnode) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
|
char* msg = NULL;
|
||||||
|
int32_t nNotifyAddr = 0;
|
||||||
|
int32_t nNotifyEvents = 0;
|
||||||
|
SStreamNotifyHandle* pHandle = NULL;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(pTask, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
TSDB_CHECK_NULL(pVnode, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
|
nNotifyAddr = taosArrayGetSize(pTask->notifyInfo.pNotifyAddrUrls);
|
||||||
|
if (nNotifyAddr == 0) {
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = packupStreamNotifyEvent(pTask->notifyInfo.streamName, pBlocks, &msg, &nNotifyEvents);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
if (msg == NULL) {
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
tqDebug("stream task %s prepare to send %d notify events, total msg length: %" PRIu64, pTask->notifyInfo.streamName,
|
||||||
|
nNotifyEvents, (uint64_t)strlen(msg));
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < nNotifyAddr; ++i) {
|
||||||
|
if (streamTaskShouldStop(pTask)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const char* url = taosArrayGetP(pTask->notifyInfo.pNotifyAddrUrls, i);
|
||||||
|
code = acquireStreamNotifyHandle(pVnode->pNotifyHandleMap, url, &pHandle);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("failed to get stream notify handle of %s", url);
|
||||||
|
if (pTask->notifyInfo.notifyErrorHandle == SNOTIFY_ERROR_HANDLE_PAUSE) {
|
||||||
|
// retry for event message sending in PAUSE error handling mode
|
||||||
|
taosMsleep(STREAM_EVENT_NOTIFY_RETRY_MS);
|
||||||
|
--i;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// simply ignore the failure in DROP error handling mode
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
code = sendSingleStreamNotify(pHandle, msg);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("failed to send stream notify handle to %s since %s", url, tstrerror(code));
|
||||||
|
if (pTask->notifyInfo.notifyErrorHandle == SNOTIFY_ERROR_HANDLE_PAUSE) {
|
||||||
|
// retry for event message sending in PAUSE error handling mode
|
||||||
|
taosMsleep(STREAM_EVENT_NOTIFY_RETRY_MS);
|
||||||
|
--i;
|
||||||
|
} else {
|
||||||
|
// simply ignore the failure in DROP error handling mode
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tqDebug("stream task %s send %d notify events to %s successfully", pTask->notifyInfo.streamName, nNotifyEvents,
|
||||||
|
url);
|
||||||
|
}
|
||||||
|
releaseStreamNotifyHandle(&pHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
if (msg) {
|
||||||
|
taosMemoryFreeClear(msg);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
|
@ -86,6 +86,14 @@ int32_t tqExpandStreamTask(SStreamTask* pTask) {
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code =
|
||||||
|
qSetStreamNotifyInfo(pTask->exec.pExecutor, pTask->notifyInfo.notifyEventTypes,
|
||||||
|
pTask->notifyInfo.pSchemaWrapper, pTask->notifyInfo.stbFullName, IS_NEW_SUBTB_RULE(pTask));
|
||||||
|
if (code) {
|
||||||
|
tqError("s-task:%s failed to set stream notify info, code:%s", pTask->id.idStr, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamSetupScheduleTrigger(pTask);
|
streamSetupScheduleTrigger(pTask);
|
||||||
|
@ -1358,4 +1366,4 @@ int32_t tqStreamTaskProcessConsenChkptIdReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ typedef struct {
|
||||||
SFileSetCommitInfo *info;
|
SFileSetCommitInfo *info;
|
||||||
|
|
||||||
int32_t expLevel;
|
int32_t expLevel;
|
||||||
SDiskID did;
|
|
||||||
TSKEY minKey;
|
TSKEY minKey;
|
||||||
TSKEY maxKey;
|
TSKEY maxKey;
|
||||||
TABLEID tbid[1];
|
TABLEID tbid[1];
|
||||||
|
@ -75,7 +74,7 @@ static int32_t tsdbCommitOpenWriter(SCommitter2 *committer) {
|
||||||
.cmprAlg = committer->cmprAlg,
|
.cmprAlg = committer->cmprAlg,
|
||||||
.fid = committer->ctx->info->fid,
|
.fid = committer->ctx->info->fid,
|
||||||
.cid = committer->cid,
|
.cid = committer->cid,
|
||||||
.did = committer->ctx->did,
|
.expLevel = committer->ctx->expLevel,
|
||||||
.level = 0,
|
.level = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -328,12 +327,6 @@ static int32_t tsdbCommitFileSetBegin(SCommitter2 *committer) {
|
||||||
tsdbFidKeyRange(committer->ctx->info->fid, committer->minutes, committer->precision, &committer->ctx->minKey,
|
tsdbFidKeyRange(committer->ctx->info->fid, committer->minutes, committer->precision, &committer->ctx->minKey,
|
||||||
&committer->ctx->maxKey);
|
&committer->ctx->maxKey);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tfsAllocDisk(committer->tsdb->pVnode->pTfs, committer->ctx->expLevel, &committer->ctx->did), &lino,
|
|
||||||
_exit);
|
|
||||||
|
|
||||||
if (tfsMkdirRecurAt(committer->tsdb->pVnode->pTfs, committer->tsdb->path, committer->ctx->did) != 0) {
|
|
||||||
tsdbError("vgId:%d failed to create directory %s", TD_VID(committer->tsdb->pVnode), committer->tsdb->path);
|
|
||||||
}
|
|
||||||
committer->ctx->tbid->suid = 0;
|
committer->ctx->tbid->suid = 0;
|
||||||
committer->ctx->tbid->uid = 0;
|
committer->ctx->tbid->uid = 0;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ typedef struct SDataFileRAWWriterConfig {
|
||||||
STsdb *tsdb;
|
STsdb *tsdb;
|
||||||
int32_t szPage;
|
int32_t szPage;
|
||||||
|
|
||||||
SDiskID did;
|
|
||||||
int64_t fid;
|
int64_t fid;
|
||||||
int64_t cid;
|
int64_t cid;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
|
@ -99,14 +98,12 @@ typedef struct SDataFileRAWWriter {
|
||||||
STsdbFD *fd;
|
STsdbFD *fd;
|
||||||
} SDataFileRAWWriter;
|
} SDataFileRAWWriter;
|
||||||
|
|
||||||
typedef struct SDataFileRAWWriter SDataFileRAWWriter;
|
|
||||||
|
|
||||||
int32_t tsdbDataFileRAWWriterOpen(const SDataFileRAWWriterConfig *config, SDataFileRAWWriter **writer);
|
int32_t tsdbDataFileRAWWriterOpen(const SDataFileRAWWriterConfig *config, SDataFileRAWWriter **writer);
|
||||||
int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFileOpArray *opArr);
|
int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFileOpArray *opArr);
|
||||||
|
|
||||||
int32_t tsdbDataFileRAWWriterDoOpen(SDataFileRAWWriter *writer);
|
int32_t tsdbDataFileRAWWriterDoOpen(SDataFileRAWWriter *writer);
|
||||||
int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *bHdr,
|
int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *bHdr,
|
||||||
int32_t encryptAlgorithm, char* encryptKey);
|
int32_t encryptAlgorithm, char *encryptKey);
|
||||||
int32_t tsdbDataFileRAWFlush(SDataFileRAWWriter *writer);
|
int32_t tsdbDataFileRAWFlush(SDataFileRAWWriter *writer);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -299,6 +299,7 @@ extern int32_t tBlockDataDecompress(SBufferReader *br, SBlockData *blockData, SB
|
||||||
int32_t tsdbDataFileReadBlockData(SDataFileReader *reader, const SBrinRecord *record, SBlockData *bData) {
|
int32_t tsdbDataFileReadBlockData(SDataFileReader *reader, const SBrinRecord *record, SBlockData *bData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
int32_t fid = reader->config->files[TSDB_FTYPE_DATA].file.fid;
|
||||||
|
|
||||||
SBuffer *buffer = reader->buffers + 0;
|
SBuffer *buffer = reader->buffers + 0;
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
@ -321,8 +322,8 @@ int32_t tsdbDataFileReadBlockData(SDataFileReader *reader, const SBrinRecord *re
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, __FILE__, lino,
|
tsdbError("vgId:%d %s fid %d failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, fid,
|
||||||
tstrerror(code));
|
__FILE__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -331,6 +332,7 @@ int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRe
|
||||||
STSchema *pTSchema, int16_t cids[], int32_t ncid) {
|
STSchema *pTSchema, int16_t cids[], int32_t ncid) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
int32_t fid = reader->config->files[TSDB_FTYPE_DATA].file.fid;
|
||||||
|
|
||||||
SDiskDataHdr hdr;
|
SDiskDataHdr hdr;
|
||||||
SBuffer *buffer0 = reader->buffers + 0;
|
SBuffer *buffer0 = reader->buffers + 0;
|
||||||
|
@ -505,8 +507,8 @@ int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRe
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, __FILE__, lino,
|
tsdbError("vgId:%d %s fid:%d failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, fid,
|
||||||
tstrerror(code));
|
__FILE__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -735,6 +737,7 @@ static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
int32_t ftype;
|
int32_t ftype;
|
||||||
|
SDiskID diskId = {0};
|
||||||
|
|
||||||
if (!writer->config->skmTb) writer->config->skmTb = writer->skmTb;
|
if (!writer->config->skmTb) writer->config->skmTb = writer->skmTb;
|
||||||
if (!writer->config->skmRow) writer->config->skmRow = writer->skmRow;
|
if (!writer->config->skmRow) writer->config->skmRow = writer->skmRow;
|
||||||
|
@ -748,9 +751,11 @@ static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) {
|
||||||
|
|
||||||
// .head
|
// .head
|
||||||
ftype = TSDB_FTYPE_HEAD;
|
ftype = TSDB_FTYPE_HEAD;
|
||||||
|
code = tsdbAllocateDisk(writer->config->tsdb, tsdbFTypeLabel(ftype), writer->config->expLevel, &diskId);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[ftype] = (STFile){
|
writer->files[ftype] = (STFile){
|
||||||
.type = ftype,
|
.type = ftype,
|
||||||
.did = writer->config->did,
|
.did = diskId,
|
||||||
.fid = writer->config->fid,
|
.fid = writer->config->fid,
|
||||||
.cid = writer->config->cid,
|
.cid = writer->config->cid,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
|
@ -763,9 +768,11 @@ static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) {
|
||||||
if (writer->config->files[ftype].exist) {
|
if (writer->config->files[ftype].exist) {
|
||||||
writer->files[ftype] = writer->config->files[ftype].file;
|
writer->files[ftype] = writer->config->files[ftype].file;
|
||||||
} else {
|
} else {
|
||||||
|
code = tsdbAllocateDisk(writer->config->tsdb, tsdbFTypeLabel(ftype), writer->config->expLevel, &diskId);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[ftype] = (STFile){
|
writer->files[ftype] = (STFile){
|
||||||
.type = ftype,
|
.type = ftype,
|
||||||
.did = writer->config->did,
|
.did = diskId,
|
||||||
.fid = writer->config->fid,
|
.fid = writer->config->fid,
|
||||||
.cid = writer->config->cid,
|
.cid = writer->config->cid,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
|
@ -780,9 +787,11 @@ static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) {
|
||||||
if (writer->config->files[ftype].exist) {
|
if (writer->config->files[ftype].exist) {
|
||||||
writer->files[ftype] = writer->config->files[ftype].file;
|
writer->files[ftype] = writer->config->files[ftype].file;
|
||||||
} else {
|
} else {
|
||||||
|
code = tsdbAllocateDisk(writer->config->tsdb, tsdbFTypeLabel(ftype), writer->config->expLevel, &diskId);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[ftype] = (STFile){
|
writer->files[ftype] = (STFile){
|
||||||
.type = ftype,
|
.type = ftype,
|
||||||
.did = writer->config->did,
|
.did = diskId,
|
||||||
.fid = writer->config->fid,
|
.fid = writer->config->fid,
|
||||||
.cid = writer->config->cid,
|
.cid = writer->config->cid,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
|
@ -793,9 +802,11 @@ static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) {
|
||||||
|
|
||||||
// .tomb
|
// .tomb
|
||||||
ftype = TSDB_FTYPE_TOMB;
|
ftype = TSDB_FTYPE_TOMB;
|
||||||
|
code = tsdbAllocateDisk(writer->config->tsdb, tsdbFTypeLabel(ftype), writer->config->expLevel, &diskId);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[ftype] = (STFile){
|
writer->files[ftype] = (STFile){
|
||||||
.type = ftype,
|
.type = ftype,
|
||||||
.did = writer->config->did,
|
.did = diskId,
|
||||||
.fid = writer->config->fid,
|
.fid = writer->config->fid,
|
||||||
.cid = writer->config->cid,
|
.cid = writer->config->cid,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
|
|
|
@ -75,7 +75,7 @@ typedef struct SDataFileWriterConfig {
|
||||||
int32_t szPage;
|
int32_t szPage;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
int64_t cid;
|
int64_t cid;
|
||||||
SDiskID did;
|
int32_t expLevel;
|
||||||
int64_t compactVersion;
|
int64_t compactVersion;
|
||||||
int32_t lcn;
|
int32_t lcn;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "tsdbFS2.h"
|
#include "tsdbFS2.h"
|
||||||
|
|
||||||
// SFSetRAWWriter ==================================================
|
// SFSetRAWWriter ==================================================
|
||||||
typedef struct SFSetRAWWriter {
|
struct SFSetRAWWriter {
|
||||||
SFSetRAWWriterConfig config[1];
|
SFSetRAWWriterConfig config[1];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -28,7 +28,7 @@ typedef struct SFSetRAWWriter {
|
||||||
|
|
||||||
// writer
|
// writer
|
||||||
SDataFileRAWWriter *dataWriter;
|
SDataFileRAWWriter *dataWriter;
|
||||||
} SFSetRAWWriter;
|
};
|
||||||
|
|
||||||
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer) {
|
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -74,11 +74,14 @@ static int32_t tsdbFSetRAWWriteFileDataBegin(SFSetRAWWriter *writer, STsdbDataRA
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
SDiskID diskID = {0};
|
||||||
|
code = tsdbAllocateDisk(writer->config->tsdb, tsdbFTypeLabel(bHdr->file.type), writer->config->expLevel, &diskID);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
SDataFileRAWWriterConfig config = {
|
SDataFileRAWWriterConfig config = {
|
||||||
.tsdb = writer->config->tsdb,
|
.tsdb = writer->config->tsdb,
|
||||||
.szPage = writer->config->szPage,
|
.szPage = writer->config->szPage,
|
||||||
.fid = bHdr->file.fid,
|
.fid = bHdr->file.fid,
|
||||||
.did = writer->config->did,
|
|
||||||
.cid = bHdr->file.cid,
|
.cid = bHdr->file.cid,
|
||||||
.level = writer->config->level,
|
.level = writer->config->level,
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ static int32_t tsdbFSetRAWWriteFileDataBegin(SFSetRAWWriter *writer, STsdbDataRA
|
||||||
{
|
{
|
||||||
.type = bHdr->file.type,
|
.type = bHdr->file.type,
|
||||||
.fid = bHdr->file.fid,
|
.fid = bHdr->file.fid,
|
||||||
.did = writer->config->did,
|
.did = diskID,
|
||||||
.cid = bHdr->file.cid,
|
.cid = bHdr->file.cid,
|
||||||
.size = bHdr->file.size,
|
.size = bHdr->file.size,
|
||||||
.minVer = bHdr->file.minVer,
|
.minVer = bHdr->file.minVer,
|
||||||
|
|
|
@ -26,7 +26,7 @@ typedef struct SFSetRAWWriterConfig {
|
||||||
STsdb *tsdb;
|
STsdb *tsdb;
|
||||||
int32_t szPage;
|
int32_t szPage;
|
||||||
|
|
||||||
SDiskID did;
|
int32_t expLevel;
|
||||||
int64_t fid;
|
int64_t fid;
|
||||||
int64_t cid;
|
int64_t cid;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
|
@ -36,8 +36,8 @@ typedef struct SFSetRAWWriter SFSetRAWWriter;
|
||||||
|
|
||||||
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer);
|
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer);
|
||||||
int32_t tsdbFSetRAWWriterClose(SFSetRAWWriter **writer, bool abort, TFileOpArray *fopArr);
|
int32_t tsdbFSetRAWWriterClose(SFSetRAWWriter **writer, bool abort, TFileOpArray *fopArr);
|
||||||
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm,
|
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm,
|
||||||
char* encryptKey);
|
char *encryptKey);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ int32_t tsdbFSetWriterOpen(SFSetWriterConfig *config, SFSetWriter **writer) {
|
||||||
.szPage = config->szPage,
|
.szPage = config->szPage,
|
||||||
.fid = config->fid,
|
.fid = config->fid,
|
||||||
.cid = config->cid,
|
.cid = config->cid,
|
||||||
.did = config->did,
|
.expLevel = config->expLevel,
|
||||||
.compactVersion = config->compactVersion,
|
.compactVersion = config->compactVersion,
|
||||||
.skmTb = writer[0]->skmTb,
|
.skmTb = writer[0]->skmTb,
|
||||||
.skmRow = writer[0]->skmRow,
|
.skmRow = writer[0]->skmRow,
|
||||||
|
@ -178,7 +178,7 @@ int32_t tsdbFSetWriterOpen(SFSetWriterConfig *config, SFSetWriter **writer) {
|
||||||
.szPage = config->szPage,
|
.szPage = config->szPage,
|
||||||
.cmprAlg = config->cmprAlg,
|
.cmprAlg = config->cmprAlg,
|
||||||
.compactVersion = config->compactVersion,
|
.compactVersion = config->compactVersion,
|
||||||
.did = config->did,
|
.expLevel = config->expLevel,
|
||||||
.fid = config->fid,
|
.fid = config->fid,
|
||||||
.cid = config->cid,
|
.cid = config->cid,
|
||||||
.level = config->level,
|
.level = config->level,
|
||||||
|
|
|
@ -35,7 +35,7 @@ typedef struct {
|
||||||
int8_t cmprAlg;
|
int8_t cmprAlg;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
int64_t cid;
|
int64_t cid;
|
||||||
SDiskID did;
|
int32_t expLevel;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
int32_t lcn;
|
int32_t lcn;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -455,3 +455,5 @@ int32_t tsdbTFileObjCmpr(const STFileObj **fobj1, const STFileObj **fobj2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *tsdbFTypeLabel(tsdb_ftype_t ftype) { return g_tfile_info[ftype].suffix; }
|
|
@ -82,6 +82,8 @@ struct STFileObj {
|
||||||
char fname[TSDB_FILENAME_LEN];
|
char fname[TSDB_FILENAME_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *tsdbFTypeLabel(tsdb_ftype_t ftype);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -265,14 +265,6 @@ static int32_t tsdbMergeFileSetBeginOpenWriter(SMerger *merger) {
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
int32_t vid = TD_VID(merger->tsdb->pVnode);
|
int32_t vid = TD_VID(merger->tsdb->pVnode);
|
||||||
|
|
||||||
SDiskID did;
|
|
||||||
int32_t level = tsdbFidLevel(merger->ctx->fset->fid, &merger->tsdb->keepCfg, merger->ctx->now);
|
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tfsAllocDisk(merger->tsdb->pVnode->pTfs, level, &did), &lino, _exit);
|
|
||||||
|
|
||||||
code = tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
|
|
||||||
SFSetWriterConfig config = {
|
SFSetWriterConfig config = {
|
||||||
.tsdb = merger->tsdb,
|
.tsdb = merger->tsdb,
|
||||||
.toSttOnly = true,
|
.toSttOnly = true,
|
||||||
|
@ -283,7 +275,7 @@ static int32_t tsdbMergeFileSetBeginOpenWriter(SMerger *merger) {
|
||||||
.cmprAlg = merger->cmprAlg,
|
.cmprAlg = merger->cmprAlg,
|
||||||
.fid = merger->ctx->fset->fid,
|
.fid = merger->ctx->fset->fid,
|
||||||
.cid = merger->cid,
|
.cid = merger->cid,
|
||||||
.did = did,
|
.expLevel = tsdbFidLevel(merger->ctx->fset->fid, &merger->tsdb->keepCfg, merger->ctx->now),
|
||||||
.level = merger->ctx->level,
|
.level = merger->ctx->level,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -240,59 +240,70 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbRemoveOrMoveFileObject(SRTNer *rtner, int32_t expLevel, STFileObj *fobj) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
if (fobj == NULL) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expLevel < 0) {
|
||||||
|
// remove the file
|
||||||
|
code = tsdbDoRemoveFileObject(rtner, fobj);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
} else if (expLevel > fobj->f->did.level) {
|
||||||
|
// Try to move the file to a new level
|
||||||
|
for (; expLevel > fobj->f->did.level; expLevel--) {
|
||||||
|
SDiskID diskId = {0};
|
||||||
|
|
||||||
|
code = tsdbAllocateDiskAtLevel(rtner->tsdb, expLevel, tsdbFTypeLabel(fobj->f->type), &diskId);
|
||||||
|
if (code) {
|
||||||
|
tsdbTrace("vgId:%d, cannot allocate disk for file %s, level:%d, reason:%s, skip!", TD_VID(rtner->tsdb->pVnode),
|
||||||
|
fobj->fname, expLevel, tstrerror(code));
|
||||||
|
code = 0;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
tsdbInfo("vgId:%d start to migrate file %s from level %d to %d, size:%" PRId64, TD_VID(rtner->tsdb->pVnode),
|
||||||
|
fobj->fname, fobj->f->did.level, diskId.level, fobj->f->size);
|
||||||
|
|
||||||
|
code = tsdbDoMigrateFileObj(rtner, fobj, &diskId);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
tsdbInfo("vgId:%d end to migrate file %s from level %d to %d, size:%" PRId64, TD_VID(rtner->tsdb->pVnode),
|
||||||
|
fobj->fname, fobj->f->did.level, diskId.level, fobj->f->size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
|
||||||
|
tstrerror(code));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbDoRetention(SRTNer *rtner) {
|
static int32_t tsdbDoRetention(SRTNer *rtner) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
STFileObj *fobj = NULL;
|
STFileObj *fobj = NULL;
|
||||||
STFileSet *fset = rtner->fset;
|
STFileSet *fset = rtner->fset;
|
||||||
int32_t expLevel = tsdbFidLevel(fset->fid, &rtner->tsdb->keepCfg, rtner->now);
|
|
||||||
|
|
||||||
if (expLevel < 0) { // remove the fileset
|
// handle data file sets
|
||||||
for (int32_t ftype = 0; (ftype < TSDB_FTYPE_MAX) && (fobj = fset->farr[ftype], 1); ++ftype) {
|
int32_t expLevel = tsdbFidLevel(fset->fid, &rtner->tsdb->keepCfg, rtner->now);
|
||||||
if (fobj == NULL) continue;
|
for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||||
TAOS_CHECK_GOTO(tsdbDoRemoveFileObject(rtner, fobj), &lino, _exit);
|
code = tsdbRemoveOrMoveFileObject(rtner, expLevel, fset->farr[ftype]);
|
||||||
}
|
|
||||||
|
|
||||||
SSttLvl *lvl;
|
|
||||||
TARRAY2_FOREACH(fset->lvlArr, lvl) {
|
|
||||||
TARRAY2_FOREACH(lvl->fobjArr, fobj) { TAOS_CHECK_GOTO(tsdbDoRemoveFileObject(rtner, fobj), &lino, _exit); }
|
|
||||||
}
|
|
||||||
} else if (expLevel == 0) { // only migrate to upper level
|
|
||||||
return 0;
|
|
||||||
} else { // migrate
|
|
||||||
SDiskID did;
|
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tfsAllocDisk(rtner->tsdb->pVnode->pTfs, expLevel, &did), &lino, _exit);
|
|
||||||
code = tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
// data
|
// handle stt file
|
||||||
for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX && (fobj = fset->farr[ftype], 1); ++ftype) {
|
SSttLvl *lvl;
|
||||||
if (fobj == NULL) continue;
|
TARRAY2_FOREACH(fset->lvlArr, lvl) {
|
||||||
|
TARRAY2_FOREACH(lvl->fobjArr, fobj) {
|
||||||
if (fobj->f->did.level == did.level) {
|
code = tsdbRemoveOrMoveFileObject(rtner, expLevel, fobj);
|
||||||
continue;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
|
||||||
|
|
||||||
if (fobj->f->did.level > did.level) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tsdbInfo("file:%s size: %" PRId64 " do migrate from %d to %d", fobj->fname, fobj->f->size, fobj->f->did.level,
|
|
||||||
did.level);
|
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tsdbDoMigrateFileObj(rtner, fobj, &did), &lino, _exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
// stt
|
|
||||||
SSttLvl *lvl;
|
|
||||||
TARRAY2_FOREACH(fset->lvlArr, lvl) {
|
|
||||||
TARRAY2_FOREACH(lvl->fobjArr, fobj) {
|
|
||||||
if (fobj->f->did.level == did.level) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tsdbDoMigrateFileObj(rtner, fobj, &did), &lino, _exit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -544,7 +544,7 @@ struct STsdbSnapWriter {
|
||||||
bool fsetWriteBegin;
|
bool fsetWriteBegin;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
STFileSet* fset;
|
STFileSet* fset;
|
||||||
SDiskID did;
|
int32_t expLevel;
|
||||||
bool hasData; // if have time series data
|
bool hasData; // if have time series data
|
||||||
bool hasTomb; // if have tomb data
|
bool hasTomb; // if have tomb data
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ static int32_t tsdbSnapWriteFileSetOpenWriter(STsdbSnapWriter* writer) {
|
||||||
.cmprAlg = writer->cmprAlg,
|
.cmprAlg = writer->cmprAlg,
|
||||||
.fid = writer->ctx->fid,
|
.fid = writer->ctx->fid,
|
||||||
.cid = writer->commitID,
|
.cid = writer->commitID,
|
||||||
.did = writer->ctx->did,
|
.expLevel = writer->ctx->expLevel,
|
||||||
.level = writer->ctx->toSttOnly ? 1 : 0,
|
.level = writer->ctx->toSttOnly ? 1 : 0,
|
||||||
};
|
};
|
||||||
// merge stt files to either data or a new stt file
|
// merge stt files to either data or a new stt file
|
||||||
|
@ -837,14 +837,7 @@ static int32_t tsdbSnapWriteFileSetBegin(STsdbSnapWriter* writer, int32_t fid) {
|
||||||
STFileSet** fsetPtr = TARRAY2_SEARCH(writer->fsetArr, &fset, tsdbTFileSetCmprFn, TD_EQ);
|
STFileSet** fsetPtr = TARRAY2_SEARCH(writer->fsetArr, &fset, tsdbTFileSetCmprFn, TD_EQ);
|
||||||
writer->ctx->fset = (fsetPtr == NULL) ? NULL : *fsetPtr;
|
writer->ctx->fset = (fsetPtr == NULL) ? NULL : *fsetPtr;
|
||||||
|
|
||||||
int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec());
|
writer->ctx->expLevel = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec());
|
||||||
if (tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did)) {
|
|
||||||
code = TSDB_CODE_NO_AVAIL_DISK;
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
|
||||||
if (tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did) != 0) {
|
|
||||||
tsdbError("vgId:%d failed to create directory %s", TD_VID(writer->tsdb->pVnode), writer->tsdb->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer->ctx->hasData = true;
|
writer->ctx->hasData = true;
|
||||||
writer->ctx->hasTomb = true;
|
writer->ctx->hasTomb = true;
|
||||||
|
|
|
@ -319,7 +319,6 @@ struct STsdbSnapRAWWriter {
|
||||||
bool fsetWriteBegin;
|
bool fsetWriteBegin;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
STFileSet* fset;
|
STFileSet* fset;
|
||||||
SDiskID did;
|
|
||||||
int64_t cid;
|
int64_t cid;
|
||||||
int64_t level;
|
int64_t level;
|
||||||
|
|
||||||
|
@ -371,7 +370,7 @@ static int32_t tsdbSnapRAWWriteFileSetOpenWriter(STsdbSnapRAWWriter* writer) {
|
||||||
.szPage = writer->szPage,
|
.szPage = writer->szPage,
|
||||||
.fid = writer->ctx->fid,
|
.fid = writer->ctx->fid,
|
||||||
.cid = writer->commitID,
|
.cid = writer->commitID,
|
||||||
.did = writer->ctx->did,
|
.expLevel = writer->ctx->level,
|
||||||
.level = writer->ctx->level,
|
.level = writer->ctx->level,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -400,16 +399,10 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t
|
||||||
writer->ctx->fset = (fsetPtr == NULL) ? NULL : *fsetPtr;
|
writer->ctx->fset = (fsetPtr == NULL) ? NULL : *fsetPtr;
|
||||||
|
|
||||||
int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec());
|
int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec());
|
||||||
code = tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
|
|
||||||
code = tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
|
|
||||||
code = tsdbSnapRAWWriteFileSetOpenWriter(writer);
|
code = tsdbSnapRAWWriteFileSetOpenWriter(writer);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
writer->ctx->level = level;
|
|
||||||
writer->ctx->fsetWriteBegin = true;
|
writer->ctx->fsetWriteBegin = true;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
|
|
@ -781,6 +781,7 @@ static int32_t tsdbSttFileDoWriteFooter(SSttFileWriter *writer) {
|
||||||
static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
STsdb *tsdb = writer->config->tsdb;
|
||||||
|
|
||||||
// set
|
// set
|
||||||
if (!writer->config->skmTb) writer->config->skmTb = writer->skmTb;
|
if (!writer->config->skmTb) writer->config->skmTb = writer->skmTb;
|
||||||
|
@ -790,9 +791,14 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
||||||
writer->buffers = writer->local;
|
writer->buffers = writer->local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// alloc disk id
|
||||||
|
SDiskID diskId = {0};
|
||||||
|
code = tsdbAllocateDisk(tsdb, tsdbFTypeLabel(TSDB_FTYPE_STT), writer->config->expLevel, &diskId);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
writer->file[0] = (STFile){
|
writer->file[0] = (STFile){
|
||||||
.type = TSDB_FTYPE_STT,
|
.type = TSDB_FTYPE_STT,
|
||||||
.did = writer->config->did,
|
.did = diskId,
|
||||||
.fid = writer->config->fid,
|
.fid = writer->config->fid,
|
||||||
.cid = writer->config->cid,
|
.cid = writer->config->cid,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct SSttFileWriterConfig {
|
||||||
int32_t szPage;
|
int32_t szPage;
|
||||||
int8_t cmprAlg;
|
int8_t cmprAlg;
|
||||||
int64_t compactVersion;
|
int64_t compactVersion;
|
||||||
SDiskID did;
|
int32_t expLevel;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
int64_t cid;
|
int64_t cid;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
|
|
|
@ -622,7 +622,7 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *
|
||||||
SColData *pColData = tBlockDataGetColData(pRow->pBlockData, pTColumn->colId);
|
SColData *pColData = tBlockDataGetColData(pRow->pBlockData, pTColumn->colId);
|
||||||
|
|
||||||
if (pColData) {
|
if (pColData) {
|
||||||
if (tColDataGetValue(pColData, pRow->iRow, pColVal) != 0){
|
if (tColDataGetValue(pColData, pRow->iRow, pColVal) != 0) {
|
||||||
tsdbError("failed to tColDataGetValue");
|
tsdbError("failed to tColDataGetValue");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -647,7 +647,7 @@ void tColRowGetPrimaryKey(SBlockData *pBlock, int32_t irow, SRowKey *key) {
|
||||||
SColData *pColData = &pBlock->aColData[i];
|
SColData *pColData = &pBlock->aColData[i];
|
||||||
if (pColData->cflag & COL_IS_KEY) {
|
if (pColData->cflag & COL_IS_KEY) {
|
||||||
SColVal cv;
|
SColVal cv;
|
||||||
if (tColDataGetValue(pColData, irow, &cv) != 0){
|
if (tColDataGetValue(pColData, irow, &cv) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
key->pks[key->numOfPKs] = cv.value;
|
key->pks[key->numOfPKs] = cv.value;
|
||||||
|
@ -723,7 +723,8 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pIter->iColData <= pIter->pRow->pBlockData->nColData) {
|
if (pIter->iColData <= pIter->pRow->pBlockData->nColData) {
|
||||||
if (tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData - 1], pIter->pRow->iRow, &pIter->cv) != 0){
|
if (tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData - 1], pIter->pRow->iRow, &pIter->cv) !=
|
||||||
|
0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
++pIter->iColData;
|
++pIter->iColData;
|
||||||
|
@ -1802,3 +1803,48 @@ uint32_t tsdbCvtTimestampAlg(uint32_t alg) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tsdbAllocateDisk(STsdb *tsdb, const char *label, int32_t expLevel, SDiskID *diskId) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
SDiskID did = {0};
|
||||||
|
STfs *tfs = tsdb->pVnode->pTfs;
|
||||||
|
|
||||||
|
code = tfsAllocDisk(tfs, expLevel, label, &did);
|
||||||
|
if (code) {
|
||||||
|
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tfsMkdirRecurAt(tfs, tsdb->path, did) != 0) {
|
||||||
|
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diskId) {
|
||||||
|
*diskId = did;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbAllocateDiskAtLevel(STsdb *tsdb, int32_t level, const char *label, SDiskID *diskId) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SDiskID did = {0};
|
||||||
|
STfs *tfs = tsdb->pVnode->pTfs;
|
||||||
|
|
||||||
|
code = tfsAllocDiskAtLevel(tfs, level, label, &did);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tfsMkdirRecurAt(tfs, tsdb->path, did) != 0) {
|
||||||
|
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, __LINE__,
|
||||||
|
tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diskId) {
|
||||||
|
*diskId = did;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "tcs.h"
|
#include "tcs.h"
|
||||||
|
#include "tq.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
|
@ -483,6 +484,14 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
||||||
ret = taosRealPath(tdir, NULL, sizeof(tdir));
|
ret = taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
TAOS_UNUSED(ret);
|
TAOS_UNUSED(ret);
|
||||||
|
|
||||||
|
// init handle map for stream event notification
|
||||||
|
ret = tqInitNotifyHandleMap(&pVnode->pNotifyHandleMap);
|
||||||
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
vError("vgId:%d, failed to init StreamNotifyHandleMap", TD_VID(pVnode));
|
||||||
|
terrno = ret;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
// open query
|
// open query
|
||||||
vInfo("vgId:%d, start to open vnode query", TD_VID(pVnode));
|
vInfo("vgId:%d, start to open vnode query", TD_VID(pVnode));
|
||||||
if (vnodeQueryOpen(pVnode)) {
|
if (vnodeQueryOpen(pVnode)) {
|
||||||
|
@ -555,6 +564,7 @@ void vnodeClose(SVnode *pVnode) {
|
||||||
vnodeAWait(&pVnode->commitTask);
|
vnodeAWait(&pVnode->commitTask);
|
||||||
vnodeSyncClose(pVnode);
|
vnodeSyncClose(pVnode);
|
||||||
vnodeQueryClose(pVnode);
|
vnodeQueryClose(pVnode);
|
||||||
|
tqDestroyNotifyHandleMap(&pVnode->pNotifyHandleMap);
|
||||||
tqClose(pVnode->pTq);
|
tqClose(pVnode->pTq);
|
||||||
walClose(pVnode->pWal);
|
walClose(pVnode->pWal);
|
||||||
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
|
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
|
||||||
|
|
|
@ -53,8 +53,8 @@ static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t l
|
||||||
static int32_t vnodeProcessDropTSmaCtbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp,
|
static int32_t vnodeProcessDropTSmaCtbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp,
|
||||||
SRpcMsg *pOriginRpc);
|
SRpcMsg *pOriginRpc);
|
||||||
|
|
||||||
static int32_t vnodePreCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token);
|
static int32_t vnodeCheckToken(SVnode *pVnode, char *member0Token, char *member1Token);
|
||||||
static int32_t vnodeCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token);
|
static int32_t vnodeCheckSyncd(SVnode *pVnode, char *member0Token, char *member1Token);
|
||||||
static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
|
|
||||||
extern int32_t vnodeProcessKillCompactReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
extern int32_t vnodeProcessKillCompactReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
|
@ -489,7 +489,7 @@ static int32_t vnodePreProcessArbCheckSyncMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = vnodePreCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token);
|
int32_t ret = vnodeCheckToken(pVnode, syncReq.member0Token, syncReq.member1Token);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
vError("vgId:%d, failed to preprocess arb check sync request since %s", TD_VID(pVnode), tstrerror(ret));
|
vError("vgId:%d, failed to preprocess arb check sync request since %s", TD_VID(pVnode), tstrerror(ret));
|
||||||
}
|
}
|
||||||
|
@ -2551,7 +2551,7 @@ static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pR
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodePreCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token) {
|
static int32_t vnodeCheckToken(SVnode *pVnode, char *member0Token, char *member1Token) {
|
||||||
SSyncState syncState = syncGetState(pVnode->sync);
|
SSyncState syncState = syncGetState(pVnode->sync);
|
||||||
if (syncState.state != TAOS_SYNC_STATE_LEADER) {
|
if (syncState.state != TAOS_SYNC_STATE_LEADER) {
|
||||||
return terrno = TSDB_CODE_SYN_NOT_LEADER;
|
return terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
|
@ -2571,13 +2571,13 @@ static int32_t vnodePreCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token) {
|
static int32_t vnodeCheckSyncd(SVnode *pVnode, char *member0Token, char *member1Token) {
|
||||||
int32_t code = vnodePreCheckAssignedLogSyncd(pVnode, member0Token, member1Token);
|
int32_t code = vnodeCheckToken(pVnode, member0Token, member1Token);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncGetAssignedLogSynced(pVnode->sync);
|
return syncCheckSynced(pVnode->sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
|
@ -2601,7 +2601,7 @@ static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t l
|
||||||
syncRsp.member1Token = syncReq.member1Token;
|
syncRsp.member1Token = syncReq.member1Token;
|
||||||
syncRsp.vgId = TD_VID(pVnode);
|
syncRsp.vgId = TD_VID(pVnode);
|
||||||
|
|
||||||
if (vnodeCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token) != 0) {
|
if (vnodeCheckSyncd(pVnode, syncReq.member0Token, syncReq.member1Token) != 0) {
|
||||||
vError("vgId:%d, failed to check assigned log syncd", TD_VID(pVnode));
|
vError("vgId:%d, failed to check assigned log syncd", TD_VID(pVnode));
|
||||||
}
|
}
|
||||||
syncRsp.errCode = terrno;
|
syncRsp.errCode = terrno;
|
||||||
|
|