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")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_INTEL_64 OR TD_INTEL_32)
|
||||
ADD_DEFINITIONS("-msse4.2")
|
||||
IF("${FMA_SUPPORT}" MATCHES "true")
|
||||
MESSAGE(STATUS "fma function supported")
|
||||
ADD_DEFINITIONS("-mfma")
|
||||
ELSE ()
|
||||
MESSAGE(STATUS "fma function NOT supported")
|
||||
ENDIF()
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
IF (("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") OR ("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang"))
|
||||
SET(COMPILER_SUPPORT_SSE42 true)
|
||||
MESSAGE(STATUS "Always enable sse4.2 for Clang/AppleClang")
|
||||
ELSE()
|
||||
CHECK_C_COMPILER_FLAG("-msse4.2" COMPILER_SUPPORT_SSE42)
|
||||
ENDIF()
|
||||
|
||||
IF("${SIMD_SUPPORT}" MATCHES "true")
|
||||
ADD_DEFINITIONS("-mavx -mavx2")
|
||||
MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "SIMD instruction (AVX/AVX2)is NOT ACTIVATED")
|
||||
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()
|
||||
|
||||
IF ("${SIMD_SUPPORT}" MATCHES "true")
|
||||
IF (COMPILER_SUPPORT_AVX)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||
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 ()
|
||||
|
|
|
@ -147,7 +147,7 @@ ELSE ()
|
|||
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("CXX Compiler: ${CMAKE_CXX_COMPILER} (${CMAKE_C_COMPILER_ID}, ${CMAKE_CXX_COMPILER_VERSION})")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.1.8")
|
||||
SET(TD_VER_NUMBER "3.0.2.0")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -76,7 +76,7 @@ Development: false
|
|||
### 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
|
||||
mvn clean package
|
||||
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
|
||||
mvn clean package
|
||||
unzip -d $CONFLUENT_HOME/share/java/ target/components/packages/taosdata-kafka-connect-tdengine-*.zip
|
||||
|
|
|
@ -3,19 +3,13 @@ PROJECT(TDengine)
|
|||
IF (TD_LINUX)
|
||||
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
||||
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(stream_demo "")
|
||||
add_executable(demoapi "")
|
||||
add_executable(api_reqid "")
|
||||
add_executable(schemaless "")
|
||||
add_executable(prepare "")
|
||||
add_executable(demo "")
|
||||
add_executable(asyncdemo "")
|
||||
|
||||
target_sources(tmq
|
||||
PRIVATE
|
||||
|
@ -27,16 +21,25 @@ IF (TD_LINUX)
|
|||
"stream_demo.c"
|
||||
)
|
||||
|
||||
target_sources(demoapi
|
||||
target_sources(schemaless
|
||||
PRIVATE
|
||||
"demoapi.c"
|
||||
"schemaless.c"
|
||||
)
|
||||
|
||||
target_sources(api_reqid
|
||||
target_sources(prepare
|
||||
PRIVATE
|
||||
"api_with_reqid_test.c"
|
||||
"prepare.c"
|
||||
)
|
||||
|
||||
target_sources(demo
|
||||
PRIVATE
|
||||
"demo.c"
|
||||
)
|
||||
|
||||
target_sources(asyncdemo
|
||||
PRIVATE
|
||||
"asyncdemo.c"
|
||||
)
|
||||
|
||||
target_link_libraries(tmq
|
||||
taos_static
|
||||
|
@ -46,46 +49,30 @@ IF (TD_LINUX)
|
|||
taos_static
|
||||
)
|
||||
|
||||
target_link_libraries(demoapi
|
||||
target_link_libraries(schemaless
|
||||
taos_static
|
||||
)
|
||||
|
||||
target_link_libraries(api_reqid
|
||||
target_link_libraries(prepare
|
||||
taos_static
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(tmq
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
target_link_libraries(demo
|
||||
taos_static
|
||||
)
|
||||
|
||||
target_include_directories(stream_demo
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
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"
|
||||
target_link_libraries(asyncdemo
|
||||
taos_static
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
||||
SET_TARGET_PROPERTIES(stream_demo PROPERTIES OUTPUT_NAME stream_demo)
|
||||
SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi)
|
||||
SET_TARGET_PROPERTIES(api_reqid PROPERTIES OUTPUT_NAME api_reqid)
|
||||
SET_TARGET_PROPERTIES(schemaless PROPERTIES OUTPUT_NAME schemaless)
|
||||
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 ()
|
||||
IF (TD_DARWIN)
|
||||
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)
|
||||
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 ()
|
||||
|
|
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 <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../../include/client/taos.h"
|
||||
#include <inttypes.h>
|
||||
#include "taos.h"
|
||||
|
||||
int points = 5;
|
||||
int numOfTables = 3;
|
||||
|
@ -230,7 +230,7 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code)
|
|||
if (tablesInsertProcessed >= numOfTables) {
|
||||
gettimeofday(&systemTime, NULL);
|
||||
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) {
|
||||
gettimeofday(&systemTime, NULL);
|
||||
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);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.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) {
|
||||
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 \
|
||||
-Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \
|
||||
-Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \
|
||||
-I../../../deps/cJson/inc
|
||||
-I/usr/local/include/cjson
|
||||
all: $(TARGET)
|
||||
|
||||
exe:
|
||||
gcc $(CFLAGS) ./asyncdemo.c -o $(ROOT)asyncdemo $(LFLAGS)
|
||||
gcc $(CFLAGS) ./demo.c -o $(ROOT)demo $(LFLAGS)
|
||||
gcc $(CFLAGS) ./prepare.c -o $(ROOT)prepare $(LFLAGS)
|
||||
gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS)
|
||||
gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS)
|
||||
gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS)
|
||||
gcc $(CFLAGS) ./stream_demo.c -o $(ROOT)stream_demo $(LFLAGS)
|
||||
gcc $(CFLAGS) ./tmq.c -o $(ROOT)tmq $(LFLAGS)
|
||||
gcc $(CFLAGS) ./schemaless.c -o $(ROOT)schemaless $(LFLAGS)
|
||||
|
||||
clean:
|
||||
rm $(ROOT)asyncdemo
|
||||
rm $(ROOT)demo
|
||||
rm $(ROOT)prepare
|
||||
rm $(ROOT)batchprepare
|
||||
rm $(ROOT)stream
|
||||
rm $(ROOT)subscribe
|
||||
rm $(ROOT)apitest
|
||||
rm $(ROOT)stream_demo
|
||||
rm $(ROOT)tmq
|
||||
rm $(ROOT)schemaless
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../../../include/client/taos.h"
|
||||
#include "taos.h"
|
||||
|
||||
void taosMsleep(int mseconds);
|
||||
|
||||
|
@ -70,70 +70,89 @@ int main(int argc, char *argv[])
|
|||
char blob[80];
|
||||
} 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);
|
||||
TAOS_BIND params[10];
|
||||
TAOS_MULTI_BIND params[10];
|
||||
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
params[0].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
|
||||
params[1].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
||||
params[2].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
||||
params[3].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[4].buffer_type = TSDB_DATA_TYPE_INT;
|
||||
params[4].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
|
||||
params[5].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
|
||||
params[6].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
|
||||
params[7].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
|
||||
params[8].buffer_length = sizeof(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].num = 1;
|
||||
|
||||
strcpy(v.blob, "一二三四五六七八九十");
|
||||
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].length = ¶ms[9].buffer_length;
|
||||
params[9].length = &ncharLen;
|
||||
params[9].is_null = NULL;
|
||||
params[9].num = 1;
|
||||
|
||||
int is_null = 1;
|
||||
char is_null = 1;
|
||||
|
||||
sql = "insert into m1 values(?,?,?,?,?,?,?,?,?,?)";
|
||||
code = taos_stmt_prepare(stmt, sql, 0);
|
||||
|
@ -153,7 +172,7 @@ int main(int argc, char *argv[])
|
|||
v.v8 = (int64_t)(i * 8);
|
||||
v.f4 = (float)(i * 40);
|
||||
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');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +1,17 @@
|
|||
#include "../../../include/client/taos.h"
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
|
||||
#include "taos.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int numSuperTables = 8;
|
||||
int numChildTables = 4;
|
||||
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() {
|
||||
struct timeval systemTime;
|
||||
gettimeofday(&systemTime, NULL);
|
||||
|
@ -46,7 +31,7 @@ int main(int argc, char* argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
char* info = taos_get_server_info(taos);
|
||||
const char* info = taos_get_server_info(taos);
|
||||
printf("server info: %s\n", info);
|
||||
info = taos_get_client_info(taos);
|
||||
printf("client info: %s\n", info);
|
||||
|
@ -61,9 +46,10 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
time_t ct = time(0);
|
||||
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;
|
||||
for (int i = 0; i < numSuperTables; ++i) {
|
||||
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");
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -108,10 +108,13 @@ int32_t create_stream() {
|
|||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int code;
|
||||
if (argc > 1) {
|
||||
printf("env init\n");
|
||||
code = init_env();
|
||||
int code = init_env();
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
create_stream();
|
||||
}
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
#include "taos.h"
|
||||
|
||||
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) {
|
||||
char buf[1024];
|
||||
|
@ -43,7 +40,7 @@ static int32_t msg_process(TAOS_RES* msg) {
|
|||
|
||||
TAOS_FIELD* fields = taos_fetch_fields(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);
|
||||
rows++;
|
||||
taos_print_row(buf, row, fields, numOfFields);
|
||||
|
@ -62,6 +59,13 @@ static int32_t init_env() {
|
|||
TAOS_RES* pRes;
|
||||
// drop database if exists
|
||||
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");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
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();
|
||||
if (NULL == tmq) {
|
||||
fprintf(stderr, "%% build_consumer() fail!\n");
|
||||
fprintf(stderr, "build_consumer() fail!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -259,7 +263,7 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -267,9 +271,9 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
code = tmq_consumer_close(tmq);
|
||||
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 {
|
||||
fprintf(stderr, "%% Consumer closed\n");
|
||||
fprintf(stderr, "Consumer closed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -195,6 +195,7 @@ typedef struct SDataBlockInfo {
|
|||
uint32_t capacity;
|
||||
SBlockID id;
|
||||
int16_t hasVarCol;
|
||||
int16_t dataLoad; // denote if the data is loaded or not
|
||||
|
||||
// TODO: optimize and remove following
|
||||
int64_t version; // used for stream, and need serialization
|
||||
|
|
|
@ -94,242 +94,242 @@
|
|||
#define TK_TSDB_PAGESIZE 76
|
||||
#define TK_PRECISION 77
|
||||
#define TK_REPLICA 78
|
||||
#define TK_STRICT 79
|
||||
#define TK_VGROUPS 80
|
||||
#define TK_SINGLE_STABLE 81
|
||||
#define TK_RETENTIONS 82
|
||||
#define TK_SCHEMALESS 83
|
||||
#define TK_WAL_LEVEL 84
|
||||
#define TK_WAL_FSYNC_PERIOD 85
|
||||
#define TK_WAL_RETENTION_PERIOD 86
|
||||
#define TK_WAL_RETENTION_SIZE 87
|
||||
#define TK_WAL_ROLL_PERIOD 88
|
||||
#define TK_WAL_SEGMENT_SIZE 89
|
||||
#define TK_STT_TRIGGER 90
|
||||
#define TK_TABLE_PREFIX 91
|
||||
#define TK_TABLE_SUFFIX 92
|
||||
#define TK_NK_COLON 93
|
||||
#define TK_MAX_SPEED 94
|
||||
#define TK_TABLE 95
|
||||
#define TK_NK_LP 96
|
||||
#define TK_NK_RP 97
|
||||
#define TK_STABLE 98
|
||||
#define TK_ADD 99
|
||||
#define TK_COLUMN 100
|
||||
#define TK_MODIFY 101
|
||||
#define TK_RENAME 102
|
||||
#define TK_TAG 103
|
||||
#define TK_SET 104
|
||||
#define TK_NK_EQ 105
|
||||
#define TK_USING 106
|
||||
#define TK_TAGS 107
|
||||
#define TK_COMMENT 108
|
||||
#define TK_BOOL 109
|
||||
#define TK_TINYINT 110
|
||||
#define TK_SMALLINT 111
|
||||
#define TK_INT 112
|
||||
#define TK_INTEGER 113
|
||||
#define TK_BIGINT 114
|
||||
#define TK_FLOAT 115
|
||||
#define TK_DOUBLE 116
|
||||
#define TK_BINARY 117
|
||||
#define TK_TIMESTAMP 118
|
||||
#define TK_NCHAR 119
|
||||
#define TK_UNSIGNED 120
|
||||
#define TK_JSON 121
|
||||
#define TK_VARCHAR 122
|
||||
#define TK_MEDIUMBLOB 123
|
||||
#define TK_BLOB 124
|
||||
#define TK_VARBINARY 125
|
||||
#define TK_DECIMAL 126
|
||||
#define TK_MAX_DELAY 127
|
||||
#define TK_WATERMARK 128
|
||||
#define TK_ROLLUP 129
|
||||
#define TK_TTL 130
|
||||
#define TK_SMA 131
|
||||
#define TK_DELETE_MARK 132
|
||||
#define TK_FIRST 133
|
||||
#define TK_LAST 134
|
||||
#define TK_SHOW 135
|
||||
#define TK_PRIVILEGES 136
|
||||
#define TK_DATABASES 137
|
||||
#define TK_TABLES 138
|
||||
#define TK_STABLES 139
|
||||
#define TK_MNODES 140
|
||||
#define TK_QNODES 141
|
||||
#define TK_FUNCTIONS 142
|
||||
#define TK_INDEXES 143
|
||||
#define TK_ACCOUNTS 144
|
||||
#define TK_APPS 145
|
||||
#define TK_CONNECTIONS 146
|
||||
#define TK_LICENCES 147
|
||||
#define TK_GRANTS 148
|
||||
#define TK_QUERIES 149
|
||||
#define TK_SCORES 150
|
||||
#define TK_TOPICS 151
|
||||
#define TK_VARIABLES 152
|
||||
#define TK_CLUSTER 153
|
||||
#define TK_BNODES 154
|
||||
#define TK_SNODES 155
|
||||
#define TK_TRANSACTIONS 156
|
||||
#define TK_DISTRIBUTED 157
|
||||
#define TK_CONSUMERS 158
|
||||
#define TK_SUBSCRIPTIONS 159
|
||||
#define TK_VNODES 160
|
||||
#define TK_LIKE 161
|
||||
#define TK_TBNAME 162
|
||||
#define TK_QTAGS 163
|
||||
#define TK_AS 164
|
||||
#define TK_INDEX 165
|
||||
#define TK_FUNCTION 166
|
||||
#define TK_INTERVAL 167
|
||||
#define TK_TOPIC 168
|
||||
#define TK_WITH 169
|
||||
#define TK_META 170
|
||||
#define TK_CONSUMER 171
|
||||
#define TK_GROUP 172
|
||||
#define TK_DESC 173
|
||||
#define TK_DESCRIBE 174
|
||||
#define TK_RESET 175
|
||||
#define TK_QUERY 176
|
||||
#define TK_CACHE 177
|
||||
#define TK_EXPLAIN 178
|
||||
#define TK_ANALYZE 179
|
||||
#define TK_VERBOSE 180
|
||||
#define TK_NK_BOOL 181
|
||||
#define TK_RATIO 182
|
||||
#define TK_NK_FLOAT 183
|
||||
#define TK_OUTPUTTYPE 184
|
||||
#define TK_AGGREGATE 185
|
||||
#define TK_BUFSIZE 186
|
||||
#define TK_STREAM 187
|
||||
#define TK_INTO 188
|
||||
#define TK_TRIGGER 189
|
||||
#define TK_AT_ONCE 190
|
||||
#define TK_WINDOW_CLOSE 191
|
||||
#define TK_IGNORE 192
|
||||
#define TK_EXPIRED 193
|
||||
#define TK_FILL_HISTORY 194
|
||||
#define TK_SUBTABLE 195
|
||||
#define TK_KILL 196
|
||||
#define TK_CONNECTION 197
|
||||
#define TK_TRANSACTION 198
|
||||
#define TK_BALANCE 199
|
||||
#define TK_VGROUP 200
|
||||
#define TK_MERGE 201
|
||||
#define TK_REDISTRIBUTE 202
|
||||
#define TK_SPLIT 203
|
||||
#define TK_DELETE 204
|
||||
#define TK_INSERT 205
|
||||
#define TK_NULL 206
|
||||
#define TK_NK_QUESTION 207
|
||||
#define TK_NK_ARROW 208
|
||||
#define TK_ROWTS 209
|
||||
#define TK_QSTART 210
|
||||
#define TK_QEND 211
|
||||
#define TK_QDURATION 212
|
||||
#define TK_WSTART 213
|
||||
#define TK_WEND 214
|
||||
#define TK_WDURATION 215
|
||||
#define TK_IROWTS 216
|
||||
#define TK_CAST 217
|
||||
#define TK_NOW 218
|
||||
#define TK_TODAY 219
|
||||
#define TK_TIMEZONE 220
|
||||
#define TK_CLIENT_VERSION 221
|
||||
#define TK_SERVER_VERSION 222
|
||||
#define TK_SERVER_STATUS 223
|
||||
#define TK_CURRENT_USER 224
|
||||
#define TK_COUNT 225
|
||||
#define TK_LAST_ROW 226
|
||||
#define TK_CASE 227
|
||||
#define TK_END 228
|
||||
#define TK_WHEN 229
|
||||
#define TK_THEN 230
|
||||
#define TK_ELSE 231
|
||||
#define TK_BETWEEN 232
|
||||
#define TK_IS 233
|
||||
#define TK_NK_LT 234
|
||||
#define TK_NK_GT 235
|
||||
#define TK_NK_LE 236
|
||||
#define TK_NK_GE 237
|
||||
#define TK_NK_NE 238
|
||||
#define TK_MATCH 239
|
||||
#define TK_NMATCH 240
|
||||
#define TK_CONTAINS 241
|
||||
#define TK_IN 242
|
||||
#define TK_JOIN 243
|
||||
#define TK_INNER 244
|
||||
#define TK_SELECT 245
|
||||
#define TK_DISTINCT 246
|
||||
#define TK_WHERE 247
|
||||
#define TK_PARTITION 248
|
||||
#define TK_BY 249
|
||||
#define TK_SESSION 250
|
||||
#define TK_STATE_WINDOW 251
|
||||
#define TK_SLIDING 252
|
||||
#define TK_FILL 253
|
||||
#define TK_VALUE 254
|
||||
#define TK_NONE 255
|
||||
#define TK_PREV 256
|
||||
#define TK_LINEAR 257
|
||||
#define TK_NEXT 258
|
||||
#define TK_HAVING 259
|
||||
#define TK_RANGE 260
|
||||
#define TK_EVERY 261
|
||||
#define TK_ORDER 262
|
||||
#define TK_SLIMIT 263
|
||||
#define TK_SOFFSET 264
|
||||
#define TK_LIMIT 265
|
||||
#define TK_OFFSET 266
|
||||
#define TK_ASC 267
|
||||
#define TK_NULLS 268
|
||||
#define TK_ABORT 269
|
||||
#define TK_AFTER 270
|
||||
#define TK_ATTACH 271
|
||||
#define TK_BEFORE 272
|
||||
#define TK_BEGIN 273
|
||||
#define TK_BITAND 274
|
||||
#define TK_BITNOT 275
|
||||
#define TK_BITOR 276
|
||||
#define TK_BLOCKS 277
|
||||
#define TK_CHANGE 278
|
||||
#define TK_COMMA 279
|
||||
#define TK_COMPACT 280
|
||||
#define TK_CONCAT 281
|
||||
#define TK_CONFLICT 282
|
||||
#define TK_COPY 283
|
||||
#define TK_DEFERRED 284
|
||||
#define TK_DELIMITERS 285
|
||||
#define TK_DETACH 286
|
||||
#define TK_DIVIDE 287
|
||||
#define TK_DOT 288
|
||||
#define TK_EACH 289
|
||||
#define TK_FAIL 290
|
||||
#define TK_FILE 291
|
||||
#define TK_FOR 292
|
||||
#define TK_GLOB 293
|
||||
#define TK_ID 294
|
||||
#define TK_IMMEDIATE 295
|
||||
#define TK_IMPORT 296
|
||||
#define TK_INITIALLY 297
|
||||
#define TK_INSTEAD 298
|
||||
#define TK_ISNULL 299
|
||||
#define TK_KEY 300
|
||||
#define TK_MODULES 301
|
||||
#define TK_NK_BITNOT 302
|
||||
#define TK_NK_SEMI 303
|
||||
#define TK_NOTNULL 304
|
||||
#define TK_OF 305
|
||||
#define TK_PLUS 306
|
||||
#define TK_PRIVILEGE 307
|
||||
#define TK_RAISE 308
|
||||
#define TK_REPLACE 309
|
||||
#define TK_RESTRICT 310
|
||||
#define TK_ROW 311
|
||||
#define TK_SEMI 312
|
||||
#define TK_STAR 313
|
||||
#define TK_STATEMENT 314
|
||||
#define TK_VGROUPS 79
|
||||
#define TK_SINGLE_STABLE 80
|
||||
#define TK_RETENTIONS 81
|
||||
#define TK_SCHEMALESS 82
|
||||
#define TK_WAL_LEVEL 83
|
||||
#define TK_WAL_FSYNC_PERIOD 84
|
||||
#define TK_WAL_RETENTION_PERIOD 85
|
||||
#define TK_WAL_RETENTION_SIZE 86
|
||||
#define TK_WAL_ROLL_PERIOD 87
|
||||
#define TK_WAL_SEGMENT_SIZE 88
|
||||
#define TK_STT_TRIGGER 89
|
||||
#define TK_TABLE_PREFIX 90
|
||||
#define TK_TABLE_SUFFIX 91
|
||||
#define TK_NK_COLON 92
|
||||
#define TK_MAX_SPEED 93
|
||||
#define TK_TABLE 94
|
||||
#define TK_NK_LP 95
|
||||
#define TK_NK_RP 96
|
||||
#define TK_STABLE 97
|
||||
#define TK_ADD 98
|
||||
#define TK_COLUMN 99
|
||||
#define TK_MODIFY 100
|
||||
#define TK_RENAME 101
|
||||
#define TK_TAG 102
|
||||
#define TK_SET 103
|
||||
#define TK_NK_EQ 104
|
||||
#define TK_USING 105
|
||||
#define TK_TAGS 106
|
||||
#define TK_COMMENT 107
|
||||
#define TK_BOOL 108
|
||||
#define TK_TINYINT 109
|
||||
#define TK_SMALLINT 110
|
||||
#define TK_INT 111
|
||||
#define TK_INTEGER 112
|
||||
#define TK_BIGINT 113
|
||||
#define TK_FLOAT 114
|
||||
#define TK_DOUBLE 115
|
||||
#define TK_BINARY 116
|
||||
#define TK_TIMESTAMP 117
|
||||
#define TK_NCHAR 118
|
||||
#define TK_UNSIGNED 119
|
||||
#define TK_JSON 120
|
||||
#define TK_VARCHAR 121
|
||||
#define TK_MEDIUMBLOB 122
|
||||
#define TK_BLOB 123
|
||||
#define TK_VARBINARY 124
|
||||
#define TK_DECIMAL 125
|
||||
#define TK_MAX_DELAY 126
|
||||
#define TK_WATERMARK 127
|
||||
#define TK_ROLLUP 128
|
||||
#define TK_TTL 129
|
||||
#define TK_SMA 130
|
||||
#define TK_DELETE_MARK 131
|
||||
#define TK_FIRST 132
|
||||
#define TK_LAST 133
|
||||
#define TK_SHOW 134
|
||||
#define TK_PRIVILEGES 135
|
||||
#define TK_DATABASES 136
|
||||
#define TK_TABLES 137
|
||||
#define TK_STABLES 138
|
||||
#define TK_MNODES 139
|
||||
#define TK_QNODES 140
|
||||
#define TK_FUNCTIONS 141
|
||||
#define TK_INDEXES 142
|
||||
#define TK_ACCOUNTS 143
|
||||
#define TK_APPS 144
|
||||
#define TK_CONNECTIONS 145
|
||||
#define TK_LICENCES 146
|
||||
#define TK_GRANTS 147
|
||||
#define TK_QUERIES 148
|
||||
#define TK_SCORES 149
|
||||
#define TK_TOPICS 150
|
||||
#define TK_VARIABLES 151
|
||||
#define TK_CLUSTER 152
|
||||
#define TK_BNODES 153
|
||||
#define TK_SNODES 154
|
||||
#define TK_TRANSACTIONS 155
|
||||
#define TK_DISTRIBUTED 156
|
||||
#define TK_CONSUMERS 157
|
||||
#define TK_SUBSCRIPTIONS 158
|
||||
#define TK_VNODES 159
|
||||
#define TK_LIKE 160
|
||||
#define TK_TBNAME 161
|
||||
#define TK_QTAGS 162
|
||||
#define TK_AS 163
|
||||
#define TK_INDEX 164
|
||||
#define TK_FUNCTION 165
|
||||
#define TK_INTERVAL 166
|
||||
#define TK_TOPIC 167
|
||||
#define TK_WITH 168
|
||||
#define TK_META 169
|
||||
#define TK_CONSUMER 170
|
||||
#define TK_GROUP 171
|
||||
#define TK_DESC 172
|
||||
#define TK_DESCRIBE 173
|
||||
#define TK_RESET 174
|
||||
#define TK_QUERY 175
|
||||
#define TK_CACHE 176
|
||||
#define TK_EXPLAIN 177
|
||||
#define TK_ANALYZE 178
|
||||
#define TK_VERBOSE 179
|
||||
#define TK_NK_BOOL 180
|
||||
#define TK_RATIO 181
|
||||
#define TK_NK_FLOAT 182
|
||||
#define TK_OUTPUTTYPE 183
|
||||
#define TK_AGGREGATE 184
|
||||
#define TK_BUFSIZE 185
|
||||
#define TK_STREAM 186
|
||||
#define TK_INTO 187
|
||||
#define TK_TRIGGER 188
|
||||
#define TK_AT_ONCE 189
|
||||
#define TK_WINDOW_CLOSE 190
|
||||
#define TK_IGNORE 191
|
||||
#define TK_EXPIRED 192
|
||||
#define TK_FILL_HISTORY 193
|
||||
#define TK_SUBTABLE 194
|
||||
#define TK_KILL 195
|
||||
#define TK_CONNECTION 196
|
||||
#define TK_TRANSACTION 197
|
||||
#define TK_BALANCE 198
|
||||
#define TK_VGROUP 199
|
||||
#define TK_MERGE 200
|
||||
#define TK_REDISTRIBUTE 201
|
||||
#define TK_SPLIT 202
|
||||
#define TK_DELETE 203
|
||||
#define TK_INSERT 204
|
||||
#define TK_NULL 205
|
||||
#define TK_NK_QUESTION 206
|
||||
#define TK_NK_ARROW 207
|
||||
#define TK_ROWTS 208
|
||||
#define TK_QSTART 209
|
||||
#define TK_QEND 210
|
||||
#define TK_QDURATION 211
|
||||
#define TK_WSTART 212
|
||||
#define TK_WEND 213
|
||||
#define TK_WDURATION 214
|
||||
#define TK_IROWTS 215
|
||||
#define TK_CAST 216
|
||||
#define TK_NOW 217
|
||||
#define TK_TODAY 218
|
||||
#define TK_TIMEZONE 219
|
||||
#define TK_CLIENT_VERSION 220
|
||||
#define TK_SERVER_VERSION 221
|
||||
#define TK_SERVER_STATUS 222
|
||||
#define TK_CURRENT_USER 223
|
||||
#define TK_COUNT 224
|
||||
#define TK_LAST_ROW 225
|
||||
#define TK_CASE 226
|
||||
#define TK_END 227
|
||||
#define TK_WHEN 228
|
||||
#define TK_THEN 229
|
||||
#define TK_ELSE 230
|
||||
#define TK_BETWEEN 231
|
||||
#define TK_IS 232
|
||||
#define TK_NK_LT 233
|
||||
#define TK_NK_GT 234
|
||||
#define TK_NK_LE 235
|
||||
#define TK_NK_GE 236
|
||||
#define TK_NK_NE 237
|
||||
#define TK_MATCH 238
|
||||
#define TK_NMATCH 239
|
||||
#define TK_CONTAINS 240
|
||||
#define TK_IN 241
|
||||
#define TK_JOIN 242
|
||||
#define TK_INNER 243
|
||||
#define TK_SELECT 244
|
||||
#define TK_DISTINCT 245
|
||||
#define TK_WHERE 246
|
||||
#define TK_PARTITION 247
|
||||
#define TK_BY 248
|
||||
#define TK_SESSION 249
|
||||
#define TK_STATE_WINDOW 250
|
||||
#define TK_SLIDING 251
|
||||
#define TK_FILL 252
|
||||
#define TK_VALUE 253
|
||||
#define TK_NONE 254
|
||||
#define TK_PREV 255
|
||||
#define TK_LINEAR 256
|
||||
#define TK_NEXT 257
|
||||
#define TK_HAVING 258
|
||||
#define TK_RANGE 259
|
||||
#define TK_EVERY 260
|
||||
#define TK_ORDER 261
|
||||
#define TK_SLIMIT 262
|
||||
#define TK_SOFFSET 263
|
||||
#define TK_LIMIT 264
|
||||
#define TK_OFFSET 265
|
||||
#define TK_ASC 266
|
||||
#define TK_NULLS 267
|
||||
#define TK_ABORT 268
|
||||
#define TK_AFTER 269
|
||||
#define TK_ATTACH 270
|
||||
#define TK_BEFORE 271
|
||||
#define TK_BEGIN 272
|
||||
#define TK_BITAND 273
|
||||
#define TK_BITNOT 274
|
||||
#define TK_BITOR 275
|
||||
#define TK_BLOCKS 276
|
||||
#define TK_CHANGE 277
|
||||
#define TK_COMMA 278
|
||||
#define TK_COMPACT 279
|
||||
#define TK_CONCAT 280
|
||||
#define TK_CONFLICT 281
|
||||
#define TK_COPY 282
|
||||
#define TK_DEFERRED 283
|
||||
#define TK_DELIMITERS 284
|
||||
#define TK_DETACH 285
|
||||
#define TK_DIVIDE 286
|
||||
#define TK_DOT 287
|
||||
#define TK_EACH 288
|
||||
#define TK_FAIL 289
|
||||
#define TK_FILE 290
|
||||
#define TK_FOR 291
|
||||
#define TK_GLOB 292
|
||||
#define TK_ID 293
|
||||
#define TK_IMMEDIATE 294
|
||||
#define TK_IMPORT 295
|
||||
#define TK_INITIALLY 296
|
||||
#define TK_INSTEAD 297
|
||||
#define TK_ISNULL 298
|
||||
#define TK_KEY 299
|
||||
#define TK_MODULES 300
|
||||
#define TK_NK_BITNOT 301
|
||||
#define TK_NK_SEMI 302
|
||||
#define TK_NOTNULL 303
|
||||
#define TK_OF 304
|
||||
#define TK_PLUS 305
|
||||
#define TK_PRIVILEGE 306
|
||||
#define TK_RAISE 307
|
||||
#define TK_REPLACE 308
|
||||
#define TK_RESTRICT 309
|
||||
#define TK_ROW 310
|
||||
#define TK_SEMI 311
|
||||
#define TK_STAR 312
|
||||
#define TK_STATEMENT 313
|
||||
#define TK_STRICT 314
|
||||
#define TK_STRING 315
|
||||
#define TK_TIMES 316
|
||||
#define TK_UPDATE 317
|
||||
|
|
|
@ -230,7 +230,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo);
|
|||
int32_t syncStart(int64_t rid);
|
||||
void syncStop(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 syncReconfig(int64_t rid, SSyncCfg* pCfg);
|
||||
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 syncSnapshotSending(int64_t rid);
|
||||
bool syncSnapshotRecving(int64_t rid);
|
||||
int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq);
|
||||
|
||||
SSyncState syncGetState(int64_t rid);
|
||||
void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet);
|
||||
|
|
|
@ -77,14 +77,12 @@ typedef void (*RpcDfp)(void *ahandle);
|
|||
|
||||
typedef struct SRpcInit {
|
||||
char localFqdn[TSDB_FQDN_LEN];
|
||||
uint16_t localPort; // local port
|
||||
char *label; // for debug purpose
|
||||
int32_t numOfThreads; // number of threads to handle connections
|
||||
int32_t sessions; // number of sessions allowed
|
||||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
||||
int32_t retryLimit; // retry limit
|
||||
int32_t retryInterval; // retry interval ms
|
||||
uint16_t localPort; // local port
|
||||
char *label; // for debug purpose
|
||||
int32_t numOfThreads; // number of threads to handle connections
|
||||
int32_t sessions; // number of sessions allowed
|
||||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
||||
|
||||
int32_t retryMinInterval; // retry init interval
|
||||
int32_t retryStepFactor; // retry interval factor
|
||||
|
|
|
@ -33,16 +33,16 @@ extern "C" {
|
|||
#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); }}
|
||||
// clang-format on
|
||||
|
||||
#define WAL_PROTO_VER 0
|
||||
#define WAL_NOSUFFIX_LEN 20
|
||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||
#define WAL_LOG_SUFFIX "log"
|
||||
#define WAL_INDEX_SUFFIX "idx"
|
||||
#define WAL_REFRESH_MS 1000
|
||||
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
||||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL
|
||||
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
||||
#define WAL_PROTO_VER 0
|
||||
#define WAL_NOSUFFIX_LEN 20
|
||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||
#define WAL_LOG_SUFFIX "log"
|
||||
#define WAL_INDEX_SUFFIX "idx"
|
||||
#define WAL_REFRESH_MS 1000
|
||||
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
|
||||
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
|
||||
#define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL
|
||||
#define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3)
|
||||
|
||||
typedef enum {
|
||||
TAOS_WAL_WRITE = 1,
|
||||
|
|
|
@ -36,7 +36,7 @@ extern int64_t tsStreamMax;
|
|||
extern float tsNumOfCores;
|
||||
extern int64_t tsTotalMemoryKB;
|
||||
extern char *tsProcPath;
|
||||
extern char tsSIMDEnable;
|
||||
extern char tsSIMDBuiltins;
|
||||
extern char tsSSE42Enable;
|
||||
extern char tsAVXEnable;
|
||||
extern char tsAVX2Enable;
|
||||
|
|
|
@ -337,7 +337,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DB_STRICT_ON_STR "on"
|
||||
#define TSDB_DB_STRICT_OFF 0
|
||||
#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_NONE_STR "none"
|
||||
#define TSDB_CACHE_MODEL_LAST_ROW_STR "last_row"
|
||||
|
@ -497,6 +497,9 @@ enum {
|
|||
// sort page size by default
|
||||
#define DEFAULT_PAGESIZE 4096
|
||||
|
||||
#define VNODE_TIMEOUT_SEC 60
|
||||
#define MNODE_TIMEOUT_SEC 10
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef struct STaosQnode {
|
|||
STaosQnode *next;
|
||||
STaosQueue *queue;
|
||||
int64_t timestamp;
|
||||
int64_t dataSize;
|
||||
int32_t size;
|
||||
int8_t itype;
|
||||
int8_t reserved[3];
|
||||
|
@ -103,7 +104,7 @@ typedef struct STaosQall {
|
|||
STaosQueue *taosOpenQueue();
|
||||
void taosCloseQueue(STaosQueue *queue);
|
||||
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 taosWriteQitem(STaosQueue *queue, void *pItem);
|
||||
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.compressSize = tsCompressMsgSize;
|
||||
rpcInit.dfp = destroyAhandle;
|
||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||
|
||||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||
|
@ -232,7 +231,7 @@ void destroyTscObj(void *pObj) {
|
|||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
// In any cases, we should not free app inst here. Or an race condition rises.
|
||||
/*int64_t connNum = */atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
/*int64_t connNum = */ atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
|
||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||
taosMemoryFree(pTscObj);
|
||||
|
|
|
@ -190,8 +190,9 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
(*pRequest)->body.param = param;
|
||||
|
||||
STscObj* pTscObj = (*pRequest)->pTscObj;
|
||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||
sizeof((*pRequest)->self))) {
|
||||
int32_t err = taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||
sizeof((*pRequest)->self));
|
||||
if (err) {
|
||||
tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||
(*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) {
|
||||
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* colLength = (int32_t*)(p + len);
|
||||
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.compressSize = tsCompressMsgSize;
|
||||
rpcInit.user = "_dnd";
|
||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||
|
||||
clientRpc = rpcOpen(&rpcInit);
|
||||
if (clientRpc == NULL) {
|
||||
|
@ -2294,7 +2294,7 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
|
|||
taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly);
|
||||
tsem_wait(¶m->sem);
|
||||
|
||||
SRequestObj *pRequest = NULL;
|
||||
SRequestObj* pRequest = NULL;
|
||||
if (param->pRequest != NULL) {
|
||||
param->pRequest->syncQuery = true;
|
||||
pRequest = param->pRequest;
|
||||
|
@ -2317,7 +2317,7 @@ TAOS_RES* taosQueryImplWithReqid(TAOS* taos, const char* sql, bool validateOnly,
|
|||
taosAsyncQueryImplWithReqid(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly, reqid);
|
||||
tsem_wait(¶m->sem);
|
||||
|
||||
SRequestObj *pRequest = NULL;
|
||||
SRequestObj* pRequest = NULL;
|
||||
if (param->pRequest != NULL) {
|
||||
param->pRequest->syncQuery = true;
|
||||
pRequest = param->pRequest;
|
||||
|
|
|
@ -186,10 +186,10 @@ void taos_free_result(TAOS_RES *res) {
|
|||
destroyRequest(pRequest);
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
||||
if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||
if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||
if (pRsp->rsp.withTbName) taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
||||
if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||
taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||
taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||
taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
||||
taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||
// taosx
|
||||
taosArrayDestroy(pRsp->rsp.createTableLen);
|
||||
taosArrayDestroyP(pRsp->rsp.createTableReq, taosMemoryFree);
|
||||
|
@ -199,10 +199,10 @@ void taos_free_result(TAOS_RES *res) {
|
|||
taosMemoryFree(pRsp);
|
||||
} else if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||
if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||
if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||
if (pRsp->rsp.withTbName) taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
||||
if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||
taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree);
|
||||
taosArrayDestroy(pRsp->rsp.blockDataLen);
|
||||
taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree);
|
||||
taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper);
|
||||
pRsp->resInfo.pRspMsg = NULL;
|
||||
doFreeReqResultInfo(&pRsp->resInfo);
|
||||
taosMemoryFree(pRsp);
|
||||
|
|
|
@ -691,7 +691,7 @@ void tmqAssignAskEpTask(void* param, void* tmrId) {
|
|||
int64_t refId = *(int64_t*)param;
|
||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||
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;
|
||||
taosWriteQitem(tmq->delayedTask, pTaskType);
|
||||
tsem_post(&tmq->rspSem);
|
||||
|
@ -703,7 +703,7 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
|
|||
int64_t refId = *(int64_t*)param;
|
||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||
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;
|
||||
taosWriteQitem(tmq->delayedTask, pTaskType);
|
||||
tsem_post(&tmq->rspSem);
|
||||
|
@ -715,7 +715,7 @@ void tmqAssignDelayedReportTask(void* param, void* tmrId) {
|
|||
int64_t refId = *(int64_t*)param;
|
||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
|
||||
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;
|
||||
taosWriteQitem(tmq->delayedTask, pTaskType);
|
||||
tsem_post(&tmq->rspSem);
|
||||
|
@ -814,24 +814,55 @@ int32_t tmqHandleAllDelayedTask(tmq_t* tmq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) {
|
||||
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) {
|
||||
// do nothing
|
||||
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__EP_RSP) {
|
||||
SMqAskEpRspWrapper* pEpRspWrapper = (SMqAskEpRspWrapper*)rspWrapper;
|
||||
tDeleteSMqAskEpRsp(&pEpRspWrapper->msg);
|
||||
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void tmqClearUnhandleMsg(tmq_t* tmq) {
|
||||
SMqRspWrapper* msg = NULL;
|
||||
SMqRspWrapper* rspWrapper = NULL;
|
||||
while (1) {
|
||||
taosGetQitem(tmq->qall, (void**)&msg);
|
||||
if (msg)
|
||||
taosFreeQitem(msg);
|
||||
else
|
||||
taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||
if (rspWrapper) {
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(rspWrapper);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
msg = NULL;
|
||||
rspWrapper = NULL;
|
||||
taosReadAllQitems(tmq->mqueue, tmq->qall);
|
||||
while (1) {
|
||||
taosGetQitem(tmq->qall, (void**)&msg);
|
||||
if (msg)
|
||||
taosFreeQitem(msg);
|
||||
else
|
||||
taosGetQitem(tmq->qall, (void**)&rspWrapper);
|
||||
if (rspWrapper) {
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(rspWrapper);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1171,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
goto CREATE_MSG_FAIL;
|
||||
}
|
||||
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) {
|
||||
tscWarn("msg discard from vgId:%d, epoch %d since out of memory", vgId, epoch);
|
||||
goto CREATE_MSG_FAIL;
|
||||
|
@ -1173,7 +1204,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
// handle meta rsp
|
||||
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) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
@ -1363,7 +1394,7 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tmqUpdateEp(tmq, head->epoch, &rsp);
|
||||
tDeleteSMqAskEpRsp(&rsp);
|
||||
} else {
|
||||
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM);
|
||||
SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0);
|
||||
if (pWrapper == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = -1;
|
||||
|
@ -1644,6 +1675,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
|
|||
tDeleteSMqAskEpRsp(rspMsg);
|
||||
*pReset = true;
|
||||
} else {
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
*pReset = false;
|
||||
}
|
||||
} else {
|
||||
|
@ -1695,6 +1727,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
} else {
|
||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||
pollRspWrapper->dataRsp.head.epoch, consumerEpoch);
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(pollRspWrapper);
|
||||
}
|
||||
} 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 {
|
||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||
pollRspWrapper->metaRsp.head.epoch, consumerEpoch);
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(pollRspWrapper);
|
||||
}
|
||||
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) {
|
||||
|
@ -1743,6 +1777,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
} else {
|
||||
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||
pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
||||
tmqFreeRspWrapper(rspWrapper);
|
||||
taosFreeQitem(pollRspWrapper);
|
||||
}
|
||||
} else {
|
||||
|
@ -1794,7 +1829,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
|||
while (1) {
|
||||
tmqHandleAllDelayedTask(tmq);
|
||||
if (tmqPollImpl(tmq, timeout) < 0) {
|
||||
tscDebug("return since poll err");
|
||||
tscDebug("consumer:%" PRId64 " return since poll err", tmq->consumerId);
|
||||
/*return NULL;*/
|
||||
}
|
||||
|
||||
|
|
|
@ -358,7 +358,11 @@ size_t blockDataGetNumOfCols(const SSDataBlock* pBlock) { return taosArrayGetSiz
|
|||
size_t blockDataGetNumOfRows(const SSDataBlock* pBlock) { return pBlock->info.rows; }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1157,13 +1161,14 @@ void blockDataEmpty(SSDataBlock* pDataBlock) {
|
|||
}
|
||||
|
||||
pInfo->rows = 0;
|
||||
pInfo->dataLoad = 0;
|
||||
pInfo->window.ekey = 0;
|
||||
pInfo->window.skey = 0;
|
||||
}
|
||||
|
||||
// todo temporarily disable it
|
||||
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) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1220,7 +1225,7 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) {
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) {
|
||||
pColumn->hasNull = false;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
|
||||
|
@ -2427,6 +2432,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
|||
pStart += colLen[i];
|
||||
}
|
||||
|
||||
pBlock->info.dataLoad = 1;
|
||||
pBlock->info.rows = numOfRows;
|
||||
ASSERT(pStart - pData == dataLen);
|
||||
return pStart;
|
||||
|
|
|
@ -180,8 +180,6 @@ int32_t tsUptimeInterval = 300; // seconds
|
|||
char tsUdfdResFuncs[512] = ""; // udfd resident funcs that teardown when udfd exits
|
||||
char tsUdfdLdLibPath[512] = "";
|
||||
|
||||
int32_t tsRpcRetryLimit = 100;
|
||||
int32_t tsRpcRetryInterval = 15;
|
||||
#ifndef _STORAGE
|
||||
int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||
SConfigItem *pItem = cfgGetItem(pCfg, "dataDir");
|
||||
|
@ -203,7 +201,9 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
|
|||
int32_t taosSetTfsCfg(SConfig *pCfg);
|
||||
#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,
|
||||
char *apolloUrl) {
|
||||
|
@ -313,8 +313,6 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 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, "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;
|
||||
|
||||
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, "AVX2", tsAVX2Enable, 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, "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, "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;
|
||||
return 0;
|
||||
}
|
||||
|
@ -674,8 +669,6 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval;
|
||||
tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
||||
|
||||
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
||||
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
||||
tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32;
|
||||
return 0;
|
||||
}
|
||||
|
@ -738,10 +731,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
||||
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;
|
||||
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
||||
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
||||
|
@ -761,9 +750,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
if (tsQueryBufferSize >= 0) {
|
||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||
}
|
||||
|
||||
tsRpcRetryLimit = cfgGetItem(pCfg, "rpcRetryLimit")->i32;
|
||||
tsRpcRetryInterval = cfgGetItem(pCfg, "rpcRetryInterval")->i32;
|
||||
GRANT_CFG_GET;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -159,12 +159,12 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
|||
}
|
||||
|
||||
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;
|
||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||
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);
|
||||
if (code != 0) {
|
||||
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) {
|
||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||
if (pMsg == NULL) return -1;
|
||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||
pRpc->pCont = NULL;
|
||||
|
||||
switch (qtype) {
|
||||
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);
|
||||
return 0;
|
||||
case READ_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);
|
||||
return 0;
|
||||
default:
|
||||
|
|
|
@ -130,7 +130,7 @@ void smStopWorker(SSnodeMgmt *pMgmt) {
|
|||
}
|
||||
|
||||
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) {
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
pRpc->pCont = NULL;
|
||||
|
@ -139,8 +139,8 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
|||
|
||||
SSnode *pSnode = pMgmt->pSnode;
|
||||
if (pSnode == NULL) {
|
||||
dError("msg:%p failed to put into snode queue since %s, type:%s qtype:%d", pMsg, terrstr(),
|
||||
TMSG_INFO(pMsg->msgType), qtype);
|
||||
dError("msg:%p failed to put into snode queue since %s, type:%s qtype:%d len:%d", pMsg, terrstr(),
|
||||
TMSG_INFO(pMsg->msgType), qtype, pRpc->contLen);
|
||||
taosFreeQitem(pMsg);
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
pRpc->pCont = NULL;
|
||||
|
|
|
@ -38,6 +38,8 @@ typedef struct SVnodeMgmt {
|
|||
TdThreadRwlock lock;
|
||||
SVnodesStat state;
|
||||
STfs *pTfs;
|
||||
TdThread thread;
|
||||
bool stop;
|
||||
} SVnodeMgmt;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -334,6 +334,62 @@ static void vmCleanup(SVnodeMgmt *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) {
|
||||
int32_t code = -1;
|
||||
|
||||
|
@ -510,12 +566,10 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
|
|||
taosMemoryFree(ppVnodes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return vmInitTimer(pMgmt);
|
||||
}
|
||||
|
||||
static void vmStop(SVnodeMgmt *pMgmt) {
|
||||
// process inside the vnode
|
||||
}
|
||||
static void vmStop(SVnodeMgmt *pMgmt) { vmCleanupTimer(pMgmt); }
|
||||
|
||||
SMgmtFunc vmGetMgmtFunc() {
|
||||
SMgmtFunc mgmtFunc = {0};
|
||||
|
|
|
@ -233,7 +233,7 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
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) {
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
pRpc->pCont = NULL;
|
||||
|
@ -241,7 +241,7 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
|||
}
|
||||
|
||||
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->vgId = htonl(pHead->vgId);
|
||||
|
|
|
@ -149,10 +149,13 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (count == 0) osUpdate();
|
||||
if (count == 10) {
|
||||
osUpdate();
|
||||
count = 0;
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
|
||||
count %= 10;
|
||||
count++;
|
||||
taosMsleep(100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,11 +141,12 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
}
|
||||
|
||||
pRpc->info.wrapper = pWrapper;
|
||||
pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||
pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM, pRpc->contLen);
|
||||
if (pMsg == NULL) goto _OVER;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -258,8 +259,6 @@ int32_t dmInitClient(SDnode *pDnode) {
|
|||
rpcInit.rfp = rpcRfp;
|
||||
rpcInit.compressSize = tsCompressMsgSize;
|
||||
|
||||
rpcInit.retryLimit = tsRpcRetryLimit;
|
||||
rpcInit.retryInterval = tsRpcRetryInterval;
|
||||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||
|
|
|
@ -84,14 +84,16 @@ typedef struct {
|
|||
} STelemMgmt;
|
||||
|
||||
typedef struct {
|
||||
tsem_t syncSem;
|
||||
int64_t sync;
|
||||
int32_t errCode;
|
||||
int32_t transId;
|
||||
SRWLatch lock;
|
||||
int8_t selfIndex;
|
||||
int8_t numOfReplicas;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
tsem_t syncSem;
|
||||
int64_t sync;
|
||||
int32_t errCode;
|
||||
int32_t transId;
|
||||
int32_t transSec;
|
||||
int64_t transSeq;
|
||||
TdThreadMutex lock;
|
||||
int8_t selfIndex;
|
||||
int8_t numOfReplicas;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
} SSyncMgmt;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -26,6 +26,7 @@ int32_t mndInitSync(SMnode *pMnode);
|
|||
void mndCleanupSync(SMnode *pMnode);
|
||||
bool mndIsLeader(SMnode *pMnode);
|
||||
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId);
|
||||
void mndSyncCheckTimeout(SMnode *pMnode);
|
||||
void mndSyncStart(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 mndTransSetSerial(STrans *pTrans);
|
||||
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
||||
int32_t mndTrancCheckConflict(SMnode *pMnode, STrans *pTrans);
|
||||
|
||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
||||
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
||||
|
|
|
@ -554,14 +554,6 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
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) {
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
goto SUBSCRIBE_OVER;
|
||||
|
|
|
@ -776,6 +776,8 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
|
|||
|
||||
int32_t code = -1;
|
||||
mndTransSetDbName(pTrans, pOld->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||
|
||||
if (mndSetAlterDbRedoLogs(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;
|
||||
|
@ -835,12 +837,14 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
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());
|
||||
}
|
||||
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
taosArrayDestroy(dbObj.cfg.pRetensions);
|
||||
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1187,8 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1298,7 +1303,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
|||
|
||||
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);
|
||||
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
||||
if (pDbVgVersion->vgVersion < vgVersion) {
|
||||
|
@ -1328,7 +1334,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
|||
|
||||
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
||||
|
||||
if (pDbVgVersion->vgVersion >= pDb->vgVersion && numOfTable == pDbVgVersion->numOfTable &&
|
||||
if (pDbVgVersion->vgVersion >= pDb->vgVersion && numOfTable == pDbVgVersion->numOfTable &&
|
||||
pDbVgVersion->stateTs == pDb->stateTs) {
|
||||
mTrace("db:%s, valid dbinfo, vgVersion:%d stateTs:%" PRId64
|
||||
" numOfTables:%d, not changed vgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
||||
|
|
|
@ -101,6 +101,7 @@ static void *mndBuildCheckpointTickMsg(int32_t *pContLen, int64_t sec) {
|
|||
}
|
||||
|
||||
static void mndPullupTrans(SMnode *pMnode) {
|
||||
mTrace("pullup trans msg");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
|
@ -110,6 +111,7 @@ static void mndPullupTrans(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
static void mndPullupTtl(SMnode *pMnode) {
|
||||
mTrace("pullup ttl");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&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) {
|
||||
mTrace("calc mq rebalance");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
|
@ -143,6 +146,7 @@ static void mndStreamCheckpointTick(SMnode *pMnode, int64_t sec) {
|
|||
}
|
||||
|
||||
static void mndPullupTelem(SMnode *pMnode) {
|
||||
mTrace("pullup telem msg");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
|
@ -152,6 +156,7 @@ static void mndPullupTelem(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
static void mndPullupGrant(SMnode *pMnode) {
|
||||
mTrace("pullup grant msg");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
|
@ -162,6 +167,7 @@ static void mndPullupGrant(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
static void mndIncreaseUpTime(SMnode *pMnode) {
|
||||
mTrace("increate uptime");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
|
@ -213,6 +219,9 @@ static void mndSetVgroupOffline(SMnode *pMnode, int32_t dnodeId, int64_t curMs)
|
|||
}
|
||||
|
||||
static void mndCheckDnodeOffline(SMnode *pMnode) {
|
||||
mTrace("check dnode offline");
|
||||
if (mndAcquireRpc(pMnode) != 0) return;
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
|
||||
|
@ -230,6 +239,8 @@ static void mndCheckDnodeOffline(SMnode *pMnode) {
|
|||
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
|
||||
mndReleaseRpc(pMnode);
|
||||
}
|
||||
|
||||
static void *mndThreadFp(void *param) {
|
||||
|
@ -277,6 +288,10 @@ static void *mndThreadFp(void *param) {
|
|||
if (sec % (tsStatusInterval * 5) == 0) {
|
||||
mndCheckDnodeOffline(pMnode);
|
||||
}
|
||||
|
||||
if (sec % (MNODE_TIMEOUT_SEC / 2) == 0) {
|
||||
mndSyncCheckTimeout(pMnode);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -769,7 +769,7 @@ static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
}
|
||||
|
||||
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);
|
||||
cols = 0;
|
||||
|
||||
|
|
|
@ -78,35 +78,38 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
|
|||
SSdbRaw *pRaw = pMsg->pCont;
|
||||
|
||||
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
|
||||
" 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),
|
||||
pRaw);
|
||||
pRaw, pMgmt->transSec, pMgmt->transSeq);
|
||||
|
||||
if (pMgmt->errCode == 0) {
|
||||
if (pMeta->code == 0) {
|
||||
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||
sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex);
|
||||
}
|
||||
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
taosThreadMutexLock(&pMgmt->lock);
|
||||
pMgmt->errCode = pMeta->code;
|
||||
|
||||
if (transId <= 0) {
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
mError("trans:%d, invalid commit msg", transId);
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
mError("trans:%d, invalid commit msg, cache transId:%d seq:%" PRId64, transId, pMgmt->transId, pMgmt->transSeq);
|
||||
} else if (transId == pMgmt->transId) {
|
||||
if (pMgmt->errCode != 0) {
|
||||
mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode));
|
||||
} 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->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
tsem_post(&pMgmt->syncSem);
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
} else {
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
STrans *pTrans = mndAcquireTrans(pMnode, transId);
|
||||
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);
|
||||
mndReleaseTrans(pMnode, pTrans);
|
||||
// sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA);
|
||||
|
@ -198,18 +201,20 @@ int32_t mndSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *pBuf, int3
|
|||
}
|
||||
|
||||
static void mndBecomeFollower(const SSyncFSM *pFsm) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
SMnode *pMnode = pFsm->data;
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
mInfo("vgId:1, become follower");
|
||||
|
||||
taosWLockLatch(&pMnode->syncMgmt.lock);
|
||||
if (pMnode->syncMgmt.transId != 0) {
|
||||
mInfo("vgId:1, become follower and post sem, trans:%d, failed to propose since not leader",
|
||||
pMnode->syncMgmt.transId);
|
||||
pMnode->syncMgmt.transId = 0;
|
||||
pMnode->syncMgmt.errCode = TSDB_CODE_SYN_NOT_LEADER;
|
||||
tsem_post(&pMnode->syncMgmt.syncSem);
|
||||
taosThreadMutexLock(&pMgmt->lock);
|
||||
if (pMgmt->transId != 0) {
|
||||
mInfo("vgId:1, become follower and post sem, trans:%d, failed to propose since not leader", pMgmt->transId);
|
||||
pMgmt->transId = 0;
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER;
|
||||
tsem_post(&pMgmt->syncSem);
|
||||
}
|
||||
taosWUnLockLatch(&pMnode->syncMgmt.lock);
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
}
|
||||
|
||||
static void mndBecomeLeader(const SSyncFSM *pFsm) {
|
||||
|
@ -265,8 +270,10 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
|
|||
|
||||
int32_t mndInitSync(SMnode *pMnode) {
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
taosInitRWLatch(&pMgmt->lock);
|
||||
taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||
pMgmt->transId = 0;
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
|
||||
SSyncInfo syncInfo = {
|
||||
.snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT,
|
||||
|
@ -313,12 +320,38 @@ void mndCleanupSync(SMnode *pMnode) {
|
|||
mInfo("mnode-sync is stopped, id:%" PRId64, pMgmt->sync);
|
||||
|
||||
tsem_destroy(&pMgmt->syncSem);
|
||||
taosThreadMutexDestroy(&pMgmt->lock);
|
||||
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) {
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
pMgmt->errCode = 0;
|
||||
|
||||
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
|
||||
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;
|
||||
memcpy(req.pCont, pRaw, req.contLen);
|
||||
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
taosThreadMutexLock(&pMgmt->lock);
|
||||
pMgmt->errCode = 0;
|
||||
|
||||
if (pMgmt->transId != 0) {
|
||||
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;
|
||||
return -1;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
mInfo("trans:%d, will be proposed", 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) {
|
||||
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);
|
||||
} else if (code > 0) {
|
||||
mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId);
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
pMgmt->transId = 0;
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||
sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID);
|
||||
code = 0;
|
||||
} else {
|
||||
mError("trans:%d, failed to proposed since %s", transId, terrstr());
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
pMgmt->transId = 0;
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->transSeq = 0;
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
if (terrno == 0) {
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
@ -369,7 +409,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
|||
}
|
||||
|
||||
terrno = pMgmt->errCode;
|
||||
return pMgmt->errCode;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
void mndSyncStart(SMnode *pMnode) {
|
||||
|
@ -382,13 +422,17 @@ void mndSyncStart(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
void mndSyncStop(SMnode *pMnode) {
|
||||
taosWLockLatch(&pMnode->syncMgmt.lock);
|
||||
if (pMnode->syncMgmt.transId != 0) {
|
||||
mInfo("vgId:1, is stopped and post sem, trans:%d", pMnode->syncMgmt.transId);
|
||||
pMnode->syncMgmt.transId = 0;
|
||||
tsem_post(&pMnode->syncMgmt.syncSem);
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
|
||||
taosThreadMutexLock(&pMgmt->lock);
|
||||
if (pMgmt->transId != 0) {
|
||||
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) {
|
||||
|
|
|
@ -838,7 +838,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
|||
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 (strlen(pTrans->dbname) == 0 && strlen(pTrans->stbname) == 0) {
|
||||
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
|
@ -853,6 +853,14 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pTrans->commitActions) <= 0) {
|
||||
terrno = TSDB_CODE_MND_TRANS_CLOG_IS_NULL;
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
@ -1027,6 +1035,7 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
|||
if (pAction != NULL) {
|
||||
pAction->msgReceived = 1;
|
||||
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),
|
||||
|
@ -1238,7 +1247,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
|||
if (numOfActions == 0) 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) {
|
||||
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) {
|
||||
mInfo("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||
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);
|
||||
pTrans->lastErrorNo = code;
|
||||
taosMsleep(300);
|
||||
action--;
|
||||
continue;
|
||||
} else {
|
||||
terrno = code;
|
||||
pTrans->lastErrorNo = code;
|
||||
pTrans->code = code;
|
||||
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);
|
||||
|
|
|
@ -54,6 +54,7 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs);
|
|||
void vnodeDestroy(const char *path, STfs *pTfs);
|
||||
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
||||
void vnodePreClose(SVnode *pVnode);
|
||||
void vnodeSyncCheckTimeout(SVnode* pVnode);
|
||||
void vnodeClose(SVnode *pVnode);
|
||||
|
||||
int32_t vnodeStart(SVnode *pVnode);
|
||||
|
|
|
@ -353,7 +353,12 @@ struct SVnode {
|
|||
bool blocked;
|
||||
bool restored;
|
||||
tsem_t syncSem;
|
||||
int32_t blockSec;
|
||||
int64_t blockSeq;
|
||||
SQHandle* pQuery;
|
||||
#if 0
|
||||
SRpcHandleInfo blockInfo;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
|
||||
|
|
|
@ -32,9 +32,9 @@ typedef struct SMetaStbStatsEntry {
|
|||
} SMetaStbStatsEntry;
|
||||
|
||||
typedef struct STagFilterResEntry {
|
||||
uint64_t suid; // uid for super table
|
||||
SList list; // the linked list of md5 digest, extracted from the serialized tag query condition
|
||||
uint32_t qTimes;// queried times for current super table
|
||||
uint64_t suid; // uid for super table
|
||||
SList list; // the linked list of md5 digest, extracted from the serialized tag query condition
|
||||
uint32_t qTimes; // queried times for current super table
|
||||
} STagFilterResEntry;
|
||||
|
||||
struct SMetaCache {
|
||||
|
@ -126,13 +126,14 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
|||
goto _err2;
|
||||
}
|
||||
|
||||
pCache->sTagFilterResCache.pUidResCache = taosLRUCacheInit(5*1024*1024, -1, 0.5);
|
||||
pCache->sTagFilterResCache.pUidResCache = taosLRUCacheInit(5 * 1024 * 1024, -1, 0.5);
|
||||
if (pCache->sTagFilterResCache.pUidResCache == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
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) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err2;
|
||||
|
@ -419,7 +420,8 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) {
|
|||
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;
|
||||
|
||||
// generate the composed key for LRU cache
|
||||
|
@ -428,8 +430,8 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
|||
pBuf[0] = suid;
|
||||
memcpy(&pBuf[1], pKey, keyLen);
|
||||
|
||||
int32_t len = keyLen + sizeof(uint64_t);
|
||||
LRUHandle *pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
int32_t len = keyLen + sizeof(uint64_t);
|
||||
LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
if (pHandle == NULL) {
|
||||
*acquireRes = 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -439,7 +441,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
|||
*acquireRes = 1;
|
||||
|
||||
const char* p = taosLRUCacheValue(pMeta->pCache->sTagFilterResCache.pUidResCache, pHandle);
|
||||
int32_t size = *(int32_t*) p;
|
||||
int32_t size = *(int32_t*)p;
|
||||
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
||||
|
||||
(*pEntry)->qTimes += 1;
|
||||
|
@ -467,12 +469,15 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
|||
|
||||
// remove the keys, of which query uid lists have been replaced already.
|
||||
size_t s = taosArrayGetSize(pList);
|
||||
for(int32_t i = 0; i < s; ++i) {
|
||||
for (int32_t i = 0; i < s; ++i) {
|
||||
SListNode** p1 = taosArrayGet(pList, i);
|
||||
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
|
||||
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) {
|
||||
metaDebug("vgId:%d, suid:%" PRIu64
|
||||
" 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);
|
||||
|
||||
// add to cache.
|
||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL, TAOS_LRU_PRIORITY_LOW);
|
||||
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));
|
||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW);
|
||||
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;
|
||||
}
|
||||
|
@ -539,7 +546,7 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t keyLen = sizeof(uint64_t) * 3;
|
||||
int32_t keyLen = sizeof(uint64_t) * 3;
|
||||
uint64_t p[3] = {0};
|
||||
p[0] = suid;
|
||||
|
||||
|
|
|
@ -763,7 +763,7 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, const void *pMsg, int32_t inpu
|
|||
tb_uid_t suid) {
|
||||
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) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -725,9 +725,15 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgL
|
|||
}
|
||||
taosWUnLockLatch(&pTq->pushLock);
|
||||
|
||||
code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||
if (code != 0) {
|
||||
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
|
||||
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));
|
||||
if (code != 0) {
|
||||
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
|
||||
}
|
||||
}
|
||||
|
||||
code = tqOffsetDelete(pTq->pOffsetStore, pReq->subKey);
|
||||
|
@ -736,7 +742,7 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgL
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
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->pBlock = pDelBlock;
|
||||
pRefBlock->dataRef = pRef;
|
||||
|
@ -1297,7 +1303,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
|||
}
|
||||
|
||||
#if 0
|
||||
SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
||||
SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||
pStreamBlock->type = STREAM_INPUT__DATA_BLOCK;
|
||||
pStreamBlock->blocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||
SSDataBlock block = {0};
|
||||
|
|
|
@ -533,6 +533,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
|
|||
pBlock->info.id.uid = pReader->msgIter.uid;
|
||||
pBlock->info.rows = pReader->msgIter.numOfRows;
|
||||
pBlock->info.version = pReader->pMsg->version;
|
||||
pBlock->info.dataLoad = 1;
|
||||
|
||||
while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) {
|
||||
tdSTSRowIterReset(&iter, row);
|
||||
|
|
|
@ -121,7 +121,7 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
return &pInfo->blockData[1];
|
||||
}
|
||||
|
||||
if (pIter->pSttBlk == NULL) {
|
||||
if (pIter->pSttBlk == NULL || pInfo->pSchema == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1143,6 +1143,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
i += 1;
|
||||
}
|
||||
|
||||
pResBlock->info.dataLoad = 1;
|
||||
pResBlock->info.rows = dumpedRows;
|
||||
pDumpInfo->rowIndex += step * dumpedRows;
|
||||
|
||||
|
@ -2538,6 +2539,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
|
||||
_end:
|
||||
pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0;
|
||||
pResBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]);
|
||||
|
||||
setComposedBlockFlag(pReader, true);
|
||||
|
@ -2790,7 +2792,8 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
|
|||
while (1) {
|
||||
// load the last data block of current table
|
||||
STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)pStatus->pTableIter;
|
||||
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
||||
|
||||
bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
|
||||
if (!hasVal) {
|
||||
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
|
||||
if (!hasNexTable) {
|
||||
|
@ -3621,6 +3624,7 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow*
|
|||
i += 1;
|
||||
}
|
||||
|
||||
pBlock->info.dataLoad = 1;
|
||||
pBlock->info.rows += 1;
|
||||
pScanInfo->lastKey = pTSRow->ts;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -3668,6 +3672,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
|
|||
i += 1;
|
||||
}
|
||||
|
||||
pResBlock->info.dataLoad = 1;
|
||||
pResBlock->info.rows += 1;
|
||||
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.
|
||||
// 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) {
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, -1, 1);
|
||||
if (pReader->pSchema == NULL) {
|
||||
|
@ -3840,7 +3847,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo);
|
||||
}
|
||||
|
||||
STsdbReader* p = (pReader->innerReader[0] != NULL)? pReader->innerReader[0]:pReader;
|
||||
STsdbReader* p = (pReader->innerReader[0] != NULL) ? pReader->innerReader[0] : pReader;
|
||||
pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables);
|
||||
if (pReader->status.pTableMap == NULL) {
|
||||
tsdbReaderClose(p);
|
||||
|
@ -3888,10 +3895,11 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
||||
tsdbReaderClose(pReader);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
void tsdbReaderClose(STsdbReader* pReader) {
|
||||
if (pReader == NULL) {
|
||||
|
|
|
@ -22,32 +22,21 @@ static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
|||
|
||||
static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
taosThreadMutexLock(&pVnode->lock);
|
||||
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->blockSec = 0;
|
||||
pVnode->blockSeq = 0;
|
||||
tsem_post(&pVnode->syncSem);
|
||||
}
|
||||
taosThreadMutexUnlock(&pVnode->lock);
|
||||
|
@ -217,12 +206,19 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
|||
#else
|
||||
|
||||
static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) {
|
||||
int64_t seq = 0;
|
||||
|
||||
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));
|
||||
if (wait) {
|
||||
ASSERT(!pVnode->blocked);
|
||||
pVnode->blocked = true;
|
||||
pVnode->blockSec = taosGetTimestampSec();
|
||||
pVnode->blockSeq = seq;
|
||||
#if 0
|
||||
pVnode->blockInfo = pMsg->info;
|
||||
#endif
|
||||
}
|
||||
taosThreadMutexUnlock(&pVnode->lock);
|
||||
|
||||
|
@ -289,12 +285,15 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
|||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
||||
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)) {
|
||||
vTrace("vgId:%d, blocking msg obtained from apply-queue. index:%" PRId64 ", term: %" PRId64 ", type: %s", vgId,
|
||||
pMsg->info.conn.applyIndex, pMsg->info.conn.applyTerm, TMSG_INFO(pMsg->msgType));
|
||||
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64
|
||||
", 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};
|
||||
|
@ -621,6 +620,32 @@ void vnodeSyncClose(SVnode *pVnode) {
|
|||
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) {
|
||||
SSyncState state = syncGetState(pVnode->sync);
|
||||
return state.state == TAOS_SYNC_STATE_LEADER;
|
||||
|
|
|
@ -1728,7 +1728,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
|||
}
|
||||
|
||||
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));
|
||||
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) {
|
||||
SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle;
|
||||
SDataDeleterBuf* pBuf = taosAllocateQitem(sizeof(SDataDeleterBuf), DEF_QITEM);
|
||||
SDataDeleterBuf* pBuf = taosAllocateQitem(sizeof(SDataDeleterBuf), DEF_QITEM, 0);
|
||||
if (NULL == pBuf) {
|
||||
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) {
|
||||
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
|
||||
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM);
|
||||
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM, 0);
|
||||
if (NULL == pBuf) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -510,6 +510,7 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pCo
|
|||
blockDataEnsureCapacity(pRes, pBlock->info.rows);
|
||||
|
||||
// data from mnode
|
||||
pRes->info.dataLoad = 1;
|
||||
pRes->info.rows = pBlock->info.rows;
|
||||
relocateColumnData(pRes, pColList, pBlock->pDataBlock, false);
|
||||
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,
|
||||
pBlock->info.id.groupId);
|
||||
|
||||
pBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pBlock, 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2546,6 +2546,7 @@ int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pStat
|
|||
pBlock->info.rows += pRow->numOfRows;
|
||||
releaseOutputBuf(pState, &key, pRow);
|
||||
}
|
||||
pBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pBlock, 0);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2635,6 +2636,7 @@ int32_t buildSessionResultDataBlock(SOperatorInfo* pOperator, SStreamState* pSta
|
|||
}
|
||||
}
|
||||
|
||||
pBlock->info.dataLoad = 1;
|
||||
pBlock->info.rows += pRow->numOfRows;
|
||||
// saveSessionDiscBuf(pState, pKey, pVal, size);
|
||||
releaseOutputBuf(pState, NULL, pRow);
|
||||
|
|
|
@ -314,7 +314,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
}
|
||||
|
||||
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
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -469,8 +471,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode*
|
|||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||
setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, optrDefaultBufFn, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo,
|
||||
optrDefaultBufFn, NULL);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
@ -696,6 +698,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
|||
pInfo->pageIndex += 1;
|
||||
releaseBufPage(pInfo->pBuf, page);
|
||||
|
||||
pInfo->binfo.pRes->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pInfo->binfo.pRes, 0);
|
||||
pInfo->binfo.pRes->info.id.groupId = pGroupInfo->groupId;
|
||||
|
||||
|
@ -776,6 +779,12 @@ static void destroyPartitionOperatorInfo(void* param) {
|
|||
|
||||
taosArrayDestroy(pInfo->pGroupColVals);
|
||||
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);
|
||||
|
||||
void* pGroupIter = taosHashIterate(pInfo->pGroupSet, NULL);
|
||||
|
@ -850,7 +859,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
|
|||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
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);
|
||||
return pOperator;
|
||||
|
@ -951,6 +961,8 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
|
|||
}
|
||||
taosArrayDestroy(pParInfo->rowIds);
|
||||
pParInfo->rowIds = NULL;
|
||||
pDest->info.dataLoad = 1;
|
||||
|
||||
blockDataUpdateTsWindow(pDest, pInfo->tsColIndex);
|
||||
pDest->info.id.groupId = pParInfo->groupId;
|
||||
pOperator->resultInfo.totalRows += pDest->info.rows;
|
||||
|
@ -1141,8 +1153,8 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
pInfo, pTaskInfo);
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(optrDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamHashPartition, NULL,
|
||||
destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
|
|
@ -87,11 +87,11 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
|||
}
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pJoinNode->node.pOutputDataBlockDesc);
|
||||
pInfo->pRes = createDataBlockFromDescNode(pJoinNode->node.pOutputDataBlockDesc);
|
||||
|
||||
SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &numOfCols);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
|
||||
pInfo->pRes = pResBlock;
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
setOperatorInfo(pOperator, "MergeJoinOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
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
|
||||
pRes->info.rows = nrows;
|
||||
pRes->info.dataLoad = 1;
|
||||
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
|
||||
break;
|
||||
}
|
||||
|
@ -412,7 +413,7 @@ SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator) {
|
|||
|
||||
SSDataBlock* pRes = pJoinInfo->pRes;
|
||||
blockDataCleanup(pRes);
|
||||
blockDataEnsureCapacity(pRes, 4096);
|
||||
|
||||
while (true) {
|
||||
int32_t numOfRowsBefore = pRes->info.rows;
|
||||
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 numOfOutput, SArray* pPseudoList) {
|
||||
setPseudoOutputColInfo(pResult, pCtx, pPseudoList);
|
||||
pResult->info.dataLoad = 1;
|
||||
|
||||
if (pSrcBlock == NULL) {
|
||||
for (int32_t k = 0; k < numOfOutput; ++k) {
|
||||
|
|
|
@ -110,9 +110,9 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
|||
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -122,16 +122,16 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
|||
break;
|
||||
}
|
||||
|
||||
assert(w.ekey > pBlockInfo->window.ekey);
|
||||
ASSERT(w.ekey > pBlockInfo->window.ekey);
|
||||
if (TMAX(w.skey, pBlockInfo->window.skey) <= pBlockInfo->window.ekey) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1342,6 +1342,7 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock,
|
|||
}
|
||||
pDestBlock->info.type = STREAM_CLEAR;
|
||||
pDestBlock->info.version = pSrcBlock->info.version;
|
||||
pDestBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pDestBlock, 0);
|
||||
return code;
|
||||
}
|
||||
|
@ -1450,6 +1451,7 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
|
|||
}
|
||||
if (out && pInfo->pUpdateDataRes->info.rows > 0) {
|
||||
pInfo->pUpdateDataRes->info.version = pBlock->info.version;
|
||||
pInfo->pUpdateDataRes->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pInfo->pUpdateDataRes, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
pInfo->pRes->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||
blockDataFreeRes((SSDataBlock*)pBlock);
|
||||
|
||||
|
@ -1793,6 +1796,7 @@ FETCH_NEXT_BLOCK:
|
|||
// TODO move into scan
|
||||
pBlock->info.calWin.skey = INT64_MIN;
|
||||
pBlock->info.calWin.ekey = INT64_MAX;
|
||||
pBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pBlock, 0);
|
||||
switch (pBlock->info.type) {
|
||||
case STREAM_NORMAL:
|
||||
|
@ -1970,6 +1974,7 @@ FETCH_NEXT_BLOCK:
|
|||
}
|
||||
|
||||
doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
|
||||
pInfo->pRes->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -698,6 +699,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
|
|||
pInfo->limitInfo.numOfOutputRows += p->info.rows;
|
||||
pDataBlock->info.rows = p->info.rows;
|
||||
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,
|
||||
|
|
|
@ -49,10 +49,10 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
|
|||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||
pkey->isNull = false;
|
||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||
if (!IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
memcpy(pkey->pData, val, pkey->bytes);
|
||||
} else {
|
||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||
memcpy(pkey->pData, val, varDataLen(val));
|
||||
} else {
|
||||
memcpy(pkey->pData, val, pkey->bytes);
|
||||
}
|
||||
} else {
|
||||
pkey->isNull = true;
|
||||
|
@ -91,20 +91,37 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
|||
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, pSliceInfo->tsCol.slotId);
|
||||
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.
|
||||
// TODO: optimize to ignore null values for linear interpolation.
|
||||
if (!pLinearInfo->isStartSet) {
|
||||
if (!colDataIsNull_s(pColInfoData, rowIndex)) {
|
||||
ASSERT(IS_MATHABLE_TYPE(pColInfoData->info.type));
|
||||
|
||||
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;
|
||||
} else if (!pLinearInfo->isEndSet) {
|
||||
if (!colDataIsNull_s(pColInfoData, 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;
|
||||
} else {
|
||||
|
@ -113,7 +130,15 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
|||
|
||||
if (!colDataIsNull_s(pColInfoData, 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 {
|
||||
pLinearInfo->end.key = INT64_MIN;
|
||||
}
|
||||
|
|
|
@ -1037,9 +1037,10 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe
|
|||
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
||||
TSKEY* tsCols = NULL;
|
||||
|
||||
if (pBlock->pDataBlock != NULL) {
|
||||
if (pBlock->pDataBlock != NULL && pBlock->info.dataLoad == 1) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
tsCols = (int64_t*)pColDataInfo->pData;
|
||||
ASSERT(tsCols[0] != 0);
|
||||
|
||||
// no data in primary ts
|
||||
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
|
||||
setInputDataBlock(pSup, pBlock, pInfo->inputOrder, scanFlag, true);
|
||||
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
||||
|
||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag);
|
||||
}
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
|
|||
|
||||
pInfo->current += 1;
|
||||
|
||||
pBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pBlock, 0);
|
||||
return pBlock;
|
||||
}
|
||||
|
|
|
@ -514,7 +514,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
numOfElem = pInput->numOfRows;
|
||||
pAvgRes->count += pInput->numOfRows;
|
||||
|
||||
bool simdAvailable = tsAVXEnable && tsSIMDEnable && (numOfRows > THRESHOLD_SIZE);
|
||||
bool simdAvailable = tsAVXEnable && tsSIMDBuiltins && (numOfRows > THRESHOLD_SIZE);
|
||||
|
||||
switch(type) {
|
||||
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,
|
||||
bool signVal) {
|
||||
// AVX2 version to speedup the loop
|
||||
if (tsAVX2Enable && tsSIMDEnable) {
|
||||
if (tsAVX2Enable && tsSIMDBuiltins) {
|
||||
pBuf->v = i8VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
||||
} else {
|
||||
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,
|
||||
bool signVal) {
|
||||
// AVX2 version to speedup the loop
|
||||
if (tsAVX2Enable && tsSIMDEnable) {
|
||||
if (tsAVX2Enable && tsSIMDBuiltins) {
|
||||
pBuf->v = i16VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
||||
} else {
|
||||
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,
|
||||
bool signVal) {
|
||||
// AVX2 version to speedup the loop
|
||||
if (tsAVX2Enable && tsSIMDEnable) {
|
||||
if (tsAVX2Enable && tsSIMDBuiltins) {
|
||||
pBuf->v = i32VectorCmpAVX2(data, numOfRows, isMinFunc, signVal);
|
||||
} else {
|
||||
if (!pBuf->assign) {
|
||||
|
@ -500,7 +500,7 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo
|
|||
float* val = (float*)&pBuf->v;
|
||||
|
||||
// AVX version to speedup the loop
|
||||
if (tsAVXEnable && tsSIMDEnable) {
|
||||
if (tsAVXEnable && tsSIMDBuiltins) {
|
||||
*val = floatVectorCmpAVX(pData, numOfRows, isMinFunc);
|
||||
} else {
|
||||
if (!pBuf->assign) {
|
||||
|
@ -530,7 +530,7 @@ static void handleDoubleCol(SColumnInfoData* pCol, int32_t start, int32_t numOfR
|
|||
double* val = (double*)&pBuf->v;
|
||||
|
||||
// AVX version to speedup the loop
|
||||
if (tsAVXEnable && tsSIMDEnable) {
|
||||
if (tsAVXEnable && tsSIMDBuiltins) {
|
||||
*val = (double)doubleVectorCmpAVX(pData, numOfRows, isMinFunc);
|
||||
} else {
|
||||
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);
|
||||
|
||||
// keep the pointer in memory
|
||||
setBufPageDirty(pSlot->info.data, true);
|
||||
releaseBufPage(pBucket->pBuffer, pSlot->info.data);
|
||||
pSlot->info.data = NULL;
|
||||
}
|
||||
|
@ -497,15 +498,16 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
|||
resetSlotInfo(pMemBucket);
|
||||
|
||||
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);
|
||||
|
||||
for (int32_t f = 0; f < list->size; ++f) {
|
||||
SPageInfo *pgInfo = *(SPageInfo **)taosArrayGet(list, f);
|
||||
SFilePage *pg = getBufPage(pMemBucket->pBuffer, getPageId(pgInfo));
|
||||
int32_t *pageId = taosArrayGet(list, f);
|
||||
SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||
|
||||
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);
|
||||
|
|
|
@ -837,9 +837,34 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) {
|
|||
}
|
||||
|
||||
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));
|
||||
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);
|
||||
|
||||
if (IS_VAR_DATA_TYPE((input + i)->columnData->info.type)) {
|
||||
|
|
|
@ -28,39 +28,46 @@
|
|||
#include "tmsg.h"
|
||||
#include "trpc.h"
|
||||
#include "tmisce.h"
|
||||
// clang-foramt on
|
||||
// clang-format on
|
||||
|
||||
typedef struct SUdfdContext {
|
||||
uv_loop_t * loop;
|
||||
uv_loop_t *loop;
|
||||
uv_pipe_t ctrlPipe;
|
||||
uv_signal_t intrSignal;
|
||||
char listenPipeName[PATH_MAX + UDF_LISTEN_PIPE_NAME_LEN + 2];
|
||||
uv_pipe_t listeningPipe;
|
||||
|
||||
void * clientRpc;
|
||||
void *clientRpc;
|
||||
SCorEpSet mgmtEp;
|
||||
uv_mutex_t udfsMutex;
|
||||
SHashObj * udfsHash;
|
||||
SHashObj *udfsHash;
|
||||
|
||||
SArray* residentFuncs;
|
||||
SArray *residentFuncs;
|
||||
|
||||
bool printVersion;
|
||||
} SUdfdContext;
|
||||
|
||||
SUdfdContext global;
|
||||
|
||||
struct SUdfdUvConn;
|
||||
struct SUvUdfWork;
|
||||
|
||||
typedef struct SUdfdUvConn {
|
||||
uv_stream_t *client;
|
||||
char * inputBuf;
|
||||
char *inputBuf;
|
||||
int32_t inputLen;
|
||||
int32_t inputCap;
|
||||
int32_t inputTotal;
|
||||
|
||||
struct SUvUdfWork *pWorkList; // head of work list
|
||||
} SUdfdUvConn;
|
||||
|
||||
typedef struct SUvUdfWork {
|
||||
uv_stream_t *client;
|
||||
SUdfdUvConn *conn;
|
||||
uv_buf_t input;
|
||||
uv_buf_t output;
|
||||
|
||||
struct SUvUdfWork *pWorkNext;
|
||||
} SUvUdfWork;
|
||||
|
||||
typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY, UDF_STATE_UNLOADING } EUdfState;
|
||||
|
@ -70,7 +77,7 @@ typedef struct SUdf {
|
|||
EUdfState state;
|
||||
uv_mutex_t lock;
|
||||
uv_cond_t condReady;
|
||||
bool resident;
|
||||
bool resident;
|
||||
|
||||
char name[TSDB_FUNC_NAME_LEN + 1];
|
||||
int8_t funcType;
|
||||
|
@ -107,7 +114,7 @@ typedef enum EUdfdRpcReqRspType {
|
|||
typedef struct SUdfdRpcSendRecvInfo {
|
||||
EUdfdRpcReqRspType rpcType;
|
||||
int32_t code;
|
||||
void * param;
|
||||
void *param;
|
||||
uv_sem_t resultSem;
|
||||
} SUdfdRpcSendRecvInfo;
|
||||
|
||||
|
@ -178,7 +185,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
fnInfo("setup request. seq num: %" PRId64 ", udf name: %s", request->seqNum, request->setup.udfName);
|
||||
SUdfSetupRequest *setup = &request->setup;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SUdf * udf = NULL;
|
||||
SUdf *udf = NULL;
|
||||
uv_mutex_lock(&global.udfsMutex);
|
||||
SUdf **udfInHash = taosHashGet(global.udfsHash, request->setup.udfName, strlen(request->setup.udfName));
|
||||
if (udfInHash) {
|
||||
|
@ -193,7 +200,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
uv_cond_init(&udfNew->condReady);
|
||||
|
||||
udf = udfNew;
|
||||
SUdf** pUdf = &udf;
|
||||
SUdf **pUdf = &udf;
|
||||
taosHashPut(global.udfsHash, request->setup.udfName, strlen(request->setup.udfName), pUdf, POINTER_BYTES);
|
||||
uv_mutex_unlock(&global.udfsMutex);
|
||||
}
|
||||
|
@ -207,7 +214,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
}
|
||||
udf->resident = false;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(global.residentFuncs); ++i) {
|
||||
char* funcName = taosArrayGet(global.residentFuncs, i);
|
||||
char *funcName = taosArrayGet(global.residentFuncs, i);
|
||||
if (strcmp(setup->udfName, funcName) == 0) {
|
||||
udf->resident = true;
|
||||
break;
|
||||
|
@ -248,11 +255,12 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
|
||||
void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
||||
SUdfCallRequest *call = &request->call;
|
||||
fnDebug("call request. call type %d, handle: %" PRIx64 ", seq num %" PRId64 , call->callType, call->udfHandle, request->seqNum);
|
||||
SUdfcFuncHandle * handle = (SUdfcFuncHandle *)(call->udfHandle);
|
||||
SUdf * udf = handle->udf;
|
||||
fnDebug("call request. call type %d, handle: %" PRIx64 ", seq num %" PRId64, call->callType, call->udfHandle,
|
||||
request->seqNum);
|
||||
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(call->udfHandle);
|
||||
SUdf *udf = handle->udf;
|
||||
SUdfResponse response = {0};
|
||||
SUdfResponse * rsp = &response;
|
||||
SUdfResponse *rsp = &response;
|
||||
SUdfCallResponse *subRsp = &rsp->callRsp;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -352,7 +360,7 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
|
|||
SUdfTeardownRequest *teardown = &request->teardown;
|
||||
fnInfo("teardown. seq number: %" PRId64 ", handle:%" PRIx64, request->seqNum, teardown->udfHandle);
|
||||
SUdfcFuncHandle *handle = (SUdfcFuncHandle *)(teardown->udfHandle);
|
||||
SUdf * udf = handle->udf;
|
||||
SUdf *udf = handle->udf;
|
||||
bool unloadUdf = false;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -417,7 +425,6 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
goto _return;
|
||||
}
|
||||
|
||||
|
||||
if (connectRsp.epSet.numOfEps == 0) {
|
||||
msgInfo->code = TSDB_CODE_APP_ERROR;
|
||||
goto _return;
|
||||
|
@ -434,7 +441,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
goto _return;
|
||||
}
|
||||
SFuncInfo *pFuncInfo = (SFuncInfo *)taosArrayGet(retrieveRsp.pFuncInfos, 0);
|
||||
SUdf * udf = msgInfo->param;
|
||||
SUdf *udf = msgInfo->param;
|
||||
udf->funcType = pFuncInfo->funcType;
|
||||
udf->scriptType = pFuncInfo->scriptType;
|
||||
udf->outputType = pFuncInfo->outputType;
|
||||
|
@ -487,7 +494,7 @@ int32_t udfdFillUdfInfoFromMNode(void *clientRpc, char *udfName, SUdf *udf) {
|
|||
taosArrayPush(retrieveReq.pFuncNames, udfName);
|
||||
|
||||
int32_t contLen = tSerializeSRetrieveFuncReq(NULL, 0, &retrieveReq);
|
||||
void * pReq = rpcMallocCont(contLen);
|
||||
void *pReq = rpcMallocCont(contLen);
|
||||
tSerializeSRetrieveFuncReq(pReq, contLen, &retrieveReq);
|
||||
taosArrayDestroy(retrieveReq.pFuncNames);
|
||||
|
||||
|
@ -522,7 +529,7 @@ int32_t udfdConnectToMnode() {
|
|||
connReq.startTime = taosGetTimestampMs();
|
||||
|
||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connReq);
|
||||
void * pReq = rpcMallocCont(contLen);
|
||||
void *pReq = rpcMallocCont(contLen);
|
||||
tSerializeSConnectReq(pReq, contLen, &connReq);
|
||||
|
||||
SUdfdRpcSendRecvInfo *msgInfo = taosMemoryCalloc(1, sizeof(SUdfdRpcSendRecvInfo));
|
||||
|
@ -589,7 +596,7 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
|
|||
strncpy(finishFuncName, processFuncName, sizeof(finishFuncName));
|
||||
strncat(finishFuncName, finishSuffix, strlen(finishSuffix));
|
||||
uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggFinishFunc));
|
||||
char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0};
|
||||
char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0};
|
||||
char *mergeSuffix = "_merge";
|
||||
strncpy(mergeFuncName, processFuncName, sizeof(mergeFuncName));
|
||||
strncat(mergeFuncName, mergeSuffix, strlen(mergeSuffix));
|
||||
|
@ -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 ||
|
||||
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
||||
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 true;
|
||||
|
@ -684,6 +692,17 @@ void udfdOnWrite(uv_write_t *req, int status) {
|
|||
if (status < 0) {
|
||||
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);
|
||||
taosMemoryFree(req);
|
||||
|
@ -692,10 +711,11 @@ void udfdOnWrite(uv_write_t *req, int status) {
|
|||
void udfdSendResponse(uv_work_t *work, int status) {
|
||||
SUvUdfWork *udfWork = (SUvUdfWork *)(work->data);
|
||||
|
||||
uv_write_t *write_req = taosMemoryMalloc(sizeof(uv_write_t));
|
||||
write_req->data = udfWork;
|
||||
uv_write(write_req, udfWork->client, &udfWork->output, 1, udfdOnWrite);
|
||||
|
||||
if (udfWork->conn != NULL) {
|
||||
uv_write_t *write_req = taosMemoryMalloc(sizeof(uv_write_t));
|
||||
write_req->data = udfWork;
|
||||
uv_write(write_req, udfWork->conn->client, &udfWork->output, 1, udfdOnWrite);
|
||||
}
|
||||
taosMemoryFree(work);
|
||||
}
|
||||
|
||||
|
@ -716,8 +736,8 @@ void udfdAllocBuffer(uv_handle_t *handle, size_t suggestedSize, uv_buf_t *buf) {
|
|||
buf->len = 0;
|
||||
}
|
||||
} else if (ctx->inputTotal == -1 && ctx->inputLen < msgHeadSize) {
|
||||
buf->base = ctx->inputBuf + ctx->inputLen;
|
||||
buf->len = msgHeadSize - ctx->inputLen;
|
||||
buf->base = ctx->inputBuf + ctx->inputLen;
|
||||
buf->len = msgHeadSize - ctx->inputLen;
|
||||
} else {
|
||||
ctx->inputCap = ctx->inputTotal > ctx->inputCap ? ctx->inputTotal : ctx->inputCap;
|
||||
void *inputBuf = taosMemoryRealloc(ctx->inputBuf, ctx->inputCap);
|
||||
|
@ -744,10 +764,15 @@ bool isUdfdUvMsgComplete(SUdfdUvConn *pipe) {
|
|||
}
|
||||
|
||||
void udfdHandleRequest(SUdfdUvConn *conn) {
|
||||
uv_work_t * work = taosMemoryMalloc(sizeof(uv_work_t));
|
||||
char *inputBuf = conn->inputBuf;
|
||||
int32_t inputLen = conn->inputLen;
|
||||
|
||||
uv_work_t *work = taosMemoryMalloc(sizeof(uv_work_t));
|
||||
SUvUdfWork *udfWork = taosMemoryMalloc(sizeof(SUvUdfWork));
|
||||
udfWork->client = conn->client;
|
||||
udfWork->input = uv_buf_init(conn->inputBuf, conn->inputLen);
|
||||
udfWork->conn = conn;
|
||||
udfWork->pWorkNext = conn->pWorkList;
|
||||
conn->pWorkList = udfWork;
|
||||
udfWork->input = uv_buf_init(inputBuf, inputLen);
|
||||
conn->inputBuf = NULL;
|
||||
conn->inputLen = 0;
|
||||
conn->inputCap = 0;
|
||||
|
@ -758,13 +783,19 @@ void udfdHandleRequest(SUdfdUvConn *conn) {
|
|||
|
||||
void udfdPipeCloseCb(uv_handle_t *pipe) {
|
||||
SUdfdUvConn *conn = pipe->data;
|
||||
SUvUdfWork* pWork = conn->pWorkList;
|
||||
while (pWork != NULL) {
|
||||
pWork->conn = NULL;
|
||||
pWork = pWork->pWorkNext;
|
||||
}
|
||||
|
||||
taosMemoryFree(conn->client);
|
||||
taosMemoryFree(conn->inputBuf);
|
||||
taosMemoryFree(conn);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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) {
|
||||
fnError("Receive error %s", uv_err_name(nread));
|
||||
if (nread == UV_EOF) {
|
||||
// TODO check more when close
|
||||
fnInfo("udfd pipe read EOF");
|
||||
} else {
|
||||
fnError("Receive error %s", uv_err_name(nread));
|
||||
}
|
||||
udfdUvHandleError(conn);
|
||||
}
|
||||
|
@ -799,6 +830,7 @@ void udfdOnNewConnection(uv_stream_t *server, int status) {
|
|||
uv_pipe_init(global.loop, client, 0);
|
||||
if (uv_accept(server, (uv_stream_t *)client) == 0) {
|
||||
SUdfdUvConn *ctx = taosMemoryMalloc(sizeof(SUdfdUvConn));
|
||||
ctx->pWorkList = NULL;
|
||||
ctx->client = (uv_stream_t *)client;
|
||||
ctx->inputBuf = 0;
|
||||
ctx->inputLen = 0;
|
||||
|
@ -891,7 +923,7 @@ static int32_t udfdUvInit() {
|
|||
}
|
||||
global.loop = loop;
|
||||
|
||||
if (tsStartUdfd) { // udfd is started by taosd, which shall exit when taosd exit
|
||||
if (tsStartUdfd) { // udfd is started by taosd, which shall exit when taosd exit
|
||||
uv_pipe_init(global.loop, &global.ctrlPipe, 1);
|
||||
uv_pipe_open(&global.ctrlPipe, 0);
|
||||
uv_read_start((uv_stream_t *)&global.ctrlPipe, udfdCtrlAllocBufCb, udfdCtrlReadCb);
|
||||
|
@ -966,10 +998,10 @@ int32_t udfdInitResidentFuncs() {
|
|||
}
|
||||
|
||||
global.residentFuncs = taosArrayInit(2, TSDB_FUNC_NAME_LEN);
|
||||
char* pSave = tsUdfdResFuncs;
|
||||
char* token;
|
||||
char *pSave = tsUdfdResFuncs;
|
||||
char *token;
|
||||
while ((token = strtok_r(pSave, ",", &pSave)) != NULL) {
|
||||
char func[TSDB_FUNC_NAME_LEN+1] = {0};
|
||||
char func[TSDB_FUNC_NAME_LEN + 1] = {0};
|
||||
strncpy(func, token, TSDB_FUNC_NAME_LEN);
|
||||
fnInfo("udfd add resident function %s", func);
|
||||
taosArrayPush(global.residentFuncs, func);
|
||||
|
@ -980,10 +1012,10 @@ int32_t udfdInitResidentFuncs() {
|
|||
|
||||
int32_t udfdDeinitResidentFuncs() {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(global.residentFuncs); ++i) {
|
||||
char* funcName = taosArrayGet(global.residentFuncs, i);
|
||||
SUdf** udfInHash = taosHashGet(global.udfsHash, funcName, strlen(funcName));
|
||||
char *funcName = taosArrayGet(global.residentFuncs, i);
|
||||
SUdf **udfInHash = taosHashGet(global.udfsHash, funcName, strlen(funcName));
|
||||
if (udfInHash) {
|
||||
SUdf* udf = *udfInHash;
|
||||
SUdf *udf = *udfInHash;
|
||||
if (udf->destroyFunc) {
|
||||
(udf->destroyFunc)();
|
||||
}
|
||||
|
|
|
@ -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) 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) 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) 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); }
|
||||
|
@ -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) ::= 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) ::= 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) ::= 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; }
|
||||
|
||||
%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
|
||||
TIMES UPDATE VALUES VARIABLE VIEW WAL.
|
||||
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
|
||||
STRICT STRING TIMES UPDATE VALUES VARIABLE VIEW WAL.
|
||||
|
|
|
@ -2837,7 +2837,7 @@ static int32_t rewriteProjectAlias(SNodeList* pProjectionList) {
|
|||
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),
|
||||
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
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);
|
||||
}
|
||||
taosHashCleanup(pUserAliasSet);
|
||||
if (NULL == pOutput) {
|
||||
taosHashCleanup(pUserAliasSet);
|
||||
} else {
|
||||
*pOutput = pUserAliasSet;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateProjectionList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (pSelect->isSubquery) {
|
||||
return checkProjectAlias(pCxt, pSelect->pProjectionList);
|
||||
return checkProjectAlias(pCxt, pSelect->pProjectionList, NULL);
|
||||
}
|
||||
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) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||
"Invalid option keep: %" PRId64 ", %" PRId64 ", %" PRId64 " valid range: [%dm, %dm]",
|
||||
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP,
|
||||
tsdbMaxKeep);
|
||||
pOptions->keep[0], pOptions->keep[1], pOptions->keep[2], TSDB_MIN_KEEP, tsdbMaxKeep);
|
||||
}
|
||||
|
||||
if (!((pOptions->keep[0] <= pOptions->keep[1]) && (pOptions->keep[1] <= pOptions->keep[2]))) {
|
||||
|
@ -4044,7 +4047,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
|||
code = checkDbPrecisionOption(pCxt, pOptions);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkDbKeepOption(pCxt, pOptions); // use precision
|
||||
code = checkDbKeepOption(pCxt, pOptions); // use precision
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkDbRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
||||
|
@ -5504,9 +5507,24 @@ static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
|
|||
tNameGetFullDbName(&name, pDbFName);
|
||||
}
|
||||
|
||||
static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
|
||||
static void getStreamQueryFirstProjectAliasName(SHashObj* pUserAliasSet, char* aliasName, int32_t len) {
|
||||
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);
|
||||
if (NULL == pSelect->pWindow ||
|
||||
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -5516,7 +5534,7 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
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);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
|
@ -5524,6 +5542,17 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
|||
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) {
|
||||
if (NULL == pStmt->pTags) {
|
||||
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) {
|
||||
pCxt->createStream = true;
|
||||
int32_t code = addWstartTsToCreateStreamQuery(pStmt->pQuery);
|
||||
int32_t code = addWstartTsToCreateStreamQuery(pCxt, pStmt->pQuery);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
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'}
|
||||
* | REPLICA value
|
||||
* | RETENTIONS ingestion_duration:keep_duration ...
|
||||
* | STRICT {'off' | 'on'}
|
||||
* | STRICT {'off' | 'on'} // not support
|
||||
* | WAL_LEVEL value
|
||||
* | VGROUPS value
|
||||
* | 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(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);
|
||||
setDbStrictaFunc(1);
|
||||
// setDbStrictaFunc(1);
|
||||
setDbWalLevelFunc(2);
|
||||
setDbVgroupsFunc(100);
|
||||
setDbSingleStableFunc(1);
|
||||
|
@ -244,7 +244,7 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
|||
"PRECISION 'ns' "
|
||||
"REPLICA 3 "
|
||||
"RETENTIONS 15s:7d,1m:21d,15m:500d "
|
||||
"STRICT 'on' "
|
||||
// "STRICT 'on' "
|
||||
"WAL_LEVEL 2 "
|
||||
"VGROUPS 100 "
|
||||
"SINGLE_STABLE 1 "
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
|
||||
#define QW_DEFAULT_SCHEDULER_NUMBER 100
|
||||
#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_HEARTBEAT_MSEC 5000
|
||||
#define QW_SCH_TIMEOUT_MSEC 180000
|
||||
|
@ -247,7 +247,7 @@ typedef struct SQWorkerMgmt {
|
|||
|
||||
#define QW_ERR_RET(c) \
|
||||
do { \
|
||||
int32_t _code = (c); \
|
||||
int32_t _code = (c); \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
return _code; \
|
||||
|
@ -255,7 +255,7 @@ typedef struct SQWorkerMgmt {
|
|||
} while (0)
|
||||
#define QW_RET(c) \
|
||||
do { \
|
||||
int32_t _code = (c); \
|
||||
int32_t _code = (c); \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
} \
|
||||
|
@ -263,7 +263,7 @@ typedef struct SQWorkerMgmt {
|
|||
} while (0)
|
||||
#define QW_ERR_JRET(c) \
|
||||
do { \
|
||||
code = (c); \
|
||||
code = (c); \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = code; \
|
||||
goto _return; \
|
||||
|
|
|
@ -74,6 +74,8 @@ int32_t qwAddSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType) {
|
|||
SQWSchStatus newSch = {0};
|
||||
newSch.tasksHash =
|
||||
taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
newSch.hbBrokenTs = taosGetTimestampMs();
|
||||
|
||||
if (NULL == newSch.tasksHash) {
|
||||
QW_SCH_ELOG("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum);
|
||||
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -463,6 +465,8 @@ void qwDestroyImpl(void *pMgmt) {
|
|||
int8_t nodeType = mgmt->nodeType;
|
||||
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);
|
||||
|
||||
taosTmrStop(mgmt->hbTimer);
|
||||
|
@ -472,6 +476,7 @@ void qwDestroyImpl(void *pMgmt) {
|
|||
uint64_t qId, tId;
|
||||
int32_t eId;
|
||||
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
|
||||
|
||||
while (pIter) {
|
||||
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
|
||||
void *key = taosHashGetKey(pIter, NULL);
|
||||
|
@ -480,6 +485,7 @@ void qwDestroyImpl(void *pMgmt) {
|
|||
qwFreeTaskCtx(ctx);
|
||||
QW_TASK_DLOG_E("task ctx freed");
|
||||
pIter = taosHashIterate(mgmt->ctxHash, pIter);
|
||||
taskCount++;
|
||||
}
|
||||
taosHashCleanup(mgmt->ctxHash);
|
||||
|
||||
|
@ -487,7 +493,9 @@ void qwDestroyImpl(void *pMgmt) {
|
|||
while (pIter) {
|
||||
SQWSchStatus *sch = (SQWSchStatus *)pIter;
|
||||
qwDestroySchStatus(sch);
|
||||
|
||||
pIter = taosHashIterate(mgmt->schHash, pIter);
|
||||
schStatusCount++;
|
||||
}
|
||||
taosHashCleanup(mgmt->schHash);
|
||||
|
||||
|
@ -499,7 +507,8 @@ void qwDestroyImpl(void *pMgmt) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include "qwMsg.h"
|
||||
#include "tcommon.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsg.h"
|
||||
#include "tname.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
SQWorkerMgmt gQwMgmt = {
|
||||
.lock = 0,
|
||||
|
@ -275,7 +275,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
|
|||
QW_ERR_RET(code);
|
||||
}
|
||||
|
||||
QW_TASK_DLOG("no more data in sink and query end, fetched blocks %d rows %"PRId64, pOutput->numOfBlocks,
|
||||
QW_TASK_DLOG("no more data in sink and query end, fetched blocks %d rows %" PRId64, pOutput->numOfBlocks,
|
||||
pOutput->numOfRows);
|
||||
|
||||
qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_SUCC);
|
||||
|
@ -327,12 +327,14 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -650,8 +652,8 @@ _return:
|
|||
code = qwHandlePostPhaseEvents(QW_FPARAMS(), QW_PHASE_POST_QUERY, &input, NULL);
|
||||
|
||||
if (QUERY_RSP_POLICY_QUICK == tsQueryRspPolicy && ctx != NULL && QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) {
|
||||
void *rsp = NULL;
|
||||
int32_t dataLen = 0;
|
||||
void *rsp = NULL;
|
||||
int32_t dataLen = 0;
|
||||
SOutputData sOutput = {0};
|
||||
if (qwGetQueryResFromSink(QW_FPARAMS(), ctx, &dataLen, &rsp, &sOutput)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -671,8 +673,8 @@ _return:
|
|||
qwBuildAndSendFetchRsp(ctx->fetchType, &qwMsg->connInfo, rsp, dataLen, code);
|
||||
rsp = NULL;
|
||||
|
||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code,
|
||||
tstrerror(code), dataLen);
|
||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
||||
dataLen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -748,7 +750,8 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
|||
}
|
||||
|
||||
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
|
||||
QW_SET_PHASE(ctx, 0);
|
||||
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) {
|
||||
SSchJob* pJob = schAcquireJob(jobId);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ void schedulerFreeJob(int64_t *jobId, int32_t errCode) {
|
|||
|
||||
SSchJob *pJob = schAcquireJob(*jobId);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ void streamSchedByTimer(void* param, void* tmrId) {
|
|||
}
|
||||
|
||||
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;
|
||||
trigger->type = STREAM_INPUT__GET_RES;
|
||||
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) {
|
||||
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
||||
SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||
int8_t status;
|
||||
|
||||
// enqueue
|
||||
|
@ -150,7 +150,7 @@ int32_t streamTaskEnqueue(SStreamTask* pTask, const SStreamDispatchReq* pReq, SR
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
// enqueue
|
||||
|
|
|
@ -67,7 +67,7 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock
|
|||
}
|
||||
|
||||
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;
|
||||
pDataSubmit->dataRef = (int32_t*)taosMemoryMalloc(sizeof(int32_t));
|
||||
if (pDataSubmit->dataRef == NULL) goto FAIL;
|
||||
|
@ -81,7 +81,7 @@ FAIL:
|
|||
}
|
||||
|
||||
SStreamMergedSubmit* streamMergedSubmitNew() {
|
||||
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)taosAllocateQitem(sizeof(SStreamMergedSubmit), DEF_QITEM);
|
||||
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)taosAllocateQitem(sizeof(SStreamMergedSubmit), DEF_QITEM, 0);
|
||||
if (pMerged == NULL) return NULL;
|
||||
pMerged->reqs = 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* pSubmitClone = taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM);
|
||||
SStreamDataSubmit* pSubmitClone = taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM, 0);
|
||||
if (pSubmitClone == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz) {
|
|||
taosArrayDestroy(pRes);
|
||||
break;
|
||||
}
|
||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||
if (qRes == NULL) {
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -235,7 +235,7 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
|||
qDebug("stream task %d exec end", pTask->taskId);
|
||||
|
||||
if (taosArrayGetSize(pRes) != 0) {
|
||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
|
||||
SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0);
|
||||
if (qRes == NULL) {
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
streamFreeQitem(input);
|
||||
|
|
|
@ -215,7 +215,7 @@ int32_t syncNodeStart(SSyncNode* pSyncNode);
|
|||
int32_t syncNodeStartStandBy(SSyncNode* pSyncNode);
|
||||
void syncNodeClose(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);
|
||||
void syncHbTimerDataFree(SSyncHbTimerData* pData);
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg) {
|
|||
}
|
||||
|
||||
syncNodeStartHeartbeatTimer(pSyncNode);
|
||||
//syncNodeReplicate(pSyncNode);
|
||||
// syncNodeReplicate(pSyncNode);
|
||||
}
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
|
@ -218,6 +218,26 @@ int32_t syncLeaderTransfer(int64_t rid) {
|
|||
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 minMatchIndex = SYNC_INDEX_INVALID;
|
||||
|
||||
|
@ -538,7 +558,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
|
|||
pMsg->newLeaderId.vgId = pSyncNode->vgId;
|
||||
pMsg->newNodeInfo = newLeader;
|
||||
|
||||
int32_t ret = syncNodePropose(pSyncNode, &rpcMsg, false);
|
||||
int32_t ret = syncNodePropose(pSyncNode, &rpcMsg, false, NULL);
|
||||
rpcFreeCont(rpcMsg.pCont);
|
||||
return ret;
|
||||
}
|
||||
|
@ -670,19 +690,19 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
|
|||
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);
|
||||
if (pSyncNode == NULL) {
|
||||
sError("sync propose error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ret = syncNodePropose(pSyncNode, pMsg, isWeak);
|
||||
int32_t ret = syncNodePropose(pSyncNode, pMsg, isWeak, seq);
|
||||
syncNodeRelease(pSyncNode);
|
||||
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) {
|
||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||
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);
|
||||
}
|
||||
|
||||
if (seq != NULL) *seq = seqNum;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,6 +594,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
|||
int count = 0;
|
||||
int64_t firstIndex = -1;
|
||||
SyncTerm term = -1;
|
||||
int64_t batchSize = TMAX(1, pMgr->size >> (4 + pMgr->retryBackoff));
|
||||
|
||||
for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) {
|
||||
int64_t pos = index % pMgr->size;
|
||||
|
@ -620,7 +621,10 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
|||
|
||||
retried = true;
|
||||
if (firstIndex == -1) firstIndex = index;
|
||||
count++;
|
||||
|
||||
if (batchSize <= count++) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
@ -800,8 +804,9 @@ int32_t syncLogReplMgrReplicateProbeOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode
|
|||
|
||||
int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
||||
ASSERT(pMgr->restored);
|
||||
|
||||
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;
|
||||
int64_t nowMs = taosGetMonoTimestampMs();
|
||||
int64_t limit = pMgr->size >> 1;
|
||||
|
|
|
@ -337,7 +337,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (alreadySend < writeRecordNum) {
|
||||
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) {
|
||||
sTrace("%s value%d write not leader", s, alreadySend);
|
||||
} else {
|
||||
|
|
|
@ -249,7 +249,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (alreadySend < writeRecordNum) {
|
||||
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) {
|
||||
sTrace("%s value%d write not leader", s, alreadySend);
|
||||
} else {
|
||||
|
|
|
@ -189,7 +189,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (alreadySend < writeRecordNum) {
|
||||
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) {
|
||||
sTrace("%s value%d write not leader", s, alreadySend);
|
||||
} else {
|
||||
|
|
|
@ -396,7 +396,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (alreadySend < writeRecordNum) {
|
||||
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) {
|
||||
sTrace("%s value%d write not leader, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait);
|
||||
} else {
|
||||
|
|
|
@ -97,7 +97,7 @@ int32_t syncIOEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
|||
syncRpcMsgLog2(logBuf, pMsg);
|
||||
|
||||
SRpcMsg *pTemp;
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
||||
|
||||
STaosQueue *pMsgQ = gSyncIO->pMsgQ;
|
||||
|
@ -381,7 +381,7 @@ static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
syncRpcMsgLog2((char *)"==syncIOProcessRequest==", pMsg);
|
||||
SSyncIO *io = pParent;
|
||||
SRpcMsg *pTemp;
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
||||
taosWriteQitem(io->pMsgQ, pTemp);
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ static void syncIOTickQ(void *param, void *tmrId) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncPingReply2RpcMsg(pMsg, &rpcMsg);
|
||||
SRpcMsg *pTemp;
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||
memcpy(pTemp, &rpcMsg, sizeof(SRpcMsg));
|
||||
syncRpcMsgLog2((char *)"==syncIOTickQ==", &rpcMsg);
|
||||
taosWriteQitem(io->pMsgQ, pTemp);
|
||||
|
|
|
@ -47,10 +47,8 @@ typedef struct {
|
|||
char label[TSDB_LABEL_LEN];
|
||||
char user[TSDB_UNI_LEN]; // meter ID
|
||||
|
||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||
int8_t encryption; // encrypt or not
|
||||
int32_t retryLimit; // retry limit
|
||||
int32_t retryInterval; // retry interval ms
|
||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||
int8_t encryption; // encrypt or not
|
||||
|
||||
int32_t retryMinInterval; // retry init interval
|
||||
int32_t retryStepFactor; // retry interval factor
|
||||
|
|
|
@ -47,9 +47,11 @@ void* rpcOpen(const SRpcInit* pInit) {
|
|||
}
|
||||
|
||||
pRpc->compressSize = pInit->compressSize;
|
||||
if (pRpc->compressSize < 0) {
|
||||
pRpc->compressSize = -1;
|
||||
}
|
||||
|
||||
pRpc->encryption = pInit->encryption;
|
||||
pRpc->retryLimit = pInit->retryLimit;
|
||||
pRpc->retryInterval = pInit->retryInterval;
|
||||
|
||||
pRpc->retryMinInterval = pInit->retryMinInterval; // retry init interval
|
||||
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) {
|
||||
if (update) {
|
||||
transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
conn->refId = -1;
|
||||
}
|
||||
|
@ -956,7 +957,6 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
|
||||
SCliConn* conn = exh->handle;
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
|
||||
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
|
||||
|
||||
if (T_REF_VAL_GET(conn) == 2) {
|
||||
|
@ -1574,6 +1574,9 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
pCtx->retryStep = 0;
|
||||
pCtx->retryInit = true;
|
||||
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) {
|
||||
|
@ -1626,9 +1629,9 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
pCtx->retryNextInterval = pCtx->retryMaxInterval;
|
||||
}
|
||||
|
||||
if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
||||
return false;
|
||||
}
|
||||
// if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
||||
// return false;
|
||||
// }
|
||||
} else {
|
||||
pCtx->retryNextInterval = 0;
|
||||
pCtx->epsetRetryCnt++;
|
||||
|
|
|
@ -128,7 +128,7 @@ void *processShellMsg(void *arg) {
|
|||
void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
SRpcMsg *pTemp;
|
||||
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
|
||||
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM, 0);
|
||||
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
|
||||
|
||||
int32_t idx = balance % multiQ->numOfThread;
|
||||
|
|
|
@ -223,6 +223,7 @@ void walClose(SWal *pWal) {
|
|||
taosMemoryFree(pRef);
|
||||
}
|
||||
taosHashCleanup(pWal->pRefHash);
|
||||
pWal->pRefHash = NULL;
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
|
||||
taosRemoveRef(tsWal.refSetId, pWal->refId);
|
||||
|
|
|
@ -32,15 +32,18 @@ SWalRef *walOpenRef(SWal *pWal) {
|
|||
return pRef;
|
||||
}
|
||||
|
||||
#if 1
|
||||
void walCloseRef(SWal *pWal, int64_t refId) {
|
||||
SWalRef **ppRef = taosHashGet(pWal->pRefHash, &refId, sizeof(int64_t));
|
||||
if (ppRef == NULL) return;
|
||||
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));
|
||||
taosMemoryFree(pRef);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t walRefVer(SWalRef *pRef, int64_t ver) {
|
||||
SWal *pWal = pRef->pWal;
|
||||
|
|
|
@ -37,7 +37,7 @@ float tsNumOfCores = 0;
|
|||
int64_t tsTotalMemoryKB = 0;
|
||||
char *tsProcPath = NULL;
|
||||
|
||||
char tsSIMDEnable = 0;
|
||||
char tsSIMDBuiltins = 0;
|
||||
char tsSSE42Enable = 0;
|
||||
char tsAVXEnable = 0;
|
||||
char tsAVX2Enable = 0;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue