other: merge 3.0
This commit is contained in:
commit
f636806c2a
70
Jenkinsfile2
70
Jenkinsfile2
|
@ -117,27 +117,29 @@ def pre_test(){
|
||||||
def pre_test_win(){
|
def pre_test_win(){
|
||||||
bat '''
|
bat '''
|
||||||
hostname
|
hostname
|
||||||
|
ipconfig
|
||||||
|
set
|
||||||
date /t
|
date /t
|
||||||
time /t
|
time /t
|
||||||
taskkill /f /t /im python.exe
|
|
||||||
taskkill /f /t /im bash.exe
|
|
||||||
rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
|
rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
|
||||||
exit 0
|
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
git fetch || git fetch
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
git fetch || git fetch
|
||||||
git checkout -f
|
|
||||||
'''
|
'''
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_TARGET == 'master') {
|
if (env.CHANGE_TARGET == 'master') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git checkout master
|
git checkout master
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout master
|
git checkout master
|
||||||
'''
|
'''
|
||||||
|
@ -145,6 +147,8 @@ def pre_test_win(){
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git checkout 2.0
|
git checkout 2.0
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout 2.0
|
git checkout 2.0
|
||||||
'''
|
'''
|
||||||
|
@ -152,6 +156,8 @@ def pre_test_win(){
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git checkout 3.0
|
git checkout 3.0
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout 3.0
|
git checkout 3.0
|
||||||
'''
|
'''
|
||||||
|
@ -159,6 +165,8 @@ def pre_test_win(){
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git checkout develop
|
git checkout develop
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout develop
|
git checkout develop
|
||||||
'''
|
'''
|
||||||
|
@ -169,30 +177,52 @@ def pre_test_win(){
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git pull
|
git pull
|
||||||
git log -5
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git pull
|
git pull
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
'''
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
|
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
git log -5
|
|
||||||
'''
|
'''
|
||||||
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git pull
|
git pull
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
'''
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
git log -5
|
'''
|
||||||
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git pull
|
git pull
|
||||||
git log -5
|
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
sh '''
|
bat '''
|
||||||
echo "unmatched reposiotry ${CHANGE_URL}"
|
echo "unmatched reposiotry %CHANGE_URL%"
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git branch
|
||||||
|
git log -5
|
||||||
|
'''
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
|
git branch
|
||||||
|
git log -5
|
||||||
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
@ -205,10 +235,15 @@ def pre_test_build_win() {
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
mkdir debug
|
mkdir debug
|
||||||
cd debug
|
cd debug
|
||||||
|
time /t
|
||||||
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
|
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
|
||||||
set CL=/MP8
|
set CL=/MP8
|
||||||
cmake .. -G "NMake Makefiles JOM"
|
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> cmake"
|
||||||
jom -j 4 || exit 8
|
time /t
|
||||||
|
cmake .. -G "NMake Makefiles JOM" || exit 7
|
||||||
|
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> jom -j 6"
|
||||||
|
time /t
|
||||||
|
jom -j 6 || exit 8
|
||||||
time /t
|
time /t
|
||||||
'''
|
'''
|
||||||
return 1
|
return 1
|
||||||
|
@ -226,6 +261,13 @@ pipeline {
|
||||||
stages {
|
stages {
|
||||||
stage('run test') {
|
stage('run test') {
|
||||||
parallel {
|
parallel {
|
||||||
|
stage('windows test') {
|
||||||
|
agent{label " windows10_01 || windows10_02 || windows10_03 || windows10_04 "}
|
||||||
|
steps {
|
||||||
|
pre_test_win()
|
||||||
|
pre_test_build_win()
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('linux test') {
|
stage('linux test') {
|
||||||
agent{label " slave3_0 || slave15 || slave16 || slave17 "}
|
agent{label " slave3_0 || slave15 || slave16 || slave17 "}
|
||||||
options { skipDefaultCheckout() }
|
options { skipDefaultCheckout() }
|
||||||
|
|
|
@ -5,22 +5,27 @@ IF (TD_LINUX)
|
||||||
ELSEIF (TD_WINDOWS)
|
ELSEIF (TD_WINDOWS)
|
||||||
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
|
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
|
||||||
|
|
||||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/go DESTINATION connector)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/go DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/nodejs DESTINATION connector)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/nodejs DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg DESTINATION cfg)
|
INSTALL(FILES ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg DESTINATION cfg)
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/src/inc/taos.h DESTINATION include)
|
INSTALL(FILES ${TD_SOURCE_DIR}/include/client/taos.h DESTINATION include)
|
||||||
INSTALL(FILES ${TD_SOURCE_DIR}/src/inc/taoserror.h DESTINATION include)
|
INSTALL(FILES ${TD_SOURCE_DIR}/include/util/taoserror.h DESTINATION include)
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos_static.lib DESTINATION driver)
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos_static.lib DESTINATION driver)
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
|
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
|
||||||
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
|
||||||
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosd.exe DESTINATION .)
|
||||||
|
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/udfd.exe DESTINATION .)
|
||||||
|
|
||||||
IF (TD_MVN_INSTALLED)
|
IF (TD_MVN_INSTALLED)
|
||||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.bat")
|
||||||
|
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||||
|
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} :needAdmin ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Windows ${TD_VER_NUMBER})")
|
||||||
ELSEIF (TD_DARWIN)
|
ELSEIF (TD_DARWIN)
|
||||||
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
|
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
|
||||||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||||
|
|
|
@ -239,7 +239,7 @@ void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||||
msg_process(tmqmessage);
|
msg_process(tmqmessage);
|
||||||
taos_free_result(tmqmessage);
|
taos_free_result(tmqmessage);
|
||||||
|
|
||||||
tmq_commit(tmq, NULL, 1);
|
tmq_commit_async(tmq, NULL, tmq_commit_cb_print, NULL);
|
||||||
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,11 +232,11 @@ DLL_EXPORT tmq_resp_err_t tmq_unsubscribe(tmq_t *tmq);
|
||||||
DLL_EXPORT tmq_resp_err_t tmq_subscription(tmq_t *tmq, tmq_list_t **topics);
|
DLL_EXPORT tmq_resp_err_t tmq_subscription(tmq_t *tmq, tmq_list_t **topics);
|
||||||
DLL_EXPORT TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t wait_time);
|
DLL_EXPORT TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t wait_time);
|
||||||
DLL_EXPORT tmq_resp_err_t tmq_consumer_close(tmq_t *tmq);
|
DLL_EXPORT tmq_resp_err_t tmq_consumer_close(tmq_t *tmq);
|
||||||
DLL_EXPORT tmq_resp_err_t tmq_commit(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets, int32_t async);
|
|
||||||
DLL_EXPORT void tmq_commit_async(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets, tmq_commit_cb *cb, void *param);
|
|
||||||
DLL_EXPORT tmq_resp_err_t tmq_commit_sync(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets);
|
DLL_EXPORT tmq_resp_err_t tmq_commit_sync(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets);
|
||||||
|
DLL_EXPORT void tmq_commit_async(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets, tmq_commit_cb *cb, void *param);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
DLL_EXPORT tmq_resp_err_t tmq_commit_message(tmq_t* tmq, const tmq_message_t* tmqmessage, int32_t async);
|
DLL_EXPORT tmq_resp_err_t tmq_commit(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets, int32_t async);
|
||||||
DLL_EXPORT tmq_resp_err_t tmq_seek(tmq_t *tmq, const tmq_topic_vgroup_t *offset);
|
DLL_EXPORT tmq_resp_err_t tmq_seek(tmq_t *tmq, const tmq_topic_vgroup_t *offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -301,6 +301,8 @@ typedef struct SSchema {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t nCols;
|
int32_t nCols;
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
|
int32_t tagVer;
|
||||||
|
int32_t colVer;
|
||||||
SSchema* pSchema;
|
SSchema* pSchema;
|
||||||
} SSchemaWrapper;
|
} SSchemaWrapper;
|
||||||
|
|
||||||
|
@ -309,6 +311,8 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
||||||
if (pSW == NULL) return pSW;
|
if (pSW == NULL) return pSW;
|
||||||
pSW->nCols = pSchemaWrapper->nCols;
|
pSW->nCols = pSchemaWrapper->nCols;
|
||||||
pSW->sver = pSchemaWrapper->sver;
|
pSW->sver = pSchemaWrapper->sver;
|
||||||
|
pSW->tagVer = pSchemaWrapper->tagVer;
|
||||||
|
pSW->colVer = pSchemaWrapper->colVer;
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
if (pSW->pSchema == NULL) {
|
if (pSW->pSchema == NULL) {
|
||||||
taosMemoryFree(pSW);
|
taosMemoryFree(pSW);
|
||||||
|
@ -364,6 +368,8 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
||||||
tlen += taosEncodeVariantI32(buf, pSW->sver);
|
tlen += taosEncodeVariantI32(buf, pSW->sver);
|
||||||
|
tlen += taosEncodeVariantI32(buf, pSW->tagVer);
|
||||||
|
tlen += taosEncodeVariantI32(buf, pSW->colVer);
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
|
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
|
||||||
}
|
}
|
||||||
|
@ -373,6 +379,8 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
|
||||||
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
||||||
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
||||||
buf = taosDecodeVariantI32(buf, &pSW->sver);
|
buf = taosDecodeVariantI32(buf, &pSW->sver);
|
||||||
|
buf = taosDecodeVariantI32(buf, &pSW->tagVer);
|
||||||
|
buf = taosDecodeVariantI32(buf, &pSW->colVer);
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
if (pSW->pSchema == NULL) {
|
if (pSW->pSchema == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -387,6 +395,8 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapp
|
||||||
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
||||||
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
||||||
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
||||||
|
if (tEncodeI32v(pEncoder, pSW->tagVer) < 0) return -1;
|
||||||
|
if (tEncodeI32v(pEncoder, pSW->colVer) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
@ -397,6 +407,8 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSch
|
||||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||||
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
||||||
|
if (tDecodeI32v(pDecoder, &pSW->tagVer) < 0) return -1;
|
||||||
|
if (tDecodeI32v(pDecoder, &pSW->colVer) < 0) return -1;
|
||||||
|
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
if (pSW->pSchema == NULL) return -1;
|
if (pSW->pSchema == NULL) return -1;
|
||||||
|
@ -410,6 +422,8 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWra
|
||||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||||
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
||||||
|
if (tDecodeI32v(pDecoder, &pSW->tagVer) < 0) return -1;
|
||||||
|
if (tDecodeI32v(pDecoder, &pSW->colVer) < 0) return -1;
|
||||||
|
|
||||||
pSW->pSchema = (SSchema*)tDecoderMalloc(pDecoder, pSW->nCols * sizeof(SSchema));
|
pSW->pSchema = (SSchema*)tDecoderMalloc(pDecoder, pSW->nCols * sizeof(SSchema));
|
||||||
if (pSW->pSchema == NULL) return -1;
|
if (pSW->pSchema == NULL) return -1;
|
||||||
|
@ -455,6 +469,7 @@ int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
|
int32_t verInBlock;
|
||||||
int32_t numOfFields;
|
int32_t numOfFields;
|
||||||
SArray* pFields;
|
SArray* pFields;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
|
@ -1480,6 +1495,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
char cgroup[TSDB_CGROUP_LEN];
|
char cgroup[TSDB_CGROUP_LEN];
|
||||||
|
char clientId[256];
|
||||||
SArray* topicNames; // SArray<char**>
|
SArray* topicNames; // SArray<char**>
|
||||||
} SCMSubscribeReq;
|
} SCMSubscribeReq;
|
||||||
|
|
||||||
|
@ -1487,6 +1503,7 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
|
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
|
||||||
tlen += taosEncodeString(buf, pReq->cgroup);
|
tlen += taosEncodeString(buf, pReq->cgroup);
|
||||||
|
tlen += taosEncodeString(buf, pReq->clientId);
|
||||||
|
|
||||||
int32_t topicNum = taosArrayGetSize(pReq->topicNames);
|
int32_t topicNum = taosArrayGetSize(pReq->topicNames);
|
||||||
tlen += taosEncodeFixedI32(buf, topicNum);
|
tlen += taosEncodeFixedI32(buf, topicNum);
|
||||||
|
@ -1500,6 +1517,7 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
||||||
static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
|
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
|
||||||
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
||||||
|
buf = taosDecodeStringTo(buf, pReq->clientId);
|
||||||
|
|
||||||
int32_t topicNum;
|
int32_t topicNum;
|
||||||
buf = taosDecodeFixedI32(buf, &topicNum);
|
buf = taosDecodeFixedI32(buf, &topicNum);
|
||||||
|
|
|
@ -60,9 +60,9 @@ typedef struct {
|
||||||
ReportStartup reportStartupFp;
|
ReportStartup reportStartupFp;
|
||||||
} SMsgCb;
|
} SMsgCb;
|
||||||
|
|
||||||
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb);
|
void tmsgSetDefault(const SMsgCb* msgcb);
|
||||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pMsg);
|
int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg);
|
||||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype);
|
||||||
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
||||||
void tmsgSendRsp(SRpcMsg* pMsg);
|
void tmsgSendRsp(SRpcMsg* pMsg);
|
||||||
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||||
|
|
|
@ -333,23 +333,23 @@ SSdbRow *sdbAllocRow(int32_t objSize);
|
||||||
void *sdbGetRowObj(SSdbRow *pRow);
|
void *sdbGetRowObj(SSdbRow *pRow);
|
||||||
|
|
||||||
typedef struct SSdb {
|
typedef struct SSdb {
|
||||||
SMnode *pMnode;
|
SMnode *pMnode;
|
||||||
char *currDir;
|
char *currDir;
|
||||||
char *syncDir;
|
char *syncDir;
|
||||||
char *tmpDir;
|
char *tmpDir;
|
||||||
int64_t lastCommitVer;
|
int64_t lastCommitVer;
|
||||||
int64_t curVer;
|
int64_t curVer;
|
||||||
int64_t tableVer[SDB_MAX];
|
int64_t tableVer[SDB_MAX];
|
||||||
int64_t maxId[SDB_MAX];
|
int64_t maxId[SDB_MAX];
|
||||||
EKeyType keyTypes[SDB_MAX];
|
EKeyType keyTypes[SDB_MAX];
|
||||||
SHashObj *hashObjs[SDB_MAX];
|
SHashObj *hashObjs[SDB_MAX];
|
||||||
SRWLatch locks[SDB_MAX];
|
TdThreadRwlock locks[SDB_MAX];
|
||||||
SdbInsertFp insertFps[SDB_MAX];
|
SdbInsertFp insertFps[SDB_MAX];
|
||||||
SdbUpdateFp updateFps[SDB_MAX];
|
SdbUpdateFp updateFps[SDB_MAX];
|
||||||
SdbDeleteFp deleteFps[SDB_MAX];
|
SdbDeleteFp deleteFps[SDB_MAX];
|
||||||
SdbDeployFp deployFps[SDB_MAX];
|
SdbDeployFp deployFps[SDB_MAX];
|
||||||
SdbEncodeFp encodeFps[SDB_MAX];
|
SdbEncodeFp encodeFps[SDB_MAX];
|
||||||
SdbDecodeFp decodeFps[SDB_MAX];
|
SdbDecodeFp decodeFps[SDB_MAX];
|
||||||
} SSdb;
|
} SSdb;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -59,6 +59,11 @@ typedef struct SMetaData {
|
||||||
SArray *pQnodeList; // qnode list, SArray<SQueryNodeAddr>
|
SArray *pQnodeList; // qnode list, SArray<SQueryNodeAddr>
|
||||||
} SMetaData;
|
} SMetaData;
|
||||||
|
|
||||||
|
typedef struct STbSVersion {
|
||||||
|
char* tbFName;
|
||||||
|
int32_t sver;
|
||||||
|
} STbSVersion;
|
||||||
|
|
||||||
typedef struct SCatalogCfg {
|
typedef struct SCatalogCfg {
|
||||||
uint32_t maxTblCacheNum;
|
uint32_t maxTblCacheNum;
|
||||||
uint32_t maxDBCacheNum;
|
uint32_t maxDBCacheNum;
|
||||||
|
@ -165,6 +170,8 @@ int32_t catalogUpdateSTableMeta(SCatalog* pCatalog, STableMetaRsp *rspMsg);
|
||||||
*/
|
*/
|
||||||
int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const char* dbFName);
|
int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const char* dbFName);
|
||||||
|
|
||||||
|
int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SArray* pTables);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force refresh a table's local cached meta data.
|
* Force refresh a table's local cached meta data.
|
||||||
* @param pCatalog (input, got with catalogGetHandle)
|
* @param pCatalog (input, got with catalogGetHandle)
|
||||||
|
|
|
@ -142,6 +142,8 @@ void fmFuncMgtDestroy();
|
||||||
|
|
||||||
int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc);
|
int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc);
|
||||||
|
|
||||||
|
bool fmIsBuiltinFunc(const char* pFunc);
|
||||||
|
|
||||||
bool fmIsAggFunc(int32_t funcId);
|
bool fmIsAggFunc(int32_t funcId);
|
||||||
bool fmIsScalarFunc(int32_t funcId);
|
bool fmIsScalarFunc(int32_t funcId);
|
||||||
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
||||||
|
|
|
@ -78,7 +78,7 @@ typedef struct SAlterDatabaseStmt {
|
||||||
|
|
||||||
typedef struct STableOptions {
|
typedef struct STableOptions {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char comment[TSDB_STB_COMMENT_LEN];
|
char comment[TSDB_TB_COMMENT_LEN];
|
||||||
int32_t delay;
|
int32_t delay;
|
||||||
float filesFactor;
|
float filesFactor;
|
||||||
SNodeList* pRollupFuncs;
|
SNodeList* pRollupFuncs;
|
||||||
|
@ -90,7 +90,7 @@ typedef struct SColumnDefNode {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char colName[TSDB_COL_NAME_LEN];
|
char colName[TSDB_COL_NAME_LEN];
|
||||||
SDataType dataType;
|
SDataType dataType;
|
||||||
char comments[TSDB_STB_COMMENT_LEN];
|
char comments[TSDB_TB_COMMENT_LEN];
|
||||||
bool sma;
|
bool sma;
|
||||||
} SColumnDefNode;
|
} SColumnDefNode;
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_FILL,
|
QUERY_NODE_PHYSICAL_PLAN_FILL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW,
|
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW,
|
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW,
|
||||||
|
|
|
@ -248,6 +248,7 @@ typedef struct SSetOperator {
|
||||||
SNode* pRight;
|
SNode* pRight;
|
||||||
SNodeList* pOrderByList; // SOrderByExprNode
|
SNodeList* pOrderByList; // SOrderByExprNode
|
||||||
SNode* pLimit;
|
SNode* pLimit;
|
||||||
|
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||||
} SSetOperator;
|
} SSetOperator;
|
||||||
|
|
||||||
typedef enum ESqlClause {
|
typedef enum ESqlClause {
|
||||||
|
|
|
@ -220,23 +220,23 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
taosPrintLog("QRY ", DEBUG_INFO, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_INFO, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qDebug(...) \
|
#define qDebug(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||||
taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qTrace(...) \
|
#define qTrace(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_TRACE) { \
|
if (qDebugFlag & DEBUG_TRACE) { \
|
||||||
taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define qDebugL(...) \
|
#define qDebugL(...) \
|
||||||
do { \
|
do { \
|
||||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||||
taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define QRY_ERR_RET(c) \
|
#define QRY_ERR_RET(c) \
|
||||||
|
|
|
@ -72,7 +72,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg);
|
||||||
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, int64_t startTs, bool needRes, SQueryResult *pRes);
|
int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, int64_t startTs, SQueryResult *pRes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the query job, generated according to the query physical plan.
|
* Process the query job, generated according to the query physical plan.
|
||||||
|
|
|
@ -38,6 +38,13 @@ typedef int32_t TdUcs4;
|
||||||
#define wcsncpy WCSNCPY_FUNC_TAOS_FORBID
|
#define wcsncpy WCSNCPY_FUNC_TAOS_FORBID
|
||||||
#define wchar_t WCHAR_T_TYPE_TAOS_FORBID
|
#define wchar_t WCHAR_T_TYPE_TAOS_FORBID
|
||||||
#define strcasestr STR_CASE_STR_FORBID
|
#define strcasestr STR_CASE_STR_FORBID
|
||||||
|
#define strtoll STR_TO_LL_FUNC_TAOS_FORBID
|
||||||
|
#define strtoull STR_TO_ULL_FUNC_TAOS_FORBID
|
||||||
|
#define strtol STR_TO_L_FUNC_TAOS_FORBID
|
||||||
|
#define strtoul STR_TO_UL_FUNC_TAOS_FORBID
|
||||||
|
#define strtod STR_TO_LD_FUNC_TAOS_FORBID
|
||||||
|
#define strtold STR_TO_D_FUNC_TAOS_FORBID
|
||||||
|
#define strtof STR_TO_F_FUNC_TAOS_FORBID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -72,6 +79,17 @@ int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size);
|
||||||
|
|
||||||
char *taosStrCaseStr(const char *str, const char *pattern);
|
char *taosStrCaseStr(const char *str, const char *pattern);
|
||||||
|
|
||||||
|
int64_t taosStr2Int64(const char *str, char** pEnd, int32_t radix);
|
||||||
|
uint64_t taosStr2UInt64(const char *str, char** pEnd, int32_t radix);
|
||||||
|
int32_t taosStr2Int32(const char *str, char** pEnd, int32_t radix);
|
||||||
|
uint32_t taosStr2UInt32(const char *str, char** pEnd, int32_t radix);
|
||||||
|
int16_t taosStr2Int16(const char *str, char** pEnd, int32_t radix);
|
||||||
|
uint16_t taosStr2UInt16(const char *str, char** pEnd, int32_t radix);
|
||||||
|
int8_t taosStr2Int8(const char *str, char** pEnd, int32_t radix);
|
||||||
|
uint8_t taosStr2UInt8(const char *str, char** pEnd, int32_t radix);
|
||||||
|
double taosStr2Double(const char *str, char** pEnd);
|
||||||
|
float taosStr2Float(const char *str, char** pEnd);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -646,6 +646,9 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_ALTER_TABLE TAOS_DEF_ERROR_CODE(0, 0x2649)
|
#define TSDB_CODE_PAR_INVALID_ALTER_TABLE TAOS_DEF_ERROR_CODE(0, 0x2649)
|
||||||
#define TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY TAOS_DEF_ERROR_CODE(0, 0x264A)
|
#define TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY TAOS_DEF_ERROR_CODE(0, 0x264A)
|
||||||
#define TSDB_CODE_PAR_INVALID_MODIFY_COL TAOS_DEF_ERROR_CODE(0, 0x264B)
|
#define TSDB_CODE_PAR_INVALID_MODIFY_COL TAOS_DEF_ERROR_CODE(0, 0x264B)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_TBNAME TAOS_DEF_ERROR_CODE(0, 0x264C)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_FUNCTION_NAME TAOS_DEF_ERROR_CODE(0, 0x264D)
|
||||||
|
#define TSDB_CODE_PAR_COMMENT_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x264E)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -218,8 +218,8 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MAX_SQL_SHOW_LEN 1024
|
#define TSDB_MAX_SQL_SHOW_LEN 1024
|
||||||
#define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u) // sql length should be less than 1mb
|
#define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u) // sql length should be less than 1mb
|
||||||
|
|
||||||
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
||||||
#define TSDB_STB_COMMENT_LEN 1024
|
#define TSDB_TB_COMMENT_LEN 1025
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
||||||
|
|
|
@ -56,10 +56,10 @@ typedef enum { SSkipListPutSuccess = 0, SSkipListPutEarlyStop = 1, SSkipListPutS
|
||||||
|
|
||||||
typedef struct SSkipList {
|
typedef struct SSkipList {
|
||||||
uint32_t seed;
|
uint32_t seed;
|
||||||
|
uint16_t len;
|
||||||
__compar_fn_t comparFn;
|
__compar_fn_t comparFn;
|
||||||
__sl_key_fn_t keyFn;
|
__sl_key_fn_t keyFn;
|
||||||
TdThreadRwlock *lock;
|
TdThreadRwlock *lock;
|
||||||
uint16_t len;
|
|
||||||
uint8_t maxLevel;
|
uint8_t maxLevel;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t type; // static info above
|
uint8_t type; // static info above
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
@echo off
|
||||||
|
goto %1
|
||||||
|
:needAdmin
|
||||||
|
mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&goto :eof
|
||||||
|
:hasAdmin
|
||||||
|
cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32
|
|
@ -83,6 +83,15 @@ void closeTransporter(STscObj *pTscObj) {
|
||||||
rpcClose(pTscObj->pAppInfo->pTransporter);
|
rpcClose(pTscObj->pAppInfo->pTransporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool clientRpcRfp(int32_t code) {
|
||||||
|
if (code == TSDB_CODE_RPC_REDIRECT) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO refactor
|
// TODO refactor
|
||||||
void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||||
SRpcInit rpcInit;
|
SRpcInit rpcInit;
|
||||||
|
@ -91,6 +100,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||||
rpcInit.label = "TSC";
|
rpcInit.label = "TSC";
|
||||||
rpcInit.numOfThreads = numOfThread;
|
rpcInit.numOfThreads = numOfThread;
|
||||||
rpcInit.cfp = processMsgFromServer;
|
rpcInit.cfp = processMsgFromServer;
|
||||||
|
rpcInit.rfp = clientRpcRfp;
|
||||||
rpcInit.sessions = 1024;
|
rpcInit.sessions = 1024;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.user = (char *)user;
|
rpcInit.user = (char *)user;
|
||||||
|
|
|
@ -291,7 +291,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
||||||
|
|
||||||
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf};
|
||||||
int32_t code = schedulerExecJob(pTransporter, pNodeList, pDag, &pRequest->body.queryJob, pRequest->sqlstr,
|
int32_t code = schedulerExecJob(pTransporter, pNodeList, pDag, &pRequest->body.queryJob, pRequest->sqlstr,
|
||||||
pRequest->metric.start, NULL != pRes, &res);
|
pRequest->metric.start, &res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
if (pRequest->body.queryJob != 0) {
|
if (pRequest->body.queryJob != 0) {
|
||||||
schedulerFreeJob(pRequest->body.queryJob);
|
schedulerFreeJob(pRequest->body.queryJob);
|
||||||
|
@ -310,9 +310,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRes) {
|
*pRes = res.res;
|
||||||
*pRes = res.res;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRequest->code = res.code;
|
pRequest->code = res.code;
|
||||||
terrno = res.code;
|
terrno = res.code;
|
||||||
|
@ -324,7 +322,60 @@ int32_t getQueryPlan(SRequestObj* pRequest, SQuery* pQuery, SArray** pNodeList)
|
||||||
return getPlan(pRequest, pQuery, &pRequest->body.pDag, *pNodeList);
|
return getPlan(pRequest, pQuery, &pRequest->body.pDag, *pNodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t validateSversion(SRequestObj* pRequest, void* res) {
|
||||||
|
SArray* pArray = NULL;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (TDMT_VND_SUBMIT == pRequest->type) {
|
||||||
|
SSubmitRsp* pRsp = (SSubmitRsp*)res;
|
||||||
|
if (pRsp->nBlocks <= 0) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
pArray = taosArrayInit(pRsp->nBlocks, sizeof(STbSVersion));
|
||||||
|
if (NULL == pArray) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pRsp->nBlocks; ++i) {
|
||||||
|
SSubmitBlkRsp *blk = pRsp->pBlocks + i;
|
||||||
|
STbSVersion tbSver = {.tbFName = blk->tblFName, .sver = blk->sver};
|
||||||
|
taosArrayPush(pArray, &tbSver);
|
||||||
|
}
|
||||||
|
} else if (TDMT_VND_QUERY == pRequest->type) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SCatalog* pCatalog = NULL;
|
||||||
|
CHECK_CODE_GOTO(catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog), _return);
|
||||||
|
|
||||||
|
SEpSet epset = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||||
|
|
||||||
|
code = catalogChkTbMetaVersion(pCatalog, pRequest->pTscObj->pAppInfo->pTransporter, &epset, pArray);
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
taosArrayDestroy(pArray);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeRequestRes(SRequestObj* pRequest, void* res) {
|
||||||
|
if (NULL == res) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TDMT_VND_SUBMIT == pRequest->type) {
|
||||||
|
tFreeSSubmitRsp((SSubmitRsp*)res);
|
||||||
|
} else if (TDMT_VND_QUERY == pRequest->type) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code, bool keepQuery, void** res) {
|
SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code, bool keepQuery, void** res) {
|
||||||
|
void* pRes = NULL;
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
switch (pQuery->execMode) {
|
switch (pQuery->execMode) {
|
||||||
case QUERY_EXEC_MODE_LOCAL:
|
case QUERY_EXEC_MODE_LOCAL:
|
||||||
|
@ -337,7 +388,10 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
|
||||||
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||||
code = getPlan(pRequest, pQuery, &pRequest->body.pDag, pNodeList);
|
code = getPlan(pRequest, pQuery, &pRequest->body.pDag, pNodeList);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = scheduleQuery(pRequest, pRequest->body.pDag, pNodeList, res);
|
code = scheduleQuery(pRequest, pRequest->body.pDag, pNodeList, &pRes);
|
||||||
|
if (NULL != pRes) {
|
||||||
|
code = validateSversion(pRequest, pRes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pNodeList);
|
taosArrayDestroy(pNodeList);
|
||||||
break;
|
break;
|
||||||
|
@ -356,6 +410,12 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
|
||||||
|
|
||||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
||||||
pRequest->code = terrno;
|
pRequest->code = terrno;
|
||||||
|
freeRequestRes(pRequest, pRes);
|
||||||
|
pRes = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
*res = pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pRequest;
|
return pRequest;
|
||||||
|
|
|
@ -580,7 +580,7 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
|
||||||
const char *pVal = kvVal->value;
|
const char *pVal = kvVal->value;
|
||||||
int32_t len = kvVal->length;
|
int32_t len = kvVal->length;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
double result = strtod(pVal, &endptr);
|
double result = taosStr2Double(pVal, &endptr);
|
||||||
if(pVal == endptr){
|
if(pVal == endptr){
|
||||||
smlBuildInvalidDataMsg(msg, "invalid data", pVal);
|
smlBuildInvalidDataMsg(msg, "invalid data", pVal);
|
||||||
return false;
|
return false;
|
||||||
|
@ -714,7 +714,7 @@ static bool smlIsNchar(const char *pVal, uint16_t len) {
|
||||||
|
|
||||||
static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
|
static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
|
||||||
char *endPtr = NULL;
|
char *endPtr = NULL;
|
||||||
int64_t tsInt64 = strtoll(value, &endPtr, 10);
|
int64_t tsInt64 = taosStr2Int64(value, &endPtr, 10);
|
||||||
if(value + len != endPtr){
|
if(value + len != endPtr){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ static const SSysDbTableSchema topicSchema[] = {
|
||||||
static const SSysDbTableSchema consumerSchema[] = {
|
static const SSysDbTableSchema consumerSchema[] = {
|
||||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "consumer_group", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "consumer_group", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "app_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
|
|
|
@ -600,6 +600,7 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq)
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->verInBlock) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfFields) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfFields) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pReq->numOfFields; ++i) {
|
for (int32_t i = 0; i < pReq->numOfFields; ++i) {
|
||||||
SField *pField = taosArrayGet(pReq->pFields, i);
|
SField *pField = taosArrayGet(pReq->pFields, i);
|
||||||
|
@ -626,6 +627,7 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->verInBlock) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfFields) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfFields) < 0) return -1;
|
||||||
pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SField));
|
pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SField));
|
||||||
if (pReq->pFields == NULL) {
|
if (pReq->pFields == NULL) {
|
||||||
|
@ -4087,10 +4089,8 @@ static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBl
|
||||||
|
|
||||||
if (tEncodeI32(pEncoder, pBlock->code) < 0) return -1;
|
if (tEncodeI32(pEncoder, pBlock->code) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pBlock->hashMeta) < 0) return -1;
|
if (tEncodeI8(pEncoder, pBlock->hashMeta) < 0) return -1;
|
||||||
if (pBlock->hashMeta) {
|
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
|
||||||
}
|
|
||||||
if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1;
|
||||||
if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1;
|
if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1;
|
||||||
if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1;
|
if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1;
|
||||||
|
@ -4104,12 +4104,10 @@ static int32_t tDecodeSSubmitBlkRsp(SDecoder *pDecoder, SSubmitBlkRsp *pBlock) {
|
||||||
|
|
||||||
if (tDecodeI32(pDecoder, &pBlock->code) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pBlock->code) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pBlock->hashMeta) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pBlock->hashMeta) < 0) return -1;
|
||||||
if (pBlock->hashMeta) {
|
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
||||||
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
if (NULL == pBlock->tblFName) return -1;
|
||||||
if (NULL == pBlock->tblFName) return -1;
|
if (tDecodeCStrTo(pDecoder, pBlock->tblFName) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pBlock->tblFName) < 0) return -1;
|
|
||||||
}
|
|
||||||
if (tDecodeI32v(pDecoder, &pBlock->numOfRows) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pBlock->numOfRows) < 0) return -1;
|
||||||
if (tDecodeI32v(pDecoder, &pBlock->affectedRows) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pBlock->affectedRows) < 0) return -1;
|
||||||
if (tDecodeI64v(pDecoder, &pBlock->sver) < 0) return -1;
|
if (tDecodeI64v(pDecoder, &pBlock->sver) < 0) return -1;
|
||||||
|
|
|
@ -17,46 +17,46 @@
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
|
||||||
static SMsgCb tsDefaultMsgCb;
|
static SMsgCb defaultMsgCb;
|
||||||
|
|
||||||
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb) { tsDefaultMsgCb = *pMsgCb; }
|
void tmsgSetDefault(const SMsgCb* msgcb) { defaultMsgCb = *msgcb; }
|
||||||
|
|
||||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pMsg) {
|
int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg) {
|
||||||
PutToQueueFp fp = pMsgCb->queueFps[qtype];
|
PutToQueueFp fp = msgcb->queueFps[qtype];
|
||||||
return (*fp)(pMsgCb->mgmt, pMsg);
|
return (*fp)(msgcb->mgmt, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) {
|
int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype) {
|
||||||
GetQueueSizeFp fp = pMsgCb->qsizeFp;
|
GetQueueSizeFp fp = msgcb->qsizeFp;
|
||||||
return (*fp)(pMsgCb->mgmt, vgId, qtype);
|
return (*fp)(msgcb->mgmt, vgId, qtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg) {
|
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg) {
|
||||||
SendReqFp fp = tsDefaultMsgCb.sendReqFp;
|
SendReqFp fp = defaultMsgCb.sendReqFp;
|
||||||
return (*fp)(epSet, pMsg);
|
return (*fp)(epSet, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgSendRsp(SRpcMsg* pMsg) {
|
void tmsgSendRsp(SRpcMsg* pMsg) {
|
||||||
SendRspFp fp = tsDefaultMsgCb.sendRspFp;
|
SendRspFp fp = defaultMsgCb.sendRspFp;
|
||||||
return (*fp)(pMsg);
|
return (*fp)(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet) {
|
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet) {
|
||||||
SendRedirectRspFp fp = tsDefaultMsgCb.sendRedirectRspFp;
|
SendRedirectRspFp fp = defaultMsgCb.sendRedirectRspFp;
|
||||||
(*fp)(pMsg, pNewEpSet);
|
(*fp)(pMsg, pNewEpSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) {
|
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) {
|
||||||
RegisterBrokenLinkArgFp fp = tsDefaultMsgCb.registerBrokenLinkArgFp;
|
RegisterBrokenLinkArgFp fp = defaultMsgCb.registerBrokenLinkArgFp;
|
||||||
(*fp)(pMsg);
|
(*fp)(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) {
|
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) {
|
||||||
ReleaseHandleFp fp = tsDefaultMsgCb.releaseHandleFp;
|
ReleaseHandleFp fp = defaultMsgCb.releaseHandleFp;
|
||||||
(*fp)(pHandle, type);
|
(*fp)(pHandle, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgReportStartup(const char* name, const char* desc) {
|
void tmsgReportStartup(const char* name, const char* desc) {
|
||||||
ReportStartup fp = tsDefaultMsgCb.reportStartupFp;
|
ReportStartup fp = defaultMsgCb.reportStartupFp;
|
||||||
(*fp)(name, desc);
|
(*fp)(name, desc);
|
||||||
}
|
}
|
|
@ -250,7 +250,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst->acctId = strtoll(str, NULL, 10);
|
dst->acctId = taosStr2Int32(str, NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((type & T_NAME_DB) == T_NAME_DB) {
|
if ((type & T_NAME_DB) == T_NAME_DB) {
|
||||||
|
|
|
@ -1063,7 +1063,7 @@ bool tdSTpRowGetVal(STSRow *pRow, col_id_t colId, col_type_t colType, int32_t fl
|
||||||
|
|
||||||
int32_t tdGetColDataOfRow(SCellVal *pVal, SDataCol *pCol, int32_t row, int8_t bitmapMode) {
|
int32_t tdGetColDataOfRow(SCellVal *pVal, SDataCol *pCol, int32_t row, int8_t bitmapMode) {
|
||||||
if (isAllRowsNone(pCol)) {
|
if (isAllRowsNone(pCol)) {
|
||||||
pVal->valType = TD_VTYPE_NULL;
|
pVal->valType = TD_VTYPE_NONE;
|
||||||
#ifdef TD_SUPPORT_READ2
|
#ifdef TD_SUPPORT_READ2
|
||||||
pVal->val = (void *)getNullValue(pCol->type);
|
pVal->val = (void *)getNullValue(pCol->type);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -590,7 +590,7 @@ int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* dura
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
|
|
||||||
/* get the basic numeric value */
|
/* get the basic numeric value */
|
||||||
int64_t timestamp = strtoll(token, &endPtr, 10);
|
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
/* get the basic numeric value */
|
/* get the basic numeric value */
|
||||||
*duration = strtoll(token, NULL, 10);
|
*duration = taosStr2Int64(token, NULL, 10);
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char *endPtr = NULL;
|
char *endPtr = NULL;
|
||||||
|
|
||||||
*value = strtoll(z, &endPtr, base);
|
*value = taosStr2Int64(z, &endPtr, base);
|
||||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -58,7 +58,7 @@ int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*value = strtoull(z, &endPtr, base);
|
*value = taosStr2UInt64(z, &endPtr, base);
|
||||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -434,7 +434,7 @@ static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *val
|
||||||
// return -1;
|
// return -1;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// *value = strtod(pStr, NULL);
|
// *value = taosStr2Double(pStr, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
double v = strtod(pVariant->pz, NULL);
|
double v = taosStr2Double(pVariant->pz, NULL);
|
||||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||||
taosMemoryFree(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "bmInt.h"
|
#include "bmInt.h"
|
||||||
|
|
||||||
static void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
||||||
|
|
||||||
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
SMonBmInfo bmInfo = {0};
|
SMonBmInfo bmInfo = {0};
|
||||||
|
|
|
@ -38,9 +38,9 @@ static void bmSendErrorRsps(STaosQall *qall, int32_t numOfMsgs, int32_t code) {
|
||||||
static inline void bmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
static inline void bmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.code = code,
|
.code = code,
|
||||||
.info = pMsg->info,
|
|
||||||
.pCont = pMsg->info.rsp,
|
.pCont = pMsg->info.rsp,
|
||||||
.contLen = pMsg->info.rspLen,
|
.contLen = pMsg->info.rspLen,
|
||||||
|
.info = pMsg->info,
|
||||||
};
|
};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,9 @@ typedef struct SDnodeMgmt {
|
||||||
SSingleWorker mgmtWorker;
|
SSingleWorker mgmtWorker;
|
||||||
ProcessCreateNodeFp processCreateNodeFp;
|
ProcessCreateNodeFp processCreateNodeFp;
|
||||||
ProcessDropNodeFp processDropNodeFp;
|
ProcessDropNodeFp processDropNodeFp;
|
||||||
IsNodeRequiredFp isNodeRequiredFp;
|
SendMonitorReportFp sendMonitorReportFp;
|
||||||
|
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||||
|
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||||
} SDnodeMgmt;
|
} SDnodeMgmt;
|
||||||
|
|
||||||
// dmHandle.c
|
// dmHandle.c
|
||||||
|
@ -43,11 +45,6 @@ int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dmMonitor.c
|
|
||||||
void dmGetVnodeLoads(SDnodeMgmt *pMgmt, SMonVloadInfo *pInfo);
|
|
||||||
void dmGetMnodeLoads(SDnodeMgmt *pMgmt, SMonMloadInfo *pInfo);
|
|
||||||
void dmSendMonitorReport(SDnodeMgmt *pMgmt);
|
|
||||||
|
|
||||||
// dmWorker.c
|
// dmWorker.c
|
||||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
|
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
||||||
if (pMgmt->pData->dnodeId == 0 || pMgmt->pData->clusterId == 0) {
|
if (pMgmt->pData->dnodeId == 0 || pMgmt->pData->clusterId == 0) {
|
||||||
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
||||||
taosWLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockWrlock(&pMgmt->pData->lock);
|
||||||
pMgmt->pData->dnodeId = pCfg->dnodeId;
|
pMgmt->pData->dnodeId = pCfg->dnodeId;
|
||||||
pMgmt->pData->clusterId = pCfg->clusterId;
|
pMgmt->pData->clusterId = pCfg->clusterId;
|
||||||
dmWriteEps(pMgmt->pData);
|
dmWriteEps(pMgmt->pData);
|
||||||
taosWUnLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
SStatusReq req = {0};
|
SStatusReq req = {0};
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
||||||
req.sver = tsVersion;
|
req.sver = tsVersion;
|
||||||
req.dnodeVer = pMgmt->pData->dnodeVer;
|
req.dnodeVer = pMgmt->pData->dnodeVer;
|
||||||
req.dnodeId = pMgmt->pData->dnodeId;
|
req.dnodeId = pMgmt->pData->dnodeId;
|
||||||
|
@ -69,14 +69,14 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
||||||
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
|
||||||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||||
taosRUnLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
|
|
||||||
SMonVloadInfo vinfo = {0};
|
SMonVloadInfo vinfo = {0};
|
||||||
dmGetVnodeLoads(pMgmt, &vinfo);
|
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||||
req.pVloads = vinfo.pVloads;
|
req.pVloads = vinfo.pVloads;
|
||||||
|
|
||||||
SMonMloadInfo minfo = {0};
|
SMonMloadInfo minfo = {0};
|
||||||
dmGetMnodeLoads(pMgmt, &minfo);
|
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
@ -115,19 +115,18 @@ static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
||||||
|
|
||||||
SServerStatusRsp statusRsp = {0};
|
SServerStatusRsp statusRsp = {0};
|
||||||
SMonMloadInfo minfo = {0};
|
SMonMloadInfo minfo = {0};
|
||||||
dmGetMnodeLoads(pMgmt, &minfo);
|
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||||
if (minfo.isMnode && minfo.load.syncState != TAOS_SYNC_STATE_LEADER &&
|
if (minfo.isMnode && minfo.load.syncState == TAOS_SYNC_STATE_ERROR) {
|
||||||
minfo.load.syncState != TAOS_SYNC_STATE_CANDIDATE) {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonVloadInfo vinfo = {0};
|
SMonVloadInfo vinfo = {0};
|
||||||
dmGetVnodeLoads(pMgmt, &vinfo);
|
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(vinfo.pVloads); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(vinfo.pVloads); ++i) {
|
||||||
SVnodeLoad *pLoad = taosArrayGet(vinfo.pVloads, i);
|
SVnodeLoad *pLoad = taosArrayGet(vinfo.pVloads, i);
|
||||||
if (pLoad->syncState != TAOS_SYNC_STATE_LEADER && pLoad->syncState != TAOS_SYNC_STATE_FOLLOWER) {
|
if (pLoad->syncState == TAOS_SYNC_STATE_ERROR) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
||||||
syncStr(pLoad->syncState));
|
syncStr(pLoad->syncState));
|
||||||
|
|
|
@ -45,7 +45,9 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
pMgmt->name = pInput->name;
|
pMgmt->name = pInput->name;
|
||||||
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
|
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
|
||||||
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
|
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
|
||||||
pMgmt->isNodeRequiredFp = pInput->isNodeRequiredFp;
|
pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp;
|
||||||
|
pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp;
|
||||||
|
pMgmt->getMnodeLoadsFp = pInput->getMnodeLoadsFp;
|
||||||
|
|
||||||
if (dmStartWorker(pMgmt) != 0) {
|
if (dmStartWorker(pMgmt) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1,104 +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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#include "dmInt.h"
|
|
||||||
|
|
||||||
#define dmSendLocalRecv(pMgmt, mtype, func, pInfo) \
|
|
||||||
if (!tsMultiProcess) { \
|
|
||||||
SRpcMsg rsp = {0}; \
|
|
||||||
SRpcMsg req = {.msgType = mtype}; \
|
|
||||||
SEpSet epset = {.inUse = 0, .numOfEps = 1}; \
|
|
||||||
tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN); \
|
|
||||||
epset.eps[0].port = tsServerPort; \
|
|
||||||
rpcSendRecv(pMgmt->msgCb.clientRpc, &epset, &req, &rsp); \
|
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) { \
|
|
||||||
func(rsp.pCont, rsp.contLen, pInfo); \
|
|
||||||
} \
|
|
||||||
rpcFreeCont(rsp.pCont); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmGetMonitorBasicInfo(SDnodeMgmt *pMgmt, SMonBasicInfo *pInfo) {
|
|
||||||
pInfo->protocol = 1;
|
|
||||||
pInfo->dnode_id = pMgmt->pData->dnodeId;
|
|
||||||
pInfo->cluster_id = pMgmt->pData->clusterId;
|
|
||||||
tstrncpy(pInfo->dnode_ep, tsLocalEp, TSDB_EP_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmGetMonitorDnodeInfo(SDnodeMgmt *pMgmt, SMonDnodeInfo *pInfo) {
|
|
||||||
pInfo->uptime = (taosGetTimestampMs() - pMgmt->pData->rebootTime) / (86400000.0f);
|
|
||||||
pInfo->has_mnode = (*pMgmt->isNodeRequiredFp)(MNODE);
|
|
||||||
pInfo->has_qnode = (*pMgmt->isNodeRequiredFp)(QNODE);
|
|
||||||
pInfo->has_snode = (*pMgmt->isNodeRequiredFp)(SNODE);
|
|
||||||
pInfo->has_bnode = (*pMgmt->isNodeRequiredFp)(BNODE);
|
|
||||||
tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name));
|
|
||||||
pInfo->logdir.size = tsLogSpace.size;
|
|
||||||
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
|
||||||
pInfo->tempdir.size = tsTempSpace.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmGetMonitorInfo(SDnodeMgmt *pMgmt, SMonDmInfo *pInfo) {
|
|
||||||
dmGetMonitorBasicInfo(pMgmt, &pInfo->basic);
|
|
||||||
dmGetMonitorDnodeInfo(pMgmt, &pInfo->dnode);
|
|
||||||
dmGetMonitorSystemInfo(&pInfo->sys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dmSendMonitorReport(SDnodeMgmt *pMgmt) {
|
|
||||||
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
|
||||||
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
|
|
||||||
|
|
||||||
SMonDmInfo dmInfo = {0};
|
|
||||||
SMonMmInfo mmInfo = {0};
|
|
||||||
SMonVmInfo vmInfo = {0};
|
|
||||||
SMonQmInfo qmInfo = {0};
|
|
||||||
SMonSmInfo smInfo = {0};
|
|
||||||
SMonBmInfo bmInfo = {0};
|
|
||||||
|
|
||||||
dmGetMonitorInfo(pMgmt, &dmInfo);
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_VM_INFO, tDeserializeSMonVmInfo, &vmInfo);
|
|
||||||
if (dmInfo.dnode.has_mnode) {
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_MM_INFO, tDeserializeSMonMmInfo, &mmInfo);
|
|
||||||
}
|
|
||||||
if (dmInfo.dnode.has_qnode) {
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_QM_INFO, tDeserializeSMonQmInfo, &qmInfo);
|
|
||||||
}
|
|
||||||
if (dmInfo.dnode.has_snode) {
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_SM_INFO, tDeserializeSMonSmInfo, &smInfo);
|
|
||||||
}
|
|
||||||
if (dmInfo.dnode.has_bnode) {
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_BM_INFO, tDeserializeSMonBmInfo, &bmInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
monSetDmInfo(&dmInfo);
|
|
||||||
monSetMmInfo(&mmInfo);
|
|
||||||
monSetVmInfo(&vmInfo);
|
|
||||||
monSetQmInfo(&qmInfo);
|
|
||||||
monSetSmInfo(&smInfo);
|
|
||||||
monSetBmInfo(&bmInfo);
|
|
||||||
tFreeSMonMmInfo(&mmInfo);
|
|
||||||
tFreeSMonVmInfo(&vmInfo);
|
|
||||||
tFreeSMonQmInfo(&qmInfo);
|
|
||||||
tFreeSMonSmInfo(&smInfo);
|
|
||||||
tFreeSMonBmInfo(&bmInfo);
|
|
||||||
monSendReport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dmGetVnodeLoads(SDnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_VM_LOAD, tDeserializeSMonVloadInfo, pInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dmGetMnodeLoads(SDnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
|
||||||
dmSendLocalRecv(pMgmt, TDMT_MON_MM_LOAD, tDeserializeSMonMloadInfo, pInfo);
|
|
||||||
}
|
|
|
@ -50,7 +50,7 @@ static void *dmMonitorThreadFp(void *param) {
|
||||||
int64_t curTime = taosGetTimestampMs();
|
int64_t curTime = taosGetTimestampMs();
|
||||||
float interval = (curTime - lastTime) / 1000.0f;
|
float interval = (curTime - lastTime) / 1000.0f;
|
||||||
if (interval >= tsMonitorInterval) {
|
if (interval >= tsMonitorInterval) {
|
||||||
dmSendMonitorReport(pMgmt);
|
(*pMgmt->sendMonitorReportFp)();
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,9 +153,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
if (code != 0 && terrno != 0) code = terrno;
|
if (code != 0 && terrno != 0) code = terrno;
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.code = code,
|
.code = code,
|
||||||
.info = pMsg->info,
|
|
||||||
.pCont = pMsg->info.rsp,
|
.pCont = pMsg->info.rsp,
|
||||||
.contLen = pMsg->info.rspLen,
|
.contLen = pMsg->info.rspLen,
|
||||||
|
.info = pMsg->info,
|
||||||
};
|
};
|
||||||
rpcSendResponse(&rsp);
|
rpcSendResponse(&rsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,6 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq, bool deployed) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("successed to write %s, deployed:%d", realfile, deployed);
|
dDebug("successed to write %s, deployed:%d", realfile, deployed);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,13 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mmInt.h"
|
#include "mmInt.h"
|
||||||
|
|
||||||
static void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *mmInfo) {
|
void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
|
||||||
mndGetMonitorInfo(pMgmt->pMnode, &mmInfo->cluster, &mmInfo->vgroup, &mmInfo->grant);
|
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->grant);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
||||||
|
pInfo->isMnode = 1;
|
||||||
|
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
|
@ -45,11 +50,6 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
|
||||||
pInfo->isMnode = 1;
|
|
||||||
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
SMonMloadInfo mloads = {0};
|
SMonMloadInfo mloads = {0};
|
||||||
mmGetMnodeLoads(pMgmt, &mloads);
|
mmGetMnodeLoads(pMgmt, &mloads);
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.code = code,
|
.code = code,
|
||||||
.info = pMsg->info,
|
|
||||||
.pCont = pMsg->info.rsp,
|
.pCont = pMsg->info.rsp,
|
||||||
.contLen = pMsg->info.rspLen,
|
.contLen = pMsg->info.rspLen,
|
||||||
|
.info = pMsg->info,
|
||||||
};
|
};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "qmInt.h"
|
#include "qmInt.h"
|
||||||
|
|
||||||
static void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {}
|
void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {}
|
||||||
|
|
||||||
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
SMonQmInfo qmInfo = {0};
|
SMonQmInfo qmInfo = {0};
|
||||||
|
|
|
@ -30,7 +30,6 @@ typedef struct SSnodeMgmt {
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *name;
|
const char *name;
|
||||||
SRWLatch latch;
|
|
||||||
int8_t uniqueWorkerInUse;
|
int8_t uniqueWorkerInUse;
|
||||||
SArray *uniqueWorkers; // SArray<SMultiWorker*>
|
SArray *uniqueWorkers; // SArray<SMultiWorker*>
|
||||||
SSingleWorker sharedWorker;
|
SSingleWorker sharedWorker;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "smInt.h"
|
#include "smInt.h"
|
||||||
|
|
||||||
static void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
||||||
|
|
||||||
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
SMonSmInfo smInfo = {0};
|
SMonSmInfo smInfo = {0};
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
static inline void smSendRsp(SRpcMsg *pMsg, int32_t code) {
|
static inline void smSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.code = code,
|
.code = code,
|
||||||
.info = pMsg->info,
|
|
||||||
.pCont = pMsg->info.rsp,
|
.pCont = pMsg->info.rsp,
|
||||||
.contLen = pMsg->info.rspLen,
|
.contLen = pMsg->info.rspLen,
|
||||||
|
.info = pMsg->info,
|
||||||
};
|
};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,21 +26,21 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SVnodeMgmt {
|
typedef struct SVnodeMgmt {
|
||||||
SDnodeData *pData;
|
SDnodeData *pData;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *name;
|
const char *name;
|
||||||
SQWorkerPool queryPool;
|
SQWorkerPool queryPool;
|
||||||
SQWorkerPool fetchPool;
|
SQWorkerPool fetchPool;
|
||||||
SWWorkerPool syncPool;
|
SWWorkerPool syncPool;
|
||||||
SWWorkerPool writePool;
|
SWWorkerPool writePool;
|
||||||
SWWorkerPool mergePool;
|
SWWorkerPool mergePool;
|
||||||
SSingleWorker mgmtWorker;
|
SSingleWorker mgmtWorker;
|
||||||
SSingleWorker monitorWorker;
|
SSingleWorker monitorWorker;
|
||||||
SHashObj *hash;
|
SHashObj *hash;
|
||||||
SRWLatch latch;
|
TdThreadRwlock lock;
|
||||||
SVnodesStat state;
|
SVnodesStat state;
|
||||||
STfs *pTfs;
|
STfs *pTfs;
|
||||||
} SVnodeMgmt;
|
} SVnodeMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "vmInt.h"
|
#include "vmInt.h"
|
||||||
|
|
||||||
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
int32_t size = taosHashGetSize(pMgmt->hash);
|
int32_t size = taosHashGetSize(pMgmt->hash);
|
||||||
|
@ -38,7 +38,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
*numOfVnodes = num;
|
*numOfVnodes = num;
|
||||||
|
|
||||||
return pVnodes;
|
return pVnodes;
|
||||||
|
@ -128,7 +128,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
|
|
||||||
*numOfVnodes = vnodesNum;
|
*numOfVnodes = vnodesNum;
|
||||||
code = 0;
|
code = 0;
|
||||||
dInfo("succcessed to read file %s", file);
|
dDebug("succcessed to read file %s", file);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (content != NULL) taosMemoryFree(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "vmInt.h"
|
#include "vmInt.h"
|
||||||
|
|
||||||
static void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||||
pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad));
|
pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad));
|
||||||
if (pInfo->pVloads == NULL) return;
|
if (pInfo->pVloads == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
|
@ -34,10 +34,10 @@ static void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||||
pIter = taosHashIterate(pMgmt->hash, pIter);
|
pIter = taosHashIterate(pMgmt->hash, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||||
SMonVloadInfo vloads = {0};
|
SMonVloadInfo vloads = {0};
|
||||||
vmGetVnodeLoads(pMgmt, &vloads);
|
vmGetVnodeLoads(pMgmt, &vloads);
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,14 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
|
||||||
SVnodeObj *pVnode = NULL;
|
SVnodeObj *pVnode = NULL;
|
||||||
int32_t refCount = 0;
|
int32_t refCount = 0;
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode);
|
taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
|
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
|
||||||
} else {
|
} else {
|
||||||
refCount = atomic_add_fetch_32(&pVnode->refCount, 1);
|
refCount = atomic_add_fetch_32(&pVnode->refCount, 1);
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
if (pVnode != NULL) {
|
if (pVnode != NULL) {
|
||||||
dTrace("vgId:%d, acquire vnode, refCount:%d", pVnode->vgId, refCount);
|
dTrace("vgId:%d, acquire vnode, refCount:%d", pVnode->vgId, refCount);
|
||||||
|
@ -39,9 +39,9 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
|
||||||
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
if (pVnode == NULL) return;
|
if (pVnode == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
|
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
dTrace("vgId:%d, release vnode, refCount:%d", pVnode->vgId, refCount);
|
dTrace("vgId:%d, release vnode, refCount:%d", pVnode->vgId, refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *));
|
int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *));
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
char path[TSDB_FILENAME_LEN] = {0};
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
while (pVnode->refCount > 0) taosMsleep(10);
|
while (pVnode->refCount > 0) taosMsleep(10);
|
||||||
|
@ -239,6 +239,7 @@ static void vmCleanup(SVnodeMgmt *pMgmt) {
|
||||||
vmStopWorker(pMgmt);
|
vmStopWorker(pMgmt);
|
||||||
vnodeCleanup();
|
vnodeCleanup();
|
||||||
tfsClose(pMgmt->pTfs);
|
tfsClose(pMgmt->pTfs);
|
||||||
|
taosThreadRwlockDestroy(&pMgmt->lock);
|
||||||
taosMemoryFree(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +261,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
pMgmt->msgCb.queueFps[MERGE_QUEUE] = (PutToQueueFp)vmPutRpcMsgToMergeQueue;
|
pMgmt->msgCb.queueFps[MERGE_QUEUE] = (PutToQueueFp)vmPutRpcMsgToMergeQueue;
|
||||||
pMgmt->msgCb.qsizeFp = (GetQueueSizeFp)vmGetQueueSize;
|
pMgmt->msgCb.qsizeFp = (GetQueueSizeFp)vmGetQueueSize;
|
||||||
pMgmt->msgCb.mgmt = pMgmt;
|
pMgmt->msgCb.mgmt = pMgmt;
|
||||||
taosInitRWLatch(&pMgmt->latch);
|
taosThreadRwlockInit(&pMgmt->lock, NULL);
|
||||||
|
|
||||||
SDiskCfg dCfg = {0};
|
SDiskCfg dCfg = {0};
|
||||||
tstrncpy(dCfg.dir, tsDataDir, TSDB_FILENAME_LEN);
|
tstrncpy(dCfg.dir, tsDataDir, TSDB_FILENAME_LEN);
|
||||||
|
@ -334,19 +335,23 @@ static int32_t vmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vmStart(SVnodeMgmt *pMgmt) {
|
static int32_t vmStart(SVnodeMgmt *pMgmt) {
|
||||||
taosRLockLatch(&pMgmt->latch);
|
int32_t numOfVnodes = 0;
|
||||||
|
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
while (pIter) {
|
SVnodeObj *pVnode = pVnodes[i];
|
||||||
SVnodeObj **ppVnode = pIter;
|
|
||||||
if (ppVnode == NULL || *ppVnode == NULL) continue;
|
|
||||||
|
|
||||||
SVnodeObj *pVnode = *ppVnode;
|
|
||||||
vnodeStart(pVnode->pImpl);
|
vnodeStart(pVnode->pImpl);
|
||||||
pIter = taosHashIterate(pMgmt->hash, pIter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
|
SVnodeObj *pVnode = pVnodes[i];
|
||||||
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pVnodes != NULL) {
|
||||||
|
taosMemoryFree(pVnodes);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DND_IMP_H_
|
#ifndef _TD_DND_MGMT_H_
|
||||||
#define _TD_DND_IMP_H_
|
#define _TD_DND_MGMT_H_
|
||||||
|
|
||||||
// tobe deleted
|
// tobe deleted
|
||||||
#include "uv.h"
|
#include "uv.h"
|
||||||
|
@ -70,7 +70,7 @@ typedef struct SMgmtWrapper {
|
||||||
const char *name;
|
const char *name;
|
||||||
char *path;
|
char *path;
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
SRWLatch latch;
|
TdThreadRwlock lock;
|
||||||
EDndNodeType ntype;
|
EDndNodeType ntype;
|
||||||
bool deployed;
|
bool deployed;
|
||||||
bool required;
|
bool required;
|
||||||
|
@ -165,16 +165,13 @@ SMsgCb dmGetMsgcb(SDnode *pDnode);
|
||||||
int32_t dmInitMsgHandle(SDnode *pDnode);
|
int32_t dmInitMsgHandle(SDnode *pDnode);
|
||||||
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// mgmt nodes
|
// dmMonitor.c
|
||||||
SMgmtFunc dmGetMgmtFunc();
|
void dmSendMonitorReport();
|
||||||
SMgmtFunc bmGetMgmtFunc();
|
void dmGetVnodeLoads(SMonVloadInfo *pInfo);
|
||||||
SMgmtFunc qmGetMgmtFunc();
|
void dmGetMnodeLoads(SMonMloadInfo *pInfo);
|
||||||
SMgmtFunc smGetMgmtFunc();
|
|
||||||
SMgmtFunc vmGetMgmtFunc();
|
|
||||||
SMgmtFunc mmGetMgmtFunc();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DND_IMP_H_*/
|
#endif /*_TD_DND_MGMT_H_*/
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_DND_NODES_H_
|
||||||
|
#define _TD_DND_NODES_H_
|
||||||
|
|
||||||
|
#include "dmInt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SMgmtFunc dmGetMgmtFunc();
|
||||||
|
SMgmtFunc bmGetMgmtFunc();
|
||||||
|
SMgmtFunc qmGetMgmtFunc();
|
||||||
|
SMgmtFunc smGetMgmtFunc();
|
||||||
|
SMgmtFunc vmGetMgmtFunc();
|
||||||
|
SMgmtFunc mmGetMgmtFunc();
|
||||||
|
|
||||||
|
void mmGetMonitorInfo(void *pMgmt, SMonMmInfo *pInfo);
|
||||||
|
void vmGetMonitorInfo(void *pMgmt, SMonVmInfo *pInfo);
|
||||||
|
void qmGetMonitorInfo(void *pMgmt, SMonQmInfo *pInfo);
|
||||||
|
void smGetMonitorInfo(void *pMgmt, SMonSmInfo *pInfo);
|
||||||
|
void bmGetMonitorInfo(void *pMgmt, SMonBmInfo *pInfo);
|
||||||
|
|
||||||
|
void vmGetVnodeLoads(void *pMgmt, SMonVloadInfo *pInfo);
|
||||||
|
void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_DND_NODES_H_*/
|
|
@ -168,11 +168,6 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dmIsNodeRequired(EDndNodeType ntype) {
|
|
||||||
SDnode *pDnode = dmInstance();
|
|
||||||
return pDnode->wrappers[ntype].required;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
||||||
SMgmtInputOpt opt = {
|
SMgmtInputOpt opt = {
|
||||||
.path = pWrapper->path,
|
.path = pWrapper->path,
|
||||||
|
@ -180,7 +175,9 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
||||||
.pData = &pWrapper->pDnode->data,
|
.pData = &pWrapper->pDnode->data,
|
||||||
.processCreateNodeFp = dmProcessCreateNodeReq,
|
.processCreateNodeFp = dmProcessCreateNodeReq,
|
||||||
.processDropNodeFp = dmProcessDropNodeReq,
|
.processDropNodeFp = dmProcessDropNodeReq,
|
||||||
.isNodeRequiredFp = dmIsNodeRequired,
|
.sendMonitorReportFp = dmSendMonitorReport,
|
||||||
|
.getVnodeLoadsFp = dmGetVnodeLoads,
|
||||||
|
.getMnodeLoadsFp = dmGetMnodeLoads,
|
||||||
};
|
};
|
||||||
|
|
||||||
opt.msgCb = dmGetMsgcb(pWrapper->pDnode);
|
opt.msgCb = dmGetMsgcb(pWrapper->pDnode);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmMgmt.h"
|
#include "dmMgmt.h"
|
||||||
|
#include "dmNodes.h"
|
||||||
|
|
||||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||||
|
@ -90,7 +91,7 @@ static int32_t dmInitVars(SDnode *pDnode, EDndNodeType rtype) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosInitRWLatch(&pData->latch);
|
taosThreadRwlockInit(&pData->lock, NULL);
|
||||||
taosThreadMutexInit(&pDnode->mutex, NULL);
|
taosThreadMutexInit(&pDnode->mutex, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +100,7 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
taosMemoryFreeClear(pWrapper->path);
|
taosMemoryFreeClear(pWrapper->path);
|
||||||
|
taosThreadRwlockDestroy(&pWrapper->lock);
|
||||||
}
|
}
|
||||||
if (pDnode->lockfile != NULL) {
|
if (pDnode->lockfile != NULL) {
|
||||||
taosUnLockFile(pDnode->lockfile);
|
taosUnLockFile(pDnode->lockfile);
|
||||||
|
@ -107,7 +109,7 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeData *pData = &pDnode->data;
|
SDnodeData *pData = &pDnode->data;
|
||||||
taosWLockLatch(&pData->latch);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
if (pData->dnodeEps != NULL) {
|
if (pData->dnodeEps != NULL) {
|
||||||
taosArrayDestroy(pData->dnodeEps);
|
taosArrayDestroy(pData->dnodeEps);
|
||||||
pData->dnodeEps = NULL;
|
pData->dnodeEps = NULL;
|
||||||
|
@ -116,8 +118,9 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
taosHashCleanup(pData->dnodeHash);
|
taosHashCleanup(pData->dnodeHash);
|
||||||
pData->dnodeHash = NULL;
|
pData->dnodeHash = NULL;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
|
|
||||||
|
taosThreadRwlockDestroy(&pData->lock);
|
||||||
taosThreadMutexDestroy(&pDnode->mutex);
|
taosThreadMutexDestroy(&pDnode->mutex);
|
||||||
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
||||||
}
|
}
|
||||||
|
@ -150,7 +153,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
|
||||||
if (ntype == DNODE) {
|
if (ntype == DNODE) {
|
||||||
pWrapper->proc.ptype = DND_PROC_SINGLE;
|
pWrapper->proc.ptype = DND_PROC_SINGLE;
|
||||||
}
|
}
|
||||||
taosInitRWLatch(&pWrapper->latch);
|
taosThreadRwlockInit(&pWrapper->lock, NULL);
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
|
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
|
||||||
pWrapper->path = strdup(path);
|
pWrapper->path = strdup(path);
|
||||||
|
@ -189,7 +192,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dmReportStartup("dnode-transport", "initialized");
|
dmReportStartup("dnode-transport", "initialized");
|
||||||
dInfo("dnode is created, ptr:%p", pDnode);
|
dDebug("dnode is created, ptr:%p", pDnode);
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -208,7 +211,7 @@ void dmCleanupDnode(SDnode *pDnode) {
|
||||||
dmCleanupClient(pDnode);
|
dmCleanupClient(pDnode);
|
||||||
dmCleanupServer(pDnode);
|
dmCleanupServer(pDnode);
|
||||||
dmClearVars(pDnode);
|
dmClearVars(pDnode);
|
||||||
dInfo("dnode is closed, ptr:%p", pDnode);
|
dDebug("dnode is closed, ptr:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
||||||
|
@ -222,7 +225,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
SMgmtWrapper *pRetWrapper = pWrapper;
|
SMgmtWrapper *pRetWrapper = pWrapper;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosThreadRwlockRdlock(&pWrapper->lock);
|
||||||
if (pWrapper->deployed) {
|
if (pWrapper->deployed) {
|
||||||
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
||||||
dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount);
|
||||||
|
@ -230,7 +233,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
pRetWrapper = NULL;
|
pRetWrapper = NULL;
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
|
|
||||||
return pRetWrapper;
|
return pRetWrapper;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +241,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosThreadRwlockRdlock(&pWrapper->lock);
|
||||||
if (pWrapper->deployed || (InParentProc(pWrapper) && pWrapper->required)) {
|
if (pWrapper->deployed || (InParentProc(pWrapper) && pWrapper->required)) {
|
||||||
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
||||||
dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount);
|
||||||
|
@ -246,7 +249,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -254,9 +257,9 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
void dmReleaseWrapper(SMgmtWrapper *pWrapper) {
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper) {
|
||||||
if (pWrapper == NULL) return;
|
if (pWrapper == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosThreadRwlockRdlock(&pWrapper->lock);
|
||||||
int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1);
|
int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1);
|
||||||
taosRUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
dTrace("node:%s, is released, ref:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is released, ref:%d", pWrapper->name, refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +278,7 @@ static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) {
|
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
dDebug("start to process net test req");
|
dDebug("msg:%p, net test req will be processed", pMsg);
|
||||||
SRpcMsg rsp = {.code = 0, .info = pMsg->info};
|
SRpcMsg rsp = {.code = 0, .info = pMsg->info};
|
||||||
rsp.pCont = rpcMallocCont(pMsg->contLen);
|
rsp.pCont = rpcMallocCont(pMsg->contLen);
|
||||||
if (rsp.pCont == NULL) {
|
if (rsp.pCont == NULL) {
|
||||||
|
@ -287,8 +290,7 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) {
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
dDebug("start to process server startup status req");
|
dDebug("msg:%p, server startup status req will be processed", pMsg);
|
||||||
|
|
||||||
SServerStatusRsp statusRsp = {0};
|
SServerStatusRsp statusRsp = {0};
|
||||||
dmGetServerStartupStatus(pDnode, &statusRsp);
|
dmGetServerStartupStatus(pDnode, &statusRsp);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "dmMgmt.h"
|
||||||
|
#include "dmNodes.h"
|
||||||
|
|
||||||
|
#define dmSendLocalRecv(pDnode, mtype, func, pInfo) \
|
||||||
|
SRpcMsg rsp = {0}; \
|
||||||
|
SRpcMsg req = {.msgType = mtype}; \
|
||||||
|
SEpSet epset = {.inUse = 0, .numOfEps = 1}; \
|
||||||
|
tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN); \
|
||||||
|
epset.eps[0].port = tsServerPort; \
|
||||||
|
rpcSendRecv(pDnode->trans.clientRpc, &epset, &req, &rsp); \
|
||||||
|
if (rsp.code == 0 && rsp.contLen > 0) { \
|
||||||
|
func(rsp.pCont, rsp.contLen, pInfo); \
|
||||||
|
} \
|
||||||
|
rpcFreeCont(rsp.pCont);
|
||||||
|
|
||||||
|
static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||||
|
pInfo->protocol = 1;
|
||||||
|
pInfo->dnode_id = pDnode->data.dnodeId;
|
||||||
|
pInfo->cluster_id = pDnode->data.clusterId;
|
||||||
|
tstrncpy(pInfo->dnode_ep, tsLocalEp, TSDB_EP_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
||||||
|
pInfo->uptime = (taosGetTimestampMs() - pDnode->data.rebootTime) / (86400000.0f);
|
||||||
|
pInfo->has_mnode = pDnode->wrappers[MNODE].required;
|
||||||
|
pInfo->has_qnode = pDnode->wrappers[QNODE].required;
|
||||||
|
pInfo->has_snode = pDnode->wrappers[SNODE].required;
|
||||||
|
pInfo->has_bnode = pDnode->wrappers[BNODE].required;
|
||||||
|
tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name));
|
||||||
|
pInfo->logdir.size = tsLogSpace.size;
|
||||||
|
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
||||||
|
pInfo->tempdir.size = tsTempSpace.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetDmMonitorInfo(SDnode *pDnode) {
|
||||||
|
SMonDmInfo dmInfo = {0};
|
||||||
|
dmGetMonitorBasicInfo(pDnode, &dmInfo.basic);
|
||||||
|
dmGetMonitorDnodeInfo(pDnode, &dmInfo.dnode);
|
||||||
|
dmGetMonitorSystemInfo(&dmInfo.sys);
|
||||||
|
monSetDmInfo(&dmInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetMmMonitorInfo(SDnode *pDnode) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
SMonMmInfo mmInfo = {0};
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_MM_INFO, tDeserializeSMonMmInfo, &mmInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
mmGetMonitorInfo(pWrapper->pMgmt, &mmInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
monSetMmInfo(&mmInfo);
|
||||||
|
tFreeSMonMmInfo(&mmInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetVmMonitorInfo(SDnode *pDnode) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
SMonVmInfo vmInfo = {0};
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_VM_INFO, tDeserializeSMonVmInfo, &vmInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
vmGetMonitorInfo(pWrapper->pMgmt, &vmInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
monSetVmInfo(&vmInfo);
|
||||||
|
tFreeSMonVmInfo(&vmInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetQmMonitorInfo(SDnode *pDnode) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[QNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
SMonQmInfo qmInfo = {0};
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_QM_INFO, tDeserializeSMonQmInfo, &qmInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
qmGetMonitorInfo(pWrapper->pMgmt, &qmInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
monSetQmInfo(&qmInfo);
|
||||||
|
tFreeSMonQmInfo(&qmInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetSmMonitorInfo(SDnode *pDnode) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[SNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
SMonSmInfo smInfo = {0};
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_SM_INFO, tDeserializeSMonSmInfo, &smInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
smGetMonitorInfo(pWrapper->pMgmt, &smInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
monSetSmInfo(&smInfo);
|
||||||
|
tFreeSMonSmInfo(&smInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dmGetBmMonitorInfo(SDnode *pDnode) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[BNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
SMonBmInfo bmInfo = {0};
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_BM_INFO, tDeserializeSMonBmInfo, &bmInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
bmGetMonitorInfo(pWrapper->pMgmt, &bmInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
monSetBmInfo(&bmInfo);
|
||||||
|
tFreeSMonBmInfo(&bmInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmSendMonitorReport() {
|
||||||
|
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
||||||
|
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
|
||||||
|
|
||||||
|
SDnode *pDnode = dmInstance();
|
||||||
|
dmGetDmMonitorInfo(pDnode);
|
||||||
|
dmGetMmMonitorInfo(pDnode);
|
||||||
|
dmGetVmMonitorInfo(pDnode);
|
||||||
|
dmGetQmMonitorInfo(pDnode);
|
||||||
|
dmGetSmMonitorInfo(pDnode);
|
||||||
|
dmGetBmMonitorInfo(pDnode);
|
||||||
|
monSendReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmGetVnodeLoads(SMonVloadInfo *pInfo) {
|
||||||
|
SDnode *pDnode = dmInstance();
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
|
||||||
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_VM_LOAD, tDeserializeSMonVloadInfo, pInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
vmGetVnodeLoads(pWrapper->pMgmt, pInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmGetMnodeLoads(SMonMloadInfo *pInfo) {
|
||||||
|
SDnode *pDnode = dmInstance();
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
|
||||||
|
if (tsMultiProcess) {
|
||||||
|
dmSendLocalRecv(pDnode, TDMT_MON_MM_LOAD, tDeserializeSMonMloadInfo, pInfo);
|
||||||
|
} else if (pWrapper->pMgmt != NULL) {
|
||||||
|
mmGetMnodeLoads(pWrapper->pMgmt, pInfo);
|
||||||
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
|
}
|
|
@ -78,7 +78,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
||||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||||
|
|
||||||
if (pWrapper->ntype == DNODE || InChildProc(pWrapper)) {
|
if (pWrapper->ntype == DNODE || InChildProc(pWrapper)) {
|
||||||
tmsgSetDefaultMsgCb(&input.msgCb);
|
tmsgSetDefault(&input.msgCb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OnlyInSingleProc(pWrapper)) {
|
if (OnlyInSingleProc(pWrapper)) {
|
||||||
|
@ -186,12 +186,12 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pWrapper->latch);
|
taosThreadRwlockWrlock(&pWrapper->lock);
|
||||||
if (pWrapper->pMgmt != NULL) {
|
if (pWrapper->pMgmt != NULL) {
|
||||||
(*pWrapper->func.closeFp)(pWrapper->pMgmt);
|
(*pWrapper->func.closeFp)(pWrapper->pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
|
|
||||||
if (!OnlyInSingleProc(pWrapper)) {
|
if (!OnlyInSingleProc(pWrapper)) {
|
||||||
dmCleanupProc(pWrapper);
|
dmCleanupProc(pWrapper);
|
||||||
|
|
|
@ -433,7 +433,7 @@ void dmCloseProcRpcHandles(SProc *proc) {
|
||||||
SRpcHandleInfo *pInfo = taosHashIterate(proc->hash, NULL);
|
SRpcHandleInfo *pInfo = taosHashIterate(proc->hash, NULL);
|
||||||
while (pInfo != NULL) {
|
while (pInfo != NULL) {
|
||||||
dError("node:%s, the child process dies and send an offline rsp to handle:%p", proc->name, pInfo->handle);
|
dError("node:%s, the child process dies and send an offline rsp to handle:%p", proc->name, pInfo->handle);
|
||||||
SRpcMsg rpcMsg = {.info = *pInfo, .code = TSDB_CODE_NODE_OFFLINE};
|
SRpcMsg rpcMsg = {.code = TSDB_CODE_NODE_OFFLINE, .info = *pInfo};
|
||||||
rpcSendResponse(&rpcMsg);
|
rpcSendResponse(&rpcMsg);
|
||||||
pInfo = taosHashIterate(proc->hash, pInfo);
|
pInfo = taosHashIterate(proc->hash, pInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,66 +344,6 @@ void dmCleanupClient(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dmGetHideUserAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
|
||||||
int32_t code = 0;
|
|
||||||
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
|
||||||
|
|
||||||
if (strcmp(user, INTERNAL_USER) == 0) {
|
|
||||||
taosEncryptPass_c((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass);
|
|
||||||
} else if (strcmp(user, TSDB_NETTEST_USER) == 0) {
|
|
||||||
taosEncryptPass_c((uint8_t *)(TSDB_NETTEST_USER), strlen(TSDB_NETTEST_USER), pass);
|
|
||||||
} else {
|
|
||||||
code = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code == 0) {
|
|
||||||
memcpy(secret, pass, TSDB_PASSWORD_LEN);
|
|
||||||
*spi = 1;
|
|
||||||
*encrypt = 0;
|
|
||||||
*ckey = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret,
|
|
||||||
char *ckey) {
|
|
||||||
if (dmGetHideUserAuth(user, spi, encrypt, secret, ckey) == 0) {
|
|
||||||
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SAuthReq authReq = {0};
|
|
||||||
tstrncpy(authReq.user, user, TSDB_USER_LEN);
|
|
||||||
int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq);
|
|
||||||
void *pReq = rpcMallocCont(contLen);
|
|
||||||
tSerializeSAuthReq(pReq, contLen, &authReq);
|
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .info.ahandle = (void *)9528};
|
|
||||||
SRpcMsg rpcRsp = {0};
|
|
||||||
SEpSet epSet = {0};
|
|
||||||
dTrace("user:%s, send user auth req to other mnodes, spi:%d encrypt:%d", user, authReq.spi, authReq.encrypt);
|
|
||||||
dmGetMnodeEpSet(&pDnode->data, &epSet);
|
|
||||||
dmSendRecv(&epSet, &rpcMsg, &rpcRsp);
|
|
||||||
|
|
||||||
if (rpcRsp.code != 0) {
|
|
||||||
terrno = rpcRsp.code;
|
|
||||||
dError("user:%s, failed to get user auth from other mnodes since %s", user, terrstr());
|
|
||||||
} else {
|
|
||||||
SAuthRsp authRsp = {0};
|
|
||||||
tDeserializeSAuthReq(rpcRsp.pCont, rpcRsp.contLen, &authRsp);
|
|
||||||
memcpy(secret, authRsp.secret, TSDB_PASSWORD_LEN);
|
|
||||||
memcpy(ckey, authRsp.ckey, TSDB_PASSWORD_LEN);
|
|
||||||
*spi = authRsp.spi;
|
|
||||||
*encrypt = authRsp.encrypt;
|
|
||||||
dTrace("user:%s, success to get user auth from other mnodes, spi:%d encrypt:%d", user, authRsp.spi,
|
|
||||||
authRsp.encrypt);
|
|
||||||
}
|
|
||||||
|
|
||||||
rpcFreeCont(rpcRsp.pCont);
|
|
||||||
return rpcRsp.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmInitServer(SDnode *pDnode) {
|
int32_t dmInitServer(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
|
||||||
|
@ -416,7 +356,6 @@ int32_t dmInitServer(SDnode *pDnode) {
|
||||||
rpcInit.sessions = tsMaxShellConns;
|
rpcInit.sessions = tsMaxShellConns;
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.afp = (RpcAfp)dmRetrieveUserAuthInfo;
|
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
|
|
||||||
pTrans->serverRpc = rpcOpen(&rpcInit);
|
pTrans->serverRpc = rpcOpen(&rpcInit);
|
||||||
|
|
|
@ -89,21 +89,23 @@ typedef enum {
|
||||||
|
|
||||||
typedef int32_t (*ProcessCreateNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
|
typedef int32_t (*ProcessCreateNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
|
||||||
typedef int32_t (*ProcessDropNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
|
typedef int32_t (*ProcessDropNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
|
||||||
typedef bool (*IsNodeRequiredFp)(EDndNodeType ntype);
|
typedef void (*SendMonitorReportFp)();
|
||||||
|
typedef void (*GetVnodeLoadsFp)();
|
||||||
|
typedef void (*GetMnodeLoadsFp)();
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
int64_t dnodeVer;
|
int64_t dnodeVer;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int64_t rebootTime;
|
int64_t rebootTime;
|
||||||
bool dropped;
|
bool dropped;
|
||||||
bool stopped;
|
bool stopped;
|
||||||
SEpSet mnodeEps;
|
SEpSet mnodeEps;
|
||||||
SArray *dnodeEps;
|
SArray *dnodeEps;
|
||||||
SHashObj *dnodeHash;
|
SHashObj *dnodeHash;
|
||||||
SRWLatch latch;
|
TdThreadRwlock lock;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
} SDnodeData;
|
} SDnodeData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -113,7 +115,9 @@ typedef struct {
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
ProcessCreateNodeFp processCreateNodeFp;
|
ProcessCreateNodeFp processCreateNodeFp;
|
||||||
ProcessDropNodeFp processDropNodeFp;
|
ProcessDropNodeFp processDropNodeFp;
|
||||||
IsNodeRequiredFp isNodeRequiredFp;
|
SendMonitorReportFp sendMonitorReportFp;
|
||||||
|
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||||
|
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||||
} SMgmtInputOpt;
|
} SMgmtInputOpt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -21,7 +21,7 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep);
|
||||||
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps);
|
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps);
|
||||||
|
|
||||||
static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
|
static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
|
||||||
taosRLockLatch(&pData->latch);
|
taosThreadRwlockRdlock(&pData->lock);
|
||||||
|
|
||||||
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
if (pDnodeEp != NULL) {
|
if (pDnodeEp != NULL) {
|
||||||
|
@ -36,7 +36,7 @@ static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmReadEps(SDnodeData *pData) {
|
int32_t dmReadEps(SDnodeData *pData) {
|
||||||
|
@ -232,7 +232,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
|
||||||
int32_t numOfEps = taosArrayGetSize(eps);
|
int32_t numOfEps = taosArrayGetSize(eps);
|
||||||
if (numOfEps <= 0) return;
|
if (numOfEps <= 0) return;
|
||||||
|
|
||||||
taosWLockLatch(&pData->latch);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
|
|
||||||
int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pData->dnodeEps);
|
int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pData->dnodeEps);
|
||||||
if (numOfEps != numOfEpsOld) {
|
if (numOfEps != numOfEpsOld) {
|
||||||
|
@ -246,7 +246,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
||||||
|
@ -292,7 +292,7 @@ static void dmPrintEps(SDnodeData *pData) {
|
||||||
static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
|
static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (dnodeId == 0) return changed;
|
if (dnodeId == 0) return changed;
|
||||||
taosRLockLatch(&pData->latch);
|
taosThreadRwlockRdlock(&pData->lock);
|
||||||
|
|
||||||
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
if (pDnodeEp != NULL) {
|
if (pDnodeEp != NULL) {
|
||||||
|
@ -304,24 +304,23 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
taosRLockLatch(&pData->latch);
|
taosThreadRwlockRdlock(&pData->lock);
|
||||||
*pEpSet = pData->mnodeEps;
|
*pEpSet = pData->mnodeEps;
|
||||||
taosRUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
|
|
||||||
taosWLockLatch(&pData->latch);
|
|
||||||
pData->mnodeEps = *pEpSet;
|
pData->mnodeEps = *pEpSet;
|
||||||
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
|
|
||||||
|
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
||||||
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
||||||
dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
|
dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pData->latch);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,6 +365,8 @@ typedef struct {
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
int32_t version;
|
int32_t version;
|
||||||
|
int32_t tagVer;
|
||||||
|
int32_t colVer;
|
||||||
int32_t nextColId;
|
int32_t nextColId;
|
||||||
float xFilesFactor;
|
float xFilesFactor;
|
||||||
int32_t delay;
|
int32_t delay;
|
||||||
|
@ -463,7 +465,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
char cgroup[TSDB_CGROUP_LEN];
|
char cgroup[TSDB_CGROUP_LEN];
|
||||||
char appId[TSDB_CGROUP_LEN];
|
char clientId[256];
|
||||||
int8_t updateType; // used only for update
|
int8_t updateType; // used only for update
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
int32_t status;
|
int32_t status;
|
||||||
|
|
|
@ -37,7 +37,7 @@ int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray
|
||||||
|
|
||||||
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,6 +427,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
||||||
pConsumerOld = mndAcquireConsumer(pMnode, consumerId);
|
pConsumerOld = mndAcquireConsumer(pMnode, consumerId);
|
||||||
if (pConsumerOld == NULL) {
|
if (pConsumerOld == NULL) {
|
||||||
pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup);
|
pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup);
|
||||||
|
tstrncpy(pConsumerNew->clientId, subscribe.clientId, 256);
|
||||||
pConsumerNew->updateType = CONSUMER_UPDATE__MODIFY;
|
pConsumerNew->updateType = CONSUMER_UPDATE__MODIFY;
|
||||||
pConsumerNew->rebNewTopics = newSub;
|
pConsumerNew->rebNewTopics = newSub;
|
||||||
subscribe.topicNames = NULL;
|
subscribe.topicNames = NULL;
|
||||||
|
@ -848,11 +849,11 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)cgroup, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)cgroup, false);
|
||||||
|
|
||||||
// app id
|
// app id
|
||||||
char appId[TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE] = {0};
|
char clientId[TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
tstrncpy(varDataVal(appId), pConsumer->appId, TSDB_CGROUP_LEN);
|
tstrncpy(varDataVal(clientId), pConsumer->clientId, TSDB_CGROUP_LEN);
|
||||||
varDataSetLen(appId, strlen(varDataVal(appId)));
|
varDataSetLen(clientId, strlen(varDataVal(clientId)));
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)appId, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)clientId, false);
|
||||||
|
|
||||||
// status
|
// status
|
||||||
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
|
|
@ -261,8 +261,7 @@ void mndReleaseDb(SMnode *pMnode, SDbObj *pDb) {
|
||||||
sdbRelease(pSdb, pDb);
|
sdbRelease(pSdb, pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid) {
|
||||||
bool isRedo) {
|
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||||
|
@ -279,48 +278,29 @@ static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
||||||
action.msgType = TDMT_DND_CREATE_VNODE;
|
action.msgType = TDMT_DND_CREATE_VNODE;
|
||||||
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
|
||||||
if (isRedo) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
taosMemoryFree(pReq);
|
||||||
taosMemoryFree(pReq);
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
static int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
bool isRedo) {
|
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
|
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
|
||||||
if (pDnode == NULL) return -1;
|
|
||||||
action.epSet = mndGetDnodeEpset(pDnode);
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pReq = mndBuildAlterVnodeReq(pMnode, pDnode, pDb, pVgroup, &contLen);
|
void *pReq = mndBuildAlterVnodeReq(pMnode, pDb, pVgroup, &contLen);
|
||||||
if (pReq == NULL) return -1;
|
if (pReq == NULL) return -1;
|
||||||
|
|
||||||
action.pCont = pReq;
|
action.pCont = pReq;
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = TDMT_VND_ALTER_VNODE;
|
action.msgType = TDMT_VND_ALTER_VNODE;
|
||||||
|
|
||||||
if (isRedo) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
taosMemoryFree(pReq);
|
||||||
taosMemoryFree(pReq);
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
|
||||||
taosMemoryFree(pReq);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -487,7 +467,7 @@ static int32_t mndSetCreateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
|
|
||||||
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
||||||
SVnodeGid *pVgid = pVgroup->vnodeGid + vn;
|
SVnodeGid *pVgid = pVgroup->vnodeGid + vn;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pVgid, true) != 0) {
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pVgid) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,11 +706,8 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
||||||
|
|
||||||
static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SArray *pArray) {
|
static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SArray *pArray) {
|
||||||
if (pVgroup->replica <= 0 || pVgroup->replica == pDb->cfg.replications) {
|
if (pVgroup->replica <= 0 || pVgroup->replica == pDb->cfg.replications) {
|
||||||
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup) != 0) {
|
||||||
SVnodeGid *pVgid = pVgroup->vnodeGid + vn;
|
return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, pVgid, true) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SVgObj newVgroup = {0};
|
SVgObj newVgroup = {0};
|
||||||
|
@ -744,9 +721,9 @@ static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
newVgroup.replica = pDb->cfg.replications;
|
newVgroup.replica = pDb->cfg.replications;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[0], true) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[1], true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[2], true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
mInfo("db:%s, vgId:%d, will remove 2 vnodes", pVgroup->dbName, pVgroup->vgId);
|
mInfo("db:%s, vgId:%d, will remove 2 vnodes", pVgroup->dbName, pVgroup->vgId);
|
||||||
|
|
||||||
|
@ -757,7 +734,7 @@ static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
newVgroup.replica = pDb->cfg.replications;
|
newVgroup.replica = pDb->cfg.replications;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[0], true) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,8 +197,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
goto CONN_OVER;
|
goto CONN_OVER;
|
||||||
}
|
}
|
||||||
if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) {
|
if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) {
|
||||||
mError("user:%s, failed to auth while acquire user, input:%s saved:%s", pReq->conn.user, connReq.passwd,
|
mError("user:%s, failed to auth while acquire user, input:%s", pReq->conn.user, connReq.passwd);
|
||||||
pUser->pass);
|
|
||||||
code = TSDB_CODE_RPC_AUTH_FAILURE;
|
code = TSDB_CODE_RPC_AUTH_FAILURE;
|
||||||
goto CONN_OVER;
|
goto CONN_OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,8 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pStb->uid, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pStb->uid, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->version, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->version, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pStb->tagVer, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pStb->colVer, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, (int32_t)(pStb->xFilesFactor * 10000), _OVER)
|
SDB_SET_INT32(pRaw, dataPos, (int32_t)(pStb->xFilesFactor * 10000), _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pStb->delay, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pStb->delay, _OVER)
|
||||||
|
@ -166,6 +168,8 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pStb->uid, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pStb->uid, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->version, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->version, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pStb->tagVer, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pStb->colVer, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER)
|
||||||
int32_t xFilesFactor = 0;
|
int32_t xFilesFactor = 0;
|
||||||
SDB_GET_INT32(pRaw, dataPos, &xFilesFactor, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &xFilesFactor, _OVER)
|
||||||
|
@ -317,6 +321,8 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
|
|
||||||
pOld->updateTime = pNew->updateTime;
|
pOld->updateTime = pNew->updateTime;
|
||||||
pOld->version = pNew->version;
|
pOld->version = pNew->version;
|
||||||
|
pOld->tagVer = pNew->tagVer;
|
||||||
|
pOld->colVer = pNew->colVer;
|
||||||
pOld->nextColId = pNew->nextColId;
|
pOld->nextColId = pNew->nextColId;
|
||||||
pOld->ttl = pNew->ttl;
|
pOld->ttl = pNew->ttl;
|
||||||
pOld->numOfColumns = pNew->numOfColumns;
|
pOld->numOfColumns = pNew->numOfColumns;
|
||||||
|
@ -384,6 +390,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
req.rollup = pStb->ast1Len > 0 ? 1 : 0;
|
req.rollup = pStb->ast1Len > 0 ? 1 : 0;
|
||||||
req.schema.nCols = pStb->numOfColumns;
|
req.schema.nCols = pStb->numOfColumns;
|
||||||
req.schema.sver = pStb->version;
|
req.schema.sver = pStb->version;
|
||||||
|
req.schema.tagVer = pStb->tagVer;
|
||||||
|
req.schema.colVer = pStb->colVer;
|
||||||
req.schema.pSchema = pStb->pColumns;
|
req.schema.pSchema = pStb->pColumns;
|
||||||
req.schemaTag.nCols = pStb->numOfTags;
|
req.schemaTag.nCols = pStb->numOfTags;
|
||||||
req.schemaTag.sver = 1;
|
req.schemaTag.sver = 1;
|
||||||
|
@ -657,6 +665,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
||||||
pDst->uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
pDst->uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||||
pDst->dbUid = pDb->uid;
|
pDst->dbUid = pDb->uid;
|
||||||
pDst->version = 1;
|
pDst->version = 1;
|
||||||
|
pDst->tagVer = 1;
|
||||||
|
pDst->colVer = 1;
|
||||||
pDst->nextColId = 1;
|
pDst->nextColId = 1;
|
||||||
pDst->xFilesFactor = pCreate->xFilesFactor;
|
pDst->xFilesFactor = pCreate->xFilesFactor;
|
||||||
pDst->delay = pCreate->delay;
|
pDst->delay = pCreate->delay;
|
||||||
|
@ -949,6 +959,7 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *p
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->tagVer++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,6 +978,7 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
|
||||||
pNew->numOfTags--;
|
pNew->numOfTags--;
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->tagVer++;
|
||||||
mDebug("stb:%s, start to drop tag %s", pNew->name, tagName);
|
mDebug("stb:%s, start to drop tag %s", pNew->name, tagName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1007,6 +1019,7 @@ static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, SArray *pF
|
||||||
memcpy(pSchema->name, newTagName, TSDB_COL_NAME_LEN);
|
memcpy(pSchema->name, newTagName, TSDB_COL_NAME_LEN);
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->tagVer++;
|
||||||
mDebug("stb:%s, start to modify tag %s to %s", pNew->name, oldTagName, newTagName);
|
mDebug("stb:%s, start to modify tag %s to %s", pNew->name, oldTagName, newTagName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1036,6 +1049,7 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SFi
|
||||||
|
|
||||||
pTag->bytes = pField->bytes;
|
pTag->bytes = pField->bytes;
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->tagVer++;
|
||||||
|
|
||||||
mDebug("stb:%s, start to modify tag len %s to %d", pNew->name, pField->name, pField->bytes);
|
mDebug("stb:%s, start to modify tag len %s to %d", pNew->name, pField->name, pField->bytes);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1075,6 +1089,7 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->colVer++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,6 +1118,7 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
|
||||||
pNew->numOfColumns--;
|
pNew->numOfColumns--;
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->colVer++;
|
||||||
mDebug("stb:%s, start to drop col %s", pNew->name, colName);
|
mDebug("stb:%s, start to drop col %s", pNew->name, colName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1141,6 +1157,7 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
|
||||||
|
|
||||||
pCol->bytes = pField->bytes;
|
pCol->bytes = pField->bytes;
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
pNew->colVer++;
|
||||||
|
|
||||||
mDebug("stb:%s, start to modify col len %s to %d", pNew->name, pField->name, pField->bytes);
|
mDebug("stb:%s, start to modify col len %s to %d", pNew->name, pField->name, pField->bytes);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1300,6 +1317,13 @@ static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alterReq.verInBlock > 0 && alterReq.verInBlock <= pStb->version) {
|
||||||
|
mDebug("stb:%s, already exist, verInBlock:%d smaller than verInStb:%d, alter success", alterReq.name,
|
||||||
|
alterReq.verInBlock, pStb->version);
|
||||||
|
code = 0;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -206,7 +206,7 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
||||||
static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) {
|
static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) {
|
||||||
int32_t totalVgNum = pOutput->pSub->vgNum;
|
int32_t totalVgNum = pOutput->pSub->vgNum;
|
||||||
|
|
||||||
mInfo("mq rebalance subscription: %s, vgNum: %d", pOutput->pSub->key, pOutput->pSub->vgNum);
|
mInfo("mq rebalance: subscription: %s, vgNum: %d", pOutput->pSub->key, pOutput->pSub->vgNum);
|
||||||
|
|
||||||
// 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg
|
// 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg
|
||||||
SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||||
|
@ -231,6 +231,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
.pVgEp = pVgEp,
|
.pVgEp = pVgEp,
|
||||||
};
|
};
|
||||||
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
||||||
|
mInfo("mq rebalance: remove vg %d from consumer %ld", pVgEp->vgId, consumerId);
|
||||||
}
|
}
|
||||||
taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t));
|
taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t));
|
||||||
// put into removed
|
// put into removed
|
||||||
|
@ -250,6 +251,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
.pVgEp = pVgEp,
|
.pVgEp = pVgEp,
|
||||||
};
|
};
|
||||||
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg));
|
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg));
|
||||||
|
mInfo("mq rebalance: remove vg %d from unassigned", pVgEp->vgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +265,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
minVgCnt = totalVgNum / afterRebConsumerNum;
|
minVgCnt = totalVgNum / afterRebConsumerNum;
|
||||||
imbConsumerNum = totalVgNum % afterRebConsumerNum;
|
imbConsumerNum = totalVgNum % afterRebConsumerNum;
|
||||||
}
|
}
|
||||||
|
mInfo("mq rebalance: %d consumer after rebalance, at least %d vg each, %d consumer has more vg", afterRebConsumerNum,
|
||||||
|
minVgCnt, imbConsumerNum);
|
||||||
|
|
||||||
// 4. first scan: remove consumer more than wanted, put to remove hash
|
// 4. first scan: remove consumer more than wanted, put to remove hash
|
||||||
int32_t imbCnt = 0;
|
int32_t imbCnt = 0;
|
||||||
|
@ -290,6 +294,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
.pVgEp = pVgEp,
|
.pVgEp = pVgEp,
|
||||||
};
|
};
|
||||||
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
||||||
|
mInfo("mq rebalance: remove vg %d from consumer %ld (first scan)", pVgEp->vgId, pConsumerEp->consumerId);
|
||||||
}
|
}
|
||||||
imbCnt++;
|
imbCnt++;
|
||||||
}
|
}
|
||||||
|
@ -303,6 +308,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
.pVgEp = pVgEp,
|
.pVgEp = pVgEp,
|
||||||
};
|
};
|
||||||
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
||||||
|
mInfo("mq rebalance: remove vg %d from consumer %ld (first scan)", pVgEp->vgId, pConsumerEp->consumerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,6 +325,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
newConsumerEp.vgs = taosArrayInit(0, sizeof(void *));
|
newConsumerEp.vgs = taosArrayInit(0, sizeof(void *));
|
||||||
taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp));
|
taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp));
|
||||||
taosArrayPush(pOutput->newConsumers, &consumerId);
|
taosArrayPush(pOutput->newConsumers, &consumerId);
|
||||||
|
mInfo("mq rebalance: add new consumer %ld", consumerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,6 +350,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp);
|
taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp);
|
||||||
pRebVg->newConsumerId = pConsumerEp->consumerId;
|
pRebVg->newConsumerId = pConsumerEp->consumerId;
|
||||||
taosArrayPush(pOutput->rebVgs, pRebVg);
|
taosArrayPush(pOutput->rebVgs, pRebVg);
|
||||||
|
mInfo("mq rebalance: add vg %d to consumer %ld (second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +368,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp);
|
taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp);
|
||||||
pRebVg->newConsumerId = pConsumerEp->consumerId;
|
pRebVg->newConsumerId = pConsumerEp->consumerId;
|
||||||
taosArrayPush(pOutput->rebVgs, pRebVg);
|
taosArrayPush(pOutput->rebVgs, pRebVg);
|
||||||
|
mInfo("mq rebalance: add vg %d to consumer %ld (second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if all consumer is removed, put all vg into unassigned
|
// if all consumer is removed, put all vg into unassigned
|
||||||
|
@ -372,6 +381,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
ASSERT(pRebOutput->newConsumerId == -1);
|
ASSERT(pRebOutput->newConsumerId == -1);
|
||||||
taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp);
|
taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp);
|
||||||
taosArrayPush(pOutput->rebVgs, pRebOutput);
|
taosArrayPush(pOutput->rebVgs, pRebOutput);
|
||||||
|
mInfo("mq rebalance: unassign vg %d (second scan)", pRebOutput->pVgEp->vgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -492,8 +492,8 @@ static int32_t mndDropTopic(SMnode *pMnode, STrans *pTrans, SRpcMsg *pReq, SMqTo
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
/*SSdb *pSdb = pMnode->pSdb;*/
|
||||||
SMDropTopicReq dropReq = {0};
|
SMDropTopicReq dropReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMDropTopicReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSMDropTopicReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||||
|
@ -502,16 +502,16 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, dropReq.name);
|
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, dropReq.name);
|
||||||
// if (pTopic == NULL) {
|
if (pTopic == NULL) {
|
||||||
// if (dropReq.igNotExists) {
|
if (dropReq.igNotExists) {
|
||||||
// mDebug("topic:%s, not exist, ignore not exist is set", dropReq.name);
|
mDebug("topic:%s, not exist, ignore not exist is set", dropReq.name);
|
||||||
// return 0;
|
return 0;
|
||||||
// } else {
|
} else {
|
||||||
// terrno = TSDB_CODE_MND_TOPIC_NOT_EXIST;
|
terrno = TSDB_CODE_MND_TOPIC_NOT_EXIST;
|
||||||
// mError("topic:%s, failed to drop since %s", dropReq.name, terrstr());
|
mError("topic:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||||
// return -1;
|
return -1;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (pTopic->refConsumerCnt != 0) {
|
if (pTopic->refConsumerCnt != 0) {
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
@ -528,12 +528,10 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mDebug("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
mDebug("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (mndDropOffsetByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
if (mndDropOffsetByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
|
@ -842,13 +842,12 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
taosMemoryFree(pTrans->rpcRsp);
|
taosMemoryFree(pTrans->rpcRsp);
|
||||||
|
|
||||||
mDebug("trans:%d, send rsp, code:0x%x stage:%d app:%p", pTrans->id, code & 0xFFFF, pTrans->stage,
|
mDebug("trans:%d, send rsp, code:0x%x stage:%d app:%p", pTrans->id, code, pTrans->stage, pTrans->rpcInfo.ahandle);
|
||||||
pTrans->rpcInfo.ahandle);
|
|
||||||
SRpcMsg rspMsg = {
|
SRpcMsg rspMsg = {
|
||||||
.info = pTrans->rpcInfo,
|
|
||||||
.code = code,
|
.code = code,
|
||||||
.pCont = rpcCont,
|
.pCont = rpcCont,
|
||||||
.contLen = pTrans->rpcRspLen,
|
.contLen = pTrans->rpcRspLen,
|
||||||
|
.info = pTrans->rpcInfo,
|
||||||
};
|
};
|
||||||
tmsgSendRsp(&rspMsg);
|
tmsgSendRsp(&rspMsg);
|
||||||
pTrans->rpcInfo.handle = NULL;
|
pTrans->rpcInfo.handle = NULL;
|
||||||
|
@ -986,7 +985,8 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
|
||||||
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
|
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
|
||||||
|
|
||||||
if (tmsgSendReq(&pAction->epSet, &rpcMsg) == 0) {
|
if (tmsgSendReq(&pAction->epSet, &rpcMsg) == 0) {
|
||||||
mDebug("trans:%d, action:%d is sent", pTrans->id, action);
|
mDebug("trans:%d, action:%d is sent to %s:%u", pTrans->id, action, pAction->epSet.eps[pAction->epSet.inUse].fqdn,
|
||||||
|
pAction->epSet.eps[pAction->epSet.inUse].port);
|
||||||
pAction->msgSent = 1;
|
pAction->msgSent = 1;
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
pAction->errCode = 0;
|
pAction->errCode = 0;
|
||||||
|
|
|
@ -256,7 +256,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
||||||
SAlterVnodeReq alterReq = {0};
|
SAlterVnodeReq alterReq = {0};
|
||||||
alterReq.vgVersion = pVgroup->version;
|
alterReq.vgVersion = pVgroup->version;
|
||||||
alterReq.buffer = pDb->cfg.buffer;
|
alterReq.buffer = pDb->cfg.buffer;
|
||||||
|
@ -285,16 +285,14 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgO
|
||||||
pReplica->port = pVgidDnode->port;
|
pReplica->port = pVgidDnode->port;
|
||||||
memcpy(pReplica->fqdn, pVgidDnode->fqdn, TSDB_FQDN_LEN);
|
memcpy(pReplica->fqdn, pVgidDnode->fqdn, TSDB_FQDN_LEN);
|
||||||
mndReleaseDnode(pMnode, pVgidDnode);
|
mndReleaseDnode(pMnode, pVgidDnode);
|
||||||
|
|
||||||
if (pDnode->id == pVgid->dnodeId) {
|
|
||||||
alterReq.selfIndex = v;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (alterReq.selfIndex == -1) {
|
if (alterReq.selfIndex == -1) {
|
||||||
terrno = TSDB_CODE_MND_APP_ERROR;
|
terrno = TSDB_CODE_MND_APP_ERROR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterVnodeReq(NULL, 0, &alterReq);
|
int32_t contLen = tSerializeSAlterVnodeReq(NULL, 0, &alterReq);
|
||||||
if (contLen < 0) {
|
if (contLen < 0) {
|
||||||
|
|
|
@ -343,19 +343,20 @@ void mndStop(SMnode *pMnode) { return mndCleanupTimer(pMnode); }
|
||||||
int32_t mndProcessMsg(SRpcMsg *pMsg) {
|
int32_t mndProcessMsg(SRpcMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
void *ahandle = pMsg->info.ahandle;
|
void *ahandle = pMsg->info.ahandle;
|
||||||
|
|
||||||
mTrace("msg:%p, will be processed, type:%s app:%p", pMsg, TMSG_INFO(pMsg->msgType), ahandle);
|
mTrace("msg:%p, will be processed, type:%s app:%p", pMsg, TMSG_INFO(pMsg->msgType), ahandle);
|
||||||
|
|
||||||
if (IsReq(pMsg) && !mndIsMaster(pMnode)) {
|
if (IsReq(pMsg)) {
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
if (!mndIsMaster(pMnode)) {
|
||||||
mDebug("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle);
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
return -1;
|
mDebug("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsReq(pMsg) && (pMsg->contLen == 0 || pMsg->pCont == NULL)) {
|
if (pMsg->contLen == 0 || pMsg->pCont == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
mError("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle);
|
mError("msg:%p, failed to process since %s, app:%p", pMsg, terrstr(), ahandle);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)];
|
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)];
|
||||||
|
@ -488,7 +489,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
||||||
tstrncpy(desc.status, "ready", sizeof(desc.status));
|
tstrncpy(desc.status, "ready", sizeof(desc.status));
|
||||||
pClusterInfo->vgroups_alive++;
|
pClusterInfo->vgroups_alive++;
|
||||||
}
|
}
|
||||||
if (pVgid->role == TAOS_SYNC_STATE_LEADER || pVgid->role == TAOS_SYNC_STATE_CANDIDATE) {
|
if (pVgid->role != TAOS_SYNC_STATE_ERROR) {
|
||||||
pClusterInfo->vnodes_alive++;
|
pClusterInfo->vnodes_alive++;
|
||||||
}
|
}
|
||||||
pClusterInfo->vnodes_total++;
|
pClusterInfo->vnodes_total++;
|
||||||
|
|
|
@ -32,7 +32,7 @@ class MndTestStb : public ::testing::Test {
|
||||||
void* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes, int32_t* pContLen);
|
void* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes, int32_t* pContLen);
|
||||||
void* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
void* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
||||||
void* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
void* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
||||||
void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen);
|
void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen, int32_t verInBlock);
|
||||||
};
|
};
|
||||||
|
|
||||||
Testbase MndTestStb::test;
|
Testbase MndTestStb::test;
|
||||||
|
@ -271,12 +271,13 @@ void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* co
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
||||||
int32_t* pContLen) {
|
int32_t* pContLen, int32_t verInBlock) {
|
||||||
SMAlterStbReq req = {0};
|
SMAlterStbReq req = {0};
|
||||||
strcpy(req.name, stbname);
|
strcpy(req.name, stbname);
|
||||||
req.numOfFields = 1;
|
req.numOfFields = 1;
|
||||||
req.pFields = taosArrayInit(1, sizeof(SField));
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
req.alterType = TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES;
|
req.alterType = TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES;
|
||||||
|
req.verInBlock = verInBlock;
|
||||||
|
|
||||||
SField field = {0};
|
SField field = {0};
|
||||||
field.bytes = bytes;
|
field.bytes = bytes;
|
||||||
|
@ -781,31 +782,40 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col5", 12, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col5", 12, &contLen, 0);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "ts", 8, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "ts", 8, &contLen, 0);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 8, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 8, &contLen, 0);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", TSDB_MAX_BYTES_PER_ROW, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", TSDB_MAX_BYTES_PER_ROW, &contLen, 0);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 20, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 20, &contLen, 0);
|
||||||
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname);
|
||||||
|
EXPECT_EQ(test.GetShowRows(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col_not_exist", 20, &contLen, 1);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class MndTestTrans2 : public ::testing::Test {
|
||||||
msgCb.sendReqFp = sendReq;
|
msgCb.sendReqFp = sendReq;
|
||||||
msgCb.sendRspFp = sendRsp;
|
msgCb.sendRspFp = sendRsp;
|
||||||
msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack
|
msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack
|
||||||
tmsgSetDefaultMsgCb(&msgCb);
|
tmsgSetDefault(&msgCb);
|
||||||
|
|
||||||
SMnodeOpt opt = {0};
|
SMnodeOpt opt = {0};
|
||||||
opt.deploy = 1;
|
opt.deploy = 1;
|
||||||
|
|
|
@ -48,7 +48,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
||||||
taosInitRWLatch(&pSdb->locks[i]);
|
taosThreadRwlockInit(&pSdb->locks[i], NULL);
|
||||||
pSdb->maxId[i] = 0;
|
pSdb->maxId[i] = 0;
|
||||||
pSdb->tableVer[i] = 0;
|
pSdb->tableVer[i] = 0;
|
||||||
pSdb->keyTypes[i] = SDB_KEY_INT32;
|
pSdb->keyTypes[i] = SDB_KEY_INT32;
|
||||||
|
@ -98,7 +98,10 @@ void sdbCleanup(SSdb *pSdb) {
|
||||||
|
|
||||||
taosHashClear(hash);
|
taosHashClear(hash);
|
||||||
taosHashCleanup(hash);
|
taosHashCleanup(hash);
|
||||||
|
taosThreadRwlockDestroy(&pSdb->locks[i]);
|
||||||
pSdb->hashObjs[i] = NULL;
|
pSdb->hashObjs[i] = NULL;
|
||||||
|
memset(&pSdb->locks[i], 0, sizeof(pSdb->locks[i]));
|
||||||
|
|
||||||
mDebug("sdb table:%s is cleaned up", sdbTableName(i));
|
mDebug("sdb table:%s is cleaned up", sdbTableName(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +137,6 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
|
||||||
|
|
||||||
pSdb->maxId[sdbType] = 0;
|
pSdb->maxId[sdbType] = 0;
|
||||||
pSdb->hashObjs[sdbType] = hash;
|
pSdb->hashObjs[sdbType] = hash;
|
||||||
taosInitRWLatch(&pSdb->locks[sdbType]);
|
|
||||||
mDebug("sdb table:%s is initialized", sdbTableName(sdbType));
|
mDebug("sdb table:%s is initialized", sdbTableName(sdbType));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -257,8 +257,8 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
mTrace("write %s to file, total %d rows", sdbTableName(i), sdbGetSize(pSdb, i));
|
mTrace("write %s to file, total %d rows", sdbTableName(i), sdbGetSize(pSdb, i));
|
||||||
|
|
||||||
SHashObj *hash = pSdb->hashObjs[i];
|
SHashObj *hash = pSdb->hashObjs[i];
|
||||||
SRWLatch *pLock = &pSdb->locks[i];
|
TdThreadRwlock *pLock = &pSdb->locks[i];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -303,7 +303,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
|
|
@ -129,12 +129,12 @@ static int32_t sdbGetkeySize(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
||||||
if (pOldRow != NULL) {
|
if (pOldRow != NULL) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -145,13 +145,13 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
sdbPrintOper(pSdb, pRow, "insert");
|
sdbPrintOper(pSdb, pRow, "insert");
|
||||||
|
|
||||||
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
||||||
|
@ -159,9 +159,9 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
code = (*insertFp)(pSdb, pRow->pObj);
|
code = (*insertFp)(pSdb, pRow->pObj);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
taosHashRemove(hash, pRow->pObj, keySize);
|
taosHashRemove(hash, pRow->pObj, keySize);
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -180,19 +180,19 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pNewRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pNewRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow *pOldRow = *ppOldRow;
|
SSdbRow *pOldRow = *ppOldRow;
|
||||||
pOldRow->status = pRaw->status;
|
pOldRow->status = pRaw->status;
|
||||||
sdbPrintOper(pSdb, pOldRow, "update");
|
sdbPrintOper(pSdb, pOldRow, "update");
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
||||||
|
@ -207,12 +207,12 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -223,7 +223,7 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
sdbPrintOper(pSdb, pOldRow, "delete");
|
sdbPrintOper(pSdb, pOldRow, "delete");
|
||||||
|
|
||||||
taosHashRemove(hash, pOldRow->pObj, keySize);
|
taosHashRemove(hash, pOldRow->pObj, keySize);
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
|
@ -278,12 +278,12 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
void *pRet = NULL;
|
void *pRet = NULL;
|
||||||
int32_t keySize = sdbGetkeySize(pSdb, type, pKey);
|
int32_t keySize = sdbGetkeySize(pSdb, type, pKey);
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashGet(hash, pKey, keySize);
|
SSdbRow **ppRow = taosHashGet(hash, pKey, keySize);
|
||||||
if (ppRow == NULL || *ppRow == NULL) {
|
if (ppRow == NULL || *ppRow == NULL) {
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -306,13 +306,13 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
int32_t ref = atomic_load_32(&pRow->refCount);
|
int32_t ref = atomic_load_32(&pRow->refCount);
|
||||||
sdbPrintOper(pSdb, pRow, "check");
|
sdbPrintOper(pSdb, pRow, "check");
|
||||||
|
@ -320,7 +320,7 @@ static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbRelease(SSdb *pSdb, void *pObj) {
|
void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
|
@ -329,8 +329,8 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
||||||
if (pRow->type >= SDB_MAX) return;
|
if (pRow->type >= SDB_MAX) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
||||||
sdbPrintOper(pSdb, pRow, "release");
|
sdbPrintOper(pSdb, pRow, "release");
|
||||||
|
@ -338,7 +338,7 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
|
@ -347,8 +347,8 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return NULL;
|
if (hash == NULL) return NULL;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -363,7 +363,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
*ppObj = pRow->pObj;
|
*ppObj = pRow->pObj;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
return ppRow;
|
return ppRow;
|
||||||
}
|
}
|
||||||
|
@ -374,18 +374,18 @@ void sdbCancelFetch(SSdb *pSdb, void *pIter) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
|
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
|
||||||
if (hash == NULL) return;
|
if (hash == NULL) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
taosHashCancelIterate(hash, pIter);
|
taosHashCancelIterate(hash, pIter);
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2, void *p3) {
|
void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2, void *p3) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return;
|
if (hash == NULL) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -401,17 +401,17 @@ void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sdbGetSize(SSdb *pSdb, ESdbType type) {
|
int32_t sdbGetSize(SSdb *pSdb, ESdbType type) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return 0;
|
if (hash == NULL) return 0;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
int32_t size = taosHashGetSize(hash);
|
int32_t size = taosHashGetSize(hash);
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -424,8 +424,8 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
|
||||||
|
|
||||||
int32_t maxId = 0;
|
int32_t maxId = 0;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -435,7 +435,7 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
maxId = TMAX(maxId, pSdb->maxId[type]);
|
maxId = TMAX(maxId, pSdb->maxId[type]);
|
||||||
return maxId + 1;
|
return maxId + 1;
|
||||||
|
|
|
@ -179,6 +179,7 @@ struct STQ {
|
||||||
SHashObj* pStreamTasks;
|
SHashObj* pStreamTasks;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
|
// TDB* pTdb;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -104,6 +104,7 @@ int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeep
|
||||||
int tsdbClose(STsdb** pTsdb);
|
int tsdbClose(STsdb** pTsdb);
|
||||||
int tsdbBegin(STsdb* pTsdb);
|
int tsdbBegin(STsdb* pTsdb);
|
||||||
int tsdbCommit(STsdb* pTsdb);
|
int tsdbCommit(STsdb* pTsdb);
|
||||||
|
int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, const SSubmitReq *pMsg);
|
||||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||||
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
||||||
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
|
|
|
@ -44,6 +44,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
pMeta->path = (char *)&pMeta[1];
|
pMeta->path = (char *)&pMeta[1];
|
||||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
VNODE_META_DIR);
|
VNODE_META_DIR);
|
||||||
|
taosRealPath(pMeta->path, NULL, slen);
|
||||||
pMeta->pVnode = pVnode;
|
pMeta->pVnode = pVnode;
|
||||||
|
|
||||||
// create path if not created yet
|
// create path if not created yet
|
||||||
|
|
|
@ -442,7 +442,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.version = version;
|
entry.version = version;
|
||||||
int tlen;
|
int tlen;
|
||||||
|
SSchema *pNewSchema = NULL;
|
||||||
switch (pAlterTbReq->action) {
|
switch (pAlterTbReq->action) {
|
||||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||||
if (pColumn) {
|
if (pColumn) {
|
||||||
|
@ -451,8 +452,9 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
}
|
}
|
||||||
pSchema->sver++;
|
pSchema->sver++;
|
||||||
pSchema->nCols++;
|
pSchema->nCols++;
|
||||||
pSchema->pSchema =
|
pNewSchema = taosMemoryMalloc(sizeof(SSchema) * pSchema->nCols);
|
||||||
taosMemoryRealloc(entry.ntbEntry.schema.pSchema, sizeof(SSchema) * entry.ntbEntry.schema.nCols);
|
memcpy(pNewSchema, pSchema->pSchema, sizeof(SSchema) * (pSchema->nCols - 1));
|
||||||
|
pSchema->pSchema = pNewSchema;
|
||||||
pSchema->pSchema[entry.ntbEntry.schema.nCols - 1].bytes = pAlterTbReq->bytes;
|
pSchema->pSchema[entry.ntbEntry.schema.nCols - 1].bytes = pAlterTbReq->bytes;
|
||||||
pSchema->pSchema[entry.ntbEntry.schema.nCols - 1].type = pAlterTbReq->type;
|
pSchema->pSchema[entry.ntbEntry.schema.nCols - 1].type = pAlterTbReq->type;
|
||||||
pSchema->pSchema[entry.ntbEntry.schema.nCols - 1].flags = pAlterTbReq->flags;
|
pSchema->pSchema[entry.ntbEntry.schema.nCols - 1].flags = pAlterTbReq->flags;
|
||||||
|
@ -511,6 +513,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
|
if (pNewSchema) taosMemoryFree(pNewSchema);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
|
|
|
@ -32,6 +32,9 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
||||||
pTq->path = strdup(path);
|
pTq->path = strdup(path);
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
pTq->pWal = pWal;
|
pTq->pWal = pWal;
|
||||||
|
/*if (tdbOpen(path, 4096, 1, &pTq->pTdb) < 0) {*/
|
||||||
|
/*ASSERT(0);*/
|
||||||
|
/*}*/
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
pTq->tqMeta = tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer,
|
pTq->tqMeta = tqStoreOpen(pTq, path, (FTqSerialize)tqSerializeConsumer, (FTqDeserialize)tqDeserializeConsumer,
|
||||||
|
@ -108,6 +111,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList) {
|
||||||
pIter = taosHashIterate(pTq->execs, pIter);
|
pIter = taosHashIterate(pTq->execs, pIter);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
pExec = (STqExec*)pIter;
|
pExec = (STqExec*)pIter;
|
||||||
|
if (pExec->subType == TOPIC_SUB_TYPE__DB) continue;
|
||||||
for (int32_t i = 0; i < 5; i++) {
|
for (int32_t i = 0; i < 5; i++) {
|
||||||
int32_t code = qUpdateQualifiedTableId(pExec->task[i], tbUidList, true);
|
int32_t code = qUpdateQualifiedTableId(pExec->task[i], tbUidList, true);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
|
|
@ -320,6 +320,8 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo
|
||||||
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
strcat(pRsp->tblFName, mr.me.name);
|
||||||
|
|
||||||
if (mr.me.type == TSDB_NORMAL_TABLE) {
|
if (mr.me.type == TSDB_NORMAL_TABLE) {
|
||||||
sverNew = mr.me.ntbEntry.schema.sver;
|
sverNew = mr.me.ntbEntry.schema.sver;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -55,6 +55,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
memcpy(pTsdb->dir, dir, strlen(dir));
|
memcpy(pTsdb->dir, dir, strlen(dir));
|
||||||
pTsdb->path = (char *)&pTsdb[1];
|
pTsdb->path = (char *)&pTsdb[1];
|
||||||
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, dir);
|
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, dir);
|
||||||
|
taosRealPath(pTsdb->path, NULL, slen);
|
||||||
pTsdb->pVnode = pVnode;
|
pTsdb->pVnode = pVnode;
|
||||||
pTsdb->repoLocked = false;
|
pTsdb->repoLocked = false;
|
||||||
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
||||||
|
|
|
@ -420,6 +420,11 @@ static STsdbReadHandle* tsdbQueryTablesImpl(SVnode* pVnode, SQueryTableDataCond*
|
||||||
setQueryTimewindow(pReadHandle, pCond);
|
setQueryTimewindow(pReadHandle, pCond);
|
||||||
|
|
||||||
if (pCond->numOfCols > 0) {
|
if (pCond->numOfCols > 0) {
|
||||||
|
int32_t rowLen = 0;
|
||||||
|
for(int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||||
|
rowLen += pCond->colList[i].bytes;
|
||||||
|
}
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
pReadHandle->suppInfo.pstatis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
pReadHandle->suppInfo.pstatis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
||||||
if (pReadHandle->suppInfo.pstatis == NULL) {
|
if (pReadHandle->suppInfo.pstatis == NULL) {
|
||||||
|
|
|
@ -330,12 +330,12 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo,
|
||||||
ASSERT(pReadh->pDCols[0]->bitmapMode != 0);
|
ASSERT(pReadh->pDCols[0]->bitmapMode != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mergeBitmap && !tdDataColsIsBitmapI(pReadh->pDCols[0])) {
|
if (mergeBitmap && !tdDataColsIsBitmapI(pReadh->pDCols[0])) {
|
||||||
for (int i = 0; i < numOfColsIds; ++i) {
|
for (int i = 0; i < numOfColsIds; ++i) {
|
||||||
SDataCol *pDataCol = pReadh->pDCols[0]->cols + i;
|
SDataCol *pDataCol = pReadh->pDCols[0]->cols + i;
|
||||||
if (pDataCol->bitmap) {
|
if (pDataCol->len > 0 && pDataCol->bitmap) {
|
||||||
ASSERT(pDataCol->colId != PRIMARYKEY_TIMESTAMP_COL_ID);
|
ASSERT(pDataCol->colId != PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
|
ASSERT(pDataCol->pBitmap);
|
||||||
tdMergeBitmap(pDataCol->pBitmap, pReadh->pDCols[0]->numOfRows, pDataCol->pBitmap);
|
tdMergeBitmap(pDataCol->pBitmap, pReadh->pDCols[0]->numOfRows, pDataCol->pBitmap);
|
||||||
tdDataColsSetBitmapI(pReadh->pDCols[0]);
|
tdDataColsSetBitmapI(pReadh->pDCols[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg);
|
// static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg);
|
||||||
|
|
||||||
int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
|
@ -54,7 +54,38 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
#if 0
|
||||||
|
static FORCE_INLINE int tsdbCheckRowRange(STsdb *pTsdb, STable *pTable, STSRow *row, TSKEY minKey, TSKEY maxKey,
|
||||||
|
TSKEY now) {
|
||||||
|
TSKEY rowKey = TD_ROW_KEY(row);
|
||||||
|
if (rowKey < minKey || rowKey > maxKey) {
|
||||||
|
tsdbError("vgId:%d table %s tid %d uid %" PRIu64 " timestamp is out of range! now %" PRId64 " minKey %" PRId64
|
||||||
|
" maxKey %" PRId64 " row key %" PRId64,
|
||||||
|
REPO_ID(pTsdb), TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), now, minKey, maxKey,
|
||||||
|
rowKey);
|
||||||
|
terrno = TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static FORCE_INLINE int tsdbCheckRowRange(STsdb *pTsdb, tb_uid_t uid, STSRow *row, TSKEY minKey, TSKEY maxKey,
|
||||||
|
TSKEY now) {
|
||||||
|
TSKEY rowKey = TD_ROW_KEY(row);
|
||||||
|
if (rowKey < minKey || rowKey > maxKey) {
|
||||||
|
tsdbError("vgId:%d table uid %" PRIu64 " timestamp is out of range! now %" PRId64 " minKey %" PRId64
|
||||||
|
" maxKey %" PRId64 " row key %" PRId64,
|
||||||
|
REPO_ID(pTsdb), uid, now, minKey, maxKey, rowKey);
|
||||||
|
terrno = TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, const SSubmitReq *pMsg) {
|
||||||
ASSERT(pMsg != NULL);
|
ASSERT(pMsg != NULL);
|
||||||
// STsdbMeta * pMeta = pTsdb->tsdbMeta;
|
// STsdbMeta * pMeta = pTsdb->tsdbMeta;
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
|
@ -112,14 +143,14 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
tsdbInitSubmitBlkIter(pBlock, &blkIter);
|
tInitSubmitBlkIter(&msgIter, pBlock, &blkIter);
|
||||||
while ((row = tsdbGetSubmitBlkNext(&blkIter)) != NULL) {
|
while ((row = tGetSubmitBlkNext(&blkIter)) != NULL) {
|
||||||
if (tsdbCheckRowRange(pTsdb, pTable, row, minKey, maxKey, now) < 0) {
|
if (tsdbCheckRowRange(pTsdb, msgIter.uid, row, minKey, maxKey, now) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
||||||
|
|
|
@ -109,6 +109,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open wal
|
// open wal
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||||
|
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||||
if (pVnode->pWal == NULL) {
|
if (pVnode->pWal == NULL) {
|
||||||
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
@ -117,6 +118,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open tq
|
// open tq
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||||
|
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
||||||
if (pVnode->pTq == NULL) {
|
if (pVnode->pTq == NULL) {
|
||||||
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
|
|
@ -631,6 +631,11 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
vnodeDebugPrintSubmitMsg(pVnode, pReq, __func__);
|
vnodeDebugPrintSubmitMsg(pVnode, pReq, __func__);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (tsdbScanAndConvertSubmitMsg(pVnode->pTsdb, pSubmitReq) < 0) {
|
||||||
|
pRsp->code = terrno;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
// handle the request
|
// handle the request
|
||||||
if (tInitSubmitMsgIter(pSubmitReq, &msgIter) < 0) {
|
if (tInitSubmitMsgIter(pSubmitReq, &msgIter) < 0) {
|
||||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
pRsp->code = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -681,6 +686,9 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
|
|
||||||
vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid");
|
vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid");
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
} else {
|
||||||
|
submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN);
|
||||||
|
sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbInsertTableData(pVnode->pTsdb, &msgIter, pBlock, &submitBlkRsp) < 0) {
|
if (tsdbInsertTableData(pVnode->pTsdb, &msgIter, pBlock, &submitBlkRsp) < 0) {
|
||||||
|
|
|
@ -2883,6 +2883,110 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgGetTbSverFromCache(SCatalog* pCtg, const SName* pTableName, int32_t* sver) {
|
||||||
|
*sver = -1;
|
||||||
|
|
||||||
|
if (NULL == pCtg->dbCache) {
|
||||||
|
ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
|
tNameGetFullDbName(pTableName, dbFName);
|
||||||
|
|
||||||
|
ctgAcquireDBCache(pCtg, dbFName, &dbCache);
|
||||||
|
if (NULL == dbCache) {
|
||||||
|
ctgDebug("db %s not in cache", pTableName->tname);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tbType = 0;
|
||||||
|
uint64_t suid = 0;
|
||||||
|
CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
|
STableMeta* tbMeta = taosHashGet(dbCache->tbCache.metaCache, pTableName->tname, strlen(pTableName->tname));
|
||||||
|
if (tbMeta) {
|
||||||
|
tbType = tbMeta->tableType;
|
||||||
|
suid = tbMeta->suid;
|
||||||
|
if (tbType != TSDB_CHILD_TABLE) {
|
||||||
|
*sver = tbMeta->sversion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock);
|
||||||
|
|
||||||
|
if (NULL == tbMeta) {
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tbType != TSDB_CHILD_TABLE) {
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
ctgDebug("Got sver %d from cache, type:%d, dbFName:%s, tbName:%s", *sver, tbType, dbFName, pTableName->tname);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgDebug("Got subtable meta from cache, dbFName:%s, tbName:%s, suid:%" PRIx64, dbFName, pTableName->tname, suid);
|
||||||
|
|
||||||
|
CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
|
|
||||||
|
STableMeta **stbMeta = taosHashGet(dbCache->tbCache.stbCache, &suid, sizeof(suid));
|
||||||
|
if (NULL == stbMeta || NULL == *stbMeta) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
ctgDebug("stb not in stbCache, suid:%"PRIx64, suid);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*stbMeta)->suid != suid) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
ctgError("stable suid in stbCache mis-match, expected suid:%"PRIx64 ",actual suid:%"PRIx64, suid, (*stbMeta)->suid);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
*sver = (*stbMeta)->sversion;
|
||||||
|
|
||||||
|
CTG_UNLOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
|
|
||||||
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
|
|
||||||
|
ctgDebug("Got sver %d from cache, type:%d, dbFName:%s, tbName:%s", *sver, tbType, dbFName, pTableName->tname);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SArray* pTables) {
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
if (NULL == pCtg || NULL == pTrans || NULL == pMgmtEps || NULL == pTables) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
SName name;
|
||||||
|
int32_t sver = 0;
|
||||||
|
int32_t tbNum = taosArrayGetSize(pTables);
|
||||||
|
for (int32_t i = 0; i < tbNum; ++i) {
|
||||||
|
STbSVersion* pTb = (STbSVersion*)taosArrayGet(pTables, i);
|
||||||
|
tNameFromString(&name, pTb->tbFName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
||||||
|
if (CTG_IS_SYS_DBNAME(name.dbname)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgGetTbSverFromCache(pCtg, &name, &sver);
|
||||||
|
if (sver >= 0 && sver < pTb->sver) {
|
||||||
|
catalogRemoveTableMeta(pCtg, &name); //TODO REMOVE STB FROM CACHE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const char* dbFName) {
|
int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const char* dbFName) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
|
|
@ -385,6 +385,13 @@ typedef enum EStreamScanMode {
|
||||||
STREAM_SCAN_FROM_DATAREADER,
|
STREAM_SCAN_FROM_DATAREADER,
|
||||||
} EStreamScanMode;
|
} EStreamScanMode;
|
||||||
|
|
||||||
|
typedef struct SCatchSupporter {
|
||||||
|
SHashObj* pWindowHashTable; // quick locate the window object for each window
|
||||||
|
SDiskbasedBuf* pDataBuf; // buffer based on blocked-wised disk file
|
||||||
|
int32_t keySize;
|
||||||
|
int64_t* pKeyBuf;
|
||||||
|
} SCatchSupporter;
|
||||||
|
|
||||||
typedef struct SStreamBlockScanInfo {
|
typedef struct SStreamBlockScanInfo {
|
||||||
SArray* pBlockLists; // multiple SSDatablock.
|
SArray* pBlockLists; // multiple SSDatablock.
|
||||||
SSDataBlock* pRes; // result SSDataBlock
|
SSDataBlock* pRes; // result SSDataBlock
|
||||||
|
@ -407,6 +414,8 @@ typedef struct SStreamBlockScanInfo {
|
||||||
EStreamScanMode scanMode;
|
EStreamScanMode scanMode;
|
||||||
SOperatorInfo* pOperatorDumy;
|
SOperatorInfo* pOperatorDumy;
|
||||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
||||||
|
SCatchSupporter childAggSup;
|
||||||
|
SArray* childIds;
|
||||||
} SStreamBlockScanInfo;
|
} SStreamBlockScanInfo;
|
||||||
|
|
||||||
typedef struct SSysTableScanInfo {
|
typedef struct SSysTableScanInfo {
|
||||||
|
@ -467,6 +476,16 @@ typedef struct SIntervalAggOperatorInfo {
|
||||||
bool invertible;
|
bool invertible;
|
||||||
} SIntervalAggOperatorInfo;
|
} SIntervalAggOperatorInfo;
|
||||||
|
|
||||||
|
typedef struct SStreamFinalIntervalOperatorInfo {
|
||||||
|
SOptrBasicInfo binfo; // basic info
|
||||||
|
SGroupResInfo groupResInfo; // multiple results build supporter
|
||||||
|
SInterval interval; // interval info
|
||||||
|
int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator.
|
||||||
|
SAggSupporter aggSup; // aggregate supporter
|
||||||
|
int32_t order; // current SSDataBlock scan order
|
||||||
|
STimeWindowAggSupp twAggSup;
|
||||||
|
} SStreamFinalIntervalOperatorInfo;
|
||||||
|
|
||||||
typedef struct SAggOperatorInfo {
|
typedef struct SAggOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
SAggSupporter aggSup;
|
SAggSupporter aggSup;
|
||||||
|
@ -704,6 +723,9 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
||||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
|
SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
|
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
|
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
|
@ -779,9 +801,8 @@ int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimary
|
||||||
TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item,
|
TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item,
|
||||||
int32_t order);
|
int32_t order);
|
||||||
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||||
|
int32_t initCatchSupporter(SCatchSupporter* pCatchSup, size_t rowSize, size_t keyBufSize,
|
||||||
void doClearWindow(SIntervalAggOperatorInfo* pInfo, char* pData, int16_t bytes,
|
const char* pKey, const char* pDir);
|
||||||
uint64_t groupId, int32_t numOfOutput);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
|
||||||
pMsg->contentLen = pMsg->contentLen;
|
pMsg->contentLen = pMsg->contentLen;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qDebugL("stream task string %s", (const char*)msg);
|
/*qDebugL("stream task string %s", (const char*)msg);*/
|
||||||
|
|
||||||
struct SSubplan* plan = NULL;
|
struct SSubplan* plan = NULL;
|
||||||
int32_t code = qStringToSubplan(msg, &plan);
|
int32_t code = qStringToSubplan(msg, &plan);
|
||||||
|
|
|
@ -343,31 +343,6 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId,
|
||||||
return pResultRow;
|
return pResultRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doClearWindow(SIntervalAggOperatorInfo* pInfo, char* pData, int16_t bytes, uint64_t groupId, int32_t numOfOutput) {
|
|
||||||
SAggSupporter* pSup = &pInfo->aggSup;
|
|
||||||
SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
|
|
||||||
|
|
||||||
SResultRowPosition* p1 =
|
|
||||||
(SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
|
|
||||||
|
|
||||||
SResultRow* pResult = getResultRowByPos(pSup->pResultBuf, p1);
|
|
||||||
|
|
||||||
SqlFunctionCtx* pCtx = pInfo->binfo.pCtx;
|
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
|
||||||
pCtx[i].resultInfo = getResultCell(pResult, i, pInfo->binfo.rowCellInfoOffset);
|
|
||||||
struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo;
|
|
||||||
|
|
||||||
if (fmIsWindowPseudoColumnFunc(pCtx[i].functionId)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pResInfo->initialized = false;
|
|
||||||
if (pCtx[i].functionId != -1) {
|
|
||||||
pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the struct of key in hash table
|
* the struct of key in hash table
|
||||||
* +----------+---------------+
|
* +----------+---------------+
|
||||||
|
@ -855,7 +830,11 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
SColumnInfoData idata = {.info = pResColData->info, .hasNull = true};
|
SColumnInfoData idata = {.info = pResColData->info, .hasNull = true};
|
||||||
|
|
||||||
SScalarParam dest = {.columnData = &idata};
|
SScalarParam dest = {.columnData = &idata};
|
||||||
scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
int32_t code = scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosArrayDestroy(pBlockList);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
||||||
colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity);
|
colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity);
|
||||||
|
@ -5312,3 +5291,16 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t initCatchSupporter(SCatchSupporter* pCatchSup, size_t rowSize, size_t keyBufSize,
|
||||||
|
const char* pKey, const char* pDir) {
|
||||||
|
pCatchSup->keySize = sizeof(int64_t) + sizeof(int64_t) + sizeof(TSKEY);
|
||||||
|
pCatchSup->pKeyBuf = taosMemoryCalloc(1, pCatchSup->keySize);
|
||||||
|
int32_t pageSize = rowSize * 32;
|
||||||
|
int32_t bufSize = pageSize * 4096;
|
||||||
|
createDiskbasedBuf(&pCatchSup->pDataBuf, pageSize, bufSize, pKey, pDir);
|
||||||
|
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||||
|
pCatchSup->pWindowHashTable = taosHashInit(10000, hashFn, true, HASH_NO_LOCK);;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
||||||
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
||||||
|
|
||||||
|
typedef struct SWindowPosition {
|
||||||
|
int32_t pageId;
|
||||||
|
int32_t rowId;
|
||||||
|
} SWindowPosition;
|
||||||
|
|
||||||
static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity);
|
static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity);
|
||||||
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
||||||
const char* dbName);
|
const char* dbName);
|
||||||
|
@ -675,6 +680,96 @@ static SSDataBlock* getUpdateDataBlock(SStreamBlockScanInfo* pInfo, bool inverti
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void static setSupKeyBuf(SCatchSupporter* pSup, int64_t groupId, int64_t childId, TSKEY ts) {
|
||||||
|
int64_t* pKey = (int64_t*)pSup->pKeyBuf;
|
||||||
|
pKey[0] = groupId;
|
||||||
|
pKey[1] = childId;
|
||||||
|
pKey[2] = ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t catchWidonwInfo(SSDataBlock* pDataBlock, SCatchSupporter* pSup,
|
||||||
|
int32_t pageId, int32_t tsIndex, int64_t childId) {
|
||||||
|
SColumnInfoData* pColDataInfo = taosArrayGet(pDataBlock->pDataBlock, tsIndex);
|
||||||
|
TSKEY* tsCols = (int64_t*)pColDataInfo->pData;
|
||||||
|
for (int32_t i = 0; i < pDataBlock->info.rows; i++) {
|
||||||
|
setSupKeyBuf(pSup, pDataBlock->info.groupId, childId, tsCols[i]);
|
||||||
|
SWindowPosition* p1 = (SWindowPosition*)taosHashGet(pSup->pWindowHashTable,
|
||||||
|
pSup->pKeyBuf, pSup->keySize);
|
||||||
|
if (p1 == NULL) {
|
||||||
|
SWindowPosition pos = {.pageId = pageId, .rowId = i};
|
||||||
|
int32_t code = taosHashPut(pSup->pWindowHashTable, pSup->pKeyBuf, pSup->keySize, &pos,
|
||||||
|
sizeof(SWindowPosition));
|
||||||
|
if (code != TSDB_CODE_SUCCESS ) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p1->pageId = pageId;
|
||||||
|
p1->rowId = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t catchDatablock(SSDataBlock* pDataBlock, SCatchSupporter* pSup,
|
||||||
|
int32_t tsIndex, int64_t childId) {
|
||||||
|
int32_t start = 0;
|
||||||
|
int32_t stop = 0;
|
||||||
|
int32_t pageSize = getBufPageSize(pSup->pDataBuf);
|
||||||
|
while(start < pDataBlock->info.rows) {
|
||||||
|
blockDataSplitRows(pDataBlock, pDataBlock->info.hasVarCol, start, &stop, pageSize);
|
||||||
|
SSDataBlock* pDB = blockDataExtractBlock(pDataBlock, start, stop - start + 1);
|
||||||
|
if (pDB == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
int32_t pageId = -1;
|
||||||
|
void* pPage = getNewBufPage(pSup->pDataBuf, pDataBlock->info.groupId, &pageId);
|
||||||
|
if (pPage == NULL) {
|
||||||
|
blockDataDestroy(pDB);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
int32_t size = blockDataGetSize(pDB) + sizeof(int32_t) + pDB->info.numOfCols * sizeof(int32_t);
|
||||||
|
assert(size <= pageSize);
|
||||||
|
blockDataToBuf(pPage, pDB);
|
||||||
|
setBufPageDirty(pPage, true);
|
||||||
|
releaseBufPage(pSup->pDataBuf, pPage);
|
||||||
|
blockDataDestroy(pDB);
|
||||||
|
start = stop + 1;
|
||||||
|
int32_t code = catchWidonwInfo(pDB, pSup, pageId, tsIndex, childId);
|
||||||
|
if (code != TSDB_CODE_SUCCESS ) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* getDataFromCatch(SStreamBlockScanInfo* pInfo) {
|
||||||
|
SSDataBlock* pBlock = pInfo->pUpdateRes;
|
||||||
|
if (pInfo->updateResIndex < pBlock->info.rows) {
|
||||||
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
SCatchSupporter* pCSup = &pInfo->childAggSup;
|
||||||
|
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
TSKEY *tsCols = (TSKEY*)pColDataInfo->pData;
|
||||||
|
int32_t size = taosArrayGetSize(pInfo->childIds);
|
||||||
|
for (int32_t i = 0; i < size; i++) {
|
||||||
|
int64_t id = *(int64_t *)taosArrayGet(pInfo->childIds, i);
|
||||||
|
setSupKeyBuf(pCSup, pBlock->info.groupId, id,
|
||||||
|
tsCols[pInfo->updateResIndex]);
|
||||||
|
SWindowPosition* pos = (SWindowPosition*)taosHashGet(pCSup->pWindowHashTable,
|
||||||
|
pCSup->pKeyBuf, pCSup->keySize);
|
||||||
|
void* buf = getBufPage(pCSup->pDataBuf, pos->pageId);
|
||||||
|
SSDataBlock* pDB = createOneDataBlock(pInfo->pRes, false);
|
||||||
|
blockDataFromBuf(pDB, buf);
|
||||||
|
SSDataBlock* pSub = blockDataExtractBlock(pDB, pos->rowId, 1);
|
||||||
|
blockDataMerge(pInfo->pRes, pSub, NULL);
|
||||||
|
blockDataDestroy(pDB);
|
||||||
|
blockDataDestroy(pSub);
|
||||||
|
}
|
||||||
|
pInfo->updateResIndex++;
|
||||||
|
return pInfo->pRes;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
// NOTE: this operator does never check if current status is done or not
|
// NOTE: this operator does never check if current status is done or not
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -688,6 +783,15 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||||
if (pInfo->blockType == STREAM_DATA_TYPE_SSDATA_BLOCK) {
|
if (pInfo->blockType == STREAM_DATA_TYPE_SSDATA_BLOCK) {
|
||||||
|
if (pInfo->scanMode == STREAM_SCAN_FROM_UPDATERES) {
|
||||||
|
SSDataBlock* pDB = getDataFromCatch(pInfo);
|
||||||
|
if (pDB != NULL) {
|
||||||
|
return pDB;
|
||||||
|
} else {
|
||||||
|
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->validBlockIndex >= total) {
|
if (pInfo->validBlockIndex >= total) {
|
||||||
doClearBufferedBlocks(pInfo);
|
doClearBufferedBlocks(pInfo);
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
@ -695,7 +799,17 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t current = pInfo->validBlockIndex++;
|
int32_t current = pInfo->validBlockIndex++;
|
||||||
return taosArrayGetP(pInfo->pBlockLists, current);
|
SSDataBlock* pBlock = taosArrayGetP(pInfo->pBlockLists, current);
|
||||||
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
|
pInfo->scanMode = STREAM_SCAN_FROM_UPDATERES;
|
||||||
|
} else {
|
||||||
|
int32_t code = catchDatablock(pBlock, &pInfo->childAggSup, pInfo->primaryTsIndex, 0);
|
||||||
|
if (code != TDB_CODE_SUCCESS) {
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
longjmp(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pBlock;
|
||||||
} else {
|
} else {
|
||||||
if (pInfo->scanMode == STREAM_SCAN_FROM_RES) {
|
if (pInfo->scanMode == STREAM_SCAN_FROM_RES) {
|
||||||
blockDataDestroy(pInfo->pUpdateRes);
|
blockDataDestroy(pInfo->pUpdateRes);
|
||||||
|
@ -857,6 +971,10 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataR
|
||||||
pInfo->pOperatorDumy = pOperatorDumy;
|
pInfo->pOperatorDumy = pOperatorDumy;
|
||||||
pInfo->interval = pSTInfo->interval;
|
pInfo->interval = pSTInfo->interval;
|
||||||
|
|
||||||
|
size_t childKeyBufSize = sizeof(int64_t) + sizeof(int64_t) + sizeof(TSKEY);
|
||||||
|
initCatchSupporter(&pInfo->childAggSup, 1024, childKeyBufSize,
|
||||||
|
"StreamFinalInterval", "/tmp/"); // TODO(liuyao) get row size from phy plan
|
||||||
|
|
||||||
pOperator->name = "StreamBlockScanOperator";
|
pOperator->name = "StreamBlockScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
|
|
|
@ -8,6 +8,8 @@ typedef enum SResultTsInterpType {
|
||||||
RESULT_ROW_END_INTERP = 2,
|
RESULT_ROW_END_INTERP = 2,
|
||||||
} SResultTsInterpType;
|
} SResultTsInterpType;
|
||||||
|
|
||||||
|
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are two cases to handle:
|
* There are two cases to handle:
|
||||||
*
|
*
|
||||||
|
@ -473,8 +475,7 @@ static bool setTimeWindowInterpolationEndTs(SOperatorInfo* pOperatorInfo, SqlFun
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
static int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
||||||
TSKEY* primaryKeys, int32_t prevPosition, SIntervalAggOperatorInfo* pInfo) {
|
TSKEY* primaryKeys, int32_t prevPosition, int32_t order) {
|
||||||
int32_t order = pInfo->order;
|
|
||||||
bool ascQuery = (order == TSDB_ORDER_ASC);
|
bool ascQuery = (order == TSDB_ORDER_ASC);
|
||||||
|
|
||||||
int32_t precision = pInterval->precision;
|
int32_t precision = pInterval->precision;
|
||||||
|
@ -723,7 +724,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
STimeWindow nextWin = win;
|
STimeWindow nextWin = win;
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
||||||
startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, pInfo);
|
startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, pInfo->order);
|
||||||
if (startPos < 0) {
|
if (startPos < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1031,18 +1032,41 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void doClearWindows(SIntervalAggOperatorInfo* pInfo, int32_t numOfOutput, SSDataBlock* pBlock) {
|
|
||||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
void doClearWindow(SAggSupporter* pSup, SOptrBasicInfo* pBinfo, char* pData,
|
||||||
|
int16_t bytes, uint64_t groupId, int32_t numOfOutput) {
|
||||||
|
SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
|
||||||
|
SResultRowPosition* p1 =
|
||||||
|
(SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf,
|
||||||
|
GET_RES_WINDOW_KEY_LEN(bytes));
|
||||||
|
SResultRow* pResult = getResultRowByPos(pSup->pResultBuf, p1);
|
||||||
|
SqlFunctionCtx* pCtx = pBinfo->pCtx;
|
||||||
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
|
pCtx[i].resultInfo = getResultCell(pResult, i, pBinfo->rowCellInfoOffset);
|
||||||
|
struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo;
|
||||||
|
if (fmIsWindowPseudoColumnFunc(pCtx[i].functionId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pResInfo->initialized = false;
|
||||||
|
if (pCtx[i].functionId != -1) {
|
||||||
|
pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void doClearWindows(SAggSupporter* pSup, SOptrBasicInfo* pBinfo,
|
||||||
|
SInterval* pIntrerval, int32_t tsIndex, int32_t numOfOutput, SSDataBlock* pBlock) {
|
||||||
|
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, tsIndex);
|
||||||
TSKEY *tsCols = (TSKEY*)pColDataInfo->pData;
|
TSKEY *tsCols = (TSKEY*)pColDataInfo->pData;
|
||||||
int32_t step = 0;
|
int32_t step = 0;
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
||||||
SResultRowInfo dumyInfo;
|
SResultRowInfo dumyInfo;
|
||||||
dumyInfo.cur.pageId = -1;
|
dumyInfo.cur.pageId = -1;
|
||||||
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], &pInfo->interval,
|
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], pIntrerval,
|
||||||
pInfo->interval.precision, NULL);
|
pIntrerval->precision, NULL);
|
||||||
step = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, i,
|
step = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, i,
|
||||||
win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
||||||
doClearWindow(pInfo, (char*)&win.skey, sizeof(TKEY), pBlock->info.groupId, numOfOutput);
|
doClearWindow(pSup, pBinfo, (char*)&win.skey, sizeof(TKEY), pBlock->info.groupId, numOfOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,7 +1109,8 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
doClearWindows(pInfo, pOperator->numOfExprs, pBlock);
|
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval,
|
||||||
|
pInfo->primaryTsIndex, pOperator->numOfExprs, pBlock);
|
||||||
qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
|
qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1099,8 +1124,6 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
|
|
||||||
// TODO: remove for stream
|
|
||||||
/*ASSERT(pInfo->binfo.pRes->info.rows > 0);*/
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
|
||||||
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
|
@ -1118,6 +1141,12 @@ void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
cleanupAggSup(&pInfo->aggSup);
|
cleanupAggSup(&pInfo->aggSup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
|
SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo *)param;
|
||||||
|
doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
|
||||||
|
cleanupAggSup(&pInfo->aggSup);
|
||||||
|
}
|
||||||
|
|
||||||
bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) {
|
bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) {
|
||||||
for (int32_t i = 0; i < numOfCols; i++) {
|
for (int32_t i = 0; i < numOfCols; i++) {
|
||||||
if (!fmIsInvertible(pFCtx[i].functionId)) {
|
if (!fmIsInvertible(pFCtx[i].functionId)) {
|
||||||
|
@ -1187,6 +1216,63 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
|
STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
|
||||||
|
SExecTaskInfo* pTaskInfo) {
|
||||||
|
SStreamFinalIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamFinalIntervalOperatorInfo));
|
||||||
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
pInfo->order = TSDB_ORDER_ASC;
|
||||||
|
pInfo->interval = *pInterval;
|
||||||
|
pInfo->twAggSup = *pTwAggSupp;
|
||||||
|
pInfo->primaryTsIndex = primaryTsSlotId;
|
||||||
|
|
||||||
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
|
initResultSizeInfo(pOperator, 4096);
|
||||||
|
|
||||||
|
int32_t code =
|
||||||
|
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, pResBlock,
|
||||||
|
keyBufSize, pTaskInfo->id.str);
|
||||||
|
|
||||||
|
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1);
|
||||||
|
|
||||||
|
pOperator->name = "StreamFinalIntervalOperator";
|
||||||
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL;
|
||||||
|
pOperator->blocking = true;
|
||||||
|
pOperator->status = OP_NOT_OPENED;
|
||||||
|
pOperator->pExpr = pExprInfo;
|
||||||
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
pOperator->numOfExprs = numOfCols;
|
||||||
|
pOperator->info = pInfo;
|
||||||
|
|
||||||
|
pOperator->fpSet = createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL,
|
||||||
|
destroyStreamFinalIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pOperator;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
destroyStreamFinalIntervalOperatorInfo(pInfo, numOfCols);
|
||||||
|
taosMemoryFreeClear(pInfo);
|
||||||
|
taosMemoryFreeClear(pOperator);
|
||||||
|
pTaskInfo->code = code;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
|
STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
|
||||||
|
@ -1550,3 +1636,91 @@ _error:
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SArray* doHashInterval(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock,
|
||||||
|
int32_t tableGroupId) {
|
||||||
|
SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)pOperatorInfo->info;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
|
||||||
|
int32_t numOfOutput = pOperatorInfo->numOfExprs;
|
||||||
|
SArray* pUpdated = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
int32_t step = 1;
|
||||||
|
bool ascScan = true;
|
||||||
|
TSKEY* tsCols = NULL;
|
||||||
|
SResultRow* pResult = NULL;
|
||||||
|
int32_t forwardStep = 0;
|
||||||
|
|
||||||
|
if (pSDataBlock->pDataBlock != NULL) {
|
||||||
|
SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
|
tsCols = (int64_t*)pColDataInfo->pData;
|
||||||
|
}
|
||||||
|
int32_t startPos = ascScan ? 0 : (pSDataBlock->info.rows - 1);
|
||||||
|
TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascScan);
|
||||||
|
STimeWindow nextWin = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts,
|
||||||
|
&pInfo->interval, pInfo->interval.precision, NULL);
|
||||||
|
while (1) {
|
||||||
|
int32_t code =
|
||||||
|
setTimeWindowOutputBuf(pResultRowInfo, &nextWin, true, &pResult, tableGroupId, pInfo->binfo.pCtx,
|
||||||
|
numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||||
|
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
|
||||||
|
pos->groupId = tableGroupId;
|
||||||
|
pos->pos = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
||||||
|
*(int64_t*)pos->key = pResult->win.skey;
|
||||||
|
taosArrayPush(pUpdated, &pos);
|
||||||
|
forwardStep =
|
||||||
|
getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
||||||
|
// window start(end) key interpolation
|
||||||
|
doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &nextWin, startPos, forwardStep,
|
||||||
|
pInfo->order, false);
|
||||||
|
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
|
||||||
|
doApplyFunctions(pTaskInfo, pInfo->binfo.pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardStep, tsCols,
|
||||||
|
pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||||
|
int32_t prevEndPos = (forwardStep - 1) * step + startPos;
|
||||||
|
startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, pInfo->order);
|
||||||
|
if (startPos < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
|
SArray* pUpdated = NULL;
|
||||||
|
|
||||||
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
|
return NULL;
|
||||||
|
} else if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
}
|
||||||
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
if (pBlock == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
|
||||||
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
|
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval,
|
||||||
|
pInfo->primaryTsIndex, pOperator->numOfExprs, pBlock);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pUpdated = doHashInterval(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
finalizeUpdatedResult(pOperator->numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset);
|
||||||
|
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
||||||
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
|
}
|
||||||
|
|
|
@ -100,6 +100,10 @@ int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc) {
|
||||||
return getUdfInfo(pParam, pFunc);
|
return getUdfInfo(pParam, pFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fmIsBuiltinFunc(const char* pFunc) {
|
||||||
|
return NULL != taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc));
|
||||||
|
}
|
||||||
|
|
||||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||||
if (fmIsUserDefinedFunc(pFunc->funcId) || pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
if (fmIsUserDefinedFunc(pFunc->funcId) || pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
||||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
|
|
@ -118,21 +118,21 @@ TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t d
|
||||||
}
|
}
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_FLOAT) {
|
} else if (dtype == TSDB_DATA_TYPE_FLOAT) {
|
||||||
float va = strtod(a, NULL);
|
float va = taosStr2Float(a, NULL);
|
||||||
if (errno == ERANGE && va == -1) {
|
if (errno == ERANGE && va == -1) {
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
float vb = strtod(b, NULL);
|
float vb = taosStr2Float(b, NULL);
|
||||||
if (errno == ERANGE && va == -1) {
|
if (errno == ERANGE && va == -1) {
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (dtype == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
double va = strtod(a, NULL);
|
double va = taosStr2Double(a, NULL);
|
||||||
if (errno == ERANGE && va == -1) {
|
if (errno == ERANGE && va == -1) {
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
double vb = strtod(b, NULL);
|
double vb = taosStr2Double(b, NULL);
|
||||||
if (errno == ERANGE && va == -1) {
|
if (errno == ERANGE && va == -1) {
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -946,6 +946,23 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkLogicPlanSubplans = "Subplans";
|
||||||
|
|
||||||
|
static int32_t logicPlanToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SQueryLogicPlan* pNode = (const SQueryLogicPlan*)pObj;
|
||||||
|
return tjsonAddObject(pJson, jkLogicPlanSubplans, nodeToJson, nodesListGetNode(pNode->pTopSubplans, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToLogicPlan(const SJson* pJson, void* pObj) {
|
||||||
|
SQueryLogicPlan* pNode = (SQueryLogicPlan*)pObj;
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
int32_t code = jsonToNodeObject(pJson, jkLogicPlanSubplans, &pChild);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListMakeStrictAppend(&pNode->pTopSubplans, pChild);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkJoinLogicPlanJoinType = "JoinType";
|
static const char* jkJoinLogicPlanJoinType = "JoinType";
|
||||||
static const char* jkJoinLogicPlanOnConditions = "OnConditions";
|
static const char* jkJoinLogicPlanOnConditions = "OnConditions";
|
||||||
|
|
||||||
|
@ -3029,7 +3046,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return logicSubplanToJson(pObj, pJson);
|
return logicSubplanToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN:
|
case QUERY_NODE_LOGIC_PLAN:
|
||||||
break;
|
return logicPlanToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
return physiTagScanNodeToJson(pObj, pJson);
|
return physiTagScanNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||||
|
@ -3126,6 +3143,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToLogicPartitionNode(pJson, pObj);
|
return jsonToLogicPartitionNode(pJson, pObj);
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return jsonToLogicSubplan(pJson, pObj);
|
return jsonToLogicSubplan(pJson, pObj);
|
||||||
|
case QUERY_NODE_LOGIC_PLAN:
|
||||||
|
return jsonToLogicPlan(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
return jsonToPhysiTagScanNode(pJson, pObj);
|
return jsonToPhysiTagScanNode(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||||
|
|
|
@ -621,6 +621,7 @@ column_reference(A) ::= table_name(B) NK_DOT column_name(C).
|
||||||
|
|
||||||
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
|
pseudo_column(A) ::= table_name(B) NK_DOT TBNAME(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &C, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)))); }
|
||||||
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
|
|
|
@ -123,7 +123,7 @@ static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, ch
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
||||||
} else {
|
} else {
|
||||||
strncpy(pFqdn, ep, pColon - ep);
|
strncpy(pFqdn, ep, pColon - ep);
|
||||||
*pPort = strtol(pColon + 1, NULL, 10);
|
*pPort = taosStr2Int32(pColon + 1, NULL, 10);
|
||||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t
|
||||||
if (NULL == pPortToken) {
|
if (NULL == pPortToken) {
|
||||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||||
} else {
|
} else {
|
||||||
*pPort = strtol(pPortToken->z, NULL, 10);
|
*pPort = taosStr2Int32(pPortToken->z, NULL, 10);
|
||||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||||
}
|
}
|
||||||
|
@ -155,9 +155,9 @@ static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t
|
||||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) {
|
static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool demandDb) {
|
||||||
if (NULL == pDbName) {
|
if (NULL == pDbName) {
|
||||||
if (query && NULL == pCxt->pQueryCxt->db) {
|
if (demandDb && NULL == pCxt->pQueryCxt->db) {
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED);
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,6 +196,15 @@ static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, bool demand) {
|
||||||
|
if (NULL == pCommentToken) {
|
||||||
|
pCxt->errCode = demand ? TSDB_CODE_PAR_SYNTAX_ERROR : TSDB_CODE_SUCCESS;
|
||||||
|
} else if (pCommentToken->n >= (TSDB_TB_COMMENT_LEN + 2)) {
|
||||||
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_COMMENT_TOO_LONG);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
||||||
SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR);
|
SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR);
|
||||||
CHECK_OUT_OF_MEM(target);
|
CHECK_OUT_OF_MEM(target);
|
||||||
|
@ -457,6 +466,8 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_SELECT_STMT == nodeType(pSubquery)) {
|
if (QUERY_NODE_SELECT_STMT == nodeType(pSubquery)) {
|
||||||
strcpy(((SSelectStmt*)pSubquery)->stmtName, tempTable->table.tableAlias);
|
strcpy(((SSelectStmt*)pSubquery)->stmtName, tempTable->table.tableAlias);
|
||||||
|
} else if (QUERY_NODE_SET_OPERATOR == nodeType(pSubquery)) {
|
||||||
|
strcpy(((SSetOperator*)pSubquery)->stmtName, tempTable->table.tableAlias);
|
||||||
}
|
}
|
||||||
return (SNode*)tempTable;
|
return (SNode*)tempTable;
|
||||||
}
|
}
|
||||||
|
@ -474,9 +485,9 @@ SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft
|
||||||
SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset) {
|
SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset) {
|
||||||
SLimitNode* limitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT);
|
SLimitNode* limitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT);
|
||||||
CHECK_OUT_OF_MEM(limitNode);
|
CHECK_OUT_OF_MEM(limitNode);
|
||||||
limitNode->limit = strtol(pLimit->z, NULL, 10);
|
limitNode->limit = taosStr2Int64(pLimit->z, NULL, 10);
|
||||||
if (NULL != pOffset) {
|
if (NULL != pOffset) {
|
||||||
limitNode->offset = strtol(pOffset->z, NULL, 10);
|
limitNode->offset = taosStr2Int64(pOffset->z, NULL, 10);
|
||||||
}
|
}
|
||||||
return (SNode*)limitNode;
|
return (SNode*)limitNode;
|
||||||
}
|
}
|
||||||
|
@ -637,6 +648,7 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
|
||||||
setOp->opType = type;
|
setOp->opType = type;
|
||||||
setOp->pLeft = pLeft;
|
setOp->pLeft = pLeft;
|
||||||
setOp->pRight = pRight;
|
setOp->pRight = pRight;
|
||||||
|
sprintf(setOp->stmtName, "%p", setOp);
|
||||||
return (SNode*)setOp;
|
return (SNode*)setOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,59 +703,59 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
||||||
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) {
|
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DB_OPTION_BUFFER:
|
case DB_OPTION_BUFFER:
|
||||||
((SDatabaseOptions*)pOptions)->buffer = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->buffer = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_CACHELAST:
|
case DB_OPTION_CACHELAST:
|
||||||
((SDatabaseOptions*)pOptions)->cachelast = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->cachelast = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_COMP:
|
case DB_OPTION_COMP:
|
||||||
((SDatabaseOptions*)pOptions)->compressionLevel = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->compressionLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_DAYS: {
|
case DB_OPTION_DAYS: {
|
||||||
SToken* pToken = pVal;
|
SToken* pToken = pVal;
|
||||||
if (TK_NK_INTEGER == pToken->type) {
|
if (TK_NK_INTEGER == pToken->type) {
|
||||||
((SDatabaseOptions*)pOptions)->daysPerFile = strtol(pToken->z, NULL, 10) * 1440;
|
((SDatabaseOptions*)pOptions)->daysPerFile = taosStr2Int32(pToken->z, NULL, 10) * 1440;
|
||||||
} else {
|
} else {
|
||||||
((SDatabaseOptions*)pOptions)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, pToken);
|
((SDatabaseOptions*)pOptions)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, pToken);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DB_OPTION_FSYNC:
|
case DB_OPTION_FSYNC:
|
||||||
((SDatabaseOptions*)pOptions)->fsyncPeriod = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->fsyncPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_MAXROWS:
|
case DB_OPTION_MAXROWS:
|
||||||
((SDatabaseOptions*)pOptions)->maxRowsPerBlock = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->maxRowsPerBlock = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_MINROWS:
|
case DB_OPTION_MINROWS:
|
||||||
((SDatabaseOptions*)pOptions)->minRowsPerBlock = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->minRowsPerBlock = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_KEEP:
|
case DB_OPTION_KEEP:
|
||||||
((SDatabaseOptions*)pOptions)->pKeep = pVal;
|
((SDatabaseOptions*)pOptions)->pKeep = pVal;
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_PAGES:
|
case DB_OPTION_PAGES:
|
||||||
((SDatabaseOptions*)pOptions)->pages = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->pages = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_PAGESIZE:
|
case DB_OPTION_PAGESIZE:
|
||||||
((SDatabaseOptions*)pOptions)->pagesize = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->pagesize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_PRECISION:
|
case DB_OPTION_PRECISION:
|
||||||
copyStringFormStringToken((SToken*)pVal, ((SDatabaseOptions*)pOptions)->precisionStr,
|
copyStringFormStringToken((SToken*)pVal, ((SDatabaseOptions*)pOptions)->precisionStr,
|
||||||
sizeof(((SDatabaseOptions*)pOptions)->precisionStr));
|
sizeof(((SDatabaseOptions*)pOptions)->precisionStr));
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_REPLICA:
|
case DB_OPTION_REPLICA:
|
||||||
((SDatabaseOptions*)pOptions)->replica = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_STRICT:
|
case DB_OPTION_STRICT:
|
||||||
((SDatabaseOptions*)pOptions)->strict = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->strict = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_WAL:
|
case DB_OPTION_WAL:
|
||||||
((SDatabaseOptions*)pOptions)->walLevel = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->walLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_VGROUPS:
|
case DB_OPTION_VGROUPS:
|
||||||
((SDatabaseOptions*)pOptions)->numOfVgroups = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->numOfVgroups = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_SINGLE_STABLE:
|
case DB_OPTION_SINGLE_STABLE:
|
||||||
((SDatabaseOptions*)pOptions)->singleStable = strtol(((SToken*)pVal)->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->singleStable = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case DB_OPTION_RETENTIONS:
|
case DB_OPTION_RETENTIONS:
|
||||||
((SDatabaseOptions*)pOptions)->pRetentions = pVal;
|
((SDatabaseOptions*)pOptions)->pRetentions = pVal;
|
||||||
|
@ -820,20 +832,22 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
|
||||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal) {
|
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TABLE_OPTION_COMMENT:
|
case TABLE_OPTION_COMMENT:
|
||||||
copyStringFormStringToken((SToken*)pVal, ((STableOptions*)pOptions)->comment,
|
if (checkComment(pCxt, (SToken*)pVal, true)) {
|
||||||
sizeof(((STableOptions*)pOptions)->comment));
|
copyStringFormStringToken((SToken*)pVal, ((STableOptions*)pOptions)->comment,
|
||||||
|
sizeof(((STableOptions*)pOptions)->comment));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_DELAY:
|
case TABLE_OPTION_DELAY:
|
||||||
((STableOptions*)pOptions)->delay = strtol(((SToken*)pVal)->z, NULL, 10);
|
((STableOptions*)pOptions)->delay = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_FILE_FACTOR:
|
case TABLE_OPTION_FILE_FACTOR:
|
||||||
((STableOptions*)pOptions)->filesFactor = strtod(((SToken*)pVal)->z, NULL);
|
((STableOptions*)pOptions)->filesFactor = taosStr2Float(((SToken*)pVal)->z, NULL);
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_ROLLUP:
|
case TABLE_OPTION_ROLLUP:
|
||||||
((STableOptions*)pOptions)->pRollupFuncs = pVal;
|
((STableOptions*)pOptions)->pRollupFuncs = pVal;
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_TTL:
|
case TABLE_OPTION_TTL:
|
||||||
((STableOptions*)pOptions)->ttl = strtol(((SToken*)pVal)->z, NULL, 10);
|
((STableOptions*)pOptions)->ttl = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_SMA:
|
case TABLE_OPTION_SMA:
|
||||||
((STableOptions*)pOptions)->pSma = pVal;
|
((STableOptions*)pOptions)->pSma = pVal;
|
||||||
|
@ -845,7 +859,7 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment) {
|
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment) {
|
||||||
if (!checkColumnName(pCxt, pColName)) {
|
if (!checkColumnName(pCxt, pColName) || !checkComment(pCxt, pComment, false)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
||||||
|
@ -865,7 +879,7 @@ SDataType createDataType(uint8_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
||||||
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = strtol(pLen->z, NULL, 10)};
|
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = taosStr2Int16(pLen->z, NULL, 10)};
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,7 +1130,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
||||||
SDropDnodeStmt* pStmt = (SDropDnodeStmt*)nodesMakeNode(QUERY_NODE_DROP_DNODE_STMT);
|
SDropDnodeStmt* pStmt = (SDropDnodeStmt*)nodesMakeNode(QUERY_NODE_DROP_DNODE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
if (TK_NK_INTEGER == pDnode->type) {
|
if (TK_NK_INTEGER == pDnode->type) {
|
||||||
pStmt->dnodeId = strtol(pDnode->z, NULL, 10);
|
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||||
} else {
|
} else {
|
||||||
if (!checkAndSplitEndpoint(pCxt, pDnode, pStmt->fqdn, &pStmt->port)) {
|
if (!checkAndSplitEndpoint(pCxt, pDnode, pStmt->fqdn, &pStmt->port)) {
|
||||||
nodesDestroyNode(pStmt);
|
nodesDestroyNode(pStmt);
|
||||||
|
@ -1130,7 +1144,7 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
||||||
const SToken* pValue) {
|
const SToken* pValue) {
|
||||||
SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->dnodeId = strtol(pDnode->z, NULL, 10);
|
pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10);
|
||||||
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config));
|
||||||
if (NULL != pValue) {
|
if (NULL != pValue) {
|
||||||
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
||||||
|
@ -1140,7 +1154,7 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
||||||
|
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
||||||
SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
||||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName) || !checkDbName(pCxt, NULL, true)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
||||||
|
@ -1180,7 +1194,7 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
|
||||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
||||||
SCreateComponentNodeStmt* pStmt = nodesMakeNode(type);
|
SCreateComponentNodeStmt* pStmt = nodesMakeNode(type);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);
|
pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10);
|
||||||
;
|
;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -1188,7 +1202,7 @@ SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, co
|
||||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
||||||
SDropComponentNodeStmt* pStmt = nodesMakeNode(type);
|
SDropComponentNodeStmt* pStmt = nodesMakeNode(type);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);
|
pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10);
|
||||||
;
|
;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -1248,7 +1262,7 @@ SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken*
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal) {
|
SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal) {
|
||||||
((SExplainOptions*)pOptions)->ratio = strtod(pVal->z, NULL);
|
((SExplainOptions*)pOptions)->ratio = taosStr2Double(pVal->z, NULL);
|
||||||
return pOptions;
|
return pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1344,7 +1358,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const
|
||||||
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) {
|
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) {
|
||||||
SKillStmt* pStmt = nodesMakeNode(type);
|
SKillStmt* pStmt = nodesMakeNode(type);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->targetId = strtol(pId->z, NULL, 10);
|
pStmt->targetId = taosStr2Int32(pId->z, NULL, 10);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,7 +442,7 @@ static bool isNullStr(SToken* pToken) {
|
||||||
|
|
||||||
static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPtr) {
|
static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPtr) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
*value = strtold(pToken->z, endPtr);
|
*value = taosStr2Double(pToken->z, endPtr);
|
||||||
|
|
||||||
// not a valid integer number, return error
|
// not a valid integer number, return error
|
||||||
if ((*endPtr - pToken->z) != pToken->n) {
|
if ((*endPtr - pToken->z) != pToken->n) {
|
||||||
|
@ -482,9 +482,9 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z);
|
||||||
}
|
}
|
||||||
} else if (pToken->type == TK_NK_INTEGER) {
|
} else if (pToken->type == TK_NK_INTEGER) {
|
||||||
return func(pMsgBuf, ((strtoll(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param);
|
return func(pMsgBuf, ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param);
|
||||||
} else if (pToken->type == TK_NK_FLOAT) {
|
} else if (pToken->type == TK_NK_FLOAT) {
|
||||||
return func(pMsgBuf, ((strtod(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param);
|
return func(pMsgBuf, ((taosStr2Double(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param);
|
||||||
} else {
|
} else {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,6 +272,10 @@ static bool isTimelineFunc(const SNode* pNode) {
|
||||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsTimelineFunc(((SFunctionNode*)pNode)->funcId));
|
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsTimelineFunc(((SFunctionNode*)pNode)->funcId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isScanPseudoColumnFunc(const SNode* pNode) {
|
||||||
|
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsScanPseudoColumnFunc(((SFunctionNode*)pNode)->funcId));
|
||||||
|
}
|
||||||
|
|
||||||
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
||||||
return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct);
|
return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +502,7 @@ static int32_t parseTimeFromValueNode(SValueNode* pVal) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
char* pEnd = NULL;
|
char* pEnd = NULL;
|
||||||
pVal->datum.i = strtoll(pVal->literal, &pEnd, 10);
|
pVal->datum.i = taosStr2Int64(pVal->literal, &pEnd, 10);
|
||||||
return (NULL != pEnd && '\0' == *pEnd) ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED;
|
return (NULL != pEnd && '\0' == *pEnd) ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED;
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
@ -527,61 +531,61 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
pVal->datum.i = taosStr2Int64(pVal->literal, &endPtr, 10);
|
||||||
*(int8_t*)&pVal->typeData = pVal->datum.i;
|
*(int8_t*)&pVal->typeData = pVal->datum.i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
case TSDB_DATA_TYPE_SMALLINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
pVal->datum.i = taosStr2Int64(pVal->literal, &endPtr, 10);
|
||||||
*(int16_t*)&pVal->typeData = pVal->datum.i;
|
*(int16_t*)&pVal->typeData = pVal->datum.i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
pVal->datum.i = taosStr2Int64(pVal->literal, &endPtr, 10);
|
||||||
*(int32_t*)&pVal->typeData = pVal->datum.i;
|
*(int32_t*)&pVal->typeData = pVal->datum.i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
pVal->datum.i = taosStr2Int64(pVal->literal, &endPtr, 10);
|
||||||
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
case TSDB_DATA_TYPE_UTINYINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
pVal->datum.u = taosStr2UInt64(pVal->literal, &endPtr, 10);
|
||||||
*(uint8_t*)&pVal->typeData = pVal->datum.u;
|
*(uint8_t*)&pVal->typeData = pVal->datum.u;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
pVal->datum.u = taosStr2UInt64(pVal->literal, &endPtr, 10);
|
||||||
*(uint16_t*)&pVal->typeData = pVal->datum.u;
|
*(uint16_t*)&pVal->typeData = pVal->datum.u;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
case TSDB_DATA_TYPE_UINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
pVal->datum.u = taosStr2UInt64(pVal->literal, &endPtr, 10);
|
||||||
*(uint32_t*)&pVal->typeData = pVal->datum.u;
|
*(uint32_t*)&pVal->typeData = pVal->datum.u;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
pVal->datum.u = taosStr2UInt64(pVal->literal, &endPtr, 10);
|
||||||
*(uint64_t*)&pVal->typeData = pVal->datum.u;
|
*(uint64_t*)&pVal->typeData = pVal->datum.u;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
pVal->datum.d = taosStr2Double(pVal->literal, &endPtr);
|
||||||
*(float*)&pVal->typeData = pVal->datum.d;
|
*(float*)&pVal->typeData = pVal->datum.d;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
char* endPtr = NULL;
|
char* endPtr = NULL;
|
||||||
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
pVal->datum.d = taosStr2Double(pVal->literal, &endPtr);
|
||||||
*(double*)&pVal->typeData = pVal->datum.d;
|
*(double*)&pVal->typeData = pVal->datum.d;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -766,6 +770,20 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
|
||||||
pCxt->pCurrStmt->hasRepeatScanFuncs = true;
|
pCxt->pCurrStmt->hasRepeatScanFuncs = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == pCxt->errCode && fmIsScanPseudoColumnFunc(pFunc->funcId)) {
|
||||||
|
if (0 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
|
if (QUERY_NODE_REAL_TABLE != nodeType(pCxt->pCurrStmt->pFromTable)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_TBNAME);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SValueNode* pVal = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
STableNode* pTable = NULL;
|
||||||
|
pCxt->errCode = findTable(pCxt, pVal->literal, &pTable);
|
||||||
|
if (TSDB_CODE_SUCCESS == pCxt->errCode && (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable))) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_TBNAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,7 +896,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
if (pCxt->selectFuncNum > 1) {
|
if (pCxt->selectFuncNum > 1) {
|
||||||
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
||||||
} else {
|
} else {
|
||||||
|
@ -916,7 +934,7 @@ static EDealRes rewriteColsToSelectValFuncImpl(SNode** pNode, void* pContext) {
|
||||||
if (isAggFunc(*pNode)) {
|
if (isAggFunc(*pNode)) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
return rewriteColToSelectValFunc((STranslateContext*)pContext, NULL, pNode);
|
return rewriteColToSelectValFunc((STranslateContext*)pContext, NULL, pNode);
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -944,7 +962,7 @@ static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) {
|
||||||
pCxt->existAggFunc = true;
|
pCxt->existAggFunc = true;
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (isScanPseudoColumnFunc(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
pCxt->existCol = true;
|
pCxt->existCol = true;
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -1758,12 +1776,13 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* createSetOperProject(SNode* pNode) {
|
static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
||||||
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pCol->node.resType = ((SExprNode*)pNode)->resType;
|
pCol->node.resType = ((SExprNode*)pNode)->resType;
|
||||||
|
strcpy(pCol->tableAlias, pTableAlias);
|
||||||
strcpy(pCol->colName, ((SExprNode*)pNode)->aliasName);
|
strcpy(pCol->colName, ((SExprNode*)pNode)->aliasName);
|
||||||
strcpy(pCol->node.aliasName, pCol->colName);
|
strcpy(pCol->node.aliasName, pCol->colName);
|
||||||
return (SNode*)pCol;
|
return (SNode*)pCol;
|
||||||
|
@ -1817,7 +1836,8 @@ static int32_t translateSetOperatorImpl(STranslateContext* pCxt, SSetOperator* p
|
||||||
}
|
}
|
||||||
strcpy(pRightExpr->aliasName, pLeftExpr->aliasName);
|
strcpy(pRightExpr->aliasName, pLeftExpr->aliasName);
|
||||||
pRightExpr->aliasName[strlen(pLeftExpr->aliasName)] = '\0';
|
pRightExpr->aliasName[strlen(pLeftExpr->aliasName)] = '\0';
|
||||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSetOperator->pProjectionList, createSetOperProject(pLeft))) {
|
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSetOperator->pProjectionList,
|
||||||
|
createSetOperProject(pSetOperator->stmtName, pLeft))) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3245,6 +3265,9 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionStmt* pStmt) {
|
static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionStmt* pStmt) {
|
||||||
|
if (fmIsBuiltinFunc(pStmt->funcName)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FUNCTION_NAME);
|
||||||
|
}
|
||||||
SCreateFuncReq req = {0};
|
SCreateFuncReq req = {0};
|
||||||
strcpy(req.name, pStmt->funcName);
|
strcpy(req.name, pStmt->funcName);
|
||||||
req.igExists = pStmt->ignoreExists;
|
req.igExists = pStmt->ignoreExists;
|
||||||
|
|
|
@ -158,6 +158,12 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "Primary timestamp column cannot be dropped";
|
return "Primary timestamp column cannot be dropped";
|
||||||
case TSDB_CODE_PAR_INVALID_MODIFY_COL:
|
case TSDB_CODE_PAR_INVALID_MODIFY_COL:
|
||||||
return "Only binary/nchar column length could be modified";
|
return "Only binary/nchar column length could be modified";
|
||||||
|
case TSDB_CODE_PAR_INVALID_TBNAME:
|
||||||
|
return "Invalid tbname pseudo column";
|
||||||
|
case TSDB_CODE_PAR_INVALID_FUNCTION_NAME:
|
||||||
|
return "Invalid function name";
|
||||||
|
case TSDB_CODE_PAR_COMMENT_TOO_LONG:
|
||||||
|
return "Comment too long";
|
||||||
case TSDB_CODE_OUT_OF_MEMORY:
|
case TSDB_CODE_OUT_OF_MEMORY:
|
||||||
return "Out of memory";
|
return "Out of memory";
|
||||||
default:
|
default:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue