Merge remote-tracking branch 'origin/3.0' into feature/3.0_constant
This commit is contained in:
commit
b0c6118f0b
70
Jenkinsfile2
70
Jenkinsfile2
|
@ -117,27 +117,29 @@ def pre_test(){
|
|||
def pre_test_win(){
|
||||
bat '''
|
||||
hostname
|
||||
ipconfig
|
||||
set
|
||||
date /t
|
||||
time /t
|
||||
taskkill /f /t /im python.exe
|
||||
taskkill /f /t /im bash.exe
|
||||
rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
|
||||
exit 0
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
git reset --hard
|
||||
git fetch || git fetch
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git reset --hard
|
||||
git fetch || git fetch
|
||||
git checkout -f
|
||||
'''
|
||||
script {
|
||||
if (env.CHANGE_TARGET == 'master') {
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
git checkout master
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git checkout master
|
||||
'''
|
||||
|
@ -145,6 +147,8 @@ def pre_test_win(){
|
|||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
git checkout 2.0
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git checkout 2.0
|
||||
'''
|
||||
|
@ -152,6 +156,8 @@ def pre_test_win(){
|
|||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
git checkout 3.0
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git checkout 3.0
|
||||
'''
|
||||
|
@ -159,6 +165,8 @@ def pre_test_win(){
|
|||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
git checkout develop
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git checkout develop
|
||||
'''
|
||||
|
@ -169,30 +177,52 @@ def pre_test_win(){
|
|||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
git pull
|
||||
git log -5
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
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 log -5
|
||||
'''
|
||||
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
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 log -5
|
||||
'''
|
||||
bat '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git pull
|
||||
git log -5
|
||||
'''
|
||||
} else {
|
||||
sh '''
|
||||
echo "unmatched reposiotry ${CHANGE_URL}"
|
||||
bat '''
|
||||
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 '''
|
||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||
git submodule update --init --recursive
|
||||
|
@ -205,10 +235,15 @@ def pre_test_build_win() {
|
|||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||
mkdir debug
|
||||
cd debug
|
||||
time /t
|
||||
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
|
||||
set CL=/MP8
|
||||
cmake .. -G "NMake Makefiles JOM"
|
||||
jom -j 4 || exit 8
|
||||
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> cmake"
|
||||
time /t
|
||||
cmake .. -G "NMake Makefiles JOM" || exit 7
|
||||
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> jom -j 6"
|
||||
time /t
|
||||
jom -j 6 || exit 8
|
||||
time /t
|
||||
'''
|
||||
return 1
|
||||
|
@ -226,6 +261,13 @@ pipeline {
|
|||
stages {
|
||||
stage('run test') {
|
||||
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') {
|
||||
agent{label " slave3_0 || slave15 || slave16 || slave17 "}
|
||||
options { skipDefaultCheckout() }
|
||||
|
|
|
@ -5,22 +5,27 @@ IF (TD_LINUX)
|
|||
ELSEIF (TD_WINDOWS)
|
||||
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
|
||||
|
||||
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/python DESTINATION connector)
|
||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
||||
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
||||
# 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/python DESTINATION connector)
|
||||
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
||||
# INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
||||
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}/src/inc/taoserror.h DESTINATION include)
|
||||
INSTALL(FILES ${TD_SOURCE_DIR}/include/client/taos.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_static.lib DESTINATION driver)
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp 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)
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
|
||||
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)
|
||||
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
|
||||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||
|
|
|
@ -226,10 +226,10 @@ endif(${BUILD_WITH_NURAFT})
|
|||
if(${BUILD_PTHREAD})
|
||||
set(CMAKE_BUILD_TYPE release)
|
||||
add_definitions(-DPTW32_STATIC_LIB)
|
||||
add_subdirectory(pthread)
|
||||
add_subdirectory(pthread EXCLUDE_FROM_ALL)
|
||||
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
|
||||
add_library(pthread STATIC IMPORTED GLOBAL)
|
||||
SET_PROPERTY(TARGET pthread PROPERTY IMPORTED_LOCATION ${LIBRARY_OUTPUT_PATH}/pthread.lib)
|
||||
add_library(pthread INTERFACE)
|
||||
target_link_libraries(pthread INTERFACE libpthreadVC3)
|
||||
endif()
|
||||
|
||||
# iconv
|
||||
|
|
|
@ -239,7 +239,7 @@ void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
|||
msg_process(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);*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 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_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 void tmq_commit_async(tmq_t *tmq, const tmq_topic_vgroup_list_t *offsets, tmq_commit_cb *cb, void *param);
|
||||
|
||||
#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);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,27 +29,42 @@ extern "C" {
|
|||
typedef struct SSchema SSchema;
|
||||
typedef struct STColumn STColumn;
|
||||
typedef struct STSchema STSchema;
|
||||
typedef struct SColVal SColVal;
|
||||
typedef struct STSRow2 STSRow2;
|
||||
typedef struct STSRowBuilder STSRowBuilder;
|
||||
typedef struct SKVIdx SKVIdx;
|
||||
|
||||
// STSchema
|
||||
|
||||
// STSRow2
|
||||
int32_t tEncodeTSRow(SEncoder *pEncoder, const STSRow2 *pRow);
|
||||
int32_t tDecodeTSRow(SDecoder *pDecoder, STSRow2 *pRow);
|
||||
typedef struct STagVal STagVal;
|
||||
typedef struct STag STag;
|
||||
|
||||
// STSchema
|
||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
||||
void tTSchemaDestroy(STSchema *pTSchema);
|
||||
|
||||
// SColVal
|
||||
#define ColValNONE ((SColVal){.type = COL_VAL_NONE, .nData = 0, .pData = NULL})
|
||||
#define ColValNULL ((SColVal){.type = COL_VAL_NULL, .nData = 0, .pData = NULL})
|
||||
#define ColValDATA(nData, pData) ((SColVal){.type = COL_VAL_DATA, .nData = (nData), .pData = (pData)})
|
||||
|
||||
// STSRow2
|
||||
int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow);
|
||||
int32_t tGetTSRow(uint8_t *p, STSRow2 *pRow);
|
||||
int32_t tTSRowDup(const STSRow2 *pRow, STSRow2 **ppRow);
|
||||
void tTSRowFree(STSRow2 *pRow);
|
||||
int32_t tTSRowGet(const STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||
|
||||
// STSRowBuilder
|
||||
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, SSchema *pSchema, int32_t nCols);
|
||||
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, int32_t nCols, SSchema *pSchema);
|
||||
void tTSRowBuilderClear(STSRowBuilder *pBuilder);
|
||||
void tTSRowBuilderReset(STSRowBuilder *pBuilder);
|
||||
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, const uint8_t *pData, uint32_t nData);
|
||||
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, uint8_t *pData, uint32_t nData);
|
||||
int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow);
|
||||
|
||||
// STag
|
||||
int32_t tTagNew(STagVal *pTagVals, int16_t nTag, STag **ppTag);
|
||||
void tTagFree(STag *pTag);
|
||||
void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, int32_t *nData);
|
||||
int32_t tEncodeTag(SEncoder *pEncoder, STag *pTag);
|
||||
int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag);
|
||||
|
||||
// STRUCT =================
|
||||
struct STColumn {
|
||||
col_id_t colId;
|
||||
|
@ -68,31 +83,47 @@ struct STSchema {
|
|||
STColumn columns[];
|
||||
};
|
||||
|
||||
#define TSROW_HAS_NONE ((uint8_t)0x1)
|
||||
#define TSROW_HAS_NULL ((uint8_t)0x2U)
|
||||
#define TSROW_HAS_VAL ((uint8_t)0x4U)
|
||||
#define TSROW_KV_ROW ((uint8_t)0x10U)
|
||||
struct STSRow2 {
|
||||
TSKEY ts;
|
||||
uint32_t flags;
|
||||
union {
|
||||
int32_t sver;
|
||||
int32_t ncols;
|
||||
};
|
||||
uint32_t nData;
|
||||
const uint8_t *pData;
|
||||
uint8_t flags;
|
||||
int32_t sver;
|
||||
uint32_t nData;
|
||||
uint8_t *pData;
|
||||
};
|
||||
|
||||
struct STSRowBuilder {
|
||||
STColumn *pTColumn;
|
||||
STSchema *pTSchema;
|
||||
int32_t szBitMap1;
|
||||
int32_t szBitMap2;
|
||||
int32_t szKVBuf;
|
||||
uint8_t *pKVBuf;
|
||||
int32_t szTPBuf;
|
||||
uint8_t *pTPBuf;
|
||||
int32_t nCols;
|
||||
int32_t kvVLen;
|
||||
int32_t tpVLen;
|
||||
int32_t iCol;
|
||||
int32_t vlenKV;
|
||||
int32_t vlenTP;
|
||||
STSRow2 row;
|
||||
};
|
||||
|
||||
#if 1 //====================================
|
||||
typedef enum { COL_VAL_NONE = 0, COL_VAL_NULL = 1, COL_VAL_DATA = 2 } EColValT;
|
||||
struct SColVal {
|
||||
EColValT type;
|
||||
uint32_t nData;
|
||||
uint8_t *pData;
|
||||
};
|
||||
|
||||
struct STagVal {
|
||||
int16_t cid;
|
||||
int8_t type;
|
||||
uint32_t nData;
|
||||
uint8_t *pData;
|
||||
};
|
||||
|
||||
#if 1 //================================================================================================================================================
|
||||
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
||||
#define TD_SUPPORT_BITMAP
|
||||
#define TD_SUPPORT_READ2
|
||||
|
|
|
@ -258,6 +258,7 @@ typedef struct {
|
|||
char* tblFName;
|
||||
int32_t numOfRows;
|
||||
int32_t affectedRows;
|
||||
int64_t sver;
|
||||
} SSubmitBlkRsp;
|
||||
|
||||
typedef struct {
|
||||
|
@ -274,10 +275,10 @@ int32_t tEncodeSSubmitRsp(SEncoder* pEncoder, const SSubmitRsp* pRsp);
|
|||
int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp);
|
||||
void tFreeSSubmitRsp(SSubmitRsp* pRsp);
|
||||
|
||||
#define COL_SMA_ON ((int8_t)0x1)
|
||||
#define COL_IDX_ON ((int8_t)0x2)
|
||||
#define COL_VAL_SET ((int8_t)0x4)
|
||||
|
||||
#define COL_SMA_ON ((int8_t)0x1)
|
||||
#define COL_IDX_ON ((int8_t)0x2)
|
||||
#define COL_SET_NULL ((int8_t)0x10)
|
||||
#define COL_SET_VAL ((int8_t)0x20)
|
||||
typedef struct SSchema {
|
||||
int8_t type;
|
||||
int8_t flags;
|
||||
|
@ -286,6 +287,9 @@ typedef struct SSchema {
|
|||
char name[TSDB_COL_NAME_LEN];
|
||||
} SSchema;
|
||||
|
||||
#define COL_IS_SET(FLG) ((FLG) & (COL_SET_VAL | COL_SET_NULL) != 0)
|
||||
#define COL_CLR_SET(FLG) ((FLG) &= (~(COL_SET_VAL | COL_SET_NULL)))
|
||||
|
||||
#define IS_BSMA_ON(s) (((s)->flags & 0x01) == COL_SMA_ON)
|
||||
|
||||
#define SSCHMEA_TYPE(s) ((s)->type)
|
||||
|
@ -297,6 +301,8 @@ typedef struct SSchema {
|
|||
typedef struct {
|
||||
int32_t nCols;
|
||||
int32_t sver;
|
||||
int32_t tagVer;
|
||||
int32_t colVer;
|
||||
SSchema* pSchema;
|
||||
} SSchemaWrapper;
|
||||
|
||||
|
@ -305,6 +311,8 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
|||
if (pSW == NULL) return pSW;
|
||||
pSW->nCols = pSchemaWrapper->nCols;
|
||||
pSW->sver = pSchemaWrapper->sver;
|
||||
pSW->tagVer = pSchemaWrapper->tagVer;
|
||||
pSW->colVer = pSchemaWrapper->colVer;
|
||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||
if (pSW->pSchema == NULL) {
|
||||
taosMemoryFree(pSW);
|
||||
|
@ -360,6 +368,8 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
|
|||
int32_t tlen = 0;
|
||||
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
||||
tlen += taosEncodeVariantI32(buf, pSW->sver);
|
||||
tlen += taosEncodeVariantI32(buf, pSW->tagVer);
|
||||
tlen += taosEncodeVariantI32(buf, pSW->colVer);
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
|
||||
}
|
||||
|
@ -369,6 +379,8 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
|
|||
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
||||
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
||||
buf = taosDecodeVariantI32(buf, &pSW->sver);
|
||||
buf = taosDecodeVariantI32(buf, &pSW->tagVer);
|
||||
buf = taosDecodeVariantI32(buf, &pSW->colVer);
|
||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||
if (pSW->pSchema == NULL) {
|
||||
return NULL;
|
||||
|
@ -383,6 +395,8 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapp
|
|||
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
||||
if (tEncodeI32v(pEncoder, pSW->nCols) < 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++) {
|
||||
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
||||
}
|
||||
|
@ -393,6 +407,8 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSch
|
|||
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 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));
|
||||
if (pSW->pSchema == NULL) return -1;
|
||||
|
@ -406,6 +422,8 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWra
|
|||
static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 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));
|
||||
if (pSW->pSchema == NULL) return -1;
|
||||
|
@ -451,6 +469,7 @@ int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
|
|||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
int8_t alterType;
|
||||
int32_t verInBlock;
|
||||
int32_t numOfFields;
|
||||
SArray* pFields;
|
||||
int32_t ttl;
|
||||
|
@ -1476,6 +1495,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
int64_t consumerId;
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
char clientId[256];
|
||||
SArray* topicNames; // SArray<char**>
|
||||
} SCMSubscribeReq;
|
||||
|
||||
|
@ -1483,6 +1503,7 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
|||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
|
||||
tlen += taosEncodeString(buf, pReq->cgroup);
|
||||
tlen += taosEncodeString(buf, pReq->clientId);
|
||||
|
||||
int32_t topicNum = taosArrayGetSize(pReq->topicNames);
|
||||
tlen += taosEncodeFixedI32(buf, topicNum);
|
||||
|
@ -1496,6 +1517,7 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
|||
static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
||||
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
|
||||
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
||||
buf = taosDecodeStringTo(buf, pReq->clientId);
|
||||
|
||||
int32_t topicNum;
|
||||
buf = taosDecodeFixedI32(buf, &topicNum);
|
||||
|
|
|
@ -41,8 +41,8 @@ typedef enum {
|
|||
typedef int32_t (*PutToQueueFp)(void* pMgmt, SRpcMsg* pMsg);
|
||||
typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
|
||||
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
typedef void (*SendRspFp)(const SRpcMsg* pMsg);
|
||||
typedef void (*SendRedirectRspFp)(const SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||
typedef void (*SendRspFp)(SRpcMsg* pMsg);
|
||||
typedef void (*SendRedirectRspFp)(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||
typedef void (*RegisterBrokenLinkArgFp)(SRpcMsg* pMsg);
|
||||
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
|
||||
typedef void (*ReportStartup)(const char* name, const char* desc);
|
||||
|
@ -60,12 +60,12 @@ typedef struct {
|
|||
ReportStartup reportStartupFp;
|
||||
} SMsgCb;
|
||||
|
||||
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb);
|
||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pMsg);
|
||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
||||
void tmsgSetDefault(const SMsgCb* msgcb);
|
||||
int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg);
|
||||
int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype);
|
||||
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
||||
void tmsgSendRsp(const SRpcMsg* pMsg);
|
||||
void tmsgSendRedirectRsp(const SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||
void tmsgSendRsp(SRpcMsg* pMsg);
|
||||
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
|
||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type);
|
||||
void tmsgReportStartup(const char* name, const char* desc);
|
||||
|
|
|
@ -179,6 +179,8 @@ typedef struct {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
//TODO: use varchar(0) to represent NULL type
|
||||
#define IS_NULL_TYPE(_t) ((_t) == TSDB_DATA_TYPE_NULL)
|
||||
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
|
||||
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
||||
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
||||
|
|
|
@ -59,6 +59,11 @@ typedef struct SMetaData {
|
|||
SArray *pQnodeList; // qnode list, SArray<SQueryNodeAddr>
|
||||
} SMetaData;
|
||||
|
||||
typedef struct STbSVersion {
|
||||
char* tbFName;
|
||||
int32_t sver;
|
||||
} STbSVersion;
|
||||
|
||||
typedef struct SCatalogCfg {
|
||||
uint32_t maxTblCacheNum;
|
||||
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 catalogChkTbMetaVersion(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SArray* pTables);
|
||||
|
||||
/**
|
||||
* Force refresh a table's local cached meta data.
|
||||
* @param pCatalog (input, got with catalogGetHandle)
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct SReadHandle {
|
|||
#define STREAM_DATA_TYPE_SSDATA_BLOCK 0x2
|
||||
|
||||
typedef enum {
|
||||
OPTR_EXEC_MODEL_BATCH = 0x1,
|
||||
OPTR_EXEC_MODEL_BATCH = 0x1,
|
||||
OPTR_EXEC_MODEL_STREAM = 0x2,
|
||||
} EOPTR_EXEC_MODEL;
|
||||
|
||||
|
@ -81,7 +81,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
|||
* @param isAdd
|
||||
* @return
|
||||
*/
|
||||
int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, SArray* tableIdList, bool isAdd);
|
||||
int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bool isAdd);
|
||||
|
||||
/**
|
||||
* Create the exec task object according to task json
|
||||
|
@ -169,7 +169,7 @@ int32_t qUpdateQueriedTableIdList(qTaskInfo_t tinfo, int64_t uid, int32_t type);
|
|||
|
||||
void qProcessFetchRsp(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
|
||||
|
||||
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t *resNum, SExplainExecInfo **pRes);
|
||||
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t* resNum, SExplainExecInfo** pRes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -170,32 +170,18 @@ typedef struct SInputColumnInfoData {
|
|||
|
||||
// sql function runtime context
|
||||
typedef struct SqlFunctionCtx {
|
||||
SInputColumnInfoData input;
|
||||
SResultDataInfo resDataInfo;
|
||||
uint32_t order; // data block scanner order: asc|desc
|
||||
uint8_t scanFlag; // record current running step, default: 0
|
||||
////////////////////////////////////////////////////////////////
|
||||
int32_t startRow; // start row index
|
||||
int32_t size; // handled processed row number
|
||||
SColumnInfoData* pInput;
|
||||
SColumnDataAgg agg;
|
||||
int16_t inputType; // TODO remove it
|
||||
int16_t inputBytes; // TODO remove it
|
||||
bool hasNull; // null value exist in current block, TODO remove it
|
||||
bool requireNull; // require null in some function, TODO remove it
|
||||
int32_t columnIndex; // TODO remove it
|
||||
bool isAggSet;
|
||||
int64_t startTs; // timestamp range of current query when function is executed on a specific data block, TODO remove it
|
||||
bool stableQuery;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
int16_t functionId; // function id
|
||||
char * pOutput; // final result output buffer, point to sdata->data
|
||||
int32_t numOfParams;
|
||||
SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
||||
int64_t *ptsList; // corresponding timestamp array list
|
||||
SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/
|
||||
int32_t offset;
|
||||
SVariant tag;
|
||||
SInputColumnInfoData input;
|
||||
SResultDataInfo resDataInfo;
|
||||
uint32_t order; // data block scanner order: asc|desc
|
||||
uint8_t scanFlag; // record current running step, default: 0
|
||||
int16_t functionId; // function id
|
||||
char *pOutput; // final result output buffer, point to sdata->data
|
||||
int32_t numOfParams;
|
||||
SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
||||
int64_t *ptsList; // corresponding timestamp array list
|
||||
SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/
|
||||
int32_t offset;
|
||||
SVariant tag;
|
||||
struct SResultRowEntryInfo *resultInfo;
|
||||
SSubsidiaryResInfo subsidiaries;
|
||||
SPoint1 start;
|
||||
|
|
|
@ -142,6 +142,8 @@ void fmFuncMgtDestroy();
|
|||
|
||||
int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc);
|
||||
|
||||
bool fmIsBuiltinFunc(const char* pFunc);
|
||||
|
||||
bool fmIsAggFunc(int32_t funcId);
|
||||
bool fmIsScalarFunc(int32_t funcId);
|
||||
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef struct SAlterDatabaseStmt {
|
|||
|
||||
typedef struct STableOptions {
|
||||
ENodeType type;
|
||||
char comment[TSDB_STB_COMMENT_LEN];
|
||||
char comment[TSDB_TB_COMMENT_LEN];
|
||||
int32_t delay;
|
||||
float filesFactor;
|
||||
SNodeList* pRollupFuncs;
|
||||
|
@ -90,7 +90,7 @@ typedef struct SColumnDefNode {
|
|||
ENodeType type;
|
||||
char colName[TSDB_COL_NAME_LEN];
|
||||
SDataType dataType;
|
||||
char comments[TSDB_STB_COMMENT_LEN];
|
||||
char comments[TSDB_TB_COMMENT_LEN];
|
||||
bool sma;
|
||||
} SColumnDefNode;
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
||||
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL,
|
||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL,
|
||||
QUERY_NODE_PHYSICAL_PLAN_FILL,
|
||||
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW,
|
||||
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW,
|
||||
|
|
|
@ -248,6 +248,7 @@ typedef struct SSetOperator {
|
|||
SNode* pRight;
|
||||
SNodeList* pOrderByList; // SOrderByExprNode
|
||||
SNode* pLimit;
|
||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||
} SSetOperator;
|
||||
|
||||
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__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qDebug(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||
taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
#define qDebug(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||
taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qTrace(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_TRACE) { \
|
||||
taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
#define qTrace(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_TRACE) { \
|
||||
taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define qDebugL(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||
taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
#define qDebugL(...) \
|
||||
do { \
|
||||
if (qDebugFlag & DEBUG_DEBUG) { \
|
||||
taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define QRY_ERR_RET(c) \
|
||||
|
|
|
@ -72,7 +72,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg);
|
|||
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
|
||||
* @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.
|
||||
|
|
|
@ -38,6 +38,13 @@ typedef int32_t TdUcs4;
|
|||
#define wcsncpy WCSNCPY_FUNC_TAOS_FORBID
|
||||
#define wchar_t WCHAR_T_TYPE_TAOS_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
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
@ -72,6 +79,17 @@ int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size);
|
|||
|
||||
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
|
||||
}
|
||||
#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_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_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
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
|
|
@ -219,8 +219,8 @@ typedef enum ELogicConditionType {
|
|||
#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_APP_NAME_LEN TSDB_UNI_LEN
|
||||
#define TSDB_STB_COMMENT_LEN 1024
|
||||
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
||||
#define TSDB_TB_COMMENT_LEN 1025
|
||||
|
||||
/**
|
||||
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
||||
|
|
|
@ -456,52 +456,189 @@ static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) {
|
|||
return p;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutBinary(uint8_t* p, const uint8_t* pData, uint32_t nData) {
|
||||
int n = 0;
|
||||
uint32_t v = nData;
|
||||
// ===========================================
|
||||
#define tPutV(p, v) \
|
||||
do { \
|
||||
int32_t n = 0; \
|
||||
for (;;) { \
|
||||
if (v <= 0x7f) { \
|
||||
if (p) p[n] = v; \
|
||||
n++; \
|
||||
break; \
|
||||
} \
|
||||
if (p) p[n] = (v & 0x7f) | 0x80; \
|
||||
n++; \
|
||||
v >>= 7; \
|
||||
} \
|
||||
return n; \
|
||||
} while (0)
|
||||
|
||||
for (;;) {
|
||||
if (v <= 0x7f) {
|
||||
if (p) p[n] = v;
|
||||
n++;
|
||||
break;
|
||||
}
|
||||
#define tGetV(p, v) \
|
||||
do { \
|
||||
int32_t n = 0; \
|
||||
if (v) *v = 0; \
|
||||
for (;;) { \
|
||||
if (p[n] <= 0x7f) { \
|
||||
if (v) (*v) |= (p[n] << (7 * n)); \
|
||||
n++; \
|
||||
break; \
|
||||
} \
|
||||
if (v) (*v) |= ((p[n] & 0x7f) << (7 * n)); \
|
||||
n++; \
|
||||
} \
|
||||
return n; \
|
||||
} while (0)
|
||||
|
||||
if (p) p[n] = (v & 0x7f) | 0x80;
|
||||
n++;
|
||||
v >>= 7;
|
||||
}
|
||||
// PUT
|
||||
static FORCE_INLINE int32_t tPutU8(uint8_t* p, uint8_t v) {
|
||||
if (p) ((uint8_t*)p)[0] = v;
|
||||
return sizeof(uint8_t);
|
||||
}
|
||||
|
||||
if (p) {
|
||||
memcpy(p + n, pData, nData);
|
||||
}
|
||||
static FORCE_INLINE int32_t tPutI8(uint8_t* p, int8_t v) {
|
||||
if (p) ((int8_t*)p)[0] = v;
|
||||
return sizeof(int8_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutU16(uint8_t* p, uint16_t v) {
|
||||
if (p) ((uint16_t*)p)[0] = v;
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutI16(uint8_t* p, int16_t v) {
|
||||
if (p) ((int16_t*)p)[0] = v;
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutU32(uint8_t* p, uint32_t v) {
|
||||
if (p) ((uint32_t*)p)[0] = v;
|
||||
return sizeof(uint32_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutI32(uint8_t* p, int32_t v) {
|
||||
if (p) ((int32_t*)p)[0] = v;
|
||||
return sizeof(int32_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutU64(uint8_t* p, uint64_t v) {
|
||||
if (p) ((uint64_t*)p)[0] = v;
|
||||
return sizeof(uint64_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutI64(uint8_t* p, int64_t v) {
|
||||
if (p) ((int64_t*)p)[0] = v;
|
||||
return sizeof(int64_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tPutU16v(uint8_t* p, uint16_t v) { tPutV(p, v); }
|
||||
|
||||
static FORCE_INLINE int32_t tPutI16v(uint8_t* p, int16_t v) { return tPutU16v(p, ZIGZAGE(int16_t, v)); }
|
||||
|
||||
static FORCE_INLINE int32_t tPutU32v(uint8_t* p, uint32_t v) { tPutV(p, v); }
|
||||
|
||||
static FORCE_INLINE int32_t tPutI32v(uint8_t* p, int32_t v) { return tPutU32v(p, ZIGZAGE(int32_t, v)); }
|
||||
|
||||
static FORCE_INLINE int32_t tPutU64v(uint8_t* p, uint64_t v) { tPutV(p, v); }
|
||||
|
||||
static FORCE_INLINE int32_t tPutI64v(uint8_t* p, int64_t v) { return tPutU64v(p, ZIGZAGE(int64_t, v)); }
|
||||
|
||||
// GET
|
||||
static FORCE_INLINE int32_t tGetU8(uint8_t* p, uint8_t* v) {
|
||||
if (v) *v = ((uint8_t*)p)[0];
|
||||
return sizeof(uint8_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetI8(uint8_t* p, int8_t* v) {
|
||||
if (v) *v = ((int8_t*)p)[0];
|
||||
return sizeof(int8_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetU16(uint8_t* p, uint16_t* v) {
|
||||
if (v) *v = ((uint16_t*)p)[0];
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetI16(uint8_t* p, int16_t* v) {
|
||||
if (v) *v = ((int16_t*)p)[0];
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetU32(uint8_t* p, uint32_t* v) {
|
||||
if (v) *v = ((uint32_t*)p)[0];
|
||||
return sizeof(uint32_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetI32(uint8_t* p, int32_t* v) {
|
||||
if (v) *v = ((int32_t*)p)[0];
|
||||
return sizeof(int32_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetU64(uint8_t* p, uint64_t* v) {
|
||||
if (v) *v = ((uint64_t*)p)[0];
|
||||
return sizeof(uint64_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetI64(uint8_t* p, int64_t* v) {
|
||||
if (v) *v = ((int64_t*)p)[0];
|
||||
return sizeof(int64_t);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetU16v(uint8_t* p, uint16_t* v) { tGetV(p, v); }
|
||||
|
||||
static FORCE_INLINE int32_t tGetI16v(uint8_t* p, int16_t* v) {
|
||||
int32_t n;
|
||||
uint16_t tv;
|
||||
|
||||
n = tGetU16v(p, &tv);
|
||||
if (v) *v = ZIGZAGD(int16_t, tv);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetU32v(uint8_t* p, uint32_t* v) { tGetV(p, v); }
|
||||
|
||||
static FORCE_INLINE int32_t tGetI32v(uint8_t* p, int32_t* v) {
|
||||
int32_t n;
|
||||
uint32_t tv;
|
||||
|
||||
n = tGetU32v(p, &tv);
|
||||
if (v) *v = ZIGZAGD(int32_t, tv);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetU64v(uint8_t* p, uint64_t* v) { tGetV(p, v); }
|
||||
|
||||
static FORCE_INLINE int32_t tGetI64v(uint8_t* p, int64_t* v) {
|
||||
int32_t n;
|
||||
uint64_t tv;
|
||||
|
||||
n = tGetU64v(p, &tv);
|
||||
if (v) *v = ZIGZAGD(int64_t, tv);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// =====================
|
||||
static FORCE_INLINE int32_t tPutBinary(uint8_t* p, uint8_t* pData, uint32_t nData) {
|
||||
int n = 0;
|
||||
|
||||
n += tPutU32v(p ? p + n : p, nData);
|
||||
if (p) memcpy(p + n, pData, nData);
|
||||
n += nData;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tGetBinary(const uint8_t* p, const uint8_t** ppData, uint32_t* nData) {
|
||||
static FORCE_INLINE int32_t tGetBinary(uint8_t* p, uint8_t** ppData, uint32_t* nData) {
|
||||
int32_t n = 0;
|
||||
uint32_t tv = 0;
|
||||
uint32_t t;
|
||||
uint32_t nt;
|
||||
|
||||
for (;;) {
|
||||
if (p[n] <= 0x7f) {
|
||||
t = p[n];
|
||||
tv |= (t << (7 * n));
|
||||
n++;
|
||||
break;
|
||||
}
|
||||
|
||||
t = p[n] & 0x7f;
|
||||
tv |= (t << (7 * n));
|
||||
n++;
|
||||
}
|
||||
|
||||
if (nData) *nData = n;
|
||||
n += tGetU32v(p, &nt);
|
||||
if (nData) *nData = nt;
|
||||
if (ppData) *ppData = p + n;
|
||||
n += nt;
|
||||
|
||||
n += tv;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ typedef enum { SSkipListPutSuccess = 0, SSkipListPutEarlyStop = 1, SSkipListPutS
|
|||
|
||||
typedef struct SSkipList {
|
||||
uint32_t seed;
|
||||
uint16_t len;
|
||||
__compar_fn_t comparFn;
|
||||
__sl_key_fn_t keyFn;
|
||||
TdThreadRwlock *lock;
|
||||
uint16_t len;
|
||||
uint8_t maxLevel;
|
||||
uint8_t flags;
|
||||
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);
|
||||
}
|
||||
|
||||
static bool clientRpcRfp(int32_t code) {
|
||||
if (code == TSDB_CODE_RPC_REDIRECT) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO refactor
|
||||
void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||
SRpcInit rpcInit;
|
||||
|
@ -91,6 +100,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
rpcInit.label = "TSC";
|
||||
rpcInit.numOfThreads = numOfThread;
|
||||
rpcInit.cfp = processMsgFromServer;
|
||||
rpcInit.rfp = clientRpcRfp;
|
||||
rpcInit.sessions = 1024;
|
||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||
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};
|
||||
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 (pRequest->body.queryJob != 0) {
|
||||
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;
|
||||
terrno = res.code;
|
||||
|
@ -324,7 +322,60 @@ int32_t getQueryPlan(SRequestObj* pRequest, SQuery* pQuery, SArray** 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) {
|
||||
void* pRes = NULL;
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
switch (pQuery->execMode) {
|
||||
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));
|
||||
code = getPlan(pRequest, pQuery, &pRequest->body.pDag, pNodeList);
|
||||
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);
|
||||
break;
|
||||
|
@ -356,6 +410,12 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
|
|||
|
||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
||||
pRequest->code = terrno;
|
||||
freeRequestRes(pRequest, pRes);
|
||||
pRes = NULL;
|
||||
}
|
||||
|
||||
if (res) {
|
||||
*res = pRes;
|
||||
}
|
||||
|
||||
return pRequest;
|
||||
|
|
|
@ -580,7 +580,7 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
|
|||
const char *pVal = kvVal->value;
|
||||
int32_t len = kvVal->length;
|
||||
char *endptr = NULL;
|
||||
double result = strtod(pVal, &endptr);
|
||||
double result = taosStr2Double(pVal, &endptr);
|
||||
if(pVal == endptr){
|
||||
smlBuildInvalidDataMsg(msg, "invalid data", pVal);
|
||||
return false;
|
||||
|
@ -714,25 +714,31 @@ static bool smlIsNchar(const char *pVal, uint16_t len) {
|
|||
|
||||
static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
|
||||
char *endPtr = NULL;
|
||||
double ts = (double)strtoll(value, &endPtr, 10);
|
||||
int64_t tsInt64 = taosStr2Int64(value, &endPtr, 10);
|
||||
if(value + len != endPtr){
|
||||
return -1;
|
||||
}
|
||||
double ts = tsInt64;
|
||||
switch (type) {
|
||||
case TSDB_TIME_PRECISION_HOURS:
|
||||
ts *= (3600 * 1e9);
|
||||
tsInt64 *= (3600 * 1e9);
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MINUTES:
|
||||
ts *= (60 * 1e9);
|
||||
tsInt64 *= (60 * 1e9);
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_SECONDS:
|
||||
ts *= (1e9);
|
||||
tsInt64 *= (1e9);
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
ts *= (1e6);
|
||||
tsInt64 *= (1e6);
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
ts *= (1e3);
|
||||
tsInt64 *= (1e3);
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
break;
|
||||
|
@ -743,7 +749,7 @@ static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
return (int64_t)ts;
|
||||
return tsInt64;
|
||||
}
|
||||
|
||||
static int64_t smlGetTimeNow(int8_t precision) {
|
||||
|
|
|
@ -218,6 +218,13 @@ int32_t stmtParseSql(STscStmt* pStmt) {
|
|||
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
||||
if (pStmt->sql.pQuery->pRoot && 0 == pStmt->sql.type) {
|
||||
pStmt->sql.type = STMT_TYPE_INSERT;
|
||||
} else if (pStmt->sql.pQuery->pPrepareRoot) {
|
||||
pStmt->sql.type = STMT_TYPE_QUERY;
|
||||
}
|
||||
|
||||
/*
|
||||
switch (nodeType(pStmt->sql.pQuery->pRoot)) {
|
||||
case QUERY_NODE_VNODE_MODIF_STMT:
|
||||
if (0 == pStmt->sql.type) {
|
||||
|
@ -231,6 +238,7 @@ int32_t stmtParseSql(STscStmt* pStmt) {
|
|||
tscError("not supported stmt type %d", nodeType(pStmt->sql.pQuery->pRoot));
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_CLAUSE_ERROR);
|
||||
}
|
||||
*/
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -252,8 +260,8 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
|
||||
if (STMT_TYPE_QUERY != pStmt->sql.type || freeRequest) {
|
||||
int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) {
|
||||
if (STMT_TYPE_QUERY != pStmt->sql.type || deepClean) {
|
||||
taos_free_result(pStmt->exec.pRequest);
|
||||
pStmt->exec.pRequest = NULL;
|
||||
}
|
||||
|
@ -272,7 +280,11 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
|
|||
continue;
|
||||
}
|
||||
|
||||
qFreeStmtDataBlock(pBlocks);
|
||||
if (STMT_TYPE_MULTI_INSERT == pStmt->sql.type) {
|
||||
qFreeStmtDataBlock(pBlocks);
|
||||
} else {
|
||||
qDestroyStmtDataBlock(pBlocks);
|
||||
}
|
||||
taosHashRemove(pStmt->exec.pBlockHash, key, keyLen);
|
||||
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
|
@ -312,11 +324,11 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
|||
taosHashCleanup(pStmt->sql.pTableCache);
|
||||
pStmt->sql.pTableCache = NULL;
|
||||
|
||||
memset(&pStmt->sql, 0, sizeof(pStmt->sql));
|
||||
|
||||
STMT_ERR_RET(stmtCleanExecInfo(pStmt, false, true));
|
||||
STMT_ERR_RET(stmtCleanBindInfo(pStmt));
|
||||
|
||||
memset(&pStmt->sql, 0, sizeof(pStmt->sql));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -830,10 +830,12 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
}
|
||||
|
||||
// init hb timer
|
||||
tmq->hbTimer = taosTmrStart(tmqAssignDelayedHbTask, 1000, tmq, tmqMgmt.timer);
|
||||
if (tmq->hbTimer == NULL) {
|
||||
tmq->hbTimer = taosTmrStart(tmqAssignDelayedHbTask, 1000, tmq, tmqMgmt.timer);
|
||||
}
|
||||
|
||||
// init auto commit timer
|
||||
if (tmq->autoCommit) {
|
||||
if (tmq->autoCommit && tmq->commitTimer == NULL) {
|
||||
tmq->commitTimer = taosTmrStart(tmqAssignDelayedCommitTask, tmq->autoCommitInterval, tmq, tmqMgmt.timer);
|
||||
}
|
||||
|
||||
|
@ -1456,9 +1458,18 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t wait_time) {
|
|||
|
||||
tmq_resp_err_t tmq_consumer_close(tmq_t* tmq) {
|
||||
if (tmq->status == TMQ_CONSUMER_STATUS__READY) {
|
||||
tmq_list_t* lst = tmq_list_new();
|
||||
tmq_resp_err_t rsp = tmq_subscribe(tmq, lst);
|
||||
tmq_resp_err_t rsp = tmq_commit_sync(tmq, NULL);
|
||||
if (rsp == TMQ_RESP_ERR__SUCCESS) {
|
||||
// TODO: free resources
|
||||
return TMQ_RESP_ERR__SUCCESS;
|
||||
} else {
|
||||
return TMQ_RESP_ERR__FAIL;
|
||||
}
|
||||
|
||||
tmq_list_t* lst = tmq_list_new();
|
||||
rsp = tmq_subscribe(tmq, lst);
|
||||
tmq_list_destroy(lst);
|
||||
|
||||
if (rsp == TMQ_RESP_ERR__SUCCESS) {
|
||||
// TODO: free resources
|
||||
return TMQ_RESP_ERR__SUCCESS;
|
||||
|
|
|
@ -1188,3 +1188,36 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
|
|||
destroyRequest(request);
|
||||
smlDestroyInfo(info);
|
||||
}
|
||||
|
||||
TEST(testCase, sml_TD15662_Test) {
|
||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(taos, nullptr);
|
||||
|
||||
TAOS_RES *pRes = taos_query(taos, "create database if not exists db_15662 precision 'ns'");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(taos, "use db_15662");
|
||||
taos_free_result(pRes);
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||
ASSERT_NE(request, nullptr);
|
||||
|
||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||
ASSERT_NE(info, nullptr);
|
||||
|
||||
const char *sql[] = {
|
||||
"iyyyje,id=iyyyje_41943_1303,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
|
||||
};
|
||||
int ret = smlProcess(info, (char **)sql, sizeof(sql) / sizeof(sql[0]));
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// case 1
|
||||
TAOS_RES *res = taos_query(taos, "select * from t_a5615048edae55218a22a149edebdc82");
|
||||
ASSERT_NE(res, nullptr);
|
||||
|
||||
TAOS_ROW row = taos_fetch_row(res);
|
||||
int64_t ts = *(int64_t*)row[0];
|
||||
ASSERT_EQ(ts, 1626006833639000000);
|
||||
|
||||
taos_free_result(res);
|
||||
}
|
|
@ -263,7 +263,7 @@ static const SSysDbTableSchema topicSchema[] = {
|
|||
static const SSysDbTableSchema consumerSchema[] = {
|
||||
{.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 = "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 = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
|
|
|
@ -600,10 +600,11 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
|||
}
|
||||
|
||||
int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) {
|
||||
pBlock->info.rows = *(int32_t*)buf;
|
||||
pBlock->info.rows = *(int32_t*) buf;
|
||||
pBlock->info.groupId = *(uint64_t*) (buf + sizeof(int32_t));
|
||||
|
||||
int32_t numOfCols = pBlock->info.numOfCols;
|
||||
const char* pStart = buf + sizeof(uint32_t);
|
||||
const char* pStart = buf + sizeof(uint32_t) + sizeof(uint64_t);
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i);
|
||||
|
@ -669,7 +670,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) {
|
|||
return sizeof(int32_t) + sizeof(uint64_t) + pBlock->info.numOfCols * sizeof(int32_t);
|
||||
}
|
||||
|
||||
double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
||||
double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
||||
ASSERT(pBlock != NULL);
|
||||
double rowSize = 0;
|
||||
|
||||
|
@ -1224,7 +1225,27 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
|||
}
|
||||
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) {
|
||||
return (int32_t)((pageSize - blockDataGetSerialMetaSize(pBlock)) / blockDataGetSerialRowSize(pBlock));
|
||||
int32_t payloadSize = pageSize - blockDataGetSerialMetaSize(pBlock);
|
||||
|
||||
int32_t rowSize = pBlock->info.rowSize;
|
||||
|
||||
int32_t nRows = payloadSize / rowSize;
|
||||
|
||||
// the true value must be less than the value of nRows
|
||||
int32_t additional = 0;
|
||||
for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
||||
additional += nRows * sizeof(int32_t);
|
||||
} else {
|
||||
additional += BitmapLen(nRows);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t newRows = (payloadSize - additional) / rowSize;
|
||||
ASSERT(newRows <= nRows && newRows > 1);
|
||||
|
||||
return newRows;
|
||||
}
|
||||
|
||||
void colDataDestroy(SColumnInfoData* pColData) {
|
||||
|
|
|
@ -19,37 +19,209 @@
|
|||
#include "tdatablock.h"
|
||||
#include "tlog.h"
|
||||
|
||||
#define TD_KV_ROW 0x1U
|
||||
|
||||
struct SKVIdx {
|
||||
typedef struct SKVIdx {
|
||||
int32_t cid;
|
||||
int32_t offset;
|
||||
} SKVIdx;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct {
|
||||
int16_t nCols;
|
||||
SKVIdx idx[];
|
||||
} STSKVRow;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct STagIdx {
|
||||
int16_t cid;
|
||||
uint16_t offset;
|
||||
} STagIdx;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct STag {
|
||||
uint16_t len;
|
||||
uint16_t nTag;
|
||||
STagIdx idx[];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
int32_t tEncodeTSRow(SEncoder *pEncoder, const STSRow2 *pRow) {
|
||||
if (tEncodeI64(pEncoder, pRow->ts) < 0) return -1;
|
||||
if (tEncodeU32v(pEncoder, pRow->flags) < 0) return -1;
|
||||
if (pRow->flags & TD_KV_ROW) {
|
||||
if (tEncodeI32v(pEncoder, pRow->ncols) < 0) return -1;
|
||||
} else {
|
||||
if (tEncodeI32v(pEncoder, pRow->sver) < 0) return -1;
|
||||
#define TSROW_IS_KV_ROW(r) ((r)->flags & TSROW_KV_ROW)
|
||||
#define BIT1_SIZE(n) (((n)-1) / 8 + 1)
|
||||
#define BIT2_SIZE(n) (((n)-1) / 4 + 1)
|
||||
#define SET_BIT1(p, i, v) ((p)[(i) / 8] = (p)[(i) / 8] & (~(((uint8_t)1) << ((i) % 8))) | ((v) << ((i) % 8)))
|
||||
#define SET_BIT2(p, i, v) ((p)[(i) / 4] = (p)[(i) / 4] & (~(((uint8_t)3) << ((i) % 4))) | ((v) << ((i) % 4)))
|
||||
#define GET_BIT1(p, i) (((p)[(i) / 8] >> ((i) % 8)) & ((uint8_t)1))
|
||||
#define GET_BIT2(p, i) (((p)[(i) / 4] >> ((i) % 4)) & ((uint8_t)3))
|
||||
|
||||
static FORCE_INLINE int tSKVIdxCmprFn(const void *p1, const void *p2);
|
||||
|
||||
// STSRow2
|
||||
int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI64(p ? p + n : p, pRow->ts);
|
||||
n += tPutI8(p ? p + n : p, pRow->flags);
|
||||
n += tPutI32v(p ? p + n : p, pRow->sver);
|
||||
|
||||
ASSERT(pRow->flags & 0xf);
|
||||
|
||||
switch (pRow->flags & 0xf) {
|
||||
case TSROW_HAS_NONE:
|
||||
case TSROW_HAS_NULL:
|
||||
break;
|
||||
default:
|
||||
n += tPutBinary(p ? p + n : p, pRow->pData, pRow->nData);
|
||||
break;
|
||||
}
|
||||
if (tEncodeBinary(pEncoder, pRow->pData, pRow->nData) < 0) return -1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t tGetTSRow(uint8_t *p, STSRow2 *pRow) {
|
||||
int32_t n = 0;
|
||||
uint8_t flags;
|
||||
|
||||
n += tGetI64(p + n, pRow ? &pRow->ts : NULL);
|
||||
n += tGetI8(p + n, pRow ? &pRow->flags : &flags);
|
||||
n += tGetI32v(p + n, pRow ? &pRow->sver : NULL);
|
||||
|
||||
if (pRow) flags = pRow->flags;
|
||||
switch (flags & 0xf) {
|
||||
case TSROW_HAS_NONE:
|
||||
case TSROW_HAS_NULL:
|
||||
break;
|
||||
default:
|
||||
n += tGetBinary(p + n, pRow ? &pRow->pData : NULL, pRow ? &pRow->nData : NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t tTSRowDup(const STSRow2 *pRow, STSRow2 **ppRow) {
|
||||
(*ppRow) = taosMemoryMalloc(sizeof(*pRow) + pRow->nData);
|
||||
if (*ppRow == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
(*ppRow)->ts = pRow->ts;
|
||||
(*ppRow)->flags = pRow->flags;
|
||||
(*ppRow)->sver = pRow->sver;
|
||||
(*ppRow)->nData = pRow->nData;
|
||||
if (pRow->nData) {
|
||||
(*ppRow)->pData = (uint8_t *)(&(*ppRow)[1]);
|
||||
memcpy((*ppRow)->pData, pRow->pData, pRow->nData);
|
||||
} else {
|
||||
(*ppRow)->pData = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeTSRow(SDecoder *pDecoder, STSRow2 *pRow) {
|
||||
if (tDecodeI64(pDecoder, &pRow->ts) < 0) return -1;
|
||||
if (tDecodeU32v(pDecoder, &pRow->flags) < 0) return -1;
|
||||
if (pRow->flags & TD_KV_ROW) {
|
||||
if (tDecodeI32v(pDecoder, &pRow->ncols) < 0) return -1;
|
||||
} else {
|
||||
if (tDecodeI32v(pDecoder, &pRow->sver) < 0) return -1;
|
||||
void tTSRowFree(STSRow2 *pRow) {
|
||||
if (pRow) taosMemoryFree(pRow);
|
||||
}
|
||||
|
||||
int32_t tTSRowGet(const STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
|
||||
uint32_t n;
|
||||
uint8_t *p;
|
||||
uint8_t v;
|
||||
int32_t bidx = iCol - 1;
|
||||
STColumn *pTColumn = &pTSchema->columns[iCol];
|
||||
STSKVRow *pTSKVRow;
|
||||
SKVIdx *pKVIdx;
|
||||
|
||||
ASSERT(iCol != 0);
|
||||
ASSERT(pTColumn->colId != 0);
|
||||
|
||||
ASSERT(pRow->flags & 0xf != 0);
|
||||
switch (pRow->flags & 0xf) {
|
||||
case TSROW_HAS_NONE:
|
||||
*pColVal = ColValNONE;
|
||||
return 0;
|
||||
case TSROW_HAS_NULL:
|
||||
*pColVal = ColValNULL;
|
||||
return 0;
|
||||
}
|
||||
if (tDecodeBinary(pDecoder, &pRow->pData, &pRow->nData) < 0) return -1;
|
||||
|
||||
if (TSROW_IS_KV_ROW(pRow)) {
|
||||
ASSERT((pRow->flags & 0xf) != TSROW_HAS_VAL);
|
||||
|
||||
pTSKVRow = (STSKVRow *)pRow->pData;
|
||||
pKVIdx =
|
||||
bsearch(&((SKVIdx){.cid = pTColumn->colId}), pTSKVRow->idx, pTSKVRow->nCols, sizeof(SKVIdx), tSKVIdxCmprFn);
|
||||
if (pKVIdx == NULL) {
|
||||
*pColVal = ColValNONE;
|
||||
} else if (pKVIdx->offset < 0) {
|
||||
*pColVal = ColValNULL;
|
||||
} else {
|
||||
p = pRow->pData + sizeof(STSKVRow) + sizeof(SKVIdx) * pTSKVRow->nCols + pKVIdx->offset;
|
||||
pColVal->type = COL_VAL_DATA;
|
||||
tGetBinary(p, &pColVal->pData, &pColVal->nData);
|
||||
}
|
||||
} else {
|
||||
// get bitmap
|
||||
p = pRow->pData;
|
||||
switch (pRow->flags & 0xf) {
|
||||
case TSROW_HAS_NULL | TSROW_HAS_NONE:
|
||||
v = GET_BIT1(p, bidx);
|
||||
if (v == 0) {
|
||||
*pColVal = ColValNONE;
|
||||
} else {
|
||||
*pColVal = ColValNULL;
|
||||
}
|
||||
return 0;
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NONE:
|
||||
v = GET_BIT1(p, bidx);
|
||||
if (v == 1) {
|
||||
p = p + BIT1_SIZE(pTSchema->numOfCols - 1);
|
||||
break;
|
||||
} else {
|
||||
*pColVal = ColValNONE;
|
||||
return 0;
|
||||
}
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NULL:
|
||||
v = GET_BIT1(p, bidx);
|
||||
if (v == 1) {
|
||||
p = p + BIT1_SIZE(pTSchema->numOfCols - 1);
|
||||
break;
|
||||
} else {
|
||||
*pColVal = ColValNULL;
|
||||
return 0;
|
||||
}
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NULL | TSROW_HAS_NONE:
|
||||
v = GET_BIT2(p, bidx);
|
||||
if (v == 0) {
|
||||
*pColVal = ColValNONE;
|
||||
return 0;
|
||||
} else if (v == 1) {
|
||||
*pColVal = ColValNULL;
|
||||
return 0;
|
||||
} else if (v == 2) {
|
||||
p = p + BIT2_SIZE(pTSchema->numOfCols - 1);
|
||||
break;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// get real value
|
||||
p = p + pTColumn->offset;
|
||||
pColVal->type = COL_VAL_DATA;
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
tGetBinary(p + pTSchema->flen + *(int32_t *)p, &pColVal->pData, &pColVal->nData);
|
||||
} else {
|
||||
pColVal->pData = p;
|
||||
pColVal->nData = pTColumn->bytes;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// STSchema
|
||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t ncols, STSchema **ppTSchema) {
|
||||
*ppTSchema = (STSchema *)taosMemoryMalloc(sizeof(STSchema) + sizeof(STColumn) * ncols);
|
||||
if (*ppTSchema == NULL) {
|
||||
|
@ -85,170 +257,360 @@ int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t ncols, STSchema *
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tTSchemaDestroy(STSchema *pTSchema) { taosMemoryFree(pTSchema); }
|
||||
|
||||
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, SSchema *pSchema, int32_t nCols) {
|
||||
int32_t kvBufLen;
|
||||
int32_t tpBufLen;
|
||||
uint8_t *p;
|
||||
void tTSchemaDestroy(STSchema *pTSchema) {
|
||||
if (pTSchema) taosMemoryFree(pTSchema);
|
||||
}
|
||||
|
||||
// STSRowBuilder
|
||||
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, int32_t nCols, SSchema *pSchema) {
|
||||
if (tTSchemaCreate(sver, pSchema, nCols, &pBuilder->pTSchema) < 0) return -1;
|
||||
|
||||
kvBufLen = sizeof(SKVIdx) * nCols + pBuilder->pTSchema->flen + pBuilder->pTSchema->vlen;
|
||||
tpBufLen = pBuilder->pTSchema->flen + pBuilder->pTSchema->vlen;
|
||||
|
||||
if (pBuilder->szKVBuf < kvBufLen) {
|
||||
p = taosMemoryRealloc(pBuilder->pKVBuf, kvBufLen);
|
||||
if (p == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pBuilder->pKVBuf = p;
|
||||
pBuilder->szKVBuf = kvBufLen;
|
||||
pBuilder->szBitMap1 = BIT1_SIZE(nCols - 1);
|
||||
pBuilder->szBitMap2 = BIT2_SIZE(nCols - 1);
|
||||
pBuilder->szKVBuf =
|
||||
sizeof(STSKVRow) + sizeof(SKVIdx) * (nCols - 1) + pBuilder->pTSchema->flen + pBuilder->pTSchema->vlen;
|
||||
pBuilder->szTPBuf = pBuilder->szBitMap2 + pBuilder->pTSchema->flen + pBuilder->pTSchema->vlen;
|
||||
pBuilder->pKVBuf = taosMemoryMalloc(pBuilder->szKVBuf);
|
||||
if (pBuilder->pKVBuf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tTSchemaDestroy(pBuilder->pTSchema);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pBuilder->szTPBuf < tpBufLen) {
|
||||
p = taosMemoryRealloc(pBuilder->pTPBuf, tpBufLen);
|
||||
if (p == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
pBuilder->pTPBuf = p;
|
||||
pBuilder->szTPBuf = tpBufLen;
|
||||
pBuilder->pTPBuf = taosMemoryMalloc(pBuilder->szTPBuf);
|
||||
if (pBuilder->pTPBuf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pBuilder->pKVBuf);
|
||||
tTSchemaDestroy(pBuilder->pTSchema);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tTSRowBuilderReset(pBuilder);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tTSRowBuilderClear(STSRowBuilder *pBuilder) {
|
||||
taosMemoryFree(pBuilder->pKVBuf);
|
||||
taosMemoryFree(pBuilder->pTPBuf);
|
||||
if (pBuilder->pTPBuf) {
|
||||
taosMemoryFree(pBuilder->pTPBuf);
|
||||
pBuilder->pTPBuf = NULL;
|
||||
}
|
||||
if (pBuilder->pKVBuf) {
|
||||
taosMemoryFree(pBuilder->pKVBuf);
|
||||
pBuilder->pKVBuf = NULL;
|
||||
}
|
||||
tTSchemaDestroy(pBuilder->pTSchema);
|
||||
pBuilder->pTSchema = NULL;
|
||||
}
|
||||
|
||||
void tTSRowBuilderReset(STSRowBuilder *pBuilder) {
|
||||
for (int32_t iCol = pBuilder->pTSchema->numOfCols - 1; iCol >= 0; iCol--) {
|
||||
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
|
||||
pBuilder->pTColumn->flags &= (~COL_VAL_SET);
|
||||
STColumn *pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
COL_CLR_SET(pTColumn->flags);
|
||||
}
|
||||
|
||||
pBuilder->nCols = 0;
|
||||
pBuilder->kvVLen = 0;
|
||||
pBuilder->tpVLen = 0;
|
||||
pBuilder->iCol = 0;
|
||||
((STSKVRow *)pBuilder->pKVBuf)->nCols = 0;
|
||||
pBuilder->vlenKV = 0;
|
||||
pBuilder->vlenTP = 0;
|
||||
pBuilder->row.flags = 0;
|
||||
}
|
||||
|
||||
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, const uint8_t *pData, uint32_t nData) {
|
||||
int32_t iCol;
|
||||
uint8_t *p;
|
||||
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, uint8_t *pData, uint32_t nData) {
|
||||
STColumn *pTColumn = &pBuilder->pTSchema->columns[pBuilder->iCol];
|
||||
uint8_t *p;
|
||||
int32_t iCol;
|
||||
STSKVRow *pTSKVRow = (STSKVRow *)pBuilder->pKVBuf;
|
||||
|
||||
// search column
|
||||
if (pBuilder->pTColumn->colId < cid) {
|
||||
iCol = (pBuilder->pTColumn - pBuilder->pTSchema->columns) / sizeof(STColumn) + 1;
|
||||
for (; iCol < pBuilder->pTSchema->numOfCols; iCol++) {
|
||||
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
if (pBuilder->pTColumn->colId == cid) break;
|
||||
// use interp search
|
||||
if (pTColumn->colId < cid) { // right search
|
||||
for (iCol = pBuilder->iCol + 1; iCol < pBuilder->pTSchema->numOfCols; iCol++) {
|
||||
pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
if (pTColumn->colId >= cid) break;
|
||||
}
|
||||
} else if (pBuilder->pTColumn->colId > cid) {
|
||||
iCol = (pBuilder->pTColumn - pBuilder->pTSchema->columns) / sizeof(STColumn) - 1;
|
||||
for (; iCol >= 0; iCol--) {
|
||||
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
if (pBuilder->pTColumn->colId == cid) break;
|
||||
} else if (pTColumn->colId > cid) { // left search
|
||||
for (iCol = pBuilder->iCol - 1; iCol >= 0; iCol--) {
|
||||
pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
if (pTColumn->colId <= cid) break;
|
||||
}
|
||||
}
|
||||
|
||||
// check
|
||||
if (pBuilder->pTColumn->colId != cid || pBuilder->pTColumn->flags & COL_VAL_SET) {
|
||||
if (pTColumn->colId != cid || COL_IS_SET(pTColumn->flags)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pBuilder->iCol = iCol;
|
||||
|
||||
// set value
|
||||
if (cid == 0) {
|
||||
ASSERT(pData && nData == sizeof(TSKEY));
|
||||
ASSERT(pData && nData == sizeof(TSKEY) && iCol == 0);
|
||||
pBuilder->row.ts = *(TSKEY *)pData;
|
||||
pTColumn->flags |= COL_SET_VAL;
|
||||
} else {
|
||||
if (pData) {
|
||||
// ASSERT(!IS_NULL(pData));
|
||||
// set VAL
|
||||
|
||||
// set tuple data
|
||||
p = pBuilder->pTPBuf + pBuilder->pTColumn->offset;
|
||||
if (IS_VAR_DATA_TYPE(pBuilder->pTColumn->type)) {
|
||||
*(int32_t *)p = pBuilder->tpVLen;
|
||||
pBuilder->row.flags |= TSROW_HAS_VAL;
|
||||
pTColumn->flags |= COL_SET_VAL;
|
||||
|
||||
// encode the variant-length data
|
||||
p = pBuilder->pTPBuf + pBuilder->pTSchema->flen + pBuilder->tpVLen;
|
||||
pBuilder->tpVLen += tPutBinary(p, pData, nData);
|
||||
} else {
|
||||
memcpy(p, pData, nData);
|
||||
/* KV */
|
||||
if (1) { // avoid KV at some threshold (todo)
|
||||
pTSKVRow->idx[pTSKVRow->nCols].cid = cid;
|
||||
pTSKVRow->idx[pTSKVRow->nCols].offset = pBuilder->vlenKV;
|
||||
|
||||
p = pBuilder->pKVBuf + sizeof(STSKVRow) + sizeof(SKVIdx) * (pBuilder->pTSchema->numOfCols - 1) +
|
||||
pBuilder->vlenKV;
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
ASSERT(nData <= pTColumn->bytes);
|
||||
pBuilder->vlenKV += tPutBinary(p, pData, nData);
|
||||
} else {
|
||||
ASSERT(nData == pTColumn->bytes);
|
||||
memcpy(p, pData, nData);
|
||||
pBuilder->vlenKV += nData;
|
||||
}
|
||||
}
|
||||
|
||||
// set kv data
|
||||
p = pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->nCols;
|
||||
((SKVIdx *)p)->cid = cid;
|
||||
((SKVIdx *)p)->offset = pBuilder->kvVLen;
|
||||
/* TUPLE */
|
||||
p = pBuilder->pTPBuf + pBuilder->szBitMap2 + pTColumn->offset;
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
ASSERT(nData <= pTColumn->bytes);
|
||||
*(int32_t *)p = pBuilder->vlenTP;
|
||||
|
||||
p = pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->pTSchema->numOfCols + pBuilder->kvVLen;
|
||||
if (IS_VAR_DATA_TYPE(pBuilder->pTColumn->type)) {
|
||||
pBuilder->kvVLen += tPutBinary(p, pData, nData);
|
||||
p = pBuilder->pTPBuf + pBuilder->szBitMap2 + pBuilder->pTSchema->flen + pBuilder->vlenTP;
|
||||
pBuilder->vlenTP += tPutBinary(p, pData, nData);
|
||||
} else {
|
||||
ASSERT(nData == pTColumn->bytes);
|
||||
memcpy(p, pData, nData);
|
||||
pBuilder->kvVLen += nData;
|
||||
}
|
||||
} else {
|
||||
// set NULL val
|
||||
// set NULL
|
||||
|
||||
pBuilder->row.flags |= TSROW_HAS_NULL;
|
||||
pTColumn->flags |= COL_SET_NULL;
|
||||
|
||||
pTSKVRow->idx[pTSKVRow->nCols].cid = cid;
|
||||
pTSKVRow->idx[pTSKVRow->nCols].offset = -1;
|
||||
}
|
||||
|
||||
pTSKVRow->nCols++;
|
||||
}
|
||||
|
||||
pBuilder->pTColumn->flags |= COL_VAL_SET;
|
||||
pBuilder->nCols++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int tSKVIdxCmprFn(const void *p1, const void *p2) {
|
||||
SKVIdx *pKVIdx1 = (SKVIdx *)p1;
|
||||
SKVIdx *pKVIdx2 = (SKVIdx *)p2;
|
||||
if (pKVIdx1->cid > pKVIdx2->cid) {
|
||||
return 1;
|
||||
} else if (pKVIdx1->cid < pKVIdx2->cid) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static void setBitMap(uint8_t *p, STSchema *pTSchema, uint8_t flags) {
|
||||
int32_t bidx;
|
||||
STColumn *pTColumn;
|
||||
|
||||
for (int32_t iCol = 1; iCol < pTSchema->numOfCols; iCol++) {
|
||||
pTColumn = &pTSchema->columns[iCol];
|
||||
bidx = iCol - 1;
|
||||
|
||||
switch (flags) {
|
||||
case TSROW_HAS_NULL | TSROW_HAS_NONE:
|
||||
if (pTColumn->flags & COL_SET_NULL) {
|
||||
SET_BIT1(p, bidx, (uint8_t)1);
|
||||
} else {
|
||||
SET_BIT1(p, bidx, (uint8_t)0);
|
||||
}
|
||||
break;
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NULL | TSROW_HAS_NONE:
|
||||
if (pTColumn->flags & COL_SET_NULL) {
|
||||
SET_BIT2(p, bidx, (uint8_t)1);
|
||||
} else if (pTColumn->flags & COL_SET_VAL) {
|
||||
SET_BIT2(p, bidx, (uint8_t)2);
|
||||
} else {
|
||||
SET_BIT2(p, bidx, (uint8_t)0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (pTColumn->flags & COL_SET_VAL) {
|
||||
SET_BIT1(p, bidx, (uint8_t)1);
|
||||
} else {
|
||||
SET_BIT1(p, bidx, (uint8_t)0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow) {
|
||||
if ((pBuilder->pTSchema->columns[0].flags & COL_VAL_SET) == 0) {
|
||||
int32_t nDataTP, nDataKV;
|
||||
uint32_t flags;
|
||||
STSKVRow *pTSKVRow = (STSKVRow *)pBuilder->pKVBuf;
|
||||
int32_t nCols = pBuilder->pTSchema->numOfCols;
|
||||
|
||||
// error not set ts
|
||||
if (!COL_IS_SET(pBuilder->pTSchema->columns->flags)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pBuilder->nCols * sizeof(SKVIdx) + pBuilder->kvVLen < pBuilder->pTSchema->flen + pBuilder->tpVLen) {
|
||||
// encode as TD_KV_ROW
|
||||
pBuilder->row.flags |= TD_KV_ROW;
|
||||
pBuilder->row.ncols = pBuilder->nCols;
|
||||
pBuilder->row.nData = pBuilder->nCols * sizeof(SKVIdx) + pBuilder->kvVLen;
|
||||
ASSERT(pTSKVRow->nCols < nCols);
|
||||
if (pTSKVRow->nCols < nCols - 1) {
|
||||
pBuilder->row.flags |= TSROW_HAS_NONE;
|
||||
}
|
||||
|
||||
ASSERT(pBuilder->row.flags & 0xf != 0);
|
||||
*(ppRow) = &pBuilder->row;
|
||||
switch (pBuilder->row.flags & 0xf) {
|
||||
case TSROW_HAS_NONE:
|
||||
case TSROW_HAS_NULL:
|
||||
pBuilder->row.nData = 0;
|
||||
pBuilder->row.pData = NULL;
|
||||
return 0;
|
||||
case TSROW_HAS_NULL | TSROW_HAS_NONE:
|
||||
nDataTP = pBuilder->szBitMap1;
|
||||
break;
|
||||
case TSROW_HAS_VAL:
|
||||
nDataTP = pBuilder->pTSchema->flen + pBuilder->vlenTP;
|
||||
break;
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NONE:
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NULL:
|
||||
nDataTP = pBuilder->szBitMap1 + pBuilder->pTSchema->flen + pBuilder->vlenTP;
|
||||
break;
|
||||
case TSROW_HAS_VAL | TSROW_HAS_NULL | TSROW_HAS_NONE:
|
||||
nDataTP = pBuilder->szBitMap2 + pBuilder->pTSchema->flen + pBuilder->vlenTP;
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
nDataKV = sizeof(STSKVRow) + sizeof(SKVIdx) * pTSKVRow->nCols + pBuilder->vlenKV;
|
||||
pBuilder->row.sver = pBuilder->pTSchema->version;
|
||||
if (nDataKV < nDataTP) {
|
||||
// generate KV row
|
||||
|
||||
ASSERT(pBuilder->row.flags & 0xf != TSROW_HAS_VAL);
|
||||
|
||||
pBuilder->row.flags |= TSROW_KV_ROW;
|
||||
pBuilder->row.nData = nDataKV;
|
||||
pBuilder->row.pData = pBuilder->pKVBuf;
|
||||
|
||||
if (pBuilder->nCols < pBuilder->pTSchema->numOfCols) {
|
||||
memmove(pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->nCols,
|
||||
pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->pTSchema->numOfCols, pBuilder->kvVLen);
|
||||
qsort(pTSKVRow->idx, pTSKVRow->nCols, sizeof(SKVIdx), tSKVIdxCmprFn);
|
||||
if (pTSKVRow->nCols < nCols - 1) {
|
||||
memmove(&pTSKVRow->idx[pTSKVRow->nCols], &pTSKVRow->idx[nCols - 1], pBuilder->vlenKV);
|
||||
}
|
||||
} else {
|
||||
// encode as TD_TUPLE_ROW
|
||||
pBuilder->row.flags &= (~TD_KV_ROW);
|
||||
pBuilder->row.sver = pBuilder->pTSchema->version;
|
||||
pBuilder->row.nData = pBuilder->pTSchema->flen + pBuilder->tpVLen;
|
||||
pBuilder->row.pData = pBuilder->pTPBuf;
|
||||
// generate TUPLE row
|
||||
|
||||
if (pBuilder->nCols < pBuilder->pTSchema->numOfCols) {
|
||||
// set non-set cols as None
|
||||
for (int32_t iCol = 1; iCol < pBuilder->pTSchema->numOfCols; iCol++) {
|
||||
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||
if (pBuilder->pTColumn->flags & COL_VAL_SET) continue;
|
||||
pBuilder->row.nData = nDataTP;
|
||||
|
||||
{
|
||||
// set None (todo)
|
||||
}
|
||||
uint8_t *p;
|
||||
uint8_t flags = pBuilder->row.flags & 0xf;
|
||||
|
||||
pBuilder->pTColumn->flags |= COL_VAL_SET;
|
||||
if (flags == TSROW_HAS_VAL) {
|
||||
pBuilder->row.pData = pBuilder->pTPBuf + pBuilder->szBitMap2;
|
||||
} else {
|
||||
if (flags == TSROW_HAS_VAL | TSROW_HAS_NULL | TSROW_HAS_NONE) {
|
||||
pBuilder->row.pData = pBuilder->pTPBuf;
|
||||
} else {
|
||||
pBuilder->row.pData = pBuilder->pTPBuf + pBuilder->szBitMap2 - pBuilder->szBitMap1;
|
||||
}
|
||||
|
||||
setBitMap(pBuilder->row.pData, pBuilder->pTSchema, flags);
|
||||
}
|
||||
}
|
||||
|
||||
*ppRow = &pBuilder->row;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 1 // ====================
|
||||
static FORCE_INLINE int tTagIdxCmprFn(const void *p1, const void *p2) {
|
||||
STagIdx *pTagIdx1 = (STagIdx *)p1;
|
||||
STagIdx *pTagIdx2 = (STagIdx *)p2;
|
||||
if (pTagIdx1->cid < pTagIdx1->cid) {
|
||||
return -1;
|
||||
} else if (pTagIdx1->cid > pTagIdx1->cid) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int32_t tTagNew(STagVal *pTagVals, int16_t nTag, STag **ppTag) {
|
||||
STagVal *pTagVal;
|
||||
uint8_t *p;
|
||||
int32_t n;
|
||||
uint16_t tsize = sizeof(STag) + sizeof(STagIdx) * nTag;
|
||||
|
||||
for (int16_t iTag = 0; iTag < nTag; iTag++) {
|
||||
pTagVal = &pTagVals[iTag];
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||
tsize += tPutBinary(NULL, pTagVal->pData, pTagVal->nData);
|
||||
} else {
|
||||
ASSERT(pTagVal->nData == TYPE_BYTES[pTagVal->type]);
|
||||
tsize += pTagVal->nData;
|
||||
}
|
||||
}
|
||||
|
||||
(*ppTag) = (STag *)taosMemoryMalloc(tsize);
|
||||
if (*ppTag == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
p = (uint8_t *)&((*ppTag)->idx[nTag]);
|
||||
n = 0;
|
||||
|
||||
(*ppTag)->len = tsize;
|
||||
(*ppTag)->nTag = nTag;
|
||||
for (int16_t iTag = 0; iTag < nTag; iTag++) {
|
||||
pTagVal = &pTagVals[iTag];
|
||||
|
||||
(*ppTag)->idx[iTag].cid = pTagVal->cid;
|
||||
(*ppTag)->idx[iTag].offset = n;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||
n += tPutBinary(p + n, pTagVal->pData, pTagVal->nData);
|
||||
} else {
|
||||
memcpy(p + n, pTagVal->pData, pTagVal->nData);
|
||||
n += pTagVal->nData;
|
||||
}
|
||||
}
|
||||
|
||||
qsort((*ppTag)->idx, (*ppTag)->nTag, sizeof(STagIdx), tTagIdxCmprFn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tTagFree(STag *pTag) {
|
||||
if (pTag) taosMemoryFree(pTag);
|
||||
}
|
||||
|
||||
void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, int32_t *nData) {
|
||||
STagIdx *pTagIdx = bsearch(&((STagIdx){.cid = cid}), pTag->idx, pTag->nTag, sizeof(STagIdx), tTagIdxCmprFn);
|
||||
if (pTagIdx == NULL) {
|
||||
*ppData = NULL;
|
||||
*nData = 0;
|
||||
} else {
|
||||
uint8_t *p = (uint8_t *)&pTag->idx[pTag->nTag] + pTagIdx->offset;
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
tGetBinary(p, ppData, nData);
|
||||
} else {
|
||||
*ppData = p;
|
||||
*nData = TYPE_BYTES[type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tEncodeTag(SEncoder *pEncoder, STag *pTag) {
|
||||
// return tEncodeBinary(pEncoder, (uint8_t *)pTag, pTag->len);
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag) {
|
||||
// uint32_t n;
|
||||
// return tDecodeBinary(pDecoder, (const uint8_t **)ppTag, &n);
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 1 // ===================================================================================================================
|
||||
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
||||
int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||
int spaceNeeded = pCol->bytes * maxPoints;
|
||||
|
@ -260,8 +622,8 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
|||
spaceNeeded += (int)nBitmapBytes;
|
||||
// TODO: Currently, the compression of bitmap parts is affiliated to the column data parts, thus allocate 1 more
|
||||
// TYPE_BYTES as to comprise complete TYPE_BYTES. Otherwise, invalid read/write would be triggered.
|
||||
// spaceNeeded += TYPE_BYTES[pCol->type]; // the bitmap part is append as a single part since 2022.04.03, thus remove
|
||||
// the additional space
|
||||
// spaceNeeded += TYPE_BYTES[pCol->type]; // the bitmap part is append as a single part since 2022.04.03, thus
|
||||
// remove the additional space
|
||||
#endif
|
||||
|
||||
if (pCol->spaceSize < spaceNeeded) {
|
||||
|
|
|
@ -600,6 +600,7 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq)
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->name) < 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;
|
||||
for (int32_t i = 0; i < pReq->numOfFields; ++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 (tDecodeCStrTo(&decoder, pReq->name) < 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;
|
||||
pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SField));
|
||||
if (pReq->pFields == NULL) {
|
||||
|
@ -4087,12 +4089,11 @@ static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBl
|
|||
|
||||
if (tEncodeI32(pEncoder, pBlock->code) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pBlock->hashMeta) < 0) return -1;
|
||||
if (pBlock->hashMeta) {
|
||||
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
||||
}
|
||||
if (tEncodeI64(pEncoder, pBlock->uid) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pBlock->tblFName) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pBlock->numOfRows) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pBlock->affectedRows) < 0) return -1;
|
||||
if (tEncodeI64v(pEncoder, pBlock->sver) < 0) return -1;
|
||||
|
||||
tEndEncode(pEncoder);
|
||||
return 0;
|
||||
|
@ -4103,14 +4104,13 @@ static int32_t tDecodeSSubmitBlkRsp(SDecoder *pDecoder, SSubmitBlkRsp *pBlock) {
|
|||
|
||||
if (tDecodeI32(pDecoder, &pBlock->code) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pBlock->hashMeta) < 0) return -1;
|
||||
if (pBlock->hashMeta) {
|
||||
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
||||
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
||||
if (NULL == pBlock->tblFName) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pBlock->tblFName) < 0) return -1;
|
||||
}
|
||||
if (tDecodeI64(pDecoder, &pBlock->uid) < 0) return -1;
|
||||
pBlock->tblFName = taosMemoryCalloc(TSDB_TABLE_FNAME_LEN, 1);
|
||||
if (NULL == pBlock->tblFName) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pBlock->tblFName) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pBlock->numOfRows) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pBlock->affectedRows) < 0) return -1;
|
||||
if (tDecodeI64v(pDecoder, &pBlock->sver) < 0) return -1;
|
||||
|
||||
tEndDecode(pDecoder);
|
||||
return 0;
|
||||
|
|
|
@ -17,46 +17,46 @@
|
|||
#include "tmsgcb.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* pReq) {
|
||||
PutToQueueFp fp = pMsgCb->queueFps[qtype];
|
||||
return (*fp)(pMsgCb->mgmt, pReq);
|
||||
int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg) {
|
||||
PutToQueueFp fp = msgcb->queueFps[qtype];
|
||||
return (*fp)(msgcb->mgmt, pMsg);
|
||||
}
|
||||
|
||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) {
|
||||
GetQueueSizeFp fp = pMsgCb->qsizeFp;
|
||||
return (*fp)(pMsgCb->mgmt, vgId, qtype);
|
||||
int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype) {
|
||||
GetQueueSizeFp fp = msgcb->qsizeFp;
|
||||
return (*fp)(msgcb->mgmt, vgId, qtype);
|
||||
}
|
||||
|
||||
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pReq) {
|
||||
SendReqFp fp = tsDefaultMsgCb.sendReqFp;
|
||||
return (*fp)(epSet, pReq);
|
||||
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg) {
|
||||
SendReqFp fp = defaultMsgCb.sendReqFp;
|
||||
return (*fp)(epSet, pMsg);
|
||||
}
|
||||
|
||||
void tmsgSendRsp(const SRpcMsg* pMsg) {
|
||||
SendRspFp fp = tsDefaultMsgCb.sendRspFp;
|
||||
void tmsgSendRsp(SRpcMsg* pMsg) {
|
||||
SendRspFp fp = defaultMsgCb.sendRspFp;
|
||||
return (*fp)(pMsg);
|
||||
}
|
||||
|
||||
void tmsgSendRedirectRsp(const SRpcMsg* pMsg, const SEpSet* pNewEpSet) {
|
||||
SendRedirectRspFp fp = tsDefaultMsgCb.sendRedirectRspFp;
|
||||
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet) {
|
||||
SendRedirectRspFp fp = defaultMsgCb.sendRedirectRspFp;
|
||||
(*fp)(pMsg, pNewEpSet);
|
||||
}
|
||||
|
||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) {
|
||||
RegisterBrokenLinkArgFp fp = tsDefaultMsgCb.registerBrokenLinkArgFp;
|
||||
RegisterBrokenLinkArgFp fp = defaultMsgCb.registerBrokenLinkArgFp;
|
||||
(*fp)(pMsg);
|
||||
}
|
||||
|
||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) {
|
||||
ReleaseHandleFp fp = tsDefaultMsgCb.releaseHandleFp;
|
||||
ReleaseHandleFp fp = defaultMsgCb.releaseHandleFp;
|
||||
(*fp)(pHandle, type);
|
||||
}
|
||||
|
||||
void tmsgReportStartup(const char* name, const char* desc) {
|
||||
ReportStartup fp = tsDefaultMsgCb.reportStartupFp;
|
||||
ReportStartup fp = defaultMsgCb.reportStartupFp;
|
||||
(*fp)(name, desc);
|
||||
}
|
|
@ -250,7 +250,7 @@ int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dst->acctId = strtoll(str, NULL, 10);
|
||||
dst->acctId = taosStr2Int32(str, NULL, 10);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (isAllRowsNone(pCol)) {
|
||||
pVal->valType = TD_VTYPE_NULL;
|
||||
pVal->valType = TD_VTYPE_NONE;
|
||||
#ifdef TD_SUPPORT_READ2
|
||||
pVal->val = (void *)getNullValue(pCol->type);
|
||||
#else
|
||||
|
|
|
@ -374,39 +374,135 @@ char getPrecisionUnit(int32_t precision) {
|
|||
}
|
||||
|
||||
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
|
||||
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI ||
|
||||
fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
fromPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
assert(toPrecision == TSDB_TIME_PRECISION_MILLI ||
|
||||
toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
toPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
static double factors[3][3] = {{1., 1000., 1000000.}, {1.0 / 1000, 1., 1000.}, {1.0 / 1000000, 1.0 / 1000, 1.}};
|
||||
return (int64_t)((double)time * factors[fromPrecision][toPrecision]);
|
||||
double tempResult = (double)time;
|
||||
switch(fromPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI: {
|
||||
switch (toPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
return time;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
tempResult *= 1000;
|
||||
time *= 1000;
|
||||
goto end_;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
tempResult *= 1000000;
|
||||
time *= 1000000;
|
||||
goto end_;
|
||||
}
|
||||
} // end from milli
|
||||
case TSDB_TIME_PRECISION_MICRO: {
|
||||
switch (toPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
return time / 1000;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
return time;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
tempResult *= 1000;
|
||||
time *= 1000;
|
||||
goto end_;
|
||||
}
|
||||
} //end from micro
|
||||
case TSDB_TIME_PRECISION_NANO: {
|
||||
switch (toPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
return time / 1000000;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
return time / 1000;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
return time;
|
||||
}
|
||||
} //end from nano
|
||||
default: {
|
||||
assert(0);
|
||||
return time; // only to pass windows compilation
|
||||
}
|
||||
} //end switch fromPrecision
|
||||
end_:
|
||||
if (tempResult >= (double)INT64_MAX) return INT64_MAX;
|
||||
if (tempResult <= (double)INT64_MIN) return INT64_MIN; // INT64_MIN means NULL
|
||||
return time;
|
||||
}
|
||||
|
||||
// !!!!notice:there are precision problems, double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064
|
||||
//int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
|
||||
// assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
// fromPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
// assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
// toPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
// static double factors[3][3] = {{1., 1000., 1000000.}, {1.0 / 1000, 1., 1000.}, {1.0 / 1000000, 1.0 / 1000, 1.}};
|
||||
// ((double)time * factors[fromPrecision][toPrecision]);
|
||||
//}
|
||||
|
||||
|
||||
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064
|
||||
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) {
|
||||
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
fromPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
static double factors[3] = {1000000., 1000., 1.};
|
||||
int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1};
|
||||
double tmp = time;
|
||||
switch (toUnit) {
|
||||
case 's':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_SEC;
|
||||
case 's':{
|
||||
tmp /= (NANOSECOND_PER_SEC/factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_SEC/factors[fromPrecision]);
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_MINUTE;
|
||||
tmp /= (NANOSECOND_PER_MINUTE/factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_MINUTE/factors[fromPrecision]);
|
||||
break;
|
||||
case 'h':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_HOUR;
|
||||
tmp /= (NANOSECOND_PER_HOUR/factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_HOUR/factors[fromPrecision]);
|
||||
break;
|
||||
case 'd':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_DAY;
|
||||
tmp /= (NANOSECOND_PER_DAY/factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_DAY/factors[fromPrecision]);
|
||||
break;
|
||||
case 'w':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_WEEK;
|
||||
tmp /= (NANOSECOND_PER_WEEK/factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_WEEK/factors[fromPrecision]);
|
||||
break;
|
||||
case 'a':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_MSEC;
|
||||
tmp /= (NANOSECOND_PER_MSEC/factors[fromPrecision]); // the result of division is an integer
|
||||
time /= (NANOSECOND_PER_MSEC/factors[fromPrecision]);
|
||||
break;
|
||||
case 'u':
|
||||
return time * factors[fromPrecision] / NANOSECOND_PER_USEC;
|
||||
// the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double
|
||||
switch (fromPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:{
|
||||
tmp *= 1000;
|
||||
time *= 1000;
|
||||
break;
|
||||
}
|
||||
case TSDB_TIME_PRECISION_MICRO:{
|
||||
tmp /= 1;
|
||||
time /= 1;
|
||||
break;
|
||||
}
|
||||
case TSDB_TIME_PRECISION_NANO:{
|
||||
tmp /= 1000;
|
||||
time /= 1000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
return time * factors[fromPrecision];
|
||||
tmp *= factors[fromPrecision];
|
||||
time *= factors[fromPrecision];
|
||||
break;
|
||||
default: {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (tmp >= (double)INT64_MAX) return INT64_MAX;
|
||||
if (tmp <= (double)INT64_MIN) return INT64_MIN;
|
||||
return time;
|
||||
}
|
||||
|
||||
int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal) {
|
||||
|
@ -494,7 +590,7 @@ int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* dura
|
|||
char* endPtr = NULL;
|
||||
|
||||
/* get the basic numeric value */
|
||||
int64_t timestamp = strtoll(token, &endPtr, 10);
|
||||
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
||||
if (errno != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -512,7 +608,7 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
|
|||
errno = 0;
|
||||
|
||||
/* get the basic numeric value */
|
||||
*duration = strtoll(token, NULL, 10);
|
||||
*duration = taosStr2Int64(token, NULL, 10);
|
||||
if (errno != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
|
|||
errno = 0;
|
||||
char *endPtr = NULL;
|
||||
|
||||
*value = strtoll(z, &endPtr, base);
|
||||
*value = taosStr2Int64(z, &endPtr, base);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
errno = 0;
|
||||
return -1;
|
||||
|
@ -58,7 +58,7 @@ int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
*value = strtoull(z, &endPtr, base);
|
||||
*value = taosStr2UInt64(z, &endPtr, base);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
errno = 0;
|
||||
return -1;
|
||||
|
@ -434,7 +434,7 @@ static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *val
|
|||
// return -1;
|
||||
// }
|
||||
//
|
||||
// *value = strtod(pStr, NULL);
|
||||
// *value = taosStr2Double(pStr, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
|
|||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
errno = 0;
|
||||
double v = strtod(pVariant->pz, NULL);
|
||||
double v = taosStr2Double(pVariant->pz, NULL);
|
||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
return -1;
|
||||
|
|
|
@ -17,6 +17,15 @@ TARGET_INCLUDE_DIRECTORIES(
|
|||
PRIVATE "${TD_SOURCE_DIR}/source/libs/common/inc"
|
||||
)
|
||||
|
||||
# dataformatTest.cpp
|
||||
add_executable(dataformatTest "")
|
||||
target_sources(
|
||||
dataformatTest
|
||||
PRIVATE
|
||||
"dataformatTest.cpp"
|
||||
)
|
||||
target_link_libraries(dataformatTest gtest gtest_main util)
|
||||
|
||||
# tmsg test
|
||||
# add_executable(tmsgTest "")
|
||||
# target_sources(tmsgTest
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "gtest/gtest.h"
|
|
@ -1,23 +0,0 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "trow.h"
|
||||
|
||||
TEST(td_row_test, build_row_to_target) {
|
||||
#if 0
|
||||
char dst[1024];
|
||||
SRow* pRow = (SRow*)dst;
|
||||
int ncols = 10;
|
||||
col_id_t cid;
|
||||
void* pData;
|
||||
SRowBuilder rb = trbInit(TD_OR_ROW_BUILDER, NULL, 0, pRow, 1024);
|
||||
|
||||
trbSetRowInfo(&rb, false, 0);
|
||||
trbSetRowTS(&rb, 1637550210000);
|
||||
for (int c = 0; c < ncols; c++) {
|
||||
cid = c;
|
||||
if (trbWriteCol(&rb, pData, cid) < 0) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -1,14 +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/>.
|
||||
*/
|
|
@ -16,7 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "bmInt.h"
|
||||
|
||||
static void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
||||
void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
||||
|
||||
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||
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) {
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.info = pMsg->info,
|
||||
.pCont = pMsg->info.rsp,
|
||||
.contLen = pMsg->info.rspLen,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ static void bmProcessMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
bmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ typedef struct SDnodeMgmt {
|
|||
SSingleWorker mgmtWorker;
|
||||
ProcessCreateNodeFp processCreateNodeFp;
|
||||
ProcessDropNodeFp processDropNodeFp;
|
||||
IsNodeRequiredFp isNodeRequiredFp;
|
||||
SendMonitorReportFp sendMonitorReportFp;
|
||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||
} SDnodeMgmt;
|
||||
|
||||
// dmHandle.c
|
||||
|
@ -43,11 +45,6 @@ int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
|||
int32_t dmProcessGrantRsp(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
|
||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
|
||||
|
|
|
@ -72,11 +72,11 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
taosRUnLockLatch(&pMgmt->pData->latch);
|
||||
|
||||
SMonVloadInfo vinfo = {0};
|
||||
dmGetVnodeLoads(pMgmt, &vinfo);
|
||||
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||
req.pVloads = vinfo.pVloads;
|
||||
|
||||
SMonMloadInfo minfo = {0};
|
||||
dmGetMnodeLoads(pMgmt, &minfo);
|
||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||
|
||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||
void *pHead = rpcMallocCont(contLen);
|
||||
|
@ -86,7 +86,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527};
|
||||
SRpcMsg rpcRsp = {0};
|
||||
|
||||
dTrace("send status msg to mnode, app:%p", rpcMsg.info.ahandle);
|
||||
dTrace("send status msg to mnode");
|
||||
|
||||
SEpSet epSet = {0};
|
||||
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||
|
@ -115,19 +115,18 @@ static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
|||
|
||||
SServerStatusRsp statusRsp = {0};
|
||||
SMonMloadInfo minfo = {0};
|
||||
dmGetMnodeLoads(pMgmt, &minfo);
|
||||
if (minfo.isMnode && minfo.load.syncState != TAOS_SYNC_STATE_LEADER &&
|
||||
minfo.load.syncState != TAOS_SYNC_STATE_CANDIDATE) {
|
||||
(*pMgmt->getMnodeLoadsFp)(&minfo);
|
||||
if (minfo.isMnode && minfo.load.syncState == TAOS_SYNC_STATE_ERROR) {
|
||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||
return;
|
||||
}
|
||||
|
||||
SMonVloadInfo vinfo = {0};
|
||||
dmGetVnodeLoads(pMgmt, &vinfo);
|
||||
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(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;
|
||||
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
||||
syncStr(pLoad->syncState));
|
||||
|
|
|
@ -45,7 +45,9 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
pMgmt->name = pInput->name;
|
||||
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
|
||||
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
|
||||
pMgmt->isNodeRequiredFp = pInput->isNodeRequiredFp;
|
||||
pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp;
|
||||
pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp;
|
||||
pMgmt->getMnodeLoadsFp = pInput->getMnodeLoadsFp;
|
||||
|
||||
if (dmStartWorker(pMgmt) != 0) {
|
||||
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();
|
||||
float interval = (curTime - lastTime) / 1000.0f;
|
||||
if (interval >= tsMonitorInterval) {
|
||||
dmSendMonitorReport(pMgmt);
|
||||
(*pMgmt->sendMonitorReportFp)();
|
||||
lastTime = curTime;
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
|
|||
void dmStopStatusThread(SDnodeMgmt *pMgmt) {
|
||||
if (taosCheckPthreadValid(pMgmt->statusThread)) {
|
||||
taosThreadJoin(pMgmt->statusThread, NULL);
|
||||
taosThreadClear(&pMgmt->statusThread);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +96,7 @@ int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) {
|
|||
void dmStopMonitorThread(SDnodeMgmt *pMgmt) {
|
||||
if (taosCheckPthreadValid(pMgmt->monitorThread)) {
|
||||
taosThreadJoin(pMgmt->monitorThread, NULL);
|
||||
taosThreadClear(&pMgmt->monitorThread);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,14 +153,14 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
if (code != 0 && terrno != 0) code = terrno;
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.info = pMsg->info,
|
||||
.pCont = pMsg->info.rsp,
|
||||
.contLen = pMsg->info.rspLen,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
rpcSendResponse(&rsp);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
|
|
@ -154,6 +154,6 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq, bool deployed) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dInfo("successed to write %s, deployed:%d", realfile, deployed);
|
||||
dDebug("successed to write %s, deployed:%d", realfile, deployed);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,13 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "mmInt.h"
|
||||
|
||||
static void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *mmInfo) {
|
||||
mndGetMonitorInfo(pMgmt->pMnode, &mmInfo->cluster, &mmInfo->vgroup, &mmInfo->grant);
|
||||
void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
|
||||
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) {
|
||||
|
@ -45,11 +50,6 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
||||
pInfo->isMnode = 1;
|
||||
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
||||
}
|
||||
|
||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||
SMonMloadInfo mloads = {0};
|
||||
mmGetMnodeLoads(pMgmt, &mloads);
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.info = pMsg->info,
|
||||
.pCont = pMsg->info.rsp,
|
||||
.contLen = pMsg->info.rspLen,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
|||
static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
int32_t code = -1;
|
||||
dTrace("msg:%p, get from mnode queue, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
dTrace("msg:%p, get from mnode queue", pMsg);
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_DND_ALTER_MNODE:
|
||||
|
@ -51,7 +51,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
mmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -84,13 +84,20 @@ static int32_t mmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mmPutNodeMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutNodeMsgToWorker(&pMgmt->writeWorker, pMsg); }
|
||||
int32_t mmPutNodeMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutNodeMsgToWorker(&pMgmt->writeWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutNodeMsgToWorker(&pMgmt->syncWorker, pMsg); }
|
||||
int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutNodeMsgToWorker(&pMgmt->syncWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutNodeMsgToWorker(&pMgmt->readWorker, pMsg); }
|
||||
int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutNodeMsgToWorker(&pMgmt->readWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
|
@ -101,25 +108,25 @@ static inline int32_t mmPutRpcMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pRpc)
|
|||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||
if (pMsg == NULL) return -1;
|
||||
|
||||
dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, create and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mmPutRpcMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc) {
|
||||
return mmPutRpcMsgToWorker(&pMgmt->queryWorker, pRpc);
|
||||
int32_t mmPutRpcMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutRpcMsgToWorker(&pMgmt->queryWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutRpcMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc) {
|
||||
return mmPutRpcMsgToWorker(&pMgmt->writeWorker, pRpc);
|
||||
int32_t mmPutRpcMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutRpcMsgToWorker(&pMgmt->writeWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutRpcMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc) {
|
||||
return mmPutRpcMsgToWorker(&pMgmt->readWorker, pRpc);
|
||||
int32_t mmPutRpcMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutRpcMsgToWorker(&pMgmt->readWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc) { return mmPutRpcMsgToWorker(&pMgmt->syncWorker, pRpc); }
|
||||
int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutRpcMsgToWorker(&pMgmt->syncWorker, pMsg); }
|
||||
|
||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||
SSingleWorkerCfg qCfg = {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "qmInt.h"
|
||||
|
||||
static void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {}
|
||||
void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {}
|
||||
|
||||
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||
SMonQmInfo qmInfo = {0};
|
||||
|
|
|
@ -44,7 +44,7 @@ static void qmProcessMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
qmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ static void qmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
qmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ static void qmProcessFetchQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
qmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ static int32_t qmPutRpcMsgToWorker(SQnodeMgmt *pMgmt, SSingleWorker *pWorker, SR
|
|||
return -1;
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is created and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, create and put into worker:%s, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType));
|
||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "smInt.h"
|
||||
|
||||
static void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
||||
void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
||||
|
||||
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||
SMonSmInfo smInfo = {0};
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
static inline void smSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.info = pMsg->info,
|
||||
.pCont = pMsg->info.rsp,
|
||||
.contLen = pMsg->info.rspLen,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ static void smProcessMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
smSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pRpc->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
int32_t smPutNodeMsgToMonitorQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
||||
|
||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ int32_t smPutNodeMsgToUniqueQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ int32_t smPutNodeMsgToUniqueQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
int32_t smPutNodeMsgToSharedQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SSingleWorker *pWorker = &pMgmt->sharedWorker;
|
||||
|
||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
|||
|
||||
*numOfVnodes = vnodesNum;
|
||||
code = 0;
|
||||
dInfo("succcessed to read file %s", file);
|
||||
dDebug("succcessed to read file %s", file);
|
||||
|
||||
_OVER:
|
||||
if (content != NULL) taosMemoryFree(content);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "vmInt.h"
|
||||
|
||||
static void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||
void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||
pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad));
|
||||
if (pInfo->pVloads == NULL) return;
|
||||
|
||||
|
@ -37,7 +37,7 @@ static void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
|||
taosRUnLockLatch(&pMgmt->latch);
|
||||
}
|
||||
|
||||
static void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||
void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||
SMonVloadInfo vloads = {0};
|
||||
vmGetVnodeLoads(pMgmt, &vloads);
|
||||
|
||||
|
|
|
@ -196,6 +196,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
|||
SVnodeThread *pThread = &threads[t];
|
||||
if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) {
|
||||
taosThreadJoin(pThread->thread, NULL);
|
||||
taosThreadClear(&pThread->thread);
|
||||
}
|
||||
taosMemoryFree(pThread->pCfgs);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ static void vmProcessMgmtMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
dError("msg:%p, not processed in vnode-mgmt/monitor queue", pMsg);
|
||||
dError("msg:%p, not processed in vnode queue", pMsg);
|
||||
}
|
||||
|
||||
if (msgType & 1u) {
|
||||
|
@ -59,7 +59,7 @@ static void vmProcessMgmtMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -67,13 +67,13 @@ static void vmProcessMgmtMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
|
||||
dTrace("msg:%p, will be processed in vnode-query queue", pMsg);
|
||||
dTrace("msg:%p, get from vnode-query queue", pMsg);
|
||||
int32_t code = vnodeProcessQueryMsg(pVnode->pImpl, pMsg);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
vmSendRsp(pMsg, code);
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -82,13 +82,13 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
static void vmProcessFetchQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
|
||||
dTrace("msg:%p, will be processed in vnode-fetch queue", pMsg);
|
||||
dTrace("msg:%p, get from vnode-fetch queue", pMsg);
|
||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
vmSendRsp(pMsg, code);
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -96,7 +96,6 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
|
||||
static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
SRpcMsg rsp;
|
||||
|
||||
SArray *pArray = taosArrayInit(numOfMsgs, sizeof(SRpcMsg *));
|
||||
if (pArray == NULL) {
|
||||
|
@ -108,7 +107,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
SRpcMsg *pMsg = NULL;
|
||||
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
||||
|
||||
dTrace("msg:%p, will be processed in vnode-write queue", pMsg);
|
||||
dTrace("msg:%p, get from vnode-write queue", pMsg);
|
||||
if (taosArrayPush(pArray, &pMsg) == NULL) {
|
||||
dTrace("msg:%p, failed to process since %s", pMsg, terrstr());
|
||||
vmSendRsp(pMsg, TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -116,21 +115,12 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
}
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(pArray); i++) {
|
||||
SRpcMsg *pMsg;
|
||||
SRpcMsg *pRpc;
|
||||
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayGet(pArray, i);
|
||||
SRpcMsg rsp = {.info = pMsg->info, .pCont = NULL, .contLen = 0};
|
||||
|
||||
pMsg = *(SRpcMsg **)taosArrayGet(pArray, i);
|
||||
pRpc = pMsg;
|
||||
|
||||
rsp.info = pRpc->info;
|
||||
rsp.pCont = NULL;
|
||||
rsp.contLen = 0;
|
||||
|
||||
int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pRpc, false);
|
||||
int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pMsg, false);
|
||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
||||
// rsp.code = TSDB_CODE_SYN_NOT_LEADER;
|
||||
// tmsgSendRsp(&rsp);
|
||||
dTrace("syncPropose not leader redirect, vgId:%d ", syncGetVgId(vnodeGetSyncHandle(pVnode->pImpl)));
|
||||
dTrace("msg:%p, is redirect since not leader, vgId:%d ", pMsg, pVnode->vgId);
|
||||
rsp.code = TSDB_CODE_RPC_REDIRECT;
|
||||
SEpSet newEpSet;
|
||||
syncGetEpSet(vnodeGetSyncHandle(pVnode->pImpl), &newEpSet);
|
||||
|
@ -160,7 +150,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
|
||||
static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
SRpcMsg rsp;
|
||||
|
||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
|
@ -181,7 +171,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
// apply data into tsdb
|
||||
if (vnodeProcessWriteReq(pVnode->pImpl, &originalRpcMsg, pSyncApplyMsg->fsmMeta.index, &rsp) < 0) {
|
||||
rsp.code = terrno;
|
||||
dTrace("vnodeProcessWriteReq error, code:%d", terrno);
|
||||
dTrace("msg:%p, process write error since %s", pMsg, terrstr());
|
||||
}
|
||||
|
||||
syncApplyMsgDestroy(pSyncApplyMsg);
|
||||
|
@ -215,7 +205,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
|||
SRpcMsg rsp = {0};
|
||||
rsp.code = terrno;
|
||||
rsp.info = pMsg->info;
|
||||
dTrace("vmProcessSyncQueue error, code:%d", terrno);
|
||||
dTrace("msg:%p, process sync queue error since code:%s", pMsg, terrstr());
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
}
|
||||
|
@ -227,18 +217,18 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
|||
|
||||
static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
|
||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
taosGetQitem(qall, (void **)&pMsg);
|
||||
|
||||
dTrace("msg:%p, will be processed in vnode-merge queue", pMsg);
|
||||
dTrace("msg:%p, get from vnode-merge queue", pMsg);
|
||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
vmSendRsp(pMsg, code);
|
||||
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
@ -255,29 +245,29 @@ static int32_t vmPutNodeMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType
|
|||
|
||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
||||
if (pVnode == NULL) {
|
||||
dError("vgId:%d, failed to write msg:%p to vnode-queue since %s", pHead->vgId, pMsg, terrstr());
|
||||
dError("vgId:%d, failed to put msg:%p into vnode-queue since %s", pHead->vgId, pMsg, terrstr());
|
||||
return terrno != 0 ? terrno : -1;
|
||||
}
|
||||
|
||||
switch (qtype) {
|
||||
case QUERY_QUEUE:
|
||||
dTrace("msg:%p, type:%s will be written into vnode-query queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, put into vnode-query worker, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||
break;
|
||||
case FETCH_QUEUE:
|
||||
dTrace("msg:%p, type:%s will be written into vnode-fetch queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, put into vnode-fetch worker, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||
break;
|
||||
case WRITE_QUEUE:
|
||||
dTrace("msg:%p, type:%s will be written into vnode-write queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, put into vnode-write worker, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
||||
break;
|
||||
case SYNC_QUEUE:
|
||||
dTrace("msg:%p, type:%s will be written into vnode-sync queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, put into vnode-sync worker, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pSyncQ, pMsg);
|
||||
break;
|
||||
case MERGE_QUEUE:
|
||||
dTrace("msg:%p, type:%s will be written into vnode-merge queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
dTrace("msg:%p, put into vnode-merge worker, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||
break;
|
||||
default:
|
||||
|
@ -312,7 +302,7 @@ int32_t vmPutNodeMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t vmPutNodeMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
||||
dTrace("msg:%p, will be put into vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into vnode-mgmt worker, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -320,7 +310,7 @@ int32_t vmPutNodeMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
int32_t vmPutNodeMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
||||
|
||||
dTrace("msg:%p, will be put into vnode-monitor queue, worker:%s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into vnode-monitor worker, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -332,35 +322,33 @@ static int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pRpc, EQueueType q
|
|||
if (pVnode == NULL) return -1;
|
||||
|
||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||
int32_t code = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
if (pMsg != NULL) {
|
||||
dTrace("msg:%p, is created, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||
// if (pMsg->handle != NULL) assert(pMsg->refId != 0);
|
||||
switch (qtype) {
|
||||
case WRITE_QUEUE:
|
||||
dTrace("msg:%p, will be put into vnode-write queue", pMsg);
|
||||
dTrace("msg:%p, create and put into vnode-write worker, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
||||
break;
|
||||
case QUERY_QUEUE:
|
||||
dTrace("msg:%p, will be put into vnode-query queue", pMsg);
|
||||
dTrace("msg:%p, create and put into vnode-query queue, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||
break;
|
||||
case FETCH_QUEUE:
|
||||
dTrace("msg:%p, will be put into vnode-fetch queue", pMsg);
|
||||
dTrace("msg:%p, create and put into vnode-fetch queue, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||
break;
|
||||
case APPLY_QUEUE:
|
||||
dTrace("msg:%p, will be put into vnode-apply queue", pMsg);
|
||||
dTrace("msg:%p, create and put into vnode-apply queue, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pApplyQ, pMsg);
|
||||
break;
|
||||
case MERGE_QUEUE:
|
||||
dTrace("msg:%p, will be put into vnode-merge queue", pMsg);
|
||||
dTrace("msg:%p, create and put into vnode-merge queue, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||
break;
|
||||
case SYNC_QUEUE:
|
||||
dTrace("msg:%p, will be put into vnode-sync queue", pMsg);
|
||||
dTrace("msg:%p, create and put into vnode-sync queue, type:%s", pMsg, TMSG_INFO(pRpc->msgType));
|
||||
taosWriteQitem(pVnode->pSyncQ, pMsg);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_DND_IMP_H_
|
||||
#define _TD_DND_IMP_H_
|
||||
#ifndef _TD_DND_MGMT_H_
|
||||
#define _TD_DND_MGMT_H_
|
||||
|
||||
// tobe deleted
|
||||
#include "uv.h"
|
||||
|
@ -151,12 +151,10 @@ int32_t dmInitProc(struct SMgmtWrapper *pWrapper);
|
|||
void dmCleanupProc(struct SMgmtWrapper *pWrapper);
|
||||
int32_t dmRunProc(SProc *proc);
|
||||
void dmStopProc(SProc *proc);
|
||||
int64_t dmRemoveProcRpcHandle(SProc *proc, void *handle);
|
||||
void dmRemoveProcRpcHandle(SProc *proc, void *handle);
|
||||
void dmCloseProcRpcHandles(SProc *proc);
|
||||
int32_t dmPutToProcCQueue(SProc *proc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||
void *handle, int64_t handleRef, EProcFuncType ftype);
|
||||
void dmPutToProcPQueue(SProc *proc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||
EProcFuncType ftype);
|
||||
int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype);
|
||||
void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype);
|
||||
|
||||
// dmTransport.c
|
||||
int32_t dmInitServer(SDnode *pDnode);
|
||||
|
@ -167,16 +165,13 @@ SMsgCb dmGetMsgcb(SDnode *pDnode);
|
|||
int32_t dmInitMsgHandle(SDnode *pDnode);
|
||||
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||
|
||||
// mgmt nodes
|
||||
SMgmtFunc dmGetMgmtFunc();
|
||||
SMgmtFunc bmGetMgmtFunc();
|
||||
SMgmtFunc qmGetMgmtFunc();
|
||||
SMgmtFunc smGetMgmtFunc();
|
||||
SMgmtFunc vmGetMgmtFunc();
|
||||
SMgmtFunc mmGetMgmtFunc();
|
||||
// dmMonitor.c
|
||||
void dmSendMonitorReport();
|
||||
void dmGetVnodeLoads(SMonVloadInfo *pInfo);
|
||||
void dmGetMnodeLoads(SMonMloadInfo *pInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
static bool dmIsNodeRequired(EDndNodeType ntype) {
|
||||
SDnode *pDnode = dmInstance();
|
||||
return pDnode->wrappers[ntype].required;
|
||||
}
|
||||
|
||||
SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
||||
SMgmtInputOpt opt = {
|
||||
.path = pWrapper->path,
|
||||
|
@ -180,7 +175,9 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
|||
.pData = &pWrapper->pDnode->data,
|
||||
.processCreateNodeFp = dmProcessCreateNodeReq,
|
||||
.processDropNodeFp = dmProcessDropNodeReq,
|
||||
.isNodeRequiredFp = dmIsNodeRequired,
|
||||
.sendMonitorReportFp = dmSendMonitorReport,
|
||||
.getVnodeLoadsFp = dmGetVnodeLoads,
|
||||
.getMnodeLoadsFp = dmGetMnodeLoads,
|
||||
};
|
||||
|
||||
opt.msgCb = dmGetMsgcb(pWrapper->pDnode);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "dmMgmt.h"
|
||||
#include "dmNodes.h"
|
||||
|
||||
static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
|
||||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||
|
@ -189,7 +190,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
|
|||
}
|
||||
|
||||
dmReportStartup("dnode-transport", "initialized");
|
||||
dInfo("dnode is created, ptr:%p", pDnode);
|
||||
dDebug("dnode is created, ptr:%p", pDnode);
|
||||
code = 0;
|
||||
|
||||
_OVER:
|
||||
|
@ -208,7 +209,7 @@ void dmCleanupDnode(SDnode *pDnode) {
|
|||
dmCleanupClient(pDnode);
|
||||
dmCleanupServer(pDnode);
|
||||
dmClearVars(pDnode);
|
||||
dInfo("dnode is closed, ptr:%p", pDnode);
|
||||
dDebug("dnode is closed, ptr:%p", pDnode);
|
||||
}
|
||||
|
||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
||||
|
@ -274,25 +275,24 @@ static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus)
|
|||
}
|
||||
}
|
||||
|
||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||
dDebug("net test req is received");
|
||||
SRpcMsg rsp = {.code = 0, .info = pReq->info};
|
||||
rsp.pCont = rpcMallocCont(pReq->contLen);
|
||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||
dDebug("msg:%p, net test req will be processed", pMsg);
|
||||
SRpcMsg rsp = {.code = 0, .info = pMsg->info};
|
||||
rsp.pCont = rpcMallocCont(pMsg->contLen);
|
||||
if (rsp.pCont == NULL) {
|
||||
rsp.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
rsp.contLen = pReq->contLen;
|
||||
rsp.contLen = pMsg->contLen;
|
||||
}
|
||||
rpcSendResponse(&rsp);
|
||||
}
|
||||
|
||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pReq) {
|
||||
dDebug("server startup status req is received");
|
||||
|
||||
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||
dDebug("msg:%p, server startup status req will be processed", pMsg);
|
||||
SServerStatusRsp statusRsp = {0};
|
||||
dmGetServerStartupStatus(pDnode, &statusRsp);
|
||||
|
||||
SRpcMsg rspMsg = {.info = pReq->info};
|
||||
SRpcMsg rspMsg = {.info = pMsg->info};
|
||||
int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp);
|
||||
if (rspLen < 0) {
|
||||
rspMsg.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -37,6 +37,7 @@ static int32_t dmCreateShm(SMgmtWrapper *pWrapper) {
|
|||
dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->proc.shm.id, shmsize);
|
||||
return 0;
|
||||
}
|
||||
|
@ -58,8 +59,9 @@ static int32_t dmNewProc(SMgmtWrapper *pWrapper, EDndNodeType ntype) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
taosIgnSignal(SIGCHLD);
|
||||
pWrapper->proc.pid = pid;
|
||||
dInfo("node:%s, continue running in new process:%d", pWrapper->name, pid);
|
||||
dInfo("node:%s, continue running in new pid:%d", pWrapper->name, pid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -76,7 +78,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
|||
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
|
||||
|
||||
if (pWrapper->ntype == DNODE || InChildProc(pWrapper)) {
|
||||
tmsgSetDefaultMsgCb(&input.msgCb);
|
||||
tmsgSetDefault(&input.msgCb);
|
||||
}
|
||||
|
||||
if (OnlyInSingleProc(pWrapper)) {
|
||||
|
@ -176,11 +178,11 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
|
|||
if (OnlyInParentProc(pWrapper)) {
|
||||
int32_t pid = pWrapper->proc.pid;
|
||||
if (pid > 0 && taosProcExist(pid)) {
|
||||
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pid);
|
||||
dInfo("node:%s, send kill signal to the child pid:%d", pWrapper->name, pid);
|
||||
taosKillProc(pid);
|
||||
dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pid);
|
||||
dInfo("node:%s, wait for child pid:%d to stop", pWrapper->name, pid);
|
||||
taosWaitProc(pid);
|
||||
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pid);
|
||||
dInfo("node:%s, child pid:%d is stopped", pWrapper->name, pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +256,7 @@ static void dmWatchNodes(SDnode *pDnode) {
|
|||
if (!OnlyInParentProc(pWrapper)) continue;
|
||||
|
||||
if (proc->pid <= 0 || !taosProcExist(proc->pid)) {
|
||||
dWarn("node:%s, process:%d is killed and needs to restart", pWrapper->name, proc->pid);
|
||||
dError("node:%s, pid:%d is killed and needs to restart", pWrapper->name, proc->pid);
|
||||
dmCloseProcRpcHandles(&pWrapper->proc);
|
||||
dmNewProc(pWrapper, ntype);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dmMgmt.h"
|
||||
|
||||
static inline int32_t CEIL8(int32_t v) {
|
||||
const int32_t c = ceil((float)(v) / 8) * 8;
|
||||
return c < 8 ? 8 : c;
|
||||
}
|
||||
static inline int32_t CEIL8(int32_t v) { return ceil((float)(v) / 8) * 8; }
|
||||
|
||||
static int32_t dmInitProcMutex(SProcQueue *queue) {
|
||||
TdThreadMutexAttr mattr = {0};
|
||||
|
@ -87,42 +84,17 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) {
|
|||
return queue;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void dmDestroyProcQueue(SProcQueue *queue) {
|
||||
if (queue->mutex != NULL) {
|
||||
taosThreadMutexDestroy(queue->mutex);
|
||||
queue->mutex = NULL;
|
||||
}
|
||||
}
|
||||
static void dmCleanupProcQueue(SProcQueue *queue) {}
|
||||
|
||||
static void dmDestroyProcSem(SProcQueue *queue) {
|
||||
if (queue->sem != NULL) {
|
||||
tsem_destroy(queue->sem);
|
||||
queue->sem = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void dmCleanupProcQueue(SProcQueue *queue) {
|
||||
#if 0
|
||||
if (queue != NULL) {
|
||||
dmDestroyProcQueue(queue);
|
||||
dmDestroyProcSem(queue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, const char *pHead, int16_t rawHeadLen,
|
||||
const char *pBody, int32_t rawBodyLen, int64_t handle, int64_t handleRef,
|
||||
EProcFuncType ftype) {
|
||||
if (rawHeadLen == 0 || pHead == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return -1;
|
||||
}
|
||||
|
||||
const int32_t headLen = CEIL8(rawHeadLen);
|
||||
static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg *pMsg, EProcFuncType ftype) {
|
||||
const void *pHead = pMsg;
|
||||
const void *pBody = pMsg->pCont;
|
||||
const int16_t rawHeadLen = sizeof(SRpcMsg);
|
||||
const int32_t rawBodyLen = pMsg->contLen;
|
||||
const int16_t headLen = CEIL8(rawHeadLen);
|
||||
const int32_t bodyLen = CEIL8(rawBodyLen);
|
||||
const int32_t fullLen = headLen + bodyLen + 8;
|
||||
const int64_t handle = (int64_t)pMsg->info.handle;
|
||||
|
||||
taosThreadMutexLock(&queue->mutex);
|
||||
if (fullLen > queue->avail) {
|
||||
|
@ -131,8 +103,8 @@ static int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, const char *pHe
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (handle != 0 && ftype == DND_FUNC_REQ) {
|
||||
if (taosHashPut(proc->hash, &handle, sizeof(int64_t), &handleRef, sizeof(int64_t)) != 0) {
|
||||
if (ftype == DND_FUNC_REQ && IsReq(pMsg) && pMsg->code == 0 && handle != 0) {
|
||||
if (taosHashPut(proc->hash, &handle, sizeof(int64_t), &pMsg->info, sizeof(SRpcConnInfo)) != 0) {
|
||||
taosThreadMutexUnlock(&queue->mutex);
|
||||
return -1;
|
||||
}
|
||||
|
@ -151,31 +123,31 @@ static int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, const char *pHe
|
|||
|
||||
if (queue->tail < queue->head) {
|
||||
memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
|
||||
memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, rawBodyLen);
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, rawBodyLen);
|
||||
queue->tail = queue->tail + 8 + headLen + bodyLen;
|
||||
} else {
|
||||
int32_t remain = queue->total - queue->tail;
|
||||
if (remain == 0) {
|
||||
memcpy(queue->pBuffer + 8, pHead, rawHeadLen);
|
||||
memcpy(queue->pBuffer + 8 + headLen, pBody, rawBodyLen);
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer + 8 + headLen, pBody, rawBodyLen);
|
||||
queue->tail = 8 + headLen + bodyLen;
|
||||
} else if (remain == 8) {
|
||||
memcpy(queue->pBuffer, pHead, rawHeadLen);
|
||||
memcpy(queue->pBuffer + headLen, pBody, rawBodyLen);
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer + headLen, pBody, rawBodyLen);
|
||||
queue->tail = headLen + bodyLen;
|
||||
} else if (remain < 8 + headLen) {
|
||||
memcpy(queue->pBuffer + queue->tail + 8, pHead, remain - 8);
|
||||
memcpy(queue->pBuffer, pHead + remain - 8, rawHeadLen - (remain - 8));
|
||||
memcpy(queue->pBuffer + headLen - (remain - 8), pBody, rawBodyLen);
|
||||
memcpy(queue->pBuffer, (char*)pHead + remain - 8, rawHeadLen - (remain - 8));
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer + headLen - (remain - 8), pBody, rawBodyLen);
|
||||
queue->tail = headLen - (remain - 8) + bodyLen;
|
||||
} else if (remain < 8 + headLen + bodyLen) {
|
||||
memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
|
||||
memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, remain - 8 - headLen);
|
||||
memcpy(queue->pBuffer, pBody + remain - 8 - headLen, rawBodyLen - (remain - 8 - headLen));
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, remain - 8 - headLen);
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer, (char*)pBody + remain - 8 - headLen, rawBodyLen - (remain - 8 - headLen));
|
||||
queue->tail = bodyLen - (remain - 8 - headLen);
|
||||
} else {
|
||||
memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
|
||||
memcpy(queue->pBuffer + queue->tail + headLen + 8, pBody, rawBodyLen);
|
||||
if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + headLen + 8, pBody, rawBodyLen);
|
||||
queue->tail = queue->tail + headLen + bodyLen + 8;
|
||||
}
|
||||
}
|
||||
|
@ -185,13 +157,12 @@ static int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, const char *pHe
|
|||
taosThreadMutexUnlock(&queue->mutex);
|
||||
tsem_post(&queue->sem);
|
||||
|
||||
dTrace("node:%s, push %s msg:%p:%d cont:%p:%d, pos:%d remain:%d", queue->name, dmFuncStr(ftype), pHead, headLen,
|
||||
pBody, bodyLen, pos, queue->items);
|
||||
dTrace("node:%s, push %s msg:%p type:%d handle:%p len:%d code:0x%x, pos:%d remain:%d", queue->name, dmFuncStr(ftype),
|
||||
pMsg, pMsg->msgType, pMsg->info.handle, pMsg->contLen, pMsg->code, pos, queue->items);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t dmPopFromProcQueue(SProcQueue *queue, void **ppHead, int16_t *pHeadLen, void **ppBody, int32_t *pBodyLen,
|
||||
EProcFuncType *pFuncType) {
|
||||
static inline int32_t dmPopFromProcQueue(SProcQueue *queue, SRpcMsg **ppMsg, EProcFuncType *pFuncType) {
|
||||
tsem_wait(&queue->sem);
|
||||
|
||||
taosThreadMutexLock(&queue->mutex);
|
||||
|
@ -217,8 +188,9 @@ static int32_t dmPopFromProcQueue(SProcQueue *queue, void **ppHead, int16_t *pHe
|
|||
int32_t bodyLen = CEIL8(rawBodyLen);
|
||||
|
||||
void *pHead = taosAllocateQitem(headLen, DEF_QITEM);
|
||||
void *pBody = rpcMallocCont(bodyLen);
|
||||
if (pHead == NULL || pBody == NULL) {
|
||||
void *pBody = NULL;
|
||||
if (bodyLen > 0) pBody = rpcMallocCont(bodyLen);
|
||||
if (pHead == NULL || (bodyLen > 0 && pBody == NULL)) {
|
||||
taosThreadMutexUnlock(&queue->mutex);
|
||||
tsem_post(&queue->sem);
|
||||
taosFreeQitem(pHead);
|
||||
|
@ -230,31 +202,31 @@ static int32_t dmPopFromProcQueue(SProcQueue *queue, void **ppHead, int16_t *pHe
|
|||
const int32_t pos = queue->head;
|
||||
if (queue->head < queue->tail) {
|
||||
memcpy(pHead, queue->pBuffer + queue->head + 8, headLen);
|
||||
memcpy(pBody, queue->pBuffer + queue->head + 8 + headLen, bodyLen);
|
||||
if (bodyLen > 0) memcpy(pBody, queue->pBuffer + queue->head + 8 + headLen, bodyLen);
|
||||
queue->head = queue->head + 8 + headLen + bodyLen;
|
||||
} else {
|
||||
int32_t remain = queue->total - queue->head;
|
||||
if (remain == 0) {
|
||||
memcpy(pHead, queue->pBuffer + 8, headLen);
|
||||
memcpy(pBody, queue->pBuffer + 8 + headLen, bodyLen);
|
||||
if (bodyLen > 0) memcpy(pBody, queue->pBuffer + 8 + headLen, bodyLen);
|
||||
queue->head = 8 + headLen + bodyLen;
|
||||
} else if (remain == 8) {
|
||||
memcpy(pHead, queue->pBuffer, headLen);
|
||||
memcpy(pBody, queue->pBuffer + headLen, bodyLen);
|
||||
if (bodyLen > 0) memcpy(pBody, queue->pBuffer + headLen, bodyLen);
|
||||
queue->head = headLen + bodyLen;
|
||||
} else if (remain < 8 + headLen) {
|
||||
memcpy(pHead, queue->pBuffer + queue->head + 8, remain - 8);
|
||||
memcpy((char *)pHead + remain - 8, queue->pBuffer, headLen - (remain - 8));
|
||||
memcpy(pBody, queue->pBuffer + headLen - (remain - 8), bodyLen);
|
||||
if (bodyLen > 0) memcpy(pBody, queue->pBuffer + headLen - (remain - 8), bodyLen);
|
||||
queue->head = headLen - (remain - 8) + bodyLen;
|
||||
} else if (remain < 8 + headLen + bodyLen) {
|
||||
memcpy(pHead, queue->pBuffer + queue->head + 8, headLen);
|
||||
memcpy(pBody, queue->pBuffer + queue->head + 8 + headLen, remain - 8 - headLen);
|
||||
memcpy((char *)pBody + remain - 8 - headLen, queue->pBuffer, bodyLen - (remain - 8 - headLen));
|
||||
if (bodyLen > 0) memcpy(pBody, queue->pBuffer + queue->head + 8 + headLen, remain - 8 - headLen);
|
||||
if (bodyLen > 0) memcpy((char *)pBody + remain - 8 - headLen, queue->pBuffer, bodyLen - (remain - 8 - headLen));
|
||||
queue->head = bodyLen - (remain - 8 - headLen);
|
||||
} else {
|
||||
memcpy(pHead, queue->pBuffer + queue->head + 8, headLen);
|
||||
memcpy(pBody, queue->pBuffer + queue->head + headLen + 8, bodyLen);
|
||||
if (bodyLen > 0) memcpy(pBody, queue->pBuffer + queue->head + headLen + 8, bodyLen);
|
||||
queue->head = queue->head + headLen + bodyLen + 8;
|
||||
}
|
||||
}
|
||||
|
@ -263,14 +235,12 @@ static int32_t dmPopFromProcQueue(SProcQueue *queue, void **ppHead, int16_t *pHe
|
|||
queue->items--;
|
||||
taosThreadMutexUnlock(&queue->mutex);
|
||||
|
||||
*ppHead = pHead;
|
||||
*ppBody = pBody;
|
||||
*pHeadLen = rawHeadLen;
|
||||
*pBodyLen = rawBodyLen;
|
||||
*ppMsg = pHead;
|
||||
(*ppMsg)->pCont = pBody;
|
||||
*pFuncType = (EProcFuncType)ftype;
|
||||
|
||||
dTrace("node:%s, pop %s msg:%p:%d cont:%p:%d, pos:%d remain:%d", queue->name, dmFuncStr(ftype), pHead, headLen, pBody,
|
||||
bodyLen, pos, queue->items);
|
||||
dTrace("node:%s, pop %s msg:%p type:%d handle:%p len:%d code:0x%x, pos:%d remain:%d", queue->name, dmFuncStr(ftype),
|
||||
(*ppMsg), (*ppMsg)->msgType, (*ppMsg)->info.handle, (*ppMsg)->contLen, (*ppMsg)->code, pos, queue->items);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -308,18 +278,14 @@ static void *dmConsumChildQueue(void *param) {
|
|||
SProc *proc = param;
|
||||
SMgmtWrapper *pWrapper = proc->wrapper;
|
||||
SProcQueue *queue = proc->cqueue;
|
||||
void *pHead = NULL;
|
||||
void *pBody = NULL;
|
||||
int16_t headLen = 0;
|
||||
int32_t bodyLen = 0;
|
||||
int32_t numOfMsgs = 0;
|
||||
int32_t code = 0;
|
||||
EProcFuncType ftype = DND_FUNC_REQ;
|
||||
SRpcMsg *pReq = NULL;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
|
||||
dDebug("node:%s, start to consume from cqueue", proc->name);
|
||||
do {
|
||||
numOfMsgs = dmPopFromProcQueue(queue, &pHead, &headLen, &pBody, &bodyLen, &ftype);
|
||||
numOfMsgs = dmPopFromProcQueue(queue, &pMsg, &ftype);
|
||||
if (numOfMsgs == 0) {
|
||||
dDebug("node:%s, get no msg from cqueue and exit thread", proc->name);
|
||||
break;
|
||||
|
@ -332,25 +298,24 @@ static void *dmConsumChildQueue(void *param) {
|
|||
}
|
||||
|
||||
if (ftype != DND_FUNC_REQ) {
|
||||
dFatal("node:%s, get msg:%p from cqueue, invalid ftype:%d", proc->name, pHead, ftype);
|
||||
taosFreeQitem(pHead);
|
||||
rpcFreeCont(pBody);
|
||||
} else {
|
||||
pReq = pHead;
|
||||
pReq->pCont = pBody;
|
||||
code = dmProcessNodeMsg(pWrapper, pReq);
|
||||
if (code != 0) {
|
||||
dError("node:%s, failed to process msg:%p since %s, put into pqueue", proc->name, pReq, terrstr());
|
||||
SRpcMsg rspMsg = {
|
||||
.info = pReq->info,
|
||||
.pCont = pReq->info.rsp,
|
||||
.contLen = pReq->info.rspLen,
|
||||
};
|
||||
dmPutToProcPQueue(proc, &rspMsg, sizeof(SRpcMsg), rspMsg.pCont, rspMsg.contLen, DND_FUNC_RSP);
|
||||
taosFreeQitem(pHead);
|
||||
rpcFreeCont(pBody);
|
||||
rpcFreeCont(rspMsg.pCont);
|
||||
}
|
||||
dError("node:%s, invalid ftype:%d from cqueue", proc->name, ftype);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
continue;
|
||||
}
|
||||
|
||||
code = dmProcessNodeMsg(pWrapper, pMsg);
|
||||
if (code != 0) {
|
||||
dError("node:%s, failed to process msg:%p since %s, put into pqueue", proc->name, pMsg, terrstr());
|
||||
SRpcMsg rsp = {
|
||||
.code = (terrno != 0 ? terrno : code),
|
||||
.pCont = pMsg->info.rsp,
|
||||
.contLen = pMsg->info.rspLen,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
dmPutToProcPQueue(proc, &rsp, DND_FUNC_RSP);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
} while (1);
|
||||
|
||||
|
@ -361,18 +326,14 @@ static void *dmConsumParentQueue(void *param) {
|
|||
SProc *proc = param;
|
||||
SMgmtWrapper *pWrapper = proc->wrapper;
|
||||
SProcQueue *queue = proc->pqueue;
|
||||
void *pHead = NULL;
|
||||
void *pBody = NULL;
|
||||
int16_t headLen = 0;
|
||||
int32_t bodyLen = 0;
|
||||
int32_t numOfMsgs = 0;
|
||||
int32_t code = 0;
|
||||
EProcFuncType ftype = DND_FUNC_REQ;
|
||||
SRpcMsg *pRsp = NULL;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
|
||||
dDebug("node:%s, start to consume from pqueue", proc->name);
|
||||
do {
|
||||
numOfMsgs = dmPopFromProcQueue(queue, &pHead, &headLen, &pBody, &bodyLen, &ftype);
|
||||
numOfMsgs = dmPopFromProcQueue(queue, &pMsg, &ftype);
|
||||
if (numOfMsgs == 0) {
|
||||
dDebug("node:%s, get no msg from pqueue and exit thread", proc->name);
|
||||
break;
|
||||
|
@ -385,31 +346,19 @@ static void *dmConsumParentQueue(void *param) {
|
|||
}
|
||||
|
||||
if (ftype == DND_FUNC_RSP) {
|
||||
pRsp = pHead;
|
||||
pRsp->pCont = pBody;
|
||||
dTrace("node:%s, get rsp msg:%p from pqueue, code:0x%04x handle:%p", proc->name, pRsp, code, pRsp->info.handle);
|
||||
dmRemoveProcRpcHandle(proc, pRsp->info.handle);
|
||||
rpcSendResponse(pRsp);
|
||||
dmRemoveProcRpcHandle(proc, pMsg->info.handle);
|
||||
rpcSendResponse(pMsg);
|
||||
} else if (ftype == DND_FUNC_REGIST) {
|
||||
pRsp = pHead;
|
||||
pRsp->pCont = pBody;
|
||||
dTrace("node:%s, get regist msg:%p from pqueue, code:0x%04x handle:%p", proc->name, pRsp, code,
|
||||
pRsp->info.handle);
|
||||
rpcRegisterBrokenLinkArg(pRsp);
|
||||
rpcRegisterBrokenLinkArg(pMsg);
|
||||
} else if (ftype == DND_FUNC_RELEASE) {
|
||||
pRsp = pHead;
|
||||
pRsp->pCont = NULL;
|
||||
dTrace("node:%s, get release msg:%p from pqueue, code:0x%04x handle:%p", proc->name, pRsp, code,
|
||||
pRsp->info.handle);
|
||||
dmRemoveProcRpcHandle(proc, pRsp->info.handle);
|
||||
rpcReleaseHandle(pRsp->info.handle, (int8_t)pRsp->code);
|
||||
rpcFreeCont(pBody);
|
||||
dmRemoveProcRpcHandle(proc, pMsg->info.handle);
|
||||
rpcReleaseHandle(pMsg->info.handle, (int8_t)pMsg->code);
|
||||
} else {
|
||||
dFatal("node:%s, get msg:%p from pqueue, invalid ftype:%d", proc->name, pHead, ftype);
|
||||
rpcFreeCont(pBody);
|
||||
dError("node:%s, invalid ftype:%d from pqueue", proc->name, ftype);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
}
|
||||
|
||||
taosFreeQitem(pHead);
|
||||
taosFreeQitem(pMsg);
|
||||
} while (1);
|
||||
|
||||
return NULL;
|
||||
|
@ -463,56 +412,60 @@ void dmCleanupProc(struct SMgmtWrapper *pWrapper) {
|
|||
SProc *proc = &pWrapper->proc;
|
||||
if (proc->name == NULL) return;
|
||||
|
||||
dDebug("node:%s, start to clean up proc", pWrapper->name);
|
||||
dDebug("node:%s, start to cleanup proc", pWrapper->name);
|
||||
dmStopProc(proc);
|
||||
dmCleanupProcQueue(proc->cqueue);
|
||||
dmCleanupProcQueue(proc->pqueue);
|
||||
taosHashCleanup(proc->hash);
|
||||
proc->hash = NULL;
|
||||
dDebug("node:%s, proc is cleaned up", pWrapper->name);
|
||||
}
|
||||
|
||||
int64_t dmRemoveProcRpcHandle(SProc *proc, void *handle) {
|
||||
void dmRemoveProcRpcHandle(SProc *proc, void *handle) {
|
||||
int64_t h = (int64_t)handle;
|
||||
taosThreadMutexLock(&proc->cqueue->mutex);
|
||||
|
||||
int64_t *pRef = taosHashGet(proc->hash, &h, sizeof(int64_t));
|
||||
int64_t ref = 0;
|
||||
if (pRef != NULL) {
|
||||
ref = *pRef;
|
||||
}
|
||||
|
||||
taosHashRemove(proc->hash, &h, sizeof(int64_t));
|
||||
taosThreadMutexUnlock(&proc->cqueue->mutex);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
void dmCloseProcRpcHandles(SProc *proc) {
|
||||
taosThreadMutexLock(&proc->cqueue->mutex);
|
||||
void *h = taosHashIterate(proc->hash, NULL);
|
||||
while (h != NULL) {
|
||||
void *handle = *((void **)h);
|
||||
h = taosHashIterate(proc->hash, h);
|
||||
|
||||
dError("node:%s, the child process dies and send an offline rsp to handle:%p", proc->name, handle);
|
||||
SRpcMsg rpcMsg = {.info.handle = handle, .code = TSDB_CODE_NODE_OFFLINE};
|
||||
SRpcHandleInfo *pInfo = taosHashIterate(proc->hash, NULL);
|
||||
while (pInfo != NULL) {
|
||||
dError("node:%s, the child process dies and send an offline rsp to handle:%p", proc->name, pInfo->handle);
|
||||
SRpcMsg rpcMsg = {.code = TSDB_CODE_NODE_OFFLINE, .info = *pInfo};
|
||||
rpcSendResponse(&rpcMsg);
|
||||
pInfo = taosHashIterate(proc->hash, pInfo);
|
||||
}
|
||||
taosHashClear(proc->hash);
|
||||
taosThreadMutexUnlock(&proc->cqueue->mutex);
|
||||
}
|
||||
|
||||
void dmPutToProcPQueue(SProc *proc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||
EProcFuncType ftype) {
|
||||
void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
|
||||
int32_t retry = 0;
|
||||
while (dmPushToProcQueue(proc, proc->pqueue, pHead, headLen, pBody, bodyLen, 0, 0, ftype) != 0) {
|
||||
dWarn("node:%s, failed to put msg:%p to pqueue since %s, retry:%d", proc->name, pHead, terrstr(), retry);
|
||||
retry++;
|
||||
taosMsleep(retry);
|
||||
while (1) {
|
||||
if (dmPushToProcQueue(proc, proc->pqueue, pMsg, ftype) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (retry == 10) {
|
||||
pMsg->code = terrno;
|
||||
if (pMsg->contLen > 0) {
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
pMsg->pCont = NULL;
|
||||
pMsg->contLen = 0;
|
||||
}
|
||||
dError("node:%s, failed to push %s msg:%p type:%d handle:%p then discard data and return error", proc->name,
|
||||
dmFuncStr(ftype), pMsg, pMsg->msgType, pMsg->info.handle);
|
||||
} else {
|
||||
dError("node:%s, failed to push %s msg:%p type:%d handle:%p len:%d since %s, retry:%d", proc->name,
|
||||
dmFuncStr(ftype), pMsg, pMsg->msgType, pMsg->info.handle, pMsg->contLen, terrstr(), retry);
|
||||
retry++;
|
||||
taosMsleep(retry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t dmPutToProcCQueue(SProc *proc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen,
|
||||
void *handle, int64_t ref, EProcFuncType ftype) {
|
||||
return dmPushToProcQueue(proc, proc->cqueue, pHead, headLen, pBody, bodyLen, (int64_t)handle, ref, ftype);
|
||||
int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
|
||||
return dmPushToProcQueue(proc, proc->cqueue, pMsg, ftype);
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dTrace("msg:%p, will be processed by %s", pMsg, pWrapper->name);
|
||||
pMsg->info.wrapper = pWrapper;
|
||||
dTrace("msg:%p, will be processed by %s, handle:%p", pMsg, pWrapper->name, pMsg->info.handle);
|
||||
return (*msgFp)(pWrapper->pMgmt, pMsg);
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)];
|
||||
SMgmtWrapper *pWrapper = NULL;
|
||||
|
||||
dTrace("msg:%s is received, handle:%p cont:%p len:%d code:0x%04x app:%p refId:%" PRId64, TMSG_INFO(pRpc->msgType),
|
||||
pRpc->info.handle, pRpc->pCont, pRpc->contLen, pRpc->code, pRpc->info.ahandle, pRpc->info.refId);
|
||||
dTrace("msg:%s is received, handle:%p len:%d code:0x%x app:%p refId:%" PRId64, TMSG_INFO(pRpc->msgType),
|
||||
pRpc->info.handle, pRpc->contLen, pRpc->code, pRpc->info.ahandle, pRpc->info.refId);
|
||||
pRpc->info.noResp = 0;
|
||||
pRpc->info.persistHandle = 0;
|
||||
pRpc->info.wrapper = NULL;
|
||||
|
@ -128,9 +128,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
}
|
||||
|
||||
if (InParentProc(pWrapper)) {
|
||||
code = dmPutToProcCQueue(&pWrapper->proc, pMsg, sizeof(SRpcMsg), pRpc->pCont, pRpc->contLen,
|
||||
(IsReq(pRpc) && (pRpc->code == 0)) ? pRpc->info.handle : NULL, pRpc->info.refId,
|
||||
DND_FUNC_REQ);
|
||||
code = dmPutToProcCQueue(&pWrapper->proc, pMsg, DND_FUNC_REQ);
|
||||
} else {
|
||||
code = dmProcessNodeMsg(pWrapper, pMsg);
|
||||
}
|
||||
|
@ -255,23 +253,23 @@ static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
static inline void dmSendRsp(const SRpcMsg *pMsg) {
|
||||
static inline void dmSendRsp(SRpcMsg *pMsg) {
|
||||
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
||||
if (InChildProc(pWrapper)) {
|
||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, sizeof(SRpcMsg), pMsg->pCont, pMsg->contLen, DND_FUNC_RSP);
|
||||
if (pMsg->code == TSDB_CODE_NODE_REDIRECT) {
|
||||
dmSendRpcRedirectRsp(pMsg);
|
||||
} else {
|
||||
if (pMsg->code == TSDB_CODE_NODE_REDIRECT) {
|
||||
dmSendRpcRedirectRsp(pMsg);
|
||||
if (InChildProc(pWrapper)) {
|
||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP);
|
||||
} else {
|
||||
rpcSendResponse(pMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dmSendRedirectRsp(const SRpcMsg *pRsp, const SEpSet *pNewEpSet) {
|
||||
SMgmtWrapper *pWrapper = pRsp->info.wrapper;
|
||||
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
||||
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
||||
if (InChildProc(pWrapper)) {
|
||||
dmPutToProcPQueue(&pWrapper->proc, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, DND_FUNC_RSP);
|
||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP);
|
||||
} else {
|
||||
SRpcMsg rsp = {0};
|
||||
SMEpSet msg = {.epSet = *pNewEpSet};
|
||||
|
@ -281,7 +279,7 @@ static inline void dmSendRedirectRsp(const SRpcMsg *pRsp, const SEpSet *pNewEpSe
|
|||
tSerializeSMEpSet(rsp.pCont, len, &msg);
|
||||
|
||||
rsp.code = TSDB_CODE_RPC_REDIRECT;
|
||||
rsp.info = pRsp->info;
|
||||
rsp.info = pMsg->info;
|
||||
rpcSendResponse(&rsp);
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +287,7 @@ static inline void dmSendRedirectRsp(const SRpcMsg *pRsp, const SEpSet *pNewEpSe
|
|||
static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) {
|
||||
SMgmtWrapper *pWrapper = pMsg->info.wrapper;
|
||||
if (InChildProc(pWrapper)) {
|
||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, sizeof(SRpcMsg), pMsg->pCont, pMsg->contLen, DND_FUNC_REGIST);
|
||||
dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_REGIST);
|
||||
} else {
|
||||
rpcRegisterBrokenLinkArg(pMsg);
|
||||
}
|
||||
|
@ -299,7 +297,7 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) {
|
|||
SMgmtWrapper *pWrapper = pHandle->wrapper;
|
||||
if (InChildProc(pWrapper)) {
|
||||
SRpcMsg msg = {.code = type, .info = *pHandle};
|
||||
dmPutToProcPQueue(&pWrapper->proc, &msg, sizeof(SRpcMsg), NULL, 0, DND_FUNC_RELEASE);
|
||||
dmPutToProcPQueue(&pWrapper->proc, &msg, DND_FUNC_RELEASE);
|
||||
} else {
|
||||
rpcReleaseHandle(pHandle->handle, type);
|
||||
}
|
||||
|
@ -346,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) {
|
||||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
|
||||
|
@ -418,7 +356,6 @@ int32_t dmInitServer(SDnode *pDnode) {
|
|||
rpcInit.sessions = tsMaxShellConns;
|
||||
rpcInit.connType = TAOS_CONN_SERVER;
|
||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||
rpcInit.afp = (RpcAfp)dmRetrieveUserAuthInfo;
|
||||
rpcInit.parent = pDnode;
|
||||
|
||||
pTrans->serverRpc = rpcOpen(&rpcInit);
|
||||
|
|
|
@ -89,21 +89,23 @@ typedef enum {
|
|||
|
||||
typedef int32_t (*ProcessCreateNodeFp)(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 {
|
||||
int32_t dnodeId;
|
||||
int64_t clusterId;
|
||||
int64_t dnodeVer;
|
||||
int64_t updateTime;
|
||||
int64_t rebootTime;
|
||||
bool dropped;
|
||||
bool stopped;
|
||||
SEpSet mnodeEps;
|
||||
SArray *dnodeEps;
|
||||
SHashObj *dnodeHash;
|
||||
SRWLatch latch;
|
||||
SMsgCb msgCb;
|
||||
int32_t dnodeId;
|
||||
int64_t clusterId;
|
||||
int64_t dnodeVer;
|
||||
int64_t updateTime;
|
||||
int64_t rebootTime;
|
||||
bool dropped;
|
||||
bool stopped;
|
||||
SEpSet mnodeEps;
|
||||
SArray *dnodeEps;
|
||||
SHashObj *dnodeHash;
|
||||
SRWLatch latch;
|
||||
SMsgCb msgCb;
|
||||
} SDnodeData;
|
||||
|
||||
typedef struct {
|
||||
|
@ -113,7 +115,9 @@ typedef struct {
|
|||
SMsgCb msgCb;
|
||||
ProcessCreateNodeFp processCreateNodeFp;
|
||||
ProcessDropNodeFp processDropNodeFp;
|
||||
IsNodeRequiredFp isNodeRequiredFp;
|
||||
SendMonitorReportFp sendMonitorReportFp;
|
||||
GetVnodeLoadsFp getVnodeLoadsFp;
|
||||
GetMnodeLoadsFp getMnodeLoadsFp;
|
||||
} SMgmtInputOpt;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -365,6 +365,8 @@ typedef struct {
|
|||
int64_t uid;
|
||||
int64_t dbUid;
|
||||
int32_t version;
|
||||
int32_t tagVer;
|
||||
int32_t colVer;
|
||||
int32_t nextColId;
|
||||
float xFilesFactor;
|
||||
int32_t delay;
|
||||
|
@ -463,7 +465,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
int64_t consumerId;
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
char appId[TSDB_CGROUP_LEN];
|
||||
char clientId[256];
|
||||
int8_t updateType; // used only for update
|
||||
int32_t epoch;
|
||||
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 *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
|
||||
}
|
||||
|
|
|
@ -427,6 +427,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
pConsumerOld = mndAcquireConsumer(pMnode, consumerId);
|
||||
if (pConsumerOld == NULL) {
|
||||
pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup);
|
||||
tstrncpy(pConsumerNew->clientId, subscribe.clientId, 256);
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE__MODIFY;
|
||||
pConsumerNew->rebNewTopics = newSub;
|
||||
subscribe.topicNames = NULL;
|
||||
|
@ -627,21 +628,26 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
|||
if (pNewConsumer->updateType == CONSUMER_UPDATE__MODIFY) {
|
||||
ASSERT(taosArrayGetSize(pOldConsumer->rebNewTopics) == 0);
|
||||
ASSERT(taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0);
|
||||
SArray *tmp = pOldConsumer->rebNewTopics;
|
||||
pOldConsumer->rebNewTopics = pNewConsumer->rebNewTopics;
|
||||
pNewConsumer->rebNewTopics = tmp;
|
||||
|
||||
tmp = pOldConsumer->rebRemovedTopics;
|
||||
pOldConsumer->rebRemovedTopics = pNewConsumer->rebRemovedTopics;
|
||||
pNewConsumer->rebRemovedTopics = tmp;
|
||||
if (taosArrayGetSize(pNewConsumer->rebNewTopics) == 0 && taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0) {
|
||||
pOldConsumer->status = MQ_CONSUMER_STATUS__READY;
|
||||
} else {
|
||||
SArray *tmp = pOldConsumer->rebNewTopics;
|
||||
pOldConsumer->rebNewTopics = pNewConsumer->rebNewTopics;
|
||||
pNewConsumer->rebNewTopics = tmp;
|
||||
|
||||
tmp = pOldConsumer->assignedTopics;
|
||||
pOldConsumer->assignedTopics = pNewConsumer->assignedTopics;
|
||||
pNewConsumer->assignedTopics = tmp;
|
||||
tmp = pOldConsumer->rebRemovedTopics;
|
||||
pOldConsumer->rebRemovedTopics = pNewConsumer->rebRemovedTopics;
|
||||
pNewConsumer->rebRemovedTopics = tmp;
|
||||
|
||||
pOldConsumer->subscribeTime = pNewConsumer->upTime;
|
||||
tmp = pOldConsumer->assignedTopics;
|
||||
pOldConsumer->assignedTopics = pNewConsumer->assignedTopics;
|
||||
pNewConsumer->assignedTopics = tmp;
|
||||
|
||||
pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY;
|
||||
pOldConsumer->subscribeTime = pNewConsumer->upTime;
|
||||
|
||||
pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY;
|
||||
}
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE__LOST) {
|
||||
ASSERT(taosArrayGetSize(pOldConsumer->rebNewTopics) == 0);
|
||||
ASSERT(taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0);
|
||||
|
@ -843,11 +849,11 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)cgroup, false);
|
||||
|
||||
// app id
|
||||
char appId[TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tstrncpy(varDataVal(appId), pConsumer->appId, TSDB_CGROUP_LEN);
|
||||
varDataSetLen(appId, strlen(varDataVal(appId)));
|
||||
char clientId[TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tstrncpy(varDataVal(clientId), pConsumer->clientId, TSDB_CGROUP_LEN);
|
||||
varDataSetLen(clientId, strlen(varDataVal(clientId)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)appId, false);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)clientId, false);
|
||||
|
||||
// status
|
||||
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
||||
|
|
|
@ -261,8 +261,7 @@ void mndReleaseDb(SMnode *pMnode, SDbObj *pDb) {
|
|||
sdbRelease(pSdb, pDb);
|
||||
}
|
||||
|
||||
static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
||||
bool isRedo) {
|
||||
static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid) {
|
||||
STransAction action = {0};
|
||||
|
||||
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.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||
|
||||
if (isRedo) {
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
||||
bool isRedo) {
|
||||
static int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
||||
STransAction action = {0};
|
||||
|
||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||
if (pDnode == NULL) return -1;
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildAlterVnodeReq(pMnode, pDnode, pDb, pVgroup, &contLen);
|
||||
void *pReq = mndBuildAlterVnodeReq(pMnode, pDb, pVgroup, &contLen);
|
||||
if (pReq == NULL) return -1;
|
||||
|
||||
action.pCont = pReq;
|
||||
action.contLen = contLen;
|
||||
action.msgType = TDMT_VND_ALTER_VNODE;
|
||||
|
||||
if (isRedo) {
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -398,11 +378,14 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1;
|
||||
if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1;
|
||||
if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
||||
if (pCfg->replications > mndGetDnodeSize(pMnode)) return -1;
|
||||
if (pCfg->replications != 1 && pCfg->replications != 3) return -1;
|
||||
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
|
||||
if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1;
|
||||
if (pCfg->hashMethod != 1) return -1;
|
||||
if (pCfg->replications > mndGetDnodeSize(pMnode)) {
|
||||
terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
return -1;
|
||||
}
|
||||
|
||||
terrno = 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -484,7 +467,7 @@ static int32_t mndSetCreateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
|||
|
||||
for (int32_t vn = 0; vn < pVgroup->replica; ++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;
|
||||
}
|
||||
}
|
||||
|
@ -723,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) {
|
||||
if (pVgroup->replica <= 0 || pVgroup->replica == pDb->cfg.replications) {
|
||||
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
||||
SVnodeGid *pVgid = pVgroup->vnodeGid + vn;
|
||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, pVgid, true) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup) != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
SVgObj newVgroup = {0};
|
||||
|
@ -741,9 +721,9 @@ static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
|
|||
return -1;
|
||||
}
|
||||
newVgroup.replica = pDb->cfg.replications;
|
||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[0], true) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[1], true) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[2], true) != 0) return -1;
|
||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1;
|
||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1;
|
||||
} else {
|
||||
mInfo("db:%s, vgId:%d, will remove 2 vnodes", pVgroup->dbName, pVgroup->vgId);
|
||||
|
||||
|
@ -754,7 +734,7 @@ static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
|
|||
return -1;
|
||||
}
|
||||
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, &del2, true) != 0) return -1;
|
||||
}
|
||||
|
@ -1447,8 +1427,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
}
|
||||
|
||||
char *status = "ready";
|
||||
char b[24] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(b, status, strlen(status));
|
||||
char statusB[24] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(statusB, status, strlen(status));
|
||||
|
||||
if (sysDb) {
|
||||
for (int32_t i = 0; i < pShow->numOfColumns; ++i) {
|
||||
|
@ -1458,7 +1438,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
} else if (i == 3) {
|
||||
colDataAppend(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
} else if (i == 20) {
|
||||
colDataAppend(pColInfo, rows, b, false);
|
||||
colDataAppend(pColInfo, rows, statusB, false);
|
||||
} else {
|
||||
colDataAppendNULL(pColInfo, rows);
|
||||
}
|
||||
|
@ -1481,9 +1461,10 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
const char *src = pDb->cfg.strict ? "strict" : "nostrict";
|
||||
STR_WITH_SIZE_TO_VARSTR(b, src, strlen(src));
|
||||
char strict[24] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(strict, src, strlen(src));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
colDataAppend(pColInfo, rows, (const char *)strict, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.daysPerFile, false);
|
||||
|
@ -1554,7 +1535,7 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfStables, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
colDataAppend(pColInfo, rows, (const char *)statusB, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,8 +197,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
|||
goto CONN_OVER;
|
||||
}
|
||||
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,
|
||||
pUser->pass);
|
||||
mError("user:%s, failed to auth while acquire user, input:%s", pReq->conn.user, connReq.passwd);
|
||||
code = TSDB_CODE_RPC_AUTH_FAILURE;
|
||||
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->dbUid, _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, (int32_t)(pStb->xFilesFactor * 10000), _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->dbUid, _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)
|
||||
int32_t xFilesFactor = 0;
|
||||
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->version = pNew->version;
|
||||
pOld->tagVer = pNew->tagVer;
|
||||
pOld->colVer = pNew->colVer;
|
||||
pOld->nextColId = pNew->nextColId;
|
||||
pOld->ttl = pNew->ttl;
|
||||
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.schema.nCols = pStb->numOfColumns;
|
||||
req.schema.sver = pStb->version;
|
||||
req.schema.tagVer = pStb->tagVer;
|
||||
req.schema.colVer = pStb->colVer;
|
||||
req.schema.pSchema = pStb->pColumns;
|
||||
req.schemaTag.nCols = pStb->numOfTags;
|
||||
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->dbUid = pDb->uid;
|
||||
pDst->version = 1;
|
||||
pDst->tagVer = 1;
|
||||
pDst->colVer = 1;
|
||||
pDst->nextColId = 1;
|
||||
pDst->xFilesFactor = pCreate->xFilesFactor;
|
||||
pDst->delay = pCreate->delay;
|
||||
|
@ -949,6 +959,7 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *p
|
|||
}
|
||||
|
||||
pNew->version++;
|
||||
pNew->tagVer++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -967,6 +978,7 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
|
|||
pNew->numOfTags--;
|
||||
|
||||
pNew->version++;
|
||||
pNew->tagVer++;
|
||||
mDebug("stb:%s, start to drop tag %s", pNew->name, tagName);
|
||||
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);
|
||||
|
||||
pNew->version++;
|
||||
pNew->tagVer++;
|
||||
mDebug("stb:%s, start to modify tag %s to %s", pNew->name, oldTagName, newTagName);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1036,6 +1049,7 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SFi
|
|||
|
||||
pTag->bytes = pField->bytes;
|
||||
pNew->version++;
|
||||
pNew->tagVer++;
|
||||
|
||||
mDebug("stb:%s, start to modify tag len %s to %d", pNew->name, pField->name, pField->bytes);
|
||||
return 0;
|
||||
|
@ -1075,6 +1089,7 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
|||
}
|
||||
|
||||
pNew->version++;
|
||||
pNew->colVer++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1103,6 +1118,7 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
|
|||
pNew->numOfColumns--;
|
||||
|
||||
pNew->version++;
|
||||
pNew->colVer++;
|
||||
mDebug("stb:%s, start to drop col %s", pNew->name, colName);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1141,6 +1157,7 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
|
|||
|
||||
pCol->bytes = pField->bytes;
|
||||
pNew->version++;
|
||||
pNew->colVer++;
|
||||
|
||||
mDebug("stb:%s, start to modify col len %s to %d", pNew->name, pField->name, pField->bytes);
|
||||
return 0;
|
||||
|
@ -1300,6 +1317,13 @@ static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq) {
|
|||
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);
|
||||
if (pUser == NULL) {
|
||||
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) {
|
||||
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
|
||||
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,
|
||||
};
|
||||
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));
|
||||
// put into removed
|
||||
|
@ -250,6 +251,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
.pVgEp = pVgEp,
|
||||
};
|
||||
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;
|
||||
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
|
||||
int32_t imbCnt = 0;
|
||||
|
@ -290,6 +294,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
.pVgEp = pVgEp,
|
||||
};
|
||||
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++;
|
||||
}
|
||||
|
@ -303,6 +308,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
.pVgEp = pVgEp,
|
||||
};
|
||||
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 *));
|
||||
taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp));
|
||||
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);
|
||||
pRebVg->newConsumerId = pConsumerEp->consumerId;
|
||||
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);
|
||||
pRebVg->newConsumerId = pConsumerEp->consumerId;
|
||||
taosArrayPush(pOutput->rebVgs, pRebVg);
|
||||
mInfo("mq rebalance: add vg %d to consumer %ld (second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId);
|
||||
}
|
||||
} else {
|
||||
// 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);
|
||||
taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp);
|
||||
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) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
/*SSdb *pSdb = pMnode->pSdb;*/
|
||||
SMDropTopicReq dropReq = {0};
|
||||
|
||||
if (tDeserializeSMDropTopicReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||
|
@ -502,6 +502,17 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, dropReq.name);
|
||||
if (pTopic == NULL) {
|
||||
if (dropReq.igNotExists) {
|
||||
mDebug("topic:%s, not exist, ignore not exist is set", dropReq.name);
|
||||
return 0;
|
||||
} else {
|
||||
terrno = TSDB_CODE_MND_TOPIC_NOT_EXIST;
|
||||
mError("topic:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTopic->refConsumerCnt != 0) {
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
|
||||
|
@ -517,12 +528,10 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
|
||||
mDebug("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
||||
|
||||
#if 1
|
||||
if (mndDropOffsetByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mndDropSubByTopic(pMnode, pTrans, dropReq.name) < 0) {
|
||||
ASSERT(0);
|
||||
|
|
|
@ -842,13 +842,12 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
taosMemoryFree(pTrans->rpcRsp);
|
||||
|
||||
mDebug("trans:%d, send rsp, code:0x%04x stage:%d app:%p", pTrans->id, code & 0xFFFF, pTrans->stage,
|
||||
pTrans->rpcInfo.ahandle);
|
||||
mDebug("trans:%d, send rsp, code:0x%x stage:%d app:%p", pTrans->id, code, pTrans->stage, pTrans->rpcInfo.ahandle);
|
||||
SRpcMsg rspMsg = {
|
||||
.info = pTrans->rpcInfo,
|
||||
.code = code,
|
||||
.pCont = rpcCont,
|
||||
.contLen = pTrans->rpcRspLen,
|
||||
.info = pTrans->rpcInfo,
|
||||
};
|
||||
tmsgSendRsp(&rspMsg);
|
||||
pTrans->rpcInfo.handle = NULL;
|
||||
|
@ -899,7 +898,7 @@ void mndTransProcessRsp(SRpcMsg *pRsp) {
|
|||
}
|
||||
}
|
||||
|
||||
mDebug("trans:%d, action:%d response is received, code:0x%04x, accept:0x%04x", transId, action, pRsp->code,
|
||||
mDebug("trans:%d, action:%d response is received, code:0x%x, accept:0x%04x", transId, action, pRsp->code,
|
||||
pAction->acceptableCode);
|
||||
mndTransExecute(pMnode, pTrans);
|
||||
|
||||
|
@ -986,7 +985,8 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
|
|||
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
|
||||
|
||||
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->msgReceived = 0;
|
||||
pAction->errCode = 0;
|
||||
|
@ -1031,7 +1031,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
|||
mDebug("trans:%d, all %d actions execute successfully", pTrans->id, numOfActions);
|
||||
return 0;
|
||||
} else {
|
||||
mError("trans:%d, all %d actions executed, code:0x%04x", pTrans->id, numOfActions, errCode & 0XFFFF);
|
||||
mError("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errCode & 0XFFFF);
|
||||
mndTransResetActions(pMnode, pTrans, pArray);
|
||||
terrno = errCode;
|
||||
return errCode;
|
||||
|
@ -1222,7 +1222,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) {
|
|||
mError("trans:%d, failed to write sdb since %s", pTrans->id, terrstr());
|
||||
}
|
||||
|
||||
mDebug("trans:%d, finished, code:0x%04x, failedTimes:%d", pTrans->id, pTrans->code, pTrans->failedTimes);
|
||||
mDebug("trans:%d, finished, code:0x%x, failedTimes:%d", pTrans->id, pTrans->code, pTrans->failedTimes);
|
||||
|
||||
return continueExec;
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
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};
|
||||
alterReq.vgVersion = pVgroup->version;
|
||||
alterReq.buffer = pDb->cfg.buffer;
|
||||
|
@ -285,16 +285,14 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgO
|
|||
pReplica->port = pVgidDnode->port;
|
||||
memcpy(pReplica->fqdn, pVgidDnode->fqdn, TSDB_FQDN_LEN);
|
||||
mndReleaseDnode(pMnode, pVgidDnode);
|
||||
|
||||
if (pDnode->id == pVgid->dnodeId) {
|
||||
alterReq.selfIndex = v;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (alterReq.selfIndex == -1) {
|
||||
terrno = TSDB_CODE_MND_APP_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t contLen = tSerializeSAlterVnodeReq(NULL, 0, &alterReq);
|
||||
if (contLen < 0) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue