Merge branch '3.0' into enh/TD-31535/assert
This commit is contained in:
commit
e28d8946c6
|
@ -33,7 +33,8 @@ static int DemoWithReqId() {
|
|||
// connect
|
||||
TAOS *taos = taos_connect(host, user, password, NULL, port);
|
||||
if (taos == NULL) {
|
||||
fprintf(stderr, "Failed to connect to %s:%hu, ErrCode: 0x%x, ErrMessage: %s.\n", host, port, taos_errno(NULL), taos_errstr(NULL));
|
||||
fprintf(stderr, "Failed to connect to %s:%hu, ErrCode: 0x%x, ErrMessage: %s.\n", host, port, taos_errno(NULL),
|
||||
taos_errstr(NULL));
|
||||
taos_cleanup();
|
||||
return -1;
|
||||
}
|
||||
|
@ -44,7 +45,8 @@ static int DemoWithReqId() {
|
|||
TAOS_RES *result = taos_query_with_reqid(taos, sql, reqid);
|
||||
code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "Failed to execute sql with reqId: %ld, ErrCode: 0x%x, ErrMessage: %s\n.", reqid, code, taos_errstr(result));
|
||||
fprintf(stderr, "Failed to execute sql with QID: %ld, ErrCode: 0x%x, ErrMessage: %s\n.", reqid, code,
|
||||
taos_errstr(result));
|
||||
taos_close(taos);
|
||||
taos_cleanup();
|
||||
return -1;
|
||||
|
@ -73,6 +75,4 @@ static int DemoWithReqId() {
|
|||
// ANCHOR_END: with_reqid
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
return DemoWithReqId();
|
||||
}
|
||||
int main(int argc, char *argv[]) { return DemoWithReqId(); }
|
||||
|
|
|
@ -30,6 +30,8 @@ extern "C" {
|
|||
#define MON_VER_LEN 12
|
||||
#define MON_LOG_LEN 1024
|
||||
|
||||
#define VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS "inserted_rows"
|
||||
|
||||
typedef struct {
|
||||
int64_t ts;
|
||||
ELogLevel level;
|
||||
|
@ -216,6 +218,7 @@ typedef struct {
|
|||
} SDmNotifyHandle;
|
||||
|
||||
int32_t monInit(const SMonCfg *pCfg);
|
||||
void monInitVnode();
|
||||
void monCleanup();
|
||||
void monRecordLog(int64_t ts, ELogLevel level, const char *content);
|
||||
int32_t monGetLogs(SMonLogs *logs);
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 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_UTIL_EXCEPTION_H_
|
||||
#define _TD_UTIL_EXCEPTION_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* cleanup actions
|
||||
*/
|
||||
typedef struct SCleanupAction {
|
||||
bool failOnly;
|
||||
uint8_t wrapper;
|
||||
uint16_t reserved;
|
||||
void* func;
|
||||
union {
|
||||
void* Ptr;
|
||||
bool Bool;
|
||||
char Char;
|
||||
int8_t Int8;
|
||||
uint8_t Uint8;
|
||||
int16_t Int16;
|
||||
uint16_t Uint16;
|
||||
int32_t Int;
|
||||
uint32_t Uint;
|
||||
int32_t Int32;
|
||||
uint32_t Uint32;
|
||||
int64_t Int64;
|
||||
uint64_t Uint64;
|
||||
float Float;
|
||||
double Double;
|
||||
} arg1, arg2;
|
||||
} SCleanupAction;
|
||||
|
||||
/*
|
||||
* exception hander registration
|
||||
*/
|
||||
typedef struct SExceptionNode {
|
||||
struct SExceptionNode* prev;
|
||||
jmp_buf jb;
|
||||
int32_t code;
|
||||
int32_t maxCleanupAction;
|
||||
int32_t numCleanupAction;
|
||||
SCleanupAction* cleanupActions;
|
||||
} SExceptionNode;
|
||||
|
||||
// functions & macros for auto-cleanup
|
||||
|
||||
void cleanupPush_void_ptr_ptr(bool failOnly, void* func, void* arg1, void* arg2);
|
||||
void cleanupPush_void_ptr_bool(bool failOnly, void* func, void* arg1, bool arg2);
|
||||
void cleanupPush_void_ptr(bool failOnly, void* func, void* arg);
|
||||
void cleanupPush_int_int(bool failOnly, void* func, int32_t arg);
|
||||
void cleanupPush_void(bool failOnly, void* func);
|
||||
void cleanupPush_int_ptr(bool failOnly, void* func, void* arg);
|
||||
|
||||
int32_t cleanupGetActionCount();
|
||||
void cleanupExecuteTo(int32_t anchor, bool failed);
|
||||
void cleanupExecute(SExceptionNode* node, bool failed);
|
||||
bool cleanupExceedLimit();
|
||||
|
||||
#define CLEANUP_PUSH_VOID_PTR_PTR(failOnly, func, arg1, arg2) \
|
||||
cleanupPush_void_ptr_ptr((failOnly), (void*)(func), (void*)(arg1), (void*)(arg2))
|
||||
#define CLEANUP_PUSH_VOID_PTR_BOOL(failOnly, func, arg1, arg2) \
|
||||
cleanupPush_void_ptr_bool((failOnly), (void*)(func), (void*)(arg1), (bool)(arg2))
|
||||
#define CLEANUP_PUSH_VOID_PTR(failOnly, func, arg) cleanupPush_void_ptr((failOnly), (void*)(func), (void*)(arg))
|
||||
#define CLEANUP_PUSH_INT_INT(failOnly, func, arg) cleanupPush_void_ptr((failOnly), (void*)(func), (int32_t)(arg))
|
||||
#define CLEANUP_PUSH_VOID(failOnly, func) cleanupPush_void((failOnly), (void*)(func))
|
||||
#define CLEANUP_PUSH_INT_PTR(failOnly, func, arg) cleanupPush_int_ptr((failOnly), (void*)(func), (void*)(arg))
|
||||
#define CLEANUP_PUSH_FREE(failOnly, arg) cleanupPush_void_ptr((failOnly), free, (void*)(arg))
|
||||
#define CLEANUP_PUSH_CLOSE(failOnly, arg) cleanupPush_int_int((failOnly), close, (int32_t)(arg))
|
||||
#define CLEANUP_PUSH_FCLOSE(failOnly, arg) cleanupPush_int_ptr((failOnly), fclose, (void*)(arg))
|
||||
|
||||
#define CLEANUP_GET_ANCHOR() cleanupGetActionCount()
|
||||
#define CLEANUP_EXECUTE_TO(anchor, failed) cleanupExecuteTo((anchor), (failed))
|
||||
#define CLEANUP_EXCEED_LIMIT() cleanupExceedLimit()
|
||||
|
||||
// functions & macros for exception handling
|
||||
|
||||
void exceptionPushNode(SExceptionNode* node);
|
||||
int32_t exceptionPopNode();
|
||||
void exceptionThrow(int32_t code);
|
||||
|
||||
#define TRY(maxCleanupActions) \
|
||||
do { \
|
||||
SExceptionNode exceptionNode = {0}; \
|
||||
SCleanupAction cleanupActions[(maxCleanupActions) > 0 ? (maxCleanupActions) : 1]; \
|
||||
exceptionNode.maxCleanupAction = (maxCleanupActions) > 0 ? (maxCleanupActions) : 1; \
|
||||
exceptionNode.cleanupActions = cleanupActions; \
|
||||
exceptionPushNode(&exceptionNode); \
|
||||
int32_t caughtException = setjmp(exceptionNode.jb); \
|
||||
if (caughtException == 0)
|
||||
|
||||
#define CATCH(code) \
|
||||
int32_t code = exceptionPopNode(); \
|
||||
if (caughtException == 1)
|
||||
|
||||
#define FINALLY(code) int32_t code = exceptionPopNode();
|
||||
|
||||
#define END_TRY \
|
||||
} \
|
||||
while (0) \
|
||||
;
|
||||
|
||||
#define THROW(x) exceptionThrow((x))
|
||||
#define CAUGHT_EXCEPTION() ((bool)(caughtException == 1))
|
||||
#define CLEANUP_EXECUTE() cleanupExecute(&exceptionNode, CAUGHT_EXCEPTION())
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_EXCEPTION_H_*/
|
|
@ -229,6 +229,9 @@ function install_bin() {
|
|||
if [ -d ${script_dir}/${xname}/bin ]; then
|
||||
${csudo}cp -r ${script_dir}/${xname}/bin/* ${install_main_dir}/bin
|
||||
fi
|
||||
if [ -e ${script_dir}/${xname}/uninstall_${xname}.sh ]; then
|
||||
${csudo}cp -r ${script_dir}/${xname}/uninstall_${xname}.sh ${install_main_dir}/uninstall_${xname}.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f ${script_dir}/bin/quick_deploy.sh ]; then
|
||||
|
@ -250,6 +253,8 @@ function install_bin() {
|
|||
for service in "${services[@]}"; do
|
||||
[ -x ${install_main_dir}/bin/${service} ] && ${csudo}ln -sf ${install_main_dir}/bin/${service} ${bin_link_dir}/${service} || :
|
||||
done
|
||||
|
||||
[ -x ${install_main_dir}/uninstall_${xname}.sh ] && ${csudo}ln -sf ${install_main_dir}/uninstall_${xname}.sh ${bin_link_dir}/uninstall_${xname}.sh || :
|
||||
}
|
||||
|
||||
function install_lib() {
|
||||
|
|
|
@ -363,8 +363,8 @@ if [ "$verMode" == "cluster" ]; then
|
|||
# copy taosx
|
||||
if [ -d ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ]; then
|
||||
cp -r ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ${install_dir}
|
||||
cp ${top_dir}/../enterprise/src/plugins/taosx/packaging/uninstall.sh ${install_dir}/taosx
|
||||
sed -i 's/target=\"\"/target=\"taosx\"/g' ${install_dir}/taosx/uninstall.sh
|
||||
cp ${top_dir}/../enterprise/src/plugins/taosx/packaging/uninstall.sh ${install_dir}/taosx/uninstall_taosx.sh
|
||||
sed -i "s/uninstall.sh/uninstall_taosx.sh/g" ${install_dir}/taosx/uninstall_taosx.sh
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -56,7 +56,11 @@ local_bin_link_dir="/usr/local/bin"
|
|||
service_config_dir="/etc/systemd/system"
|
||||
config_dir="/etc/${PREFIX}"
|
||||
|
||||
services=(${PREFIX}"d" ${PREFIX}"adapter" ${PREFIX}"x" ${PREFIX}"-explorer" ${PREFIX}"keeper")
|
||||
if [ "${verMode}" == "cluster" ]; then
|
||||
services=(${PREFIX}"d" ${PREFIX}"adapter" ${PREFIX}"keeper")
|
||||
else
|
||||
services=(${PREFIX}"d" ${PREFIX}"adapter" ${PREFIX}"keeper" ${PREFIX}"-explorer")
|
||||
fi
|
||||
tools=(${PREFIX} ${PREFIX}"Benchmark" ${PREFIX}"dump" ${PREFIX}"demo" udfd set_core.sh TDinsight.sh $uninstallScript start-all.sh stop-all.sh)
|
||||
|
||||
csudo=""
|
||||
|
@ -222,6 +226,30 @@ function remove_data_and_config() {
|
|||
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}
|
||||
}
|
||||
|
||||
echo
|
||||
echo "Do you want to remove all the data, log and configuration files? [y/n]"
|
||||
read answer
|
||||
remove_flag=false
|
||||
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
||||
confirmMsg="I confirm that I would like to delete all data, log and configuration files"
|
||||
echo "Please enter '${confirmMsg}' to continue"
|
||||
read answer
|
||||
if [ X"$answer" == X"${confirmMsg}" ]; then
|
||||
remove_flag=true
|
||||
else
|
||||
echo "answer doesn't match, skip this step"
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
|
||||
if [ -e ${install_main_dir}/uninstall_${PREFIX}x.sh ]; then
|
||||
if [ X$remove_flag == X"true" ]; then
|
||||
bash ${install_main_dir}/uninstall_${PREFIX}x.sh --clean-all true
|
||||
else
|
||||
bash ${install_main_dir}/uninstall_${PREFIX}x.sh --clean-all false
|
||||
fi
|
||||
fi
|
||||
|
||||
remove_bin
|
||||
clean_header
|
||||
# Remove lib file
|
||||
|
@ -232,6 +260,11 @@ clean_log
|
|||
clean_config
|
||||
# Remove data link directory
|
||||
${csudo}rm -rf ${data_link_dir} || :
|
||||
|
||||
if [ X$remove_flag == X"true" ]; then
|
||||
remove_data_and_config
|
||||
fi
|
||||
|
||||
${csudo}rm -rf ${install_main_dir} || :
|
||||
if [[ -e /etc/os-release ]]; then
|
||||
osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
|
@ -254,20 +287,6 @@ if [ "$osType" = "Darwin" ]; then
|
|||
${csudo}rm -rf /Applications/TDengine.app
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Do you want to remove all the data, log and configuration files? [y/n]"
|
||||
read answer
|
||||
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
||||
confirmMsg="I confirm that I would like to delete all data, log and configuration files"
|
||||
echo "Please enter '${confirmMsg}' to continue"
|
||||
read answer
|
||||
if [ X"$answer" == X"${confirmMsg}" ]; then
|
||||
remove_data_and_config
|
||||
else
|
||||
echo "answer doesn't match, skip this step"
|
||||
fi
|
||||
fi
|
||||
|
||||
command -v systemctl >/dev/null 2>&1 && ${csudo}systemctl daemon-reload >/dev/null 2>&1 || true
|
||||
echo
|
||||
echo "${productName} is removed successfully!"
|
||||
|
|
|
@ -31,6 +31,8 @@ bin_link_dir="/usr/bin"
|
|||
lib_link_dir="/usr/lib"
|
||||
lib64_link_dir="/usr/lib64"
|
||||
inc_link_dir="/usr/include"
|
||||
log_dir="/var/log/${clientName2}"
|
||||
cfg_dir="/etc/${clientName2}"
|
||||
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
|
@ -92,6 +94,24 @@ function clean_log() {
|
|||
${csudo}rm -rf ${log_link_dir} || :
|
||||
}
|
||||
|
||||
function clean_config_and_log_dir() {
|
||||
# Remove link
|
||||
echo "Do you want to remove all the log and configuration files? [y/n]"
|
||||
read answer
|
||||
if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
||||
confirmMsg="I confirm that I would like to delete all log and configuration files"
|
||||
echo "Please enter '${confirmMsg}' to continue"
|
||||
read answer
|
||||
if [ X"$answer" == X"${confirmMsg}" ]; then
|
||||
# Remove dir
|
||||
rm -rf ${cfg_dir} || :
|
||||
rm -rf ${log_dir} || :
|
||||
else
|
||||
echo "answer doesn't match, skip this step"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop client.
|
||||
kill_client
|
||||
# Remove binary file and links
|
||||
|
@ -104,6 +124,8 @@ clean_lib
|
|||
clean_log
|
||||
# Remove link configuration file
|
||||
clean_config
|
||||
# Remove dir
|
||||
clean_config_and_log_dir
|
||||
|
||||
${csudo}rm -rf ${install_main_dir}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "qworker.h"
|
||||
#include "scheduler.h"
|
||||
#include "tcache.h"
|
||||
#include "tcompare.h"
|
||||
#include "tglobal.h"
|
||||
#include "thttp.h"
|
||||
#include "tmsg.h"
|
||||
|
@ -35,7 +36,6 @@
|
|||
#include "tsched.h"
|
||||
#include "ttime.h"
|
||||
#include "tversion.h"
|
||||
#include "tcompare.h"
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
|
@ -47,13 +47,13 @@
|
|||
#define ENV_JSON_FALSE_CHECK(c) \
|
||||
do { \
|
||||
if (!c) { \
|
||||
tscError("faild to add item to JSON object");\
|
||||
tscError("faild to add item to JSON object"); \
|
||||
code = TSDB_CODE_TSC_FAIL_GENERATE_JSON; \
|
||||
goto _end; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ENV_ERR_RET(c,info) \
|
||||
#define ENV_ERR_RET(c, info) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
|
@ -94,26 +94,26 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
|
|||
int32_t total = atomic_add_fetch_64((int64_t *)&pSummary->totalRequests, 1);
|
||||
int32_t currentInst = atomic_add_fetch_64((int64_t *)&pSummary->currentRequests, 1);
|
||||
tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64
|
||||
", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64,
|
||||
", current:%d, app current:%d, total:%d, QID:0x%" PRIx64,
|
||||
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static void concatStrings(SArray *list, char* buf, int size){
|
||||
static void concatStrings(SArray *list, char *buf, int size) {
|
||||
int len = 0;
|
||||
for(int i = 0; i < taosArrayGetSize(list); i++){
|
||||
char* db = taosArrayGet(list, i);
|
||||
for (int i = 0; i < taosArrayGetSize(list); i++) {
|
||||
char *db = taosArrayGet(list, i);
|
||||
if (NULL == db) {
|
||||
tscError("get dbname failed, buf:%s", buf);
|
||||
break;
|
||||
}
|
||||
char* dot = strchr(db, '.');
|
||||
char *dot = strchr(db, '.');
|
||||
if (dot != NULL) {
|
||||
db = dot + 1;
|
||||
}
|
||||
if (i != 0){
|
||||
if (i != 0) {
|
||||
(void)strcat(buf, ",");
|
||||
len += 1;
|
||||
}
|
||||
|
@ -123,36 +123,36 @@ static void concatStrings(SArray *list, char* buf, int size){
|
|||
break;
|
||||
}
|
||||
len += ret;
|
||||
if (len >= size){
|
||||
if (len >= size) {
|
||||
tscInfo("dbList is truncated, buf:%s, len:%d", buf, len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration){
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration) {
|
||||
cJSON *json = cJSON_CreateObject();
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (json == NULL) {
|
||||
tscError("[monitor] cJSON_CreateObject failed");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
char clusterId[32] = {0};
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRId64, pTscObj->pAppInfo->clusterId) < 0){
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRId64, pTscObj->pAppInfo->clusterId) < 0) {
|
||||
tscError("failed to generate clusterId:%" PRId64, pTscObj->pAppInfo->clusterId);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
char startTs[32] = {0};
|
||||
if (snprintf(startTs, sizeof(startTs), "%" PRId64, pRequest->metric.start/1000) < 0){
|
||||
tscError("failed to generate startTs:%" PRId64, pRequest->metric.start/1000);
|
||||
if (snprintf(startTs, sizeof(startTs), "%" PRId64, pRequest->metric.start / 1000) < 0) {
|
||||
tscError("failed to generate startTs:%" PRId64, pRequest->metric.start / 1000);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
char requestId[32] = {0};
|
||||
if (snprintf(requestId, sizeof(requestId), "%" PRIu64, pRequest->requestId) < 0){
|
||||
if (snprintf(requestId, sizeof(requestId), "%" PRIu64, pRequest->requestId) < 0) {
|
||||
tscError("failed to generate requestId:%" PRIu64, pRequest->requestId);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
|
@ -160,17 +160,18 @@ static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int
|
|||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "cluster_id", cJSON_CreateString(clusterId)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "start_ts", cJSON_CreateString(startTs)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "request_id", cJSON_CreateString(requestId)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "query_time", cJSON_CreateNumber(duration/1000)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "query_time", cJSON_CreateNumber(duration / 1000)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "code", cJSON_CreateNumber(pRequest->code)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "error_info", cJSON_CreateString(tstrerror(pRequest->code))));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
|
||||
if(pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen){
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(
|
||||
json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
|
||||
if (pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen) {
|
||||
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen];
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = '\0';
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = tmp;
|
||||
}else{
|
||||
} else {
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||
}
|
||||
|
||||
|
@ -179,24 +180,24 @@ static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int
|
|||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "ip", cJSON_CreateString(tsLocalFqdn)));
|
||||
|
||||
char pid[32] = {0};
|
||||
if (snprintf(pid, sizeof(pid), "%d", appInfo.pid) < 0){
|
||||
if (snprintf(pid, sizeof(pid), "%d", appInfo.pid) < 0) {
|
||||
tscError("failed to generate pid:%d", appInfo.pid);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "process_id", cJSON_CreateString(pid)));
|
||||
if(pRequest->dbList != NULL){
|
||||
if (pRequest->dbList != NULL) {
|
||||
char dbList[1024] = {0};
|
||||
concatStrings(pRequest->dbList, dbList, sizeof(dbList) - 1);
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString(dbList)));
|
||||
}else if(pRequest->pDb != NULL){
|
||||
} else if (pRequest->pDb != NULL) {
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString(pRequest->pDb)));
|
||||
}else{
|
||||
} else {
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString("")));
|
||||
}
|
||||
|
||||
char* value = cJSON_PrintUnformatted(json);
|
||||
char *value = cJSON_PrintUnformatted(json);
|
||||
MonitorSlowLogData data = {0};
|
||||
data.clusterId = pTscObj->pAppInfo->clusterId;
|
||||
data.type = SLOW_LOG_WRITE;
|
||||
|
@ -212,7 +213,7 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static bool checkSlowLogExceptDb(SRequestObj *pRequest, char* exceptDb) {
|
||||
static bool checkSlowLogExceptDb(SRequestObj *pRequest, char *exceptDb) {
|
||||
if (pRequest->pDb != NULL) {
|
||||
return strcmp(pRequest->pDb, exceptDb) != 0;
|
||||
}
|
||||
|
@ -227,7 +228,7 @@ static bool checkSlowLogExceptDb(SRequestObj *pRequest, char* exceptDb) {
|
|||
if (dot != NULL) {
|
||||
db = dot + 1;
|
||||
}
|
||||
if(strcmp(db, exceptDb) == 0){
|
||||
if (strcmp(db, exceptDb) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -248,14 +249,13 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
int32_t reqType = SLOW_LOG_TYPE_OTHERS;
|
||||
|
||||
int64_t duration = taosGetTimestampUs() - pRequest->metric.start;
|
||||
tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64
|
||||
tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", QID:0x%" PRIx64
|
||||
" elapsed:%.2f ms, "
|
||||
"current:%d, app current:%d",
|
||||
pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000.0, num, currentInst);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == nodesSimAcquireAllocator(pRequest->allocatorRefId)) {
|
||||
if ((pRequest->pQuery && pRequest->pQuery->pRoot &&
|
||||
QUERY_NODE_VNODE_MODIFY_STMT == pRequest->pQuery->pRoot->type &&
|
||||
if ((pRequest->pQuery && pRequest->pQuery->pRoot && QUERY_NODE_VNODE_MODIFY_STMT == pRequest->pQuery->pRoot->type &&
|
||||
(0 == ((SVnodeModifyOpStmt *)pRequest->pQuery->pRoot)->sqlNodeType)) ||
|
||||
QUERY_NODE_VNODE_MODIFY_STMT == pRequest->stmtType) {
|
||||
tscDebug("insert duration %" PRId64 "us: parseCost:%" PRId64 "us, ctgCost:%" PRId64 "us, analyseCost:%" PRId64
|
||||
|
@ -279,7 +279,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
if(pTscObj->pAppInfo->monitorParas.tsEnableMonitor){
|
||||
if (pTscObj->pAppInfo->monitorParas.tsEnableMonitor) {
|
||||
if (QUERY_NODE_VNODE_MODIFY_STMT == pRequest->stmtType || QUERY_NODE_INSERT_STMT == pRequest->stmtType) {
|
||||
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code, MONITORSQLTYPEINSERT);
|
||||
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
||||
|
@ -289,14 +289,15 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThreshold * 1000000UL || duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThresholdTest * 1000000UL) &&
|
||||
if ((duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThreshold * 1000000UL ||
|
||||
duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThresholdTest * 1000000UL) &&
|
||||
checkSlowLogExceptDb(pRequest, pTscObj->pAppInfo->monitorParas.tsSlowLogExceptDb)) {
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->numOfSlowQueries, 1);
|
||||
if (pTscObj->pAppInfo->monitorParas.tsSlowLogScope & reqType) {
|
||||
taosPrintSlowLog("PID:%d, Conn:%u, QID:0x%" PRIx64 ", Start:%" PRId64 " us, Duration:%" PRId64 "us, SQL:%s",
|
||||
taosGetPId(), pTscObj->connId, pRequest->requestId, pRequest->metric.start, duration,
|
||||
pRequest->sqlstr);
|
||||
if(pTscObj->pAppInfo->monitorParas.tsEnableMonitor){
|
||||
if (pTscObj->pAppInfo->monitorParas.tsEnableMonitor) {
|
||||
slowQueryLog(pTscObj->id, pRequest->killed, pRequest->code, duration);
|
||||
if (TSDB_CODE_SUCCESS != generateWriteSlowLog(pTscObj, pRequest, reqType, duration)) {
|
||||
tscError("failed to generate write slow log");
|
||||
|
@ -412,7 +413,7 @@ void stopAllRequests(SHashObj *pRequests) {
|
|||
}
|
||||
|
||||
void destroyAppInst(void *info) {
|
||||
SAppInstInfo* pAppInfo = *(SAppInstInfo**)info;
|
||||
SAppInstInfo *pAppInfo = *(SAppInstInfo **)info;
|
||||
tscDebug("destroy app inst mgr %p", pAppInfo);
|
||||
|
||||
int32_t code = taosThreadMutexLock(&appInfo.mutex);
|
||||
|
@ -597,9 +598,9 @@ int32_t releaseRequest(int64_t rid) { return taosReleaseRef(clientReqRefPool, ri
|
|||
int32_t removeRequest(int64_t rid) { return taosRemoveRef(clientReqRefPool, rid); }
|
||||
|
||||
/// return the most previous req ref id
|
||||
int64_t removeFromMostPrevReq(SRequestObj* pRequest) {
|
||||
int64_t removeFromMostPrevReq(SRequestObj *pRequest) {
|
||||
int64_t mostPrevReqRefId = pRequest->self;
|
||||
SRequestObj* pTmp = pRequest;
|
||||
SRequestObj *pTmp = pRequest;
|
||||
while (pTmp->relation.prevRefId) {
|
||||
pTmp = acquireRequest(pTmp->relation.prevRefId);
|
||||
if (pTmp) {
|
||||
|
@ -615,7 +616,7 @@ int64_t removeFromMostPrevReq(SRequestObj* pRequest) {
|
|||
|
||||
void destroyNextReq(int64_t nextRefId) {
|
||||
if (nextRefId) {
|
||||
SRequestObj* pObj = acquireRequest(nextRefId);
|
||||
SRequestObj *pObj = acquireRequest(nextRefId);
|
||||
if (pObj) {
|
||||
(void)releaseRequest(nextRefId); // ignore error
|
||||
(void)releaseRequest(nextRefId); // ignore error
|
||||
|
@ -929,7 +930,8 @@ void taos_init_imp(void) {
|
|||
appInfo.pid = taosGetPId();
|
||||
appInfo.startTime = taosGetTimestampMs();
|
||||
appInfo.pInstMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
appInfo.pInstMapByClusterId = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
appInfo.pInstMapByClusterId =
|
||||
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
|
||||
tscError("failed to allocate memory when init appInfo");
|
||||
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -993,8 +995,8 @@ int taos_init() {
|
|||
return tscInitRes;
|
||||
}
|
||||
|
||||
const char* getCfgName(TSDB_OPTION option) {
|
||||
const char* name = NULL;
|
||||
const char *getCfgName(TSDB_OPTION option) {
|
||||
const char *name = NULL;
|
||||
|
||||
switch (option) {
|
||||
case TSDB_OPTION_SHELL_ACTIVITY_TIMER:
|
||||
|
@ -1030,7 +1032,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
return -1;
|
||||
}
|
||||
newstr[0] = '"';
|
||||
(void)memcpy(newstr+1, str, len);
|
||||
(void)memcpy(newstr + 1, str, len);
|
||||
newstr[len + 1] = '"';
|
||||
newstr[len + 2] = '\0';
|
||||
str = newstr;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#include "cJSON.h"
|
||||
#include "clientInt.h"
|
||||
#include "clientMonitor.h"
|
||||
#include "clientLog.h"
|
||||
#include "clientMonitor.h"
|
||||
#include "command.h"
|
||||
#include "scheduler.h"
|
||||
#include "tdatablock.h"
|
||||
|
@ -68,9 +68,7 @@ bool chkRequestKilled(void* param) {
|
|||
return killed;
|
||||
}
|
||||
|
||||
void cleanupAppInfo() {
|
||||
taosHashCleanup(appInfo.pInstMap);
|
||||
}
|
||||
void cleanupAppInfo() { taosHashCleanup(appInfo.pInstMap); }
|
||||
|
||||
static int32_t taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param,
|
||||
SAppInstInfo* pAppInfo, int connType, STscObj** pTscObj);
|
||||
|
@ -176,25 +174,29 @@ int32_t taos_connect_internal(const char* ip, const char* user, const char* pass
|
|||
|
||||
_return:
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
(void)taosThreadMutexUnlock(&appInfo.mutex);
|
||||
taosMemoryFreeClear(key);
|
||||
return code;
|
||||
} else {
|
||||
code = taosThreadMutexUnlock(&appInfo.mutex);
|
||||
taosMemoryFreeClear(key);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to unlock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
return code;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(key);
|
||||
|
||||
return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst, connType, pObj);
|
||||
}
|
||||
}
|
||||
|
||||
//SAppInstInfo* getAppInstInfo(const char* clusterKey) {
|
||||
// SAppInstInfo* getAppInstInfo(const char* clusterKey) {
|
||||
// SAppInstInfo** ppAppInstInfo = taosHashGet(appInfo.pInstMap, clusterKey, strlen(clusterKey));
|
||||
// if (ppAppInstInfo != NULL && *ppAppInstInfo != NULL) {
|
||||
// return *ppAppInstInfo;
|
||||
// } else {
|
||||
// return NULL;
|
||||
// }
|
||||
//}
|
||||
// }
|
||||
|
||||
void freeQueryParam(SSyncQueryParam* param) {
|
||||
if (param == NULL) return;
|
||||
|
@ -230,7 +232,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
int32_t err = taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||
sizeof((*pRequest)->self));
|
||||
if (err) {
|
||||
tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||
tscError("%" PRId64 " failed to add to request container, QID:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
|
@ -241,7 +243,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) {
|
||||
if (TSDB_CODE_SUCCESS !=
|
||||
nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) {
|
||||
tscError("%" PRId64 " failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||
tscError("%" PRId64 " failed to create node allocator, QID:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
|
@ -249,7 +251,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
}
|
||||
}
|
||||
|
||||
tscDebugL("0x%" PRIx64 " SQL: %s, reqId:0x%" PRIx64, (*pRequest)->self, (*pRequest)->sqlstr, (*pRequest)->requestId);
|
||||
tscDebugL("0x%" PRIx64 " SQL: %s, QID:0x%" PRIx64, (*pRequest)->self, (*pRequest)->sqlstr, (*pRequest)->requestId);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -363,10 +365,10 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
|
||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||
pResultInfo->numOfRows = 0;
|
||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, QID:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, QID:0x%" PRIx64,
|
||||
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
||||
pRequest->requestId);
|
||||
}
|
||||
|
@ -432,7 +434,7 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t qnodeRequired(SRequestObj* pRequest, bool *required) {
|
||||
int32_t qnodeRequired(SRequestObj* pRequest, bool* required) {
|
||||
if (QUERY_POLICY_VNODE == tsQueryPolicy || QUERY_POLICY_CLIENT == tsQueryPolicy) {
|
||||
*required = false;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -972,8 +974,8 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
tscError("0x%" PRIx64 ", invalid exec result for request type %d, reqId:0x%" PRIx64, pRequest->self,
|
||||
pRequest->type, pRequest->requestId);
|
||||
tscError("0x%" PRIx64 ", invalid exec result for request type %d, QID:0x%" PRIx64, pRequest->self, pRequest->type,
|
||||
pRequest->requestId);
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1017,12 +1019,12 @@ void returnToUser(SRequestObj* pRequest) {
|
|||
(void)releaseRequest(pRequest->relation.userRefId);
|
||||
return;
|
||||
} else {
|
||||
tscError("0x%" PRIx64 ", user ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self,
|
||||
tscError("0x%" PRIx64 ", user ref 0x%" PRIx64 " is not there, QID:0x%" PRIx64, pRequest->self,
|
||||
pRequest->relation.userRefId, pRequest->requestId);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock**pBlock) {
|
||||
static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock** pBlock) {
|
||||
int64_t lastTs = 0;
|
||||
TAOS_FIELD* pResFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
@ -1032,7 +1034,7 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock*
|
|||
return code;
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < numOfFields; ++i) {
|
||||
for (int32_t i = 0; i < numOfFields; ++i) {
|
||||
SColumnInfoData colInfoData = createColumnInfoData(pResFields[i].type, pResFields[i].bytes, i + 1);
|
||||
code = blockDataAppendColInfo(*pBlock, &colInfoData);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -1054,7 +1056,7 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock*
|
|||
lastTs = ts;
|
||||
}
|
||||
|
||||
for(int32_t j = 0; j < numOfFields; ++j) {
|
||||
for (int32_t j = 0; j < numOfFields; ++j) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet((*pBlock)->pDataBlock, j);
|
||||
code = colDataSetVal(pColInfoData, i, pRow[j], false);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -1069,7 +1071,7 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock*
|
|||
(*pBlock)->info.window.ekey = lastTs;
|
||||
(*pBlock)->info.rows = numOfRows;
|
||||
|
||||
tscDebug("lastKey:%"PRId64" numOfRows:%d from all vgroups", lastTs, numOfRows);
|
||||
tscDebug("lastKey:%" PRId64 " numOfRows:%d from all vgroups", lastTs, numOfRows);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1084,7 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
|
|||
|
||||
SSDataBlock* pBlock = NULL;
|
||||
if (TSDB_CODE_SUCCESS != createResultBlock(res, rowNum, &pBlock)) {
|
||||
tscError("0x%" PRIx64 ", create result block failed, reqId:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
||||
tscError("0x%" PRIx64 ", create result block failed, QID:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1093,7 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
|
|||
continuePostSubQuery(pNextReq, pBlock);
|
||||
(void)releaseRequest(pRequest->relation.nextRefId);
|
||||
} else {
|
||||
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self,
|
||||
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, QID:0x%" PRIx64, pRequest->self,
|
||||
pRequest->relation.nextRefId, pRequest->requestId);
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1112,7 @@ void handlePostSubQuery(SSqlCallbackWrapper* pWrapper) {
|
|||
continuePostSubQuery(pNextReq, NULL);
|
||||
(void)releaseRequest(pRequest->relation.nextRefId);
|
||||
} else {
|
||||
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self,
|
||||
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, QID:0x%" PRIx64, pRequest->self,
|
||||
pRequest->relation.nextRefId, pRequest->requestId);
|
||||
}
|
||||
}
|
||||
|
@ -1141,11 +1143,11 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
|
|||
}
|
||||
|
||||
taosMemoryFree(pResult);
|
||||
tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
tscDebug("0x%" PRIx64 " enter scheduler exec cb, code:%s, QID:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code) && pRequest->sqlstr != NULL) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%s, tryCount:%d, reqId:0x%" PRIx64, pRequest->self,
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%s, tryCount:%d, QID:0x%" PRIx64, pRequest->self,
|
||||
tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
(void)removeMeta(pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type));
|
||||
restartAsyncQuery(pRequest, code);
|
||||
|
@ -1560,7 +1562,8 @@ int32_t taosConnectImpl(const char* user, const char* auth, const char* db, __ta
|
|||
}
|
||||
|
||||
int64_t transporterId = 0;
|
||||
code = asyncSendMsgToServer((*pTscObj)->pAppInfo->pTransporter, &(*pTscObj)->pAppInfo->mgmtEp.epSet, &transporterId, body);
|
||||
code = asyncSendMsgToServer((*pTscObj)->pAppInfo->pTransporter, &(*pTscObj)->pAppInfo->mgmtEp.epSet, &transporterId,
|
||||
body);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
destroyTscObj(*pTscObj);
|
||||
tscError("failed to send connect msg to server, code:%s", tstrerror(code));
|
||||
|
@ -1577,7 +1580,7 @@ int32_t taosConnectImpl(const char* user, const char* auth, const char* db, __ta
|
|||
*pTscObj = NULL;
|
||||
return terrno;
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, (*pTscObj)->id,
|
||||
tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, QID:0x%" PRIx64, (*pTscObj)->id,
|
||||
(*pTscObj)->connId, (*pTscObj)->pAppInfo->pTransporter, pRequest->requestId);
|
||||
destroyRequest(pRequest);
|
||||
}
|
||||
|
@ -1708,7 +1711,7 @@ int32_t doProcessMsgFromServer(void* param) {
|
|||
char tbuf[40] = {0};
|
||||
TRACE_TO_STR(trace, tbuf);
|
||||
|
||||
tscDebug("processMsgFromServer handle %p, message: %s, size:%d, code: %s, gtid: %s", pMsg->info.handle,
|
||||
tscDebug("processMsgFromServer handle %p, message: %s, size:%d, code: %s, QID:%s", pMsg->info.handle,
|
||||
TMSG_INFO(pMsg->msgType), pMsg->contLen, tstrerror(pMsg->code), tbuf);
|
||||
|
||||
if (pSendInfo->requestObjRefId != 0) {
|
||||
|
@ -1792,6 +1795,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
|||
AsyncArg* arg = taosMemoryCalloc(1, sizeof(AsyncArg));
|
||||
if (NULL == arg) {
|
||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(tEpSet);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
destroySendMsgInfo(pMsg->info.ahandle);
|
||||
return;
|
||||
|
@ -1890,7 +1894,7 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
|
|||
}
|
||||
|
||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
||||
SSchedulerReq req = { .syncReq = true, .pFetchRes = (void**)&pResInfo->pData };
|
||||
SSchedulerReq req = {.syncReq = true, .pFetchRes = (void**)&pResInfo->pData};
|
||||
|
||||
pRequest->code = schedulerFetchRows(pRequest->body.queryJob, &req);
|
||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1905,7 +1909,7 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, QID:0x%" PRIx64,
|
||||
pRequest->self, pResInfo->numOfRows, pResInfo->totalRows, pResInfo->completed, pRequest->requestId);
|
||||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
|
@ -2298,7 +2302,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
|||
|
||||
char* pStart = p;
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
if(blockVersion == BLOCK_VERSION_1){
|
||||
if (blockVersion == BLOCK_VERSION_1) {
|
||||
colLength[i] = htonl(colLength[i]);
|
||||
}
|
||||
if (colLength[i] >= dataLen) {
|
||||
|
@ -2733,7 +2737,8 @@ void syncQueryFn(void* param, void* res, int32_t code) {
|
|||
(void)tsem_post(&pParam->sem);
|
||||
}
|
||||
|
||||
void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly, int8_t source) {
|
||||
void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly,
|
||||
int8_t source) {
|
||||
if (sql == NULL || NULL == fp) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
if (fp) {
|
||||
|
@ -2854,7 +2859,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
|||
|
||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||
|
||||
tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code,
|
||||
tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, QID:0x%" PRIx64, pRequest->self, code,
|
||||
tstrerror(code), pRequest->requestId);
|
||||
|
||||
pResultInfo->pData = pResult;
|
||||
|
@ -2877,10 +2882,10 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
|||
setQueryResultFromRsp(pResultInfo, (const SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4);
|
||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||
pResultInfo->numOfRows = 0;
|
||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(pRequest->code),
|
||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, QID:0x%" PRIx64, pRequest->self, tstrerror(pRequest->code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, QID:0x%" PRIx64,
|
||||
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
||||
pRequest->requestId);
|
||||
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
#include "catalog.h"
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "clientStmt.h"
|
||||
#include "clientMonitor.h"
|
||||
#include "clientStmt.h"
|
||||
#include "functionMgt.h"
|
||||
#include "os.h"
|
||||
#include "query.h"
|
||||
#include "scheduler.h"
|
||||
#include "tcompare.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsg.h"
|
||||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
#include "version.h"
|
||||
#include "tcompare.h"
|
||||
|
||||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
@ -183,15 +183,15 @@ int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
typedef struct SFetchWhiteListInfo{
|
||||
typedef struct SFetchWhiteListInfo {
|
||||
int64_t connId;
|
||||
__taos_async_whitelist_fn_t userCbFn;
|
||||
void* userParam;
|
||||
void *userParam;
|
||||
} SFetchWhiteListInfo;
|
||||
|
||||
int32_t fetchWhiteListCallbackFn(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SFetchWhiteListInfo* pInfo = (SFetchWhiteListInfo*)param;
|
||||
TAOS* taos = &pInfo->connId;
|
||||
int32_t fetchWhiteListCallbackFn(void *param, SDataBuf *pMsg, int32_t code) {
|
||||
SFetchWhiteListInfo *pInfo = (SFetchWhiteListInfo *)param;
|
||||
TAOS *taos = &pInfo->connId;
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
pInfo->userCbFn(pInfo->userParam, code, taos, 0, NULL);
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
@ -209,7 +209,7 @@ int32_t fetchWhiteListCallbackFn(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
return terrno;
|
||||
}
|
||||
|
||||
uint64_t* pWhiteLists = taosMemoryMalloc(wlRsp.numWhiteLists * sizeof(uint64_t));
|
||||
uint64_t *pWhiteLists = taosMemoryMalloc(wlRsp.numWhiteLists * sizeof(uint64_t));
|
||||
if (pWhiteLists == NULL) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
@ -238,7 +238,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
return;
|
||||
}
|
||||
|
||||
int64_t connId = *(int64_t*)taos;
|
||||
int64_t connId = *(int64_t *)taos;
|
||||
|
||||
STscObj *pTsc = acquireTscObj(connId);
|
||||
if (NULL == pTsc) {
|
||||
|
@ -255,7 +255,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
return;
|
||||
}
|
||||
|
||||
void* pReq = taosMemoryMalloc(msgLen);
|
||||
void *pReq = taosMemoryMalloc(msgLen);
|
||||
if (pReq == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
releaseTscObj(connId);
|
||||
|
@ -269,7 +269,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
return;
|
||||
}
|
||||
|
||||
SFetchWhiteListInfo* pParam = taosMemoryMalloc(sizeof(SFetchWhiteListInfo));
|
||||
SFetchWhiteListInfo *pParam = taosMemoryMalloc(sizeof(SFetchWhiteListInfo));
|
||||
if (pParam == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
taosMemoryFree(pReq);
|
||||
|
@ -280,7 +280,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
pParam->connId = connId;
|
||||
pParam->userCbFn = fp;
|
||||
pParam->userParam = param;
|
||||
SMsgSendInfo* pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
SMsgSendInfo *pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (pSendInfo == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
taosMemoryFree(pParam);
|
||||
|
@ -443,7 +443,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(pRequest->inCallback) {
|
||||
if (pRequest->inCallback) {
|
||||
tscError("can not call taos_fetch_row before query callback ends.");
|
||||
terrno = TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
return NULL;
|
||||
|
@ -454,7 +454,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
if (msg->common.resIter == -1) {
|
||||
if(tmqGetNextResInfo(res, true, &pResultInfo) != 0){
|
||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -466,7 +466,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
pResultInfo->current += 1;
|
||||
return pResultInfo->row;
|
||||
} else {
|
||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0){
|
||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -540,22 +540,23 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
len += sprintf(str + len, "%lf", dv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_VARBINARY:{
|
||||
void* data = NULL;
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
void *data = NULL;
|
||||
uint32_t size = 0;
|
||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||
if(taosAscii2Hex(row[i], charLen, &data, &size) < 0){
|
||||
if (taosAscii2Hex(row[i], charLen, &data, &size) < 0) {
|
||||
break;
|
||||
}
|
||||
(void)memcpy(str + len, data, size);
|
||||
len += size;
|
||||
taosMemoryFree(data);
|
||||
}break;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_GEOMETRY: {
|
||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_VARBINARY || fields[i].type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY || fields[i].type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
fields[i].type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (charLen > fields[i].bytes || charLen < 0) {
|
||||
tscError("taos_print_row error binary. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
|
||||
break;
|
||||
|
@ -664,7 +665,8 @@ const char *taos_get_client_info() { return version; }
|
|||
|
||||
// return int32_t
|
||||
int taos_affected_rows(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res) || TD_RES_TMQ_BATCH_META(res)) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res) ||
|
||||
TD_RES_TMQ_BATCH_META(res)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -675,7 +677,8 @@ int taos_affected_rows(TAOS_RES *res) {
|
|||
|
||||
// return int64_t
|
||||
int64_t taos_affected_rows64(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res) || TD_RES_TMQ_BATCH_META(res)) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res) ||
|
||||
TD_RES_TMQ_BATCH_META(res)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -725,7 +728,8 @@ int taos_select_db(TAOS *taos, const char *db) {
|
|||
}
|
||||
|
||||
void taos_stop_query(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res) || TD_RES_TMQ_BATCH_META(res)) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res) ||
|
||||
TD_RES_TMQ_BATCH_META(res)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -937,7 +941,7 @@ static void doAsyncQueryFromAnalyse(SMetaData *pResultMeta, void *param, int32_t
|
|||
SRequestObj *pRequest = pWrapper->pRequest;
|
||||
SQuery *pQuery = pRequest->pQuery;
|
||||
|
||||
qDebug("0x%" PRIx64 " start to semantic analysis, reqId:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
||||
qDebug("0x%" PRIx64 " start to semantic analysis, QID:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
||||
|
||||
int64_t analyseStart = taosGetTimestampUs();
|
||||
pRequest->metric.ctgCostUs = analyseStart - pRequest->metric.ctgStart;
|
||||
|
@ -999,7 +1003,7 @@ void handleSubQueryFromAnalyse(SSqlCallbackWrapper *pWrapper, SMetaData *pResult
|
|||
}
|
||||
|
||||
pNewRequest->pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pNewRequest->pQuery);
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode **)&pNewRequest->pQuery);
|
||||
if (pNewRequest->pQuery) {
|
||||
pNewRequest->pQuery->pRoot = pRoot;
|
||||
pRoot = NULL;
|
||||
|
@ -1056,15 +1060,15 @@ void handleQueryAnslyseRes(SSqlCallbackWrapper *pWrapper, SMetaData *pResultMeta
|
|||
pRequest->pQuery = NULL;
|
||||
|
||||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, QID:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
restartAsyncQuery(pRequest, code);
|
||||
return;
|
||||
}
|
||||
|
||||
// return to app directly
|
||||
tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self,
|
||||
tstrerror(code), pRequest->requestId);
|
||||
tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, QID:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
pRequest->code = code;
|
||||
returnToUser(pRequest);
|
||||
}
|
||||
|
@ -1113,7 +1117,7 @@ static void doAsyncQueryFromParse(SMetaData *pResultMeta, void *param, int32_t c
|
|||
SQuery *pQuery = pRequest->pQuery;
|
||||
|
||||
pRequest->metric.ctgCostUs += taosGetTimestampUs() - pRequest->metric.ctgStart;
|
||||
qDebug("0x%" PRIx64 " start to continue parse, reqId:0x%" PRIx64 ", code:%s", pRequest->self, pRequest->requestId,
|
||||
qDebug("0x%" PRIx64 " start to continue parse, QID:0x%" PRIx64 ", code:%s", pRequest->self, pRequest->requestId,
|
||||
tstrerror(code));
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1126,7 +1130,7 @@ static void doAsyncQueryFromParse(SMetaData *pResultMeta, void *param, int32_t c
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pWrapper->pRequest->self, code,
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, QID:0x%" PRIx64, pWrapper->pRequest->self, code,
|
||||
tstrerror(code), pWrapper->pRequest->requestId);
|
||||
destorySqlCallbackWrapper(pWrapper);
|
||||
pRequest->pWrapper = NULL;
|
||||
|
@ -1143,7 +1147,7 @@ void continueInsertFromCsv(SSqlCallbackWrapper *pWrapper, SRequestObj *pRequest)
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pWrapper->pRequest->self, code,
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, QID:0x%" PRIx64, pWrapper->pRequest->self, code,
|
||||
tstrerror(code), pWrapper->pRequest->requestId);
|
||||
destorySqlCallbackWrapper(pWrapper);
|
||||
pRequest->pWrapper = NULL;
|
||||
|
@ -1261,7 +1265,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||
tscError("0x%" PRIx64 " error happens, code:%d - %s, QID:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
destorySqlCallbackWrapper(pWrapper);
|
||||
pRequest->pWrapper = NULL;
|
||||
|
@ -1269,9 +1273,9 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
pRequest->pQuery = NULL;
|
||||
|
||||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, QID:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
(void)refreshMeta(pRequest->pTscObj, pRequest); //ignore return code,try again
|
||||
(void)refreshMeta(pRequest->pTscObj, pRequest); // ignore return code,try again
|
||||
pRequest->prevCode = code;
|
||||
doAsyncQuery(pRequest, true);
|
||||
return;
|
||||
|
@ -1285,7 +1289,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
|
||||
void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
|
||||
tscInfo("restart request: %s p: %p", pRequest->sqlstr, pRequest);
|
||||
SRequestObj* pUserReq = pRequest;
|
||||
SRequestObj *pUserReq = pRequest;
|
||||
(void)acquireRequest(pRequest->self);
|
||||
while (pUserReq) {
|
||||
if (pUserReq->self == pUserReq->relation.userRefId || pUserReq->relation.userRefId == 0) {
|
||||
|
@ -1631,7 +1635,6 @@ TAOS_STMT *taos_stmt_init_with_options(TAOS *taos, TAOS_STMT_OPTIONS *options) {
|
|||
return pStmt;
|
||||
}
|
||||
|
||||
|
||||
int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||
if (stmt == NULL || sql == NULL) {
|
||||
tscError("NULL parameter for %s", __FUNCTION__);
|
||||
|
@ -1874,7 +1877,7 @@ int taos_stmt_close(TAOS_STMT *stmt) {
|
|||
return stmtClose(stmt);
|
||||
}
|
||||
|
||||
int taos_set_conn_mode(TAOS* taos, int mode, int value) {
|
||||
int taos_set_conn_mode(TAOS *taos, int mode, int value) {
|
||||
if (taos == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
|
@ -1897,6 +1900,4 @@ int taos_set_conn_mode(TAOS* taos, int mode, int value) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
char* getBuildInfo(){
|
||||
return buildinfo;
|
||||
}
|
||||
char *getBuildInfo() { return buildinfo; }
|
||||
|
|
|
@ -47,8 +47,7 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOG_ID_TAG "connId:0x%" PRIx64 ",reqId:0x%" PRIx64
|
||||
#define LOG_ID_TAG "connId:0x%" PRIx64 ",QID:0x%" PRIx64
|
||||
#define LOG_ID_VALUE *(int64_t*)taos, pRequest->requestId
|
||||
|
||||
#define TMQ_META_VERSION "1.0"
|
||||
|
@ -57,8 +56,8 @@ static int32_t tmqWriteBatchMetaDataImpl(TAOS* taos, void* meta, int32_t metaLen
|
|||
|
||||
static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); }
|
||||
|
||||
static void buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id,
|
||||
int8_t t, SColCmprWrapper* pColCmprRow, cJSON** pJson) {
|
||||
static void buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t,
|
||||
SColCmprWrapper* pColCmprRow, cJSON** pJson) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int8_t buildDefaultCompress = 0;
|
||||
if (pColCmprRow->nCols <= 0) {
|
||||
|
@ -463,7 +462,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
|
||||
RAW_NULL_CHECK(buf);
|
||||
if (!buf) goto end;
|
||||
if(dataConverToStr(buf, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
||||
if (dataConverToStr(buf, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(buf);
|
||||
goto end;
|
||||
}
|
||||
|
@ -534,8 +533,8 @@ static void processCreateTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
if (pCreateReq->type == TSDB_CHILD_TABLE) {
|
||||
buildCreateCTableJson(req.pReqs, req.nReqs, pJson);
|
||||
} else if (pCreateReq->type == TSDB_NORMAL_TABLE) {
|
||||
buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid,
|
||||
TSDB_NORMAL_TABLE, &pCreateReq->colCmpr, pJson);
|
||||
buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE,
|
||||
&pCreateReq->colCmpr, pJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -735,7 +734,8 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 3, 1);
|
||||
}
|
||||
RAW_NULL_CHECK(buf);
|
||||
if(dataConverToStr(buf, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL) != TSDB_CODE_SUCCESS) {
|
||||
if (dataConverToStr(buf, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL) !=
|
||||
TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(buf);
|
||||
goto end;
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
// build create stable
|
||||
pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SFieldWithOptions));
|
||||
RAW_NULL_CHECK (pReq.pColumns);
|
||||
RAW_NULL_CHECK(pReq.pColumns);
|
||||
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
||||
SSchema* pSchema = req.schemaRow.pSchema + i;
|
||||
SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||
|
@ -957,7 +957,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
pCmdMsg.pMsg = taosMemoryMalloc(pCmdMsg.msgLen);
|
||||
RAW_NULL_CHECK(pCmdMsg.pMsg);
|
||||
if (tSerializeSMCreateStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0){
|
||||
if (tSerializeSMCreateStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto end;
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
pQuery.msgType = pQuery.pCmdMsg->msgType;
|
||||
pQuery.stableQuery = true;
|
||||
|
||||
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); //ignore, because return value is pRequest
|
||||
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); // ignore, because return value is pRequest
|
||||
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS) {
|
||||
SCatalog* pCatalog = NULL;
|
||||
|
@ -1021,7 +1021,8 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)};
|
||||
SName pName = {0};
|
||||
(void)toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name, &pName); // ignore the return value, always return pName
|
||||
(void)toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name,
|
||||
&pName); // ignore the return value, always return pName
|
||||
STableMeta* pTableMeta = NULL;
|
||||
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
|
||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||
|
@ -1059,19 +1060,18 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
pCmdMsg.pMsg = taosMemoryMalloc(pCmdMsg.msgLen);
|
||||
RAW_NULL_CHECK(pCmdMsg.pMsg);
|
||||
if (tSerializeSMDropStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0){
|
||||
if (tSerializeSMDropStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
SQuery pQuery = {0};
|
||||
pQuery.execMode = QUERY_EXEC_MODE_RPC;
|
||||
pQuery.pCmdMsg = &pCmdMsg;
|
||||
pQuery.msgType = pQuery.pCmdMsg->msgType;
|
||||
pQuery.stableQuery = true;
|
||||
|
||||
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); //ignore, because return value is pRequest
|
||||
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); // ignore, because return value is pRequest
|
||||
|
||||
if (pRequest->code == TSDB_CODE_SUCCESS) {
|
||||
// ignore the error code
|
||||
|
@ -1500,7 +1500,6 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pArray));
|
||||
|
||||
|
||||
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
|
||||
pVgData = NULL;
|
||||
|
@ -1573,7 +1572,8 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS* taos, int rows, char* pDat
|
|||
RAW_RETURN_CHECK(smlInitHandle(&pQuery));
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
RAW_NULL_CHECK(pVgHash);
|
||||
RAW_RETURN_CHECK(taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData)));
|
||||
RAW_RETURN_CHECK(
|
||||
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData)));
|
||||
RAW_RETURN_CHECK(rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false, NULL, 0));
|
||||
RAW_RETURN_CHECK(smlBuildOutput(pQuery, pVgHash));
|
||||
|
||||
|
@ -1632,7 +1632,8 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha
|
|||
RAW_RETURN_CHECK(smlInitHandle(&pQuery));
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
RAW_NULL_CHECK(pVgHash);
|
||||
RAW_RETURN_CHECK(taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData)));
|
||||
RAW_RETURN_CHECK(
|
||||
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData)));
|
||||
RAW_RETURN_CHECK(rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false, NULL, 0));
|
||||
RAW_RETURN_CHECK(smlBuildOutput(pQuery, pVgHash));
|
||||
|
||||
|
@ -1982,7 +1983,7 @@ static void processBatchMetaToJson(SMqBatchMetaRsp* pMsgRsp, char** string) {
|
|||
SDecoder metaCoder = {0};
|
||||
SMqMetaRsp metaRsp = {0};
|
||||
tDecoderInit(&metaCoder, POINTER_SHIFT(tmpBuf, sizeof(SMqRspHead)), *len - sizeof(SMqRspHead));
|
||||
if(tDecodeMqMetaRsp(&metaCoder, &metaRsp) < 0 ) {
|
||||
if (tDecodeMqMetaRsp(&metaCoder, &metaRsp) < 0) {
|
||||
goto end;
|
||||
}
|
||||
cJSON* pItem = NULL;
|
||||
|
|
|
@ -334,7 +334,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
|||
|
||||
if (strcasecmp(key, "session.timeout.ms") == 0) {
|
||||
int64_t tmp = taosStr2int64(value);
|
||||
if (tmp < 6000 || tmp > 1800000){
|
||||
if (tmp < 6000 || tmp > 1800000) {
|
||||
return TMQ_CONF_INVALID;
|
||||
}
|
||||
conf->sessionTimeoutMs = tmp;
|
||||
|
@ -343,7 +343,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
|||
|
||||
if (strcasecmp(key, "heartbeat.interval.ms") == 0) {
|
||||
int64_t tmp = taosStr2int64(value);
|
||||
if (tmp < 1000 || tmp >= conf->sessionTimeoutMs){
|
||||
if (tmp < 1000 || tmp >= conf->sessionTimeoutMs) {
|
||||
return TMQ_CONF_INVALID;
|
||||
}
|
||||
conf->heartBeatIntervalMs = tmp;
|
||||
|
@ -352,7 +352,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
|||
|
||||
if (strcasecmp(key, "max.poll.interval.ms") == 0) {
|
||||
int64_t tmp = taosStr2int64(value);
|
||||
if (tmp < 1000 || tmp > INT32_MAX){
|
||||
if (tmp < 1000 || tmp > INT32_MAX) {
|
||||
return TMQ_CONF_INVALID;
|
||||
}
|
||||
conf->maxPollIntervalMs = tmp;
|
||||
|
@ -515,7 +515,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse
|
|||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
if(tEncodeMqVgOffset(&encoder, &pOffset) < 0) {
|
||||
if (tEncodeMqVgOffset(&encoder, &pOffset) < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
taosMemoryFree(buf);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
|
@ -562,7 +562,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTopicByName(tmq_t* tmq, const char* pTopicName, SMqClientTopic **topic) {
|
||||
static int32_t getTopicByName(tmq_t* tmq, const char* pTopicName, SMqClientTopic** topic) {
|
||||
int32_t numOfTopics = taosArrayGetSize(tmq->clientTopics);
|
||||
for (int32_t i = 0; i < numOfTopics; ++i) {
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
|
@ -577,8 +577,8 @@ static int32_t getTopicByName(tmq_t* tmq, const char* pTopicName, SMqClientTopic
|
|||
return TSDB_CODE_TMQ_INVALID_TOPIC;
|
||||
}
|
||||
|
||||
static int32_t prepareCommitCbParamSet(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* userParam,
|
||||
int32_t rspNum, SMqCommitCbParamSet** ppParamSet) {
|
||||
static int32_t prepareCommitCbParamSet(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* userParam, int32_t rspNum,
|
||||
SMqCommitCbParamSet** ppParamSet) {
|
||||
SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet));
|
||||
if (pParamSet == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -769,7 +769,7 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us
|
|||
if (pParamSet->waitingRspNum != 1) {
|
||||
// count down since waiting rsp num init as 1
|
||||
code = commitRspCountDown(pParamSet, tmq->consumerId, "", 0);
|
||||
if (code != 0){
|
||||
if (code != 0) {
|
||||
tscError("consumer:0x%" PRIx64 " commit rsp count down failed, code:%s", tmq->consumerId, tstrerror(code));
|
||||
pParamSet = NULL;
|
||||
goto end;
|
||||
|
@ -824,7 +824,7 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
|
|||
}
|
||||
|
||||
int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
if (code != 0){
|
||||
if (code != 0) {
|
||||
goto _return;
|
||||
}
|
||||
if (pMsg == NULL || param == NULL) {
|
||||
|
@ -881,7 +881,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
req.epoch = tmq->epoch;
|
||||
req.pollFlag = atomic_load_8(&pollFlag);
|
||||
req.topics = taosArrayInit(taosArrayGetSize(tmq->clientTopics), sizeof(TopicOffsetRows));
|
||||
if (req.topics == NULL){
|
||||
if (req.topics == NULL) {
|
||||
return;
|
||||
}
|
||||
taosRLockLatch(&tmq->lock);
|
||||
|
@ -892,21 +892,21 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
}
|
||||
int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs);
|
||||
TopicOffsetRows* data = taosArrayReserve(req.topics, 1);
|
||||
if (data == NULL){
|
||||
if (data == NULL) {
|
||||
continue;
|
||||
}
|
||||
(void)strcpy(data->topicName, pTopic->topicName);
|
||||
data->offsetRows = taosArrayInit(numOfVgroups, sizeof(OffsetRows));
|
||||
if (data->offsetRows == NULL){
|
||||
if (data->offsetRows == NULL) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < numOfVgroups; j++) {
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
||||
if (pVg == NULL){
|
||||
if (pVg == NULL) {
|
||||
continue;
|
||||
}
|
||||
OffsetRows* offRows = taosArrayReserve(data->offsetRows, 1);
|
||||
if (offRows == NULL){
|
||||
if (offRows == NULL) {
|
||||
continue;
|
||||
}
|
||||
offRows->vgId = pVg->vgId;
|
||||
|
@ -964,7 +964,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
(void)atomic_val_compare_exchange_8(&pollFlag, 1, 0);
|
||||
OVER:
|
||||
tDestroySMqHbReq(&req);
|
||||
if(tmrId != NULL){
|
||||
if (tmrId != NULL) {
|
||||
(void)taosTmrReset(tmqSendHbReq, tmq->heartBeatIntervalMs, param, tmqMgmt.timer, &tmq->hbLiveTimer);
|
||||
}
|
||||
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||
|
@ -1006,7 +1006,8 @@ void tmqHandleAllDelayedTask(tmq_t* pTmq) {
|
|||
continue;
|
||||
}
|
||||
tscDebug("consumer:0x%" PRIx64 " retrieve ep from mnode in 1s", pTmq->consumerId);
|
||||
(void)taosTmrReset(tmqAssignAskEpTask, DEFAULT_ASKEP_INTERVAL, (void*)(pTmq->refId), tmqMgmt.timer, &pTmq->epTimer);
|
||||
(void)taosTmrReset(tmqAssignAskEpTask, DEFAULT_ASKEP_INTERVAL, (void*)(pTmq->refId), tmqMgmt.timer,
|
||||
&pTmq->epTimer);
|
||||
} else if (*pTaskType == TMQ_DELAYED_TASK__COMMIT) {
|
||||
tmq_commit_cb* pCallbackFn = pTmq->commitCb ? pTmq->commitCb : defaultCommitCbFn;
|
||||
asyncCommitAllOffsets(pTmq, pCallbackFn, pTmq->commitCbUserParam);
|
||||
|
@ -1100,16 +1101,16 @@ int32_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) {
|
|||
taosRLockLatch(&tmq->lock);
|
||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||
SMqClientTopic* topic = taosArrayGet(tmq->clientTopics, i);
|
||||
if(topic == NULL) {
|
||||
if (topic == NULL) {
|
||||
tscError("topic is null");
|
||||
continue;
|
||||
}
|
||||
char* tmp = strchr(topic->topicName, '.');
|
||||
if(tmp == NULL) {
|
||||
if (tmp == NULL) {
|
||||
tscError("topic name is invalid:%s", topic->topicName);
|
||||
continue;
|
||||
}
|
||||
if(tmq_list_append(*topics, tmp+ 1) != 0) {
|
||||
if (tmq_list_append(*topics, tmp + 1) != 0) {
|
||||
tscError("failed to append topic:%s", tmp + 1);
|
||||
continue;
|
||||
}
|
||||
|
@ -1227,27 +1228,31 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
}
|
||||
code = taosOpenQueue(&pTmq->mqueue);
|
||||
if (code) {
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code), pTmq->groupId);
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code),
|
||||
pTmq->groupId);
|
||||
SET_ERROR_MSG_TMQ("open queue failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
code = taosOpenQueue(&pTmq->delayedTask);
|
||||
if (code) {
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code), pTmq->groupId);
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code),
|
||||
pTmq->groupId);
|
||||
SET_ERROR_MSG_TMQ("open delayed task queue failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
code = taosAllocateQall(&pTmq->qall);
|
||||
if (code) {
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code), pTmq->groupId);
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code),
|
||||
pTmq->groupId);
|
||||
SET_ERROR_MSG_TMQ("allocate qall failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
if (conf->groupId[0] == 0) {
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code), pTmq->groupId);
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, tstrerror(code),
|
||||
pTmq->groupId);
|
||||
SET_ERROR_MSG_TMQ("malloc tmq element failed or group is empty")
|
||||
goto _failed;
|
||||
}
|
||||
|
@ -1287,8 +1292,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
|
||||
// init semaphore
|
||||
if (tsem2_init(&pTmq->rspSem, 0, 0) != 0) {
|
||||
tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, tstrerror(TAOS_SYSTEM_ERROR(errno)),
|
||||
pTmq->groupId);
|
||||
tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId,
|
||||
tstrerror(TAOS_SYSTEM_ERROR(errno)), pTmq->groupId);
|
||||
SET_ERROR_MSG_TMQ("init t_sem failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
@ -1371,7 +1376,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
SName name = {0};
|
||||
code = tNameSetDbName(&name, tmq->pTscObj->acctId, topic, strlen(topic));
|
||||
if (code) {
|
||||
tscError("consumer:0x%" PRIx64 " cgroup:%s, failed to set topic name, code:%d", tmq->consumerId, tmq->groupId, code);
|
||||
tscError("consumer:0x%" PRIx64 " cgroup:%s, failed to set topic name, code:%d", tmq->consumerId, tmq->groupId,
|
||||
code);
|
||||
goto FAIL;
|
||||
}
|
||||
char* topicFName = taosMemoryCalloc(1, TSDB_TOPIC_FNAME_LEN);
|
||||
|
@ -1382,7 +1388,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
|
||||
code = tNameExtractFullName(&name, topicFName);
|
||||
if (code) {
|
||||
tscError("consumer:0x%" PRIx64 " cgroup:%s, failed to extract topic name, code:%d", tmq->consumerId, tmq->groupId, code);
|
||||
tscError("consumer:0x%" PRIx64 " cgroup:%s, failed to extract topic name, code:%d", tmq->consumerId, tmq->groupId,
|
||||
code);
|
||||
taosMemoryFree(topicFName);
|
||||
goto FAIL;
|
||||
}
|
||||
|
@ -1459,7 +1466,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
}
|
||||
|
||||
tmq->epTimer = taosTmrStart(tmqAssignAskEpTask, DEFAULT_ASKEP_INTERVAL, (void*)(tmq->refId), tmqMgmt.timer);
|
||||
tmq->commitTimer =taosTmrStart(tmqAssignDelayedCommitTask, tmq->autoCommitInterval, (void*)(tmq->refId), tmqMgmt.timer);
|
||||
tmq->commitTimer =
|
||||
taosTmrStart(tmqAssignDelayedCommitTask, tmq->autoCommitInterval, (void*)(tmq->refId), tmqMgmt.timer);
|
||||
if (tmq->epTimer == NULL || tmq->commitTimer == NULL) {
|
||||
code = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
goto FAIL;
|
||||
|
@ -1562,7 +1570,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if (msgEpoch < clientEpoch) {
|
||||
// do not write into queue since updating epoch reset
|
||||
tscWarn("consumer:0x%" PRIx64
|
||||
" msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, reqId:0x%" PRIx64,
|
||||
" msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, QID:0x%" PRIx64,
|
||||
tmq->consumerId, vgId, msgEpoch, clientEpoch, requestId);
|
||||
code = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
goto END;
|
||||
|
@ -1594,7 +1602,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.common.rspOffset);
|
||||
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
||||
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, QID:0x%" PRIx64,
|
||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.common.reqOffset.version, buf, rspType, requestId);
|
||||
} else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||
SDecoder decoder = {0};
|
||||
|
@ -1626,23 +1634,24 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
tDecoderClear(&decoder);
|
||||
(void)memcpy(&pRspWrapper->batchMetaRsp, pMsg->pData, sizeof(SMqRspHead));
|
||||
tscDebug("consumer:0x%" PRIx64 " recv poll batchmeta rsp, vgId:%d, reqId:0x%" PRIx64, tmq->consumerId, vgId,requestId);
|
||||
tscDebug("consumer:0x%" PRIx64 " recv poll batchmeta rsp, vgId:%d, QID:0x%" PRIx64, tmq->consumerId, vgId,
|
||||
requestId);
|
||||
} else { // invalid rspType
|
||||
tscError("consumer:0x%" PRIx64 " invalid rsp msg received, type:%d ignored", tmq->consumerId, rspType);
|
||||
}
|
||||
|
||||
END:
|
||||
if (pRspWrapper){
|
||||
if (pRspWrapper) {
|
||||
pRspWrapper->code = code;
|
||||
pRspWrapper->vgId = vgId;
|
||||
(void)strcpy(pRspWrapper->topicName, pParam->topicName);
|
||||
code = taosWriteQitem(tmq->mqueue, pRspWrapper);
|
||||
if(code != 0){
|
||||
if (code != 0) {
|
||||
tscError("consumer:0x%" PRIx64 " put poll res into mqueue failed, code:%d", tmq->consumerId, code);
|
||||
}
|
||||
}
|
||||
int32_t total = taosQueueItemSize(tmq->mqueue);
|
||||
tscDebug("consumer:0x%" PRIx64 " put poll res into mqueue, type:%d, vgId:%d, total in queue:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("consumer:0x%" PRIx64 " put poll res into mqueue, type:%d, vgId:%d, total in queue:%d, QID:0x%" PRIx64,
|
||||
tmq ? tmq->consumerId : 0, rspType, vgId, total, requestId);
|
||||
|
||||
if (tmq) (void)tsem2_post(&tmq->rspSem);
|
||||
|
@ -1681,7 +1690,7 @@ static void initClientTopicFromRsp(SMqClientTopic* pTopic, SMqSubTopicEp* pTopic
|
|||
}
|
||||
for (int32_t j = 0; j < vgNumGet; j++) {
|
||||
SMqSubVgEp* pVgEp = taosArrayGet(pTopicEp->vgs, j);
|
||||
if (pVgEp == NULL){
|
||||
if (pVgEp == NULL) {
|
||||
continue;
|
||||
}
|
||||
(void)sprintf(vgKey, "%s:%d", pTopic->topicName, pVgEp->vgId);
|
||||
|
@ -1717,7 +1726,7 @@ static void initClientTopicFromRsp(SMqClientTopic* pTopic, SMqSubTopicEp* pTopic
|
|||
clientVg.offsetInfo.committedOffset = offsetNew;
|
||||
clientVg.offsetInfo.beginOffset = offsetNew;
|
||||
}
|
||||
if (taosArrayPush(pTopic->vgs, &clientVg) == NULL){
|
||||
if (taosArrayPush(pTopic->vgs, &clientVg) == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 ", failed to push vg:%d into topic:%s", tmq->consumerId, pVgEp->vgId,
|
||||
pTopic->topicName);
|
||||
freeClientVg(&clientVg);
|
||||
|
@ -1778,7 +1787,7 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
|
|||
.commitOffset = pVgCur->offsetInfo.committedOffset,
|
||||
.numOfRows = pVgCur->numOfRows,
|
||||
.vgStatus = pVgCur->vgStatus};
|
||||
if(taosHashPut(pVgOffsetHashMap, vgKey, strlen(vgKey), &info, sizeof(SVgroupSaveInfo)) != 0){
|
||||
if (taosHashPut(pVgOffsetHashMap, vgKey, strlen(vgKey), &info, sizeof(SVgroupSaveInfo)) != 0) {
|
||||
tscError("consumer:0x%" PRIx64 ", failed to put vg:%d into hashmap", tmq->consumerId, pVgCur->vgId);
|
||||
}
|
||||
}
|
||||
|
@ -1792,7 +1801,7 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
|
|||
continue;
|
||||
}
|
||||
initClientTopicFromRsp(&topic, pTopicEp, pVgOffsetHashMap, tmq);
|
||||
if(taosArrayPush(newTopics, &topic) == NULL){
|
||||
if (taosArrayPush(newTopics, &topic) == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 ", failed to push topic:%s into new topics", tmq->consumerId, topic.topicName);
|
||||
freeClientTopic(&topic);
|
||||
}
|
||||
|
@ -1927,7 +1936,7 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
if (!pDataRsp->withSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||
pDataRsp->withSchema = true;
|
||||
pDataRsp->blockSchema = taosArrayInit(pDataRsp->blockNum, sizeof(void*));
|
||||
if (pDataRsp->blockSchema == NULL){
|
||||
if (pDataRsp->blockSchema == NULL) {
|
||||
tscError("failed to allocate memory for blockSchema");
|
||||
return;
|
||||
}
|
||||
|
@ -1946,7 +1955,7 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
if (needTransformSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||
SSchemaWrapper* schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema);
|
||||
if (schema) {
|
||||
if (taosArrayPush(pDataRsp->blockSchema, &schema) == NULL){
|
||||
if (taosArrayPush(pDataRsp->blockSchema, &schema) == NULL) {
|
||||
tscError("failed to push schema into blockSchema");
|
||||
continue;
|
||||
}
|
||||
|
@ -1955,7 +1964,8 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObj** ppRspObj) {
|
||||
int32_t tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows,
|
||||
SMqRspObj** ppRspObj) {
|
||||
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
||||
if (pRspObj == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1967,7 +1977,8 @@ int32_t tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, in
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqTaosxRspObj** ppRspObj) {
|
||||
int32_t tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows,
|
||||
SMqTaosxRspObj** ppRspObj) {
|
||||
SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj));
|
||||
if (pRspObj == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -2038,7 +2049,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
|||
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->offsetInfo.endOffset);
|
||||
code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
||||
tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
||||
tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s, QID:0x%" PRIx64,
|
||||
pTmq->consumerId, pTopic->topicName, pVg->vgId, code, pTmq->epoch, offsetFormatBuf, req.reqId);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
|
@ -2064,7 +2075,7 @@ static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
|||
|
||||
for (int i = 0; i < numOfTopics; i++) {
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
if (pTopic == NULL){
|
||||
if (pTopic == NULL) {
|
||||
continue;
|
||||
}
|
||||
int32_t numOfVg = taosArrayGetSize(pTopic->vgs);
|
||||
|
@ -2211,7 +2222,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pDataRsp->rspOffset);
|
||||
if (pDataRsp->blockNum == 0) {
|
||||
tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d, offset:%s, vg total:%" PRId64
|
||||
", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
", total:%" PRId64 ", QID:0x%" PRIx64,
|
||||
tmq->consumerId, pVg->vgId, buf, pVg->numOfRows, tmq->totalRows, pollRspWrapper->reqId);
|
||||
pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
||||
tmqFreeRspWrapper(pRspWrapper);
|
||||
|
@ -2228,13 +2239,13 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
pVg->blockSleepForReplay = pRsp->rsp.sleepTime;
|
||||
if (pVg->blockSleepForReplay > 0) {
|
||||
if (taosTmrStart(tmqReplayTask, pVg->blockSleepForReplay, (void*)(tmq->refId), tmqMgmt.timer) == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 " failed to start replay timer, vgId:%d, sleep:%"PRId64, tmq->consumerId,
|
||||
pVg->vgId, pVg->blockSleepForReplay);
|
||||
tscError("consumer:0x%" PRIx64 " failed to start replay timer, vgId:%d, sleep:%" PRId64,
|
||||
tmq->consumerId, pVg->vgId, pVg->blockSleepForReplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
tscDebug("consumer:0x%" PRIx64 " process poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", QID:0x%" PRIx64,
|
||||
tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows, tmq->totalRows,
|
||||
pollRspWrapper->reqId);
|
||||
taosFreeQitem(pRspWrapper);
|
||||
|
@ -2310,7 +2321,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
pollRspWrapper->batchMetaRsp.head.walsver, pollRspWrapper->batchMetaRsp.head.walever,
|
||||
tmq->consumerId, true);
|
||||
SMqBatchMetaRspObj* pRsp = NULL;
|
||||
(void)tmqBuildBatchMetaRspFromWrapper(pollRspWrapper, &pRsp) ;
|
||||
(void)tmqBuildBatchMetaRspFromWrapper(pollRspWrapper, &pRsp);
|
||||
taosFreeQitem(pRspWrapper);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return pRsp;
|
||||
|
@ -2345,7 +2356,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
tmq->consumerId, pDataRsp->blockNum != 0);
|
||||
|
||||
if (pDataRsp->blockNum == 0) {
|
||||
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", QID:0x%" PRIx64,
|
||||
tmq->consumerId, pVg->vgId, pVg->numOfRows, pollRspWrapper->reqId);
|
||||
pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
||||
tmqFreeRspWrapper(pRspWrapper);
|
||||
|
@ -2359,7 +2370,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
// build rsp
|
||||
int64_t numOfRows = 0;
|
||||
SMqTaosxRspObj* pRsp = NULL;
|
||||
if (tmqBuildTaosxRspFromWrapper(pollRspWrapper, pVg, &numOfRows, &pRsp) !=0 ) {
|
||||
if (tmqBuildTaosxRspFromWrapper(pollRspWrapper, pVg, &numOfRows, &pRsp) != 0) {
|
||||
tscError("consumer:0x%" PRIx64 " build taosx rsp failed, vgId:%d", tmq->consumerId, pVg->vgId);
|
||||
}
|
||||
tmq->totalRows += numOfRows;
|
||||
|
@ -2367,7 +2378,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset);
|
||||
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", QID:0x%" PRIx64,
|
||||
tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows, tmq->totalRows,
|
||||
pollRspWrapper->reqId);
|
||||
|
||||
|
@ -2479,7 +2490,7 @@ static void displayConsumeStatistics(tmq_t* pTmq) {
|
|||
tscDebug("consumer:0x%" PRIx64 " rows dist end", pTmq->consumerId);
|
||||
}
|
||||
|
||||
static int32_t innerClose(tmq_t* tmq){
|
||||
static int32_t innerClose(tmq_t* tmq) {
|
||||
if (tmq->status != TMQ_CONSUMER_STATUS__READY) {
|
||||
tscInfo("consumer:0x%" PRIx64 " not in ready state, unsubscribe it directly", tmq->consumerId);
|
||||
return 0;
|
||||
|
@ -2493,7 +2504,7 @@ static int32_t innerClose(tmq_t* tmq){
|
|||
tmqSendHbReq((void*)(tmq->refId), NULL);
|
||||
|
||||
tmq_list_t* lst = tmq_list_new();
|
||||
if (lst == NULL){
|
||||
if (lst == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t code = tmq_subscribe(tmq, lst);
|
||||
|
@ -2507,7 +2518,7 @@ int32_t tmq_unsubscribe(tmq_t* tmq) {
|
|||
int32_t code = 0;
|
||||
if (atomic_load_8(&tmq->status) != TMQ_CONSUMER_STATUS__CLOSED) {
|
||||
code = innerClose(tmq);
|
||||
if(code == 0){
|
||||
if (code == 0) {
|
||||
atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__CLOSED);
|
||||
}
|
||||
}
|
||||
|
@ -2522,12 +2533,12 @@ int32_t tmq_consumer_close(tmq_t* tmq) {
|
|||
int32_t code = 0;
|
||||
if (atomic_load_8(&tmq->status) != TMQ_CONSUMER_STATUS__CLOSED) {
|
||||
code = innerClose(tmq);
|
||||
if(code == 0){
|
||||
if (code == 0) {
|
||||
atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__CLOSED);
|
||||
}
|
||||
}
|
||||
|
||||
if (code == 0){
|
||||
if (code == 0) {
|
||||
(void)taosRemoveRef(tmqMgmt.rsetId, tmq->refId);
|
||||
}
|
||||
return code;
|
||||
|
@ -2570,13 +2581,13 @@ const char* tmq_get_topic_name(TAOS_RES* res) {
|
|||
return NULL;
|
||||
}
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res) || TD_RES_TMQ_BATCH_META(res)) {
|
||||
char *tmp = strchr(((SMqRspObjCommon*)res)->topic, '.');
|
||||
char* tmp = strchr(((SMqRspObjCommon*)res)->topic, '.');
|
||||
if (tmp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return tmp + 1;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
char *tmp = strchr(((SMqMetaRspObj*)res)->topic, '.');
|
||||
char* tmp = strchr(((SMqMetaRspObj*)res)->topic, '.');
|
||||
if (tmp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2592,13 +2603,13 @@ const char* tmq_get_db_name(TAOS_RES* res) {
|
|||
}
|
||||
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res) || TD_RES_TMQ_BATCH_META(res)) {
|
||||
char *tmp = strchr(((SMqRspObjCommon*)res)->db, '.');
|
||||
char* tmp = strchr(((SMqRspObjCommon*)res)->db, '.');
|
||||
if (tmp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return tmp + 1;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
char *tmp = strchr(((SMqMetaRspObj*)res)->db, '.');
|
||||
char* tmp = strchr(((SMqMetaRspObj*)res)->db, '.');
|
||||
if (tmp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2698,7 +2709,7 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
|
|||
int32_t code = 0;
|
||||
|
||||
SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo));
|
||||
if(pInfo == NULL) {
|
||||
if (pInfo == NULL) {
|
||||
tscError("failed to allocate memory for sync commit");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -2865,7 +2876,7 @@ int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d", tmq->consumerId, head->epoch, epoch);
|
||||
if (pParam->sync) {
|
||||
SMqAskEpRsp rsp = {0};
|
||||
if(tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp) != NULL){
|
||||
if (tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp) != NULL) {
|
||||
(void)doUpdateLocalEp(tmq, head->epoch, &rsp);
|
||||
}
|
||||
tDeleteSMqAskEpRsp(&rsp);
|
||||
|
@ -2879,10 +2890,10 @@ int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
pWrapper->tmqRspType = TMQ_MSG_TYPE__EP_RSP;
|
||||
pWrapper->epoch = head->epoch;
|
||||
(void)memcpy(&pWrapper->msg, pMsg->pData, sizeof(SMqRspHead));
|
||||
if (tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pWrapper->msg) == NULL){
|
||||
if (tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pWrapper->msg) == NULL) {
|
||||
tmqFreeRspWrapper((SMqRspWrapper*)pWrapper);
|
||||
taosFreeQitem(pWrapper);
|
||||
}else{
|
||||
} else {
|
||||
(void)taosWriteQitem(tmq->mqueue, pWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -2980,7 +2991,7 @@ int32_t askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) {
|
|||
sendInfo->msgType = TDMT_MND_TMQ_ASK_EP;
|
||||
|
||||
SEpSet epSet = getEpSet_s(&pTmq->pTscObj->pAppInfo->mgmtEp);
|
||||
tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, reqId:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId);
|
||||
tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, QID:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId);
|
||||
return asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo);
|
||||
}
|
||||
|
||||
|
@ -3023,7 +3034,7 @@ int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pRes
|
|||
if (common->withSchema) {
|
||||
doFreeReqResultInfo(&pRspObj->resInfo);
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(common->blockSchema, pRspObj->resIter);
|
||||
if (pSW){
|
||||
if (pSW) {
|
||||
TAOS_CHECK_RETURN(setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols));
|
||||
}
|
||||
}
|
||||
|
@ -3040,9 +3051,9 @@ int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pRes
|
|||
pRspObj->resInfo.precision = precision;
|
||||
|
||||
pRspObj->resInfo.totalRows += pRspObj->resInfo.numOfRows;
|
||||
int32_t code = setResultDataPtr(&pRspObj->resInfo, pRspObj->resInfo.fields, pRspObj->resInfo.numOfCols, pRspObj->resInfo.numOfRows,
|
||||
convertUcs4);
|
||||
if (code != 0){
|
||||
int32_t code = setResultDataPtr(&pRspObj->resInfo, pRspObj->resInfo.fields, pRspObj->resInfo.numOfCols,
|
||||
pRspObj->resInfo.numOfRows, convertUcs4);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
*pResInfo = &pRspObj->resInfo;
|
||||
|
@ -3070,7 +3081,7 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||
code = tDecodeMqDataRsp(&decoder, &rsp);
|
||||
tDecoderClear(&decoder);
|
||||
if (code != 0){
|
||||
if (code != 0) {
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
@ -3081,7 +3092,7 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
.vgId = pParam->vgId};
|
||||
|
||||
(void)taosThreadMutexLock(&pCommon->mutex);
|
||||
if(taosArrayPush(pCommon->pList, &assignment) == NULL){
|
||||
if (taosArrayPush(pCommon->pList, &assignment) == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 " failed to push the wal info from vgId:%d for topic:%s", pCommon->consumerId,
|
||||
pParam->vgId, pCommon->pTopicName);
|
||||
code = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
|
@ -3192,7 +3203,7 @@ int64_t getCommittedFromServer(tmq_t* tmq, char* tname, int32_t vgId, SEpSet* ep
|
|||
taosMemoryFree(sendInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (tsem2_init(&pParam->sem, 0, 0) != 0){
|
||||
if (tsem2_init(&pParam->sem, 0, 0) != 0) {
|
||||
taosMemoryFree(buf);
|
||||
taosMemoryFree(sendInfo);
|
||||
taosMemoryFree(pParam);
|
||||
|
@ -3366,7 +3377,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
*numOfAssignment = taosArrayGetSize(pTopic->vgs);
|
||||
for (int32_t j = 0; j < (*numOfAssignment); ++j) {
|
||||
SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, j);
|
||||
if (pClientVg == NULL){
|
||||
if (pClientVg == NULL) {
|
||||
continue;
|
||||
}
|
||||
int32_t type = pClientVg->offsetInfo.beginOffset.type;
|
||||
|
@ -3389,7 +3400,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
for (int32_t j = 0; j < (*numOfAssignment); ++j) {
|
||||
SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, j);
|
||||
if (pClientVg == NULL){
|
||||
if (pClientVg == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (pClientVg->offsetInfo.beginOffset.type != TMQ_OFFSET__LOG) {
|
||||
|
@ -3418,7 +3429,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
if (tsem2_init(&pCommon->rsp, 0, 0) != 0){
|
||||
if (tsem2_init(&pCommon->rsp, 0, 0) != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3428,7 +3439,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
for (int32_t i = 0; i < (*numOfAssignment); ++i) {
|
||||
SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, i);
|
||||
if (pClientVg == NULL){
|
||||
if (pClientVg == NULL) {
|
||||
continue;
|
||||
}
|
||||
SMqVgWalInfoParam* pParam = taosMemoryMalloc(sizeof(SMqVgWalInfoParam));
|
||||
|
@ -3487,8 +3498,8 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pClientVg->offsetInfo.beginOffset);
|
||||
|
||||
tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
||||
tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
||||
tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s, QID:0x%" PRIx64, tmq->consumerId,
|
||||
pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
||||
code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pClientVg->epSet, &transporterId, sendInfo);
|
||||
if (code != 0) {
|
||||
goto end;
|
||||
|
@ -3512,7 +3523,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pTopic->vgs); ++i) {
|
||||
SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, i);
|
||||
if (pClientVg == NULL){
|
||||
if (pClientVg == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (pClientVg->vgId != p->vgId) {
|
||||
|
@ -3639,7 +3650,7 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_
|
|||
taosMemoryFree(sendInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (tsem2_init(&pParam->sem, 0, 0) != 0){
|
||||
if (tsem2_init(&pParam->sem, 0, 0) != 0) {
|
||||
taosMemoryFree(msg);
|
||||
taosMemoryFree(sendInfo);
|
||||
taosMemoryFree(pParam);
|
||||
|
|
|
@ -1670,6 +1670,8 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
|
|||
int32_t code = 0;
|
||||
|
||||
dst->info = src->info;
|
||||
dst->info.pks[0].pData = NULL;
|
||||
dst->info.pks[1].pData = NULL;
|
||||
dst->info.rows = 0;
|
||||
dst->info.capacity = 0;
|
||||
|
||||
|
@ -1707,6 +1709,8 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
|
|||
|
||||
uint32_t cap = dst->info.capacity;
|
||||
dst->info = src->info;
|
||||
dst->info.pks[0].pData = NULL;
|
||||
dst->info.pks[1].pData = NULL;
|
||||
dst->info.capacity = cap;
|
||||
return code;
|
||||
}
|
||||
|
@ -1737,6 +1741,8 @@ int32_t copyDataBlock(SSDataBlock* pDst, const SSDataBlock* pSrc) {
|
|||
uint32_t cap = pDst->info.capacity;
|
||||
|
||||
pDst->info = pSrc->info;
|
||||
pDst->info.pks[0].pData = NULL;
|
||||
pDst->info.pks[1].pData = NULL;
|
||||
code = copyPkVal(&pDst->info, &pSrc->info);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
|
@ -1854,6 +1860,8 @@ int32_t blockCopyOneRow(const SSDataBlock* pDataBlock, int32_t rowIdx, SSDataBlo
|
|||
}
|
||||
|
||||
pBlock->info = pDataBlock->info;
|
||||
pBlock->info.pks[0].pData = NULL;
|
||||
pBlock->info.pks[1].pData = NULL;
|
||||
pBlock->info.rows = 0;
|
||||
pBlock->info.capacity = 0;
|
||||
|
||||
|
@ -1916,20 +1924,20 @@ int32_t copyPkVal(SDataBlockInfo* pDst, const SDataBlockInfo* pSrc) {
|
|||
// prepare the pk buffer if needed
|
||||
SValue* p = &pDst->pks[0];
|
||||
|
||||
p->type = pDst->pks[0].type;
|
||||
p->pData = taosMemoryCalloc(1, pDst->pks[0].nData);
|
||||
p->type = pSrc->pks[0].type;
|
||||
p->pData = taosMemoryCalloc(1, pSrc->pks[0].nData);
|
||||
QUERY_CHECK_NULL(p->pData, code, lino, _end, terrno);
|
||||
|
||||
p->nData = pDst->pks[0].nData;
|
||||
memcpy(p->pData, pDst->pks[0].pData, p->nData);
|
||||
p->nData = pSrc->pks[0].nData;
|
||||
memcpy(p->pData, pSrc->pks[0].pData, p->nData);
|
||||
|
||||
p = &pDst->pks[1];
|
||||
p->type = pDst->pks[1].type;
|
||||
p->pData = taosMemoryCalloc(1, pDst->pks[1].nData);
|
||||
p->type = pSrc->pks[1].type;
|
||||
p->pData = taosMemoryCalloc(1, pSrc->pks[1].nData);
|
||||
QUERY_CHECK_NULL(p->pData, code, lino, _end, terrno);
|
||||
|
||||
p->nData = pDst->pks[1].nData;
|
||||
memcpy(p->pData, pDst->pks[1].pData, p->nData);
|
||||
p->nData = pSrc->pks[1].nData;
|
||||
memcpy(p->pData, pSrc->pks[1].pData, p->nData);
|
||||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1951,6 +1959,8 @@ int32_t createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData, SSDataB
|
|||
}
|
||||
|
||||
pDstBlock->info = pDataBlock->info;
|
||||
pDstBlock->info.pks[0].pData = NULL;
|
||||
pDstBlock->info.pks[1].pData = NULL;
|
||||
|
||||
pDstBlock->info.rows = 0;
|
||||
pDstBlock->info.capacity = 0;
|
||||
|
|
|
@ -83,12 +83,12 @@ extern "C" {
|
|||
}\
|
||||
}
|
||||
|
||||
#define dGFatal(param, ...) {if (dDebugFlag & DEBUG_FATAL) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define dGError(param, ...) {if (dDebugFlag & DEBUG_ERROR) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define dGWarn(param, ...) {if (dDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define dGInfo(param, ...) {if (dDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define dGDebug(param, ...) {if (dDebugFlag & DEBUG_DEBUG) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define dGTrace(param, ...) {if (dDebugFlag & DEBUG_TRACE) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define dGFatal(param, ...) {if (dDebugFlag & DEBUG_FATAL) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define dGError(param, ...) {if (dDebugFlag & DEBUG_ERROR) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define dGWarn(param, ...) {if (dDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define dGInfo(param, ...) {if (dDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define dGDebug(param, ...) {if (dDebugFlag & DEBUG_DEBUG) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define dGTrace(param, ...) {if (dDebugFlag & DEBUG_TRACE) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
@ -208,7 +208,7 @@ void dmGetMonitorSystemInfo(SMonSysInfo *pInfo);
|
|||
int32_t dmReadFile(const char *path, const char *name, bool *pDeployed);
|
||||
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
|
||||
int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile);
|
||||
//int32_t dmCheckRunningWrapper(const char *dataDir, TdFilePtr *pFile);
|
||||
// int32_t dmCheckRunningWrapper(const char *dataDir, TdFilePtr *pFile);
|
||||
|
||||
// dmodule.c
|
||||
int32_t dmInitDndInfo(SDnodeData *pData);
|
||||
|
|
|
@ -41,12 +41,12 @@ extern "C" {
|
|||
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
|
||||
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
|
||||
|
||||
#define mGFatal(param, ...) { if (mDebugFlag & DEBUG_FATAL){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define mGError(param, ...) { if (mDebugFlag & DEBUG_ERROR){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define mGWarn(param, ...) { if (mDebugFlag & DEBUG_WARN){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define mGInfo(param, ...) { if (mDebugFlag & DEBUG_INFO){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define mGDebug(param, ...) { if (mDebugFlag & DEBUG_DEBUG){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define mGTrace(param, ...) { if (mDebugFlag & DEBUG_TRACE){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);}}
|
||||
#define mGFatal(param, ...) { if (mDebugFlag & DEBUG_FATAL){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define mGError(param, ...) { if (mDebugFlag & DEBUG_ERROR){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define mGWarn(param, ...) { if (mDebugFlag & DEBUG_WARN){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define mGInfo(param, ...) { if (mDebugFlag & DEBUG_INFO){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define mGDebug(param, ...) { if (mDebugFlag & DEBUG_DEBUG){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
#define mGTrace(param, ...) { if (mDebugFlag & DEBUG_TRACE){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", QID:%s", __VA_ARGS__, buf);}}
|
||||
// clang-format on
|
||||
|
||||
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
|
||||
typedef int32_t (*MndMsgFp)(SRpcMsg *pMsg);
|
||||
typedef int32_t (*MndMsgFpExt)(SRpcMsg *pMsg, SQueueInfo* pInfo);
|
||||
typedef int32_t (*MndMsgFpExt)(SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||
typedef int32_t (*MndInitFp)(SMnode *pMnode);
|
||||
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
||||
typedef int32_t (*ShowRetrieveFp)(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
|
|
|
@ -1774,7 +1774,7 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
|
|||
int32_t nCols) {
|
||||
// if (pColCmpr == NULL || colName == NULL) return -1;
|
||||
|
||||
ASSERT(taosArrayGetSize(pField) == nCols);
|
||||
if (taosArrayGetSize(pField) != nCols) return TSDB_CODE_FAILED;
|
||||
TAOS_FIELD *p = taosArrayGet(pField, 0);
|
||||
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -52,6 +52,8 @@ static void sdbResetData(SSdb *pSdb) {
|
|||
SHashObj *hash = pSdb->hashObjs[i];
|
||||
if (hash == NULL) continue;
|
||||
|
||||
sdbWriteLock(pSdb, i);
|
||||
|
||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||
while (ppRow != NULL) {
|
||||
SSdbRow *pRow = *ppRow;
|
||||
|
@ -60,15 +62,13 @@ static void sdbResetData(SSdb *pSdb) {
|
|||
sdbFreeRow(pSdb, pRow, true);
|
||||
ppRow = taosHashIterate(hash, ppRow);
|
||||
}
|
||||
}
|
||||
|
||||
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
||||
SHashObj *hash = pSdb->hashObjs[i];
|
||||
if (hash == NULL) continue;
|
||||
|
||||
taosHashClear(pSdb->hashObjs[i]);
|
||||
pSdb->tableVer[i] = 0;
|
||||
pSdb->maxId[i] = 0;
|
||||
|
||||
sdbUnLock(pSdb, i);
|
||||
|
||||
mInfo("sdb:%s is reset", sdbTableName(i));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ extern "C" {
|
|||
#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
|
||||
|
||||
#define vGTrace(param, ...) do { if (vDebugFlag & DEBUG_TRACE) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGFatal(param, ...) do { if (vDebugFlag & DEBUG_FATAL) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vFatal(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGError(param, ...) do { if (vDebugFlag & DEBUG_ERROR) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vError(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGWarn(param, ...) do { if (vDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vWarn(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGInfo(param, ...) do { if (vDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vInfo(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGDebug(param, ...) do { if (vDebugFlag & DEBUG_DEBUG) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vDebug(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGTrace(param, ...) do { if (vDebugFlag & DEBUG_TRACE) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGFatal(param, ...) do { if (vDebugFlag & DEBUG_FATAL) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vFatal(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGError(param, ...) do { if (vDebugFlag & DEBUG_ERROR) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vError(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGWarn(param, ...) do { if (vDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vWarn(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGInfo(param, ...) do { if (vDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vInfo(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define vGDebug(param, ...) do { if (vDebugFlag & DEBUG_DEBUG) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vDebug(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -101,20 +101,6 @@ typedef struct SQueryNode SQueryNode;
|
|||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||
|
||||
#define VNODE_METRIC_SQL_COUNT "taosd_sql_req:count"
|
||||
|
||||
#define VNODE_METRIC_TAG_NAME_SQL_TYPE "sql_type"
|
||||
#define VNODE_METRIC_TAG_NAME_CLUSTER_ID "cluster_id"
|
||||
#define VNODE_METRIC_TAG_NAME_DNODE_ID "dnode_id"
|
||||
#define VNODE_METRIC_TAG_NAME_DNODE_EP "dnode_ep"
|
||||
#define VNODE_METRIC_TAG_NAME_VGROUP_ID "vgroup_id"
|
||||
#define VNODE_METRIC_TAG_NAME_USERNAME "username"
|
||||
#define VNODE_METRIC_TAG_NAME_RESULT "result"
|
||||
|
||||
#define VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS "inserted_rows"
|
||||
// #define VNODE_METRIC_TAG_VALUE_INSERT "insert"
|
||||
// #define VNODE_METRIC_TAG_VALUE_DELETE "delete"
|
||||
|
||||
// vnd.h
|
||||
typedef int32_t (*_query_reseek_func_t)(void* pQHandle);
|
||||
struct SQueryNode {
|
||||
|
@ -452,7 +438,6 @@ typedef struct SVMonitorObj {
|
|||
char strClusterId[TSDB_CLUSTER_ID_LEN];
|
||||
char strDnodeId[TSDB_NODE_ID_LEN];
|
||||
char strVgId[TSDB_VGROUP_ID_LEN];
|
||||
taos_counter_t* insertCounter;
|
||||
} SVMonitorObj;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -512,7 +512,6 @@ static void initCacheKey(uint64_t* buf, const SHashObj* pHashMap, uint64_t suid,
|
|||
buf[0] = (uint64_t)pHashMap;
|
||||
buf[1] = suid;
|
||||
setMD5DigestInKey(buf, key, keyLen);
|
||||
ASSERT(keyLen == sizeof(uint64_t) * 2);
|
||||
}
|
||||
|
||||
int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1,
|
||||
|
|
|
@ -673,7 +673,7 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
}
|
||||
}
|
||||
|
||||
if (ASSERTS(sver > 0, "failed to get table schema version: %d", sver)) {
|
||||
if (!(sver > 0)) {
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -1608,8 +1608,6 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t
|
|||
metaULock(pVnodeObj->pMeta);
|
||||
if (numOfTables) *numOfTables = state.ctbNum;
|
||||
if (numOfCols) *numOfCols = state.colNum;
|
||||
ASSERTS(state.colNum > 0, "vgId:%d, suid:%" PRIi64 " nCols:%d <= 0 in metaCache", TD_VID(pVnodeObj), uid,
|
||||
state.colNum);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
|||
dataRsp.common.blockNum = 0;
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset);
|
||||
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf,
|
||||
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, QID:0x%" PRIx64, req.consumerId, vgId, buf,
|
||||
req.reqId);
|
||||
|
||||
code = tqSendDataRsp(pHandle, pHandle->msg, &req, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
|
@ -193,7 +193,7 @@ int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq*
|
|||
(void)tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset);
|
||||
(void)tFormatOffset(buf2, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->rspOffset);
|
||||
|
||||
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64,
|
||||
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, QID:0x%" PRIx64,
|
||||
vgId, pReq->consumerId, pReq->epoch, ((SMqDataRspCommon*)pRsp)->blockNum, buf1, buf2, pReq->reqId);
|
||||
|
||||
return tqDoSendDataRsp(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type, sver, ever);
|
||||
|
@ -421,7 +421,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &reqOffset);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, recv poll req vgId:%d, req:%s, reqId:0x%" PRIx64,
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, recv poll req vgId:%d, req:%s, QID:0x%" PRIx64,
|
||||
consumerId, req.epoch, pHandle->subKey, vgId, buf, req.reqId);
|
||||
|
||||
code = tqExtractDataForMq(pTq, pHandle, &req, pMsg);
|
||||
|
@ -1216,8 +1216,8 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
}
|
||||
|
||||
if (req.mndTrigger) {
|
||||
tqInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64 ", transId:%d, ", pTask->id.idStr,
|
||||
vgId, pTask->info.taskLevel, req.checkpointId, req.transId);
|
||||
tqInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64 ", transId:%d, ",
|
||||
pTask->id.idStr, vgId, pTask->info.taskLevel, req.checkpointId, req.transId);
|
||||
} else {
|
||||
const char* pPrevStatus = streamTaskGetStatusStr(streamTaskGetPrevStatus(pTask));
|
||||
tqInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64
|
||||
|
|
|
@ -74,7 +74,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
pCreateReq = req.pReqs + iReq;
|
||||
if (pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid) {
|
||||
reqNew.nReqs++;
|
||||
if (taosArrayPush(reqNew.pArray, pCreateReq) == NULL){
|
||||
if (taosArrayPush(reqNew.pArray, pCreateReq) == NULL) {
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
tDeleteSVCreateTbBatchReq(&req);
|
||||
goto end;
|
||||
|
@ -155,7 +155,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
pDropReq = req.pReqs + iReq;
|
||||
if (pDropReq->suid == tbSuid) {
|
||||
reqNew.nReqs++;
|
||||
if (taosArrayPush(reqNew.pArray, pDropReq) == NULL){
|
||||
if (taosArrayPush(reqNew.pArray, pDropReq) == NULL) {
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
goto end;
|
||||
}
|
||||
|
@ -214,12 +214,12 @@ int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t
|
|||
while (offset <= appliedVer) {
|
||||
if (walFetchHead(pHandle->pWalReader, offset) < 0) {
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", (epoch %d) vgId:%d offset %" PRId64
|
||||
", no more log to return, reqId:0x%" PRIx64 " 0x%" PRIx64,
|
||||
", no more log to return, QID:0x%" PRIx64 " 0x%" PRIx64,
|
||||
pHandle->consumerId, pHandle->epoch, vgId, offset, reqId, id);
|
||||
goto END;
|
||||
}
|
||||
|
||||
tqDebug("vgId:%d, consumer:0x%" PRIx64 " taosx get msg ver %" PRId64 ", type: %s, reqId:0x%" PRIx64 " 0x%" PRIx64,
|
||||
tqDebug("vgId:%d, consumer:0x%" PRIx64 " taosx get msg ver %" PRId64 ", type: %s, QID:0x%" PRIx64 " 0x%" PRIx64,
|
||||
vgId, pHandle->consumerId, offset, TMSG_INFO(pHandle->pWalReader->pHead->head.msgType), reqId, id);
|
||||
|
||||
if (pHandle->pWalReader->pHead->head.msgType == TDMT_VND_SUBMIT) {
|
||||
|
@ -261,10 +261,10 @@ END:
|
|||
|
||||
bool tqGetTablePrimaryKey(STqReader* pReader) { return pReader->hasPrimaryKey; }
|
||||
|
||||
void tqSetTablePrimaryKey(STqReader* pReader, int64_t uid){
|
||||
void tqSetTablePrimaryKey(STqReader* pReader, int64_t uid) {
|
||||
bool ret = false;
|
||||
SSchemaWrapper *schema = metaGetTableSchema(pReader->pVnodeMeta, uid, -1, 1);
|
||||
if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY){
|
||||
SSchemaWrapper* schema = metaGetTableSchema(pReader->pVnodeMeta, uid, -1, 1);
|
||||
if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) {
|
||||
ret = true;
|
||||
}
|
||||
tDeleteSchemaWrapper(schema);
|
||||
|
@ -487,7 +487,7 @@ bool tqNextBlockImpl(STqReader* pReader, const char* idstr) {
|
|||
(pReader->nextBlk + 1), numOfBlocks, idstr);
|
||||
|
||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||
if (pSubmitTbData == NULL){
|
||||
if (pSubmitTbData == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
|
@ -720,7 +720,8 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
SColData* pCol = taosArrayGet(pCols, sourceIdx);
|
||||
TSDB_CHECK_NULL(pCol, code, line, END, terrno);
|
||||
SColVal colVal = {0};
|
||||
tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual, sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId);
|
||||
tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual,
|
||||
sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId);
|
||||
if (pCol->cid < pColData->info.colId) {
|
||||
sourceIdx++;
|
||||
} else if (pCol->cid == pColData->info.colId) {
|
||||
|
@ -770,11 +771,10 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
END:
|
||||
if (code != 0){
|
||||
if (code != 0) {
|
||||
tqError("tqRetrieveDataBlock failed, line:%d, code:%d", line, code);
|
||||
}
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
|
@ -782,29 +782,29 @@ END:
|
|||
}
|
||||
|
||||
#define PROCESS_VAL \
|
||||
if (curRow == 0) {\
|
||||
assigned[j] = !COL_VAL_IS_NONE(&colVal);\
|
||||
buildNew = true;\
|
||||
} else {\
|
||||
bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal);\
|
||||
if (currentRowAssigned != assigned[j]) {\
|
||||
assigned[j] = currentRowAssigned;\
|
||||
buildNew = true;\
|
||||
}\
|
||||
if (curRow == 0) { \
|
||||
assigned[j] = !COL_VAL_IS_NONE(&colVal); \
|
||||
buildNew = true; \
|
||||
} else { \
|
||||
bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal); \
|
||||
if (currentRowAssigned != assigned[j]) { \
|
||||
assigned[j] = currentRowAssigned; \
|
||||
buildNew = true; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_DATA \
|
||||
if (colVal.cid < pColData->info.colId) {\
|
||||
sourceIdx++;\
|
||||
} else if (colVal.cid == pColData->info.colId) {\
|
||||
TQ_ERR_GO_TO_END(doSetVal(pColData, curRow - lastRow, &colVal));\
|
||||
sourceIdx++;\
|
||||
targetIdx++;\
|
||||
if (colVal.cid < pColData->info.colId) { \
|
||||
sourceIdx++; \
|
||||
} else if (colVal.cid == pColData->info.colId) { \
|
||||
TQ_ERR_GO_TO_END(doSetVal(pColData, curRow - lastRow, &colVal)); \
|
||||
sourceIdx++; \
|
||||
targetIdx++; \
|
||||
}
|
||||
|
||||
static int32_t processBuildNew(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks,
|
||||
SArray* schemas, SSchemaWrapper* pSchemaWrapper, char* assigned,
|
||||
int32_t numOfRows, int32_t curRow, int32_t* lastRow){
|
||||
static int32_t processBuildNew(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas,
|
||||
SSchemaWrapper* pSchemaWrapper, char* assigned, int32_t numOfRows, int32_t curRow,
|
||||
int32_t* lastRow) {
|
||||
int32_t code = 0;
|
||||
SSchemaWrapper* pSW = NULL;
|
||||
SSDataBlock* block = NULL;
|
||||
|
@ -839,7 +839,7 @@ END:
|
|||
taosMemoryFree(block);
|
||||
return code;
|
||||
}
|
||||
static int32_t tqProcessColData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas){
|
||||
static int32_t tqProcessColData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas) {
|
||||
int32_t code = 0;
|
||||
int32_t curRow = 0;
|
||||
int32_t lastRow = 0;
|
||||
|
@ -865,7 +865,8 @@ static int32_t tqProcessColData(STqReader* pReader, SSubmitTbData* pSubmitTbData
|
|||
}
|
||||
|
||||
if (buildNew) {
|
||||
TQ_ERR_GO_TO_END(processBuildNew(pReader, pSubmitTbData, blocks, schemas, pSchemaWrapper, assigned, numOfRows, curRow, &lastRow));
|
||||
TQ_ERR_GO_TO_END(processBuildNew(pReader, pSubmitTbData, blocks, schemas, pSchemaWrapper, assigned, numOfRows,
|
||||
curRow, &lastRow));
|
||||
}
|
||||
|
||||
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
||||
|
@ -897,7 +898,7 @@ END:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tqProcessRowData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas){
|
||||
int32_t tqProcessRowData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas) {
|
||||
int32_t code = 0;
|
||||
STSchema* pTSchema = NULL;
|
||||
|
||||
|
@ -923,7 +924,8 @@ int32_t tqProcessRowData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArra
|
|||
}
|
||||
|
||||
if (buildNew) {
|
||||
TQ_ERR_GO_TO_END(processBuildNew(pReader, pSubmitTbData, blocks, schemas, pSchemaWrapper, assigned, numOfRows, curRow, &lastRow));
|
||||
TQ_ERR_GO_TO_END(processBuildNew(pReader, pSubmitTbData, blocks, schemas, pSchemaWrapper, assigned, numOfRows,
|
||||
curRow, &lastRow));
|
||||
}
|
||||
|
||||
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
||||
|
@ -958,7 +960,7 @@ int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas
|
|||
SSDataBlock* block = NULL;
|
||||
|
||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||
if(pSubmitTbData == NULL){
|
||||
if (pSubmitTbData == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
pReader->nextBlk++;
|
||||
|
@ -1039,7 +1041,7 @@ bool tqCurrentBlockConsumed(const STqReader* pReader) { return pReader->msg.msgS
|
|||
void tqReaderRemoveTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
||||
if (pKey && taosHashRemove(pReader->tbIdHash, pKey, sizeof(int64_t)) != 0){
|
||||
if (pKey && taosHashRemove(pReader->tbIdHash, pKey, sizeof(int64_t)) != 0) {
|
||||
tqError("failed to remove table uid:%" PRId64 " from hash", *pKey);
|
||||
}
|
||||
}
|
||||
|
@ -1069,7 +1071,8 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
|||
int32_t sz = taosArrayGetSize(tbUidList);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int64_t* tbUid = (int64_t*)taosArrayGet(tbUidList, i);
|
||||
if (tbUid && taosHashPut(pTqHandle->execHandle.execDb.pFilterOutTbUid, tbUid, sizeof(int64_t), NULL, 0) != 0){
|
||||
if (tbUid &&
|
||||
taosHashPut(pTqHandle->execHandle.execDb.pFilterOutTbUid, tbUid, sizeof(int64_t), NULL, 0) != 0) {
|
||||
tqError("failed to add table uid:%" PRId64 " to hash", *tbUid);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
char formatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(formatBuf, TSDB_OFFSET_LEN, pOffsetVal);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64
|
||||
", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue. reqId:0x%" PRIx64,
|
||||
", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue. QID:0x%" PRIx64,
|
||||
consumerId, pHandle->subKey, vgId, formatBuf, pRequest->reqId);
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -117,7 +117,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
||||
|
||||
code = tqInitDataRsp(&dataRsp.common, *pOffsetVal);
|
||||
if (code != 0){
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
||||
|
@ -176,7 +176,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
end : {
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.rspOffset);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%" PRIx64
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, QID:0x%" PRIx64
|
||||
" code:%d",
|
||||
consumerId, pHandle->subKey, vgId, dataRsp.common.blockNum, buf, pRequest->reqId, code);
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
|
@ -642,7 +642,7 @@ int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void*
|
|||
}
|
||||
|
||||
END:
|
||||
if (code != 0){
|
||||
if (code != 0) {
|
||||
tqError("failed to extract delete data block, line:%d code:%d", line, code);
|
||||
}
|
||||
tDecoderClear(pCoder);
|
||||
|
@ -672,7 +672,7 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b
|
|||
|
||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||
if (pId == NULL){
|
||||
if (pId == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (pId->streamId != streamId) {
|
||||
|
|
|
@ -207,7 +207,7 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
|||
updated = streamTaskUpdateEpsetInfo(pTask, req.pNodeList);
|
||||
|
||||
// send the checkpoint-source-rsp for source task to end the checkpoint trans in mnode
|
||||
(void) streamTaskSendCheckpointsourceRsp(pTask);
|
||||
(void)streamTaskSendCheckpointsourceRsp(pTask);
|
||||
streamTaskResetStatus(pTask);
|
||||
|
||||
streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, pTask->id.idStr);
|
||||
|
@ -482,8 +482,8 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe
|
|||
}
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
tqDebug("tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%" PRIx64 ") from 0x%x (vgId:%d) status %d",
|
||||
rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status);
|
||||
tqDebug("tq task:0x%x (vgId:%d) recv check rsp(QID:0x%" PRIx64 ") from 0x%x (vgId:%d) status %d", rsp.upstreamTaskId,
|
||||
rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status);
|
||||
|
||||
if (!isLeader) {
|
||||
tqError("vgId:%d not leader, task:0x%x not handle the check rsp, downstream:0x%x (vgId:%d)", vgId,
|
||||
|
@ -681,7 +681,8 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen
|
|||
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x firstly", pReq->taskId, vgId, (int32_t)hTaskId.taskId);
|
||||
code = streamMetaUnregisterTask(pMeta, hTaskId.streamId, hTaskId.taskId);
|
||||
if (code) {
|
||||
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x failed", pReq->taskId, vgId, (int32_t)hTaskId.taskId);
|
||||
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x failed", pReq->taskId, vgId,
|
||||
(int32_t)hTaskId.taskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -793,16 +794,16 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead
|
|||
int32_t vgId = pMeta->vgId;
|
||||
|
||||
if (type == STREAM_EXEC_T_START_ONE_TASK) {
|
||||
(void) streamMetaStartOneTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
(void)streamMetaStartOneTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_START_ALL_TASKS) {
|
||||
(void) streamMetaStartAllTasks(pMeta);
|
||||
(void)streamMetaStartAllTasks(pMeta);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_RESTART_ALL_TASKS) {
|
||||
(void) restartStreamTasks(pMeta, isLeader);
|
||||
(void)restartStreamTasks(pMeta, isLeader);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_STOP_ALL_TASKS) {
|
||||
(void) streamMetaStopAllTasks(pMeta);
|
||||
(void)streamMetaStopAllTasks(pMeta);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_ADD_FAILED_TASK) {
|
||||
int32_t code = streamMetaAddFailedTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
|
@ -837,7 +838,7 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead
|
|||
if (streamTaskReadyToRun(pTask, &p)) {
|
||||
tqDebug("vgId:%d s-task:%s status:%s start to process block from inputQ, next checked ver:%" PRId64, vgId,
|
||||
pTask->id.idStr, p, pTask->chkInfo.nextProcessVer);
|
||||
(void) streamExecTask(pTask);
|
||||
(void)streamExecTask(pTask);
|
||||
} else {
|
||||
int8_t status = streamTaskSetSchedStatusInactive(pTask);
|
||||
tqDebug("vgId:%d s-task:%s ignore run req since not in ready state, status:%s, sched-status:%d", vgId,
|
||||
|
@ -924,9 +925,9 @@ int32_t tqStreamTaskProcessTaskResetReq(SStreamMeta* pMeta, char* pMsg) {
|
|||
|
||||
streamTaskSetStatusReady(pTask);
|
||||
} else if (pState.state == TASK_STATUS__UNINIT) {
|
||||
// tqDebug("s-task:%s start task by checking downstream tasks", pTask->id.idStr);
|
||||
// ASSERT(pTask->status.downstreamReady == 0);
|
||||
// tqStreamTaskRestoreCheckpoint(pMeta, pTask->id.streamId, pTask->id.taskId);
|
||||
// tqDebug("s-task:%s start task by checking downstream tasks", pTask->id.idStr);
|
||||
// ASSERT(pTask->status.downstreamReady == 0);
|
||||
// tqStreamTaskRestoreCheckpoint(pMeta, pTask->id.streamId, pTask->id.taskId);
|
||||
tqDebug("s-task:%s status:%s do nothing after receiving reset-task from mnode", pTask->id.idStr, pState.name);
|
||||
} else {
|
||||
tqDebug("s-task:%s status:%s do nothing after receiving reset-task from mnode", pTask->id.idStr, pState.name);
|
||||
|
@ -1169,7 +1170,9 @@ int32_t tqStreamProcessReqCheckpointRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) { ret
|
|||
|
||||
int32_t tqStreamProcessChkptReportRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) { return doProcessDummyRspMsg(pMeta, pMsg); }
|
||||
|
||||
int32_t tqStreamProcessConsensusChkptRsp2(SStreamMeta* pMeta, SRpcMsg* pMsg) { return doProcessDummyRspMsg(pMeta, pMsg); }
|
||||
int32_t tqStreamProcessConsensusChkptRsp2(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||
return doProcessDummyRspMsg(pMeta, pMsg);
|
||||
}
|
||||
|
||||
int32_t tqStreamProcessCheckpointReadyRsp(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||
SMStreamCheckpointReadyRspMsg* pRsp = pMsg->pCont;
|
||||
|
@ -1211,7 +1214,8 @@ int32_t tqStreamTaskProcessConsenChkptIdReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
|||
SStreamTask* pTask = NULL;
|
||||
code = streamMetaAcquireTask(pMeta, req.streamId, req.taskId, &pTask);
|
||||
if (pTask == NULL || (code != 0)) {
|
||||
tqError("vgId:%d process set consensus checkpointId req, failed to acquire task:0x%x, it may have been dropped already",
|
||||
tqError(
|
||||
"vgId:%d process set consensus checkpointId req, failed to acquire task:0x%x, it may have been dropped already",
|
||||
pMeta->vgId, req.taskId);
|
||||
(void)streamMetaAddFailedTask(pMeta, req.streamId, req.taskId);
|
||||
return code;
|
||||
|
@ -1221,7 +1225,8 @@ int32_t tqStreamTaskProcessConsenChkptIdReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
|||
if (req.startTs < pTask->execInfo.created) {
|
||||
tqWarn("s-task:%s vgId:%d create time:%" PRId64 " recv expired consensus checkpointId:%" PRId64
|
||||
" from task createTs:%" PRId64 " < task createTs:%" PRId64 ", discard",
|
||||
pTask->id.idStr, pMeta->vgId, pTask->execInfo.created, req.checkpointId, req.startTs, pTask->execInfo.created);
|
||||
pTask->id.idStr, pMeta->vgId, pTask->execInfo.created, req.checkpointId, req.startTs,
|
||||
pTask->execInfo.created);
|
||||
streamMetaAddFailedTaskSelf(pTask, now);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1234,15 +1239,15 @@ int32_t tqStreamTaskProcessConsenChkptIdReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
|||
ASSERT(pTask->chkInfo.checkpointId >= req.checkpointId);
|
||||
|
||||
if (pTask->chkInfo.consensusTransId >= req.transId) {
|
||||
tqDebug("s-task:%s vgId:%d latest consensus transId:%d, expired consensus trans:%d, discard",
|
||||
pTask->id.idStr, vgId, pTask->chkInfo.consensusTransId, req.transId);
|
||||
tqDebug("s-task:%s vgId:%d latest consensus transId:%d, expired consensus trans:%d, discard", pTask->id.idStr, vgId,
|
||||
pTask->chkInfo.consensusTransId, req.transId);
|
||||
streamMutexUnlock(&pTask->lock);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pTask->chkInfo.checkpointId != req.checkpointId) {
|
||||
tqDebug("s-task:%s vgId:%d update the checkpoint from %" PRId64 " to %" PRId64" transId:%d", pTask->id.idStr, vgId,
|
||||
tqDebug("s-task:%s vgId:%d update the checkpoint from %" PRId64 " to %" PRId64 " transId:%d", pTask->id.idStr, vgId,
|
||||
pTask->chkInfo.checkpointId, req.checkpointId, req.transId);
|
||||
pTask->chkInfo.checkpointId = req.checkpointId;
|
||||
tqSetRestoreVersionInfo(pTask);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "cos.h"
|
||||
#include "monitor.h"
|
||||
#include "vnd.h"
|
||||
|
||||
static volatile int32_t VINIT = 0;
|
||||
|
@ -26,6 +27,8 @@ int vnodeInit(int nthreads, StopDnodeFp stopDnodeFp) {
|
|||
TAOS_CHECK_RETURN(vnodeAsyncOpen(nthreads));
|
||||
TAOS_CHECK_RETURN(walInit(stopDnodeFp));
|
||||
|
||||
monInitVnode();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -494,24 +494,6 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
snprintf(pVnode->monitor.strDnodeId, TSDB_NODE_ID_LEN, "%" PRId32, pVnode->config.syncCfg.nodeInfo[0].nodeId);
|
||||
snprintf(pVnode->monitor.strVgId, TSDB_VGROUP_ID_LEN, "%" PRId32, pVnode->config.vgId);
|
||||
|
||||
if (tsEnableMonitor && pVnode->monitor.insertCounter == NULL) {
|
||||
taos_counter_t *counter = NULL;
|
||||
int32_t label_count = 7;
|
||||
const char *sample_labels[] = {VNODE_METRIC_TAG_NAME_SQL_TYPE, VNODE_METRIC_TAG_NAME_CLUSTER_ID,
|
||||
VNODE_METRIC_TAG_NAME_DNODE_ID, VNODE_METRIC_TAG_NAME_DNODE_EP,
|
||||
VNODE_METRIC_TAG_NAME_VGROUP_ID, VNODE_METRIC_TAG_NAME_USERNAME,
|
||||
VNODE_METRIC_TAG_NAME_RESULT};
|
||||
counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", label_count, sample_labels);
|
||||
vInfo("vgId:%d, new metric:%p", TD_VID(pVnode), counter);
|
||||
if (taos_collector_registry_register_metric(counter) == 1) {
|
||||
(void)taos_counter_destroy(counter);
|
||||
counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT);
|
||||
vInfo("vgId:%d, get metric from registry:%p", TD_VID(pVnode), counter);
|
||||
}
|
||||
pVnode->monitor.insertCounter = counter;
|
||||
vInfo("vgId:%d, succeed to set metric:%p", TD_VID(pVnode), counter);
|
||||
}
|
||||
|
||||
return pVnode;
|
||||
|
||||
_err:
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "audit.h"
|
||||
#include "cos.h"
|
||||
#include "monitor.h"
|
||||
#include "tencode.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsg.h"
|
||||
|
@ -23,6 +24,8 @@
|
|||
#include "vnode.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
extern taos_counter_t *tsInsertCounter;
|
||||
|
||||
static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||
static int32_t vnodeProcessAlterStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||
static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||
|
@ -1903,7 +1906,8 @@ _exit:
|
|||
(void)atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows);
|
||||
(void)atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1);
|
||||
|
||||
if (tsEnableMonitor && pSubmitRsp->affectedRows > 0 && strlen(pOriginalMsg->info.conn.user) > 0) {
|
||||
if (tsEnableMonitor && tsMonitorFqdn[0] != 0 && tsMonitorPort != 0 && pSubmitRsp->affectedRows > 0 &&
|
||||
strlen(pOriginalMsg->info.conn.user) > 0 && tsInsertCounter != NULL) {
|
||||
const char *sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS,
|
||||
pVnode->monitor.strClusterId,
|
||||
pVnode->monitor.strDnodeId,
|
||||
|
@ -1911,7 +1915,7 @@ _exit:
|
|||
pVnode->monitor.strVgId,
|
||||
pOriginalMsg->info.conn.user,
|
||||
"Success"};
|
||||
(void)taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels);
|
||||
(void)taos_counter_add(tsInsertCounter, pSubmitRsp->affectedRows, sample_labels);
|
||||
}
|
||||
|
||||
if (code == 0) {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
|
||||
|
||||
void ctgIsTaskDone(SCtgJob* pJob, CTG_TASK_TYPE type, bool* done) {
|
||||
SCtgTask* pTask = NULL;
|
||||
|
||||
|
@ -95,7 +94,8 @@ int32_t ctgInitGetTbMetasTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
|||
ctx->pNames = param;
|
||||
ctx->pResList = taosArrayInit(pJob->tbMetaNum, sizeof(SMetaRes));
|
||||
if (NULL == ctx->pResList) {
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbMetaNum, (int32_t)sizeof(SMetaRes));
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbMetaNum,
|
||||
(int32_t)sizeof(SMetaRes));
|
||||
ctgFreeTask(&task, true);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -245,7 +245,8 @@ int32_t ctgInitGetTbHashsTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
|||
ctx->pNames = param;
|
||||
ctx->pResList = taosArrayInit(pJob->tbHashNum, sizeof(SMetaRes));
|
||||
if (NULL == ctx->pResList) {
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbHashNum, (int32_t)sizeof(SMetaRes));
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbHashNum,
|
||||
(int32_t)sizeof(SMetaRes));
|
||||
ctgFreeTask(&task, true);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -513,7 +514,8 @@ int32_t ctgInitGetViewsTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
|
|||
ctx->pNames = param;
|
||||
ctx->pResList = taosArrayInit(pJob->viewNum, sizeof(SMetaRes));
|
||||
if (NULL == ctx->pResList) {
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->viewNum, (int32_t)sizeof(SMetaRes));
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->viewNum,
|
||||
(int32_t)sizeof(SMetaRes));
|
||||
ctgFreeTask(&task, true);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -544,7 +546,8 @@ int32_t ctgInitGetTbTSMATask(SCtgJob* pJob, int32_t taskId, void* param) {
|
|||
pTaskCtx->pNames = param;
|
||||
pTaskCtx->pResList = taosArrayInit(pJob->tbTsmaNum, sizeof(SMetaRes));
|
||||
if (NULL == pTaskCtx->pResList) {
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbTsmaNum, (int32_t)sizeof(SMetaRes));
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tbTsmaNum,
|
||||
(int32_t)sizeof(SMetaRes));
|
||||
ctgFreeTask(&task, true);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -571,7 +574,8 @@ int32_t ctgInitGetTSMATask(SCtgJob* pJob, int32_t taskId, void* param) {
|
|||
pTaskCtx->pNames = param;
|
||||
pTaskCtx->pResList = taosArrayInit(pJob->tsmaNum, sizeof(SMetaRes));
|
||||
if (NULL == pTaskCtx->pResList) {
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tsmaNum, (int32_t)sizeof(SMetaRes));
|
||||
qError("QID:0x%" PRIx64 " taosArrayInit %d SMetaRes %d failed", pJob->queryId, pJob->tsmaNum,
|
||||
(int32_t)sizeof(SMetaRes));
|
||||
ctgFreeTask(&task, true);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -584,7 +588,6 @@ int32_t ctgInitGetTSMATask(SCtgJob* pJob, int32_t taskId, void* param) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleForceUpdateView(SCatalog* pCtg, const SCatalogReq* pReq) {
|
||||
int32_t viewNum = taosArrayGetSize(pReq->pView);
|
||||
for (int32_t i = 0; i < viewNum; ++i) {
|
||||
|
@ -604,7 +607,6 @@ int32_t ctgHandleForceUpdateView(SCatalog* pCtg, const SCatalogReq* pReq) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, const SCatalogReq* pReq) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
|
@ -826,7 +828,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
|
||||
*job = taosMemoryCalloc(1, sizeof(SCtgJob));
|
||||
if (NULL == *job) {
|
||||
ctgError("failed to calloc, size:%d, reqId:0x%" PRIx64, (int32_t)sizeof(SCtgJob), pConn->requestId);
|
||||
ctgError("failed to calloc, size:%d, QID:0x%" PRIx64, (int32_t)sizeof(SCtgJob), pConn->requestId);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -953,7 +955,6 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_TAG, name, NULL));
|
||||
}
|
||||
|
||||
|
||||
for (int32_t i = 0; i < indexNum; ++i) {
|
||||
char* indexName = taosArrayGet(pReq->pIndex, i);
|
||||
if (NULL == indexName) {
|
||||
|
@ -1183,7 +1184,6 @@ int32_t ctgDumpTbTagRes(SCtgTask* pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgDumpIndexRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1350,7 +1350,6 @@ int32_t ctgDumpSvrVer(SCtgTask* pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgDumpViewsRes(SCtgTask* pTask) {
|
||||
if (pTask->subTask) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1363,7 +1362,6 @@ int32_t ctgDumpViewsRes(SCtgTask* pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgCallSubCb(SCtgTask* pTask) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -1806,7 +1804,8 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
|||
|
||||
SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx);
|
||||
if (NULL == pRes) {
|
||||
ctgTaskError("fail to get the %dth res in pResList, resNum:%d", pFetch->resIdx, (int32_t)taosArrayGetSize(ctx->pResList));
|
||||
ctgTaskError("fail to get the %dth res in pResList, resNum:%d", pFetch->resIdx,
|
||||
(int32_t)taosArrayGetSize(ctx->pResList));
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -1827,7 +1826,8 @@ _return:
|
|||
if (code) {
|
||||
SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx);
|
||||
if (NULL == pRes) {
|
||||
ctgTaskError("fail to get the %dth res in pResList, resNum:%d", pFetch->resIdx, (int32_t)taosArrayGetSize(ctx->pResList));
|
||||
ctgTaskError("fail to get the %dth res in pResList, resNum:%d", pFetch->resIdx,
|
||||
(int32_t)taosArrayGetSize(ctx->pResList));
|
||||
} else {
|
||||
pRes->code = code;
|
||||
pRes->pRes = NULL;
|
||||
|
@ -1904,7 +1904,8 @@ int32_t ctgHandleGetTbHashRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf
|
|||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, &pTask->pJob->conn.mgmtEps, pOut->dbVgroup, ctx->pName, (SVgroupInfo*)pTask->res));
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, &pTask->pJob->conn.mgmtEps, pOut->dbVgroup, ctx->pName,
|
||||
(SVgroupInfo*)pTask->res));
|
||||
|
||||
CTG_ERR_JRET(ctgUpdateVgroupEnqueue(pCtg, ctx->dbFName, pOut->dbId, pOut->dbVgroup, false));
|
||||
pOut->dbVgroup = NULL;
|
||||
|
@ -1952,11 +1953,13 @@ int32_t ctgHandleGetTbHashsRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
|
|||
|
||||
STablesReq* pReq = taosArrayGet(ctx->pNames, pFetch->dbIdx);
|
||||
if (NULL == pReq) {
|
||||
ctgError("fail to get the %dth tb in ctx->pNames, reqNum:%d", pFetch->dbIdx, (int32_t)taosArrayGetSize(ctx->pNames));
|
||||
ctgError("fail to get the %dth tb in ctx->pNames, reqNum:%d", pFetch->dbIdx,
|
||||
(int32_t)taosArrayGetSize(ctx->pNames));
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetVgInfosFromHashValue(pCtg, &pTask->pJob->conn.mgmtEps, tReq, pOut->dbVgroup, ctx, pMsgCtx->target, pReq->pTables, true));
|
||||
CTG_ERR_JRET(ctgGetVgInfosFromHashValue(pCtg, &pTask->pJob->conn.mgmtEps, tReq, pOut->dbVgroup, ctx,
|
||||
pMsgCtx->target, pReq->pTables, true));
|
||||
|
||||
CTG_ERR_JRET(ctgUpdateVgroupEnqueue(pCtg, pMsgCtx->target, pOut->dbId, pOut->dbVgroup, false));
|
||||
pOut->dbVgroup = NULL;
|
||||
|
@ -1978,13 +1981,15 @@ _return:
|
|||
if (code) {
|
||||
STablesReq* pReq = taosArrayGet(ctx->pNames, pFetch->dbIdx);
|
||||
if (NULL == pReq) {
|
||||
ctgError("fail to get the %dth tb in ctx->pNames, reqNum:%d", pFetch->dbIdx, (int32_t)taosArrayGetSize(ctx->pNames));
|
||||
ctgError("fail to get the %dth tb in ctx->pNames, reqNum:%d", pFetch->dbIdx,
|
||||
(int32_t)taosArrayGetSize(ctx->pNames));
|
||||
} else {
|
||||
int32_t num = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx + i);
|
||||
if (NULL == pRes) {
|
||||
ctgError("fail to get the %dth res in ctx->pResList, resNum:%d", pFetch->resIdx + i, (int32_t)taosArrayGetSize(ctx->pResList));
|
||||
ctgError("fail to get the %dth res in ctx->pResList, resNum:%d", pFetch->resIdx + i,
|
||||
(int32_t)taosArrayGetSize(ctx->pResList));
|
||||
} else {
|
||||
pRes->code = code;
|
||||
pRes->pRes = NULL;
|
||||
|
@ -2055,7 +2060,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleGetTbTagRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
|
@ -2107,7 +2111,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleGetDbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
|
@ -2303,7 +2306,8 @@ int32_t ctgHandleGetViewsRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf*
|
|||
|
||||
SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx);
|
||||
if (NULL == pRes) {
|
||||
ctgTaskError("fail to get the %dth res in ctx->pResList, totalResNum:%d", pFetch->resIdx, (int32_t)taosArrayGetSize(ctx->pResList));
|
||||
ctgTaskError("fail to get the %dth res in ctx->pResList, totalResNum:%d", pFetch->resIdx,
|
||||
(int32_t)taosArrayGetSize(ctx->pResList));
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -2319,7 +2323,8 @@ _return:
|
|||
if (code) {
|
||||
SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx);
|
||||
if (NULL == pRes) {
|
||||
ctgTaskError("fail to get the %dth res in ctx->pResList, totalResNum:%d", pFetch->resIdx, (int32_t)taosArrayGetSize(ctx->pResList));
|
||||
ctgTaskError("fail to get the %dth res in ctx->pResList, totalResNum:%d", pFetch->resIdx,
|
||||
(int32_t)taosArrayGetSize(ctx->pResList));
|
||||
} else {
|
||||
pRes->code = code;
|
||||
pRes->pRes = NULL;
|
||||
|
@ -2347,7 +2352,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
static int32_t ctgTsmaFetchStreamProgress(SCtgTaskReq* tReq, SHashObj* pVgHash, const STableTSMAInfoRsp* pTsmas) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
|
@ -2358,7 +2362,8 @@ static int32_t ctgTsmaFetchStreamProgress(SCtgTaskReq* tReq, SHashObj* pVgHash,
|
|||
SVgroupInfo* pVgInfo = NULL;
|
||||
SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx);
|
||||
if (NULL == pFetch) {
|
||||
ctgError("fail to get the %dth SCtgTSMAFetch, totalNum:%d", tReq->msgIdx, (int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
ctgError("fail to get the %dth SCtgTSMAFetch, totalNum:%d", tReq->msgIdx,
|
||||
(int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -2402,7 +2407,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleGetTSMARsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
|
@ -2496,7 +2500,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgHandleGetTbTSMARsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) {
|
||||
bool taskDone = false;
|
||||
int32_t code = 0;
|
||||
|
@ -2517,7 +2520,8 @@ int32_t ctgHandleGetTbTSMARsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf
|
|||
|
||||
SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx);
|
||||
if (NULL == pFetch) {
|
||||
ctgError("fail to get the %dth SCtgTSMAFetch, totalNum:%d", tReq->msgIdx, (int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
ctgError("fail to get the %dth SCtgTSMAFetch, totalNum:%d", tReq->msgIdx,
|
||||
(int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -2722,7 +2726,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgAsyncRefreshTbMeta(SCtgTaskReq* tReq, int32_t flag, SName* pName, int32_t* vgId) {
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||
|
@ -2940,7 +2943,8 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask* pTask) {
|
|||
if (NULL == pTask->res) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, &pConn->mgmtEps, dbCache->vgCache.vgInfo, pCtx->pName, (SVgroupInfo*)pTask->res));
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, &pConn->mgmtEps, dbCache->vgCache.vgInfo, pCtx->pName,
|
||||
(SVgroupInfo*)pTask->res));
|
||||
|
||||
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||
dbCache = NULL;
|
||||
|
@ -2991,8 +2995,8 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) {
|
|||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = -1;
|
||||
CTG_ERR_JRET(
|
||||
ctgGetVgInfosFromHashValue(pCtg, &pConn->mgmtEps, &tReq, dbCache->vgCache.vgInfo, pCtx, pReq->dbFName, pReq->pTables, false));
|
||||
CTG_ERR_JRET(ctgGetVgInfosFromHashValue(pCtg, &pConn->mgmtEps, &tReq, dbCache->vgCache.vgInfo, pCtx,
|
||||
pReq->dbFName, pReq->pTables, false));
|
||||
|
||||
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||
dbCache = NULL;
|
||||
|
@ -3003,7 +3007,7 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) {
|
|||
|
||||
baseResIdx += taosArrayGetSize(pReq->pTables);
|
||||
int32_t inc = baseResIdx - taosArrayGetSize(pCtx->pResList);
|
||||
for(int32_t j = 0; j < inc; ++j) {
|
||||
for (int32_t j = 0; j < inc; ++j) {
|
||||
if (NULL == taosArrayPush(pCtx->pResList, &(SMetaRes){0})) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -3158,7 +3162,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgLaunchGetTbTagTask(SCtgTask* pTask) {
|
||||
int32_t code = 0;
|
||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||
|
@ -3205,7 +3208,6 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgLaunchGetQnodeTask(SCtgTask* pTask) {
|
||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
||||
|
@ -3406,8 +3408,8 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
|
|||
if (inCache) {
|
||||
pTask->res = rsp.pRawRes;
|
||||
|
||||
ctgTaskDebug("Final res got, pass:[%d,%d], pCond:[%p,%p]",
|
||||
rsp.pRawRes->pass[0], rsp.pRawRes->pass[1], rsp.pRawRes->pCond[0], rsp.pRawRes->pCond[1]);
|
||||
ctgTaskDebug("Final res got, pass:[%d,%d], pCond:[%p,%p]", rsp.pRawRes->pass[0], rsp.pRawRes->pass[1],
|
||||
rsp.pRawRes->pCond[0], rsp.pRawRes->pCond[1]);
|
||||
|
||||
CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -3456,7 +3458,7 @@ int32_t ctgLaunchGetViewsTask(SCtgTask* pTask) {
|
|||
bool tbMetaDone = false;
|
||||
SName* pName = NULL;
|
||||
|
||||
/*
|
||||
/*
|
||||
ctgIsTaskDone(pJob, CTG_TASK_GET_TB_META_BATCH, &tbMetaDone);
|
||||
if (tbMetaDone) {
|
||||
CTG_ERR_RET(ctgBuildViewNullRes(pTask, pCtx));
|
||||
|
@ -3465,7 +3467,7 @@ int32_t ctgLaunchGetViewsTask(SCtgTask* pTask) {
|
|||
CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
int32_t dbNum = taosArrayGetSize(pCtx->pNames);
|
||||
int32_t fetchIdx = 0;
|
||||
|
@ -3534,7 +3536,8 @@ int32_t ctgAsyncRefreshTbTsma(SCtgTaskReq* pReq, const SCtgTSMAFetch* pFetch) {
|
|||
SCtgDBCache* pDbCache = NULL;
|
||||
STablesReq* pTbReq = taosArrayGet(pTaskCtx->pNames, pFetch->dbIdx);
|
||||
if (NULL == pTbReq) {
|
||||
ctgError("fail to get the %dth STablesReq, totalNum:%d", pFetch->dbIdx, (int32_t)taosArrayGetSize(pTaskCtx->pNames));
|
||||
ctgError("fail to get the %dth STablesReq, totalNum:%d", pFetch->dbIdx,
|
||||
(int32_t)taosArrayGetSize(pTaskCtx->pNames));
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -3759,7 +3762,8 @@ int32_t ctgGetTbCfgCb(SCtgTask* pTask) {
|
|||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pTask->pJob->pCtg, &pTask->pJob->conn.mgmtEps, pDb, pCtx->pName, pCtx->pVgInfo));
|
||||
CTG_ERR_JRET(
|
||||
ctgGetVgInfoFromHashValue(pTask->pJob->pCtg, &pTask->pJob->conn.mgmtEps, pDb, pCtx->pName, pCtx->pVgInfo));
|
||||
}
|
||||
|
||||
CTG_RET(ctgLaunchGetTbCfgTask(pTask));
|
||||
|
@ -3783,7 +3787,8 @@ int32_t ctgGetTbTagCb(SCtgTask* pTask) {
|
|||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pTask->pJob->pCtg, &pTask->pJob->conn.mgmtEps, pDb, pCtx->pName, pCtx->pVgInfo));
|
||||
CTG_ERR_JRET(
|
||||
ctgGetVgInfoFromHashValue(pTask->pJob->pCtg, &pTask->pJob->conn.mgmtEps, pDb, pCtx->pName, pCtx->pVgInfo));
|
||||
}
|
||||
|
||||
CTG_RET(ctgLaunchGetTbTagTask(pTask));
|
||||
|
@ -3793,8 +3798,6 @@ _return:
|
|||
CTG_RET(ctgHandleTaskEnd(pTask, pTask->subRes.code));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t ctgGetUserCb(SCtgTask* pTask) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -3808,7 +3811,6 @@ _return:
|
|||
CTG_RET(ctgHandleTaskEnd(pTask, pTask->subRes.code));
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgCompDbVgTasks(SCtgTask* pTask, void* param, bool* equal) {
|
||||
SCtgDbVgCtx* ctx = pTask->taskCtx;
|
||||
|
||||
|
@ -3966,7 +3968,6 @@ SCtgTask* ctgGetTask(SCtgJob* pJob, int32_t taskId) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgLaunchSubTask(SCtgTask** ppTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param) {
|
||||
SCtgJob* pJob = (*ppTask)->pJob;
|
||||
int32_t subTaskId = -1;
|
||||
|
|
|
@ -117,7 +117,8 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
ctgDebug("QID:0x%" PRIx64 " ctg task %d idx %d start to handle rsp %s, pBatchs: %p", pJob->queryId, pTask->taskId,
|
||||
pRsp->msgIdx, TMSG_INFO(taskMsg.msgType + 1), pBatchs);
|
||||
|
||||
(void)(*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, pRsp->reqType, &taskMsg, (pRsp->rspCode ? pRsp->rspCode : rspCode)); // error handled internal
|
||||
(void)(*gCtgAsyncFps[pTask->type].handleRspFp)(
|
||||
&tReq, pRsp->reqType, &taskMsg, (pRsp->rspCode ? pRsp->rspCode : rspCode)); // error handled internal
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||
|
@ -537,7 +538,7 @@ int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob* pJob,
|
|||
CTG_ERR_JRET(code);
|
||||
}
|
||||
|
||||
ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pJob->queryId, msgType, TMSG_INFO(msgType));
|
||||
ctgDebug("ctg req msg sent, QID:0x%" PRIx64 ", msg type:%d, %s", pJob->queryId, msgType, TMSG_INFO(msgType));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
@ -602,7 +603,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
|
||||
SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
|
||||
CTG_ERR_JRET(ctgGetFetchName(ctx->pNames, fetch, &pName));
|
||||
} else if (CTG_TASK_GET_TB_TSMA == pTask->type){
|
||||
} else if (CTG_TASK_GET_TB_TSMA == pTask->type) {
|
||||
SCtgTbTSMACtx* pCtx = pTask->taskCtx;
|
||||
SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx);
|
||||
STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx);
|
||||
|
@ -619,7 +620,8 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
SCtgTbTSMACtx* pCtx = pTask->taskCtx;
|
||||
SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx);
|
||||
if (NULL == pFetch) {
|
||||
ctgError("fail to get %d SCtgTSMAFetch, totalFetchs:%d", tReq->msgIdx, (int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
ctgError("fail to get %d SCtgTSMAFetch, totalFetchs:%d", tReq->msgIdx,
|
||||
(int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx);
|
||||
|
@ -678,7 +680,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx;
|
||||
SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx);
|
||||
CTG_ERR_JRET(ctgGetFetchName(ctx->pNames, fetch, &pName));
|
||||
} else if (CTG_TASK_GET_TB_TSMA == pTask->type){
|
||||
} else if (CTG_TASK_GET_TB_TSMA == pTask->type) {
|
||||
SCtgTbTSMACtx* pCtx = pTask->taskCtx;
|
||||
SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx);
|
||||
STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx);
|
||||
|
@ -695,7 +697,8 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
SCtgTbTSMACtx* pCtx = pTask->taskCtx;
|
||||
SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx);
|
||||
if (NULL == pFetch) {
|
||||
ctgError("fail to get %d SCtgTSMAFetch, totalFetchs:%d", tReq->msgIdx, (int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
ctgError("fail to get %d SCtgTSMAFetch, totalFetchs:%d", tReq->msgIdx,
|
||||
(int32_t)taosArrayGetSize(pCtx->pFetches));
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx);
|
||||
|
@ -1734,7 +1737,8 @@ int32_t ctgGetStreamProgressFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, c
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, vgroupInfo->vgId, reqType, msg, msgLen));
|
||||
CTG_RET(
|
||||
ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, vgroupInfo->vgId, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ typedef struct SMsortComparParam {
|
|||
typedef struct SSortHandle SSortHandle;
|
||||
typedef struct STupleHandle STupleHandle;
|
||||
|
||||
typedef SSDataBlock* (*_sort_fetch_block_fn_t)(void* param);
|
||||
typedef int32_t (*_sort_fetch_block_fn_t)(void* param, SSDataBlock** ppBlock);
|
||||
typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void* param);
|
||||
|
||||
/**
|
||||
|
|
|
@ -521,6 +521,7 @@ void doDestroyExchangeOperatorInfo(void* param) {
|
|||
int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SFetchRspHandleWrapper* pWrapper = (SFetchRspHandleWrapper*)param;
|
||||
|
||||
taosMemoryFreeClear(pMsg->pEpSet);
|
||||
SExchangeInfo* pExchangeInfo = taosAcquireRef(exchangeObjRefPool, pWrapper->exchangeId);
|
||||
if (pExchangeInfo == NULL) {
|
||||
qWarn("failed to acquire exchange operator, since it may have been released, %p", pExchangeInfo);
|
||||
|
|
|
@ -65,10 +65,10 @@ static SSDataBlock* doNonSortMerge1(SOperatorInfo* pOperator);
|
|||
static SSDataBlock* doColsMerge1(SOperatorInfo* pOperator);
|
||||
static int32_t doColsMerge(SOperatorInfo* pOperator, SSDataBlock** pResBlock);
|
||||
|
||||
SSDataBlock* sortMergeloadNextDataBlock(void* param) {
|
||||
int32_t sortMergeloadNextDataBlock(void* param, SSDataBlock** ppBlock) {
|
||||
SOperatorInfo* pOperator = (SOperatorInfo*)param;
|
||||
SSDataBlock* pBlock = pOperator->fpSet.getNextFn(pOperator);
|
||||
return pBlock;
|
||||
*ppBlock = pOperator->fpSet.getNextFn(pOperator);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t openSortMergeOperator(SOperatorInfo* pOperator) {
|
||||
|
|
|
@ -5414,7 +5414,7 @@ static void doGetBlockForTableMergeScan(SOperatorInfo* pOperator, bool* pFinishe
|
|||
return;
|
||||
}
|
||||
|
||||
static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
||||
static int32_t getBlockForTableMergeScan(void* param, SSDataBlock** ppBlock) {
|
||||
STableMergeScanSortSourceParam* source = param;
|
||||
|
||||
SOperatorInfo* pOperator = source->pOperator;
|
||||
|
@ -5422,6 +5422,7 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SSDataBlock* pBlock = NULL;
|
||||
int64_t st = taosGetTimestampUs();
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
while (true) {
|
||||
if (pInfo->rtnNextDurationBlocks) {
|
||||
|
@ -5456,10 +5457,11 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
|||
|
||||
if (pInfo->bNextDurationBlockEvent || pInfo->bNewFilesetEvent) {
|
||||
if (!bSkipped) {
|
||||
int32_t code = createOneDataBlock(pBlock, true, &pInfo->nextDurationBlocks[pInfo->numNextDurationBlocks]);
|
||||
code = createOneDataBlock(pBlock, true, &pInfo->nextDurationBlocks[pInfo->numNextDurationBlocks]);
|
||||
if (code) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
*ppBlock = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
++pInfo->numNextDurationBlocks;
|
||||
|
@ -5473,7 +5475,8 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
|||
|
||||
if (pInfo->bNewFilesetEvent) {
|
||||
pInfo->rtnNextDurationBlocks = true;
|
||||
return NULL;
|
||||
*ppBlock = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
if (pInfo->bNextDurationBlockEvent) {
|
||||
|
@ -5488,11 +5491,13 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
|||
|
||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||
pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||
*ppBlock = pBlock;
|
||||
|
||||
return pBlock;
|
||||
return code;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
*ppBlock = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t generateSortByTsPkInfo(SArray* colMatchInfo, int32_t order, SArray** ppSortArray) {
|
||||
|
|
|
@ -337,10 +337,10 @@ static int32_t getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock,
|
|||
return code;
|
||||
}
|
||||
|
||||
SSDataBlock* loadNextDataBlock(void* param) {
|
||||
int32_t loadNextDataBlock(void* param, SSDataBlock** ppBlock) {
|
||||
SOperatorInfo* pOperator = (SOperatorInfo*)param;
|
||||
SSDataBlock* pBlock = pOperator->fpSet.getNextFn(pOperator);
|
||||
return pBlock;
|
||||
*ppBlock = pOperator->fpSet.getNextFn(pOperator);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// todo refactor: merged with fetch fp
|
||||
|
@ -609,30 +609,32 @@ typedef struct SGroupSortSourceParam {
|
|||
SGroupSortOperatorInfo* grpSortOpInfo;
|
||||
} SGroupSortSourceParam;
|
||||
|
||||
SSDataBlock* fetchNextGroupSortDataBlock(void* param) {
|
||||
int32_t fetchNextGroupSortDataBlock(void* param, SSDataBlock** ppBlock) {
|
||||
*ppBlock = NULL;
|
||||
|
||||
SGroupSortSourceParam* source = param;
|
||||
SGroupSortOperatorInfo* grpSortOpInfo = source->grpSortOpInfo;
|
||||
if (grpSortOpInfo->prefetchedSortInput) {
|
||||
SSDataBlock* block = grpSortOpInfo->prefetchedSortInput;
|
||||
grpSortOpInfo->prefetchedSortInput = NULL;
|
||||
return block;
|
||||
*ppBlock = block;
|
||||
} else {
|
||||
SOperatorInfo* childOp = source->childOpInfo;
|
||||
SSDataBlock* block = childOp->fpSet.getNextFn(childOp);
|
||||
if (block != NULL) {
|
||||
if (block->info.id.groupId == grpSortOpInfo->currGroupId) {
|
||||
grpSortOpInfo->childOpStatus = CHILD_OP_SAME_GROUP;
|
||||
return block;
|
||||
*ppBlock = block;
|
||||
} else {
|
||||
grpSortOpInfo->childOpStatus = CHILD_OP_NEW_GROUP;
|
||||
grpSortOpInfo->prefetchedSortInput = block;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
grpSortOpInfo->childOpStatus = CHILD_OP_FINISHED;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t beginSortGroup(SOperatorInfo* pOperator) {
|
||||
|
|
|
@ -1436,7 +1436,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
|
|||
int64_t suid = mr.me.ctbEntry.suid;
|
||||
code = pAPI->metaReaderFn.getTableEntryByUid(&mr1, suid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("failed to get super table meta, cname:%s, suid:0x%" PRIx64 ", code:%s, %s", pInfo->pCur->mr.me.name,
|
||||
qError("failed to get super table meta, cname:%s, suid:0x%" PRIx64 ", code:%s, %s", mr.me.name,
|
||||
suid, tstrerror(terrno), GET_TASKID(pTaskInfo));
|
||||
pAPI->metaReaderFn.clearReader(&mr1);
|
||||
pAPI->metaReaderFn.clearReader(&mr);
|
||||
|
|
|
@ -619,7 +619,7 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32
|
|||
|
||||
for (int32_t i = 0; i < pParam->numOfSources; ++i) {
|
||||
SSortSource* pSource = pParam->pSources[i];
|
||||
pSource->src.pBlock = pHandle->fetchfp(pSource->param);
|
||||
TAOS_CHECK_RETURN(pHandle->fetchfp(pSource->param, &pSource->src.pBlock));
|
||||
|
||||
// set current source is done
|
||||
if (pSource->src.pBlock == NULL) {
|
||||
|
@ -711,7 +711,7 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeT
|
|||
}
|
||||
} else {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
pSource->src.pBlock = pHandle->fetchfp(((SSortSource*)pSource)->param);
|
||||
TAOS_CHECK_RETURN(pHandle->fetchfp(((SSortSource*)pSource)->param, &pSource->src.pBlock));
|
||||
pSource->fetchUs += taosGetTimestampUs() - st;
|
||||
pSource->fetchNum++;
|
||||
if (pSource->src.pBlock == NULL) {
|
||||
|
@ -1350,7 +1350,7 @@ static int32_t createSortMemFile(SSortHandle* pHandle) {
|
|||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
taosGetTmpfilePath(tsTempDir, "sort-ext-mem", pMemFile->memFilePath);
|
||||
pMemFile->pTdFile = taosOpenCFile(pMemFile->memFilePath, "w+");
|
||||
pMemFile->pTdFile = taosOpenCFile(pMemFile->memFilePath, "w+b");
|
||||
if (pMemFile->pTdFile == NULL) {
|
||||
code = terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
|
@ -2236,8 +2236,9 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
|
|||
while (1) {
|
||||
bool bExtractedBlock = false;
|
||||
bool bSkipBlock = false;
|
||||
SSDataBlock* pBlk = NULL;
|
||||
|
||||
SSDataBlock* pBlk = pHandle->fetchfp(pSrc->param);
|
||||
TAOS_CHECK_RETURN(pHandle->fetchfp(pSrc->param, &pBlk));
|
||||
if (pBlk != NULL && pHandle->mergeLimit > 0) {
|
||||
SSDataBlock* p = NULL;
|
||||
code = getRowsBlockWithinMergeLimit(pHandle, mTableNumRows, pBlk, &bExtractedBlock, &bSkipBlock, &p);
|
||||
|
@ -2390,7 +2391,8 @@ static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
|
|||
tsortClearOrderdSource(pHandle->pOrderedSource, NULL, NULL);
|
||||
|
||||
while (1) {
|
||||
SSDataBlock* pBlock = pHandle->fetchfp(source->param);
|
||||
SSDataBlock* pBlock = NULL;
|
||||
TAOS_CHECK_RETURN(pHandle->fetchfp(source->param, &pBlock));
|
||||
if (pBlock == NULL) {
|
||||
break;
|
||||
}
|
||||
|
@ -2701,7 +2703,8 @@ static int32_t tsortOpenForPQSort(SSortHandle* pHandle) {
|
|||
|
||||
while (1) {
|
||||
// fetch data
|
||||
SSDataBlock* pBlock = pHandle->fetchfp(source->param);
|
||||
SSDataBlock* pBlock = NULL;
|
||||
TAOS_CHECK_RETURN(pHandle->fetchfp(source->param, &pBlock));
|
||||
if (NULL == pBlock) {
|
||||
break;
|
||||
}
|
||||
|
@ -2828,7 +2831,9 @@ static int32_t tsortSingleTableMergeNextTuple(SSortHandle* pHandle, STupleHandle
|
|||
}
|
||||
|
||||
SSortSource* source = *pSource;
|
||||
SSDataBlock* pBlock = pHandle->fetchfp(source->param);
|
||||
SSDataBlock* pBlock = NULL;
|
||||
TAOS_CHECK_RETURN(pHandle->fetchfp(source->param, &pBlock));
|
||||
|
||||
if (!pBlock || pBlock->info.rows == 0) {
|
||||
setCurrentSourceDone(source, pHandle);
|
||||
pHandle->tupleHandle.pBlock = NULL;
|
||||
|
|
|
@ -21,11 +21,25 @@
|
|||
#include "thttp.h"
|
||||
#include "ttime.h"
|
||||
|
||||
#define VNODE_METRIC_SQL_COUNT "taosd_sql_req:count"
|
||||
|
||||
#define VNODE_METRIC_TAG_NAME_SQL_TYPE "sql_type"
|
||||
#define VNODE_METRIC_TAG_NAME_CLUSTER_ID "cluster_id"
|
||||
#define VNODE_METRIC_TAG_NAME_DNODE_ID "dnode_id"
|
||||
#define VNODE_METRIC_TAG_NAME_DNODE_EP "dnode_ep"
|
||||
#define VNODE_METRIC_TAG_NAME_VGROUP_ID "vgroup_id"
|
||||
#define VNODE_METRIC_TAG_NAME_USERNAME "username"
|
||||
#define VNODE_METRIC_TAG_NAME_RESULT "result"
|
||||
|
||||
// #define VNODE_METRIC_TAG_VALUE_INSERT "insert"
|
||||
// #define VNODE_METRIC_TAG_VALUE_DELETE "delete"
|
||||
|
||||
SMonitor tsMonitor = {0};
|
||||
char *tsMonUri = "/report";
|
||||
char *tsMonFwUri = "/general-metric";
|
||||
char *tsMonSlowLogUri = "/slow-sql-detail-batch";
|
||||
char *tsMonFwBasicUri = "/taosd-cluster-basic";
|
||||
taos_counter_t *tsInsertCounter = NULL;
|
||||
|
||||
void monRecordLog(int64_t ts, ELogLevel level, const char *content) {
|
||||
(void)taosThreadMutexLock(&tsMonitor.lock);
|
||||
|
@ -117,6 +131,28 @@ int32_t monInit(const SMonCfg *pCfg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void monInitVnode() {
|
||||
if (tsEnableMonitor && tsMonitorFqdn[0] != 0 && tsMonitorPort != 0 && tsInsertCounter == NULL) {
|
||||
taos_counter_t *counter = NULL;
|
||||
int32_t label_count = 7;
|
||||
const char *sample_labels[] = {VNODE_METRIC_TAG_NAME_SQL_TYPE, VNODE_METRIC_TAG_NAME_CLUSTER_ID,
|
||||
VNODE_METRIC_TAG_NAME_DNODE_ID, VNODE_METRIC_TAG_NAME_DNODE_EP,
|
||||
VNODE_METRIC_TAG_NAME_VGROUP_ID, VNODE_METRIC_TAG_NAME_USERNAME,
|
||||
VNODE_METRIC_TAG_NAME_RESULT};
|
||||
counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", label_count, sample_labels);
|
||||
uDebug("new metric:%p", counter);
|
||||
if (taos_collector_registry_register_metric(counter) == 1) {
|
||||
(void)taos_counter_destroy(counter);
|
||||
uError("failed to register metric:%p", counter);
|
||||
} else {
|
||||
tsInsertCounter = counter;
|
||||
uInfo("succeed to set inserted row metric:%p", tsInsertCounter);
|
||||
}
|
||||
} else {
|
||||
uError("failed to set insert counter, already set");
|
||||
}
|
||||
}
|
||||
|
||||
void monCleanup() {
|
||||
tsLogFp = NULL;
|
||||
taosArrayDestroy(tsMonitor.logs);
|
||||
|
|
|
@ -107,11 +107,12 @@ void streamTaskSendCheckMsg(SStreamTask* pTask) {
|
|||
streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, pDispatch->taskId, pDispatch->nodeId, idstr);
|
||||
|
||||
stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " check single downstream task:0x%x(vgId:%d) ver:%" PRId64 "-%" PRId64
|
||||
" window:%" PRId64 "-%" PRId64 " reqId:0x%" PRIx64,
|
||||
" window:%" PRId64 "-%" PRId64 " QID:0x%" PRIx64,
|
||||
idstr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, pRange->range.minVer,
|
||||
pRange->range.maxVer, pWindow->skey, pWindow->ekey, req.reqId);
|
||||
|
||||
(void) streamSendCheckMsg(pTask, &req, pTask->outputInfo.fixedDispatcher.nodeId, &pTask->outputInfo.fixedDispatcher.epSet);
|
||||
(void)streamSendCheckMsg(pTask, &req, pTask->outputInfo.fixedDispatcher.nodeId,
|
||||
&pTask->outputInfo.fixedDispatcher.epSet);
|
||||
|
||||
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||
streamTaskStartMonitorCheckRsp(pTask);
|
||||
|
@ -132,9 +133,9 @@ void streamTaskSendCheckMsg(SStreamTask* pTask) {
|
|||
streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, pVgInfo->taskId, pVgInfo->vgId, idstr);
|
||||
|
||||
stDebug("s-task:%s (vgId:%d) stage:%" PRId64
|
||||
" check downstream task:0x%x (vgId:%d) (shuffle), idx:%d, reqId:0x%" PRIx64,
|
||||
" check downstream task:0x%x (vgId:%d) (shuffle), idx:%d, QID:0x%" PRIx64,
|
||||
idstr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i, req.reqId);
|
||||
(void) streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet);
|
||||
(void)streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet);
|
||||
}
|
||||
} else { // for sink task, set it ready directly.
|
||||
stDebug("s-task:%s (vgId:%d) set downstream ready, since no downstream", idstr, pTask->info.nodeId);
|
||||
|
@ -170,14 +171,14 @@ void streamTaskProcessCheckMsg(SStreamMeta* pMeta, SStreamTaskCheckReq* pReq, SS
|
|||
streamTaskCheckStatus(pTask, pReq->upstreamTaskId, pReq->upstreamNodeId, pReq->stage, &pRsp->oldStage);
|
||||
|
||||
SStreamTaskState pState = streamTaskGetStatus(pTask);
|
||||
stDebug("s-task:%s status:%s, stage:%" PRId64 " recv task check req(reqId:0x%" PRIx64
|
||||
stDebug("s-task:%s status:%s, stage:%" PRId64 " recv task check req(QID:0x%" PRIx64
|
||||
") task:0x%x (vgId:%d), check_status:%d",
|
||||
pTask->id.idStr, pState.name, pRsp->oldStage, pRsp->reqId, pRsp->upstreamTaskId, pRsp->upstreamNodeId,
|
||||
pRsp->status);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
} else {
|
||||
pRsp->status = TASK_DOWNSTREAM_NOT_READY;
|
||||
stDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(reqId:0x%" PRIx64
|
||||
stDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(QID:0x%" PRIx64
|
||||
") from task:0x%x (vgId:%d), rsp check_status %d",
|
||||
pReq->streamId, taskId, pRsp->reqId, pRsp->upstreamTaskId, pRsp->upstreamNodeId, pRsp->status);
|
||||
}
|
||||
|
@ -261,7 +262,7 @@ int32_t streamTaskSendCheckRsp(const SStreamMeta* pMeta, int32_t vgId, SStreamTa
|
|||
|
||||
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
tEncoderInit(&encoder, (uint8_t*)abuf, len);
|
||||
(void) tEncodeStreamTaskCheckRsp(&encoder, pRsp);
|
||||
(void)tEncodeStreamTaskCheckRsp(&encoder, pRsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
SRpcMsg rspMsg = {.code = 0, .pCont = buf, .contLen = sizeof(SMsgHead) + len, .info = *pRpcInfo};
|
||||
|
@ -300,7 +301,8 @@ void streamTaskStartMonitorCheckRsp(SStreamTask* pTask) {
|
|||
if (pInfo->checkRspTmr == NULL) {
|
||||
pInfo->checkRspTmr = taosTmrStart(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer);
|
||||
} else {
|
||||
streamTmrReset(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr, vgId, "check-status-monitor");
|
||||
streamTmrReset(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr, vgId,
|
||||
"check-status-monitor");
|
||||
}
|
||||
|
||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||
|
@ -319,7 +321,7 @@ void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo) {
|
|||
pInfo->pList = NULL;
|
||||
|
||||
if (pInfo->checkRspTmr != NULL) {
|
||||
(void) taosTmrStop(pInfo->checkRspTmr);
|
||||
(void)taosTmrStop(pInfo->checkRspTmr);
|
||||
pInfo->checkRspTmr = NULL;
|
||||
}
|
||||
|
||||
|
@ -329,11 +331,11 @@ void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo) {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void processDownstreamReadyRsp(SStreamTask* pTask) {
|
||||
EStreamTaskEvent event = (pTask->info.fillHistory == 0) ? TASK_EVENT_INIT : TASK_EVENT_INIT_SCANHIST;
|
||||
(void) streamTaskOnHandleEventSuccess(pTask->status.pSM, event, NULL, NULL);
|
||||
(void)streamTaskOnHandleEventSuccess(pTask->status.pSM, event, NULL, NULL);
|
||||
|
||||
int64_t checkTs = pTask->execInfo.checkTs;
|
||||
int64_t readyTs = pTask->execInfo.readyTs;
|
||||
(void) streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, checkTs, readyTs, true);
|
||||
(void)streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, checkTs, readyTs, true);
|
||||
|
||||
if (pTask->status.taskStatus == TASK_STATUS__HALT) {
|
||||
if (!HAS_RELATED_FILLHISTORY_TASK(pTask) || (pTask->info.fillHistory != 0)) {
|
||||
|
@ -355,7 +357,7 @@ void processDownstreamReadyRsp(SStreamTask* pTask) {
|
|||
// todo: let's retry
|
||||
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
|
||||
stDebug("s-task:%s try to launch related fill-history task", pTask->id.idStr);
|
||||
(void) streamLaunchFillHistoryTask(pTask);
|
||||
(void)streamLaunchFillHistoryTask(pTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -430,7 +432,7 @@ int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t
|
|||
findCheckRspStatus(pInfo, taskId, &p);
|
||||
if (p != NULL) {
|
||||
if (reqId != p->reqId) {
|
||||
stError("s-task:%s reqId:0x%" PRIx64 " expected:0x%" PRIx64
|
||||
stError("s-task:%s QID:0x%" PRIx64 " expected:0x%" PRIx64
|
||||
" expired check-rsp recv from downstream task:0x%x, discarded",
|
||||
id, reqId, p->reqId, taskId);
|
||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||
|
@ -452,7 +454,7 @@ int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t
|
|||
}
|
||||
|
||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||
stError("s-task:%s unexpected check rsp msg, invalid downstream task:0x%x, reqId:%" PRIx64 " discarded", id, taskId,
|
||||
stError("s-task:%s unexpected check rsp msg, invalid downstream task:0x%x, QID:%" PRIx64 " discarded", id, taskId,
|
||||
reqId);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -539,10 +541,10 @@ void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) {
|
|||
STaskDispatcherFixed* pDispatch = &pOutputInfo->fixedDispatcher;
|
||||
setCheckDownstreamReqInfo(&req, p->reqId, pDispatch->taskId, pDispatch->nodeId);
|
||||
|
||||
stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) reqId:0x%" PRIx64, id,
|
||||
stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) QID:0x%" PRIx64, id,
|
||||
pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, req.reqId);
|
||||
|
||||
(void) streamSendCheckMsg(pTask, &req, pOutputInfo->fixedDispatcher.nodeId, &pOutputInfo->fixedDispatcher.epSet);
|
||||
(void)streamSendCheckMsg(pTask, &req, pOutputInfo->fixedDispatcher.nodeId, &pOutputInfo->fixedDispatcher.epSet);
|
||||
} else if (pOutputInfo->type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||
SArray* vgInfo = pOutputInfo->shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||
int32_t numOfVgs = taosArrayGetSize(vgInfo);
|
||||
|
@ -557,9 +559,9 @@ void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) {
|
|||
setCheckDownstreamReqInfo(&req, p->reqId, pVgInfo->taskId, pVgInfo->vgId);
|
||||
|
||||
stDebug("s-task:%s (vgId:%d) stage:%" PRId64
|
||||
" re-send check downstream task:0x%x(vgId:%d) (shuffle), idx:%d reqId:0x%" PRIx64,
|
||||
" re-send check downstream task:0x%x(vgId:%d) (shuffle), idx:%d QID:0x%" PRIx64,
|
||||
id, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i, p->reqId);
|
||||
(void) streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet);
|
||||
(void)streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -583,12 +585,12 @@ void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfReady, i
|
|||
} else { // TASK_DOWNSTREAM_NOT_READY
|
||||
if (p->rspTs == 0) { // not response yet
|
||||
if (el >= CHECK_NOT_RSP_DURATION) { // not receive info for 10 sec.
|
||||
(void) taosArrayPush(pTimeoutList, &p->taskId);
|
||||
(void)taosArrayPush(pTimeoutList, &p->taskId);
|
||||
} else { // el < CHECK_NOT_RSP_DURATION
|
||||
(*numOfNotRsp) += 1; // do nothing and continue waiting for their rsp
|
||||
}
|
||||
} else {
|
||||
(void) taosArrayPush(pNotReadyList, &p->taskId);
|
||||
(void)taosArrayPush(pNotReadyList, &p->taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,10 +619,9 @@ void handleTimeoutDownstreamTasks(SStreamTask* pTask, SArray* pTimeoutList) {
|
|||
SDownstreamStatusInfo* p = NULL;
|
||||
findCheckRspStatus(pInfo, taskId, &p);
|
||||
if (p != NULL) {
|
||||
|
||||
if (p->status != -1 || p->rspTs != 0) {
|
||||
stError("s-task:%s invalid rsp record entry, index:%d, status:%d, rspTs:%"PRId64, pTask->id.idStr, i, p->status,
|
||||
p->rspTs);
|
||||
stError("s-task:%s invalid rsp record entry, index:%d, status:%d, rspTs:%" PRId64, pTask->id.idStr, i,
|
||||
p->status, p->rspTs);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -721,7 +722,7 @@ void rspMonitorFn(void* param, void* tmrId) {
|
|||
// not record the failed of the current task if try to close current vnode
|
||||
// otherwise, the put of message operation may incur invalid read of message queue.
|
||||
if (!pMeta->closeFlag) {
|
||||
(void) addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
|
||||
(void)addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
|
||||
}
|
||||
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
|
@ -740,8 +741,8 @@ void rspMonitorFn(void* param, void* tmrId) {
|
|||
streamMutexLock(&pInfo->checkInfoLock);
|
||||
if (pInfo->notReadyTasks == 0) {
|
||||
int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1);
|
||||
stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr, ref:%d", id, state.name,
|
||||
vgId, ref);
|
||||
stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr, ref:%d", id, state.name, vgId,
|
||||
ref);
|
||||
|
||||
streamTaskCompleteCheckRsp(pInfo, false, id);
|
||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||
|
@ -803,7 +804,7 @@ void rspMonitorFn(void* param, void* tmrId) {
|
|||
streamTaskCompleteCheckRsp(pInfo, false, id);
|
||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||
|
||||
(void) addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
|
||||
(void)addDownstreamFailedStatusResultAsync(pTask->pMsgCb, vgId, pTask->id.streamId, pTask->id.taskId);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
|
||||
taosArrayDestroy(pNotReadyList);
|
||||
|
@ -819,7 +820,8 @@ void rspMonitorFn(void* param, void* tmrId) {
|
|||
handleTimeoutDownstreamTasks(pTask, pTimeoutList);
|
||||
}
|
||||
|
||||
streamTmrReset(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr, vgId, "check-status-monitor");
|
||||
streamTmrReset(rspMonitorFn, CHECK_RSP_CHECK_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr, vgId,
|
||||
"check-status-monitor");
|
||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||
|
||||
stDebug(
|
||||
|
|
|
@ -118,7 +118,7 @@ int32_t streamTaskBroadcastRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* r
|
|||
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
(void) tEncodeStreamRetrieveReq(&encoder, req);
|
||||
(void)tEncodeStreamRetrieveReq(&encoder, req);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
SRpcMsg rpcMsg = {0};
|
||||
|
@ -130,7 +130,7 @@ int32_t streamTaskBroadcastRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* r
|
|||
return code;
|
||||
}
|
||||
|
||||
stDebug("s-task:%s (child %d) send retrieve req to task:0x%x (vgId:%d), reqId:0x%" PRIx64, pTask->id.idStr,
|
||||
stDebug("s-task:%s (child %d) send retrieve req to task:0x%x (vgId:%d), QID:0x%" PRIx64, pTask->id.idStr,
|
||||
pTask->info.selfChildId, pEpInfo->taskId, pEpInfo->nodeId, req->reqId);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ static SStreamDispatchReq* createDispatchDataReq(SStreamTask* pTask, const SStre
|
|||
int32_t type = pTask->outputInfo.type;
|
||||
int32_t num = streamTaskGetNumOfDownstream(pTask);
|
||||
|
||||
if(type != TASK_OUTPUT__SHUFFLE_DISPATCH && type != TASK_OUTPUT__FIXED_DISPATCH) {
|
||||
if (type != TASK_OUTPUT__SHUFFLE_DISPATCH && type != TASK_OUTPUT__FIXED_DISPATCH) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
stError("s-task:%s invalid dispatch type:%d not dispatch data", pTask->id.idStr, type);
|
||||
return NULL;
|
||||
|
@ -470,7 +470,7 @@ static void addDispatchEntry(SDispatchMsgInfo* pMsgInfo, int32_t nodeId, int64_t
|
|||
streamMutexLock(&pMsgInfo->lock);
|
||||
}
|
||||
|
||||
(void) taosArrayPush(pMsgInfo->pSendInfo, &entry);
|
||||
(void)taosArrayPush(pMsgInfo->pSendInfo, &entry);
|
||||
|
||||
if (lock) {
|
||||
streamMutexUnlock(&pMsgInfo->lock);
|
||||
|
@ -617,7 +617,8 @@ static void doMonitorDispatchData(void* param, void* tmrId) {
|
|||
void streamStartMonitorDispatchData(SStreamTask* pTask, int64_t waitDuration) {
|
||||
int32_t vgId = pTask->pMeta->vgId;
|
||||
if (pTask->msgInfo.pRetryTmr != NULL) {
|
||||
streamTmrReset(doMonitorDispatchData, waitDuration, pTask, streamTimer, &pTask->msgInfo.pRetryTmr, vgId, "dispatch-monitor-tmr");
|
||||
streamTmrReset(doMonitorDispatchData, waitDuration, pTask, streamTimer, &pTask->msgInfo.pRetryTmr, vgId,
|
||||
"dispatch-monitor-tmr");
|
||||
} else {
|
||||
pTask->msgInfo.pRetryTmr = taosTmrStart(doMonitorDispatchData, waitDuration, pTask, streamTimer);
|
||||
}
|
||||
|
@ -651,7 +652,8 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S
|
|||
}
|
||||
}
|
||||
} else {
|
||||
(void) buildCtbNameByGroupIdImpl(pTask->outputInfo.shuffleDispatcher.stbFullName, groupId, pDataBlock->info.parTbName);
|
||||
(void)buildCtbNameByGroupIdImpl(pTask->outputInfo.shuffleDispatcher.stbFullName, groupId,
|
||||
pDataBlock->info.parTbName);
|
||||
}
|
||||
|
||||
snprintf(ctbName, TSDB_TABLE_NAME_LEN, "%s.%s", pTask->outputInfo.shuffleDispatcher.dbInfo.db,
|
||||
|
@ -666,7 +668,7 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S
|
|||
|
||||
// failed to put into name buffer, no need to do anything
|
||||
if (tSimpleHashGetSize(pTask->pNameMap) < MAX_BLOCK_NAME_NUM) {
|
||||
(void) tSimpleHashPut(pTask->pNameMap, &groupId, sizeof(int64_t), &bln, sizeof(SBlockName));
|
||||
(void)tSimpleHashPut(pTask->pNameMap, &groupId, sizeof(int64_t), &bln, sizeof(SBlockName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -848,7 +850,8 @@ static void checkpointReadyMsgSendMonitorFn(void* param, void* tmrId) {
|
|||
}
|
||||
|
||||
if (++pTmrInfo->activeCounter < 50) {
|
||||
streamTmrReset(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, "chkpt-ready-monitor");
|
||||
streamTmrReset(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId,
|
||||
"chkpt-ready-monitor");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -907,7 +910,7 @@ static void checkpointReadyMsgSendMonitorFn(void* param, void* tmrId) {
|
|||
continue;
|
||||
}
|
||||
|
||||
(void) taosArrayPush(pNotRspList, &pInfo->upstreamTaskId);
|
||||
(void)taosArrayPush(pNotRspList, &pInfo->upstreamTaskId);
|
||||
stDebug("s-task:%s vgId:%d level:%d checkpoint-ready rsp from upstream:0x%x not confirmed yet", id, vgId,
|
||||
pTask->info.taskLevel, pInfo->upstreamTaskId);
|
||||
}
|
||||
|
@ -931,8 +934,8 @@ static void checkpointReadyMsgSendMonitorFn(void* param, void* tmrId) {
|
|||
if (*pTaskId == pReadyInfo->upstreamTaskId) { // send msg again
|
||||
|
||||
SRpcMsg msg = {0};
|
||||
int32_t code = initCheckpointReadyMsg(pTask, pReadyInfo->upstreamNodeId, pReadyInfo->upstreamTaskId, pReadyInfo->childId,
|
||||
checkpointId, &msg);
|
||||
int32_t code = initCheckpointReadyMsg(pTask, pReadyInfo->upstreamNodeId, pReadyInfo->upstreamTaskId,
|
||||
pReadyInfo->childId, checkpointId, &msg);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = tmsgSendReq(&pReadyInfo->upstreamNodeEpset, &msg);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -948,7 +951,8 @@ static void checkpointReadyMsgSendMonitorFn(void* param, void* tmrId) {
|
|||
}
|
||||
}
|
||||
|
||||
streamTmrReset(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, "chkpt-ready-monitor");
|
||||
streamTmrReset(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId,
|
||||
"chkpt-ready-monitor");
|
||||
streamMutexUnlock(&pActiveInfo->lock);
|
||||
} else {
|
||||
int32_t ref = streamCleanBeforeQuitTmr(pTmrInfo, pTask);
|
||||
|
@ -1015,7 +1019,8 @@ int32_t streamTaskSendCheckpointReadyMsg(SStreamTask* pTask) {
|
|||
if (pTmrInfo->tmrHandle == NULL) {
|
||||
pTmrInfo->tmrHandle = taosTmrStart(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer);
|
||||
} else {
|
||||
streamTmrReset(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId, "chkpt-ready-monitor");
|
||||
streamTmrReset(checkpointReadyMsgSendMonitorFn, 200, pTask, streamTimer, &pTmrInfo->tmrHandle, vgId,
|
||||
"chkpt-ready-monitor");
|
||||
}
|
||||
|
||||
// mark the timer monitor checkpointId
|
||||
|
@ -1087,8 +1092,8 @@ int32_t streamAddBlockIntoDispatchMsg(const SSDataBlock* pBlock, SStreamDispatch
|
|||
|
||||
payloadLen += sizeof(SRetrieveTableRsp);
|
||||
|
||||
(void) taosArrayPush(pReq->dataLen, &payloadLen);
|
||||
(void) taosArrayPush(pReq->data, &buf);
|
||||
(void)taosArrayPush(pReq->dataLen, &payloadLen);
|
||||
(void)taosArrayPush(pReq->data, &buf);
|
||||
|
||||
pReq->totalLen += dataStrLen;
|
||||
return 0;
|
||||
|
@ -1169,7 +1174,7 @@ int32_t streamTaskBuildCheckpointSourceRsp(SStreamCheckpointSourceReq* pReq, SRp
|
|||
void* abuf = POINTER_SHIFT(pBuf, sizeof(SMsgHead));
|
||||
|
||||
tEncoderInit(&encoder, (uint8_t*)abuf, len);
|
||||
(void) tEncodeStreamCheckpointSourceRsp(&encoder, &rsp);
|
||||
(void)tEncodeStreamCheckpointSourceRsp(&encoder, &rsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
initRpcMsg(pMsg, 0, pBuf, sizeof(SMsgHead) + len);
|
||||
|
@ -1185,7 +1190,7 @@ int32_t streamAddCheckpointSourceRspMsg(SStreamCheckpointSourceReq* pReq, SRpcHa
|
|||
.recvTs = taosGetTimestampMs(), .transId = pReq->transId, .checkpointId = pReq->checkpointId};
|
||||
|
||||
// todo retry until it success
|
||||
(void) streamTaskBuildCheckpointSourceRsp(pReq, pRpcInfo, &info.msg, TSDB_CODE_SUCCESS);
|
||||
(void)streamTaskBuildCheckpointSourceRsp(pReq, pRpcInfo, &info.msg, TSDB_CODE_SUCCESS);
|
||||
|
||||
SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo;
|
||||
streamMutexLock(&pActiveInfo->lock);
|
||||
|
@ -1208,7 +1213,7 @@ int32_t streamAddCheckpointSourceRspMsg(SStreamCheckpointSourceReq* pReq, SRpcHa
|
|||
pTask->id.idStr, pReady->checkpointId, pReady->transId, pReq->transId, pReq->checkpointId);
|
||||
}
|
||||
} else {
|
||||
(void) taosArrayPush(pActiveInfo->pReadyMsgList, &info);
|
||||
(void)taosArrayPush(pActiveInfo->pReadyMsgList, &info);
|
||||
stDebug("s-task:%s add checkpoint source rsp msg, total:%d", pTask->id.idStr, size + 1);
|
||||
}
|
||||
|
||||
|
@ -1246,7 +1251,7 @@ int32_t streamAddCheckpointReadyMsg(SStreamTask* pTask, int32_t upstreamTaskId,
|
|||
SActiveCheckpointInfo* pActiveInfo = pTask->chkInfo.pActiveInfo;
|
||||
|
||||
streamMutexLock(&pActiveInfo->lock);
|
||||
(void) taosArrayPush(pActiveInfo->pReadyMsgList, &info);
|
||||
(void)taosArrayPush(pActiveInfo->pReadyMsgList, &info);
|
||||
|
||||
int32_t numOfRecv = taosArrayGetSize(pActiveInfo->pReadyMsgList);
|
||||
int32_t total = streamTaskGetNumOfUpstream(pTask);
|
||||
|
|
|
@ -54,7 +54,7 @@ static int32_t doOutputResultBlockImpl(SStreamTask* pTask, SStreamDataBlock* pBl
|
|||
|
||||
// not handle error, if dispatch failed, try next time.
|
||||
// checkpoint trigger will be checked
|
||||
(void) streamDispatchStreamBlock(pTask);
|
||||
(void)streamDispatchStreamBlock(pTask);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -99,7 +99,7 @@ void streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, int64_t* to
|
|||
*totalSize = 0;
|
||||
|
||||
int32_t size = 0;
|
||||
int32_t numOfBlocks= 0;
|
||||
int32_t numOfBlocks = 0;
|
||||
SArray* pRes = NULL;
|
||||
|
||||
while (1) {
|
||||
|
@ -129,7 +129,7 @@ void streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, int64_t* to
|
|||
const SStreamDataBlock* pRetrieveBlock = (const SStreamDataBlock*)pItem;
|
||||
ASSERT(taosArrayGetSize(pRetrieveBlock->blocks) == 1);
|
||||
|
||||
(void) assignOneDataBlock(&block, taosArrayGet(pRetrieveBlock->blocks, 0));
|
||||
(void)assignOneDataBlock(&block, taosArrayGet(pRetrieveBlock->blocks, 0));
|
||||
block.info.type = STREAM_PULL_OVER;
|
||||
block.info.childId = pTask->info.selfChildId;
|
||||
|
||||
|
@ -140,7 +140,7 @@ void streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, int64_t* to
|
|||
stError("s-task:%s failed to add retrieve block", pTask->id.idStr);
|
||||
}
|
||||
|
||||
stDebug("s-task:%s(child %d) retrieve process completed, reqId:0x%" PRIx64 " dump results", pTask->id.idStr,
|
||||
stDebug("s-task:%s(child %d) retrieve process completed, QID:0x%" PRIx64 " dump results", pTask->id.idStr,
|
||||
pTask->info.selfChildId, pRetrieveBlock->reqId);
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ static void streamScanHistoryDataImpl(SStreamTask* pTask, SArray* pRes, int32_t*
|
|||
}
|
||||
|
||||
SSDataBlock block = {0};
|
||||
(void) assignOneDataBlock(&block, output);
|
||||
(void)assignOneDataBlock(&block, output);
|
||||
block.info.childId = pTask->info.selfChildId;
|
||||
|
||||
void* p = taosArrayPush(pRes, &block);
|
||||
|
@ -259,7 +259,8 @@ static void streamScanHistoryDataImpl(SStreamTask* pTask, SArray* pRes, int32_t*
|
|||
stError("s-task:%s failed to add computing results, the final res may be incorrect", pTask->id.idStr);
|
||||
}
|
||||
|
||||
(*pSize) += blockDataGetSize(output) + sizeof(SSDataBlock) + sizeof(SColumnInfoData) * blockDataGetNumOfCols(&block);
|
||||
(*pSize) +=
|
||||
blockDataGetSize(output) + sizeof(SSDataBlock) + sizeof(SColumnInfoData) * blockDataGetNumOfCols(&block);
|
||||
numOfBlocks += 1;
|
||||
|
||||
if (numOfBlocks >= STREAM_RESULT_DUMP_THRESHOLD || (*pSize) >= STREAM_RESULT_DUMP_SIZE_THRESHOLD) {
|
||||
|
@ -283,7 +284,7 @@ SScanhistoryDataInfo streamScanHistoryData(SStreamTask* pTask, int64_t st) {
|
|||
const char* id = pTask->id.idStr;
|
||||
|
||||
if (!pTask->hTaskInfo.operatorOpen) {
|
||||
(void) qSetStreamOpOpen(exec);
|
||||
(void)qSetStreamOpOpen(exec);
|
||||
pTask->hTaskInfo.operatorOpen = true;
|
||||
}
|
||||
|
||||
|
@ -315,13 +316,13 @@ SScanhistoryDataInfo streamScanHistoryData(SStreamTask* pTask, int64_t st) {
|
|||
int32_t size = 0;
|
||||
streamScanHistoryDataImpl(pTask, pRes, &size, &finished);
|
||||
|
||||
if(streamTaskShouldStop(pTask)) {
|
||||
if (streamTaskShouldStop(pTask)) {
|
||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||
return buildScanhistoryExecRet(TASK_SCANHISTORY_QUIT, 0);
|
||||
}
|
||||
|
||||
// dispatch the generated results, todo fix error
|
||||
(void) handleScanhistoryResultBlocks(pTask, pRes, size);
|
||||
(void)handleScanhistoryResultBlocks(pTask, pRes, size);
|
||||
|
||||
if (finished) {
|
||||
return buildScanhistoryExecRet(TASK_SCANHISTORY_CONT, 0);
|
||||
|
@ -346,11 +347,11 @@ int32_t streamTransferStateDoPrepare(SStreamTask* pTask) {
|
|||
stError(
|
||||
"s-task:%s failed to find related stream task:0x%x, it may have been destroyed or closed, destroy the related "
|
||||
"fill-history task",
|
||||
id, (int32_t) pTask->streamTaskId.taskId);
|
||||
id, (int32_t)pTask->streamTaskId.taskId);
|
||||
|
||||
// 1. free it and remove fill-history task from disk meta-store
|
||||
// todo: this function should never be failed.
|
||||
(void) streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, 0);
|
||||
(void)streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, 0);
|
||||
|
||||
// 2. save to disk
|
||||
streamMetaWLock(pMeta);
|
||||
|
@ -408,14 +409,14 @@ int32_t streamTransferStateDoPrepare(SStreamTask* pTask) {
|
|||
pStreamTask->id.idStr, TASK_LEVEL__SOURCE, pTimeWindow->skey, pTimeWindow->ekey, INT64_MIN,
|
||||
pTimeWindow->ekey, p, pStreamTask->status.schedStatus);
|
||||
|
||||
(void) streamTaskResetTimewindowFilter(pStreamTask);
|
||||
(void)streamTaskResetTimewindowFilter(pStreamTask);
|
||||
} else {
|
||||
stDebug("s-task:%s no need to update/reset filter time window for non-source tasks", pStreamTask->id.idStr);
|
||||
}
|
||||
|
||||
// NOTE: transfer the ownership of executor state before handle the checkpoint block during stream exec
|
||||
// 2. send msg to mnode to launch a checkpoint to keep the state for current stream
|
||||
(void) streamTaskSendCheckpointReq(pStreamTask);
|
||||
(void)streamTaskSendCheckpointReq(pStreamTask);
|
||||
|
||||
// 3. assign the status to the value that will be kept in disk
|
||||
pStreamTask->status.taskStatus = streamTaskGetStatus(pStreamTask).state;
|
||||
|
@ -429,7 +430,7 @@ int32_t streamTransferStateDoPrepare(SStreamTask* pTask) {
|
|||
|
||||
static int32_t haltCallback(SStreamTask* pTask, void* param) {
|
||||
streamTaskOpenAllUpstreamInput(pTask);
|
||||
(void) streamTaskSendCheckpointReq(pTask);
|
||||
(void)streamTaskSendCheckpointReq(pTask);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -549,7 +550,7 @@ void streamProcessTransstateBlock(SStreamTask* pTask, SStreamDataBlock* pBlock)
|
|||
pBlock->srcVgId = pTask->pMeta->vgId;
|
||||
code = taosWriteQitem(pTask->outputq.queue->pQueue, pBlock);
|
||||
if (code == 0) {
|
||||
(void) streamDispatchStreamBlock(pTask);
|
||||
(void)streamDispatchStreamBlock(pTask);
|
||||
} else { // todo put into queue failed, retry
|
||||
streamFreeQitem((SStreamQueueItem*)pBlock);
|
||||
}
|
||||
|
@ -568,7 +569,7 @@ void streamProcessTransstateBlock(SStreamTask* pTask, SStreamDataBlock* pBlock)
|
|||
}
|
||||
}
|
||||
|
||||
//static void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime) { pTask->status.schedIdleTime = idleTime; }
|
||||
// static void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime) { pTask->status.schedIdleTime = idleTime; }
|
||||
static void setLastExecTs(SStreamTask* pTask, int64_t ts) { pTask->status.lastExecTs = ts; }
|
||||
|
||||
static void doStreamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pBlock, int32_t num) {
|
||||
|
@ -581,7 +582,7 @@ static void doStreamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pBlock, i
|
|||
stDebug("s-task:%s start to process batch blocks, num:%d, type:%s", id, num, streamQueueItemGetTypeStr(pBlock->type));
|
||||
|
||||
int32_t code = doSetStreamInputBlock(pTask, pBlock, &ver, id);
|
||||
if(code) {
|
||||
if (code) {
|
||||
stError("s-task:%s failed to set input block, not exec for these blocks", id);
|
||||
return;
|
||||
}
|
||||
|
@ -627,8 +628,8 @@ void flushStateDataInExecutor(SStreamTask* pTask, SStreamQueueItem* pCheckpointB
|
|||
SStreamTask* pHTask = NULL;
|
||||
int32_t code = streamMetaAcquireTask(pTask->pMeta, pHTaskId->streamId, pHTaskId->taskId, &pHTask);
|
||||
if (code == TSDB_CODE_SUCCESS) { // ignore the error code.
|
||||
(void) streamTaskReleaseState(pHTask);
|
||||
(void) streamTaskReloadState(pTask);
|
||||
(void)streamTaskReleaseState(pHTask);
|
||||
(void)streamTaskReloadState(pTask);
|
||||
stDebug("s-task:%s transfer state from fill-history task:%s, status:%s completed", id, pHTask->id.idStr,
|
||||
streamTaskGetStatus(pHTask).name);
|
||||
// todo execute qExecTask to fetch the reload-generated result, if this is stream is for session window query.
|
||||
|
@ -707,7 +708,7 @@ static int32_t doStreamExecTask(SStreamTask* pTask) {
|
|||
// dispatch checkpoint msg to all downstream tasks
|
||||
int32_t type = pInput->type;
|
||||
if (type == STREAM_INPUT__CHECKPOINT_TRIGGER) {
|
||||
(void) streamProcessCheckpointTriggerBlock(pTask, (SStreamDataBlock*)pInput);
|
||||
(void)streamProcessCheckpointTriggerBlock(pTask, (SStreamDataBlock*)pInput);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -750,7 +751,7 @@ static int32_t doStreamExecTask(SStreamTask* pTask) {
|
|||
SStreamTaskState pState = streamTaskGetStatus(pTask);
|
||||
if (pState.state == TASK_STATUS__CK) {
|
||||
stDebug("s-task:%s checkpoint block received, set status:%s", id, pState.name);
|
||||
(void) streamTaskBuildCheckpoint(pTask); // ignore this error msg, and continue
|
||||
(void)streamTaskBuildCheckpoint(pTask); // ignore this error msg, and continue
|
||||
} else { // todo refactor
|
||||
int32_t code = 0;
|
||||
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||
|
@ -804,7 +805,7 @@ void streamResumeTask(SStreamTask* pTask) {
|
|||
const char* id = pTask->id.idStr;
|
||||
|
||||
while (1) {
|
||||
(void) doStreamExecTask(pTask);
|
||||
(void)doStreamExecTask(pTask);
|
||||
|
||||
// check if continue
|
||||
streamMutexLock(&pTask->lock);
|
||||
|
|
|
@ -1092,7 +1092,7 @@ static int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq*
|
|||
}
|
||||
|
||||
// enqueue
|
||||
stDebug("s-task:%s (vgId:%d level:%d) recv retrieve req from task:0x%x(vgId:%d), reqId:0x%" PRIx64, pTask->id.idStr,
|
||||
stDebug("s-task:%s (vgId:%d level:%d) recv retrieve req from task:0x%x(vgId:%d), QID:0x%" PRIx64, pTask->id.idStr,
|
||||
pTask->pMeta->vgId, pTask->info.taskLevel, pReq->srcTaskId, pReq->srcNodeId, pReq->reqId);
|
||||
|
||||
pData->type = STREAM_INPUT__DATA_RETRIEVE;
|
||||
|
|
|
@ -57,14 +57,12 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
}
|
||||
|
||||
if (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
||||
if (pMsg->term > raftStoreGetTerm(ths)) {
|
||||
if (pMsg->term != raftStoreGetTerm(ths)) {
|
||||
syncLogRecvAppendEntriesReply(ths, pMsg, "error term");
|
||||
syncNodeStepDown(ths, pMsg->term);
|
||||
return TSDB_CODE_SYN_WRONG_TERM;
|
||||
}
|
||||
|
||||
ASSERT(pMsg->term == raftStoreGetTerm(ths));
|
||||
|
||||
sTrace("vgId:%d, received append entries reply. srcId:0x%016" PRIx64 ", term:%" PRId64 ", matchIndex:%" PRId64 "",
|
||||
pMsg->vgId, pMsg->srcId.addr, pMsg->term, pMsg->matchIndex);
|
||||
|
||||
|
|
|
@ -57,7 +57,10 @@ int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) { return pSyncNode->qu
|
|||
bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index) {
|
||||
int count = 0;
|
||||
SSyncIndexMgr* pMatches = pNode->pMatchIndex;
|
||||
ASSERT(pNode->replicaNum == pMatches->replicaNum);
|
||||
if (pNode->replicaNum != pMatches->replicaNum) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return false;
|
||||
};
|
||||
|
||||
for (int i = 0; i < pNode->totalReplicaNum; i++) {
|
||||
if(pNode->raftCfg.cfg.nodeInfo[i].nodeRole == TAOS_SYNC_ROLE_VOTER){
|
||||
|
|
|
@ -119,7 +119,7 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
|
|||
}
|
||||
|
||||
ret = syncNodeRequestVotePeers(pSyncNode);
|
||||
ASSERT(ret == 0);
|
||||
if (ret != 0) return ret;
|
||||
|
||||
syncNodeResetElectTimer(pSyncNode);
|
||||
return ret;
|
||||
|
|
|
@ -988,9 +988,18 @@ static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) {
|
|||
|
||||
int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) {
|
||||
int32_t code = 0;
|
||||
ASSERTS(pNode->pLogStore != NULL, "log store not created");
|
||||
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
||||
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
||||
if (pNode->pLogStore == NULL) {
|
||||
sError("vgId:%d, log store not created", pNode->vgId);
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
if (pNode->pFsm == NULL) {
|
||||
sError("vgId:%d, pFsm not registered", pNode->vgId);
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
if (pNode->pFsm->FpGetSnapshotInfo == NULL) {
|
||||
sError("vgId:%d, FpGetSnapshotInfo not registered", pNode->vgId);
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
SSnapshot snapshot = {0};
|
||||
// TODO check return value
|
||||
(void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||
|
@ -1384,8 +1393,14 @@ void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
|||
|
||||
int32_t syncNodeRestore(SSyncNode* pSyncNode) {
|
||||
int32_t code = 0;
|
||||
ASSERTS(pSyncNode->pLogStore != NULL, "log store not created");
|
||||
ASSERTS(pSyncNode->pLogBuf != NULL, "ring log buffer not created");
|
||||
if (pSyncNode->pLogStore == NULL) {
|
||||
sError("vgId:%d, log store not created", pSyncNode->vgId);
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
if (pSyncNode->pLogBuf == NULL) {
|
||||
sError("vgId:%d, ring log buffer not created", pSyncNode->vgId);
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
(void)taosThreadMutexLock(&pSyncNode->pLogBuf->mutex);
|
||||
SyncIndex lastVer = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
|
||||
|
@ -1400,7 +1415,7 @@ int32_t syncNodeRestore(SSyncNode* pSyncNode) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
ASSERT(endIndex == lastVer + 1);
|
||||
if (endIndex != lastVer + 1) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
pSyncNode->commitIndex = TMAX(pSyncNode->commitIndex, commitIndex);
|
||||
sInfo("vgId:%d, restore sync until commitIndex:%" PRId64, pSyncNode->vgId, pSyncNode->commitIndex);
|
||||
|
||||
|
@ -1743,7 +1758,10 @@ inline bool syncNodeInConfig(SSyncNode* pNode, const SSyncCfg* pCfg) {
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(b1 == b2);
|
||||
if (b1 != b2) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return false;
|
||||
}
|
||||
return b1;
|
||||
}
|
||||
|
||||
|
@ -2194,7 +2212,7 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
|
|||
}
|
||||
|
||||
SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
|
||||
// ASSERT(lastIndex >= 0);
|
||||
|
||||
sInfo("vgId:%d, become leader. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64 "", pSyncNode->vgId,
|
||||
raftStoreGetTerm(pSyncNode), pSyncNode->commitIndex, lastIndex);
|
||||
}
|
||||
|
@ -2222,7 +2240,7 @@ void syncNodeFollower2Candidate(SSyncNode* pSyncNode) {
|
|||
}
|
||||
|
||||
int32_t syncNodeAssignedLeader2Leader(SSyncNode* pSyncNode) {
|
||||
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER);
|
||||
if (pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
syncNodeBecomeLeader(pSyncNode, "assigned leader to leader");
|
||||
|
||||
sNTrace(pSyncNode, "assigned leader to leader");
|
||||
|
|
|
@ -71,16 +71,32 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
|
|||
goto _err;
|
||||
}
|
||||
|
||||
ASSERT(index == pBuf->endIndex);
|
||||
if (index != pBuf->endIndex) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _err;
|
||||
};
|
||||
|
||||
SSyncRaftEntry* pExist = pBuf->entries[index % pBuf->size].pItem;
|
||||
ASSERT(pExist == NULL);
|
||||
if (pExist != NULL) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// initial log buffer with at least one item, e.g. commitIndex
|
||||
SSyncRaftEntry* pMatch = pBuf->entries[(index - 1 + pBuf->size) % pBuf->size].pItem;
|
||||
ASSERTS(pMatch != NULL, "no matched log entry");
|
||||
ASSERT(pMatch->index + 1 == index);
|
||||
ASSERT(pMatch->term <= pEntry->term);
|
||||
if (pMatch == NULL) {
|
||||
sError("vgId:%d, no matched log entry", pNode->vgId);
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
if (pMatch->index + 1 != index) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
if (!(pMatch->term <= pEntry->term)) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = pMatch->index, .prevLogTerm = pMatch->term};
|
||||
pBuf->entries[index % pBuf->size] = tmp;
|
||||
|
@ -114,7 +130,7 @@ int32_t syncLogReplGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncI
|
|||
TAOS_RETURN(TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||
}
|
||||
|
||||
ASSERT(index - 1 == prevIndex);
|
||||
if (index - 1 != prevIndex) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
if (prevIndex >= pBuf->startIndex) {
|
||||
pEntry = pBuf->entries[(prevIndex + pBuf->size) % pBuf->size].pItem;
|
||||
|
@ -178,9 +194,18 @@ int32_t syncLogValidateAlignmentOfCommit(SSyncNode* pNode, SyncIndex commitIndex
|
|||
}
|
||||
|
||||
int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
||||
ASSERTS(pNode->pLogStore != NULL, "log store not created");
|
||||
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
||||
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
||||
if (pNode->pLogStore == NULL) {
|
||||
sError("log store not created");
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
if (pNode->pFsm == NULL) {
|
||||
sError("pFsm not registered");
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
if (pNode->pFsm->FpGetSnapshotInfo == NULL) {
|
||||
sError("FpGetSnapshotInfo not registered");
|
||||
return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
int32_t code = 0, lino = 0;
|
||||
SSnapshot snapshot = {0};
|
||||
|
@ -191,7 +216,8 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
|||
TAOS_CHECK_EXIT(syncLogValidateAlignmentOfCommit(pNode, commitIndex));
|
||||
|
||||
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
||||
ASSERT(lastVer >= commitIndex);
|
||||
if (lastVer < commitIndex) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
;
|
||||
SyncIndex toIndex = lastVer;
|
||||
// update match index
|
||||
pBuf->commitIndex = commitIndex;
|
||||
|
@ -239,7 +265,7 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
|||
|
||||
// put a dummy record at commitIndex if present in log buffer
|
||||
if (takeDummy) {
|
||||
ASSERT(index == pBuf->commitIndex);
|
||||
if (index != pBuf->commitIndex) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
SSyncRaftEntry* pDummy = syncEntryBuildDummy(commitTerm, commitIndex, pNode->vgId);
|
||||
if (pDummy == NULL) {
|
||||
|
@ -392,9 +418,18 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
|
|||
}
|
||||
|
||||
// update
|
||||
ASSERT(pBuf->startIndex < index);
|
||||
ASSERT(index - pBuf->startIndex < pBuf->size);
|
||||
ASSERT(pBuf->entries[index % pBuf->size].pItem == NULL);
|
||||
if (!(pBuf->startIndex < index)) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
};
|
||||
if (!(index - pBuf->startIndex < pBuf->size)) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
if (pBuf->entries[index % pBuf->size].pItem != NULL) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = prevIndex, .prevLogTerm = prevTerm};
|
||||
pEntry = NULL;
|
||||
pBuf->entries[index % pBuf->size] = tmp;
|
||||
|
@ -422,14 +457,14 @@ static inline bool syncLogStoreNeedFlush(SSyncRaftEntry* pEntry, int32_t replica
|
|||
|
||||
int32_t syncLogStorePersist(SSyncLogStore* pLogStore, SSyncNode* pNode, SSyncRaftEntry* pEntry) {
|
||||
int32_t code = 0;
|
||||
ASSERT(pEntry->index >= 0);
|
||||
if (pEntry->index < 0) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
SyncIndex lastVer = pLogStore->syncLogLastIndex(pLogStore);
|
||||
if (lastVer >= pEntry->index && (code = pLogStore->syncLogTruncate(pLogStore, pEntry->index)) < 0) {
|
||||
sError("failed to truncate log store since %s. from index:%" PRId64 "", tstrerror(code), pEntry->index);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
lastVer = pLogStore->syncLogLastIndex(pLogStore);
|
||||
ASSERT(pEntry->index == lastVer + 1);
|
||||
if (pEntry->index != lastVer + 1) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
bool doFsync = syncLogStoreNeedFlush(pEntry, pNode->replicaNum);
|
||||
if ((code = pLogStore->syncLogAppendEntry(pLogStore, pEntry, doFsync)) < 0) {
|
||||
|
@ -439,7 +474,7 @@ int32_t syncLogStorePersist(SSyncLogStore* pLogStore, SSyncNode* pNode, SSyncRaf
|
|||
}
|
||||
|
||||
lastVer = pLogStore->syncLogLastIndex(pLogStore);
|
||||
ASSERT(pEntry->index == lastVer);
|
||||
if (pEntry->index != lastVer) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -718,7 +753,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
|
|||
SyncIndex until = pBuf->commitIndex - TSDB_SYNC_LOG_BUFFER_RETENTION;
|
||||
for (SyncIndex index = pBuf->startIndex; index < until; index++) {
|
||||
SSyncRaftEntry* pEntry = pBuf->entries[(index + pBuf->size) % pBuf->size].pItem;
|
||||
ASSERT(pEntry != NULL);
|
||||
if (pEntry == NULL) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
syncEntryDestroy(pEntry);
|
||||
(void)memset(&pBuf->entries[(index + pBuf->size) % pBuf->size], 0, sizeof(pBuf->entries[0]));
|
||||
pBuf->startIndex = index + 1;
|
||||
|
@ -786,7 +821,10 @@ int32_t syncLogReplRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
|||
|
||||
for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) {
|
||||
int64_t pos = index % pMgr->size;
|
||||
ASSERT(!pMgr->states[pos].barrier || (index == pMgr->startIndex || index + 1 == pMgr->endIndex));
|
||||
if (!(!pMgr->states[pos].barrier || (index == pMgr->startIndex || index + 1 == pMgr->endIndex))) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
|
||||
if (nowMs < pMgr->states[pos].timeMs + retryWaitMs) {
|
||||
break;
|
||||
|
@ -809,7 +847,10 @@ int32_t syncLogReplRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
|||
tstrerror(code), index, pDestId->addr);
|
||||
goto _out;
|
||||
}
|
||||
ASSERT(barrier == pMgr->states[pos].barrier);
|
||||
if (barrier != pMgr->states[pos].barrier) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
pMgr->states[pos].timeMs = nowMs;
|
||||
pMgr->states[pos].term = term;
|
||||
pMgr->states[pos].acked = false;
|
||||
|
@ -839,11 +880,11 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn
|
|||
SSyncLogBuffer* pBuf = pNode->pLogBuf;
|
||||
SRaftId destId = pMsg->srcId;
|
||||
int32_t code = 0;
|
||||
ASSERT(pMgr->restored == false);
|
||||
if (pMgr->restored != false) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
if (pMgr->endIndex == 0) {
|
||||
ASSERT(pMgr->startIndex == 0);
|
||||
ASSERT(pMgr->matchIndex == 0);
|
||||
if (pMgr->startIndex != 0) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
if (pMgr->matchIndex != 0) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
if (pMsg->matchIndex < 0) {
|
||||
pMgr->restored = true;
|
||||
sInfo("vgId:%d, sync log repl restored. peer: dnode:%d (%" PRIx64 "), repl-mgr:[%" PRId64 " %" PRId64 ", %" PRId64
|
||||
|
@ -909,7 +950,7 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn
|
|||
|
||||
if ((index + 1 < firstVer) || (term < 0) ||
|
||||
(term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) {
|
||||
ASSERT(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||
if (!(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
if ((code = syncNodeStartSnapshot(pNode, &destId)) < 0) {
|
||||
sError("vgId:%d, failed to start snapshot for peer dnode:%d", pNode->vgId, DID(&destId));
|
||||
TAOS_RETURN(code);
|
||||
|
@ -918,13 +959,13 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn
|
|||
return 0;
|
||||
}
|
||||
|
||||
ASSERT(index + 1 >= firstVer);
|
||||
if (!(index + 1 >= firstVer)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
if (term == pMsg->lastMatchTerm) {
|
||||
index = index + 1;
|
||||
ASSERT(index <= pNode->pLogBuf->matchIndex);
|
||||
if (!(index <= pNode->pLogBuf->matchIndex)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
} else {
|
||||
ASSERT(index > firstVer);
|
||||
if (!(index > firstVer)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,8 +1016,8 @@ int32_t syncLogReplStart(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
|||
}
|
||||
|
||||
int32_t syncLogReplProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) {
|
||||
ASSERT(!pMgr->restored);
|
||||
ASSERT(pMgr->startIndex >= 0);
|
||||
if (pMgr->restored) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
if (!(pMgr->startIndex >= 0)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
int64_t retryMaxWaitMs = syncGetRetryMaxWaitMs();
|
||||
int64_t nowMs = taosGetMonoTimestampMs();
|
||||
int32_t code = 0;
|
||||
|
@ -996,7 +1037,7 @@ int32_t syncLogReplProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex inde
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
ASSERT(index >= 0);
|
||||
if (!(index >= 0)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
pMgr->states[index % pMgr->size].barrier = barrier;
|
||||
pMgr->states[index % pMgr->size].timeMs = nowMs;
|
||||
pMgr->states[index % pMgr->size].term = term;
|
||||
|
@ -1014,7 +1055,7 @@ int32_t syncLogReplProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex inde
|
|||
}
|
||||
|
||||
int32_t syncLogReplAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
||||
ASSERT(pMgr->restored);
|
||||
if (!pMgr->restored) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
SRaftId* pDestId = &pNode->replicasId[pMgr->peerId];
|
||||
int32_t batchSize = TMAX(1, pMgr->size >> (4 + pMgr->retryBackoff));
|
||||
|
@ -1070,7 +1111,7 @@ int32_t syncLogReplAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
|
|||
}
|
||||
|
||||
int32_t syncLogReplContinue(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) {
|
||||
ASSERT(pMgr->restored == true);
|
||||
if (pMgr->restored != true) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
if (pMgr->startIndex <= pMsg->lastSendIndex && pMsg->lastSendIndex < pMgr->endIndex) {
|
||||
if (pMgr->startIndex < pMgr->matchIndex && pMgr->retryBackoff > 0) {
|
||||
int64_t firstMs = pMgr->states[pMgr->startIndex % pMgr->size].timeMs;
|
||||
|
@ -1100,7 +1141,10 @@ SSyncLogReplMgr* syncLogReplCreate() {
|
|||
|
||||
pMgr->size = sizeof(pMgr->states) / sizeof(pMgr->states[0]);
|
||||
|
||||
ASSERT(pMgr->size == TSDB_SYNC_LOG_BUFFER_SIZE);
|
||||
if (pMgr->size != TSDB_SYNC_LOG_BUFFER_SIZE) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pMgr;
|
||||
}
|
||||
|
@ -1115,7 +1159,7 @@ void syncLogReplDestroy(SSyncLogReplMgr* pMgr) {
|
|||
|
||||
int32_t syncNodeLogReplInit(SSyncNode* pNode) {
|
||||
for (int i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; i++) {
|
||||
ASSERT(pNode->logReplMgrs[i] == NULL);
|
||||
if (pNode->logReplMgrs[i] != NULL) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
pNode->logReplMgrs[i] = syncLogReplCreate();
|
||||
if (pNode->logReplMgrs[i] == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -1141,7 +1185,10 @@ int32_t syncLogBufferCreate(SSyncLogBuffer** ppBuf) {
|
|||
|
||||
pBuf->size = sizeof(pBuf->entries) / sizeof(pBuf->entries[0]);
|
||||
|
||||
ASSERT(pBuf->size == TSDB_SYNC_LOG_BUFFER_SIZE);
|
||||
if (pBuf->size != TSDB_SYNC_LOG_BUFFER_SIZE) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (taosThreadMutexAttrInit(&pBuf->attr) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -1194,7 +1241,7 @@ void syncLogBufferDestroy(SSyncLogBuffer* pBuf) {
|
|||
|
||||
int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex toIndex) {
|
||||
int32_t code = 0;
|
||||
ASSERT(pBuf->commitIndex < toIndex && toIndex <= pBuf->endIndex);
|
||||
if (!(pBuf->commitIndex < toIndex && toIndex <= pBuf->endIndex)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
if (toIndex == pBuf->endIndex) {
|
||||
return 0;
|
||||
|
@ -1217,7 +1264,7 @@ int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex
|
|||
}
|
||||
pBuf->endIndex = toIndex;
|
||||
pBuf->matchIndex = TMIN(pBuf->matchIndex, index);
|
||||
ASSERT(index + 1 == toIndex);
|
||||
if (index + 1 != toIndex) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
// trunc wal
|
||||
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
||||
|
@ -1227,7 +1274,7 @@ int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
||||
ASSERT(toIndex == lastVer + 1);
|
||||
if (toIndex != lastVer + 1) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
// refill buffer on need
|
||||
if (toIndex <= pBuf->startIndex) {
|
||||
|
@ -1237,7 +1284,7 @@ int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(pBuf->endIndex == toIndex);
|
||||
if (pBuf->endIndex != toIndex) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
(void)syncLogBufferValidate(pBuf);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1246,7 +1293,7 @@ int32_t syncLogBufferReset(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
|||
(void)taosThreadMutexLock(&pBuf->mutex);
|
||||
(void)syncLogBufferValidate(pBuf);
|
||||
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
||||
ASSERT(lastVer == pBuf->matchIndex);
|
||||
if (lastVer != pBuf->matchIndex) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
SyncIndex index = pBuf->endIndex - 1;
|
||||
|
||||
(void)syncLogBufferRollback(pBuf, pNode, pBuf->matchIndex + 1);
|
||||
|
|
|
@ -70,7 +70,10 @@ SSyncRaftEntry* syncEntryBuildFromAppendEntries(const SyncAppendEntries* pMsg) {
|
|||
return NULL;
|
||||
}
|
||||
memcpy(pEntry, pMsg->data, pMsg->dataLen);
|
||||
ASSERT(pEntry->bytes == pMsg->dataLen);
|
||||
if (pEntry->bytes != pMsg->dataLen) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,10 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
|||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
pData->pSyncNode = pSyncNode;
|
||||
pData->pWal = pSyncNode->pWal;
|
||||
ASSERT(pData->pWal != NULL);
|
||||
if (pData->pWal == NULL) {
|
||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
(void)taosThreadMutexInit(&(pData->mutex), NULL);
|
||||
pData->pWalHandle = walOpenReader(pData->pWal, NULL, 0);
|
||||
|
@ -115,7 +118,7 @@ void logStoreDestory(SSyncLogStore* pLogStore) {
|
|||
|
||||
// log[m .. n]
|
||||
static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncIndex snapshotIndex) {
|
||||
ASSERT(snapshotIndex >= 0);
|
||||
if (!(snapshotIndex >= 0)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
|
@ -303,14 +306,14 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
|
|||
}
|
||||
|
||||
*ppEntry = syncEntryBuild(pWalHandle->pHead->head.bodyLen);
|
||||
ASSERT(*ppEntry != NULL);
|
||||
if (*ppEntry == NULL) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
(*ppEntry)->msgType = TDMT_SYNC_CLIENT_REQUEST;
|
||||
(*ppEntry)->originalRpcType = pWalHandle->pHead->head.msgType;
|
||||
(*ppEntry)->seqNum = pWalHandle->pHead->head.syncMeta.seqNum;
|
||||
(*ppEntry)->isWeak = pWalHandle->pHead->head.syncMeta.isWeek;
|
||||
(*ppEntry)->term = pWalHandle->pHead->head.syncMeta.term;
|
||||
(*ppEntry)->index = index;
|
||||
ASSERT((*ppEntry)->dataLen == pWalHandle->pHead->head.bodyLen);
|
||||
if ((*ppEntry)->dataLen != pWalHandle->pHead->head.bodyLen) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
(void)memcpy((*ppEntry)->data, pWalHandle->pHead->head.body, pWalHandle->pHead->head.bodyLen);
|
||||
|
||||
/*
|
||||
|
@ -362,14 +365,14 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn
|
|||
static int32_t raftLogGetLastEntry(SSyncLogStore* pLogStore, SSyncRaftEntry** ppLastEntry) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
ASSERT(ppLastEntry != NULL);
|
||||
if (ppLastEntry == NULL) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
*ppLastEntry = NULL;
|
||||
if (walIsEmpty(pWal)) {
|
||||
TAOS_RETURN(TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||
} else {
|
||||
SyncIndex lastIndex = raftLogLastIndex(pLogStore);
|
||||
ASSERT(lastIndex >= SYNC_INDEX_BEGIN);
|
||||
if (!(lastIndex >= SYNC_INDEX_BEGIN)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
int32_t code = raftLogGetEntry(pLogStore, lastIndex, ppLastEntry);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
|
|
@ -104,7 +104,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
syncNodeStepDown(ths, pMsg->term);
|
||||
}
|
||||
SyncTerm currentTerm = raftStoreGetTerm(ths);
|
||||
ASSERT(pMsg->term <= currentTerm);
|
||||
if (!(pMsg->term <= currentTerm)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
bool grant = (pMsg->term == currentTerm) && logOK &&
|
||||
((!raftStoreHasVoted(ths)) || (syncUtilSameId(&ths->raftStore.voteFor, &pMsg->srcId)));
|
||||
|
@ -130,7 +130,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
pReply->destId = pMsg->srcId;
|
||||
pReply->term = currentTerm;
|
||||
pReply->voteGranted = grant;
|
||||
ASSERT(!grant || pMsg->term == pReply->term);
|
||||
if (!(!grant || pMsg->term == pReply->term)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
// trace log
|
||||
syncLogRecvRequestVote(ths, pMsg, pReply->voteGranted, "");
|
||||
|
|
|
@ -64,7 +64,7 @@ int32_t syncNodeOnRequestVoteReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
}
|
||||
|
||||
syncLogRecvRequestVoteReply(ths, pMsg, "");
|
||||
ASSERT(pMsg->term == currentTerm);
|
||||
if (pMsg->term != currentTerm) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
// This tallies votes even when the current state is not Candidate,
|
||||
// but they won't be looked at, so it doesn't matter.
|
||||
|
|
|
@ -57,7 +57,7 @@ static int32_t syncSnapBufferCreate(SSyncSnapBuffer **ppBuf) {
|
|||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
pBuf->size = sizeof(pBuf->entries) / sizeof(void *);
|
||||
ASSERT(pBuf->size == TSDB_SYNC_SNAP_BUFFER_SIZE);
|
||||
if (pBuf->size != TSDB_SYNC_SNAP_BUFFER_SIZE) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
(void)taosThreadMutexInit(&pBuf->mutex, NULL);
|
||||
*ppBuf = pBuf;
|
||||
TAOS_RETURN(0);
|
||||
|
@ -311,7 +311,10 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) {
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(pSender->seq >= SYNC_SNAPSHOT_SEQ_BEGIN && pSender->seq <= SYNC_SNAPSHOT_SEQ_END);
|
||||
if (!(pSender->seq >= SYNC_SNAPSHOT_SEQ_BEGIN && pSender->seq <= SYNC_SNAPSHOT_SEQ_END)) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _OUT;
|
||||
}
|
||||
|
||||
// send msg
|
||||
int32_t blockLen = (pBlk) ? pBlk->blockLen : 0;
|
||||
|
@ -323,7 +326,10 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) {
|
|||
// put in buffer
|
||||
int64_t nowMs = taosGetTimestampMs();
|
||||
if (pBlk) {
|
||||
ASSERT(pBlk->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pBlk->seq < SYNC_SNAPSHOT_SEQ_END);
|
||||
if (!(pBlk->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pBlk->seq < SYNC_SNAPSHOT_SEQ_END)) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _OUT;
|
||||
}
|
||||
pBlk->sendTimeMs = nowMs;
|
||||
pSender->pSndBuf->entries[pSender->seq % pSender->pSndBuf->size] = pBlk;
|
||||
pBlk = NULL;
|
||||
|
@ -351,7 +357,10 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) {
|
|||
|
||||
for (int32_t seq = pSndBuf->cursor + 1; seq < pSndBuf->end; ++seq) {
|
||||
SyncSnapBlock *pBlk = pSndBuf->entries[seq % pSndBuf->size];
|
||||
ASSERT(pBlk);
|
||||
if (!pBlk) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
int64_t nowMs = taosGetTimestampMs();
|
||||
if (pBlk->acked || nowMs < pBlk->sendTimeMs + SYNC_SNAP_RESEND_MS) {
|
||||
continue;
|
||||
|
@ -682,7 +691,7 @@ SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) {
|
|||
|
||||
static int32_t syncSnapReceiverExchgSnapInfo(SSyncNode *pSyncNode, SSyncSnapshotReceiver *pReceiver,
|
||||
SyncSnapshotSend *pMsg, SSnapshot *pInfo) {
|
||||
ASSERT(pMsg->payloadType == TDMT_SYNC_PREP_SNAPSHOT);
|
||||
if (pMsg->payloadType != TDMT_SYNC_PREP_SNAPSHOT) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
int32_t code = 0, lino = 0;
|
||||
|
||||
// copy snap info from leader
|
||||
|
@ -878,7 +887,7 @@ static int32_t syncSnapBufferRecv(SSyncSnapshotReceiver *pReceiver, SyncSnapshot
|
|||
goto _out;
|
||||
}
|
||||
|
||||
ASSERT(pRcvBuf->start <= pRcvBuf->cursor + 1 && pRcvBuf->cursor < pRcvBuf->end);
|
||||
if (!(pRcvBuf->start <= pRcvBuf->cursor + 1 && pRcvBuf->cursor < pRcvBuf->end)) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
if (pMsg->seq > pRcvBuf->cursor) {
|
||||
if (pRcvBuf->entries[pMsg->seq % pRcvBuf->size]) {
|
||||
|
@ -922,7 +931,7 @@ static int32_t syncNodeOnSnapshotReceive(SSyncNode *pSyncNode, SyncSnapshotSend
|
|||
// condition 4
|
||||
// transfering
|
||||
SyncSnapshotSend *pMsg = ppMsg[0];
|
||||
ASSERT(pMsg);
|
||||
if (!pMsg) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver;
|
||||
int64_t timeNow = taosGetTimestampMs();
|
||||
int32_t code = 0;
|
||||
|
@ -1071,7 +1080,7 @@ _out:;
|
|||
}
|
||||
|
||||
static int32_t syncSnapSenderExchgSnapInfo(SSyncNode *pSyncNode, SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) {
|
||||
ASSERT(pMsg->payloadType == TDMT_SYNC_PREP_SNAPSHOT_REPLY);
|
||||
if (pMsg->payloadType != TDMT_SYNC_PREP_SNAPSHOT_REPLY) return TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
|
||||
SSyncTLV *datHead = (void *)pMsg->data;
|
||||
if (datHead->typ != pMsg->payloadType) {
|
||||
|
@ -1168,11 +1177,17 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp
|
|||
goto _out;
|
||||
}
|
||||
|
||||
ASSERT(pSndBuf->start <= pSndBuf->cursor + 1 && pSndBuf->cursor < pSndBuf->end);
|
||||
if (!(pSndBuf->start <= pSndBuf->cursor + 1 && pSndBuf->cursor < pSndBuf->end)) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
|
||||
if (pMsg->ack > pSndBuf->cursor && pMsg->ack < pSndBuf->end) {
|
||||
SyncSnapBlock *pBlk = pSndBuf->entries[pMsg->ack % pSndBuf->size];
|
||||
ASSERT(pBlk);
|
||||
if (!pBlk) {
|
||||
code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||
goto _out;
|
||||
}
|
||||
pBlk->acked = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1133,7 +1133,7 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
|
|||
|
||||
memcpy(pCell + nLocal - sizeof(pgno), &pgno, sizeof(pgno));
|
||||
|
||||
int lastKeyPageSpace = 0;
|
||||
size_t lastKeyPageSpace = 0;
|
||||
// pack left key & val to ovpages
|
||||
do {
|
||||
// cal key to cpy
|
||||
|
|
|
@ -32,12 +32,12 @@ extern "C" {
|
|||
#define tTrace(...) { if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }}
|
||||
#define tDump(x, y) { if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } }
|
||||
|
||||
#define tGTrace(param, ...) do { if (rpcDebugFlag & DEBUG_TRACE){char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", gtid:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define tGFatal(param, ...) do {if (rpcDebugFlag & DEBUG_FATAL){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tFatal(param ", gtid:%s", __VA_ARGS__, buf); }} while (0)
|
||||
#define tGError(param, ...) do { if (rpcDebugFlag & DEBUG_ERROR){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tError(param ", gtid:%s", __VA_ARGS__, buf);} } while(0)
|
||||
#define tGWarn(param, ...) do { if (rpcDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tWarn(param ", gtid:%s", __VA_ARGS__, buf); }} while(0)
|
||||
#define tGInfo(param, ...) do { if (rpcDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tInfo(param ", gtid:%s", __VA_ARGS__, buf); }} while(0)
|
||||
#define tGDebug(param,...) do {if (rpcDebugFlag & DEBUG_DEBUG){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tDebug(param ", gtid:%s", __VA_ARGS__, buf); }} while(0)
|
||||
#define tGTrace(param, ...) do { if (rpcDebugFlag & DEBUG_TRACE){char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", QID:%s", __VA_ARGS__, buf);}} while(0)
|
||||
#define tGFatal(param, ...) do {if (rpcDebugFlag & DEBUG_FATAL){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tFatal(param ", QID:%s", __VA_ARGS__, buf); }} while (0)
|
||||
#define tGError(param, ...) do { if (rpcDebugFlag & DEBUG_ERROR){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tError(param ", QID:%s", __VA_ARGS__, buf);} } while(0)
|
||||
#define tGWarn(param, ...) do { if (rpcDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tWarn(param ", QID:%s", __VA_ARGS__, buf); }} while(0)
|
||||
#define tGInfo(param, ...) do { if (rpcDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tInfo(param ", QID:%s", __VA_ARGS__, buf); }} while(0)
|
||||
#define tGDebug(param,...) do {if (rpcDebugFlag & DEBUG_DEBUG){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tDebug(param ", QID:%s", __VA_ARGS__, buf); }} while(0)
|
||||
|
||||
|
||||
// clang-format on
|
||||
|
|
|
@ -1633,7 +1633,14 @@ int taosCloseCFile(FILE *f) { return fclose(f); }
|
|||
|
||||
int taosSetAutoDelFile(char *path) {
|
||||
#ifdef WINDOWS
|
||||
return SetFileAttributes(path, FILE_ATTRIBUTE_TEMPORARY);
|
||||
bool succ = SetFileAttributes(path, FILE_ATTRIBUTE_TEMPORARY);
|
||||
if (succ) {
|
||||
return 0;
|
||||
} else {
|
||||
DWORD error = GetLastError();
|
||||
terrno = TAOS_SYSTEM_ERROR(error);
|
||||
return terrno;
|
||||
}
|
||||
#else
|
||||
if (-1 == unlink(path)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
|
|
|
@ -266,8 +266,9 @@ void* taosArrayInsert(SArray* pArray, size_t index, const void* pData) {
|
|||
}
|
||||
|
||||
void taosArraySet(SArray* pArray, size_t index, void* pData) {
|
||||
ASSERT(index < pArray->size);
|
||||
if (index < pArray->size) {
|
||||
memcpy(TARRAY_GET_ELEM(pArray, index), pData, pArray->elemSize);
|
||||
}
|
||||
}
|
||||
|
||||
void taosArrayPopFrontBatch(SArray* pArray, size_t cnt) {
|
||||
|
@ -291,7 +292,9 @@ void taosArrayPopTailBatch(SArray* pArray, size_t cnt) {
|
|||
}
|
||||
|
||||
void taosArrayRemove(SArray* pArray, size_t index) {
|
||||
ASSERT(index < pArray->size);
|
||||
if (!(index < pArray->size)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == pArray->size - 1) {
|
||||
(void)taosArrayPop(pArray);
|
||||
|
@ -305,8 +308,7 @@ void taosArrayRemove(SArray* pArray, size_t index) {
|
|||
}
|
||||
|
||||
void taosArrayRemoveBatch(SArray* pArray, size_t index, size_t num, FDelete fp) {
|
||||
ASSERT(index + num <= pArray->size);
|
||||
|
||||
if (index + num <= pArray->size) {
|
||||
if (fp) {
|
||||
for (int32_t i = 0; i < num; i++) {
|
||||
fp(taosArrayGet(pArray, index + i));
|
||||
|
@ -316,6 +318,7 @@ void taosArrayRemoveBatch(SArray* pArray, size_t index, size_t num, FDelete fp)
|
|||
memmove((char*)pArray->pData + index * pArray->elemSize, (char*)pArray->pData + (index + num) * pArray->elemSize,
|
||||
(pArray->size - index - num) * pArray->elemSize);
|
||||
pArray->size -= num;
|
||||
}
|
||||
}
|
||||
|
||||
SArray* taosArrayFromList(const void* src, size_t size, size_t elemSize) {
|
||||
|
@ -349,8 +352,6 @@ SArray* taosArrayDup(const SArray* pSrc, __array_item_dup_fn_t fn) {
|
|||
if (fn == NULL) {
|
||||
memcpy(dst->pData, pSrc->pData, pSrc->elemSize * pSrc->size);
|
||||
} else {
|
||||
ASSERT(pSrc->elemSize == sizeof(void*));
|
||||
|
||||
for (int32_t i = 0; i < pSrc->size; ++i) {
|
||||
void* p = fn(taosArrayGetP(pSrc, i));
|
||||
memcpy(((char*)dst->pData) + i * dst->elemSize, &p, dst->elemSize);
|
||||
|
|
|
@ -78,7 +78,9 @@ _error:
|
|||
}
|
||||
|
||||
int32_t tBloomFilterPutHash(SBloomFilter* pBF, uint64_t hash1, uint64_t hash2) {
|
||||
ASSERT(!tBloomFilterIsFull(pBF));
|
||||
if (tBloomFilterIsFull(pBF)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
bool hasChange = false;
|
||||
const register uint64_t size = pBF->numBits;
|
||||
uint64_t cbHash = hash1;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -121,7 +121,9 @@ int32_t cfgGetSize(SConfig *pCfg) { return taosArrayGetSize(pCfg->array); }
|
|||
|
||||
static int32_t cfgCheckAndSetConf(SConfigItem *pItem, const char *conf) {
|
||||
cfgItemFreeVal(pItem);
|
||||
ASSERT(pItem->str == NULL);
|
||||
if (!(pItem->str == NULL)) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
pItem->str = taosStrdup(conf);
|
||||
if (pItem->str == NULL) {
|
||||
|
|
|
@ -143,24 +143,20 @@ int32_t tdigestCompress(TDigest *t) {
|
|||
|
||||
if (a->mean <= b->mean) {
|
||||
mergeCentroid(&args, a);
|
||||
ASSERTS(args.idx < t->size, "idx over size");
|
||||
i++;
|
||||
} else {
|
||||
mergeCentroid(&args, b);
|
||||
ASSERTS(args.idx < t->size, "idx over size");
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
while (i < num_unmerged) {
|
||||
mergeCentroid(&args, &unmerged_centroids[i++]);
|
||||
ASSERTS(args.idx < t->size, "idx over size");
|
||||
}
|
||||
taosMemoryFree((void *)unmerged_centroids);
|
||||
|
||||
while (j < t->num_centroids) {
|
||||
mergeCentroid(&args, &t->centroids[j++]);
|
||||
ASSERTS(args.idx < t->size, "idx over size");
|
||||
}
|
||||
|
||||
if (t->total_weight > 0) {
|
||||
|
|
|
@ -104,7 +104,6 @@ void tEndEncode(SEncoder* pCoder) {
|
|||
|
||||
if (pCoder->data) {
|
||||
pNode = pCoder->eStack;
|
||||
ASSERT(pNode);
|
||||
pCoder->eStack = pNode->pNext;
|
||||
|
||||
len = pCoder->pos;
|
||||
|
@ -148,7 +147,6 @@ void tEndDecode(SDecoder* pCoder) {
|
|||
SDecoderNode* pNode;
|
||||
|
||||
pNode = pCoder->dStack;
|
||||
ASSERT(pNode);
|
||||
pCoder->dStack = pNode->pNext;
|
||||
|
||||
pCoder->data = pNode->data;
|
||||
|
|
|
@ -1,150 +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 "texception.h"
|
||||
#include "tlog.h"
|
||||
|
||||
static threadlocal SExceptionNode* expList;
|
||||
|
||||
void exceptionPushNode(SExceptionNode* node) {
|
||||
node->prev = expList;
|
||||
expList = node;
|
||||
}
|
||||
|
||||
int32_t exceptionPopNode() {
|
||||
SExceptionNode* node = expList;
|
||||
expList = node->prev;
|
||||
return node->code;
|
||||
}
|
||||
|
||||
void exceptionThrow(int32_t code) {
|
||||
expList->code = code;
|
||||
longjmp(expList->jb, 1);
|
||||
}
|
||||
|
||||
static void cleanupWrapper_void_ptr_ptr(SCleanupAction* ca) {
|
||||
void (*func)(void*, void*) = ca->func;
|
||||
func(ca->arg1.Ptr, ca->arg2.Ptr);
|
||||
}
|
||||
|
||||
static void cleanupWrapper_void_ptr_bool(SCleanupAction* ca) {
|
||||
void (*func)(void*, bool) = ca->func;
|
||||
func(ca->arg1.Ptr, ca->arg2.Bool);
|
||||
}
|
||||
|
||||
static void cleanupWrapper_void_ptr(SCleanupAction* ca) {
|
||||
void (*func)(void*) = ca->func;
|
||||
func(ca->arg1.Ptr);
|
||||
}
|
||||
|
||||
static void cleanupWrapper_int_int(SCleanupAction* ca) {
|
||||
int32_t (*func)(int32_t) = ca->func;
|
||||
(void)func(ca->arg1.Int);
|
||||
}
|
||||
|
||||
static void cleanupWrapper_void(SCleanupAction* ca) {
|
||||
void (*func)() = ca->func;
|
||||
func();
|
||||
}
|
||||
|
||||
static void cleanupWrapper_int_ptr(SCleanupAction* ca) {
|
||||
int32_t (*func)(void*) = ca->func;
|
||||
(void)func(ca->arg1.Ptr);
|
||||
}
|
||||
|
||||
typedef void (*wrapper)(SCleanupAction*);
|
||||
static wrapper wrappers[] = {
|
||||
cleanupWrapper_void_ptr_ptr, cleanupWrapper_void_ptr_bool, cleanupWrapper_void_ptr,
|
||||
cleanupWrapper_int_int, cleanupWrapper_void, cleanupWrapper_int_ptr,
|
||||
};
|
||||
|
||||
void cleanupPush_void_ptr_ptr(bool failOnly, void* func, void* arg1, void* arg2) {
|
||||
ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction");
|
||||
|
||||
SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++;
|
||||
ca->wrapper = 0;
|
||||
ca->failOnly = failOnly;
|
||||
ca->func = func;
|
||||
ca->arg1.Ptr = arg1;
|
||||
ca->arg2.Ptr = arg2;
|
||||
}
|
||||
|
||||
void cleanupPush_void_ptr_bool(bool failOnly, void* func, void* arg1, bool arg2) {
|
||||
ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction");
|
||||
|
||||
SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++;
|
||||
ca->wrapper = 1;
|
||||
ca->failOnly = failOnly;
|
||||
ca->func = func;
|
||||
ca->arg1.Ptr = arg1;
|
||||
ca->arg2.Bool = arg2;
|
||||
}
|
||||
|
||||
void cleanupPush_void_ptr(bool failOnly, void* func, void* arg) {
|
||||
ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction");
|
||||
|
||||
SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++;
|
||||
ca->wrapper = 2;
|
||||
ca->failOnly = failOnly;
|
||||
ca->func = func;
|
||||
ca->arg1.Ptr = arg;
|
||||
}
|
||||
|
||||
void cleanupPush_int_int(bool failOnly, void* func, int32_t arg) {
|
||||
ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction");
|
||||
|
||||
SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++;
|
||||
ca->wrapper = 3;
|
||||
ca->failOnly = failOnly;
|
||||
ca->func = func;
|
||||
ca->arg1.Int = arg;
|
||||
}
|
||||
|
||||
void cleanupPush_void(bool failOnly, void* func) {
|
||||
ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction");
|
||||
|
||||
SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++;
|
||||
ca->wrapper = 4;
|
||||
ca->failOnly = failOnly;
|
||||
ca->func = func;
|
||||
}
|
||||
|
||||
void cleanupPush_int_ptr(bool failOnly, void* func, void* arg) {
|
||||
ASSERTS(expList->numCleanupAction < expList->maxCleanupAction, "numCleanupAction over maxCleanupAction");
|
||||
|
||||
SCleanupAction* ca = expList->cleanupActions + expList->numCleanupAction++;
|
||||
ca->wrapper = 5;
|
||||
ca->failOnly = failOnly;
|
||||
ca->func = func;
|
||||
ca->arg1.Ptr = arg;
|
||||
}
|
||||
|
||||
int32_t cleanupGetActionCount() { return expList->numCleanupAction; }
|
||||
|
||||
static void doExecuteCleanup(SExceptionNode* node, int32_t anchor, bool failed) {
|
||||
while (node->numCleanupAction > anchor) {
|
||||
--node->numCleanupAction;
|
||||
SCleanupAction* ca = node->cleanupActions + node->numCleanupAction;
|
||||
if (failed || !(ca->failOnly)) {
|
||||
wrappers[ca->wrapper](ca);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cleanupExecuteTo(int32_t anchor, bool failed) { doExecuteCleanup(expList, anchor, failed); }
|
||||
|
||||
void cleanupExecute(SExceptionNode* node, bool failed) { doExecuteCleanup(node, 0, failed); }
|
||||
bool cleanupExceedLimit() { return expList->numCleanupAction >= expList->maxCleanupAction; }
|
|
@ -191,14 +191,12 @@ static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry *pe, SH
|
|||
(void)atomic_sub_fetch_16(&pNode->refCount, 1);
|
||||
if (prev != NULL) {
|
||||
prev->next = pNewNode;
|
||||
ASSERT(prev->next != prev);
|
||||
} else {
|
||||
pe->next = pNewNode;
|
||||
}
|
||||
|
||||
if (pNode->refCount <= 0) {
|
||||
pNewNode->next = pNode->next;
|
||||
ASSERT(pNewNode->next != pNewNode);
|
||||
|
||||
FREE_HASH_NODE(pHashObj->freeFp, pNode);
|
||||
} else {
|
||||
|
@ -508,7 +506,6 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
|
|||
pe->next = pNode->next;
|
||||
} else {
|
||||
prevNode->next = pNode->next;
|
||||
ASSERT(prevNode->next != prevNode);
|
||||
}
|
||||
|
||||
pe->num--;
|
||||
|
@ -759,12 +756,10 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) {
|
|||
if (pOld->refCount <= 0) {
|
||||
if (prevNode) {
|
||||
prevNode->next = pOld->next;
|
||||
ASSERT(prevNode->next != prevNode);
|
||||
} else {
|
||||
pe->next = pOld->next;
|
||||
SHashNode *x = pe->next;
|
||||
if (x != NULL) {
|
||||
ASSERT(x->next != x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@ struct SLRUEntry {
|
|||
#define TAOS_LRU_ENTRY_REF(h) (++(h)->refs)
|
||||
|
||||
static bool taosLRUEntryUnref(SLRUEntry *entry) {
|
||||
ASSERT(entry->refs > 0);
|
||||
// ASSERT(entry->refs > 0);
|
||||
--entry->refs;
|
||||
return entry->refs == 0;
|
||||
}
|
||||
|
||||
static void taosLRUEntryFree(SLRUEntry *entry) {
|
||||
ASSERT(entry->refs == 0);
|
||||
// ASSERT(entry->refs == 0);
|
||||
|
||||
if (entry->deleter) {
|
||||
(*entry->deleter)(entry->keyData, entry->keyLength, entry->value, entry->ud);
|
||||
|
@ -129,7 +129,7 @@ static void taosLRUEntryTableApply(SLRUEntryTable *table, _taos_lru_table_func_t
|
|||
SLRUEntry *h = table->list[i];
|
||||
while (h) {
|
||||
SLRUEntry *n = h->nextHash;
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(h));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(h));
|
||||
func(h);
|
||||
h = n;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ static int taosLRUEntryTableApplyF(SLRUEntryTable *table, _taos_lru_functor_t fu
|
|||
SLRUEntry *h = table->list[i];
|
||||
while (h) {
|
||||
SLRUEntry *n = h->nextHash;
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(h));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(h));
|
||||
ret = functor(h->keyData, h->keyLength, h->value, ud);
|
||||
if (ret) {
|
||||
return ret;
|
||||
|
@ -205,7 +205,7 @@ static void taosLRUEntryTableResize(SLRUEntryTable *table) {
|
|||
++count;
|
||||
}
|
||||
}
|
||||
ASSERT(table->elems == count);
|
||||
// ASSERT(table->elems == count);
|
||||
|
||||
taosMemoryFree(table->list);
|
||||
table->list = newList;
|
||||
|
@ -261,16 +261,16 @@ struct SLRUCacheShard {
|
|||
static void taosLRUCacheShardMaintainPoolSize(SLRUCacheShard *shard) {
|
||||
while (shard->highPriPoolUsage > shard->highPriPoolCapacity) {
|
||||
shard->lruLowPri = shard->lruLowPri->next;
|
||||
ASSERT(shard->lruLowPri != &shard->lru);
|
||||
// ASSERT(shard->lruLowPri != &shard->lru);
|
||||
TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(shard->lruLowPri, false);
|
||||
|
||||
ASSERT(shard->highPriPoolUsage >= shard->lruLowPri->totalCharge);
|
||||
// ASSERT(shard->highPriPoolUsage >= shard->lruLowPri->totalCharge);
|
||||
shard->highPriPoolUsage -= shard->lruLowPri->totalCharge;
|
||||
}
|
||||
}
|
||||
|
||||
static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||
ASSERT(e->next == NULL && e->prev == NULL);
|
||||
// ASSERT(e->next == NULL && e->prev == NULL);
|
||||
|
||||
if (shard->highPriPoolRatio > 0 && (TAOS_LRU_ENTRY_IS_HIGH_PRI(e) || TAOS_LRU_ENTRY_HAS_HIT(e))) {
|
||||
e->next = &shard->lru;
|
||||
|
@ -297,7 +297,7 @@ static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) {
|
|||
}
|
||||
|
||||
static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||
ASSERT(e->next && e->prev);
|
||||
// ASSERT(e->next && e->prev);
|
||||
|
||||
if (shard->lruLowPri == e) {
|
||||
shard->lruLowPri = e->prev;
|
||||
|
@ -306,10 +306,10 @@ static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
|||
e->prev->next = e->next;
|
||||
e->prev = e->next = NULL;
|
||||
|
||||
ASSERT(shard->lruUsage >= e->totalCharge);
|
||||
// ASSERT(shard->lruUsage >= e->totalCharge);
|
||||
shard->lruUsage -= e->totalCharge;
|
||||
if (TAOS_LRU_ENTRY_IN_HIGH_POOL(e)) {
|
||||
ASSERT(shard->highPriPoolUsage >= e->totalCharge);
|
||||
// ASSERT(shard->highPriPoolUsage >= e->totalCharge);
|
||||
shard->highPriPoolUsage -= e->totalCharge;
|
||||
}
|
||||
}
|
||||
|
@ -317,13 +317,13 @@ static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
|||
static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArray *deleted) {
|
||||
while (shard->usage + charge > shard->capacity && shard->lru.next != &shard->lru) {
|
||||
SLRUEntry *old = shard->lru.next;
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old));
|
||||
|
||||
taosLRUCacheShardLRURemove(shard, old);
|
||||
(void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash);
|
||||
|
||||
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
||||
ASSERT(shard->usage >= old->totalCharge);
|
||||
// ASSERT(shard->usage >= old->totalCharge);
|
||||
shard->usage -= old->totalCharge;
|
||||
|
||||
(void)taosArrayPush(deleted, &old);
|
||||
|
@ -332,6 +332,9 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr
|
|||
|
||||
static void taosLRUCacheShardSetCapacity(SLRUCacheShard *shard, size_t capacity) {
|
||||
SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES);
|
||||
if (!lastReferenceList) {
|
||||
return;
|
||||
}
|
||||
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
|
@ -411,11 +414,11 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *
|
|||
if (old != NULL) {
|
||||
status = TAOS_LRU_STATUS_OK_OVERWRITTEN;
|
||||
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old));
|
||||
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
||||
if (!TAOS_LRU_ENTRY_HAS_REFS(old)) {
|
||||
taosLRUCacheShardLRURemove(shard, old);
|
||||
ASSERT(shard->usage >= old->totalCharge);
|
||||
// ASSERT(shard->usage >= old->totalCharge);
|
||||
shard->usage -= old->totalCharge;
|
||||
|
||||
(void)taosArrayPush(lastReferenceList, &old);
|
||||
|
@ -476,7 +479,7 @@ static LRUHandle *taosLRUCacheShardLookup(SLRUCacheShard *shard, const void *key
|
|||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
e = taosLRUEntryTableLookup(&shard->table, key, keyLen, hash);
|
||||
if (e != NULL) {
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
||||
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
||||
taosLRUCacheShardLRURemove(shard, e);
|
||||
}
|
||||
|
@ -495,12 +498,12 @@ static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_
|
|||
|
||||
SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, key, keyLen, hash);
|
||||
if (e != NULL) {
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
||||
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
||||
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
||||
taosLRUCacheShardLRURemove(shard, e);
|
||||
|
||||
ASSERT(shard->usage >= e->totalCharge);
|
||||
// ASSERT(shard->usage >= e->totalCharge);
|
||||
shard->usage -= e->totalCharge;
|
||||
lastReference = true;
|
||||
}
|
||||
|
@ -532,11 +535,11 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
|
|||
|
||||
while (shard->lru.next != &shard->lru) {
|
||||
SLRUEntry *old = shard->lru.next;
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old));
|
||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old));
|
||||
taosLRUCacheShardLRURemove(shard, old);
|
||||
(void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash);
|
||||
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
||||
ASSERT(shard->usage >= old->totalCharge);
|
||||
// ASSERT(shard->usage >= old->totalCharge);
|
||||
shard->usage -= old->totalCharge;
|
||||
|
||||
(void)taosArrayPush(lastReferenceList, &old);
|
||||
|
@ -557,7 +560,7 @@ static bool taosLRUCacheShardRef(SLRUCacheShard *shard, LRUHandle *handle) {
|
|||
SLRUEntry *e = (SLRUEntry *)handle;
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
ASSERT(TAOS_LRU_ENTRY_HAS_REFS(e));
|
||||
// ASSERT(TAOS_LRU_ENTRY_HAS_REFS(e));
|
||||
TAOS_LRU_ENTRY_REF(e);
|
||||
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
@ -578,7 +581,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
|||
lastReference = taosLRUEntryUnref(e);
|
||||
if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) {
|
||||
if (shard->usage > shard->capacity || eraseIfLastRef) {
|
||||
ASSERT(shard->lru.next == &shard->lru || eraseIfLastRef);
|
||||
// ASSERT(shard->lru.next == &shard->lru || eraseIfLastRef);
|
||||
|
||||
(void)taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash);
|
||||
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
||||
|
@ -590,7 +593,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
|||
}
|
||||
|
||||
if (lastReference && e->value) {
|
||||
ASSERT(shard->usage >= e->totalCharge);
|
||||
// ASSERT(shard->usage >= e->totalCharge);
|
||||
shard->usage -= e->totalCharge;
|
||||
}
|
||||
|
||||
|
@ -628,7 +631,7 @@ static size_t taosLRUCacheShardGetPinnedUsage(SLRUCacheShard *shard) {
|
|||
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
ASSERT(shard->usage >= shard->lruUsage);
|
||||
// ASSERT(shard->usage >= shard->lruUsage);
|
||||
usage = shard->usage - shard->lruUsage;
|
||||
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
@ -698,9 +701,11 @@ SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoo
|
|||
size_t perShard = (capacity + (numShards - 1)) / numShards;
|
||||
for (int i = 0; i < numShards; ++i) {
|
||||
if (TSDB_CODE_SUCCESS !=
|
||||
taosLRUCacheShardInit(&cache->shards[i], perShard, strictCapacity, highPriPoolRatio, 32 - numShardBits))
|
||||
taosLRUCacheShardInit(&cache->shards[i], perShard, strictCapacity, highPriPoolRatio, 32 - numShardBits)) {
|
||||
taosMemoryFree(cache);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
cache->numShards = numShards;
|
||||
|
||||
|
@ -718,7 +723,7 @@ void taosLRUCacheCleanup(SLRUCache *cache) {
|
|||
if (cache) {
|
||||
if (cache->shards) {
|
||||
int numShards = cache->numShards;
|
||||
ASSERT(numShards > 0);
|
||||
// ASSERT(numShards > 0);
|
||||
for (int i = 0; i < numShards; ++i) {
|
||||
taosLRUCacheShardCleanup(&cache->shards[i]);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "tpagedbuf.h"
|
||||
#include "taoserror.h"
|
||||
#include "tcompression.h"
|
||||
#include "tsimplehash.h"
|
||||
#include "tlog.h"
|
||||
#include "tsimplehash.h"
|
||||
|
||||
#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES)
|
||||
#define BUF_PAGE_IN_MEM(_p) ((_p)->pData != NULL)
|
||||
|
@ -38,7 +38,7 @@ struct SDiskbasedBuf {
|
|||
int32_t inMemPages; // numOfPages that are allocated in memory
|
||||
SList* freePgList; // free page list
|
||||
SArray* pIdList; // page id list
|
||||
SSHashObj*all;
|
||||
SSHashObj* all;
|
||||
SList* lruList;
|
||||
void* emptyDummyIdList; // dummy id list
|
||||
void* assistBuf; // assistant buffer for compress/decompress data
|
||||
|
@ -95,7 +95,8 @@ static int32_t doDecompressData(void* data, int32_t srcSize, int32_t* dst, SDisk
|
|||
} else if (*dst < 0) {
|
||||
return terrno;
|
||||
}
|
||||
return code;;
|
||||
return code;
|
||||
;
|
||||
}
|
||||
|
||||
static uint64_t allocateNewPositionInFile(SDiskbasedBuf* pBuf, size_t size) {
|
||||
|
@ -300,7 +301,6 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) {
|
|||
SPageInfo* pageInfo = *(SPageInfo**)pn->data;
|
||||
|
||||
SPageInfo* p = *(SPageInfo**)(pageInfo->pData);
|
||||
ASSERT(pageInfo->pageId >= 0 && pageInfo->pn == pn && p == pageInfo);
|
||||
|
||||
if (!pageInfo->used) {
|
||||
break;
|
||||
|
@ -538,8 +538,6 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
|
|||
#endif
|
||||
return (void*)(GET_PAYLOAD_DATA(*pi));
|
||||
} else { // not in memory
|
||||
ASSERT((!BUF_PAGE_IN_MEM(*pi)) && (*pi)->pn == NULL &&
|
||||
(((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1)));
|
||||
|
||||
bool newPage = false;
|
||||
(*pi)->pData = doExtractPage(pBuf, &newPage);
|
||||
|
|
|
@ -263,7 +263,6 @@ static void rbtree_delete_fixup(rbtree_t *rbtree, rbnode_t *child, rbnode_t *chi
|
|||
child_parent->color = BLACK;
|
||||
return;
|
||||
}
|
||||
ASSERTS(sibling != RBTREE_NULL, "sibling is NULL");
|
||||
|
||||
/* get a new sibling, by rotating at sibling. See which child
|
||||
of sibling is red */
|
||||
|
@ -293,11 +292,9 @@ static void rbtree_delete_fixup(rbtree_t *rbtree, rbnode_t *child, rbnode_t *chi
|
|||
sibling->color = child_parent->color;
|
||||
child_parent->color = BLACK;
|
||||
if (child_parent->right == child) {
|
||||
ASSERTS(sibling->left->color == RED, "slibing->left->color=%d not equal RED", sibling->left->color);
|
||||
sibling->left->color = BLACK;
|
||||
rbtree_rotate_right(rbtree, child_parent);
|
||||
} else {
|
||||
ASSERTS(sibling->right->color == RED, "slibing->right->color=%d not equal RED", sibling->right->color);
|
||||
sibling->right->color = BLACK;
|
||||
rbtree_rotate_left(rbtree, child_parent);
|
||||
}
|
||||
|
@ -320,18 +317,15 @@ static void swap_np(rbnode_t **x, rbnode_t **y) {
|
|||
/** Update parent pointers of child trees of 'parent' */
|
||||
static void change_parent_ptr(rbtree_t *rbtree, rbnode_t *parent, rbnode_t *old, rbnode_t *new) {
|
||||
if (parent == RBTREE_NULL) {
|
||||
ASSERTS(rbtree->root == old, "root not equal old");
|
||||
if (rbtree->root == old) rbtree->root = new;
|
||||
return;
|
||||
}
|
||||
ASSERT(parent->left == old || parent->right == old || parent->left == new || parent->right == new);
|
||||
if (parent->left == old) parent->left = new;
|
||||
if (parent->right == old) parent->right = new;
|
||||
}
|
||||
/** Update parent pointer of a node 'child' */
|
||||
static void change_child_ptr(rbtree_t *rbtree, rbnode_t *child, rbnode_t *old, rbnode_t *new) {
|
||||
if (child == RBTREE_NULL) return;
|
||||
ASSERT(child->parent == old || child->parent == new);
|
||||
if (child->parent == old) child->parent = new;
|
||||
}
|
||||
|
||||
|
@ -376,7 +370,6 @@ rbnode_t *rbtree_delete(rbtree_t *rbtree, void *key) {
|
|||
|
||||
/* now delete to_delete (which is at the location where the smright previously was) */
|
||||
}
|
||||
ASSERT(to_delete->left == RBTREE_NULL || to_delete->right == RBTREE_NULL);
|
||||
|
||||
if (to_delete->left != RBTREE_NULL)
|
||||
child = to_delete->left;
|
||||
|
|
|
@ -261,8 +261,7 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons
|
|||
static FORCE_INLINE SHNode *doSearchInEntryList(SSHashObj *pHashObj, const void *key, size_t keyLen, int32_t index) {
|
||||
SHNode *pNode = pHashObj->hashList[index];
|
||||
while (pNode) {
|
||||
const char* p = GET_SHASH_NODE_KEY(pNode, pNode->dataLen);
|
||||
ASSERT(keyLen > 0);
|
||||
const char *p = GET_SHASH_NODE_KEY(pNode, pNode->dataLen);
|
||||
|
||||
if (pNode->keyLen == keyLen && ((*(pHashObj->equalFp))(p, key, keyLen) == 0)) {
|
||||
break;
|
||||
|
|
|
@ -366,51 +366,6 @@ void *tSkipListDestroyIter(SSkipListIterator *iter) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) {
|
||||
if (pSkipList == NULL || pSkipList->level < nlevel || nlevel <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSkipListNode *p = SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, nlevel - 1);
|
||||
|
||||
int32_t id = 1;
|
||||
char *prev = NULL;
|
||||
|
||||
while (p != pSkipList->pTail) {
|
||||
char *key = SL_GET_NODE_KEY(pSkipList, p);
|
||||
if (prev != NULL) {
|
||||
ASSERT(pSkipList->comparFn(prev, key) < 0);
|
||||
}
|
||||
|
||||
switch (pSkipList->type) {
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
fprintf(stdout, "%d: %d\n", id++, *(int32_t *)key);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
fprintf(stdout, "%d: %" PRId64 " \n", id++, *(int64_t *)key);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
case TSDB_DATA_TYPE_GEOMETRY:
|
||||
fprintf(stdout, "%d: %s \n", id++, key);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
fprintf(stdout, "%d: %lf \n", id++, *(double *)key);
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
prev = SL_GET_NODE_KEY(pSkipList, p);
|
||||
|
||||
p = SL_NODE_GET_FORWARD_POINTER(p, nlevel - 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **direction, SSkipListNode *pNode, bool isForward) {
|
||||
for (int32_t i = 0; i < pNode->level; ++i) {
|
||||
SSkipListNode *x = direction[i];
|
||||
|
@ -538,33 +493,6 @@ static bool tSkipListGetPosToPut(SSkipList *pSkipList, SSkipListNode **backward,
|
|||
return hasDupKey;
|
||||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
static void tSkipListRemoveNodeImpl(SSkipList *pSkipList, SSkipListNode *pNode) {
|
||||
int32_t level = pNode->level;
|
||||
uint8_t dupMode = SL_DUP_MODE(pSkipList);
|
||||
ASSERT(dupMode != SL_DISCARD_DUP_KEY && dupMode != SL_UPDATE_DUP_KEY);
|
||||
|
||||
for (int32_t j = level - 1; j >= 0; --j) {
|
||||
SSkipListNode *prev = SL_NODE_GET_BACKWARD_POINTER(pNode, j);
|
||||
SSkipListNode *next = SL_NODE_GET_FORWARD_POINTER(pNode, j);
|
||||
|
||||
SL_NODE_GET_FORWARD_POINTER(prev, j) = next;
|
||||
SL_NODE_GET_BACKWARD_POINTER(next, j) = prev;
|
||||
}
|
||||
|
||||
tSkipListFreeNode(pNode);
|
||||
pSkipList->size--;
|
||||
}
|
||||
|
||||
// Function must be called after calling tSkipListRemoveNodeImpl() function
|
||||
static void tSkipListCorrectLevel(SSkipList *pSkipList) {
|
||||
while (pSkipList->level > 0 &&
|
||||
SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == pSkipList->pTail) {
|
||||
pSkipList->level -= 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED_FUNC static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList,
|
||||
int32_t level) { // record link count in each level
|
||||
#if SKIP_LIST_RECORD_PERFORMANCE
|
||||
|
|
|
@ -124,7 +124,6 @@ char **strsplit(char *z, const char *delim, int32_t *num) {
|
|||
if (split == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ASSERTS(NULL != split, "realloc memory failed. size=%d", (int32_t)POINTER_BYTES * size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue