commit
e67ca45dda
|
@ -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})")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef uint16_t tmsg_t;
|
|||
|
||||
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
||||
(type == TDMT_VND_UPDATE_TAG_VAL);
|
||||
(type == TDMT_VND_UPDATE_TAG_VAL) || (type == TDMT_VND_ALTER_CONFIRM);
|
||||
}
|
||||
|
||||
static inline bool syncUtilUserCommit(tmsg_t msgType) {
|
||||
|
|
|
@ -94,244 +94,244 @@
|
|||
#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_EVENT_WINDOW 252
|
||||
#define TK_START 253
|
||||
#define TK_SLIDING 254
|
||||
#define TK_FILL 255
|
||||
#define TK_VALUE 256
|
||||
#define TK_NONE 257
|
||||
#define TK_PREV 258
|
||||
#define TK_LINEAR 259
|
||||
#define TK_NEXT 260
|
||||
#define TK_HAVING 261
|
||||
#define TK_RANGE 262
|
||||
#define TK_EVERY 263
|
||||
#define TK_ORDER 264
|
||||
#define TK_SLIMIT 265
|
||||
#define TK_SOFFSET 266
|
||||
#define TK_LIMIT 267
|
||||
#define TK_OFFSET 268
|
||||
#define TK_ASC 269
|
||||
#define TK_NULLS 270
|
||||
#define TK_ABORT 271
|
||||
#define TK_AFTER 272
|
||||
#define TK_ATTACH 273
|
||||
#define TK_BEFORE 274
|
||||
#define TK_BEGIN 275
|
||||
#define TK_BITAND 276
|
||||
#define TK_BITNOT 277
|
||||
#define TK_BITOR 278
|
||||
#define TK_BLOCKS 279
|
||||
#define TK_CHANGE 280
|
||||
#define TK_COMMA 281
|
||||
#define TK_COMPACT 282
|
||||
#define TK_CONCAT 283
|
||||
#define TK_CONFLICT 284
|
||||
#define TK_COPY 285
|
||||
#define TK_DEFERRED 286
|
||||
#define TK_DELIMITERS 287
|
||||
#define TK_DETACH 288
|
||||
#define TK_DIVIDE 289
|
||||
#define TK_DOT 290
|
||||
#define TK_EACH 291
|
||||
#define TK_FAIL 292
|
||||
#define TK_FILE 293
|
||||
#define TK_FOR 294
|
||||
#define TK_GLOB 295
|
||||
#define TK_ID 296
|
||||
#define TK_IMMEDIATE 297
|
||||
#define TK_IMPORT 298
|
||||
#define TK_INITIALLY 299
|
||||
#define TK_INSTEAD 300
|
||||
#define TK_ISNULL 301
|
||||
#define TK_KEY 302
|
||||
#define TK_MODULES 303
|
||||
#define TK_NK_BITNOT 304
|
||||
#define TK_NK_SEMI 305
|
||||
#define TK_NOTNULL 306
|
||||
#define TK_OF 307
|
||||
#define TK_PLUS 308
|
||||
#define TK_PRIVILEGE 309
|
||||
#define TK_RAISE 310
|
||||
#define TK_REPLACE 311
|
||||
#define TK_RESTRICT 312
|
||||
#define TK_ROW 313
|
||||
#define TK_SEMI 314
|
||||
#define TK_STAR 315
|
||||
#define TK_STATEMENT 316
|
||||
#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_EVENT_WINDOW 251
|
||||
#define TK_START 252
|
||||
#define TK_SLIDING 253
|
||||
#define TK_FILL 254
|
||||
#define TK_VALUE 255
|
||||
#define TK_NONE 256
|
||||
#define TK_PREV 257
|
||||
#define TK_LINEAR 258
|
||||
#define TK_NEXT 259
|
||||
#define TK_HAVING 260
|
||||
#define TK_RANGE 261
|
||||
#define TK_EVERY 262
|
||||
#define TK_ORDER 263
|
||||
#define TK_SLIMIT 264
|
||||
#define TK_SOFFSET 265
|
||||
#define TK_LIMIT 266
|
||||
#define TK_OFFSET 267
|
||||
#define TK_ASC 268
|
||||
#define TK_NULLS 269
|
||||
#define TK_ABORT 270
|
||||
#define TK_AFTER 271
|
||||
#define TK_ATTACH 272
|
||||
#define TK_BEFORE 273
|
||||
#define TK_BEGIN 274
|
||||
#define TK_BITAND 275
|
||||
#define TK_BITNOT 276
|
||||
#define TK_BITOR 277
|
||||
#define TK_BLOCKS 278
|
||||
#define TK_CHANGE 279
|
||||
#define TK_COMMA 280
|
||||
#define TK_COMPACT 281
|
||||
#define TK_CONCAT 282
|
||||
#define TK_CONFLICT 283
|
||||
#define TK_COPY 284
|
||||
#define TK_DEFERRED 285
|
||||
#define TK_DELIMITERS 286
|
||||
#define TK_DETACH 287
|
||||
#define TK_DIVIDE 288
|
||||
#define TK_DOT 289
|
||||
#define TK_EACH 290
|
||||
#define TK_FAIL 291
|
||||
#define TK_FILE 292
|
||||
#define TK_FOR 293
|
||||
#define TK_GLOB 294
|
||||
#define TK_ID 295
|
||||
#define TK_IMMEDIATE 296
|
||||
#define TK_IMPORT 297
|
||||
#define TK_INITIALLY 298
|
||||
#define TK_INSTEAD 299
|
||||
#define TK_ISNULL 300
|
||||
#define TK_KEY 301
|
||||
#define TK_MODULES 302
|
||||
#define TK_NK_BITNOT 303
|
||||
#define TK_NK_SEMI 304
|
||||
#define TK_NOTNULL 305
|
||||
#define TK_OF 306
|
||||
#define TK_PLUS 307
|
||||
#define TK_PRIVILEGE 308
|
||||
#define TK_RAISE 309
|
||||
#define TK_REPLACE 310
|
||||
#define TK_RESTRICT 311
|
||||
#define TK_ROW 312
|
||||
#define TK_SEMI 313
|
||||
#define TK_STAR 314
|
||||
#define TK_STATEMENT 315
|
||||
#define TK_STRICT 316
|
||||
#define TK_STRING 317
|
||||
#define TK_TIMES 318
|
||||
#define TK_UPDATE 319
|
||||
|
|
|
@ -58,8 +58,7 @@ typedef enum {
|
|||
#define QUERY_RSP_POLICY_QUICK 1
|
||||
|
||||
#define QUERY_MSG_MASK_SHOW_REWRITE() (1 << 0)
|
||||
#define TEST_SHOW_REWRITE_MASK(m) (((m) & QUERY_MSG_MASK_SHOW_REWRITE()) != 0)
|
||||
|
||||
#define TEST_SHOW_REWRITE_MASK(m) (((m)&QUERY_MSG_MASK_SHOW_REWRITE()) != 0)
|
||||
|
||||
typedef struct STableComInfo {
|
||||
uint8_t numOfTags; // the number of tags in schema
|
||||
|
@ -128,7 +127,7 @@ typedef struct SDBVgInfo {
|
|||
int8_t hashMethod;
|
||||
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
|
||||
int64_t stateTs;
|
||||
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
||||
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
||||
SArray* vgArray;
|
||||
} SDBVgInfo;
|
||||
|
||||
|
@ -262,23 +261,26 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
(NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \
|
||||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||
|
||||
#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR || (_code) == TSDB_CODE_VND_STOPPED || (_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
||||
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
|
||||
#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR || \
|
||||
(_code) == TSDB_CODE_VND_STOPPED || (_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
||||
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
|
||||
|
||||
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
||||
|
||||
#define NEED_REDIRECT_ERROR(_code) \
|
||||
#define NEED_REDIRECT_ERROR(_code) \
|
||||
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code))
|
||||
|
||||
|
||||
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
||||
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
||||
(_type) == TDMT_MND_DROP_STB)
|
||||
|
||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||
(SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code))
|
||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||
(SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_OTHER_LEADER_REDIRECT_ERROR(_code))
|
||||
|
||||
#define REQUEST_TOTAL_EXEC_TIMES 2
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -342,6 +342,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2)
|
||||
#define TSDB_CODE_MND_STREAM_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03F3)
|
||||
#define TSDB_CODE_MND_STREAM_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x03F4)
|
||||
#define TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB TAOS_DEF_ERROR_CODE(0, 0x03F5)
|
||||
|
||||
// mnode-sma
|
||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
(*pRequest)->body.param = param;
|
||||
|
||||
STscObj* pTscObj = (*pRequest)->pTscObj;
|
||||
int32_t err = 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);
|
||||
|
@ -1646,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;
|
||||
|
@ -1972,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) {
|
||||
|
@ -2295,14 +2294,14 @@ 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;
|
||||
} else {
|
||||
taosMemoryFree(param);
|
||||
}
|
||||
|
||||
|
||||
return pRequest;
|
||||
}
|
||||
|
||||
|
@ -2318,13 +2317,13 @@ 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;
|
||||
} else {
|
||||
taosMemoryFree(param);
|
||||
}
|
||||
|
||||
|
||||
return pRequest;
|
||||
}
|
||||
|
|
|
@ -1035,7 +1035,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
SCMSubscribeReq req = {0};
|
||||
int32_t code = -1;
|
||||
|
||||
tscDebug("call tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz);
|
||||
tscDebug("tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz);
|
||||
|
||||
req.consumerId = tmq->consumerId;
|
||||
tstrncpy(req.clientId, tmq->clientId, 256);
|
||||
|
@ -1043,7 +1043,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
req.topicNames = taosArrayInit(sz, sizeof(void*));
|
||||
if (req.topicNames == NULL) goto FAIL;
|
||||
|
||||
tscDebug("call tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz);
|
||||
tscDebug("tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz);
|
||||
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char* topic = taosArrayGetP(container, i);
|
||||
|
@ -1570,7 +1570,6 @@ SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
|||
}
|
||||
|
||||
int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
||||
/*tscDebug("call poll");*/
|
||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||
|
@ -1794,7 +1793,6 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
}
|
||||
|
||||
TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||
/*tscDebug("call poll1");*/
|
||||
void* rspObj;
|
||||
int64_t startTime = taosGetTimestampMs();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -214,6 +214,9 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
|||
case SNODE:
|
||||
terrno = TSDB_CODE_SNODE_NOT_FOUND;
|
||||
break;
|
||||
case VNODE:
|
||||
terrno = TSDB_CODE_VND_STOPPED;
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_APP_IS_STOPPING;
|
||||
break;
|
||||
|
|
|
@ -145,7 +145,8 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
if (pMsg == NULL) goto _OVER;
|
||||
|
||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||
dGTrace("msg:%p, is created, type:%s handle:%p len:%d", pMsg, TMSG_INFO(pRpc->msgType), pMsg->info.handle, pRpc->contLen);
|
||||
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);
|
||||
|
|
|
@ -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,21 +1303,22 @@ 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) {
|
||||
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
||||
|
||||
|
||||
mndBuildDBVgroupInfo(NULL, pMnode, usedbRsp.pVgroupInfos);
|
||||
usedbRsp.vgVersion = vgVersion++;
|
||||
} else {
|
||||
usedbRsp.vgVersion = pDbVgVersion->vgVersion;
|
||||
}
|
||||
usedbRsp.vgNum = taosArrayGetSize(usedbRsp.pVgroupInfos);
|
||||
|
||||
|
||||
taosArrayPush(batchUseRsp.pArray, &usedbRsp);
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
|
|
@ -672,6 +672,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
|||
snprintf(ep, TSDB_EP_LEN, "%s:%d", createReq.fqdn, createReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode != NULL) {
|
||||
terrno = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -648,7 +663,9 @@ _OVER:
|
|||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
SEpSet epSet = {0};
|
||||
int32_t tmpCode = terrno;
|
||||
mndGetMnodeEpSet(pMnode, &epSet);
|
||||
terrno = tmpCode;
|
||||
|
||||
mGDebug(
|
||||
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
|
||||
|
|
|
@ -164,7 +164,8 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
|
|||
STREAM_DECODE_OVER:
|
||||
taosMemoryFreeClear(buf);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
mError("stream:%s, failed to decode from raw:%p since %s", pStream == NULL ? "null" : pStream->name, pRaw, terrstr());
|
||||
mError("stream:%s, failed to decode from raw:%p since %s", pStream == NULL ? "null" : pStream->name, pRaw,
|
||||
terrstr());
|
||||
taosMemoryFreeClear(pRow);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -624,6 +625,16 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
pDb = mndAcquireDb(pMnode, streamObj.sourceDb);
|
||||
if (pDb->cfg.replications != 1) {
|
||||
mError("stream source db must have only 1 replica, but %s has %d", pDb->name, pDb->cfg.replications);
|
||||
terrno = TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB;
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
pDb = NULL;
|
||||
goto _OVER;
|
||||
}
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "create-stream");
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||
|
@ -680,7 +691,6 @@ _OVER:
|
|||
}
|
||||
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
|
||||
tFreeSCMCreateStreamReq(&createStreamReq);
|
||||
tFreeStreamObj(&streamObj);
|
||||
|
|
|
@ -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());
|
||||
|
@ -919,7 +927,8 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
} else {
|
||||
if (pTrans->stage == TRN_STAGE_REDO_ACTION) {
|
||||
if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_APP_IS_STARTING) {
|
||||
if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_APP_IS_STARTING ||
|
||||
code == TSDB_CODE_SYN_PROPOSE_NOT_READY) {
|
||||
if (pTrans->failedTimes > 60) sendRsp = true;
|
||||
} else {
|
||||
if (pTrans->failedTimes > 6) sendRsp = true;
|
||||
|
@ -1027,6 +1036,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 +1248,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 +1299,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);
|
||||
|
@ -1324,6 +1337,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
|
||||
if (mndCannotExecuteTransAction(pMnode)) return false;
|
||||
terrno = code;
|
||||
|
||||
if (code == 0) {
|
||||
pTrans->code = 0;
|
||||
|
|
|
@ -1126,8 +1126,12 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
}
|
||||
|
||||
if (!force) {
|
||||
#if 1
|
||||
{
|
||||
#else
|
||||
if (newVg.replica == 1) {
|
||||
mInfo("vgId:%d, will add 1 vnode, replca:1", pVgroup->vgId);
|
||||
#endif
|
||||
mInfo("vgId:%d, will add 1 vnode, replca:%d", pVgroup->vgId, newVg.replica);
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||
for (int32_t i = 0; i < newVg.replica - 1; ++i) {
|
||||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
|
@ -1155,6 +1159,9 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg, newVg.vnodeGid[i].dnodeId) != 0) return -1;
|
||||
}
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
#if 1
|
||||
}
|
||||
#else
|
||||
} else { // new replica == 3
|
||||
mInfo("vgId:%d, will add 1 vnode, replca:3", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||
|
@ -1181,6 +1188,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
|||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[vnIndex]) != 0) return -1;
|
||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
mInfo("vgId:%d, will add 1 vnode and force remove 1 vnode", pVgroup->vgId);
|
||||
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg, pArray) != 0) return -1;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -87,17 +87,24 @@ typedef struct SCommitInfo SCommitInfo;
|
|||
#define VNODE_RSMA1_DIR "rsma1"
|
||||
#define VNODE_RSMA2_DIR "rsma2"
|
||||
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
|
||||
// vnd.h
|
||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||
int vnodeDecodeInfo(uint8_t* pData, SVnodeInfo* pInfo);
|
||||
|
||||
// meta
|
||||
typedef struct SMCtbCursor SMCtbCursor;
|
||||
typedef struct SMStbCursor SMStbCursor;
|
||||
typedef struct STbUidStore STbUidStore;
|
||||
|
||||
#define META_BEGIN_HEAP_BUFFERPOOL 0
|
||||
#define META_BEGIN_HEAP_OS 1
|
||||
#define META_BEGIN_HEAP_NIL 2
|
||||
|
||||
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
|
||||
int metaClose(SMeta* pMeta);
|
||||
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
||||
|
@ -105,6 +112,7 @@ TXN* metaGetTxn(SMeta* pMeta);
|
|||
int metaCommit(SMeta* pMeta, TXN* txn);
|
||||
int metaFinishCommit(SMeta* pMeta, TXN* txn);
|
||||
int metaPrepareAsyncCommit(SMeta* pMeta);
|
||||
int metaAbort(SMeta* pMeta);
|
||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq, SArray* tbUidList);
|
||||
|
@ -238,6 +246,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData);
|
|||
// STsdbSnapWriter ========================================
|
||||
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter);
|
||||
int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
|
||||
int32_t tsdbSnapWriterPrepareClose(STsdbSnapWriter* pWriter);
|
||||
int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback);
|
||||
// STqSnapshotReader ==
|
||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapReader** ppReader);
|
||||
|
@ -344,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)
|
||||
|
|
|
@ -19,19 +19,21 @@ static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) { return vnodeBuf
|
|||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
|
||||
// begin a meta txn
|
||||
int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
||||
void *(*xMalloc)(void *, size_t);
|
||||
void (*xFree)(void *, void *);
|
||||
int metaBegin(SMeta *pMeta, int8_t heap) {
|
||||
void *(*xMalloc)(void *, size_t) = NULL;
|
||||
void (*xFree)(void *, void *) = NULL;
|
||||
void *xArg = NULL;
|
||||
|
||||
if (fromSys) {
|
||||
// default heap to META_BEGIN_HEAP_NIL
|
||||
if (heap == META_BEGIN_HEAP_OS) {
|
||||
xMalloc = tdbDefaultMalloc;
|
||||
xFree = tdbDefaultFree;
|
||||
} else {
|
||||
} else if (heap == META_BEGIN_HEAP_BUFFERPOOL) {
|
||||
xMalloc = metaMalloc;
|
||||
xFree = metaFree;
|
||||
xArg = pMeta->pVnode->inUse;
|
||||
}
|
||||
|
||||
if (tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
metaBegin(pMeta, 1);
|
||||
metaBegin(pMeta, META_BEGIN_HEAP_NIL);
|
||||
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
@ -161,7 +161,8 @@ int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) {
|
|||
SMetaSnapWriter* pWriter = *ppWriter;
|
||||
|
||||
if (rollback) {
|
||||
ASSERT(0);
|
||||
code = metaAbort(pWriter->pMeta);
|
||||
if (code) goto _err;
|
||||
} else {
|
||||
code = metaCommit(pWriter->pMeta, pWriter->pMeta->txn);
|
||||
if (code) goto _err;
|
||||
|
|
|
@ -738,7 +738,7 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgL
|
|||
|
||||
code = tqOffsetDelete(pTq->pOffsetStore, pReq->subKey);
|
||||
if (code != 0) {
|
||||
tqError("cannot process tq delete req %s, since no such offset", pReq->subKey);
|
||||
tqError("cannot process tq delete req %s, since no such offset in cache", pReq->subKey);
|
||||
}
|
||||
|
||||
if (tqMetaDeleteHandle(pTq, pReq->subKey) < 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);
|
||||
|
|
|
@ -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);
|
||||
|
@ -3622,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;
|
||||
|
@ -3669,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;
|
||||
}
|
||||
|
|
|
@ -1376,27 +1376,34 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbSnapWriterPrepareClose(STsdbSnapWriter* pWriter) {
|
||||
int32_t code = 0;
|
||||
if (pWriter->dWriter.pWriter) {
|
||||
code = tsdbSnapWriteCloseFile(pWriter);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
|
||||
code = tsdbSnapWriteDelEnd(pWriter);
|
||||
if (code) goto _exit;
|
||||
|
||||
code = tsdbFSPrepareCommit(pWriter->pTsdb, &pWriter->fs);
|
||||
if (code) goto _exit;
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
||||
int32_t code = 0;
|
||||
STsdbSnapWriter* pWriter = *ppWriter;
|
||||
STsdb* pTsdb = pWriter->pTsdb;
|
||||
|
||||
if (rollback) {
|
||||
ASSERT(0);
|
||||
// code = tsdbFSRollback(pWriter->pTsdb->pFS);
|
||||
// if (code) goto _err;
|
||||
tsdbRollbackCommit(pWriter->pTsdb);
|
||||
} else {
|
||||
if (pWriter->dWriter.pWriter) {
|
||||
code = tsdbSnapWriteCloseFile(pWriter);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
code = tsdbSnapWriteDelEnd(pWriter);
|
||||
if (code) goto _err;
|
||||
|
||||
code = tsdbFSPrepareCommit(pWriter->pTsdb, &pWriter->fs);
|
||||
if (code) goto _err;
|
||||
|
||||
// lock
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
|
||||
|
|
|
@ -115,7 +115,6 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
|||
if (tjsonAddIntegerToObject(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "hashPrefix", pCfg->hashPrefix) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "hashSuffix", pCfg->hashSuffix) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "tsdbPageSize", pCfg->tsdbPageSize) < 0) return -1;
|
||||
|
||||
if (tjsonAddIntegerToObject(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "syncCfg.myIndex", pCfg->syncCfg.myIndex) < 0) return -1;
|
||||
|
@ -135,9 +134,6 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
|||
tjsonAddItemToArray(pNodeInfoArr, pNodeInfo);
|
||||
}
|
||||
|
||||
// add tsdb page size config
|
||||
if (tjsonAddIntegerToObject(pJson, "tsdbPageSize", pCfg->tsdbPageSize) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -256,7 +252,9 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
}
|
||||
|
||||
tjsonGetNumberValue(pJson, "tsdbPageSize", pCfg->tsdbPageSize, code);
|
||||
if (code < 0) pCfg->tsdbPageSize = TSDB_DEFAULT_TSDB_PAGESIZE * 1024;
|
||||
if (code < 0 || pCfg->tsdbPageSize < TSDB_MIN_PAGESIZE_PER_VNODE * 1024) {
|
||||
pCfg->tsdbPageSize = TSDB_DEFAULT_TSDB_PAGESIZE * 1024;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
#include "vnd.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||
|
||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo);
|
||||
static int vnodeCommitImpl(SCommitInfo *pInfo);
|
||||
|
||||
int vnodeBegin(SVnode *pVnode) {
|
||||
|
@ -40,7 +38,7 @@ int vnodeBegin(SVnode *pVnode) {
|
|||
|
||||
pVnode->state.commitID++;
|
||||
// begin meta
|
||||
if (metaBegin(pVnode->pMeta, 0) < 0) {
|
||||
if (metaBegin(pVnode->pMeta, META_BEGIN_HEAP_BUFFERPOOL) < 0) {
|
||||
vError("vgId:%d, failed to begin meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -407,7 +405,7 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) {
|
||||
int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) {
|
||||
SJson *pJson = NULL;
|
||||
|
||||
pJson = tjsonParse(pData);
|
||||
|
|
|
@ -21,6 +21,8 @@ struct SVSnapReader {
|
|||
int64_t sver;
|
||||
int64_t ever;
|
||||
int64_t index;
|
||||
// config
|
||||
int8_t cfgDone;
|
||||
// meta
|
||||
int8_t metaDone;
|
||||
SMetaSnapReader *pMetaReader;
|
||||
|
@ -88,6 +90,53 @@ int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
|||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
||||
int32_t code = 0;
|
||||
|
||||
// CONFIG ==============
|
||||
// FIXME: if commit multiple times and the config changed?
|
||||
if (!pReader->cfgDone) {
|
||||
char fName[TSDB_FILENAME_LEN];
|
||||
if (pReader->pVnode->pTfs) {
|
||||
snprintf(fName, TSDB_FILENAME_LEN, "%s%s%s%s%s", tfsGetPrimaryPath(pReader->pVnode->pTfs), TD_DIRSEP,
|
||||
pReader->pVnode->path, TD_DIRSEP, VND_INFO_FNAME);
|
||||
} else {
|
||||
snprintf(fName, TSDB_FILENAME_LEN, "%s%s%s", pReader->pVnode->path, TD_DIRSEP, VND_INFO_FNAME);
|
||||
}
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(fName, TD_FILE_READ);
|
||||
if (NULL == pFile) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
int64_t size;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosCloseFile(&pFile);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1);
|
||||
if (*ppData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosCloseFile(&pFile);
|
||||
goto _err;
|
||||
}
|
||||
((SSnapDataHdr *)(*ppData))->type = SNAP_DATA_CFG;
|
||||
((SSnapDataHdr *)(*ppData))->size = size + 1;
|
||||
((SSnapDataHdr *)(*ppData))->data[size] = '\0';
|
||||
|
||||
if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(*ppData);
|
||||
taosCloseFile(&pFile);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
pReader->cfgDone = 1;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// META ==============
|
||||
if (!pReader->metaDone) {
|
||||
// open reader if not
|
||||
|
@ -230,6 +279,8 @@ struct SVSnapWriter {
|
|||
int64_t ever;
|
||||
int64_t commitID;
|
||||
int64_t index;
|
||||
// config
|
||||
SVnodeInfo info;
|
||||
// meta
|
||||
SMetaSnapWriter *pMetaSnapWriter;
|
||||
// tsdb
|
||||
|
@ -248,6 +299,10 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
|||
int32_t code = 0;
|
||||
SVSnapWriter *pWriter = NULL;
|
||||
|
||||
// commit memory data
|
||||
vnodeAsyncCommit(pVnode);
|
||||
tsem_wait(&pVnode->canCommit);
|
||||
|
||||
// alloc
|
||||
pWriter = (SVSnapWriter *)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
|
@ -258,16 +313,8 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
// commit it
|
||||
code = vnodeSyncCommit(pVnode);
|
||||
if (code) {
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// inc commit ID
|
||||
pVnode->state.commitID++;
|
||||
pWriter->commitID = pVnode->state.commitID;
|
||||
pWriter->commitID = ++pVnode->state.commitID;
|
||||
|
||||
vInfo("vgId:%d, vnode snapshot writer opened, sver:%" PRId64 " ever:%" PRId64 " commit id:%" PRId64, TD_VID(pVnode),
|
||||
sver, ever, pWriter->commitID);
|
||||
|
@ -284,53 +331,89 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
|||
int32_t code = 0;
|
||||
SVnode *pVnode = pWriter->pVnode;
|
||||
|
||||
// prepare
|
||||
if (pWriter->pTsdbSnapWriter) {
|
||||
tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter);
|
||||
}
|
||||
|
||||
// commit json
|
||||
if (!rollback) {
|
||||
pVnode->config = pWriter->info.config;
|
||||
pVnode->state = (SVState){.committed = pWriter->info.state.committed,
|
||||
.applied = pWriter->info.state.committed,
|
||||
.commitID = pWriter->commitID,
|
||||
.commitTerm = pWriter->info.state.commitTerm,
|
||||
.applyTerm = pWriter->info.state.commitTerm};
|
||||
pVnode->statis = pWriter->info.statis;
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
if (pWriter->pVnode->pTfs) {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
} else {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pWriter->pVnode->path);
|
||||
}
|
||||
|
||||
vnodeCommitInfo(dir, &pWriter->info);
|
||||
} else {
|
||||
vnodeRollback(pWriter->pVnode);
|
||||
}
|
||||
|
||||
// commit/rollback sub-system
|
||||
if (pWriter->pMetaSnapWriter) {
|
||||
code = metaSnapWriterClose(&pWriter->pMetaSnapWriter, rollback);
|
||||
if (code) goto _err;
|
||||
if (code) goto _exit;
|
||||
}
|
||||
|
||||
if (pWriter->pTsdbSnapWriter) {
|
||||
code = tsdbSnapWriterClose(&pWriter->pTsdbSnapWriter, rollback);
|
||||
if (code) goto _err;
|
||||
if (code) goto _exit;
|
||||
}
|
||||
|
||||
if (pWriter->pRsmaSnapWriter) {
|
||||
code = rsmaSnapWriterClose(&pWriter->pRsmaSnapWriter, rollback);
|
||||
if (code) goto _err;
|
||||
if (code) goto _exit;
|
||||
}
|
||||
|
||||
if (!rollback) {
|
||||
SVnodeInfo info = {0};
|
||||
char dir[TSDB_FILENAME_LEN];
|
||||
vnodeBegin(pVnode);
|
||||
|
||||
pVnode->state.committed = pWriter->ever;
|
||||
pVnode->state.applied = pWriter->ever;
|
||||
pVnode->state.applyTerm = pSnapshot->lastApplyTerm;
|
||||
pVnode->state.commitTerm = pSnapshot->lastApplyTerm;
|
||||
|
||||
info.config = pVnode->config;
|
||||
info.state.committed = pVnode->state.applied;
|
||||
info.state.commitTerm = pVnode->state.applyTerm;
|
||||
info.state.commitID = pVnode->state.commitID;
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
code = vnodeSaveInfo(dir, &info);
|
||||
if (code) goto _err;
|
||||
|
||||
code = vnodeCommitInfo(dir, &info);
|
||||
if (code) goto _err;
|
||||
|
||||
vnodeBegin(pVnode);
|
||||
_exit:
|
||||
if (code) {
|
||||
vError("vgId:%d, vnode snapshot writer close failed since %s", TD_VID(pWriter->pVnode), tstrerror(code));
|
||||
} else {
|
||||
ASSERT(0);
|
||||
vInfo("vgId:%d, vnode snapshot writer closed, rollback:%d", TD_VID(pVnode), rollback);
|
||||
taosMemoryFree(pWriter);
|
||||
}
|
||||
tsem_post(&pVnode->canCommit);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
||||
int32_t code = 0;
|
||||
|
||||
SSnapDataHdr *pHdr = (SSnapDataHdr *)pData;
|
||||
|
||||
// decode info
|
||||
if (vnodeDecodeInfo(pHdr->data, &pWriter->info) < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// change some value
|
||||
pWriter->info.state.commitID = pWriter->commitID;
|
||||
|
||||
// modify info as needed
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
if (pWriter->pVnode->pTfs) {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pWriter->pVnode->pTfs), TD_DIRSEP,
|
||||
pWriter->pVnode->path);
|
||||
} else {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pWriter->pVnode->path);
|
||||
}
|
||||
if (vnodeSaveInfo(dir, &pWriter->info) < 0) {
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
vInfo("vgId:%d, vnode snapshot writer closed, rollback:%d", TD_VID(pVnode), rollback);
|
||||
taosMemoryFree(pWriter);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
vError("vgId:%d, vnode snapshot writer close failed since %s", TD_VID(pWriter->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -347,6 +430,10 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
|||
pHdr->type, nData);
|
||||
|
||||
switch (pHdr->type) {
|
||||
case SNAP_DATA_CFG: {
|
||||
code = vnodeSnapWriteInfo(pWriter, pData, nData);
|
||||
if (code) goto _err;
|
||||
} break;
|
||||
case SNAP_DATA_META: {
|
||||
// meta
|
||||
if (pWriter->pMetaSnapWriter == NULL) {
|
||||
|
|
|
@ -317,11 +317,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
// commit if need
|
||||
if (vnodeShouldCommit(pVnode)) {
|
||||
vInfo("vgId:%d, commit at version %" PRId64, TD_VID(pVnode), version);
|
||||
#if 0
|
||||
vnodeSyncCommit(pVnode);
|
||||
#else
|
||||
vnodeAsyncCommit(pVnode);
|
||||
#endif
|
||||
|
||||
// start a new one
|
||||
if (vnodeBegin(pVnode) < 0) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -698,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;
|
||||
|
||||
|
@ -960,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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -409,15 +417,14 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
if (msgInfo->rpcType == UDFD_RPC_MNODE_CONNECT) {
|
||||
SConnectRsp connectRsp = {0};
|
||||
tDeserializeSConnectRsp(pMsg->pCont, pMsg->contLen, &connectRsp);
|
||||
|
||||
|
||||
int32_t now = taosGetTimestampSec();
|
||||
int32_t delta = abs(now - connectRsp.svrTimestamp);
|
||||
if (delta > 900) {
|
||||
msgInfo->code = TSDB_CODE_TIME_UNSYNCED;
|
||||
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,9 +608,10 @@ 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;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -663,7 +671,7 @@ int32_t udfdOpenClientRpc() {
|
|||
rpcInit.parent = &global;
|
||||
rpcInit.rfp = udfdRpcRfp;
|
||||
rpcInit.compressSize = tsCompressMsgSize;
|
||||
|
||||
|
||||
global.clientRpc = rpcOpen(&rpcInit);
|
||||
if (global.clientRpc == NULL) {
|
||||
fnError("failed to init dnode rpc client");
|
||||
|
@ -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); }
|
||||
|
@ -1069,5 +1069,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.
|
||||
|
|
|
@ -1411,6 +1411,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
(*pNumOfRows) = 0;
|
||||
char* pLine = NULL;
|
||||
int64_t readLen = 0;
|
||||
bool firstLine = (pStmt->fileProcessing == false);
|
||||
pStmt->fileProcessing = false;
|
||||
while (TSDB_CODE_SUCCESS == code && (readLen = taosGetLineFile(pStmt->fp, &pLine)) != -1) {
|
||||
if (('\r' == pLine[readLen - 1]) || ('\n' == pLine[readLen - 1])) {
|
||||
|
@ -1418,6 +1419,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
}
|
||||
|
||||
if (readLen == 0) {
|
||||
firstLine = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1431,6 +1433,11 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
strtolower(pLine, pLine);
|
||||
const char* pRow = pLine;
|
||||
code = parseOneRow(pCxt, (const char**)&pRow, pDataBuf, &gotRow, &token);
|
||||
if (code && firstLine) {
|
||||
firstLine = false;
|
||||
code = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && gotRow) {
|
||||
|
@ -1442,6 +1449,8 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
pStmt->fileProcessing = true;
|
||||
break;
|
||||
}
|
||||
|
||||
firstLine = false;
|
||||
}
|
||||
taosMemoryFree(pLine);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -3899,8 +3903,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]))) {
|
||||
|
@ -4055,7 +4058,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);
|
||||
|
@ -5515,9 +5518,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;
|
||||
|
@ -5527,7 +5545,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);
|
||||
|
@ -5535,6 +5553,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;
|
||||
|
@ -5637,7 +5666,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 3000
|
||||
#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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
sError("no message handle 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;
|
||||
|
|
|
@ -35,11 +35,16 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) {
|
|||
pObj->seqNum = 0;
|
||||
taosThreadMutexInit(&(pObj->mutex), NULL);
|
||||
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, create resp manager", pNode->vgId);
|
||||
return pObj;
|
||||
}
|
||||
|
||||
void syncRespMgrDestroy(SSyncRespMgr *pObj) {
|
||||
if (pObj != NULL) {
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, destroy resp manager", pNode->vgId);
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
taosHashCleanup(pObj->pRespHash);
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
|
@ -81,6 +86,8 @@ int32_t syncRespMgrGet(SSyncRespMgr *pObj, uint64_t seq, SRespStub *pStub) {
|
|||
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
return 1; // get one object
|
||||
} else {
|
||||
sNError(pObj->data, "get message handle, no object of seq:%" PRIu64, seq);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
|
@ -99,6 +106,8 @@ int32_t syncRespMgrGetAndDel(SSyncRespMgr *pObj, uint64_t seq, SRpcHandleInfo *p
|
|||
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
return 1; // get one object
|
||||
} else {
|
||||
sNError(pObj->data, "get-and-del message handle, no object of seq:%" PRIu64, seq);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
|
@ -114,7 +123,7 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
|
|||
SArray *delIndexArray = taosArrayInit(4, sizeof(uint64_t));
|
||||
if (delIndexArray == NULL) return;
|
||||
|
||||
sDebug("vgId:%d, resp mgr begin clean by ttl", pSyncNode->vgId);
|
||||
sDebug("vgId:%d, resp manager begin clean by ttl", pSyncNode->vgId);
|
||||
while (pStub) {
|
||||
size_t len;
|
||||
void *key = taosHashGetKey(pStub, &len);
|
||||
|
@ -143,34 +152,39 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
|
|||
|
||||
// TODO: and make rpcMsg body, call commit cb
|
||||
// pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &pStub->rpcMsg, cbMeta);
|
||||
|
||||
pStub->rpcMsg.code = TSDB_CODE_SYN_NOT_LEADER;
|
||||
if (pStub->rpcMsg.info.handle != NULL) {
|
||||
tmsgSendRsp(&pStub->rpcMsg);
|
||||
}
|
||||
SRpcMsg rpcMsg = {.info = pStub->rpcMsg.info, .code = TSDB_CODE_SYN_TIMEOUT};
|
||||
sInfo("vgId:%d, message handle:%p expired, type:%s ahandle:%p", pSyncNode->vgId, rpcMsg.info.handle,
|
||||
TMSG_INFO(pStub->rpcMsg.msgType), rpcMsg.info.ahandle);
|
||||
rpcSendResponse(&rpcMsg);
|
||||
}
|
||||
|
||||
pStub = taosHashIterate(pObj->pRespHash, pStub);
|
||||
}
|
||||
|
||||
int32_t arraySize = taosArrayGetSize(delIndexArray);
|
||||
sDebug("vgId:%d, resp mgr end clean by ttl, sum:%d, cnt:%d, array-size:%d", pSyncNode->vgId, sum, cnt, arraySize);
|
||||
sDebug("vgId:%d, resp manager end clean by ttl, sum:%d, cnt:%d, array-size:%d", pSyncNode->vgId, sum, cnt, arraySize);
|
||||
|
||||
for (int32_t i = 0; i < arraySize; ++i) {
|
||||
uint64_t *pSeqNum = taosArrayGet(delIndexArray, i);
|
||||
taosHashRemove(pObj->pRespHash, pSeqNum, sizeof(uint64_t));
|
||||
sDebug("vgId:%d, resp mgr clean by ttl, seq:%" PRId64 "", pSyncNode->vgId, *pSeqNum);
|
||||
sDebug("vgId:%d, resp manager clean by ttl, seq:%" PRId64, pSyncNode->vgId, *pSeqNum);
|
||||
}
|
||||
taosArrayDestroy(delIndexArray);
|
||||
}
|
||||
|
||||
void syncRespCleanRsp(SSyncRespMgr *pObj) {
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, clean all rsp", pNode->vgId);
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
syncRespCleanByTTL(pObj, -1, true);
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
}
|
||||
|
||||
void syncRespClean(SSyncRespMgr *pObj) {
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, clean rsp by ttl", pNode->vgId);
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
syncRespCleanByTTL(pObj, pObj->ttl, false);
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
@ -1595,7 +1598,7 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
} else if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_INTERNAL_ERROR ||
|
||||
code == TSDB_CODE_SYN_PROPOSE_NOT_READY || code == TSDB_CODE_VND_STOPPED ||
|
||||
code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
||||
code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
code == TSDB_CODE_APP_IS_STOPPING || code == TSDB_CODE_VND_STOPPED) {
|
||||
tTrace("code str %s, contlen:%d 1", tstrerror(code), pResp->contLen);
|
||||
noDelay = cliResetEpset(pCtx, pResp, true);
|
||||
transFreeMsg(pResp->pCont);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -464,7 +464,9 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
|||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockWrlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if (pFile->fd < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t nleft = count;
|
||||
int64_t nwritten = 0;
|
||||
|
|
|
@ -489,11 +489,11 @@ int32_t taosGetCpuInstructions(char* sse42, char* avx, char* avx2, char* fma) {
|
|||
#ifdef _TD_X86_
|
||||
// Since the compiler is not support avx/avx2 instructions, the global variables always need to be
|
||||
// set to be false
|
||||
#if __AVX__ || __AVX2__
|
||||
tsSIMDEnable = true;
|
||||
#else
|
||||
tsSIMDEnable = false;
|
||||
#endif
|
||||
//#if __AVX__ || __AVX2__
|
||||
// tsSIMDBuiltins = true;
|
||||
//#else
|
||||
// tsSIMDBuiltins = false;
|
||||
//#endif
|
||||
|
||||
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
|
||||
|
||||
|
|
|
@ -281,6 +281,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_ALREADY_EXIST, "Stream already exists
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_NOT_EXIST, "Stream not exist")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_OPTION, "Invalid stream option")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_MUST_BE_DELETED, "Stream must be dropped first")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB, "Stream temporarily does not support source db having replica > 1")
|
||||
|
||||
// mnode-sma
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_ALREADY_EXIST, "SMA already exists")
|
||||
|
|
|
@ -445,6 +445,9 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) {
|
|||
static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *buffer, int32_t len) {
|
||||
if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile != NULL && osLogSpaceAvailable()) {
|
||||
taosUpdateLogNums(level);
|
||||
#if 0
|
||||
// DEBUG_FATAL and DEBUG_ERROR are duplicated
|
||||
// fsync will cause thread blocking and may also generate log misalignment in case of asyncLog
|
||||
if (tsAsyncLog && level != DEBUG_FATAL) {
|
||||
taosPushLogBuffer(tsLogObj.logHandle, buffer, len);
|
||||
} else {
|
||||
|
@ -453,6 +456,13 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b
|
|||
taosFsyncFile(tsLogObj.logHandle->pFile);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (tsAsyncLog) {
|
||||
taosPushLogBuffer(tsLogObj.logHandle, buffer, len);
|
||||
} else {
|
||||
taosWriteFile(tsLogObj.logHandle->pFile, buffer, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tsLogObj.maxLines > 0) {
|
||||
atomic_add_fetch_32(&tsLogObj.lines, 1);
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
,,y,script,./test.sh -f tsim/query/scalarNull.sim
|
||||
,,y,script,./test.sh -f tsim/query/session.sim
|
||||
,,y,script,./test.sh -f tsim/query/udf.sim
|
||||
,,y,script,./test.sh -f tsim/query/udf_with_const.sim
|
||||
,,y,script,./test.sh -f tsim/qnode/basic1.sim
|
||||
,,y,script,./test.sh -f tsim/snode/basic1.sim
|
||||
,,y,script,./test.sh -f tsim/mnode/basic1.sim
|
||||
|
|
|
@ -0,0 +1,936 @@
|
|||
// sample code to verify all TDengine API
|
||||
// to compile: gcc -o apitest apitest.c -ltaos
|
||||
|
||||
#include "cJSON.h"
|
||||
#include "taoserror.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "../../include/client/taos.h"
|
||||
|
||||
static int64_t count = 10000;
|
||||
|
||||
int64_t genReqid() {
|
||||
count += 100;
|
||||
return count;
|
||||
}
|
||||
|
||||
static void prepare_data(TAOS* taos) {
|
||||
TAOS_RES* result;
|
||||
result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
result = taos_query(taos, "create database test precision 'us';");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
result = taos_query(taos, "create table meters(ts timestamp, a int) tags(area int);");
|
||||
taos_free_result(result);
|
||||
|
||||
result = taos_query(taos, "create table t0 using meters tags(0);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t1 using meters tags(1);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t2 using meters tags(2);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t3 using meters tags(3);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t4 using meters tags(4);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t5 using meters tags(5);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t6 using meters tags(6);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t7 using meters tags(7);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t8 using meters tags(8);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t9 using meters tags(9);");
|
||||
taos_free_result(result);
|
||||
|
||||
result = taos_query(taos,
|
||||
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
|
||||
" ('2020-01-01 00:01:00.000', 0)"
|
||||
" ('2020-01-01 00:02:00.000', 0)"
|
||||
" t1 values('2020-01-01 00:00:00.000', 0)"
|
||||
" ('2020-01-01 00:01:00.000', 0)"
|
||||
" ('2020-01-01 00:02:00.000', 0)"
|
||||
" ('2020-01-01 00:03:00.000', 0)"
|
||||
" t2 values('2020-01-01 00:00:00.000', 0)"
|
||||
" ('2020-01-01 00:01:00.000', 0)"
|
||||
" ('2020-01-01 00:01:01.000', 0)"
|
||||
" ('2020-01-01 00:01:02.000', 0)"
|
||||
" t3 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t4 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t5 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t6 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t7 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t8 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t9 values('2020-01-01 00:01:02.000', 0)");
|
||||
int affected = taos_affected_rows(result);
|
||||
if (affected != 18) {
|
||||
printf("\033[31m%d rows affected by last insert statement, but it should be 18\033[0m\n", affected);
|
||||
}
|
||||
taos_free_result(result);
|
||||
// super tables subscription
|
||||
usleep(1000000);
|
||||
}
|
||||
|
||||
static int print_result(TAOS_RES* res, int blockFetch) {
|
||||
TAOS_ROW row = NULL;
|
||||
int num_fields = taos_num_fields(res);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||
int nRows = 0;
|
||||
|
||||
if (blockFetch) {
|
||||
int rows = 0;
|
||||
while ((rows = taos_fetch_block(res, &row))) {
|
||||
// for (int i = 0; i < rows; i++) {
|
||||
// char temp[256];
|
||||
// taos_print_row(temp, row + i, fields, num_fields);
|
||||
// puts(temp);
|
||||
// }
|
||||
nRows += rows;
|
||||
}
|
||||
} else {
|
||||
while ((row = taos_fetch_row(res))) {
|
||||
char temp[256] = {0};
|
||||
taos_print_row(temp, row, fields, num_fields);
|
||||
puts(temp);
|
||||
nRows++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d rows consumed.\n", nRows);
|
||||
return nRows;
|
||||
}
|
||||
|
||||
static void check_row_count(int line, TAOS_RES* res, int expected) {
|
||||
int actual = print_result(res, expected % 2);
|
||||
if (actual != expected) {
|
||||
printf("\033[31mline %d: row count mismatch, expected: %d, actual: %d\033[0m\n", line, expected, actual);
|
||||
} else {
|
||||
printf("line %d: %d rows consumed as expected\n", line, actual);
|
||||
}
|
||||
}
|
||||
|
||||
static void verify_query(TAOS* taos) {
|
||||
prepare_data(taos);
|
||||
|
||||
int code = taos_load_table_info(taos, "t0,t1,t2,t3,t4,t5,t6,t7,t8,t9");
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to load table info: 0x%08x\033[0m\n", code);
|
||||
}
|
||||
|
||||
code = taos_validate_sql(taos, "select * from nonexisttable");
|
||||
if (code == 0) {
|
||||
printf("\033[31mimpossible, the table does not exists\033[0m\n");
|
||||
}
|
||||
|
||||
code = taos_validate_sql(taos, "select * from meters");
|
||||
if (code != 0) {
|
||||
printf("\033[31mimpossible, the table does exists: 0x%08x\033[0m\n", code);
|
||||
}
|
||||
|
||||
TAOS_RES* res = taos_query_with_reqid(taos, "select * from meters", genReqid());
|
||||
check_row_count(__LINE__, res, 18);
|
||||
printf("result precision is: %d\n", taos_result_precision(res));
|
||||
int c = taos_field_count(res);
|
||||
printf("field count is: %d\n", c);
|
||||
int* lengths = taos_fetch_lengths(res);
|
||||
for (int i = 0; i < c; i++) {
|
||||
printf("length of column %d is %d\n", i, lengths[i]);
|
||||
}
|
||||
taos_free_result(res);
|
||||
|
||||
res = taos_query_with_reqid(taos, "select * from t0", genReqid());
|
||||
check_row_count(__LINE__, res, 3);
|
||||
taos_free_result(res);
|
||||
|
||||
res = taos_query_with_reqid(taos, "select * from nonexisttable", genReqid());
|
||||
code = taos_errno(res);
|
||||
printf("code=%d, error msg=%s\n", code, taos_errstr(res));
|
||||
taos_free_result(res);
|
||||
|
||||
res = taos_query_with_reqid(taos, "select * from meters", genReqid());
|
||||
taos_stop_query(res);
|
||||
taos_free_result(res);
|
||||
}
|
||||
|
||||
void subscribe_callback(TAOS_SUB* tsub, TAOS_RES* res, void* param, int code) {
|
||||
int rows = print_result(res, *(int*)param);
|
||||
printf("%d rows consumed in subscribe_callback\n", rows);
|
||||
}
|
||||
|
||||
void verify_prepare(TAOS* taos) {
|
||||
TAOS_RES* result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
|
||||
usleep(100000);
|
||||
result = taos_query(taos, "create database test;");
|
||||
|
||||
int code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
return;
|
||||
}
|
||||
|
||||
taos_free_result(result);
|
||||
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
// create table
|
||||
const char* sql =
|
||||
"create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
|
||||
"binary(40), blob nchar(10))";
|
||||
result = taos_query_with_reqid(taos, sql, genReqid());
|
||||
code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
return;
|
||||
}
|
||||
taos_free_result(result);
|
||||
|
||||
// insert 10 records
|
||||
struct {
|
||||
int64_t ts;
|
||||
int8_t b;
|
||||
int8_t v1;
|
||||
int16_t v2;
|
||||
int32_t v4;
|
||||
int64_t v8;
|
||||
float f4;
|
||||
double f8;
|
||||
char bin[40];
|
||||
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;
|
||||
TAOS_STMT* stmt = taos_stmt_init(taos);
|
||||
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 = &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 = &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 = &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 = &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 = &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 = &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 = &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 = &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 = &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 = sizeof(v.blob);
|
||||
params[9].buffer = v.blob;
|
||||
params[9].length = &ncharLen;
|
||||
params[9].is_null = NULL;
|
||||
params[9].num = 1;
|
||||
|
||||
char is_null = 1;
|
||||
|
||||
sql = "insert into m1 values(?,?,?,?,?,?,?,?,?,?)";
|
||||
code = taos_stmt_prepare(stmt, sql, 0);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
v.ts = 1591060628000;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
v.ts += 1;
|
||||
for (int j = 1; j < 10; ++j) {
|
||||
params[j].is_null = ((i == j) ? &is_null : 0);
|
||||
}
|
||||
v.b = (int8_t)i % 2;
|
||||
v.v1 = (int8_t)i;
|
||||
v.v2 = (int16_t)(i * 2);
|
||||
v.v4 = (int32_t)(i * 4);
|
||||
v.v8 = (int64_t)(i * 8);
|
||||
v.f4 = (float)(i * 40);
|
||||
v.f8 = (double)(i * 80);
|
||||
for (int j = 0; j < sizeof(v.bin); ++j) {
|
||||
v.bin[j] = (char)(i + '0');
|
||||
}
|
||||
|
||||
taos_stmt_bind_param(stmt, params);
|
||||
taos_stmt_add_batch(stmt);
|
||||
}
|
||||
if (taos_stmt_execute(stmt) != 0) {
|
||||
printf("\033[31mfailed to execute insert statement.error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
taos_stmt_close(stmt);
|
||||
|
||||
// query the records
|
||||
stmt = taos_stmt_init(taos);
|
||||
taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0);
|
||||
v.v1 = 5;
|
||||
v.v2 = 15;
|
||||
taos_stmt_bind_param(stmt, params + 2);
|
||||
if (taos_stmt_execute(stmt) != 0) {
|
||||
printf("\033[31mfailed to execute select statement.error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
result = taos_stmt_use_result(stmt);
|
||||
|
||||
TAOS_ROW row;
|
||||
int rows = 0;
|
||||
int num_fields = taos_num_fields(result);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(result);
|
||||
|
||||
// fetch the records row by row
|
||||
while ((row = taos_fetch_row(result))) {
|
||||
char temp[256] = {0};
|
||||
rows++;
|
||||
taos_print_row(temp, row, fields, num_fields);
|
||||
printf("%s\n", temp);
|
||||
}
|
||||
|
||||
taos_free_result(result);
|
||||
taos_stmt_close(stmt);
|
||||
}
|
||||
|
||||
void verify_prepare2(TAOS* taos) {
|
||||
TAOS_RES* result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
result = taos_query(taos, "create database test;");
|
||||
|
||||
int code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
return;
|
||||
}
|
||||
taos_free_result(result);
|
||||
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
// create table
|
||||
const char* sql =
|
||||
"create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
|
||||
"binary(40), blob nchar(10))";
|
||||
result = taos_query(taos, sql);
|
||||
code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
return;
|
||||
}
|
||||
taos_free_result(result);
|
||||
|
||||
// insert 10 records
|
||||
struct {
|
||||
int64_t ts[10];
|
||||
int8_t b[10];
|
||||
int8_t v1[10];
|
||||
int16_t v2[10];
|
||||
int32_t v4[10];
|
||||
int64_t v8[10];
|
||||
float f4[10];
|
||||
double f8[10];
|
||||
char bin[10][40];
|
||||
char blob[10][80];
|
||||
} v;
|
||||
|
||||
int32_t* t8_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* t16_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* t32_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* t64_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* float_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* double_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* bin_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* blob_len = malloc(sizeof(int32_t) * 10);
|
||||
|
||||
TAOS_STMT* stmt = taos_stmt_init(taos);
|
||||
TAOS_MULTI_BIND params[10];
|
||||
char is_null[10] = {0};
|
||||
|
||||
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
params[0].buffer_length = sizeof(v.ts[0]);
|
||||
params[0].buffer = v.ts;
|
||||
params[0].length = t64_len;
|
||||
params[0].is_null = is_null;
|
||||
params[0].num = 10;
|
||||
|
||||
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
|
||||
params[1].buffer_length = sizeof(v.b[0]);
|
||||
params[1].buffer = v.b;
|
||||
params[1].length = t8_len;
|
||||
params[1].is_null = is_null;
|
||||
params[1].num = 10;
|
||||
|
||||
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
||||
params[2].buffer_length = sizeof(v.v1[0]);
|
||||
params[2].buffer = v.v1;
|
||||
params[2].length = t8_len;
|
||||
params[2].is_null = is_null;
|
||||
params[2].num = 10;
|
||||
|
||||
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
||||
params[3].buffer_length = sizeof(v.v2[0]);
|
||||
params[3].buffer = v.v2;
|
||||
params[3].length = t16_len;
|
||||
params[3].is_null = is_null;
|
||||
params[3].num = 10;
|
||||
|
||||
params[4].buffer_type = TSDB_DATA_TYPE_INT;
|
||||
params[4].buffer_length = sizeof(v.v4[0]);
|
||||
params[4].buffer = v.v4;
|
||||
params[4].length = t32_len;
|
||||
params[4].is_null = is_null;
|
||||
params[4].num = 10;
|
||||
|
||||
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
|
||||
params[5].buffer_length = sizeof(v.v8[0]);
|
||||
params[5].buffer = v.v8;
|
||||
params[5].length = t64_len;
|
||||
params[5].is_null = is_null;
|
||||
params[5].num = 10;
|
||||
|
||||
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
|
||||
params[6].buffer_length = sizeof(v.f4[0]);
|
||||
params[6].buffer = v.f4;
|
||||
params[6].length = float_len;
|
||||
params[6].is_null = is_null;
|
||||
params[6].num = 10;
|
||||
|
||||
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
|
||||
params[7].buffer_length = sizeof(v.f8[0]);
|
||||
params[7].buffer = v.f8;
|
||||
params[7].length = double_len;
|
||||
params[7].is_null = is_null;
|
||||
params[7].num = 10;
|
||||
|
||||
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
|
||||
params[8].buffer_length = sizeof(v.bin[0]);
|
||||
params[8].buffer = v.bin;
|
||||
params[8].length = bin_len;
|
||||
params[8].is_null = is_null;
|
||||
params[8].num = 10;
|
||||
|
||||
params[9].buffer_type = TSDB_DATA_TYPE_NCHAR;
|
||||
params[9].buffer_length = sizeof(v.blob[0]);
|
||||
params[9].buffer = v.blob;
|
||||
params[9].length = blob_len;
|
||||
params[9].is_null = is_null;
|
||||
params[9].num = 10;
|
||||
|
||||
sql = "insert into ? (ts, b, v1, v2, v4, v8, f4, f8, bin, blob) values(?,?,?,?,?,?,?,?,?,?)";
|
||||
code = taos_stmt_prepare(stmt, sql, 0);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
code = taos_stmt_set_tbname(stmt, "m1");
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t ts = 1591060628000;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
v.ts[i] = ts++;
|
||||
is_null[i] = 0;
|
||||
|
||||
v.b[i] = (int8_t)i % 2;
|
||||
v.v1[i] = (int8_t)i;
|
||||
v.v2[i] = (int16_t)(i * 2);
|
||||
v.v4[i] = (int32_t)(i * 4);
|
||||
v.v8[i] = (int64_t)(i * 8);
|
||||
v.f4[i] = (float)(i * 40);
|
||||
v.f8[i] = (double)(i * 80);
|
||||
for (int j = 0; j < sizeof(v.bin[0]); ++j) {
|
||||
v.bin[i][j] = (char)(i + '0');
|
||||
}
|
||||
strcpy(v.blob[i], "一二三四五六七八九十");
|
||||
|
||||
t8_len[i] = sizeof(int8_t);
|
||||
t16_len[i] = sizeof(int16_t);
|
||||
t32_len[i] = sizeof(int32_t);
|
||||
t64_len[i] = sizeof(int64_t);
|
||||
float_len[i] = sizeof(float);
|
||||
double_len[i] = sizeof(double);
|
||||
bin_len[i] = sizeof(v.bin[0]);
|
||||
blob_len[i] = (int32_t)strlen(v.blob[i]);
|
||||
}
|
||||
|
||||
taos_stmt_bind_param_batch(stmt, params);
|
||||
taos_stmt_add_batch(stmt);
|
||||
|
||||
if (taos_stmt_execute(stmt) != 0) {
|
||||
printf("\033[31mfailed to execute insert statement.error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
taos_stmt_close(stmt);
|
||||
|
||||
// query the records
|
||||
stmt = taos_stmt_init(taos);
|
||||
taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0);
|
||||
TAOS_MULTI_BIND qparams[2];
|
||||
|
||||
int8_t v1 = 5;
|
||||
int16_t v2 = 15;
|
||||
int32_t tinyLen = sizeof(v1);
|
||||
int32_t smallLen = sizeof(v2);
|
||||
|
||||
qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
||||
qparams[0].buffer_length = sizeof(v1);
|
||||
qparams[0].buffer = &v1;
|
||||
qparams[0].length = &tinyLen;
|
||||
qparams[0].is_null = NULL;
|
||||
qparams[0].num = 1;
|
||||
|
||||
qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
||||
qparams[1].buffer_length = sizeof(v2);
|
||||
qparams[1].buffer = &v2;
|
||||
qparams[1].length = &smallLen;
|
||||
qparams[1].is_null = NULL;
|
||||
qparams[1].num = 1;
|
||||
|
||||
taos_stmt_bind_param(stmt, qparams);
|
||||
if (taos_stmt_execute(stmt) != 0) {
|
||||
printf("\033[31mfailed to execute select statement.error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
result = taos_stmt_use_result(stmt);
|
||||
|
||||
TAOS_ROW row;
|
||||
int rows = 0;
|
||||
int num_fields = taos_num_fields(result);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(result);
|
||||
|
||||
// fetch the records row by row
|
||||
while ((row = taos_fetch_row(result))) {
|
||||
char temp[256] = {0};
|
||||
rows++;
|
||||
taos_print_row(temp, row, fields, num_fields);
|
||||
printf("%s\n", temp);
|
||||
}
|
||||
|
||||
taos_free_result(result);
|
||||
taos_stmt_close(stmt);
|
||||
|
||||
free(t8_len);
|
||||
free(t16_len);
|
||||
free(t32_len);
|
||||
free(t64_len);
|
||||
free(float_len);
|
||||
free(double_len);
|
||||
free(bin_len);
|
||||
free(blob_len);
|
||||
}
|
||||
|
||||
void verify_prepare3(TAOS* taos) {
|
||||
TAOS_RES* result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
result = taos_query(taos, "create database test;");
|
||||
|
||||
int code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
return;
|
||||
}
|
||||
taos_free_result(result);
|
||||
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
// create table
|
||||
const char* sql =
|
||||
"create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
|
||||
"binary(40), blob nchar(10)) tags (id1 int, id2 binary(40))";
|
||||
result = taos_query(taos, sql);
|
||||
code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
return;
|
||||
}
|
||||
taos_free_result(result);
|
||||
|
||||
TAOS_MULTI_BIND tags[2];
|
||||
|
||||
int32_t id1 = 1;
|
||||
char id2[40] = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
int32_t id2_len = (int32_t)strlen(id2);
|
||||
|
||||
tags[0].buffer_type = TSDB_DATA_TYPE_INT;
|
||||
tags[0].buffer_length = sizeof(int);
|
||||
tags[0].buffer = &id1;
|
||||
tags[0].length = NULL;
|
||||
tags[0].is_null = NULL;
|
||||
tags[0].num = 1;
|
||||
|
||||
tags[1].buffer_type = TSDB_DATA_TYPE_BINARY;
|
||||
tags[1].buffer_length = sizeof(id2);
|
||||
tags[1].buffer = id2;
|
||||
tags[1].length = &id2_len;
|
||||
tags[1].is_null = NULL;
|
||||
tags[1].num = 1;
|
||||
|
||||
// insert 10 records
|
||||
struct {
|
||||
int64_t ts[10];
|
||||
int8_t b[10];
|
||||
int8_t v1[10];
|
||||
int16_t v2[10];
|
||||
int32_t v4[10];
|
||||
int64_t v8[10];
|
||||
float f4[10];
|
||||
double f8[10];
|
||||
char bin[10][40];
|
||||
char blob[10][80];
|
||||
} v;
|
||||
|
||||
int32_t* t8_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* t16_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* t32_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* t64_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* float_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* double_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* bin_len = malloc(sizeof(int32_t) * 10);
|
||||
int32_t* blob_len = malloc(sizeof(int32_t) * 10);
|
||||
|
||||
TAOS_STMT* stmt = taos_stmt_init(taos);
|
||||
TAOS_MULTI_BIND params[10];
|
||||
char is_null[10] = {0};
|
||||
|
||||
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
params[0].buffer_length = sizeof(v.ts[0]);
|
||||
params[0].buffer = v.ts;
|
||||
params[0].length = t64_len;
|
||||
params[0].is_null = is_null;
|
||||
params[0].num = 10;
|
||||
|
||||
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
|
||||
params[1].buffer_length = sizeof(v.b[0]);
|
||||
params[1].buffer = v.b;
|
||||
params[1].length = t8_len;
|
||||
params[1].is_null = is_null;
|
||||
params[1].num = 10;
|
||||
|
||||
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
||||
params[2].buffer_length = sizeof(v.v1[0]);
|
||||
params[2].buffer = v.v1;
|
||||
params[2].length = t8_len;
|
||||
params[2].is_null = is_null;
|
||||
params[2].num = 10;
|
||||
|
||||
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
||||
params[3].buffer_length = sizeof(v.v2[0]);
|
||||
params[3].buffer = v.v2;
|
||||
params[3].length = t16_len;
|
||||
params[3].is_null = is_null;
|
||||
params[3].num = 10;
|
||||
|
||||
params[4].buffer_type = TSDB_DATA_TYPE_INT;
|
||||
params[4].buffer_length = sizeof(v.v4[0]);
|
||||
params[4].buffer = v.v4;
|
||||
params[4].length = t32_len;
|
||||
params[4].is_null = is_null;
|
||||
params[4].num = 10;
|
||||
|
||||
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
|
||||
params[5].buffer_length = sizeof(v.v8[0]);
|
||||
params[5].buffer = v.v8;
|
||||
params[5].length = t64_len;
|
||||
params[5].is_null = is_null;
|
||||
params[5].num = 10;
|
||||
|
||||
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
|
||||
params[6].buffer_length = sizeof(v.f4[0]);
|
||||
params[6].buffer = v.f4;
|
||||
params[6].length = float_len;
|
||||
params[6].is_null = is_null;
|
||||
params[6].num = 10;
|
||||
|
||||
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
|
||||
params[7].buffer_length = sizeof(v.f8[0]);
|
||||
params[7].buffer = v.f8;
|
||||
params[7].length = double_len;
|
||||
params[7].is_null = is_null;
|
||||
params[7].num = 10;
|
||||
|
||||
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
|
||||
params[8].buffer_length = sizeof(v.bin[0]);
|
||||
params[8].buffer = v.bin;
|
||||
params[8].length = bin_len;
|
||||
params[8].is_null = is_null;
|
||||
params[8].num = 10;
|
||||
|
||||
params[9].buffer_type = TSDB_DATA_TYPE_NCHAR;
|
||||
params[9].buffer_length = sizeof(v.blob[0]);
|
||||
params[9].buffer = v.blob;
|
||||
params[9].length = blob_len;
|
||||
params[9].is_null = is_null;
|
||||
params[9].num = 10;
|
||||
|
||||
sql = "insert into ? using st1 tags(?,?) values(?,?,?,?,?,?,?,?,?,?)";
|
||||
code = taos_stmt_prepare(stmt, sql, 0);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
code = taos_stmt_set_tbname_tags(stmt, "m1", tags);
|
||||
if (code != 0) {
|
||||
printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t ts = 1591060628000;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
v.ts[i] = ts++;
|
||||
is_null[i] = 0;
|
||||
|
||||
v.b[i] = (int8_t)i % 2;
|
||||
v.v1[i] = (int8_t)i;
|
||||
v.v2[i] = (int16_t)(i * 2);
|
||||
v.v4[i] = (int32_t)(i * 4);
|
||||
v.v8[i] = (int64_t)(i * 8);
|
||||
v.f4[i] = (float)(i * 40);
|
||||
v.f8[i] = (double)(i * 80);
|
||||
for (int j = 0; j < sizeof(v.bin[0]); ++j) {
|
||||
v.bin[i][j] = (char)(i + '0');
|
||||
}
|
||||
strcpy(v.blob[i], "一二三四五六七八九十");
|
||||
|
||||
t8_len[i] = sizeof(int8_t);
|
||||
t16_len[i] = sizeof(int16_t);
|
||||
t32_len[i] = sizeof(int32_t);
|
||||
t64_len[i] = sizeof(int64_t);
|
||||
float_len[i] = sizeof(float);
|
||||
double_len[i] = sizeof(double);
|
||||
bin_len[i] = sizeof(v.bin[0]);
|
||||
blob_len[i] = (int32_t)strlen(v.blob[i]);
|
||||
}
|
||||
|
||||
taos_stmt_bind_param_batch(stmt, params);
|
||||
taos_stmt_add_batch(stmt);
|
||||
|
||||
if (taos_stmt_execute(stmt) != 0) {
|
||||
printf("\033[31mfailed to execute insert statement.error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
taos_stmt_close(stmt);
|
||||
|
||||
// query the records
|
||||
stmt = taos_stmt_init(taos);
|
||||
taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0);
|
||||
|
||||
TAOS_MULTI_BIND qparams[2];
|
||||
|
||||
int8_t v1 = 5;
|
||||
int16_t v2 = 15;
|
||||
int32_t tinyLen = sizeof(v1);
|
||||
int32_t smallLen = sizeof(v2);
|
||||
|
||||
qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT;
|
||||
qparams[0].buffer_length = sizeof(v1);
|
||||
qparams[0].buffer = &v1;
|
||||
qparams[0].length = &tinyLen;
|
||||
qparams[0].is_null = NULL;
|
||||
qparams[0].num = 1;
|
||||
|
||||
qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
|
||||
qparams[1].buffer_length = sizeof(v2);
|
||||
qparams[1].buffer = &v2;
|
||||
qparams[1].length = &smallLen;
|
||||
qparams[1].is_null = NULL;
|
||||
qparams[1].num = 1;
|
||||
|
||||
taos_stmt_bind_param(stmt, qparams);
|
||||
if (taos_stmt_execute(stmt) != 0) {
|
||||
printf("\033[31mfailed to execute select statement.error:%s\033[0m\n", taos_stmt_errstr(stmt));
|
||||
taos_stmt_close(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
result = taos_stmt_use_result(stmt);
|
||||
|
||||
TAOS_ROW row;
|
||||
int rows = 0;
|
||||
int num_fields = taos_num_fields(result);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(result);
|
||||
|
||||
// fetch the records row by row
|
||||
while ((row = taos_fetch_row(result))) {
|
||||
char temp[256] = {0};
|
||||
rows++;
|
||||
taos_print_row(temp, row, fields, num_fields);
|
||||
printf("%s\n", temp);
|
||||
}
|
||||
|
||||
taos_free_result(result);
|
||||
taos_stmt_close(stmt);
|
||||
|
||||
free(t8_len);
|
||||
free(t16_len);
|
||||
free(t32_len);
|
||||
free(t64_len);
|
||||
free(float_len);
|
||||
free(double_len);
|
||||
free(bin_len);
|
||||
free(blob_len);
|
||||
}
|
||||
|
||||
void retrieve_callback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||
if (numOfRows > 0) {
|
||||
printf("%d rows async retrieved\n", numOfRows);
|
||||
taos_fetch_rows_a(tres, retrieve_callback, param);
|
||||
} else {
|
||||
if (numOfRows < 0) {
|
||||
printf("\033[31masync retrieve failed, code: %d\033[0m\n", numOfRows);
|
||||
} else {
|
||||
printf("async retrieve completed\n");
|
||||
}
|
||||
taos_free_result(tres);
|
||||
}
|
||||
}
|
||||
|
||||
void select_callback(void* param, TAOS_RES* tres, int code) {
|
||||
if (code == 0 && tres) {
|
||||
taos_fetch_rows_a(tres, retrieve_callback, param);
|
||||
} else {
|
||||
printf("\033[31masync select failed, code: %d\033[0m\n", code);
|
||||
}
|
||||
}
|
||||
|
||||
void verify_async(TAOS* taos) {
|
||||
prepare_data(taos);
|
||||
taos_query_a(taos, "select * from meters", select_callback, NULL);
|
||||
usleep(1000000);
|
||||
}
|
||||
|
||||
void stream_callback(void* param, TAOS_RES* res, TAOS_ROW row) {
|
||||
if (res == NULL || row == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
int num_fields = taos_num_fields(res);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||
|
||||
printf("got one row from stream_callback\n");
|
||||
char temp[256] = {0};
|
||||
taos_print_row(temp, row, fields, num_fields);
|
||||
puts(temp);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const char* host = "127.0.0.1";
|
||||
const char* user = "root";
|
||||
const char* passwd = "taosdata";
|
||||
|
||||
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
|
||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||
if (taos == NULL) {
|
||||
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
printf("************ verify query *************\n");
|
||||
verify_query(taos);
|
||||
|
||||
printf("********* verify async query **********\n");
|
||||
verify_async(taos);
|
||||
|
||||
printf("************ verify prepare *************\n");
|
||||
verify_prepare(taos);
|
||||
|
||||
printf("************ verify prepare2 *************\n");
|
||||
verify_prepare2(taos);
|
||||
printf("************ verify prepare3 *************\n");
|
||||
verify_prepare3(taos);
|
||||
|
||||
printf("done\n");
|
||||
taos_close(taos);
|
||||
taos_cleanup();
|
||||
}
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef WINDOWS
|
||||
#include <argp.h>
|
||||
#endif
|
||||
#include "osSleep.h"
|
||||
#include "taos.h"
|
||||
|
||||
#define debugPrint(fmt, ...) \
|
||||
|
@ -81,11 +80,9 @@ static void prepare_data(TAOS* taos) {
|
|||
TAOS_RES *res;
|
||||
res = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(res);
|
||||
taosMsleep(100);
|
||||
|
||||
res = taos_query(taos, "create database test;");
|
||||
taos_free_result(res);
|
||||
taosMsleep(100);
|
||||
if (taos_select_db(taos, "test")) {
|
||||
errorPrint("%s() LN%d: taos_select_db() failed\n",
|
||||
__func__, __LINE__);
|
|
@ -1,10 +1,11 @@
|
|||
set +e
|
||||
|
||||
rm -rf /tmp/udf/libbitand.so /tmp/udf/libsqrsum.so
|
||||
rm -rf /tmp/udf/libbitand.so /tmp/udf/libsqrsum.so /tmp/udf/libgpd.so
|
||||
mkdir -p /tmp/udf
|
||||
echo "compile udf bit_and and sqr_sum"
|
||||
gcc -fPIC -shared sh/bit_and.c -I../../include/libs/function/ -I../../include/client -I../../include/util -o /tmp/udf/libbitand.so
|
||||
gcc -fPIC -shared sh/l2norm.c -I../../include/libs/function/ -I../../include/client -I../../include/util -o /tmp/udf/libl2norm.so
|
||||
gcc -fPIC -shared sh/gpd.c -I../../include/libs/function/ -I../../include/client -I../../include/util -o /tmp/udf/libgpd.so
|
||||
echo "debug show /tmp/udf/*.so"
|
||||
ls /tmp/udf/*.so
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue