Merge branch 'main' into fix/td-21029
This commit is contained in:
commit
cb8cd5f733
|
@ -123,21 +123,37 @@ ELSE ()
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_INTEL_64 OR TD_INTEL_32)
|
INCLUDE(CheckCCompilerFlag)
|
||||||
ADD_DEFINITIONS("-msse4.2")
|
IF (("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") OR ("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang"))
|
||||||
IF("${FMA_SUPPORT}" MATCHES "true")
|
SET(COMPILER_SUPPORT_SSE42 true)
|
||||||
MESSAGE(STATUS "fma function supported")
|
MESSAGE(STATUS "Always enable sse4.2 for Clang/AppleClang")
|
||||||
ADD_DEFINITIONS("-mfma")
|
|
||||||
ELSE()
|
ELSE()
|
||||||
MESSAGE(STATUS "fma function NOT supported")
|
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
CHECK_C_COMPILER_FLAG("-mfma" COMPILER_SUPPORT_FMA)
|
||||||
|
CHECK_C_COMPILER_FLAG("-mavx" COMPILER_SUPPORT_AVX)
|
||||||
|
CHECK_C_COMPILER_FLAG("-mavx2" COMPILER_SUPPORT_AVX2)
|
||||||
|
|
||||||
|
IF (COMPILER_SUPPORT_SSE42)
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
|
||||||
|
ENDIF()
|
||||||
|
IF (COMPILER_SUPPORT_FMA)
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
||||||
ADD_DEFINITIONS("-mavx -mavx2")
|
IF (COMPILER_SUPPORT_AVX)
|
||||||
MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||||
ELSE()
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||||
MESSAGE(STATUS "SIMD instruction (AVX/AVX2)is NOT ACTIVATED")
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
IF (COMPILER_SUPPORT_AVX2)
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
||||||
|
ENDIF()
|
||||||
|
MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
|
@ -147,7 +147,7 @@ ELSE ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
MESSAGE(STATUS "platform arch:" ${PLATFORM_ARCH_STR})
|
MESSAGE(STATUS "Platform arch:" ${PLATFORM_ARCH_STR})
|
||||||
|
|
||||||
MESSAGE("C Compiler: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID}, ${CMAKE_C_COMPILER_VERSION})")
|
MESSAGE("C Compiler: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID}, ${CMAKE_C_COMPILER_VERSION})")
|
||||||
MESSAGE("CXX Compiler: ${CMAKE_CXX_COMPILER} (${CMAKE_C_COMPILER_ID}, ${CMAKE_CXX_COMPILER_VERSION})")
|
MESSAGE("CXX Compiler: ${CMAKE_CXX_COMPILER} (${CMAKE_C_COMPILER_ID}, ${CMAKE_CXX_COMPILER_VERSION})")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
IF (DEFINED VERNUMBER)
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_NUMBER "3.0.1.8")
|
SET(TD_VER_NUMBER "3.0.2.0")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERCOMPATIBLE)
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
|
|
|
@ -76,7 +76,7 @@ Development: false
|
||||||
### Install from source code
|
### Install from source code
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com:taosdata/kafka-connect-tdengine.git
|
git clone https://github.com/taosdata/kafka-connect-tdengine.git
|
||||||
cd kafka-connect-tdengine
|
cd kafka-connect-tdengine
|
||||||
mvn clean package
|
mvn clean package
|
||||||
unzip -d $CONFLUENT_HOME/share/java/ target/components/packages/taosdata-kafka-connect-tdengine-*.zip
|
unzip -d $CONFLUENT_HOME/share/java/ target/components/packages/taosdata-kafka-connect-tdengine-*.zip
|
||||||
|
|
|
@ -79,7 +79,7 @@ Development: false
|
||||||
### 从源码安装
|
### 从源码安装
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com:taosdata/kafka-connect-tdengine.git
|
git clone https://github.com/taosdata/kafka-connect-tdengine.git
|
||||||
cd kafka-connect-tdengine
|
cd kafka-connect-tdengine
|
||||||
mvn clean package
|
mvn clean package
|
||||||
unzip -d $CONFLUENT_HOME/share/java/ target/components/packages/taosdata-kafka-connect-tdengine-*.zip
|
unzip -d $CONFLUENT_HOME/share/java/ target/components/packages/taosdata-kafka-connect-tdengine-*.zip
|
||||||
|
|
|
@ -3,19 +3,13 @@ PROJECT(TDengine)
|
||||||
IF (TD_LINUX)
|
IF (TD_LINUX)
|
||||||
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
||||||
AUX_SOURCE_DIRECTORY(. SRC)
|
AUX_SOURCE_DIRECTORY(. SRC)
|
||||||
# ADD_EXECUTABLE(demo apitest.c)
|
|
||||||
#TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread )
|
|
||||||
#ADD_EXECUTABLE(sml schemaless.c)
|
|
||||||
#TARGET_LINK_LIBRARIES(sml taos_static trpc tutil pthread )
|
|
||||||
#ADD_EXECUTABLE(subscribe subscribe.c)
|
|
||||||
#TARGET_LINK_LIBRARIES(subscribe taos_static trpc tutil pthread )
|
|
||||||
#ADD_EXECUTABLE(epoll epoll.c)
|
|
||||||
#TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread lua)
|
|
||||||
|
|
||||||
add_executable(tmq "")
|
add_executable(tmq "")
|
||||||
add_executable(stream_demo "")
|
add_executable(stream_demo "")
|
||||||
add_executable(demoapi "")
|
add_executable(schemaless "")
|
||||||
add_executable(api_reqid "")
|
add_executable(prepare "")
|
||||||
|
add_executable(demo "")
|
||||||
|
add_executable(asyncdemo "")
|
||||||
|
|
||||||
target_sources(tmq
|
target_sources(tmq
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
@ -27,16 +21,25 @@ IF (TD_LINUX)
|
||||||
"stream_demo.c"
|
"stream_demo.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(demoapi
|
target_sources(schemaless
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"demoapi.c"
|
"schemaless.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(api_reqid
|
target_sources(prepare
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"api_with_reqid_test.c"
|
"prepare.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_sources(demo
|
||||||
|
PRIVATE
|
||||||
|
"demo.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(asyncdemo
|
||||||
|
PRIVATE
|
||||||
|
"asyncdemo.c"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(tmq
|
target_link_libraries(tmq
|
||||||
taos_static
|
taos_static
|
||||||
|
@ -46,46 +49,30 @@ IF (TD_LINUX)
|
||||||
taos_static
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(demoapi
|
target_link_libraries(schemaless
|
||||||
taos_static
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(api_reqid
|
target_link_libraries(prepare
|
||||||
taos_static
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(demo
|
||||||
target_include_directories(tmq
|
taos_static
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(stream_demo
|
target_link_libraries(asyncdemo
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
taos_static
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(demoapi
|
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(api_reqid
|
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
||||||
SET_TARGET_PROPERTIES(stream_demo PROPERTIES OUTPUT_NAME stream_demo)
|
SET_TARGET_PROPERTIES(stream_demo PROPERTIES OUTPUT_NAME stream_demo)
|
||||||
SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi)
|
SET_TARGET_PROPERTIES(schemaless PROPERTIES OUTPUT_NAME schemaless)
|
||||||
SET_TARGET_PROPERTIES(api_reqid PROPERTIES OUTPUT_NAME api_reqid)
|
SET_TARGET_PROPERTIES(prepare PROPERTIES OUTPUT_NAME prepare)
|
||||||
|
SET_TARGET_PROPERTIES(demo PROPERTIES OUTPUT_NAME demo)
|
||||||
|
SET_TARGET_PROPERTIES(asyncdemo PROPERTIES OUTPUT_NAME asyncdemo)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
IF (TD_DARWIN)
|
IF (TD_DARWIN)
|
||||||
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
||||||
AUX_SOURCE_DIRECTORY(. SRC)
|
AUX_SOURCE_DIRECTORY(. SRC)
|
||||||
#ADD_EXECUTABLE(demo demo.c)
|
|
||||||
#TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread lua)
|
|
||||||
#ADD_EXECUTABLE(epoll epoll.c)
|
|
||||||
#TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread lua)
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
1948
examples/c/apitest.c
1948
examples/c/apitest.c
File diff suppressed because it is too large
Load Diff
|
@ -23,8 +23,8 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include "../../../include/client/taos.h"
|
#include "taos.h"
|
||||||
|
|
||||||
int points = 5;
|
int points = 5;
|
||||||
int numOfTables = 3;
|
int numOfTables = 3;
|
||||||
|
@ -230,7 +230,7 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code)
|
||||||
if (tablesInsertProcessed >= numOfTables) {
|
if (tablesInsertProcessed >= numOfTables) {
|
||||||
gettimeofday(&systemTime, NULL);
|
gettimeofday(&systemTime, NULL);
|
||||||
et = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
|
et = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
|
||||||
printf("%lld mseconds to insert %d data points\n", (et - st) / 1000, points*numOfTables);
|
printf("%" PRId64 " mseconds to insert %d data points\n", (et - st) / 1000, points*numOfTables);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows)
|
||||||
if (tablesSelectProcessed >= numOfTables) {
|
if (tablesSelectProcessed >= numOfTables) {
|
||||||
gettimeofday(&systemTime, NULL);
|
gettimeofday(&systemTime, NULL);
|
||||||
et = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
|
et = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
|
||||||
printf("%lld mseconds to query %d data rows\n", (et - st) / 1000, points * numOfTables);
|
printf("%" PRId64 " mseconds to query %d data rows\n", (et - st) / 1000, points * numOfTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_free_result(tres);
|
taos_free_result(tres);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../../../include/client/taos.h" // TAOS header file
|
#include "taos.h" // TAOS header file
|
||||||
|
|
||||||
static void queryDB(TAOS *taos, char *command) {
|
static void queryDB(TAOS *taos, char *command) {
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -1,304 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// how to use to do a pressure-test upon eok
|
|
||||||
// tester: cat /dev/urandom | nc -c <ip> <port>
|
|
||||||
// testee: ./debug/build/bin/epoll -l <port> > /dev/null
|
|
||||||
// compare against: nc -l <port> > /dev/null
|
|
||||||
// monitor and compare : glances
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include "osEok.h"
|
|
||||||
#else // __APPLE__
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
#endif // __APPLE__
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
|
|
||||||
#define D(fmt, ...) fprintf(stderr, "%s[%d]%s(): " fmt "\n", basename(__FILE__), __LINE__, __func__, ##__VA_ARGS__)
|
|
||||||
#define A(statement, fmt, ...) do { \
|
|
||||||
if (statement) break; \
|
|
||||||
fprintf(stderr, "%s[%d]%s(): assert [%s] failed: %d[%s]: " fmt "\n", \
|
|
||||||
basename(__FILE__), __LINE__, __func__, \
|
|
||||||
#statement, errno, strerror(errno), \
|
|
||||||
##__VA_ARGS__); \
|
|
||||||
abort(); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define E(fmt, ...) do { \
|
|
||||||
fprintf(stderr, "%s[%d]%s(): %d[%s]: " fmt "\n", \
|
|
||||||
basename(__FILE__), __LINE__, __func__, \
|
|
||||||
errno, strerror(errno), \
|
|
||||||
##__VA_ARGS__); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#include "os.h"
|
|
||||||
|
|
||||||
typedef struct ep_s ep_t;
|
|
||||||
struct ep_s {
|
|
||||||
int ep;
|
|
||||||
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
int sv[2]; // 0 for read, 1 for write;
|
|
||||||
pthread_t thread;
|
|
||||||
|
|
||||||
volatile unsigned int stopping:1;
|
|
||||||
volatile unsigned int waiting:1;
|
|
||||||
volatile unsigned int wakenup:1;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int ep_dummy = 0;
|
|
||||||
|
|
||||||
static ep_t* ep_create(void);
|
|
||||||
static void ep_destroy(ep_t *ep);
|
|
||||||
static void* routine(void* arg);
|
|
||||||
static int open_listen(unsigned short port);
|
|
||||||
|
|
||||||
typedef struct fde_s fde_t;
|
|
||||||
struct fde_s {
|
|
||||||
int skt;
|
|
||||||
void (*on_event)(ep_t *ep, struct epoll_event *events, fde_t *client);
|
|
||||||
};
|
|
||||||
|
|
||||||
static void listen_event(ep_t *ep, struct epoll_event *ev, fde_t *client);
|
|
||||||
static void null_event(ep_t *ep, struct epoll_event *ev, fde_t *client);
|
|
||||||
|
|
||||||
#define usage(arg0, fmt, ...) do { \
|
|
||||||
if (fmt[0]) { \
|
|
||||||
fprintf(stderr, "" fmt "\n", ##__VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
fprintf(stderr, "usage:\n"); \
|
|
||||||
fprintf(stderr, " %s -l <port> : specify listenning port\n", arg0); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
char *prg = basename(argv[0]);
|
|
||||||
if (argc==1) {
|
|
||||||
usage(prg, "");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ep_t* ep = ep_create();
|
|
||||||
A(ep, "failed");
|
|
||||||
for (int i=1; i<argc; ++i) {
|
|
||||||
const char *arg = argv[i];
|
|
||||||
if (0==strcmp(arg, "-l")) {
|
|
||||||
++i;
|
|
||||||
if (i>=argc) {
|
|
||||||
usage(prg, "expecting <port> after -l, but got nothing");
|
|
||||||
return 1; // confirmed potential leakage
|
|
||||||
}
|
|
||||||
arg = argv[i];
|
|
||||||
int port = atoi(arg);
|
|
||||||
int skt = open_listen(port);
|
|
||||||
if (skt==-1) continue;
|
|
||||||
fde_t *client = (fde_t*)calloc(1, sizeof(*client));
|
|
||||||
if (!client) {
|
|
||||||
E("out of memory");
|
|
||||||
close(skt);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
client->skt = skt;
|
|
||||||
client->on_event = listen_event;
|
|
||||||
struct epoll_event ev = {0};
|
|
||||||
ev.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLRDHUP;
|
|
||||||
ev.data.ptr = client;
|
|
||||||
A(0==epoll_ctl(ep->ep, EPOLL_CTL_ADD, skt, &ev), "");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
usage(prg, "unknown argument: [%s]", arg);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
char *line = NULL;
|
|
||||||
size_t linecap = 0;
|
|
||||||
ssize_t linelen;
|
|
||||||
while ((linelen = getline(&line, &linecap, stdin)) > 0) {
|
|
||||||
line[strlen(line)-1] = '\0';
|
|
||||||
if (0==strcmp(line, "exit")) break;
|
|
||||||
if (0==strcmp(line, "quit")) break;
|
|
||||||
if (line==strstr(line, "close")) {
|
|
||||||
int fd = 0;
|
|
||||||
sscanf(line, "close %d", &fd);
|
|
||||||
if (fd<=2) {
|
|
||||||
fprintf(stderr, "fd [%d] invalid\n", fd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
A(0==epoll_ctl(ep->ep, EPOLL_CTL_DEL, fd, NULL), "");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strlen(line)==0) continue;
|
|
||||||
fprintf(stderr, "unknown cmd:[%s]\n", line);
|
|
||||||
}
|
|
||||||
ep_destroy(ep);
|
|
||||||
D("");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ep_t* ep_create(void) {
|
|
||||||
ep_t *ep = (ep_t*)calloc(1, sizeof(*ep));
|
|
||||||
A(ep, "out of memory");
|
|
||||||
A(-1!=(ep->ep = epoll_create(1)), "");
|
|
||||||
ep->sv[0] = -1;
|
|
||||||
ep->sv[1] = -1;
|
|
||||||
A(0==socketpair(AF_LOCAL, SOCK_STREAM, 0, ep->sv), "");
|
|
||||||
A(0==pthread_mutex_init(&ep->lock, NULL), "");
|
|
||||||
A(0==pthread_mutex_lock(&ep->lock), "");
|
|
||||||
struct epoll_event ev = {0};
|
|
||||||
ev.events = EPOLLIN;
|
|
||||||
ev.data.ptr = &ep_dummy;
|
|
||||||
A(0==epoll_ctl(ep->ep, EPOLL_CTL_ADD, ep->sv[0], &ev), "");
|
|
||||||
A(0==pthread_create(&ep->thread, NULL, routine, ep), "");
|
|
||||||
A(0==pthread_mutex_unlock(&ep->lock), "");
|
|
||||||
return ep;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ep_destroy(ep_t *ep) {
|
|
||||||
A(ep, "invalid argument");
|
|
||||||
ep->stopping = 1;
|
|
||||||
A(1==send(ep->sv[1], "1", 1, 0), "");
|
|
||||||
A(0==pthread_join(ep->thread, NULL), "");
|
|
||||||
A(0==pthread_mutex_destroy(&ep->lock), "");
|
|
||||||
A(0==close(ep->sv[0]), "");
|
|
||||||
A(0==close(ep->sv[1]), "");
|
|
||||||
A(0==close(ep->ep), "");
|
|
||||||
free(ep);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* routine(void* arg) {
|
|
||||||
A(arg, "invalid argument");
|
|
||||||
ep_t *ep = (ep_t*)arg;
|
|
||||||
|
|
||||||
while (!ep->stopping) {
|
|
||||||
struct epoll_event evs[10];
|
|
||||||
memset(evs, 0, sizeof(evs));
|
|
||||||
|
|
||||||
A(0==pthread_mutex_lock(&ep->lock), "");
|
|
||||||
A(ep->waiting==0, "internal logic error");
|
|
||||||
ep->waiting = 1;
|
|
||||||
A(0==pthread_mutex_unlock(&ep->lock), "");
|
|
||||||
|
|
||||||
int r = epoll_wait(ep->ep, evs, sizeof(evs)/sizeof(evs[0]), -1);
|
|
||||||
A(r>0, "indefinite epoll_wait shall not timeout:[%d]", r);
|
|
||||||
|
|
||||||
A(0==pthread_mutex_lock(&ep->lock), "");
|
|
||||||
A(ep->waiting==1, "internal logic error");
|
|
||||||
ep->waiting = 0;
|
|
||||||
A(0==pthread_mutex_unlock(&ep->lock), "");
|
|
||||||
|
|
||||||
for (int i=0; i<r; ++i) {
|
|
||||||
struct epoll_event *ev = evs + i;
|
|
||||||
if (ev->data.ptr == &ep_dummy) {
|
|
||||||
char c = '\0';
|
|
||||||
A(1==recv(ep->sv[0], &c, 1, 0), "internal logic error");
|
|
||||||
A(0==pthread_mutex_lock(&ep->lock), "");
|
|
||||||
ep->wakenup = 0;
|
|
||||||
A(0==pthread_mutex_unlock(&ep->lock), "");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
A(ev->data.ptr, "internal logic error");
|
|
||||||
fde_t *client = (fde_t*)ev->data.ptr;
|
|
||||||
client->on_event(ep, ev, client);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_listen(unsigned short port) {
|
|
||||||
int r = 0;
|
|
||||||
int skt = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
||||||
if (skt==-1) {
|
|
||||||
E("socket() failed");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
struct sockaddr_in si = {0};
|
|
||||||
si.sin_family = AF_INET;
|
|
||||||
si.sin_addr.s_addr = inet_addr("0.0.0.0");
|
|
||||||
si.sin_port = htons(port);
|
|
||||||
r = bind(skt, (struct sockaddr*)&si, sizeof(si));
|
|
||||||
if (r) {
|
|
||||||
E("bind(%u) failed", port);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
r = listen(skt, 100);
|
|
||||||
if (r) {
|
|
||||||
E("listen() failed");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memset(&si, 0, sizeof(si));
|
|
||||||
socklen_t len = sizeof(si);
|
|
||||||
r = getsockname(skt, (struct sockaddr *)&si, &len);
|
|
||||||
if (r) {
|
|
||||||
E("getsockname() failed");
|
|
||||||
}
|
|
||||||
A(len==sizeof(si), "internal logic error");
|
|
||||||
D("listenning at: %d", ntohs(si.sin_port));
|
|
||||||
return skt;
|
|
||||||
} while (0);
|
|
||||||
close(skt);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void listen_event(ep_t *ep, struct epoll_event *ev, fde_t *client) {
|
|
||||||
A(ev->events & EPOLLIN, "internal logic error");
|
|
||||||
struct sockaddr_in si = {0};
|
|
||||||
socklen_t silen = sizeof(si);
|
|
||||||
int skt = accept(client->skt, (struct sockaddr*)&si, &silen);
|
|
||||||
A(skt!=-1, "internal logic error");
|
|
||||||
fde_t *server = (fde_t*)calloc(1, sizeof(*server));
|
|
||||||
if (!server) {
|
|
||||||
close(skt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
server->skt = skt;
|
|
||||||
server->on_event = null_event;
|
|
||||||
struct epoll_event ee = {0};
|
|
||||||
ee.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLRDHUP;
|
|
||||||
ee.data.ptr = server;
|
|
||||||
A(0==epoll_ctl(ep->ep, EPOLL_CTL_ADD, skt, &ee), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void null_event(ep_t *ep, struct epoll_event *ev, fde_t *client) {
|
|
||||||
if (ev->events & EPOLLIN) {
|
|
||||||
char buf[8192];
|
|
||||||
int n = recv(client->skt, buf, sizeof(buf), 0);
|
|
||||||
A(n>=0 && n<=sizeof(buf), "internal logic error:[%d]", n);
|
|
||||||
A(n==fwrite(buf, 1, n, stdout), "internal logic error");
|
|
||||||
}
|
|
||||||
if (ev->events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) {
|
|
||||||
A(0==pthread_mutex_lock(&ep->lock), "");
|
|
||||||
A(0==epoll_ctl(ep->ep, EPOLL_CTL_DEL, client->skt, NULL), "");
|
|
||||||
A(0==pthread_mutex_unlock(&ep->lock), "");
|
|
||||||
close(client->skt);
|
|
||||||
client->skt = -1;
|
|
||||||
client->on_event = NULL;
|
|
||||||
free(client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,22 +7,21 @@ LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt
|
||||||
CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \
|
CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \
|
||||||
-Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \
|
-Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \
|
||||||
-Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \
|
-Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \
|
||||||
-I../../../deps/cJson/inc
|
-I/usr/local/include/cjson
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
exe:
|
exe:
|
||||||
gcc $(CFLAGS) ./asyncdemo.c -o $(ROOT)asyncdemo $(LFLAGS)
|
gcc $(CFLAGS) ./asyncdemo.c -o $(ROOT)asyncdemo $(LFLAGS)
|
||||||
gcc $(CFLAGS) ./demo.c -o $(ROOT)demo $(LFLAGS)
|
gcc $(CFLAGS) ./demo.c -o $(ROOT)demo $(LFLAGS)
|
||||||
gcc $(CFLAGS) ./prepare.c -o $(ROOT)prepare $(LFLAGS)
|
gcc $(CFLAGS) ./prepare.c -o $(ROOT)prepare $(LFLAGS)
|
||||||
gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS)
|
gcc $(CFLAGS) ./stream_demo.c -o $(ROOT)stream_demo $(LFLAGS)
|
||||||
gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS)
|
gcc $(CFLAGS) ./tmq.c -o $(ROOT)tmq $(LFLAGS)
|
||||||
gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS)
|
gcc $(CFLAGS) ./schemaless.c -o $(ROOT)schemaless $(LFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(ROOT)asyncdemo
|
rm $(ROOT)asyncdemo
|
||||||
rm $(ROOT)demo
|
rm $(ROOT)demo
|
||||||
rm $(ROOT)prepare
|
rm $(ROOT)prepare
|
||||||
rm $(ROOT)batchprepare
|
rm $(ROOT)stream_demo
|
||||||
rm $(ROOT)stream
|
rm $(ROOT)tmq
|
||||||
rm $(ROOT)subscribe
|
rm $(ROOT)schemaless
|
||||||
rm $(ROOT)apitest
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../../../include/client/taos.h"
|
#include "taos.h"
|
||||||
|
|
||||||
void taosMsleep(int mseconds);
|
void taosMsleep(int mseconds);
|
||||||
|
|
||||||
|
@ -70,70 +70,89 @@ int main(int argc, char *argv[])
|
||||||
char blob[80];
|
char blob[80];
|
||||||
} v = {0};
|
} v = {0};
|
||||||
|
|
||||||
|
int32_t boolLen = sizeof(int8_t);
|
||||||
|
int32_t sintLen = sizeof(int16_t);
|
||||||
|
int32_t intLen = sizeof(int32_t);
|
||||||
|
int32_t bintLen = sizeof(int64_t);
|
||||||
|
int32_t floatLen = sizeof(float);
|
||||||
|
int32_t doubleLen = sizeof(double);
|
||||||
|
int32_t binLen = sizeof(v.bin);
|
||||||
|
int32_t ncharLen = 30;
|
||||||
|
|
||||||
stmt = taos_stmt_init(taos);
|
stmt = taos_stmt_init(taos);
|
||||||
TAOS_BIND params[10];
|
TAOS_MULTI_BIND params[10];
|
||||||
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
|
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
params[0].buffer_length = sizeof(v.ts);
|
params[0].buffer_length = sizeof(v.ts);
|
||||||
params[0].buffer = &v.ts;
|
params[0].buffer = &v.ts;
|
||||||
params[0].length = ¶ms[0].buffer_length;
|
params[0].length = &bintLen;
|
||||||
params[0].is_null = NULL;
|
params[0].is_null = NULL;
|
||||||
|
params[0].num = 1;
|
||||||
|
|
||||||
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
|
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
|
||||||
params[1].buffer_length = sizeof(v.b);
|
params[1].buffer_length = sizeof(v.b);
|
||||||
params[1].buffer = &v.b;
|
params[1].buffer = &v.b;
|
||||||
params[1].length = ¶ms[1].buffer_length;
|
params[1].length = &boolLen;
|
||||||
params[1].is_null = NULL;
|
params[1].is_null = NULL;
|
||||||
|
params[1].num = 1;
|
||||||
|
|
||||||
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
||||||
params[2].buffer_length = sizeof(v.v1);
|
params[2].buffer_length = sizeof(v.v1);
|
||||||
params[2].buffer = &v.v1;
|
params[2].buffer = &v.v1;
|
||||||
params[2].length = ¶ms[2].buffer_length;
|
params[2].length = &boolLen;
|
||||||
params[2].is_null = NULL;
|
params[2].is_null = NULL;
|
||||||
|
params[2].num = 1;
|
||||||
|
|
||||||
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
params[3].buffer_length = sizeof(v.v2);
|
params[3].buffer_length = sizeof(v.v2);
|
||||||
params[3].buffer = &v.v2;
|
params[3].buffer = &v.v2;
|
||||||
params[3].length = ¶ms[3].buffer_length;
|
params[3].length = &sintLen;
|
||||||
params[3].is_null = NULL;
|
params[3].is_null = NULL;
|
||||||
|
params[3].num = 1;
|
||||||
|
|
||||||
params[4].buffer_type = TSDB_DATA_TYPE_INT;
|
params[4].buffer_type = TSDB_DATA_TYPE_INT;
|
||||||
params[4].buffer_length = sizeof(v.v4);
|
params[4].buffer_length = sizeof(v.v4);
|
||||||
params[4].buffer = &v.v4;
|
params[4].buffer = &v.v4;
|
||||||
params[4].length = ¶ms[4].buffer_length;
|
params[4].length = &intLen;
|
||||||
params[4].is_null = NULL;
|
params[4].is_null = NULL;
|
||||||
|
params[4].num = 1;
|
||||||
|
|
||||||
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
|
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
|
||||||
params[5].buffer_length = sizeof(v.v8);
|
params[5].buffer_length = sizeof(v.v8);
|
||||||
params[5].buffer = &v.v8;
|
params[5].buffer = &v.v8;
|
||||||
params[5].length = ¶ms[5].buffer_length;
|
params[5].length = &bintLen;
|
||||||
params[5].is_null = NULL;
|
params[5].is_null = NULL;
|
||||||
|
params[5].num = 1;
|
||||||
|
|
||||||
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
|
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
|
||||||
params[6].buffer_length = sizeof(v.f4);
|
params[6].buffer_length = sizeof(v.f4);
|
||||||
params[6].buffer = &v.f4;
|
params[6].buffer = &v.f4;
|
||||||
params[6].length = ¶ms[6].buffer_length;
|
params[6].length = &floatLen;
|
||||||
params[6].is_null = NULL;
|
params[6].is_null = NULL;
|
||||||
|
params[6].num = 1;
|
||||||
|
|
||||||
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
|
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
params[7].buffer_length = sizeof(v.f8);
|
params[7].buffer_length = sizeof(v.f8);
|
||||||
params[7].buffer = &v.f8;
|
params[7].buffer = &v.f8;
|
||||||
params[7].length = ¶ms[7].buffer_length;
|
params[7].length = &doubleLen;
|
||||||
params[7].is_null = NULL;
|
params[7].is_null = NULL;
|
||||||
|
params[7].num = 1;
|
||||||
|
|
||||||
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
|
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
|
||||||
params[8].buffer_length = sizeof(v.bin);
|
params[8].buffer_length = sizeof(v.bin);
|
||||||
params[8].buffer = v.bin;
|
params[8].buffer = v.bin;
|
||||||
params[8].length = ¶ms[8].buffer_length;
|
params[8].length = &binLen;
|
||||||
params[8].is_null = NULL;
|
params[8].is_null = NULL;
|
||||||
|
params[8].num = 1;
|
||||||
|
|
||||||
strcpy(v.blob, "一二三四五六七八九十");
|
strcpy(v.blob, "一二三四五六七八九十");
|
||||||
params[9].buffer_type = TSDB_DATA_TYPE_NCHAR;
|
params[9].buffer_type = TSDB_DATA_TYPE_NCHAR;
|
||||||
params[9].buffer_length = strlen(v.blob);
|
params[9].buffer_length = sizeof(v.blob);
|
||||||
params[9].buffer = v.blob;
|
params[9].buffer = v.blob;
|
||||||
params[9].length = ¶ms[9].buffer_length;
|
params[9].length = &ncharLen;
|
||||||
params[9].is_null = NULL;
|
params[9].is_null = NULL;
|
||||||
|
params[9].num = 1;
|
||||||
|
|
||||||
int is_null = 1;
|
char is_null = 1;
|
||||||
|
|
||||||
sql = "insert into m1 values(?,?,?,?,?,?,?,?,?,?)";
|
sql = "insert into m1 values(?,?,?,?,?,?,?,?,?,?)";
|
||||||
code = taos_stmt_prepare(stmt, sql, 0);
|
code = taos_stmt_prepare(stmt, sql, 0);
|
||||||
|
@ -153,7 +172,7 @@ int main(int argc, char *argv[])
|
||||||
v.v8 = (int64_t)(i * 8);
|
v.v8 = (int64_t)(i * 8);
|
||||||
v.f4 = (float)(i * 40);
|
v.f4 = (float)(i * 40);
|
||||||
v.f8 = (double)(i * 80);
|
v.f8 = (double)(i * 80);
|
||||||
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
|
for (int j = 0; j < sizeof(v.bin); ++j) {
|
||||||
v.bin[j] = (char)(i + '0');
|
v.bin[j] = (char)(i + '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,17 @@
|
||||||
#include "../../../include/client/taos.h"
|
#include "taos.h"
|
||||||
#include "os.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
int numSuperTables = 8;
|
int numSuperTables = 8;
|
||||||
int numChildTables = 4;
|
int numChildTables = 4;
|
||||||
int numRowsPerChildTable = 2048;
|
int numRowsPerChildTable = 2048;
|
||||||
|
|
||||||
void shuffle(char**lines, size_t n)
|
|
||||||
{
|
|
||||||
if (n > 1)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < n - 1; i++)
|
|
||||||
{
|
|
||||||
size_t j = i + taosRand() / (RAND_MAX / (n - i) + 1);
|
|
||||||
char* t = lines[j];
|
|
||||||
lines[j] = lines[i];
|
|
||||||
lines[i] = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int64_t getTimeInUs() {
|
static int64_t getTimeInUs() {
|
||||||
struct timeval systemTime;
|
struct timeval systemTime;
|
||||||
gettimeofday(&systemTime, NULL);
|
gettimeofday(&systemTime, NULL);
|
||||||
|
@ -46,7 +31,7 @@ int main(int argc, char* argv[]) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* info = taos_get_server_info(taos);
|
const char* info = taos_get_server_info(taos);
|
||||||
printf("server info: %s\n", info);
|
printf("server info: %s\n", info);
|
||||||
info = taos_get_client_info(taos);
|
info = taos_get_client_info(taos);
|
||||||
printf("client info: %s\n", info);
|
printf("client info: %s\n", info);
|
||||||
|
@ -61,9 +46,10 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
time_t ct = time(0);
|
time_t ct = time(0);
|
||||||
int64_t ts = ct * 1000;
|
int64_t ts = ct * 1000;
|
||||||
char* lineFormat = "sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=254u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" %lldms";
|
char* lineFormat = "sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=254u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" %" PRId64;
|
||||||
|
|
||||||
char** lines = calloc(numSuperTables * numChildTables * numRowsPerChildTable, sizeof(char*));
|
int lineNum = numSuperTables * numChildTables * numRowsPerChildTable;
|
||||||
|
char** lines = calloc((size_t)lineNum, sizeof(char*));
|
||||||
int l = 0;
|
int l = 0;
|
||||||
for (int i = 0; i < numSuperTables; ++i) {
|
for (int i = 0; i < numSuperTables; ++i) {
|
||||||
for (int j = 0; j < numChildTables; ++j) {
|
for (int j = 0; j < numChildTables; ++j) {
|
||||||
|
@ -75,13 +61,13 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//shuffle(lines, numSuperTables * numChildTables * numRowsPerChildTable);
|
|
||||||
|
|
||||||
printf("%s\n", "begin taos_insert_lines");
|
printf("%s\n", "begin taos_insert_lines");
|
||||||
int64_t begin = getTimeInUs();
|
int64_t begin = getTimeInUs();
|
||||||
int32_t code = taos_insert_lines(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable);
|
TAOS_RES *res = taos_schemaless_insert(taos, lines, lineNum, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
|
||||||
int64_t end = getTimeInUs();
|
int64_t end = getTimeInUs();
|
||||||
printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin);
|
printf("code: %s. time used: %" PRId64 "\n", taos_errstr(res), end-begin);
|
||||||
|
taos_free_result(res);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,10 +108,13 @@ int32_t create_stream() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
int code;
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
printf("env init\n");
|
printf("env init\n");
|
||||||
code = init_env();
|
int code = init_env();
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
create_stream();
|
create_stream();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
|
||||||
static int running = 1;
|
static int running = 1;
|
||||||
static char dbName[64] = "tmqdb";
|
|
||||||
static char stbName[64] = "stb";
|
|
||||||
static char topicName[64] = "topicname";
|
|
||||||
|
|
||||||
static int32_t msg_process(TAOS_RES* msg) {
|
static int32_t msg_process(TAOS_RES* msg) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -43,7 +40,7 @@ static int32_t msg_process(TAOS_RES* msg) {
|
||||||
|
|
||||||
TAOS_FIELD* fields = taos_fetch_fields(msg);
|
TAOS_FIELD* fields = taos_fetch_fields(msg);
|
||||||
int32_t numOfFields = taos_field_count(msg);
|
int32_t numOfFields = taos_field_count(msg);
|
||||||
int32_t* length = taos_fetch_lengths(msg);
|
//int32_t* length = taos_fetch_lengths(msg);
|
||||||
int32_t precision = taos_result_precision(msg);
|
int32_t precision = taos_result_precision(msg);
|
||||||
rows++;
|
rows++;
|
||||||
taos_print_row(buf, row, fields, numOfFields);
|
taos_print_row(buf, row, fields, numOfFields);
|
||||||
|
@ -62,6 +59,13 @@ static int32_t init_env() {
|
||||||
TAOS_RES* pRes;
|
TAOS_RES* pRes;
|
||||||
// drop database if exists
|
// drop database if exists
|
||||||
printf("create database\n");
|
printf("create database\n");
|
||||||
|
pRes = taos_query(pConn, "drop topic topicname");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in drop tmqdb, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "drop database if exists tmqdb");
|
pRes = taos_query(pConn, "drop database if exists tmqdb");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in drop tmqdb, reason:%s\n", taos_errstr(pRes));
|
printf("error in drop tmqdb, reason:%s\n", taos_errstr(pRes));
|
||||||
|
@ -249,7 +253,7 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
tmq_t* tmq = build_consumer();
|
tmq_t* tmq = build_consumer();
|
||||||
if (NULL == tmq) {
|
if (NULL == tmq) {
|
||||||
fprintf(stderr, "%% build_consumer() fail!\n");
|
fprintf(stderr, "build_consumer() fail!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +263,7 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = tmq_subscribe(tmq, topic_list))) {
|
if ((code = tmq_subscribe(tmq, topic_list))) {
|
||||||
fprintf(stderr, "%% Failed to tmq_subscribe(): %s\n", tmq_err2str(code));
|
fprintf(stderr, "Failed to tmq_subscribe(): %s\n", tmq_err2str(code));
|
||||||
}
|
}
|
||||||
tmq_list_destroy(topic_list);
|
tmq_list_destroy(topic_list);
|
||||||
|
|
||||||
|
@ -267,9 +271,9 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
code = tmq_consumer_close(tmq);
|
code = tmq_consumer_close(tmq);
|
||||||
if (code) {
|
if (code) {
|
||||||
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
fprintf(stderr, "Failed to close consumer: %s\n", tmq_err2str(code));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%% Consumer closed\n");
|
fprintf(stderr, "Consumer closed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -195,6 +195,7 @@ typedef struct SDataBlockInfo {
|
||||||
uint32_t capacity;
|
uint32_t capacity;
|
||||||
SBlockID id;
|
SBlockID id;
|
||||||
int16_t hasVarCol;
|
int16_t hasVarCol;
|
||||||
|
int16_t dataLoad; // denote if the data is loaded or not
|
||||||
|
|
||||||
// TODO: optimize and remove following
|
// TODO: optimize and remove following
|
||||||
int64_t version; // used for stream, and need serialization
|
int64_t version; // used for stream, and need serialization
|
||||||
|
|
|
@ -94,242 +94,242 @@
|
||||||
#define TK_TSDB_PAGESIZE 76
|
#define TK_TSDB_PAGESIZE 76
|
||||||
#define TK_PRECISION 77
|
#define TK_PRECISION 77
|
||||||
#define TK_REPLICA 78
|
#define TK_REPLICA 78
|
||||||
#define TK_STRICT 79
|
#define TK_VGROUPS 79
|
||||||
#define TK_VGROUPS 80
|
#define TK_SINGLE_STABLE 80
|
||||||
#define TK_SINGLE_STABLE 81
|
#define TK_RETENTIONS 81
|
||||||
#define TK_RETENTIONS 82
|
#define TK_SCHEMALESS 82
|
||||||
#define TK_SCHEMALESS 83
|
#define TK_WAL_LEVEL 83
|
||||||
#define TK_WAL_LEVEL 84
|
#define TK_WAL_FSYNC_PERIOD 84
|
||||||
#define TK_WAL_FSYNC_PERIOD 85
|
#define TK_WAL_RETENTION_PERIOD 85
|
||||||
#define TK_WAL_RETENTION_PERIOD 86
|
#define TK_WAL_RETENTION_SIZE 86
|
||||||
#define TK_WAL_RETENTION_SIZE 87
|
#define TK_WAL_ROLL_PERIOD 87
|
||||||
#define TK_WAL_ROLL_PERIOD 88
|
#define TK_WAL_SEGMENT_SIZE 88
|
||||||
#define TK_WAL_SEGMENT_SIZE 89
|
#define TK_STT_TRIGGER 89
|
||||||
#define TK_STT_TRIGGER 90
|
#define TK_TABLE_PREFIX 90
|
||||||
#define TK_TABLE_PREFIX 91
|
#define TK_TABLE_SUFFIX 91
|
||||||
#define TK_TABLE_SUFFIX 92
|
#define TK_NK_COLON 92
|
||||||
#define TK_NK_COLON 93
|
#define TK_MAX_SPEED 93
|
||||||
#define TK_MAX_SPEED 94
|
#define TK_TABLE 94
|
||||||
#define TK_TABLE 95
|
#define TK_NK_LP 95
|
||||||
#define TK_NK_LP 96
|
#define TK_NK_RP 96
|
||||||
#define TK_NK_RP 97
|
#define TK_STABLE 97
|
||||||
#define TK_STABLE 98
|
#define TK_ADD 98
|
||||||
#define TK_ADD 99
|
#define TK_COLUMN 99
|
||||||
#define TK_COLUMN 100
|
#define TK_MODIFY 100
|
||||||
#define TK_MODIFY 101
|
#define TK_RENAME 101
|
||||||
#define TK_RENAME 102
|
#define TK_TAG 102
|
||||||
#define TK_TAG 103
|
#define TK_SET 103
|
||||||
#define TK_SET 104
|
#define TK_NK_EQ 104
|
||||||
#define TK_NK_EQ 105
|
#define TK_USING 105
|
||||||
#define TK_USING 106
|
#define TK_TAGS 106
|
||||||
#define TK_TAGS 107
|
#define TK_COMMENT 107
|
||||||
#define TK_COMMENT 108
|
#define TK_BOOL 108
|
||||||
#define TK_BOOL 109
|
#define TK_TINYINT 109
|
||||||
#define TK_TINYINT 110
|
#define TK_SMALLINT 110
|
||||||
#define TK_SMALLINT 111
|
#define TK_INT 111
|
||||||
#define TK_INT 112
|
#define TK_INTEGER 112
|
||||||
#define TK_INTEGER 113
|
#define TK_BIGINT 113
|
||||||
#define TK_BIGINT 114
|
#define TK_FLOAT 114
|
||||||
#define TK_FLOAT 115
|
#define TK_DOUBLE 115
|
||||||
#define TK_DOUBLE 116
|
#define TK_BINARY 116
|
||||||
#define TK_BINARY 117
|
#define TK_TIMESTAMP 117
|
||||||
#define TK_TIMESTAMP 118
|
#define TK_NCHAR 118
|
||||||
#define TK_NCHAR 119
|
#define TK_UNSIGNED 119
|
||||||
#define TK_UNSIGNED 120
|
#define TK_JSON 120
|
||||||
#define TK_JSON 121
|
#define TK_VARCHAR 121
|
||||||
#define TK_VARCHAR 122
|
#define TK_MEDIUMBLOB 122
|
||||||
#define TK_MEDIUMBLOB 123
|
#define TK_BLOB 123
|
||||||
#define TK_BLOB 124
|
#define TK_VARBINARY 124
|
||||||
#define TK_VARBINARY 125
|
#define TK_DECIMAL 125
|
||||||
#define TK_DECIMAL 126
|
#define TK_MAX_DELAY 126
|
||||||
#define TK_MAX_DELAY 127
|
#define TK_WATERMARK 127
|
||||||
#define TK_WATERMARK 128
|
#define TK_ROLLUP 128
|
||||||
#define TK_ROLLUP 129
|
#define TK_TTL 129
|
||||||
#define TK_TTL 130
|
#define TK_SMA 130
|
||||||
#define TK_SMA 131
|
#define TK_DELETE_MARK 131
|
||||||
#define TK_DELETE_MARK 132
|
#define TK_FIRST 132
|
||||||
#define TK_FIRST 133
|
#define TK_LAST 133
|
||||||
#define TK_LAST 134
|
#define TK_SHOW 134
|
||||||
#define TK_SHOW 135
|
#define TK_PRIVILEGES 135
|
||||||
#define TK_PRIVILEGES 136
|
#define TK_DATABASES 136
|
||||||
#define TK_DATABASES 137
|
#define TK_TABLES 137
|
||||||
#define TK_TABLES 138
|
#define TK_STABLES 138
|
||||||
#define TK_STABLES 139
|
#define TK_MNODES 139
|
||||||
#define TK_MNODES 140
|
#define TK_QNODES 140
|
||||||
#define TK_QNODES 141
|
#define TK_FUNCTIONS 141
|
||||||
#define TK_FUNCTIONS 142
|
#define TK_INDEXES 142
|
||||||
#define TK_INDEXES 143
|
#define TK_ACCOUNTS 143
|
||||||
#define TK_ACCOUNTS 144
|
#define TK_APPS 144
|
||||||
#define TK_APPS 145
|
#define TK_CONNECTIONS 145
|
||||||
#define TK_CONNECTIONS 146
|
#define TK_LICENCES 146
|
||||||
#define TK_LICENCES 147
|
#define TK_GRANTS 147
|
||||||
#define TK_GRANTS 148
|
#define TK_QUERIES 148
|
||||||
#define TK_QUERIES 149
|
#define TK_SCORES 149
|
||||||
#define TK_SCORES 150
|
#define TK_TOPICS 150
|
||||||
#define TK_TOPICS 151
|
#define TK_VARIABLES 151
|
||||||
#define TK_VARIABLES 152
|
#define TK_CLUSTER 152
|
||||||
#define TK_CLUSTER 153
|
#define TK_BNODES 153
|
||||||
#define TK_BNODES 154
|
#define TK_SNODES 154
|
||||||
#define TK_SNODES 155
|
#define TK_TRANSACTIONS 155
|
||||||
#define TK_TRANSACTIONS 156
|
#define TK_DISTRIBUTED 156
|
||||||
#define TK_DISTRIBUTED 157
|
#define TK_CONSUMERS 157
|
||||||
#define TK_CONSUMERS 158
|
#define TK_SUBSCRIPTIONS 158
|
||||||
#define TK_SUBSCRIPTIONS 159
|
#define TK_VNODES 159
|
||||||
#define TK_VNODES 160
|
#define TK_LIKE 160
|
||||||
#define TK_LIKE 161
|
#define TK_TBNAME 161
|
||||||
#define TK_TBNAME 162
|
#define TK_QTAGS 162
|
||||||
#define TK_QTAGS 163
|
#define TK_AS 163
|
||||||
#define TK_AS 164
|
#define TK_INDEX 164
|
||||||
#define TK_INDEX 165
|
#define TK_FUNCTION 165
|
||||||
#define TK_FUNCTION 166
|
#define TK_INTERVAL 166
|
||||||
#define TK_INTERVAL 167
|
#define TK_TOPIC 167
|
||||||
#define TK_TOPIC 168
|
#define TK_WITH 168
|
||||||
#define TK_WITH 169
|
#define TK_META 169
|
||||||
#define TK_META 170
|
#define TK_CONSUMER 170
|
||||||
#define TK_CONSUMER 171
|
#define TK_GROUP 171
|
||||||
#define TK_GROUP 172
|
#define TK_DESC 172
|
||||||
#define TK_DESC 173
|
#define TK_DESCRIBE 173
|
||||||
#define TK_DESCRIBE 174
|
#define TK_RESET 174
|
||||||
#define TK_RESET 175
|
#define TK_QUERY 175
|
||||||
#define TK_QUERY 176
|
#define TK_CACHE 176
|
||||||
#define TK_CACHE 177
|
#define TK_EXPLAIN 177
|
||||||
#define TK_EXPLAIN 178
|
#define TK_ANALYZE 178
|
||||||
#define TK_ANALYZE 179
|
#define TK_VERBOSE 179
|
||||||
#define TK_VERBOSE 180
|
#define TK_NK_BOOL 180
|
||||||
#define TK_NK_BOOL 181
|
#define TK_RATIO 181
|
||||||
#define TK_RATIO 182
|
#define TK_NK_FLOAT 182
|
||||||
#define TK_NK_FLOAT 183
|
#define TK_OUTPUTTYPE 183
|
||||||
#define TK_OUTPUTTYPE 184
|
#define TK_AGGREGATE 184
|
||||||
#define TK_AGGREGATE 185
|
#define TK_BUFSIZE 185
|
||||||
#define TK_BUFSIZE 186
|
#define TK_STREAM 186
|
||||||
#define TK_STREAM 187
|
#define TK_INTO 187
|
||||||
#define TK_INTO 188
|
#define TK_TRIGGER 188
|
||||||
#define TK_TRIGGER 189
|
#define TK_AT_ONCE 189
|
||||||
#define TK_AT_ONCE 190
|
#define TK_WINDOW_CLOSE 190
|
||||||
#define TK_WINDOW_CLOSE 191
|
#define TK_IGNORE 191
|
||||||
#define TK_IGNORE 192
|
#define TK_EXPIRED 192
|
||||||
#define TK_EXPIRED 193
|
#define TK_FILL_HISTORY 193
|
||||||
#define TK_FILL_HISTORY 194
|
#define TK_SUBTABLE 194
|
||||||
#define TK_SUBTABLE 195
|
#define TK_KILL 195
|
||||||
#define TK_KILL 196
|
#define TK_CONNECTION 196
|
||||||
#define TK_CONNECTION 197
|
#define TK_TRANSACTION 197
|
||||||
#define TK_TRANSACTION 198
|
#define TK_BALANCE 198
|
||||||
#define TK_BALANCE 199
|
#define TK_VGROUP 199
|
||||||
#define TK_VGROUP 200
|
#define TK_MERGE 200
|
||||||
#define TK_MERGE 201
|
#define TK_REDISTRIBUTE 201
|
||||||
#define TK_REDISTRIBUTE 202
|
#define TK_SPLIT 202
|
||||||
#define TK_SPLIT 203
|
#define TK_DELETE 203
|
||||||
#define TK_DELETE 204
|
#define TK_INSERT 204
|
||||||
#define TK_INSERT 205
|
#define TK_NULL 205
|
||||||
#define TK_NULL 206
|
#define TK_NK_QUESTION 206
|
||||||
#define TK_NK_QUESTION 207
|
#define TK_NK_ARROW 207
|
||||||
#define TK_NK_ARROW 208
|
#define TK_ROWTS 208
|
||||||
#define TK_ROWTS 209
|
#define TK_QSTART 209
|
||||||
#define TK_QSTART 210
|
#define TK_QEND 210
|
||||||
#define TK_QEND 211
|
#define TK_QDURATION 211
|
||||||
#define TK_QDURATION 212
|
#define TK_WSTART 212
|
||||||
#define TK_WSTART 213
|
#define TK_WEND 213
|
||||||
#define TK_WEND 214
|
#define TK_WDURATION 214
|
||||||
#define TK_WDURATION 215
|
#define TK_IROWTS 215
|
||||||
#define TK_IROWTS 216
|
#define TK_CAST 216
|
||||||
#define TK_CAST 217
|
#define TK_NOW 217
|
||||||
#define TK_NOW 218
|
#define TK_TODAY 218
|
||||||
#define TK_TODAY 219
|
#define TK_TIMEZONE 219
|
||||||
#define TK_TIMEZONE 220
|
#define TK_CLIENT_VERSION 220
|
||||||
#define TK_CLIENT_VERSION 221
|
#define TK_SERVER_VERSION 221
|
||||||
#define TK_SERVER_VERSION 222
|
#define TK_SERVER_STATUS 222
|
||||||
#define TK_SERVER_STATUS 223
|
#define TK_CURRENT_USER 223
|
||||||
#define TK_CURRENT_USER 224
|
#define TK_COUNT 224
|
||||||
#define TK_COUNT 225
|
#define TK_LAST_ROW 225
|
||||||
#define TK_LAST_ROW 226
|
#define TK_CASE 226
|
||||||
#define TK_CASE 227
|
#define TK_END 227
|
||||||
#define TK_END 228
|
#define TK_WHEN 228
|
||||||
#define TK_WHEN 229
|
#define TK_THEN 229
|
||||||
#define TK_THEN 230
|
#define TK_ELSE 230
|
||||||
#define TK_ELSE 231
|
#define TK_BETWEEN 231
|
||||||
#define TK_BETWEEN 232
|
#define TK_IS 232
|
||||||
#define TK_IS 233
|
#define TK_NK_LT 233
|
||||||
#define TK_NK_LT 234
|
#define TK_NK_GT 234
|
||||||
#define TK_NK_GT 235
|
#define TK_NK_LE 235
|
||||||
#define TK_NK_LE 236
|
#define TK_NK_GE 236
|
||||||
#define TK_NK_GE 237
|
#define TK_NK_NE 237
|
||||||
#define TK_NK_NE 238
|
#define TK_MATCH 238
|
||||||
#define TK_MATCH 239
|
#define TK_NMATCH 239
|
||||||
#define TK_NMATCH 240
|
#define TK_CONTAINS 240
|
||||||
#define TK_CONTAINS 241
|
#define TK_IN 241
|
||||||
#define TK_IN 242
|
#define TK_JOIN 242
|
||||||
#define TK_JOIN 243
|
#define TK_INNER 243
|
||||||
#define TK_INNER 244
|
#define TK_SELECT 244
|
||||||
#define TK_SELECT 245
|
#define TK_DISTINCT 245
|
||||||
#define TK_DISTINCT 246
|
#define TK_WHERE 246
|
||||||
#define TK_WHERE 247
|
#define TK_PARTITION 247
|
||||||
#define TK_PARTITION 248
|
#define TK_BY 248
|
||||||
#define TK_BY 249
|
#define TK_SESSION 249
|
||||||
#define TK_SESSION 250
|
#define TK_STATE_WINDOW 250
|
||||||
#define TK_STATE_WINDOW 251
|
#define TK_SLIDING 251
|
||||||
#define TK_SLIDING 252
|
#define TK_FILL 252
|
||||||
#define TK_FILL 253
|
#define TK_VALUE 253
|
||||||
#define TK_VALUE 254
|
#define TK_NONE 254
|
||||||
#define TK_NONE 255
|
#define TK_PREV 255
|
||||||
#define TK_PREV 256
|
#define TK_LINEAR 256
|
||||||
#define TK_LINEAR 257
|
#define TK_NEXT 257
|
||||||
#define TK_NEXT 258
|
#define TK_HAVING 258
|
||||||
#define TK_HAVING 259
|
#define TK_RANGE 259
|
||||||
#define TK_RANGE 260
|
#define TK_EVERY 260
|
||||||
#define TK_EVERY 261
|
#define TK_ORDER 261
|
||||||
#define TK_ORDER 262
|
#define TK_SLIMIT 262
|
||||||
#define TK_SLIMIT 263
|
#define TK_SOFFSET 263
|
||||||
#define TK_SOFFSET 264
|
#define TK_LIMIT 264
|
||||||
#define TK_LIMIT 265
|
#define TK_OFFSET 265
|
||||||
#define TK_OFFSET 266
|
#define TK_ASC 266
|
||||||
#define TK_ASC 267
|
#define TK_NULLS 267
|
||||||
#define TK_NULLS 268
|
#define TK_ABORT 268
|
||||||
#define TK_ABORT 269
|
#define TK_AFTER 269
|
||||||
#define TK_AFTER 270
|
#define TK_ATTACH 270
|
||||||
#define TK_ATTACH 271
|
#define TK_BEFORE 271
|
||||||
#define TK_BEFORE 272
|
#define TK_BEGIN 272
|
||||||
#define TK_BEGIN 273
|
#define TK_BITAND 273
|
||||||
#define TK_BITAND 274
|
#define TK_BITNOT 274
|
||||||
#define TK_BITNOT 275
|
#define TK_BITOR 275
|
||||||
#define TK_BITOR 276
|
#define TK_BLOCKS 276
|
||||||
#define TK_BLOCKS 277
|
#define TK_CHANGE 277
|
||||||
#define TK_CHANGE 278
|
#define TK_COMMA 278
|
||||||
#define TK_COMMA 279
|
#define TK_COMPACT 279
|
||||||
#define TK_COMPACT 280
|
#define TK_CONCAT 280
|
||||||
#define TK_CONCAT 281
|
#define TK_CONFLICT 281
|
||||||
#define TK_CONFLICT 282
|
#define TK_COPY 282
|
||||||
#define TK_COPY 283
|
#define TK_DEFERRED 283
|
||||||
#define TK_DEFERRED 284
|
#define TK_DELIMITERS 284
|
||||||
#define TK_DELIMITERS 285
|
#define TK_DETACH 285
|
||||||
#define TK_DETACH 286
|
#define TK_DIVIDE 286
|
||||||
#define TK_DIVIDE 287
|
#define TK_DOT 287
|
||||||
#define TK_DOT 288
|
#define TK_EACH 288
|
||||||
#define TK_EACH 289
|
#define TK_FAIL 289
|
||||||
#define TK_FAIL 290
|
#define TK_FILE 290
|
||||||
#define TK_FILE 291
|
#define TK_FOR 291
|
||||||
#define TK_FOR 292
|
#define TK_GLOB 292
|
||||||
#define TK_GLOB 293
|
#define TK_ID 293
|
||||||
#define TK_ID 294
|
#define TK_IMMEDIATE 294
|
||||||
#define TK_IMMEDIATE 295
|
#define TK_IMPORT 295
|
||||||
#define TK_IMPORT 296
|
#define TK_INITIALLY 296
|
||||||
#define TK_INITIALLY 297
|
#define TK_INSTEAD 297
|
||||||
#define TK_INSTEAD 298
|
#define TK_ISNULL 298
|
||||||
#define TK_ISNULL 299
|
#define TK_KEY 299
|
||||||
#define TK_KEY 300
|
#define TK_MODULES 300
|
||||||
#define TK_MODULES 301
|
#define TK_NK_BITNOT 301
|
||||||
#define TK_NK_BITNOT 302
|
#define TK_NK_SEMI 302
|
||||||
#define TK_NK_SEMI 303
|
#define TK_NOTNULL 303
|
||||||
#define TK_NOTNULL 304
|
#define TK_OF 304
|
||||||
#define TK_OF 305
|
#define TK_PLUS 305
|
||||||
#define TK_PLUS 306
|
#define TK_PRIVILEGE 306
|
||||||
#define TK_PRIVILEGE 307
|
#define TK_RAISE 307
|
||||||
#define TK_RAISE 308
|
#define TK_REPLACE 308
|
||||||
#define TK_REPLACE 309
|
#define TK_RESTRICT 309
|
||||||
#define TK_RESTRICT 310
|
#define TK_ROW 310
|
||||||
#define TK_ROW 311
|
#define TK_SEMI 311
|
||||||
#define TK_SEMI 312
|
#define TK_STAR 312
|
||||||
#define TK_STAR 313
|
#define TK_STATEMENT 313
|
||||||
#define TK_STATEMENT 314
|
#define TK_STRICT 314
|
||||||
#define TK_STRING 315
|
#define TK_STRING 315
|
||||||
#define TK_TIMES 316
|
#define TK_TIMES 316
|
||||||
#define TK_UPDATE 317
|
#define TK_UPDATE 317
|
||||||
|
|
|
@ -230,7 +230,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo);
|
||||||
int32_t syncStart(int64_t rid);
|
int32_t syncStart(int64_t rid);
|
||||||
void syncStop(int64_t rid);
|
void syncStop(int64_t rid);
|
||||||
void syncPreStop(int64_t rid);
|
void syncPreStop(int64_t rid);
|
||||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak);
|
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq);
|
||||||
int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg);
|
int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg);
|
||||||
int32_t syncReconfig(int64_t rid, SSyncCfg* pCfg);
|
int32_t syncReconfig(int64_t rid, SSyncCfg* pCfg);
|
||||||
int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex);
|
int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex);
|
||||||
|
@ -240,6 +240,7 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm);
|
||||||
bool syncIsReadyForRead(int64_t rid);
|
bool syncIsReadyForRead(int64_t rid);
|
||||||
bool syncSnapshotSending(int64_t rid);
|
bool syncSnapshotSending(int64_t rid);
|
||||||
bool syncSnapshotRecving(int64_t rid);
|
bool syncSnapshotRecving(int64_t rid);
|
||||||
|
int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq);
|
||||||
|
|
||||||
SSyncState syncGetState(int64_t rid);
|
SSyncState syncGetState(int64_t rid);
|
||||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
|
|
|
@ -83,8 +83,6 @@ typedef struct SRpcInit {
|
||||||
int32_t sessions; // number of sessions allowed
|
int32_t sessions; // number of sessions allowed
|
||||||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||||
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
||||||
int32_t retryLimit; // retry limit
|
|
||||||
int32_t retryInterval; // retry interval ms
|
|
||||||
|
|
||||||
int32_t retryMinInterval; // retry init interval
|
int32_t retryMinInterval; // retry init interval
|
||||||
int32_t retryStepFactor; // retry interval factor
|
int32_t retryStepFactor; // retry interval factor
|
||||||
|
|
|
@ -36,7 +36,7 @@ extern int64_t tsStreamMax;
|
||||||
extern float tsNumOfCores;
|
extern float tsNumOfCores;
|
||||||
extern int64_t tsTotalMemoryKB;
|
extern int64_t tsTotalMemoryKB;
|
||||||
extern char *tsProcPath;
|
extern char *tsProcPath;
|
||||||
extern char tsSIMDEnable;
|
extern char tsSIMDBuiltins;
|
||||||
extern char tsSSE42Enable;
|
extern char tsSSE42Enable;
|
||||||
extern char tsAVXEnable;
|
extern char tsAVXEnable;
|
||||||
extern char tsAVX2Enable;
|
extern char tsAVX2Enable;
|
||||||
|
|
|
@ -337,7 +337,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DB_STRICT_ON_STR "on"
|
#define TSDB_DB_STRICT_ON_STR "on"
|
||||||
#define TSDB_DB_STRICT_OFF 0
|
#define TSDB_DB_STRICT_OFF 0
|
||||||
#define TSDB_DB_STRICT_ON 1
|
#define TSDB_DB_STRICT_ON 1
|
||||||
#define TSDB_DEFAULT_DB_STRICT TSDB_DB_STRICT_OFF
|
#define TSDB_DEFAULT_DB_STRICT TSDB_DB_STRICT_ON
|
||||||
#define TSDB_CACHE_MODEL_STR_LEN sizeof(TSDB_CACHE_MODEL_LAST_VALUE_STR)
|
#define TSDB_CACHE_MODEL_STR_LEN sizeof(TSDB_CACHE_MODEL_LAST_VALUE_STR)
|
||||||
#define TSDB_CACHE_MODEL_NONE_STR "none"
|
#define TSDB_CACHE_MODEL_NONE_STR "none"
|
||||||
#define TSDB_CACHE_MODEL_LAST_ROW_STR "last_row"
|
#define TSDB_CACHE_MODEL_LAST_ROW_STR "last_row"
|
||||||
|
@ -497,6 +497,9 @@ enum {
|
||||||
// sort page size by default
|
// sort page size by default
|
||||||
#define DEFAULT_PAGESIZE 4096
|
#define DEFAULT_PAGESIZE 4096
|
||||||
|
|
||||||
|
#define VNODE_TIMEOUT_SEC 60
|
||||||
|
#define MNODE_TIMEOUT_SEC 10
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,6 +65,7 @@ typedef struct STaosQnode {
|
||||||
STaosQnode *next;
|
STaosQnode *next;
|
||||||
STaosQueue *queue;
|
STaosQueue *queue;
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
|
int64_t dataSize;
|
||||||
int32_t size;
|
int32_t size;
|
||||||
int8_t itype;
|
int8_t itype;
|
||||||
int8_t reserved[3];
|
int8_t reserved[3];
|
||||||
|
@ -103,7 +104,7 @@ typedef struct STaosQall {
|
||||||
STaosQueue *taosOpenQueue();
|
STaosQueue *taosOpenQueue();
|
||||||
void taosCloseQueue(STaosQueue *queue);
|
void taosCloseQueue(STaosQueue *queue);
|
||||||
void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp);
|
void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp);
|
||||||
void *taosAllocateQitem(int32_t size, EQItype itype);
|
void *taosAllocateQitem(int32_t size, EQItype itype, int64_t dataSize);
|
||||||
void taosFreeQitem(void *pItem);
|
void taosFreeQitem(void *pItem);
|
||||||
void taosWriteQitem(STaosQueue *queue, void *pItem);
|
void taosWriteQitem(STaosQueue *queue, void *pItem);
|
||||||
int32_t taosReadQitem(STaosQueue *queue, void **ppItem);
|
int32_t taosReadQitem(STaosQueue *queue, void **ppItem);
|
||||||
|
|
|
@ -146,8 +146,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
rpcInit.dfp = destroyAhandle;
|
rpcInit.dfp = destroyAhandle;
|
||||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
|
||||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
|
||||||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||||
|
|
|
@ -190,8 +190,9 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
||||||
(*pRequest)->body.param = param;
|
(*pRequest)->body.param = param;
|
||||||
|
|
||||||
STscObj* pTscObj = (*pRequest)->pTscObj;
|
STscObj* pTscObj = (*pRequest)->pTscObj;
|
||||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
int32_t err = taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||||
sizeof((*pRequest)->self))) {
|
sizeof((*pRequest)->self));
|
||||||
|
if (err) {
|
||||||
tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||||
|
|
||||||
|
@ -1645,7 +1646,8 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols) {
|
||||||
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
|
|
||||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
||||||
|
// length |
|
||||||
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
||||||
int32_t* colLength = (int32_t*)(p + len);
|
int32_t* colLength = (int32_t*)(p + len);
|
||||||
len += sizeof(int32_t) * numOfCols;
|
len += sizeof(int32_t) * numOfCols;
|
||||||
|
@ -1971,8 +1973,6 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
rpcInit.user = "_dnd";
|
rpcInit.user = "_dnd";
|
||||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
|
||||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
|
||||||
|
|
||||||
clientRpc = rpcOpen(&rpcInit);
|
clientRpc = rpcOpen(&rpcInit);
|
||||||
if (clientRpc == NULL) {
|
if (clientRpc == NULL) {
|
||||||
|
|
|
@ -186,10 +186,10 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
||||||
if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||||
if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen);
|
taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||||
if (pRsp->rsp.withTbName) taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
||||||
if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||||
// taosx
|
// taosx
|
||||||
taosArrayDestroy(pRsp->rsp.createTableLen);
|
taosArrayDestroy(pRsp->rsp.createTableLen);
|
||||||
taosArrayDestroyP(pRsp->rsp.createTableReq, taosMemoryFree);
|
taosArrayDestroyP(pRsp->rsp.createTableReq, taosMemoryFree);
|
||||||
|
@ -199,10 +199,10 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
} else if (TD_RES_TMQ(res)) {
|
} else if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||||
if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||||
if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen);
|
taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||||
if (pRsp->rsp.withTbName) taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
||||||
if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||||
pRsp->resInfo.pRspMsg = NULL;
|
pRsp->resInfo.pRspMsg = NULL;
|
||||||
doFreeReqResultInfo(&pRsp->resInfo);
|
doFreeReqResultInfo(&pRsp->resInfo);
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
|
|
|
@ -691,7 +691,7 @@ void tmqAssignAskEpTask(void* param, void* tmrId) {
|
||||||
int64_t refId = *(int64_t*)param;
|
int64_t refId = *(int64_t*)param;
|
||||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||||
if (tmq != NULL) {
|
if (tmq != NULL) {
|
||||||
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM);
|
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM, 0);
|
||||||
*pTaskType = TMQ_DELAYED_TASK__ASK_EP;
|
*pTaskType = TMQ_DELAYED_TASK__ASK_EP;
|
||||||
taosWriteQitem(tmq->delayedTask, pTaskType);
|
taosWriteQitem(tmq->delayedTask, pTaskType);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
|
@ -703,7 +703,7 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
|
||||||
int64_t refId = *(int64_t*)param;
|
int64_t refId = *(int64_t*)param;
|
||||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||||
if (tmq != NULL) {
|
if (tmq != NULL) {
|
||||||
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM);
|
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM, 0);
|
||||||
*pTaskType = TMQ_DELAYED_TASK__COMMIT;
|
*pTaskType = TMQ_DELAYED_TASK__COMMIT;
|
||||||
taosWriteQitem(tmq->delayedTask, pTaskType);
|
taosWriteQitem(tmq->delayedTask, pTaskType);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
|
@ -715,7 +715,7 @@ void tmqAssignDelayedReportTask(void* param, void* tmrId) {
|
||||||
int64_t refId = *(int64_t*)param;
|
int64_t refId = *(int64_t*)param;
|
||||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||||
if (tmq != NULL) {
|
if (tmq != NULL) {
|
||||||
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM);
|
int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM, 0);
|
||||||
*pTaskType = TMQ_DELAYED_TASK__REPORT;
|
*pTaskType = TMQ_DELAYED_TASK__REPORT;
|
||||||
taosWriteQitem(tmq->delayedTask, pTaskType);
|
taosWriteQitem(tmq->delayedTask, pTaskType);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
|
@ -814,26 +814,57 @@ int32_t tmqHandleAllDelayedTask(tmq_t* tmq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmqClearUnhandleMsg(tmq_t* tmq) {
|
static void tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) {
|
||||||
SMqRspWrapper* msg = NULL;
|
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) {
|
||||||
while (1) {
|
// do nothing
|
||||||
taosGetQitem(tmq->qall, (void**)&msg);
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__EP_RSP) {
|
||||||
if (msg)
|
SMqAskEpRspWrapper* pEpRspWrapper = (SMqAskEpRspWrapper*)rspWrapper;
|
||||||
taosFreeQitem(msg);
|
tDeleteSMqAskEpRsp(&pEpRspWrapper->msg);
|
||||||
else
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) {
|
||||||
break;
|
SMqPollRspWrapper* pRsp = (SMqPollRspWrapper*)rspWrapper;
|
||||||
|
taosArrayDestroyP(pRsp->dataRsp.blockData, taosMemoryFree);
|
||||||
|
taosArrayDestroy(pRsp->dataRsp.blockDataLen);
|
||||||
|
taosArrayDestroyP(pRsp->dataRsp.blockTbName, taosMemoryFree);
|
||||||
|
taosArrayDestroyP(pRsp->dataRsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||||
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||||
|
SMqPollRspWrapper* pRsp = (SMqPollRspWrapper*)rspWrapper;
|
||||||
|
taosMemoryFree(pRsp->metaRsp.metaRsp);
|
||||||
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) {
|
||||||
|
SMqPollRspWrapper* pRsp = (SMqPollRspWrapper*)rspWrapper;
|
||||||
|
taosArrayDestroyP(pRsp->taosxRsp.blockData, taosMemoryFree);
|
||||||
|
taosArrayDestroy(pRsp->taosxRsp.blockDataLen);
|
||||||
|
taosArrayDestroyP(pRsp->taosxRsp.blockTbName, taosMemoryFree);
|
||||||
|
taosArrayDestroyP(pRsp->taosxRsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||||
|
// taosx
|
||||||
|
taosArrayDestroy(pRsp->taosxRsp.createTableLen);
|
||||||
|
taosArrayDestroyP(pRsp->taosxRsp.createTableReq, taosMemoryFree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = NULL;
|
void tmqClearUnhandleMsg(tmq_t* tmq) {
|
||||||
|
SMqRspWrapper* rspWrapper = NULL;
|
||||||
|
while (1) {
|
||||||
|
taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||||
|
if (rspWrapper) {
|
||||||
|
tmqFreeRspWrapper(rspWrapper);
|
||||||
|
taosFreeQitem(rspWrapper);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rspWrapper = NULL;
|
||||||
taosReadAllQitems(tmq->mqueue, tmq->qall);
|
taosReadAllQitems(tmq->mqueue, tmq->qall);
|
||||||
while (1) {
|
while (1) {
|
||||||
taosGetQitem(tmq->qall, (void**)&msg);
|
taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||||
if (msg)
|
if (rspWrapper) {
|
||||||
taosFreeQitem(msg);
|
tmqFreeRspWrapper(rspWrapper);
|
||||||
else
|
taosFreeQitem(rspWrapper);
|
||||||
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) {
|
int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SMqSubscribeCbParam* pParam = (SMqSubscribeCbParam*)param;
|
SMqSubscribeCbParam* pParam = (SMqSubscribeCbParam*)param;
|
||||||
|
@ -1140,7 +1171,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
goto CREATE_MSG_FAIL;
|
goto CREATE_MSG_FAIL;
|
||||||
}
|
}
|
||||||
if (code == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) {
|
if (code == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) {
|
||||||
SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM);
|
SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM, 0);
|
||||||
if (pRspWrapper == NULL) {
|
if (pRspWrapper == NULL) {
|
||||||
tscWarn("msg discard from vgId:%d, epoch %d since out of memory", vgId, epoch);
|
tscWarn("msg discard from vgId:%d, epoch %d since out of memory", vgId, epoch);
|
||||||
goto CREATE_MSG_FAIL;
|
goto CREATE_MSG_FAIL;
|
||||||
|
@ -1173,7 +1204,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
// handle meta rsp
|
// handle meta rsp
|
||||||
int8_t rspType = ((SMqRspHead*)pMsg->pData)->mqMsgType;
|
int8_t rspType = ((SMqRspHead*)pMsg->pData)->mqMsgType;
|
||||||
|
|
||||||
SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM);
|
SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM, 0);
|
||||||
if (pRspWrapper == NULL) {
|
if (pRspWrapper == NULL) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFree(pMsg->pEpSet);
|
||||||
|
@ -1363,7 +1394,7 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
tmqUpdateEp(tmq, head->epoch, &rsp);
|
tmqUpdateEp(tmq, head->epoch, &rsp);
|
||||||
tDeleteSMqAskEpRsp(&rsp);
|
tDeleteSMqAskEpRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM);
|
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0);
|
||||||
if (pWrapper == NULL) {
|
if (pWrapper == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
code = -1;
|
code = -1;
|
||||||
|
@ -1644,6 +1675,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
|
||||||
tDeleteSMqAskEpRsp(rspMsg);
|
tDeleteSMqAskEpRsp(rspMsg);
|
||||||
*pReset = true;
|
*pReset = true;
|
||||||
} else {
|
} else {
|
||||||
|
tmqFreeRspWrapper(rspWrapper);
|
||||||
*pReset = false;
|
*pReset = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1695,6 +1727,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
} else {
|
} else {
|
||||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||||
pollRspWrapper->dataRsp.head.epoch, consumerEpoch);
|
pollRspWrapper->dataRsp.head.epoch, consumerEpoch);
|
||||||
|
tmqFreeRspWrapper(rspWrapper);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||||
|
@ -1713,6 +1746,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
} else {
|
} else {
|
||||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||||
pollRspWrapper->metaRsp.head.epoch, consumerEpoch);
|
pollRspWrapper->metaRsp.head.epoch, consumerEpoch);
|
||||||
|
tmqFreeRspWrapper(rspWrapper);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) {
|
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) {
|
||||||
|
@ -1743,6 +1777,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
} else {
|
} else {
|
||||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||||
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
||||||
|
tmqFreeRspWrapper(rspWrapper);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1794,7 +1829,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||||
while (1) {
|
while (1) {
|
||||||
tmqHandleAllDelayedTask(tmq);
|
tmqHandleAllDelayedTask(tmq);
|
||||||
if (tmqPollImpl(tmq, timeout) < 0) {
|
if (tmqPollImpl(tmq, timeout) < 0) {
|
||||||
tscDebug("return since poll err");
|
tscDebug("consumer:%" PRId64 " return since poll err", tmq->consumerId);
|
||||||
/*return NULL;*/
|
/*return NULL;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,11 @@ size_t blockDataGetNumOfCols(const SSDataBlock* pBlock) { return taosArrayGetSiz
|
||||||
size_t blockDataGetNumOfRows(const SSDataBlock* pBlock) { return pBlock->info.rows; }
|
size_t blockDataGetNumOfRows(const SSDataBlock* pBlock) { return pBlock->info.rows; }
|
||||||
|
|
||||||
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) {
|
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) {
|
||||||
if (pDataBlock == NULL || pDataBlock->info.rows <= 0) {
|
if (pDataBlock->info.rows > 0) {
|
||||||
|
// ASSERT(pDataBlock->info.dataLoad == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDataBlock == NULL || pDataBlock->info.rows <= 0 || pDataBlock->info.dataLoad == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,13 +1161,14 @@ void blockDataEmpty(SSDataBlock* pDataBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->rows = 0;
|
pInfo->rows = 0;
|
||||||
|
pInfo->dataLoad = 0;
|
||||||
pInfo->window.ekey = 0;
|
pInfo->window.ekey = 0;
|
||||||
pInfo->window.skey = 0;
|
pInfo->window.skey = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo temporarily disable it
|
// todo temporarily disable it
|
||||||
static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockInfo, uint32_t numOfRows, bool clearPayload) {
|
static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockInfo, uint32_t numOfRows, bool clearPayload) {
|
||||||
ASSERT(numOfRows > 0 /*&& pBlockInfo->capacity >= pBlockInfo->rows*/);
|
ASSERT(numOfRows > 0);
|
||||||
if (numOfRows <= pBlockInfo->capacity) {
|
if (numOfRows <= pBlockInfo->capacity) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2427,6 +2432,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
pStart += colLen[i];
|
pStart += colLen[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
pBlock->info.rows = numOfRows;
|
pBlock->info.rows = numOfRows;
|
||||||
ASSERT(pStart - pData == dataLen);
|
ASSERT(pStart - pData == dataLen);
|
||||||
return pStart;
|
return pStart;
|
||||||
|
|
|
@ -180,8 +180,6 @@ int32_t tsUptimeInterval = 300; // seconds
|
||||||
char tsUdfdResFuncs[512] = ""; // udfd resident funcs that teardown when udfd exits
|
char tsUdfdResFuncs[512] = ""; // udfd resident funcs that teardown when udfd exits
|
||||||
char tsUdfdLdLibPath[512] = "";
|
char tsUdfdLdLibPath[512] = "";
|
||||||
|
|
||||||
int32_t tsRpcRetryLimit = 100;
|
|
||||||
int32_t tsRpcRetryInterval = 15;
|
|
||||||
#ifndef _STORAGE
|
#ifndef _STORAGE
|
||||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, "dataDir");
|
SConfigItem *pItem = cfgGetItem(pCfg, "dataDir");
|
||||||
|
@ -203,7 +201,9 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
int32_t taosSetTfsCfg(SConfig *pCfg);
|
int32_t taosSetTfsCfg(SConfig *pCfg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct SConfig *taosGetCfg() { return tsCfg; }
|
struct SConfig *taosGetCfg() {
|
||||||
|
return tsCfg;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
||||||
char *apolloUrl) {
|
char *apolloUrl) {
|
||||||
|
@ -313,8 +313,6 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||||
if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
|
if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1;
|
if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "rpcRetryLimit", tsRpcRetryLimit, 1, 100000, 0) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcRetryInterval", tsRpcRetryInterval, 1, 100000, 0) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, 0) != 0) return -1;
|
||||||
|
|
||||||
tsNumOfTaskQueueThreads = tsNumOfCores / 2;
|
tsNumOfTaskQueueThreads = tsNumOfCores / 2;
|
||||||
|
@ -341,7 +339,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
|
||||||
if (cfgAddBool(pCfg, "AVX", tsAVXEnable, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "AVX", tsAVXEnable, 0) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "AVX2", tsAVX2Enable, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "AVX2", tsAVX2Enable, 0) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "FMA", tsFMAEnable, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "FMA", tsFMAEnable, 0) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "SIMD-Supported", tsSIMDEnable, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1;
|
if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1;
|
||||||
if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1;
|
if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1;
|
||||||
|
@ -457,9 +455,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1;
|
if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1;
|
||||||
if (cfgAddString(pCfg, "udfdLdLibPath", tsUdfdLdLibPath, 0) != 0) return -1;
|
if (cfgAddString(pCfg, "udfdLdLibPath", tsUdfdLdLibPath, 0) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddInt32(pCfg, "rpcRetryLimit", tsRpcRetryLimit, 1, 100000, 0) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcRetryInterval", tsRpcRetryInterval, 1, 100000, 0) != 0) return -1;
|
|
||||||
|
|
||||||
GRANT_CFG_ADD;
|
GRANT_CFG_ADD;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -674,8 +669,6 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
||||||
tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval;
|
tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval;
|
||||||
tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
||||||
|
|
||||||
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
|
||||||
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
|
||||||
tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32;
|
tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -738,10 +731,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
||||||
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
||||||
|
|
||||||
tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32;
|
|
||||||
tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32;
|
|
||||||
tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32;
|
|
||||||
|
|
||||||
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||||
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
||||||
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
||||||
|
@ -761,9 +750,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
if (tsQueryBufferSize >= 0) {
|
if (tsQueryBufferSize >= 0) {
|
||||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
|
||||||
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
|
||||||
GRANT_CFG_GET;
|
GRANT_CFG_GET;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,12 +159,12 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWorker == NULL) return -1;
|
if (pWorker == NULL) return -1;
|
||||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||||
if (pMsg == NULL) return -1;
|
if (pMsg == NULL) return -1;
|
||||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||||
pRpc->pCont = NULL;
|
pRpc->pCont = NULL;
|
||||||
|
|
||||||
dTrace("msg:%p, is created and will put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
dTrace("msg:%p, is created and will put into %s queue, type:%s len:%d", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType), pRpc->contLen);
|
||||||
int32_t code = mmPutMsgToWorker(pMgmt, pWorker, pMsg);
|
int32_t code = mmPutMsgToWorker(pMgmt, pWorker, pMsg);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
dTrace("msg:%p, is freed", pMsg);
|
dTrace("msg:%p, is freed", pMsg);
|
||||||
|
|
|
@ -58,19 +58,19 @@ int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||||
if (pMsg == NULL) return -1;
|
if (pMsg == NULL) return -1;
|
||||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||||
pRpc->pCont = NULL;
|
pRpc->pCont = NULL;
|
||||||
|
|
||||||
switch (qtype) {
|
switch (qtype) {
|
||||||
case QUERY_QUEUE:
|
case QUERY_QUEUE:
|
||||||
dTrace("msg:%p, is created and will put into qnode-query queue", pMsg);
|
dTrace("msg:%p, is created and will put into qnode-query queue, len:%d", pMsg, pRpc->contLen);
|
||||||
taosWriteQitem(pMgmt->queryWorker.queue, pMsg);
|
taosWriteQitem(pMgmt->queryWorker.queue, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
case READ_QUEUE:
|
case READ_QUEUE:
|
||||||
case FETCH_QUEUE:
|
case FETCH_QUEUE:
|
||||||
dTrace("msg:%p, is created and will put into qnode-fetch queue", pMsg);
|
dTrace("msg:%p, is created and will put into qnode-fetch queue, len:%d", pMsg, pRpc->contLen);
|
||||||
taosWriteQitem(pMgmt->fetchWorker.queue, pMsg);
|
taosWriteQitem(pMgmt->fetchWorker.queue, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -130,7 +130,7 @@ void smStopWorker(SSnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) {
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
pRpc->pCont = NULL;
|
pRpc->pCont = NULL;
|
||||||
|
@ -139,8 +139,8 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
|
|
||||||
SSnode *pSnode = pMgmt->pSnode;
|
SSnode *pSnode = pMgmt->pSnode;
|
||||||
if (pSnode == NULL) {
|
if (pSnode == NULL) {
|
||||||
dError("msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
dError("msg:%p failed to put into snode queue since %s, type:%s qtype:%d len:%d", pMsg, terrstr(),
|
||||||
TMSG_INFO(pMsg->msgType), qtype);
|
TMSG_INFO(pMsg->msgType), qtype, pRpc->contLen);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
pRpc->pCont = NULL;
|
pRpc->pCont = NULL;
|
||||||
|
|
|
@ -38,6 +38,8 @@ typedef struct SVnodeMgmt {
|
||||||
TdThreadRwlock lock;
|
TdThreadRwlock lock;
|
||||||
SVnodesStat state;
|
SVnodesStat state;
|
||||||
STfs *pTfs;
|
STfs *pTfs;
|
||||||
|
TdThread thread;
|
||||||
|
bool stop;
|
||||||
} SVnodeMgmt;
|
} SVnodeMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -334,6 +334,62 @@ static void vmCleanup(SVnodeMgmt *pMgmt) {
|
||||||
taosMemoryFree(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vmCheckSyncTimeout(SVnodeMgmt *pMgmt) {
|
||||||
|
int32_t numOfVnodes = 0;
|
||||||
|
SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
|
SVnodeObj *pVnode = ppVnodes[i];
|
||||||
|
vnodeSyncCheckTimeout(pVnode->pImpl);
|
||||||
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ppVnodes != NULL) {
|
||||||
|
taosMemoryFree(ppVnodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *vmThreadFp(void *param) {
|
||||||
|
SVnodeMgmt *pMgmt = param;
|
||||||
|
int64_t lastTime = 0;
|
||||||
|
setThreadName("vnode-timer");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
lastTime++;
|
||||||
|
taosMsleep(100);
|
||||||
|
if (pMgmt->stop) break;
|
||||||
|
if (lastTime % 10 != 0) continue;
|
||||||
|
|
||||||
|
int64_t sec = lastTime / 10;
|
||||||
|
if (sec % (VNODE_TIMEOUT_SEC / 2) == 0) {
|
||||||
|
vmCheckSyncTimeout(pMgmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t vmInitTimer(SVnodeMgmt *pMgmt) {
|
||||||
|
TdThreadAttr thAttr;
|
||||||
|
taosThreadAttrInit(&thAttr);
|
||||||
|
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
if (taosThreadCreate(&pMgmt->thread, &thAttr, vmThreadFp, pMgmt) != 0) {
|
||||||
|
dError("failed to create vnode timer thread since %s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosThreadAttrDestroy(&thAttr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vmCleanupTimer(SVnodeMgmt *pMgmt) {
|
||||||
|
pMgmt->stop = true;
|
||||||
|
if (taosCheckPthreadValid(pMgmt->thread)) {
|
||||||
|
taosThreadJoin(pMgmt->thread, NULL);
|
||||||
|
taosThreadClear(&pMgmt->thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
|
@ -510,12 +566,10 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
|
||||||
taosMemoryFree(ppVnodes);
|
taosMemoryFree(ppVnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return vmInitTimer(pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vmStop(SVnodeMgmt *pMgmt) {
|
static void vmStop(SVnodeMgmt *pMgmt) { vmCleanupTimer(pMgmt); }
|
||||||
// process inside the vnode
|
|
||||||
}
|
|
||||||
|
|
||||||
SMgmtFunc vmGetMgmtFunc() {
|
SMgmtFunc vmGetMgmtFunc() {
|
||||||
SMgmtFunc mgmtFunc = {0};
|
SMgmtFunc mgmtFunc = {0};
|
||||||
|
|
|
@ -233,7 +233,7 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) {
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
pRpc->pCont = NULL;
|
pRpc->pCont = NULL;
|
||||||
|
@ -241,7 +241,7 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgHead *pHead = pRpc->pCont;
|
SMsgHead *pHead = pRpc->pCont;
|
||||||
dTrace("vgId:%d, msg:%p is created, type:%s", pHead->vgId, pMsg, TMSG_INFO(pRpc->msgType));
|
dTrace("vgId:%d, msg:%p is created, type:%s len:%d", pHead->vgId, pMsg, TMSG_INFO(pRpc->msgType), pRpc->contLen);
|
||||||
|
|
||||||
pHead->contLen = htonl(pHead->contLen);
|
pHead->contLen = htonl(pHead->contLen);
|
||||||
pHead->vgId = htonl(pHead->vgId);
|
pHead->vgId = htonl(pHead->vgId);
|
||||||
|
|
|
@ -149,10 +149,13 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0) osUpdate();
|
if (count == 10) {
|
||||||
|
osUpdate();
|
||||||
count %= 10;
|
count = 0;
|
||||||
|
} else {
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,11 +141,12 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pRpc->info.wrapper = pWrapper;
|
pRpc->info.wrapper = pWrapper;
|
||||||
pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||||
if (pMsg == NULL) goto _OVER;
|
if (pMsg == NULL) goto _OVER;
|
||||||
|
|
||||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||||
dGTrace("msg:%p, is created, type:%s handle:%p", pMsg, TMSG_INFO(pRpc->msgType), pMsg->info.handle);
|
dGTrace("msg:%p, is created, type:%s handle:%p len:%d", pMsg, TMSG_INFO(pRpc->msgType), pMsg->info.handle,
|
||||||
|
pRpc->contLen);
|
||||||
|
|
||||||
code = dmProcessNodeMsg(pWrapper, pMsg);
|
code = dmProcessNodeMsg(pWrapper, pMsg);
|
||||||
|
|
||||||
|
@ -258,8 +259,6 @@ int32_t dmInitClient(SDnode *pDnode) {
|
||||||
rpcInit.rfp = rpcRfp;
|
rpcInit.rfp = rpcRfp;
|
||||||
rpcInit.compressSize = tsCompressMsgSize;
|
rpcInit.compressSize = tsCompressMsgSize;
|
||||||
|
|
||||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
|
||||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
|
||||||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||||
|
|
|
@ -88,7 +88,9 @@ typedef struct {
|
||||||
int64_t sync;
|
int64_t sync;
|
||||||
int32_t errCode;
|
int32_t errCode;
|
||||||
int32_t transId;
|
int32_t transId;
|
||||||
SRWLatch lock;
|
int32_t transSec;
|
||||||
|
int64_t transSeq;
|
||||||
|
TdThreadMutex lock;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
int8_t numOfReplicas;
|
int8_t numOfReplicas;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
|
|
|
@ -26,6 +26,7 @@ int32_t mndInitSync(SMnode *pMnode);
|
||||||
void mndCleanupSync(SMnode *pMnode);
|
void mndCleanupSync(SMnode *pMnode);
|
||||||
bool mndIsLeader(SMnode *pMnode);
|
bool mndIsLeader(SMnode *pMnode);
|
||||||
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId);
|
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId);
|
||||||
|
void mndSyncCheckTimeout(SMnode *pMnode);
|
||||||
void mndSyncStart(SMnode *pMnode);
|
void mndSyncStart(SMnode *pMnode);
|
||||||
void mndSyncStop(SMnode *pMnode);
|
void mndSyncStop(SMnode *pMnode);
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, voi
|
||||||
void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname);
|
void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname);
|
||||||
void mndTransSetSerial(STrans *pTrans);
|
void mndTransSetSerial(STrans *pTrans);
|
||||||
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
||||||
|
int32_t mndTrancCheckConflict(SMnode *pMnode, STrans *pTrans);
|
||||||
|
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
||||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
||||||
|
|
|
@ -554,14 +554,6 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
goto SUBSCRIBE_OVER;
|
goto SUBSCRIBE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check topic only
|
|
||||||
#if 0
|
|
||||||
if (mndCheckDbPrivilegeByName(pMnode, pMsg->info.conn.user, MND_OPER_READ_DB, pTopic->db) != 0) {
|
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
|
||||||
goto SUBSCRIBE_OVER;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mndCheckTopicPrivilege(pMnode, pMsg->info.conn.user, MND_OPER_SUBSCRIBE, pTopic) != 0) {
|
if (mndCheckTopicPrivilege(pMnode, pMsg->info.conn.user, MND_OPER_SUBSCRIBE, pTopic) != 0) {
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
goto SUBSCRIBE_OVER;
|
goto SUBSCRIBE_OVER;
|
||||||
|
|
|
@ -776,6 +776,8 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
mndTransSetDbName(pTrans, pOld->name, NULL);
|
mndTransSetDbName(pTrans, pOld->name, NULL);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||||
|
|
||||||
if (mndSetAlterDbRedoLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
if (mndSetAlterDbRedoLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||||
if (mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
if (mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||||
if (mndSetAlterDbRedoActions(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
if (mndSetAlterDbRedoActions(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||||
|
@ -835,12 +837,14 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
mError("db:%s, failed to alter since %s", alterReq.db, terrstr());
|
mError("db:%s, failed to alter since %s", alterReq.db, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
taosArrayDestroy(dbObj.cfg.pRetensions);
|
taosArrayDestroy(dbObj.cfg.pRetensions);
|
||||||
|
|
||||||
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1183,7 +1187,8 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
|
||||||
|
|
||||||
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
||||||
|
|
||||||
if (pReq == NULL || pReq->vgVersion < pDb->vgVersion || pReq->dbId != pDb->uid || numOfTable != pReq->numOfTable || pReq->stateTs < pDb->stateTs) {
|
if (pReq == NULL || pReq->vgVersion < pDb->vgVersion || pReq->dbId != pDb->uid || numOfTable != pReq->numOfTable ||
|
||||||
|
pReq->stateTs < pDb->stateTs) {
|
||||||
mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos);
|
mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,7 +1303,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
||||||
|
|
||||||
SUseDbRsp usedbRsp = {0};
|
SUseDbRsp usedbRsp = {0};
|
||||||
|
|
||||||
if ((0 == strcasecmp(pDbVgVersion->dbFName, TSDB_INFORMATION_SCHEMA_DB) || (0 == strcasecmp(pDbVgVersion->dbFName, TSDB_PERFORMANCE_SCHEMA_DB)))) {
|
if ((0 == strcasecmp(pDbVgVersion->dbFName, TSDB_INFORMATION_SCHEMA_DB) ||
|
||||||
|
(0 == strcasecmp(pDbVgVersion->dbFName, TSDB_PERFORMANCE_SCHEMA_DB)))) {
|
||||||
memcpy(usedbRsp.db, pDbVgVersion->dbFName, TSDB_DB_FNAME_LEN);
|
memcpy(usedbRsp.db, pDbVgVersion->dbFName, TSDB_DB_FNAME_LEN);
|
||||||
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
||||||
if (pDbVgVersion->vgVersion < vgVersion) {
|
if (pDbVgVersion->vgVersion < vgVersion) {
|
||||||
|
|
|
@ -101,6 +101,7 @@ static void *mndBuildCheckpointTickMsg(int32_t *pContLen, int64_t sec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndPullupTrans(SMnode *pMnode) {
|
static void mndPullupTrans(SMnode *pMnode) {
|
||||||
|
mTrace("pullup trans msg");
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
|
@ -110,6 +111,7 @@ static void mndPullupTrans(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndPullupTtl(SMnode *pMnode) {
|
static void mndPullupTtl(SMnode *pMnode) {
|
||||||
|
mTrace("pullup ttl");
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen};
|
||||||
|
@ -117,6 +119,7 @@ static void mndPullupTtl(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndCalMqRebalance(SMnode *pMnode) {
|
static void mndCalMqRebalance(SMnode *pMnode) {
|
||||||
|
mTrace("calc mq rebalance");
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
|
@ -143,6 +146,7 @@ static void mndStreamCheckpointTick(SMnode *pMnode, int64_t sec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndPullupTelem(SMnode *pMnode) {
|
static void mndPullupTelem(SMnode *pMnode) {
|
||||||
|
mTrace("pullup telem msg");
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
|
@ -152,6 +156,7 @@ static void mndPullupTelem(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndPullupGrant(SMnode *pMnode) {
|
static void mndPullupGrant(SMnode *pMnode) {
|
||||||
|
mTrace("pullup grant msg");
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
|
@ -162,6 +167,7 @@ static void mndPullupGrant(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndIncreaseUpTime(SMnode *pMnode) {
|
static void mndIncreaseUpTime(SMnode *pMnode) {
|
||||||
|
mTrace("increate uptime");
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildTimerMsg(&contLen);
|
void *pReq = mndBuildTimerMsg(&contLen);
|
||||||
if (pReq != NULL) {
|
if (pReq != NULL) {
|
||||||
|
@ -213,6 +219,9 @@ static void mndSetVgroupOffline(SMnode *pMnode, int32_t dnodeId, int64_t curMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndCheckDnodeOffline(SMnode *pMnode) {
|
static void mndCheckDnodeOffline(SMnode *pMnode) {
|
||||||
|
mTrace("check dnode offline");
|
||||||
|
if (mndAcquireRpc(pMnode) != 0) return;
|
||||||
|
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
|
||||||
|
@ -230,6 +239,8 @@ static void mndCheckDnodeOffline(SMnode *pMnode) {
|
||||||
|
|
||||||
sdbRelease(pSdb, pDnode);
|
sdbRelease(pSdb, pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mndReleaseRpc(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mndThreadFp(void *param) {
|
static void *mndThreadFp(void *param) {
|
||||||
|
@ -277,6 +288,10 @@ static void *mndThreadFp(void *param) {
|
||||||
if (sec % (tsStatusInterval * 5) == 0) {
|
if (sec % (tsStatusInterval * 5) == 0) {
|
||||||
mndCheckDnodeOffline(pMnode);
|
mndCheckDnodeOffline(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sec % (MNODE_TIMEOUT_SEC / 2) == 0) {
|
||||||
|
mndSyncCheckTimeout(pMnode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -769,7 +769,7 @@ static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfQueries = taosArrayGetSize(pConn->pQueries);
|
int32_t numOfQueries = taosArrayGetSize(pConn->pQueries);
|
||||||
for (int32_t i = 0; i < numOfQueries; ++i) {
|
for (int32_t i = 0; i < numOfQueries && numOfRows < rows; ++i) {
|
||||||
SQueryDesc *pQuery = taosArrayGet(pConn->pQueries, i);
|
SQueryDesc *pQuery = taosArrayGet(pConn->pQueries, i);
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
|
||||||
|
|
|
@ -78,35 +78,38 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
|
||||||
SSdbRaw *pRaw = pMsg->pCont;
|
SSdbRaw *pRaw = pMsg->pCont;
|
||||||
|
|
||||||
int32_t transId = sdbGetIdFromRaw(pMnode->pSdb, pRaw);
|
int32_t transId = sdbGetIdFromRaw(pMnode->pSdb, pRaw);
|
||||||
pMgmt->errCode = pMeta->code;
|
|
||||||
mInfo("trans:%d, is proposed, saved:%d code:0x%x, apply index:%" PRId64 " term:%" PRIu64 " config:%" PRId64
|
mInfo("trans:%d, is proposed, saved:%d code:0x%x, apply index:%" PRId64 " term:%" PRIu64 " config:%" PRId64
|
||||||
" role:%s raw:%p",
|
" role:%s raw:%p sec:%d seq:%" PRId64,
|
||||||
transId, pMgmt->transId, pMeta->code, pMeta->index, pMeta->term, pMeta->lastConfigIndex, syncStr(pMeta->state),
|
transId, pMgmt->transId, pMeta->code, pMeta->index, pMeta->term, pMeta->lastConfigIndex, syncStr(pMeta->state),
|
||||||
pRaw);
|
pRaw, pMgmt->transSec, pMgmt->transSeq);
|
||||||
|
|
||||||
if (pMgmt->errCode == 0) {
|
if (pMeta->code == 0) {
|
||||||
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||||
sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex);
|
sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->lock);
|
taosThreadMutexLock(&pMgmt->lock);
|
||||||
|
pMgmt->errCode = pMeta->code;
|
||||||
|
|
||||||
if (transId <= 0) {
|
if (transId <= 0) {
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
mError("trans:%d, invalid commit msg", transId);
|
mError("trans:%d, invalid commit msg, cache transId:%d seq:%" PRId64, transId, pMgmt->transId, pMgmt->transSeq);
|
||||||
} else if (transId == pMgmt->transId) {
|
} else if (transId == pMgmt->transId) {
|
||||||
if (pMgmt->errCode != 0) {
|
if (pMgmt->errCode != 0) {
|
||||||
mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode));
|
mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode));
|
||||||
} else {
|
} else {
|
||||||
mInfo("trans:%d, is proposed and post sem", transId);
|
mInfo("trans:%d, is proposed and post sem, seq:%" PRId64, transId, pMgmt->transSeq);
|
||||||
}
|
}
|
||||||
pMgmt->transId = 0;
|
pMgmt->transId = 0;
|
||||||
|
pMgmt->transSec = 0;
|
||||||
|
pMgmt->transSeq = 0;
|
||||||
tsem_post(&pMgmt->syncSem);
|
tsem_post(&pMgmt->syncSem);
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
} else {
|
} else {
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
STrans *pTrans = mndAcquireTrans(pMnode, transId);
|
STrans *pTrans = mndAcquireTrans(pMnode, transId);
|
||||||
if (pTrans != NULL) {
|
if (pTrans != NULL) {
|
||||||
mInfo("trans:%d, execute in mnode which not leader", transId);
|
mInfo("trans:%d, execute in mnode which not leader or sync timeout", transId);
|
||||||
mndTransExecute(pMnode, pTrans);
|
mndTransExecute(pMnode, pTrans);
|
||||||
mndReleaseTrans(pMnode, pTrans);
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
// sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA);
|
// sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA);
|
||||||
|
@ -199,17 +202,19 @@ int32_t mndSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int3
|
||||||
|
|
||||||
static void mndBecomeFollower(const SSyncFSM *pFsm) {
|
static void mndBecomeFollower(const SSyncFSM *pFsm) {
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
mInfo("vgId:1, become follower");
|
mInfo("vgId:1, become follower");
|
||||||
|
|
||||||
taosWLockLatch(&pMnode->syncMgmt.lock);
|
taosThreadMutexLock(&pMgmt->lock);
|
||||||
if (pMnode->syncMgmt.transId != 0) {
|
if (pMgmt->transId != 0) {
|
||||||
mInfo("vgId:1, become follower and post sem, trans:%d, failed to propose since not leader",
|
mInfo("vgId:1, become follower and post sem, trans:%d, failed to propose since not leader", pMgmt->transId);
|
||||||
pMnode->syncMgmt.transId);
|
pMgmt->transId = 0;
|
||||||
pMnode->syncMgmt.transId = 0;
|
pMgmt->transSec = 0;
|
||||||
pMnode->syncMgmt.errCode = TSDB_CODE_SYN_NOT_LEADER;
|
pMgmt->transSeq = 0;
|
||||||
tsem_post(&pMnode->syncMgmt.syncSem);
|
pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
|
tsem_post(&pMgmt->syncSem);
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pMnode->syncMgmt.lock);
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndBecomeLeader(const SSyncFSM *pFsm) {
|
static void mndBecomeLeader(const SSyncFSM *pFsm) {
|
||||||
|
@ -265,8 +270,10 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
||||||
|
|
||||||
int32_t mndInitSync(SMnode *pMnode) {
|
int32_t mndInitSync(SMnode *pMnode) {
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
taosInitRWLatch(&pMgmt->lock);
|
taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||||
pMgmt->transId = 0;
|
pMgmt->transId = 0;
|
||||||
|
pMgmt->transSec = 0;
|
||||||
|
pMgmt->transSeq = 0;
|
||||||
|
|
||||||
SSyncInfo syncInfo = {
|
SSyncInfo syncInfo = {
|
||||||
.snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT,
|
.snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT,
|
||||||
|
@ -313,12 +320,38 @@ void mndCleanupSync(SMnode *pMnode) {
|
||||||
mInfo("mnode-sync is stopped, id:%" PRId64, pMgmt->sync);
|
mInfo("mnode-sync is stopped, id:%" PRId64, pMgmt->sync);
|
||||||
|
|
||||||
tsem_destroy(&pMgmt->syncSem);
|
tsem_destroy(&pMgmt->syncSem);
|
||||||
|
taosThreadMutexDestroy(&pMgmt->lock);
|
||||||
memset(pMgmt, 0, sizeof(SSyncMgmt));
|
memset(pMgmt, 0, sizeof(SSyncMgmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mndSyncCheckTimeout(SMnode *pMnode) {
|
||||||
|
mTrace("check sync timeout");
|
||||||
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
|
taosThreadMutexLock(&pMgmt->lock);
|
||||||
|
if (pMgmt->transId != 0) {
|
||||||
|
int32_t curSec = taosGetTimestampSec();
|
||||||
|
int32_t delta = curSec - pMgmt->transSec;
|
||||||
|
if (delta > MNODE_TIMEOUT_SEC) {
|
||||||
|
mError("trans:%d, failed to propose since timeout, start:%d cur:%d delta:%d seq:%" PRId64, pMgmt->transId,
|
||||||
|
pMgmt->transSec, curSec, delta, pMgmt->transSeq);
|
||||||
|
pMgmt->transId = 0;
|
||||||
|
pMgmt->transSec = 0;
|
||||||
|
pMgmt->transSeq = 0;
|
||||||
|
terrno = TSDB_CODE_SYN_TIMEOUT;
|
||||||
|
pMgmt->errCode = TSDB_CODE_SYN_TIMEOUT;
|
||||||
|
tsem_post(&pMgmt->syncSem);
|
||||||
|
} else {
|
||||||
|
mDebug("trans:%d, waiting for sync confirm, start:%d cur:%d delta:%d seq:%" PRId64, pMgmt->transId,
|
||||||
|
pMgmt->transSec, curSec, curSec - pMgmt->transSec, pMgmt->transSeq);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// mTrace("check sync timeout msg, no trans waiting for confirm");
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
pMgmt->errCode = 0;
|
|
||||||
|
|
||||||
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
||||||
if (req.contLen <= 0) return -1;
|
if (req.contLen <= 0) return -1;
|
||||||
|
@ -327,35 +360,42 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
if (req.pCont == NULL) return -1;
|
if (req.pCont == NULL) return -1;
|
||||||
memcpy(req.pCont, pRaw, req.contLen);
|
memcpy(req.pCont, pRaw, req.contLen);
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->lock);
|
taosThreadMutexLock(&pMgmt->lock);
|
||||||
|
pMgmt->errCode = 0;
|
||||||
|
|
||||||
if (pMgmt->transId != 0) {
|
if (pMgmt->transId != 0) {
|
||||||
mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId);
|
mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId);
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
terrno = TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED;
|
terrno = TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED;
|
||||||
return -1;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("trans:%d, will be proposed", transId);
|
mInfo("trans:%d, will be proposed", transId);
|
||||||
pMgmt->transId = transId;
|
pMgmt->transId = transId;
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
pMgmt->transSec = taosGetTimestampSec();
|
||||||
|
|
||||||
int32_t code = syncPropose(pMgmt->sync, &req, false);
|
int64_t seq = 0;
|
||||||
|
int32_t code = syncPropose(pMgmt->sync, &req, false, &seq);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
mInfo("trans:%d, is proposing and wait sem", pMgmt->transId);
|
mInfo("trans:%d, is proposing and wait sem, seq:%" PRId64, transId, seq);
|
||||||
|
pMgmt->transSeq = seq;
|
||||||
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
tsem_wait(&pMgmt->syncSem);
|
tsem_wait(&pMgmt->syncSem);
|
||||||
} else if (code > 0) {
|
} else if (code > 0) {
|
||||||
mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId);
|
mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId);
|
||||||
taosWLockLatch(&pMgmt->lock);
|
|
||||||
pMgmt->transId = 0;
|
pMgmt->transId = 0;
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
pMgmt->transSec = 0;
|
||||||
|
pMgmt->transSeq = 0;
|
||||||
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||||
sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID);
|
sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID);
|
||||||
code = 0;
|
code = 0;
|
||||||
} else {
|
} else {
|
||||||
mError("trans:%d, failed to proposed since %s", transId, terrstr());
|
mError("trans:%d, failed to proposed since %s", transId, terrstr());
|
||||||
taosWLockLatch(&pMgmt->lock);
|
|
||||||
pMgmt->transId = 0;
|
pMgmt->transId = 0;
|
||||||
taosWUnLockLatch(&pMgmt->lock);
|
pMgmt->transSec = 0;
|
||||||
|
pMgmt->transSeq = 0;
|
||||||
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
if (terrno == 0) {
|
if (terrno == 0) {
|
||||||
terrno = TSDB_CODE_APP_ERROR;
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +409,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = pMgmt->errCode;
|
terrno = pMgmt->errCode;
|
||||||
return pMgmt->errCode;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndSyncStart(SMnode *pMnode) {
|
void mndSyncStart(SMnode *pMnode) {
|
||||||
|
@ -382,13 +422,17 @@ void mndSyncStart(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndSyncStop(SMnode *pMnode) {
|
void mndSyncStop(SMnode *pMnode) {
|
||||||
taosWLockLatch(&pMnode->syncMgmt.lock);
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
if (pMnode->syncMgmt.transId != 0) {
|
|
||||||
mInfo("vgId:1, is stopped and post sem, trans:%d", pMnode->syncMgmt.transId);
|
taosThreadMutexLock(&pMgmt->lock);
|
||||||
pMnode->syncMgmt.transId = 0;
|
if (pMgmt->transId != 0) {
|
||||||
tsem_post(&pMnode->syncMgmt.syncSem);
|
mInfo("vgId:1, is stopped and post sem, trans:%d", pMgmt->transId);
|
||||||
|
pMgmt->transId = 0;
|
||||||
|
pMgmt->transSec = 0;
|
||||||
|
pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING;
|
||||||
|
tsem_post(&pMgmt->syncSem);
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pMnode->syncMgmt.lock);
|
taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndIsLeader(SMnode *pMnode) {
|
bool mndIsLeader(SMnode *pMnode) {
|
||||||
|
|
|
@ -838,7 +838,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
||||||
return conflict;
|
return conflict;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
int32_t mndTrancCheckConflict(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
|
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
|
||||||
if (strlen(pTrans->dbname) == 0 && strlen(pTrans->stbname) == 0) {
|
if (strlen(pTrans->dbname) == 0 && strlen(pTrans->stbname) == 0) {
|
||||||
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||||
|
@ -853,6 +853,14 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pTrans->commitActions) <= 0) {
|
if (taosArrayGetSize(pTrans->commitActions) <= 0) {
|
||||||
terrno = TSDB_CODE_MND_TRANS_CLOG_IS_NULL;
|
terrno = TSDB_CODE_MND_TRANS_CLOG_IS_NULL;
|
||||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||||
|
@ -1027,6 +1035,7 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||||
if (pAction != NULL) {
|
if (pAction != NULL) {
|
||||||
pAction->msgReceived = 1;
|
pAction->msgReceived = 1;
|
||||||
pAction->errCode = pRsp->code;
|
pAction->errCode = pRsp->code;
|
||||||
|
pTrans->lastErrorNo = pRsp->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mndTransStr(pAction->stage),
|
mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mndTransStr(pAction->stage),
|
||||||
|
@ -1238,7 +1247,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
||||||
if (numOfActions == 0) return code;
|
if (numOfActions == 0) return code;
|
||||||
if (pTrans->redoActionPos >= numOfActions) return code;
|
if (pTrans->redoActionPos >= numOfActions) return code;
|
||||||
|
|
||||||
mInfo("trans:%d, execute %d actions serial", pTrans->id, numOfActions);
|
mInfo("trans:%d, execute %d actions serial, current redoAction:%d", pTrans->id, numOfActions, pTrans->redoActionPos);
|
||||||
|
|
||||||
for (int32_t action = pTrans->redoActionPos; action < numOfActions; ++action) {
|
for (int32_t action = pTrans->redoActionPos; action < numOfActions; ++action) {
|
||||||
STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->redoActionPos);
|
STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->redoActionPos);
|
||||||
|
@ -1289,13 +1298,16 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
||||||
} else if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
} else if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mInfo("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
mInfo("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||||
break;
|
break;
|
||||||
} else if (code == pAction->retryCode) {
|
} else if (code == pAction->retryCode || code == TSDB_CODE_SYN_PROPOSE_NOT_READY ||
|
||||||
|
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
mInfo("trans:%d, %s:%d receive code:0x%x and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id, code);
|
mInfo("trans:%d, %s:%d receive code:0x%x and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id, code);
|
||||||
|
pTrans->lastErrorNo = code;
|
||||||
taosMsleep(300);
|
taosMsleep(300);
|
||||||
action--;
|
action--;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
pTrans->lastErrorNo = code;
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
mInfo("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id,
|
mInfo("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id,
|
||||||
mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes);
|
mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes);
|
||||||
|
|
|
@ -54,6 +54,7 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs);
|
||||||
void vnodeDestroy(const char *path, STfs *pTfs);
|
void vnodeDestroy(const char *path, STfs *pTfs);
|
||||||
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
||||||
void vnodePreClose(SVnode *pVnode);
|
void vnodePreClose(SVnode *pVnode);
|
||||||
|
void vnodeSyncCheckTimeout(SVnode* pVnode);
|
||||||
void vnodeClose(SVnode *pVnode);
|
void vnodeClose(SVnode *pVnode);
|
||||||
|
|
||||||
int32_t vnodeStart(SVnode *pVnode);
|
int32_t vnodeStart(SVnode *pVnode);
|
||||||
|
|
|
@ -353,7 +353,12 @@ struct SVnode {
|
||||||
bool blocked;
|
bool blocked;
|
||||||
bool restored;
|
bool restored;
|
||||||
tsem_t syncSem;
|
tsem_t syncSem;
|
||||||
|
int32_t blockSec;
|
||||||
|
int64_t blockSeq;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
|
#if 0
|
||||||
|
SRpcHandleInfo blockInfo;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
||||||
|
|
|
@ -132,7 +132,8 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
||||||
goto _err2;
|
goto _err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCache->sTagFilterResCache.pTableEntry = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
pCache->sTagFilterResCache.pTableEntry =
|
||||||
|
taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
|
||||||
if (pCache->sTagFilterResCache.pTableEntry == NULL) {
|
if (pCache->sTagFilterResCache.pTableEntry == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err2;
|
goto _err2;
|
||||||
|
@ -419,7 +420,8 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1, bool* acquireRes) {
|
int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1,
|
||||||
|
bool* acquireRes) {
|
||||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
||||||
|
|
||||||
// generate the composed key for LRU cache
|
// generate the composed key for LRU cache
|
||||||
|
@ -470,9 +472,12 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
||||||
for (int32_t i = 0; i < s; ++i) {
|
for (int32_t i = 0; i < s; ++i) {
|
||||||
SListNode** p1 = taosArrayGet(pList, i);
|
SListNode** p1 = taosArrayGet(pList, i);
|
||||||
tdListPopNode(&(*pEntry)->list, *p1);
|
tdListPopNode(&(*pEntry)->list, *p1);
|
||||||
|
taosMemoryFree(*p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pEntry)->qTimes = 0; // reset the query times
|
(*pEntry)->qTimes = 0; // reset the query times
|
||||||
|
|
||||||
|
taosArrayDestroy(pList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +492,8 @@ static void freePayload(const void* key, size_t keyLen, void* value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check both the payload size and selectivity ratio
|
// check both the payload size and selectivity ratio
|
||||||
int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, void* pPayload, int32_t payloadLen, double selectivityRatio) {
|
int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, void* pPayload,
|
||||||
|
int32_t payloadLen, double selectivityRatio) {
|
||||||
if (selectivityRatio > tsSelectivityRatio) {
|
if (selectivityRatio > tsSelectivityRatio) {
|
||||||
metaDebug("vgId:%d, suid:%" PRIu64
|
metaDebug("vgId:%d, suid:%" PRIu64
|
||||||
" failed to add to uid list cache, due to selectivity ratio %.2f less than threshold %.2f",
|
" failed to add to uid list cache, due to selectivity ratio %.2f less than threshold %.2f",
|
||||||
|
@ -525,9 +531,10 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
||||||
ASSERT(sizeof(uint64_t) + keyLen == 24);
|
ASSERT(sizeof(uint64_t) + keyLen == 24);
|
||||||
|
|
||||||
// add to cache.
|
// add to cache.
|
||||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL, TAOS_LRU_PRIORITY_LOW);
|
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||||
metaDebug("vgId:%d, suid:%"PRIu64" list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode),
|
TAOS_LRU_PRIORITY_LOW);
|
||||||
suid, (int32_t) taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry));
|
metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode), suid,
|
||||||
|
(int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -763,7 +763,7 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, const void *pMsg, int32_t inpu
|
||||||
tb_uid_t suid) {
|
tb_uid_t suid) {
|
||||||
const SSubmitReq *pReq = (const SSubmitReq *)pMsg;
|
const SSubmitReq *pReq = (const SSubmitReq *)pMsg;
|
||||||
|
|
||||||
void *qItem = taosAllocateQitem(pReq->header.contLen, DEF_QITEM);
|
void *qItem = taosAllocateQitem(pReq->header.contLen, DEF_QITEM, 0);
|
||||||
if (!qItem) {
|
if (!qItem) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -725,10 +725,16 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgL
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pTq->pushLock);
|
taosWUnLockLatch(&pTq->pushLock);
|
||||||
|
|
||||||
|
STqHandle* pHandle = taosHashGet(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||||
|
if (pHandle) {
|
||||||
|
if (pHandle->pRef) {
|
||||||
|
walCloseRef(pTq->pVnode->pWal, pHandle->pRef->refId);
|
||||||
|
}
|
||||||
code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
|
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
code = tqOffsetDelete(pTq->pOffsetStore, pReq->subKey);
|
code = tqOffsetDelete(pTq->pOffsetStore, pReq->subKey);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -736,7 +742,7 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgL
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) {
|
if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) {
|
||||||
ASSERT(0);
|
tqError("cannot process tq delete req %s, since no such offset in tdb", pReq->subKey);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1265,7 +1271,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
||||||
qDebug("delete req enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
|
qDebug("delete req enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
|
||||||
|
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
SStreamRefDataBlock* pRefBlock = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM);
|
SStreamRefDataBlock* pRefBlock = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0);
|
||||||
pRefBlock->type = STREAM_INPUT__REF_DATA_BLOCK;
|
pRefBlock->type = STREAM_INPUT__REF_DATA_BLOCK;
|
||||||
pRefBlock->pBlock = pDelBlock;
|
pRefBlock->pBlock = pDelBlock;
|
||||||
pRefBlock->dataRef = pRef;
|
pRefBlock->dataRef = pRef;
|
||||||
|
@ -1297,7 +1303,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||||
pStreamBlock->type = STREAM_INPUT__DATA_BLOCK;
|
pStreamBlock->type = STREAM_INPUT__DATA_BLOCK;
|
||||||
pStreamBlock->blocks = taosArrayInit(0, sizeof(SSDataBlock));
|
pStreamBlock->blocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||||
SSDataBlock block = {0};
|
SSDataBlock block = {0};
|
||||||
|
|
|
@ -533,6 +533,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
||||||
pBlock->info.id.uid = pReader->msgIter.uid;
|
pBlock->info.id.uid = pReader->msgIter.uid;
|
||||||
pBlock->info.rows = pReader->msgIter.numOfRows;
|
pBlock->info.rows = pReader->msgIter.numOfRows;
|
||||||
pBlock->info.version = pReader->pMsg->version;
|
pBlock->info.version = pReader->pMsg->version;
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
|
|
||||||
while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) {
|
while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) {
|
||||||
tdSTSRowIterReset(&iter, row);
|
tdSTSRowIterReset(&iter, row);
|
||||||
|
|
|
@ -121,7 +121,7 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
||||||
return &pInfo->blockData[1];
|
return &pInfo->blockData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pIter->pSttBlk == NULL) {
|
if (pIter->pSttBlk == NULL || pInfo->pSchema == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1143,6 +1143,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pResBlock->info.dataLoad = 1;
|
||||||
pResBlock->info.rows = dumpedRows;
|
pResBlock->info.rows = dumpedRows;
|
||||||
pDumpInfo->rowIndex += step * dumpedRows;
|
pDumpInfo->rowIndex += step * dumpedRows;
|
||||||
|
|
||||||
|
@ -2538,6 +2539,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0;
|
pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0;
|
||||||
|
pResBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]);
|
blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]);
|
||||||
|
|
||||||
setComposedBlockFlag(pReader, true);
|
setComposedBlockFlag(pReader, true);
|
||||||
|
@ -2790,6 +2792,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
|
||||||
while (1) {
|
while (1) {
|
||||||
// load the last data block of current table
|
// load the last data block of current table
|
||||||
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)pStatus->pTableIter;
|
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)pStatus->pTableIter;
|
||||||
|
|
||||||
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
||||||
if (!hasVal) {
|
if (!hasVal) {
|
||||||
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
|
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
|
||||||
|
@ -3621,6 +3624,7 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow*
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
pBlock->info.rows += 1;
|
pBlock->info.rows += 1;
|
||||||
pScanInfo->lastKey = pTSRow->ts;
|
pScanInfo->lastKey = pTSRow->ts;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -3668,6 +3672,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pResBlock->info.dataLoad = 1;
|
||||||
pResBlock->info.rows += 1;
|
pResBlock->info.rows += 1;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3823,6 +3828,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: the endVersion in pCond is the data version not schema version, so pCond->endVersion is not correct here.
|
// NOTE: the endVersion in pCond is the data version not schema version, so pCond->endVersion is not correct here.
|
||||||
|
// no valid error code set in metaGetTbTSchema, so let's set the error code here.
|
||||||
|
// we should proceed in case of tmq processing.
|
||||||
if (pCond->suid != 0) {
|
if (pCond->suid != 0) {
|
||||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, -1, 1);
|
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, -1, 1);
|
||||||
if (pReader->pSchema == NULL) {
|
if (pReader->pSchema == NULL) {
|
||||||
|
@ -3890,6 +3897,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
||||||
|
tsdbReaderClose(pReader);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,32 +22,21 @@ static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
||||||
|
|
||||||
static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
vGTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType));
|
vGTrace("vgId:%d, msg:%p wait block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg,
|
||||||
|
TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq);
|
||||||
tsem_wait(&pVnode->syncSem);
|
tsem_wait(&pVnode->syncSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void vnodeWaitBlockMsgOld(SVnode *pVnode, const SRpcMsg *pMsg) {
|
|
||||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
|
||||||
taosThreadMutexLock(&pVnode->lock);
|
|
||||||
if (!pVnode->blocked) {
|
|
||||||
vGTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType));
|
|
||||||
pVnode->blocked = true;
|
|
||||||
taosThreadMutexUnlock(&pVnode->lock);
|
|
||||||
tsem_wait(&pVnode->syncSem);
|
|
||||||
} else {
|
|
||||||
taosThreadMutexUnlock(&pVnode->lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
taosThreadMutexLock(&pVnode->lock);
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
if (pVnode->blocked) {
|
if (pVnode->blocked) {
|
||||||
vGTrace("vgId:%d, msg:%p post block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType));
|
vGTrace("vgId:%d, msg:%p post block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg,
|
||||||
|
TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq);
|
||||||
pVnode->blocked = false;
|
pVnode->blocked = false;
|
||||||
|
pVnode->blockSec = 0;
|
||||||
|
pVnode->blockSeq = 0;
|
||||||
tsem_post(&pVnode->syncSem);
|
tsem_post(&pVnode->syncSem);
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&pVnode->lock);
|
taosThreadMutexUnlock(&pVnode->lock);
|
||||||
|
@ -217,12 +206,19 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) {
|
static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) {
|
||||||
|
int64_t seq = 0;
|
||||||
|
|
||||||
taosThreadMutexLock(&pVnode->lock);
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak);
|
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak, &seq);
|
||||||
bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType));
|
bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType));
|
||||||
if (wait) {
|
if (wait) {
|
||||||
ASSERT(!pVnode->blocked);
|
ASSERT(!pVnode->blocked);
|
||||||
pVnode->blocked = true;
|
pVnode->blocked = true;
|
||||||
|
pVnode->blockSec = taosGetTimestampSec();
|
||||||
|
pVnode->blockSeq = seq;
|
||||||
|
#if 0
|
||||||
|
pVnode->blockInfo = pMsg->info;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&pVnode->lock);
|
taosThreadMutexUnlock(&pVnode->lock);
|
||||||
|
|
||||||
|
@ -289,12 +285,15 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
||||||
const STraceId *trace = &pMsg->info.traceId;
|
const STraceId *trace = &pMsg->info.traceId;
|
||||||
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64, vgId, pMsg,
|
|
||||||
TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex);
|
|
||||||
|
|
||||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||||
vTrace("vgId:%d, blocking msg obtained from apply-queue. index:%" PRId64 ", term: %" PRId64 ", type: %s", vgId,
|
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64
|
||||||
pMsg->info.conn.applyIndex, pMsg->info.conn.applyTerm, TMSG_INFO(pMsg->msgType));
|
", blocking msg obtained sec:%d seq:%" PRId64,
|
||||||
|
vgId, pMsg, TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex, pVnode->blockSec,
|
||||||
|
pVnode->blockSeq);
|
||||||
|
} else {
|
||||||
|
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64, vgId, pMsg,
|
||||||
|
TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info};
|
SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info};
|
||||||
|
@ -621,6 +620,32 @@ void vnodeSyncClose(SVnode *pVnode) {
|
||||||
syncStop(pVnode->sync);
|
syncStop(pVnode->sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vnodeSyncCheckTimeout(SVnode *pVnode) {
|
||||||
|
vTrace("vgId:%d, check sync timeout msg", pVnode->config.vgId);
|
||||||
|
taosThreadMutexLock(&pVnode->lock);
|
||||||
|
if (pVnode->blocked) {
|
||||||
|
int32_t curSec = taosGetTimestampSec();
|
||||||
|
int32_t delta = curSec - pVnode->blockSec;
|
||||||
|
if (delta > VNODE_TIMEOUT_SEC) {
|
||||||
|
vError("vgId:%d, failed to propose since timeout and post block, start:%d cur:%d delta:%d seq:%" PRId64,
|
||||||
|
pVnode->config.vgId, pVnode->blockSec, curSec, delta, pVnode->blockSeq);
|
||||||
|
if (syncSendTimeoutRsp(pVnode->sync, pVnode->blockSeq) != 0) {
|
||||||
|
#if 0
|
||||||
|
SRpcMsg rpcMsg = {.code = TSDB_CODE_SYN_TIMEOUT, .info = pVnode->blockInfo};
|
||||||
|
vError("send timeout response since its applyed, seq:%" PRId64 " handle:%p ahandle:%p", pVnode->blockSeq,
|
||||||
|
rpcMsg.info.handle, rpcMsg.info.ahandle);
|
||||||
|
rpcSendResponse(&rpcMsg);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
pVnode->blocked = false;
|
||||||
|
pVnode->blockSec = 0;
|
||||||
|
pVnode->blockSeq = 0;
|
||||||
|
tsem_post(&pVnode->syncSem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&pVnode->lock);
|
||||||
|
}
|
||||||
|
|
||||||
bool vnodeIsRoleLeader(SVnode *pVnode) {
|
bool vnodeIsRoleLeader(SVnode *pVnode) {
|
||||||
SSyncState state = syncGetState(pVnode->sync);
|
SSyncState state = syncGetState(pVnode->sync);
|
||||||
return state.state == TAOS_SYNC_STATE_LEADER;
|
return state.state == TAOS_SYNC_STATE_LEADER;
|
||||||
|
|
|
@ -1728,7 +1728,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbInfo->vgVersion < 0 || taosHashGetSize(dbInfo->vgHash) <= 0) {
|
if (dbInfo->vgVersion < 0 || taosHashGetSize(dbInfo->vgHash) <= 0) {
|
||||||
ctgError("invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d", dbFName, dbInfo->vgHash,
|
ctgDebug("invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d", dbFName, dbInfo->vgHash,
|
||||||
dbInfo->vgVersion, taosHashGetSize(dbInfo->vgHash));
|
dbInfo->vgVersion, taosHashGetSize(dbInfo->vgHash));
|
||||||
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ static int32_t getStatus(SDataDeleterHandle* pDeleter) {
|
||||||
|
|
||||||
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
|
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
|
||||||
SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle;
|
SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle;
|
||||||
SDataDeleterBuf* pBuf = taosAllocateQitem(sizeof(SDataDeleterBuf), DEF_QITEM);
|
SDataDeleterBuf* pBuf = taosAllocateQitem(sizeof(SDataDeleterBuf), DEF_QITEM, 0);
|
||||||
if (NULL == pBuf) {
|
if (NULL == pBuf) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ static int32_t getStatus(SDataDispatchHandle* pDispatcher) {
|
||||||
|
|
||||||
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
|
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
|
||||||
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
|
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
|
||||||
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM);
|
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM, 0);
|
||||||
if (NULL == pBuf) {
|
if (NULL == pBuf) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,6 +510,7 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pCo
|
||||||
blockDataEnsureCapacity(pRes, pBlock->info.rows);
|
blockDataEnsureCapacity(pRes, pBlock->info.rows);
|
||||||
|
|
||||||
// data from mnode
|
// data from mnode
|
||||||
|
pRes->info.dataLoad = 1;
|
||||||
pRes->info.rows = pBlock->info.rows;
|
pRes->info.rows = pBlock->info.rows;
|
||||||
relocateColumnData(pRes, pColList, pBlock->pDataBlock, false);
|
relocateColumnData(pRes, pColList, pBlock->pDataBlock, false);
|
||||||
blockDataDestroy(pBlock);
|
blockDataDestroy(pBlock);
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS
|
||||||
|
|
||||||
qDebug("%s result generated, rows:%d, groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows,
|
qDebug("%s result generated, rows:%d, groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows,
|
||||||
pBlock->info.id.groupId);
|
pBlock->info.id.groupId);
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2546,6 +2546,7 @@ int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pStat
|
||||||
pBlock->info.rows += pRow->numOfRows;
|
pBlock->info.rows += pRow->numOfRows;
|
||||||
releaseOutputBuf(pState, &key, pRow);
|
releaseOutputBuf(pState, &key, pRow);
|
||||||
}
|
}
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2635,6 +2636,7 @@ int32_t buildSessionResultDataBlock(SOperatorInfo* pOperator, SStreamState* pSta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
pBlock->info.rows += pRow->numOfRows;
|
pBlock->info.rows += pRow->numOfRows;
|
||||||
// saveSessionDiscBuf(pState, pKey, pVal, size);
|
// saveSessionDiscBuf(pState, pKey, pVal, size);
|
||||||
releaseOutputBuf(pState, NULL, pRow);
|
releaseOutputBuf(pState, NULL, pRow);
|
||||||
|
|
|
@ -314,7 +314,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rowIndex = j - num;
|
int32_t rowIndex = j - num;
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pCtx, NULL, rowIndex, num, pBlock->info.rows, pOperator->exprSupp.numOfExprs);
|
applyAggFunctionOnPartialTuples(pTaskInfo, pCtx, NULL, rowIndex, num, pBlock->info.rows,
|
||||||
|
pOperator->exprSupp.numOfExprs);
|
||||||
|
|
||||||
// assign the group keys or user input constant values if required
|
// assign the group keys or user input constant values if required
|
||||||
doAssignGroupKeys(pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.rows, rowIndex);
|
doAssignGroupKeys(pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.rows, rowIndex);
|
||||||
|
@ -331,7 +332,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rowIndex = pBlock->info.rows - num;
|
int32_t rowIndex = pBlock->info.rows - num;
|
||||||
applyAggFunctionOnPartialTuples(pTaskInfo, pCtx, NULL, rowIndex, num, pBlock->info.rows, pOperator->exprSupp.numOfExprs);
|
applyAggFunctionOnPartialTuples(pTaskInfo, pCtx, NULL, rowIndex, num, pBlock->info.rows,
|
||||||
|
pOperator->exprSupp.numOfExprs);
|
||||||
doAssignGroupKeys(pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.rows, rowIndex);
|
doAssignGroupKeys(pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.rows, rowIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,8 +471,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode*
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||||
setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo,
|
||||||
createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, optrDefaultBufFn, NULL);
|
optrDefaultBufFn, NULL);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -696,6 +698,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
pInfo->pageIndex += 1;
|
pInfo->pageIndex += 1;
|
||||||
releaseBufPage(pInfo->pBuf, page);
|
releaseBufPage(pInfo->pBuf, page);
|
||||||
|
|
||||||
|
pInfo->binfo.pRes->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pInfo->binfo.pRes, 0);
|
blockDataUpdateTsWindow(pInfo->binfo.pRes, 0);
|
||||||
pInfo->binfo.pRes->info.id.groupId = pGroupInfo->groupId;
|
pInfo->binfo.pRes->info.id.groupId = pGroupInfo->groupId;
|
||||||
|
|
||||||
|
@ -776,6 +779,12 @@ static void destroyPartitionOperatorInfo(void* param) {
|
||||||
|
|
||||||
taosArrayDestroy(pInfo->pGroupColVals);
|
taosArrayDestroy(pInfo->pGroupColVals);
|
||||||
taosMemoryFree(pInfo->keyBuf);
|
taosMemoryFree(pInfo->keyBuf);
|
||||||
|
|
||||||
|
int32_t size = taosArrayGetSize(pInfo->sortedGroupArray);
|
||||||
|
for (int32_t i = 0; i < size; i++) {
|
||||||
|
SDataGroupInfo* pGp = taosArrayGet(pInfo->sortedGroupArray, i);
|
||||||
|
taosArrayDestroy(pGp->pPageList);
|
||||||
|
}
|
||||||
taosArrayDestroy(pInfo->sortedGroupArray);
|
taosArrayDestroy(pInfo->sortedGroupArray);
|
||||||
|
|
||||||
void* pGroupIter = taosHashIterate(pInfo->pGroupSet, NULL);
|
void* pGroupIter = taosHashIterate(pInfo->pGroupSet, NULL);
|
||||||
|
@ -850,7 +859,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(optrDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
@ -951,6 +961,8 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pParInfo->rowIds);
|
taosArrayDestroy(pParInfo->rowIds);
|
||||||
pParInfo->rowIds = NULL;
|
pParInfo->rowIds = NULL;
|
||||||
|
pDest->info.dataLoad = 1;
|
||||||
|
|
||||||
blockDataUpdateTsWindow(pDest, pInfo->tsColIndex);
|
blockDataUpdateTsWindow(pDest, pInfo->tsColIndex);
|
||||||
pDest->info.id.groupId = pParInfo->groupId;
|
pDest->info.id.groupId = pParInfo->groupId;
|
||||||
pOperator->resultInfo.totalRows += pDest->info.rows;
|
pOperator->resultInfo.totalRows += pDest->info.rows;
|
||||||
|
@ -1141,8 +1153,8 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
||||||
pInfo, pTaskInfo);
|
pInfo, pTaskInfo);
|
||||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
pOperator->fpSet =
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamHashPartition, NULL,
|
||||||
createOperatorFpSet(optrDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
|
|
@ -87,11 +87,11 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pJoinNode->node.pOutputDataBlockDesc);
|
pInfo->pRes = createDataBlockFromDescNode(pJoinNode->node.pOutputDataBlockDesc);
|
||||||
|
|
||||||
SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &numOfCols);
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
pInfo->pRes = pResBlock;
|
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "MergeJoinOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "MergeJoinOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||||
|
@ -401,6 +401,7 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
pRes->info.rows = nrows;
|
pRes->info.rows = nrows;
|
||||||
|
pRes->info.dataLoad = 1;
|
||||||
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +413,7 @@ SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
SSDataBlock* pRes = pJoinInfo->pRes;
|
SSDataBlock* pRes = pJoinInfo->pRes;
|
||||||
blockDataCleanup(pRes);
|
blockDataCleanup(pRes);
|
||||||
blockDataEnsureCapacity(pRes, 4096);
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int32_t numOfRowsBefore = pRes->info.rows;
|
int32_t numOfRowsBefore = pRes->info.rows;
|
||||||
doMergeJoinImpl(pOperator, pRes);
|
doMergeJoinImpl(pOperator, pRes);
|
||||||
|
|
|
@ -654,6 +654,7 @@ static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, S
|
||||||
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
||||||
int32_t numOfOutput, SArray* pPseudoList) {
|
int32_t numOfOutput, SArray* pPseudoList) {
|
||||||
setPseudoOutputColInfo(pResult, pCtx, pPseudoList);
|
setPseudoOutputColInfo(pResult, pCtx, pPseudoList);
|
||||||
|
pResult->info.dataLoad = 1;
|
||||||
|
|
||||||
if (pSrcBlock == NULL) {
|
if (pSrcBlock == NULL) {
|
||||||
for (int32_t k = 0; k < numOfOutput; ++k) {
|
for (int32_t k = 0; k < numOfOutput; ++k) {
|
||||||
|
|
|
@ -110,9 +110,9 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
||||||
|
|
||||||
if (order == TSDB_ORDER_ASC) {
|
if (order == TSDB_ORDER_ASC) {
|
||||||
w = getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.skey);
|
w = getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.skey);
|
||||||
assert(w.ekey >= pBlockInfo->window.skey);
|
ASSERT(w.ekey >= pBlockInfo->window.skey);
|
||||||
|
|
||||||
if (TMAX(w.skey, pBlockInfo->window.skey) <= TMIN(w.ekey, pBlockInfo->window.ekey)) {
|
if (w.ekey < pBlockInfo->window.ekey) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,16 +122,16 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(w.ekey > pBlockInfo->window.ekey);
|
ASSERT(w.ekey > pBlockInfo->window.ekey);
|
||||||
if (TMAX(w.skey, pBlockInfo->window.skey) <= pBlockInfo->window.ekey) {
|
if (TMAX(w.skey, pBlockInfo->window.skey) <= pBlockInfo->window.ekey) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
w = getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.ekey);
|
w = getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.ekey);
|
||||||
assert(w.skey <= pBlockInfo->window.ekey);
|
ASSERT(w.skey <= pBlockInfo->window.ekey);
|
||||||
|
|
||||||
if (TMAX(w.skey, pBlockInfo->window.skey) <= TMIN(w.ekey, pBlockInfo->window.ekey)) {
|
if (w.skey > pBlockInfo->window.skey) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,6 +1342,7 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock,
|
||||||
}
|
}
|
||||||
pDestBlock->info.type = STREAM_CLEAR;
|
pDestBlock->info.type = STREAM_CLEAR;
|
||||||
pDestBlock->info.version = pSrcBlock->info.version;
|
pDestBlock->info.version = pSrcBlock->info.version;
|
||||||
|
pDestBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pDestBlock, 0);
|
blockDataUpdateTsWindow(pDestBlock, 0);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1450,6 +1451,7 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
|
||||||
}
|
}
|
||||||
if (out && pInfo->pUpdateDataRes->info.rows > 0) {
|
if (out && pInfo->pUpdateDataRes->info.rows > 0) {
|
||||||
pInfo->pUpdateDataRes->info.version = pBlock->info.version;
|
pInfo->pUpdateDataRes->info.version = pBlock->info.version;
|
||||||
|
pInfo->pUpdateDataRes->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pInfo->pUpdateDataRes, 0);
|
blockDataUpdateTsWindow(pInfo->pUpdateDataRes, 0);
|
||||||
pInfo->pUpdateDataRes->info.type = pInfo->partitionSup.needCalc ? STREAM_DELETE_DATA : STREAM_CLEAR;
|
pInfo->pUpdateDataRes->info.type = pInfo->partitionSup.needCalc ? STREAM_DELETE_DATA : STREAM_CLEAR;
|
||||||
}
|
}
|
||||||
|
@ -1512,6 +1514,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pInfo->pRes->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||||
blockDataFreeRes((SSDataBlock*)pBlock);
|
blockDataFreeRes((SSDataBlock*)pBlock);
|
||||||
|
|
||||||
|
@ -1793,6 +1796,7 @@ FETCH_NEXT_BLOCK:
|
||||||
// TODO move into scan
|
// TODO move into scan
|
||||||
pBlock->info.calWin.skey = INT64_MIN;
|
pBlock->info.calWin.skey = INT64_MIN;
|
||||||
pBlock->info.calWin.ekey = INT64_MAX;
|
pBlock->info.calWin.ekey = INT64_MAX;
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
switch (pBlock->info.type) {
|
switch (pBlock->info.type) {
|
||||||
case STREAM_NORMAL:
|
case STREAM_NORMAL:
|
||||||
|
@ -1970,6 +1974,7 @@ FETCH_NEXT_BLOCK:
|
||||||
}
|
}
|
||||||
|
|
||||||
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
||||||
|
pInfo->pRes->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||||
|
|
||||||
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
||||||
|
|
|
@ -105,6 +105,7 @@ void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
pBlock->info.rows += 1;
|
pBlock->info.rows += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,6 +699,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
|
||||||
pInfo->limitInfo.numOfOutputRows += p->info.rows;
|
pInfo->limitInfo.numOfOutputRows += p->info.rows;
|
||||||
pDataBlock->info.rows = p->info.rows;
|
pDataBlock->info.rows = p->info.rows;
|
||||||
pDataBlock->info.id.groupId = pInfo->groupId;
|
pDataBlock->info.id.groupId = pInfo->groupId;
|
||||||
|
pDataBlock->info.dataLoad = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.id.groupId,
|
qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.id.groupId,
|
||||||
|
|
|
@ -49,10 +49,10 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
|
||||||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||||
pkey->isNull = false;
|
pkey->isNull = false;
|
||||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||||
if (!IS_VAR_DATA_TYPE(pkey->type)) {
|
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||||
memcpy(pkey->pData, val, pkey->bytes);
|
|
||||||
} else {
|
|
||||||
memcpy(pkey->pData, val, varDataLen(val));
|
memcpy(pkey->pData, val, varDataLen(val));
|
||||||
|
} else {
|
||||||
|
memcpy(pkey->pData, val, pkey->bytes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pkey->isNull = true;
|
pkey->isNull = true;
|
||||||
|
@ -91,20 +91,37 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
||||||
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, pSliceInfo->tsCol.slotId);
|
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, pSliceInfo->tsCol.slotId);
|
||||||
SFillLinearInfo* pLinearInfo = taosArrayGet(pSliceInfo->pLinearInfo, i);
|
SFillLinearInfo* pLinearInfo = taosArrayGet(pSliceInfo->pLinearInfo, i);
|
||||||
|
|
||||||
|
|
||||||
|
if (!IS_MATHABLE_TYPE(pColInfoData->info.type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// null value is represented by using key = INT64_MIN for now.
|
// null value is represented by using key = INT64_MIN for now.
|
||||||
// TODO: optimize to ignore null values for linear interpolation.
|
// TODO: optimize to ignore null values for linear interpolation.
|
||||||
if (!pLinearInfo->isStartSet) {
|
if (!pLinearInfo->isStartSet) {
|
||||||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||||
ASSERT(IS_MATHABLE_TYPE(pColInfoData->info.type));
|
|
||||||
|
|
||||||
pLinearInfo->start.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
pLinearInfo->start.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
||||||
memcpy(pLinearInfo->start.val, colDataGetData(pColInfoData, rowIndex), pLinearInfo->bytes);
|
char* p = colDataGetData(pColInfoData, rowIndex);
|
||||||
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
|
ASSERT(varDataTLen(p) <= pColInfoData->info.bytes);
|
||||||
|
memcpy(pLinearInfo->start.val, p, varDataTLen(p));
|
||||||
|
} else {
|
||||||
|
memcpy(pLinearInfo->start.val, p, pLinearInfo->bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pLinearInfo->isStartSet = true;
|
pLinearInfo->isStartSet = true;
|
||||||
} else if (!pLinearInfo->isEndSet) {
|
} else if (!pLinearInfo->isEndSet) {
|
||||||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||||
pLinearInfo->end.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
pLinearInfo->end.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
||||||
memcpy(pLinearInfo->end.val, colDataGetData(pColInfoData, rowIndex), pLinearInfo->bytes);
|
|
||||||
|
char* p = colDataGetData(pColInfoData, rowIndex);
|
||||||
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
|
ASSERT(varDataTLen(p) <= pColInfoData->info.bytes);
|
||||||
|
memcpy(pLinearInfo->end.val, p, varDataTLen(p));
|
||||||
|
} else {
|
||||||
|
memcpy(pLinearInfo->end.val, p, pLinearInfo->bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pLinearInfo->isEndSet = true;
|
pLinearInfo->isEndSet = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,7 +130,15 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
||||||
|
|
||||||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||||
pLinearInfo->end.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
pLinearInfo->end.key = *(int64_t*)colDataGetData(pTsCol, rowIndex);
|
||||||
memcpy(pLinearInfo->end.val, colDataGetData(pColInfoData, rowIndex), pLinearInfo->bytes);
|
|
||||||
|
char* p = colDataGetData(pColInfoData, rowIndex);
|
||||||
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
|
ASSERT(varDataTLen(p) <= pColInfoData->info.bytes);
|
||||||
|
memcpy(pLinearInfo->end.val, p, varDataTLen(p));
|
||||||
|
} else {
|
||||||
|
memcpy(pLinearInfo->end.val, p, pLinearInfo->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
pLinearInfo->end.key = INT64_MIN;
|
pLinearInfo->end.key = INT64_MIN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1037,9 +1037,10 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe
|
||||||
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
||||||
TSKEY* tsCols = NULL;
|
TSKEY* tsCols = NULL;
|
||||||
|
|
||||||
if (pBlock->pDataBlock != NULL) {
|
if (pBlock->pDataBlock != NULL && pBlock->info.dataLoad == 1) {
|
||||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
tsCols = (int64_t*)pColDataInfo->pData;
|
tsCols = (int64_t*)pColDataInfo->pData;
|
||||||
|
ASSERT(tsCols[0] != 0);
|
||||||
|
|
||||||
// no data in primary ts
|
// no data in primary ts
|
||||||
if (tsCols[0] == 0 && tsCols[pBlock->info.rows - 1] == 0) {
|
if (tsCols[0] == 0 && tsCols[pBlock->info.rows - 1] == 0) {
|
||||||
|
@ -1083,8 +1084,6 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pSup, pBlock, pInfo->inputOrder, scanFlag, true);
|
setInputDataBlock(pSup, pBlock, pInfo->inputOrder, scanFlag, true);
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
|
||||||
|
|
||||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag);
|
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pInfo->current += 1;
|
pInfo->current += 1;
|
||||||
|
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -514,7 +514,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
numOfElem = pInput->numOfRows;
|
numOfElem = pInput->numOfRows;
|
||||||
pAvgRes->count += pInput->numOfRows;
|
pAvgRes->count += pInput->numOfRows;
|
||||||
|
|
||||||
bool simdAvailable = tsAVXEnable && tsSIMDEnable && (numOfRows > THRESHOLD_SIZE);
|
bool simdAvailable = tsAVXEnable && tsSIMDBuiltins && (numOfRows > THRESHOLD_SIZE);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
|
|
|
@ -369,7 +369,7 @@ static int32_t findFirstValPosition(const SColumnInfoData* pCol, int32_t start,
|
||||||
static void handleInt8Col(const void* data, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc,
|
static void handleInt8Col(const void* data, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc,
|
||||||
bool signVal) {
|
bool signVal) {
|
||||||
// AVX2 version to speedup the loop
|
// AVX2 version to speedup the loop
|
||||||
if (tsAVX2Enable && tsSIMDEnable) {
|
if (tsAVX2Enable && tsSIMDBuiltins) {
|
||||||
pBuf->v = i8VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
pBuf->v = i8VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
||||||
} else {
|
} else {
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
|
@ -403,7 +403,7 @@ static void handleInt8Col(const void* data, int32_t start, int32_t numOfRows, SM
|
||||||
static void handleInt16Col(const void* data, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc,
|
static void handleInt16Col(const void* data, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc,
|
||||||
bool signVal) {
|
bool signVal) {
|
||||||
// AVX2 version to speedup the loop
|
// AVX2 version to speedup the loop
|
||||||
if (tsAVX2Enable && tsSIMDEnable) {
|
if (tsAVX2Enable && tsSIMDBuiltins) {
|
||||||
pBuf->v = i16VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
pBuf->v = i16VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
||||||
} else {
|
} else {
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
|
@ -437,7 +437,7 @@ static void handleInt16Col(const void* data, int32_t start, int32_t numOfRows, S
|
||||||
static void handleInt32Col(const void* data, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc,
|
static void handleInt32Col(const void* data, int32_t start, int32_t numOfRows, SMinmaxResInfo* pBuf, bool isMinFunc,
|
||||||
bool signVal) {
|
bool signVal) {
|
||||||
// AVX2 version to speedup the loop
|
// AVX2 version to speedup the loop
|
||||||
if (tsAVX2Enable && tsSIMDEnable) {
|
if (tsAVX2Enable && tsSIMDBuiltins) {
|
||||||
pBuf->v = i32VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
pBuf->v = i32VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
||||||
} else {
|
} else {
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
|
@ -500,7 +500,7 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo
|
||||||
float* val = (float*)&pBuf->v;
|
float* val = (float*)&pBuf->v;
|
||||||
|
|
||||||
// AVX version to speedup the loop
|
// AVX version to speedup the loop
|
||||||
if (tsAVXEnable && tsSIMDEnable) {
|
if (tsAVXEnable && tsSIMDBuiltins) {
|
||||||
*val = floatVectorCmpAVX(pData, numOfRows, isMinFunc);
|
*val = floatVectorCmpAVX(pData, numOfRows, isMinFunc);
|
||||||
} else {
|
} else {
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
|
@ -530,7 +530,7 @@ static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfR
|
||||||
double* val = (double*)&pBuf->v;
|
double* val = (double*)&pBuf->v;
|
||||||
|
|
||||||
// AVX version to speedup the loop
|
// AVX version to speedup the loop
|
||||||
if (tsAVXEnable && tsSIMDEnable) {
|
if (tsAVXEnable && tsSIMDBuiltins) {
|
||||||
*val = (double)doubleVectorCmpAVX(pData, numOfRows, isMinFunc);
|
*val = (double)doubleVectorCmpAVX(pData, numOfRows, isMinFunc);
|
||||||
} else {
|
} else {
|
||||||
if (!pBuf->assign) {
|
if (!pBuf->assign) {
|
||||||
|
|
|
@ -364,6 +364,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
|
||||||
assert(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0);
|
assert(pSlot->info.data->num >= pBucket->elemPerPage && pSlot->info.size > 0);
|
||||||
|
|
||||||
// keep the pointer in memory
|
// keep the pointer in memory
|
||||||
|
setBufPageDirty(pSlot->info.data, true);
|
||||||
releaseBufPage(pBucket->pBuffer, pSlot->info.data);
|
releaseBufPage(pBucket->pBuffer, pSlot->info.data);
|
||||||
pSlot->info.data = NULL;
|
pSlot->info.data = NULL;
|
||||||
}
|
}
|
||||||
|
@ -497,15 +498,16 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
resetSlotInfo(pMemBucket);
|
resetSlotInfo(pMemBucket);
|
||||||
|
|
||||||
int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1);
|
int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1);
|
||||||
SArray* list = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
|
SArray* list = *(SArray **)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId));
|
||||||
ASSERT(list != NULL && list->size > 0);
|
ASSERT(list != NULL && list->size > 0);
|
||||||
|
|
||||||
for (int32_t f = 0; f < list->size; ++f) {
|
for (int32_t f = 0; f < list->size; ++f) {
|
||||||
SPageInfo *pgInfo = *(SPageInfo **)taosArrayGet(list, f);
|
int32_t *pageId = taosArrayGet(list, f);
|
||||||
SFilePage *pg = getBufPage(pMemBucket->pBuffer, getPageId(pgInfo));
|
SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||||
|
|
||||||
tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num);
|
tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num);
|
||||||
releaseBufPageInfo(pMemBucket->pBuffer, pgInfo);
|
setBufPageDirty(pg, true);
|
||||||
|
releaseBufPage(pMemBucket->pBuffer, pg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPercentileImpl(pMemBucket, count - num, fraction);
|
return getPercentileImpl(pMemBucket, count - num, fraction);
|
||||||
|
|
|
@ -837,9 +837,34 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SSDataBlock *output) {
|
int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SSDataBlock *output) {
|
||||||
output->info.rows = input->numOfRows;
|
int32_t numOfRows = 0;
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
numOfRows = (input[i].numOfRows > numOfRows) ? input[i].numOfRows : numOfRows;
|
||||||
|
}
|
||||||
|
output->info.rows = numOfRows;
|
||||||
output->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
output->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
if ((input+i)->numOfRows < numOfRows) {
|
||||||
|
SColumnInfoData* pColInfoData = (input+i)->columnData;
|
||||||
|
int32_t startRow = (input+i)->numOfRows;
|
||||||
|
int32_t expandRows = numOfRows - startRow;
|
||||||
|
colInfoDataEnsureCapacity(pColInfoData, numOfRows, false);
|
||||||
|
bool isNull = colDataIsNull_s(pColInfoData, (input+i)->numOfRows - 1);
|
||||||
|
if (isNull) {
|
||||||
|
colDataAppendNNULL(pColInfoData, startRow, expandRows);
|
||||||
|
} else {
|
||||||
|
char* src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1);
|
||||||
|
int32_t bytes = pColInfoData->info.bytes;
|
||||||
|
char* data = taosMemoryMalloc(bytes);
|
||||||
|
memcpy(data, src, bytes);
|
||||||
|
for (int j = 0; j < expandRows; ++j) {
|
||||||
|
colDataAppend(pColInfoData, startRow+j, data, false);
|
||||||
|
}
|
||||||
|
//colDataAppendNItems(pColInfoData, startRow, data, expandRows);
|
||||||
|
taosMemoryFree(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
taosArrayPush(output->pDataBlock, (input + i)->columnData);
|
taosArrayPush(output->pDataBlock, (input + i)->columnData);
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE((input + i)->columnData->info.type)) {
|
if (IS_VAR_DATA_TYPE((input + i)->columnData->info.type)) {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
// clang-foramt on
|
// clang-format on
|
||||||
|
|
||||||
typedef struct SUdfdContext {
|
typedef struct SUdfdContext {
|
||||||
uv_loop_t *loop;
|
uv_loop_t *loop;
|
||||||
|
@ -49,18 +49,25 @@ typedef struct SUdfdContext {
|
||||||
|
|
||||||
SUdfdContext global;
|
SUdfdContext global;
|
||||||
|
|
||||||
|
struct SUdfdUvConn;
|
||||||
|
struct SUvUdfWork;
|
||||||
|
|
||||||
typedef struct SUdfdUvConn {
|
typedef struct SUdfdUvConn {
|
||||||
uv_stream_t *client;
|
uv_stream_t *client;
|
||||||
char *inputBuf;
|
char *inputBuf;
|
||||||
int32_t inputLen;
|
int32_t inputLen;
|
||||||
int32_t inputCap;
|
int32_t inputCap;
|
||||||
int32_t inputTotal;
|
int32_t inputTotal;
|
||||||
|
|
||||||
|
struct SUvUdfWork *pWorkList; // head of work list
|
||||||
} SUdfdUvConn;
|
} SUdfdUvConn;
|
||||||
|
|
||||||
typedef struct SUvUdfWork {
|
typedef struct SUvUdfWork {
|
||||||
uv_stream_t *client;
|
SUdfdUvConn *conn;
|
||||||
uv_buf_t input;
|
uv_buf_t input;
|
||||||
uv_buf_t output;
|
uv_buf_t output;
|
||||||
|
|
||||||
|
struct SUvUdfWork *pWorkNext;
|
||||||
} SUvUdfWork;
|
} SUvUdfWork;
|
||||||
|
|
||||||
typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY, UDF_STATE_UNLOADING } EUdfState;
|
typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY, UDF_STATE_UNLOADING } EUdfState;
|
||||||
|
@ -248,7 +255,8 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||||
|
|
||||||
void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||||
SUdfCallRequest *call = &request->call;
|
SUdfCallRequest *call = &request->call;
|
||||||
fnDebug("call request. call type %d, handle: %" PRIx64 ", seq num %" PRId64 , call->callType, call->udfHandle, request->seqNum);
|
fnDebug("call request. call type %d, handle: %" PRIx64 ", seq num %" PRId64, call->callType, call->udfHandle,
|
||||||
|
request->seqNum);
|
||||||
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(call->udfHandle);
|
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(call->udfHandle);
|
||||||
SUdf *udf = handle->udf;
|
SUdf *udf = handle->udf;
|
||||||
SUdfResponse response = {0};
|
SUdfResponse response = {0};
|
||||||
|
@ -417,7 +425,6 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (connectRsp.epSet.numOfEps == 0) {
|
if (connectRsp.epSet.numOfEps == 0) {
|
||||||
msgInfo->code = TSDB_CODE_APP_ERROR;
|
msgInfo->code = TSDB_CODE_APP_ERROR;
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -601,7 +608,8 @@ static bool udfdRpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER ||
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER ||
|
||||||
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
||||||
code == TSDB_CODE_APP_IS_STOPPING) {
|
code == TSDB_CODE_APP_IS_STOPPING) {
|
||||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || msgType == TDMT_SCH_MERGE_FETCH) {
|
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
||||||
|
msgType == TDMT_SCH_MERGE_FETCH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -684,6 +692,17 @@ void udfdOnWrite(uv_write_t *req, int status) {
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
fnError("udfd send response error, length: %zu code: %s", work->output.len, uv_err_name(status));
|
fnError("udfd send response error, length: %zu code: %s", work->output.len, uv_err_name(status));
|
||||||
}
|
}
|
||||||
|
// remove work from the connection work list
|
||||||
|
if (work->conn != NULL) {
|
||||||
|
SUvUdfWork **ppWork;
|
||||||
|
for (ppWork = &work->conn->pWorkList; *ppWork && (*ppWork != work); ppWork = &((*ppWork)->pWorkNext)) {
|
||||||
|
}
|
||||||
|
if (*ppWork == work) {
|
||||||
|
*ppWork = work->pWorkNext;
|
||||||
|
} else {
|
||||||
|
fnError("work not in conn any more");
|
||||||
|
}
|
||||||
|
}
|
||||||
taosMemoryFree(work->output.base);
|
taosMemoryFree(work->output.base);
|
||||||
taosMemoryFree(work);
|
taosMemoryFree(work);
|
||||||
taosMemoryFree(req);
|
taosMemoryFree(req);
|
||||||
|
@ -692,10 +711,11 @@ void udfdOnWrite(uv_write_t *req, int status) {
|
||||||
void udfdSendResponse(uv_work_t *work, int status) {
|
void udfdSendResponse(uv_work_t *work, int status) {
|
||||||
SUvUdfWork *udfWork = (SUvUdfWork *)(work->data);
|
SUvUdfWork *udfWork = (SUvUdfWork *)(work->data);
|
||||||
|
|
||||||
|
if (udfWork->conn != NULL) {
|
||||||
uv_write_t *write_req = taosMemoryMalloc(sizeof(uv_write_t));
|
uv_write_t *write_req = taosMemoryMalloc(sizeof(uv_write_t));
|
||||||
write_req->data = udfWork;
|
write_req->data = udfWork;
|
||||||
uv_write(write_req, udfWork->client, &udfWork->output, 1, udfdOnWrite);
|
uv_write(write_req, udfWork->conn->client, &udfWork->output, 1, udfdOnWrite);
|
||||||
|
}
|
||||||
taosMemoryFree(work);
|
taosMemoryFree(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,10 +764,15 @@ bool isUdfdUvMsgComplete(SUdfdUvConn *pipe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void udfdHandleRequest(SUdfdUvConn *conn) {
|
void udfdHandleRequest(SUdfdUvConn *conn) {
|
||||||
|
char *inputBuf = conn->inputBuf;
|
||||||
|
int32_t inputLen = conn->inputLen;
|
||||||
|
|
||||||
uv_work_t *work = taosMemoryMalloc(sizeof(uv_work_t));
|
uv_work_t *work = taosMemoryMalloc(sizeof(uv_work_t));
|
||||||
SUvUdfWork *udfWork = taosMemoryMalloc(sizeof(SUvUdfWork));
|
SUvUdfWork *udfWork = taosMemoryMalloc(sizeof(SUvUdfWork));
|
||||||
udfWork->client = conn->client;
|
udfWork->conn = conn;
|
||||||
udfWork->input = uv_buf_init(conn->inputBuf, conn->inputLen);
|
udfWork->pWorkNext = conn->pWorkList;
|
||||||
|
conn->pWorkList = udfWork;
|
||||||
|
udfWork->input = uv_buf_init(inputBuf, inputLen);
|
||||||
conn->inputBuf = NULL;
|
conn->inputBuf = NULL;
|
||||||
conn->inputLen = 0;
|
conn->inputLen = 0;
|
||||||
conn->inputCap = 0;
|
conn->inputCap = 0;
|
||||||
|
@ -758,13 +783,19 @@ void udfdHandleRequest(SUdfdUvConn *conn) {
|
||||||
|
|
||||||
void udfdPipeCloseCb(uv_handle_t *pipe) {
|
void udfdPipeCloseCb(uv_handle_t *pipe) {
|
||||||
SUdfdUvConn *conn = pipe->data;
|
SUdfdUvConn *conn = pipe->data;
|
||||||
|
SUvUdfWork* pWork = conn->pWorkList;
|
||||||
|
while (pWork != NULL) {
|
||||||
|
pWork->conn = NULL;
|
||||||
|
pWork = pWork->pWorkNext;
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFree(conn->client);
|
taosMemoryFree(conn->client);
|
||||||
taosMemoryFree(conn->inputBuf);
|
taosMemoryFree(conn->inputBuf);
|
||||||
taosMemoryFree(conn);
|
taosMemoryFree(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void udfdPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
|
void udfdPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
|
||||||
fnDebug("udf read %zd bytes from client", nread);
|
fnDebug("udfd read %zd bytes from client", nread);
|
||||||
if (nread == 0) return;
|
if (nread == 0) return;
|
||||||
|
|
||||||
SUdfdUvConn *conn = client->data;
|
SUdfdUvConn *conn = client->data;
|
||||||
|
@ -780,10 +811,10 @@ void udfdPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
fnError("Receive error %s", uv_err_name(nread));
|
|
||||||
if (nread == UV_EOF) {
|
if (nread == UV_EOF) {
|
||||||
// TODO check more when close
|
fnInfo("udfd pipe read EOF");
|
||||||
} else {
|
} else {
|
||||||
|
fnError("Receive error %s", uv_err_name(nread));
|
||||||
}
|
}
|
||||||
udfdUvHandleError(conn);
|
udfdUvHandleError(conn);
|
||||||
}
|
}
|
||||||
|
@ -799,6 +830,7 @@ void udfdOnNewConnection(uv_stream_t *server, int status) {
|
||||||
uv_pipe_init(global.loop, client, 0);
|
uv_pipe_init(global.loop, client, 0);
|
||||||
if (uv_accept(server, (uv_stream_t *)client) == 0) {
|
if (uv_accept(server, (uv_stream_t *)client) == 0) {
|
||||||
SUdfdUvConn *ctx = taosMemoryMalloc(sizeof(SUdfdUvConn));
|
SUdfdUvConn *ctx = taosMemoryMalloc(sizeof(SUdfdUvConn));
|
||||||
|
ctx->pWorkList = NULL;
|
||||||
ctx->client = (uv_stream_t *)client;
|
ctx->client = (uv_stream_t *)client;
|
||||||
ctx->inputBuf = 0;
|
ctx->inputBuf = 0;
|
||||||
ctx->inputLen = 0;
|
ctx->inputLen = 0;
|
||||||
|
|
|
@ -194,7 +194,7 @@ db_options(A) ::= db_options(B) PAGESIZE NK_INTEGER(C).
|
||||||
db_options(A) ::= db_options(B) TSDB_PAGESIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TSDB_PAGESIZE, &C); }
|
db_options(A) ::= db_options(B) TSDB_PAGESIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TSDB_PAGESIZE, &C); }
|
||||||
db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); }
|
db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); }
|
||||||
db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); }
|
db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); }
|
||||||
db_options(A) ::= db_options(B) STRICT NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STRICT, &C); }
|
//db_options(A) ::= db_options(B) STRICT NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STRICT, &C); }
|
||||||
db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); }
|
db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); }
|
||||||
db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); }
|
db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); }
|
||||||
db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, C); }
|
db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, C); }
|
||||||
|
@ -232,7 +232,7 @@ alter_db_option(A) ::= KEEP integer_list(B).
|
||||||
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; }
|
||||||
alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
|
alter_db_option(A) ::= PAGES NK_INTEGER(B). { A.type = DB_OPTION_PAGES; A.val = B; }
|
||||||
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
||||||
alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
//alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; }
|
||||||
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||||
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; }
|
||||||
|
|
||||||
|
@ -1067,5 +1067,5 @@ null_ordering_opt(A) ::= NULLS FIRST.
|
||||||
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
|
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
|
||||||
|
|
||||||
%fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA COMPACT CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL
|
%fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA COMPACT CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL
|
||||||
FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT STRING
|
FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT
|
||||||
TIMES UPDATE VALUES VARIABLE VIEW WAL.
|
STRICT STRING TIMES UPDATE VALUES VARIABLE VIEW WAL.
|
||||||
|
|
|
@ -2837,7 +2837,7 @@ static int32_t rewriteProjectAlias(SNodeList* pProjectionList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkProjectAlias(STranslateContext* pCxt, SNodeList* pProjectionList) {
|
static int32_t checkProjectAlias(STranslateContext* pCxt, SNodeList* pProjectionList, SHashObj** pOutput) {
|
||||||
SHashObj* pUserAliasSet = taosHashInit(LIST_LENGTH(pProjectionList),
|
SHashObj* pUserAliasSet = taosHashInit(LIST_LENGTH(pProjectionList),
|
||||||
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
SNode* pProject = NULL;
|
SNode* pProject = NULL;
|
||||||
|
@ -2849,13 +2849,17 @@ static int32_t checkProjectAlias(STranslateContext* pCxt, SNodeList* pProjection
|
||||||
}
|
}
|
||||||
taosHashPut(pUserAliasSet, pExpr->userAlias, strlen(pExpr->userAlias), &pExpr, POINTER_BYTES);
|
taosHashPut(pUserAliasSet, pExpr->userAlias, strlen(pExpr->userAlias), &pExpr, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
if (NULL == pOutput) {
|
||||||
taosHashCleanup(pUserAliasSet);
|
taosHashCleanup(pUserAliasSet);
|
||||||
|
} else {
|
||||||
|
*pOutput = pUserAliasSet;
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateProjectionList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateProjectionList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (pSelect->isSubquery) {
|
if (pSelect->isSubquery) {
|
||||||
return checkProjectAlias(pCxt, pSelect->pProjectionList);
|
return checkProjectAlias(pCxt, pSelect->pProjectionList, NULL);
|
||||||
}
|
}
|
||||||
return rewriteProjectAlias(pSelect->pProjectionList);
|
return rewriteProjectAlias(pSelect->pProjectionList);
|
||||||
}
|
}
|
||||||
|
@ -3888,8 +3892,7 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
pOptions->keep[0] > tsdbMaxKeep || pOptions->keep[1] > tsdbMaxKeep || pOptions->keep[2] > tsdbMaxKeep) {
|
pOptions->keep[0] > tsdbMaxKeep || pOptions->keep[1] > tsdbMaxKeep || pOptions->keep[2] > tsdbMaxKeep) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
"Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]",
|
"Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]",
|
||||||
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP,
|
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP, tsdbMaxKeep);
|
||||||
tsdbMaxKeep);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
||||||
|
@ -5504,8 +5507,23 @@ static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
|
||||||
tNameGetFullDbName(&name, pDbFName);
|
tNameGetFullDbName(&name, pDbFName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
static void getStreamQueryFirstProjectAliasName(SHashObj* pUserAliasSet, char* aliasName, int32_t len) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
if (NULL == taosHashGet(pUserAliasSet, "_wstart", strlen("_wstart"))) {
|
||||||
|
snprintf(aliasName, len, "%s", "_wstart");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (NULL == taosHashGet(pUserAliasSet, "ts", strlen("ts"))) {
|
||||||
|
snprintf(aliasName, len, "%s", "ts");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
taosRandStr(aliasName, len - 1);
|
||||||
|
aliasName[len - 1] = '\0';
|
||||||
|
} while (NULL != taosHashGet(pUserAliasSet, aliasName, strlen(aliasName)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t addWstartTsToCreateStreamQueryImpl(SSelectStmt* pSelect, SHashObj* pUserAliasSet) {
|
||||||
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
|
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
|
||||||
if (NULL == pSelect->pWindow ||
|
if (NULL == pSelect->pWindow ||
|
||||||
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
|
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
|
||||||
|
@ -5516,7 +5534,7 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pFunc->functionName, "_wstart");
|
strcpy(pFunc->functionName, "_wstart");
|
||||||
strcpy(pFunc->node.aliasName, pFunc->functionName);
|
getStreamQueryFirstProjectAliasName(pUserAliasSet, pFunc->node.aliasName, sizeof(pFunc->node.aliasName));
|
||||||
int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyNode((SNode*)pFunc);
|
nodesDestroyNode((SNode*)pFunc);
|
||||||
|
@ -5524,6 +5542,17 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t addWstartTsToCreateStreamQuery(STranslateContext* pCxt, SNode* pStmt) {
|
||||||
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||||
|
SHashObj* pUserAliasSet = NULL;
|
||||||
|
int32_t code = checkProjectAlias(pCxt, pSelect->pProjectionList, &pUserAliasSet);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = addWstartTsToCreateStreamQueryImpl(pSelect, pUserAliasSet);
|
||||||
|
}
|
||||||
|
taosHashCleanup(pUserAliasSet);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t addTagsToCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SSelectStmt* pSelect) {
|
static int32_t addTagsToCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pStmt->pTags) {
|
if (NULL == pStmt->pTags) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -5626,7 +5655,7 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
|
|
||||||
static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
|
||||||
pCxt->createStream = true;
|
pCxt->createStream = true;
|
||||||
int32_t code = addWstartTsToCreateStreamQuery(pStmt->pQuery);
|
int32_t code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addSubtableInfoToCreateStreamQuery(pCxt, pStmt);
|
code = addSubtableInfoToCreateStreamQuery(pCxt, pStmt);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -48,7 +48,7 @@ TEST_F(ParserInitialCTest, createAccount) {
|
||||||
* | PRECISION {'ms' | 'us' | 'ns'}
|
* | PRECISION {'ms' | 'us' | 'ns'}
|
||||||
* | REPLICA value
|
* | REPLICA value
|
||||||
* | RETENTIONS ingestion_duration:keep_duration ...
|
* | RETENTIONS ingestion_duration:keep_duration ...
|
||||||
* | STRICT {'off' | 'on'}
|
* | STRICT {'off' | 'on'} // not support
|
||||||
* | WAL_LEVEL value
|
* | WAL_LEVEL value
|
||||||
* | VGROUPS value
|
* | VGROUPS value
|
||||||
* | SINGLE_STABLE {0 | 1}
|
* | SINGLE_STABLE {0 | 1}
|
||||||
|
@ -216,7 +216,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
||||||
addDbRetentionFunc(15 * MILLISECOND_PER_SECOND, 7 * MILLISECOND_PER_DAY, TIME_UNIT_SECOND, TIME_UNIT_DAY);
|
addDbRetentionFunc(15 * MILLISECOND_PER_SECOND, 7 * MILLISECOND_PER_DAY, TIME_UNIT_SECOND, TIME_UNIT_DAY);
|
||||||
addDbRetentionFunc(1 * MILLISECOND_PER_MINUTE, 21 * MILLISECOND_PER_DAY, TIME_UNIT_MINUTE, TIME_UNIT_DAY);
|
addDbRetentionFunc(1 * MILLISECOND_PER_MINUTE, 21 * MILLISECOND_PER_DAY, TIME_UNIT_MINUTE, TIME_UNIT_DAY);
|
||||||
addDbRetentionFunc(15 * MILLISECOND_PER_MINUTE, 500 * MILLISECOND_PER_DAY, TIME_UNIT_MINUTE, TIME_UNIT_DAY);
|
addDbRetentionFunc(15 * MILLISECOND_PER_MINUTE, 500 * MILLISECOND_PER_DAY, TIME_UNIT_MINUTE, TIME_UNIT_DAY);
|
||||||
setDbStrictaFunc(1);
|
// setDbStrictaFunc(1);
|
||||||
setDbWalLevelFunc(2);
|
setDbWalLevelFunc(2);
|
||||||
setDbVgroupsFunc(100);
|
setDbVgroupsFunc(100);
|
||||||
setDbSingleStableFunc(1);
|
setDbSingleStableFunc(1);
|
||||||
|
@ -244,7 +244,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
||||||
"PRECISION 'ns' "
|
"PRECISION 'ns' "
|
||||||
"REPLICA 3 "
|
"REPLICA 3 "
|
||||||
"RETENTIONS 15s:7d,1m:21d,15m:500d "
|
"RETENTIONS 15s:7d,1m:21d,15m:500d "
|
||||||
"STRICT 'on' "
|
// "STRICT 'on' "
|
||||||
"WAL_LEVEL 2 "
|
"WAL_LEVEL 2 "
|
||||||
"VGROUPS 100 "
|
"VGROUPS 100 "
|
||||||
"SINGLE_STABLE 1 "
|
"SINGLE_STABLE 1 "
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
||||||
|
|
||||||
#define QW_DEFAULT_SCHEDULER_NUMBER 100
|
#define QW_DEFAULT_SCHEDULER_NUMBER 100
|
||||||
#define QW_DEFAULT_TASK_NUMBER 10000
|
#define QW_DEFAULT_TASK_NUMBER 10000
|
||||||
#define QW_DEFAULT_SCH_TASK_NUMBER 10000
|
#define QW_DEFAULT_SCH_TASK_NUMBER 500
|
||||||
#define QW_DEFAULT_SHORT_RUN_TIMES 2
|
#define QW_DEFAULT_SHORT_RUN_TIMES 2
|
||||||
#define QW_DEFAULT_HEARTBEAT_MSEC 5000
|
#define QW_DEFAULT_HEARTBEAT_MSEC 5000
|
||||||
#define QW_SCH_TIMEOUT_MSEC 180000
|
#define QW_SCH_TIMEOUT_MSEC 180000
|
||||||
|
|
|
@ -74,6 +74,8 @@ int32_t qwAddSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType) {
|
||||||
SQWSchStatus newSch = {0};
|
SQWSchStatus newSch = {0};
|
||||||
newSch.tasksHash =
|
newSch.tasksHash =
|
||||||
taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
newSch.hbBrokenTs = taosGetTimestampMs();
|
||||||
|
|
||||||
if (NULL == newSch.tasksHash) {
|
if (NULL == newSch.tasksHash) {
|
||||||
QW_SCH_ELOG("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum);
|
QW_SCH_ELOG("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum);
|
||||||
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -463,6 +465,8 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
int8_t nodeType = mgmt->nodeType;
|
int8_t nodeType = mgmt->nodeType;
|
||||||
int32_t nodeId = mgmt->nodeId;
|
int32_t nodeId = mgmt->nodeId;
|
||||||
|
|
||||||
|
int32_t taskCount = 0;
|
||||||
|
int32_t schStatusCount = 0;
|
||||||
qDebug("start to destroy qworker, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt);
|
qDebug("start to destroy qworker, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt);
|
||||||
|
|
||||||
taosTmrStop(mgmt->hbTimer);
|
taosTmrStop(mgmt->hbTimer);
|
||||||
|
@ -472,6 +476,7 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
uint64_t qId, tId;
|
uint64_t qId, tId;
|
||||||
int32_t eId;
|
int32_t eId;
|
||||||
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
|
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
|
||||||
|
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
|
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
|
||||||
void *key = taosHashGetKey(pIter, NULL);
|
void *key = taosHashGetKey(pIter, NULL);
|
||||||
|
@ -480,6 +485,7 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
qwFreeTaskCtx(ctx);
|
qwFreeTaskCtx(ctx);
|
||||||
QW_TASK_DLOG_E("task ctx freed");
|
QW_TASK_DLOG_E("task ctx freed");
|
||||||
pIter = taosHashIterate(mgmt->ctxHash, pIter);
|
pIter = taosHashIterate(mgmt->ctxHash, pIter);
|
||||||
|
taskCount++;
|
||||||
}
|
}
|
||||||
taosHashCleanup(mgmt->ctxHash);
|
taosHashCleanup(mgmt->ctxHash);
|
||||||
|
|
||||||
|
@ -487,7 +493,9 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SQWSchStatus *sch = (SQWSchStatus *)pIter;
|
SQWSchStatus *sch = (SQWSchStatus *)pIter;
|
||||||
qwDestroySchStatus(sch);
|
qwDestroySchStatus(sch);
|
||||||
|
|
||||||
pIter = taosHashIterate(mgmt->schHash, pIter);
|
pIter = taosHashIterate(mgmt->schHash, pIter);
|
||||||
|
schStatusCount++;
|
||||||
}
|
}
|
||||||
taosHashCleanup(mgmt->schHash);
|
taosHashCleanup(mgmt->schHash);
|
||||||
|
|
||||||
|
@ -499,7 +507,8 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
|
|
||||||
qwCloseRef();
|
qwCloseRef();
|
||||||
|
|
||||||
qDebug("qworker destroyed, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt);
|
qDebug("qworker destroyed, type:%d, id:%d, handle:%p, taskCount:%d, schStatusCount: %d", nodeType, nodeId, mgmt,
|
||||||
|
taskCount, schStatusCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwOpenRef(void) {
|
int32_t qwOpenRef(void) {
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include "qwMsg.h"
|
#include "qwMsg.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
#include "tglobal.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tglobal.h"
|
|
||||||
|
|
||||||
SQWorkerMgmt gQwMgmt = {
|
SQWorkerMgmt gQwMgmt = {
|
||||||
.lock = 0,
|
.lock = 0,
|
||||||
|
@ -327,12 +327,14 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == ctx->level) {
|
if (0 == ctx->level) {
|
||||||
QW_TASK_DLOG("task fetched blocks %d rows %"PRId64", level %d", pOutput->numOfBlocks, pOutput->numOfRows, ctx->level);
|
QW_TASK_DLOG("task fetched blocks %d rows %" PRId64 ", level %d", pOutput->numOfBlocks, pOutput->numOfRows,
|
||||||
|
ctx->level);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOutput->numOfRows >= QW_MIN_RES_ROWS) {
|
if (pOutput->numOfRows >= QW_MIN_RES_ROWS) {
|
||||||
QW_TASK_DLOG("task fetched blocks %d rows %" PRId64 " reaches the min rows", pOutput->numOfBlocks, pOutput->numOfRows);
|
QW_TASK_DLOG("task fetched blocks %d rows %" PRId64 " reaches the min rows", pOutput->numOfBlocks,
|
||||||
|
pOutput->numOfRows);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,8 +673,8 @@ _return:
|
||||||
qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code);
|
qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code);
|
||||||
rsp = NULL;
|
rsp = NULL;
|
||||||
|
|
||||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code,
|
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
||||||
tstrerror(code), dataLen);
|
dataLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,7 +750,8 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_LOCK(QW_WRITE, &ctx->lock);
|
QW_LOCK(QW_WRITE, &ctx->lock);
|
||||||
if ((queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code || 0 == atomic_load_8((int8_t *)&ctx->queryContinue)) {
|
if ((queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code ||
|
||||||
|
0 == atomic_load_8((int8_t *)&ctx->queryContinue)) {
|
||||||
// Note: query is not running anymore
|
// Note: query is not running anymore
|
||||||
QW_SET_PHASE(ctx, 0);
|
QW_SET_PHASE(ctx, 0);
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
|
|
|
@ -64,7 +64,7 @@ _return:
|
||||||
int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SSchedulerReq* pReq) {
|
int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SSchedulerReq* pReq) {
|
||||||
SSchJob* pJob = schAcquireJob(jobId);
|
SSchJob* pJob = schAcquireJob(jobId);
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
qWarn("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId);
|
qDebug("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId);
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ void schedulerFreeJob(int64_t *jobId, int32_t errCode) {
|
||||||
|
|
||||||
SSchJob *pJob = schAcquireJob(*jobId);
|
SSchJob *pJob = schAcquireJob(*jobId);
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
qWarn("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, *jobId);
|
qDebug("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, *jobId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ void streamSchedByTimer(void* param, void* tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atomic_load_8(&pTask->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) {
|
if (atomic_load_8(&pTask->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) {
|
||||||
SStreamTrigger* trigger = taosAllocateQitem(sizeof(SStreamTrigger), DEF_QITEM);
|
SStreamTrigger* trigger = taosAllocateQitem(sizeof(SStreamTrigger), DEF_QITEM, 0);
|
||||||
if (trigger == NULL) return;
|
if (trigger == NULL) return;
|
||||||
trigger->type = STREAM_INPUT__GET_RES;
|
trigger->type = STREAM_INPUT__GET_RES;
|
||||||
trigger->pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
trigger->pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
@ -112,7 +112,7 @@ int32_t streamSchedExec(SStreamTask* pTask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamTaskEnqueue(SStreamTask* pTask, const SStreamDispatchReq* pReq, SRpcMsg* pRsp) {
|
int32_t streamTaskEnqueue(SStreamTask* pTask, const SStreamDispatchReq* pReq, SRpcMsg* pRsp) {
|
||||||
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||||
int8_t status;
|
int8_t status;
|
||||||
|
|
||||||
// enqueue
|
// enqueue
|
||||||
|
@ -150,7 +150,7 @@ int32_t streamTaskEnqueue(SStreamTask* pTask, const SStreamDispatchReq* pReq, SR
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pRsp) {
|
int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pRsp) {
|
||||||
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||||
int8_t status = TASK_INPUT_STATUS__NORMAL;
|
int8_t status = TASK_INPUT_STATUS__NORMAL;
|
||||||
|
|
||||||
// enqueue
|
// enqueue
|
||||||
|
|
|
@ -67,7 +67,7 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamDataSubmit* streamDataSubmitNew(SSubmitReq* pReq) {
|
SStreamDataSubmit* streamDataSubmitNew(SSubmitReq* pReq) {
|
||||||
SStreamDataSubmit* pDataSubmit = (SStreamDataSubmit*)taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM);
|
SStreamDataSubmit* pDataSubmit = (SStreamDataSubmit*)taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM, 0);
|
||||||
if (pDataSubmit == NULL) return NULL;
|
if (pDataSubmit == NULL) return NULL;
|
||||||
pDataSubmit->dataRef = (int32_t*)taosMemoryMalloc(sizeof(int32_t));
|
pDataSubmit->dataRef = (int32_t*)taosMemoryMalloc(sizeof(int32_t));
|
||||||
if (pDataSubmit->dataRef == NULL) goto FAIL;
|
if (pDataSubmit->dataRef == NULL) goto FAIL;
|
||||||
|
@ -81,7 +81,7 @@ FAIL:
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamMergedSubmit* streamMergedSubmitNew() {
|
SStreamMergedSubmit* streamMergedSubmitNew() {
|
||||||
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)taosAllocateQitem(sizeof(SStreamMergedSubmit), DEF_QITEM);
|
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)taosAllocateQitem(sizeof(SStreamMergedSubmit), DEF_QITEM, 0);
|
||||||
if (pMerged == NULL) return NULL;
|
if (pMerged == NULL) return NULL;
|
||||||
pMerged->reqs = taosArrayInit(0, sizeof(void*));
|
pMerged->reqs = taosArrayInit(0, sizeof(void*));
|
||||||
pMerged->dataRefs = taosArrayInit(0, sizeof(void*));
|
pMerged->dataRefs = taosArrayInit(0, sizeof(void*));
|
||||||
|
@ -107,7 +107,7 @@ static FORCE_INLINE void streamDataSubmitRefInc(SStreamDataSubmit* pDataSubmit)
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamDataSubmit* streamSubmitRefClone(SStreamDataSubmit* pSubmit) {
|
SStreamDataSubmit* streamSubmitRefClone(SStreamDataSubmit* pSubmit) {
|
||||||
SStreamDataSubmit* pSubmitClone = taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM);
|
SStreamDataSubmit* pSubmitClone = taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM, 0);
|
||||||
if (pSubmitClone == NULL) {
|
if (pSubmitClone == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz) {
|
||||||
taosArrayDestroy(pRes);
|
taosArrayDestroy(pRes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||||
if (qRes == NULL) {
|
if (qRes == NULL) {
|
||||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -235,7 +235,7 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
qDebug("stream task %d exec end", pTask->taskId);
|
qDebug("stream task %d exec end", pTask->taskId);
|
||||||
|
|
||||||
if (taosArrayGetSize(pRes) != 0) {
|
if (taosArrayGetSize(pRes) != 0) {
|
||||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||||
if (qRes == NULL) {
|
if (qRes == NULL) {
|
||||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
streamFreeQitem(input);
|
streamFreeQitem(input);
|
||||||
|
|
|
@ -215,7 +215,7 @@ int32_t syncNodeStart(SSyncNode* pSyncNode);
|
||||||
int32_t syncNodeStartStandBy(SSyncNode* pSyncNode);
|
int32_t syncNodeStartStandBy(SSyncNode* pSyncNode);
|
||||||
void syncNodeClose(SSyncNode* pSyncNode);
|
void syncNodeClose(SSyncNode* pSyncNode);
|
||||||
void syncNodePreClose(SSyncNode* pSyncNode);
|
void syncNodePreClose(SSyncNode* pSyncNode);
|
||||||
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak);
|
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_t *seq);
|
||||||
int32_t syncNodeRestore(SSyncNode* pSyncNode);
|
int32_t syncNodeRestore(SSyncNode* pSyncNode);
|
||||||
void syncHbTimerDataFree(SSyncHbTimerData* pData);
|
void syncHbTimerDataFree(SSyncHbTimerData* pData);
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,26 @@ int32_t syncLeaderTransfer(int64_t rid) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) {
|
||||||
|
SSyncNode* pNode = syncNodeAcquire(rid);
|
||||||
|
if (pNode == NULL) return -1;
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {0};
|
||||||
|
int32_t ret = syncRespMgrGetAndDel(pNode->pSyncRespMgr, seq, &rpcMsg.info);
|
||||||
|
rpcMsg.code = TSDB_CODE_SYN_TIMEOUT;
|
||||||
|
|
||||||
|
syncNodeRelease(pNode);
|
||||||
|
if (ret == 1) {
|
||||||
|
sInfo("send timeout response, seq:%" PRId64 " handle:%p ahandle:%p", seq, rpcMsg.info.handle,
|
||||||
|
rpcMsg.info.ahandle);
|
||||||
|
rpcSendResponse(&rpcMsg);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
sInfo("no rpcinfo to send timeout response, seq:%" PRId64, seq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SyncIndex syncMinMatchIndex(SSyncNode* pSyncNode) {
|
SyncIndex syncMinMatchIndex(SSyncNode* pSyncNode) {
|
||||||
SyncIndex minMatchIndex = SYNC_INDEX_INVALID;
|
SyncIndex minMatchIndex = SYNC_INDEX_INVALID;
|
||||||
|
|
||||||
|
@ -538,7 +558,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
|
||||||
pMsg->newLeaderId.vgId = pSyncNode->vgId;
|
pMsg->newLeaderId.vgId = pSyncNode->vgId;
|
||||||
pMsg->newNodeInfo = newLeader;
|
pMsg->newNodeInfo = newLeader;
|
||||||
|
|
||||||
int32_t ret = syncNodePropose(pSyncNode, &rpcMsg, false);
|
int32_t ret = syncNodePropose(pSyncNode, &rpcMsg, false, NULL);
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -670,19 +690,19 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
|
int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq) {
|
||||||
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
SSyncNode* pSyncNode = syncNodeAcquire(rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
sError("sync propose error");
|
sError("sync propose error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = syncNodePropose(pSyncNode, pMsg, isWeak);
|
int32_t ret = syncNodePropose(pSyncNode, pMsg, isWeak, seq);
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
|
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_t* seq) {
|
||||||
if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
|
||||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
sNError(pSyncNode, "sync propose not leader, %s, type:%s", syncStr(pSyncNode->state), TMSG_INFO(pMsg->msgType));
|
sNError(pSyncNode, "sync propose not leader, %s, type:%s", syncStr(pSyncNode->state), TMSG_INFO(pMsg->msgType));
|
||||||
|
@ -739,6 +759,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
|
||||||
(void)syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum);
|
(void)syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (seq != NULL) *seq = seqNum;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,6 +594,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int64_t firstIndex = -1;
|
int64_t firstIndex = -1;
|
||||||
SyncTerm term = -1;
|
SyncTerm term = -1;
|
||||||
|
int64_t batchSize = TMAX(1, pMgr->size >> (4 + pMgr->retryBackoff));
|
||||||
|
|
||||||
for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) {
|
for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) {
|
||||||
int64_t pos = index % pMgr->size;
|
int64_t pos = index % pMgr->size;
|
||||||
|
@ -620,7 +621,10 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
||||||
|
|
||||||
retried = true;
|
retried = true;
|
||||||
if (firstIndex == -1) firstIndex = index;
|
if (firstIndex == -1) firstIndex = index;
|
||||||
count++;
|
|
||||||
|
if (batchSize <= count++) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -800,8 +804,9 @@ int32_t syncLogReplMgrReplicateProbeOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode
|
||||||
|
|
||||||
int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
||||||
ASSERT(pMgr->restored);
|
ASSERT(pMgr->restored);
|
||||||
|
|
||||||
SRaftId* pDestId = &pNode->replicasId[pMgr->peerId];
|
SRaftId* pDestId = &pNode->replicasId[pMgr->peerId];
|
||||||
int32_t batchSize = TMAX(1, pMgr->size / 20);
|
int32_t batchSize = TMAX(1, pMgr->size >> (4 + pMgr->retryBackoff));
|
||||||
int32_t count = 0;
|
int32_t count = 0;
|
||||||
int64_t nowMs = taosGetMonoTimestampMs();
|
int64_t nowMs = taosGetMonoTimestampMs();
|
||||||
int64_t limit = pMgr->size >> 1;
|
int64_t limit = pMgr->size >> 1;
|
||||||
|
|
|
@ -337,7 +337,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false, NULL);
|
||||||
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader", s, alreadySend);
|
sTrace("%s value%d write not leader", s, alreadySend);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -249,7 +249,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false, NULL);
|
||||||
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader", s, alreadySend);
|
sTrace("%s value%d write not leader", s, alreadySend);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -189,7 +189,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false, NULL);
|
||||||
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader", s, alreadySend);
|
sTrace("%s value%d write not leader", s, alreadySend);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -396,7 +396,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false, NULL);
|
||||||
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait);
|
sTrace("%s value%d write not leader, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -97,7 +97,7 @@ int32_t syncIOEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||||
syncRpcMsgLog2(logBuf, pMsg);
|
syncRpcMsgLog2(logBuf, pMsg);
|
||||||
|
|
||||||
SRpcMsg *pTemp;
|
SRpcMsg *pTemp;
|
||||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||||
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
||||||
|
|
||||||
STaosQueue *pMsgQ = gSyncIO->pMsgQ;
|
STaosQueue *pMsgQ = gSyncIO->pMsgQ;
|
||||||
|
@ -381,7 +381,7 @@ static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
syncRpcMsgLog2((char *)"==syncIOProcessRequest==", pMsg);
|
syncRpcMsgLog2((char *)"==syncIOProcessRequest==", pMsg);
|
||||||
SSyncIO *io = pParent;
|
SSyncIO *io = pParent;
|
||||||
SRpcMsg *pTemp;
|
SRpcMsg *pTemp;
|
||||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||||
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
||||||
taosWriteQitem(io->pMsgQ, pTemp);
|
taosWriteQitem(io->pMsgQ, pTemp);
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ static void syncIOTickQ(void *param, void *tmrId) {
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg;
|
||||||
syncPingReply2RpcMsg(pMsg, &rpcMsg);
|
syncPingReply2RpcMsg(pMsg, &rpcMsg);
|
||||||
SRpcMsg *pTemp;
|
SRpcMsg *pTemp;
|
||||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||||
memcpy(pTemp, &rpcMsg, sizeof(SRpcMsg));
|
memcpy(pTemp, &rpcMsg, sizeof(SRpcMsg));
|
||||||
syncRpcMsgLog2((char *)"==syncIOTickQ==", &rpcMsg);
|
syncRpcMsgLog2((char *)"==syncIOTickQ==", &rpcMsg);
|
||||||
taosWriteQitem(io->pMsgQ, pTemp);
|
taosWriteQitem(io->pMsgQ, pTemp);
|
||||||
|
|
|
@ -49,8 +49,6 @@ typedef struct {
|
||||||
|
|
||||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||||
int8_t encryption; // encrypt or not
|
int8_t encryption; // encrypt or not
|
||||||
int32_t retryLimit; // retry limit
|
|
||||||
int32_t retryInterval; // retry interval ms
|
|
||||||
|
|
||||||
int32_t retryMinInterval; // retry init interval
|
int32_t retryMinInterval; // retry init interval
|
||||||
int32_t retryStepFactor; // retry interval factor
|
int32_t retryStepFactor; // retry interval factor
|
||||||
|
|
|
@ -47,9 +47,11 @@ void* rpcOpen(const SRpcInit* pInit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pRpc->compressSize = pInit->compressSize;
|
pRpc->compressSize = pInit->compressSize;
|
||||||
|
if (pRpc->compressSize < 0) {
|
||||||
|
pRpc->compressSize = -1;
|
||||||
|
}
|
||||||
|
|
||||||
pRpc->encryption = pInit->encryption;
|
pRpc->encryption = pInit->encryption;
|
||||||
pRpc->retryLimit = pInit->retryLimit;
|
|
||||||
pRpc->retryInterval = pInit->retryInterval;
|
|
||||||
|
|
||||||
pRpc->retryMinInterval = pInit->retryMinInterval; // retry init interval
|
pRpc->retryMinInterval = pInit->retryMinInterval; // retry init interval
|
||||||
pRpc->retryStepFactor = pInit->retryStepFactor;
|
pRpc->retryStepFactor = pInit->retryStepFactor;
|
||||||
|
|
|
@ -604,6 +604,7 @@ static int32_t allocConnRef(SCliConn* conn, bool update) {
|
||||||
|
|
||||||
static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
|
static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
|
||||||
if (update) {
|
if (update) {
|
||||||
|
transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||||
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||||
conn->refId = -1;
|
conn->refId = -1;
|
||||||
}
|
}
|
||||||
|
@ -956,7 +957,6 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
|
|
||||||
SCliConn* conn = exh->handle;
|
SCliConn* conn = exh->handle;
|
||||||
transReleaseExHandle(transGetRefMgt(), refId);
|
transReleaseExHandle(transGetRefMgt(), refId);
|
||||||
|
|
||||||
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
|
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
|
||||||
|
|
||||||
if (T_REF_VAL_GET(conn) == 2) {
|
if (T_REF_VAL_GET(conn) == 2) {
|
||||||
|
@ -1574,6 +1574,9 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||||
pCtx->retryStep = 0;
|
pCtx->retryStep = 0;
|
||||||
pCtx->retryInit = true;
|
pCtx->retryInit = true;
|
||||||
pCtx->retryCode = TSDB_CODE_SUCCESS;
|
pCtx->retryCode = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
// already retry, not use handle specified by app;
|
||||||
|
pMsg->msg.info.handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
||||||
|
@ -1626,9 +1629,9 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||||
pCtx->retryNextInterval = pCtx->retryMaxInterval;
|
pCtx->retryNextInterval = pCtx->retryMaxInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
// if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
pCtx->retryNextInterval = 0;
|
pCtx->retryNextInterval = 0;
|
||||||
pCtx->epsetRetryCnt++;
|
pCtx->epsetRetryCnt++;
|
||||||
|
|
|
@ -128,7 +128,7 @@ void *processShellMsg(void *arg) {
|
||||||
void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
SRpcMsg *pTemp;
|
SRpcMsg *pTemp;
|
||||||
|
|
||||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||||
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
||||||
|
|
||||||
int32_t idx = balance % multiQ->numOfThread;
|
int32_t idx = balance % multiQ->numOfThread;
|
||||||
|
|
|
@ -223,6 +223,7 @@ void walClose(SWal *pWal) {
|
||||||
taosMemoryFree(pRef);
|
taosMemoryFree(pRef);
|
||||||
}
|
}
|
||||||
taosHashCleanup(pWal->pRefHash);
|
taosHashCleanup(pWal->pRefHash);
|
||||||
|
pWal->pRefHash = NULL;
|
||||||
taosThreadMutexUnlock(&pWal->mutex);
|
taosThreadMutexUnlock(&pWal->mutex);
|
||||||
|
|
||||||
taosRemoveRef(tsWal.refSetId, pWal->refId);
|
taosRemoveRef(tsWal.refSetId, pWal->refId);
|
||||||
|
|
|
@ -32,15 +32,18 @@ SWalRef *walOpenRef(SWal *pWal) {
|
||||||
return pRef;
|
return pRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
void walCloseRef(SWal *pWal, int64_t refId) {
|
void walCloseRef(SWal *pWal, int64_t refId) {
|
||||||
SWalRef **ppRef = taosHashGet(pWal->pRefHash, &refId, sizeof(int64_t));
|
SWalRef **ppRef = taosHashGet(pWal->pRefHash, &refId, sizeof(int64_t));
|
||||||
if (ppRef == NULL) return;
|
if (ppRef == NULL) return;
|
||||||
SWalRef *pRef = *ppRef;
|
SWalRef *pRef = *ppRef;
|
||||||
|
if (pRef) {
|
||||||
|
wDebug("vgId:%d, wal close ref %" PRId64 ", refId %" PRId64, pWal->cfg.vgId, pRef->refVer, pRef->refId);
|
||||||
|
} else {
|
||||||
|
wDebug("vgId:%d, wal close ref null, refId %" PRId64, pWal->cfg.vgId, refId);
|
||||||
|
}
|
||||||
taosHashRemove(pWal->pRefHash, &refId, sizeof(int64_t));
|
taosHashRemove(pWal->pRefHash, &refId, sizeof(int64_t));
|
||||||
taosMemoryFree(pRef);
|
taosMemoryFree(pRef);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t walRefVer(SWalRef *pRef, int64_t ver) {
|
int32_t walRefVer(SWalRef *pRef, int64_t ver) {
|
||||||
SWal *pWal = pRef->pWal;
|
SWal *pWal = pRef->pWal;
|
||||||
|
|
|
@ -37,7 +37,7 @@ float tsNumOfCores = 0;
|
||||||
int64_t tsTotalMemoryKB = 0;
|
int64_t tsTotalMemoryKB = 0;
|
||||||
char *tsProcPath = NULL;
|
char *tsProcPath = NULL;
|
||||||
|
|
||||||
char tsSIMDEnable = 0;
|
char tsSIMDBuiltins = 0;
|
||||||
char tsSSE42Enable = 0;
|
char tsSSE42Enable = 0;
|
||||||
char tsAVXEnable = 0;
|
char tsAVXEnable = 0;
|
||||||
char tsAVX2Enable = 0;
|
char tsAVX2Enable = 0;
|
||||||
|
|
|
@ -485,11 +485,11 @@ int32_t taosGetCpuInstructions(char* sse42, char* avx, char* avx2, char* fma) {
|
||||||
#ifdef _TD_X86_
|
#ifdef _TD_X86_
|
||||||
// Since the compiler is not support avx/avx2 instructions, the global variables always need to be
|
// Since the compiler is not support avx/avx2 instructions, the global variables always need to be
|
||||||
// set to be false
|
// set to be false
|
||||||
#if __AVX__ || __AVX2__
|
//#if __AVX__ || __AVX2__
|
||||||
tsSIMDEnable = true;
|
// tsSIMDBuiltins = true;
|
||||||
#else
|
//#else
|
||||||
tsSIMDEnable = false;
|
// tsSIMDBuiltins = false;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
|
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue