Merge branch '3.0' into feature/3.0_glzhao
This commit is contained in:
commit
05f1e64108
12
Jenkinsfile2
12
Jenkinsfile2
|
@ -88,12 +88,6 @@ def pre_test(){
|
|||
cmake .. > /dev/null
|
||||
make -j4> /dev/null
|
||||
'''
|
||||
sh'''
|
||||
cd ${WKPY}
|
||||
git reset --hard
|
||||
git pull
|
||||
pip3 install .
|
||||
'''
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -103,7 +97,6 @@ pipeline {
|
|||
environment{
|
||||
WK = '/var/lib/jenkins/workspace/TDinternal'
|
||||
WKC= '/var/lib/jenkins/workspace/TDengine'
|
||||
WKPY= '/var/lib/jenkins/workspace/taos-connector-python'
|
||||
}
|
||||
stages {
|
||||
stage('pre_build'){
|
||||
|
@ -124,11 +117,6 @@ pipeline {
|
|||
./test-all.sh b1fq
|
||||
'''
|
||||
sh'''
|
||||
export LD_LIBRARY_PATH=${WKC}/debug/build/lib
|
||||
cd ${WKC}/tests/system-test
|
||||
./fulltest.sh
|
||||
'''
|
||||
sh'''
|
||||
cd ${WKC}/debug
|
||||
ctest
|
||||
'''
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
#set output directory
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
|
||||
|
@ -43,11 +45,14 @@ ENDIF ()
|
|||
IF (TD_WINDOWS)
|
||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
|
||||
SET(COMMON_FLAGS "/nologo /WX /wd4018 /wd4999 /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
|
||||
SET(COMMON_FLAGS "/W3 /D_WIN32")
|
||||
|
||||
IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||
SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||
ENDIF ()
|
||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||
# ENDIF ()
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
|
||||
|
||||
ELSE ()
|
||||
IF (${SANITIZER} MATCHES "true")
|
||||
|
|
|
@ -25,9 +25,28 @@ IF(${TD_WINDOWS})
|
|||
ON
|
||||
)
|
||||
|
||||
ENDIF ()
|
||||
MESSAGE("build msvcregex Win32")
|
||||
option(
|
||||
BUILD_MSVCREGEX
|
||||
"If build msvcregex on Windows"
|
||||
ON
|
||||
)
|
||||
|
||||
IF(${TD_LINUX} MATCHES TRUE)
|
||||
MESSAGE("build wcwidth Win32")
|
||||
option(
|
||||
BUILD_WCWIDTH
|
||||
"If build wcwidth on Windows"
|
||||
ON
|
||||
)
|
||||
|
||||
MESSAGE("build wingetopt Win32")
|
||||
option(
|
||||
BUILD_WINGETOPT
|
||||
"If build wingetopt on Windows"
|
||||
ON
|
||||
)
|
||||
|
||||
ENDIF ()
|
||||
|
||||
option(
|
||||
BUILD_TEST
|
||||
|
@ -35,8 +54,6 @@ option(
|
|||
ON
|
||||
)
|
||||
|
||||
ENDIF ()
|
||||
|
||||
option(
|
||||
BUILD_WITH_LEVELDB
|
||||
"If build with leveldb"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
# msvcregex
|
||||
ExternalProject_Add(msvcregex
|
||||
GIT_REPOSITORY https://gitee.com/l0km/libgnurx-msvc.git
|
||||
GIT_TAG master
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/msvcregex"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
|
@ -3,7 +3,7 @@
|
|||
ExternalProject_Add(pthread
|
||||
GIT_REPOSITORY https://github.com/GerHobbelt/pthread-win32
|
||||
GIT_TAG v3.0.3.1
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/pthread-win32"
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/pthread"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
# wcwidth
|
||||
ExternalProject_Add(wcwidth
|
||||
GIT_REPOSITORY https://github.com/fumiyas/wcwidth-cjk.git
|
||||
GIT_TAG master
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/wcwidth"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
# wingetopt
|
||||
ExternalProject_Add(wingetopt
|
||||
GIT_REPOSITORY https://github.com/alex85k/wingetopt.git
|
||||
GIT_TAG master
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/wingetopt"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
|
@ -14,9 +14,24 @@ if(${BUILD_PTHREAD})
|
|||
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
# gnu regex
|
||||
if(${BUILD_GNUREGEX})
|
||||
cat("${TD_SUPPORT_DIR}/gnuregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
# iconv
|
||||
if(${BUILD_WITH_ICONV})
|
||||
cat("${TD_SUPPORT_DIR}/iconv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
# msvc regex
|
||||
if(${BUILD_MSVCREGEX})
|
||||
cat("${TD_SUPPORT_DIR}/msvcregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
# wcwidth
|
||||
if(${BUILD_WCWIDTH})
|
||||
cat("${TD_SUPPORT_DIR}/wcwidth_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
# wingetopt
|
||||
if(${BUILD_WINGETOPT})
|
||||
cat("${TD_SUPPORT_DIR}/wingetopt_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
# googletest
|
||||
|
@ -99,8 +114,27 @@ if(${BUILD_TEST})
|
|||
target_include_directories(
|
||||
gtest
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
||||
)
|
||||
if(${TD_WINDOWS})
|
||||
target_include_directories(
|
||||
gtest
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_win>
|
||||
)
|
||||
endif(${TD_WINDOWS})
|
||||
if(${TD_LINUX})
|
||||
target_include_directories(
|
||||
gtest
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
||||
)
|
||||
endif(${TD_LINUX})
|
||||
if(${TD_DARWIN})
|
||||
target_include_directories(
|
||||
gtest
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_darwin>
|
||||
)
|
||||
endif(${TD_DARWIN})
|
||||
|
||||
|
||||
endif(${BUILD_TEST})
|
||||
|
||||
# cJson
|
||||
|
@ -182,6 +216,53 @@ if(${BUILD_WITH_NURAFT})
|
|||
add_subdirectory(nuraft)
|
||||
endif(${BUILD_WITH_NURAFT})
|
||||
|
||||
# pthread
|
||||
if(${BUILD_PTHREAD})
|
||||
set(CMAKE_BUILD_TYPE release)
|
||||
add_definitions(-DPTW32_STATIC_LIB)
|
||||
add_subdirectory(pthread)
|
||||
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
|
||||
add_library(pthread STATIC IMPORTED GLOBAL)
|
||||
SET_PROPERTY(TARGET pthread PROPERTY IMPORTED_LOCATION ${LIBRARY_OUTPUT_PATH}/pthread.lib)
|
||||
endif()
|
||||
|
||||
# iconv
|
||||
if(${BUILD_WITH_ICONV})
|
||||
add_subdirectory(iconv)
|
||||
endif(${BUILD_WITH_ICONV})
|
||||
|
||||
# wingetopt
|
||||
if(${BUILD_WINGETOPT})
|
||||
add_subdirectory(wingetopt)
|
||||
endif(${BUILD_WINGETOPT})
|
||||
|
||||
# msvcregex
|
||||
if(${BUILD_MSVCREGEX})
|
||||
add_library(msvcregex STATIC "")
|
||||
target_sources(msvcregex
|
||||
PRIVATE "msvcregex/regex.c"
|
||||
)
|
||||
target_include_directories(msvcregex
|
||||
PRIVATE "msvcregex"
|
||||
)
|
||||
target_link_libraries(msvcregex
|
||||
INTERFACE Shell32
|
||||
)
|
||||
SET_TARGET_PROPERTIES(msvcregex PROPERTIES OUTPUT_NAME msvcregex)
|
||||
endif(${BUILD_MSVCREGEX})
|
||||
|
||||
# msvcregex
|
||||
if(${BUILD_WCWIDTH})
|
||||
add_library(wcwidth STATIC "")
|
||||
target_sources(wcwidth
|
||||
PRIVATE "wcwidth/wcwidth.c"
|
||||
)
|
||||
target_include_directories(wcwidth
|
||||
PRIVATE "wcwidth"
|
||||
)
|
||||
SET_TARGET_PROPERTIES(wcwidth PROPERTIES OUTPUT_NAME wcwidth)
|
||||
endif(${BUILD_WCWIDTH})
|
||||
|
||||
# CRAFT
|
||||
if(${BUILD_WITH_CRAFT})
|
||||
add_library(craft STATIC IMPORTED GLOBAL)
|
||||
|
@ -238,8 +319,12 @@ if(${BUILD_WITH_SQLITE})
|
|||
target_link_libraries(sqlite
|
||||
INTERFACE m
|
||||
INTERFACE pthread
|
||||
INTERFACE dl
|
||||
)
|
||||
if(NOT TD_WINDOWS)
|
||||
target_link_libraries(sqlite
|
||||
INTERFACE dl
|
||||
)
|
||||
endif(NOT TD_WINDOWS)
|
||||
endif(${BUILD_WITH_SQLITE})
|
||||
|
||||
# pthread
|
||||
|
|
|
@ -1,2 +1,9 @@
|
|||
add_executable(simulate_vnode "simulate_vnode.c")
|
||||
target_link_libraries(simulate_vnode PUBLIC craft lz4 uv_a)
|
||||
target_link_libraries(simulate_vnode PUBLIC craft lz4 uv_a)
|
||||
if(${BUILD_WINGETOPT})
|
||||
target_link_libraries(simulate_vnode PUBLIC wingetopt)
|
||||
target_include_directories(
|
||||
simulate_vnode
|
||||
PUBLIC "${TD_SOURCE_DIR}/contrib/wingetopt/src"
|
||||
)
|
||||
endif()
|
|
@ -6,43 +6,39 @@
|
|||
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
|
||||
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
|
||||
|
||||
#define tPutA(buf, val) \
|
||||
({ \
|
||||
memcpy(buf, &val, sizeof(val)); \
|
||||
POINTER_SHIFT(buf, sizeof(val)); \
|
||||
})
|
||||
static inline void tPutA(void **buf, uint64_t val) {
|
||||
memcpy(buf, &val, sizeof(val));
|
||||
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||
}
|
||||
|
||||
#define tPutB(buf, val) \
|
||||
({ \
|
||||
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \
|
||||
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \
|
||||
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \
|
||||
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \
|
||||
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
|
||||
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
|
||||
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
|
||||
((uint8_t *)buf)[0] = (val)&0xff; \
|
||||
POINTER_SHIFT(buf, sizeof(val)); \
|
||||
})
|
||||
static inline void tPutB(void **buf, uint64_t val) {
|
||||
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff;
|
||||
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff;
|
||||
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff;
|
||||
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff;
|
||||
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff;
|
||||
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff;
|
||||
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff;
|
||||
((uint8_t *)buf)[0] = (val)&0xff;
|
||||
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||
}
|
||||
|
||||
#define tPutC(buf, val) \
|
||||
({ \
|
||||
if (buf) { \
|
||||
((uint64_t *)buf)[0] = (val); \
|
||||
POINTER_SHIFT(buf, sizeof(val)); \
|
||||
} \
|
||||
NULL; \
|
||||
})
|
||||
static inline void tPutC(void **buf, uint64_t val) {
|
||||
if (buf) {
|
||||
((uint64_t *)buf)[0] = (val);
|
||||
POINTER_SHIFT(buf, sizeof(val));
|
||||
}
|
||||
*buf = NULL;
|
||||
}
|
||||
|
||||
#define tPutD(buf, val) \
|
||||
({ \
|
||||
uint64_t tmp = val; \
|
||||
for (size_t i = 0; i < sizeof(val); i++) { \
|
||||
((uint8_t *)buf)[i] = tmp & 0xff; \
|
||||
tmp >>= 8; \
|
||||
} \
|
||||
POINTER_SHIFT(buf, sizeof(val)); \
|
||||
})
|
||||
static inline void tPutD(void **buf, uint64_t val) {
|
||||
uint64_t tmp = val;
|
||||
for (size_t i = 0; i < sizeof(val); i++) {
|
||||
((uint8_t *)buf)[i] = tmp & 0xff;
|
||||
tmp >>= 8;
|
||||
}
|
||||
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||
}
|
||||
|
||||
static inline void tPutE(void **buf, uint64_t val) {
|
||||
if (buf) {
|
||||
|
@ -61,7 +57,7 @@ static void func(T t) {
|
|||
switch (t) {
|
||||
case A:
|
||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||
pBuf = tPutA(pBuf, val);
|
||||
tPutA(pBuf, val);
|
||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||
pBuf = buf;
|
||||
}
|
||||
|
@ -69,7 +65,7 @@ static void func(T t) {
|
|||
break;
|
||||
case B:
|
||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||
pBuf = tPutB(pBuf, val);
|
||||
tPutB(pBuf, val);
|
||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||
pBuf = buf;
|
||||
}
|
||||
|
@ -77,7 +73,7 @@ static void func(T t) {
|
|||
break;
|
||||
case C:
|
||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||
pBuf = tPutC(pBuf, val);
|
||||
tPutC(pBuf, val);
|
||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||
pBuf = buf;
|
||||
}
|
||||
|
@ -85,7 +81,7 @@ static void func(T t) {
|
|||
break;
|
||||
case D:
|
||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||
pBuf = tPutD(pBuf, val);
|
||||
tPutD(pBuf, val);
|
||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||
pBuf = buf;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ target_include_directories(tstream
|
|||
|
||||
target_include_directories(demoapi
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
// #include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#ifndef WINDOWS
|
||||
#include <argp.h>
|
||||
|
||||
#endif
|
||||
#include "osSleep.h"
|
||||
#include "taos.h"
|
||||
|
||||
#define debugPrint(fmt, ...) \
|
||||
|
@ -32,6 +34,7 @@
|
|||
int64_t g_num_of_tb = 2;
|
||||
int64_t g_num_of_rec = 3;
|
||||
|
||||
#ifndef WINDOWS
|
||||
static struct argp_option options[] = {
|
||||
{"tables", 't', "NUMBER", 0, "Number of child tables, default is 10000."},
|
||||
{"records", 'n', "NUMBER", 0,
|
||||
|
@ -61,16 +64,16 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||
}
|
||||
|
||||
static struct argp argp = {options, parse_opt, "", ""};
|
||||
|
||||
#endif
|
||||
static void prepare_data(TAOS* taos) {
|
||||
TAOS_RES *res;
|
||||
res = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(res);
|
||||
usleep(100000);
|
||||
taosMsleep(100);
|
||||
|
||||
res = taos_query(taos, "create database test;");
|
||||
taos_free_result(res);
|
||||
usleep(100000);
|
||||
taosMsleep(100);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
char command[1024] = {0};
|
||||
|
@ -87,18 +90,17 @@ static void prepare_data(TAOS* taos) {
|
|||
taos_free_result(res);
|
||||
|
||||
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
||||
// sprintf(command, "create table t%"PRId64" using meters "
|
||||
// "tags(%"PRId64", '%s', '%s', '%s');",
|
||||
// i, i, (i%2)?"beijing":"shanghai",
|
||||
// (i%2)?"朝阳区":"黄浦区",
|
||||
// (i%2)?"长安街":"中山路");
|
||||
sprintf(command, "create table t%"PRId64" using meters "
|
||||
"tags(%"PRId64", '%s', '%s', '%s');",
|
||||
i, i, (i%2)?"beijing":"shanghai",
|
||||
(i%2)?"朝阳区":"黄浦区",
|
||||
(i%2)?"长安街":"中山路");
|
||||
/* sprintf(command, "create table t%"PRId64" using meters "
|
||||
"tags(%"PRId64", '%s', '%s', '%s');",
|
||||
i, i,
|
||||
(i%2)?"beijing":"shanghai",
|
||||
(i%2)?"chaoyang":"huangpu",
|
||||
(i%2?"changan street":"jianguo rd"));
|
||||
*/
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
okPrint("t%" PRId64 " created\n", i);
|
||||
|
@ -117,7 +119,8 @@ static void prepare_data(TAOS* taos) {
|
|||
"'%c%d', '%s%c%d', '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j,
|
||||
'a'+(int)j%25, rand(),
|
||||
"涛思", 'z' - (int)j%25, rand(),
|
||||
// "涛思", 'z' - (int)j%25, rand(),
|
||||
"TAOS", 'z' - (int)j%25, rand(),
|
||||
'b' - (int)j%25, rand()
|
||||
);
|
||||
res = taos_query(taos, command);
|
||||
|
@ -196,7 +199,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d, row: %"PRId64", "
|
||||
"value: %"PRId64"\n",
|
||||
f, c,
|
||||
*(int64_t*)(row[f]+c*sizeof(int64_t)));
|
||||
*(int64_t*)((char*)(row[f])+c*sizeof(int64_t)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -208,7 +211,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d, row: %"PRId64", "
|
||||
"value: %d\n",
|
||||
f, c,
|
||||
*(int32_t*)(row[f]+c*sizeof(int32_t)));
|
||||
*(int32_t*)((char*)(row[f])+c*sizeof(int32_t)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -220,7 +223,7 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
printf("col%d, row: %"PRId64", "
|
||||
"value: %f\n",
|
||||
f, c,
|
||||
*(float*)(row[f]+c*sizeof(float)));
|
||||
*(float*)((char*)(row[f])+c*sizeof(float)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -235,9 +238,9 @@ static int print_result(char *tbname, TAOS_RES* res, int block) {
|
|||
if (offsets) {
|
||||
for (int c = 0; c < rows; c++) {
|
||||
if (offsets[c] != -1) {
|
||||
int length = *(int16_t*)(row[f] + offsets[c]);
|
||||
int length = *(int16_t*)((char*)(row[f]) + offsets[c]);
|
||||
char *buf = calloc(1, length + 1);
|
||||
strncpy(buf, (char *)(row[f] + offsets[c] + 2), length);
|
||||
strncpy(buf, (char *)((char*)(row[f]) + offsets[c] + 2), length);
|
||||
printf("row: %d, col: %d, offset: %d, length: %d, content: %s\n",
|
||||
c, f, offsets[c], length, buf);
|
||||
free(buf);
|
||||
|
@ -314,8 +317,9 @@ int main(int argc, char *argv[]) {
|
|||
const char* host = "127.0.0.1";
|
||||
const char* user = "root";
|
||||
const char* passwd = "taosdata";
|
||||
|
||||
#ifndef WINDOWS
|
||||
argp_parse(&argp, argc, argv, 0, 0, NULL);
|
||||
#endif
|
||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||
if (taos == NULL) {
|
||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||
|
|
|
@ -103,6 +103,7 @@ int32_t create_topic() {
|
|||
|
||||
/*const char* sql = "select * from tu1";*/
|
||||
/*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));*/
|
||||
/*pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");*/
|
||||
pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from ct1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
||||
|
|
|
@ -146,6 +146,7 @@ DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
|
|||
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
|
||||
DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt);
|
||||
|
||||
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
|
||||
DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
||||
|
@ -215,7 +216,6 @@ typedef struct tmq_topic_vgroup_list_t tmq_topic_vgroup_list_t;
|
|||
|
||||
typedef struct tmq_conf_t tmq_conf_t;
|
||||
typedef struct tmq_list_t tmq_list_t;
|
||||
// typedef struct tmq_message_t tmq_message_t;
|
||||
|
||||
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *));
|
||||
|
||||
|
@ -261,12 +261,6 @@ DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const
|
|||
DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
|
||||
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb);
|
||||
|
||||
#if 0
|
||||
// temporary used function for demo only
|
||||
void tmqShowMsg(tmq_message_t *tmq_message);
|
||||
int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message);
|
||||
#endif
|
||||
|
||||
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
||||
|
||||
DLL_EXPORT char *tmq_get_topic_name(TAOS_RES *res);
|
||||
|
@ -277,12 +271,8 @@ DLL_EXPORT char *tmq_get_block_table_name(TAOS_RES *res);
|
|||
#endif
|
||||
|
||||
#if 0
|
||||
DLL_EXPORT TAOS_ROW tmq_get_row(tmq_message_t *message);
|
||||
DLL_EXPORT int64_t tmq_get_request_offset(tmq_message_t *message);
|
||||
DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message);
|
||||
DLL_EXPORT TAOS_FIELD *tmq_get_fields(tmq_t *tmq, const char *topic);
|
||||
DLL_EXPORT int32_t tmq_field_count(tmq_t *tmq, const char *topic);
|
||||
DLL_EXPORT void tmq_message_destroy(TAOS_RES *res);
|
||||
#endif
|
||||
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
|
||||
#if 0
|
||||
|
|
|
@ -78,13 +78,6 @@ typedef enum {
|
|||
TSDB_SMA_TYPE_ROLLUP = 2, // Rollup SMA
|
||||
} ETsdbSmaType;
|
||||
|
||||
typedef enum {
|
||||
TSDB_BSMA_TYPE_NONE = 0, // no block-wise SMA
|
||||
TSDB_BSMA_TYPE_I = 1, // sum/min/max(default)
|
||||
} ETsdbBSmaType;
|
||||
|
||||
#define TSDB_BSMA_TYPE_LATEST TSDB_BSMA_TYPE_I
|
||||
|
||||
extern char *qtypeStr[];
|
||||
|
||||
#define TSDB_PORT_HTTP 11
|
||||
|
|
|
@ -326,11 +326,20 @@ int32_t tDecodeSEpSet(SCoder* pDecoder, SEpSet* pEp);
|
|||
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
|
||||
void* taosDecodeSEpSet(const void* buf, SEpSet* pEp);
|
||||
|
||||
typedef struct {
|
||||
SEpSet epSet;
|
||||
} SMEpSet;
|
||||
|
||||
int32_t tSerializeSMEpSet(void* buf, int32_t bufLen, SMEpSet* pReq);
|
||||
int32_t tDeserializeSMEpSet(void* buf, int32_t buflen, SMEpSet* pReq);
|
||||
|
||||
typedef struct {
|
||||
int8_t connType;
|
||||
int32_t pid;
|
||||
char app[TSDB_APP_NAME_LEN];
|
||||
char db[TSDB_DB_NAME_LEN];
|
||||
char user[TSDB_USER_LEN];
|
||||
char passwd[TSDB_PASSWORD_LEN];
|
||||
int64_t startTime;
|
||||
} SConnectReq;
|
||||
|
||||
|
@ -482,7 +491,7 @@ typedef struct {
|
|||
char intervalUnit;
|
||||
char slidingUnit;
|
||||
char
|
||||
offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
|
||||
offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
|
||||
int8_t precision;
|
||||
int64_t interval;
|
||||
int64_t sliding;
|
||||
|
@ -680,6 +689,7 @@ int32_t tDeserializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
|
|||
|
||||
typedef struct {
|
||||
int32_t numOfFuncs;
|
||||
bool ignoreCodeComment;
|
||||
SArray* pFuncNames;
|
||||
} SRetrieveFuncReq;
|
||||
|
||||
|
@ -708,6 +718,7 @@ typedef struct {
|
|||
|
||||
int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
|
||||
int32_t tDeserializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
|
||||
void tFreeSFuncInfo(SFuncInfo *pInfo);
|
||||
void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
|
@ -980,7 +991,6 @@ int32_t tDeserializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
|
|||
void tFreeSShowRsp(SShowRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
int32_t type;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
char tb[TSDB_TABLE_NAME_LEN];
|
||||
int64_t showId;
|
||||
|
@ -1273,11 +1283,16 @@ typedef struct {
|
|||
} SMVCreateStreamRsp, SMSCreateStreamRsp;
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TOPIC_FNAME_LEN];
|
||||
int8_t igExists;
|
||||
char* sql;
|
||||
char* ast;
|
||||
char subscribeDbName[TSDB_DB_NAME_LEN];
|
||||
char name[TSDB_TOPIC_FNAME_LEN];
|
||||
int8_t igExists;
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
int8_t withTag;
|
||||
int8_t withTagSchema;
|
||||
char* sql;
|
||||
char* ast;
|
||||
int64_t subDbUid;
|
||||
char subscribeDbName[TSDB_DB_NAME_LEN];
|
||||
} SCMCreateTopicReq;
|
||||
|
||||
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
|
||||
|
@ -1471,8 +1486,12 @@ typedef struct {
|
|||
typedef struct {
|
||||
float xFilesFactor;
|
||||
int32_t delay;
|
||||
int8_t nFuncIds;
|
||||
int32_t qmsg1Len;
|
||||
int32_t qmsg2Len;
|
||||
func_id_t* pFuncIds;
|
||||
char* qmsg1; // not null: pAst1:qmsg1:SRetention1 => trigger aggr task1
|
||||
char* qmsg2; // not null: pAst2:qmsg2:SRetention2 => trigger aggr task2
|
||||
int8_t nFuncIds;
|
||||
} SRSmaParam;
|
||||
|
||||
typedef struct SVCreateTbReq {
|
||||
|
@ -1932,12 +1951,22 @@ static FORCE_INLINE void* taosDecodeSMqMsg(void* buf, SMqHbMsg* pMsg) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
enum {
|
||||
TOPIC_SUB_TYPE__DB = 1,
|
||||
TOPIC_SUB_TYPE__TABLE,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int64_t leftForVer;
|
||||
int32_t vgId;
|
||||
int64_t oldConsumerId;
|
||||
int64_t newConsumerId;
|
||||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
int8_t subType;
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
int8_t withTag;
|
||||
int8_t withTagSchema;
|
||||
char* qmsg;
|
||||
} SMqRebVgReq;
|
||||
|
||||
|
@ -1948,7 +1977,14 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
|
|||
tlen += taosEncodeFixedI64(buf, pReq->oldConsumerId);
|
||||
tlen += taosEncodeFixedI64(buf, pReq->newConsumerId);
|
||||
tlen += taosEncodeString(buf, pReq->subKey);
|
||||
tlen += taosEncodeString(buf, pReq->qmsg);
|
||||
tlen += taosEncodeFixedI8(buf, pReq->subType);
|
||||
tlen += taosEncodeFixedI8(buf, pReq->withTbName);
|
||||
tlen += taosEncodeFixedI8(buf, pReq->withSchema);
|
||||
tlen += taosEncodeFixedI8(buf, pReq->withTag);
|
||||
tlen += taosEncodeFixedI8(buf, pReq->withTagSchema);
|
||||
if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
tlen += taosEncodeString(buf, pReq->qmsg);
|
||||
}
|
||||
return tlen;
|
||||
}
|
||||
|
||||
|
@ -1958,7 +1994,14 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
|
|||
buf = taosDecodeFixedI64(buf, &pReq->oldConsumerId);
|
||||
buf = taosDecodeFixedI64(buf, &pReq->newConsumerId);
|
||||
buf = taosDecodeStringTo(buf, pReq->subKey);
|
||||
buf = taosDecodeString(buf, &pReq->qmsg);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->subType);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->withTbName);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->withSchema);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->withTag);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->withTagSchema);
|
||||
if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
buf = taosDecodeString(buf, &pReq->qmsg);
|
||||
}
|
||||
return (void*)buf;
|
||||
}
|
||||
|
||||
|
@ -2298,9 +2341,10 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
|
|||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tdFreeTSmaWrapper(STSmaWrapper* pSW) {
|
||||
static FORCE_INLINE void* tdFreeTSmaWrapper(STSmaWrapper* pSW) {
|
||||
tdDestroyTSmaWrapper(pSW);
|
||||
taosMemoryFreeClear(pSW);
|
||||
taosMemoryFree(pSW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
||||
|
@ -2688,6 +2732,7 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p
|
|||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1359,7 +1359,7 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema) {
|
|||
printf(">>>");
|
||||
for (int i = 0; i < pSchema->numOfCols; ++i) {
|
||||
STColumn *stCol = pSchema->columns + i;
|
||||
SCellVal sVal = {.valType = 255, .val = NULL};
|
||||
SCellVal sVal = { 255, NULL};
|
||||
if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ extern "C" {
|
|||
typedef struct SBnode SBnode;
|
||||
|
||||
typedef struct {
|
||||
#ifdef WINDOWS
|
||||
size_t avoidCompilationErrors;
|
||||
#endif
|
||||
} SBnodeLoad;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -213,7 +213,6 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, void * pTransporter, const
|
|||
*/
|
||||
int32_t catalogGetAllMeta(SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const SCatalogReq* pReq, SMetaData* pRsp);
|
||||
|
||||
|
||||
int32_t catalogGetQnodeList(SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, SArray* pQnodeList);
|
||||
|
||||
int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableMetaVersion **stables, uint32_t *num);
|
||||
|
@ -224,6 +223,8 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
|
|||
|
||||
int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* indexName, SIndexInfo* pInfo);
|
||||
|
||||
int32_t catalogGetUdfInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* funcName, SFuncInfo** pInfo);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy catalog and relase all resources
|
||||
|
|
|
@ -166,6 +166,7 @@ typedef struct SInputColumnInfoData {
|
|||
SColumnInfoData *pPTS; // primary timestamp column
|
||||
SColumnInfoData **pData;
|
||||
SColumnDataAgg **pColumnDataAgg;
|
||||
uint64_t uid; // table uid
|
||||
} SInputColumnInfoData;
|
||||
|
||||
// sql function runtime context
|
||||
|
@ -191,7 +192,7 @@ typedef struct SqlFunctionCtx {
|
|||
int16_t functionId; // function id
|
||||
char * pOutput; // final result output buffer, point to sdata->data
|
||||
int32_t numOfParams;
|
||||
SVariant param[4]; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
||||
SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
||||
int64_t *ptsList; // corresponding timestamp array list
|
||||
SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/
|
||||
int32_t offset;
|
||||
|
|
|
@ -119,12 +119,19 @@ typedef enum EFunctionType {
|
|||
struct SqlFunctionCtx;
|
||||
struct SResultRowEntryInfo;
|
||||
struct STimeWindow;
|
||||
struct SCatalog;
|
||||
|
||||
typedef struct SFmGetFuncInfoParam {
|
||||
struct SCatalog* pCtg;
|
||||
void *pRpc;
|
||||
const SEpSet* pMgmtEps;
|
||||
} SFmGetFuncInfoParam;
|
||||
|
||||
int32_t fmFuncMgtInit();
|
||||
|
||||
void fmFuncMgtDestroy();
|
||||
|
||||
int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncType);
|
||||
int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, const char* pFuncName, int32_t* pFuncId, int32_t* pFuncType);
|
||||
|
||||
int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ extern "C" {
|
|||
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
|
||||
cell1 = cell1->pNext, cell2 = cell2->pNext)
|
||||
|
||||
#define REPLACE_LIST1_NODE(newNode) cell1->pNode = (SNode*)(newNode)
|
||||
#define REPLACE_LIST2_NODE(newNode) cell2->pNode = (SNode*)(newNode)
|
||||
|
||||
#define FOREACH_FOR_REWRITE(node, list) \
|
||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
|
||||
|
||||
|
|
|
@ -155,7 +155,6 @@ typedef struct SLogicSubplan {
|
|||
|
||||
typedef struct SQueryLogicPlan {
|
||||
ENodeType type;
|
||||
int32_t totalLevel;
|
||||
SNodeList* pTopSubplans;
|
||||
} SQueryLogicPlan;
|
||||
|
||||
|
|
|
@ -229,10 +229,10 @@ typedef struct SFillNode {
|
|||
typedef struct SSelectStmt {
|
||||
ENodeType type; // QUERY_NODE_SELECT_STMT
|
||||
bool isDistinct;
|
||||
SNodeList* pProjectionList; // SNode
|
||||
SNodeList* pProjectionList;
|
||||
SNode* pFromTable;
|
||||
SNode* pWhere;
|
||||
SNodeList* pPartitionByList; // SNode
|
||||
SNodeList* pPartitionByList;
|
||||
SNode* pWindow;
|
||||
SNodeList* pGroupByList; // SGroupingSetNode
|
||||
SNode* pHaving;
|
||||
|
@ -245,12 +245,14 @@ typedef struct SSelectStmt {
|
|||
} SSelectStmt;
|
||||
|
||||
typedef enum ESetOperatorType {
|
||||
SET_OP_TYPE_UNION_ALL = 1
|
||||
SET_OP_TYPE_UNION_ALL = 1,
|
||||
SET_OP_TYPE_UNION
|
||||
} ESetOperatorType;
|
||||
|
||||
typedef struct SSetOperator {
|
||||
ENodeType type; // QUERY_NODE_SET_OPERATOR
|
||||
ESetOperatorType opType;
|
||||
SNodeList* pProjectionList;
|
||||
SNode* pLeft;
|
||||
SNode* pRight;
|
||||
SNodeList* pOrderByList; // SOrderByExprNode
|
||||
|
|
|
@ -51,6 +51,10 @@ typedef struct STableComInfo {
|
|||
|
||||
typedef struct SIndexMeta {
|
||||
|
||||
#ifdef WINDOWS
|
||||
size_t avoidCompilationErrors;
|
||||
#endif
|
||||
|
||||
} SIndexMeta;
|
||||
|
||||
|
||||
|
|
|
@ -54,12 +54,13 @@ typedef struct {
|
|||
uint16_t clientPort;
|
||||
SRpcMsg rpcMsg;
|
||||
int32_t rspLen;
|
||||
void *pRsp;
|
||||
void *pNode;
|
||||
void * pRsp;
|
||||
void * pNode;
|
||||
} SNodeMsg;
|
||||
|
||||
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *);
|
||||
typedef int (*RpcAfp)(void *parent, char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
typedef int (*RpcRfp)(void *parent, SRpcMsg *, SEpSet *);
|
||||
|
||||
typedef struct SRpcInit {
|
||||
uint16_t localPort; // local port
|
||||
|
@ -80,22 +81,25 @@ typedef struct SRpcInit {
|
|||
RpcCfp cfp;
|
||||
|
||||
// call back to retrieve the client auth info, for server app only
|
||||
RpcAfp afp;;
|
||||
RpcAfp afp;
|
||||
|
||||
// user defined retry func
|
||||
RpcRfp rfp;
|
||||
|
||||
void *parent;
|
||||
} SRpcInit;
|
||||
|
||||
typedef struct {
|
||||
void *val;
|
||||
void *val;
|
||||
int32_t (*clone)(void *src, void **dst);
|
||||
void (*freeFunc)(const void *arg);
|
||||
void (*freeFunc)(const void *arg);
|
||||
} SRpcCtxVal;
|
||||
|
||||
typedef struct {
|
||||
int32_t msgType;
|
||||
void *val;
|
||||
int32_t msgType;
|
||||
void * val;
|
||||
int32_t (*clone)(void *src, void **dst);
|
||||
void (*freeFunc)(const void *arg);
|
||||
void (*freeFunc)(const void *arg);
|
||||
} SRpcBrokenlinkVal;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -22,7 +22,6 @@ extern "C" {
|
|||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
|
@ -51,6 +50,15 @@ extern "C" {
|
|||
#include <sys/prctl.h>
|
||||
#include <argp.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
#include <time.h>
|
||||
#ifndef TD_USE_WINSOCK
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -63,22 +63,22 @@ int8_t atomic_add_fetch_8(int8_t volatile *ptr, int8_t val);
|
|||
int16_t atomic_add_fetch_16(int16_t volatile *ptr, int16_t val);
|
||||
int32_t atomic_add_fetch_32(int32_t volatile *ptr, int32_t val);
|
||||
int64_t atomic_add_fetch_64(int64_t volatile *ptr, int64_t val);
|
||||
void* atomic_add_fetch_ptr(void *ptr, int32_t val);
|
||||
void* atomic_add_fetch_ptr(void *ptr, void *val);
|
||||
int8_t atomic_fetch_add_8(int8_t volatile *ptr, int8_t val);
|
||||
int16_t atomic_fetch_add_16(int16_t volatile *ptr, int16_t val);
|
||||
int32_t atomic_fetch_add_32(int32_t volatile *ptr, int32_t val);
|
||||
int64_t atomic_fetch_add_64(int64_t volatile *ptr, int64_t val);
|
||||
void* atomic_fetch_add_ptr(void *ptr, int32_t val);
|
||||
void* atomic_fetch_add_ptr(void *ptr, void *val);
|
||||
int8_t atomic_sub_fetch_8(int8_t volatile *ptr, int8_t val);
|
||||
int16_t atomic_sub_fetch_16(int16_t volatile *ptr, int16_t val);
|
||||
int32_t atomic_sub_fetch_32(int32_t volatile *ptr, int32_t val);
|
||||
int64_t atomic_sub_fetch_64(int64_t volatile *ptr, int64_t val);
|
||||
void* atomic_sub_fetch_ptr(void *ptr, int32_t val);
|
||||
void* atomic_sub_fetch_ptr(void *ptr, void *val);
|
||||
int8_t atomic_fetch_sub_8(int8_t volatile *ptr, int8_t val);
|
||||
int16_t atomic_fetch_sub_16(int16_t volatile *ptr, int16_t val);
|
||||
int32_t atomic_fetch_sub_32(int32_t volatile *ptr, int32_t val);
|
||||
int64_t atomic_fetch_sub_64(int64_t volatile *ptr, int64_t val);
|
||||
void* atomic_fetch_sub_ptr(void *ptr, int32_t val);
|
||||
void* atomic_fetch_sub_ptr(void *ptr, void *val);
|
||||
int8_t atomic_and_fetch_8(int8_t volatile *ptr, int8_t val);
|
||||
int16_t atomic_and_fetch_16(int16_t volatile *ptr, int16_t val);
|
||||
int32_t atomic_and_fetch_32(int32_t volatile *ptr, int32_t val);
|
||||
|
|
|
@ -191,7 +191,7 @@ extern "C" {
|
|||
#define threadlocal __declspec( thread )
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#ifdef WINDOWS
|
||||
#define PRIzu "ld"
|
||||
#else
|
||||
#define PRIzu "zu"
|
||||
|
|
|
@ -36,12 +36,12 @@ typedef struct TdDirEntry *TdDirEntryPtr;
|
|||
|
||||
|
||||
void taosRemoveDir(const char *dirname);
|
||||
bool taosDirExist(char *dirname);
|
||||
bool taosDirExist(const char *dirname);
|
||||
int32_t taosMkDir(const char *dirname);
|
||||
int32_t taosMulMkDir(const char *dirname);
|
||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
||||
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
||||
int32_t taosRealPath(char *dirname, int32_t maxlen);
|
||||
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
|
||||
bool taosIsDir(const char *dirname);
|
||||
char* taosDirName(char *dirname);
|
||||
char* taosDirEntryBaseName(char *dirname);
|
||||
|
@ -50,7 +50,7 @@ TdDirPtr taosOpenDir(const char *dirname);
|
|||
TdDirEntryPtr taosReadDir(TdDirPtr pDir);
|
||||
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
|
||||
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry);
|
||||
int32_t taosCloseDir(TdDirPtr pDir);
|
||||
int32_t taosCloseDir(TdDirPtr *ppDir);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ extern int64_t tsOpenMax;
|
|||
extern int64_t tsStreamMax;
|
||||
extern float tsNumOfCores;
|
||||
extern int64_t tsTotalMemoryKB;
|
||||
extern char* tsProcPath;
|
||||
|
||||
extern char configDir[];
|
||||
extern char tsDataDir[];
|
||||
|
|
|
@ -93,7 +93,6 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix,
|
|||
|
||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
||||
|
||||
void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length);
|
||||
bool taosValidFile(TdFilePtr pFile);
|
||||
|
||||
int32_t taosGetErrorFile(TdFilePtr pFile);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#ifdef WINDOWS
|
||||
int32_t BUILDIN_CLZL(uint64_t val);
|
||||
int32_t BUILDIN_CLZ(uint32_t val);
|
||||
int32_t BUILDIN_CTZL(uint64_t val);
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
#define TPOW2(x) ((x) * (x))
|
||||
#define TABS(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#ifdef WINDOWS
|
||||
|
||||
#define TSWAP(a, b, c) \
|
||||
do { \
|
||||
|
@ -33,6 +33,7 @@ extern "C" {
|
|||
} while (0)
|
||||
#define TMAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define TMIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)),(aa) = TMIN((aa), (cc)))
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -19,32 +19,53 @@
|
|||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
#define socket SOCKET_FUNC_TAOS_FORBID
|
||||
#define bind BIND_FUNC_TAOS_FORBID
|
||||
#define listen LISTEN_FUNC_TAOS_FORBID
|
||||
#define accept ACCEPT_FUNC_TAOS_FORBID
|
||||
#define epoll_create EPOLL_CREATE_FUNC_TAOS_FORBID
|
||||
#define epoll_ctl EPOLL_CTL_FUNC_TAOS_FORBID
|
||||
#define epoll_wait EPOLL_WAIT_FUNC_TAOS_FORBID
|
||||
#define inet_addr INET_ADDR_FUNC_TAOS_FORBID
|
||||
#define inet_ntoa INET_NTOA_FUNC_TAOS_FORBID
|
||||
#define socket SOCKET_FUNC_TAOS_FORBID
|
||||
#define bind BIND_FUNC_TAOS_FORBID
|
||||
#define listen LISTEN_FUNC_TAOS_FORBID
|
||||
#define accept ACCEPT_FUNC_TAOS_FORBID
|
||||
#define epoll_create EPOLL_CREATE_FUNC_TAOS_FORBID
|
||||
#define epoll_ctl EPOLL_CTL_FUNC_TAOS_FORBID
|
||||
#define epoll_wait EPOLL_WAIT_FUNC_TAOS_FORBID
|
||||
#define inet_addr INET_ADDR_FUNC_TAOS_FORBID
|
||||
#define inet_ntoa INET_NTOA_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#include "winsock2.h"
|
||||
#include <WS2tcpip.h>
|
||||
#include <winbase.h>
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#include <stdlib.h>
|
||||
#define htobe16(x) _byteswap_ushort(x)
|
||||
#define htole16(x) (x)
|
||||
#define be16toh(x) _byteswap_ushort(x)
|
||||
#define le16toh(x) (x)
|
||||
|
||||
#define htobe32(x) _byteswap_ulong(x)
|
||||
#define htole32(x) (x)
|
||||
#define be32toh(x) _byteswap_ulong(x)
|
||||
#define le32toh(x) (x)
|
||||
|
||||
#define htobe64(x) _byteswap_uint64(x)
|
||||
#define htole64(x) (x)
|
||||
#define be64toh(x) _byteswap_uint64(x)
|
||||
#define le64toh(x) (x)
|
||||
#else
|
||||
#error byte order not supported
|
||||
#endif
|
||||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
#include <osEok.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
#define __BYTE_ORDER BYTE_ORDER
|
||||
#define __BIG_ENDIAN BIG_ENDIAN
|
||||
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
#define __PDP_ENDIAN PDP_ENDIAN
|
||||
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#if defined(_TD_DARWIN_64)
|
||||
#include <osEok.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -52,14 +73,10 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#define htobe64 htonll
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
typedef int socklen_t;
|
||||
#define TAOS_EPOLL_WAIT_TIME 100
|
||||
typedef SOCKET eventfd_t;
|
||||
#define eventfd(a, b) -1
|
||||
typedef SOCKET EpollFd;
|
||||
#define EpollClose(pollFd) epoll_close(pollFd)
|
||||
#ifndef EPOLLWAKEUP
|
||||
#define EPOLLWAKEUP (1u << 29)
|
||||
|
@ -79,31 +96,29 @@ extern "C" {
|
|||
#if defined(_TD_DARWIN_64)
|
||||
// #define htobe64 htonll
|
||||
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
# define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
# define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
# define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
# define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
#define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
#define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
#define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
|
||||
# define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
# define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
# define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
# define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
#define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
#define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
|
||||
# define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
# define htole64(x) OSSwapHostToLittleInt64(x)
|
||||
# define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
# define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
#define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
#define htole64(x) OSSwapHostToLittleInt64(x)
|
||||
#define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
|
||||
# define __BYTE_ORDER BYTE_ORDER
|
||||
# define __BIG_ENDIAN BIG_ENDIAN
|
||||
# define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
# define __PDP_ENDIAN PDP_ENDIAN
|
||||
#define __BYTE_ORDER BYTE_ORDER
|
||||
#define __BIG_ENDIAN BIG_ENDIAN
|
||||
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
#define __PDP_ENDIAN PDP_ENDIAN
|
||||
#endif
|
||||
|
||||
#define TAOS_EPOLL_WAIT_TIME 500
|
||||
|
||||
typedef int32_t SocketFd;
|
||||
typedef SocketFd EpollFd;
|
||||
|
||||
|
@ -122,7 +137,7 @@ typedef struct TdEpoll *TdEpollPtr;
|
|||
int32_t taosSendto(TdSocketPtr pSocket, void * msg, int len, unsigned int flags, const struct sockaddr * to, int tolen);
|
||||
int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len);
|
||||
int32_t taosReadSocket(TdSocketPtr pSocket, void *msg, int len);
|
||||
int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t flags, struct sockaddr *destAddr, socklen_t *addrLen);
|
||||
int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t flags, struct sockaddr *destAddr, int *addrLen);
|
||||
int32_t taosCloseSocketNoCheck1(SocketFd fd);
|
||||
int32_t taosCloseSocket(TdSocketPtr *ppSocket);
|
||||
int32_t taosCloseSocketServer(TdSocketServerPtr *ppSocketServer);
|
||||
|
@ -139,14 +154,15 @@ int32_t taosWriteMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
|||
int32_t taosReadMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
||||
int32_t taosNonblockwrite(TdSocketPtr pSocket, char *ptr, int32_t nbytes);
|
||||
int64_t taosCopyFds(TdSocketPtr pSrcSocket, TdSocketPtr pDestSocket, int64_t len);
|
||||
void taosWinSocketInit();
|
||||
|
||||
TdSocketPtr taosOpenUdpSocket(uint32_t localIp, uint16_t localPort);
|
||||
TdSocketPtr taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp);
|
||||
TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port);
|
||||
int32_t taosKeepTcpAlive(TdSocketPtr pSocket);
|
||||
TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, struct sockaddr *destAddr, socklen_t *addrLen);
|
||||
TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, struct sockaddr *destAddr, int *addrLen);
|
||||
|
||||
int32_t taosGetSocketName(TdSocketPtr pSocket,struct sockaddr *destAddr, socklen_t *addrLen);
|
||||
int32_t taosGetSocketName(TdSocketPtr pSocket,struct sockaddr *destAddr, int *addrLen);
|
||||
|
||||
void taosBlockSIGPIPE();
|
||||
uint32_t taosGetIpv4FromFqdn(const char *);
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef int32_t TdUcs4;
|
|||
#define wchar_t WCHAR_T_TYPE_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#ifdef WINDOWS
|
||||
#define tstrdup(str) _strdup(str)
|
||||
#else
|
||||
#define tstrdup(str) strdup(str)
|
||||
|
|
|
@ -22,9 +22,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef WINDOWS
|
||||
#ifndef __USE_XOPEN2K
|
||||
#define TD_USE_SPINLOCK_AS_MUTEX
|
||||
typedef pthread_mutex_t pthread_spinlock_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef pthread_t TdThread;
|
||||
typedef pthread_spinlock_t TdThreadSpinlock;
|
||||
|
@ -41,6 +44,13 @@ typedef pthread_key_t TdThreadKey;
|
|||
#define taosThreadCleanupPush pthread_cleanup_push
|
||||
#define taosThreadCleanupPop pthread_cleanup_pop
|
||||
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1)
|
||||
#else
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
#endif
|
||||
|
||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
|
@ -218,8 +228,7 @@ int32_t taosThreadSpinLock(TdThreadSpinlock * lock);
|
|||
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock);
|
||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock);
|
||||
void taosThreadTestCancel(void);
|
||||
int32_t taosThreadSigMask(int32_t how, sigset_t const *set, sigset_t * oset);
|
||||
int32_t taosThreadSigWait(const sigset_t * set, int32_t *sig);
|
||||
void taosThreadClear(TdThread *thread);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
|
@ -34,7 +32,7 @@ extern "C" {
|
|||
#define mktime MKTIME_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#ifdef WINDOWS
|
||||
|
||||
#define CLOCK_REALTIME 0
|
||||
|
||||
|
@ -58,6 +56,8 @@ extern "C" {
|
|||
|
||||
int32_t taosGetTimeOfDay(struct timeval *tv);
|
||||
|
||||
int32_t taosClockGetTime(int clock_id, struct timespec *pTS);
|
||||
|
||||
//@return timestamp in second
|
||||
int32_t taosGetTimestampSec();
|
||||
|
||||
|
@ -78,7 +78,7 @@ static FORCE_INLINE int64_t taosGetTimestampUs() {
|
|||
//@return timestamp in nanosecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||
struct timespec systemTime = {0};
|
||||
clock_gettime(CLOCK_REALTIME, &systemTime);
|
||||
taosClockGetTime(CLOCK_REALTIME, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void *taosbsearch(const void *key, const void *base, int64_t nmemb, int64_t size
|
|||
* @return
|
||||
*/
|
||||
void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const void *parcompar,
|
||||
__ext_compar_fn_t compar, const void *parswap, __ext_swap_fn_t swap, bool maxroot);
|
||||
__ext_compar_fn_t compar, char* buf, bool maxroot);
|
||||
|
||||
/**
|
||||
* sort heap to make sure it is a max/min root heap
|
||||
|
@ -98,7 +98,7 @@ void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const
|
|||
* @return
|
||||
*/
|
||||
void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, __ext_compar_fn_t compar,
|
||||
const void *parswap, __ext_swap_fn_t swap, bool maxroot);
|
||||
bool maxroot);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -614,6 +614,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
|
||||
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
|
||||
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
|
||||
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
|
||||
|
||||
//planner
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
|
|
@ -236,7 +236,8 @@ static FORCE_INLINE int32_t tEncodeFloat(SCoder* pEncoder, float val) {
|
|||
union {
|
||||
uint32_t ui;
|
||||
float f;
|
||||
} v = {.f = val};
|
||||
} v;
|
||||
v.f = val;
|
||||
|
||||
return tEncodeU32(pEncoder, v.ui);
|
||||
}
|
||||
|
@ -245,7 +246,8 @@ static FORCE_INLINE int32_t tEncodeDouble(SCoder* pEncoder, double val) {
|
|||
union {
|
||||
uint64_t ui;
|
||||
double d;
|
||||
} v = {.d = val};
|
||||
} v;
|
||||
v.d = val;
|
||||
|
||||
return tEncodeU64(pEncoder, v.ui);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define tjsonGetNumberValue(pJson, pName, val) -1
|
||||
#else
|
||||
#define tjsonGetNumberValue(pJson, pName, val) \
|
||||
({ \
|
||||
uint64_t _tmp = 0; \
|
||||
|
@ -29,6 +32,7 @@ extern "C" {
|
|||
val = _tmp; \
|
||||
_code; \
|
||||
})
|
||||
#endif
|
||||
|
||||
typedef void SJson;
|
||||
|
||||
|
|
|
@ -219,6 +219,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo);
|
|||
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
||||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4);
|
||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
||||
|
||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||
SMqRspObj* msg = (SMqRspObj*)res;
|
||||
|
@ -306,7 +307,6 @@ void hbMgrInitMqHbRspHandle();
|
|||
|
||||
SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code, bool keepQuery);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef struct SStmtBindInfo {
|
|||
} SStmtBindInfo;
|
||||
|
||||
typedef struct SStmtExecInfo {
|
||||
int32_t affectedRows;
|
||||
SRequestObj* pRequest;
|
||||
SHashObj* pVgHash;
|
||||
SHashObj* pBlockHash;
|
||||
|
|
|
@ -30,15 +30,15 @@
|
|||
#define TSC_VAR_RELEASED 0
|
||||
|
||||
SAppInfo appInfo;
|
||||
int32_t clientReqRefPool = -1;
|
||||
int32_t clientReqRefPool = -1;
|
||||
int32_t clientConnRefPool = -1;
|
||||
|
||||
static TdThreadOnce tscinit = PTHREAD_ONCE_INIT;
|
||||
volatile int32_t tscInitRes = 0;
|
||||
static TdThreadOnce tscinit = PTHREAD_ONCE_INIT;
|
||||
volatile int32_t tscInitRes = 0;
|
||||
|
||||
static void registerRequest(SRequestObj *pRequest) {
|
||||
STscObj *pTscObj = acquireTscObj(pRequest->pTscObj->id);
|
||||
|
||||
|
||||
assert(pTscObj != NULL);
|
||||
|
||||
// connection has been released already, abort creating request.
|
||||
|
@ -49,8 +49,8 @@ static void registerRequest(SRequestObj *pRequest) {
|
|||
if (pTscObj->pAppInfo) {
|
||||
SInstanceSummary *pSummary = &pTscObj->pAppInfo->summary;
|
||||
|
||||
int32_t total = atomic_add_fetch_64((int64_t*)&pSummary->totalRequests, 1);
|
||||
int32_t currentInst = atomic_add_fetch_64((int64_t*)&pSummary->currentRequests, 1);
|
||||
int32_t total = atomic_add_fetch_64((int64_t *)&pSummary->totalRequests, 1);
|
||||
int32_t currentInst = atomic_add_fetch_64((int64_t *)&pSummary->currentRequests, 1);
|
||||
tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64
|
||||
", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
|
@ -60,16 +60,16 @@ static void registerRequest(SRequestObj *pRequest) {
|
|||
static void deregisterRequest(SRequestObj *pRequest) {
|
||||
assert(pRequest != NULL);
|
||||
|
||||
STscObj * pTscObj = pRequest->pTscObj;
|
||||
STscObj *pTscObj = pRequest->pTscObj;
|
||||
SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary;
|
||||
|
||||
int32_t currentInst = atomic_sub_fetch_64((int64_t*)&pActivity->currentRequests, 1);
|
||||
int32_t currentInst = atomic_sub_fetch_64((int64_t *)&pActivity->currentRequests, 1);
|
||||
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1);
|
||||
|
||||
int64_t duration = taosGetTimestampUs() - pRequest->metric.start;
|
||||
tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64
|
||||
" ms, current:%d, app current:%d",
|
||||
pRequest->self, pTscObj->id, pRequest->requestId, duration/1000, num, currentInst);
|
||||
pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000, num, currentInst);
|
||||
releaseTscObj(pTscObj->id);
|
||||
}
|
||||
|
||||
|
@ -109,12 +109,12 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
}
|
||||
|
||||
void closeAllRequests(SHashObj *pRequests) {
|
||||
void *pIter = taosHashIterate(pRequests, NULL);
|
||||
void *pIter = taosHashIterate(pRequests, NULL);
|
||||
while (pIter != NULL) {
|
||||
int64_t *rid = pIter;
|
||||
|
||||
releaseRequest(*rid);
|
||||
|
||||
releaseRequest(*rid);
|
||||
|
||||
pIter = taosHashIterate(pRequests, pIter);
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
|
|||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pObj->pAppInfo = pAppInfo;
|
||||
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
||||
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
|
||||
|
@ -160,13 +160,9 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
|
|||
return pObj;
|
||||
}
|
||||
|
||||
STscObj *acquireTscObj(int64_t rid) {
|
||||
return (STscObj *)taosAcquireRef(clientConnRefPool, rid);
|
||||
}
|
||||
STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientConnRefPool, rid); }
|
||||
|
||||
int32_t releaseTscObj(int64_t rid) {
|
||||
return taosReleaseRef(clientConnRefPool, rid);
|
||||
}
|
||||
int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, rid); }
|
||||
|
||||
void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) {
|
||||
assert(pObj != NULL);
|
||||
|
@ -190,11 +186,11 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
|
|||
tsem_init(&pRequest->body.rspSem, 0, 0);
|
||||
|
||||
registerRequest(pRequest);
|
||||
|
||||
|
||||
return pRequest;
|
||||
}
|
||||
|
||||
static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
||||
void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
||||
taosMemoryFreeClear(pResInfo->pRspMsg);
|
||||
taosMemoryFreeClear(pResInfo->length);
|
||||
taosMemoryFreeClear(pResInfo->row);
|
||||
|
@ -217,7 +213,7 @@ static void doDestroyRequest(void *p) {
|
|||
assert(RID_VALID(pRequest->self));
|
||||
|
||||
taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||
|
||||
|
||||
taosMemoryFreeClear(pRequest->msgBuf);
|
||||
taosMemoryFreeClear(pRequest->sqlstr);
|
||||
taosMemoryFreeClear(pRequest->pDb);
|
||||
|
@ -244,14 +240,9 @@ void destroyRequest(SRequestObj *pRequest) {
|
|||
taosRemoveRef(clientReqRefPool, pRequest->self);
|
||||
}
|
||||
|
||||
SRequestObj *acquireRequest(int64_t rid) {
|
||||
return (SRequestObj *)taosAcquireRef(clientReqRefPool, rid);
|
||||
}
|
||||
|
||||
int32_t releaseRequest(int64_t rid) {
|
||||
return taosReleaseRef(clientReqRefPool, rid);
|
||||
}
|
||||
SRequestObj *acquireRequest(int64_t rid) { return (SRequestObj *)taosAcquireRef(clientReqRefPool, rid); }
|
||||
|
||||
int32_t releaseRequest(int64_t rid) { return taosReleaseRef(clientReqRefPool, rid); }
|
||||
|
||||
void taos_init_imp(void) {
|
||||
// In the APIs of other program language, taos_cleanup is not available yet.
|
||||
|
@ -380,7 +371,7 @@ uint64_t generateRequestId() {
|
|||
}
|
||||
|
||||
uint64_t id = 0;
|
||||
|
||||
|
||||
while (true) {
|
||||
int64_t ts = taosGetTimestampMs();
|
||||
uint64_t pid = taosGetPId();
|
||||
|
|
|
@ -146,7 +146,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
|
|||
(*pRequest)->sqlstr[sqlLen] = 0;
|
||||
(*pRequest)->sqlLen = sqlLen;
|
||||
|
||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self, sizeof((*pRequest)->self))) {
|
||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||
sizeof((*pRequest)->self))) {
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
tscError("put request to request hash failed");
|
||||
|
@ -263,7 +264,8 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
|
|||
}
|
||||
|
||||
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
|
||||
if (precision != TSDB_TIME_PRECISION_MILLI && precision != TSDB_TIME_PRECISION_MICRO && precision != TSDB_TIME_PRECISION_NANO) {
|
||||
if (precision != TSDB_TIME_PRECISION_MILLI && precision != TSDB_TIME_PRECISION_MICRO &&
|
||||
precision != TSDB_TIME_PRECISION_NANO) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +277,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
|||
|
||||
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
||||
int32_t code = schedulerExecJob(pTransporter, pNodeList, pDag, &pRequest->body.queryJob, pRequest->sqlstr,
|
||||
pRequest->metric.start, &res);
|
||||
pRequest->metric.start, &res);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
if (pRequest->body.queryJob != 0) {
|
||||
schedulerFreeJob(pRequest->body.queryJob);
|
||||
|
@ -300,7 +302,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
|||
}
|
||||
|
||||
SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code, bool keepQuery) {
|
||||
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
switch (pQuery->execMode) {
|
||||
|
@ -328,7 +330,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
|
|||
if (!keepQuery) {
|
||||
qDestroyQuery(pQuery);
|
||||
}
|
||||
|
||||
|
||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
||||
pRequest->code = terrno;
|
||||
}
|
||||
|
@ -336,7 +338,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
|
|||
return pRequest;
|
||||
}
|
||||
|
||||
|
||||
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
|
||||
SRequestObj* pRequest = NULL;
|
||||
SQuery* pQuery = NULL;
|
||||
|
@ -522,6 +523,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest, int8_t connType) {
|
|||
connectReq.pid = htonl(appInfo.pid);
|
||||
connectReq.startTime = htobe64(appInfo.startTime);
|
||||
tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app));
|
||||
tstrncpy(connectReq.user, pObj->user, sizeof(connectReq.user));
|
||||
tstrncpy(connectReq.passwd, pObj->pass, sizeof(connectReq.passwd));
|
||||
|
||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
||||
void* pReq = taosMemoryMalloc(contLen);
|
||||
|
@ -726,7 +729,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
|
||||
ASSERT(len <= bytes);
|
||||
ASSERT((p + len) < (pResultInfo->convertBuf[i] + colLength[i]));
|
||||
|
||||
|
||||
varDataSetLen(p, len);
|
||||
pCol->offset[j] = (p - pResultInfo->convertBuf[i]);
|
||||
p += (len + VARSTR_HEADER_SIZE);
|
||||
|
@ -744,51 +747,55 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
}
|
||||
|
||||
pResultInfo->convertBuf[i] = p;
|
||||
int32_t len = 0;
|
||||
int32_t len = 0;
|
||||
SResultColumn* pCol = &pResultInfo->pCol[i];
|
||||
for (int32_t j = 0; j < numOfRows; ++j) {
|
||||
if (pCol->offset[j] != -1) {
|
||||
char* pStart = pCol->offset[j] + pCol->pData;
|
||||
|
||||
int32_t jsonInnerType = *pStart;
|
||||
char *jsonInnerData = pStart + CHAR_BYTES;
|
||||
char dst[TSDB_MAX_JSON_TAG_LEN] = {0};
|
||||
if(jsonInnerType == TSDB_DATA_TYPE_NULL){
|
||||
char* jsonInnerData = pStart + CHAR_BYTES;
|
||||
char dst[TSDB_MAX_JSON_TAG_LEN] = {0};
|
||||
if (jsonInnerType == TSDB_DATA_TYPE_NULL) {
|
||||
sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
}else if(jsonInnerType == TSDB_DATA_TYPE_JSON){
|
||||
int32_t length = taosUcs4ToMbs((TdUcs4 *)varDataVal(jsonInnerData), varDataLen(jsonInnerData), varDataVal(dst));
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_JSON) {
|
||||
int32_t length =
|
||||
taosUcs4ToMbs((TdUcs4*)varDataVal(jsonInnerData), varDataLen(jsonInnerData), varDataVal(dst));
|
||||
|
||||
if (length <= 0) {
|
||||
tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, varDataVal(jsonInnerData));
|
||||
tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset,
|
||||
varDataVal(jsonInnerData));
|
||||
length = 0;
|
||||
}
|
||||
varDataSetLen(dst, length);
|
||||
}else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||
*(char*)varDataVal(dst) = '\"';
|
||||
int32_t length = taosUcs4ToMbs((TdUcs4 *)varDataVal(jsonInnerData), varDataLen(jsonInnerData), varDataVal(dst) + CHAR_BYTES);
|
||||
int32_t length = taosUcs4ToMbs((TdUcs4*)varDataVal(jsonInnerData), varDataLen(jsonInnerData),
|
||||
varDataVal(dst) + CHAR_BYTES);
|
||||
if (length <= 0) {
|
||||
tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, varDataVal(jsonInnerData));
|
||||
tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset,
|
||||
varDataVal(jsonInnerData));
|
||||
length = 0;
|
||||
}
|
||||
varDataSetLen(dst, length + CHAR_BYTES*2);
|
||||
varDataSetLen(dst, length + CHAR_BYTES * 2);
|
||||
*(char*)(varDataVal(dst), length + CHAR_BYTES) = '\"';
|
||||
}else if(jsonInnerType == TSDB_DATA_TYPE_DOUBLE){
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
double jsonVd = *(double*)(jsonInnerData);
|
||||
sprintf(varDataVal(dst), "%.9lf", jsonVd);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
}else if(jsonInnerType == TSDB_DATA_TYPE_BIGINT){
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_BIGINT) {
|
||||
int64_t jsonVd = *(int64_t*)(jsonInnerData);
|
||||
sprintf(varDataVal(dst), "%" PRId64, jsonVd);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
}else if(jsonInnerType == TSDB_DATA_TYPE_BOOL){
|
||||
sprintf(varDataVal(dst), "%s", (*((char *)jsonInnerData) == 1) ? "true" : "false");
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
||||
sprintf(varDataVal(dst), "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
}else {
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if(len + varDataTLen(dst) > colLength[i]){
|
||||
if (len + varDataTLen(dst) > colLength[i]) {
|
||||
p = taosMemoryRealloc(pResultInfo->convertBuf[i], len + varDataTLen(dst));
|
||||
if (p == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -135,6 +135,16 @@ void taos_free_result(TAOS_RES *res) {
|
|||
if (TD_RES_QUERY(res)) {
|
||||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
destroyRequest(pRequest);
|
||||
} else if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||
if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||
if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||
if (pRsp->rsp.blockSchema) taosArrayDestroy(pRsp->rsp.blockSchema);
|
||||
if (pRsp->rsp.blockTbName) taosArrayDestroy(pRsp->rsp.blockTbName);
|
||||
if (pRsp->rsp.blockTags) taosArrayDestroy(pRsp->rsp.blockTags);
|
||||
if (pRsp->rsp.blockTagSchema) taosArrayDestroy(pRsp->rsp.blockTagSchema);
|
||||
pRsp->resInfo.pRspMsg = NULL;
|
||||
doFreeReqResultInfo(&pRsp->resInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,6 +632,10 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) {
|
|||
return stmtSetTbName(stmt, name);
|
||||
}
|
||||
|
||||
int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name) {
|
||||
return taos_stmt_set_tbname(stmt, name);
|
||||
}
|
||||
|
||||
int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND_v2 *bind) {
|
||||
if (stmt == NULL || bind == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
|
|
|
@ -486,7 +486,8 @@ int stmtExec(TAOS_STMT *stmt) {
|
|||
|
||||
STMT_ERR_JRET(pStmt->exec.pRequest->code);
|
||||
|
||||
pStmt->affectedRows += taos_affected_rows(pStmt->exec.pRequest);
|
||||
pStmt->exec.affectedRows = taos_affected_rows(pStmt->exec.pRequest);
|
||||
pStmt->affectedRows += pStmt->exec.affectedRows;
|
||||
|
||||
_return:
|
||||
|
||||
|
|
|
@ -24,16 +24,6 @@
|
|||
#include "tqueue.h"
|
||||
#include "tref.h"
|
||||
|
||||
#if 0
|
||||
struct tmq_message_t {
|
||||
SMqPollRsp msg;
|
||||
char* topic;
|
||||
SArray* res; // SArray<SReqResultInfo>
|
||||
int32_t vgId;
|
||||
int32_t resIter;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int8_t tmqRspType;
|
||||
int32_t epoch;
|
||||
|
@ -770,105 +760,12 @@ _return:
|
|||
}
|
||||
#endif
|
||||
|
||||
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||
time_t tt;
|
||||
int32_t ms = 0;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
tt = (time_t)(val / 1000000000);
|
||||
ms = val % 1000000000;
|
||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
tt = (time_t)(val / 1000000);
|
||||
ms = val % 1000000;
|
||||
} else {
|
||||
tt = (time_t)(val / 1000);
|
||||
ms = val % 1000;
|
||||
}
|
||||
|
||||
/* comment out as it make testcases like select_with_tags.sim fail.
|
||||
but in windows, this may cause the call to localtime crash if tt < 0,
|
||||
need to find a better solution.
|
||||
if (tt < 0) {
|
||||
tt = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef WINDOWS
|
||||
if (tt < 0) tt = 0;
|
||||
#endif
|
||||
if (tt <= 0 && ms < 0) {
|
||||
tt--;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
ms += 1000000000;
|
||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
ms += 1000000;
|
||||
} else {
|
||||
ms += 1000;
|
||||
}
|
||||
}
|
||||
|
||||
struct tm* ptm = taosLocalTime(&tt, NULL);
|
||||
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", ptm);
|
||||
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
sprintf(buf + pos, ".%09d", ms);
|
||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
sprintf(buf + pos, ".%06d", ms);
|
||||
} else {
|
||||
sprintf(buf + pos, ".%03d", ms);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
#if 0
|
||||
int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) {
|
||||
if (tmq_message == NULL) return 0;
|
||||
SMqPollRsp* pRsp = &tmq_message->msg;
|
||||
return pRsp->skipLogNum;
|
||||
}
|
||||
|
||||
void tmqShowMsg(tmq_message_t* tmq_message) {
|
||||
if (tmq_message == NULL) return;
|
||||
|
||||
static bool noPrintSchema;
|
||||
char pBuf[128];
|
||||
SMqPollRsp* pRsp = &tmq_message->msg;
|
||||
int32_t colNum = 2;
|
||||
if (!noPrintSchema) {
|
||||
printf("|");
|
||||
for (int32_t i = 0; i < colNum; i++) {
|
||||
if (i == 0)
|
||||
printf(" %25s |", pRsp->schema->pSchema[i].name);
|
||||
else
|
||||
printf(" %15s |", pRsp->schema->pSchema[i].name);
|
||||
}
|
||||
printf("\n");
|
||||
printf("===============================================\n");
|
||||
noPrintSchema = true;
|
||||
}
|
||||
int32_t sz = taosArrayGetSize(pRsp->pBlockData);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGet(pRsp->pBlockData, i);
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
printf("|");
|
||||
for (int32_t k = 0; k < colNum; k++) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
formatTimestamp(pBuf, *(uint64_t*)var, TSDB_TIME_PRECISION_MILLI);
|
||||
printf(" %25s |", pBuf);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
printf(" %15u |", *(uint32_t*)var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||
|
@ -1049,7 +946,6 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
tDeleteSMqCMGetSubEpRsp(&rsp);
|
||||
} else {
|
||||
/*SMqCMGetSubEpRsp* pRsp = taosAllocateQitem(sizeof(SMqCMGetSubEpRsp));*/
|
||||
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper));
|
||||
if (pWrapper == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1208,7 +1104,6 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
|||
pRspObj->resIter = -1;
|
||||
memcpy(&pRspObj->rsp, &pWrapper->msg, sizeof(SMqDataBlkRsp));
|
||||
|
||||
/*SRetrieveTableRsp* pRetrieve = taosArrayGetP(pWrapper->msg.blockData, 0);*/
|
||||
pRspObj->resInfo.totalRows = 0;
|
||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
||||
|
@ -1355,31 +1250,6 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t blockingTime, bool pollIfReset) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
tmq_message_t* tmq_consumer_poll_v1(tmq_t* tmq, int64_t blocking_time) {
|
||||
tmq_message_t* rspMsg = NULL;
|
||||
int64_t startTime = taosGetTimestampMs();
|
||||
|
||||
int64_t status = atomic_load_64(&tmq->status);
|
||||
tmqAskEp(tmq, status == TMQ_CONSUMER_STATUS__INIT);
|
||||
|
||||
while (1) {
|
||||
rspMsg = tmqSyncPollImpl(tmq, blocking_time);
|
||||
if (rspMsg && rspMsg->consumeRsp.numOfTopics) {
|
||||
return rspMsg;
|
||||
}
|
||||
|
||||
if (blocking_time != 0) {
|
||||
int64_t endTime = taosGetTimestampMs();
|
||||
if (endTime - startTime > blocking_time) {
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
||||
SMqRspObj* rspObj;
|
||||
int64_t startTime = taosGetTimestampMs();
|
||||
|
@ -1417,137 +1287,10 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
if (blocking_time <= 0) blocking_time = 1;
|
||||
if (blocking_time > 1000) blocking_time = 1000;
|
||||
/*blocking_time = 1;*/
|
||||
|
||||
if (taosArrayGetSize(tmq->clientTopics) == 0) {
|
||||
tscDebug("consumer:%ld poll but not assigned", tmq->consumerId);
|
||||
/*printf("over1\n");*/
|
||||
taosMsleep(blocking_time);
|
||||
return NULL;
|
||||
}
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, tmq->nextTopicIdx);
|
||||
if (taosArrayGetSize(pTopic->vgs) == 0) {
|
||||
/*printf("over2\n");*/
|
||||
taosMsleep(blocking_time);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmq->nextTopicIdx = (tmq->nextTopicIdx + 1) % taosArrayGetSize(tmq->clientTopics);
|
||||
int32_t beginVgIdx = pTopic->nextVgIdx;
|
||||
while (1) {
|
||||
pTopic->nextVgIdx = (pTopic->nextVgIdx + 1) % taosArrayGetSize(pTopic->vgs);
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, pTopic->nextVgIdx);
|
||||
/*printf("consume vg %d, offset %ld\n", pVg->vgId, pVg->currentOffset);*/
|
||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, blocking_time, pTopic, pVg);
|
||||
if (pReq == NULL) {
|
||||
ASSERT(false);
|
||||
taosMsleep(blocking_time);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SMqPollCbParam* param = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
||||
if (param == NULL) {
|
||||
ASSERT(false);
|
||||
taosMsleep(blocking_time);
|
||||
return NULL;
|
||||
}
|
||||
param->tmq = tmq;
|
||||
param->retMsg = &tmq_message;
|
||||
param->pVg = pVg;
|
||||
tsem_init(¶m->rspSem, 0, 0);
|
||||
|
||||
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
||||
pRequest->body.requestMsg = (SDataBuf){
|
||||
.pData = pReq,
|
||||
.len = sizeof(SMqConsumeReq),
|
||||
.handle = NULL,
|
||||
};
|
||||
|
||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = param;
|
||||
sendInfo->fp = tmqPollCb;
|
||||
|
||||
/*printf("req offset: %ld\n", pReq->offset);*/
|
||||
|
||||
int64_t transporterId = 0;
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
||||
tmq->pollCnt++;
|
||||
|
||||
tsem_wait(¶m->rspSem);
|
||||
tsem_destroy(¶m->rspSem);
|
||||
taosMemoryFree(param);
|
||||
|
||||
if (tmq_message == NULL) {
|
||||
if (beginVgIdx == pTopic->nextVgIdx) {
|
||||
taosMsleep(blocking_time);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return tmq_message;
|
||||
}
|
||||
|
||||
/*tsem_wait(&pRequest->body.rspSem);*/
|
||||
|
||||
/*if (body != NULL) {*/
|
||||
/*destroySendMsgInfo(body);*/
|
||||
/*}*/
|
||||
|
||||
/*if (pRequest != NULL && terrno != TSDB_CODE_SUCCESS) {*/
|
||||
/*pRequest->code = terrno;*/
|
||||
/*}*/
|
||||
|
||||
/*return pRequest;*/
|
||||
tmq_resp_err_t tmq_consumer_close(tmq_t* tmq) {
|
||||
// TODO
|
||||
return TMQ_RESP_ERR__SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_vgroup_list, int32_t async) {
|
||||
if (tmq_topic_vgroup_list != NULL) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// TODO: change semaphore to gate
|
||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, 0, pTopic, pVg);
|
||||
|
||||
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
||||
pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)};
|
||||
SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
|
||||
if (pParam == NULL) {
|
||||
continue;
|
||||
}
|
||||
pParam->tmq = tmq;
|
||||
pParam->pVg = pVg;
|
||||
pParam->async = async;
|
||||
if (!async) tsem_init(&pParam->rspSem, 0, 0);
|
||||
|
||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqCommitCb;
|
||||
|
||||
int64_t transporterId = 0;
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
||||
|
||||
if (!async) tsem_wait(&pParam->rspSem);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
tmq_resp_err_t tmq_consumer_close(tmq_t* tmq) { return TMQ_RESP_ERR__SUCCESS; }
|
||||
|
||||
const char* tmq_err2str(tmq_resp_err_t err) {
|
||||
if (err == TMQ_RESP_ERR__SUCCESS) {
|
||||
|
@ -1573,10 +1316,3 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tmq_message_destroy(TAOS_RES* res) {
|
||||
if (res == NULL) return;
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) {
|
|||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select count(*) from tu");
|
||||
pRes = taos_query(pConn, "select now() from m1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
|
|
|
@ -5,8 +5,8 @@ target_include_directories(
|
|||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
IF(${TD_WINDOWS})
|
||||
PRIVATE "${TD_SOURCE_DIR}/contrib/pthread-win32"
|
||||
PRIVATE "${TD_SOURCE_DIR}/contrib/gnuregex"
|
||||
PRIVATE "${TD_SOURCE_DIR}/contrib/pthread"
|
||||
PRIVATE "${TD_SOURCE_DIR}/contrib/msvcregex"
|
||||
ENDIF ()
|
||||
)
|
||||
target_link_libraries(
|
||||
|
|
|
@ -110,7 +110,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
|
|||
|
||||
for (int i = 0; i < numOfCols; i++) {
|
||||
col_type_t type = 0;
|
||||
int8_t sma = TSDB_BSMA_TYPE_NONE;
|
||||
int8_t sma = 0;
|
||||
col_id_t colId = 0;
|
||||
col_bytes_t bytes = 0;
|
||||
buf = taosDecodeFixedI8(buf, &type);
|
||||
|
|
|
@ -434,6 +434,15 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
|||
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
||||
}
|
||||
tlen += taosEncodeFixedI32(buf, param->qmsg1Len);
|
||||
if (param->qmsg1Len > 0) {
|
||||
tlen += taosEncodeString(buf, param->qmsg1);
|
||||
}
|
||||
|
||||
tlen += taosEncodeFixedI32(buf, param->qmsg2Len);
|
||||
if (param->qmsg2Len > 0) {
|
||||
tlen += taosEncodeString(buf, param->qmsg2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TD_CHILD_TABLE:
|
||||
|
@ -496,18 +505,25 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
|||
buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
|
||||
}
|
||||
if (pReq->rollup) {
|
||||
pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
||||
pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryCalloc(1, sizeof(SRSmaParam));
|
||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
||||
buf = taosDecodeBinaryTo(buf, (void *)¶m->xFilesFactor, sizeof(param->xFilesFactor));
|
||||
buf = taosDecodeFixedI32(buf, ¶m->delay);
|
||||
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
||||
if (param->nFuncIds > 0) {
|
||||
param->pFuncIds = (func_id_t *)taosMemoryMalloc(param->nFuncIds * sizeof(func_id_t));
|
||||
param->pFuncIds = (func_id_t *)taosMemoryCalloc(param->nFuncIds, sizeof(func_id_t));
|
||||
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
||||
}
|
||||
} else {
|
||||
param->pFuncIds = NULL;
|
||||
}
|
||||
buf = taosDecodeFixedI32(buf, ¶m->qmsg1Len);
|
||||
if (param->qmsg1Len > 0) {
|
||||
buf = taosDecodeString(buf, ¶m->qmsg1);
|
||||
}
|
||||
|
||||
buf = taosDecodeFixedI32(buf, ¶m->qmsg2Len);
|
||||
if (param->qmsg2Len > 0) {
|
||||
buf = taosDecodeString(buf, ¶m->qmsg2);
|
||||
}
|
||||
} else {
|
||||
pReq->stbCfg.pRSmaParam = NULL;
|
||||
|
@ -828,6 +844,27 @@ void tFreeSMAltertbReq(SMAltertbReq *pReq) {
|
|||
taosArrayDestroy(pReq->pFields);
|
||||
pReq->pFields = NULL;
|
||||
}
|
||||
int32_t tSerializeSMEpSet(void *buf, int32_t bufLen, SMEpSet *pReq) {
|
||||
SCoder encoder = {0};
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeSEpSet(&encoder, &pReq->epSet) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
int32_t tlen = encoder.pos;
|
||||
tCoderClear(&encoder);
|
||||
return tlen;
|
||||
}
|
||||
int32_t tDeserializeSMEpSet(void *buf, int32_t bufLen, SMEpSet *pReq) {
|
||||
SCoder decoder = {0};
|
||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeSEpSet(&decoder, &pReq->epSet) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
tCoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq) {
|
||||
SCoder encoder = {0};
|
||||
|
@ -1624,6 +1661,7 @@ int32_t tSerializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq *
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfFuncs) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->ignoreCodeComment) < 0) return -1;
|
||||
|
||||
if (pReq->numOfFuncs != (int32_t)taosArrayGetSize(pReq->pFuncNames)) return -1;
|
||||
for (int32_t i = 0; i < pReq->numOfFuncs; ++i) {
|
||||
|
@ -1644,6 +1682,7 @@ int32_t tDeserializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfFuncs) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, (int8_t *)&pReq->ignoreCodeComment) < 0) return -1;
|
||||
|
||||
pReq->pFuncNames = taosArrayInit(pReq->numOfFuncs, TSDB_FUNC_NAME_LEN);
|
||||
if (pReq->pFuncNames == NULL) return -1;
|
||||
|
@ -1681,8 +1720,12 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp *
|
|||
if (tEncodeI64(&encoder, pInfo->signature) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pInfo->codeSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pInfo->commentSize) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pInfo->pCode) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pInfo->pComment) < 0) return -1;
|
||||
if (pInfo->codeSize) {
|
||||
if (tEncodeCStr(&encoder, pInfo->pCode) < 0) return -1;
|
||||
}
|
||||
if (pInfo->commentSize) {
|
||||
if (tEncodeCStr(&encoder, pInfo->pComment) < 0) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
@ -1713,15 +1756,23 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
|
|||
if (tDecodeI64(&decoder, &fInfo.signature) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &fInfo.codeSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &fInfo.commentSize) < 0) return -1;
|
||||
fInfo.pCode = taosMemoryCalloc(1, fInfo.codeSize);
|
||||
fInfo.pComment = taosMemoryCalloc(1, fInfo.commentSize);
|
||||
if (fInfo.pCode == NULL || fInfo.pComment == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
if (fInfo.codeSize) {
|
||||
fInfo.pCode = taosMemoryCalloc(1, fInfo.codeSize);
|
||||
if (fInfo.pCode == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
if (tDecodeCStrTo(&decoder, fInfo.pCode) < 0) return -1;
|
||||
}
|
||||
if (fInfo.commentSize) {
|
||||
fInfo.pComment = taosMemoryCalloc(1, fInfo.commentSize);
|
||||
if (fInfo.pComment == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
if (tDecodeCStrTo(&decoder, fInfo.pComment) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tDecodeCStrTo(&decoder, fInfo.pCode) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, fInfo.pComment) < 0) return -1;
|
||||
taosArrayPush(pRsp->pFuncInfos, &fInfo);
|
||||
}
|
||||
tEndDecode(&decoder);
|
||||
|
@ -1730,12 +1781,20 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tFreeSFuncInfo(SFuncInfo *pInfo) {
|
||||
if (NULL == pInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
taosMemoryFree(pInfo->pCode);
|
||||
taosMemoryFree(pInfo->pComment);
|
||||
}
|
||||
|
||||
void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp *pRsp) {
|
||||
int32_t size = taosArrayGetSize(pRsp->pFuncInfos);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SFuncInfo *pInfo = taosArrayGet(pRsp->pFuncInfos, i);
|
||||
taosMemoryFree(pInfo->pCode);
|
||||
taosMemoryFree(pInfo->pComment);
|
||||
tFreeSFuncInfo(pInfo);
|
||||
}
|
||||
taosArrayDestroy(pRsp->pFuncInfos);
|
||||
}
|
||||
|
@ -2403,7 +2462,6 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->showId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->type) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->tb) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
@ -2419,7 +2477,6 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->showId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->type) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->tb) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
@ -2674,6 +2731,10 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withTbName) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withSchema) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withTag) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withTagSchema) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, sqlLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, astLen) < 0) return -1;
|
||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||
|
@ -2696,6 +2757,10 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->withTbName) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->withSchema) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->withTag) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->withTagSchema) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||
|
||||
|
@ -2756,6 +2821,8 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
|
|||
if (tEncodeI32(&encoder, pReq->pid) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->app) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->passwd) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->startTime) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -2773,6 +2840,8 @@ int32_t tDeserializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
|
|||
if (tDecodeI32(&decoder, &pReq->pid) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->app) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->passwd) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->startTime) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
|
@ -3032,7 +3101,6 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq) {
|
||||
SCoder encoder = {0};
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||
|
@ -3052,7 +3120,7 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
|
|||
SReplica *pReplica = &pReq->replicas[i];
|
||||
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
||||
}
|
||||
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -3085,7 +3153,6 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSKillQueryReq(void *buf, int32_t bufLen, SKillQueryReq *pReq) {
|
||||
SCoder encoder = {0};
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||
|
|
|
@ -167,7 +167,7 @@ TEST(testCase, Datablock_test) {
|
|||
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
||||
|
||||
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
||||
SBlockOrderInfo order = {.nullFirst = true, .order = TSDB_ORDER_ASC, .slotId = 0};
|
||||
SBlockOrderInfo order = { true, TSDB_ORDER_ASC, 0, NULL };
|
||||
taosArrayPush(pOrderInfo, &order);
|
||||
|
||||
blockDataSort(b, pOrderInfo);
|
||||
|
|
|
@ -40,10 +40,12 @@ static void dmSetSignalHandle() {
|
|||
taosSetSignal(SIGTERM, dmStopDnode);
|
||||
taosSetSignal(SIGHUP, dmStopDnode);
|
||||
taosSetSignal(SIGINT, dmStopDnode);
|
||||
taosSetSignal(SIGTSTP, dmStopDnode);
|
||||
taosSetSignal(SIGABRT, dmStopDnode);
|
||||
taosSetSignal(SIGBREAK, dmStopDnode);
|
||||
#ifndef WINDOWS
|
||||
taosSetSignal(SIGTSTP, dmStopDnode);
|
||||
taosSetSignal(SIGQUIT, dmStopDnode);
|
||||
#endif
|
||||
|
||||
if (!tsMultiProcess) {
|
||||
} else if (global.ntype == DNODE || global.ntype == NODE_END) {
|
||||
|
|
|
@ -216,6 +216,126 @@ static void dmStopMgmt(SMgmtWrapper *pWrapper) {
|
|||
dmStopStatusThread(pWrapper->pDnode);
|
||||
}
|
||||
|
||||
static int32_t dmSpawnUdfd(SDnode *pDnode);
|
||||
|
||||
void dmUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) {
|
||||
dInfo("udfd process exited with status %" PRId64 ", signal %d", exitStatus, termSignal);
|
||||
uv_close((uv_handle_t*)process, NULL);
|
||||
SDnode *pDnode = process->data;
|
||||
SUdfdData *pData = &pDnode->udfdData;
|
||||
if (atomic_load_8(&pData->stopping) != 0) {
|
||||
dDebug("udfd process exit due to stopping");
|
||||
} else {
|
||||
uv_close((uv_handle_t*)&pData->ctrlPipe, NULL);
|
||||
dmSpawnUdfd(pDnode);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t dmSpawnUdfd(SDnode *pDnode) {
|
||||
dInfo("dnode start spawning udfd");
|
||||
uv_process_options_t options = {0};
|
||||
|
||||
char path[PATH_MAX] = {0};
|
||||
if (tsProcPath == NULL) {
|
||||
path[0] = '.';
|
||||
} else {
|
||||
strncpy(path, tsProcPath, strlen(tsProcPath));
|
||||
taosDirName(path);
|
||||
}
|
||||
strcat(path, "/udfd");
|
||||
char* argsUdfd[] = {path, "-c", configDir, NULL};
|
||||
options.args = argsUdfd;
|
||||
options.file = path;
|
||||
|
||||
options.exit_cb = dmUdfdExit;
|
||||
SUdfdData *pData = &pDnode->udfdData;
|
||||
uv_pipe_init(&pData->loop, &pData->ctrlPipe, 1);
|
||||
|
||||
uv_stdio_container_t child_stdio[3];
|
||||
child_stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
|
||||
child_stdio[0].data.stream = (uv_stream_t*) &pData->ctrlPipe;
|
||||
child_stdio[1].flags = UV_IGNORE;
|
||||
child_stdio[2].flags = UV_INHERIT_FD;
|
||||
child_stdio[2].data.fd = 2;
|
||||
options.stdio_count = 3;
|
||||
options.stdio = child_stdio;
|
||||
|
||||
char dnodeIdEnvItem[32] = {0};
|
||||
char thrdPoolSizeEnvItem[32] = {0};
|
||||
snprintf(dnodeIdEnvItem, 32, "%s=%d", "DNODE_ID", pDnode->data.dnodeId);
|
||||
float numCpuCores = 4;
|
||||
taosGetCpuCores(&numCpuCores);
|
||||
snprintf(thrdPoolSizeEnvItem,32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores*2);
|
||||
char* envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, NULL};
|
||||
options.env = envUdfd;
|
||||
|
||||
int err = uv_spawn(&pData->loop, &pData->process, &options);
|
||||
pData->process.data = (void*)pDnode;
|
||||
|
||||
if (err != 0) {
|
||||
dError("can not spawn udfd. path: %s, error: %s", path, uv_strerror(err));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void dmUdfdCloseWalkCb(uv_handle_t* handle, void* arg) {
|
||||
if (!uv_is_closing(handle)) {
|
||||
uv_close(handle, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void dmWatchUdfd(void *args) {
|
||||
SDnode *pDnode = args;
|
||||
SUdfdData *pData = &pDnode->udfdData;
|
||||
uv_loop_init(&pData->loop);
|
||||
int32_t err = dmSpawnUdfd(pDnode);
|
||||
atomic_store_32(&pData->spawnErr, err);
|
||||
uv_barrier_wait(&pData->barrier);
|
||||
uv_run(&pData->loop, UV_RUN_DEFAULT);
|
||||
err = uv_loop_close(&pData->loop);
|
||||
while (err == UV_EBUSY) {
|
||||
uv_walk(&pData->loop, dmUdfdCloseWalkCb, NULL);
|
||||
uv_run(&pData->loop, UV_RUN_DEFAULT);
|
||||
err = uv_loop_close(&pData->loop);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t dmStartUdfd(SDnode *pDnode) {
|
||||
SUdfdData *pData = &pDnode->udfdData;
|
||||
if (pData->startCalled) {
|
||||
dInfo("dnode-mgmt start udfd already called");
|
||||
return 0;
|
||||
}
|
||||
pData->startCalled = true;
|
||||
uv_barrier_init(&pData->barrier, 2);
|
||||
pData->stopping = 0;
|
||||
uv_thread_create(&pData->thread, dmWatchUdfd, pDnode);
|
||||
uv_barrier_wait(&pData->barrier);
|
||||
pData->needCleanUp = true;
|
||||
return pData->spawnErr;
|
||||
}
|
||||
|
||||
int32_t dmStopUdfd(SDnode *pDnode) {
|
||||
dInfo("dnode-mgmt to stop udfd. need cleanup: %d, spawn err: %d",
|
||||
pDnode->udfdData.needCleanUp, pDnode->udfdData.spawnErr);
|
||||
SUdfdData *pData = &pDnode->udfdData;
|
||||
if (!pData->needCleanUp) {
|
||||
return 0;
|
||||
}
|
||||
atomic_store_8(&pData->stopping, 1);
|
||||
|
||||
uv_barrier_destroy(&pData->barrier);
|
||||
if (pData->spawnErr == 0) {
|
||||
uv_process_kill(&pData->process, SIGINT);
|
||||
}
|
||||
uv_stop(&pData->loop);
|
||||
uv_thread_join(&pData->thread);
|
||||
|
||||
atomic_store_8(&pData->stopping, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
|
||||
dInfo("dnode-mgmt start to init");
|
||||
SDnode *pDnode = pWrapper->pDnode;
|
||||
|
@ -247,6 +367,10 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
|
|||
}
|
||||
dmReportStartup(pDnode, "dnode-transport", "initialized");
|
||||
|
||||
if (dmStartUdfd(pDnode) != 0) {
|
||||
dError("failed to start udfd");
|
||||
}
|
||||
|
||||
dInfo("dnode-mgmt is initialized");
|
||||
return 0;
|
||||
}
|
||||
|
@ -254,6 +378,7 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
|
|||
static void dmCleanupMgmt(SMgmtWrapper *pWrapper) {
|
||||
dInfo("dnode-mgmt start to clean up");
|
||||
SDnode *pDnode = pWrapper->pDnode;
|
||||
dmStopUdfd(pDnode);
|
||||
dmStopWorker(pDnode);
|
||||
|
||||
taosWLockLatch(&pDnode->data.latch);
|
||||
|
|
|
@ -119,10 +119,10 @@ _OVER:
|
|||
}
|
||||
|
||||
static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
SDnodeTrans * pTrans = &pDnode->trans;
|
||||
tmsg_t msgType = pMsg->msgType;
|
||||
bool isReq = msgType & 1u;
|
||||
SMsgHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(msgType)];
|
||||
SMsgHandle * pHandle = &pTrans->msgHandles[TMSG_INDEX(msgType)];
|
||||
SMgmtWrapper *pWrapper = pHandle->pNdWrapper;
|
||||
|
||||
if (msgType == TDMT_DND_SERVER_STATUS) {
|
||||
|
@ -443,7 +443,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
|
|||
SAuthReq authReq = {0};
|
||||
tstrncpy(authReq.user, user, TSDB_USER_LEN);
|
||||
int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq);
|
||||
void *pReq = rpcMallocCont(contLen);
|
||||
void * pReq = rpcMallocCont(contLen);
|
||||
tSerializeSAuthReq(pReq, contLen, &authReq);
|
||||
|
||||
SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .ahandle = (void *)9528};
|
||||
|
@ -523,4 +523,4 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) {
|
|||
.pWrapper = pWrapper,
|
||||
};
|
||||
return msgCb;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef _TD_DM_DEF_H_
|
||||
#define _TD_DM_DEF_H_
|
||||
|
||||
#include "uv.h"
|
||||
#include "dmLog.h"
|
||||
|
||||
#include "cJSON.h"
|
||||
|
@ -142,6 +143,18 @@ typedef struct {
|
|||
char desc[TSDB_STEP_DESC_LEN];
|
||||
} SStartupInfo;
|
||||
|
||||
typedef struct SUdfdData {
|
||||
bool startCalled;
|
||||
bool needCleanUp;
|
||||
uv_loop_t loop;
|
||||
uv_thread_t thread;
|
||||
uv_barrier_t barrier;
|
||||
uv_process_t process;
|
||||
int spawnErr;
|
||||
int8_t stopping;
|
||||
uv_pipe_t ctrlPipe;
|
||||
} SUdfdData;
|
||||
|
||||
typedef struct SDnode {
|
||||
EDndProcType ptype;
|
||||
EDndNodeType ntype;
|
||||
|
@ -150,6 +163,7 @@ typedef struct SDnode {
|
|||
SStartupInfo startup;
|
||||
SDnodeTrans trans;
|
||||
SDnodeData data;
|
||||
SUdfdData udfdData;
|
||||
TdThreadMutex mutex;
|
||||
SMgmtWrapper wrappers[NODE_END];
|
||||
} SDnode;
|
||||
|
|
|
@ -89,7 +89,6 @@ int32_t Testbase::SendShowReq(int8_t showType, const char *tb, const char* db) {
|
|||
}
|
||||
|
||||
SRetrieveTableReq retrieveReq = {0};
|
||||
retrieveReq.type = showType;
|
||||
strcpy(retrieveReq.db, db);
|
||||
strcpy(retrieveReq.tb, tb);
|
||||
|
||||
|
|
|
@ -391,7 +391,6 @@ typedef struct {
|
|||
int16_t numOfColumns;
|
||||
int32_t rowSize;
|
||||
int32_t numOfRows;
|
||||
int32_t payloadLen;
|
||||
void* pIter;
|
||||
SMnode* pMnode;
|
||||
STableMetaRsp* pMeta;
|
||||
|
@ -418,82 +417,6 @@ typedef struct {
|
|||
char payload[];
|
||||
} SSysTableRetrieveObj;
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId; // -1 for unassigned
|
||||
int32_t status;
|
||||
int32_t epoch;
|
||||
SEpSet epSet;
|
||||
int64_t oldConsumerId;
|
||||
int64_t consumerId; // -1 for unassigned
|
||||
char* qmsg;
|
||||
} SMqConsumerEp;
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSMqConsumerEp(void** buf, const SMqConsumerEp* pConsumerEp) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI32(buf, pConsumerEp->vgId);
|
||||
tlen += taosEncodeFixedI32(buf, pConsumerEp->status);
|
||||
tlen += taosEncodeFixedI32(buf, pConsumerEp->epoch);
|
||||
tlen += taosEncodeSEpSet(buf, &pConsumerEp->epSet);
|
||||
tlen += taosEncodeFixedI64(buf, pConsumerEp->oldConsumerId);
|
||||
tlen += taosEncodeFixedI64(buf, pConsumerEp->consumerId);
|
||||
tlen += taosEncodeString(buf, pConsumerEp->qmsg);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDecodeSMqConsumerEp(void** buf, SMqConsumerEp* pConsumerEp) {
|
||||
buf = taosDecodeFixedI32(buf, &pConsumerEp->vgId);
|
||||
buf = taosDecodeFixedI32(buf, &pConsumerEp->status);
|
||||
buf = taosDecodeFixedI32(buf, &pConsumerEp->epoch);
|
||||
buf = taosDecodeSEpSet(buf, &pConsumerEp->epSet);
|
||||
buf = taosDecodeFixedI64(buf, &pConsumerEp->oldConsumerId);
|
||||
buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId);
|
||||
buf = taosDecodeString(buf, &pConsumerEp->qmsg);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tDeleteSMqConsumerEp(SMqConsumerEp* pConsumerEp) {
|
||||
if (pConsumerEp) {
|
||||
taosMemoryFreeClear(pConsumerEp->qmsg);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int64_t consumerId;
|
||||
SArray* vgInfo; // SArray<SMqConsumerEp>
|
||||
} SMqSubConsumer;
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSMqSubConsumer(void** buf, const SMqSubConsumer* pConsumer) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI64(buf, pConsumer->consumerId);
|
||||
int32_t sz = taosArrayGetSize(pConsumer->vgInfo);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp* pCEp = taosArrayGet(pConsumer->vgInfo, i);
|
||||
tlen += tEncodeSMqConsumerEp(buf, pCEp);
|
||||
}
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDecodeSMqSubConsumer(void** buf, SMqSubConsumer* pConsumer) {
|
||||
int32_t sz;
|
||||
buf = taosDecodeFixedI64(buf, &pConsumer->consumerId);
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pConsumer->vgInfo = taosArrayInit(sz, sizeof(SMqConsumerEp));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp consumerEp;
|
||||
buf = tDecodeSMqConsumerEp(buf, &consumerEp);
|
||||
taosArrayPush(pConsumer->vgInfo, &consumerEp);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tDeleteSMqSubConsumer(SMqSubConsumer* pSubConsumer) {
|
||||
if (pSubConsumer->vgInfo) {
|
||||
taosArrayDestroyEx(pSubConsumer->vgInfo, (void (*)(void*))tDeleteSMqConsumerEp);
|
||||
pSubConsumer->vgInfo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char key[TSDB_PARTITION_KEY_LEN];
|
||||
int64_t offset;
|
||||
|
@ -512,147 +435,21 @@ static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset)
|
|||
return buf;
|
||||
}
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
int32_t status;
|
||||
int32_t vgNum;
|
||||
SArray* consumers; // SArray<SMqSubConsumer>
|
||||
SArray* lostConsumers; // SArray<SMqSubConsumer>
|
||||
SArray* unassignedVg; // SArray<SMqConsumerEp>
|
||||
} SMqSubscribeObj;
|
||||
|
||||
static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
|
||||
SMqSubscribeObj* pSub = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
|
||||
if (pSub == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSub->consumers = taosArrayInit(0, sizeof(SMqSubConsumer));
|
||||
if (pSub->consumers == NULL) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pSub->lostConsumers = taosArrayInit(0, sizeof(SMqSubConsumer));
|
||||
if (pSub->lostConsumers == NULL) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pSub->unassignedVg = taosArrayInit(0, sizeof(SMqConsumerEp));
|
||||
if (pSub->unassignedVg == NULL) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pSub->key[0] = 0;
|
||||
pSub->vgNum = 0;
|
||||
pSub->status = 0;
|
||||
|
||||
return pSub;
|
||||
|
||||
_err:
|
||||
taosMemoryFreeClear(pSub->consumers);
|
||||
taosMemoryFreeClear(pSub->lostConsumers);
|
||||
taosMemoryFreeClear(pSub->unassignedVg);
|
||||
taosMemoryFreeClear(pSub);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeString(buf, pSub->key);
|
||||
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
|
||||
tlen += taosEncodeFixedI32(buf, pSub->status);
|
||||
int32_t sz;
|
||||
|
||||
sz = taosArrayGetSize(pSub->consumers);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqSubConsumer* pSubConsumer = taosArrayGet(pSub->consumers, i);
|
||||
tlen += tEncodeSMqSubConsumer(buf, pSubConsumer);
|
||||
}
|
||||
|
||||
sz = taosArrayGetSize(pSub->lostConsumers);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqSubConsumer* pSubConsumer = taosArrayGet(pSub->lostConsumers, i);
|
||||
tlen += tEncodeSMqSubConsumer(buf, pSubConsumer);
|
||||
}
|
||||
|
||||
sz = taosArrayGetSize(pSub->unassignedVg);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp* pCEp = taosArrayGet(pSub->unassignedVg, i);
|
||||
tlen += tEncodeSMqConsumerEp(buf, pCEp);
|
||||
}
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub) {
|
||||
buf = taosDecodeStringTo(buf, pSub->key);
|
||||
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
|
||||
buf = taosDecodeFixedI32(buf, &pSub->status);
|
||||
|
||||
int32_t sz;
|
||||
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pSub->consumers = taosArrayInit(sz, sizeof(SMqSubConsumer));
|
||||
if (pSub->consumers == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqSubConsumer subConsumer = {0};
|
||||
buf = tDecodeSMqSubConsumer(buf, &subConsumer);
|
||||
taosArrayPush(pSub->consumers, &subConsumer);
|
||||
}
|
||||
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pSub->lostConsumers = taosArrayInit(sz, sizeof(SMqSubConsumer));
|
||||
if (pSub->lostConsumers == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqSubConsumer subConsumer = {0};
|
||||
buf = tDecodeSMqSubConsumer(buf, &subConsumer);
|
||||
taosArrayPush(pSub->lostConsumers, &subConsumer);
|
||||
}
|
||||
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pSub->unassignedVg = taosArrayInit(sz, sizeof(SMqConsumerEp));
|
||||
if (pSub->unassignedVg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp consumerEp = {0};
|
||||
buf = tDecodeSMqConsumerEp(buf, &consumerEp);
|
||||
taosArrayPush(pSub->unassignedVg, &consumerEp);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) {
|
||||
if (pSub->consumers) {
|
||||
// taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
|
||||
// taosArrayDestroy(pSub->consumers);
|
||||
pSub->consumers = NULL;
|
||||
}
|
||||
|
||||
if (pSub->unassignedVg) {
|
||||
// taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
|
||||
// taosArrayDestroy(pSub->unassignedVg);
|
||||
pSub->unassignedVg = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TOPIC_FNAME_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t createTime;
|
||||
int64_t updateTime;
|
||||
int64_t uid;
|
||||
char name[TSDB_TOPIC_FNAME_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t createTime;
|
||||
int64_t updateTime;
|
||||
int64_t uid;
|
||||
// TODO: use subDbUid
|
||||
int64_t dbUid;
|
||||
int64_t subDbUid;
|
||||
int32_t version;
|
||||
int8_t subType; // db or table
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
int8_t withTag;
|
||||
int8_t withTagSchema;
|
||||
SRWLatch lock;
|
||||
int32_t sqlLen;
|
||||
int32_t astLen;
|
||||
|
@ -662,79 +459,6 @@ typedef struct {
|
|||
SSchemaWrapper schema;
|
||||
} SMqTopicObj;
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
int64_t consumerId;
|
||||
int64_t connId;
|
||||
SRWLatch lock;
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
SArray* currentTopics; // SArray<char*>
|
||||
SArray* recentRemovedTopics; // SArray<char*>
|
||||
int32_t epoch;
|
||||
// stat
|
||||
int64_t pollCnt;
|
||||
// status
|
||||
int32_t status;
|
||||
// heartbeat from the consumer reset hbStatus to 0
|
||||
// each checkConsumerAlive msg add hbStatus by 1
|
||||
// if checkConsumerAlive > CONSUMER_REBALANCE_CNT, mask to lost
|
||||
int32_t hbStatus;
|
||||
} SMqConsumerObj;
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer) {
|
||||
int32_t sz;
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI64(buf, pConsumer->consumerId);
|
||||
tlen += taosEncodeFixedI64(buf, pConsumer->connId);
|
||||
tlen += taosEncodeFixedI32(buf, pConsumer->epoch);
|
||||
tlen += taosEncodeFixedI64(buf, pConsumer->pollCnt);
|
||||
tlen += taosEncodeFixedI32(buf, pConsumer->status);
|
||||
tlen += taosEncodeString(buf, pConsumer->cgroup);
|
||||
|
||||
sz = taosArrayGetSize(pConsumer->currentTopics);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char* topic = taosArrayGetP(pConsumer->currentTopics, i);
|
||||
tlen += taosEncodeString(buf, topic);
|
||||
}
|
||||
|
||||
sz = taosArrayGetSize(pConsumer->recentRemovedTopics);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char* topic = taosArrayGetP(pConsumer->recentRemovedTopics, i);
|
||||
tlen += taosEncodeString(buf, topic);
|
||||
}
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pConsumer) {
|
||||
int32_t sz;
|
||||
buf = taosDecodeFixedI64(buf, &pConsumer->consumerId);
|
||||
buf = taosDecodeFixedI64(buf, &pConsumer->connId);
|
||||
buf = taosDecodeFixedI32(buf, &pConsumer->epoch);
|
||||
buf = taosDecodeFixedI64(buf, &pConsumer->pollCnt);
|
||||
buf = taosDecodeFixedI32(buf, &pConsumer->status);
|
||||
buf = taosDecodeStringTo(buf, pConsumer->cgroup);
|
||||
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pConsumer->currentTopics = taosArrayInit(sz, sizeof(void*));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char* topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->currentTopics, &topic);
|
||||
}
|
||||
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pConsumer->recentRemovedTopics = taosArrayInit(sz, sizeof(void*));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char* topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->recentRemovedTopics, &topic);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
enum {
|
||||
CONSUMER_UPDATE__TOUCH = 1,
|
||||
CONSUMER_UPDATE__ADD,
|
||||
|
@ -753,12 +477,9 @@ typedef struct {
|
|||
int32_t hbStatus;
|
||||
// lock is used for topics update
|
||||
SRWLatch lock;
|
||||
SArray* currentTopics; // SArray<char*>
|
||||
#if 0
|
||||
SArray* waitingRebTopics; // SArray<char*>
|
||||
#endif
|
||||
SArray* rebNewTopics; // SArray<char*>
|
||||
SArray* rebRemovedTopics; // SArray<char*>
|
||||
SArray* currentTopics; // SArray<char*>
|
||||
SArray* rebNewTopics; // SArray<char*>
|
||||
SArray* rebRemovedTopics; // SArray<char*>
|
||||
} SMqConsumerObj;
|
||||
|
||||
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
|
||||
|
@ -769,8 +490,7 @@ void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer
|
|||
typedef struct {
|
||||
int32_t vgId;
|
||||
char* qmsg;
|
||||
// char topic[TSDB_TOPIC_FNAME_LEN];
|
||||
SEpSet epSet;
|
||||
SEpSet epSet;
|
||||
} SMqVgEp;
|
||||
|
||||
SMqVgEp* tCloneSMqVgEp(const SMqVgEp* pVgEp);
|
||||
|
@ -792,7 +512,14 @@ typedef struct {
|
|||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
SRWLatch lock;
|
||||
int32_t vgNum;
|
||||
int8_t subType;
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
int8_t withTag;
|
||||
int8_t withTagSchema;
|
||||
SHashObj* consumerHash; // consumerId -> SMqConsumerEpInSub
|
||||
// TODO put -1 into unassignVgs
|
||||
// SArray* unassignedVgs;
|
||||
} SMqSubscribeObj;
|
||||
|
||||
SMqSubscribeObj* tNewSubscribeObj(const char key[TSDB_SUBSCRIBE_KEY_LEN]);
|
||||
|
@ -821,18 +548,6 @@ void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
|
|||
int32_t tEncodeSMqSubActionLogObj(void** buf, const SMqSubActionLogObj* pLog);
|
||||
void* tDecodeSMqSubActionLogObj(const void* buf, SMqSubActionLogObj* pLog);
|
||||
|
||||
typedef struct {
|
||||
int64_t consumerId;
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
SRWLatch lock;
|
||||
SArray* vgs; // SArray<SMqVgEp*>
|
||||
} SMqConsumerEpObj;
|
||||
|
||||
SMqConsumerEpObj* tCloneSMqConsumerEpObj(const SMqConsumerEpObj* pConsumerEp);
|
||||
void tDeleteSMqConsumerEpObj(SMqConsumerEpObj* pConsumerEp);
|
||||
int32_t tEncodeSMqConsumerEpObj(void** buf, const SMqConsumerEpObj* pConsumerEp);
|
||||
void* tDecodeSMqConsumerEpObj(const void* buf, SMqConsumerEpObj* pConsumerEp);
|
||||
|
||||
typedef struct {
|
||||
const SMqSubscribeObj* pOldSub;
|
||||
const SMqTopicObj* pTopic;
|
||||
|
@ -845,12 +560,6 @@ typedef struct {
|
|||
SMqVgEp* pVgEp;
|
||||
} SMqRebOutputVg;
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
int64_t consumerId;
|
||||
} SMqRebOutputConsumer;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
SArray* rebVgs; // SArray<SMqRebOutputVg>
|
||||
SArray* newConsumers; // SArray<int64_t>
|
||||
|
|
|
@ -851,6 +851,8 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
|
|||
cfgRsp.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
cfgRsp.streamMode = pDb->cfg.streamMode;
|
||||
cfgRsp.singleSTable = pDb->cfg.singleSTable;
|
||||
cfgRsp.numOfRetensions = pDb->cfg.numOfRetensions;
|
||||
cfgRsp.pRetensions = pDb->cfg.pRetensions;
|
||||
|
||||
int32_t contLen = tSerializeSDbCfgRsp(NULL, 0, &cfgRsp);
|
||||
void *pRsp = rpcMallocCont(contLen);
|
||||
|
|
|
@ -32,9 +32,6 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_L
|
|||
taosInitRWLatch(&pConsumer->lock);
|
||||
|
||||
pConsumer->currentTopics = taosArrayInit(0, sizeof(void *));
|
||||
#if 0
|
||||
pConsumer->waitingRebTopics = NULL;
|
||||
#endif
|
||||
pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *));
|
||||
pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *));
|
||||
|
||||
|
@ -53,11 +50,6 @@ void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
|
|||
if (pConsumer->currentTopics) {
|
||||
taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree);
|
||||
}
|
||||
#if 0
|
||||
if (pConsumer->waitingRebTopics) {
|
||||
taosArrayDestroyP(pConsumer->waitingRebTopics, taosMemoryFree);
|
||||
}
|
||||
#endif
|
||||
if (pConsumer->rebNewTopics) {
|
||||
taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree);
|
||||
}
|
||||
|
@ -87,20 +79,6 @@ int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
|
|||
tlen += taosEncodeFixedI32(buf, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// waiting reb topics
|
||||
if (pConsumer->waitingRebTopics) {
|
||||
sz = taosArrayGetSize(pConsumer->waitingRebTopics);
|
||||
tlen += taosEncodeFixedI32(buf, sz);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic = taosArrayGetP(pConsumer->waitingRebTopics, i);
|
||||
tlen += taosEncodeString(buf, topic);
|
||||
}
|
||||
} else {
|
||||
tlen += taosEncodeFixedI32(buf, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// reb new topics
|
||||
if (pConsumer->rebNewTopics) {
|
||||
sz = taosArrayGetSize(pConsumer->rebNewTopics);
|
||||
|
@ -145,17 +123,6 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer) {
|
|||
taosArrayPush(pConsumer->currentTopics, &topic);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// waiting reb topics
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pConsumer->waitingRebTopics = taosArrayInit(sz, sizeof(void *));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->waitingRebTopics, &topic);
|
||||
}
|
||||
#endif
|
||||
|
||||
// reb new topics
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pConsumer->rebNewTopics = taosArrayInit(sz, sizeof(void *));
|
||||
|
@ -182,7 +149,6 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
|
|||
if (pVgEpNew == NULL) return NULL;
|
||||
pVgEpNew->vgId = pVgEp->vgId;
|
||||
pVgEpNew->qmsg = strdup(pVgEp->qmsg);
|
||||
/*memcpy(pVgEpNew->topic, pVgEp->topic, TSDB_TOPIC_FNAME_LEN);*/
|
||||
pVgEpNew->epSet = pVgEp->epSet;
|
||||
return pVgEpNew;
|
||||
}
|
||||
|
@ -193,7 +159,6 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
|
|||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
|
||||
tlen += taosEncodeString(buf, pVgEp->qmsg);
|
||||
/*tlen += taosEncodeString(buf, pVgEp->topic);*/
|
||||
tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
|
||||
return tlen;
|
||||
}
|
||||
|
@ -201,40 +166,10 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
|
|||
void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp) {
|
||||
buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
|
||||
buf = taosDecodeString(buf, &pVgEp->qmsg);
|
||||
/*buf = taosDecodeStringTo(buf, pVgEp->topic);*/
|
||||
buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
|
||||
return (void *)buf;
|
||||
}
|
||||
|
||||
SMqConsumerEpObj *tCloneSMqConsumerEpObj(const SMqConsumerEpObj *pConsumerEp) {
|
||||
SMqConsumerEpObj *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEpObj));
|
||||
if (pConsumerEpNew == NULL) return NULL;
|
||||
pConsumerEpNew->consumerId = pConsumerEp->consumerId;
|
||||
memcpy(pConsumerEpNew->cgroup, pConsumerEp->cgroup, TSDB_CGROUP_LEN);
|
||||
taosInitRWLatch(&pConsumerEpNew->lock);
|
||||
pConsumerEpNew->vgs = taosArrayDeepCopy(pConsumerEpNew->vgs, (FCopy)tCloneSMqVgEp);
|
||||
return pConsumerEpNew;
|
||||
}
|
||||
|
||||
void tDeleteSMqConsumerEpObj(SMqConsumerEpObj *pConsumerEp) {
|
||||
taosArrayDestroyEx(pConsumerEp->vgs, (FDelete)tDeleteSMqVgEp);
|
||||
}
|
||||
|
||||
int32_t tEncodeSMqConsumerEpObj(void **buf, const SMqConsumerEpObj *pConsumerEp) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI64(buf, pConsumerEp->consumerId);
|
||||
tlen += taosEncodeString(buf, pConsumerEp->cgroup);
|
||||
tlen += taosEncodeArray(buf, pConsumerEp->vgs, (FEncode)tEncodeSMqVgEp);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
void *tDecodeSMqConsumerEpObj(const void *buf, SMqConsumerEpObj *pConsumerEp) {
|
||||
buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId);
|
||||
buf = taosDecodeStringTo(buf, pConsumerEp->cgroup);
|
||||
buf = taosDecodeArray(buf, &pConsumerEp->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqSubVgEp));
|
||||
return (void *)buf;
|
||||
}
|
||||
|
||||
SMqConsumerEpInSub *tCloneSMqConsumerEpInSub(const SMqConsumerEpInSub *pEpInSub) {
|
||||
SMqConsumerEpInSub *pEpInSubNew = taosMemoryMalloc(sizeof(SMqConsumerEpInSub));
|
||||
if (pEpInSubNew == NULL) return NULL;
|
||||
|
@ -276,7 +211,7 @@ void *tDecodeSMqConsumerEpInSub(const void *buf, SMqConsumerEpInSub *pEpInSub) {
|
|||
}
|
||||
|
||||
SMqSubscribeObj *tNewSubscribeObj(const char key[TSDB_SUBSCRIBE_KEY_LEN]) {
|
||||
SMqSubscribeObj *pSubNew = taosMemoryMalloc(sizeof(SMqSubscribeObj));
|
||||
SMqSubscribeObj *pSubNew = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
|
||||
if (pSubNew == NULL) return NULL;
|
||||
memcpy(pSubNew->key, key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
taosInitRWLatch(&pSubNew->lock);
|
||||
|
@ -297,8 +232,14 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
|
|||
if (pSubNew == NULL) return NULL;
|
||||
memcpy(pSubNew->key, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
taosInitRWLatch(&pSubNew->lock);
|
||||
|
||||
pSubNew->subType = pSub->subType;
|
||||
pSubNew->withTbName = pSub->withTbName;
|
||||
pSubNew->withSchema = pSub->withSchema;
|
||||
pSubNew->withTag = pSub->withTag;
|
||||
pSubNew->withTagSchema = pSub->withTagSchema;
|
||||
|
||||
pSubNew->vgNum = pSub->vgNum;
|
||||
/*pSubNew->consumerEps = taosArrayDeepCopy(pSub->consumerEps, (FCopy)tCloneSMqConsumerEpInSub);*/
|
||||
pSubNew->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
/*taosHashSetFreeFp(pSubNew->consumerHash, taosArrayDestroy);*/
|
||||
void *pIter = NULL;
|
||||
|
@ -325,6 +266,11 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
|
|||
int32_t tlen = 0;
|
||||
tlen += taosEncodeString(buf, pSub->key);
|
||||
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
|
||||
tlen += taosEncodeFixedI8(buf, pSub->subType);
|
||||
tlen += taosEncodeFixedI8(buf, pSub->withTbName);
|
||||
tlen += taosEncodeFixedI8(buf, pSub->withSchema);
|
||||
tlen += taosEncodeFixedI8(buf, pSub->withTag);
|
||||
tlen += taosEncodeFixedI8(buf, pSub->withTagSchema);
|
||||
|
||||
void *pIter = NULL;
|
||||
int32_t sz = taosHashGetSize(pSub->consumerHash);
|
||||
|
@ -347,6 +293,11 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
|
|||
//
|
||||
buf = taosDecodeStringTo(buf, pSub->key);
|
||||
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
|
||||
buf = taosDecodeFixedI8(buf, &pSub->subType);
|
||||
buf = taosDecodeFixedI8(buf, &pSub->withTbName);
|
||||
buf = taosDecodeFixedI8(buf, &pSub->withSchema);
|
||||
buf = taosDecodeFixedI8(buf, &pSub->withTag);
|
||||
buf = taosDecodeFixedI8(buf, &pSub->withTagSchema);
|
||||
|
||||
int32_t sz;
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
|
|
|
@ -427,7 +427,6 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
|
|||
|
||||
SFuncObj *pFunc = mndAcquireFunc(pMnode, funcName);
|
||||
if (pFunc == NULL) {
|
||||
terrno = TSDB_CODE_MND_INVALID_FUNC;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
|
@ -439,21 +438,26 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
|
|||
funcInfo.outputLen = pFunc->outputLen;
|
||||
funcInfo.bufSize = pFunc->bufSize;
|
||||
funcInfo.signature = pFunc->signature;
|
||||
funcInfo.commentSize = pFunc->commentSize;
|
||||
funcInfo.codeSize = pFunc->codeSize;
|
||||
funcInfo.pCode = taosMemoryCalloc(1, funcInfo.codeSize);
|
||||
if (funcInfo.pCode == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
memcpy(funcInfo.pCode, pFunc->pCode, pFunc->codeSize);
|
||||
if (funcInfo.commentSize > 0) {
|
||||
funcInfo.pComment = taosMemoryCalloc(1, funcInfo.commentSize);
|
||||
if (funcInfo.pComment == NULL) {
|
||||
if (retrieveReq.ignoreCodeComment) {
|
||||
funcInfo.commentSize = 0;
|
||||
funcInfo.codeSize = 0;
|
||||
} else {
|
||||
funcInfo.commentSize = pFunc->commentSize;
|
||||
funcInfo.codeSize = pFunc->codeSize;
|
||||
funcInfo.pCode = taosMemoryCalloc(1, funcInfo.codeSize);
|
||||
if (funcInfo.pCode == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
memcpy(funcInfo.pComment, pFunc->pComment, pFunc->commentSize);
|
||||
memcpy(funcInfo.pCode, pFunc->pCode, pFunc->codeSize);
|
||||
if (funcInfo.commentSize > 0) {
|
||||
funcInfo.pComment = taosMemoryCalloc(1, funcInfo.commentSize);
|
||||
if (funcInfo.pComment == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
memcpy(funcInfo.pComment, pFunc->pComment, pFunc->commentSize);
|
||||
}
|
||||
}
|
||||
taosArrayPush(retrieveRsp.pFuncInfos, &funcInfo);
|
||||
mndReleaseFunc(pMnode, pFunc);
|
||||
|
@ -518,11 +522,16 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b1, false);
|
||||
|
||||
char *b2 = taosMemoryCalloc(1, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->bytes[cols]);
|
||||
if (pFunc->pComment) {
|
||||
char *b2 = taosMemoryCalloc(1, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->bytes[cols]);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b2, false);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b2, false);
|
||||
} else {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, NULL, true);
|
||||
}
|
||||
|
||||
int32_t isAgg = (pFunc->funcType == TSDB_FUNC_TYPE_AGGREGATE) ? 1 : 0;
|
||||
|
||||
|
@ -556,4 +565,4 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
static void mndCancelGetNextFunc(SMnode *pMnode, void *pIter) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ static const SInfosTableSchema userFuncSchema[] = {
|
|||
{.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comment", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "output_type", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
|
|
|
@ -133,9 +133,9 @@ OFFSET_DECODE_OVER:
|
|||
int32_t mndCreateOffsets(STrans *pTrans, const char *cgroup, const char *topicName, const SArray *vgs) {
|
||||
int32_t sz = taosArrayGetSize(vgs);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp *pConsumerEp = taosArrayGet(vgs, i);
|
||||
SMqOffsetObj offsetObj;
|
||||
if (mndMakePartitionKey(offsetObj.key, cgroup, topicName, pConsumerEp->vgId) < 0) {
|
||||
int32_t vgId = *(int32_t *)taosArrayGet(vgs, i);
|
||||
SMqOffsetObj offsetObj;
|
||||
if (mndMakePartitionKey(offsetObj.key, cgroup, topicName, vgId) < 0) {
|
||||
return -1;
|
||||
}
|
||||
offsetObj.offset = -1;
|
||||
|
|
|
@ -41,10 +41,10 @@ static const SPerfsTableSchema queriesSchema[] = {
|
|||
|
||||
static const SPerfsTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
/*{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},*/
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
/*{.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},*/
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema consumerSchema[] = {
|
||||
|
|
|
@ -24,20 +24,20 @@
|
|||
#include "version.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
int8_t connType;
|
||||
char user[TSDB_USER_LEN];
|
||||
char app[TSDB_APP_NAME_LEN]; // app name that invokes taosc
|
||||
int64_t appStartTimeMs; // app start time
|
||||
int32_t pid; // pid of app that invokes taosc
|
||||
uint32_t ip;
|
||||
uint16_t port;
|
||||
int8_t killed;
|
||||
int64_t loginTimeMs;
|
||||
int64_t lastAccessTimeMs;
|
||||
uint64_t killId;
|
||||
int32_t numOfQueries;
|
||||
SArray *pQueries; //SArray<SQueryDesc>
|
||||
uint32_t id;
|
||||
int8_t connType;
|
||||
char user[TSDB_USER_LEN];
|
||||
char app[TSDB_APP_NAME_LEN]; // app name that invokes taosc
|
||||
int64_t appStartTimeMs; // app start time
|
||||
int32_t pid; // pid of app that invokes taosc
|
||||
uint32_t ip;
|
||||
uint16_t port;
|
||||
int8_t killed;
|
||||
int64_t loginTimeMs;
|
||||
int64_t lastAccessTimeMs;
|
||||
uint64_t killId;
|
||||
int32_t numOfQueries;
|
||||
SArray * pQueries; // SArray<SQueryDesc>
|
||||
} SConnObj;
|
||||
|
||||
static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType, uint32_t ip, uint16_t port,
|
||||
|
@ -45,7 +45,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
static void mndFreeConn(SConnObj *pConn);
|
||||
static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId);
|
||||
static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn);
|
||||
static void *mndGetNextConn(SMnode *pMnode, SCacheIter *pIter);
|
||||
static void * mndGetNextConn(SMnode *pMnode, SCacheIter *pIter);
|
||||
static void mndCancelGetNextConn(SMnode *pMnode, void *pIter);
|
||||
static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessConnectReq(SNodeMsg *pReq);
|
||||
|
@ -71,9 +71,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_QUERY, mndProcessKillQueryReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_CONN, mndProcessKillConnReq);
|
||||
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndCancelGetNextConn);
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndCancelGetNextQuery);
|
||||
|
||||
return 0;
|
||||
|
@ -91,7 +91,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
int32_t pid, const char *app, int64_t startTime) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
char connStr[255] = {0};
|
||||
char connStr[255] = {0};
|
||||
int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app);
|
||||
int32_t connId = mndGenerateUid(connStr, len);
|
||||
if (startTime == 0) startTime = taosGetTimestampMs();
|
||||
|
@ -174,10 +174,10 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
|
|||
}
|
||||
|
||||
static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SUserObj *pUser = NULL;
|
||||
SDbObj *pDb = NULL;
|
||||
SConnObj *pConn = NULL;
|
||||
SMnode * pMnode = pReq->pNode;
|
||||
SUserObj * pUser = NULL;
|
||||
SDbObj * pDb = NULL;
|
||||
SConnObj * pConn = NULL;
|
||||
int32_t code = -1;
|
||||
SConnectReq connReq = {0};
|
||||
char ip[30] = {0};
|
||||
|
@ -194,6 +194,11 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
|
|||
mError("user:%s, failed to login while acquire user since %s", pReq->user, terrstr());
|
||||
goto CONN_OVER;
|
||||
}
|
||||
if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) {
|
||||
mError("user:%s, failed to auth while acquire user\n %s \r\n %s", pReq->user, connReq.passwd, pUser->pass);
|
||||
code = TSDB_CODE_RPC_AUTH_FAILURE;
|
||||
goto CONN_OVER;
|
||||
}
|
||||
|
||||
if (connReq.db[0]) {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
|
@ -253,8 +258,8 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
|
|||
|
||||
pConn->pQueries = pBasic->queryDesc;
|
||||
pBasic->queryDesc = NULL;
|
||||
|
||||
pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0;
|
||||
|
||||
pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -324,9 +329,10 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq, SClientHbBatchRsp *pBatchRsp) {
|
||||
static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq,
|
||||
SClientHbBatchRsp *pBatchRsp) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL};
|
||||
SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL};
|
||||
|
||||
if (pHbReq->query) {
|
||||
SQueryHbReqBasic *pBasic = pHbReq->query;
|
||||
|
@ -335,8 +341,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
rpcGetConnInfo(pMsg->handle, &connInfo);
|
||||
|
||||
SConnObj *pConn = mndAcquireConn(pMnode, pBasic->connId);
|
||||
if (pConn == NULL) {
|
||||
pConn = mndCreateConn(pMnode, connInfo.user, CONN_TYPE__QUERY, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0);
|
||||
if (pConn == NULL) {
|
||||
pConn = mndCreateConn(pMnode, connInfo.user, CONN_TYPE__QUERY, connInfo.clientIp, connInfo.clientPort,
|
||||
pBasic->pid, pBasic->app, 0);
|
||||
if (pConn == NULL) {
|
||||
mError("user:%s, conn:%u is freed and failed to create new since %s", connInfo.user, pBasic->connId, terrstr());
|
||||
return -1;
|
||||
|
@ -345,7 +352,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
}
|
||||
} else if (pConn->killed) {
|
||||
mError("user:%s, conn:%u is already killed", connInfo.user, pConn->id);
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
terrno = TSDB_CODE_MND_INVALID_CONNECTION;
|
||||
return -1;
|
||||
}
|
||||
|
@ -369,8 +376,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
}
|
||||
|
||||
rspBasic->connId = pConn->id;
|
||||
rspBasic->totalDnodes = 1; //TODO
|
||||
rspBasic->onlineDnodes = 1; //TODO
|
||||
rspBasic->totalDnodes = 1; // TODO
|
||||
rspBasic->onlineDnodes = 1; // TODO
|
||||
mndGetMnodeEpSet(pMnode, &rspBasic->epSet);
|
||||
mndReleaseConn(pMnode, pConn);
|
||||
|
||||
|
@ -379,7 +386,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
|
||||
int32_t kvNum = taosHashGetSize(pHbReq->info);
|
||||
if (NULL == pHbReq->info || kvNum <= 0) {
|
||||
taosArrayPush(pBatchRsp->rsps, &hbRsp);
|
||||
taosArrayPush(pBatchRsp->rsps, &hbRsp);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -396,7 +403,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
|
||||
switch (kv->key) {
|
||||
case HEARTBEAT_KEY_DBINFO: {
|
||||
void *rspMsg = NULL;
|
||||
void * rspMsg = NULL;
|
||||
int32_t rspLen = 0;
|
||||
mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen);
|
||||
if (rspMsg && rspLen > 0) {
|
||||
|
@ -406,7 +413,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
break;
|
||||
}
|
||||
case HEARTBEAT_KEY_STBINFO: {
|
||||
void *rspMsg = NULL;
|
||||
void * rspMsg = NULL;
|
||||
int32_t rspLen = 0;
|
||||
mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen);
|
||||
if (rspMsg && rspLen > 0) {
|
||||
|
@ -457,7 +464,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
|||
taosArrayDestroyEx(batchReq.reqs, tFreeClientHbReq);
|
||||
|
||||
int32_t tlen = tSerializeSClientHbBatchRsp(NULL, 0, &batchRsp);
|
||||
void *buf = rpcMallocCont(tlen);
|
||||
void * buf = rpcMallocCont(tlen);
|
||||
tSerializeSClientHbBatchRsp(buf, tlen, &batchRsp);
|
||||
|
||||
int32_t rspNum = (int32_t)taosArrayGetSize(batchRsp.rsps);
|
||||
|
@ -479,7 +486,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SMnode * pMnode = pReq->pNode;
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
|
@ -513,7 +520,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SMnode * pMnode = pReq->pNode;
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
|
@ -545,11 +552,11 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SMnode * pMnode = pReq->pNode;
|
||||
int32_t numOfRows = 0;
|
||||
SConnObj *pConn = NULL;
|
||||
int32_t cols = 0;
|
||||
char *pWrite;
|
||||
char * pWrite;
|
||||
char ipStr[TSDB_IPv4ADDR_LEN + 6];
|
||||
|
||||
if (pShow->pIter == NULL) {
|
||||
|
@ -604,8 +611,8 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
|
|||
}
|
||||
|
||||
static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t numOfRows = 0;
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t numOfRows = 0;
|
||||
#if 0
|
||||
SConnObj *pConn = NULL;
|
||||
int32_t cols = 0;
|
||||
|
@ -703,7 +710,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
|
|||
}
|
||||
|
||||
pShow->numOfRows += numOfRows;
|
||||
#endif
|
||||
#endif
|
||||
return numOfRows;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#define SHOW_STEP_SIZE 100
|
||||
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq);
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq);
|
||||
static void mndFreeShowObj(SShowObj *pShow);
|
||||
static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId);
|
||||
static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove);
|
||||
|
@ -47,18 +47,80 @@ void mndCleanupShow(SMnode *pMnode) {
|
|||
}
|
||||
}
|
||||
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq) {
|
||||
static int32_t convertToRetrieveType(char* name, int32_t len) {
|
||||
int32_t type = -1;
|
||||
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_DNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_DNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_MNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_MODULE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_QNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_BNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_BNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_SNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CLUSTER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_DB;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_FUNCTIONS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_FUNC;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_INDEXES, len) == 0) {
|
||||
// type = TSDB_MGMT_TABLE_INDEX;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_STABLES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_STB;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_STREAMS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_STREAMS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TABLE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, len) == 0) {
|
||||
// type = TSDB_MGMT_TABLE_DIST;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_USER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_GRANTS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_VGROUP;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TOPICS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONSUMERS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONSUMERS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIBES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_SUBSCRIBES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TRANS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TRANS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SMAS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_SMAS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONFIGS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONNS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONNS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QUERIES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_QUERIES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_VNODES;
|
||||
} else {
|
||||
// ASSERT(0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) {
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
|
||||
int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1);
|
||||
if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1);
|
||||
|
||||
int32_t size = sizeof(SShowObj) + pReq->payloadLen;
|
||||
int32_t size = sizeof(SShowObj);
|
||||
|
||||
SShowObj showObj = {0};
|
||||
showObj.id = showId;
|
||||
showObj.id = showId;
|
||||
showObj.pMnode = pMnode;
|
||||
showObj.type = pReq->type;
|
||||
showObj.payloadLen = pReq->payloadLen;
|
||||
showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb));
|
||||
memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
|
||||
|
||||
int32_t keepTime = tsShellActivityTimer * 6 * 1000;
|
||||
|
@ -127,10 +189,6 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
if (retrieveReq.showId == 0) {
|
||||
SShowReq req = {0};
|
||||
req.type = retrieveReq.type;
|
||||
strncpy(req.db, retrieveReq.db, tListLen(req.db));
|
||||
|
||||
STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1);
|
||||
if (pMeta == NULL) {
|
||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
||||
|
@ -138,7 +196,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pShow = mndCreateShowObj(pMnode, &req);
|
||||
pShow = mndCreateShowObj(pMnode, &retrieveReq);
|
||||
if (pShow == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("failed to process show-meta req since %s", terrstr());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "mndInfoSchema.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndPerfSchema.h"
|
||||
#include "mndScheduler.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
|
@ -443,6 +444,25 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
|||
for (int32_t f = 0; f < pRSmaParam->nFuncIds; ++f) {
|
||||
*(pRSmaParam->pFuncIds + f) = pStb->aggregationMethod;
|
||||
}
|
||||
if (pStb->ast1Len > 0) {
|
||||
if (mndConvertRSmaTask(pStb->pAst1, 0, 0, &pRSmaParam->qmsg1, &pRSmaParam->qmsg1Len) != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFreeClear(pRSmaParam->pFuncIds);
|
||||
taosMemoryFreeClear(req.stbCfg.pRSmaParam);
|
||||
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (pStb->ast2Len > 0) {
|
||||
int32_t qmsgLen2 = 0;
|
||||
if (mndConvertRSmaTask(pStb->pAst2, 0, 0, &pRSmaParam->qmsg2, &pRSmaParam->qmsg2Len) != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFreeClear(pRSmaParam->pFuncIds);
|
||||
taosMemoryFreeClear(pRSmaParam->qmsg1);
|
||||
taosMemoryFreeClear(req.stbCfg.pRSmaParam);
|
||||
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
req.stbCfg.pRSmaParam = pRSmaParam;
|
||||
}
|
||||
|
||||
|
@ -451,6 +471,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
|||
if (pHead == NULL) {
|
||||
if (pRSmaParam) {
|
||||
taosMemoryFreeClear(pRSmaParam->pFuncIds);
|
||||
taosMemoryFreeClear(pRSmaParam->qmsg1);
|
||||
taosMemoryFreeClear(pRSmaParam->qmsg2);
|
||||
taosMemoryFreeClear(pRSmaParam);
|
||||
}
|
||||
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||
|
@ -467,6 +489,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
|||
*pContLen = contLen;
|
||||
if (pRSmaParam) {
|
||||
taosMemoryFreeClear(pRSmaParam->pFuncIds);
|
||||
taosMemoryFreeClear(pRSmaParam->qmsg1);
|
||||
taosMemoryFreeClear(pRSmaParam->qmsg2);
|
||||
taosMemoryFreeClear(pRSmaParam);
|
||||
}
|
||||
taosMemoryFreeClear(req.stbCfg.pSchema);
|
||||
|
|
|
@ -59,7 +59,7 @@ int32_t mndInitStream(SMnode *pMnode) {
|
|||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
|
||||
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveStream);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextStream);
|
||||
/*mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextStream);*/
|
||||
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
@ -247,7 +247,8 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, int8_t triggerType, int64_t watermark, STrans *pTrans) {
|
||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, int8_t triggerType, int64_t watermark,
|
||||
STrans *pTrans) {
|
||||
SNode *pAst = NULL;
|
||||
|
||||
if (nodesStringToNode(ast, &pAst) < 0) {
|
||||
|
|
|
@ -46,16 +46,8 @@ static int32_t mndSubActionInsert(SSdb *pSdb, SMqSubscribeObj *);
|
|||
static int32_t mndSubActionDelete(SSdb *pSdb, SMqSubscribeObj *);
|
||||
static int32_t mndSubActionUpdate(SSdb *pSdb, SMqSubscribeObj *pOldSub, SMqSubscribeObj *pNewSub);
|
||||
|
||||
/*static int32_t mndProcessSubscribeReq(SNodeMsg *pMsg);*/
|
||||
/*static int32_t mndProcessSubscribeRsp(SNodeMsg *pMsg);*/
|
||||
static int32_t mndProcessSubscribeInternalReq(SNodeMsg *pMsg);
|
||||
static int32_t mndProcessSubscribeInternalRsp(SNodeMsg *pMsg);
|
||||
/*static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg);*/
|
||||
/*static int32_t mndProcessGetSubEpReq(SNodeMsg *pMsg);*/
|
||||
/*static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg);*/
|
||||
/*static int32_t mndProcessResetOffsetReq(SNodeMsg *pMsg);*/
|
||||
|
||||
static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg);
|
||||
static int32_t mndProcessSubscribeInternalRsp(SNodeMsg *pMsg);
|
||||
|
||||
static int32_t mndSetSubRedoLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub) {
|
||||
SSdbRaw *pRedoRaw = mndSubActionEncode(pSub);
|
||||
|
@ -73,15 +65,6 @@ static int32_t mndSetSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeO
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqTopicObj *pTopic, const char *cgroup,*/
|
||||
/*const SMqConsumerEp *pConsumerEp);*/
|
||||
|
||||
/*static int32_t mndPersistRebalanceMsg(SMnode *pMnode, STrans *pTrans, const SMqConsumerEp *pConsumerEp,*/
|
||||
/*const char *topicName);*/
|
||||
|
||||
/*static int32_t mndPersistCancelConnReq(SMnode *pMnode, STrans *pTrans, const SMqConsumerEp *pConsumerEp,*/
|
||||
/*const char *oldTopicName);*/
|
||||
|
||||
int32_t mndInitSubscribe(SMnode *pMnode) {
|
||||
SSdbTable table = {.sdbType = SDB_SUBSCRIBE,
|
||||
.keyType = SDB_KEY_BINARY,
|
||||
|
@ -91,13 +74,6 @@ int32_t mndInitSubscribe(SMnode *pMnode) {
|
|||
.updateFp = (SdbUpdateFp)mndSubActionUpdate,
|
||||
.deleteFp = (SdbDeleteFp)mndSubActionDelete};
|
||||
|
||||
/*mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE, mndProcessSubscribeReq);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_VND_MQ_SET_CONN_RSP, mndProcessSubscribeInternalRsp);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_VND_MQ_REB_RSP, mndProcessSubscribeInternalRsp);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_VND_MQ_CANCEL_CONN_RSP, mndProcessSubscribeInternalRsp);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_MND_MQ_TIMER, mndProcessMqTimerMsg);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_MND_GET_SUB_EP, mndProcessGetSubEpReq);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessDoRebalanceMsg);*/
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_CHANGE_RSP, mndProcessSubscribeInternalRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessRebalanceReq);
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
|
@ -109,6 +85,12 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
pSub->subType = pTopic->subType;
|
||||
pSub->withTbName = pTopic->withTbName;
|
||||
pSub->withSchema = pTopic->withSchema;
|
||||
pSub->withTag = pTopic->withTag;
|
||||
pSub->withTagSchema = pTopic->withTagSchema;
|
||||
|
||||
ASSERT(taosHashGetSize(pSub->consumerHash) == 1);
|
||||
|
||||
if (mndSchedInitSubEp(pMnode, pTopic, pSub) < 0) {
|
||||
|
@ -122,144 +104,19 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
|
|||
return pSub;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj *pTopic, const char *cgroup) {
|
||||
SMqSubscribeObj *pSub = tNewSubscribeObj();
|
||||
if (pSub == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
mndMakeSubscribeKey(key, cgroup, pTopic->name);
|
||||
strcpy(pSub->key, key);
|
||||
|
||||
if (mndSchedInitSubEp(pMnode, pTopic, pSub) < 0) {
|
||||
tDeleteSMqSubscribeObj(pSub);
|
||||
taosMemoryFree(pSub);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: disable alter subscribed table
|
||||
return pSub;
|
||||
}
|
||||
|
||||
static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsumerEp *pConsumerEp,
|
||||
const char *topicName) {
|
||||
SMqMVRebReq req = {
|
||||
.vgId = pConsumerEp->vgId,
|
||||
.oldConsumerId = pConsumerEp->oldConsumerId,
|
||||
.newConsumerId = pConsumerEp->consumerId,
|
||||
};
|
||||
req.topic = strdup(topicName);
|
||||
|
||||
int32_t tlen = tEncodeSMqMVRebReq(NULL, &req);
|
||||
void *buf = taosMemoryMalloc(sizeof(SMsgHead) + tlen);
|
||||
if (buf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
SMsgHead *pMsgHead = (SMsgHead *)buf;
|
||||
|
||||
pMsgHead->contLen = htonl(sizeof(SMsgHead) + tlen);
|
||||
pMsgHead->vgId = htonl(pConsumerEp->vgId);
|
||||
|
||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
tEncodeSMqMVRebReq(&abuf, &req);
|
||||
taosMemoryFree(req.topic);
|
||||
|
||||
*pBuf = buf;
|
||||
*pLen = tlen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndPersistRebalanceMsg(SMnode *pMnode, STrans *pTrans, const SMqConsumerEp *pConsumerEp,
|
||||
const char *topicName) {
|
||||
ASSERT(pConsumerEp->oldConsumerId != -1);
|
||||
|
||||
void *buf;
|
||||
int32_t tlen;
|
||||
if (mndBuildRebalanceMsg(&buf, &tlen, pConsumerEp, topicName) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t vgId = pConsumerEp->vgId;
|
||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + tlen;
|
||||
action.msgType = TDMT_VND_MQ_REB;
|
||||
|
||||
mndReleaseVgroup(pMnode, pVgObj);
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndBuildCancelConnReq(void **pBuf, int32_t *pLen, const SMqConsumerEp *pConsumerEp,
|
||||
const char *oldTopicName) {
|
||||
SMqCancelConnReq req = {0};
|
||||
req.consumerId = pConsumerEp->consumerId;
|
||||
req.vgId = pConsumerEp->vgId;
|
||||
req.epoch = pConsumerEp->epoch;
|
||||
strcpy(req.topicName, oldTopicName);
|
||||
|
||||
int32_t tlen = tEncodeSMqCancelConnReq(NULL, &req);
|
||||
void *buf = taosMemoryMalloc(sizeof(SMsgHead) + tlen);
|
||||
if (buf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
SMsgHead *pMsgHead = (SMsgHead *)buf;
|
||||
|
||||
pMsgHead->contLen = htonl(sizeof(SMsgHead) + tlen);
|
||||
pMsgHead->vgId = htonl(pConsumerEp->vgId);
|
||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
tEncodeSMqCancelConnReq(&abuf, &req);
|
||||
*pBuf = buf;
|
||||
*pLen = tlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndPersistCancelConnReq(SMnode *pMnode, STrans *pTrans, const SMqConsumerEp *pConsumerEp,
|
||||
const char *oldTopicName) {
|
||||
void *buf;
|
||||
int32_t tlen;
|
||||
if (mndBuildCancelConnReq(&buf, &tlen, pConsumerEp, oldTopicName) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t vgId = pConsumerEp->vgId;
|
||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + tlen;
|
||||
action.msgType = TDMT_VND_MQ_CANCEL_CONN;
|
||||
|
||||
mndReleaseVgroup(pMnode, pVgObj);
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const char *subKey, const SMqRebOutputVg *pRebVg) {
|
||||
static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscribeObj *pSub,
|
||||
const SMqRebOutputVg *pRebVg) {
|
||||
SMqRebVgReq req = {0};
|
||||
req.oldConsumerId = pRebVg->oldConsumerId;
|
||||
req.newConsumerId = pRebVg->newConsumerId;
|
||||
req.vgId = pRebVg->pVgEp->vgId;
|
||||
req.qmsg = pRebVg->pVgEp->qmsg;
|
||||
strncpy(req.subKey, subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
req.subType = pSub->subType;
|
||||
req.withTbName = pSub->withTbName;
|
||||
req.withSchema = pSub->withSchema;
|
||||
req.withTag = pSub->withTag;
|
||||
req.withTagSchema = pSub->withTagSchema;
|
||||
strncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
|
||||
int32_t tlen = sizeof(SMsgHead) + tEncodeSMqRebVgReq(NULL, &req);
|
||||
void *buf = taosMemoryMalloc(tlen);
|
||||
|
@ -280,13 +137,13 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const char *subK
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const char *subKey,
|
||||
static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const SMqSubscribeObj *pSub,
|
||||
const SMqRebOutputVg *pRebVg) {
|
||||
ASSERT(pRebVg->oldConsumerId != pRebVg->newConsumerId);
|
||||
|
||||
void *buf;
|
||||
int32_t tlen;
|
||||
if (mndBuildSubChangeReq(&buf, &tlen, subKey, pRebVg) < 0) {
|
||||
if (mndBuildSubChangeReq(&buf, &tlen, pSub, pRebVg) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -307,108 +164,6 @@ static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const ch
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int32_t mndProcessGetSubEpReq(SNodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pNode;
|
||||
SMqCMGetSubEpReq *pReq = (SMqCMGetSubEpReq *)pMsg->rpcMsg.pCont;
|
||||
SMqCMGetSubEpRsp rsp = {0};
|
||||
int64_t consumerId = be64toh(pReq->consumerId);
|
||||
int32_t epoch = ntohl(pReq->epoch);
|
||||
|
||||
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMsg->pNode, consumerId);
|
||||
if (pConsumer == NULL) {
|
||||
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
// TODO add lock
|
||||
ASSERT(strcmp(pReq->cgroup, pConsumer->cgroup) == 0);
|
||||
int32_t serverEpoch = pConsumer->epoch;
|
||||
|
||||
// TODO
|
||||
int32_t hbStatus = atomic_load_32(&pConsumer->hbStatus);
|
||||
mDebug("consumer %ld epoch(%d) try to get sub ep, server epoch %d, old val: %d", consumerId, epoch, serverEpoch,
|
||||
hbStatus);
|
||||
atomic_store_32(&pConsumer->hbStatus, 0);
|
||||
/*SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pConsumer);*/
|
||||
/*sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY);*/
|
||||
/*sdbWrite(pMnode->pSdb, pConsumerRaw);*/
|
||||
|
||||
strcpy(rsp.cgroup, pReq->cgroup);
|
||||
if (epoch != serverEpoch) {
|
||||
mInfo("send new assignment to consumer %ld, consumer epoch %d, server epoch %d", pConsumer->consumerId, epoch,
|
||||
serverEpoch);
|
||||
mDebug("consumer %ld try r lock", consumerId);
|
||||
taosRLockLatch(&pConsumer->lock);
|
||||
mDebug("consumer %ld r locked", consumerId);
|
||||
SArray *pTopics = pConsumer->currentTopics;
|
||||
int32_t sz = taosArrayGetSize(pTopics);
|
||||
rsp.topics = taosArrayInit(sz, sizeof(SMqSubTopicEp));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topicName = taosArrayGetP(pTopics, i);
|
||||
SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topicName);
|
||||
ASSERT(pSub);
|
||||
int32_t csz = taosArrayGetSize(pSub->consumers);
|
||||
// TODO: change to bsearch
|
||||
for (int32_t j = 0; j < csz; j++) {
|
||||
SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, j);
|
||||
if (consumerId == pSubConsumer->consumerId) {
|
||||
int32_t vgsz = taosArrayGetSize(pSubConsumer->vgInfo);
|
||||
mInfo("topic %s has %d vg", topicName, serverEpoch);
|
||||
|
||||
SMqSubTopicEp topicEp;
|
||||
strcpy(topicEp.topic, topicName);
|
||||
|
||||
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topicName);
|
||||
ASSERT(pTopic != NULL);
|
||||
topicEp.schema = pTopic->schema;
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
|
||||
topicEp.vgs = taosArrayInit(vgsz, sizeof(SMqSubVgEp));
|
||||
for (int32_t k = 0; k < vgsz; k++) {
|
||||
char offsetKey[TSDB_PARTITION_KEY_LEN];
|
||||
SMqConsumerEp *pConsumerEp = taosArrayGet(pSubConsumer->vgInfo, k);
|
||||
SMqSubVgEp vgEp = {
|
||||
.epSet = pConsumerEp->epSet,
|
||||
.vgId = pConsumerEp->vgId,
|
||||
.offset = -1,
|
||||
};
|
||||
mndMakePartitionKey(offsetKey, pConsumer->cgroup, topicName, pConsumerEp->vgId);
|
||||
SMqOffsetObj *pOffsetObj = mndAcquireOffset(pMnode, offsetKey);
|
||||
if (pOffsetObj != NULL) {
|
||||
vgEp.offset = pOffsetObj->offset;
|
||||
mndReleaseOffset(pMnode, pOffsetObj);
|
||||
}
|
||||
taosArrayPush(topicEp.vgs, &vgEp);
|
||||
}
|
||||
taosArrayPush(rsp.topics, &topicEp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mndReleaseSubscribe(pMnode, pSub);
|
||||
}
|
||||
taosRUnLockLatch(&pConsumer->lock);
|
||||
mDebug("consumer %ld r unlock", consumerId);
|
||||
}
|
||||
int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqCMGetSubEpRsp(NULL, &rsp);
|
||||
void *buf = rpcMallocCont(tlen);
|
||||
if (buf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
((SMqRspHead *)buf)->mqMsgType = TMQ_MSG_TYPE__EP_RSP;
|
||||
((SMqRspHead *)buf)->epoch = serverEpoch;
|
||||
((SMqRspHead *)buf)->consumerId = pConsumer->consumerId;
|
||||
|
||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
|
||||
tEncodeSMqCMGetSubEpRsp(&abuf, &rsp);
|
||||
tDeleteSMqCMGetSubEpRsp(&rsp);
|
||||
mndReleaseConsumer(pMnode, pConsumer);
|
||||
pMsg->pRsp = buf;
|
||||
pMsg->rspLen = tlen;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t mndSplitSubscribeKey(const char *key, char *topic, char *cgroup) {
|
||||
int32_t i = 0;
|
||||
while (key[i] != TMQ_SEPARATOR) {
|
||||
|
@ -433,235 +188,6 @@ static SMqRebSubscribe *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
|||
return pRebSub;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SMqConsumerObj *pConsumer;
|
||||
void *pIter = NULL;
|
||||
SMqDoRebalanceMsg *pRebMsg = rpcMallocCont(sizeof(SMqDoRebalanceMsg));
|
||||
pRebMsg->rebSubHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK);
|
||||
|
||||
while (1) {
|
||||
pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer);
|
||||
if (pIter == NULL) break;
|
||||
int32_t hbStatus = atomic_add_fetch_32(&pConsumer->hbStatus, 1);
|
||||
if (hbStatus > MND_SUBSCRIBE_REBALANCE_CNT) {
|
||||
int32_t old =
|
||||
atomic_val_compare_exchange_32(&pConsumer->status, MQ_CONSUMER_STATUS__ACTIVE, MQ_CONSUMER_STATUS__LOST);
|
||||
if (old == MQ_CONSUMER_STATUS__ACTIVE) {
|
||||
// get all topics of that topic
|
||||
int32_t sz = taosArrayGetSize(pConsumer->currentTopics);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic = taosArrayGetP(pConsumer->currentTopics, i);
|
||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
mndMakeSubscribeKey(key, pConsumer->cgroup, topic);
|
||||
SMqRebSubscribe *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
||||
taosArrayPush(pRebSub->lostConsumers, &pConsumer->consumerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
int32_t status = atomic_load_32(&pConsumer->status);
|
||||
if (status == MQ_CONSUMER_STATUS__INIT || status == MQ_CONSUMER_STATUS__MODIFY) {
|
||||
SArray *rebSubs;
|
||||
if (status == MQ_CONSUMER_STATUS__INIT) {
|
||||
rebSubs = pConsumer->currentTopics;
|
||||
} else {
|
||||
rebSubs = pConsumer->recentRemovedTopics;
|
||||
}
|
||||
int32_t sz = taosArrayGetSize(rebSubs);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic = taosArrayGetP(rebSubs, i);
|
||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
mndMakeSubscribeKey(key, pConsumer->cgroup, topic);
|
||||
SMqRebSubscribe *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
||||
if (status == MQ_CONSUMER_STATUS__INIT) {
|
||||
taosArrayPush(pRebSub->newConsumers, &pConsumer->consumerId);
|
||||
} else if (status == MQ_CONSUMER_STATUS__MODIFY) {
|
||||
taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId);
|
||||
}
|
||||
}
|
||||
if (status == MQ_CONSUMER_STATUS__MODIFY) {
|
||||
int32_t removeSz = taosArrayGetSize(pConsumer->recentRemovedTopics);
|
||||
for (int32_t i = 0; i < removeSz; i++) {
|
||||
char *topicName = taosArrayGetP(pConsumer->recentRemovedTopics, i);
|
||||
taosMemoryFree(topicName);
|
||||
}
|
||||
taosArrayClear(pConsumer->recentRemovedTopics);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (taosHashGetSize(pRebMsg->rebSubHash) != 0) {
|
||||
mInfo("mq rebalance will be triggered");
|
||||
SRpcMsg rpcMsg = {
|
||||
.msgType = TDMT_MND_MQ_DO_REBALANCE,
|
||||
.pCont = pRebMsg,
|
||||
.contLen = sizeof(SMqDoRebalanceMsg),
|
||||
};
|
||||
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
taosHashCleanup(pRebMsg->rebSubHash);
|
||||
rpcFreeCont(pRebMsg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pNode;
|
||||
SMqDoRebalanceMsg *pReq = pMsg->rpcMsg.pCont;
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_REBALANCE, &pMsg->rpcMsg);
|
||||
void *pIter = NULL;
|
||||
|
||||
mInfo("mq rebalance start");
|
||||
|
||||
while (1) {
|
||||
pIter = taosHashIterate(pReq->rebSubHash, pIter);
|
||||
if (pIter == NULL) break;
|
||||
SMqRebSubscribe *pRebSub = (SMqRebSubscribe *)pIter;
|
||||
SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebSub->key);
|
||||
|
||||
mInfo("mq rebalance subscription: %s, vgNum: %d, unassignedVg: %d", pSub->key, pSub->vgNum,
|
||||
(int32_t)taosArrayGetSize(pSub->unassignedVg));
|
||||
|
||||
// remove lost consumer
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pRebSub->lostConsumers); i++) {
|
||||
int64_t lostConsumerId = *(int64_t *)taosArrayGet(pRebSub->lostConsumers, i);
|
||||
|
||||
mInfo("mq remove lost consumer %" PRId64 "", lostConsumerId);
|
||||
|
||||
for (int32_t j = 0; j < taosArrayGetSize(pSub->consumers); j++) {
|
||||
SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, j);
|
||||
if (pSubConsumer->consumerId == lostConsumerId) {
|
||||
taosArrayAddAll(pSub->unassignedVg, pSubConsumer->vgInfo);
|
||||
taosArrayPush(pSub->lostConsumers, pSubConsumer);
|
||||
taosArrayRemove(pSub->consumers, j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate rebalance
|
||||
int32_t consumerNum = taosArrayGetSize(pSub->consumers);
|
||||
if (consumerNum != 0) {
|
||||
int32_t vgNum = pSub->vgNum;
|
||||
int32_t vgEachConsumer = vgNum / consumerNum;
|
||||
int32_t imbalanceVg = vgNum % consumerNum;
|
||||
|
||||
// iterate all consumers, set unassignedVgStash
|
||||
for (int32_t i = 0; i < consumerNum; i++) {
|
||||
SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, i);
|
||||
int32_t vgThisConsumerBeforeRb = taosArrayGetSize(pSubConsumer->vgInfo);
|
||||
int32_t vgThisConsumerAfterRb;
|
||||
if (i < imbalanceVg)
|
||||
vgThisConsumerAfterRb = vgEachConsumer + 1;
|
||||
else
|
||||
vgThisConsumerAfterRb = vgEachConsumer;
|
||||
|
||||
mInfo("mq consumer:%" PRId64 ", connectted vgroup number change from %d to %d", pSubConsumer->consumerId,
|
||||
vgThisConsumerBeforeRb, vgThisConsumerAfterRb);
|
||||
|
||||
while (taosArrayGetSize(pSubConsumer->vgInfo) > vgThisConsumerAfterRb) {
|
||||
SMqConsumerEp *pConsumerEp = taosArrayPop(pSubConsumer->vgInfo);
|
||||
ASSERT(pConsumerEp != NULL);
|
||||
ASSERT(pConsumerEp->consumerId == pSubConsumer->consumerId);
|
||||
taosArrayPush(pSub->unassignedVg, pConsumerEp);
|
||||
mDebug("mq rebalance: vg %d push to unassignedVg", pConsumerEp->vgId);
|
||||
}
|
||||
|
||||
SMqConsumerObj *pRebConsumer = mndAcquireConsumer(pMnode, pSubConsumer->consumerId);
|
||||
mDebug("consumer %ld try w lock", pRebConsumer->consumerId);
|
||||
taosWLockLatch(&pRebConsumer->lock);
|
||||
mDebug("consumer %ld w locked", pRebConsumer->consumerId);
|
||||
int32_t status = atomic_load_32(&pRebConsumer->status);
|
||||
if (vgThisConsumerAfterRb != vgThisConsumerBeforeRb ||
|
||||
(vgThisConsumerAfterRb != 0 && status != MQ_CONSUMER_STATUS__ACTIVE) ||
|
||||
(vgThisConsumerAfterRb == 0 && status != MQ_CONSUMER_STATUS__LOST)) {
|
||||
/*if (vgThisConsumerAfterRb != vgThisConsumerBeforeRb) {*/
|
||||
/*pRebConsumer->epoch++;*/
|
||||
/*}*/
|
||||
if (vgThisConsumerAfterRb != 0) {
|
||||
atomic_store_32(&pRebConsumer->status, MQ_CONSUMER_STATUS__ACTIVE);
|
||||
} else {
|
||||
atomic_store_32(&pRebConsumer->status, MQ_CONSUMER_STATUS__IDLE);
|
||||
}
|
||||
|
||||
mInfo("mq consumer:%" PRId64 ", status change from %d to %d", pRebConsumer->consumerId, status,
|
||||
pRebConsumer->status);
|
||||
|
||||
SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pRebConsumer);
|
||||
sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY);
|
||||
mndTransAppendCommitlog(pTrans, pConsumerRaw);
|
||||
}
|
||||
taosWUnLockLatch(&pRebConsumer->lock);
|
||||
mDebug("consumer %ld w unlock", pRebConsumer->consumerId);
|
||||
mndReleaseConsumer(pMnode, pRebConsumer);
|
||||
}
|
||||
|
||||
// assign to vgroup
|
||||
if (taosArrayGetSize(pSub->unassignedVg) != 0) {
|
||||
for (int32_t i = 0; i < consumerNum; i++) {
|
||||
SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, i);
|
||||
int32_t vgThisConsumerAfterRb;
|
||||
if (i < imbalanceVg)
|
||||
vgThisConsumerAfterRb = vgEachConsumer + 1;
|
||||
else
|
||||
vgThisConsumerAfterRb = vgEachConsumer;
|
||||
|
||||
while (taosArrayGetSize(pSubConsumer->vgInfo) < vgThisConsumerAfterRb) {
|
||||
SMqConsumerEp *pConsumerEp = taosArrayPop(pSub->unassignedVg);
|
||||
mDebug("mq rebalance: vg %d pop from unassignedVg", pConsumerEp->vgId);
|
||||
ASSERT(pConsumerEp != NULL);
|
||||
|
||||
pConsumerEp->oldConsumerId = pConsumerEp->consumerId;
|
||||
pConsumerEp->consumerId = pSubConsumer->consumerId;
|
||||
// TODO
|
||||
pConsumerEp->epoch = 0;
|
||||
taosArrayPush(pSubConsumer->vgInfo, pConsumerEp);
|
||||
|
||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
mndSplitSubscribeKey(pSub->key, topic, cgroup);
|
||||
if (pConsumerEp->oldConsumerId == -1) {
|
||||
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic);
|
||||
|
||||
mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 " cgroup: %s", pConsumerEp->vgId,
|
||||
topic, pConsumerEp->consumerId, cgroup);
|
||||
|
||||
mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp);
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
} else {
|
||||
mInfo("mq rebalance: assign vgroup %d, from consumer %" PRId64 " to consumer %" PRId64 "",
|
||||
pConsumerEp->vgId, pConsumerEp->oldConsumerId, pConsumerEp->consumerId);
|
||||
|
||||
mndPersistRebalanceMsg(pMnode, pTrans, pConsumerEp, topic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ASSERT(taosArrayGetSize(pSub->unassignedVg) == 0);
|
||||
|
||||
// TODO: log rebalance statistics
|
||||
SSdbRaw *pSubRaw = mndSubActionEncode(pSub);
|
||||
sdbSetRawStatus(pSubRaw, SDB_STATUS_READY);
|
||||
mndTransAppendRedolog(pTrans, pSubRaw);
|
||||
}
|
||||
mndReleaseSubscribe(pMnode, pSub);
|
||||
}
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("mq-rebalance-trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
taosHashCleanup(pReq->rebSubHash);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosHashCleanup(pReq->rebSubHash);
|
||||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) {
|
||||
if (pInput->pTopic != NULL) {
|
||||
// create subscribe
|
||||
|
@ -825,36 +351,6 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
pRebVg->newConsumerId = pEpInSub->consumerId;
|
||||
taosArrayPush(pOutput->rebVgs, pRebVg);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*int32_t consumerVgNum = taosArrayGetSize(pEpInSub->vgs);*/
|
||||
if (imbCnt < imbConsumerNum) {
|
||||
imbCnt++;
|
||||
// push until equal minVg + 1
|
||||
while (taosArrayGetSize(pEpInSub->vgs) < minVgCnt + 1) {
|
||||
// iter hash and find one vg
|
||||
pRemovedIter = taosHashIterate(pHash, pRemovedIter);
|
||||
ASSERT(pRemovedIter);
|
||||
pRebVg = (SMqRebOutputVg *)pRemovedIter;
|
||||
// push
|
||||
taosArrayPush(pEpInSub->vgs, &pRebVg->pVgEp);
|
||||
pRebVg->newConsumerId = pEpInSub->consumerId;
|
||||
taosArrayPush(pOutput->rebVgs, pRebVg);
|
||||
}
|
||||
} else {
|
||||
// push until equal minVg
|
||||
while (taosArrayGetSize(pEpInSub->vgs) < minVgCnt) {
|
||||
// iter hash and find one vg
|
||||
pRemovedIter = taosHashIterate(pHash, pRemovedIter);
|
||||
ASSERT(pRemovedIter);
|
||||
pRebVg = (SMqRebOutputVg *)pRemovedIter;
|
||||
// push
|
||||
taosArrayPush(pEpInSub->vgs, &pRebVg->pVgEp);
|
||||
pRebVg->newConsumerId = pEpInSub->consumerId;
|
||||
taosArrayPush(pOutput->rebVgs, pRebVg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 7. handle unassigned vg
|
||||
|
@ -911,7 +407,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SNodeMsg *pMsg, const SMqRebO
|
|||
int32_t vgNum = taosArrayGetSize(rebVgs);
|
||||
for (int32_t i = 0; i < vgNum; i++) {
|
||||
SMqRebOutputVg *pRebVg = taosArrayGet(rebVgs, i);
|
||||
if (mndPersistSubChangeVgReq(pMnode, pTrans, pOutput->pSub->key, pRebVg) < 0) {
|
||||
if (mndPersistSubChangeVgReq(pMnode, pTrans, pOutput->pSub, pRebVg) < 0) {
|
||||
goto REB_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -1040,52 +536,6 @@ static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqTopicObj *pTopic, const char *cgroup,
|
||||
const SMqConsumerEp *pConsumerEp) {
|
||||
ASSERT(pConsumerEp->oldConsumerId == -1);
|
||||
int32_t vgId = pConsumerEp->vgId;
|
||||
|
||||
SMqSetCVgReq req = {
|
||||
.vgId = vgId,
|
||||
.consumerId = pConsumerEp->consumerId,
|
||||
.sql = pTopic->sql,
|
||||
.physicalPlan = pTopic->physicalPlan,
|
||||
.qmsg = pConsumerEp->qmsg,
|
||||
};
|
||||
|
||||
strcpy(req.cgroup, cgroup);
|
||||
strcpy(req.topicName, pTopic->name);
|
||||
int32_t tlen = tEncodeSMqSetCVgReq(NULL, &req);
|
||||
void *buf = taosMemoryMalloc(sizeof(SMsgHead) + tlen);
|
||||
if (buf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMsgHead *pMsgHead = (SMsgHead *)buf;
|
||||
|
||||
pMsgHead->contLen = htonl(sizeof(SMsgHead) + tlen);
|
||||
pMsgHead->vgId = htonl(vgId);
|
||||
|
||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
tEncodeSMqSetCVgReq(&abuf, &req);
|
||||
|
||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
action.pCont = buf;
|
||||
action.contLen = sizeof(SMsgHead) + tlen;
|
||||
action.msgType = TDMT_VND_MQ_SET_CONN;
|
||||
|
||||
mndReleaseVgroup(pMnode, pVgObj);
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndCleanupSubscribe(SMnode *pMnode) {}
|
||||
|
||||
static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) {
|
||||
|
|
|
@ -35,7 +35,7 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj
|
|||
static int32_t mndProcessCreateTopicReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessDropTopicReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessDropTopicInRsp(SNodeMsg *pRsp);
|
||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
||||
|
||||
int32_t mndInitTopic(SMnode *pMnode) {
|
||||
|
@ -51,7 +51,7 @@ int32_t mndInitTopic(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndProcessDropTopicInRsp);
|
||||
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic);
|
||||
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
|
@ -76,7 +76,13 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
|||
SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT64(pRaw, dataPos, pTopic->uid, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT64(pRaw, dataPos, pTopic->subDbUid, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, pTopic->version, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT8(pRaw, dataPos, pTopic->subType, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withTbName, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withSchema, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withTag, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withTagSchema, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, pTopic->astLen, TOPIC_ENCODE_OVER);
|
||||
|
@ -134,7 +140,13 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT64(pRaw, dataPos, &pTopic->updateTime, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->uid, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->dbUid, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->subDbUid, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->subType, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withTbName, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withSchema, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withTag, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withTagSchema, TOPIC_DECODE_OVER);
|
||||
|
||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char));
|
||||
|
@ -254,34 +266,14 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
|
|||
terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((pCreate->ast == NULL || pCreate->ast[0] == 0) && pCreate->subscribeDbName[0] == 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
|
||||
if (NULL == pCreate->ast) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode *pAst = NULL;
|
||||
int32_t code = nodesStringToNode(pCreate->ast, &pAst);
|
||||
|
||||
SQueryPlan *pPlan = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
|
||||
code = qCreateQueryPlan(&cxt, &pPlan, NULL);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesNodeToString(pPlan, false, pStr, NULL);
|
||||
}
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyNode(pPlan);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) {
|
||||
mDebug("topic:%s to create", pCreate->name);
|
||||
SMqTopicObj topicObj = {0};
|
||||
|
@ -297,28 +289,38 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
|
|||
topicObj.ast = strdup(pCreate->ast);
|
||||
topicObj.astLen = strlen(pCreate->ast) + 1;
|
||||
|
||||
SNode *pAst = NULL;
|
||||
if (nodesStringToNode(pCreate->ast, &pAst) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
if (pCreate->ast && pCreate->ast[0]) {
|
||||
topicObj.subType = TOPIC_SUB_TYPE__TABLE;
|
||||
topicObj.withTbName = 0;
|
||||
topicObj.withSchema = 0;
|
||||
|
||||
SQueryPlan *pPlan = NULL;
|
||||
SNode *pAst = NULL;
|
||||
if (nodesStringToNode(pCreate->ast, &pAst) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
|
||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
SQueryPlan *pPlan = NULL;
|
||||
|
||||
if (qExtractResultSchema(pAst, &topicObj.schema.nCols, &topicObj.schema.pSchema) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
|
||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
if (qExtractResultSchema(pAst, &topicObj.schema.nCols, &topicObj.schema.pSchema) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
topicObj.subType = TOPIC_SUB_TYPE__DB;
|
||||
topicObj.withTbName = 1;
|
||||
topicObj.withSchema = 1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg);
|
||||
|
@ -509,56 +511,40 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
SMqTopicObj *pTopic = NULL;
|
||||
int32_t cols = 0;
|
||||
char *pWrite;
|
||||
char prefix[TSDB_DB_FNAME_LEN] = {0};
|
||||
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, pShow->db);
|
||||
if (pDb == NULL) return 0;
|
||||
|
||||
tstrncpy(prefix, pShow->db, TSDB_DB_FNAME_LEN);
|
||||
strcat(prefix, TS_PATH_DELIMITER);
|
||||
int32_t prefixLen = (int32_t)strlen(prefix);
|
||||
|
||||
while (numOfRows < rows) {
|
||||
while (numOfRows < rowsCapacity) {
|
||||
pShow->pIter = sdbFetch(pSdb, SDB_TOPIC, pShow->pIter, (void **)&pTopic);
|
||||
if (pShow->pIter == NULL) break;
|
||||
|
||||
if (pTopic->dbUid != pDb->uid) {
|
||||
if (strncmp(pTopic->name, prefix, prefixLen) != 0) {
|
||||
mError("Inconsistent topic data, name:%s, db:%s, dbUid:%" PRIu64, pTopic->name, pDb->name, pDb->uid);
|
||||
}
|
||||
int32_t cols = 0;
|
||||
|
||||
sdbRelease(pSdb, pTopic);
|
||||
continue;
|
||||
}
|
||||
char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tstrncpy(&topicName[VARSTR_HEADER_SIZE], pTopic->name, TSDB_TOPIC_NAME_LEN);
|
||||
varDataSetLen(topicName, strlen(&topicName[VARSTR_HEADER_SIZE]));
|
||||
|
||||
cols = 0;
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)topicName, false);
|
||||
|
||||
char topicName[TSDB_TOPIC_NAME_LEN] = {0};
|
||||
tstrncpy(topicName, pTopic->name + prefixLen, TSDB_TOPIC_NAME_LEN);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_TO_VARSTR(pWrite, topicName);
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pTopic->createTime, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int64_t *)pWrite = pTopic->createTime;
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
char *sql = taosMemoryCalloc(1, strlen(pTopic->sql) + 1 + VARSTR_HEADER_SIZE);
|
||||
strcpy(&sql[VARSTR_HEADER_SIZE], pTopic->sql);
|
||||
varDataSetLen(sql, strlen(&sql[VARSTR_HEADER_SIZE]));
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)sql, false);
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pTopic->sql, pShow->bytes[cols]);
|
||||
cols++;
|
||||
taosMemoryFree(sql);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pTopic);
|
||||
}
|
||||
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
pShow->numOfRows += numOfRows;
|
||||
return numOfRows;
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_FUNC);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_FUNC_NOT_EXIST);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -371,7 +371,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_RETRIEVE_FUNC, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_FUNC);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_FUNC_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,15 @@ int32_t MndTestProfile::connId;
|
|||
TEST_F(MndTestProfile, 01_ConnectMsg) {
|
||||
SConnectReq connectReq = {0};
|
||||
connectReq.pid = 1234;
|
||||
|
||||
char passwd[] = "taosdata";
|
||||
char secretEncrypt[TSDB_PASSWORD_LEN] = {0};
|
||||
taosEncryptPass_c((uint8_t*)passwd, strlen(passwd), secretEncrypt);
|
||||
|
||||
strcpy(connectReq.app, "mnode_test_profile");
|
||||
strcpy(connectReq.db, "");
|
||||
strcpy(connectReq.user, "root");
|
||||
strcpy(connectReq.passwd, secretEncrypt);
|
||||
|
||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
|
@ -58,10 +65,16 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
|
|||
}
|
||||
|
||||
TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) {
|
||||
char passwd[] = "taosdata";
|
||||
char secretEncrypt[TSDB_PASSWORD_LEN] = {0};
|
||||
taosEncryptPass_c((uint8_t*)passwd, strlen(passwd), secretEncrypt);
|
||||
|
||||
SConnectReq connectReq = {0};
|
||||
connectReq.pid = 1234;
|
||||
strcpy(connectReq.app, "mnode_test_profile");
|
||||
strcpy(connectReq.db, "invalid_db");
|
||||
strcpy(connectReq.user, "root");
|
||||
strcpy(connectReq.passwd, secretEncrypt);
|
||||
|
||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG);
|
||||
ASSERT_NE(pRsp->code, 0);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
||||
|
@ -50,14 +50,20 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG);
|
||||
ASSERT_NE(pRsp->code, 0);
|
||||
}
|
||||
|
||||
TEST_F(MndTestShow, 03_ShowMsg_Conn) {
|
||||
char passwd[] = "taosdata";
|
||||
char secretEncrypt[TSDB_PASSWORD_LEN] = {0};
|
||||
taosEncryptPass_c((uint8_t*)passwd, strlen(passwd), secretEncrypt);
|
||||
|
||||
SConnectReq connectReq = {0};
|
||||
connectReq.pid = 1234;
|
||||
strcpy(connectReq.app, "mnode_test_show");
|
||||
strcpy(connectReq.db, "");
|
||||
strcpy(connectReq.user, "root");
|
||||
strcpy(connectReq.passwd, secretEncrypt);
|
||||
|
||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
|
@ -74,4 +80,4 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
|
|||
TEST_F(MndTestShow, 04_ShowMsg_Cluster) {
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_CLUSTER, "cluster", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,8 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
|
|||
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
||||
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
||||
bool tqNextDataBlock(STqReadHandle *pHandle);
|
||||
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, int32_t *pNumOfRows);
|
||||
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, int32_t *pNumOfRows,
|
||||
int16_t *pNumOfCols);
|
||||
|
||||
// need to reposition
|
||||
|
||||
|
|
|
@ -88,22 +88,12 @@ struct STqReadHandle {
|
|||
SSubmitMsgIter msgIter;
|
||||
SSubmitBlkIter blkIter;
|
||||
SMeta* pVnodeMeta;
|
||||
SArray* pColIdList; // SArray<int32_t>
|
||||
SArray* pColIdList; // SArray<int16_t>
|
||||
int32_t sver;
|
||||
SSchemaWrapper* pSchemaWrapper;
|
||||
STSchema* pSchema;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int8_t type;
|
||||
int8_t reserved[7];
|
||||
union {
|
||||
void* data;
|
||||
int64_t wmTs;
|
||||
int64_t checkpointId;
|
||||
};
|
||||
} STqStreamToken;
|
||||
|
||||
typedef struct {
|
||||
int16_t ver;
|
||||
int16_t action;
|
||||
|
@ -155,24 +145,26 @@ typedef struct {
|
|||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
int64_t consumerId;
|
||||
int32_t epoch;
|
||||
int8_t subType;
|
||||
int8_t withTbName;
|
||||
int8_t withSchema;
|
||||
int8_t withTag;
|
||||
int8_t withTagSchema;
|
||||
char* qmsg;
|
||||
// SRWLatch lock;
|
||||
SWalReadHandle* pReadHandle;
|
||||
SWalReadHandle* pWalReader;
|
||||
// number should be identical to fetch thread num
|
||||
qTaskInfo_t task[4];
|
||||
STqReadHandle* pStreamReader[4];
|
||||
qTaskInfo_t task[4];
|
||||
} STqExec;
|
||||
|
||||
struct STQ {
|
||||
// the collection of groups
|
||||
// the handle of meta kvstore
|
||||
bool writeTrigger;
|
||||
char* path;
|
||||
STqMetaStore* tqMeta;
|
||||
SHashObj* tqMetaNew; // subKey -> tqExec
|
||||
SHashObj* pStreamTasks;
|
||||
SVnode* pVnode;
|
||||
SWal* pWal;
|
||||
SMeta* pVnodeMeta;
|
||||
char* path;
|
||||
// STqMetaStore* tqMeta;
|
||||
SHashObj* execs; // subKey -> tqExec
|
||||
SHashObj* pStreamTasks;
|
||||
SVnode* pVnode;
|
||||
SWal* pWal;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -252,7 +244,7 @@ int tqInit();
|
|||
void tqCleanUp();
|
||||
|
||||
// open in each vnode
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pMeta, SMemAllocatorFactory* allocFac);
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal);
|
||||
void tqClose(STQ*);
|
||||
// required by vnode
|
||||
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version);
|
||||
|
|
|
@ -391,6 +391,7 @@ struct SReadH {
|
|||
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
|
||||
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
|
||||
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
|
||||
#define TSDB_READ_TABLE_UID(rh) ((rh)->pTable->uid)
|
||||
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
|
||||
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
|
||||
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
|
||||
|
|
|
@ -23,6 +23,9 @@ struct SMetaIdx {
|
|||
SIndex *pIdx;
|
||||
#endif
|
||||
/* data */
|
||||
#ifdef WINDOWS
|
||||
size_t avoidCompilationErrors;
|
||||
#endif
|
||||
};
|
||||
|
||||
int metaOpenIdx(SMeta *pMeta) {
|
||||
|
|
|
@ -45,10 +45,12 @@ struct SMetaDB {
|
|||
#endif
|
||||
};
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
#pragma pack(push,1)
|
||||
typedef struct {
|
||||
tb_uid_t uid;
|
||||
int32_t sver;
|
||||
} SSchemaDbKey;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
|
@ -626,14 +628,8 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
|||
#ifdef META_TDB_SMA_TEST
|
||||
STSmaWrapper *pSW = NULL;
|
||||
|
||||
pSW = taosMemoryCalloc(1, sizeof(*pSW));
|
||||
if (pSW == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SMSmaCursor *pCur = metaOpenSmaCursor(pMeta, uid);
|
||||
if (pCur == NULL) {
|
||||
taosMemoryFree(pSW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -653,6 +649,12 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((pSW == NULL) && ((pSW = taosMemoryCalloc(1, sizeof(*pSW))) == NULL)) {
|
||||
TDB_FREE(pSmaVal);
|
||||
metaCloseSmaCursor(pCur);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
++pSW->number;
|
||||
STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
|
||||
if (tptr == NULL) {
|
||||
|
|
|
@ -19,7 +19,7 @@ int32_t tqInit() { return tqPushMgrInit(); }
|
|||
|
||||
void tqCleanUp() { tqPushMgrCleanUp(); }
|
||||
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, SMemAllocatorFactory* allocFac) {
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
||||
STQ* pTq = taosMemoryMalloc(sizeof(STQ));
|
||||
if (pTq == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
|
@ -28,15 +28,16 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, SMe
|
|||
pTq->path = strdup(path);
|
||||
pTq->pVnode = pVnode;
|
||||
pTq->pWal = pWal;
|
||||
pTq->pVnodeMeta = pVnodeMeta;
|
||||
#if 0
|
||||
pTq->tqMeta = tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer,
|
||||
(FTqDelete)taosMemoryFree, 0);
|
||||
if (pTq->tqMeta == NULL) {
|
||||
taosMemoryFree(pTq);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
pTq->tqMetaNew = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
pTq->execs = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
|
||||
pTq->pStreamTasks = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
|
||||
|
@ -104,7 +105,11 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tqCommit(STQ* pTq) { return tqStorePersist(pTq->tqMeta); }
|
||||
int tqCommit(STQ* pTq) {
|
||||
// do nothing
|
||||
/*return tqStorePersist(pTq->tqMeta);*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqGetTopicHandleSize(const STqTopic* pTopic) {
|
||||
return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->physicalPlan) + strlen(pTopic->qmsg) +
|
||||
|
@ -219,10 +224,10 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu
|
|||
}
|
||||
for (int j = 0; j < TQ_BUFFER_SIZE; j++) {
|
||||
pTopic->buffer.output[j].status = 0;
|
||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||
SReadHandle handle = {
|
||||
.reader = pReadHandle,
|
||||
.meta = pTq->pVnodeMeta,
|
||||
.meta = pTq->pVnode->pMeta,
|
||||
};
|
||||
pTopic->buffer.output[j].pReadHandle = pReadHandle;
|
||||
pTopic->buffer.output[j].task = qCreateStreamExecTaskInfo(pTopic->qmsg, &handle);
|
||||
|
@ -238,6 +243,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
int32_t reqEpoch = pReq->epoch;
|
||||
int64_t fetchOffset;
|
||||
|
||||
// get offset to fetch message
|
||||
if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) {
|
||||
fetchOffset = walGetFirstVer(pTq->pWal);
|
||||
} else if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__LATEST) {
|
||||
|
@ -249,7 +255,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
||||
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
|
||||
|
||||
STqExec* pExec = taosHashGet(pTq->tqMetaNew, pReq->subKey, strlen(pReq->subKey));
|
||||
STqExec* pExec = taosHashGet(pTq->execs, pReq->subKey, strlen(pReq->subKey));
|
||||
ASSERT(pExec);
|
||||
|
||||
int32_t consumerEpoch = atomic_load_32(&pExec->epoch);
|
||||
|
@ -271,7 +277,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
}
|
||||
|
||||
SWalReadHead* pHead;
|
||||
if (walReadWithHandle_s(pExec->pReadHandle, fetchOffset, &pHead) < 0) {
|
||||
if (walReadWithHandle_s(pExec->pWalReader, fetchOffset, &pHead) < 0) {
|
||||
// TODO: no more log, set timer to wait blocking time
|
||||
// if data inserted during waiting, launch query and
|
||||
// response to user
|
||||
|
@ -285,41 +291,73 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
|
||||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||
SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
|
||||
qTaskInfo_t task = pExec->task[workerId];
|
||||
ASSERT(task);
|
||||
qSetStreamInput(task, pCont, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
||||
while (1) {
|
||||
SSDataBlock* pDataBlock = NULL;
|
||||
uint64_t ts = 0;
|
||||
if (qExecTask(task, &pDataBlock, &ts) < 0) {
|
||||
ASSERT(0);
|
||||
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
qTaskInfo_t task = pExec->task[workerId];
|
||||
ASSERT(task);
|
||||
qSetStreamInput(task, pCont, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
||||
while (1) {
|
||||
SSDataBlock* pDataBlock = NULL;
|
||||
uint64_t ts = 0;
|
||||
if (qExecTask(task, &pDataBlock, &ts) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
if (pDataBlock == NULL) break;
|
||||
|
||||
ASSERT(pDataBlock->info.rows != 0);
|
||||
ASSERT(pDataBlock->info.numOfCols != 0);
|
||||
|
||||
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pDataBlock);
|
||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
||||
pRetrieve->useconds = ts;
|
||||
pRetrieve->precision = TSDB_DEFAULT_PRECISION;
|
||||
pRetrieve->compressed = 0;
|
||||
pRetrieve->completed = 1;
|
||||
pRetrieve->numOfRows = htonl(pDataBlock->info.rows);
|
||||
|
||||
// TODO enable compress
|
||||
int32_t actualLen = 0;
|
||||
blockCompressEncode(pDataBlock, pRetrieve->data, &actualLen, pDataBlock->info.numOfCols, false);
|
||||
actualLen += sizeof(SRetrieveTableRsp);
|
||||
ASSERT(actualLen <= dataStrLen);
|
||||
taosArrayPush(rsp.blockDataLen, &actualLen);
|
||||
taosArrayPush(rsp.blockData, &buf);
|
||||
rsp.blockNum++;
|
||||
}
|
||||
if (pDataBlock == NULL) break;
|
||||
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||
STqReadHandle* pReader = pExec->pStreamReader[workerId];
|
||||
tqReadHandleSetMsg(pReader, pCont, 0);
|
||||
while (tqNextDataBlock(pReader)) {
|
||||
SSDataBlock block = {0};
|
||||
if (tqRetrieveDataBlock(&block.pDataBlock, pReader, &block.info.groupId, &block.info.rows,
|
||||
&block.info.numOfCols) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(&block);
|
||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
||||
/*pRetrieve->useconds = 0;*/
|
||||
pRetrieve->precision = TSDB_DEFAULT_PRECISION;
|
||||
pRetrieve->compressed = 0;
|
||||
pRetrieve->completed = 1;
|
||||
pRetrieve->numOfRows = htonl(block.info.rows);
|
||||
|
||||
ASSERT(pDataBlock->info.rows != 0);
|
||||
ASSERT(pDataBlock->info.numOfCols != 0);
|
||||
|
||||
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pDataBlock);
|
||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
||||
pRetrieve->useconds = ts;
|
||||
pRetrieve->precision = TSDB_DEFAULT_PRECISION;
|
||||
pRetrieve->compressed = 0;
|
||||
pRetrieve->completed = 1;
|
||||
pRetrieve->numOfRows = htonl(pDataBlock->info.rows);
|
||||
|
||||
// TODO enable compress
|
||||
int32_t actualLen = 0;
|
||||
blockCompressEncode(pDataBlock, pRetrieve->data, &actualLen, pDataBlock->info.numOfCols, false);
|
||||
actualLen += sizeof(SRetrieveTableRsp);
|
||||
ASSERT(actualLen <= dataStrLen);
|
||||
taosArrayPush(rsp.blockDataLen, &actualLen);
|
||||
taosArrayPush(rsp.blockData, &buf);
|
||||
rsp.blockNum++;
|
||||
// TODO enable compress
|
||||
int32_t actualLen = 0;
|
||||
blockCompressEncode(&block, pRetrieve->data, &actualLen, block.info.numOfCols, false);
|
||||
actualLen += sizeof(SRetrieveTableRsp);
|
||||
ASSERT(actualLen <= dataStrLen);
|
||||
taosArrayPush(rsp.blockDataLen, &actualLen);
|
||||
taosArrayPush(rsp.blockData, &buf);
|
||||
rsp.blockNum++;
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO batch optimization
|
||||
// TODO batch optimization:
|
||||
// TODO continue scan until meeting batch requirement
|
||||
if (rsp.blockNum != 0) break;
|
||||
rsp.skipLogNum++;
|
||||
fetchOffset++;
|
||||
|
@ -572,10 +610,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
|||
|
||||
// TODO: persist meta into tdb
|
||||
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SMqRebVgReq req;
|
||||
SMqRebVgReq req = {0};
|
||||
tDecodeSMqRebVgReq(msg, &req);
|
||||
// todo lock
|
||||
STqExec* pExec = taosHashGet(pTq->tqMetaNew, req.subKey, strlen(req.subKey));
|
||||
STqExec* pExec = taosHashGet(pTq->execs, req.subKey, strlen(req.subKey));
|
||||
if (pExec == NULL) {
|
||||
ASSERT(req.oldConsumerId == -1);
|
||||
ASSERT(req.newConsumerId != -1);
|
||||
|
@ -586,19 +624,27 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
memcpy(pExec->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
pExec->consumerId = req.newConsumerId;
|
||||
pExec->epoch = -1;
|
||||
|
||||
pExec->subType = req.subType;
|
||||
pExec->withTbName = req.withTbName;
|
||||
pExec->withSchema = req.withSchema;
|
||||
pExec->withTag = req.withTag;
|
||||
pExec->withTagSchema = req.withTagSchema;
|
||||
|
||||
pExec->qmsg = req.qmsg;
|
||||
req.qmsg = NULL;
|
||||
pExec->pReadHandle = walOpenReadHandle(pTq->pVnode->pWal);
|
||||
|
||||
pExec->pWalReader = walOpenReadHandle(pTq->pVnode->pWal);
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
||||
SReadHandle handle = {
|
||||
.reader = pReadHandle,
|
||||
.meta = pTq->pVnodeMeta,
|
||||
pExec->pStreamReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||
SReadHandle handle = {
|
||||
.reader = pExec->pStreamReader[i],
|
||||
.meta = pTq->pVnode->pMeta,
|
||||
};
|
||||
pExec->task[i] = qCreateStreamExecTaskInfo(pExec->qmsg, &handle);
|
||||
ASSERT(pExec->task[i]);
|
||||
}
|
||||
taosHashPut(pTq->tqMetaNew, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec));
|
||||
taosHashPut(pTq->execs, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec));
|
||||
return 0;
|
||||
} else {
|
||||
/*if (req.newConsumerId != -1) {*/
|
||||
|
@ -618,127 +664,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tqProcessRebReq(STQ* pTq, char* msg) {
|
||||
SMqMVRebReq req = {0};
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
tDecodeSMqMVRebReq(msg, &req);
|
||||
|
||||
vDebug("vg %d set from consumer %ld to consumer %ld", req.vgId, req.oldConsumerId, req.newConsumerId);
|
||||
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, req.oldConsumerId);
|
||||
ASSERT(pConsumer);
|
||||
ASSERT(pConsumer->consumerId == req.oldConsumerId);
|
||||
int32_t numOfTopics = taosArrayGetSize(pConsumer->topics);
|
||||
if (numOfTopics == 1) {
|
||||
STqTopic* pTopic = taosArrayGet(pConsumer->topics, 0);
|
||||
ASSERT(strcmp(pTopic->topicName, req.topic) == 0);
|
||||
STqConsumer* pNewConsumer = tqHandleGet(pTq->tqMeta, req.newConsumerId);
|
||||
if (pNewConsumer == NULL) {
|
||||
pConsumer->consumerId = req.newConsumerId;
|
||||
tqHandleMovePut(pTq->tqMeta, req.newConsumerId, pConsumer);
|
||||
tqHandleCommit(pTq->tqMeta, req.newConsumerId);
|
||||
tqHandlePurge(pTq->tqMeta, req.oldConsumerId);
|
||||
return 0;
|
||||
} else {
|
||||
taosArrayPush(pNewConsumer->topics, pTopic);
|
||||
}
|
||||
} else {
|
||||
for (int32_t i = 0; i < numOfTopics; i++) {
|
||||
STqTopic* pTopic = taosArrayGet(pConsumer->topics, i);
|
||||
if (strcmp(pTopic->topicName, req.topic) == 0) {
|
||||
STqConsumer* pNewConsumer = tqHandleGet(pTq->tqMeta, req.newConsumerId);
|
||||
if (pNewConsumer == NULL) {
|
||||
pNewConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
|
||||
if (pNewConsumer == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
strcpy(pNewConsumer->cgroup, pConsumer->cgroup);
|
||||
pNewConsumer->topics = taosArrayInit(0, sizeof(STqTopic));
|
||||
pNewConsumer->consumerId = req.newConsumerId;
|
||||
pNewConsumer->epoch = 0;
|
||||
|
||||
taosArrayPush(pNewConsumer->topics, pTopic);
|
||||
tqHandleMovePut(pTq->tqMeta, req.newConsumerId, pConsumer);
|
||||
tqHandleCommit(pTq->tqMeta, req.newConsumerId);
|
||||
return 0;
|
||||
}
|
||||
ASSERT(pNewConsumer->consumerId == req.newConsumerId);
|
||||
taosArrayPush(pNewConsumer->topics, pTopic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
|
||||
SMqSetCVgReq req = {0};
|
||||
tDecodeSMqSetCVgReq(msg, &req);
|
||||
bool create = false;
|
||||
|
||||
vDebug("vg %d set to consumer %ld", req.vgId, req.consumerId);
|
||||
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, req.consumerId);
|
||||
if (pConsumer == NULL) {
|
||||
pConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
|
||||
if (pConsumer == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
strcpy(pConsumer->cgroup, req.cgroup);
|
||||
pConsumer->topics = taosArrayInit(0, sizeof(STqTopic));
|
||||
pConsumer->consumerId = req.consumerId;
|
||||
pConsumer->epoch = 0;
|
||||
create = true;
|
||||
}
|
||||
|
||||
STqTopic* pTopic = taosMemoryCalloc(1, sizeof(STqTopic));
|
||||
if (pTopic == NULL) {
|
||||
taosArrayDestroy(pConsumer->topics);
|
||||
taosMemoryFree(pConsumer);
|
||||
return -1;
|
||||
}
|
||||
strcpy(pTopic->topicName, req.topicName);
|
||||
pTopic->sql = req.sql;
|
||||
pTopic->physicalPlan = req.physicalPlan;
|
||||
pTopic->qmsg = req.qmsg;
|
||||
/*pTopic->committedOffset = -1;*/
|
||||
/*pTopic->currentOffset = -1;*/
|
||||
|
||||
pTopic->buffer.firstOffset = -1;
|
||||
pTopic->buffer.lastOffset = -1;
|
||||
pTopic->pReadhandle = walOpenReadHandle(pTq->pWal);
|
||||
if (pTopic->pReadhandle == NULL) {
|
||||
ASSERT(false);
|
||||
}
|
||||
for (int i = 0; i < TQ_BUFFER_SIZE; i++) {
|
||||
pTopic->buffer.output[i].status = 0;
|
||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
||||
SReadHandle handle = {
|
||||
.reader = pReadHandle,
|
||||
.meta = pTq->pVnodeMeta,
|
||||
};
|
||||
pTopic->buffer.output[i].pReadHandle = pReadHandle;
|
||||
pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle);
|
||||
ASSERT(pTopic->buffer.output[i].task);
|
||||
}
|
||||
vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, TD_VID(pTq->pVnode));
|
||||
taosArrayPush(pConsumer->topics, pTopic);
|
||||
if (create) {
|
||||
tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer);
|
||||
tqHandleCommit(pTq->tqMeta, req.consumerId);
|
||||
}
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessCancelConnReq(STQ* pTq, char* msg) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
|
||||
if (pTask->execType == TASK_EXEC__NONE) return 0;
|
||||
|
||||
|
@ -748,12 +673,12 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
|
|||
return -1;
|
||||
}
|
||||
for (int32_t i = 0; i < parallel; i++) {
|
||||
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
|
||||
STqReadHandle* pStreamReader = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||
SReadHandle handle = {
|
||||
.reader = pReadHandle,
|
||||
.meta = pTq->pVnodeMeta,
|
||||
.reader = pStreamReader,
|
||||
.meta = pTq->pVnode->pMeta,
|
||||
};
|
||||
pTask->exec.runners[i].inputHandle = pReadHandle;
|
||||
pTask->exec.runners[i].inputHandle = pStreamReader;
|
||||
pTask->exec.runners[i].executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle);
|
||||
ASSERT(pTask->exec.runners[i].executor);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
}
|
||||
strcpy(pMeta->dirPath, path);
|
||||
|
||||
char name[pathLen + 10];
|
||||
char *name = taosMemoryMalloc(pathLen + 10) ;
|
||||
|
||||
strcpy(name, path);
|
||||
if (!taosDirExist(name) && taosMkDir(name) != 0) {
|
||||
|
@ -99,6 +99,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tqError("failed to open file:%s since %s ", name, terrstr());
|
||||
// free memory
|
||||
taosMemoryFree(name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -106,6 +107,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
pMeta->unpersistHead = taosMemoryCalloc(1, sizeof(STqMetaList));
|
||||
if (pMeta->unpersistHead == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
taosMemoryFree(name);
|
||||
return NULL;
|
||||
}
|
||||
pMeta->unpersistHead->unpersistNext = pMeta->unpersistHead->unpersistPrev = pMeta->unpersistHead;
|
||||
|
@ -116,8 +118,10 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tqError("failed to open file:%s since %s", name, terrstr());
|
||||
taosMemoryFree(name);
|
||||
return NULL;
|
||||
}
|
||||
taosMemoryFree(name);
|
||||
|
||||
pMeta->pFile = pFile;
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* pGroupId, int32_t* pNumOfRows) {
|
||||
int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* pGroupId, int32_t* pNumOfRows,
|
||||
int16_t* pNumOfCols) {
|
||||
/*int32_t sversion = pHandle->pBlock->sversion;*/
|
||||
// TODO set to real sversion
|
||||
int32_t sversion = 0;
|
||||
|
@ -104,7 +105,6 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
|||
SSchemaWrapper* pSchemaWrapper = pHandle->pSchemaWrapper;
|
||||
|
||||
*pNumOfRows = pHandle->pBlock->numOfRows;
|
||||
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
|
||||
int32_t colNumNeed = taosArrayGetSize(pHandle->pColIdList);
|
||||
|
||||
if (colNumNeed > pSchemaWrapper->nCols) {
|
||||
|
@ -142,6 +142,7 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
|||
}
|
||||
|
||||
int32_t colActual = taosArrayGetSize(*ppCols);
|
||||
*pNumOfCols = colActual;
|
||||
|
||||
// TODO in stream shuffle case, fetch groupId
|
||||
*pGroupId = 0;
|
||||
|
|
|
@ -3260,6 +3260,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
tsdbDebug("vgId:%d succeed to load block statis part for uid %" PRIu64, REPO_ID(pHandle->pTsdb),
|
||||
TSDB_READ_TABLE_UID(&pHandle->rhelper));
|
||||
|
||||
int16_t* colIds = pHandle->defaultLoadColumn->pData;
|
||||
|
||||
size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle);
|
||||
|
|
|
@ -322,15 +322,18 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
|
|||
ASSERT(pBlock->numOfSubBlocks <= 1);
|
||||
|
||||
if (!pBlock->aggrStat) {
|
||||
tsdbDebug("vgId:%d no need to load block statis part for uid %" PRIu64 " since not exist", REPO_ID(pReadh->pRepo),
|
||||
TSDB_READ_TABLE_UID(pReadh));
|
||||
return TSDB_STATIS_NONE;
|
||||
}
|
||||
|
||||
SDFile *pDFileAggr = pBlock->last ? TSDB_READ_SMAL_FILE(pReadh) : TSDB_READ_SMAD_FILE(pReadh);
|
||||
|
||||
if (tsdbSeekDFile(pDFileAggr, pBlock->aggrOffset, SEEK_SET) < 0) {
|
||||
tsdbError("vgId:%d failed to load block aggr part while seek file %s to offset %" PRIu64 " since %s",
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr), (uint64_t)pBlock->aggrOffset,
|
||||
tstrerror(terrno));
|
||||
tsdbError("vgId:%d failed to load block statis part for uid %" PRIu64 " while seek file %s to offset %" PRIu64
|
||||
" since %s",
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_READ_TABLE_UID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr),
|
||||
(uint64_t)pBlock->aggrOffset, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -339,25 +342,28 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
|
|||
|
||||
int64_t nreadAggr = tsdbReadDFile(pDFileAggr, (void *)(pReadh->pAggrBlkData), sizeAggr);
|
||||
if (nreadAggr < 0) {
|
||||
tsdbError("vgId:%d failed to load block aggr part while read file %s since %s, offset:%" PRIu64 " len :%" PRIzu,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr), tstrerror(terrno),
|
||||
(uint64_t)pBlock->aggrOffset, sizeAggr);
|
||||
tsdbError("vgId:%d failed to load block statis part for uid %" PRIu64
|
||||
" while read file %s since %s, offset:%" PRIu64 " len :%" PRIzu,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_READ_TABLE_UID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr),
|
||||
tstrerror(terrno), (uint64_t)pBlock->aggrOffset, sizeAggr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nreadAggr < sizeAggr) {
|
||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
tsdbError("vgId:%d block aggr part in file %s is corrupted, offset:%" PRIu64 " expected bytes:%" PRIzu
|
||||
" read bytes: %" PRId64,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr), (uint64_t)pBlock->aggrOffset, sizeAggr,
|
||||
nreadAggr);
|
||||
tsdbError("vgId:%d block statis part for uid %" PRIu64 " in file %s is corrupted, offset:%" PRIu64
|
||||
" expected bytes:%" PRIzu " read bytes: %" PRId64,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_READ_TABLE_UID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr),
|
||||
(uint64_t)pBlock->aggrOffset, sizeAggr, nreadAggr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!taosCheckChecksumWhole((uint8_t *)(pReadh->pAggrBlkData), (uint32_t)sizeAggr)) {
|
||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
tsdbError("vgId:%d block aggr part in file %s is corrupted since wrong checksum, offset:%" PRIu64 " len :%" PRIzu,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr), (uint64_t)pBlock->aggrOffset, sizeAggr);
|
||||
tsdbError("vgId:%d block statis part for uid %" PRIu64
|
||||
"in file %s is corrupted since wrong checksum, offset:%" PRIu64 " len :%" PRIzu,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_READ_TABLE_UID(pReadh), TSDB_FILE_FULL_NAME(pDFileAggr),
|
||||
(uint64_t)pBlock->aggrOffset, sizeAggr);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -367,7 +373,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
|
|||
ASSERT(pBlock->numOfSubBlocks <= 1);
|
||||
SDFile *pDFile = (pBlock->last) ? TSDB_READ_LAST_FILE(pReadh) : TSDB_READ_DATA_FILE(pReadh);
|
||||
if (tsdbSeekDFile(pDFile, pBlock->offset, SEEK_SET) < 0) {
|
||||
tsdbError("vgId:%d failed to load block statis part while seek file %s to offset %" PRId64 " since %s",
|
||||
tsdbError("vgId:%d failed to load block head part while seek file %s to offset %" PRId64 " since %s",
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), (int64_t)pBlock->offset, tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -377,14 +383,14 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
|
|||
|
||||
int64_t nread = tsdbReadDFile(pDFile, (void *)(pReadh->pBlkData), size);
|
||||
if (nread < 0) {
|
||||
tsdbError("vgId:%d failed to load block statis part while read file %s since %s, offset:%" PRId64 " len :%" PRIzu,
|
||||
tsdbError("vgId:%d failed to load block head part while read file %s since %s, offset:%" PRId64 " len :%" PRIzu,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), tstrerror(terrno), (int64_t)pBlock->offset, size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nread < size) {
|
||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
tsdbError("vgId:%d block statis part in file %s is corrupted, offset:%" PRId64 " expected bytes:%" PRIzu
|
||||
tsdbError("vgId:%d block head part in file %s is corrupted, offset:%" PRId64 " expected bytes:%" PRIzu
|
||||
" read bytes: %" PRId64,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), (int64_t)pBlock->offset, size, nread);
|
||||
return -1;
|
||||
|
@ -392,7 +398,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
|
|||
|
||||
if (!taosCheckChecksumWhole((uint8_t *)(pReadh->pBlkData), (uint32_t)size)) {
|
||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
tsdbError("vgId:%d block statis part in file %s is corrupted since wrong checksum, offset:%" PRId64 " len :%" PRIzu,
|
||||
tsdbError("vgId:%d block head part in file %s is corrupted since wrong checksum, offset:%" PRId64 " len :%" PRIzu,
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), (int64_t)pBlock->offset, size);
|
||||
return -1;
|
||||
}
|
||||
|
@ -546,7 +552,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
|
|||
int32_t tsize = (int32_t)tsdbBlockStatisSize(pBlock->numOfCols, (uint32_t)pBlock->blkVer);
|
||||
if (!taosCheckChecksumWhole((uint8_t *)TSDB_READ_BUF(pReadh), tsize)) {
|
||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
tsdbError("vgId:%d block statis part in file %s is corrupted since wrong checksum, offset:%" PRId64 " len :%d",
|
||||
tsdbError("vgId:%d block head part in file %s is corrupted since wrong checksum, offset:%" PRId64 " len :%d",
|
||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), (int64_t)pBlock->offset, tsize);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -643,6 +643,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
|
|||
SSubmitMsgIter msgIter = {0};
|
||||
SSubmitBlk *pBlock = NULL;
|
||||
SInterval interval = {0};
|
||||
TSKEY lastWinSKey = INT64_MIN;
|
||||
|
||||
if (tInitSubmitMsgIter(pMsg, &msgIter) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_FAILED;
|
||||
|
@ -657,7 +658,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
|
|||
|
||||
SSubmitBlkIter blkIter = {0};
|
||||
if (tInitSubmitBlkIter(pBlock, &blkIter) != TSDB_CODE_SUCCESS) {
|
||||
tdFreeTSmaWrapper(pSW);
|
||||
pSW = tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -667,31 +668,37 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
|
|||
tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
if (pSW == NULL) {
|
||||
if (!pSW || (pTSma->tableUid != pBlock->suid)) {
|
||||
if (pSW) {
|
||||
pSW = tdFreeTSmaWrapper(pSW);
|
||||
}
|
||||
if ((pSW = metaGetSmaInfoByTable(REPO_META(pTsdb), pBlock->suid)) == NULL) {
|
||||
break;
|
||||
}
|
||||
if ((pSW->number) <= 0 || (pSW->tSma == NULL)) {
|
||||
tdFreeTSmaWrapper(pSW);
|
||||
pSW = tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
pTSma = pSW->tSma;
|
||||
}
|
||||
|
||||
interval.interval = pTSma->interval;
|
||||
interval.intervalUnit = pTSma->intervalUnit;
|
||||
interval.offset = pTSma->offset;
|
||||
interval.precision = REPO_CFG(pTsdb)->precision;
|
||||
interval.sliding = pTSma->sliding;
|
||||
interval.slidingUnit = pTSma->slidingUnit;
|
||||
pTSma = pSW->tSma;
|
||||
|
||||
interval.interval = pTSma->interval;
|
||||
interval.intervalUnit = pTSma->intervalUnit;
|
||||
interval.offset = pTSma->offset;
|
||||
interval.precision = REPO_CFG(pTsdb)->precision;
|
||||
interval.sliding = pTSma->sliding;
|
||||
interval.slidingUnit = pTSma->slidingUnit;
|
||||
}
|
||||
|
||||
TSKEY winSKey = taosTimeTruncate(TD_ROW_KEY(row), &interval, interval.precision);
|
||||
|
||||
tsdbSetExpiredWindow(pTsdb, pItemsHash, pTSma->indexUid, winSKey, version);
|
||||
|
||||
// TODO: release only when suid changes.
|
||||
tdDestroyTSmaWrapper(pSW);
|
||||
taosMemoryFreeClear(pSW);
|
||||
if (lastWinSKey != winSKey) {
|
||||
lastWinSKey = winSKey;
|
||||
tsdbSetExpiredWindow(pTsdb, pItemsHash, pTSma->indexUid, winSKey, version);
|
||||
} else {
|
||||
tsdbDebug("vgId:%d smaIndex %" PRIi64 ", put skey %" PRIi64 " to expire window ignore as duplicated",
|
||||
REPO_ID(pTsdb), pTSma->indexUid, winSKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
|
||||
// open tq
|
||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal, pVnode->pMeta, vBufPoolGetMAF(pVnode));
|
||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
||||
if (pVnode->pTq == NULL) {
|
||||
vError("vgId: %d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
|
|
|
@ -215,10 +215,21 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// TODO: remove the debug log
|
||||
SRSmaParam *param = vCreateTbReq.stbCfg.pRSmaParam;
|
||||
if (param) {
|
||||
printf("qmsg1 len = %d, body = %s\n", param->qmsg1 ? (int32_t)strlen(param->qmsg1) : 0,
|
||||
param->qmsg1 ? param->qmsg1 : "");
|
||||
printf("qmsg1 len = %d, body = %s\n", param->qmsg2 ? (int32_t)strlen(param->qmsg2) : 0,
|
||||
param->qmsg2 ? param->qmsg2 : "");
|
||||
}
|
||||
|
||||
taosMemoryFree(vCreateTbReq.stbCfg.pSchema);
|
||||
taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema);
|
||||
if (vCreateTbReq.stbCfg.pRSmaParam) {
|
||||
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->pFuncIds);
|
||||
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->qmsg1);
|
||||
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->qmsg2);
|
||||
taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam);
|
||||
}
|
||||
taosMemoryFree(vCreateTbReq.name);
|
||||
|
|
|
@ -104,6 +104,10 @@ typedef struct SCatalog {
|
|||
|
||||
typedef struct SCtgApiStat {
|
||||
|
||||
#ifdef WINDOWS
|
||||
size_t avoidCompilationErrors;
|
||||
#endif
|
||||
|
||||
} SCtgApiStat;
|
||||
|
||||
typedef struct SCtgRuntimeStat {
|
||||
|
|
|
@ -643,6 +643,49 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmt
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char *funcName, SFuncInfo **out) {
|
||||
char *msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
|
||||
ctgDebug("try to get udf info from mnode, funcName:%s", funcName);
|
||||
|
||||
int32_t code = queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)]((void *)funcName, &msg, 0, &msgLen);
|
||||
if (code) {
|
||||
ctgError("Build get udf msg failed, code:%x, db:%s", code, funcName);
|
||||
CTG_ERR_RET(code);
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
.msgType = TDMT_MND_RETRIEVE_FUNC,
|
||||
.pCont = msg,
|
||||
.contLen = msgLen,
|
||||
};
|
||||
|
||||
SRpcMsg rpcRsp = {0};
|
||||
|
||||
rpcSendRecv(pRpc, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||
if (TSDB_CODE_SUCCESS != rpcRsp.code) {
|
||||
if (TSDB_CODE_MND_FUNC_NOT_EXIST == rpcRsp.code) {
|
||||
ctgDebug("funcName %s not exist in mnode", funcName);
|
||||
taosMemoryFreeClear(*out);
|
||||
CTG_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
ctgError("error rsp for get udf, error:%s, funcName:%s", tstrerror(rpcRsp.code), funcName);
|
||||
CTG_ERR_RET(rpcRsp.code);
|
||||
}
|
||||
|
||||
code = queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)](*out, rpcRsp.pCont, rpcRsp.contLen);
|
||||
if (code) {
|
||||
ctgError("Process get udf rsp failed, code:%x, funcName:%s", code, funcName);
|
||||
CTG_ERR_RET(code);
|
||||
}
|
||||
|
||||
ctgDebug("Got udf from mnode, funcName:%s", funcName);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32_t *exist) {
|
||||
if (NULL == pCtg->dbCache) {
|
||||
|
@ -2811,6 +2854,30 @@ int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps,
|
|||
CTG_API_LEAVE(ctgGetIndexInfoFromMnode(pCtg, pRpc, pMgmtEps, indexName, pInfo));
|
||||
}
|
||||
|
||||
int32_t catalogGetUdfInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* funcName, SFuncInfo** pInfo) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == funcName || NULL == pInfo) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
*pInfo = taosMemoryMalloc(sizeof(SFuncInfo));
|
||||
if (NULL == *pInfo) {
|
||||
CTG_API_LEAVE(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetUdfInfoFromMnode(pCtg, pRpc, pMgmtEps, funcName, pInfo));
|
||||
|
||||
_return:
|
||||
|
||||
if (code) {
|
||||
taosMemoryFreeClear(*pInfo);
|
||||
}
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
|
||||
void catalogDestroy(void) {
|
||||
qInfo("start to destroy catalog");
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
#include <addr_any.h>
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define TD_USE_WINSOCK
|
||||
#endif
|
||||
#include "os.h"
|
||||
#include "tglobal.h"
|
||||
#include "catalog.h"
|
||||
|
@ -155,11 +158,11 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) {
|
|||
}
|
||||
|
||||
void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
|
||||
SName cn = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName cn = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(cn.dbname, "db1");
|
||||
strcpy(cn.tname, ctgTestCTablename);
|
||||
|
||||
SName sn = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName sn = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(sn.dbname, "db1");
|
||||
strcpy(sn.tname, ctgTestSTablename);
|
||||
|
||||
|
@ -577,9 +580,16 @@ void ctgTestSetRspDbVgroups() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspDbVgroups);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspDbVgroups);
|
||||
}
|
||||
|
@ -590,9 +600,16 @@ void ctgTestSetRspTableMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspTableMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspTableMeta);
|
||||
}
|
||||
|
@ -603,9 +620,16 @@ void ctgTestSetRspCTableMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspCTableMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspCTableMeta);
|
||||
}
|
||||
|
@ -616,9 +640,16 @@ void ctgTestSetRspSTableMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspSTableMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspSTableMeta);
|
||||
}
|
||||
|
@ -629,9 +660,16 @@ void ctgTestSetRspMultiSTableMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspMultiSTableMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspMultiSTableMeta);
|
||||
}
|
||||
|
@ -642,9 +680,16 @@ void ctgTestSetRspByIdx() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspByIdx);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspByIdx);
|
||||
}
|
||||
|
@ -656,9 +701,16 @@ void ctgTestSetRspDbVgroupsAndNormalMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndNormalMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspDbVgroupsAndNormalMeta);
|
||||
}
|
||||
|
@ -669,9 +721,16 @@ void ctgTestSetRspDbVgroupsAndChildMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndChildMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspDbVgroupsAndChildMeta);
|
||||
}
|
||||
|
@ -682,9 +741,16 @@ void ctgTestSetRspDbVgroupsAndSuperMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndSuperMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspDbVgroupsAndSuperMeta);
|
||||
}
|
||||
|
@ -695,9 +761,16 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() {
|
|||
static Stub stub;
|
||||
stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndMultiSuperMeta);
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
AddrAny any;
|
||||
std::map<std::string,void*> result;
|
||||
any.get_func_addr("rpcSendRecv", result);
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
AddrAny any("libtransport.so");
|
||||
std::map<std::string, void *> result;
|
||||
any.get_global_func_addr_dynsym("^rpcSendRecv$", result);
|
||||
#endif
|
||||
for (const auto &f : result) {
|
||||
stub.set(f.second, ctgTestRspDbVgroupsAndMultiSuperMeta);
|
||||
}
|
||||
|
@ -789,7 +862,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
|
|||
STableMeta *tbMeta = NULL;
|
||||
bool inCache = false;
|
||||
|
||||
SName cn = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName cn = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(cn.dbname, "db1");
|
||||
strcpy(cn.tname, ctgTestCTablename);
|
||||
|
||||
|
@ -871,7 +944,7 @@ TEST(tableMeta, normalTable) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -978,7 +1051,7 @@ TEST(tableMeta, childTableCase) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestCTablename);
|
||||
|
||||
|
@ -1085,7 +1158,7 @@ TEST(tableMeta, superTableCase) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestSTablename);
|
||||
|
||||
|
@ -1210,7 +1283,7 @@ TEST(tableMeta, rmStbMeta) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestSTablename);
|
||||
|
||||
|
@ -1280,7 +1353,7 @@ TEST(tableMeta, updateStbMeta) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestSTablename);
|
||||
|
||||
|
@ -1378,7 +1451,7 @@ TEST(refreshGetMeta, normal2normal) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -1457,7 +1530,7 @@ TEST(refreshGetMeta, normal2notexist) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -1529,7 +1602,7 @@ TEST(refreshGetMeta, normal2child) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
ctgTestCurrentCTableName = ctgTestTablename;
|
||||
|
@ -1613,7 +1686,7 @@ TEST(refreshGetMeta, stable2child) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
ctgTestCurrentSTableName = ctgTestTablename;
|
||||
|
@ -1699,7 +1772,7 @@ TEST(refreshGetMeta, stable2stable) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
ctgTestCurrentSTableName = ctgTestTablename;
|
||||
|
@ -1786,7 +1859,7 @@ TEST(refreshGetMeta, child2stable) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
ctgTestCurrentCTableName = ctgTestTablename;
|
||||
|
@ -1871,7 +1944,7 @@ TEST(tableDistVgroup, normalTable) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -1913,7 +1986,7 @@ TEST(tableDistVgroup, childTableCase) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestCTablename);
|
||||
|
||||
|
@ -1956,7 +2029,7 @@ TEST(tableDistVgroup, superTableCase) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestSTablename);
|
||||
|
||||
|
@ -2006,7 +2079,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -2091,7 +2164,7 @@ TEST(multiThread, getSetRmSameDbVgroup) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -2143,7 +2216,7 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -2195,7 +2268,7 @@ TEST(multiThread, ctableMeta) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
strcpy(n.tname, ctgTestTablename);
|
||||
|
||||
|
@ -2247,7 +2320,7 @@ TEST(rentTest, allRent) {
|
|||
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SName n = {.type = TSDB_TABLE_NAME_T, .acctId = 1};
|
||||
SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} };
|
||||
strcpy(n.dbname, "db1");
|
||||
|
||||
for (int32_t i = 1; i <= 10; ++i) {
|
||||
|
|
|
@ -382,7 +382,7 @@ typedef struct SSysTableScanInfo {
|
|||
void* pCur; // cursor for iterate the local table meta store.
|
||||
SArray* scanCols; // SArray<int16_t> scan column id list
|
||||
|
||||
int32_t type; // show type, TODO remove it
|
||||
// int32_t type; // show type, TODO remove it
|
||||
SName name;
|
||||
SSDataBlock* pRes;
|
||||
int32_t capacity;
|
||||
|
@ -479,7 +479,7 @@ typedef struct {
|
|||
|
||||
typedef struct SGroupbyOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SArray* pGroupCols;
|
||||
SArray* pGroupCols; // group by columns, SArray<SColumn>
|
||||
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
||||
SNode* pCondition;
|
||||
bool isInit; // denote if current val is initialized or not
|
||||
|
@ -600,7 +600,6 @@ typedef struct SJoinOperatorInfo {
|
|||
int32_t rightPos;
|
||||
SColumnInfo rightCol;
|
||||
SNode *pOnCondition;
|
||||
// SRspResultInfo resultInfo;
|
||||
} SJoinOperatorInfo;
|
||||
|
||||
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
|
||||
|
|
|
@ -1087,6 +1087,7 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
|||
pCtx[i].currentStage = MAIN_SCAN;
|
||||
|
||||
SInputColumnInfoData* pInput = &pCtx[i].input;
|
||||
pInput->uid = pBlock->info.uid;
|
||||
|
||||
SExprInfo* pOneExpr = &pOperator->pExpr[i];
|
||||
for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
|
||||
|
@ -1101,7 +1102,9 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
|||
pInput->pPTS = taosArrayGet(pBlock->pDataBlock, 0); // todo set the correct timestamp column
|
||||
ASSERT(pInput->pData[j] != NULL);
|
||||
} else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
|
||||
if (createDummyCol) {
|
||||
// todo avoid case: top(k, 12), 12 is the value parameter.
|
||||
// sum(11), 11 is also the value parameter.
|
||||
if (createDummyCol && pOneExpr->base.numOfParams == 1) {
|
||||
code = doCreateConstantValColumnInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
|
@ -1876,67 +1879,58 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
}
|
||||
}
|
||||
pCtx->resDataInfo.interBufSize = env.calcMemSize;
|
||||
} else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN || pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR || pExpr->pExpr->nodeType == QUERY_NODE_VALUE) {
|
||||
pCtx->resDataInfo.interBufSize = pFunct->resSchema.bytes; // for simple column, the intermediate buffer needs to hold one element.
|
||||
} else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN || pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR ||
|
||||
pExpr->pExpr->nodeType == QUERY_NODE_VALUE) {
|
||||
// for simple column, the intermediate buffer needs to hold one element.
|
||||
pCtx->resDataInfo.interBufSize = pFunct->resSchema.bytes;
|
||||
}
|
||||
|
||||
pCtx->input.numOfInputCols = pFunct->numOfParams;
|
||||
pCtx->input.pData = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
||||
pCtx->input.pColumnDataAgg = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
||||
|
||||
pCtx->pTsOutput = NULL;
|
||||
pCtx->pTsOutput = NULL;
|
||||
pCtx->resDataInfo.bytes = pFunct->resSchema.bytes;
|
||||
pCtx->resDataInfo.type = pFunct->resSchema.type;
|
||||
pCtx->order = TSDB_ORDER_ASC;
|
||||
pCtx->start.key = INT64_MIN;
|
||||
pCtx->end.key = INT64_MIN;
|
||||
#if 0
|
||||
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
||||
// int16_t type = pFunct->param[j].nType;
|
||||
// int16_t bytes = pFunct->param[j].nLen;
|
||||
pCtx->resDataInfo.type = pFunct->resSchema.type;
|
||||
pCtx->order = TSDB_ORDER_ASC;
|
||||
pCtx->start.key = INT64_MIN;
|
||||
pCtx->end.key = INT64_MIN;
|
||||
pCtx->numOfParams = pExpr->base.numOfParams;
|
||||
|
||||
// if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
||||
// taosVariantCreateFromBinary(&pCtx->param[j], pFunct->param[j].pz, bytes, type);
|
||||
// } else {
|
||||
// taosVariantCreateFromBinary(&pCtx->param[j], (char *)&pFunct->param[j].i, bytes, type);
|
||||
pCtx->param = pFunct->pParam;
|
||||
// for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
||||
// // set the order information for top/bottom query
|
||||
// int32_t functionId = pCtx->functionId;
|
||||
// if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
|
||||
// int32_t f = getExprFunctionId(&pExpr[0]);
|
||||
// assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY);
|
||||
//
|
||||
// // pCtx->param[2].i = pQueryAttr->order.order;
|
||||
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
// // pCtx->param[3].i = functionId;
|
||||
// // pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
//
|
||||
// // pCtx->param[1].i = pQueryAttr->order.col.info.colId;
|
||||
// } else if (functionId == FUNCTION_INTERP) {
|
||||
// // pCtx->param[2].i = (int8_t)pQueryAttr->fillType;
|
||||
// // if (pQueryAttr->fillVal != NULL) {
|
||||
// // if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)) {
|
||||
// // pCtx->param[1].nType = TSDB_DATA_TYPE_NULL;
|
||||
// // } else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value
|
||||
// // if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) {
|
||||
// // taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i], pCtx->inputBytes, pCtx->inputType);
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// } else if (functionId == FUNCTION_TWA) {
|
||||
// // pCtx->param[1].i = pQueryAttr->window.skey;
|
||||
// // pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
// // pCtx->param[2].i = pQueryAttr->window.ekey;
|
||||
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
// } else if (functionId == FUNCTION_ARITHM) {
|
||||
// // pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i);
|
||||
// }
|
||||
}
|
||||
|
||||
// set the order information for top/bottom query
|
||||
int32_t functionId = pCtx->functionId;
|
||||
if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
|
||||
int32_t f = getExprFunctionId(&pExpr[0]);
|
||||
assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY);
|
||||
|
||||
// pCtx->param[2].i = pQueryAttr->order.order;
|
||||
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pCtx->param[3].i = functionId;
|
||||
pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
|
||||
// pCtx->param[1].i = pQueryAttr->order.col.info.colId;
|
||||
} else if (functionId == FUNCTION_INTERP) {
|
||||
// pCtx->param[2].i = (int8_t)pQueryAttr->fillType;
|
||||
// if (pQueryAttr->fillVal != NULL) {
|
||||
// if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)) {
|
||||
// pCtx->param[1].nType = TSDB_DATA_TYPE_NULL;
|
||||
// } else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value
|
||||
// if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) {
|
||||
// taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i], pCtx->inputBytes, pCtx->inputType);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} else if (functionId == FUNCTION_TS_COMP) {
|
||||
// pCtx->param[0].i = pQueryAttr->vgId; //TODO this should be the parameter from client
|
||||
pCtx->param[0].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
} else if (functionId == FUNCTION_TWA) {
|
||||
// pCtx->param[1].i = pQueryAttr->window.skey;
|
||||
pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
// pCtx->param[2].i = pQueryAttr->window.ekey;
|
||||
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
} else if (functionId == FUNCTION_ARITHM) {
|
||||
// pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i);
|
||||
}
|
||||
#endif
|
||||
// }
|
||||
}
|
||||
|
||||
for (int32_t i = 1; i < numOfOutput; ++i) {
|
||||
|
@ -1955,7 +1949,7 @@ static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
|||
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
for (int32_t j = 0; j < pCtx[i].numOfParams; ++j) {
|
||||
taosVariantDestroy(&pCtx[i].param[j]);
|
||||
taosVariantDestroy(&pCtx[i].param[j].param);
|
||||
}
|
||||
|
||||
taosVariantDestroy(&pCtx[i].tag);
|
||||
|
@ -6487,9 +6481,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
|
||||
int32_t numOfCols = 0;
|
||||
tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||
if (pDataReader == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
|
|
|
@ -410,8 +410,8 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
int32_t contentLen = 0;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
int32_t* offset = pPage + startOffset;
|
||||
columnLen = pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity;
|
||||
int32_t* offset = (int32_t*)((char*)pPage + startOffset);
|
||||
columnLen = (char*)pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity;
|
||||
char* data = (char*)(columnLen + sizeof(int32_t));
|
||||
|
||||
if (colDataIsNull_s(pColInfoData, j)) {
|
||||
|
@ -424,8 +424,8 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
contentLen = varDataTLen(src);
|
||||
}
|
||||
} else {
|
||||
char* bitmap = pPage + startOffset;
|
||||
columnLen = pPage + startOffset + BitmapLen(pInfo->rowCapacity);
|
||||
char* bitmap = (char*)pPage + startOffset;
|
||||
columnLen = (char*)pPage + startOffset + BitmapLen(pInfo->rowCapacity);
|
||||
char* data = (char*) columnLen + sizeof(int32_t);
|
||||
|
||||
bool isNull = colDataIsNull_f(pColInfoData->nullbitmap, j);
|
||||
|
|
|
@ -319,7 +319,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
||||
// The read handle is not initialized yet, since no qualified tables exists
|
||||
if (pTableScanInfo->dataReader == NULL) {
|
||||
if (pTableScanInfo->dataReader == NULL || pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -375,10 +375,9 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
return p;
|
||||
}
|
||||
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput,
|
||||
int32_t dataLoadFlag, int32_t repeatTime, int32_t reverseTime,
|
||||
SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition,
|
||||
SInterval* pInterval, double sampleRatio, SExecTaskInfo* pTaskInfo) {
|
||||
SOperatorInfo* createTableScanOperatorInfo(void* pDataReader, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag,
|
||||
int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock,
|
||||
SNode* pCondition, SInterval* pInterval, double sampleRatio, SExecTaskInfo* pTaskInfo) {
|
||||
assert(repeatTime > 0);
|
||||
|
||||
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
||||
|
@ -391,19 +390,19 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->sampleRatio = sampleRatio;
|
||||
pInfo->dataBlockLoadFlag = dataLoadFlag;
|
||||
pInfo->pResBlock = pResBlock;
|
||||
pInfo->pFilterNode = pCondition;
|
||||
pInfo->dataReader = pTsdbReadHandle;
|
||||
pInfo->times = repeatTime;
|
||||
pInfo->reverseTimes = reverseTime;
|
||||
pInfo->order = order;
|
||||
pInfo->current = 0;
|
||||
pInfo->scanFlag = MAIN_SCAN;
|
||||
pInfo->pColMatchInfo = pColMatchInfo;
|
||||
pOperator->name = "TableScanOperator";
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->sampleRatio = sampleRatio;
|
||||
pInfo->dataBlockLoadFlag= dataLoadFlag;
|
||||
pInfo->pResBlock = pResBlock;
|
||||
pInfo->pFilterNode = pCondition;
|
||||
pInfo->dataReader = pDataReader;
|
||||
pInfo->times = repeatTime;
|
||||
pInfo->reverseTimes = reverseTime;
|
||||
pInfo->order = order;
|
||||
pInfo->current = 0;
|
||||
pInfo->scanFlag = MAIN_SCAN;
|
||||
pInfo->pColMatchInfo = pColMatchInfo;
|
||||
pOperator->name = "TableScanOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
||||
pOperator->blockingOptr = false;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
|
@ -561,7 +560,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
|||
SArray* pCols = NULL;
|
||||
uint64_t groupId;
|
||||
int32_t numOfRows;
|
||||
int32_t code = tqRetrieveDataBlock(&pCols, pInfo->readerHandle, &groupId, &numOfRows);
|
||||
int16_t outputCol;
|
||||
int32_t code = tqRetrieveDataBlock(&pCols, pInfo->readerHandle, &groupId, &numOfRows, &outputCol);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS || numOfRows == 0) {
|
||||
pTaskInfo->code = code;
|
||||
|
@ -677,7 +677,8 @@ static void destroySysScanOperator(void* param, int32_t numOfOutput) {
|
|||
tsem_destroy(&pInfo->ready);
|
||||
blockDataDestroy(pInfo->pRes);
|
||||
|
||||
if (pInfo->type == TSDB_MGMT_TABLE_TABLE) {
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
metaCloseTbCursor(pInfo->pCur);
|
||||
}
|
||||
}
|
||||
|
@ -812,7 +813,8 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
SSysTableScanInfo* pInfo = pOperator->info;
|
||||
|
||||
// retrieve local table list info from vnode
|
||||
if (pInfo->type == TSDB_MGMT_TABLE_TABLE) {
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
if (pInfo->pCur == NULL) {
|
||||
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle);
|
||||
}
|
||||
|
@ -864,8 +866,6 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
|
||||
while (1) {
|
||||
int64_t startTs = taosGetTimestampUs();
|
||||
|
||||
pInfo->req.type = pInfo->type;
|
||||
strncpy(pInfo->req.tb, tNameGetTableName(&pInfo->name), tListLen(pInfo->req.tb));
|
||||
|
||||
if (pInfo->showRewrite) {
|
||||
|
@ -947,68 +947,9 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
|||
pInfo->pCondition = pCondition;
|
||||
pInfo->scanCols = colList;
|
||||
|
||||
// TODO remove it
|
||||
int32_t tableType = 0;
|
||||
const char* name = tNameGetTableName(pName);
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_DNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_DNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_MNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_MODULE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_QNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_BNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_BNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CLUSTER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_DB;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_FUNCTIONS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_FUNC;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_INDEXES, tListLen(pName->tname)) == 0) {
|
||||
// tableType = TSDB_MGMT_TABLE_INDEX;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_STABLES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_STB;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_STREAMS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_STREAMS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_TABLE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, tListLen(pName->tname)) == 0) {
|
||||
// tableType = TSDB_MGMT_TABLE_DIST;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_USER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_GRANTS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_VGROUP;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_TOPICS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONSUMERS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CONSUMERS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIBES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SUBSCRIBES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TRANS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_TRANS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SMAS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SMAS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CONFIGS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONNS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CONNS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QUERIES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_QUERIES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_VNODES;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
tNameAssign(&pInfo->name, pName);
|
||||
pInfo->type = tableType;
|
||||
if (pInfo->type == TSDB_MGMT_TABLE_TABLE) {
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
pInfo->readHandle = pSysTableReadHandle;
|
||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->capacity);
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,7 @@ struct SSHashObj {
|
|||
};
|
||||
|
||||
static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
||||
int32_t len = MIN(length, HASH_MAX_CAPACITY);
|
||||
int32_t len = (length < HASH_MAX_CAPACITY ? length : HASH_MAX_CAPACITY);
|
||||
|
||||
int32_t i = 4;
|
||||
while (i < len) i = (i << 1u);
|
||||
|
@ -127,7 +127,7 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
|
|||
}
|
||||
|
||||
size_t inc = newCapacity - pHashObj->capacity;
|
||||
memset(pNewEntryList + pHashObj->capacity * sizeof(void*), 0, inc);
|
||||
memset((char*)pNewEntryList + pHashObj->capacity * sizeof(void*), 0, inc);
|
||||
|
||||
pHashObj->hashList = pNewEntryList;
|
||||
pHashObj->capacity = newCapacity;
|
||||
|
@ -301,7 +301,7 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj) {
|
|||
|
||||
void *tSimpleHashGetKey(const SSHashObj* pHashObj, void *data, size_t* keyLen) {
|
||||
int32_t offset = offsetof(SHNode, data);
|
||||
SHNode *node = data - offset;
|
||||
SHNode *node = ((SHNode*)(char*)data - offset);
|
||||
if (keyLen != NULL) {
|
||||
*keyLen = pHashObj->keyLen;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ SSDataBlock* getDummyBlock(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
} else if (pInfo->type == data_asc) {
|
||||
v = ++pInfo->startVal;
|
||||
} else if (pInfo->type == data_rand) {
|
||||
v = random();
|
||||
v = taosRand();
|
||||
}
|
||||
|
||||
colDataAppend(pColInfo, i, reinterpret_cast<const char*>(&v), false);
|
||||
|
@ -172,7 +172,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
} else if (pInfo->type == data_asc) {
|
||||
v = ++pInfo->startVal;
|
||||
} else if (pInfo->type == data_rand) {
|
||||
v = random();
|
||||
v = taosRand();
|
||||
}
|
||||
|
||||
colDataAppend(pColInfo1, i, reinterpret_cast<const char*>(&v), false);
|
||||
|
@ -938,7 +938,7 @@ TEST(testCase, build_executor_tree_Test) {
|
|||
|
||||
SExecTaskInfo* pTaskInfo = nullptr;
|
||||
DataSinkHandle sinkHandle = nullptr;
|
||||
SReadHandle handle = {.reader = reinterpret_cast<void*>(0x1), .meta = reinterpret_cast<void*>(0x1)};
|
||||
SReadHandle handle = { reinterpret_cast<void*>(0x1), reinterpret_cast<void*>(0x1), NULL };
|
||||
|
||||
struct SSubplan *plan = NULL;
|
||||
int32_t code = qStringToSubplan(msg, &plan);
|
||||
|
|
|
@ -47,6 +47,9 @@ target_include_directories(
|
|||
"${TD_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
udf1 PUBLIC os
|
||||
)
|
||||
|
||||
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
||||
add_executable(udfd src/udfd.c)
|
||||
|
|
|
@ -63,6 +63,9 @@ bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
|||
int32_t firstFunction(SqlFunctionCtx *pCtx);
|
||||
int32_t lastFunction(SqlFunctionCtx *pCtx);
|
||||
|
||||
bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
||||
int32_t topFunction(SqlFunctionCtx *pCtx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -21,47 +21,38 @@
|
|||
#include <stdbool.h>
|
||||
#include "tmsg.h"
|
||||
#include "tcommon.h"
|
||||
#include "function.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UDF_LISTEN_PIPE_NAME_LEN 32
|
||||
#define UDF_LISTEN_PIPE_NAME_PREFIX "udf.sock."
|
||||
#define UDF_LISTEN_PIPE_NAME_PREFIX "udfd.sock."
|
||||
|
||||
//======================================================================================
|
||||
//begin API to taosd and qworker
|
||||
|
||||
enum {
|
||||
UDFC_CODE_STOPPING = -1,
|
||||
UDFC_CODE_RESTARTING = -2,
|
||||
UDFC_CODE_PIPE_READ_ERR = -3,
|
||||
};
|
||||
|
||||
/*TODO: no api for dnode startudfd/stopudfd*/
|
||||
/**
|
||||
* start udfd dameon service
|
||||
*/
|
||||
int32_t startUdfd(int32_t dnodeId);
|
||||
|
||||
/**
|
||||
* stop udfd dameon service
|
||||
*/
|
||||
int32_t stopUdfd(int32_t dnodeId);
|
||||
typedef void *UdfcHandle;
|
||||
typedef void *UdfcFuncHandle;
|
||||
|
||||
/**
|
||||
* create udfd proxy, called once in process that call setupUdf/callUdfxxx/teardownUdf
|
||||
* @return error code
|
||||
*/
|
||||
int32_t createUdfdProxy(int32_t dnodeId);
|
||||
int32_t udfcOpen(int32_t dnodeId, UdfcHandle* proxyHandle);
|
||||
|
||||
/**
|
||||
* destroy udfd proxy
|
||||
* @return error code
|
||||
*/
|
||||
int32_t destroyUdfdProxy(int32_t dnodeId);
|
||||
int32_t udfcClose(UdfcHandle proxyhandle);
|
||||
|
||||
typedef void *UdfHandle;
|
||||
|
||||
/**
|
||||
* setup udf
|
||||
|
@ -69,7 +60,7 @@ typedef void *UdfHandle;
|
|||
* @param handle, out
|
||||
* @return error code
|
||||
*/
|
||||
int32_t setupUdf(char udfName[], SEpSet *epSet, UdfHandle *handle);
|
||||
int32_t setupUdf(UdfcHandle proxyHandle, char udfName[], SEpSet *epSet, UdfcFuncHandle *handle);
|
||||
|
||||
typedef struct SUdfColumnMeta {
|
||||
int16_t type;
|
||||
|
@ -116,26 +107,25 @@ typedef struct SUdfInterBuf {
|
|||
} SUdfInterBuf;
|
||||
|
||||
// output: interBuf
|
||||
int32_t callUdfAggInit(UdfHandle handle, SUdfInterBuf *interBuf);
|
||||
int32_t callUdfAggInit(UdfcFuncHandle handle, SUdfInterBuf *interBuf);
|
||||
// input: block, state
|
||||
// output: newState
|
||||
int32_t callUdfAggProcess(UdfHandle handle, SSDataBlock *block, SUdfInterBuf *state, SUdfInterBuf *newState);
|
||||
int32_t callUdfAggProcess(UdfcFuncHandle handle, SSDataBlock *block, SUdfInterBuf *state, SUdfInterBuf *newState);
|
||||
// input: interBuf
|
||||
// output: resultData
|
||||
int32_t callUdfAggFinalize(UdfHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData);
|
||||
int32_t callUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData);
|
||||
// input: interbuf1, interbuf2
|
||||
// output: resultBuf
|
||||
int32_t callUdfAggMerge(UdfHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf);
|
||||
int32_t callUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf);
|
||||
// input: block
|
||||
// output: resultData
|
||||
int32_t callUdfScalaProcess(UdfHandle handle, SSDataBlock *block, SSDataBlock *resultData);
|
||||
|
||||
int32_t callUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output);
|
||||
/**
|
||||
* tearn down udf
|
||||
* @param handle
|
||||
* @return
|
||||
*/
|
||||
int32_t teardownUdf(UdfHandle handle);
|
||||
int32_t teardownUdf(UdfcFuncHandle handle);
|
||||
|
||||
// end API to taosd and qworker
|
||||
//=============================================================================================================================
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue