diff --git a/documentation/tdenginedocs-cn/administrator/index.html b/documentation/tdenginedocs-cn/administrator/index.html
index 553313505f..eaaf04ff95 100644
--- a/documentation/tdenginedocs-cn/administrator/index.html
+++ b/documentation/tdenginedocs-cn/administrator/index.html
@@ -55,7 +55,7 @@
enableMonitor: 系统监测标志位,0:关闭,1:打开
logDir: 日志文件目录,缺省是/var/log/taos
numOfLogLines:日志文件的最大行数
-debugFlag: 系统debug日志开关,131:仅错误和报警信息,135:所有
+debugFlag: 系统debug日志开关,131:仅错误和报警信息,135:调试信息,143:非常详细的调试信息
不同应用场景的数据往往具有不同的数据特征,比如保留天数、副本数、采集频次、记录大小、采集点的数量、压缩等都可完全不同。为获得在存储上的最高效率,TDengine提供如下存储相关的系统配置参数:
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
index ac1894369d..00fa1a1479 100644
--- a/src/client/CMakeLists.txt
+++ b/src/client/CMakeLists.txt
@@ -34,7 +34,9 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
VERSION_INFO)
MESSAGE(STATUS "build version ${VERSION_INFO}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)
-
+
+ ADD_SUBDIRECTORY(tests)
+
ELSEIF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32)
diff --git a/src/client/inc/tscLog.h b/src/client/inc/tscLog.h
index dfa15049e5..c395951742 100644
--- a/src/client/inc/tscLog.h
+++ b/src/client/inc/tscLog.h
@@ -23,12 +23,17 @@ extern "C" {
#include "tlog.h"
extern int32_t cDebugFlag;
+extern int32_t tscEmbedded;
-#define tscError(...) { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR TSC ", cDebugFlag, __VA_ARGS__); }}
-#define tscWarn(...) { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); }}
-#define tscTrace(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }}
-#define tscDump(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); }}
-#define tscPrint(...) { taosPrintLog("TSC ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
+#define tscFatal(...) { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
+#define tscError(...) { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
+#define tscWarn(...) { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
+#define tscInfo(...) { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC INFO ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }}
+#define tscDebug(...) { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC DEBUG ", cDebugFlag, __VA_ARGS__); }}
+#define tscTrace(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC TRACE ", cDebugFlag, __VA_ARGS__); }}
+
+#define tscDebugDump(...) { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC DEBUG ", cDebugFlag, __VA_ARGS__); }}
+#define tscTraceDump(...) { if (cDebugFlag & DEBUG_TRACE) { taosPrintLongString("TSC TRACE ", cDebugFlag, __VA_ARGS__); }}
#ifdef __cplusplus
}
diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h
index 29abff7685..471db9c99f 100644
--- a/src/client/inc/tsclient.h
+++ b/src/client/inc/tsclient.h
@@ -171,11 +171,7 @@ typedef struct STableDataBlocks {
* to avoid it to be removed from cache
*/
STableMeta *pTableMeta;
-
- union {
- char *filename;
- char *pData;
- };
+ char *pData;
// for parameter ('?') binding
uint32_t numOfAllocedParams;
@@ -398,7 +394,7 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code) ;
int doAsyncParseSql(SSqlObj* pSql);
void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, void (*fp)(), void *param, const char *sqlstr, size_t sqlLen);
-void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql);
+void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql);
void tscKillSTableQuery(SSqlObj *pSql);
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
bool tscIsUpdateQuery(SSqlObj* pSql);
diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c
index 4ec63e9c6d..d070fad11b 100644
--- a/src/client/src/TSDBJNIConnector.c
+++ b/src/client/src/TSDBJNIConnector.c
@@ -22,26 +22,15 @@
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
-#define jniError(...) \
- { \
- if (jniDebugFlag & DEBUG_ERROR) { \
- taosPrintLog("ERROR JNI ", jniDebugFlag, __VA_ARGS__); \
- } \
- }
-#define jniWarn(...) \
- { \
- if (jniDebugFlag & DEBUG_WARN) { \
- taosPrintLog("WARN JNI ", jniDebugFlag, __VA_ARGS__); \
- } \
- }
-#define jniTrace(...) \
- { \
- if (jniDebugFlag & DEBUG_TRACE) { \
- taosPrintLog("JNI ", jniDebugFlag, __VA_ARGS__); \
- } \
- }
-#define jniPrint(...) \
- { taosPrintLog("JNI ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
+#define jniFatal(...) { if (jniDebugFlag & DEBUG_FATAL) { taosPrintLog("JNI FATAL ", tscEmbedded ? 255 : jniDebugFlag, __VA_ARGS__); }}
+#define jniError(...) { if (jniDebugFlag & DEBUG_ERROR) { taosPrintLog("JNI ERROR ", tscEmbedded ? 255 : jniDebugFlag, __VA_ARGS__); }}
+#define jniWarn(...) { if (jniDebugFlag & DEBUG_WARN) { taosPrintLog("JNI WARN ", tscEmbedded ? 255 : jniDebugFlag, __VA_ARGS__); }}
+#define jniInfo(...) { if (jniDebugFlag & DEBUG_INFO) { taosPrintLog("JNI INFO ", tscEmbedded ? 255 : jniDebugFlag, __VA_ARGS__); }}
+#define jniDebug(...) { if (jniDebugFlag & DEBUG_DEBUG) { taosPrintLog("JNI DEBUG ", jniDebugFlag, __VA_ARGS__); }}
+#define jniTrace(...) { if (jniDebugFlag & DEBUG_TRACE) { taosPrintLog("JNI TRACE ", jniDebugFlag, __VA_ARGS__); }}
+
+#define jniDebugDump(...) { if (jniDebugFlag & DEBUG_DEBUG) { taosPrintLongString("JNI DEBUG ", jniDebugFlag, __VA_ARGS__); }}
+#define jniTraceDump(...) { if (jniDebugFlag & DEBUG_TRACE) { taosPrintLongString("JNI DEBUG ", jniDebugFlag, __VA_ARGS__); }}
int __init = 0;
@@ -130,7 +119,7 @@ void jniGetGlobalMethod(JNIEnv *env) {
(*env)->DeleteLocalRef(env, rowdataClass);
atomic_store_32(&__init, 2);
- jniTrace("native method register finished");
+ jniDebug("native method register finished");
}
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setAllocModeImp(JNIEnv *env, jobject jobj, jint jMode,
@@ -158,13 +147,13 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *e
}
jniGetGlobalMethod(env);
- jniTrace("jni initialized successfully, config directory: %s", configDir);
+ jniDebug("jni initialized successfully, config directory: %s", configDir);
}
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv *env, jobject jobj, jint optionIndex,
jstring optionValue) {
if (optionValue == NULL) {
- jniTrace("option index:%d value is null", optionIndex);
+ jniDebug("option index:%d value is null", optionIndex);
return 0;
}
@@ -174,27 +163,27 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv
const char *locale = (*env)->GetStringUTFChars(env, optionValue, NULL);
if (locale && strlen(locale) != 0) {
res = taos_options(TSDB_OPTION_LOCALE, locale);
- jniTrace("set locale to %s, result:%d", locale, res);
+ jniDebug("set locale to %s, result:%d", locale, res);
} else {
- jniTrace("input locale is empty");
+ jniDebug("input locale is empty");
}
(*env)->ReleaseStringUTFChars(env, optionValue, locale);
} else if (optionIndex == TSDB_OPTION_CHARSET) {
const char *charset = (*env)->GetStringUTFChars(env, optionValue, NULL);
if (charset && strlen(charset) != 0) {
res = taos_options(TSDB_OPTION_CHARSET, charset);
- jniTrace("set character encoding to %s, result:%d", charset, res);
+ jniDebug("set character encoding to %s, result:%d", charset, res);
} else {
- jniTrace("input character encoding is empty");
+ jniDebug("input character encoding is empty");
}
(*env)->ReleaseStringUTFChars(env, optionValue, charset);
} else if (optionIndex == TSDB_OPTION_TIMEZONE) {
const char *tz1 = (*env)->GetStringUTFChars(env, optionValue, NULL);
if (tz1 && strlen(tz1) != 0) {
res = taos_options(TSDB_OPTION_TIMEZONE, tz1);
- jniTrace("set timezone to %s, result:%d", tz1, res);
+ jniDebug("set timezone to %s, result:%d", tz1, res);
} else {
- jniTrace("input timezone is empty");
+ jniDebug("input timezone is empty");
}
(*env)->ReleaseStringUTFChars(env, optionValue, tz1);
} else {
@@ -227,10 +216,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn
}
if (user == NULL) {
- jniTrace("jobj:%p, user is null, use default user %s", jobj, TSDB_DEFAULT_USER);
+ jniDebug("jobj:%p, user is null, use default user %s", jobj, TSDB_DEFAULT_USER);
}
if (pass == NULL) {
- jniTrace("jobj:%p, pass is null, use default password", jobj);
+ jniDebug("jobj:%p, pass is null, use default password", jobj);
}
/*
@@ -244,7 +233,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn
jniError("jobj:%p, conn:%p, connect to database failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
(char *)host, (char *)user, (char *)dbname, jport);
} else {
- jniTrace("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
+ jniDebug("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
(char *)host, (char *)user, (char *)dbname, jport);
}
@@ -282,7 +271,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(
// todo handle error
}
- jniTrace("jobj:%p, conn:%p, sql:%s", jobj, tscon, dst);
+ jniDebug("jobj:%p, conn:%p, sql:%s", jobj, tscon, dst);
SSqlObj *pSql = taos_query(tscon, dst);
int32_t code = taos_errno(pSql);
@@ -293,9 +282,9 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(
int32_t affectRows = 0;
if (pSql->cmd.command == TSDB_SQL_INSERT) {
affectRows = taos_affected_rows(pSql);
- jniTrace("jobj:%p, conn:%p, code:%s, affect rows:%d", jobj, tscon, tstrerror(code), affectRows);
+ jniDebug("jobj:%p, conn:%p, code:%s, affect rows:%d", jobj, tscon, tstrerror(code), affectRows);
} else {
- jniTrace("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
+ jniDebug("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
}
}
@@ -343,10 +332,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp(
if (tscIsUpdateQuery(pSql)) {
// taos_free_result(pSql); // free result here
- jniTrace("jobj:%p, conn:%p, no resultset, %p", jobj, pObj, (void *)tres);
+ jniDebug("jobj:%p, conn:%p, no resultset, %p", jobj, pObj, (void *)tres);
return 0;
} else {
- jniTrace("jobj:%p, conn:%p, get resultset, %p", jobj, pObj, (void *)tres);
+ jniDebug("jobj:%p, conn:%p, get resultset, %p", jobj, pObj, (void *)tres);
return tres;
}
}
@@ -365,7 +354,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(
}
taos_free_result((void *)res);
- jniTrace("jobj:%p, conn:%p, free resultset:%p", jobj, tscon, (void *)res);
+ jniDebug("jobj:%p, conn:%p, free resultset:%p", jobj, tscon, (void *)res);
return JNI_SUCCESS;
}
@@ -383,7 +372,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getAffectedRowsIm
}
jint ret = taos_affected_rows((SSqlObj *)res);
- jniTrace("jobj:%p, conn:%p, sql:%p, res: %p, affect rows:%d", jobj, tscon, (void *)con, (void *)res, ret);
+ jniDebug("jobj:%p, conn:%p, sql:%p, res: %p, affect rows:%d", jobj, tscon, (void *)con, (void *)res, ret);
return ret;
}
@@ -412,7 +401,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
jniError("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, (void *)res, num_fields);
return JNI_NUM_OF_FIELDS_0;
} else {
- jniTrace("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, (void *)res, num_fields);
+ jniDebug("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, (void *)res, num_fields);
for (int i = 0; i < num_fields; ++i) {
jobject metadataObj = (*env)->NewObject(env, g_metadataClass, g_metadataConstructFp);
(*env)->SetIntField(env, metadataObj, g_metadataColtypeField, fields[i].type);
@@ -471,10 +460,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
if (row == NULL) {
int tserrno = taos_errno(result);
if (tserrno == 0) {
- jniTrace("jobj:%p, conn:%p, resultset:%p, fields size is %d, fetch row to the end", jobj, tscon, (void*)res, num_fields);
+ jniDebug("jobj:%p, conn:%p, resultset:%p, fields size is %d, fetch row to the end", jobj, tscon, (void*)res, num_fields);
return JNI_FETCH_END;
} else {
- jniTrace("jobj:%p, conn:%p, interruptted query", jobj, tscon);
+ jniDebug("jobj:%p, conn:%p, interruptted query", jobj, tscon);
return JNI_RESULT_SET_NULL;
}
}
@@ -542,7 +531,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeConnectionIm
jniError("jobj:%p, connection is already closed", jobj);
return JNI_CONNECTION_NULL;
} else {
- jniTrace("jobj:%p, conn:%p, close connection success", jobj, tscon);
+ jniDebug("jobj:%p, conn:%p, close connection success", jobj, tscon);
taos_close(tscon);
return JNI_SUCCESS;
}
@@ -556,7 +545,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_subscribeImp(JNI
char *sql = NULL;
jniGetGlobalMethod(env);
- jniTrace("jobj:%p, in TSDBJNIConnector_subscribeImp", jobj);
+ jniDebug("jobj:%p, in TSDBJNIConnector_subscribeImp", jobj);
if (jtopic != NULL) {
topic = (char *)(*env)->GetStringUTFChars(env, jtopic, NULL);
@@ -566,7 +555,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_subscribeImp(JNI
}
if (topic == NULL || sql == NULL) {
- jniTrace("jobj:%p, invalid argument: topic or sql is NULL", jobj);
+ jniDebug("jobj:%p, invalid argument: topic or sql is NULL", jobj);
return sub;
}
@@ -574,9 +563,9 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_subscribeImp(JNI
sub = (jlong)tsub;
if (sub == 0) {
- jniTrace("jobj:%p, failed to subscribe: topic:%s", jobj, topic);
+ jniDebug("jobj:%p, failed to subscribe: topic:%s", jobj, topic);
} else {
- jniTrace("jobj:%p, successfully subscribe: topic: %s", jobj, topic);
+ jniDebug("jobj:%p, successfully subscribe: topic: %s", jobj, topic);
}
(*env)->ReleaseStringUTFChars(env, jtopic, topic);
@@ -586,7 +575,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_subscribeImp(JNI
}
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_consumeImp(JNIEnv *env, jobject jobj, jlong sub) {
- jniTrace("jobj:%p, in TSDBJNIConnector_consumeImp, sub:%lld", jobj, sub);
+ jniDebug("jobj:%p, in TSDBJNIConnector_consumeImp, sub:%lld", jobj, sub);
jniGetGlobalMethod(env);
TAOS_SUB *tsub = (TAOS_SUB *)sub;
@@ -629,7 +618,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
}
int code = taos_validate_sql(tscon, dst);
- jniTrace("jobj:%p, conn:%p, code is %d", jobj, tscon, code);
+ jniDebug("jobj:%p, conn:%p, code is %d", jobj, tscon, code);
free(dst);
return code;
diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c
index 2b99d23099..0bfee46b4b 100644
--- a/src/client/src/tscAsync.c
+++ b/src/client/src/tscAsync.c
@@ -55,7 +55,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
strtolower(pSql->sqlstr, sqlstr);
- tscDump("%p SQL: %s", pSql, pSql->sqlstr);
+ tscDebugDump("%p SQL: %s", pSql, pSql->sqlstr);
pSql->cmd.curSql = pSql->sqlstr;
int32_t code = tsParseSql(pSql, true);
@@ -361,7 +361,7 @@ void tscProcessAsyncRes(SSchedMsg *pMsg) {
}
if (shouldFree) {
- tscTrace("%p sqlObj is automatically freed in async res", pSql);
+ tscDebug("%p sqlObj is automatically freed in async res", pSql);
tscFreeSqlObj(pSql);
}
}
@@ -385,7 +385,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
void tscQueueAsyncRes(SSqlObj *pSql) {
if (pSql == NULL || pSql->signature != pSql) {
- tscTrace("%p SqlObj is freed, not add into queue async res", pSql);
+ tscDebug("%p SqlObj is freed, not add into queue async res", pSql);
return;
} else {
tscError("%p add into queued async res, code:%s", pSql, tstrerror(pSql->res.code));
@@ -401,12 +401,12 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
void tscProcessAsyncFree(SSchedMsg *pMsg) {
SSqlObj *pSql = (SSqlObj *)pMsg->ahandle;
- tscTrace("%p sql is freed", pSql);
+ tscDebug("%p sql is freed", pSql);
taos_free_result(pSql);
}
void tscQueueAsyncFreeResult(SSqlObj *pSql) {
- tscTrace("%p sqlObj put in queue to async free", pSql);
+ tscDebug("%p sqlObj put in queue to async free", pSql);
SSchedMsg schedMsg = { 0 };
schedMsg.fp = tscProcessAsyncFree;
@@ -436,7 +436,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
// check if it is a sub-query of super table query first, if true, enter another routine
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY)) {
- tscTrace("%p update table meta in local cache, continue to process sql and send corresponding subquery", pSql);
+ tscDebug("%p update table meta in local cache, continue to process sql and send corresponding subquery", pSql);
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
code = tscGetTableMeta(pSql, pTableMetaInfo);
@@ -462,7 +462,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
}
} else { // continue to process normal async query
if (pCmd->parseFinished) {
- tscTrace("%p update table meta in local cache, continue to process sql and send corresponding query", pSql);
+ tscDebug("%p update table meta in local cache, continue to process sql and send corresponding query", pSql);
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
code = tscGetTableMeta(pSql, pTableMetaInfo);
@@ -481,7 +481,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
// code = tscSendMsgToServer(pSql);
// if (code == TSDB_CODE_SUCCESS) return;
} else {
- tscTrace("%p continue parse sql after get table meta", pSql);
+ tscDebug("%p continue parse sql after get table meta", pSql);
code = tsParseSql(pSql, false);
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STMT_INSERT)) {
@@ -522,14 +522,14 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
}
if (pSql->pStream) {
- tscTrace("%p stream:%p meta is updated, start new query, command:%d", pSql, pSql->pStream, pSql->cmd.command);
+ tscDebug("%p stream:%p meta is updated, start new query, command:%d", pSql, pSql->pStream, pSql->cmd.command);
if (!pSql->cmd.parseFinished) {
tsParseSql(pSql, false);
sem_post(&pSql->rspSem);
}
return;
} else {
- tscTrace("%p get tableMeta successfully", pSql);
+ tscDebug("%p get tableMeta successfully", pSql);
}
tscDoQuery(pSql);
diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c
index d5e3126f71..afdad05b43 100644
--- a/src/client/src/tscFunctionImpl.c
+++ b/src/client/src/tscFunctionImpl.c
@@ -962,7 +962,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
} else if (pCtx->inputType == TSDB_DATA_TYPE_INT) {
int32_t *data = (int32_t *)pOutput;
#if defined(_DEBUG_VIEW)
- tscTrace("max value updated according to pre-cal:%d", *data);
+ tscDebug("max value updated according to pre-cal:%d", *data);
#endif
if ((*data < val) ^ isMin) {
@@ -1022,7 +1022,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
*notNullElems += 1;
}
#if defined(_DEBUG_VIEW)
- tscTrace("max value updated:%d", *retVal);
+ tscDebug("max value updated:%d", *retVal);
#endif
} else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) {
TYPED_LOOPCHECK_N(int64_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems);
@@ -1704,7 +1704,7 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind
if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[index]) {
#if defined(_DEBUG_VIEW)
- tscTrace("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData);
+ tscDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData);
#endif
memcpy(pCtx->aOutputBuf, pData, pCtx->inputBytes);
@@ -3973,7 +3973,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo) {
double resultVal = ((double)diff) / duration;
- tscTrace("do_calc_rate() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " resultVal:%f",
+ tscDebug("do_calc_rate() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " resultVal:%f",
pRateInfo->isIRate, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, resultVal);
return resultVal;
@@ -4009,12 +4009,12 @@ static void rate_function(SQLFunctionCtx *pCtx) {
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
TSKEY *primaryKey = pCtx->ptsList;
- tscTrace("%p rate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
+ tscDebug("%p rate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
for (int32_t i = 0; i < pCtx->size; ++i) {
char *pData = GET_INPUT_CHAR_INDEX(pCtx, i);
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
- tscTrace("%p rate_function() index of null data:%d", pCtx, i);
+ tscDebug("%p rate_function() index of null data:%d", pCtx, i);
continue;
}
@@ -4042,19 +4042,19 @@ static void rate_function(SQLFunctionCtx *pCtx) {
pRateInfo->firstValue = v;
pRateInfo->firstKey = primaryKey[i];
- tscTrace("firstValue:%" PRId64 " firstKey:%" PRId64, pRateInfo->firstValue, pRateInfo->firstKey);
+ tscDebug("firstValue:%" PRId64 " firstKey:%" PRId64, pRateInfo->firstValue, pRateInfo->firstKey);
}
if (INT64_MIN == pRateInfo->lastValue) {
pRateInfo->lastValue = v;
} else if (v < pRateInfo->lastValue) {
pRateInfo->CorrectionValue += pRateInfo->lastValue;
- tscTrace("CorrectionValue:%" PRId64, pRateInfo->CorrectionValue);
+ tscDebug("CorrectionValue:%" PRId64, pRateInfo->CorrectionValue);
}
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[i];
- tscTrace("lastValue:%" PRId64 " lastKey:%" PRId64, pRateInfo->lastValue, pRateInfo->lastKey);
+ tscDebug("lastValue:%" PRId64 " lastKey:%" PRId64, pRateInfo->lastValue, pRateInfo->lastKey);
}
if (!pCtx->hasNull) {
@@ -4117,7 +4117,7 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[index];
- tscTrace("====%p rate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " CorrectionValue:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->CorrectionValue);
+ tscDebug("====%p rate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " CorrectionValue:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->CorrectionValue);
SET_VAL(pCtx, 1, 1);
@@ -4137,7 +4137,7 @@ static void rate_func_merge(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
assert(pResInfo->superTableQ);
- tscTrace("rate_func_merge() size:%d", pCtx->size);
+ tscDebug("rate_func_merge() size:%d", pCtx->size);
//SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
SRateInfo *pBuf = (SRateInfo *)pCtx->aOutputBuf;
@@ -4154,7 +4154,7 @@ static void rate_func_merge(SQLFunctionCtx *pCtx) {
numOfNotNull++;
memcpy(pBuf, pInput, sizeof(SRateInfo));
- tscTrace("%p rate_func_merge() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64,
+ tscDebug("%p rate_func_merge() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64,
pCtx, pInput->isIRate, pInput->firstKey, pInput->lastKey, pInput->firstValue, pInput->lastValue, pInput->CorrectionValue);
}
@@ -4177,7 +4177,7 @@ static void rate_func_copy(SQLFunctionCtx *pCtx) {
pResInfo->hasResult = ((SRateInfo*)pCtx->aInputElemBuf)->hasResult;
SRateInfo* pRateInfo = (SRateInfo*)pCtx->aInputElemBuf;
- tscTrace("%p rate_func_second_merge() firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
+ tscDebug("%p rate_func_second_merge() firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
pCtx, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, pRateInfo->hasResult);
}
@@ -4187,7 +4187,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
- tscTrace("%p isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
+ tscDebug("%p isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d",
pCtx, pRateInfo->isIRate, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, pRateInfo->hasResult);
if (pRateInfo->hasResult != DATA_SET_FLAG) {
@@ -4197,7 +4197,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
*(double*)pCtx->aOutputBuf = do_calc_rate(pRateInfo);
- tscTrace("rate_finalizer() output result:%f", *(double *)pCtx->aOutputBuf);
+ tscDebug("rate_finalizer() output result:%f", *(double *)pCtx->aOutputBuf);
// cannot set the numOfIteratedElems again since it is set during previous iteration
pResInfo->numOfRes = 1;
@@ -4214,7 +4214,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
TSKEY *primaryKey = pCtx->ptsList;
- tscTrace("%p irate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
+ tscDebug("%p irate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
if (pCtx->size < 1) {
return;
@@ -4223,7 +4223,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
for (int32_t i = pCtx->size - 1; i >= 0; --i) {
char *pData = GET_INPUT_CHAR_INDEX(pCtx, i);
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
- tscTrace("%p irate_function() index of null data:%d", pCtx, i);
+ tscDebug("%p irate_function() index of null data:%d", pCtx, i);
continue;
}
@@ -4252,7 +4252,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[i];
- tscTrace("%p irate_function() lastValue:%" PRId64 " lastKey:%" PRId64, pCtx, pRateInfo->lastValue, pRateInfo->lastKey);
+ tscDebug("%p irate_function() lastValue:%" PRId64 " lastKey:%" PRId64, pCtx, pRateInfo->lastValue, pRateInfo->lastKey);
continue;
}
@@ -4260,7 +4260,7 @@ static void irate_function(SQLFunctionCtx *pCtx) {
pRateInfo->firstValue = v;
pRateInfo->firstKey = primaryKey[i];
- tscTrace("%p irate_function() firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, pRateInfo->firstValue, pRateInfo->firstKey);
+ tscDebug("%p irate_function() firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, pRateInfo->firstValue, pRateInfo->firstKey);
break;
}
}
@@ -4313,7 +4313,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
pRateInfo->lastValue = v;
pRateInfo->lastKey = primaryKey[index];
- tscTrace("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey);
+ tscDebug("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey);
SET_VAL(pCtx, 1, 1);
@@ -4337,7 +4337,7 @@ static void do_sumrate_merge(SQLFunctionCtx *pCtx) {
for (int32_t i = 0; i < pCtx->size; ++i, input += pCtx->inputBytes) {
SRateInfo *pInput = (SRateInfo *)input;
- tscTrace("%p do_sumrate_merge() hasResult:%d input num:%" PRId64 " input sum:%f total num:%" PRId64 " total sum:%f", pCtx, pInput->hasResult, pInput->num, pInput->sum, pRateInfo->num, pRateInfo->sum);
+ tscDebug("%p do_sumrate_merge() hasResult:%d input num:%" PRId64 " input sum:%f total num:%" PRId64 " total sum:%f", pCtx, pInput->hasResult, pInput->num, pInput->sum, pRateInfo->num, pRateInfo->sum);
if (pInput->hasResult != DATA_SET_FLAG) {
continue;
@@ -4360,12 +4360,12 @@ static void do_sumrate_merge(SQLFunctionCtx *pCtx) {
}
static void sumrate_func_merge(SQLFunctionCtx *pCtx) {
- tscTrace("%p sumrate_func_merge() process ...", pCtx);
+ tscDebug("%p sumrate_func_merge() process ...", pCtx);
do_sumrate_merge(pCtx);
}
static void sumrate_func_second_merge(SQLFunctionCtx *pCtx) {
- tscTrace("%p sumrate_func_second_merge() process ...", pCtx);
+ tscDebug("%p sumrate_func_second_merge() process ...", pCtx);
do_sumrate_merge(pCtx);
}
@@ -4373,7 +4373,7 @@ static void sumrate_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
SRateInfo *pRateInfo = (SRateInfo *)pResInfo->interResultBuf;
- tscTrace("%p sumrate_finalizer() superTableQ:%d num:%" PRId64 " sum:%f hasResult:%d", pCtx, pResInfo->superTableQ, pRateInfo->num, pRateInfo->sum, pRateInfo->hasResult);
+ tscDebug("%p sumrate_finalizer() superTableQ:%d num:%" PRId64 " sum:%f hasResult:%d", pCtx, pResInfo->superTableQ, pRateInfo->num, pRateInfo->sum, pRateInfo->hasResult);
if (pRateInfo->hasResult != DATA_SET_FLAG) {
setNull(pCtx->aOutputBuf, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c
index a731fbae8e..0ce64df647 100644
--- a/src/client/src/tscLocalMerge.c
+++ b/src/client/src/tscLocalMerge.c
@@ -177,7 +177,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
for (int32_t i = 0; i < numOfBuffer; ++i) {
int32_t len = pMemBuffer[i]->fileMeta.flushoutData.nLength;
if (len == 0) {
- tscTrace("%p no data retrieved from orderOfVnode:%d", pSql, i + 1);
+ tscDebug("%p no data retrieved from orderOfVnode:%d", pSql, i + 1);
continue;
}
@@ -186,7 +186,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
if (numOfFlush == 0 || numOfBuffer == 0) {
tscLocalReducerEnvDestroy(pMemBuffer, pDesc, finalmodel, numOfBuffer);
- tscTrace("%p retrieved no data", pSql);
+ tscDebug("%p retrieved no data", pSql);
return;
}
@@ -219,7 +219,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer->numOfVnode = numOfBuffer;
pReducer->pDesc = pDesc;
- tscTrace("%p the number of merged leaves is: %d", pSql, pReducer->numOfBuffer);
+ tscDebug("%p the number of merged leaves is: %d", pSql, pReducer->numOfBuffer);
int32_t idx = 0;
for (int32_t i = 0; i < numOfBuffer; ++i) {
@@ -242,7 +242,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
ds->pageId = 0;
ds->rowIdx = 0;
- tscTrace("%p load data from disk into memory, orderOfVnode:%d, total:%d", pSql, i + 1, idx + 1);
+ tscDebug("%p load data from disk into memory, orderOfVnode:%d, total:%d", pSql, i + 1, idx + 1);
tExtMemBufferLoadData(pMemBuffer[i], &(ds->filePage), j, 0);
#ifdef _DEBUG_VIEW
printf("load data page into mem for build loser tree: %" PRIu64 " rows\n", ds->filePage.num);
@@ -256,7 +256,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
#endif
if (ds->filePage.num == 0) { // no data in this flush, the index does not increase
- tscTrace("%p flush data is empty, ignore %d flush record", pSql, idx);
+ tscDebug("%p flush data is empty, ignore %d flush record", pSql, idx);
tfree(ds);
continue;
}
@@ -477,10 +477,10 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
return;
}
- tscTrace("%p start to free local reducer", pSql);
+ tscDebug("%p start to free local reducer", pSql);
SSqlRes *pRes = &(pSql->res);
if (pRes->pLocalReducer == NULL) {
- tscTrace("%p local reducer has been freed, abort", pSql);
+ tscDebug("%p local reducer has been freed, abort", pSql);
return;
}
@@ -494,7 +494,7 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
while ((status = atomic_val_compare_exchange_32(&pLocalReducer->status, TSC_LOCALREDUCE_READY,
TSC_LOCALREDUCE_TOBE_FREED)) == TSC_LOCALREDUCE_IN_PROGRESS) {
taosMsleep(100);
- tscTrace("%p waiting for delete procedure, status: %d", pSql, status);
+ tscDebug("%p waiting for delete procedure, status: %d", pSql, status);
}
pLocalReducer->pFillInfo = taosDestoryFillInfo(pLocalReducer->pFillInfo);
@@ -543,10 +543,10 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
pLocalReducer->numOfCompleted = 0;
free(pLocalReducer);
} else {
- tscTrace("%p already freed or another free function is invoked", pSql);
+ tscDebug("%p already freed or another free function is invoked", pSql);
}
- tscTrace("%p free local reducer finished", pSql);
+ tscDebug("%p free local reducer finished", pSql);
}
static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCmd, SColumnModel *pModel) {
@@ -1407,7 +1407,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
tscResetForNextRetrieve(pRes);
if (pSql->signature != pSql || pRes == NULL || pRes->pLocalReducer == NULL) { // all data has been processed
- tscTrace("%p %s call the drop local reducer", pSql, __FUNCTION__);
+ tscDebug("%p %s call the drop local reducer", pSql, __FUNCTION__);
tscDestroyLocalReducer(pSql);
return 0;
}
diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c
index f2af4f1d32..124e093b70 100644
--- a/src/client/src/tscParseInsert.c
+++ b/src/client/src/tscParseInsert.c
@@ -1050,7 +1050,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
str = pCmd->curSql;
}
- tscTrace("%p create data block list for submit data:%p, pTableList:%p", pSql, pCmd->pDataBlocks, pCmd->pTableList);
+ tscDebug("%p create data block list for submit data:%p, pTableList:%p", pSql, pCmd->pDataBlocks, pCmd->pTableList);
while (1) {
int32_t index = 0;
@@ -1153,29 +1153,19 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto _error;
}
- char fname[PATH_MAX] = {0};
- strncpy(fname, sToken.z, sToken.n);
- strdequote(fname);
+ strncpy(pCmd->payload, sToken.z, sToken.n);
+ strdequote(pCmd->payload);
+ // todo refactor extract method
wordexp_t full_path;
- if (wordexp(fname, &full_path, 0) != 0) {
+ if (wordexp(pCmd->payload, &full_path, 0) != 0) {
code = tscInvalidSQLErrMsg(pCmd->payload, "invalid filename", sToken.z);
goto _error;
}
- strcpy(fname, full_path.we_wordv[0]);
+
+ tstrncpy(pCmd->payload, full_path.we_wordv[0], pCmd->allocSize);
wordfree(&full_path);
- STableDataBlocks *pDataBlock = NULL;
- STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
-
- int32_t ret = tscCreateDataBlock(PATH_MAX, tinfo.rowSize, sizeof(SSubmitBlk), pTableMetaInfo->name,
- pTableMeta, &pDataBlock);
- if (ret != TSDB_CODE_SUCCESS) {
- goto _error;
- }
-
- taosArrayPush(pCmd->pDataBlocks, &pDataBlock);
- strcpy(pDataBlock->filename, fname);
} else if (sToken.type == TK_LP) {
/* insert into tablename(col1, col2,..., coln) values(v1, v2,... vn); */
STableMeta *pTableMeta = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0)->pTableMeta;
@@ -1320,7 +1310,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
SSqlCmd* pCmd = &pSql->cmd;
if ((!pCmd->parseFinished) && (!initial)) {
- tscTrace("%p resume to parse sql: %s", pSql, pCmd->curSql);
+ tscDebug("%p resume to parse sql: %s", pSql, pCmd->curSql);
}
if (tscIsInsertData(pSql->sqlstr)) {
@@ -1361,6 +1351,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlocks *pTableDataBlocks) {
int32_t code = TSDB_CODE_SUCCESS;
SSqlCmd *pCmd = &pSql->cmd;
+ pSql->res.numOfRows = 0;
assert(pCmd->numOfClause == 1);
STableMeta *pTableMeta = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0)->pTableMeta;
@@ -1377,172 +1368,145 @@ static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlock
return code;
}
- if ((code = tscProcessSql(pSql)) != TSDB_CODE_SUCCESS) {
- return code;
- }
-
- return TSDB_CODE_SUCCESS;
+ return tscProcessSql(pSql);
}
-static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
- size_t readLen = 0;
- char * line = NULL;
- size_t n = 0;
- int len = 0;
- int32_t maxRows = 0;
- SSqlCmd * pCmd = &pSql->cmd;
- int numOfRows = 0;
- int32_t code = 0;
- int nrows = 0;
-
+typedef struct SImportFileSupport {
+ SSqlObj *pSql;
+ FILE *fp;
+} SImportFileSupport;
+
+static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
+ assert(param != NULL && tres != NULL);
+
+ SSqlObj *pSql = tres;
+ SSqlCmd *pCmd = &pSql->cmd;
+
+ SImportFileSupport *pSupporter = (SImportFileSupport *) param;
+
+ SSqlObj *pParentSql = pSupporter->pSql;
+ FILE *fp = pSupporter->fp;
+
+ if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { // handle error
+ assert(taos_errno(pSql) == code);
+
+ taos_free_result(pSql);
+ tfree(pSupporter);
+ fclose(fp);
+
+ pParentSql->res.code = code;
+ tscQueueAsyncRes(pParentSql);
+ return;
+ }
+
+ // accumulate the total submit records
+ pParentSql->res.numOfRows += pSql->res.numOfRows;
+
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
- STableComInfo tinfo = tscGetTableInfo(pTableMeta);
-
- assert(pCmd->numOfClause == 1);
-
- int32_t rowSize = tinfo.rowSize;
+ SSchema * pSchema = tscGetTableSchema(pTableMeta);
+ STableComInfo tinfo = tscGetTableInfo(pTableMeta);
+
+ SParsedDataColInfo spd = {.numOfCols = tinfo.numOfColumns};
+ tscSetAssignedColumnInfo(&spd, pSchema, tinfo.numOfColumns);
+
+ size_t n = 0;
+ ssize_t readLen = 0;
+ char * line = NULL;
+ int32_t count = 0;
+ int32_t maxRows = 0;
+
+ tscDestroyBlockArrayList(pSql->cmd.pDataBlocks);
+ pCmd->pDataBlocks = taosArrayInit(1, POINTER_BYTES);
- pCmd->pDataBlocks = taosArrayInit(4, POINTER_BYTES);
STableDataBlocks *pTableDataBlock = NULL;
-
- int32_t ret = tscCreateDataBlock(TSDB_PAYLOAD_SIZE, rowSize, sizeof(SSubmitBlk), pTableMetaInfo->name, pTableMeta, &pTableDataBlock);
+ int32_t ret = tscCreateDataBlock(TSDB_PAYLOAD_SIZE, tinfo.rowSize, sizeof(SSubmitBlk), pTableMetaInfo->name, pTableMeta, &pTableDataBlock);
if (ret != TSDB_CODE_SUCCESS) {
- return ret;
+// return ret;
}
taosArrayPush(pCmd->pDataBlocks, &pTableDataBlock);
+ tscAllocateMemIfNeed(pTableDataBlock, tinfo.rowSize, &maxRows);
- code = tscAllocateMemIfNeed(pTableDataBlock, rowSize, &maxRows);
- if (TSDB_CODE_SUCCESS != code) return -1;
-
- int count = 0;
- SParsedDataColInfo spd = {.numOfCols = tinfo.numOfColumns};
- SSchema * pSchema = tscGetTableSchema(pTableMeta);
-
- tscSetAssignedColumnInfo(&spd, pSchema, tinfo.numOfColumns);
+ char *tokenBuf = calloc(1, 4096);
while ((readLen = getline(&line, &n, fp)) != -1) {
- // line[--readLen] = '\0';
- if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) line[--readLen] = 0;
- if (readLen == 0) continue; // fang, <= to ==
+ if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
+ line[--readLen] = 0;
+ }
+
+ if (readLen == 0) {
+ continue;
+ }
char *lineptr = line;
strtolower(line, line);
-
- len = tsParseOneRowData(&lineptr, pTableDataBlock, pSchema, &spd, pCmd->payload, tinfo.precision, &code, tmpTokenBuf);
+
+ int32_t len =
+ tsParseOneRowData(&lineptr, pTableDataBlock, pSchema, &spd, pCmd->payload, tinfo.precision, &code, tokenBuf);
if (len <= 0 || pTableDataBlock->numOfParams > 0) {
pSql->res.code = code;
- return (-code);
+ break;
}
pTableDataBlock->size += len;
- count++;
- nrows++;
- if (count >= maxRows) {
- if ((code = doPackSendDataBlock(pSql, count, pTableDataBlock)) != TSDB_CODE_SUCCESS) {
- return -code;
- }
-
- pTableDataBlock = taosArrayGetP(pCmd->pDataBlocks, 0);
- pTableDataBlock->size = sizeof(SSubmitBlk);
- pTableDataBlock->rowSize = tinfo.rowSize;
-
- numOfRows += pSql->res.numOfRows;
- pSql->res.numOfRows = 0;
- count = 0;
+ if (++count >= maxRows) {
+ break;
}
}
+ tfree(tokenBuf);
+ free(line);
+
if (count > 0) {
- if ((code = doPackSendDataBlock(pSql, count, pTableDataBlock)) != TSDB_CODE_SUCCESS) {
- return -code;
+ code = doPackSendDataBlock(pSql, count, pTableDataBlock);
+ if (code != TSDB_CODE_SUCCESS) {
+ pParentSql->res.code = code;
+ tscQueueAsyncRes(pParentSql);
+ return;
}
- numOfRows += pSql->res.numOfRows;
- pSql->res.numOfRows = 0;
+ } else {
+ taos_free_result(pSql);
+ tfree(pSupporter);
+ fclose(fp);
+
+ pParentSql->fp = pParentSql->fetchFp;
+
+ // all data has been sent to vnode, call user function
+ int32_t v = (pParentSql->res.code != TSDB_CODE_SUCCESS) ? pParentSql->res.code : pParentSql->res.numOfRows;
+ (*pParentSql->fp)(pParentSql->param, pParentSql, v);
}
-
- if (line) tfree(line);
-
- return numOfRows;
}
-void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) {
+void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd;
if (pCmd->command != TSDB_SQL_INSERT) {
return;
}
- SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
- STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
+ assert(pCmd->dataSourceType == DATA_FROM_DATA_FILE && strlen(pCmd->payload) != 0);
- STableDataBlocks *pDataBlock = NULL;
- int32_t affected_rows = 0;
+ SImportFileSupport *pSupporter = calloc(1, sizeof(SImportFileSupport));
+ SSqlObj *pNew = createSubqueryObj(pSql, 0, parseFileSendDataBlock, pSupporter, TSDB_SQL_INSERT, NULL);
- assert(pCmd->dataSourceType == DATA_FROM_DATA_FILE && pCmd->pDataBlocks != NULL);
- SArray *pDataBlockList = pCmd->pDataBlocks;
- pCmd->pDataBlocks = NULL;
+ pNew->cmd.pDataBlocks = taosArrayInit(4, POINTER_BYTES);
+ pCmd->count = 1;
- char path[PATH_MAX] = {0};
+ FILE *fp = fopen(pCmd->payload, "r");
+ if (fp == NULL) {
+ pSql->res.code = TAOS_SYSTEM_ERROR(errno);
+ tscError("%p failed to open file %s to load data from file, code:%s", pSql, pCmd->payload, tstrerror(pSql->res.code));
- size_t size = taosArrayGetSize(pDataBlockList);
- for (int32_t i = 0; i < size; ++i) {
- pDataBlock = taosArrayGetP(pDataBlockList, i );
- if (pDataBlock == NULL) {
- continue;
- }
+ tfree(pSupporter)
+ tscQueueAsyncRes(pSql);
- if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, TSDB_PAYLOAD_SIZE)) {
- tscError("%p failed to malloc when insert file", pSql);
- continue;
- }
- pCmd->count = 1;
-
- tstrncpy(path, pDataBlock->filename, sizeof(path));
-
- FILE *fp = fopen(path, "r");
- if (fp == NULL) {
- tscError("%p failed to open file %s to load data from file, reason:%s", pSql, path, strerror(errno));
- continue;
- }
-
- tstrncpy(pTableMetaInfo->name, pDataBlock->tableId, sizeof(pTableMetaInfo->name));
- memset(pDataBlock->pData, 0, pDataBlock->nAllocSize);
-
- int32_t ret = tscGetTableMeta(pSql, pTableMetaInfo);
- if (ret != TSDB_CODE_SUCCESS) {
- tscError("%p get meter meta failed, abort", pSql);
- continue;
- }
-
- char *tmpTokenBuf = calloc(1, 4096); // used for deleting Escape character: \\, \', \"
- if (NULL == tmpTokenBuf) {
- tscError("%p calloc failed", pSql);
- continue;
- }
-
- int nrows = tscInsertDataFromFile(pSql, fp, tmpTokenBuf);
- free(tmpTokenBuf);
-
- pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
-
- if (nrows < 0) {
- fclose(fp);
- tscTrace("%p no records(%d) in file %s", pSql, nrows, path);
- continue;
- }
-
- fclose(fp);
- affected_rows += nrows;
-
- tscTrace("%p Insert data %d records from file %s", pSql, nrows, path);
+ return;
}
- pSql->res.numOfRows = affected_rows;
+ pSupporter->pSql = pSql;
+ pSupporter->fp = fp;
- // all data have been submit to vnode, release data blocks
- pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
- tscDestroyBlockArrayList(pDataBlockList);
+ parseFileSendDataBlock(pSupporter, pNew, 0);
}
diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c
index 6a0ba02ad4..22b6be1c57 100644
--- a/src/client/src/tscPrepare.c
+++ b/src/client/src/tscPrepare.c
@@ -140,7 +140,7 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
break;
default:
- tscTrace("param %d: type mismatch or invalid", i);
+ tscDebug("param %d: type mismatch or invalid", i);
return TSDB_CODE_TSC_INVALID_VALUE;
}
}
@@ -356,7 +356,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
SParamInfo* param = pBlock->params + j;
int code = doBindParam(data, param, bind + param->idx);
if (code != TSDB_CODE_SUCCESS) {
- tscTrace("param %d: type mismatch or invalid", param->idx);
+ tscDebug("param %d: type mismatch or invalid", param->idx);
return code;
}
}
@@ -538,7 +538,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
pRes->numOfRows = 1;
strtolower(pSql->sqlstr, sql);
- tscDump("%p SQL: %s", pSql, pSql->sqlstr);
+ tscDebugDump("%p SQL: %s", pSql, pSql->sqlstr);
if (tscIsInsertData(pSql->sqlstr)) {
pStmt->isInsert = true;
diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c
index 55243c4382..602b4654df 100644
--- a/src/client/src/tscProfile.c
+++ b/src/client/src/tscProfile.c
@@ -34,7 +34,7 @@ void tscInitConnCb(void *param, TAOS_RES *result, int code) {
tscSlowQueryConnInitialized = false;
free(sql);
} else {
- tscTrace("taos:%p, slow query connect success, code:%d", tscSlowQueryConn, code);
+ tscDebug("taos:%p, slow query connect success, code:%d", tscSlowQueryConn, code);
tscSlowQueryConnInitialized = true;
tscSaveSlowQueryFp(sql, NULL);
}
@@ -59,14 +59,14 @@ void tscAddIntoSqlList(SSqlObj *pSql) {
pSql->stime = taosGetTimestampMs();
pSql->listed = 1;
- tscTrace("%p added into sqlList", pSql);
+ tscDebug("%p added into sqlList", pSql);
}
void tscSaveSlowQueryFpCb(void *param, TAOS_RES *result, int code) {
if (code < 0) {
tscError("failed to save slow query, code:%d", code);
} else {
- tscTrace("success to save slow query, code:%d", code);
+ tscDebug("success to save slow query, code:%d", code);
}
}
@@ -75,14 +75,14 @@ void tscSaveSlowQueryFp(void *handle, void *tmrId) {
if (!tscSlowQueryConnInitialized) {
if (tscSlowQueryConn == NULL) {
- tscTrace("start to init slow query connect");
+ tscDebug("start to init slow query connect");
taos_connect_a(NULL, "monitor", tsInternalPass, "", 0, tscInitConnCb, sql, &tscSlowQueryConn);
} else {
tscError("taos:%p, slow query connect is already initialized", tscSlowQueryConn);
free(sql);
}
} else {
- tscTrace("taos:%p, save slow query:%s", tscSlowQueryConn, sql);
+ tscDebug("taos:%p, save slow query:%s", tscSlowQueryConn, sql);
taos_query_a(tscSlowQueryConn, sql, tscSaveSlowQueryFpCb, NULL);
free(sql);
}
@@ -96,7 +96,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
return;
}
- tscTrace("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
+ tscDebug("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
int32_t sqlSize = TSDB_SLOW_QUERY_SQL_LEN + size;
char *sql = malloc(sqlSize);
@@ -138,7 +138,7 @@ void tscRemoveFromSqlList(SSqlObj *pSql) {
pSql->listed = 0;
tscSaveSlowQuery(pSql);
- tscTrace("%p removed from sqlList", pSql);
+ tscDebug("%p removed from sqlList", pSql);
}
void tscKillQuery(STscObj *pObj, uint32_t killId) {
@@ -154,7 +154,7 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) {
if (pSql == NULL) return;
- tscTrace("%p query is killed, queryId:%d", pSql, killId);
+ tscDebug("%p query is killed, queryId:%d", pSql, killId);
taos_stop_query(pSql);
}
@@ -208,7 +208,7 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
pthread_mutex_unlock(&pObj->mutex);
if (pStream) {
- tscTrace("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId);
+ tscDebug("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId);
if (pStream->callback) {
pStream->callback(pStream->param);
}
@@ -299,6 +299,6 @@ void tscKillConnection(STscObj *pObj) {
pthread_mutex_unlock(&pObj->mutex);
- tscTrace("connection:%p is killed", pObj);
+ tscDebug("connection:%p is killed", pObj);
taos_close(pObj);
}
diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c
index 25b98e18c3..df18d7a56b 100644
--- a/src/client/src/tscSQLParser.c
+++ b/src/client/src/tscSQLParser.c
@@ -4754,7 +4754,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
pQueryInfo->clauseLimit = pQueryInfo->limit.limit;
pQueryInfo->slimit = pQuerySql->slimit;
- tscTrace("%p limit:%" PRId64 ", offset:%" PRId64 " slimit:%" PRId64 ", soffset:%" PRId64, pSql, pQueryInfo->limit.limit,
+ tscDebug("%p limit:%" PRId64 ", offset:%" PRId64 " slimit:%" PRId64 ", soffset:%" PRId64, pSql, pQueryInfo->limit.limit,
pQueryInfo->limit.offset, pQueryInfo->slimit.limit, pQueryInfo->slimit.offset);
if (pQueryInfo->slimit.offset < 0 || pQueryInfo->limit.offset < 0) {
@@ -4762,7 +4762,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
}
if (pQueryInfo->limit.limit == 0) {
- tscTrace("%p limit 0, no output result", pSql);
+ tscDebug("%p limit 0, no output result", pSql);
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
return TSDB_CODE_SUCCESS;
}
@@ -4784,7 +4784,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
}
if (pQueryInfo->slimit.limit == 0) {
- tscTrace("%p slimit 0, no output result", pSql);
+ tscDebug("%p slimit 0, no output result", pSql);
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
return TSDB_CODE_SUCCESS;
}
@@ -4802,7 +4802,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
// No tables included. No results generated. Query results are empty.
if (pTableMetaInfo->vgroupList->numOfVgroups == 0) {
- tscTrace("%p no table in super table, no output result", pSql);
+ tscDebug("%p no table in super table, no output result", pSql);
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
return TSDB_CODE_SUCCESS;
}
@@ -5522,7 +5522,7 @@ void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex) {
}
str[offset] = ']';
- tscTrace("%p select clause:%s", pSql, str);
+ tscDebug("%p select clause:%s", pSql, str);
}
int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* pInfo) {
diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c
index 631a9b5eb3..470a829805 100644
--- a/src/client/src/tscServer.c
+++ b/src/client/src/tscServer.c
@@ -61,7 +61,7 @@ void tscPrintMgmtIp() {
tscError("invalid mnode IP list:%d", tscMgmtIpSet.numOfIps);
} else {
for (int i = 0; i < tscMgmtIpSet.numOfIps; ++i) {
- tscTrace("mnode index:%d %s:%d", i, tscMgmtIpSet.fqdn[i], tscMgmtIpSet.port[i]);
+ tscDebug("mnode index:%d %s:%d", i, tscMgmtIpSet.fqdn[i], tscMgmtIpSet.port[i]);
}
}
}
@@ -76,9 +76,9 @@ void tscSetMgmtIpList(SRpcIpSet *pIpList) {
void tscUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
tscMgmtIpSet = *pIpSet;
- tscTrace("mnode IP list is changed for ufp is called, numOfIps:%d inUse:%d", tscMgmtIpSet.numOfIps, tscMgmtIpSet.inUse);
+ tscDebug("mnode IP list is changed for ufp is called, numOfIps:%d inUse:%d", tscMgmtIpSet.numOfIps, tscMgmtIpSet.inUse);
for (int32_t i = 0; i < tscMgmtIpSet.numOfIps; ++i) {
- tscTrace("index:%d fqdn:%s port:%d", i, tscMgmtIpSet.fqdn[i], tscMgmtIpSet.port[i]);
+ tscDebug("index:%d fqdn:%s port:%d", i, tscMgmtIpSet.fqdn[i], tscMgmtIpSet.port[i]);
}
}
@@ -121,7 +121,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
if (pRsp->streamId) tscKillStream(pObj, htonl(pRsp->streamId));
}
} else {
- tscTrace("heart beat failed, code:%s", tstrerror(code));
+ tscDebug("heart beat failed, code:%s", tstrerror(code));
}
taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer);
@@ -157,11 +157,11 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
pObj->pHb = pSql;
tscAddSubqueryInfo(&pObj->pHb->cmd);
- tscTrace("%p pHb is allocated, pObj:%p", pObj->pHb, pObj);
+ tscDebug("%p pHb is allocated, pObj:%p", pObj->pHb, pObj);
}
if (tscShouldFreeHeatBeat(pObj->pHb)) {
- tscTrace("%p free HB object and release connection", pObj);
+ tscDebug("%p free HB object and release connection", pObj);
tscFreeSqlObj(pObj->pHb);
tscCloseTscObj(pObj);
return;
@@ -195,7 +195,11 @@ int tscSendMsgToServer(SSqlObj *pSql) {
.code = 0
};
- pSql->pRpcCtx = rpcSendRequest(pObj->pDnodeConn, &pSql->ipList, &rpcMsg);
+ // NOTE: the rpc context should be acquired before sending data to server.
+ // Otherwise, the pSql object may have been released already during the response function, which is
+ // processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
+ // cause crash.
+ /*pSql->pRpcCtx = */rpcSendRequest(pObj->pDnodeConn, &pSql->ipList, &rpcMsg);
return TSDB_CODE_SUCCESS;
}
@@ -211,7 +215,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
SSqlCmd *pCmd = &pSql->cmd;
if (pObj->signature != pObj) {
- tscTrace("%p DB connection is closed, cmd:%d pObj:%p signature:%p", pSql, pCmd->command, pObj, pObj->signature);
+ tscDebug("%p DB connection is closed, cmd:%d pObj:%p signature:%p", pSql, pCmd->command, pObj, pObj->signature);
tscFreeSqlObj(pSql);
rpcFreeCont(rpcMsg->pCont);
@@ -220,7 +224,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
if (pQueryInfo != NULL && pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE) {
- tscTrace("%p sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p",
+ tscDebug("%p sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p",
pSql, pCmd->command, pQueryInfo->type, pObj, pObj->signature);
tscFreeSqlObj(pSql);
@@ -275,11 +279,11 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
if (pRes->code != TSDB_CODE_TSC_QUERY_CANCELLED) {
pRes->code = (rpcMsg->code != TSDB_CODE_SUCCESS) ? rpcMsg->code : TSDB_CODE_RPC_NETWORK_UNAVAIL;
} else {
- tscTrace("%p query is cancelled, code:%s", pSql, tstrerror(pRes->code));
+ tscDebug("%p query is cancelled, code:%s", pSql, tstrerror(pRes->code));
}
if (pRes->code == TSDB_CODE_SUCCESS) {
- tscTrace("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry);
+ tscDebug("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry);
pSql->retry = 0;
}
@@ -314,10 +318,10 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
pMsg->numOfFailedBlocks = htonl(pMsg->numOfFailedBlocks);
pRes->numOfRows += pMsg->affectedRows;
- tscTrace("%p SQL cmd:%s, code:%s inserted rows:%d rspLen:%d", pSql, sqlCmd[pCmd->command],
+ tscDebug("%p SQL cmd:%s, code:%s inserted rows:%d rspLen:%d", pSql, sqlCmd[pCmd->command],
tstrerror(pRes->code), pMsg->affectedRows, pRes->rspLen);
} else {
- tscTrace("%p SQL cmd:%s, code:%s rspLen:%d", pSql, sqlCmd[pCmd->command], tstrerror(pRes->code), pRes->rspLen);
+ tscDebug("%p SQL cmd:%s, code:%s rspLen:%d", pSql, sqlCmd[pCmd->command], tstrerror(pRes->code), pRes->rspLen);
}
}
@@ -332,7 +336,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
(*pSql->fp)(pSql->param, pSql, rpcMsg->code);
if (shouldFree) {
- tscTrace("%p sqlObj is automatically freed", pSql);
+ tscDebug("%p sqlObj is automatically freed", pSql);
tscFreeSqlObj(pSql);
}
}
@@ -390,7 +394,7 @@ int tscProcessSql(SSqlObj *pSql) {
assert((pQueryInfo->numOfTables == 0 && pQueryInfo->command == TSDB_SQL_HB) || pQueryInfo->numOfTables > 0);
}
- tscTrace("%p SQL cmd:%s will be processed, name:%s, type:%d", pSql, sqlCmd[pCmd->command], name, type);
+ tscDebug("%p SQL cmd:%s will be processed, name:%s, type:%d", pSql, sqlCmd[pCmd->command], name, type);
if (pCmd->command < TSDB_SQL_MGMT) { // the pTableMetaInfo cannot be NULL
if (pTableMetaInfo == NULL) {
pSql->res.code = TSDB_CODE_TSC_APP_ERROR;
@@ -443,7 +447,7 @@ void tscKillSTableQuery(SSqlObj *pSql) {
}
}
- tscTrace("%p super table query cancelled", pSql);
+ tscDebug("%p super table query cancelled", pSql);
}
int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
@@ -500,7 +504,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSql->cmd.msgType = TSDB_MSG_TYPE_SUBMIT;
tscSetDnodeIpList(pSql, &pTableMeta->vgroupInfo);
- tscTrace("%p build submit msg, vgId:%d numOfTables:%d numberOfIP:%d", pSql, vgId, pSql->cmd.numOfTablesInSubmit,
+ tscDebug("%p build submit msg, vgId:%d numOfTables:%d numberOfIP:%d", pSql, vgId, pSql->cmd.numOfTablesInSubmit,
pSql->ipList.numOfIps);
return TSDB_CODE_SUCCESS;
}
@@ -533,7 +537,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
assert(index >= 0);
pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index];
- tscTrace("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, pTableMetaInfo->vgroupList->numOfVgroups);
+ tscDebug("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, pTableMetaInfo->vgroupList->numOfVgroups);
} else {
pVgroupInfo = &pTableMeta->vgroupInfo;
}
@@ -553,7 +557,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
int32_t numOfVgroups = taosArrayGetSize(pTableMetaInfo->pVgroupTables);
assert(index >= 0 && index < numOfVgroups);
- tscTrace("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, numOfVgroups);
+ tscDebug("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, numOfVgroups);
SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, index);
@@ -576,7 +580,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
}
}
- tscTrace("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name,
+ tscDebug("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name,
pTableMeta->sid, pTableMeta->uid);
return pMsg;
@@ -845,7 +849,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t msgLen = pMsg - pCmd->payload;
- tscTrace("%p msg built success,len:%d bytes", pSql, msgLen);
+ tscDebug("%p msg built success,len:%d bytes", pSql, msgLen);
pCmd->payloadLen = msgLen;
pSql->cmd.msgType = TSDB_MSG_TYPE_QUERY;
@@ -1517,7 +1521,7 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
assert(pCmd->payloadLen + minMsgSize() <= pCmd->allocSize);
- tscTrace("%p build load multi-metermeta msg completed, numOfTables:%d, msg size:%d", pSql, pCmd->count,
+ tscDebug("%p build load multi-metermeta msg completed, numOfTables:%d, msg size:%d", pSql, pCmd->count,
pCmd->payloadLen);
return pCmd->payloadLen;
@@ -1677,7 +1681,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
- tscTrace("%p recv table meta, uid:%"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->uid, pTableMeta->sid, pTableMetaInfo->name);
+ tscDebug("%p recv table meta, uid:%"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->uid, pTableMeta->sid, pTableMetaInfo->name);
free(pTableMeta);
return TSDB_CODE_SUCCESS;
@@ -1786,7 +1790,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pSql->res.code = TSDB_CODE_SUCCESS;
pSql->res.numOfTotal = i;
- tscTrace("%p load multi-metermeta resp from complete num:%d", pSql, pSql->res.numOfTotal);
+ tscDebug("%p load multi-metermeta resp from complete num:%d", pSql, pSql->res.numOfTotal);
#endif
return TSDB_CODE_SUCCESS;
@@ -1955,7 +1959,7 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
* The cached information is expired, however, we may have lost the ref of original meter. So, clear whole cache
* instead.
*/
- tscTrace("%p force release table meta after drop table:%s", pSql, pTableMetaInfo->name);
+ tscDebug("%p force release table meta after drop table:%s", pSql, pTableMetaInfo->name);
taosCacheRelease(tscCacheHandle, (void **)&pTableMeta, true);
if (pTableMetaInfo->pTableMeta) {
@@ -1973,7 +1977,7 @@ int tscProcessAlterTableMsgRsp(SSqlObj *pSql) {
return 0;
}
- tscTrace("%p force release metermeta in cache after alter-table: %s", pSql, pTableMetaInfo->name);
+ tscDebug("%p force release metermeta in cache after alter-table: %s", pSql, pTableMetaInfo->name);
taosCacheRelease(tscCacheHandle, (void **)&pTableMeta, true);
if (pTableMetaInfo->pTableMeta) {
@@ -1981,7 +1985,7 @@ int tscProcessAlterTableMsgRsp(SSqlObj *pSql) {
taosCacheRelease(tscCacheHandle, (void **)&(pTableMetaInfo->pTableMeta), true);
if (isSuperTable) { // if it is a super table, reset whole query cache
- tscTrace("%p reset query cache since table:%s is stable", pSql, pTableMetaInfo->name);
+ tscDebug("%p reset query cache since table:%s is stable", pSql, pTableMetaInfo->name);
taosCacheEmpty(tscCacheHandle);
}
}
@@ -2045,7 +2049,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
}
pRes->row = 0;
- tscTrace("%p numOfRows:%" PRId64 ", offset:%" PRId64 ", complete:%d", pSql, pRes->numOfRows, pRes->offset, pRes->completed);
+ tscDebug("%p numOfRows:%" PRId64 ", offset:%" PRId64 ", complete:%d", pSql, pRes->numOfRows, pRes->offset, pRes->completed);
return 0;
}
@@ -2097,7 +2101,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name));
memcpy(pNew->cmd.payload, pSql->cmd.payload, pSql->cmd.payloadLen); // tag information if table does not exists.
pNew->cmd.payloadLen = pSql->cmd.payloadLen;
- tscTrace("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
+ tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
pNew->fp = tscTableMetaCallBack;
pNew->param = pSql;
@@ -2121,7 +2125,7 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
pTableMetaInfo->pTableMeta = (STableMeta *)taosCacheAcquireByName(tscCacheHandle, pTableMetaInfo->name);
if (pTableMetaInfo->pTableMeta != NULL) {
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
- tscTrace("%p retrieve table Meta from cache, the number of columns:%d, numOfTags:%d, %p", pSql, tinfo.numOfColumns,
+ tscDebug("%p retrieve table Meta from cache, the number of columns:%d, numOfTags:%d, %p", pSql, tinfo.numOfColumns,
tinfo.numOfTags, pTableMetaInfo->pTableMeta);
return TSDB_CODE_SUCCESS;
@@ -2149,7 +2153,7 @@ int tscRenewTableMeta(SSqlObj *pSql, char *tableId) {
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
if (pTableMetaInfo->pTableMeta) {
- tscTrace("%p update table meta, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64 ", addr:%p", pSql,
+ tscDebug("%p update table meta, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64 ", addr:%p", pSql,
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->uid, pTableMeta);
}
@@ -2203,7 +2207,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
}
pNewQueryInfo->numOfTables = pQueryInfo->numOfTables;
- tscTrace("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables);
+ tscDebug("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables);
pNew->fp = tscTableMetaCallBack;
pNew->param = pSql;
diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c
index 720e412225..8fbc1f0109 100644
--- a/src/client/src/tscSql.c
+++ b/src/client/src/tscSql.c
@@ -145,7 +145,7 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
}
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
- tscTrace("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
+ tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
if (user == NULL) user = TSDB_DEFAULT_USER;
if (pass == NULL) pass = TSDB_DEFAULT_PASS;
@@ -165,7 +165,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
return NULL;
}
- tscTrace("%p DB connection is opening, dnodeConn:%p", pObj, pObj->pDnodeConn);
+ tscDebug("%p DB connection is opening, dnodeConn:%p", pObj, pObj->pDnodeConn);
taos_free_result(pSql);
// version compare only requires the first 3 segments of the version string
@@ -190,7 +190,7 @@ TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port,
}
pSql->res.code = tscProcessSql(pSql);
- tscTrace("%p DB async connection is opening", taos);
+ tscDebug("%p DB async connection is opening", taos);
return taos;
}
@@ -441,7 +441,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
assert(pSql->fp == NULL);
- tscTrace("%p try data in the next subclause:%d, total subclause:%d", pSql, pCmd->clauseIndex, pCmd->numOfClause);
+ tscDebug("%p try data in the next subclause:%d, total subclause:%d", pSql, pCmd->clauseIndex, pCmd->numOfClause);
tscProcessSql(pSql);
nRows = taos_fetch_block_impl(res, rows);
@@ -487,7 +487,7 @@ static bool tscFreeQhandleInVnode(SSqlObj* pSql) {
(pCmd->command == TSDB_SQL_SELECT && pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)) {
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
- tscTrace("%p send msg to dnode to free qhandle ASAP, command:%s", pSql, sqlCmd[pCmd->command]);
+ tscDebug("%p send msg to dnode to free qhandle ASAP, command:%s", pSql, sqlCmd[pCmd->command]);
tscProcessSql(pSql);
// in case of sync model query, waits for response and then goes on
@@ -495,9 +495,9 @@ static bool tscFreeQhandleInVnode(SSqlObj* pSql) {
// sem_wait(&pSql->rspSem);
// tscFreeSqlObj(pSql);
-// tscTrace("%p sqlObj is freed by app", pSql);
+// tscDebug("%p sqlObj is freed by app", pSql);
// } else {
- tscTrace("%p sqlObj will be freed while rsp received", pSql);
+ tscDebug("%p sqlObj will be freed while rsp received", pSql);
// }
return true;
@@ -510,7 +510,7 @@ void taos_free_result(TAOS_RES *res) {
SSqlObj *pSql = (SSqlObj *)res;
if (pSql == NULL || pSql->signature != pSql) {
- tscTrace("%p sqlObj has been freed", pSql);
+ tscDebug("%p sqlObj has been freed", pSql);
return;
}
@@ -518,7 +518,7 @@ void taos_free_result(TAOS_RES *res) {
SSqlRes *pRes = &pSql->res;
if (pRes == NULL || pRes->qhandle == 0) {
tscFreeSqlObj(pSql);
- tscTrace("%p SqlObj is freed by app, qhandle is null", pSql);
+ tscDebug("%p SqlObj is freed by app, qhandle is null", pSql);
return;
}
@@ -526,14 +526,14 @@ void taos_free_result(TAOS_RES *res) {
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
if (pQueryInfo == NULL) {
tscFreeSqlObj(pSql);
- tscTrace("%p SqlObj is freed by app", pSql);
+ tscDebug("%p SqlObj is freed by app", pSql);
return;
}
pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE;
if (!tscFreeQhandleInVnode(pSql)) {
tscFreeSqlObj(pSql);
- tscTrace("%p sqlObj is freed by app", pSql);
+ tscDebug("%p sqlObj is freed by app", pSql);
}
}
@@ -615,7 +615,7 @@ void taos_stop_query(TAOS_RES *res) {
SSqlCmd *pCmd = &pSql->cmd;
if (pSql->signature != pSql) return;
- tscTrace("%p start to cancel query", res);
+ tscDebug("%p start to cancel query", res);
pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
@@ -630,7 +630,7 @@ void taos_stop_query(TAOS_RES *res) {
}
rpcCancelRequest(pSql->pRpcCtx);
- tscTrace("%p query is cancelled", res);
+ tscDebug("%p query is cancelled", res);
}
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
@@ -714,7 +714,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
pRes->numOfTotal = 0;
pRes->numOfClauseTotal = 0;
- tscTrace("%p Valid SQL: %s pObj:%p", pSql, sql, pObj);
+ tscDebug("%p Valid SQL: %s pObj:%p", pSql, sql, pObj);
int32_t sqlLen = strlen(sql);
if (sqlLen > tsMaxSQLStringLen) {
@@ -728,7 +728,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
if (pSql->sqlstr == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
tscError("%p failed to malloc sql string buffer", pSql);
- tscTrace("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
+ tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
tfree(pSql);
return pRes->code;
}
@@ -744,7 +744,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
pRes->code = (uint8_t)tsParseSql(pSql, false);
int code = pRes->code;
- tscTrace("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
+ tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
taos_free_result(pSql);
return code;
@@ -848,7 +848,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
pRes->code = 0;
assert(pSql->fp == NULL);
- tscTrace("%p tableNameList: %s pObj:%p", pSql, tableNameList, pObj);
+ tscDebug("%p tableNameList: %s pObj:%p", pSql, tableNameList, pObj);
int32_t tblListLen = strlen(tableNameList);
if (tblListLen > MAX_TABLE_NAME_LENGTH) {
@@ -884,7 +884,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
tscDoQuery(pSql);
- tscTrace("%p load multi metermeta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
+ tscDebug("%p load multi metermeta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj);
if (pRes->code != TSDB_CODE_SUCCESS) {
tscPartiallyFreeSqlObj(pSql);
}
diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c
index 86a41b7ba4..a6d111dbc7 100644
--- a/src/client/src/tscStream.c
+++ b/src/client/src/tscStream.c
@@ -91,7 +91,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
} else {
tscTansformSQLFuncForSTableQuery(pQueryInfo);
- tscTrace("%p stream:%p start stream query on:%s", pSql, pStream, pTableMetaInfo->name);
+ tscDebug("%p stream:%p start stream query on:%s", pSql, pStream, pTableMetaInfo->name);
tscDoQuery(pStream->pSql);
tscIncStreamExecutionCount(pStream);
}
@@ -106,7 +106,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
pStream->numOfRes = 0; // reset the numOfRes.
SSqlObj *pSql = pStream->pSql;
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
- tscTrace("%p add into timer", pSql);
+ tscDebug("%p add into timer", pSql);
if (isProjectStream(pQueryInfo)) {
/*
@@ -184,7 +184,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
for(int32_t i = 0; i < numOfRows; ++i) {
TAOS_ROW row = taos_fetch_row(res);
- tscTrace("%p stream:%p fetch result", pSql, pStream);
+ tscDebug("%p stream:%p fetch result", pSql, pStream);
if (isProjectStream(pQueryInfo)) {
pStream->stime = *(TSKEY *)row[0];
} else {
@@ -227,8 +227,8 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
// char result[512] = {0};
// taos_print_row(result, row, pQueryInfo->fieldsInfo.pFields, pQueryInfo->fieldsInfo.numOfOutput);
- // tscPrint("%p stream:%p query result: %s", pSql, pStream, result);
- tscTrace("%p stream:%p fetch result", pSql, pStream);
+ // tscInfo("%p stream:%p query result: %s", pSql, pStream, result);
+ tscDebug("%p stream:%p fetch result", pSql, pStream);
// user callback function
(*pStream->fp)(pStream->param, res, row);
@@ -250,7 +250,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
}
}
- tscTrace("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name,
+ tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name,
pStream->numOfRes);
// release the metric/meter meta information reference, so data in cache can be updated
@@ -273,7 +273,7 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
/*
* current time window will be closed, since it too early to exceed the maxRetentWindow value
*/
- tscTrace("%p stream:%p, etime:%" PRId64 " is too old, exceeds the max retention time window:%" PRId64 ", stop the stream",
+ tscDebug("%p stream:%p, etime:%" PRId64 " is too old, exceeds the max retention time window:%" PRId64 ", stop the stream",
pStream->pSql, pStream, pStream->stime, pStream->etime);
// TODO : How to terminate stream here
if (pStream->callback) {
@@ -284,10 +284,10 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
return;
}
- tscTrace("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
+ tscDebug("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
now + timer, timer, delay, pStream->stime, etime);
} else {
- tscTrace("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
+ tscDebug("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
pStream->stime, timer, delay, pStream->stime - pStream->interval, pStream->stime - 1);
}
@@ -331,7 +331,7 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
*/
timer = pStream->slidingTime;
if (pStream->stime > pStream->etime) {
- tscTrace("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
+ tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
pStream->stime, pStream->etime);
// TODO : How to terminate stream here
if (pStream->callback) {
@@ -344,7 +344,7 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
} else {
pStream->stime += pStream->slidingTime;
if ((pStream->stime - pStream->interval) >= pStream->etime) {
- tscTrace("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
+ tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
pStream->stime, pStream->etime);
// TODO : How to terminate stream here
if (pStream->callback) {
@@ -503,7 +503,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
}
strtolower(pSql->sqlstr, sqlstr);
- tscDump("%p SQL: %s", pSql, pSql->sqlstr);
+ tscDebugDump("%p SQL: %s", pSql, pSql->sqlstr);
tsem_init(&pSql->rspSem, 0, 0);
int32_t code = tsParseSql(pSql, true);
@@ -541,7 +541,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
pCmd->command = TSDB_SQL_SELECT;
taosTmrReset(tscProcessStreamTimer, starttime, pStream, tscTmr, &pStream->pTimer);
- tscTrace("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql,
+ tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql,
pStream, pTableMetaInfo->name, pStream->interval, pStream->slidingTime, starttime, sqlstr);
return pStream;
@@ -564,7 +564,7 @@ void taos_close_stream(TAOS_STREAM *handle) {
taosTmrStopA(&(pStream->pTimer));
- tscTrace("%p stream:%p is closed", pSql, pStream);
+ tscDebug("%p stream:%p is closed", pSql, pStream);
tscFreeSqlObj(pSql);
pStream->pSql = NULL;
diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c
index 8099effc2e..f7d03bd787 100644
--- a/src/client/src/tscSub.c
+++ b/src/client/src/tscSub.c
@@ -260,12 +260,12 @@ static int tscLoadSubscriptionProgress(SSub* pSub) {
FILE* fp = fopen(buf, "r");
if (fp == NULL) {
- tscTrace("subscription progress file does not exist: %s", pSub->topic);
+ tscDebug("subscription progress file does not exist: %s", pSub->topic);
return 1;
}
if (fgets(buf, sizeof(buf), fp) == NULL) {
- tscTrace("invalid subscription progress file: %s", pSub->topic);
+ tscDebug("invalid subscription progress file: %s", pSub->topic);
fclose(fp);
return 0;
}
@@ -279,7 +279,7 @@ static int tscLoadSubscriptionProgress(SSub* pSub) {
}
}
if (strcmp(buf, pSub->pSql->sqlstr) != 0) {
- tscTrace("subscription sql statement mismatch: %s", pSub->topic);
+ tscDebug("subscription sql statement mismatch: %s", pSub->topic);
fclose(fp);
return 0;
}
@@ -299,7 +299,7 @@ static int tscLoadSubscriptionProgress(SSub* pSub) {
fclose(fp);
taosArraySort(progress, tscCompareSubscriptionProgress);
- tscTrace("subscription progress loaded, %zu tables: %s", taosArrayGetSize(progress), pSub->topic);
+ tscDebug("subscription progress loaded, %zu tables: %s", taosArrayGetSize(progress), pSub->topic);
return 1;
}
@@ -344,7 +344,7 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char
pSub->taos = taos;
if (restart) {
- tscTrace("restart subscription: %s", topic);
+ tscDebug("restart subscription: %s", topic);
} else {
tscLoadSubscriptionProgress(pSub);
}
@@ -356,7 +356,7 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char
pSub->interval = interval;
if (fp != NULL) {
- tscTrace("asynchronize subscription, create new timer: %s", topic);
+ tscDebug("asynchronize subscription, create new timer: %s", topic);
pSub->fp = fp;
pSub->param = param;
taosTmrReset(tscProcessSubscriptionTimer, interval, pSub, tscTmr, &pSub->pTimer);
@@ -379,7 +379,7 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
if (pSub->pTimer == NULL) {
int64_t duration = taosGetTimestampMs() - pSub->lastConsumeTime;
if (duration < (int64_t)(pSub->interval)) {
- tscTrace("subscription consume too frequently, blocking...");
+ tscDebug("subscription consume too frequently, blocking...");
taosMsleep(pSub->interval - (int32_t)duration);
}
}
@@ -388,9 +388,9 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
tscRemoveFromSqlList(pSql);
if (taosGetTimestampMs() - pSub->lastSyncTime > 10 * 60 * 1000) {
- tscTrace("begin table synchronization");
+ tscDebug("begin table synchronization");
if (!tscUpdateSubscription(pSub->taos, pSub)) return NULL;
- tscTrace("table synchronization completed");
+ tscDebug("table synchronization completed");
}
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c
index e6daab99c6..02c2511a58 100644
--- a/src/client/src/tscSubquery.c
+++ b/src/client/src/tscSubquery.c
@@ -64,7 +64,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
tsBufFlush(output1);
tsBufFlush(output2);
- tscTrace("%p input1 is empty, 0 for secondary query after ts blocks intersecting", pSql);
+ tscDebug("%p input1 is empty, 0 for secondary query after ts blocks intersecting", pSql);
return 0;
}
@@ -72,7 +72,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
tsBufFlush(output1);
tsBufFlush(output2);
- tscTrace("%p input2 is empty, 0 for secondary query after ts blocks intersecting", pSql);
+ tscDebug("%p input2 is empty, 0 for secondary query after ts blocks intersecting", pSql);
return 0;
}
@@ -84,7 +84,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
STSElem elem2 = tsBufGetElem(pSupporter2->pTSBuf);
#ifdef _DEBUG_VIEW
- tscPrint("%" PRId64 ", tags:%d \t %" PRId64 ", tags:%d", elem1.ts, elem1.tag, elem2.ts, elem2.tag);
+ tscInfo("%" PRId64 ", tags:%d \t %" PRId64 ", tags:%d", elem1.ts, elem1.tag, elem2.ts, elem2.tag);
#endif
if (elem1.tag < elem2.tag || (elem1.tag == elem2.tag && tsCompare(order, elem1.ts, elem2.ts))) {
@@ -149,7 +149,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
tsBufDestory(pSupporter1->pTSBuf);
tsBufDestory(pSupporter2->pTSBuf);
- tscTrace("%p input1:%" PRId64 ", input2:%" PRId64 ", final:%" PRId64 " for secondary query after ts blocks "
+ tscDebug("%p input1:%" PRId64 ", input2:%" PRId64 ", final:%" PRId64 " for secondary query after ts blocks "
"intersecting, skey:%" PRId64 ", ekey:%" PRId64, pSql, numOfInput1, numOfInput2, output1->numOfTotal,
win->skey, win->ekey);
@@ -250,7 +250,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
assert(numOfSub > 0);
// scan all subquery, if one sub query has only ts, ignore it
- tscTrace("%p start to launch secondary subqueries, total:%d, only:%d needs to query", pSql, pSql->numOfSubs, numOfSub);
+ tscDebug("%p start to launch secondary subqueries, total:%d, only:%d needs to query", pSql, pSql->numOfSubs, numOfSub);
//the subqueries that do not actually launch the secondary query to virtual node is set as completed.
SSubqueryState* pState = pSupporter->pState;
@@ -266,7 +266,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
pSupporter = pPrevSub->param;
if (taosArrayGetSize(pSupporter->exprList) == 0) {
- tscTrace("%p subIndex: %d, no need to launch query, ignore it", pSql, i);
+ tscDebug("%p subIndex: %d, no need to launch query, ignore it", pSql, i);
tscDestroyJoinSupporter(pSupporter);
tscFreeSqlObj(pPrevSub);
@@ -355,7 +355,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
}
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
- tscTrace("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%zu, colList:%zu, fieldsInfo:%d, name:%s",
+ tscDebug("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%zu, colList:%zu, fieldsInfo:%d, name:%s",
pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, taosArrayGetSize(pNewQueryInfo->exprList),
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
}
@@ -431,7 +431,7 @@ static UNUSED_FUNC void tSIntersectionAndLaunchSecQuery(SJoinSupporter* pSupport
//// int32_t totalVnode = pTableMetaInfo->pMetricMeta->numOfVnodes;
// int32_t totalVnode = 0;
// if ((++pTableMetaInfo->vgroupIndex) < totalVnode) {
-// tscTrace("%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d", pSql,
+// tscDebug("%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d", pSql,
// pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVnode, pRes->numOfTotal);
//
// pSql->cmd.command = TSDB_SQL_SELECT;
@@ -448,7 +448,7 @@ static UNUSED_FUNC void tSIntersectionAndLaunchSecQuery(SJoinSupporter* pSupport
STimeWindow win = TSWINDOW_INITIALIZER;
int64_t num = doTSBlockIntersect(pParentSql, p1, p2, &win);
if (num <= 0) { // no result during ts intersect
- tscTrace("%p free all sub SqlObj and quit", pParentSql);
+ tscDebug("%p free all sub SqlObj and quit", pParentSql);
freeJoinSubqueryObj(pParentSql);
} else {
updateQueryTimeRange(pParentQueryInfo, &win);
@@ -495,7 +495,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr
taosArrayPush(result, &info);
}
- tscTrace("%p tid:%d, uid:%"PRIu64",vgId:%d added for vnode query", pSql, tt->tid, tt->uid, tt->vgId)
+ tscDebug("%p tid:%d, uid:%"PRIu64",vgId:%d added for vnode query", pSql, tt->tid, tt->uid, tt->vgId)
STableIdInfo item = {.uid = tt->uid, .tid = tt->tid, .key = INT64_MIN};
taosArrayPush(vgTables, &item);
prev = tt;
@@ -550,7 +550,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
- tscTrace(
+ tscDebug(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, "
"numOfExpr:%zu, colList:%zu, numOfOutputFields:%d, name:%s",
pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type,
@@ -581,7 +581,7 @@ static bool checkForDuplicateTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1,
}
static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) {
- tscTrace("%p all subqueries retrieve complete, do tags match", pParentSql);
+ tscDebug("%p all subqueries retrieve complete, do tags match", pParentSql);
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
SJoinSupporter* p2 = pParentSql->pSubs[1]->param;
@@ -611,7 +611,7 @@ static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParent
int32_t ret = doCompare(pp1->tag, pp2->tag, pColSchema->type, pColSchema->bytes);
if (ret == 0) {
- tscTrace("%p tag matched, vgId:%d, val:%d, tid:%d, uid:%"PRIu64", tid:%d, uid:%"PRIu64, pParentSql, pp1->vgId,
+ tscDebug("%p tag matched, vgId:%d, val:%d, tid:%d, uid:%"PRIu64", tid:%d, uid:%"PRIu64, pParentSql, pp1->vgId,
*(int*) pp1->tag, pp1->tid, pp1->uid, pp2->tid, pp2->uid);
taosArrayPush(*s1, pp1);
@@ -691,7 +691,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pTableMetaInfo->vgroupIndex += 1;
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
- tscTrace("%p tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
+ tscDebug("%p tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pSupporter->num);
pCmd->command = TSDB_SQL_SELECT;
@@ -712,7 +712,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
SArray *s1 = NULL, *s2 = NULL;
getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2);
if (taosArrayGetSize(s1) == 0 || taosArrayGetSize(s2) == 0) { // no results,return.
- tscTrace("%p free all sub SqlObj and quit", pParentSql);
+ tscDebug("%p free all sub SqlObj and quit", pParentSql);
freeJoinSubqueryObj(pParentSql);
} else {
@@ -782,7 +782,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
}
if (pSupporter->pTSBuf == NULL) {
- tscTrace("%p create tmp file for ts block:%s, size:%d bytes", pSql, pBuf->path, numOfRows);
+ tscDebug("%p create tmp file for ts block:%s, size:%d bytes", pSql, pBuf->path, numOfRows);
pSupporter->pTSBuf = pBuf;
} else {
assert(pQueryInfo->numOfTables == 1); // for subquery, only one
@@ -810,7 +810,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pTableMetaInfo->vgroupIndex += 1;
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
- tscTrace("%p results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64,
+ tscDebug("%p results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64,
pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups,
pRes->numOfClauseTotal);
@@ -834,7 +834,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
return;
}
- tscTrace("%p all subquery retrieve ts complete, do ts block intersect", pParentSql);
+ tscDebug("%p all subquery retrieve ts complete, do ts block intersect", pParentSql);
// proceeds to launched secondary query to retrieve final data
SJoinSupporter* p1 = pParentSql->pSubs[0]->param;
@@ -843,7 +843,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
STimeWindow win = TSWINDOW_INITIALIZER;
int64_t num = doTSBlockIntersect(pParentSql, p1, p2, &win);
if (num <= 0) { // no result during ts intersect
- tscTrace("%p no results generated in ts intersection, free all sub SqlObj and quit", pParentSql);
+ tscDebug("%p no results generated in ts intersection, free all sub SqlObj and quit", pParentSql);
freeJoinSubqueryObj(pParentSql);
return;
@@ -897,11 +897,11 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
}
if (atomic_sub_fetch_32(&pState->numOfRemain, 1) > 0) {
- tscTrace("%p sub:%p completed, remain:%d, total:%d", pParentSql, tres, pState->numOfRemain, pState->numOfTotal);
+ tscDebug("%p sub:%p completed, remain:%d, total:%d", pParentSql, tres, pState->numOfRemain, pState->numOfTotal);
return;
}
- tscTrace("%p all %d secondary subqueries retrieval completed, code:%d", tres, pState->numOfTotal, pParentSql->res.code);
+ tscDebug("%p all %d secondary subqueries retrieval completed, code:%d", tres, pState->numOfTotal, pParentSql->res.code);
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
freeJoinSubqueryObj(pParentSql);
@@ -1000,7 +1000,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
}
// TODO multi-vnode retrieve for projection query with limitation has bugs, since the global limiation is not handled
- tscTrace("%p retrieve data from %d subqueries", pSql, numOfFetch);
+ tscDebug("%p retrieve data from %d subqueries", pSql, numOfFetch);
SJoinSupporter* pSupporter = tscUpdateSubqueryStatus(pSql, numOfFetch);
for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
@@ -1021,7 +1021,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
if (pRes1->row >= pRes1->numOfRows) {
- tscTrace("%p subquery:%p retrieve data from vnode, subquery:%d, vgroupIndex:%d", pSql, pSql1,
+ tscDebug("%p subquery:%p retrieve data from vnode, subquery:%d, vgroupIndex:%d", pSql, pSql1,
pSupporter->subqueryIndex, pTableMetaInfo->vgroupIndex);
tscResetForNextRetrieve(pRes1);
@@ -1041,7 +1041,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
SSqlCmd* pCmd = &pSql->cmd;
SSqlRes* pRes = &pSql->res;
- tscTrace("%p all subquery response, retrieve data", pSql);
+ tscDebug("%p all subquery response, retrieve data", pSql);
// the column transfer support struct has been built
if (pRes->pColumnIndex != NULL) {
@@ -1243,7 +1243,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &index, &s1, TSDB_COL_TAG);
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
- tscTrace(
+ tscDebug(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), "
"exprInfo:%zu, colList:%zu, fieldsInfo:%d, tagIndex:%d, name:%s",
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
@@ -1278,7 +1278,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
- tscTrace(
+ tscDebug(
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%u, transfer to ts_comp query to retrieve timestamps, "
"exprInfo:%zu, colList:%zu, fieldsInfo:%d, name:%s",
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
@@ -1302,7 +1302,7 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
pState->numOfTotal = pQueryInfo->numOfTables;
pState->numOfRemain = pState->numOfTotal;
- tscTrace("%p start subquery, total:%d", pSql, pQueryInfo->numOfTables);
+ tscDebug("%p start subquery, total:%d", pSql, pQueryInfo->numOfTables);
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
SJoinSupporter *pSupporter = tscCreateJoinSupporter(pSql, pState, i);
@@ -1384,7 +1384,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
pSql->pSubs = calloc(pSql->numOfSubs, POINTER_BYTES);
- tscTrace("%p retrieved query data from %d vnode(s)", pSql, pSql->numOfSubs);
+ tscDebug("%p retrieved query data from %d vnode(s)", pSql, pSql->numOfSubs);
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
pState->numOfTotal = pSql->numOfSubs;
pState->numOfRemain = pSql->numOfSubs;
@@ -1436,7 +1436,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
assert(pNewQueryInfo->tsBuf != NULL);
}
- tscTrace("%p sub:%p create subquery success. orderOfSub:%d", pSql, pNew, trs->subqueryIndex);
+ tscDebug("%p sub:%p create subquery success. orderOfSub:%d", pSql, pNew, trs->subqueryIndex);
}
if (i < pSql->numOfSubs) {
@@ -1458,7 +1458,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
SSqlObj* pSub = pSql->pSubs[j];
SRetrieveSupport* pSupport = pSub->param;
- tscTrace("%p sub:%p launch subquery, orderOfSub:%d.", pSql, pSub, pSupport->subqueryIndex);
+ tscDebug("%p sub:%p launch subquery, orderOfSub:%d.", pSql, pSub, pSupport->subqueryIndex);
tscProcessSql(pSub);
}
@@ -1466,7 +1466,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
}
static void tscFreeSubSqlObj(SRetrieveSupport *trsupport, SSqlObj *pSql) {
- tscTrace("%p start to free subquery result", pSql);
+ tscDebug("%p start to free subquery result", pSql);
if (pSql->res.code == TSDB_CODE_SUCCESS) {
taos_free_result(pSql);
@@ -1522,12 +1522,12 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
*/
pSql->res.numOfRows = 0;
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; // disable retry efforts
- tscTrace("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%d", pParentSql, pSql,
+ tscDebug("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%d", pParentSql, pSql,
subqueryIndex, pParentSql->res.code);
}
if (numOfRows >= 0) { // current query is successful, but other sub query failed, still abort current query.
- tscTrace("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pParentSql, pSql, numOfRows, subqueryIndex);
+ tscDebug("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pParentSql, pSql, numOfRows, subqueryIndex);
tscError("%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%d", pParentSql, pSql,
subqueryIndex, pParentSql->res.code);
} else {
@@ -1542,7 +1542,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
trsupport->localBuffer->num = 0;
pthread_mutex_unlock(&trsupport->queryMutex);
- tscTrace("%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSqlObj, pSql,
+ tscDebug("%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSqlObj, pSql,
tstrerror(numOfRows), subqueryIndex, trsupport->numOfRetry);
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSqlObj, trsupport, pSql);
@@ -1566,7 +1566,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
int32_t remain = -1;
if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) {
- tscTrace("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex,
+ tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex,
pState->numOfTotal - remain);
return tscFreeSubSqlObj(trsupport, pSql);
@@ -1607,7 +1607,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// data in from current vnode is stored in cache and disk
uint32_t numOfRowsFromSubquery = trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->num;
- tscTrace("%p sub:%p all data retrieved from ip:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pPObj, pSql,
+ tscDebug("%p sub:%p all data retrieved from ip:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pPObj, pSql,
pTableMetaInfo->vgroupList->vgroups[0].ipAddr[0].fqdn, pTableMetaInfo->vgroupList->vgroups[0].vgId,
numOfRowsFromSubquery, idx);
@@ -1637,7 +1637,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
int32_t remain = -1;
if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) {
- tscTrace("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pPObj, pSql, trsupport->subqueryIndex,
+ tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pPObj, pSql, trsupport->subqueryIndex,
pState->numOfTotal - remain);
return tscFreeSubSqlObj(trsupport, pSql);
@@ -1646,14 +1646,14 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// all sub-queries are returned, start to local merge process
pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage;
- tscTrace("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pPObj,
+ tscDebug("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pPObj,
pState->numOfTotal, pState->numOfRetrievedRows);
SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pPObj->cmd, 0);
tscClearInterpInfo(pPQueryInfo);
tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfTotal, pDesc, trsupport->pFinalColModel, pPObj);
- tscTrace("%p build loser tree completed", pPObj);
+ tscDebug("%p build loser tree completed", pPObj);
pPObj->res.precision = pSql->res.precision;
pPObj->res.numOfRows = 0;
@@ -1680,7 +1680,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
SSqlObj *pSql = (SSqlObj *)tres;
if (pSql == NULL) { // sql object has been released in error process, return immediately
- tscTrace("%p subquery has been released, idx:%d, abort", pPObj, idx);
+ tscDebug("%p subquery has been released, idx:%d, abort", pPObj, idx);
return;
}
@@ -1701,7 +1701,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
assert(pRes->numOfRows == numOfRows);
int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows);
- tscTrace("%p sub:%p retrieve numOfRows:%" PRId64 " totalNumOfRows:%" PRIu64 " from ip:%s, orderOfSub:%d", pPObj, pSql,
+ tscDebug("%p sub:%p retrieve numOfRows:%" PRId64 " totalNumOfRows:%" PRIu64 " from ip:%s, orderOfSub:%d", pPObj, pSql,
pRes->numOfRows, pState->numOfRetrievedRows, pSql->ipList.fqdn[pSql->ipList.inUse], idx);
if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0)) {
@@ -1790,7 +1790,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
code = pParentSql->res.code;
}
- tscTrace("%p query cancelled or failed, sub:%p, orderOfSub:%d abort, code:%s", pParentSql, pSql,
+ tscDebug("%p query cancelled or failed, sub:%p, orderOfSub:%d abort, code:%s", pParentSql, pSql,
trsupport->subqueryIndex, tstrerror(code));
}
@@ -1803,10 +1803,10 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
*/
if (code != TSDB_CODE_SUCCESS) {
if (trsupport->numOfRetry++ >= MAX_NUM_OF_SUBQUERY_RETRY) {
- tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
+ tscDebug("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, code);
} else { // does not reach the maximum retry time, go on
- tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
+ tscDebug("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
SSqlObj *pNew = tscCreateSqlObjForSubquery(pParentSql, trsupport, pSql);
@@ -1828,12 +1828,12 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
}
if (pParentSql->res.code != TSDB_CODE_SUCCESS) { // at least one peer subquery failed, abort current query
- tscTrace("%p sub:%p query failed,ip:%s,vgId:%d,orderOfSub:%d,global code:%d", pParentSql, pSql,
+ tscDebug("%p sub:%p query failed,ip:%s,vgId:%d,orderOfSub:%d,global code:%d", pParentSql, pSql,
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex, pParentSql->res.code);
tscHandleSubqueryError(param, tres, pParentSql->res.code);
} else { // success, proceed to retrieve data from dnode
- tscTrace("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSqlObj, pSql,
+ tscDebug("%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSqlObj, pSql,
pVgroup->ipAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
if (pSql->res.qhandle == 0) { // qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
@@ -1869,7 +1869,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
return;
}
- tscTrace("%p Async insertion completed, total inserted:%" PRId64, pParentObj, pParentObj->res.numOfRows);
+ tscDebug("%p Async insertion completed, total inserted:%" PRId64, pParentObj, pParentObj->res.numOfRows);
// release data block data
tfree(pState);
@@ -1892,7 +1892,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
pSql->pSubs = calloc(size, POINTER_BYTES);
pSql->numOfSubs = size;
- tscTrace("%p submit data to %zu vnode(s)", pSql, size);
+ tscDebug("%p submit data to %zu vnode(s)", pSql, size);
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
pState->numOfTotal = pSql->numOfSubs;
@@ -1922,10 +1922,10 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
STableDataBlocks* pTableDataBlock = taosArrayGetP(pCmd->pDataBlocks, numOfSub);
pRes->code = tscCopyDataBlockToPayload(pNew, pTableDataBlock);
if (pRes->code == TSDB_CODE_SUCCESS) {
- tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, numOfSub);
+ tscDebug("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, numOfSub);
numOfSub++;
} else {
- tscTrace("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%zu, code:%s", pSql, numOfSub,
+ tscDebug("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%zu, code:%s", pSql, numOfSub,
size, tstrerror(pRes->code));
goto _error;
}
@@ -1940,7 +1940,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
// use the local variable
for (int32_t j = 0; j < numOfSub; ++j) {
SSqlObj *pSub = pSql->pSubs[j];
- tscTrace("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, j);
+ tscDebug("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, j);
tscProcessSql(pSub);
}
@@ -2006,7 +2006,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
break;
} else { // continue retrieve data from vnode
if (!tscHasRemainDataInSubqueryResultSet(pSql)) {
- tscTrace("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
+ tscDebug("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
SSubqueryState *pState = NULL;
// free all sub sqlobj
diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c
index f04b8b6337..201ace43de 100644
--- a/src/client/src/tscSystem.c
+++ b/src/client/src/tscSystem.c
@@ -72,7 +72,7 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
tscError("failed to init connection to TDengine");
return -1;
} else {
- tscTrace("dnodeConn:%p is created, user:%s", *pDnodeConn, user);
+ tscDebug("dnodeConn:%p is created, user:%s", *pDnodeConn, user);
}
}
@@ -106,8 +106,8 @@ void taos_init_imp() {
taosCheckGlobalCfg();
taosPrintGlobalCfg();
- tscTrace("starting to initialize TAOS client ...");
- tscTrace("Local End Point is:%s", tsLocalEp);
+ tscDebug("starting to initialize TAOS client ...");
+ tscDebug("Local End Point is:%s", tsLocalEp);
}
taosSetCoreDump();
@@ -151,7 +151,7 @@ void taos_init_imp() {
tscCacheHandle = taosCacheInit(refreshTime);
}
- tscTrace("client is initialized successfully");
+ tscDebug("client is initialized successfully");
}
void taos_init() { pthread_once(&tscinit, taos_init_imp); }
@@ -182,7 +182,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
tstrncpy(configDir, pStr, TSDB_FILENAME_LEN);
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
- tscPrint("set config file directory:%s", pStr);
+ tscInfo("set config file directory:%s", pStr);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
@@ -198,7 +198,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
if (tsShellActivityTimer < 1) tsShellActivityTimer = 1;
if (tsShellActivityTimer > 3600) tsShellActivityTimer = 3600;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
- tscPrint("set shellActivityTimer:%d", tsShellActivityTimer);
+ tscInfo("set shellActivityTimer:%d", tsShellActivityTimer);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, pStr,
tsCfgStatusStr[cfg->cfgStatus], *(int32_t *)cfg->ptr);
@@ -211,7 +211,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
size_t len = strlen(pStr);
if (len == 0 || len > TSDB_LOCALE_LEN) {
- tscPrint("Invalid locale:%s, use default", pStr);
+ tscInfo("Invalid locale:%s, use default", pStr);
return -1;
}
@@ -227,11 +227,11 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
char *locale = setlocale(LC_CTYPE, pStr);
if (locale != NULL) {
- tscPrint("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
+ tscInfo("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else { // set the user-specified localed failed, use default LC_CTYPE as current locale
locale = setlocale(LC_CTYPE, tsLocale);
- tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale);
+ tscInfo("failed to set locale:%s, current locale:%s", pStr, tsLocale);
}
tstrncpy(tsLocale, locale, sizeof(tsLocale));
@@ -244,21 +244,21 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
if (taosValidateEncodec(charset)) {
if (strlen(tsCharset) == 0) {
- tscPrint("charset set:%s", charset);
+ tscInfo("charset set:%s", charset);
} else {
- tscPrint("charset changed from %s to %s", tsCharset, charset);
+ tscInfo("charset changed from %s to %s", tsCharset, charset);
}
tstrncpy(tsCharset, charset, sizeof(tsCharset));
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else {
- tscPrint("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
+ tscInfo("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
}
free(charset);
} else { // it may be windows system
- tscPrint("charset remains:%s", tsCharset);
+ tscInfo("charset remains:%s", tsCharset);
}
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr,
@@ -274,22 +274,22 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
size_t len = strlen(pStr);
if (len == 0 || len > TSDB_LOCALE_LEN) {
- tscPrint("failed to set charset:%s", pStr);
+ tscInfo("failed to set charset:%s", pStr);
return -1;
}
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
if (taosValidateEncodec(pStr)) {
if (strlen(tsCharset) == 0) {
- tscPrint("charset is set:%s", pStr);
+ tscInfo("charset is set:%s", pStr);
} else {
- tscPrint("charset changed from %s to %s", tsCharset, pStr);
+ tscInfo("charset changed from %s to %s", tsCharset, pStr);
}
tstrncpy(tsCharset, pStr, sizeof(tsCharset));
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
} else {
- tscPrint("charset:%s not valid", pStr);
+ tscInfo("charset:%s not valid", pStr);
}
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr,
@@ -307,7 +307,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
tstrncpy(tsTimezone, pStr, sizeof(tsTimezone));
tsSetTimeZone();
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
- tscTrace("timezone set:%s, input:%s by taos_options", tsTimezone, pStr);
+ tscDebug("timezone set:%s, input:%s by taos_options", tsTimezone, pStr);
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, pStr,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
@@ -328,7 +328,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) {
if (i % 1000 == 0) {
- tscPrint("haven't acquire lock after spin %d times.", i);
+ tscInfo("haven't acquire lock after spin %d times.", i);
sched_yield();
}
}
diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c
index 4d90caddcb..d15a0d7fcc 100644
--- a/src/client/src/tscUtil.c
+++ b/src/client/src/tscUtil.c
@@ -374,7 +374,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
return;
}
- tscTrace("%p start to free sql object", pSql);
+ tscDebug("%p start to free sql object", pSql);
tscPartiallyFreeSqlObj(pSql);
pSql->signature = NULL;
@@ -656,7 +656,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
tscSortRemoveDataBlockDupRows(pOneTableBlock);
char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1);
- tscTrace("%p tableId:%s, sid:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, pOneTableBlock->tableId,
+ tscDebug("%p tableId:%s, sid:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, pOneTableBlock->tableId,
pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey));
@@ -702,7 +702,7 @@ void tscCloseTscObj(STscObj* pObj) {
rpcClose(pObj->pDnodeConn);
}
- tscTrace("%p DB connection is closed, dnodeConn:%p", pObj, pObj->pDnodeConn);
+ tscDebug("%p DB connection is closed, dnodeConn:%p", pObj, pObj->pDnodeConn);
tfree(pObj);
}
@@ -1562,7 +1562,7 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd) {
}
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) {
- tscTrace("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables);
+ tscDebug("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables);
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
@@ -1844,7 +1844,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
if (cmd == TSDB_SQL_SELECT) {
size_t size = taosArrayGetSize(pNewQueryInfo->colList);
- tscTrace(
+ tscDebug(
"%p new subquery:%p, tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%zu, colList:%zu,"
"fieldInfo:%d, name:%s, qrang:%" PRId64 " - %" PRId64 " order:%d, limit:%" PRId64,
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
@@ -1853,7 +1853,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
tscPrintSelectClause(pNew, 0);
} else {
- tscTrace("%p new sub insertion: %p, vnodeIdx:%d", pSql, pNew, pTableMetaInfo->vgroupIndex);
+ tscDebug("%p new sub insertion: %p, vnodeIdx:%d", pSql, pNew, pTableMetaInfo->vgroupIndex);
}
return pNew;
@@ -1880,7 +1880,7 @@ void tscDoQuery(SSqlObj* pSql) {
}
if (pCmd->dataSourceType == DATA_FROM_DATA_FILE) {
- tscProcessMultiVnodesInsertFromFile(pSql);
+ tscProcessMultiVnodesImportFromFile(pSql);
} else {
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
uint16_t type = pQueryInfo->type;
@@ -2012,7 +2012,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups;
while (++pTableMetaInfo->vgroupIndex < totalVgroups) {
- tscTrace("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql,
+ tscDebug("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql,
pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal);
/*
@@ -2031,7 +2031,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
pQueryInfo->limit.offset = pRes->offset;
assert((pRes->offset >= 0 && pRes->numOfRows == 0) || (pRes->offset == 0 && pRes->numOfRows >= 0));
- tscTrace("%p new query to next vgroup, index:%d, limit:%" PRId64 ", offset:%" PRId64 ", glimit:%" PRId64,
+ tscDebug("%p new query to next vgroup, index:%d, limit:%" PRId64 ", offset:%" PRId64 ", glimit:%" PRId64,
pSql, pTableMetaInfo->vgroupIndex, pQueryInfo->limit.limit, pQueryInfo->limit.offset, pQueryInfo->clauseLimit);
/*
@@ -2081,7 +2081,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) {
assert(queryFp != NULL);
}
- tscTrace("%p try data in the next subclause:%d, total subclause:%d", pSql, pCmd->clauseIndex, pCmd->numOfClause);
+ tscDebug("%p try data in the next subclause:%d, total subclause:%d", pSql, pCmd->clauseIndex, pCmd->numOfClause);
if (pCmd->command > TSDB_SQL_LOCAL) {
tscProcessLocalCmd(pSql);
} else {
diff --git a/src/client/tests/CMakeLists.txt b/src/client/tests/CMakeLists.txt
new file mode 100644
index 0000000000..f07af85e25
--- /dev/null
+++ b/src/client/tests/CMakeLists.txt
@@ -0,0 +1,15 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(TDengine)
+
+FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest)
+FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib)
+
+IF (HEADER_GTEST_INCLUDE_DIR AND LIB_GTEST_STATIC_DIR)
+ MESSAGE(STATUS "gTest library found, build unit test")
+
+ INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR})
+ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
+
+ ADD_EXECUTABLE(cliTest ${SOURCE_LIST})
+ TARGET_LINK_LIBRARIES(cliTest taos tutil common gtest pthread)
+ENDIF()
\ No newline at end of file
diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h
index 2a51eb9933..371df5c335 100644
--- a/src/common/inc/tglobal.h
+++ b/src/common/inc/tglobal.h
@@ -158,9 +158,10 @@ extern int32_t mqttDebugFlag;
extern int32_t monitorDebugFlag;
extern int32_t uDebugFlag;
extern int32_t rpcDebugFlag;
-extern int32_t debugFlag;
extern int32_t odbcDebugFlag;
extern int32_t qDebugFlag;
+extern int32_t wDebugFlag;
+extern int32_t debugFlag;
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
diff --git a/src/common/inc/tulog.h b/src/common/inc/tulog.h
index 07120d7cbe..63c838be69 100644
--- a/src/common/inc/tulog.h
+++ b/src/common/inc/tulog.h
@@ -25,15 +25,18 @@ extern "C" {
extern int32_t uDebugFlag;
extern int32_t tscEmbedded;
-#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR UTL ", uDebugFlag, __VA_ARGS__); }}
-#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("WARN UTL ", uDebugFlag, __VA_ARGS__); }}
-#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
-#define uDump(x, y) { if (uDebugFlag & DEBUG_DUMP) { taosDumpData(x, y); }}
-#define uPrint(...) { taosPrintLog("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
-#define uForcePrint(...) { taosPrintLog("ERROR UTL ", 255, __VA_ARGS__); }
+#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
+#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
+#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
+#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL INFO ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
+#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL DEBUG ", uDebugFlag, __VA_ARGS__); }}
+#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL TRACE ", uDebugFlag, __VA_ARGS__); }}
-#define pError(...) { taosPrintLog("ERROR APP ", 255, __VA_ARGS__); }
-#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
+#define uDebugDump(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLongString("UTL DEBUG ", uDebugFlag, __VA_ARGS__); }}
+#define uTraceDump(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLongString("UTL TRACE ", uDebugFlag, __VA_ARGS__); }}
+
+#define pError(...) { taosPrintLog("APP ERROR ", 255, __VA_ARGS__); }
+#define pPrint(...) { taosPrintLog("APP INFO ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c
index d04033abc9..6dc6a82d09 100644
--- a/src/common/src/tglobal.c
+++ b/src/common/src/tglobal.c
@@ -182,19 +182,20 @@ int32_t tsNumOfLogLines = 10000000;
int32_t mDebugFlag = 135;
int32_t sdbDebugFlag = 135;
int32_t dDebugFlag = 135;
-int32_t vDebugFlag = 135;
-int32_t cDebugFlag = 135;
+int32_t vDebugFlag = 131;
+int32_t cDebugFlag = 131;
int32_t jniDebugFlag = 131;
int32_t odbcDebugFlag = 131;
int32_t httpDebugFlag = 131;
int32_t mqttDebugFlag = 131;
int32_t monitorDebugFlag = 131;
int32_t qDebugFlag = 131;
-int32_t rpcDebugFlag = 135;
+int32_t rpcDebugFlag = 131;
int32_t uDebugFlag = 131;
int32_t debugFlag = 131;
int32_t sDebugFlag = 135;
-int32_t tsdbDebugFlag = 135;
+int32_t wDebugFlag = 135;
+int32_t tsdbDebugFlag = 131;
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
@@ -213,10 +214,11 @@ void taosSetAllDebugFlag() {
rpcDebugFlag = debugFlag;
uDebugFlag = debugFlag;
sDebugFlag = debugFlag;
+ wDebugFlag = debugFlag;
tsdbDebugFlag = debugFlag;
qDebugFlag = debugFlag;
}
- uPrint("all debug flag are set to %d", debugFlag);
+ uInfo("all debug flag are set to %d", debugFlag);
}
bool taosCfgDynamicOptions(char *msg) {
@@ -234,7 +236,7 @@ bool taosCfgDynamicOptions(char *msg) {
vint = atoi(value);
}
- uPrint("change dynamic option: %s, value: %d", option, vint);
+ uInfo("change dynamic option: %s, value: %d", option, vint);
for (int32_t i = 0; i < tsGlobalConfigNum; ++i) {
SGlobalCfg *cfg = tsGlobalConfig + i;
@@ -977,6 +979,17 @@ static void doInitGlobalConfig() {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
+ cfg.option = "wDebugFlag";
+ cfg.ptr = &wDebugFlag;
+ cfg.valType = TAOS_CFG_VTYPE_INT32;
+ cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
+ cfg.minValue = 0;
+ cfg.maxValue = 255;
+ cfg.ptrLength = 0;
+ cfg.unitType = TAOS_CFG_UTYPE_NONE;
+ taosInitConfigOption(cfg);
+
+
cfg.option = "sdbDebugFlag";
cfg.ptr = &sdbDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32;
@@ -1067,7 +1080,6 @@ static void doInitGlobalConfig() {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
-
cfg.option = "monitorDebugFlag";
cfg.ptr = &monitorDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32;
@@ -1088,6 +1100,16 @@ static void doInitGlobalConfig() {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
+ cfg.option = "vDebugFlag";
+ cfg.ptr = &vDebugFlag;
+ cfg.valType = TAOS_CFG_VTYPE_INT32;
+ cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
+ cfg.minValue = 0;
+ cfg.maxValue = 255;
+ cfg.ptrLength = 0;
+ cfg.unitType = TAOS_CFG_UTYPE_NONE;
+ taosInitConfigOption(cfg);
+
cfg.option = "tsdbDebugFlag";
cfg.ptr = &tsdbDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32;
@@ -1175,7 +1197,7 @@ void taosInitGlobalCfg() {
}
bool taosCheckGlobalCfg() {
- if (debugFlag == 135 || debugFlag == 199) {
+ if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG) {
taosSetAllDebugFlag();
}
@@ -1184,7 +1206,7 @@ bool taosCheckGlobalCfg() {
}
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%d", tsLocalFqdn, tsServerPort);
- uPrint("localEp is: %s", tsLocalEp);
+ uInfo("localEp is: %s", tsLocalEp);
if (tsFirst[0] == 0) {
strcpy(tsFirst, tsLocalEp);
diff --git a/src/common/src/ttimezone.c b/src/common/src/ttimezone.c
index ae6ffea59a..edb6aea7f9 100644
--- a/src/common/src/ttimezone.c
+++ b/src/common/src/ttimezone.c
@@ -20,9 +20,10 @@
#include "tconfig.h"
#include "tutil.h"
+// TODO refactor to set the tz value through parameter
void tsSetTimeZone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
- uPrint("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
+ uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
#ifdef WINDOWS
char winStr[TSDB_LOCALE_LEN * 2];
@@ -60,5 +61,5 @@ void tsSetTimeZone() {
sprintf(tsTimezone, "(%s, %s%02d00)", tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
tsDaylight = daylight;
- uPrint("timezone format changed to %s", tsTimezone);
+ uInfo("timezone format changed to %s", tsTimezone);
}
diff --git a/src/connector/grafana/tdengine/package.json b/src/connector/grafana/tdengine/package.json
index 0eb7a76be6..678278ec47 100644
--- a/src/connector/grafana/tdengine/package.json
+++ b/src/connector/grafana/tdengine/package.json
@@ -1,7 +1,7 @@
{
"name": "TDengine",
"private": false,
- "version": "1.0.0",
+ "version": "2.0.0",
"description": "grafana datasource plugin for tdengine",
"scripts": {
"build": "./node_modules/grunt-cli/bin/grunt",
diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt
index 05c8bebafe..7f823b97b2 100644
--- a/src/connector/jdbc/CMakeLists.txt
+++ b/src/connector/jdbc/CMakeLists.txt
@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-1.0.3-dist.jar ${LIBRARY_OUTPUT_PATH}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.0-dist.jar ${LIBRARY_OUTPUT_PATH}
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMENT "build jdbc driver")
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
diff --git a/src/connector/jdbc/buildTDengine.sh b/src/connector/jdbc/buildTDengine.sh
new file mode 100755
index 0000000000..cf98215c85
--- /dev/null
+++ b/src/connector/jdbc/buildTDengine.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+ulimit -c unlimited
+
+function buildTDengine {
+ cd /root/TDengine
+
+ git remote update
+ REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop`
+ LOCAL_COMMIT=`git rev-parse --short @`
+
+ echo " LOCAL: $LOCAL_COMMIT"
+ echo "REMOTE: $REMOTE_COMMIT"
+ if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then
+ echo "repo up-to-date"
+ else
+ echo "repo need to pull"
+ git pull
+
+ LOCAL_COMMIT=`git rev-parse --short @`
+ cd /root/TDengine/debug
+ rm -rf /root/TDengine/debug/*
+ cmake ..
+ make > /dev/null
+ make install
+ fi
+}
+
+function restartTaosd {
+ systemctl stop taosd
+ pkill -KILL -x taosd
+ sleep 10
+
+ logDir=`grep 'logDir' /etc/taos/taos.cfg|awk 'END{print $2}'`
+ dataDir=`grep 'dataDir' /etc/taos/taos.cfg|awk '{print $2}'`
+
+ rm -rf $logDir/*
+ rm -rf $dataDir/*
+
+ taosd 2>&1 > /dev/null &
+ sleep 10
+}
+
+buildTDengine
+restartTaosd
diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml
index 5aa4f6a2e3..2f0c3c78e7 100755
--- a/src/connector/jdbc/pom.xml
+++ b/src/connector/jdbc/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.taosdata.jdbc
taos-jdbcdriver
- 1.0.3
+ 2.0.0
jar
JDBCDriver
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
diff --git a/src/connector/jdbc/src/test/java/TestAsyncTSDBSubscribe.java b/src/connector/jdbc/src/test/java/TestAsyncTSDBSubscribe.java
index 55ab2fdc52..03a4761b91 100644
--- a/src/connector/jdbc/src/test/java/TestAsyncTSDBSubscribe.java
+++ b/src/connector/jdbc/src/test/java/TestAsyncTSDBSubscribe.java
@@ -8,7 +8,7 @@ import java.util.Properties;
public class TestAsyncTSDBSubscribe {
public static void main(String[] args) throws SQLException {
- String usage = "java -cp taos-jdbcdriver-1.0.3_dev-dist.jar com.taosdata.jdbc.TSDBSubscribe -db dbName -topic topicName " +
+ String usage = "java -cp taos-jdbcdriver-2.0.0_dev-dist.jar com.taosdata.jdbc.TSDBSubscribe -db dbName -topic topicName " +
"-tname tableName -h host";
if (args.length < 2) {
System.err.println(usage);
diff --git a/src/connector/jdbc/src/test/java/TestTSDBSubscribe.java b/src/connector/jdbc/src/test/java/TestTSDBSubscribe.java
index f628f3cada..598ef4bbc0 100644
--- a/src/connector/jdbc/src/test/java/TestTSDBSubscribe.java
+++ b/src/connector/jdbc/src/test/java/TestTSDBSubscribe.java
@@ -10,7 +10,7 @@ import java.util.Properties;
public class TestTSDBSubscribe {
public static void main(String[] args) throws Exception {
- String usage = "java -cp taos-jdbcdriver-1.0.3_dev-dist.jar com.taosdata.jdbc.TSDBSubscribe -db dbName " +
+ String usage = "java -cp taos-jdbcdriver-2.0.0_dev-dist.jar com.taosdata.jdbc.TSDBSubscribe -db dbName " +
"-topic topicName -tname tableName -h host";
if (args.length < 2) {
System.err.println(usage);
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/AsyncSubscribeTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/AsyncSubscribeTest.java
index 98b0d38b8d..7f2314d295 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/AsyncSubscribeTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/AsyncSubscribeTest.java
@@ -12,7 +12,7 @@ import java.util.Properties;
import static org.junit.Assert.assertTrue;
-public class AsyncSubscribeTest {
+public class AsyncSubscribeTest extends BaseTest {
Connection connection = null;
Statement statement = null;
String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
new file mode 100644
index 0000000000..fd9ab49c49
--- /dev/null
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BaseTest.java
@@ -0,0 +1,27 @@
+package com.taosdata.jdbc;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import org.junit.BeforeClass;
+
+public class BaseTest {
+
+ @BeforeClass
+ public static void setupEnv() {
+ try{
+ String path = System.getProperty("user.dir");
+ String bashPath = path + "/buildTDengine.sh";
+
+ Process ps = Runtime.getRuntime().exec(bashPath);
+ ps.waitFor();
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
+ while(br.readLine() != null) {
+ System.out.println(br.readLine());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java
index 5e5dabfe81..3fc8913ca3 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java
@@ -10,7 +10,7 @@ import java.util.Properties;
import static org.junit.Assert.assertTrue;
-public class ConnectionTest {
+public class ConnectionTest extends BaseTest {
static Connection connection = null;
static Statement statement = null;
static String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
index 20ebc093ec..4c4d56020d 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
@@ -7,7 +7,7 @@ import org.junit.Test;
import java.sql.*;
import java.util.Properties;
-public class DatabaseMetaDataTest {
+public class DatabaseMetaDataTest extends BaseTest {
static Connection connection = null;
static PreparedStatement statement = null;
static String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java
index b42d46aefe..016eff1a35 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java
@@ -9,7 +9,7 @@ import java.util.Properties;
import static org.junit.Assert.assertEquals;
-public class ImportTest {
+public class ImportTest extends BaseTest {
Connection connection = null;
Statement statement = null;
String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java
index 4c49727a7f..d391771269 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@FixMethodOrder(MethodSorters.DEFAULT)
-public class PreparedStatementTest {
+public class PreparedStatementTest extends BaseTest {
static Connection connection = null;
static PreparedStatement statement = null;
static String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
index 2b74a98db2..5d86840ec3 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ResultSetTest.java
@@ -13,7 +13,7 @@ import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class ResultSetTest {
+public class ResultSetTest extends BaseTest {
static Connection connection = null;
static Statement statement = null;
static String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java
index 282ca6c1a7..de21cc6195 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java
@@ -9,7 +9,7 @@ import java.util.Properties;
import static org.junit.Assert.assertEquals;
-public class SelectTest {
+public class SelectTest extends BaseTest {
Connection connection = null;
Statement statement = null;
String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java
index b275112e18..c1321d08fc 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java
@@ -12,7 +12,7 @@ import java.util.Properties;
import static org.junit.Assert.assertEquals;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class StableTest {
+public class StableTest extends BaseTest {
static Connection connection = null;
static Statement statement = null;
static String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
index 4be68519c5..4fe5c39486 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java
@@ -10,7 +10,7 @@ import java.util.Properties;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class StatementTest {
+public class StatementTest extends BaseTest {
static Connection connection = null;
static Statement statement = null;
static String dbName = "test";
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
index 25f7f7a285..58e93fbc7f 100644
--- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
@@ -12,7 +12,7 @@ import java.util.Properties;
import static org.junit.Assert.assertTrue;
-public class SubscribeTest {
+public class SubscribeTest extends BaseTest {
Connection connection = null;
Statement statement = null;
String dbName = "test";
diff --git a/src/connector/nodejs/package.json b/src/connector/nodejs/package.json
index 8d7a971aa3..2bc4a2453d 100644
--- a/src/connector/nodejs/package.json
+++ b/src/connector/nodejs/package.json
@@ -1,6 +1,6 @@
{
"name": "td-connector",
- "version": "1.6.1",
+ "version": "2.0.0",
"description": "A Node.js connector for TDengine.",
"main": "tdengine.js",
"scripts": {
diff --git a/src/connector/python/linux/python2/setup.py b/src/connector/python/linux/python2/setup.py
index ae5ebad671..2e4f80b8f0 100644
--- a/src/connector/python/linux/python2/setup.py
+++ b/src/connector/python/linux/python2/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="taos",
- version="1.4.15",
+ version="2.0.0",
author="Taosdata Inc.",
author_email="support@taosdata.com",
description="TDengine python client package",
diff --git a/src/connector/python/linux/python2/taos.egg-info/PKG-INFO b/src/connector/python/linux/python2/taos.egg-info/PKG-INFO
index ce6d8c58b2..96bf9059fd 100644
--- a/src/connector/python/linux/python2/taos.egg-info/PKG-INFO
+++ b/src/connector/python/linux/python2/taos.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: taos
-Version: 1.4.15
+Version: 2.0.0
Summary: TDengine python client package
Home-page: https://github.com/pypa/sampleproject
Author: Taosdata Inc.
diff --git a/src/connector/python/linux/python3/setup.py b/src/connector/python/linux/python3/setup.py
index 0669953ca3..03a49fc1c5 100644
--- a/src/connector/python/linux/python3/setup.py
+++ b/src/connector/python/linux/python3/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="taos",
- version="1.4.15",
+ version="2.0.0",
author="Taosdata Inc.",
author_email="support@taosdata.com",
description="TDengine python client package",
diff --git a/src/connector/python/linux/python3/taos.egg-info/PKG-INFO b/src/connector/python/linux/python3/taos.egg-info/PKG-INFO
index b1a77c8ac7..1e6c829ef1 100644
--- a/src/connector/python/linux/python3/taos.egg-info/PKG-INFO
+++ b/src/connector/python/linux/python3/taos.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: taos
-Version: 1.4.15
+Version: 2.0.0
Summary: TDengine python client package
Home-page: https://github.com/pypa/sampleproject
Author: Taosdata Inc.
diff --git a/src/connector/python/windows/python2/setup.py b/src/connector/python/windows/python2/setup.py
index cace06f443..fd82a55650 100644
--- a/src/connector/python/windows/python2/setup.py
+++ b/src/connector/python/windows/python2/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="taos",
- version="1.4.15",
+ version="2.0.0",
author="Taosdata Inc.",
author_email="support@taosdata.com",
description="TDengine python client package",
diff --git a/src/connector/python/windows/python2/taos.egg-info/PKG-INFO b/src/connector/python/windows/python2/taos.egg-info/PKG-INFO
index 9673ab6c5c..9babb669a7 100644
--- a/src/connector/python/windows/python2/taos.egg-info/PKG-INFO
+++ b/src/connector/python/windows/python2/taos.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: taos
-Version: 1.4.15
+Version: 2.0.0
Summary: TDengine python client package
Home-page: https://github.com/pypa/sampleproject
Author: Taosdata Inc.
diff --git a/src/connector/python/windows/python3/setup.py b/src/connector/python/windows/python3/setup.py
index 7cac04b723..9abdace5a9 100644
--- a/src/connector/python/windows/python3/setup.py
+++ b/src/connector/python/windows/python3/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="taos",
- version="1.4.15",
+ version="2.0.0",
author="Taosdata Inc.",
author_email="support@taosdata.com",
description="TDengine python client package",
diff --git a/src/connector/python/windows/python3/taos.egg-info/PKG-INFO b/src/connector/python/windows/python3/taos.egg-info/PKG-INFO
index 191327092b..6213b0d165 100644
--- a/src/connector/python/windows/python3/taos.egg-info/PKG-INFO
+++ b/src/connector/python/windows/python3/taos.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: taos
-Version: 1.4.15
+Version: 2.0.0
Summary: TDengine python client package
Home-page: https://github.com/pypa/sampleproject
Author: Hongze Cheng
diff --git a/src/dnode/inc/dnodeInt.h b/src/dnode/inc/dnodeInt.h
index 34bfe6e4f7..76f2f41673 100644
--- a/src/dnode/inc/dnodeInt.h
+++ b/src/dnode/inc/dnodeInt.h
@@ -24,10 +24,12 @@ extern "C" {
extern int32_t dDebugFlag;
-#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR DND ", 255, __VA_ARGS__); }}
-#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); }}
-#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
-#define dPrint(...) { taosPrintLog("DND ", 255, __VA_ARGS__); }
+#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", 255, __VA_ARGS__); }}
+#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", 255, __VA_ARGS__); }}
+#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", 255, __VA_ARGS__); }}
+#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND INFO ", 255, __VA_ARGS__); }}
+#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND DEBUG ", dDebugFlag, __VA_ARGS__); }}
+#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND TRACE ", dDebugFlag, __VA_ARGS__); }}
#ifdef __cplusplus
}
diff --git a/src/dnode/src/dnodeMPeer.c b/src/dnode/src/dnodeMPeer.c
index 71c2d0e65f..3211487ff9 100644
--- a/src/dnode/src/dnodeMPeer.c
+++ b/src/dnode/src/dnodeMPeer.c
@@ -55,7 +55,7 @@ int32_t dnodeInitMnodePeer() {
pWorker->workerId = i;
}
- dPrint("dnode mpeer is opened");
+ dInfo("dnode mpeer is opened");
return 0;
}
@@ -74,7 +74,9 @@ void dnodeCleanupMnodePeer() {
}
}
- dPrint("dnode mpeer is closed");
+ taosCloseQset(tsMPeerQset);
+ tfree(tsMPeerPool.peerWorker);
+ dInfo("dnode mpeer is closed");
}
int32_t dnodeAllocateMnodePqueue() {
@@ -96,10 +98,10 @@ int32_t dnodeAllocateMnodePqueue() {
}
pthread_attr_destroy(&thAttr);
- dTrace("dnode mpeer worker:%d is launched, total:%d", pWorker->workerId, tsMPeerPool.num);
+ dDebug("dnode mpeer worker:%d is launched, total:%d", pWorker->workerId, tsMPeerPool.num);
}
- dTrace("dnode mpeer queue:%p is allocated", tsMPeerQueue);
+ dDebug("dnode mpeer queue:%p is allocated", tsMPeerQueue);
return TSDB_CODE_SUCCESS;
}
@@ -145,11 +147,11 @@ static void *dnodeProcessMnodePeerQueue(void *param) {
while (1) {
if (taosReadQitemFromQset(tsMPeerQset, &type, (void **)&pPeerMsg, &unUsed) == 0) {
- dTrace("dnodeProcessMnodePeerQueue: got no message from qset, exiting...");
+ dDebug("dnodeProcessMnodePeerQueue: got no message from qset, exiting...");
break;
}
- dTrace("msg:%s will be processed in mpeer queue", taosMsg[pPeerMsg->rpcMsg.msgType]);
+ dDebug("msg:%s will be processed in mpeer queue", taosMsg[pPeerMsg->rpcMsg.msgType]);
int32_t code = mnodeProcessPeerReq(pPeerMsg);
dnodeSendRpcMnodePeerRsp(pPeerMsg, code);
}
diff --git a/src/dnode/src/dnodeMRead.c b/src/dnode/src/dnodeMRead.c
index cb02ffbb1d..c431cc23db 100644
--- a/src/dnode/src/dnodeMRead.c
+++ b/src/dnode/src/dnodeMRead.c
@@ -57,7 +57,7 @@ int32_t dnodeInitMnodeRead() {
pWorker->workerId = i;
}
- dPrint("dnode mread is opened");
+ dInfo("dnode mread is opened");
return 0;
}
@@ -79,7 +79,7 @@ void dnodeCleanupMnodeRead() {
taosCloseQset(tsMReadQset);
free(tsMReadPool.readWorker);
- dPrint("dnode mread is closed");
+ dInfo("dnode mread is closed");
}
int32_t dnodeAllocateMnodeRqueue() {
@@ -101,10 +101,10 @@ int32_t dnodeAllocateMnodeRqueue() {
}
pthread_attr_destroy(&thAttr);
- dTrace("dnode mread worker:%d is launched, total:%d", pWorker->workerId, tsMReadPool.num);
+ dDebug("dnode mread worker:%d is launched, total:%d", pWorker->workerId, tsMReadPool.num);
}
- dTrace("dnode mread queue:%p is allocated", tsMReadQueue);
+ dDebug("dnode mread queue:%p is allocated", tsMReadQueue);
return TSDB_CODE_SUCCESS;
}
@@ -155,11 +155,11 @@ static void *dnodeProcessMnodeReadQueue(void *param) {
while (1) {
if (taosReadQitemFromQset(tsMReadQset, &type, (void **)&pReadMsg, &unUsed) == 0) {
- dTrace("dnodeProcessMnodeReadQueue: got no message from qset, exiting...");
+ dDebug("dnodeProcessMnodeReadQueue: got no message from qset, exiting...");
break;
}
- dTrace("%p, msg:%s will be processed in mread queue", pReadMsg->rpcMsg.ahandle, taosMsg[pReadMsg->rpcMsg.msgType]);
+ dDebug("%p, msg:%s will be processed in mread queue", pReadMsg->rpcMsg.ahandle, taosMsg[pReadMsg->rpcMsg.msgType]);
int32_t code = mnodeProcessRead(pReadMsg);
dnodeSendRpcMnodeReadRsp(pReadMsg, code);
}
diff --git a/src/dnode/src/dnodeMWrite.c b/src/dnode/src/dnodeMWrite.c
index e3a228919f..caa808fddf 100644
--- a/src/dnode/src/dnodeMWrite.c
+++ b/src/dnode/src/dnodeMWrite.c
@@ -57,7 +57,7 @@ int32_t dnodeInitMnodeWrite() {
pWorker->workerId = i;
}
- dPrint("dnode mwrite is opened");
+ dInfo("dnode mwrite is opened");
return 0;
}
@@ -76,7 +76,9 @@ void dnodeCleanupMnodeWrite() {
}
}
- dPrint("dnode mwrite is closed");
+ taosCloseQset(tsMWriteQset);
+ tfree(tsMWritePool.writeWorker);
+ dInfo("dnode mwrite is closed");
}
int32_t dnodeAllocateMnodeWqueue() {
@@ -98,10 +100,10 @@ int32_t dnodeAllocateMnodeWqueue() {
}
pthread_attr_destroy(&thAttr);
- dTrace("dnode mwrite worker:%d is launched, total:%d", pWorker->workerId, tsMWritePool.num);
+ dDebug("dnode mwrite worker:%d is launched, total:%d", pWorker->workerId, tsMWritePool.num);
}
- dTrace("dnode mwrite queue:%p is allocated", tsMWriteQueue);
+ dDebug("dnode mwrite queue:%p is allocated", tsMWriteQueue);
return TSDB_CODE_SUCCESS;
}
@@ -119,7 +121,7 @@ void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) {
SMnodeMsg *pWrite = (SMnodeMsg *)taosAllocateQitem(sizeof(SMnodeMsg));
mnodeCreateMsg(pWrite, pMsg);
- dTrace("app:%p:%p, msg:%s is put into mwrite queue", pWrite->rpcMsg.ahandle, pWrite, taosMsg[pWrite->rpcMsg.msgType]);
+ dDebug("app:%p:%p, msg:%s is put into mwrite queue", pWrite->rpcMsg.ahandle, pWrite, taosMsg[pWrite->rpcMsg.msgType]);
taosWriteQitem(tsMWriteQueue, TAOS_QTYPE_RPC, pWrite);
}
@@ -155,11 +157,11 @@ static void *dnodeProcessMnodeWriteQueue(void *param) {
while (1) {
if (taosReadQitemFromQset(tsMWriteQset, &type, (void **)&pWrite, &unUsed) == 0) {
- dTrace("dnodeProcessMnodeWriteQueue: got no message from qset, exiting...");
+ dDebug("dnodeProcessMnodeWriteQueue: got no message from qset, exiting...");
break;
}
- dTrace("app:%p:%p, msg:%s will be processed in mwrite queue", pWrite->rpcMsg.ahandle, pWrite,
+ dDebug("app:%p:%p, msg:%s will be processed in mwrite queue", pWrite->rpcMsg.ahandle, pWrite,
taosMsg[pWrite->rpcMsg.msgType]);
int32_t code = mnodeProcessWrite(pWrite);
@@ -173,13 +175,13 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
SMnodeMsg *pWrite = pMsg;
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
- dTrace("app:%p:%p, msg:%s is redirected for mnode not running, retry times:%d", pWrite->rpcMsg.ahandle, pWrite,
+ dDebug("app:%p:%p, msg:%s is redirected for mnode not running, retry times:%d", pWrite->rpcMsg.ahandle, pWrite,
taosMsg[pWrite->rpcMsg.msgType], pWrite->retry);
dnodeSendRedirectMsg(pMsg, true);
dnodeFreeMnodeWriteMsg(pWrite);
} else {
- dTrace("app:%p:%p, msg:%s is reput into mwrite queue, retry times:%d", pWrite->rpcMsg.ahandle, pWrite,
+ dDebug("app:%p:%p, msg:%s is reput into mwrite queue, retry times:%d", pWrite->rpcMsg.ahandle, pWrite,
taosMsg[pWrite->rpcMsg.msgType], pWrite->retry);
taosWriteQitem(tsMWriteQueue, TAOS_QTYPE_RPC, pWrite);
@@ -194,4 +196,4 @@ void dnodeDelayReprocessMnodeWriteMsg(void *pMsg) {
SMnodeMsg *mnodeMsg = pMsg;
void *unUsed = NULL;
taosTmrReset(dnodeDoDelayReprocessMnodeWriteMsg, 300, mnodeMsg, tsDnodeTmr, &unUsed);
-}
\ No newline at end of file
+}
diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c
index 91f146dde4..2ec87cbdd4 100644
--- a/src/dnode/src/dnodeMain.c
+++ b/src/dnode/src/dnodeMain.c
@@ -114,7 +114,7 @@ int32_t dnodeInitSystem() {
}
taosPrintGlobalCfg();
- dPrint("start to initialize TDengine on %s", tsLocalEp);
+ dInfo("start to initialize TDengine on %s", tsLocalEp);
if (dnodeInitComponents() != 0) {
return -1;
@@ -124,7 +124,7 @@ int32_t dnodeInitSystem() {
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_RUNING);
dnodeStartStream();
- dPrint("TDengine is initialized successfully");
+ dInfo("TDengine is initialized successfully");
return 0;
}
@@ -189,7 +189,7 @@ static int32_t dnodeInitStorage() {
dnodeCheckDataDirOpenned(tsDnodeDir);
- dPrint("storage directory is initialized");
+ dInfo("storage directory is initialized");
return 0;
}
diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c
index d971e3ad6d..a0c23689d0 100644
--- a/src/dnode/src/dnodeMgmt.c
+++ b/src/dnode/src/dnodeMgmt.c
@@ -141,7 +141,7 @@ int32_t dnodeInitMgmt() {
taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer);
- dPrint("dnode mgmt is initialized");
+ dInfo("dnode mgmt is initialized");
return TSDB_CODE_SUCCESS;
}
@@ -196,11 +196,11 @@ static void *dnodeProcessMgmtQueue(void *param) {
while (1) {
if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) {
- dTrace("dnode mgmt got no message from qset, exit ...");
+ dDebug("dnode mgmt got no message from qset, exit ...");
break;
}
- dTrace("%p, msg:%s will be processed", pMsg->ahandle, taosMsg[pMsg->msgType]);
+ dDebug("%p, msg:%s will be processed", pMsg->ahandle, taosMsg[pMsg->msgType]);
if (dnodeProcessMgmtMsgFp[pMsg->msgType]) {
rsp.code = (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg);
} else {
@@ -252,7 +252,7 @@ static int32_t dnodeOpenVnodes() {
status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
if (status != TSDB_CODE_SUCCESS) {
- dPrint("Get dnode list failed");
+ dInfo("Get dnode list failed");
free(vnodeList);
return status;
}
@@ -263,7 +263,7 @@ static int32_t dnodeOpenVnodes() {
}
free(vnodeList);
- dPrint("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, numOfVnodes-failed, failed);
+ dInfo("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, numOfVnodes-failed, failed);
return TSDB_CODE_SUCCESS;
}
@@ -273,7 +273,7 @@ void dnodeStartStream() {
int32_t status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
if (status != TSDB_CODE_SUCCESS) {
- dPrint("Get dnode list failed");
+ dInfo("Get dnode list failed");
return;
}
@@ -281,7 +281,7 @@ void dnodeStartStream() {
vnodeStartStream(vnodeList[i]);
}
- dPrint("streams started");
+ dInfo("streams started");
}
static void dnodeCloseVnodes() {
@@ -292,7 +292,7 @@ static void dnodeCloseVnodes() {
status = dnodeGetVnodeList(vnodeList, &numOfVnodes);
if (status != TSDB_CODE_SUCCESS) {
- dPrint("Get dnode list failed");
+ dInfo("Get dnode list failed");
free(vnodeList);
return;
}
@@ -302,7 +302,7 @@ static void dnodeCloseVnodes() {
}
free(vnodeList);
- dPrint("total vnodes:%d are all closed", numOfVnodes);
+ dInfo("total vnodes:%d are all closed", numOfVnodes);
}
static int32_t dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) {
@@ -360,10 +360,10 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
}
void dnodeUpdateMnodeIpSetForPeer(SRpcIpSet *pIpSet) {
- dPrint("mnode IP list for is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse);
+ dInfo("mnode IP list for is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse);
for (int i = 0; i < pIpSet->numOfIps; ++i) {
pIpSet->port[i] -= TSDB_PORT_DNODEDNODE;
- dPrint("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i])
+ dInfo("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i])
}
tsDMnodeIpSet = *pIpSet;
@@ -440,9 +440,9 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) {
if (!dnodeCheckMnodeInfos(pMnodes)) return;
memcpy(&tsDMnodeInfos, pMnodes, sizeof(SDMMnodeInfos));
- dPrint("mnode infos is changed, nodeNum:%d inUse:%d", tsDMnodeInfos.nodeNum, tsDMnodeInfos.inUse);
+ dInfo("mnode infos is changed, nodeNum:%d inUse:%d", tsDMnodeInfos.nodeNum, tsDMnodeInfos.inUse);
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
- dPrint("mnode index:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
+ dInfo("mnode index:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
}
tsDMnodeIpSet.inUse = tsDMnodeInfos.inUse;
@@ -461,7 +461,7 @@ static bool dnodeReadMnodeInfos() {
sprintf(ipFile, "%s/mnodeIpList.json", tsDnodeDir);
FILE *fp = fopen(ipFile, "r");
if (!fp) {
- dTrace("failed to read mnodeIpList.json, file not exist");
+ dDebug("failed to read mnodeIpList.json, file not exist");
return false;
}
@@ -530,9 +530,9 @@ static bool dnodeReadMnodeInfos() {
ret = true;
- dPrint("read mnode iplist successed, numOfIps:%d inUse:%d", tsDMnodeInfos.nodeNum, tsDMnodeInfos.inUse);
+ dInfo("read mnode iplist successed, numOfIps:%d inUse:%d", tsDMnodeInfos.nodeNum, tsDMnodeInfos.inUse);
for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) {
- dPrint("mnode:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
+ dInfo("mnode:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp);
}
PARSE_OVER:
@@ -572,7 +572,7 @@ static void dnodeSaveMnodeInfos() {
fclose(fp);
free(content);
- dPrint("save mnode iplist successed");
+ dInfo("save mnode iplist successed");
}
char *dnodeGetMnodeMasterEp() {
@@ -645,7 +645,7 @@ static bool dnodeReadDnodeCfg() {
FILE *fp = fopen(dnodeCfgFile, "r");
if (!fp) {
- dTrace("failed to read dnodeCfg.json, file not exist");
+ dDebug("failed to read dnodeCfg.json, file not exist");
return false;
}
@@ -676,7 +676,7 @@ static bool dnodeReadDnodeCfg() {
ret = true;
- dPrint("read numOfVnodes successed, dnodeId:%d", tsDnodeCfg.dnodeId);
+ dInfo("read numOfVnodes successed, dnodeId:%d", tsDnodeCfg.dnodeId);
PARSE_CFG_OVER:
free(content);
@@ -705,12 +705,12 @@ static void dnodeSaveDnodeCfg() {
fclose(fp);
free(content);
- dPrint("save dnodeId successed");
+ dInfo("save dnodeId successed");
}
void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg) {
if (tsDnodeCfg.dnodeId == 0) {
- dPrint("dnodeId is set to %d", pCfg->dnodeId);
+ dInfo("dnodeId is set to %d", pCfg->dnodeId);
tsDnodeCfg.dnodeId = pCfg->dnodeId;
dnodeSaveDnodeCfg();
}
@@ -721,7 +721,7 @@ int32_t dnodeGetDnodeId() {
}
void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell) {
- SRpcConnInfo connInfo;
+ SRpcConnInfo connInfo = {0};
rpcGetConnInfo(rpcMsg->handle, &connInfo);
SRpcIpSet ipSet = {0};
@@ -731,11 +731,11 @@ void dnodeSendRedirectMsg(SRpcMsg *rpcMsg, bool forShell) {
dnodeGetMnodeIpSetForPeer(&ipSet);
}
- dTrace("msg:%s will be redirected, dnodeIp:%s user:%s, numOfIps:%d inUse:%d", taosMsg[rpcMsg->msgType],
+ dDebug("msg:%s will be redirected, dnodeIp:%s user:%s, numOfIps:%d inUse:%d", taosMsg[rpcMsg->msgType],
taosIpStr(connInfo.clientIp), connInfo.user, ipSet.numOfIps, ipSet.inUse);
for (int i = 0; i < ipSet.numOfIps; ++i) {
- dTrace("mnode index:%d %s:%d", i, ipSet.fqdn[i], ipSet.port[i]);
+ dDebug("mnode index:%d %s:%d", i, ipSet.fqdn[i], ipSet.port[i]);
ipSet.port[i] = htons(ipSet.port[i]);
}
diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c
index c2e8c1d102..f8acb871c5 100644
--- a/src/dnode/src/dnodeModule.c
+++ b/src/dnode/src/dnodeModule.c
@@ -127,14 +127,14 @@ void dnodeProcessModuleStatus(uint32_t moduleStatus) {
for (int32_t module = TSDB_MOD_MNODE; module < TSDB_MOD_HTTP; ++module) {
bool enableModule = moduleStatus & (1 << module);
if (!tsModule[module].enable && enableModule) {
- dPrint("module status:%u is received, start %s module", tsModuleStatus, tsModule[module].name);
+ dInfo("module status:%u is received, start %s module", tsModuleStatus, tsModule[module].name);
tsModule[module].enable = true;
dnodeSetModuleStatus(module);
(*tsModule[module].startFp)();
}
if (tsModule[module].enable && !enableModule) {
- dPrint("module status:%u is received, stop %s module", tsModuleStatus, tsModule[module].name);
+ dInfo("module status:%u is received, stop %s module", tsModuleStatus, tsModule[module].name);
tsModule[module].enable = false;
dnodeUnSetModuleStatus(module);
(*tsModule[module].stopFp)();
diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c
index bd5f3208ee..6ab5188934 100644
--- a/src/dnode/src/dnodePeer.c
+++ b/src/dnode/src/dnodePeer.c
@@ -70,7 +70,7 @@ int32_t dnodeInitServer() {
return -1;
}
- dPrint("inter-dnodes RPC server is opened");
+ dInfo("inter-dnodes RPC server is opened");
return 0;
}
@@ -78,7 +78,7 @@ void dnodeCleanupServer() {
if (tsDnodeServerRpc) {
rpcClose(tsDnodeServerRpc);
tsDnodeServerRpc = NULL;
- dPrint("inter-dnodes RPC server is closed");
+ dInfo("inter-dnodes RPC server is closed");
}
}
@@ -95,7 +95,7 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
rspMsg.code = TSDB_CODE_RPC_NOT_READY;
rpcSendResponse(&rspMsg);
rpcFreeCont(pMsg->pCont);
- dTrace("RPC %p, msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
+ dDebug("RPC %p, msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
return;
}
@@ -108,7 +108,7 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
if (dnodeProcessReqMsgFp[pMsg->msgType]) {
(*dnodeProcessReqMsgFp[pMsg->msgType])(pMsg);
} else {
- dTrace("RPC %p, message:%s not processed", pMsg->handle, taosMsg[pMsg->msgType]);
+ dDebug("RPC %p, message:%s not processed", pMsg->handle, taosMsg[pMsg->msgType]);
rspMsg.code = TSDB_CODE_DND_MSG_NOT_PROCESSED;
rpcSendResponse(&rspMsg);
rpcFreeCont(pMsg->pCont);
@@ -135,7 +135,7 @@ int32_t dnodeInitClient() {
return -1;
}
- dPrint("inter-dnodes rpc client is opened");
+ dInfo("inter-dnodes rpc client is opened");
return 0;
}
@@ -143,7 +143,7 @@ void dnodeCleanupClient() {
if (tsDnodeClientRpc) {
rpcClose(tsDnodeClientRpc);
tsDnodeClientRpc = NULL;
- dPrint("inter-dnodes rpc client is closed");
+ dInfo("inter-dnodes rpc client is closed");
}
}
diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c
index 4252e63f8d..43358de470 100644
--- a/src/dnode/src/dnodeShell.c
+++ b/src/dnode/src/dnodeShell.c
@@ -97,7 +97,7 @@ int32_t dnodeInitShell() {
return -1;
}
- dPrint("shell rpc server is opened");
+ dInfo("shell rpc server is opened");
return 0;
}
@@ -154,7 +154,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
rpcMsg.contLen = sizeof(SDMAuthMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_DM_AUTH;
- dTrace("user:%s, send auth msg to mnode", user);
+ dDebug("user:%s, send auth msg to mnode", user);
SRpcMsg rpcRsp = {0};
dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp);
@@ -162,7 +162,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
dError("user:%s, auth msg received from mnode, error:%s", user, tstrerror(rpcRsp.code));
} else {
SDMAuthRsp *pRsp = rpcRsp.pCont;
- dTrace("user:%s, auth msg received from mnode", user);
+ dDebug("user:%s, auth msg received from mnode", user);
memcpy(secret, pRsp->secret, TSDB_KEY_LEN);
memcpy(ckey, pRsp->ckey, TSDB_KEY_LEN);
*spi = pRsp->spi;
@@ -174,7 +174,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
}
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) {
- dTrace("vgId:%d, sid:%d send config table msg to mnode", vgId, sid);
+ dDebug("vgId:%d, sid:%d send config table msg to mnode", vgId, sid);
int32_t contLen = sizeof(SDMConfigTableMsg);
SDMConfigTableMsg *pMsg = rpcMallocCont(contLen);
@@ -197,7 +197,7 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) {
dError("vgId:%d, sid:%d failed to config table from mnode", vgId, sid);
return NULL;
} else {
- dPrint("vgId:%d, sid:%d config table msg is received", vgId, sid);
+ dInfo("vgId:%d, sid:%d config table msg is received", vgId, sid);
// delete this after debug finished
SMDCreateTableMsg *pTable = rpcRsp.pCont;
@@ -205,7 +205,7 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) {
int16_t numOfTags = htons(pTable->numOfTags);
int32_t sid = htonl(pTable->sid);
uint64_t uid = htobe64(pTable->uid);
- dPrint("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:%" PRIu64, pTable->tableId, numOfColumns, numOfTags, sid, uid);
+ dInfo("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:%" PRIu64, pTable->tableId, numOfColumns, numOfTags, sid, uid);
return rpcRsp.pCont;
}
diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c
index 2fa738e480..01f0cf25c0 100644
--- a/src/dnode/src/dnodeSystem.c
+++ b/src/dnode/src/dnodeSystem.c
@@ -92,7 +92,7 @@ int32_t main(int32_t argc, char *argv[]) {
// Initialize the system
if (dnodeInitSystem() < 0) {
syslog(LOG_ERR, "Error initialize TDengine system");
- dPrint("Failed to start TDengine, please check the log at:%s", tsLogDir);
+ dInfo("Failed to start TDengine, please check the log at:%s", tsLogDir);
closelog();
exit(EXIT_FAILURE);
}
@@ -109,14 +109,14 @@ int32_t main(int32_t argc, char *argv[]) {
dnodeCleanUpSystem();
// close the syslog
syslog(LOG_INFO, "Shut down TDengine service successfully");
- dPrint("TDengine is shut down!");
+ dInfo("TDengine is shut down!");
closelog();
return EXIT_SUCCESS;
}
static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
if (signum == SIGUSR1) {
- taosCfgDynamicOptions("debugFlag 135");
+ taosCfgDynamicOptions("debugFlag 151");
return;
}
if (signum == SIGUSR2) {
@@ -127,7 +127,7 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
syslog(LOG_INFO, "Shut down signal is %d", signum);
syslog(LOG_INFO, "Shutting down TDengine service...");
// clean the system.
- dPrint("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid);
+ dInfo("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid);
// protect the application from receive another signal
struct sigaction act = {{0}};
diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c
index cd18ae6dda..19be83f36b 100644
--- a/src/dnode/src/dnodeVRead.c
+++ b/src/dnode/src/dnodeVRead.c
@@ -59,7 +59,7 @@ int32_t dnodeInitVnodeRead() {
pWorker->workerId = i;
}
- dPrint("dnode read is opened");
+ dInfo("dnode read is opened");
return 0;
}
@@ -81,7 +81,7 @@ void dnodeCleanupVnodeRead() {
free(readPool.readWorker);
taosCloseQset(readQset);
- dPrint("dnode read is closed");
+ dInfo("dnode read is closed");
}
void dnodeDispatchToVnodeReadQueue(SRpcMsg *pMsg) {
@@ -131,6 +131,7 @@ void dnodeDispatchToVnodeReadQueue(SRpcMsg *pMsg) {
.msgType = 0
};
rpcSendResponse(&rpcRsp);
+ rpcFreeCont(pMsg->pCont);
}
}
@@ -155,11 +156,11 @@ void *dnodeAllocateVnodeRqueue(void *pVnode) {
pthread_attr_destroy(&thAttr);
readPool.num++;
- dTrace("read worker:%d is launched, total:%d", pWorker->workerId, readPool.num);
+ dDebug("read worker:%d is launched, total:%d", pWorker->workerId, readPool.num);
} while (readPool.num < readPool.min);
}
- dTrace("pVnode:%p, read queue:%p is allocated", pVnode, queue);
+ dDebug("pVnode:%p, read queue:%p is allocated", pVnode, queue);
return queue;
}
@@ -206,11 +207,11 @@ static void *dnodeProcessReadQueue(void *param) {
while (1) {
if (taosReadQitemFromQset(readQset, &type, (void **)&pReadMsg, &pVnode) == 0) {
- dTrace("dnodeProcessReadQueee: got no message from qset, exiting...");
+ dDebug("dnodeProcessReadQueee: got no message from qset, exiting...");
break;
}
- dTrace("%p, msg:%s will be processed in vread queue", pReadMsg->rpcMsg.ahandle, taosMsg[pReadMsg->rpcMsg.msgType]);
+ dDebug("%p, msg:%s will be processed in vread queue", pReadMsg->rpcMsg.ahandle, taosMsg[pReadMsg->rpcMsg.msgType]);
int32_t code = vnodeProcessRead(pVnode, pReadMsg);
dnodeSendRpcReadRsp(pVnode, pReadMsg, code);
taosFreeQitem(pReadMsg);
@@ -226,7 +227,7 @@ static void dnodeHandleIdleReadWorker(SReadWorker *pWorker) {
if (num == 0 || (num <= readPool.min && readPool.num > readPool.min)) {
readPool.num--;
- dTrace("read worker:%d is released, total:%d", pWorker->workerId, readPool.num);
+ dDebug("read worker:%d is released, total:%d", pWorker->workerId, readPool.num);
pthread_exit(NULL);
} else {
usleep(30000);
diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c
index e61364355d..6de6fceb2f 100644
--- a/src/dnode/src/dnodeVWrite.c
+++ b/src/dnode/src/dnodeVWrite.c
@@ -63,7 +63,7 @@ int32_t dnodeInitVnodeWrite() {
wWorkerPool.writeWorker[i].workerId = i;
}
- dPrint("dnode write is opened");
+ dInfo("dnode write is opened");
return 0;
}
@@ -85,7 +85,7 @@ void dnodeCleanupVnodeWrite() {
}
free(wWorkerPool.writeWorker);
- dPrint("dnode write is closed");
+ dInfo("dnode write is closed");
}
void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) {
@@ -119,6 +119,7 @@ void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) {
.msgType = 0
};
rpcSendResponse(&rpcRsp);
+ rpcFreeCont(pMsg->pCont);
}
}
@@ -152,7 +153,7 @@ void *dnodeAllocateVnodeWqueue(void *pVnode) {
taosCloseQueue(queue);
queue = NULL;
} else {
- dTrace("write worker:%d is launched", pWorker->workerId);
+ dDebug("write worker:%d is launched", pWorker->workerId);
wWorkerPool.nextId = (wWorkerPool.nextId + 1) % wWorkerPool.max;
}
@@ -162,7 +163,7 @@ void *dnodeAllocateVnodeWqueue(void *pVnode) {
wWorkerPool.nextId = (wWorkerPool.nextId + 1) % wWorkerPool.max;
}
- dTrace("pVnode:%p, write queue:%p is allocated", pVnode, queue);
+ dDebug("pVnode:%p, write queue:%p is allocated", pVnode, queue);
return queue;
}
@@ -203,7 +204,7 @@ static void *dnodeProcessWriteQueue(void *param) {
while (1) {
numOfMsgs = taosReadAllQitemsFromQset(pWorker->qset, pWorker->qall, &pVnode);
if (numOfMsgs == 0) {
- dTrace("dnodeProcessWriteQueee: got no message from qset, exiting...");
+ dDebug("dnodeProcessWriteQueee: got no message from qset, exiting...");
break;
}
@@ -216,7 +217,7 @@ static void *dnodeProcessWriteQueue(void *param) {
pHead->msgType = pWrite->rpcMsg.msgType;
pHead->version = 0;
pHead->len = pWrite->contLen;
- dTrace("%p, msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]);
+ dDebug("%p, msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]);
} else {
pHead = (SWalHead *)item;
}
@@ -255,7 +256,7 @@ static void dnodeHandleIdleWorker(SWriteWorker *pWorker) {
taosFreeQall(pWorker->qall);
taosCloseQset(pWorker->qset);
pWorker->qset = NULL;
- dTrace("write worker:%d is released", pWorker->workerId);
+ dDebug("write worker:%d is released", pWorker->workerId);
pthread_exit(NULL);
}
}
diff --git a/src/inc/mnode.h b/src/inc/mnode.h
index bbb6fc5385..01358fdb44 100644
--- a/src/inc/mnode.h
+++ b/src/inc/mnode.h
@@ -48,6 +48,7 @@ typedef struct SMnodeMsg {
struct SDbObj * pDb;
struct SVgObj * pVgroup;
struct STableObj *pTable;
+ struct SSuperTableObj *pSTable;
} SMnodeMsg;
void mnodeCreateMsg(SMnodeMsg *pMsg, SRpcMsg *rpcMsg);
diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h
index 8cc5e82590..ecf78edfd5 100644
--- a/src/inc/taosdef.h
+++ b/src/inc/taosdef.h
@@ -245,7 +245,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE
#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
-#define TSDB_DEFAULT_PAYLOAD_SIZE 2048 // default payload size
+#define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value
#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth
#define TSDB_CQ_SQL_SIZE 1024
#define TSDB_MAX_VNODES 256
@@ -354,7 +354,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_DEFAULT_DBS_HASH_SIZE 100
#define TSDB_DEFAULT_VGROUPS_HASH_SIZE 100
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
-#define TSDB_DEFAULT_CTABLES_HASH_SIZE 10000
+#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
#define TSDB_PORT_DNODESHELL 0
#define TSDB_PORT_DNODEDNODE 5
diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c
index e4b84fc8e8..3e802c9566 100644
--- a/src/kit/taosdemo/taosdemo.c
+++ b/src/kit/taosdemo/taosdemo.c
@@ -470,11 +470,12 @@ int main(int argc, char *argv[]) {
char command[BUFFER_SIZE] = "\0";
sprintf(command, "drop database %s;", db_name);
- taos_query(taos, command);
-
+ TAOS_RES* res = taos_query(taos, command);
+ taos_free_result(res);
sprintf(command, "create database %s;", db_name);
- taos_query(taos, command);
+ res = taos_query(taos, command);
+ taos_free_result(res);
char cols[STRING_LEN] = "\0";
int colIndex = 0;
@@ -498,7 +499,7 @@ int main(int argc, char *argv[]) {
/* Create all the tables; */
printf("Creating %d table(s)......\n", ntables);
for (int i = 0; i < ntables; i++) {
- snprintf(command, BUFFER_SIZE, "create table %s.%s%d (ts timestamp%s;", db_name, tb_prefix, i, cols);
+ snprintf(command, BUFFER_SIZE, "create table if not exists %s.%s%d (ts timestamp%s;", db_name, tb_prefix, i, cols);
queryDB(taos, command);
}
@@ -508,7 +509,7 @@ int main(int argc, char *argv[]) {
} else {
/* Create metric table */
printf("Creating meters super table...\n");
- snprintf(command, BUFFER_SIZE, "create table %s.meters (ts timestamp%s tags (areaid int, loc binary(10))", db_name, cols);
+ snprintf(command, BUFFER_SIZE, "create table if not exists %s.meters (ts timestamp%s tags (areaid int, loc binary(10))", db_name, cols);
queryDB(taos, command);
printf("meters created!\n");
@@ -522,9 +523,9 @@ int main(int argc, char *argv[]) {
j = i % 10;
}
if (j % 2 == 0) {
- snprintf(command, BUFFER_SIZE, "create table %s.%s%d using %s.meters tags (%d,\"%s\");", db_name, tb_prefix, i, db_name, j, "shanghai");
+ snprintf(command, BUFFER_SIZE, "create table if not exists %s.%s%d using %s.meters tags (%d,\"%s\");", db_name, tb_prefix, i, db_name, j, "shanghai");
} else {
- snprintf(command, BUFFER_SIZE, "create table %s.%s%d using %s.meters tags (%d,\"%s\");", db_name, tb_prefix, i, db_name, j, "beijing");
+ snprintf(command, BUFFER_SIZE, "create table if not exists %s.%s%d using %s.meters tags (%d,\"%s\");", db_name, tb_prefix, i, db_name, j, "beijing");
}
queryDB(taos, command);
}
@@ -546,7 +547,10 @@ int main(int argc, char *argv[]) {
threads = ntables;
a = 1;
}
- int b = ntables % threads;
+
+ int b = 0;
+ if (threads != 0)
+ b = ntables % threads;
int last = 0;
for (int i = 0; i < threads; i++) {
info *t_info = infos + i;
@@ -846,10 +850,10 @@ void *syncWrite(void *sarg) {
pstr += sprintf(pstr, "insert into %s.%s%d values", winfo->db_name, winfo->tb_prefix, tID);
int k;
for (k = 0; k < winfo->nrecords_per_request;) {
- int rand_num = trand() % 100;
+ int rand_num = rand() % 100;
int len = -1;
if (winfo->data_of_order ==1 && rand_num < winfo->data_of_rate) {
- long d = tmp_time - trand() % 1000000 + rand_num;
+ long d = tmp_time - rand() % 1000000 + rand_num;
len = generateData(data, data_type, ncols_per_record, d, len_of_binary);
} else {
len = generateData(data, data_type, ncols_per_record, tmp_time += 1000, len_of_binary);
@@ -941,10 +945,10 @@ void callBack(void *param, TAOS_RES *res, int code) {
pstr += sprintf(pstr, "insert into %s values", tb_info->tb_name);
for (int i = 0; i < tb_info->nrecords_per_request; i++) {
- int rand_num = trand() % 100;
+ int rand_num = rand() % 100;
if (tb_info->data_of_order ==1 && rand_num < tb_info->data_of_rate)
{
- long d = tmp_time - trand() % 1000000 + rand_num;
+ long d = tmp_time - rand() % 1000000 + rand_num;
generateData(data, datatype, ncols_per_record, d, len_of_binary);
} else
{
@@ -993,20 +997,20 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
for (int i = 0; i < num_of_cols; i++) {
if (strcasecmp(data_type[i % c], "tinyint") == 0) {
- pstr += sprintf(pstr, ", %d", (int)(trand() % 128));
+ pstr += sprintf(pstr, ", %d", (int)(rand() % 128));
} else if (strcasecmp(data_type[i % c], "smallint") == 0) {
- pstr += sprintf(pstr, ", %d", (int)(trand() % 32767));
+ pstr += sprintf(pstr, ", %d", (int)(rand() % 32767));
} else if (strcasecmp(data_type[i % c], "int") == 0) {
- pstr += sprintf(pstr, ", %d", (int)(trand() % 10));
+ pstr += sprintf(pstr, ", %d", (int)(rand() % 10));
} else if (strcasecmp(data_type[i % c], "bigint") == 0) {
- pstr += sprintf(pstr, ", %" PRId64, trand() % 2147483648);
+ pstr += sprintf(pstr, ", %" PRId64, rand() % 2147483648);
} else if (strcasecmp(data_type[i % c], "float") == 0) {
- pstr += sprintf(pstr, ", %10.4f", (float)(trand() / 1000.0));
+ pstr += sprintf(pstr, ", %10.4f", (float)(rand() / 1000.0));
} else if (strcasecmp(data_type[i % c], "double") == 0) {
- double t = (double)(trand() / 1000000.0);
+ double t = (double)(rand() / 1000000.0);
pstr += sprintf(pstr, ", %20.8f", t);
} else if (strcasecmp(data_type[i % c], "bool") == 0) {
- bool b = trand() & 1;
+ bool b = rand() & 1;
pstr += sprintf(pstr, ", %s", b ? "true" : "false");
} else if (strcasecmp(data_type[i % c], "binary") == 0) {
char s[len_of_binary];
@@ -1032,7 +1036,7 @@ void rand_string(char *str, int size) {
--size;
int n;
for (n = 0; n < size; n++) {
- int key = trand() % (int)(sizeof charset - 1);
+ int key = rand() % (int)(sizeof charset - 1);
str[n] = charset[key];
}
str[n] = 0;
diff --git a/src/mnode/inc/mnodeInt.h b/src/mnode/inc/mnodeInt.h
index 708f11d1f7..a450a8027f 100644
--- a/src/mnode/inc/mnodeInt.h
+++ b/src/mnode/inc/mnodeInt.h
@@ -27,23 +27,23 @@ extern int32_t mDebugFlag;
extern int32_t sdbDebugFlag;
// mnode log function
-#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); }}
-#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mDebugFlag, __VA_ARGS__); }}
-#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
-#define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); }
+#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", 255, __VA_ARGS__); }}
+#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", 255, __VA_ARGS__); }}
+#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", 255, __VA_ARGS__); }}
+#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND INFO ", 255, __VA_ARGS__); }}
+#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND DEBUG ", mDebugFlag, __VA_ARGS__); }}
+#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND TRACE ", mDebugFlag, __VA_ARGS__); }}
+
+#define sdbFatal(...) { if (sdbDebugFlag & DEBUG_FATAL) { taosPrintLog("SDB FATAL ", 255, __VA_ARGS__); }}
+#define sdbError(...) { if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("SDB ERROR ", 255, __VA_ARGS__); }}
+#define sdbWarn(...) { if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("SDB WARN ", 255, __VA_ARGS__); }}
+#define sdbInfo(...) { if (sdbDebugFlag & DEBUG_INFO) { taosPrintLog("SDB INFO ", 255, __VA_ARGS__); }}
+#define sdbDebug(...) { if (sdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("SDB DEBUG ", sdbDebugFlag, __VA_ARGS__); }}
+#define sdbTrace(...) { if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("SDB TRACE ", sdbDebugFlag, __VA_ARGS__); }}
#define mLError(...) { monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) }
#define mLWarn(...) { monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
-#define mLPrint(...) { monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) }
-
-#define sdbError(...) { if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR SDB ", 255, __VA_ARGS__); }}
-#define sdbWarn(...) { if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN SDB ", sdbDebugFlag, __VA_ARGS__); }}
-#define sdbTrace(...) { if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("SDB ", sdbDebugFlag, __VA_ARGS__);}}
-#define sdbPrint(...) { taosPrintLog("SDB ", 255, __VA_ARGS__); }
-
-#define sdbLError(...) { monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) }
-#define sdbLWarn(...) { monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) }
-#define sdbLPrint(...) { monitorSaveLog(0, __VA_ARGS__); sdbPrint(__VA_ARGS__) }
+#define mLInfo(...) { monitorSaveLog(0, __VA_ARGS__); mInfo(__VA_ARGS__) }
#ifdef __cplusplus
}
diff --git a/src/mnode/src/mnodeAcct.c b/src/mnode/src/mnodeAcct.c
index 419372e06d..d0c0f01d63 100644
--- a/src/mnode/src/mnodeAcct.c
+++ b/src/mnode/src/mnodeAcct.c
@@ -83,7 +83,7 @@ static int32_t mnodeAcctActionDecode(SSdbOper *pOper) {
static int32_t mnodeAcctActionRestored() {
int32_t numOfRows = sdbGetNumOfRows(tsAcctSdb);
if (numOfRows <= 0 && dnodeIsFirstDeploy()) {
- mPrint("dnode first deploy, create root acct");
+ mInfo("dnode first deploy, create root acct");
int32_t code = mnodeCreateRootAcct();
if (code != TSDB_CODE_SUCCESS) {
mError("failed to create root account, reason:%s", tstrerror(code));
@@ -121,7 +121,7 @@ int32_t mnodeInitAccts() {
return -1;
}
- mTrace("table:%s, hash is created", tableDesc.tableName);
+ mDebug("table:%s, hash is created", tableDesc.tableName);
return TSDB_CODE_SUCCESS;
}
diff --git a/src/mnode/src/mnodeBalance.c b/src/mnode/src/mnodeBalance.c
index 29389ce1aa..36078115f7 100644
--- a/src/mnode/src/mnodeBalance.c
+++ b/src/mnode/src/mnodeBalance.c
@@ -62,7 +62,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
pVgroup->vnodeGid[0].dnodeId = pSelDnode->dnodeId;
pVgroup->vnodeGid[0].pDnode = pSelDnode;
- mTrace("dnode:%d, alloc one vnode to vgroup, openVnodes:%d", pSelDnode->dnodeId, pSelDnode->openVnodes);
+ mDebug("dnode:%d, alloc one vnode to vgroup, openVnodes:%d", pSelDnode->dnodeId, pSelDnode->openVnodes);
return TSDB_CODE_SUCCESS;
}
diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c
index 01f56f8902..69821e3483 100644
--- a/src/mnode/src/mnodeDb.c
+++ b/src/mnode/src/mnodeDb.c
@@ -157,7 +157,7 @@ int32_t mnodeInitDbs() {
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DB, mnodeGetDbMeta);
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_DB, mnodeRetrieveDbs);
- mTrace("table:dbs table is created");
+ mDebug("table:dbs table is created");
return 0;
}
@@ -311,6 +311,15 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
if (pCfg->replications < 0) pCfg->replications = tsReplications;
}
+static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
+ SDbObj *pDb = pMsg->pDb;
+ if (pDb != NULL) {
+ mLInfo("db:%s, is created by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
+ }
+
+ return code;
+}
+
static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMsg) {
int32_t code = acctCheck(pAcct, ACCT_GRANT_DB);
if (code != 0) return code;
@@ -319,7 +328,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs
if (pDb != NULL) {
mnodeDecDbRef(pDb);
if (pCreate->ignoreExist) {
- mTrace("db:%s, already exist, ignore exist is set", pCreate->db);
+ mDebug("db:%s, already exist, ignore exist is set", pCreate->db);
return TSDB_CODE_SUCCESS;
} else {
mError("db:%s, is already exist, ignore exist not set", pCreate->db);
@@ -364,18 +373,18 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs
.table = tsDbSdb,
.pObj = pDb,
.rowSize = sizeof(SDbObj),
- .pMsg = pMsg
+ .pMsg = pMsg,
+ .cb = mnodeCreateDbCb
};
code = sdbInsertRow(&oper);
if (code != TSDB_CODE_SUCCESS) {
tfree(pDb);
+ mLInfo("db:%s, failed to create, reason:%s", pDb->name, tstrerror(code));
+ return code;
} else {
- mLPrint("db:%s, is created by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
- if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
+ return TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
-
- return code;
}
bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
@@ -388,17 +397,17 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
#if 0
void mnodePrintVgroups(SDbObj *pDb, char *oper) {
- mPrint("db:%s, vgroup link from head, oper:%s", pDb->name, oper);
+ mInfo("db:%s, vgroup link from head, oper:%s", pDb->name, oper);
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
- mPrint("vgId:%d", pVgroup->vgId);
+ mInfo("vgId:%d", pVgroup->vgId);
pVgroup = pVgroup->next;
}
- mPrint("db:%s, vgroup link from tail", pDb->name, pDb->numOfVgroups);
+ mInfo("db:%s, vgroup link from tail", pDb->name, pDb->numOfVgroups);
pVgroup = pDb->pTail;
while (pVgroup != NULL) {
- mPrint("vgId:%d", pVgroup->vgId);
+ mInfo("vgId:%d", pVgroup->vgId);
pVgroup = pVgroup->prev;
}
}
@@ -805,12 +814,12 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
}
if (totalBlocks > 0 && totalBlocks != pDb->cfg.totalBlocks) {
- mPrint("db:%s, blocks:%d change to %d", pDb->name, pDb->cfg.totalBlocks, totalBlocks);
+ mInfo("db:%s, blocks:%d change to %d", pDb->name, pDb->cfg.totalBlocks, totalBlocks);
newCfg.totalBlocks = totalBlocks;
}
if (maxTables > 0) {
- mPrint("db:%s, maxTables:%d change to %d", pDb->name, pDb->cfg.maxTables, maxTables);
+ mInfo("db:%s, maxTables:%d change to %d", pDb->name, pDb->cfg.maxTables, maxTables);
newCfg.maxTables = maxTables;
if (newCfg.maxTables < pDb->cfg.maxTables) {
mError("db:%s, tables:%d should larger than origin:%d", pDb->name, newCfg.maxTables, pDb->cfg.maxTables);
@@ -824,17 +833,17 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
}
if (daysToKeep > 0 && daysToKeep != pDb->cfg.daysToKeep) {
- mTrace("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, daysToKeep);
+ mDebug("db:%s, daysToKeep:%d change to %d", pDb->name, pDb->cfg.daysToKeep, daysToKeep);
newCfg.daysToKeep = daysToKeep;
}
if (daysToKeep1 > 0 && daysToKeep1 != pDb->cfg.daysToKeep1) {
- mTrace("db:%s, daysToKeep1:%d change to %d", pDb->name, pDb->cfg.daysToKeep1, daysToKeep1);
+ mDebug("db:%s, daysToKeep1:%d change to %d", pDb->name, pDb->cfg.daysToKeep1, daysToKeep1);
newCfg.daysToKeep1 = daysToKeep1;
}
if (daysToKeep2 > 0 && daysToKeep2 != pDb->cfg.daysToKeep2) {
- mTrace("db:%s, daysToKeep2:%d change to %d", pDb->name, pDb->cfg.daysToKeep2, daysToKeep2);
+ mDebug("db:%s, daysToKeep2:%d change to %d", pDb->name, pDb->cfg.daysToKeep2, daysToKeep2);
newCfg.daysToKeep2 = daysToKeep2;
}
@@ -859,7 +868,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
}
if (compression >= 0 && compression != pDb->cfg.compression) {
- mTrace("db:%s, compression:%d change to %d", pDb->name, pDb->cfg.compression, compression);
+ mDebug("db:%s, compression:%d change to %d", pDb->name, pDb->cfg.compression, compression);
newCfg.compression = compression;
}
@@ -869,7 +878,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
}
if (replications > 0 && replications != pDb->cfg.replications) {
- mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications);
+ mDebug("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications);
newCfg.replications = replications;
if (pDb->cfg.walLevel < TSDB_MIN_WAL_LEVEL) {
@@ -907,8 +916,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
}
sdbFreeIter(pIter);
- mTrace("db:%s, all vgroups is altered", pDb->name);
- mLPrint("db:%s, is alterd by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
+ mDebug("db:%s, all vgroups is altered", pDb->name);
+ mLInfo("db:%s, is alterd by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
balanceAsyncNotify();
@@ -948,7 +957,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SCMAlterDbMsg *pAlter, void *pMsg) {
static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
SCMAlterDbMsg *pAlter = pMsg->rpcMsg.pCont;
- mTrace("db:%s, alter db msg is received from thandle:%p", pAlter->db, pMsg->rpcMsg.handle);
+ mDebug("db:%s, alter db msg is received from thandle:%p", pAlter->db, pMsg->rpcMsg.handle);
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pAlter->db);
if (pMsg->pDb == NULL) {
@@ -959,22 +968,33 @@ static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
return mnodeAlterDb(pMsg->pDb, pAlter, pMsg);
}
+static int32_t mnodeDropDbCb(SMnodeMsg *pMsg, int32_t code) {
+ SDbObj *pDb = pMsg->pDb;
+ if (code != TSDB_CODE_SUCCESS) {
+ mError("db:%s, failed to drop from sdb, reason:%s", pDb->name, tstrerror(code));
+ } else {
+ mLInfo("db:%s, is dropped by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
+ }
+
+ return code;
+}
+
static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
SDbObj *pDb = pMsg->pDb;
- mPrint("db:%s, drop db from sdb", pDb->name);
+ mInfo("db:%s, drop db from sdb", pDb->name);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
.table = tsDbSdb,
.pObj = pDb,
- .pMsg = pMsg
+ .pMsg = pMsg,
+ .cb = mnodeDropDbCb
};
int32_t code = sdbDeleteRow(&oper);
if (code == TSDB_CODE_SUCCESS) {
- mLPrint("db:%s, is dropped by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
@@ -983,12 +1003,12 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) {
SCMDropDbMsg *pDrop = pMsg->rpcMsg.pCont;
- mTrace("db:%s, drop db msg is received from thandle:%p", pDrop->db, pMsg->rpcMsg.handle);
+ mDebug("db:%s, drop db msg is received from thandle:%p", pDrop->db, pMsg->rpcMsg.handle);
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pDrop->db);
if (pMsg->pDb == NULL) {
if (pDrop->ignoreNotExists) {
- mTrace("db:%s, db is not exist, think drop success", pDrop->db);
+ mDebug("db:%s, db is not exist, think drop success", pDrop->db);
return TSDB_CODE_SUCCESS;
} else {
mError("db:%s, failed to drop, invalid db", pDrop->db);
@@ -1009,7 +1029,7 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) {
mnodeSendDropAllDbVgroupsMsg(pMsg->pDb);
- mTrace("db:%s, all vgroups is dropped", pMsg->pDb->name);
+ mDebug("db:%s, all vgroups is dropped", pMsg->pDb->name);
return mnodeDropDb(pMsg);
}
@@ -1018,14 +1038,14 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
SDbObj *pDb = NULL;
void * pIter = NULL;
- mPrint("acct:%s, all dbs will be dropped from sdb", pAcct->user);
+ mInfo("acct:%s, all dbs will be dropped from sdb", pAcct->user);
while (1) {
pIter = mnodeGetNextDb(pIter, &pDb);
if (pDb == NULL) break;
if (pDb->pAcct == pAcct) {
- mPrint("db:%s, drop db from sdb for acct:%s is dropped", pDb->name, pAcct->user);
+ mInfo("db:%s, drop db from sdb for acct:%s is dropped", pDb->name, pAcct->user);
SSdbOper oper = {
.type = SDB_OPER_LOCAL,
.table = tsDbSdb,
@@ -1040,5 +1060,5 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
sdbFreeIter(pIter);
- mPrint("acct:%s, all dbs:%d is dropped from sdb", pAcct->user, numOfDbs);
+ mInfo("acct:%s, all dbs:%d is dropped from sdb", pAcct->user, numOfDbs);
}
diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c
index 65c47fe583..dbe9185d8e 100644
--- a/src/mnode/src/mnodeDnode.c
+++ b/src/mnode/src/mnodeDnode.c
@@ -83,7 +83,7 @@ static int32_t mnodeDnodeActionDelete(SSdbOper *pOper) {
mnodeDropMnodeLocal(pDnode->dnodeId);
balanceAsyncNotify();
- mTrace("dnode:%d, all vgroups is dropped from sdb", pDnode->dnodeId);
+ mDebug("dnode:%d, all vgroups is dropped from sdb", pDnode->dnodeId);
return TSDB_CODE_SUCCESS;
}
@@ -118,7 +118,7 @@ static int32_t mnodeDnodeActionDecode(SSdbOper *pOper) {
static int32_t mnodeDnodeActionRestored() {
int32_t numOfRows = sdbGetNumOfRows(tsDnodeSdb);
if (numOfRows <= 0 && dnodeIsFirstDeploy()) {
- mPrint("dnode first deploy, create dnode:%s", tsLocalEp);
+ mInfo("dnode first deploy, create dnode:%s", tsLocalEp);
mnodeCreateDnode(tsLocalEp, NULL);
SDnodeObj *pDnode = mnodeGetDnodeByEp(tsLocalEp);
if (pDnode != NULL) {
@@ -170,7 +170,7 @@ int32_t mnodeInitDnodes() {
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DNODE, mnodeGetDnodeMeta);
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_DNODE, mnodeRetrieveDnodes);
- mTrace("table:dnodes table is created");
+ mDebug("table:dnodes table is created");
return 0;
}
@@ -272,13 +272,13 @@ static int32_t mnodeProcessCfgDnodeMsg(SMnodeMsg *pMsg) {
};
dnodeSendMsgToDnode(&ipSet, &rpcMdCfgDnodeMsg);
- mPrint("dnode:%s, is configured by %s", pCmCfgDnode->ep, pMsg->pUser->user);
+ mInfo("dnode:%s, is configured by %s", pCmCfgDnode->ep, pMsg->pUser->user);
return TSDB_CODE_SUCCESS;
}
static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) {
- mPrint("cfg dnode rsp is received");
+ mInfo("cfg dnode rsp is received");
}
static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) {
@@ -313,7 +313,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
if (pStatus->dnodeId == 0) {
pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp);
if (pDnode == NULL) {
- mTrace("dnode %s not created", pStatus->dnodeEp);
+ mDebug("dnode %s not created", pStatus->dnodeEp);
return TSDB_CODE_MND_DNODE_NOT_EXIST;
}
} else {
@@ -332,9 +332,9 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
pDnode->moduleStatus = pStatus->moduleStatus;
if (pStatus->dnodeId == 0) {
- mTrace("dnode:%d %s, first access", pDnode->dnodeId, pDnode->dnodeEp);
+ mDebug("dnode:%d %s, first access", pDnode->dnodeId, pDnode->dnodeEp);
} else {
- //mTrace("dnode:%d, status received, access times %d", pDnode->dnodeId, pDnode->lastAccess);
+ //mDebug("dnode:%d, status received, access times %d", pDnode->dnodeId, pDnode->lastAccess);
}
int32_t openVnodes = htons(pStatus->openVnodes);
@@ -358,7 +358,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
SVgObj *pVgroup = mnodeGetVgroup(pVload->vgId);
if (pVgroup == NULL) {
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp);
- mPrint("dnode:%d, vgId:%d not exist in mnode, drop it", pDnode->dnodeId, pVload->vgId);
+ mInfo("dnode:%d, vgId:%d not exist in mnode, drop it", pDnode->dnodeId, pVload->vgId);
mnodeSendDropVnodeMsg(pVload->vgId, &ipSet, NULL);
} else {
mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload);
@@ -380,7 +380,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT;
}
- mTrace("dnode:%d, from offline to online", pDnode->dnodeId);
+ mDebug("dnode:%d, from offline to online", pDnode->dnodeId);
pDnode->status = TAOS_DN_STATUS_READY;
balanceSyncNotify();
balanceAsyncNotify();
@@ -437,7 +437,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
tfree(pDnode);
mError("failed to create dnode:%d, result:%s", dnodeId, tstrerror(code));
} else {
- mPrint("dnode:%d is created, result:%s", pDnode->dnodeId, tstrerror(code));
+ mInfo("dnode:%d is created, result:%s", pDnode->dnodeId, tstrerror(code));
if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
@@ -454,7 +454,7 @@ int32_t mnodeDropDnode(SDnodeObj *pDnode, void *pMsg) {
int32_t code = sdbDeleteRow(&oper);
if (code == TSDB_CODE_SUCCESS) {
- mLPrint("dnode:%d, is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code));
+ mLInfo("dnode:%d, is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code));
if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
@@ -474,7 +474,7 @@ static int32_t mnodeDropDnodeByEp(char *ep, SMnodeMsg *pMsg) {
return TSDB_CODE_MND_NO_REMOVE_MASTER;
}
- mPrint("dnode:%d, start to drop it", pDnode->dnodeId);
+ mInfo("dnode:%d, start to drop it", pDnode->dnodeId);
#ifndef _SYNC
return mnodeDropDnode(pDnode, pMsg);
#else
diff --git a/src/mnode/src/mnodeInt.c b/src/mnode/src/mnodeInt.c
index c2dd46d981..91c8dcb6e5 100644
--- a/src/mnode/src/mnodeInt.c
+++ b/src/mnode/src/mnodeInt.c
@@ -54,6 +54,7 @@ void mnodeCleanupMsg(SMnodeMsg *pMsg) {
if (pMsg->pDb) mnodeDecDbRef(pMsg->pDb);
if (pMsg->pVgroup) mnodeDecVgroupRef(pMsg->pVgroup);
if (pMsg->pTable) mnodeDecTableRef(pMsg->pTable);
+ if (pMsg->pSTable) mnodeDecTableRef(pMsg->pSTable);
if (pMsg->pAcct) mnodeDecAcctRef(pMsg->pAcct);
if (pMsg->pDnode) mnodeDecDnodeRef(pMsg->pDnode);
}
diff --git a/src/mnode/src/mnodeMain.c b/src/mnode/src/mnodeMain.c
index 96dc700783..ba0089c61e 100644
--- a/src/mnode/src/mnodeMain.c
+++ b/src/mnode/src/mnodeMain.c
@@ -83,11 +83,11 @@ static int32_t mnodeInitComponents() {
int32_t mnodeStartSystem() {
if (tsMgmtIsRunning) {
- mPrint("mnode module already started...");
+ mInfo("mnode module already started...");
return 0;
}
- mPrint("starting to initialize mnode ...");
+ mInfo("starting to initialize mnode ...");
if (mkdir(tsMnodeDir, 0755) != 0 && errno != EEXIST) {
mError("failed to init mnode dir:%s, reason:%s", tsMnodeDir, strerror(errno));
return -1;
@@ -104,7 +104,7 @@ int32_t mnodeStartSystem() {
grantReset(TSDB_GRANT_ALL, 0);
tsMgmtIsRunning = true;
- mPrint("mnode is initialized successfully");
+ mInfo("mnode is initialized successfully");
return 0;
}
@@ -115,30 +115,30 @@ int32_t mnodeInitSystem() {
}
void mnodeCleanupSystem() {
- mPrint("starting to clean up mnode");
+ mInfo("starting to clean up mnode");
tsMgmtIsRunning = false;
dnodeFreeMnodeWqueue();
dnodeFreeMnodeRqueue();
dnodeFreeMnodePqueue();
- mnodeCleanupTimer();
mnodeCleanupComponents(sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]) - 1);
+ mnodeCleanupTimer();
- mPrint("mnode is cleaned up");
+ mInfo("mnode is cleaned up");
}
void mnodeStopSystem() {
if (sdbIsMaster()) {
- mTrace("it is a master mnode, it could not be stopped");
+ mDebug("it is a master mnode, it could not be stopped");
return;
}
mnodeCleanupSystem();
if (remove(tsMnodeDir) != 0) {
- mPrint("failed to remove mnode file, reason:%s", strerror(errno));
+ mInfo("failed to remove mnode file, reason:%s", strerror(errno));
} else {
- mPrint("mnode file is removed");
+ mInfo("mnode file is removed");
}
}
diff --git a/src/mnode/src/mnodeMnode.c b/src/mnode/src/mnodeMnode.c
index 219fb0b0a3..4d785dd062 100644
--- a/src/mnode/src/mnodeMnode.c
+++ b/src/mnode/src/mnodeMnode.c
@@ -81,7 +81,7 @@ static int32_t mnodeMnodeActionDelete(SSdbOper *pOper) {
pDnode->isMgmt = false;
mnodeDecDnodeRef(pDnode);
- mTrace("mnode:%d, is dropped from sdb", pMnode->mnodeId);
+ mDebug("mnode:%d, is dropped from sdb", pMnode->mnodeId);
return TSDB_CODE_SUCCESS;
}
@@ -159,7 +159,7 @@ int32_t mnodeInitMnodes() {
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_MNODE, mnodeGetMnodeMeta);
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_MNODE, mnodeRetrieveMnodes);
- mTrace("table:mnodes table is created");
+ mDebug("table:mnodes table is created");
return TSDB_CODE_SUCCESS;
}
@@ -204,7 +204,7 @@ char *mnodeGetMnodeRoleStr(int32_t role) {
}
void mnodeUpdateMnodeIpSet() {
- mPrint("update mnodes ipset, numOfIps:%d ", mnodeGetMnodesNum());
+ mInfo("update mnodes ipset, numOfIps:%d ", mnodeGetMnodesNum());
mnodeMnodeWrLock();
@@ -223,11 +223,11 @@ void mnodeUpdateMnodeIpSet() {
if (pDnode != NULL) {
strcpy(tsMnodeIpSetForShell.fqdn[index], pDnode->dnodeFqdn);
tsMnodeIpSetForShell.port[index] = htons(pDnode->dnodePort);
- mTrace("mnode:%d, for shell fqdn:%s %d", pDnode->dnodeId, tsMnodeIpSetForShell.fqdn[index], htons(tsMnodeIpSetForShell.port[index]));
+ mDebug("mnode:%d, for shell fqdn:%s %d", pDnode->dnodeId, tsMnodeIpSetForShell.fqdn[index], htons(tsMnodeIpSetForShell.port[index]));
strcpy(tsMnodeIpSetForPeer.fqdn[index], pDnode->dnodeFqdn);
tsMnodeIpSetForPeer.port[index] = htons(pDnode->dnodePort + TSDB_PORT_DNODEDNODE);
- mTrace("mnode:%d, for peer fqdn:%s %d", pDnode->dnodeId, tsMnodeIpSetForPeer.fqdn[index], htons(tsMnodeIpSetForPeer.port[index]));
+ mDebug("mnode:%d, for peer fqdn:%s %d", pDnode->dnodeId, tsMnodeIpSetForPeer.fqdn[index], htons(tsMnodeIpSetForPeer.port[index]));
tsMnodeInfos.nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
strcpy(tsMnodeInfos.nodeInfos[index].nodeEp, pDnode->dnodeEp);
@@ -238,7 +238,7 @@ void mnodeUpdateMnodeIpSet() {
tsMnodeInfos.inUse = index;
}
- mPrint("mnode:%d, ep:%s %s", pDnode->dnodeId, pDnode->dnodeEp, pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : "");
+ mInfo("mnode:%d, ep:%s %s", pDnode->dnodeId, pDnode->dnodeEp, pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : "");
index++;
}
diff --git a/src/mnode/src/mnodePeer.c b/src/mnode/src/mnodePeer.c
index 9aefc73b77..04f2889607 100644
--- a/src/mnode/src/mnodePeer.c
+++ b/src/mnode/src/mnodePeer.c
@@ -58,9 +58,9 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
rpcRsp->rsp = ipSet;
rpcRsp->len = sizeof(SRpcIpSet);
- mTrace("%p, msg:%s in mpeer queue, will be redireced inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], ipSet->inUse);
+ mDebug("%p, msg:%s in mpeer queue, will be redireced inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], ipSet->inUse);
for (int32_t i = 0; i < ipSet->numOfIps; ++i) {
- mTrace("mnode index:%d ip:%s:%d", i, ipSet->fqdn[i], htons(ipSet->port[i]));
+ mDebug("mnode index:%d ip:%s:%d", i, ipSet->fqdn[i], htons(ipSet->port[i]));
}
return TSDB_CODE_RPC_REDIRECT;
diff --git a/src/mnode/src/mnodeProfile.c b/src/mnode/src/mnodeProfile.c
index 2a895c9496..f3d6a3d344 100644
--- a/src/mnode/src/mnodeProfile.c
+++ b/src/mnode/src/mnodeProfile.c
@@ -74,7 +74,7 @@ int32_t mnodeInitProfile() {
void mnodeCleanupProfile() {
if (tsMnodeConnCache != NULL) {
- mPrint("conn cache is cleanup");
+ mInfo("conn cache is cleanup");
taosCacheCleanup(tsMnodeConnCache);
tsMnodeConnCache = NULL;
}
@@ -104,7 +104,7 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) {
sprintf(key, "%u", connId);
SConnObj *pConn = taosCachePut(tsMnodeConnCache, key, &connObj, sizeof(connObj), CONN_KEEP_TIME);
- mTrace("connId:%d, is created, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port);
+ mDebug("connId:%d, is created, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port);
return pConn;
}
@@ -131,7 +131,7 @@ SConnObj *mnodeAccquireConn(uint32_t connId, char *user, uint32_t ip, uint16_t p
return NULL;
}
- // mTrace("connId:%d, is incoming, user:%s ip:%s:%u", connId, pConn->user, taosIpStr(pConn->ip), pConn->port);
+ // mDebug("connId:%d, is incoming, user:%s ip:%s:%u", connId, pConn->user, taosIpStr(pConn->ip), pConn->port);
pConn->lastAccess = expireTime;
return pConn;
}
@@ -141,7 +141,7 @@ static void mnodeFreeConn(void *data) {
tfree(pConn->pQueries);
tfree(pConn->pStreams);
- mTrace("connId:%d, is destroyed", pConn->connId);
+ mDebug("connId:%d, is destroyed", pConn->connId);
}
static void *mnodeGetNextConn(SHashMutableIterator *pIter, SConnObj **pConn) {
@@ -534,14 +534,14 @@ static int32_t mnodeProcessKillQueryMsg(SMnodeMsg *pMsg) {
if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS;
SCMKillQueryMsg *pKill = pMsg->rpcMsg.pCont;
- mPrint("kill query msg is received, queryId:%s", pKill->queryId);
+ mInfo("kill query msg is received, queryId:%s", pKill->queryId);
const char delim = ':';
char* connIdStr = strtok(pKill->queryId, &delim);
char* queryIdStr = strtok(NULL, &delim);
if (queryIdStr == NULL || connIdStr == NULL) {
- mPrint("failed to kill query, queryId:%s", pKill->queryId);
+ mInfo("failed to kill query, queryId:%s", pKill->queryId);
return TSDB_CODE_MND_INVALID_QUERY_ID;
}
@@ -552,7 +552,7 @@ static int32_t mnodeProcessKillQueryMsg(SMnodeMsg *pMsg) {
mError("connId:%s, failed to kill queryId:%d, conn not exist", connIdStr, queryId);
return TSDB_CODE_MND_INVALID_CONN_ID;
} else {
- mPrint("connId:%s, queryId:%d is killed by user:%s", connIdStr, queryId, pUser->user);
+ mInfo("connId:%s, queryId:%d is killed by user:%s", connIdStr, queryId, pUser->user);
pConn->queryId = queryId;
taosCacheRelease(tsMnodeConnCache, (void **)&pConn, false);
return TSDB_CODE_SUCCESS;
@@ -564,14 +564,14 @@ static int32_t mnodeProcessKillStreamMsg(SMnodeMsg *pMsg) {
if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS;
SCMKillQueryMsg *pKill = pMsg->rpcMsg.pCont;
- mPrint("kill stream msg is received, streamId:%s", pKill->queryId);
+ mInfo("kill stream msg is received, streamId:%s", pKill->queryId);
const char delim = ':';
char* connIdStr = strtok(pKill->queryId, &delim);
char* streamIdStr = strtok(NULL, &delim);
if (streamIdStr == NULL || connIdStr == NULL) {
- mPrint("failed to kill stream, streamId:%s", pKill->queryId);
+ mInfo("failed to kill stream, streamId:%s", pKill->queryId);
return TSDB_CODE_MND_INVALID_STREAM_ID;
}
@@ -582,7 +582,7 @@ static int32_t mnodeProcessKillStreamMsg(SMnodeMsg *pMsg) {
mError("connId:%s, failed to kill streamId:%d, conn not exist", connIdStr, streamId);
return TSDB_CODE_MND_INVALID_CONN_ID;
} else {
- mPrint("connId:%s, streamId:%d is killed by user:%s", connIdStr, streamId, pUser->user);
+ mInfo("connId:%s, streamId:%d is killed by user:%s", connIdStr, streamId, pUser->user);
pConn->streamId = streamId;
taosCacheRelease(tsMnodeConnCache, (void **)&pConn, false);
return TSDB_CODE_SUCCESS;
@@ -599,7 +599,7 @@ static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg) {
mError("connId:%s, failed to kill, conn not exist", pKill->queryId);
return TSDB_CODE_MND_INVALID_CONN_ID;
} else {
- mPrint("connId:%s, is killed by user:%s", pKill->queryId, pUser->user);
+ mInfo("connId:%s, is killed by user:%s", pKill->queryId, pUser->user);
pConn->killed = 1;
taosCacheRelease(tsMnodeConnCache, (void**)&pConn, false);
return TSDB_CODE_SUCCESS;
diff --git a/src/mnode/src/mnodeRead.c b/src/mnode/src/mnodeRead.c
index 2c1f204277..dfecf1f693 100644
--- a/src/mnode/src/mnodeRead.c
+++ b/src/mnode/src/mnodeRead.c
@@ -54,9 +54,9 @@ int32_t mnodeProcessRead(SMnodeMsg *pMsg) {
rpcRsp->rsp = ipSet;
rpcRsp->len = sizeof(SRpcIpSet);
- mTrace("%p, msg:%s in mread queue, will be redireced, inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], ipSet->inUse);
+ mDebug("%p, msg:%s in mread queue, will be redireced, inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], ipSet->inUse);
for (int32_t i = 0; i < ipSet->numOfIps; ++i) {
- mTrace("mnode index:%d ip:%s:%d", i, ipSet->fqdn[i], htons(ipSet->port[i]));
+ mDebug("mnode index:%d ip:%s:%d", i, ipSet->fqdn[i], htons(ipSet->port[i]));
}
return TSDB_CODE_RPC_REDIRECT;
diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c
index c34317437c..601745461a 100644
--- a/src/mnode/src/mnodeSdb.c
+++ b/src/mnode/src/mnodeSdb.c
@@ -181,7 +181,7 @@ static int32_t sdbInitWal() {
return -1;
}
- sdbTrace("open sdb wal for restore");
+ sdbInfo("open sdb wal for restore");
walRestore(tsSdbObj.wal, NULL, sdbWrite);
return 0;
}
@@ -198,10 +198,10 @@ static void sdbRestoreTables() {
totalRows += pTable->numOfRows;
numOfTables++;
- sdbTrace("table:%s, is restored, numOfRows:%" PRId64, pTable->tableName, pTable->numOfRows);
+ sdbDebug("table:%s, is restored, numOfRows:%" PRId64, pTable->tableName, pTable->numOfRows);
}
- sdbTrace("sdb is restored, version:%" PRId64 " totalRows:%d numOfTables:%d", tsSdbObj.version, totalRows, numOfTables);
+ sdbInfo("sdb is restored, version:%" PRId64 " totalRows:%d numOfTables:%d", tsSdbObj.version, totalRows, numOfTables);
}
void sdbUpdateMnodeRoles() {
@@ -210,12 +210,12 @@ void sdbUpdateMnodeRoles() {
SNodesRole roles = {0};
syncGetNodesRole(tsSdbObj.sync, &roles);
- sdbPrint("update mnodes sync roles, total:%d", tsSdbObj.cfg.replica);
+ sdbInfo("update mnodes sync roles, total:%d", tsSdbObj.cfg.replica);
for (int32_t i = 0; i < tsSdbObj.cfg.replica; ++i) {
SMnodeObj *pMnode = mnodeGetMnode(roles.nodeId[i]);
if (pMnode != NULL) {
pMnode->role = roles.role[i];
- sdbPrint("mnode:%d, role:%s", pMnode->mnodeId, mnodeGetMnodeRoleStr(pMnode->role));
+ sdbInfo("mnode:%d, role:%s", pMnode->mnodeId, mnodeGetMnodeRoleStr(pMnode->role));
if (pMnode->mnodeId == dnodeGetDnodeId()) tsSdbObj.role = pMnode->role;
mnodeDecMnodeRef(pMnode);
}
@@ -234,7 +234,7 @@ static int sdbGetWalInfo(void *ahandle, char *name, uint32_t *index) {
}
static void sdbNotifyRole(void *ahandle, int8_t role) {
- sdbPrint("mnode role changed from %s to %s", mnodeGetMnodeRoleStr(tsSdbObj.role), mnodeGetMnodeRoleStr(role));
+ sdbInfo("mnode role changed from %s to %s", mnodeGetMnodeRoleStr(tsSdbObj.role), mnodeGetMnodeRoleStr(role));
if (role == TAOS_SYNC_ROLE_MASTER && tsSdbObj.role != TAOS_SYNC_ROLE_MASTER) {
balanceReset();
@@ -247,15 +247,15 @@ static void sdbNotifyRole(void *ahandle, int8_t role) {
static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
tsSdbObj.code = code;
sem_post(&tsSdbObj.sem);
- sdbTrace("forward request confirmed, version:%" PRIu64 ", result:%s", (int64_t)param, tstrerror(code));
+ sdbDebug("forward request confirmed, version:%" PRIu64 ", result:%s", (int64_t)param, tstrerror(code));
}
-static int32_t sdbForwardToPeer(SWalHead *pHead) {
+ static int32_t sdbForwardToPeer(SWalHead *pHead) {
if (tsSdbObj.sync == NULL) return TSDB_CODE_SUCCESS;
int32_t code = syncForwardToPeer(tsSdbObj.sync, pHead, (void*)pHead->version, TAOS_QTYPE_RPC);
if (code > 0) {
- sdbTrace("forward request is sent, version:%" PRIu64 ", code:%d", pHead->version, code);
+ sdbDebug("forward request is sent, version:%" PRIu64 ", code:%d", pHead->version, code);
sem_wait(&tsSdbObj.sem);
return tsSdbObj.code;
}
@@ -311,9 +311,9 @@ void sdbUpdateSync() {
if (!hasThisDnode) return;
if (memcmp(&syncCfg, &tsSdbObj.cfg, sizeof(SSyncCfg)) == 0) return;
- sdbPrint("work as mnode, replica:%d", syncCfg.replica);
+ sdbInfo("work as mnode, replica:%d", syncCfg.replica);
for (int32_t i = 0; i < syncCfg.replica; ++i) {
- sdbPrint("mnode:%d, %s:%d", syncCfg.nodeInfo[i].nodeId, syncCfg.nodeInfo[i].nodeFqdn, syncCfg.nodeInfo[i].nodePort);
+ sdbInfo("mnode:%d, %s:%d", syncCfg.nodeInfo[i].nodeId, syncCfg.nodeInfo[i].nodeFqdn, syncCfg.nodeInfo[i].nodePort);
}
SSyncInfo syncInfo = {0};
@@ -388,9 +388,7 @@ void sdbIncRef(void *handle, void *pObj) {
SSdbTable *pTable = handle;
int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos);
atomic_add_fetch_32(pRefCount, 1);
- if (0 && (pTable->tableId == SDB_TABLE_CTABLE || pTable->tableId == SDB_TABLE_DB)) {
- sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount);
- }
+ sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount);
}
void sdbDecRef(void *handle, void *pObj) {
@@ -399,9 +397,7 @@ void sdbDecRef(void *handle, void *pObj) {
SSdbTable *pTable = handle;
int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos);
int32_t refCount = atomic_sub_fetch_32(pRefCount, 1);
- if (0 && (pTable->tableId == SDB_TABLE_CTABLE || pTable->tableId == SDB_TABLE_DB)) {
- sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount);
- }
+ sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount);
int8_t *updateEnd = pObj + pTable->refCountPos - 1;
if (refCount <= 0 && *updateEnd) {
@@ -469,7 +465,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
atomic_add_fetch_32(&pTable->autoIndex, 1);
}
- sdbTrace("table:%s, insert record:%s to hash, rowSize:%d numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
+ sdbDebug("table:%s, insert record:%s to hash, rowSize:%d numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
sdbGetKeyStrFromObj(pTable, pOper->pObj), pOper->rowSize, pTable->numOfRows, sdbGetVersion());
(*pTable->insertFp)(pOper);
@@ -488,7 +484,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
taosHashRemove(pTable->iHandle, key, keySize);
atomic_sub_fetch_32(&pTable->numOfRows, 1);
- sdbTrace("table:%s, delete record:%s from hash, numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
+ sdbDebug("table:%s, delete record:%s from hash, numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
sdbGetKeyStrFromObj(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion());
int8_t *updateEnd = pOper->pObj + pTable->refCountPos - 1;
@@ -499,7 +495,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
}
static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbOper *pOper) {
- sdbTrace("table:%s, update record:%s in hash, numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
+ sdbDebug("table:%s, update record:%s in hash, numOfRows:%" PRId64 " version:%" PRIu64, pTable->tableName,
sdbGetKeyStrFromObj(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion());
(*pTable->updateFp)(pOper);
@@ -525,7 +521,7 @@ static int sdbWrite(void *param, void *data, int type) {
if (pHead->version <= tsSdbObj.version) {
pthread_mutex_unlock(&tsSdbObj.mutex);
if (type == TAOS_QTYPE_FWD && tsSdbObj.sync != NULL) {
- sdbTrace("forward request is received, version:%" PRIu64 " confirm it", pHead->version);
+ sdbDebug("forward request is received, version:%" PRIu64 " confirm it", pHead->version);
syncConfirmForward(tsSdbObj.sync, pHead->version, TSDB_CODE_SUCCESS);
}
return TSDB_CODE_SUCCESS;
@@ -551,16 +547,20 @@ static int sdbWrite(void *param, void *data, int type) {
// from app, oper is created
if (pOper != NULL) {
- sdbTrace("record from app is disposed, version:%" PRIu64 " result:%s", pHead->version, tstrerror(code));
+ sdbTrace("record from app is disposed, table:%s action:%s record:%s version:%" PRIu64 " result:%s",
+ pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), pHead->version,
+ tstrerror(code));
return code;
}
-
+
// from wal or forward msg, oper not created, should add into hash
if (tsSdbObj.sync != NULL) {
- sdbTrace("record from wal forward is disposed, version:%" PRIu64 " confirm it", pHead->version);
+ sdbTrace("record from wal forward is disposed, table:%s action:%s record:%s version:%" PRIu64 " confirm it",
+ pTable->tableName, sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), pHead->version);
syncConfirmForward(tsSdbObj.sync, pHead->version, code);
} else {
- sdbTrace("record from wal restore is disposed, version:%" PRIu64 , pHead->version);
+ sdbTrace("record from wal restore is disposed, table:%s action:%s record:%s version:%" PRIu64, pTable->tableName,
+ sdbGetActionStr(action), sdbGetKeyStr(pTable, pHead->cont), pHead->version);
}
if (action == SDB_ACTION_INSERT) {
@@ -626,9 +626,11 @@ int32_t sdbInsertRow(SSdbOper *pOper) {
memcpy(pNewOper, pOper, sizeof(SSdbOper));
if (pNewOper->pMsg != NULL) {
- sdbTrace("app:%p:%p, insert action is add to sdb queue", pNewOper->pMsg->rpcMsg.ahandle, pNewOper->pMsg);
+ sdbDebug("app:%p:%p, table:%s record:%p:%s, insert action is add to sdb queue, ", pNewOper->pMsg->rpcMsg.ahandle,
+ pNewOper->pMsg, pTable->tableName, pOper->pObj, sdbGetKeyStrFromObj(pTable, pOper->pObj));
}
+ sdbIncRef(pNewOper->table, pNewOper->pObj);
taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper);
return TSDB_CODE_SUCCESS;
}
@@ -639,7 +641,7 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
SSdbRow *pMeta = sdbGetRowMetaFromObj(pTable, pOper->pObj);
if (pMeta == NULL) {
- sdbTrace("table:%s, record is not there, delete failed", pTable->tableName);
+ sdbDebug("table:%s, record is not there, delete failed", pTable->tableName);
return TSDB_CODE_MND_SDB_OBJ_NOT_THERE;
}
@@ -674,9 +676,11 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
memcpy(pNewOper, pOper, sizeof(SSdbOper));
if (pNewOper->pMsg != NULL) {
- sdbTrace("app:%p:%p, delete action is add to sdb queue", pNewOper->pMsg->rpcMsg.ahandle, pNewOper->pMsg);
+ sdbDebug("app:%p:%p, table:%s record:%p:%s, delete action is add to sdb queue, ", pNewOper->pMsg->rpcMsg.ahandle,
+ pNewOper->pMsg, pTable->tableName, pOper->pObj, sdbGetKeyStrFromObj(pTable, pOper->pObj));
}
+ sdbIncRef(pNewOper->table, pNewOper->pObj);
taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper);
return TSDB_CODE_SUCCESS;
}
@@ -687,7 +691,7 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
SSdbRow *pMeta = sdbGetRowMetaFromObj(pTable, pOper->pObj);
if (pMeta == NULL) {
- sdbTrace("table:%s, record is not there, update failed", pTable->tableName);
+ sdbDebug("table:%s, record is not there, update failed", pTable->tableName);
return TSDB_CODE_MND_SDB_OBJ_NOT_THERE;
}
@@ -722,9 +726,11 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
memcpy(pNewOper, pOper, sizeof(SSdbOper));
if (pNewOper->pMsg != NULL) {
- sdbTrace("app:%p:%p, update action is add to sdb queue", pNewOper->pMsg->rpcMsg.ahandle, pNewOper->pMsg);
+ sdbDebug("app:%p:%p, table:%s record:%p:%s, update action is add to sdb queue, ", pNewOper->pMsg->rpcMsg.ahandle,
+ pNewOper->pMsg, pTable->tableName, pOper->pObj, sdbGetKeyStrFromObj(pTable, pOper->pObj));
}
+ sdbIncRef(pNewOper->table, pNewOper->pObj);
taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper);
return TSDB_CODE_SUCCESS;
}
@@ -782,7 +788,7 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
pTable->restoredFp = pDesc->restoredFp;
_hash_fn_t hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
- if (pTable->keyType == SDB_KEY_STRING) {
+ if (pTable->keyType == SDB_KEY_STRING || pTable->keyType == SDB_KEY_VAR_STRING) {
hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
}
pTable->iHandle = taosHashInit(pTable->hashSessions, hashFp, true);
@@ -815,7 +821,7 @@ void sdbCloseTable(void *handle) {
taosHashDestroyIter(pIter);
taosHashCleanup(pTable->iHandle);
- sdbTrace("table:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbObj.numOfTables);
+ sdbDebug("table:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbObj.numOfTables);
free(pTable);
}
@@ -831,7 +837,7 @@ int32_t sdbInitWriteWorker() {
sdbAllocWriteQueue();
- mPrint("sdb write is opened");
+ mInfo("sdb write is opened");
return 0;
}
@@ -851,8 +857,9 @@ void sdbCleanupWriteWorker() {
}
sdbFreeWritequeue();
+ tfree(tsSdbPool.writeWorker);
- mPrint("sdb write is closed");
+ mInfo("sdb write is closed");
}
int32_t sdbAllocWriteQueue() {
@@ -890,10 +897,10 @@ int32_t sdbAllocWriteQueue() {
}
pthread_attr_destroy(&thAttr);
- mTrace("sdb write worker:%d is launched, total:%d", pWorker->workerId, tsSdbPool.num);
+ mDebug("sdb write worker:%d is launched, total:%d", pWorker->workerId, tsSdbPool.num);
}
- mTrace("sdb write queue:%p is allocated", tsSdbWriteQueue);
+ mDebug("sdb write queue:%p is allocated", tsSdbWriteQueue);
return TSDB_CODE_SUCCESS;
}
@@ -927,7 +934,7 @@ static void *sdbWorkerFp(void *param) {
while (1) {
numOfMsgs = taosReadAllQitemsFromQset(tsSdbWriteQset, tsSdbWriteQall, &unUsed);
if (numOfMsgs == 0) {
- sdbTrace("sdbWorkerFp: got no message from qset, exiting...");
+ sdbDebug("sdbWorkerFp: got no message from qset, exiting...");
break;
}
@@ -942,7 +949,9 @@ static void *sdbWorkerFp(void *param) {
}
if (pOper != NULL && pOper->pMsg != NULL) {
- sdbTrace("app:%p:%p, will be processed in sdb queue", pOper->pMsg->rpcMsg.ahandle, pOper->pMsg);
+ sdbDebug("app:%p:%p, table:%s record:%p:%s version:%" PRIu64 ", will be processed in sdb queue",
+ pOper->pMsg->rpcMsg.ahandle, pOper->pMsg, ((SSdbTable *)pOper->table)->tableName, pOper->pObj,
+ sdbGetKeyStr(pOper->table, pHead->cont), pHead->version);
}
int32_t code = sdbWrite(pOper, pHead, type);
@@ -958,15 +967,20 @@ static void *sdbWorkerFp(void *param) {
if (type == TAOS_QTYPE_RPC) {
pOper = (SSdbOper *)item;
if (pOper != NULL && pOper->cb != NULL) {
+ sdbTrace("app:%p:%p, will do callback func, index:%d", pOper->pMsg->rpcMsg.ahandle, pOper->pMsg, i);
pOper->retCode = (*pOper->cb)(pOper->pMsg, pOper->retCode);
}
-
+
if (pOper != NULL && pOper->pMsg != NULL) {
sdbTrace("app:%p:%p, msg is processed, result:%s", pOper->pMsg->rpcMsg.ahandle, pOper->pMsg,
tstrerror(pOper->retCode));
}
dnodeSendRpcMnodeWriteRsp(pOper->pMsg, pOper->retCode);
+
+ if (pOper != NULL) {
+ sdbDecRef(pOper->table, pOper->pObj);
+ }
}
taosFreeQitem(item);
}
diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c
index 996e9ced0b..6f5216dfa3 100644
--- a/src/mnode/src/mnodeShow.c
+++ b/src/mnode/src/mnodeShow.c
@@ -71,7 +71,7 @@ int32_t mnodeInitShow() {
void mnodeCleanUpShow() {
if (tsMnodeShowCache != NULL) {
- mPrint("show cache is cleanup");
+ mInfo("show cache is cleanup");
taosCacheCleanup(tsMnodeShowCache);
tsMnodeShowCache = NULL;
}
@@ -139,7 +139,7 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) {
pShowRsp->qhandle = htobe64((uint64_t) pShow);
int32_t code = (*tsMnodeShowMetaFp[pShowMsg->type])(&pShowRsp->tableMeta, pShow, pMsg->rpcMsg.handle);
- mTrace("%p, show type:%s index:%d, get meta finished, numOfRows:%d cols:%d result:%s", pShow,
+ mDebug("%p, show type:%s index:%d, get meta finished, numOfRows:%d cols:%d result:%s", pShow,
mnodeGetShowType(pShowMsg->type), pShow->index, pShow->numOfRows, pShow->numOfColumns, tstrerror(code));
if (code == TSDB_CODE_SUCCESS) {
@@ -172,11 +172,11 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_INVALID_SHOWOBJ;
}
- mTrace("%p, show type:%s index:%d, start retrieve data, numOfReads:%d numOfRows:%d", pShow,
+ mDebug("%p, show type:%s index:%d, start retrieve data, numOfReads:%d numOfRows:%d", pShow,
mnodeGetShowType(pShow->type), pShow->index, pShow->numOfReads, pShow->numOfRows);
if (mnodeCheckShowFinished(pShow)) {
- mTrace("%p, show is already read finished, numOfReads:%d numOfRows:%d", pShow, pShow->numOfReads, pShow->numOfRows);
+ mDebug("%p, show is already read finished, numOfReads:%d numOfRows:%d", pShow, pShow->numOfReads, pShow->numOfRows);
pShow->numOfReads = pShow->numOfRows;
}
@@ -201,7 +201,7 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) {
if ((pRetrieve->free & TSDB_QUERY_TYPE_FREE_RESOURCE) != TSDB_QUERY_TYPE_FREE_RESOURCE)
rowsRead = (*tsMnodeShowRetrieveFp[pShow->type])(pShow, pRsp->data, rowsToRead, pMsg->rpcMsg.handle);
- mTrace("%p, show type:%s index:%d, stop retrieve data, rowsRead:%d rowsToRead:%d", pShow,
+ mDebug("%p, show type:%s index:%d, stop retrieve data, rowsRead:%d rowsToRead:%d", pShow,
mnodeGetShowType(pShow->type), pShow->index, rowsRead, rowsToRead);
if (rowsRead < 0) {
@@ -219,10 +219,10 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) {
if (rowsToRead == 0 || (rowsRead == rowsToRead && pShow->numOfRows == pShow->numOfReads)) {
pRsp->completed = 1;
- mTrace("%p, retrieve completed", pShow);
+ mDebug("%p, retrieve completed", pShow);
mnodeReleaseShowObj(pShow, true);
} else {
- mTrace("%p, retrieve not completed yet", pShow);
+ mDebug("%p, retrieve not completed yet", pShow);
mnodeReleaseShowObj(pShow, false);
}
@@ -335,7 +335,7 @@ connect_over:
rpcFreeCont(pConnectRsp);
mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
} else {
- mLPrint("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
+ mLInfo("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
pMsg->rpcRsp.rsp = pConnectRsp;
pMsg->rpcRsp.len = sizeof(SCMConnectRsp);
}
@@ -368,7 +368,7 @@ static bool mnodeAccquireShowObj(SShowObj *pShow) {
SShowObj *pSaved = taosCacheAcquireByName(tsMnodeShowCache, key);
if (pSaved == pShow) {
- mTrace("%p, show is accquired from cache", pShow);
+ mDebug("%p, show is accquired from cache", pShow);
return true;
} else {
return false;
@@ -384,7 +384,7 @@ static void *mnodePutShowObj(SShowObj *pShow, int32_t size) {
SShowObj *newQhandle = taosCachePut(tsMnodeShowCache, key, pShow, size, 6);
free(pShow);
- mTrace("%p, show is put into cache, index:%s", newQhandle, key);
+ mDebug("%p, show is put into cache, index:%s", newQhandle, key);
return newQhandle;
}
@@ -394,11 +394,11 @@ static void *mnodePutShowObj(SShowObj *pShow, int32_t size) {
static void mnodeFreeShowObj(void *data) {
SShowObj *pShow = data;
sdbFreeIter(pShow->pIter);
- mTrace("%p, show is destroyed", pShow);
+ mDebug("%p, show is destroyed", pShow);
}
static void mnodeReleaseShowObj(void *pShow, bool forceRemove) {
- mTrace("%p, show is released, force:%s", pShow, forceRemove ? "true" : "false");
+ mDebug("%p, show is released, force:%s", pShow, forceRemove ? "true" : "false");
taosCacheRelease(tsMnodeShowCache, &pShow, forceRemove);
}
diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c
index 346c33f80d..023ae68919 100644
--- a/src/mnode/src/mnodeTable.c
+++ b/src/mnode/src/mnodeTable.c
@@ -370,7 +370,7 @@ static int32_t mnodeInitChildTables() {
return -1;
}
- mTrace("table:ctables is created");
+ mDebug("table:ctables is created");
return 0;
}
@@ -547,7 +547,7 @@ static int32_t mnodeInitSuperTables() {
return -1;
}
- mTrace("table:stables is created");
+ mDebug("table:stables is created");
return 0;
}
@@ -690,10 +690,10 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableId);
if (pMsg->pTable != NULL && pMsg->retry == 0) {
if (pCreate->getMeta) {
- mTrace("app:%p:%p, table:%s, continue to get meta", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
+ mDebug("app:%p:%p, table:%s, continue to get meta", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
return mnodeGetChildTableMeta(pMsg);
} else if (pCreate->igExists) {
- mTrace("app:%p:%p, table:%s, is already exist", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
+ mDebug("app:%p:%p, table:%s, is already exist", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
return TSDB_CODE_SUCCESS;
} else {
mError("app:%p:%p, table:%s, failed to create, table already exist", pMsg->rpcMsg.ahandle, pMsg,
@@ -703,11 +703,11 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
}
if (pCreate->numOfTags != 0) {
- mTrace("app:%p:%p, table:%s, create stable msg is received from thandle:%p", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, create stable msg is received from thandle:%p", pMsg->rpcMsg.ahandle, pMsg,
pCreate->tableId, pMsg->rpcMsg.handle);
return mnodeProcessCreateSuperTableMsg(pMsg);
} else {
- mTrace("app:%p:%p, table:%s, create ctable msg is received from thandle:%p", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, create ctable msg is received from thandle:%p", pMsg->rpcMsg.ahandle, pMsg,
pCreate->tableId, pMsg->rpcMsg.handle);
return mnodeProcessCreateChildTableMsg(pMsg);
}
@@ -730,7 +730,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->tableId);
if (pMsg->pTable == NULL) {
if (pDrop->igNotExists) {
- mTrace("app:%p:%p, table:%s, table is not exist, think drop success", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
+ mDebug("app:%p:%p, table:%s, table is not exist, think drop success", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
return TSDB_CODE_SUCCESS;
} else {
mError("app:%p:%p, table:%s, failed to drop table, table not exist", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
@@ -739,10 +739,10 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
}
if (pMsg->pTable->type == TSDB_SUPER_TABLE) {
- mPrint("app:%p:%p, table:%s, start to drop stable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
+ mInfo("app:%p:%p, table:%s, start to drop stable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
return mnodeProcessDropSuperTableMsg(pMsg);
} else {
- mPrint("app:%p:%p, table:%s, start to drop ctable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
+ mInfo("app:%p:%p, table:%s, start to drop ctable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
return mnodeProcessDropChildTableMsg(pMsg);
}
}
@@ -750,7 +750,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
SCMTableInfoMsg *pInfo = pMsg->rpcMsg.pCont;
pInfo->createFlag = htons(pInfo->createFlag);
- mTrace("app:%p:%p, table:%s, table meta msg is received from thandle:%p, createFlag:%d", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, table meta msg is received from thandle:%p, createFlag:%d", pMsg->rpcMsg.ahandle, pMsg,
pInfo->tableId, pMsg->rpcMsg.handle, pInfo->createFlag);
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pInfo->tableId);
@@ -767,7 +767,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
pInfo->tableId);
return TSDB_CODE_MND_INVALID_TABLE_NAME;
} else {
- mTrace("app:%p:%p, table:%s, failed to get table meta, start auto create table ", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, failed to get table meta, start auto create table ", pMsg->rpcMsg.ahandle, pMsg,
pInfo->tableId);
return mnodeAutoCreateChildTable(pMsg);
}
@@ -783,7 +783,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
if (pTable != NULL) {
- mLPrint("app:%p:%p, stable:%s, create result:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
+ mLInfo("app:%p:%p, stable:%s, is created in sdb, result:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
tstrerror(code));
}
@@ -852,6 +852,17 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
}
}
+static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
+ SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
+ if (code != TSDB_CODE_SUCCESS) {
+ mError("app:%p:%p, table:%s, failed to drop, sdb error", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
+ } else {
+ mLInfo("app:%p:%p, stable:%s, is dropped from sdb", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
+ }
+
+ return code;
+}
+
static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
@@ -869,7 +880,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
pDrop->uid = htobe64(pStable->uid);
mnodeExtractTableName(pStable->info.tableId, pDrop->tableId);
- mPrint("app:%p:%p, stable:%s, send drop stable msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mInfo("app:%p:%p, stable:%s, send drop stable msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
pVgroup->vgId);
SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pVgroup);
SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE};
@@ -882,18 +893,17 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
}
SSdbOper oper = {
- .type = SDB_OPER_GLOBAL,
+ .type = SDB_OPER_GLOBAL,
.table = tsSuperTableSdb,
- .pObj = pStable,
- .pMsg = pMsg
+ .pObj = pStable,
+ .pMsg = pMsg,
+ .cb = mnodeDropSuperTableCb
};
-
+
int32_t code = sdbDeleteRow(&oper);
if (code == TSDB_CODE_SUCCESS) {
- mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code));
- code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
+ return TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
-
return code;
}
@@ -910,7 +920,7 @@ static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *
static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
- mLPrint("app:%p:%p, stable %s, add tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mLInfo("app:%p:%p, stable %s, add tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
tstrerror(code));
return code;
@@ -950,7 +960,7 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
pStable->numOfTags += ntags;
pStable->tversion++;
- mPrint("app:%p:%p, stable %s, start to add tag %s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mInfo("app:%p:%p, stable %s, start to add tag %s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
schema[0].name);
SSdbOper oper = {
@@ -971,7 +981,7 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
- mLPrint("app:%p:%p, stable %s, drop tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mLInfo("app:%p:%p, stable %s, drop tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
tstrerror(code));
return code;
}
@@ -990,7 +1000,7 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
pStable->numOfTags--;
pStable->tversion++;
- mPrint("app:%p:%p, stable %s, start to drop tag %s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, tagName);
+ mInfo("app:%p:%p, stable %s, start to drop tag %s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, tagName);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
@@ -1010,7 +1020,7 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
- mLPrint("app:%p:%p, stable %s, modify tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mLInfo("app:%p:%p, stable %s, modify tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
tstrerror(code));
return code;
}
@@ -1038,7 +1048,7 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c
SSchema *schema = (SSchema *) (pStable->schema + pStable->numOfColumns + col);
tstrncpy(schema->name, newTagName, sizeof(schema->name));
- mPrint("app:%p:%p, stable %s, start to modify tag %s to %s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mInfo("app:%p:%p, stable %s, start to modify tag %s to %s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
oldTagName, newTagName);
SSdbOper oper = {
@@ -1070,7 +1080,7 @@ static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *col
static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
- mLPrint("app:%p:%p, stable %s, add column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mLInfo("app:%p:%p, stable %s, add column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
tstrerror(code));
return code;
}
@@ -1118,7 +1128,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
mnodeDecAcctRef(pAcct);
}
- mPrint("app:%p:%p, stable %s, start to add column", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
+ mInfo("app:%p:%p, stable %s, start to add column", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
@@ -1138,7 +1148,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
- mLPrint("app:%p:%p, stable %s, delete column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
+ mLInfo("app:%p:%p, stable %s, delete column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
tstrerror(code));
return code;
}
@@ -1168,7 +1178,7 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
mnodeDecAcctRef(pAcct);
}
- mPrint("app:%p:%p, stable %s, start to delete column", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
+ mInfo("app:%p:%p, stable %s, start to delete column", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
@@ -1316,7 +1326,7 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
int32_t dbNameLen = strlen(pDropDb->name);
SSuperTableObj *pTable = NULL;
- mPrint("db:%s, all super tables will be dropped from sdb", pDropDb->name);
+ mInfo("db:%s, all super tables will be dropped from sdb", pDropDb->name);
while (1) {
pIter = mnodeGetNextSuperTable(pIter, &pTable);
@@ -1337,7 +1347,7 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
sdbFreeIter(pIter);
- mPrint("db:%s, all super tables:%d is dropped from sdb", pDropDb->name, numOfTables);
+ mInfo("db:%s, all super tables:%d is dropped from sdb", pDropDb->name, numOfTables);
}
static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
@@ -1373,7 +1383,7 @@ static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
pMsg->rpcRsp.rsp = pMeta;
- mTrace("app:%p:%p, stable:%s, uid:%" PRIu64 " table meta is retrieved", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, stable:%s, uid:%" PRIu64 " table meta is retrieved", pMsg->rpcMsg.ahandle, pMsg,
pTable->info.tableId, pTable->uid);
return TSDB_CODE_SUCCESS;
}
@@ -1410,7 +1420,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
continue;
}
if (pTable->vgHash == NULL) {
- mError("app:%p:%p, stable:%s, not vgroup exist while get stable vgroup info", pMsg->rpcMsg.ahandle, pMsg,
+ mError("app:%p:%p, stable:%s, no vgroup exist while get stable vgroup info", pMsg->rpcMsg.ahandle, pMsg,
stableName);
mnodeDecTableRef(pTable);
@@ -1470,7 +1480,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
}
static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg) {
- mPrint("drop stable rsp received, result:%s", tstrerror(rpcMsg->code));
+ mInfo("drop stable rsp received, result:%s", tstrerror(rpcMsg->code));
}
static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTable) {
@@ -1549,7 +1559,7 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO
static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
if (pTable != NULL) {
- mTrace("app:%p:%p, table:%s, create table in id:%d, uid:%" PRIu64 ", result:%s", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, create table in id:%d, uid:%" PRIu64 ", result:%s", pMsg->rpcMsg.ahandle, pMsg,
pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code));
}
@@ -1596,19 +1606,18 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
if (pTable->info.type == TSDB_CHILD_TABLE) {
STagData *pTagData = (STagData *) pCreate->schema; // it is a tag key
- SSuperTableObj *pSuperTable = mnodeGetSuperTable(pTagData->name);
- if (pSuperTable == NULL) {
+ if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(pTagData->name);
+ if (pMsg->pSTable == NULL) {
mError("app:%p:%p, table:%s, corresponding super table:%s does not exist", pMsg->rpcMsg.ahandle, pMsg,
pCreate->tableId, pTagData->name);
mnodeDestroyChildTable(pTable);
return TSDB_CODE_MND_INVALID_TABLE_NAME;
}
- mnodeDecTableRef(pSuperTable);
-
- pTable->suid = pSuperTable->uid;
+
+ pTable->suid = pMsg->pSTable->uid;
pTable->uid = (((uint64_t)pTable->vgId) << 40) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 16) +
(sdbGetVersion() & ((1ul << 16) - 1ul));
- pTable->superTable = pSuperTable;
+ pTable->superTable = pMsg->pSTable;
} else {
pTable->uid = (((uint64_t) pTable->createdTime) << 16) + (sdbGetVersion() & ((1ul << 16) - 1ul));
pTable->sversion = 0;
@@ -1640,7 +1649,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
}
memcpy(pTable->sql, (char *) (pCreate->schema) + numOfCols * sizeof(SSchema), pTable->sqlLen);
pTable->sql[pTable->sqlLen - 1] = 0;
- mTrace("app:%p:%p, table:%s, stream sql len:%d sql:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
+ mDebug("app:%p:%p, table:%s, stream sql len:%d sql:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
pTable->sqlLen, pTable->sql);
}
}
@@ -1661,9 +1670,10 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
pMsg->pTable = NULL;
mError("app:%p:%p, table:%s, update sdb error, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
tstrerror(code));
- }
-
- return code;
+ return code;
+ } else {
+ return TSDB_CODE_MND_ACTION_IN_PROGRESS;
+ }
}
static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
@@ -1677,7 +1687,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
SVgObj *pVgroup = mnodeGetAvailableVgroup(pMsg->pDb);
if (pVgroup == NULL) {
- mTrace("app:%p:%p, table:%s, start to create a new vgroup", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
+ mDebug("app:%p:%p, table:%s, start to create a new vgroup", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
return mnodeCreateVgroup(pMsg, pMsg->pDb);
}
@@ -1685,7 +1695,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
if (pMsg->pTable == NULL) {
int32_t sid = taosAllocateId(pVgroup->idPool);
if (sid <= 0) {
- mTrace("app:%p:%p, table:%s, no enough sid in vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
+ mDebug("app:%p:%p, table:%s, no enough sid in vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
pVgroup->vgId);
return mnodeCreateVgroup(pMsg, pMsg->pDb);
}
@@ -1695,15 +1705,10 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
mnodeIncVgroupRef(pVgroup);
}
- mTrace("app:%p:%p, table:%s, create table in vgroup, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
+ mDebug("app:%p:%p, table:%s, create table in vgroup, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
pVgroup->vgId, sid);
- code = mnodeDoCreateChildTable(pMsg, sid);
- if (code != TSDB_CODE_SUCCESS) {
- return code;
- } else {
- return TSDB_CODE_MND_ACTION_IN_PROGRESS;
- }
+ return mnodeDoCreateChildTable(pMsg, sid);
}
} else {
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableId);
@@ -1714,7 +1719,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
tstrerror(terrno));
return terrno;
} else {
- mTrace("app:%p:%p, table:%s, send create msg to vnode again", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
+ mDebug("app:%p:%p, table:%s, send create msg to vnode again", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
return mnodeDoCreateChildTableCb(pMsg, TSDB_CODE_SUCCESS);
}
}
@@ -1743,7 +1748,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pMsg->pVgroup);
- mPrint("app:%p:%p, table:%s, send drop ctable msg", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
+ mInfo("app:%p:%p, table:%s, send drop ctable msg", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId);
SRpcMsg rpcMsg = {
.handle = pMsg,
.pCont = pDrop,
@@ -1800,7 +1805,7 @@ static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
.msgType = TSDB_MSG_TYPE_MD_ALTER_TABLE
};
- mTrace("app:%p:%p, ctable %s, send alter column msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
+ mDebug("app:%p:%p, ctable %s, send alter column msg to vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
pMsg->pVgroup->vgId);
dnodeSendMsgToDnode(&ipSet, &rpcMsg);
@@ -1842,7 +1847,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
mnodeDecAcctRef(pAcct);
}
- mPrint("app:%p:%p, ctable %s, start to add column", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
+ mInfo("app:%p:%p, ctable %s, start to add column", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
@@ -1880,7 +1885,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
mnodeDecAcctRef(pAcct);
}
- mPrint("app:%p:%p, ctable %s, start to drop column %s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, colName);
+ mInfo("app:%p:%p, ctable %s, start to drop column %s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, colName);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
@@ -1952,7 +1957,7 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
}
pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId);
- mTrace("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved", pMsg->rpcMsg.ahandle, pMsg,
pTable->info.tableId, pTable->uid);
return TSDB_CODE_SUCCESS;
@@ -1978,7 +1983,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
pCreateMsg->contLen = htonl(contLen);
memcpy(pCreateMsg->schema, pInfo->tags, contLen - sizeof(SCMCreateTableMsg));
- mTrace("app:%p:%p, table:%s, start to create on demand, stable:%s", pMsg->rpcMsg.ahandle, pMsg, pInfo->tableId,
+ mDebug("app:%p:%p, table:%s, start to create on demand, stable:%s", pMsg->rpcMsg.ahandle, pMsg, pInfo->tableId,
((STagData *)(pCreateMsg->schema))->name);
rpcFreeCont(pMsg->rpcMsg.pCont);
@@ -2012,7 +2017,7 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
int32_t numOfTables = 0;
SChildTableObj *pTable = NULL;
- mPrint("vgId:%d, all child tables will be dropped from sdb", pVgroup->vgId);
+ mInfo("vgId:%d, all child tables will be dropped from sdb", pVgroup->vgId);
while (1) {
pIter = mnodeGetNextChildTable(pIter, &pTable);
@@ -2032,7 +2037,7 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
sdbFreeIter(pIter);
- mPrint("vgId:%d, all child tables is dropped from sdb", pVgroup->vgId);
+ mInfo("vgId:%d, all child tables is dropped from sdb", pVgroup->vgId);
}
void mnodeDropAllChildTables(SDbObj *pDropDb) {
@@ -2041,7 +2046,7 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
int32_t dbNameLen = strlen(pDropDb->name);
SChildTableObj *pTable = NULL;
- mPrint("db:%s, all child tables will be dropped from sdb", pDropDb->name);
+ mInfo("db:%s, all child tables will be dropped from sdb", pDropDb->name);
while (1) {
pIter = mnodeGetNextChildTable(pIter, &pTable);
@@ -2061,7 +2066,7 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
sdbFreeIter(pIter);
- mPrint("db:%s, all child tables:%d is dropped from sdb", pDropDb->name, numOfTables);
+ mInfo("db:%s, all child tables:%d is dropped from sdb", pDropDb->name, numOfTables);
}
static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
@@ -2069,7 +2074,7 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
int32_t numOfTables = 0;
SChildTableObj *pTable = NULL;
- mPrint("stable:%s, all child tables(%d) will dropped from sdb", pStable->info.tableId, numOfTables);
+ mInfo("stable:%s, all child tables(%d) will dropped from sdb", pStable->info.tableId, numOfTables);
while (1) {
pIter = mnodeGetNextChildTable(pIter, &pTable);
@@ -2090,7 +2095,7 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
sdbFreeIter(pIter);
- mPrint("stable:%s, all child tables:%d is dropped from sdb", pStable->info.tableId, numOfTables);
+ mInfo("stable:%s, all child tables:%d is dropped from sdb", pStable->info.tableId, numOfTables);
}
static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t sid) {
@@ -2109,7 +2114,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
pCfg->dnodeId = htonl(pCfg->dnodeId);
pCfg->vgId = htonl(pCfg->vgId);
pCfg->sid = htonl(pCfg->sid);
- mTrace("app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
+ mDebug("app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
pCfg->vgId, pCfg->sid);
SChildTableObj *pTable = mnodeGetTableByPos(pCfg->vgId, pCfg->sid);
@@ -2139,7 +2144,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
SChildTableObj *pTable = (SChildTableObj *)mnodeMsg->pTable;
assert(pTable);
- mPrint("app:%p:%p, table:%s, drop table rsp received, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
+ mInfo("app:%p:%p, table:%s, drop table rsp received, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
if (rpcMsg->code != TSDB_CODE_SUCCESS) {
@@ -2170,7 +2175,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
}
if (mnodeMsg->pVgroup->numOfTables <= 0) {
- mPrint("app:%p:%p, vgId:%d, all tables is dropped, drop vgroup", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
+ mInfo("app:%p:%p, vgId:%d, all tables is dropped, drop vgroup", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
mnodeMsg->pVgroup->vgId);
mnodeDropVgroup(mnodeMsg->pVgroup, NULL);
}
@@ -2194,21 +2199,21 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
SCMCreateTableMsg *pCreate = mnodeMsg->rpcMsg.pCont;
if (pCreate->getMeta) {
- mTrace("app:%p:%p, table:%s, created in dnode and continue to get meta, thandle:%p result:%s",
+ mDebug("app:%p:%p, table:%s, created in dnode and continue to get meta, thandle:%p result:%s",
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->rpcMsg.handle,
tstrerror(rpcMsg->code));
mnodeMsg->retry = 0;
dnodeReprocessMnodeWriteMsg(mnodeMsg);
} else {
- mTrace("app:%p:%p, table:%s, created in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
+ mDebug("app:%p:%p, table:%s, created in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS);
}
} else {
if (mnodeMsg->retry++ < 10) {
- mTrace("app:%p:%p, table:%s, create table rsp received, need retry, times:%d result:%s thandle:%p",
+ mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d result:%s thandle:%p",
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, tstrerror(rpcMsg->code),
mnodeMsg->rpcMsg.handle);
@@ -2235,13 +2240,13 @@ static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg) {
assert(pTable);
if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
- mTrace("app:%p:%p, ctable:%s, altered in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
+ mDebug("app:%p:%p, ctable:%s, altered in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS);
} else {
if (mnodeMsg->retry++ < 3) {
- mTrace("app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p",
+ mDebug("app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p",
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, tstrerror(rpcMsg->code),
mnodeMsg->rpcMsg.handle);
@@ -2434,7 +2439,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
SCMAlterTableMsg *pAlter = pMsg->rpcMsg.pCont;
- mTrace("app:%p:%p, table:%s, alter table msg is received from thandle:%p", pMsg->rpcMsg.ahandle, pMsg,
+ mDebug("app:%p:%p, table:%s, alter table msg is received from thandle:%p", pMsg->rpcMsg.ahandle, pMsg,
pAlter->tableId, pMsg->rpcMsg.handle);
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pAlter->tableId);
@@ -2470,7 +2475,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
int32_t code = TSDB_CODE_COM_OPS_NOT_SUPPORT;
if (pMsg->pTable->type == TSDB_SUPER_TABLE) {
- mTrace("app:%p:%p, table:%s, start to alter stable", pMsg->rpcMsg.ahandle, pMsg, pAlter->tableId);
+ mDebug("app:%p:%p, table:%s, start to alter stable", pMsg->rpcMsg.ahandle, pMsg, pAlter->tableId);
if (pAlter->type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN) {
code = mnodeAddSuperTableTag(pMsg, pAlter->schema, 1);
} else if (pAlter->type == TSDB_ALTER_TABLE_DROP_TAG_COLUMN) {
@@ -2484,7 +2489,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
} else {
}
} else {
- mTrace("app:%p:%p, table:%s, start to alter ctable", pMsg->rpcMsg.ahandle, pMsg, pAlter->tableId);
+ mDebug("app:%p:%p, table:%s, start to alter ctable", pMsg->rpcMsg.ahandle, pMsg, pAlter->tableId);
if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) {
return TSDB_CODE_COM_OPS_NOT_SUPPORT;
} else if (pAlter->type == TSDB_ALTER_TABLE_ADD_COLUMN) {
diff --git a/src/mnode/src/mnodeUser.c b/src/mnode/src/mnodeUser.c
index b559116e58..fa2a2634d6 100644
--- a/src/mnode/src/mnodeUser.c
+++ b/src/mnode/src/mnodeUser.c
@@ -104,7 +104,7 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
static int32_t mnodeUserActionRestored() {
int32_t numOfRows = sdbGetNumOfRows(tsUserSdb);
if (numOfRows <= 0 && dnodeIsFirstDeploy()) {
- mPrint("dnode first deploy, create root user");
+ mInfo("dnode first deploy, create root user");
SAcctObj *pAcct = mnodeGetAcct(TSDB_DEFAULT_USER);
mnodeCreateUser(pAcct, TSDB_DEFAULT_USER, TSDB_DEFAULT_PASS, NULL);
mnodeCreateUser(pAcct, "monitor", tsInternalPass, NULL);
@@ -148,7 +148,7 @@ int32_t mnodeInitUsers() {
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_USER, mnodeRetrieveUsers);
mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_AUTH, mnodeProcessAuthMsg);
- mTrace("table:%s, hash is created", tableDesc.tableName);
+ mDebug("table:%s, hash is created", tableDesc.tableName);
return 0;
}
@@ -182,7 +182,7 @@ static int32_t mnodeUpdateUser(SUserObj *pUser, void *pMsg) {
int32_t code = sdbUpdateRow(&oper);
if (code == TSDB_CODE_SUCCESS) {
- mLPrint("user:%s, is altered by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
+ mLInfo("user:%s, is altered by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
@@ -205,7 +205,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
SUserObj *pUser = mnodeGetUser(name);
if (pUser != NULL) {
- mTrace("user:%s, is already there", name);
+ mDebug("user:%s, is already there", name);
mnodeDecUserRef(pUser);
return TSDB_CODE_MND_USER_ALREADY_EXIST;
}
@@ -238,7 +238,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
if (code != TSDB_CODE_SUCCESS) {
tfree(pUser);
} else {
- mLPrint("user:%s, is created by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
+ mLInfo("user:%s, is created by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
@@ -255,7 +255,7 @@ static int32_t mnodeDropUser(SUserObj *pUser, void *pMsg) {
int32_t code = sdbDeleteRow(&oper);
if (code == TSDB_CODE_SUCCESS) {
- mLPrint("user:%s, is dropped by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
+ mLInfo("user:%s, is dropped by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
}
@@ -541,13 +541,13 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
sdbFreeIter(pIter);
- mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers);
+ mDebug("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers);
}
int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
if (!sdbIsMaster()) {
*secret = 0;
- mTrace("user:%s, failed to auth user, reason:%s", user, tstrerror(TSDB_CODE_RPC_NOT_READY));
+ mDebug("user:%s, failed to auth user, reason:%s", user, tstrerror(TSDB_CODE_RPC_NOT_READY));
return TSDB_CODE_RPC_NOT_READY;
}
@@ -563,7 +563,7 @@ int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, cha
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
mnodeDecUserRef(pUser);
- mTrace("user:%s, auth info is returned", user);
+ mDebug("user:%s, auth info is returned", user);
return TSDB_CODE_SUCCESS;
}
}
diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c
index e6759e90db..36fa306c9f 100644
--- a/src/mnode/src/mnodeVgroup.c
+++ b/src/mnode/src/mnodeVgroup.c
@@ -129,7 +129,7 @@ static void mnodeVgroupUpdateIdPool(SVgObj *pVgroup) {
SDbObj *pDb = pVgroup->pDb;
if (pDb != NULL) {
if (pDb->cfg.maxTables != oldTables) {
- mPrint("vgId:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxTables);
+ mInfo("vgId:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxTables);
taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxTables);
int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables;
pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size);
@@ -166,7 +166,7 @@ static int32_t mnodeVgroupActionUpdate(SSdbOper *pOper) {
mnodeDecVgroupRef(pVgroup);
- mTrace("vgId:%d, is updated, numOfVnode:%d", pVgroup->vgId, pVgroup->numOfVnodes);
+ mDebug("vgId:%d, is updated, numOfVnode:%d", pVgroup->vgId, pVgroup->numOfVnodes);
return TSDB_CODE_SUCCESS;
}
@@ -228,7 +228,7 @@ int32_t mnodeInitVgroups() {
mnodeAddPeerRspHandle(TSDB_MSG_TYPE_MD_DROP_VNODE_RSP, mnodeProcessDropVnodeRsp);
mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_VNODE, mnodeProcessVnodeCfgMsg);
- mTrace("table:vgroups is created");
+ mDebug("table:vgroups is created");
return 0;
}
@@ -342,9 +342,9 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
SVgObj *pVgroup = pMsg->pVgroup;
SDbObj *pDb = pMsg->pDb;
- mPrint("vgId:%d, is created in mnode, db:%s replica:%d", pVgroup->vgId, pDb->name, pVgroup->numOfVnodes);
+ mInfo("vgId:%d, is created in mnode, db:%s replica:%d", pVgroup->vgId, pDb->name, pVgroup->numOfVnodes);
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
- mPrint("vgId:%d, index:%d, dnode:%d", pVgroup->vgId, i, pVgroup->vnodeGid[i].dnodeId);
+ mInfo("vgId:%d, index:%d, dnode:%d", pVgroup->vgId, i, pVgroup->vnodeGid[i].dnodeId);
}
mnodeIncVgroupRef(pVgroup);
@@ -394,7 +394,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
if (ahandle != NULL) {
mnodeSendDropVgroupMsg(pVgroup, ahandle);
} else {
- mTrace("vgId:%d, replica:%d is deleting from sdb", pVgroup->vgId, pVgroup->numOfVnodes);
+ mDebug("vgId:%d, replica:%d is deleting from sdb", pVgroup->vgId, pVgroup->numOfVnodes);
mnodeSendDropVgroupMsg(pVgroup, NULL);
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
@@ -662,11 +662,11 @@ void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
}
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) {
- mTrace("vgId:%d, send create all vnodes msg, numOfVnodes:%d db:%s", pVgroup->vgId, pVgroup->numOfVnodes,
+ mDebug("vgId:%d, send create all vnodes msg, numOfVnodes:%d db:%s", pVgroup->vgId, pVgroup->numOfVnodes,
pVgroup->dbName);
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
- mTrace("vgId:%d, index:%d, send create vnode msg to dnode %s, ahandle:%p", pVgroup->vgId,
+ mDebug("vgId:%d, index:%d, send create vnode msg to dnode %s, ahandle:%p", pVgroup->vgId,
i, pVgroup->vnodeGid[i].pDnode->dnodeEp, ahandle);
mnodeSendCreateVnodeMsg(pVgroup, &ipSet, ahandle);
}
@@ -684,7 +684,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
}
SVgObj *pVgroup = mnodeMsg->pVgroup;
- mTrace("vgId:%d, create vnode rsp received, result:%s received:%d successed:%d expected:%d, thandle:%p ahandle:%p",
+ mDebug("vgId:%d, create vnode rsp received, result:%s received:%d successed:%d expected:%d, thandle:%p ahandle:%p",
pVgroup->vgId, tstrerror(rpcMsg->code), mnodeMsg->received, mnodeMsg->successed, mnodeMsg->expected,
mnodeMsg->rpcMsg.handle, rpcMsg->handle);
@@ -728,16 +728,16 @@ void mnodeSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) {
}
static void mnodeSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) {
- mTrace("vgId:%d, send drop all vnodes msg, ahandle:%p", pVgroup->vgId, ahandle);
+ mDebug("vgId:%d, send drop all vnodes msg, ahandle:%p", pVgroup->vgId, ahandle);
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp);
- mTrace("vgId:%d, send drop vnode msg to dnode:%d, ahandle:%p", pVgroup->vgId, pVgroup->vnodeGid[i].dnodeId, ahandle);
+ mDebug("vgId:%d, send drop vnode msg to dnode:%d, ahandle:%p", pVgroup->vgId, pVgroup->vnodeGid[i].dnodeId, ahandle);
mnodeSendDropVnodeMsg(pVgroup->vgId, &ipSet, ahandle);
}
}
static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
- mTrace("drop vnode rsp is received, handle:%p", rpcMsg->handle);
+ mDebug("drop vnode rsp is received, handle:%p", rpcMsg->handle);
if (rpcMsg->handle == NULL) return;
SMnodeMsg *mnodeMsg = rpcMsg->handle;
@@ -748,7 +748,7 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
}
SVgObj *pVgroup = mnodeMsg->pVgroup;
- mTrace("vgId:%d, drop vnode rsp received, result:%s received:%d successed:%d expected:%d, thandle:%p ahandle:%p",
+ mDebug("vgId:%d, drop vnode rsp received, result:%s received:%d successed:%d expected:%d, thandle:%p ahandle:%p",
pVgroup->vgId, tstrerror(rpcMsg->code), mnodeMsg->received, mnodeMsg->successed, mnodeMsg->expected,
mnodeMsg->rpcMsg.handle, rpcMsg->handle);
@@ -774,19 +774,19 @@ static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) {
SDnodeObj *pDnode = mnodeGetDnode(pCfg->dnodeId);
if (pDnode == NULL) {
- mTrace("dnode:%s, vgId:%d, invalid dnode", taosIpStr(pCfg->dnodeId), pCfg->vgId);
+ mDebug("dnode:%s, vgId:%d, invalid dnode", taosIpStr(pCfg->dnodeId), pCfg->vgId);
return TSDB_CODE_MND_VGROUP_NOT_EXIST;
}
mnodeDecDnodeRef(pDnode);
SVgObj *pVgroup = mnodeGetVgroup(pCfg->vgId);
if (pVgroup == NULL) {
- mTrace("dnode:%s, vgId:%d, no vgroup info", taosIpStr(pCfg->dnodeId), pCfg->vgId);
+ mDebug("dnode:%s, vgId:%d, no vgroup info", taosIpStr(pCfg->dnodeId), pCfg->vgId);
return TSDB_CODE_MND_VGROUP_NOT_EXIST;
}
mnodeDecVgroupRef(pVgroup);
- mTrace("vgId:%d, send create vnode msg to dnode %s for vnode cfg msg", pVgroup->vgId, pDnode->dnodeEp);
+ mDebug("vgId:%d, send create vnode msg to dnode %s for vnode cfg msg", pVgroup->vgId, pDnode->dnodeEp);
SRpcIpSet ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp);
mnodeSendCreateVnodeMsg(pVgroup, &ipSet, NULL);
@@ -798,7 +798,7 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
SVgObj *pVgroup = NULL;
int32_t numOfVgroups = 0;
- mPrint("dnode:%d, all vgroups will be dropped from sdb", pDropDnode->dnodeId);
+ mInfo("dnode:%d, all vgroups will be dropped from sdb", pDropDnode->dnodeId);
while (1) {
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
@@ -819,14 +819,14 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
sdbFreeIter(pIter);
- mPrint("dnode:%d, all vgroups is dropped from sdb", pDropDnode->dnodeId);
+ mInfo("dnode:%d, all vgroups is dropped from sdb", pDropDnode->dnodeId);
}
void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) {
void * pIter = NULL;
SVgObj *pVgroup = NULL;
- mPrint("db:%s, all vgroups will be update in sdb", pAlterDb->name);
+ mInfo("db:%s, all vgroups will be update in sdb", pAlterDb->name);
while (1) {
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
@@ -841,7 +841,7 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) {
sdbFreeIter(pIter);
- mPrint("db:%s, all vgroups is updated in sdb", pAlterDb->name);
+ mInfo("db:%s, all vgroups is updated in sdb", pAlterDb->name);
}
void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
@@ -849,7 +849,7 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
int32_t numOfVgroups = 0;
SVgObj *pVgroup = NULL;
- mPrint("db:%s, all vgroups will be dropped from sdb", pDropDb->name);
+ mInfo("db:%s, all vgroups will be dropped from sdb", pDropDb->name);
while (1) {
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
if (pVgroup == NULL) break;
@@ -869,7 +869,7 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
sdbFreeIter(pIter);
- mPrint("db:%s, all vgroups:%d is dropped from sdb", pDropDb->name, numOfVgroups);
+ mInfo("db:%s, all vgroups:%d is dropped from sdb", pDropDb->name, numOfVgroups);
}
void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) {
@@ -877,7 +877,7 @@ void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) {
int32_t numOfVgroups = 0;
SVgObj *pVgroup = NULL;
- mPrint("db:%s, all vgroups will be dropped in dnode", pDropDb->name);
+ mInfo("db:%s, all vgroups will be dropped in dnode", pDropDb->name);
while (1) {
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
if (pVgroup == NULL) break;
@@ -891,5 +891,5 @@ void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) {
sdbFreeIter(pIter);
- mPrint("db:%s, all vgroups:%d drop msg is sent to dnode", pDropDb->name, numOfVgroups);
+ mInfo("db:%s, all vgroups:%d drop msg is sent to dnode", pDropDb->name, numOfVgroups);
}
diff --git a/src/mnode/src/mnodeWrite.c b/src/mnode/src/mnodeWrite.c
index cd3d722480..326ed50981 100644
--- a/src/mnode/src/mnodeWrite.c
+++ b/src/mnode/src/mnodeWrite.c
@@ -54,10 +54,10 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) {
rpcRsp->rsp = ipSet;
rpcRsp->len = sizeof(SRpcIpSet);
- mTrace("app:%p:%p, msg:%s will be redireced inUse:%d", pMsg->rpcMsg.ahandle, pMsg, taosMsg[pMsg->rpcMsg.msgType],
+ mDebug("app:%p:%p, msg:%s will be redireced inUse:%d", pMsg->rpcMsg.ahandle, pMsg, taosMsg[pMsg->rpcMsg.msgType],
ipSet->inUse);
for (int32_t i = 0; i < ipSet->numOfIps; ++i) {
- mTrace("app:%p:%p, mnode index:%d ip:%s:%d", pMsg->rpcMsg.ahandle, pMsg, i, ipSet->fqdn[i],
+ mDebug("app:%p:%p, mnode index:%d ip:%s:%d", pMsg->rpcMsg.ahandle, pMsg, i, ipSet->fqdn[i],
htons(ipSet->port[i]));
}
diff --git a/src/os/darwin/src/darwinPlatform.c b/src/os/darwin/src/darwinPlatform.c
index cae65a2927..44540cf69e 100644
--- a/src/os/darwin/src/darwinPlatform.c
+++ b/src/os/darwin/src/darwinPlatform.c
@@ -111,7 +111,7 @@ int taosGetPrivateIp(char *const ip) {
return 0;
} else {
if (hasLoCard) {
- uPrint("no net card was found, use lo:127.0.0.1 as default");
+ uInfo("no net card was found, use lo:127.0.0.1 as default");
strcpy(ip, "127.0.0.1");
return 0;
}
@@ -179,7 +179,7 @@ void taosGetSystemTimezone() {
strcpy(tsTimezone, tz);
}
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("timezone not configured, use default");
+ uInfo("timezone not configured, use default");
}
}
@@ -191,7 +191,7 @@ void taosGetSystemLocale() {
if (locale != NULL) {
tstrncpy(tsLocale, locale, sizeof(tsLocale));
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("locale not configured, set to default:%s", tsLocale);
+ uInfo("locale not configured, set to default:%s", tsLocale);
}
}
@@ -199,7 +199,7 @@ void taosGetSystemLocale() {
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
strcpy(tsCharset, "cp936");
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("charset not configured, set to default:%s", tsCharset);
+ uInfo("charset not configured, set to default:%s", tsCharset);
}
}
diff --git a/src/os/linux/src/linuxSysPara.c b/src/os/linux/src/linuxSysPara.c
index 96a8d1cb81..7c54716fbd 100644
--- a/src/os/linux/src/linuxSysPara.c
+++ b/src/os/linux/src/linuxSysPara.c
@@ -203,7 +203,7 @@ static void taosGetSystemTimezone() {
sprintf(tsTimezone, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
// cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("timezone not configured, set to system default:%s", tsTimezone);
+ uInfo("timezone not configured, set to system default:%s", tsTimezone);
}
/*
@@ -410,7 +410,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
double totalBytes = (double)(curBytes - lastBytes) / 1024 * 8; // Kb
*bandSpeedKb = (float)(totalBytes / (double)(curTime - lastTime));
- // uPrint("bandwidth lastBytes:%ld, lastTime:%ld, curBytes:%ld, curTime:%ld,
+ // uInfo("bandwidth lastBytes:%ld, lastTime:%ld, curBytes:%ld, curTime:%ld,
// speed:%f", lastBytes, lastTime, curBytes, curTime, *bandSpeed);
lastTime = curTime;
@@ -516,29 +516,29 @@ void taosGetSystemInfo() {
}
void taosPrintOsInfo() {
- uPrint(" os pageSize: %" PRId64 "(KB)", tsPageSize);
- uPrint(" os openMax: %" PRId64, tsOpenMax);
- uPrint(" os streamMax: %" PRId64, tsStreamMax);
- uPrint(" os numOfCores: %d", tsNumOfCores);
- uPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB);
- uPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB);
+ uInfo(" os pageSize: %" PRId64 "(KB)", tsPageSize);
+ uInfo(" os openMax: %" PRId64, tsOpenMax);
+ uInfo(" os streamMax: %" PRId64, tsStreamMax);
+ uInfo(" os numOfCores: %d", tsNumOfCores);
+ uInfo(" os totalDisk: %f(GB)", tsTotalDataDirGB);
+ uInfo(" os totalMemory: %d(MB)", tsTotalMemoryMB);
struct utsname buf;
if (uname(&buf)) {
- uPrint(" can't fetch os info");
+ uInfo(" can't fetch os info");
return;
}
- uPrint(" os sysname: %s", buf.sysname);
- uPrint(" os nodename: %s", buf.nodename);
- uPrint(" os release: %s", buf.release);
- uPrint(" os version: %s", buf.version);
- uPrint(" os machine: %s", buf.machine);
- uPrint("==================================");
+ uInfo(" os sysname: %s", buf.sysname);
+ uInfo(" os nodename: %s", buf.nodename);
+ uInfo(" os release: %s", buf.release);
+ uInfo(" os version: %s", buf.version);
+ uInfo(" os machine: %s", buf.machine);
+ uInfo("==================================");
}
void taosKillSystem() {
// SIGINT
- uPrint("taosd will shut down soon");
+ uInfo("taosd will shut down soon");
kill(tsProcId, 2);
}
@@ -552,11 +552,11 @@ void taosSetCoreDump() {
struct rlimit rlim;
struct rlimit rlim_new;
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
- uPrint("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
+ uInfo("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
rlim_new.rlim_cur = RLIM_INFINITY;
rlim_new.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
- uPrint("set unlimited fail, error: %s", strerror(errno));
+ uInfo("set unlimited fail, error: %s", strerror(errno));
rlim_new.rlim_cur = rlim.rlim_max;
rlim_new.rlim_max = rlim.rlim_max;
(void)setrlimit(RLIMIT_CORE, &rlim_new);
@@ -564,7 +564,7 @@ void taosSetCoreDump() {
}
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
- uPrint("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
+ uInfo("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
}
#ifndef _TD_ARM_
@@ -588,10 +588,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_usespid);
if (syscall(SYS__sysctl, &args) == -1) {
- uPrint("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
+ uInfo("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
- uPrint("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
+ uInfo("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
old_usespid = 0;
@@ -605,10 +605,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_usespid);
if (syscall(SYS__sysctl, &args) == -1) {
- uPrint("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
+ uInfo("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
- uPrint("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
+ uInfo("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
#endif
#if 0
@@ -618,7 +618,7 @@ void taosSetCoreDump() {
if (opendir(coredump_dir) == NULL) {
status = mkdir(coredump_dir, S_IRWXU | S_IRWXG | S_IRWXO);
if (status) {
- uPrint("mkdir fail, error: %s\n", strerror(errno));
+ uInfo("mkdir fail, error: %s\n", strerror(errno));
}
}
@@ -642,10 +642,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_corefile);
if (syscall(SYS__sysctl, &args) == -1) {
- uPrint("_sysctl(kern_core_pattern) set fail: %s", strerror(errno));
+ uInfo("_sysctl(kern_core_pattern) set fail: %s", strerror(errno));
}
- uPrint("The old kern_core_pattern: %*s\n", old_len, old_corefile);
+ uInfo("The old kern_core_pattern: %*s\n", old_len, old_corefile);
memset(&args, 0, sizeof(struct __sysctl_args));
@@ -657,10 +657,10 @@ void taosSetCoreDump() {
old_len = sizeof(old_corefile);
if (syscall(SYS__sysctl, &args) == -1) {
- uPrint("_sysctl(kern_core_pattern) get fail: %s", strerror(errno));
+ uInfo("_sysctl(kern_core_pattern) get fail: %s", strerror(errno));
}
- uPrint("The new kern_core_pattern: %*s\n", old_len, old_corefile);
+ uInfo("The new kern_core_pattern: %*s\n", old_len, old_corefile);
#endif
}
diff --git a/src/os/windows/src/twindows.c b/src/os/windows/src/twindows.c
index 82bcc69b11..295824846e 100644
--- a/src/os/windows/src/twindows.c
+++ b/src/os/windows/src/twindows.c
@@ -216,7 +216,7 @@ void taosGetSystemTimezone() {
strcpy(tsTimezone, tz);
}
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("timezone not configured, use default");
+ uInfo("timezone not configured, use default");
}
}
@@ -228,7 +228,7 @@ void taosGetSystemLocale() {
if (locale != NULL) {
tstrncpy(tsLocale, locale, sizeof(tsLocale));
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("locale not configured, set to default:%s", tsLocale);
+ uInfo("locale not configured, set to default:%s", tsLocale);
}
}
@@ -236,7 +236,7 @@ void taosGetSystemLocale() {
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
strcpy(tsCharset, "cp936");
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
- uPrint("charset not configured, set to default:%s", tsCharset);
+ uInfo("charset not configured, set to default:%s", tsCharset);
}
}
diff --git a/src/plugins/http/inc/httpLog.h b/src/plugins/http/inc/httpLog.h
index a940dcf6ec..3712360a1c 100644
--- a/src/plugins/http/inc/httpLog.h
+++ b/src/plugins/http/inc/httpLog.h
@@ -20,10 +20,14 @@
extern int32_t httpDebugFlag;
-#define httpError(...) { if (httpDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR HTP ", 255, __VA_ARGS__); }}
-#define httpWarn(...) { if (httpDebugFlag & DEBUG_WARN) { taosPrintLog("WARN HTP ", httpDebugFlag, __VA_ARGS__); }}
-#define httpTrace(...) { if (httpDebugFlag & DEBUG_TRACE) { taosPrintLog("HTP ", httpDebugFlag, __VA_ARGS__); }}
-#define httpDump(...) { if (httpDebugFlag & DEBUG_TRACE) { taosPrintLongString("HTP ", httpDebugFlag, __VA_ARGS__); }}
-#define httpPrint(...) { taosPrintLog("HTP ", 255, __VA_ARGS__); }
+#define httpFatal(...) { if (httpDebugFlag & DEBUG_FATAL) { taosPrintLog("HTP FATAL ", 255, __VA_ARGS__); }}
+#define httpError(...) { if (httpDebugFlag & DEBUG_ERROR) { taosPrintLog("HTP ERROR ", 255, __VA_ARGS__); }}
+#define httpWarn(...) { if (httpDebugFlag & DEBUG_WARN) { taosPrintLog("HTP WARN ", 255, __VA_ARGS__); }}
+#define httpInfo(...) { if (httpDebugFlag & DEBUG_INFO) { taosPrintLog("HTP INFO ", 255, __VA_ARGS__); }}
+#define httpDebug(...) { if (httpDebugFlag & DEBUG_DEBUG) { taosPrintLog("HTP DEBUG ", httpDebugFlag, __VA_ARGS__); }}
+#define httpTrace(...) { if (httpDebugFlag & DEBUG_TRACE) { taosPrintLog("HTP TRACE ", httpDebugFlag, __VA_ARGS__); }}
+
+#define httpDebugDump(...) { if (httpDebugFlag & DEBUG_DEBUG) { taosPrintLongString("HTP DEBUG ", httpDebugFlag, __VA_ARGS__); }}
+#define httpTraceDump(...) { if (httpDebugFlag & DEBUG_TRACE) { taosPrintLongString("HTP TRACE ", httpDebugFlag, __VA_ARGS__); }}
#endif
diff --git a/src/plugins/http/src/gcHandle.c b/src/plugins/http/src/gcHandle.c
index 20cd19df9d..72b73b4bad 100644
--- a/src/plugins/http/src/gcHandle.c
+++ b/src/plugins/http/src/gcHandle.c
@@ -67,7 +67,7 @@ bool gcGetPassFromUrl(HttpContext* pContext) {
}
bool gcProcessLoginRequest(HttpContext* pContext) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process grafana login msg", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process grafana login msg", pContext, pContext->fd, pContext->ipstr,
pContext->user);
pContext->reqType = HTTP_REQTYPE_LOGIN;
return true;
@@ -143,7 +143,7 @@ bool gcProcessLoginRequest(HttpContext* pContext) {
//}]
bool gcProcessQueryRequest(HttpContext* pContext) {
- httpTrace("context:%p, fd:%d, ip:%s, process grafana query msg", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, process grafana query msg", pContext, pContext->fd, pContext->ipstr);
HttpParser* pParser = &pContext->parser;
char* filter = pParser->data.pos;
@@ -183,7 +183,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
cJSON* refId = cJSON_GetObjectItem(query, "refId");
if (refId == NULL || refId->valuestring == NULL || strlen(refId->valuestring) == 0) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, refId is null", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, refId is null", pContext, pContext->fd, pContext->ipstr,
pContext->user);
continue;
}
@@ -211,7 +211,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
cJSON* sql = cJSON_GetObjectItem(query, "sql");
if (sql == NULL || sql->valuestring == NULL || strlen(sql->valuestring) == 0) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, sql is null", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, sql is null", pContext, pContext->fd, pContext->ipstr,
pContext->user);
continue;
}
@@ -251,7 +251,7 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
}
bool gcProcessHeartbeatRequest(HttpContext* pContext) {
- httpTrace("context:%p, fd:%d, ip:%s, process grafana heartbeat msg", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, process grafana heartbeat msg", pContext, pContext->fd, pContext->ipstr);
pContext->reqType = HTTP_REQTYPE_HEARTBEAT;
pContext->encodeMethod = &gcHeartBeatMethod;
return true;
diff --git a/src/plugins/http/src/httpAuth.c b/src/plugins/http/src/httpAuth.c
index 69630336a2..ea7024fad6 100644
--- a/src/plugins/http/src/httpAuth.c
+++ b/src/plugins/http/src/httpAuth.c
@@ -63,7 +63,7 @@ bool httpParseBasicAuthToken(HttpContext *pContext, char *token, int len) {
pContext->pass[pass_len] = 0;
free(base64);
- httpTrace("context:%p, fd:%d, ip:%s, basic token parsed success, user:%s", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, basic token parsed success, user:%s", pContext, pContext->fd, pContext->ipstr,
pContext->user);
return true;
}
@@ -93,7 +93,7 @@ bool httpParseTaosdAuthToken(HttpContext *pContext, char *token, int len) {
tstrncpy(pContext->user, descrypt, sizeof(pContext->user));
tstrncpy(pContext->pass, descrypt + TSDB_USER_LEN, sizeof(pContext->pass));
- httpTrace("context:%p, fd:%d, ip:%s, taosd token:%s parsed success, user:%s", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, taosd token:%s parsed success, user:%s", pContext, pContext->fd,
pContext->ipstr, token, pContext->user);
free(base64);
free(descrypt);
@@ -116,7 +116,7 @@ bool httpGenTaosdAuthToken(HttpContext *pContext, char *token, int maxLen) {
free(encrypt);
free(base64);
- httpTrace("context:%p, fd:%d, ip:%s, gen taosd token:%s", pContext, pContext->fd, pContext->ipstr, token);
+ httpDebug("context:%p, fd:%d, ip:%s, gen taosd token:%s", pContext, pContext->fd, pContext->ipstr, token);
return true;
}
diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c
index a9082be708..b078be5930 100644
--- a/src/plugins/http/src/httpContext.c
+++ b/src/plugins/http/src/httpContext.c
@@ -53,7 +53,7 @@ static void httpDestroyContext(void *data) {
httpFreeJsonBuf(pContext);
httpFreeMultiCmds(pContext);
- httpTrace("context:%p, is destroyed, refCount:%d", pContext, pContext->refCount);
+ httpDebug("context:%p, is destroyed, refCount:%d", pContext, pContext->refCount);
tfree(pContext);
}
@@ -70,7 +70,7 @@ bool httpInitContexts() {
void httpCleanupContexts() {
if (tsHttpServer.contextCache != NULL) {
SCacheObj *cache = tsHttpServer.contextCache;
- httpPrint("context cache is cleanuping, size:%zu", taosHashGetSize(cache->pHashTable));
+ httpInfo("context cache is cleanuping, size:%zu", taosHashGetSize(cache->pHashTable));
taosCacheCleanup(tsHttpServer.contextCache);
tsHttpServer.contextCache = NULL;
}
@@ -113,7 +113,7 @@ HttpContext *httpCreateContext(int32_t fd) {
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, contextStr, &pContext, sizeof(HttpContext *), 3);
pContext->ppContext = ppContext;
- httpTrace("context:%p, fd:%d, is created, item:%p", pContext, fd, ppContext);
+ httpDebug("context:%p, fd:%d, is created, item:%p", pContext, fd, ppContext);
// set the ref to 0
taosCacheRelease(tsHttpServer.contextCache, (void**)&ppContext, false);
@@ -131,7 +131,7 @@ HttpContext *httpGetContext(void *ptr) {
HttpContext *pContext = *ppContext;
if (pContext) {
int32_t refCount = atomic_add_fetch_32(&pContext->refCount, 1);
- httpTrace("context:%p, fd:%d, is accquired, refCount:%d", pContext, pContext->fd, refCount);
+ httpDebug("context:%p, fd:%d, is accquired, refCount:%d", pContext, pContext->fd, refCount);
return pContext;
}
}
@@ -141,7 +141,7 @@ HttpContext *httpGetContext(void *ptr) {
void httpReleaseContext(HttpContext *pContext) {
int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1);
assert(refCount >= 0);
- httpTrace("context:%p, fd:%d, is releasd, refCount:%d", pContext, pContext->fd, refCount);
+ httpDebug("context:%p, fd:%d, is releasd, refCount:%d", pContext, pContext->fd, refCount);
HttpContext **ppContext = pContext->ppContext;
taosCacheRelease(tsHttpServer.contextCache, (void **)(&ppContext), false);
@@ -164,7 +164,7 @@ bool httpInitContext(HttpContext *pContext) {
memset(pParser, 0, sizeof(HttpParser));
pParser->pCur = pParser->pLast = pParser->buffer;
- httpTrace("context:%p, fd:%d, ip:%s, thread:%s, accessTimes:%d, parsed:%d",
+ httpDebug("context:%p, fd:%d, ip:%s, thread:%s, accessTimes:%d, parsed:%d",
pContext, pContext->fd, pContext->ipstr, pContext->pThread->label, pContext->accessTimes, pContext->parsed);
return true;
}
@@ -181,18 +181,18 @@ void httpCloseContextByApp(HttpContext *pContext) {
if (keepAlive) {
if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_HANDLING, HTTP_CONTEXT_STATE_READY)) {
- httpTrace("context:%p, fd:%d, ip:%s, last state:handling, keepAlive:true, reuse connect",
+ httpDebug("context:%p, fd:%d, ip:%s, last state:handling, keepAlive:true, reuse connect",
pContext, pContext->fd, pContext->ipstr);
} else if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_DROPPING, HTTP_CONTEXT_STATE_CLOSED)) {
httpRemoveContextFromEpoll(pContext);
- httpTrace("context:%p, fd:%d, ip:%s, last state:dropping, keepAlive:true, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, last state:dropping, keepAlive:true, close connect",
pContext, pContext->fd, pContext->ipstr);
} else if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) {
- httpTrace("context:%p, fd:%d, ip:%s, last state:ready, keepAlive:true, reuse connect",
+ httpDebug("context:%p, fd:%d, ip:%s, last state:ready, keepAlive:true, reuse connect",
pContext, pContext->fd, pContext->ipstr);
} else if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_CLOSED, HTTP_CONTEXT_STATE_CLOSED)) {
httpRemoveContextFromEpoll(pContext);
- httpTrace("context:%p, fd:%d, ip:%s, last state:ready, keepAlive:true, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, last state:ready, keepAlive:true, close connect",
pContext, pContext->fd, pContext->ipstr);
} else {
httpRemoveContextFromEpoll(pContext);
@@ -201,7 +201,7 @@ void httpCloseContextByApp(HttpContext *pContext) {
}
} else {
httpRemoveContextFromEpoll(pContext);
- httpTrace("context:%p, fd:%d, ip:%s, last state:%s:%d, keepAlive:false, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, last state:%s:%d, keepAlive:false, close connect",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), pContext->state);
}
@@ -210,13 +210,13 @@ void httpCloseContextByApp(HttpContext *pContext) {
void httpCloseContextByServer(HttpContext *pContext) {
if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_HANDLING, HTTP_CONTEXT_STATE_DROPPING)) {
- httpTrace("context:%p, fd:%d, ip:%s, epoll finished, still used by app", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, epoll finished, still used by app", pContext, pContext->fd, pContext->ipstr);
} else if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_DROPPING, HTTP_CONTEXT_STATE_DROPPING)) {
- httpTrace("context:%p, fd:%d, ip:%s, epoll already finished, wait app finished", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, epoll already finished, wait app finished", pContext, pContext->fd, pContext->ipstr);
} else if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_CLOSED)) {
- httpTrace("context:%p, fd:%d, ip:%s, epoll finished, close context", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, epoll finished, close context", pContext, pContext->fd, pContext->ipstr);
} else if (httpAlterContextState(pContext, HTTP_CONTEXT_STATE_CLOSED, HTTP_CONTEXT_STATE_CLOSED)) {
- httpTrace("context:%p, fd:%d, ip:%s, epoll finished, will be closed soon", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, epoll finished, will be closed soon", pContext, pContext->fd, pContext->ipstr);
} else {
httpError("context:%p, fd:%d, ip:%s, unknown state:%d", pContext, pContext->fd, pContext->ipstr, pContext->state);
}
diff --git a/src/plugins/http/src/httpHandle.c b/src/plugins/http/src/httpHandle.c
index 0d9b0ea025..758286344a 100644
--- a/src/plugins/http/src/httpHandle.c
+++ b/src/plugins/http/src/httpHandle.c
@@ -124,7 +124,7 @@ bool httpParseHttpVersion(HttpContext* pContext) {
else
pContext->httpVersion = HTTP_VERSION_10;
- httpTrace("context:%p, fd:%d, ip:%s, httpVersion:1.%d", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, httpVersion:1.%d", pContext, pContext->fd, pContext->ipstr,
pContext->httpVersion);
return true;
}
@@ -157,7 +157,7 @@ bool httpGetHttpMethod(HttpContext* pContext) {
pParser->method.pos[pParser->method.len] = 0;
pParser->pLast = pSeek + 1;
- httpTrace("context:%p, fd:%d, ip:%s, httpMethod:%s", pContext, pContext->fd, pContext->ipstr, pParser->method.pos);
+ httpDebug("context:%p, fd:%d, ip:%s, httpMethod:%s", pContext, pContext->fd, pContext->ipstr, pParser->method.pos);
return true;
}
@@ -186,23 +186,23 @@ bool httpParseHead(HttpContext* pContext) {
HttpParser* pParser = &pContext->parser;
if (strncasecmp(pParser->pLast, "Content-Length: ", 16) == 0) {
pParser->data.len = (int32_t)atoi(pParser->pLast + 16);
- httpTrace("context:%p, fd:%d, ip:%s, Content-Length:%d", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, Content-Length:%d", pContext, pContext->fd, pContext->ipstr,
pParser->data.len);
} else if (strncasecmp(pParser->pLast, "Accept-Encoding: ", 17) == 0) {
if (tsHttpEnableCompress && strstr(pParser->pLast + 17, "gzip") != NULL) {
pContext->acceptEncoding = HTTP_COMPRESS_GZIP;
- httpTrace("context:%p, fd:%d, ip:%s, Accept-Encoding:gzip", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, Accept-Encoding:gzip", pContext, pContext->fd, pContext->ipstr);
} else {
pContext->acceptEncoding = HTTP_COMPRESS_IDENTITY;
- httpTrace("context:%p, fd:%d, ip:%s, Accept-Encoding:identity", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, Accept-Encoding:identity", pContext, pContext->fd, pContext->ipstr);
}
} else if (strncasecmp(pParser->pLast, "Content-Encoding: ", 18) == 0) {
if (strstr(pParser->pLast + 18, "gzip") != NULL) {
pContext->contentEncoding = HTTP_COMPRESS_GZIP;
- httpTrace("context:%p, fd:%d, ip:%s, Content-Encoding:gzip", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, Content-Encoding:gzip", pContext, pContext->fd, pContext->ipstr);
} else {
pContext->contentEncoding = HTTP_COMPRESS_IDENTITY;
- httpTrace("context:%p, fd:%d, ip:%s, Content-Encoding:identity", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, Content-Encoding:identity", pContext, pContext->fd, pContext->ipstr);
}
} else if (strncasecmp(pParser->pLast, "Connection: ", 12) == 0) {
if (strncasecmp(pParser->pLast + 12, "Keep-Alive", 10) == 0) {
@@ -210,7 +210,7 @@ bool httpParseHead(HttpContext* pContext) {
} else {
pContext->httpKeepAlive = HTTP_KEEPALIVE_DISABLE;
}
- httpTrace("context:%p, fd:%d, ip:%s, keepAlive:%d", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, keepAlive:%d", pContext, pContext->fd, pContext->ipstr,
pContext->httpKeepAlive);
} else if (strncasecmp(pParser->pLast, "Transfer-Encoding: ", 19) == 0) {
if (strncasecmp(pParser->pLast + 19, "chunked", 7) == 0) {
@@ -281,7 +281,7 @@ bool httpReadChunkedBody(HttpContext* pContext, HttpParser* pParser) {
httpParseChunkedBody(pContext, pParser, false);
return HTTP_CHECK_BODY_SUCCESS;
} else {
- httpTrace("context:%p, fd:%d, ip:%s, chunked body not finished, continue read", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, chunked body not finished, continue read", pContext, pContext->fd, pContext->ipstr);
if (!httpReadDataImp(pContext)) {
httpError("context:%p, fd:%d, ip:%s, read chunked request error", pContext, pContext->fd, pContext->ipstr);
return HTTP_CHECK_BODY_ERROR;
@@ -299,7 +299,7 @@ int httpReadUnChunkedBody(HttpContext* pContext, HttpParser* pParser) {
httpSendErrorResp(pContext, HTTP_PARSE_BODY_ERROR);
return HTTP_CHECK_BODY_ERROR;
} else if (dataReadLen < pParser->data.len) {
- httpTrace("context:%p, fd:%d, ip:%s, un-chunked body not finished, read size:%d dataReadLen:%d < pContext->data.len:%d, continue read",
+ httpDebug("context:%p, fd:%d, ip:%s, un-chunked body not finished, read size:%d dataReadLen:%d < pContext->data.len:%d, continue read",
pContext, pContext->fd, pContext->ipstr, pContext->parser.bufsize, dataReadLen, pParser->data.len);
return HTTP_CHECK_BODY_CONTINUE;
} else {
@@ -313,7 +313,7 @@ bool httpParseRequest(HttpContext* pContext) {
return true;
}
- httpTrace("context:%p, fd:%d, ip:%s, thread:%s, numOfFds:%d, read size:%d, raw data:\n%s",
+ httpDebug("context:%p, fd:%d, ip:%s, thread:%s, numOfFds:%d, read size:%d, raw data:\n%s",
pContext, pContext->fd, pContext->ipstr, pContext->pThread->label, pContext->pThread->numOfFds,
pContext->parser.bufsize, pContext->parser.buffer);
@@ -351,7 +351,7 @@ bool httpParseRequest(HttpContext* pContext) {
pParser->pLast = ++pParser->pCur;
} while (1);
- httpTrace("context:%p, fd:%d, ip:%s, parse http head ok", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, parse http head ok", pContext, pContext->fd, pContext->ipstr);
pContext->parsed = true;
return true;
@@ -389,7 +389,7 @@ bool httpDecodeRequest(HttpContext* pContext) {
bool httpProcessData(HttpContext* pContext) {
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_HANDLING)) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s not in ready state, stop process request",
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s not in ready state, stop process request",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state));
httpCloseContextByApp(pContext);
return false;
@@ -397,7 +397,7 @@ bool httpProcessData(HttpContext* pContext) {
// handle Cross-domain request
if (strcmp(pContext->parser.method.pos, "OPTIONS") == 0) {
- httpTrace("context:%p, fd:%d, ip:%s, process options request", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, process options request", pContext, pContext->fd, pContext->ipstr);
httpSendOptionResp(pContext, "process options request success");
} else {
if (!httpDecodeRequest(pContext)) {
diff --git a/src/plugins/http/src/httpJson.c b/src/plugins/http/src/httpJson.c
index 7b49b06571..319d87d496 100644
--- a/src/plugins/http/src/httpJson.c
+++ b/src/plugins/http/src/httpJson.c
@@ -52,13 +52,13 @@ int httpWriteBufByFd(struct HttpContext* pContext, const char* buf, int sz) {
}
if (len < 0) {
- httpTrace("context:%p, fd:%d, ip:%s, socket write errno:%d, times:%d",
+ httpDebug("context:%p, fd:%d, ip:%s, socket write errno:%d, times:%d",
pContext, pContext->fd, pContext->ipstr, errno, countWait);
if (++countWait > HTTP_WRITE_RETRY_TIMES) break;
taosMsleep(HTTP_WRITE_WAIT_TIME_MS);
continue;
} else if (len == 0) {
- httpTrace("context:%p, fd:%d, ip:%s, socket write errno:%d, connect already closed",
+ httpDebug("context:%p, fd:%d, ip:%s, socket write errno:%d, connect already closed",
pContext, pContext->fd, pContext->ipstr, errno);
break;
} else {
@@ -76,7 +76,7 @@ int httpWriteBuf(struct HttpContext *pContext, const char *buf, int sz) {
httpError("context:%p, fd:%d, ip:%s, dataSize:%d, writeSize:%d, failed to send response:\n%s",
pContext, pContext->fd, pContext->ipstr, sz, writeSz, buf);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, dataSize:%d, writeSize:%d, response:\n%s",
+ httpDebug("context:%p, fd:%d, ip:%s, dataSize:%d, writeSize:%d, response:\n%s",
pContext, pContext->fd, pContext->ipstr, sz, writeSz, buf);
}
@@ -99,7 +99,7 @@ int httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) {
uint64_t srcLen = (uint64_t) (buf->lst - buf->buf);
if (buf->pContext->fd <= 0) {
- httpTrace("context:%p, fd:%d, ip:%s, write json body error", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, write json body error", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
buf->pContext->fd = -1;
}
@@ -113,11 +113,11 @@ int httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) {
if (buf->pContext->acceptEncoding == HTTP_COMPRESS_IDENTITY) {
if (buf->lst == buf->buf) {
- httpTrace("context:%p, fd:%d, ip:%s, no data need dump", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, no data need dump", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
return 0; // there is no data to dump.
} else {
int len = sprintf(sLen, "%lx\r\n", srcLen);
- httpTrace("context:%p, fd:%d, ip:%s, write body, chunkSize:%" PRIu64 ", response:\n%s",
+ httpDebug("context:%p, fd:%d, ip:%s, write body, chunkSize:%" PRIu64 ", response:\n%s",
buf->pContext, buf->pContext->fd, buf->pContext->ipstr, srcLen, buf->buf);
httpWriteBufNoTrace(buf->pContext, sLen, len);
remain = httpWriteBufNoTrace(buf->pContext, buf->buf, (int) srcLen);
@@ -129,12 +129,12 @@ int httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) {
if (ret == 0) {
if (compressBufLen > 0) {
int len = sprintf(sLen, "%x\r\n", compressBufLen);
- httpTrace("context:%p, fd:%d, ip:%s, write body, chunkSize:%" PRIu64 ", compressSize:%d, last:%d, response:\n%s",
+ httpDebug("context:%p, fd:%d, ip:%s, write body, chunkSize:%" PRIu64 ", compressSize:%d, last:%d, response:\n%s",
buf->pContext, buf->pContext->fd, buf->pContext->ipstr, srcLen, compressBufLen, isTheLast, buf->buf);
httpWriteBufNoTrace(buf->pContext, sLen, len);
remain = httpWriteBufNoTrace(buf->pContext, (const char *) compressBuf, (int) compressBufLen);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, last:%d, compress already dumped, response:\n%s",
+ httpDebug("context:%p, fd:%d, ip:%s, last:%d, compress already dumped, response:\n%s",
buf->pContext, buf->pContext->fd, buf->pContext->ipstr, isTheLast, buf->buf);
return 0; // there is no data to dump.
}
@@ -173,7 +173,7 @@ void httpWriteJsonBufHead(JsonBuf* buf) {
void httpWriteJsonBufEnd(JsonBuf* buf) {
if (buf->pContext->fd <= 0) {
- httpTrace("context:%p, fd:%d, ip:%s, json buf fd is 0", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, json buf fd is 0", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
buf->pContext->fd = -1;
}
@@ -192,7 +192,7 @@ void httpInitJsonBuf(JsonBuf* buf, struct HttpContext* pContext) {
httpGzipCompressInit(buf->pContext);
}
- httpTrace("context:%p, fd:%d, ip:%s, json buffer initialized", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, json buffer initialized", buf->pContext, buf->pContext->fd, buf->pContext->ipstr);
}
void httpJsonItemToken(JsonBuf* buf) {
diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c
index 684f77e7d8..cef0e80690 100644
--- a/src/plugins/http/src/httpServer.c
+++ b/src/plugins/http/src/httpServer.c
@@ -68,7 +68,7 @@ void httpCleanUpConnect() {
tfree(pServer->pThreads);
pServer->pThreads = NULL;
- httpTrace("http server:%s is cleaned up", pServer->label);
+ httpDebug("http server:%s is cleaned up", pServer->label);
}
bool httpReadDataImp(HttpContext *pContext) {
@@ -81,7 +81,7 @@ bool httpReadDataImp(HttpContext *pContext) {
break;
} else if (nread < 0) {
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
- httpTrace("context:%p, fd:%d, ip:%s, read from socket error:%d, wait another event",
+ httpDebug("context:%p, fd:%d, ip:%s, read from socket error:%d, wait another event",
pContext, pContext->fd, pContext->ipstr, errno);
break;
} else {
@@ -109,7 +109,7 @@ bool httpReadDataImp(HttpContext *pContext) {
static bool httpDecompressData(HttpContext *pContext) {
if (pContext->contentEncoding != HTTP_COMPRESS_GZIP) {
- httpDump("context:%p, fd:%d, ip:%s, content:%s", pContext, pContext->fd, pContext->ipstr, pContext->parser.data.pos);
+ httpTraceDump("context:%p, fd:%d, ip:%s, content:%s", pContext, pContext->fd, pContext->ipstr, pContext->parser.data.pos);
return true;
}
@@ -125,7 +125,7 @@ static bool httpDecompressData(HttpContext *pContext) {
if (ret == 0) {
memcpy(pContext->parser.data.pos, decompressBuf, decompressBufLen);
pContext->parser.data.pos[decompressBufLen] = 0;
- httpDump("context:%p, fd:%d, ip:%s, rawSize:%d, decompressSize:%d, content:%s",
+ httpTraceDump("context:%p, fd:%d, ip:%s, rawSize:%d, decompressSize:%d, content:%s",
pContext, pContext->fd, pContext->ipstr, pContext->parser.data.len, decompressBufLen, decompressBuf);
pContext->parser.data.len = decompressBufLen;
} else {
@@ -154,10 +154,10 @@ static bool httpReadData(HttpContext *pContext) {
int ret = httpCheckReadCompleted(pContext);
if (ret == HTTP_CHECK_BODY_CONTINUE) {
- //httpTrace("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr);
+ //httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr);
return false;
} else if (ret == HTTP_CHECK_BODY_SUCCESS){
- httpTrace("context:%p, fd:%d, ip:%s, thread:%s, read size:%d, dataLen:%d",
+ httpDebug("context:%p, fd:%d, ip:%s, thread:%s, read size:%d, dataLen:%d",
pContext, pContext->fd, pContext->ipstr, pContext->pThread->label, pContext->parser.bufsize, pContext->parser.data.len);
if (httpDecompressData(pContext)) {
return true;
@@ -188,7 +188,7 @@ static void httpProcessHttpData(void *param) {
//-1 means uncertainty, 0-nowait, 1-wait 1 ms, set it from -1 to 1
fdNum = epoll_wait(pThread->pollFd, events, HTTP_MAX_EVENTS, 1);
if (pThread->stop) {
- httpTrace("%p, http thread get stop event, exiting...", pThread);
+ httpDebug("%p, http thread get stop event, exiting...", pThread);
break;
}
if (fdNum <= 0) continue;
@@ -203,42 +203,42 @@ static void httpProcessHttpData(void *param) {
}
if (events[i].events & EPOLLPRI) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s, EPOLLPRI events occured, accessed:%d, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s, EPOLLPRI events occured, accessed:%d, close connect",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), pContext->accessTimes);
httpCloseContextByServer(pContext);
continue;
}
if (events[i].events & EPOLLRDHUP) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s, EPOLLRDHUP events occured, accessed:%d, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s, EPOLLRDHUP events occured, accessed:%d, close connect",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), pContext->accessTimes);
httpCloseContextByServer(pContext);
continue;
}
if (events[i].events & EPOLLERR) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s, EPOLLERR events occured, accessed:%d, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s, EPOLLERR events occured, accessed:%d, close connect",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), pContext->accessTimes);
httpCloseContextByServer(pContext);
continue;
}
if (events[i].events & EPOLLHUP) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s, EPOLLHUP events occured, accessed:%d, close connect",
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s, EPOLLHUP events occured, accessed:%d, close connect",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), pContext->accessTimes);
httpCloseContextByServer(pContext);
continue;
}
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s, not in ready state, ignore read events",
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s, not in ready state, ignore read events",
pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state));
httpReleaseContext(pContext);
continue;
}
if (pServer->status != HTTP_SERVER_RUNNING) {
- httpTrace("context:%p, fd:%d, ip:%s, state:%s, server is not running, accessed:%d, close connect", pContext,
+ httpDebug("context:%p, fd:%d, ip:%s, state:%s, server is not running, accessed:%d, close connect", pContext,
pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), pContext->accessTimes);
httpSendErrorResp(pContext, HTTP_SERVER_OFFLINE);
httpNotifyContextClose(pContext);
@@ -273,7 +273,7 @@ static void *httpAcceptHttpConnection(void *arg) {
taosIpStr(pServer->serverIp), pServer->serverPort, strerror(errno));
return NULL;
} else {
- httpPrint("http server init success at %u", pServer->serverPort);
+ httpInfo("http server init success at %u", pServer->serverPort);
pServer->status = HTTP_SERVER_RUNNING;
}
@@ -282,7 +282,7 @@ static void *httpAcceptHttpConnection(void *arg) {
connFd = (int)accept(pServer->fd, (struct sockaddr *)&clientAddr, &addrlen);
if (connFd == -1) {
if (errno == EINVAL) {
- httpTrace("http server:%s socket was shutdown, exiting...", pServer->label);
+ httpDebug("http server:%s socket was shutdown, exiting...", pServer->label);
break;
}
httpError("http server:%s, accept connect failure, errno:%d reason:%s", pServer->label, errno, strerror(errno));
@@ -331,7 +331,7 @@ static void *httpAcceptHttpConnection(void *arg) {
// notify the data process, add into the FdObj list
atomic_add_fetch_32(&pThread->numOfFds, 1);
- httpTrace("context:%p, fd:%d, ip:%s, thread:%s numOfFds:%d totalFds:%d, accept a new connection", pContext, connFd,
+ httpDebug("context:%p, fd:%d, ip:%s, thread:%s numOfFds:%d totalFds:%d, accept a new connection", pContext, connFd,
pContext->ipstr, pThread->label, pThread->numOfFds, totalFds);
// pick up next thread for next connection
@@ -365,6 +365,7 @@ bool httpInitConnect() {
pThread->pollFd = epoll_create(HTTP_MAX_EVENTS); // size does not matter
if (pThread->pollFd < 0) {
httpError("http thread:%s, failed to create HTTP epoll", pThread->label);
+ pthread_mutex_destroy(&(pThread->threadMutex));
return false;
}
@@ -374,11 +375,12 @@ bool httpInitConnect() {
if (pthread_create(&(pThread->thread), &thattr, (void *)httpProcessHttpData, (void *)(pThread)) != 0) {
httpError("http thread:%s, failed to create HTTP process data thread, reason:%s", pThread->label,
strerror(errno));
+ pthread_mutex_destroy(&(pThread->threadMutex));
return false;
}
pthread_attr_destroy(&thattr);
- httpTrace("http thread:%p:%s, initialized", pThread, pThread->label);
+ httpDebug("http thread:%p:%s, initialized", pThread, pThread->label);
pThread++;
}
@@ -387,11 +389,12 @@ bool httpInitConnect() {
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
if (pthread_create(&(pServer->thread), &thattr, (void *)httpAcceptHttpConnection, (void *)(pServer)) != 0) {
httpError("http server:%s, failed to create Http accept thread, reason:%s", pServer->label, strerror(errno));
+ httpCleanUpConnect();
return false;
}
pthread_attr_destroy(&thattr);
- httpTrace("http server:%s, initialized, ip:%s:%u, numOfThreads:%d", pServer->label, taosIpStr(pServer->serverIp),
+ httpDebug("http server:%s, initialized, ip:%s:%u, numOfThreads:%d", pServer->label, taosIpStr(pServer->serverIp),
pServer->serverPort, pServer->numOfThreads);
return true;
}
diff --git a/src/plugins/http/src/httpSession.c b/src/plugins/http/src/httpSession.c
index e0fc708fa5..83602e1291 100644
--- a/src/plugins/http/src/httpSession.c
+++ b/src/plugins/http/src/httpSession.c
@@ -47,7 +47,7 @@ void httpCreateSession(HttpContext *pContext, void *taos) {
return;
}
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, create a new session:%p:%p sessionRef:%d", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, create a new session:%p:%p sessionRef:%d", pContext, pContext->fd,
pContext->ipstr, pContext->user, pContext->session, pContext->session->taos, pContext->session->refCount);
pthread_mutex_unlock(&server->serverMutex);
}
@@ -62,10 +62,10 @@ static void httpFetchSessionImp(HttpContext *pContext) {
pContext->session = taosCacheAcquireByName(server->sessionCache, sessionId);
if (pContext->session != NULL) {
atomic_add_fetch_32(&pContext->session->refCount, 1);
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, find an exist session:%p:%p, sessionRef:%d", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, find an exist session:%p:%p, sessionRef:%d", pContext, pContext->fd,
pContext->ipstr, pContext->user, pContext->session, pContext->session->taos, pContext->session->refCount);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, session not found", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, session not found", pContext, pContext->fd, pContext->ipstr,
pContext->user);
}
@@ -88,7 +88,7 @@ void httpReleaseSession(HttpContext *pContext) {
int32_t refCount = atomic_sub_fetch_32(&pContext->session->refCount, 1);
assert(refCount >= 0);
- httpTrace("context:%p, release session:%p:%p, sessionRef:%d", pContext, pContext->session, pContext->session->taos,
+ httpDebug("context:%p, release session:%p:%p, sessionRef:%d", pContext, pContext->session, pContext->session->taos,
pContext->session->refCount);
taosCacheRelease(tsHttpServer.sessionCache, (void **)&pContext->session, false);
@@ -97,7 +97,7 @@ void httpReleaseSession(HttpContext *pContext) {
static void httpDestroySession(void *data) {
HttpSession *session = data;
- httpTrace("session:%p:%p, is destroyed, sessionRef:%d", session, session->taos, session->refCount);
+ httpDebug("session:%p:%p, is destroyed, sessionRef:%d", session, session->taos, session->refCount);
if (session->taos != NULL) {
taos_close(session->taos);
@@ -108,7 +108,7 @@ static void httpDestroySession(void *data) {
void httpCleanUpSessions() {
if (tsHttpServer.sessionCache != NULL) {
SCacheObj *cache = tsHttpServer.sessionCache;
- httpPrint("session cache is cleanuping, size:%zu", taosHashGetSize(cache->pHashTable));
+ httpInfo("session cache is cleanuping, size:%zu", taosHashGetSize(cache->pHashTable));
taosCacheCleanup(tsHttpServer.sessionCache);
tsHttpServer.sessionCache = NULL;
}
diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c
index 9d58454460..d0e9b005fd 100644
--- a/src/plugins/http/src/httpSql.c
+++ b/src/plugins/http/src/httpSql.c
@@ -49,11 +49,11 @@ void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numO
if (isContinue) {
// retrieve next batch of rows
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, continue retrieve, numOfRows:%d, sql:%s",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, continue retrieve, numOfRows:%d, sql:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, multiCmds->pos, numOfRows, sql);
taos_fetch_rows_a(result, httpProcessMultiSqlRetrieveCallBack, param);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, stop retrieve, numOfRows:%d, sql:%s",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, stop retrieve, numOfRows:%d, sql:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, multiCmds->pos, numOfRows, sql);
if (numOfRows < 0) {
@@ -90,7 +90,7 @@ void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int code) {
if (code < 0) {
if (encode->checkFinishedFp != NULL && !encode->checkFinishedFp(pContext, singleCmd, code)) {
singleCmd->code = code;
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process pos jump to:%d, last code:%s, last sql:%s",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos jump to:%d, last code:%s, last sql:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, multiCmds->pos + 1, tstrerror(code), sql);
} else {
singleCmd->code = code;
@@ -113,7 +113,7 @@ void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int code) {
if (num_fields == 0) {
// not select or show commands
int affectRows = taos_affected_rows(result);
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, affect rows:%d, sql:%s",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, affect rows:%d, sql:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, multiCmds->pos, affectRows, sql);
singleCmd->code = 0;
@@ -139,7 +139,7 @@ void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int code) {
taos_free_result(result);
httpProcessMultiSql(pContext);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start retrieve, sql:%s",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start retrieve, sql:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, multiCmds->pos, sql);
if (singleCmd->cmdReturnType == HTTP_CMD_RETURN_TYPE_WITH_RETURN && encode->startJsonFp) {
@@ -154,7 +154,7 @@ void httpProcessMultiSql(HttpContext *pContext) {
HttpEncodeMethod *encode = pContext->encodeMethod;
if (multiCmds->pos >= multiCmds->size) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, size:%d, stop mulit-querys",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, size:%d, stop mulit-querys",
pContext, pContext->fd, pContext->ipstr, pContext->user, multiCmds->pos, multiCmds->size);
if (encode->cleanJsonFp) {
(encode->cleanJsonFp)(pContext);
@@ -166,7 +166,7 @@ void httpProcessMultiSql(HttpContext *pContext) {
HttpSqlCmd *cmd = multiCmds->cmds + multiCmds->pos;
char *sql = httpGetCmdsString(pContext, cmd->sql);
- httpDump("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start query, sql:%s", pContext, pContext->fd,
+ httpTraceDump("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, start query, sql:%s", pContext, pContext->fd,
pContext->ipstr, pContext->user, multiCmds->pos, sql);
taosNotePrintHttp(sql);
taos_query_a(pContext->session->taos, sql, httpProcessMultiSqlCallBack, (void *)pContext);
@@ -181,7 +181,7 @@ void httpProcessMultiSqlCmd(HttpContext *pContext) {
return;
}
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, start multi-querys pos:%d, size:%d", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, start multi-querys pos:%d, size:%d", pContext, pContext->fd,
pContext->ipstr, pContext->user, multiCmds->pos, multiCmds->size);
HttpEncodeMethod *encode = pContext->encodeMethod;
if (encode->initJsonFp) {
@@ -211,11 +211,11 @@ void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int num
if (isContinue) {
// retrieve next batch of rows
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, continue retrieve, numOfRows:%d", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, continue retrieve, numOfRows:%d", pContext, pContext->fd,
pContext->ipstr, pContext->user, numOfRows);
taos_fetch_rows_a(result, httpProcessSingleSqlRetrieveCallBack, param);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, stop retrieve, numOfRows:%d", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, stop retrieve, numOfRows:%d", pContext, pContext->fd, pContext->ipstr,
pContext->user, numOfRows);
if (numOfRows < 0) {
@@ -265,7 +265,7 @@ void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int code) {
// not select or show commands
int affectRows = taos_affected_rows(result);
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, affect rows:%d, stop query, sqlObj:%p",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, affect rows:%d, stop query, sqlObj:%p",
pContext, pContext->fd, pContext->ipstr, pContext->user, affectRows, result);
if (encode->startJsonFp) {
@@ -283,7 +283,7 @@ void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int code) {
taos_free_result(result);
httpCloseContextByApp(pContext);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, start retrieve", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, start retrieve", pContext, pContext->fd, pContext->ipstr,
pContext->user);
if (encode->startJsonFp) {
@@ -306,7 +306,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) {
return;
}
- httpDump("context:%p, fd:%d, ip:%s, user:%s, start query, sql:%s", pContext, pContext->fd, pContext->ipstr,
+ httpTraceDump("context:%p, fd:%d, ip:%s, user:%s, start query, sql:%s", pContext, pContext->fd, pContext->ipstr,
pContext->user, sql);
taosNotePrintHttp(sql);
taos_query_a(pSession->taos, sql, httpProcessSingleSqlCallBack, (void *)pContext);
@@ -317,7 +317,7 @@ void httpProcessLoginCmd(HttpContext *pContext) {
if (!httpGenTaosdAuthToken(pContext, token, 128)) {
httpSendErrorResp(pContext, HTTP_GEN_TAOSD_TOKEN_ERR);
} else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, login via http, return token:%s",
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, login via http, return token:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, token);
httpSendSuccResp(pContext, token);
}
@@ -368,7 +368,7 @@ void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
return;
}
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, connect tdengine success, taos:%p", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, connect tdengine success, taos:%p", pContext, pContext->fd,
pContext->ipstr, pContext->user, pContext->taos);
if (pContext->taos == NULL) {
httpError("context:%p, fd:%d, ip:%s, user:%s, login error, taos is empty", pContext, pContext->fd, pContext->ipstr,
@@ -393,7 +393,7 @@ void httpProcessRequest(HttpContext *pContext) {
if (pContext->session == NULL || pContext->reqType == HTTP_REQTYPE_LOGIN) {
taos_connect_a(NULL, pContext->user, pContext->pass, "", 0, httpProcessRequestCb, (void *)pContext,
&(pContext->taos));
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, try connect tdengine, taos:%p", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, try connect tdengine, taos:%p", pContext, pContext->fd,
pContext->ipstr, pContext->user, pContext->taos);
} else {
httpExecCmd(pContext);
diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c
index 015b0783b7..a93e7cd7ad 100644
--- a/src/plugins/http/src/httpSystem.c
+++ b/src/plugins/http/src/httpSystem.c
@@ -60,7 +60,7 @@ int httpInitSystem() {
}
int httpStartSystem() {
- httpPrint("start http server ...");
+ httpInfo("start http server ...");
if (tsHttpServer.status != HTTP_SERVER_INIT) {
httpError("http server is already started");
@@ -92,7 +92,7 @@ void httpStopSystem() {
}
void httpCleanUpSystem() {
- httpPrint("http server cleanup");
+ httpInfo("http server cleanup");
httpStopSystem();
httpCleanupContexts();
diff --git a/src/plugins/http/src/restHandle.c b/src/plugins/http/src/restHandle.c
index 2e04f562ea..f0841e2f99 100644
--- a/src/plugins/http/src/restHandle.c
+++ b/src/plugins/http/src/restHandle.c
@@ -80,14 +80,14 @@ bool restGetPassFromUrl(HttpContext* pContext) {
}
bool restProcessLoginRequest(HttpContext* pContext) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process restful login msg", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process restful login msg", pContext, pContext->fd, pContext->ipstr,
pContext->user);
pContext->reqType = HTTP_REQTYPE_LOGIN;
return true;
}
bool restProcessSqlRequest(HttpContext* pContext, int timestampFmt) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, process restful sql msg", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, process restful sql msg", pContext, pContext->fd, pContext->ipstr,
pContext->user);
char* sql = pContext->parser.data.pos;
diff --git a/src/plugins/http/src/restJson.c b/src/plugins/http/src/restJson.c
index 2d9c31935c..53b0248149 100644
--- a/src/plugins/http/src/restJson.c
+++ b/src/plugins/http/src/restJson.c
@@ -151,7 +151,7 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
}
if (cmd->numOfRows >= tsRestRowLimit) {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, retrieve rows:%d larger than limit:%d, abort retrieve", pContext,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, retrieve rows:%d larger than limit:%d, abort retrieve", pContext,
pContext->fd, pContext->ipstr, pContext->user, cmd->numOfRows, tsRestRowLimit);
return false;
}
@@ -162,7 +162,7 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
return false;
}
else {
- httpTrace("context:%p, fd:%d, ip:%s, user:%s, total rows:%d retrieved", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, user:%s, total rows:%d retrieved", pContext, pContext->fd, pContext->ipstr,
pContext->user, cmd->numOfRows);
return true;
}
diff --git a/src/plugins/http/src/tgHandle.c b/src/plugins/http/src/tgHandle.c
index 17192db3ca..48c66c4c07 100644
--- a/src/plugins/http/src/tgHandle.c
+++ b/src/plugins/http/src/tgHandle.c
@@ -266,7 +266,7 @@ int tgReadSchema(char *fileName) {
return -1;
}
- httpPrint("open telegraf schema file:%s success", fileName);
+ httpInfo("open telegraf schema file:%s success", fileName);
fseek(fp, 0, SEEK_END);
int32_t contentSize = (int32_t)ftell(fp);
if (contentSize <= 0) {
@@ -290,7 +290,7 @@ int tgReadSchema(char *fileName) {
free(content);
fclose(fp);
- httpPrint("parse telegraf schema file:%s, schema size:%d", fileName, schemaNum);
+ httpInfo("parse telegraf schema file:%s, schema size:%d", fileName, schemaNum);
return schemaNum;
}
@@ -800,7 +800,7 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
}
*/
bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
- httpTrace("context:%p, fd:%d, ip:%s, process telegraf query msg", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, process telegraf query msg", pContext, pContext->fd, pContext->ipstr);
HttpParser *pParser = &pContext->parser;
char * filter = pParser->data.pos;
@@ -818,7 +818,7 @@ bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
cJSON *metrics = cJSON_GetObjectItem(root, "metrics");
if (metrics != NULL) {
int size = cJSON_GetArraySize(metrics);
- httpTrace("context:%p, fd:%d, ip:%s, multiple metrics:%d at one time", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, multiple metrics:%d at one time", pContext, pContext->fd, pContext->ipstr,
size);
if (size <= 0) {
httpSendErrorResp(pContext, HTTP_TG_METRICS_NULL);
@@ -859,7 +859,7 @@ bool tgProcessQueryRequest(HttpContext *pContext, char *db) {
}
}
} else {
- httpTrace("context:%p, fd:%d, ip:%s, single metric", pContext, pContext->fd, pContext->ipstr);
+ httpDebug("context:%p, fd:%d, ip:%s, single metric", pContext, pContext->fd, pContext->ipstr);
if (!httpMallocMultiCmds(pContext, 3, HTTP_BUFFER_SIZE)) {
httpSendErrorResp(pContext, HTTP_NO_ENOUGH_MEMORY);
diff --git a/src/plugins/http/src/tgJson.c b/src/plugins/http/src/tgJson.c
index ed33f51d46..ed4ee0d7de 100644
--- a/src/plugins/http/src/tgJson.c
+++ b/src/plugins/http/src/tgJson.c
@@ -98,7 +98,7 @@ void tgBuildSqlAffectRowsJson(HttpContext *pContext, HttpSqlCmd *cmd, int affect
bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
HttpSqlCmds *multiCmds = pContext->multiCmds;
- httpTrace("context:%p, fd:%d, ip:%s, check telegraf command, code:%s, state:%d, type:%d, rettype:%d, tags:%d",
+ httpDebug("context:%p, fd:%d, ip:%s, check telegraf command, code:%s, state:%d, type:%d, rettype:%d, tags:%d",
pContext, pContext->fd, pContext->ipstr, tstrerror(code), cmd->cmdState, cmd->cmdType, cmd->cmdReturnType, cmd->tagNum);
if (cmd->cmdType == HTTP_CMD_TYPE_INSERT) {
@@ -107,7 +107,7 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
cmd->cmdState = HTTP_CMD_STATE_RUN_FINISHED;
if (multiCmds->cmds[0].cmdState == HTTP_CMD_STATE_NOT_RUN_YET) {
multiCmds->pos = (int16_t)-1;
- httpTrace("context:%p, fd:%d, ip:%s, import failed, try create database", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, import failed, try create database", pContext, pContext->fd,
pContext->ipstr);
return false;
}
@@ -115,7 +115,7 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
cmd->cmdState = HTTP_CMD_STATE_RUN_FINISHED;
if (multiCmds->cmds[multiCmds->pos - 1].cmdState == HTTP_CMD_STATE_NOT_RUN_YET) {
multiCmds->pos = (int16_t)(multiCmds->pos - 2);
- httpTrace("context:%p, fd:%d, ip:%s, import failed, try create stable", pContext, pContext->fd,
+ httpDebug("context:%p, fd:%d, ip:%s, import failed, try create stable", pContext, pContext->fd,
pContext->ipstr);
return false;
}
@@ -125,11 +125,11 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
}
} else if (cmd->cmdType == HTTP_CMD_TYPE_CREATE_DB) {
cmd->cmdState = HTTP_CMD_STATE_RUN_FINISHED;
- httpTrace("context:%p, fd:%d, ip:%s, code:%s, create database failed", pContext, pContext->fd, pContext->ipstr,
+ httpDebug("context:%p, fd:%d, ip:%s, code:%s, create database failed", pContext, pContext->fd, pContext->ipstr,
tstrerror(code));
} else if (cmd->cmdType == HTTP_CMD_TYPE_CREATE_STBALE) {
cmd->cmdState = HTTP_CMD_STATE_RUN_FINISHED;
- httpTrace("context:%p, fd:%d, ip:%s, code:%s, create stable failed", pContext, pContext->fd, pContext->ipstr, tstrerror(code));
+ httpDebug("context:%p, fd:%d, ip:%s, code:%s, create stable failed", pContext, pContext->fd, pContext->ipstr, tstrerror(code));
} else {
}
@@ -138,7 +138,7 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
void tgSetNextCmd(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) {
HttpSqlCmds *multiCmds = pContext->multiCmds;
- httpTrace("context:%p, fd:%d, ip:%s, get telegraf next command, pos:%d, code:%s, state:%d, type:%d, rettype:%d, tags:%d",
+ httpDebug("context:%p, fd:%d, ip:%s, get telegraf next command, pos:%d, code:%s, state:%d, type:%d, rettype:%d, tags:%d",
pContext, pContext->fd, pContext->ipstr, multiCmds->pos, tstrerror(code), cmd->cmdState, cmd->cmdType,
cmd->cmdReturnType, cmd->tagNum);
diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c
index 4ea27f4839..11b701e0ea 100644
--- a/src/plugins/monitor/src/monitorMain.c
+++ b/src/plugins/monitor/src/monitorMain.c
@@ -27,10 +27,16 @@
#include "dnode.h"
#include "monitor.h"
-#define monitorError(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MON ", 255, __VA_ARGS__); }}
-#define monitorWarn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MON ", monitorDebugFlag, __VA_ARGS__); }}
-#define monitorTrace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
-#define monitorPrint(...) { taosPrintLog("MON ", 255, __VA_ARGS__); }
+
+#define monitorFatal(...) { if (monitorDebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
+#define monitorError(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
+#define monitorWarn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
+#define monitorInfo(...) { if (monitorDebugFlag & DEBUG_INFO) { taosPrintLog("MON INFO ", 255, __VA_ARGS__); }}
+#define monitorDebug(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON DEBUG ", monitorDebugFlag, __VA_ARGS__); }}
+#define monitorTrace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON TRACE ", monitorDebugFlag, __VA_ARGS__); }}
+
+#define monitorDebugDump(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLongString("MON DEBUG ", monitorDebugFlag, __VA_ARGS__); }}
+#define monitorTraceDump(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLongString("MON TRACE ", monitorDebugFlag, __VA_ARGS__); }}
#define SQL_LENGTH 1024
#define LOG_LEN_STR 100
@@ -86,7 +92,7 @@ int32_t monitorInitSystem() {
}
int32_t monitorStartSystem() {
- monitorPrint("start monitor module");
+ monitorInfo("start monitor module");
monitorInitSystem();
taosTmrReset(monitorInitConn, 10, NULL, tscTmr, &tsMonitorConn.initTimer);
return 0;
@@ -104,7 +110,7 @@ static void monitorInitConn(void *para, void *unused) {
return;
}
- monitorPrint("starting to initialize monitor service ..");
+ monitorInfo("starting to initialize monitor service ..");
tsMonitorConn.state = MONITOR_STATE_INITIALIZING;
if (tsMonitorConn.ep[0] == 0)
@@ -134,7 +140,7 @@ static void monitorInitConnCb(void *param, TAOS_RES *result, int32_t code) {
return;
}
- monitorTrace("monitor:%p, connect to database success, reason:%s", tsMonitorConn.conn, tstrerror(code));
+ monitorDebug("monitor:%p, connect to database success, reason:%s", tsMonitorConn.conn, tstrerror(code));
monitorInitDatabase();
}
@@ -200,7 +206,7 @@ static void monitorInitDatabase() {
taos_query_a(tsMonitorConn.conn, tsMonitorConn.sql, monitorInitDatabaseCb, NULL);
} else {
tsMonitorConn.state = MONITOR_STATE_INITIALIZED;
- monitorPrint("monitor service init success");
+ monitorInfo("monitor service init success");
monitorStartTimer();
}
@@ -208,9 +214,9 @@ static void monitorInitDatabase() {
static void monitorInitDatabaseCb(void *param, TAOS_RES *result, int32_t code) {
if (-code == TSDB_CODE_MND_TABLE_ALREADY_EXIST || -code == TSDB_CODE_MND_DB_ALREADY_EXIST || code >= 0) {
- monitorTrace("monitor:%p, sql success, reason:%s, %s", tsMonitorConn.conn, tstrerror(code), tsMonitorConn.sql);
+ monitorDebug("monitor:%p, sql success, reason:%s, %s", tsMonitorConn.conn, tstrerror(code), tsMonitorConn.sql);
if (tsMonitorConn.cmdIndex == MONITOR_CMD_CREATE_TB_LOG) {
- monitorPrint("dnode:%s is started", tsLocalEp);
+ monitorInfo("dnode:%s is started", tsLocalEp);
}
tsMonitorConn.cmdIndex++;
monitorInitDatabase();
@@ -222,7 +228,7 @@ static void monitorInitDatabaseCb(void *param, TAOS_RES *result, int32_t code) {
}
void monitorStopSystem() {
- monitorPrint("monitor module is stopped");
+ monitorInfo("monitor module is stopped");
tsMonitorConn.state = MONITOR_STATE_STOPPED;
if (tsMonitorConn.initTimer != NULL) {
taosTmrStopA(&(tsMonitorConn.initTimer));
@@ -234,7 +240,7 @@ void monitorStopSystem() {
void monitorCleanUpSystem() {
monitorStopSystem();
- monitorPrint("monitor module cleanup");
+ monitorInfo("monitor module cleanup");
}
static void monitorStartTimer() {
@@ -247,7 +253,7 @@ static void dnodeMontiorInsertAcctCallback(void *param, TAOS_RES *result, int32_
} else if (code == 0) {
monitorError("monitor:%p, save account info failed, affect rows:%d", tsMonitorConn.conn, code);
} else {
- monitorTrace("monitor:%p, save account info success, code:%s", tsMonitorConn.conn, tstrerror(code));
+ monitorDebug("monitor:%p, save account info success, code:%s", tsMonitorConn.conn, tstrerror(code));
}
}
@@ -257,7 +263,7 @@ static void dnodeMontiorInsertSysCallback(void *param, TAOS_RES *result, int32_t
} else if (code == 0) {
monitorError("monitor:%p, save system info failed, affect rows:%d %s", tsMonitorConn.conn, code, tsMonitorConn.sql);
} else {
- monitorTrace("monitor:%p, save system info success, code:%s %s", tsMonitorConn.conn, tstrerror(code), tsMonitorConn.sql);
+ monitorDebug("monitor:%p, save system info success, code:%s %s", tsMonitorConn.conn, tstrerror(code), tsMonitorConn.sql);
}
}
@@ -267,7 +273,7 @@ static void dnodeMontiorInsertLogCallback(void *param, TAOS_RES *result, int32_t
} else if (code == 0) {
monitorError("monitor:%p, save log failed, affect rows:%d", tsMonitorConn.conn, code);
} else {
- monitorTrace("monitor:%p, save log info success, code:%s", tsMonitorConn.conn, tstrerror(code));
+ monitorDebug("monitor:%p, save log info success, code:%s", tsMonitorConn.conn, tstrerror(code));
}
}
@@ -351,7 +357,7 @@ static void monitorSaveSystemInfo() {
pos += monitorBuildIoSql(sql + pos);
pos += monitorBuildReqSql(sql + pos);
- monitorTrace("monitor:%p, save system info, sql:%s", tsMonitorConn.conn, sql);
+ monitorDebug("monitor:%p, save system info, sql:%s", tsMonitorConn.conn, sql);
taos_query_a(tsMonitorConn.conn, sql, dnodeMontiorInsertSysCallback, "log");
if (tsMonitorConn.timer != NULL && tsMonitorConn.state != MONITOR_STATE_STOPPED) {
@@ -389,7 +395,7 @@ void monitorSaveAcctLog(SAcctMonitorObj *pMon) {
pMon->totalConns, pMon->maxConns,
pMon->accessState);
- monitorTrace("monitor:%p, save account info, sql %s", tsMonitorConn.conn, sql);
+ monitorDebug("monitor:%p, save account info, sql %s", tsMonitorConn.conn, sql);
taos_query_a(tsMonitorConn.conn, sql, dnodeMontiorInsertAcctCallback, "account");
}
@@ -413,14 +419,14 @@ void monitorSaveLog(int32_t level, const char *const format, ...) {
len += sprintf(sql + len, "', '%s')", tsLocalEp);
sql[len++] = 0;
- monitorTrace("monitor:%p, save log, sql: %s", tsMonitorConn.conn, sql);
+ monitorDebug("monitor:%p, save log, sql: %s", tsMonitorConn.conn, sql);
taos_query_a(tsMonitorConn.conn, sql, dnodeMontiorInsertLogCallback, "log");
}
void monitorExecuteSQL(char *sql) {
if (tsMonitorConn.state != MONITOR_STATE_INITIALIZED) return;
- monitorTrace("monitor:%p, execute sql: %s", tsMonitorConn.conn, sql);
+ monitorDebug("monitor:%p, execute sql: %s", tsMonitorConn.conn, sql);
// bug while insert binary
// taos_query_a(tsMonitorConn.conn, sql, NULL, NULL);
diff --git a/src/plugins/mqtt/inc/mqttLog.h b/src/plugins/mqtt/inc/mqttLog.h
index a7ae2fc1ae..c0515c2c26 100644
--- a/src/plugins/mqtt/inc/mqttLog.h
+++ b/src/plugins/mqtt/inc/mqttLog.h
@@ -10,7 +10,7 @@
* 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 .
+ * along with this program. If not, see .
*/
#ifndef TDENGINE_MQTT_LOG_H
@@ -20,23 +20,14 @@
extern int32_t mqttDebugFlag;
-#define mqttError(...) \
- if (mqttDebugFlag & DEBUG_ERROR) { \
- taosPrintLog("ERROR MQT ", 255, __VA_ARGS__); \
- }
-#define mqttWarn(...) \
- if ( mqttDebugFlag & DEBUG_WARN) { \
- taosPrintLog("WARN MQT ", mqttDebugFlag, __VA_ARGS__); \
- }
-#define mqttTrace(...) \
- if ( mqttDebugFlag & DEBUG_TRACE) { \
- taosPrintLog("MQT ", mqttDebugFlag, __VA_ARGS__); \
- }
-#define mqttDump(...) \
- if ( mqttDebugFlag & DEBUG_TRACE) { \
- taosPrintLongString("MQT ", mqttDebugFlag, __VA_ARGS__); \
- }
-#define mqttPrint(...) \
- { taosPrintLog("MQT ", 255, __VA_ARGS__); }
+#define mqttFatal(...) { if (mqttDebugFlag & DEBUG_FATAL) { taosPrintLog("MQT FATAL ", 255, __VA_ARGS__); }}
+#define mqttError(...) { if (mqttDebugFlag & DEBUG_ERROR) { taosPrintLog("MQT ERROR ", 255, __VA_ARGS__); }}
+#define mqttWarn(...) { if (mqttDebugFlag & DEBUG_WARN) { taosPrintLog("MQT WARN ", 255, __VA_ARGS__); }}
+#define mqttInfo(...) { if (mqttDebugFlag & DEBUG_INFO) { taosPrintLog("MQT INFO ", 255, __VA_ARGS__); }}
+#define mqttDebug(...) { if (mqttDebugFlag & DEBUG_DEBUG) { taosPrintLog("MQT DEBUG ", mqttDebugFlag, __VA_ARGS__); }}
+#define mqttTrace(...) { if (mqttDebugFlag & DEBUG_TRACE) { taosPrintLog("MQT TRACE ", mqttDebugFlag, __VA_ARGS__); }}
+
+#define mqttDebugDump(...) { if (mqttDebugFlag & DEBUG_DEBUG) { taosPrintLongString("MQT DEBUG ", mqttDebugFlag, __VA_ARGS__); }}
+#define mqttTraceDump(...) { if (mqttDebugFlag & DEBUG_TRACE) { taosPrintLongString("MQT DEBUG ", mqttDebugFlag, __VA_ARGS__); }}
#endif
diff --git a/src/plugins/mqtt/src/mqttPayload.c b/src/plugins/mqtt/src/mqttPayload.c
index 5f1d792dab..96c8e71edd 100644
--- a/src/plugins/mqtt/src/mqttPayload.c
+++ b/src/plugins/mqtt/src/mqttPayload.c
@@ -43,7 +43,7 @@ char* converJsonToSql(char* json, char* _dbname, char* _tablename) {
{
cJSON* item = cJSON_GetArrayItem(jPlayload, i);
if (cJSON_Object == item->type) {
- mqttPrint("The item '%s' is not supported", item->string);
+ mqttInfo("The item '%s' is not supported", item->string);
} else {
strcat(_names, item->string);
if (i < count - 1) {
diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c
index f123d153d1..3df62f8bf4 100644
--- a/src/plugins/mqtt/src/mqttSystem.c
+++ b/src/plugins/mqtt/src/mqttSystem.c
@@ -50,7 +50,7 @@ int32_t mqttInitSystem() {
recntStatus.password = strstr(url, "@") != NULL ? strbetween(strstr(url, recntStatus.user_name), ":", "@") : NULL;
if (strlen(url) == 0) {
- mqttTrace("mqtt module not init, url is null");
+ mqttDebug("mqtt module not init, url is null");
return rc;
}
@@ -84,10 +84,10 @@ int32_t mqttInitSystem() {
int32_t mqttStartSystem() {
int rc = 0;
if (recntStatus.user_name != NULL && recntStatus.password != NULL) {
- mqttPrint("connecting to mqtt://%s:%s@%s:%s/%s/", recntStatus.user_name, recntStatus.password,
+ mqttInfo("connecting to mqtt://%s:%s@%s:%s/%s/", recntStatus.user_name, recntStatus.password,
recntStatus.hostname, recntStatus.port, topicPath);
} else if (recntStatus.user_name != NULL && recntStatus.password == NULL) {
- mqttPrint("connecting to mqtt://%s@%s:%s/%s/", recntStatus.user_name, recntStatus.hostname, recntStatus.port,
+ mqttInfo("connecting to mqtt://%s@%s:%s/%s/", recntStatus.user_name, recntStatus.hostname, recntStatus.port,
topicPath);
}
@@ -97,7 +97,7 @@ int32_t mqttStartSystem() {
mqttCleanup(EXIT_FAILURE, -1, NULL);
rc = -1;
} else {
- mqttPrint("listening for '%s' messages.", recntStatus.topic);
+ mqttInfo("listening for '%s' messages.", recntStatus.topic);
}
return rc;
}
@@ -107,18 +107,18 @@ void mqttStopSystem() {
mttIsRuning = 0;
usleep(300000U);
mqttCleanup(EXIT_SUCCESS, mqttClient.socketfd, &clientDaemonThread);
- mqttPrint("mqtt is stoped");
+ mqttInfo("mqtt is stoped");
}
void mqttCleanUpSystem() {
- mqttPrint("starting to clean up mqtt");
+ mqttInfo("starting to clean up mqtt");
free(recntStatus.user_name);
free(recntStatus.password);
free(recntStatus.hostname);
free(recntStatus.port);
free(recntStatus.topic);
free(topicPath);
- mqttPrint("mqtt is cleaned up");
+ mqttInfo("mqtt is cleaned up");
}
void mqtt_PublishCallback(void** unused, struct mqtt_response_publish* published) {
@@ -126,12 +126,12 @@ void mqtt_PublishCallback(void** unused, struct mqtt_response_publish* published
char* topic_name = (char*)malloc(published->topic_name_size + 1);
memcpy(topic_name, published->topic_name, published->topic_name_size);
topic_name[published->topic_name_size] = '\0';
- mqttPrint("received publish('%s'): %s", topic_name, (const char*)published->application_message);
+ mqttInfo("received publish('%s'): %s", topic_name, (const char*)published->application_message);
char _token[128] = {0};
char _dbname[128] = {0};
char _tablename[128] = {0};
if (mqttConnect == NULL) {
- mqttPrint("connect database");
+ mqttInfo("connect database");
taos_connect_a(NULL, "_root", tsInternalPass, "", 0, mqttInitConnCb, &mqttClient, &mqttConnect);
}
if (topic_name[1]=='/' && strncmp((char*)&topic_name[1], topicPath, strlen(topicPath)) == 0) {
@@ -145,14 +145,14 @@ void mqtt_PublishCallback(void** unused, struct mqtt_response_publish* published
strncpy(_token, p_p_cmd_part[1], 127);
strncpy(_dbname, p_p_cmd_part[2], 127);
strncpy(_tablename, p_p_cmd_part[3], 127);
- mqttPrint("part count=%d,access token:%s,database name:%s, table name:%s", part_index, _token, _dbname,
+ mqttInfo("part count=%d,access token:%s,database name:%s, table name:%s", part_index, _token, _dbname,
_tablename);
if (mqttConnect != NULL) {
char* _sql = converJsonToSql((char*)published->application_message, _dbname, _tablename);
- mqttPrint("query:%s", _sql);
+ mqttInfo("query:%s", _sql);
taos_query_a(mqttConnect, _sql, mqttQueryInsertCallback, &mqttClient);
- mqttPrint("free sql:%s", _sql);
+ mqttInfo("free sql:%s", _sql);
free(_sql);
}
}
@@ -165,12 +165,12 @@ void* mqttClientRefresher(void* client) {
mqtt_sync((struct mqtt_client*)client);
taosMsleep(100);
}
- mqttTrace("quit refresher");
+ mqttDebug("quit refresher");
return NULL;
}
void mqttCleanup(int status, int sockfd, pthread_t* client_daemon) {
- mqttPrint("clean up mqtt module");
+ mqttInfo("clean up mqtt module");
if (sockfd != -1) close(sockfd);
if (client_daemon != NULL) pthread_cancel(*client_daemon);
}
@@ -182,7 +182,7 @@ void mqttInitConnCb(void* param, TAOS_RES* result, int32_t code) {
mqttConnect = NULL;
return;
}
- mqttTrace("mqtt:%d, connect to database success, reason:%s", code, tstrerror(code));
+ mqttDebug("mqtt:%d, connect to database success, reason:%s", code, tstrerror(code));
}
void mqttQueryInsertCallback(void* param, TAOS_RES* result, int32_t code) {
@@ -191,12 +191,12 @@ void mqttQueryInsertCallback(void* param, TAOS_RES* result, int32_t code) {
} else if (code == 0) {
mqttError("mqtt:%d, save data failed, affect rows:%d", code, code);
} else {
- mqttPrint("mqtt:%d, save data success, code:%s", code, tstrerror(code));
+ mqttInfo("mqtt:%d, save data success, code:%s", code, tstrerror(code));
}
}
void mqttReconnectClient(struct mqtt_client* client, void** reconnect_state_vptr) {
- mqttPrint("reconnect client");
+ mqttInfo("reconnect client");
struct reconnect_state_t* reconnect_state = *((struct reconnect_state_t**)reconnect_state_vptr);
/* Close the clients socket if this isn't the initial reconnect call */
diff --git a/src/query/inc/queryLog.h b/src/query/inc/queryLog.h
index e92f6abe87..fd1322e995 100644
--- a/src/query/inc/queryLog.h
+++ b/src/query/inc/queryLog.h
@@ -23,10 +23,14 @@ extern "C" {
#include "tlog.h"
extern int32_t qDebugFlag;
+extern int32_t tscEmbedded;
-#define qTrace(...) { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }}
-#define qError(...) { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR QRY ", qDebugFlag, __VA_ARGS__); }}
-#define qWarn(...) { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); }}
+#define qFatal(...) { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }}
+#define qError(...) { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }}
+#define qWarn(...) { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", 255, __VA_ARGS__); }}
+#define qInfo(...) { if (qDebugFlag & DEBUG_INFO) { taosPrintLog("QRY INFO ", 255, __VA_ARGS__); }}
+#define qDebug(...) { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLog("QRY DEBUG ", qDebugFlag, __VA_ARGS__); }}
+#define qTrace(...) { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY TRACE ", qDebugFlag, __VA_ARGS__); }}
#ifdef __cplusplus
}
diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c
index d41bac2a49..e4be6d940b 100644
--- a/src/query/src/qExecutor.c
+++ b/src/query/src/qExecutor.c
@@ -273,7 +273,7 @@ static bool limitResults(SQueryRuntimeEnv* pRuntimeEnv) {
if ((pQuery->limit.limit > 0) && (pQuery->rec.total + pQuery->rec.rows > pQuery->limit.limit)) {
pQuery->rec.rows = pQuery->limit.limit - pQuery->rec.total;
- qTrace("QInfo:%p discard remain data due to result limitation, limit:%"PRId64", current return:%" PRId64 ", total:%"PRId64,
+ qDebug("QInfo:%p discard remain data due to result limitation, limit:%"PRId64", current return:%" PRId64 ", total:%"PRId64,
pQInfo, pQuery->limit.limit, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows);
assert(pQuery->rec.rows >= 0);
setQueryStatus(pQuery, QUERY_COMPLETED);
@@ -568,12 +568,12 @@ static int32_t doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKe
// the number of completed slots are larger than the threshold, return current generated results to client.
if (numOfClosed > pWindowResInfo->threshold) {
- qTrace("QInfo:%p total result window:%d closed:%d, reached the output threshold %d, return",
+ qDebug("QInfo:%p total result window:%d closed:%d, reached the output threshold %d, return",
GET_QINFO_ADDR(pRuntimeEnv), pWindowResInfo->size, numOfClosed, pQuery->rec.threshold);
setQueryStatus(pQuery, QUERY_RESBUF_FULL);
} else {
- qTrace("QInfo:%p total result window:%d already closed:%d", GET_QINFO_ADDR(pRuntimeEnv), pWindowResInfo->size,
+ qDebug("QInfo:%p total result window:%d already closed:%d", GET_QINFO_ADDR(pRuntimeEnv), pWindowResInfo->size,
numOfClosed);
}
}
@@ -767,6 +767,9 @@ static void* getDataBlockImpl(SArray* pDataBlock, int32_t colId) {
static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas, int32_t col, int32_t size,
SArray *pDataBlock) {
+ if (pDataBlock == NULL) {
+ return NULL;
+ }
char *dataBlock = NULL;
SQuery *pQuery = pRuntimeEnv->pQuery;
@@ -819,7 +822,7 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas
}
/**
- *
+ * todo set the last value for pQueryTableInfo as in rowwiseapplyfunctions
* @param pRuntimeEnv
* @param forwardStep
* @param tsCols
@@ -854,6 +857,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery);
if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pDataBlockInfo->tid, &win) != TSDB_CODE_SUCCESS) {
+ tfree(sasArray);
return;
}
@@ -1060,16 +1064,18 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* item = pQuery->current;
-
- TSKEY *tsCols = (TSKEY*) ((SColumnInfoData *)taosArrayGet(pDataBlock, 0))->pData;
- bool groupbyStateValue = isGroupbyNormalCol(pQuery->pGroupbyExpr);
+
+ SColumnInfoData* pColumnInfoData = (SColumnInfoData *)taosArrayGet(pDataBlock, 0);
+
+ TSKEY *tsCols = (pColumnInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP)? (TSKEY*) pColumnInfoData->pData:NULL;
+ bool groupbyColumnValue = isGroupbyNormalCol(pQuery->pGroupbyExpr);
SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport));
int16_t type = 0;
int16_t bytes = 0;
char *groupbyColumnData = NULL;
- if (groupbyStateValue) {
+ if (groupbyColumnValue) {
groupbyColumnData = getGroupbyColumnData(pQuery, &type, &bytes, pDataBlock);
}
@@ -1091,7 +1097,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
// from bottom to top in asc order
if (pRuntimeEnv->pTSBuf != NULL) {
SQInfo *pQInfo = (SQInfo *)GET_QINFO_ADDR(pRuntimeEnv);
- qTrace("QInfo:%p process data rows, numOfRows:%d, query order:%d, ts comp order:%d", pQInfo, pDataBlockInfo->rows,
+ qDebug("QInfo:%p process data rows, numOfRows:%d, query order:%d, ts comp order:%d", pQInfo, pDataBlockInfo->rows,
pQuery->order.order, pRuntimeEnv->pTSBuf->cur.order);
}
@@ -1157,7 +1163,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
pWindowResInfo->curIndex = index;
} else { // other queries
// decide which group this rows belongs to according to current state value
- if (groupbyStateValue) {
+ if (groupbyColumnValue) {
char *val = groupbyColumnData + bytes * offset;
int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, val, type, bytes);
@@ -1182,9 +1188,14 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
}
}
}
-
- item->lastKey = tsCols[offset] + step;
-
+
+ assert(offset >= 0);
+ if (tsCols != NULL) {
+ item->lastKey = tsCols[offset] + step;
+ } else {
+ item->lastKey = (QUERY_IS_ASC_QUERY(pQuery)? pDataBlockInfo->window.ekey:pDataBlockInfo->window.skey) + step;
+ }
+
// todo refactor: extract method
for(int32_t i = 0; i < pQuery->numOfOutput; ++i) {
if (pQuery->pSelectExpr[i].base.functionId != TSDB_FUNC_ARITHM) {
@@ -1314,11 +1325,11 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY
// int64_t e = tsList[size - 1];
// if (IS_DATA_BLOCK_LOADED(blockStatus)) {
-// qTrace("QInfo:%p query ts:%lld-%lld, offset:%d, rows:%d, bstatus:%d,
+// qDebug("QInfo:%p query ts:%lld-%lld, offset:%d, rows:%d, bstatus:%d,
// functId:%d", GET_QINFO_ADDR(pQuery),
// s, e, startOffset, size, blockStatus, functionId);
// } else {
-// qTrace("QInfo:%p block not loaded, bstatus:%d",
+// qDebug("QInfo:%p block not loaded, bstatus:%d",
// GET_QINFO_ADDR(pQuery), blockStatus);
// }
#endif
@@ -1349,10 +1360,13 @@ static void setCtxTagColumnInfo(SQuery *pQuery, SQLFunctionCtx *pCtx) {
// the column may be the normal column, group by normal_column, the functionId is TSDB_FUNC_PRJ
}
}
-
- p->tagInfo.pTagCtxList = pTagCtx;
- p->tagInfo.numOfTagCols = num;
- p->tagInfo.tagsLen = tagLen;
+ if (p != NULL) {
+ p->tagInfo.pTagCtxList = pTagCtx;
+ p->tagInfo.numOfTagCols = num;
+ p->tagInfo.tagsLen = tagLen;
+ } else {
+ tfree(pTagCtx);
+ }
}
}
@@ -1365,7 +1379,7 @@ static void setWindowResultInfo(SResultInfo *pResultInfo, SQuery *pQuery, bool i
}
static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order) {
- qTrace("QInfo:%p setup runtime env", GET_QINFO_ADDR(pRuntimeEnv));
+ qDebug("QInfo:%p setup runtime env", GET_QINFO_ADDR(pRuntimeEnv));
SQuery *pQuery = pRuntimeEnv->pQuery;
pRuntimeEnv->resultInfo = calloc(pQuery->numOfOutput, sizeof(SResultInfo));
@@ -1465,7 +1479,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
SQuery *pQuery = pRuntimeEnv->pQuery;
SQInfo* pQInfo = (SQInfo*) GET_QINFO_ADDR(pRuntimeEnv);
- qTrace("QInfo:%p teardown runtime env", pQInfo);
+ qDebug("QInfo:%p teardown runtime env", pQInfo);
cleanupTimeWindowInfo(&pRuntimeEnv->windowResInfo, pQuery->numOfOutput);
if (pRuntimeEnv->pCtx != NULL) {
@@ -1702,7 +1716,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
// todo handle the case the the order irrelevant query type mixed up with order critical query type
// descending order query for last_row query
if (isFirstLastRowQuery(pQuery)) {
- qTrace("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery),
+ qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery),
pQuery->order.order, TSDB_ORDER_DESC);
pQuery->order.order = TSDB_ORDER_DESC;
@@ -1718,7 +1732,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
if (isPointInterpoQuery(pQuery) && pQuery->intervalTime == 0) {
if (!QUERY_IS_ASC_QUERY(pQuery)) {
- qTrace(msg, GET_QINFO_ADDR(pQuery), "interp", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey,
+ qDebug(msg, GET_QINFO_ADDR(pQuery), "interp", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey,
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
}
@@ -1730,7 +1744,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
if (pQuery->intervalTime == 0) {
if (onlyFirstQuery(pQuery)) {
if (!QUERY_IS_ASC_QUERY(pQuery)) {
- qTrace(msg, GET_QINFO_ADDR(pQuery), "only-first", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey,
+ qDebug(msg, GET_QINFO_ADDR(pQuery), "only-first", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey,
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
@@ -1739,7 +1753,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
pQuery->order.order = TSDB_ORDER_ASC;
} else if (onlyLastQuery(pQuery)) {
if (QUERY_IS_ASC_QUERY(pQuery)) {
- qTrace(msg, GET_QINFO_ADDR(pQuery), "only-last", pQuery->order.order, TSDB_ORDER_DESC, pQuery->window.skey,
+ qDebug(msg, GET_QINFO_ADDR(pQuery), "only-last", pQuery->order.order, TSDB_ORDER_DESC, pQuery->window.skey,
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
@@ -1752,7 +1766,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
if (stableQuery) {
if (onlyFirstQuery(pQuery)) {
if (!QUERY_IS_ASC_QUERY(pQuery)) {
- qTrace(msg, GET_QINFO_ADDR(pQuery), "only-first stable", pQuery->order.order, TSDB_ORDER_ASC,
+ qDebug(msg, GET_QINFO_ADDR(pQuery), "only-first stable", pQuery->order.order, TSDB_ORDER_ASC,
pQuery->window.skey, pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
@@ -1761,7 +1775,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
pQuery->order.order = TSDB_ORDER_ASC;
} else if (onlyLastQuery(pQuery)) {
if (QUERY_IS_ASC_QUERY(pQuery)) {
- qTrace(msg, GET_QINFO_ADDR(pQuery), "only-last stable", pQuery->order.order, TSDB_ORDER_DESC,
+ qDebug(msg, GET_QINFO_ADDR(pQuery), "only-last stable", pQuery->order.order, TSDB_ORDER_DESC,
pQuery->window.skey, pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
@@ -1822,7 +1836,7 @@ UNUSED_FUNC void vnodeDecMeterRefcnt(SQInfo *pQInfo) {
#if 0
if (pQInfo == NULL || pQInfo->tableqinfoGroupInfo.numOfTables == 1) {
atomic_fetch_sub_32(&pQInfo->pObj->numOfQueries, 1);
- qTrace("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pQInfo->pObj->vnode,
+ qDebug("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pQInfo->pObj->vnode,
pQInfo->pObj->sid, pQInfo->pObj->meterId, pQInfo->pObj->numOfQueries);
} else {
int32_t num = 0;
@@ -1831,7 +1845,7 @@ UNUSED_FUNC void vnodeDecMeterRefcnt(SQInfo *pQInfo) {
atomic_fetch_sub_32(&(pMeter->numOfQueries), 1);
if (pMeter->numOfQueries > 0) {
- qTrace("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pMeter->vnode, pMeter->sid,
+ qDebug("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pMeter->vnode, pMeter->sid,
pMeter->meterId, pMeter->numOfQueries);
num++;
}
@@ -1842,7 +1856,7 @@ UNUSED_FUNC void vnodeDecMeterRefcnt(SQInfo *pQInfo) {
* we do not output corresponding information
*/
num = pQInfo->tableqinfoGroupInfo.numOfTables - num;
- qTrace("QInfo:%p metric query is over, dec query ref for %d meters, numOfQueries on %d meters are 0", pQInfo,
+ qDebug("QInfo:%p metric query is over, dec query ref for %d meters, numOfQueries on %d meters are 0", pQInfo,
pQInfo->tableqinfoGroupInfo.numOfTables, num);
}
#endif
@@ -1937,7 +1951,7 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle,
}
if (r == BLK_DATA_NO_NEEDED) {
- qTrace("QInfo:%p data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_QINFO_ADDR(pRuntimeEnv),
+ qDebug("QInfo:%p data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_QINFO_ADDR(pRuntimeEnv),
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
pRuntimeEnv->summary.discardBlocks += 1;
} else if (r == BLK_DATA_STATIS_NEEDED) {
@@ -1961,7 +1975,7 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle,
if (!needToLoadDataBlock(pQuery,*pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) {
#if defined(_DEBUG_VIEW)
- qTrace("QInfo:%p block discarded by per-filter", GET_QINFO_ADDR(pRuntimeEnv));
+ qDebug("QInfo:%p block discarded by per-filter", GET_QINFO_ADDR(pRuntimeEnv));
#endif
// current block has been discard due to filter applied
pRuntimeEnv->summary.discardBlocks += 1;
@@ -2061,7 +2075,7 @@ static void ensureOutputBufferSimple(SQueryRuntimeEnv* pRuntimeEnv, int32_t capa
pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data;
}
- qTrace("QInfo:%p realloc output buffer to inc output buffer from: %" PRId64 " rows to:%d rows", GET_QINFO_ADDR(pRuntimeEnv),
+ qDebug("QInfo:%p realloc output buffer to inc output buffer from: %" PRId64 " rows to:%d rows", GET_QINFO_ADDR(pRuntimeEnv),
pQuery->rec.capacity, capacity);
pQuery->rec.capacity = capacity;
@@ -2097,7 +2111,7 @@ static void ensureOutputBuffer(SQueryRuntimeEnv* pRuntimeEnv, SDataBlockInfo* pB
}
}
- qTrace("QInfo:%p realloc output buffer, new size: %d rows, old:%" PRId64 ", remain:%" PRId64, GET_QINFO_ADDR(pRuntimeEnv),
+ qDebug("QInfo:%p realloc output buffer, new size: %d rows, old:%" PRId64 ", remain:%" PRId64, GET_QINFO_ADDR(pRuntimeEnv),
newSize, pRec->capacity, newSize - pRec->rows);
pRec->capacity = newSize;
@@ -2110,7 +2124,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
STableQueryInfo* pTableQueryInfo = pQuery->current;
SQueryCostInfo* summary = &pRuntimeEnv->summary;
- qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", lastkey:%" PRId64 ", order:%d",
+ qDebug("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", lastkey:%" PRId64 ", order:%d",
GET_QINFO_ADDR(pRuntimeEnv), pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey, pTableQueryInfo->lastKey,
pQuery->order.order);
@@ -2156,7 +2170,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock);
summary->totalRows += blockInfo.rows;
- qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QINFO_ADDR(pRuntimeEnv),
+ qDebug("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QINFO_ADDR(pRuntimeEnv),
blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes, pQuery->current->lastKey);
// while the output buffer is full or limit/offset is applied, query may be paused here
@@ -2271,7 +2285,7 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
}
doSetTagValueInParam(tsdb, pTable, pExprInfo->base.arg->argValue.i64, &pRuntimeEnv->pCtx[0].tag, type, bytes);
- qTrace("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64,
+ qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64,
pRuntimeEnv->pCtx[0].tag.i64Key)
}
}
@@ -2492,10 +2506,10 @@ int32_t mergeIntoGroupResult(SQInfo *pQInfo) {
}
assert(pQInfo->numOfGroupResultPages == 0);
- qTrace("QInfo:%p no result in group %d, continue", pQInfo, pQInfo->groupIndex - 1);
+ qDebug("QInfo:%p no result in group %d, continue", pQInfo, pQInfo->groupIndex - 1);
}
- qTrace("QInfo:%p merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "ms", pQInfo,
+ qDebug("QInfo:%p merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "ms", pQInfo,
pQInfo->groupIndex - 1, numOfGroups, taosGetTimestampMs() - st);
return TSDB_CODE_SUCCESS;
@@ -2704,7 +2718,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif
- qTrace("QInfo:%p result merge completed for group:%d, elapsed time:%" PRId64 " ms", pQInfo, pQInfo->groupIndex, endt - startt);
+ qDebug("QInfo:%p result merge completed for group:%d, elapsed time:%" PRId64 " ms", pQInfo, pQInfo->groupIndex, endt - startt);
tfree(pTableList);
tfree(posList);
@@ -2952,7 +2966,7 @@ void skipResults(SQueryRuntimeEnv *pRuntimeEnv) {
}
if (pQuery->rec.rows <= pQuery->limit.offset) {
- qTrace("QInfo:%p skip rows:%" PRId64 ", new offset:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), pQuery->rec.rows,
+ qDebug("QInfo:%p skip rows:%" PRId64 ", new offset:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), pQuery->rec.rows,
pQuery->limit.offset - pQuery->rec.rows);
pQuery->limit.offset -= pQuery->rec.rows;
@@ -2967,7 +2981,7 @@ void skipResults(SQueryRuntimeEnv *pRuntimeEnv) {
pQuery->rec.rows -= numOfSkip;
pQuery->limit.offset = 0;
- qTrace("QInfo:%p skip row:%"PRId64", new offset:%d, numOfRows remain:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), numOfSkip,
+ qDebug("QInfo:%p skip row:%"PRId64", new offset:%d, numOfRows remain:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), numOfSkip,
0, pQuery->rec.rows);
for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
@@ -3167,7 +3181,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
pRuntimeEnv->scanFlag = REPEAT_SCAN;
- qTrace("QInfo:%p start to repeat scan data blocks due to query func required, qrange:%"PRId64"-%"PRId64, pQInfo,
+ qDebug("QInfo:%p start to repeat scan data blocks due to query func required, qrange:%"PRId64"-%"PRId64, pQInfo,
cond.twindow.skey, cond.twindow.ekey);
// check if query is killed or not
@@ -3183,7 +3197,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
setEnvBeforeReverseScan(pRuntimeEnv, &qstatus);
// reverse scan from current position
- qTrace("QInfo:%p start to reverse scan", pQInfo);
+ qDebug("QInfo:%p start to reverse scan", pQInfo);
doScanAllDataBlocks(pRuntimeEnv);
clearEnvAfterReverseScan(pRuntimeEnv, &qstatus);
@@ -3479,7 +3493,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
int32_t startIdx = 0;
int32_t step = -1;
- qTrace("QInfo:%p start to copy data from windowResInfo to query buf", pQInfo);
+ qDebug("QInfo:%p start to copy data from windowResInfo to query buf", pQInfo);
int32_t totalSubset = getNumOfSubset(pQInfo);
if (orderType == TSDB_ORDER_ASC) {
@@ -3497,7 +3511,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
continue;
}
- assert(result[i].numOfRows >= 0 && pQInfo->offset <= 1);
+ assert(pQInfo->offset <= 1);
int32_t numOfRowsToCopy = result[i].numOfRows - pQInfo->offset;
int32_t oldOffset = pQInfo->offset;
@@ -3528,7 +3542,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
}
}
- qTrace("QInfo:%p copy data to query buf completed", pQInfo);
+ qDebug("QInfo:%p copy data to query buf completed", pQInfo);
#ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pRuntimeEnv, numOfResult);
@@ -3687,12 +3701,12 @@ int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int
// todo apply limit output function
/* reached the start position of according to offset value, return immediately */
if (pQuery->limit.offset == 0) {
- qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows", pQInfo, pFillInfo->numOfRows, ret);
+ qDebug("QInfo:%p initial numOfRows:%d, generate filled result:%d rows", pQInfo, pFillInfo->numOfRows, ret);
return ret;
}
if (pQuery->limit.offset < ret) {
- qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%" PRId64 ". Discard due to offset, remain:%" PRId64 ", new offset:%d",
+ qDebug("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%" PRId64 ". Discard due to offset, remain:%" PRId64 ", new offset:%d",
pQInfo, pFillInfo->numOfRows, ret, pQuery->limit.offset, ret - pQuery->limit.offset, 0);
ret -= pQuery->limit.offset;
@@ -3706,7 +3720,7 @@ int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int
pQuery->limit.offset = 0;
return ret;
} else {
- qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%" PRId64 ". Discard due to offset, "
+ qDebug("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%" PRId64 ". Discard due to offset, "
"remain:%d, new offset:%" PRId64, pQInfo, pFillInfo->numOfRows, ret, pQuery->limit.offset, 0,
pQuery->limit.offset - ret);
@@ -3730,26 +3744,26 @@ static void queryCostStatis(SQInfo *pQInfo) {
//// pSummary->tmpBufferInDisk = getResBufSize(pRuntimeEnv->pResultBuf);
// }
//
-// qTrace("QInfo:%p cost: comp blocks:%d, size:%d Bytes, elapsed time:%.2f ms", pQInfo, pSummary->readCompInfo,
+// qDebug("QInfo:%p cost: comp blocks:%d, size:%d Bytes, elapsed time:%.2f ms", pQInfo, pSummary->readCompInfo,
// pSummary->totalCompInfoSize, pSummary->loadCompInfoUs / 1000.0);
//
-// qTrace("QInfo:%p cost: field info: %d, size:%d Bytes, avg size:%.2f Bytes, elapsed time:%.2f ms", pQInfo,
+// qDebug("QInfo:%p cost: field info: %d, size:%d Bytes, avg size:%.2f Bytes, elapsed time:%.2f ms", pQInfo,
// pSummary->readField, pSummary->totalFieldSize, (double)pSummary->totalFieldSize / pSummary->readField,
// pSummary->loadFieldUs / 1000.0);
//
-// qTrace(
+// qDebug(
// "QInfo:%p cost: file blocks:%d, size:%d Bytes, elapsed time:%.2f ms, skipped:%d, in-memory gen null:%d Bytes",
// pQInfo, pSummary->readDiskBlocks, pSummary->totalBlockSize, pSummary->loadBlocksUs / 1000.0,
// pSummary->skippedFileBlocks, pSummary->totalGenData);
- qTrace("QInfo:%p :cost summary: elpased time:%"PRId64" us, total blocks:%d, use block statis:%d, use block data:%d, "
+ qDebug("QInfo:%p :cost summary: elpased time:%"PRId64" us, total blocks:%d, use block statis:%d, use block data:%d, "
"total rows:%"PRId64 ", check rows:%"PRId64, pQInfo, pSummary->elapsedTime, pSummary->totalBlocks,
pSummary->loadBlockStatis, pSummary->loadBlocks, pSummary->totalRows, pSummary->totalCheckedRows);
-// qTrace("QInfo:%p cost: temp file:%d Bytes", pQInfo, pSummary->tmpBufferInDisk);
+// qDebug("QInfo:%p cost: temp file:%d Bytes", pQInfo, pSummary->tmpBufferInDisk);
//
-// qTrace("QInfo:%p cost: file:%d, table:%d", pQInfo, pSummary->numOfFiles, pSummary->numOfTables);
-// qTrace("QInfo:%p cost: seek ops:%d", pQInfo, pSummary->numOfSeek);
+// qDebug("QInfo:%p cost: file:%d, table:%d", pQInfo, pSummary->numOfFiles, pSummary->numOfTables);
+// qDebug("QInfo:%p cost: seek ops:%d", pQInfo, pSummary->numOfSeek);
//
// double total = pSummary->fileTimeUs + pSummary->cacheTimeUs;
// double io = pSummary->loadCompInfoUs + pSummary->loadBlocksUs + pSummary->loadFieldUs;
@@ -3757,7 +3771,7 @@ static void queryCostStatis(SQInfo *pQInfo) {
// todo add the intermediate result save cost!!
// double computing = total - io;
//
-// qTrace(
+// qDebug(
// "QInfo:%p cost: total elapsed time:%.2f ms, file:%.2f ms(%.2f%), cache:%.2f ms(%.2f%). io:%.2f ms(%.2f%),"
// "comput:%.2fms(%.2f%)",
// pQInfo, total / 1000.0, pSummary->fileTimeUs / 1000.0, pSummary->fileTimeUs * 100 / total,
@@ -3797,7 +3811,7 @@ static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBloc
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock);
- qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QINFO_ADDR(pRuntimeEnv),
+ qDebug("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QINFO_ADDR(pRuntimeEnv),
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, pQuery->current->lastKey);
}
@@ -3826,7 +3840,7 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
pTableQueryInfo->lastKey = (QUERY_IS_ASC_QUERY(pQuery)) ? blockInfo.window.ekey : blockInfo.window.skey;
pTableQueryInfo->lastKey += step;
- qTrace("QInfo:%p skip rows:%d, offset:%" PRId64, GET_QINFO_ADDR(pRuntimeEnv), blockInfo.rows,
+ qDebug("QInfo:%p skip rows:%d, offset:%" PRId64, GET_QINFO_ADDR(pRuntimeEnv), blockInfo.rows,
pQuery->limit.offset);
} else { // find the appropriated start position in current block
updateOffsetVal(pRuntimeEnv, &blockInfo);
@@ -3912,7 +3926,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, NULL, binarySearchForKey, pDataBlock);
pRuntimeEnv->windowResInfo.curIndex = index; // restore the window index
- qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64,
+ qDebug("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64,
GET_QINFO_ADDR(pRuntimeEnv), blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes, pQuery->current->lastKey);
return true;
@@ -4170,7 +4184,7 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
summary->totalRows += blockInfo.rows;
stableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, pDataBlock, binarySearchForKey);
- qTrace("QInfo:%p check data block, uid:%"PRId64", tid:%d, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, lastKey:%" PRId64,
+ qDebug("QInfo:%p check data block, uid:%"PRId64", tid:%d, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, lastKey:%" PRId64,
pQInfo, blockInfo.uid, blockInfo.tid, blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, pQuery->current->lastKey);
}
@@ -4189,7 +4203,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
setTagVal(pRuntimeEnv, pCheckInfo->pTable, pQInfo->tsdb);
STableId id = tsdbGetTableId(pCheckInfo->pTable);
- qTrace("QInfo:%p query on (%d): uid:%" PRIu64 ", tid:%d, qrange:%" PRId64 "-%" PRId64, pQInfo, index,
+ qDebug("QInfo:%p query on (%d): uid:%" PRIu64 ", tid:%d, qrange:%" PRId64 "-%" PRId64, pQInfo, index,
id.uid, id.tid, pCheckInfo->lastKey, pCheckInfo->win.ekey);
STsdbQueryCond cond = {
@@ -4256,7 +4270,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
while (pQInfo->groupIndex < numOfGroups) {
SArray* group = taosArrayGetP(pQInfo->tableGroupInfo.pGroupList, pQInfo->groupIndex);
- qTrace("QInfo:%p last_row query on group:%d, total group:%zu, current group:%p", pQInfo, pQInfo->groupIndex,
+ qDebug("QInfo:%p last_row query on group:%d, total group:%zu, current group:%p", pQInfo, pQInfo->groupIndex,
numOfGroups, group);
STsdbQueryCond cond = {
@@ -4321,7 +4335,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
while (pQInfo->groupIndex < numOfGroups) {
SArray* group = taosArrayGetP(pQInfo->tableGroupInfo.pGroupList, pQInfo->groupIndex);
- qTrace("QInfo:%p group by normal columns group:%d, total group:%zu", pQInfo, pQInfo->groupIndex, numOfGroups);
+ qDebug("QInfo:%p group by normal columns group:%d, total group:%zu", pQInfo, pQInfo->groupIndex, numOfGroups);
STsdbQueryCond cond = {
.twindow = pQuery->window,
@@ -4371,7 +4385,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
}
}
- qTrace("QInfo:%p generated groupby columns results %d rows for group %d completed", pQInfo, pWindowResInfo->size,
+ qDebug("QInfo:%p generated groupby columns results %d rows for group %d completed", pQInfo, pWindowResInfo->size,
pQInfo->groupIndex);
int32_t currentGroupIndex = pQInfo->groupIndex;
@@ -4506,7 +4520,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
pRuntimeEnv->cur = pRuntimeEnv->pTSBuf->cur;
}
- qTrace(
+ qDebug(
"QInfo %p numOfTables:%"PRIu64", index:%d, numOfGroups:%zu, %"PRId64" points returned, total:%"PRId64", offset:%" PRId64,
pQInfo, pQInfo->tableqinfoGroupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total,
pQuery->limit.offset);
@@ -4594,20 +4608,20 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult);
}
- qTrace("QInfo:%p current:%"PRId64", total:%"PRId64"", pQInfo, pQuery->rec.rows, pQuery->rec.total);
+ qDebug("QInfo:%p current:%"PRId64", total:%"PRId64"", pQInfo, pQuery->rec.rows, pQuery->rec.total);
return;
}
- qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", order:%d, forward scan start", pQInfo,
+ qDebug("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", order:%d, forward scan start", pQInfo,
pQuery->window.skey, pQuery->window.ekey, pQuery->order.order);
// do check all qualified data blocks
int64_t el = scanMultiTableDataBlocks(pQInfo);
- qTrace("QInfo:%p master scan completed, elapsed time: %" PRId64 "ms, reverse scan start", pQInfo, el);
+ qDebug("QInfo:%p master scan completed, elapsed time: %" PRId64 "ms, reverse scan start", pQInfo, el);
// query error occurred or query is killed, abort current execution
if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) {
- qTrace("QInfo:%p query killed or error occurred, code:%s, abort", pQInfo, tstrerror(pQInfo->code));
+ qDebug("QInfo:%p query killed or error occurred, code:%s, abort", pQInfo, tstrerror(pQInfo->code));
return;
}
@@ -4618,17 +4632,17 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
doSaveContext(pQInfo);
el = scanMultiTableDataBlocks(pQInfo);
- qTrace("QInfo:%p reversed scan completed, elapsed time: %" PRId64 "ms", pQInfo, el);
+ qDebug("QInfo:%p reversed scan completed, elapsed time: %" PRId64 "ms", pQInfo, el);
doRestoreContext(pQInfo);
} else {
- qTrace("QInfo:%p no need to do reversed scan, query completed", pQInfo);
+ qDebug("QInfo:%p no need to do reversed scan, query completed", pQInfo);
}
setQueryStatus(pQuery, QUERY_COMPLETED);
if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) {
- qTrace("QInfo:%p query killed or error occurred, code:%s, abort", pQInfo, tstrerror(pQInfo->code));
+ qDebug("QInfo:%p query killed or error occurred, code:%s, abort", pQInfo, tstrerror(pQInfo->code));
return;
}
@@ -4645,7 +4659,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
}
// handle the limitation of output buffer
- qTrace("QInfo:%p points returned:%" PRId64 ", total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows);
+ qDebug("QInfo:%p points returned:%" PRId64 ", total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows);
}
/*
@@ -4717,7 +4731,7 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
break;
}
- qTrace("QInfo:%p skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64,
+ qDebug("QInfo:%p skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64,
pQInfo, pQuery->limit.offset, pQuery->current->lastKey, pQuery->current->win.ekey);
resetCtxOutputBuf(pRuntimeEnv);
@@ -4725,7 +4739,7 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
limitResults(pRuntimeEnv);
if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) {
- qTrace("QInfo:%p query paused due to output limitation, next qrange:%" PRId64 "-%" PRId64, pQInfo,
+ qDebug("QInfo:%p query paused due to output limitation, next qrange:%" PRId64 "-%" PRId64, pQInfo,
pQuery->current->lastKey, pQuery->window.ekey);
} else if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
STableIdInfo tidInfo;
@@ -4848,7 +4862,7 @@ static void tableQueryImpl(SQInfo *pQInfo) {
limitResults(pRuntimeEnv);
}
- qTrace("QInfo:%p current:%" PRId64 " returned, total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total);
+ qDebug("QInfo:%p current:%" PRId64 " returned, total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total);
return;
}
@@ -4868,13 +4882,13 @@ static void tableQueryImpl(SQInfo *pQInfo) {
clearFirstNTimeWindow(pRuntimeEnv, pQInfo->groupIndex);
if (pQuery->rec.rows > 0) {
- qTrace("QInfo:%p %"PRId64" rows returned from group results, total:%"PRId64"", pQInfo, pQuery->rec.rows, pQuery->rec.total);
+ qDebug("QInfo:%p %"PRId64" rows returned from group results, total:%"PRId64"", pQInfo, pQuery->rec.rows, pQuery->rec.total);
return;
}
}
}
- qTrace("QInfo:%p query over, %"PRId64" rows are returned", pQInfo, pQuery->rec.total);
+ qDebug("QInfo:%p query over, %"PRId64" rows are returned", pQInfo, pQuery->rec.total);
return;
}
@@ -4902,9 +4916,9 @@ static void tableQueryImpl(SQInfo *pQInfo) {
/* check if query is killed or not */
if (isQueryKilled(pQInfo)) {
- qTrace("QInfo:%p query is killed", pQInfo);
+ qDebug("QInfo:%p query is killed", pQInfo);
} else {
- qTrace("QInfo:%p query paused, %" PRId64 " rows returned, numOfTotal:%" PRId64 " rows",
+ qDebug("QInfo:%p query paused, %" PRId64 " rows returned, numOfTotal:%" PRId64 " rows",
pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows);
}
}
@@ -4930,7 +4944,7 @@ static void stableQueryImpl(SQInfo *pQInfo) {
pQInfo->runtimeEnv.summary.elapsedTime += (taosGetTimestampUs() - st);
if (pQuery->rec.rows == 0) {
- qTrace("QInfo:%p over, %zu tables queried, %"PRId64" rows are returned", pQInfo, pQInfo->tableqinfoGroupInfo.numOfTables, pQuery->rec.total);
+ qDebug("QInfo:%p over, %zu tables queried, %"PRId64" rows are returned", pQInfo, pQInfo->tableqinfoGroupInfo.numOfTables, pQuery->rec.total);
}
}
@@ -5220,7 +5234,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pMsg += len;
}
- qTrace("qmsg:%p query %d tables, type:%d, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, "
+ qDebug("qmsg:%p query %d tables, type:%d, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, "
"outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, compNumOfBlocks:%d, limit:%" PRId64 ", offset:%" PRId64,
pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->queryType, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols,
pQueryMsg->order, pQueryMsg->numOfOutput, pQueryMsg->numOfCols, pQueryMsg->intervalTime,
@@ -5239,7 +5253,7 @@ _cleanup:
}
static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTableMsg *pQueryMsg) {
- qTrace("qmsg:%p create arithmetic expr from binary string: %s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz);
+ qDebug("qmsg:%p create arithmetic expr from binary string: %s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz);
tExprNode* pExprNode = NULL;
TRY(32) {
@@ -5295,9 +5309,9 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
bytes = s.bytes;
} else{
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
- assert(j < pQueryMsg->numOfCols || j < pQueryMsg->numOfTags || j == TSDB_TBNAME_COLUMN_INDEX);
+ assert(j < pQueryMsg->numOfCols || j < pQueryMsg->numOfTags);
- if (pExprs[i].base.colInfo.colId != TSDB_TBNAME_COLUMN_INDEX) {
+ if (pExprs[i].base.colInfo.colId != TSDB_TBNAME_COLUMN_INDEX && j >= 0) {
SColumnInfo* pCol = (TSDB_COL_IS_TAG(pExprs[i].base.colInfo.flag))? &pTagCols[j]:&pQueryMsg->colList[j];
type = pCol->type;
bytes = pCol->bytes;
@@ -5339,8 +5353,6 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
assert(ret == TSDB_CODE_SUCCESS);
}
}
-
- tfree(pExprMsg);
*pExprInfo = pExprs;
return TSDB_CODE_SUCCESS;
@@ -5591,11 +5603,14 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
pQInfo->signature = pQInfo;
pQInfo->tableGroupInfo = *pTableGroupInfo;
- size_t numOfGroups = taosArrayGetSize(pTableGroupInfo->pGroupList);
+ size_t numOfGroups = 0;
+ if (pTableGroupInfo->pGroupList != NULL) {
+ numOfGroups = taosArrayGetSize(pTableGroupInfo->pGroupList);
+
+ pQInfo->tableqinfoGroupInfo.pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
+ pQInfo->tableqinfoGroupInfo.numOfTables = pTableGroupInfo->numOfTables;
+ }
- pQInfo->tableqinfoGroupInfo.pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
- pQInfo->tableqinfoGroupInfo.numOfTables = pTableGroupInfo->numOfTables;
-
int tableIndex = 0;
STimeWindow window = pQueryMsg->window;
taosArraySort(pTableIdList, compareTableIdInfo);
@@ -5639,7 +5654,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
colIdCheck(pQuery);
- qTrace("qmsg:%p QInfo:%p created", pQueryMsg, pQInfo);
+ qDebug("qmsg:%p QInfo:%p created", pQueryMsg, pQInfo);
return pQInfo;
_cleanup:
@@ -5693,13 +5708,14 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
pTSBuf = tsBufCreateFromCompBlocks(tsBlock, pQueryMsg->tsNumOfBlocks, pQueryMsg->tsLen, pQueryMsg->tsOrder);
tsBufResetPos(pTSBuf);
- tsBufNextPos(pTSBuf);
+ bool ret = tsBufNextPos(pTSBuf);
+ UNUSED(ret);
}
// only the successful complete requries the sem_post/over = 1 operations.
if ((QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.skey > pQuery->window.ekey)) ||
(!QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.ekey > pQuery->window.skey))) {
- qTrace("QInfo:%p no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo, pQuery->window.skey,
+ qDebug("QInfo:%p no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo, pQuery->window.skey,
pQuery->window.ekey, pQuery->order.order);
setQueryStatus(pQuery, QUERY_COMPLETED);
@@ -5708,7 +5724,7 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
}
if (pQInfo->tableqinfoGroupInfo.numOfTables == 0) {
- qTrace("QInfo:%p no table qualified for tag filter, abort query", pQInfo);
+ qDebug("QInfo:%p no table qualified for tag filter, abort query", pQInfo);
setQueryStatus(pQuery, QUERY_COMPLETED);
sem_post(&pQInfo->dataReady);
@@ -5736,7 +5752,7 @@ static void freeQInfo(SQInfo *pQInfo) {
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
setQueryKilled(pQInfo);
- qTrace("QInfo:%p start to free QInfo", pQInfo);
+ qDebug("QInfo:%p start to free QInfo", pQInfo);
for (int32_t col = 0; col < pQuery->numOfOutput; ++col) {
tfree(pQuery->sdata[col]);
}
@@ -5800,7 +5816,7 @@ static void freeQInfo(SQInfo *pQInfo) {
tfree(pQuery);
- qTrace("QInfo:%p QInfo is freed", pQInfo);
+ qDebug("QInfo:%p QInfo is freed", pQInfo);
// destroy signature, in order to avoid the query process pass the object safety check
memset(pQInfo, 0, sizeof(SQInfo));
@@ -5839,18 +5855,25 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// make sure file exist
if (FD_VALID(fd)) {
- size_t s = lseek(fd, 0, SEEK_END);
- qTrace("QInfo:%p ts comp data return, file:%s, size:%zu", pQInfo, pQuery->sdata[0]->data, s);
+ int32_t s = lseek(fd, 0, SEEK_END);
+ UNUSED(s);
+ qDebug("QInfo:%p ts comp data return, file:%s, size:%d", pQInfo, pQuery->sdata[0]->data, s);
+ if (lseek(fd, 0, SEEK_SET) >= 0) {
+ size_t sz = read(fd, data, s);
+ UNUSED(sz);
+ } else {
+ // todo handle error
+ }
- lseek(fd, 0, SEEK_SET);
- read(fd, data, s);
close(fd);
-
unlink(pQuery->sdata[0]->data);
} else {
- // todo return the error code to client
+ // todo return the error code to client and handle invalid fd
qError("QInfo:%p failed to open tmp file to send ts-comp data to client, path:%s, reason:%s", pQInfo,
pQuery->sdata[0]->data, strerror(errno));
+ if (fd != -1) {
+ close(fd);
+ }
}
// all data returned, set query over
@@ -5862,10 +5885,10 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
}
pQuery->rec.total += pQuery->rec.rows;
- qTrace("QInfo:%p current numOfRes rows:%" PRId64 ", total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total);
+ qDebug("QInfo:%p current numOfRes rows:%" PRId64 ", total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total);
if (pQuery->limit.limit > 0 && pQuery->limit.limit == pQuery->rec.total) {
- qTrace("QInfo:%p results limitation reached, limitation:%"PRId64, pQInfo, pQuery->limit.limit);
+ qDebug("QInfo:%p results limitation reached, limitation:%"PRId64, pQInfo, pQuery->limit.limit);
setQueryStatus(pQuery, QUERY_OVER);
}
@@ -5903,7 +5926,6 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
}
if ((code = createQFunctionExprFromMsg(pQueryMsg, &pExprs, pExprMsg, pTagColumnInfo)) != TSDB_CODE_SUCCESS) {
- free(pExprMsg);
goto _over;
}
@@ -5918,7 +5940,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_TABLE_QUERY)) {
STableIdInfo *id = taosArrayGet(pTableIdList, 0);
- qTrace("qmsg:%p query normal table, uid:%"PRId64", tid:%d", pQueryMsg, id->uid, id->tid);
+ qDebug("qmsg:%p query normal table, uid:%"PRId64", tid:%d", pQueryMsg, id->uid, id->tid);
if ((code = tsdbGetOneTableGroup(tsdb, id->uid, &tableGroupInfo)) != TSDB_CODE_SUCCESS) {
goto _over;
}
@@ -5947,7 +5969,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
goto _over;
}
- qTrace("qmsg:%p query on %zu tables in one group from client", pQueryMsg, tableGroupInfo.numOfTables);
+ qDebug("qmsg:%p query on %zu tables in one group from client", pQueryMsg, tableGroupInfo.numOfTables);
}
} else {
assert(0);
@@ -5975,6 +5997,7 @@ _over:
}
free(pTagColumnInfo);
free(pExprs);
+ free(pExprMsg);
taosArrayDestroy(pTableIdList);
//pQInfo already freed in initQInfo, but *pQInfo may not pointer to null;
@@ -5993,7 +6016,7 @@ _over:
static void doDestoryQueryInfo(SQInfo* pQInfo) {
assert(pQInfo != NULL);
- qTrace("QInfo:%p query completed", pQInfo);
+ qDebug("QInfo:%p query completed", pQInfo);
queryCostStatis(pQInfo); // print the query cost summary
freeQInfo(pQInfo);
}
@@ -6005,7 +6028,7 @@ void qDestroyQueryInfo(qinfo_t qHandle, void (*fp)(void*), void* param) {
}
int16_t ref = T_REF_DEC(pQInfo);
- qTrace("QInfo:%p dec refCount, value:%d", pQInfo, ref);
+ qDebug("QInfo:%p dec refCount, value:%d", pQInfo, ref);
if (ref == 0) {
doDestoryQueryInfo(pQInfo);
@@ -6020,17 +6043,17 @@ void qTableQuery(qinfo_t qinfo, void (*fp)(void*), void* param) {
SQInfo *pQInfo = (SQInfo *)qinfo;
if (pQInfo == NULL || pQInfo->signature != pQInfo) {
- qTrace("QInfo:%p has been freed, no need to execute", pQInfo);
+ qDebug("QInfo:%p has been freed, no need to execute", pQInfo);
return;
}
if (isQueryKilled(pQInfo)) {
- qTrace("QInfo:%p it is already killed, abort", pQInfo);
+ qDebug("QInfo:%p it is already killed, abort", pQInfo);
qDestroyQueryInfo(pQInfo, fp, param);
return;
}
- qTrace("QInfo:%p query task is launched", pQInfo);
+ qDebug("QInfo:%p query task is launched", pQInfo);
if (onlyQueryTags(pQInfo->runtimeEnv.pQuery)) {
assert(pQInfo->runtimeEnv.pQueryHandle == NULL);
@@ -6054,12 +6077,12 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo) {
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
if (isQueryKilled(pQInfo)) {
- qTrace("QInfo:%p query is killed, code:%d", pQInfo, pQInfo->code);
+ qDebug("QInfo:%p query is killed, code:%d", pQInfo, pQInfo->code);
return pQInfo->code;
}
sem_wait(&pQInfo->dataReady);
- qTrace("QInfo:%p retrieve result info, rowsize:%d, rows:%"PRId64", code:%d", pQInfo, pQuery->rowSize, pQuery->rec.rows,
+ qDebug("QInfo:%p retrieve result info, rowsize:%d, rows:%"PRId64", code:%d", pQInfo, pQuery->rowSize, pQuery->rec.rows,
pQInfo->code);
return pQInfo->code;
@@ -6069,7 +6092,7 @@ bool qHasMoreResultsToRetrieve(qinfo_t qinfo) {
SQInfo *pQInfo = (SQInfo *)qinfo;
if (!isValidQInfo(pQInfo) || pQInfo->code != TSDB_CODE_SUCCESS) {
- qTrace("QInfo:%p invalid qhandle or error occurs, abort query, code:%x", pQInfo, pQInfo->code);
+ qDebug("QInfo:%p invalid qhandle or error occurs, abort query, code:%x", pQInfo, pQInfo->code);
return false;
}
@@ -6087,7 +6110,7 @@ bool qHasMoreResultsToRetrieve(qinfo_t qinfo) {
if (ret) {
T_REF_INC(pQInfo);
- qTrace("QInfo:%p has more results waits for client retrieve", pQInfo);
+ qDebug("QInfo:%p has more results waits for client retrieve", pQInfo);
}
return ret;
@@ -6228,14 +6251,14 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
count += 1;
}
- qTrace("QInfo:%p create (tableId, tag) info completed, rows:%d", pQInfo, count);
+ qDebug("QInfo:%p create (tableId, tag) info completed, rows:%d", pQInfo, count);
} else if (functionId == TSDB_FUNC_COUNT) {// handle the "count(tbname)" query
*(int64_t*) pQuery->sdata[0]->data = num;
count = 1;
pQInfo->tableIndex = num; //set query completed
- qTrace("QInfo:%p create count(tbname) query, res:%d rows:1", pQInfo, count);
+ qDebug("QInfo:%p create count(tbname) query, res:%d rows:1", pQInfo, count);
} else { // return only the tags|table name etc.
count = 0;
SSchema tbnameSchema = tGetTableNameColumnSchema();
@@ -6275,7 +6298,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
count += 1;
}
- qTrace("QInfo:%p create tag values results completed, rows:%d", pQInfo, count);
+ qDebug("QInfo:%p create tag values results completed, rows:%d", pQInfo, count);
}
pQuery->rec.rows = count;
diff --git a/src/query/src/qextbuffer.c b/src/query/src/qextbuffer.c
index 35f5e22ed5..ce3f60c072 100644
--- a/src/query/src/qextbuffer.c
+++ b/src/query/src/qextbuffer.c
@@ -42,7 +42,7 @@ tExtMemBuffer* createExtMemBuffer(int32_t inMemSize, int32_t elemSize, SColumnMo
getTmpfilePath("extbuf", name);
pMemBuffer->path = strdup(name);
- uTrace("create tmp file:%s", pMemBuffer->path);
+ uDebug("create tmp file:%s", pMemBuffer->path);
SExtFileInfo *pFMeta = &pMemBuffer->fileMeta;
@@ -83,7 +83,7 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
uError("failed to close file:%s, reason:%s", pMemBuffer->path, strerror(errno));
}
- uTrace("remove temp file:%s for external buffer", pMemBuffer->path);
+ uDebug("remove temp file:%s for external buffer", pMemBuffer->path);
unlink(pMemBuffer->path);
}
diff --git a/src/query/src/qpercentile.c b/src/query/src/qpercentile.c
index e192cf3873..dc5ecb796a 100644
--- a/src/query/src/qpercentile.c
+++ b/src/query/src/qpercentile.c
@@ -315,7 +315,7 @@ tMemBucket *tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nE
pBucket->pSegs[i].pBoundingEntries = NULL;
}
- uTrace("MemBucket:%p,created,buffer size:%ld,elem size:%d", pBucket, pBucket->numOfTotalPages * DEFAULT_PAGE_SIZE,
+ uDebug("MemBucket:%p,created,buffer size:%ld,elem size:%d", pBucket, pBucket->numOfTotalPages * DEFAULT_PAGE_SIZE,
pBucket->nElemSize);
return pBucket;
@@ -545,7 +545,7 @@ void tMemBucketPut(tMemBucket *pBucket, void *data, int32_t numOfRows) {
// ensure available memory pages to allocate
int16_t cseg = 0, cslot = 0;
if (pBucket->numOfAvailPages == 0) {
- uTrace("MemBucket:%p,max avail size:%d, no avail memory pages,", pBucket, pBucket->numOfTotalPages);
+ uDebug("MemBucket:%p,max avail size:%d, no avail memory pages,", pBucket, pBucket->numOfTotalPages);
tBucketGetMaxMemSlot(pBucket, &cseg, &cslot);
if (cseg == -1 || cslot == -1) {
@@ -560,10 +560,10 @@ void tMemBucketPut(tMemBucket *pBucket, void *data, int32_t numOfRows) {
UNUSED(avail);
tExtMemBufferFlush(pBucket->pSegs[cseg].pBuffer[cslot]);
- uTrace("MemBucket:%p,seg:%d,slot:%d flushed to disk,new avail pages:%d", pBucket, cseg, cslot,
+ uDebug("MemBucket:%p,seg:%d,slot:%d flushed to disk,new avail pages:%d", pBucket, cseg, cslot,
pBucket->numOfAvailPages);
} else {
- uTrace("MemBucket:%p,failed to choose slot to flush to disk seg:%d,slot:%d", pBucket, cseg, cslot);
+ uDebug("MemBucket:%p,failed to choose slot to flush to disk seg:%d,slot:%d", pBucket, cseg, cslot);
}
}
int16_t consumedPgs = pSeg->pBuffer[slotIdx]->numOfInMemPages;
@@ -835,10 +835,10 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
return finalResult;
}
- uTrace("MemBucket:%p,start second round bucketing", pMemBucket);
+ uDebug("MemBucket:%p,start second round bucketing", pMemBucket);
if (pSeg->pBuffer[j]->numOfElemsInBuffer != 0) {
- uTrace("MemBucket:%p,flush %d pages to disk, clear status", pMemBucket, pSeg->pBuffer[j]->numOfInMemPages);
+ uDebug("MemBucket:%p,flush %d pages to disk, clear status", pMemBucket, pSeg->pBuffer[j]->numOfInMemPages);
pMemBucket->numOfAvailPages += pSeg->pBuffer[j]->numOfInMemPages;
tExtMemBufferFlush(pSeg->pBuffer[j]);
@@ -880,8 +880,11 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
for (uint32_t jx = 0; jx < pFlushInfo->numOfPages; ++jx) {
size_t sz = fread(pPage, pMemBuffer->pageSize, 1, pMemBuffer->file);
- UNUSED(sz);
- tMemBucketPut(pMemBucket, pPage->data, pPage->num);
+ if (sz != pMemBuffer->pageSize) {
+ uError("MemBucket:%p, read tmp file %s failed", pMemBucket, pMemBuffer->path);
+ } else {
+ tMemBucketPut(pMemBucket, pPage->data, pPage->num);
+ }
}
fclose(pMemBuffer->file);
diff --git a/src/query/src/qresultBuf.c b/src/query/src/qresultBuf.c
index 7841c0bbbe..f63f072b0b 100644
--- a/src/query/src/qresultBuf.c
+++ b/src/query/src/qresultBuf.c
@@ -48,7 +48,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si
return TSDB_CODE_QRY_OUT_OF_MEMORY; // todo change error code
}
- qTrace("QInfo:%p create tmp file for output result, %s, %" PRId64 "bytes", handle, pResBuf->path,
+ qDebug("QInfo:%p create tmp file for output result, %s, %" PRId64 "bytes", handle, pResBuf->path,
pResBuf->totalBufSize);
return TSDB_CODE_SUCCESS;
@@ -196,7 +196,7 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf, void* handle) {
close(pResultBuf->fd);
}
- qTrace("QInfo:%p disk-based output buffer closed, %" PRId64 " bytes, file:%s", handle, pResultBuf->totalBufSize, pResultBuf->path);
+ qDebug("QInfo:%p disk-based output buffer closed, %" PRId64 " bytes, file:%s", handle, pResultBuf->totalBufSize, pResultBuf->path);
munmap(pResultBuf->pBuf, pResultBuf->totalBufSize);
unlink(pResultBuf->path);
diff --git a/src/query/src/qtsbuf.c b/src/query/src/qtsbuf.c
index 1b589a0085..fedaa315d3 100644
--- a/src/query/src/qtsbuf.c
+++ b/src/query/src/qtsbuf.c
@@ -131,7 +131,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf->cur.order = TSDB_ORDER_ASC;
pTSBuf->autoDelete = autoDelete;
-// tscTrace("create tsBuf from file:%s, fd:%d, size:%d, numOfVnode:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
+// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfVnode:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
// pTSBuf->fileSize, pTSBuf->numOfVnodes, pTSBuf->autoDelete);
return pTSBuf;
@@ -154,7 +154,7 @@ void* tsBufDestory(STSBuf* pTSBuf) {
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
unlink(pTSBuf->path);
} else {
-// tscTrace("tsBuf %p destroyed, tmp file:%s, remains", pTSBuf, pTSBuf->path);
+// tscDebug("tsBuf %p destroyed, tmp file:%s, remains", pTSBuf, pTSBuf->path);
}
free(pTSBuf);
@@ -767,7 +767,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeId) {
assert(pDestBuf->fileSize == oldSize + size);
-// tscTrace("tsBuf merge success, %p, path:%s, fd:%d, file size:%d, numOfVnode:%d, autoDelete:%d", pDestBuf,
+// tscDebug("tsBuf merge success, %p, path:%s, fd:%d, file size:%d, numOfVnode:%d, autoDelete:%d", pDestBuf,
// pDestBuf->path, fileno(pDestBuf->f), pDestBuf->fileSize, pDestBuf->numOfVnodes, pDestBuf->autoDelete);
return 0;
@@ -884,7 +884,7 @@ void tsBufDisplay(STSBuf* pTSBuf) {
while (tsBufNextPos(pTSBuf)) {
STSElem elem = tsBufGetElem(pTSBuf);
- printf("%d-%" PRId64 "-%" PRId64 "\n", elem.vnode, *(int64_t*) elem.tag, elem.ts);
+ printf("%d-%" PRId64 "-%" PRId64 "\n", elem.vnode, elem.tag, elem.ts);
}
pTSBuf->cur.order = old;
diff --git a/src/rpc/inc/rpcLog.h b/src/rpc/inc/rpcLog.h
index 10ef974298..0504ddac43 100644
--- a/src/rpc/inc/rpcLog.h
+++ b/src/rpc/inc/rpcLog.h
@@ -23,12 +23,17 @@ extern "C" {
#include "tlog.h"
extern int32_t rpcDebugFlag;
+extern int32_t tscEmbedded;
-#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR RPC ", rpcDebugFlag, __VA_ARGS__); }}
-#define tWarn(...) { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("WARN RPC ", rpcDebugFlag, __VA_ARGS__); }}
-#define tTrace(...) { if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC ", rpcDebugFlag, __VA_ARGS__); }}
-#define tDump(x, y) { if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); }}
-#define tPrint(...) { taosPrintLog("RPC ", 255, __VA_ARGS__); }
+#define tFatal(...) { if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
+#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR) { taosPrintLog("RPC ERROR ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
+#define tWarn(...) { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
+#define tInfo(...) { if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC INFO ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
+#define tDebug(...) { if (rpcDebugFlag & DEBUG_DEBUG) { taosPrintLog("RPC DEBUG ", rpcDebugFlag, __VA_ARGS__); }}
+#define tTrace(...) { if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC TRACE ", rpcDebugFlag, __VA_ARGS__); }}
+
+#define tDebugDump(x, y) { if (rpcDebugFlag & DEBUG_DEBUG) { taosDumpData((unsigned char *)x, y); }}
+#define tTraceDump(x, y) { if (rpcDebugFlag & DEBUG_TRACE) { taosDumpData((unsigned char *)x, y); }}
#ifdef __cplusplus
}
diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c
index 1a81f32cf2..3ab0dddb5c 100644
--- a/src/rpc/src/rpcMain.c
+++ b/src/rpc/src/rpcMain.c
@@ -58,7 +58,7 @@ typedef struct {
void (*cfp)(SRpcMsg *, SRpcIpSet *);
int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey);
- int refCount;
+ int32_t refCount;
void *idPool; // handle to ID pool
void *tmrCtrl; // handle to timer
SHashObj *hash; // handle returned by hash utility
@@ -288,7 +288,7 @@ void *rpcOpen(const SRpcInit *pInit) {
return NULL;
}
- tTrace("%s rpc is openned, threads:%d sessions:%d", pRpc->label, pRpc->numOfThreads, pInit->sessions);
+ tDebug("%s rpc is openned, threads:%d sessions:%d", pRpc->label, pRpc->numOfThreads, pInit->sessions);
return pRpc;
}
@@ -311,7 +311,7 @@ void rpcClose(void *param) {
(*taosCleanUpConn[pRpc->connType | RPC_CONN_TCP])(pRpc->tcphandle);
(*taosCleanUpConn[pRpc->connType])(pRpc->udphandle);
- tTrace("%s rpc is closed", pRpc->label);
+ tDebug("%s rpc is closed", pRpc->label);
rpcDecRef(pRpc);
}
@@ -331,6 +331,7 @@ void rpcFreeCont(void *cont) {
if ( cont ) {
char *temp = ((char *)cont) - sizeof(SRpcHead) - sizeof(SRpcReqContext);
free(temp);
+ // tTrace("free mem: %p", temp);
}
}
@@ -405,7 +406,7 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
rpcLockConn(pConn);
if ( pConn->inType == 0 || pConn->user[0] == 0 ) {
- tTrace("%s, connection is already released, rsp wont be sent", pConn->info);
+ tDebug("%s, connection is already released, rsp wont be sent", pConn->info);
rpcUnlockConn(pConn);
rpcFreeCont(pMsg->pCont);
rpcDecRef(pRpc);
@@ -514,7 +515,7 @@ int rpcReportProgress(void *handle, char *pCont, int contLen) {
pConn->pReqMsg = pCont;
pConn->reqMsgLen = contLen;
} else {
- tTrace("%s, rpc connection is already released", pConn->info);
+ tDebug("%s, rpc connection is already released", pConn->info);
rpcFreeCont(pCont);
code = -1;
}
@@ -529,7 +530,7 @@ void rpcCancelRequest(void *handle) {
SRpcReqContext *pContext = handle;
if (pContext->pConn) {
- tTrace("%s, app trys to cancel request", pContext->pConn->info);
+ tDebug("%s, app trys to cancel request", pContext->pConn->info);
rpcCloseConn(pContext->pConn);
pContext->pConn = NULL;
rpcFreeCont(pContext->pCont);
@@ -540,6 +541,7 @@ static void rpcFreeMsg(void *msg) {
if ( msg ) {
char *temp = (char *)msg - sizeof(SRpcReqContext);
free(temp);
+ // tTrace("free mem: %p", temp);
}
}
@@ -610,7 +612,7 @@ static void rpcReleaseConn(SRpcConn *pConn) {
pConn->pContext = NULL;
taosFreeId(pRpc->idPool, pConn->sid);
- tTrace("%s, rpc connection is released", pConn->info);
+ tDebug("%s, rpc connection is released", pConn->info);
}
static void rpcCloseConn(void *thandle) {
@@ -642,7 +644,7 @@ static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc) {
pConn->spi = pRpc->spi;
pConn->encrypt = pRpc->encrypt;
if (pConn->spi) memcpy(pConn->secret, pRpc->secret, TSDB_KEY_LEN);
- tTrace("%s %p client connection is allocated", pRpc->label, pConn);
+ tDebug("%s %p client connection is allocated", pRpc->label, pConn);
}
return pConn;
@@ -697,7 +699,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
}
taosHashPut(pRpc->hash, hashstr, size, (char *)&pConn, POINTER_BYTES);
- tTrace("%s %p server connection is allocated", pRpc->label, pConn);
+ tDebug("%s %p server connection is allocated", pRpc->label, pConn);
}
return pConn;
@@ -759,7 +761,7 @@ static int rpcProcessReqHead(SRpcConn *pConn, SRpcHead *pHead) {
pConn->peerId = pHead->sourceId;
} else {
if (pConn->peerId != pHead->sourceId) {
- tTrace("%s, source Id is changed, old:0x%08x new:0x%08x", pConn->info,
+ tDebug("%s, source Id is changed, old:0x%08x new:0x%08x", pConn->info,
pConn->peerId, pHead->sourceId);
return TSDB_CODE_RPC_INVALID_VALUE;
}
@@ -768,16 +770,16 @@ static int rpcProcessReqHead(SRpcConn *pConn, SRpcHead *pHead) {
if (pConn->inTranId == pHead->tranId) {
if (pConn->inType == pHead->msgType) {
if (pHead->code == 0) {
- tTrace("%s, %s is retransmitted", pConn->info, taosMsg[pHead->msgType]);
+ tDebug("%s, %s is retransmitted", pConn->info, taosMsg[pHead->msgType]);
rpcSendQuickRsp(pConn, TSDB_CODE_RPC_ACTION_IN_PROGRESS);
} else {
// do nothing, it is heart beat from client
}
} else if (pConn->inType == 0) {
- tTrace("%s, %s is already processed, tranId:%d", pConn->info, taosMsg[pHead->msgType], pConn->inTranId);
+ tDebug("%s, %s is already processed, tranId:%d", pConn->info, taosMsg[pHead->msgType], pConn->inTranId);
rpcSendMsgToPeer(pConn, pConn->pRspMsg, pConn->rspMsgLen); // resend the response
} else {
- tTrace("%s, mismatched message %s and tranId", pConn->info, taosMsg[pHead->msgType]);
+ tDebug("%s, mismatched message %s and tranId", pConn->info, taosMsg[pHead->msgType]);
}
// do not reply any message
@@ -785,7 +787,7 @@ static int rpcProcessReqHead(SRpcConn *pConn, SRpcHead *pHead) {
}
if (pConn->inType != 0) {
- tTrace("%s, last session is not finished, inTranId:%d tranId:%d", pConn->info,
+ tDebug("%s, last session is not finished, inTranId:%d tranId:%d", pConn->info,
pConn->inTranId, pHead->tranId);
return TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED;
}
@@ -816,23 +818,25 @@ static int rpcProcessRspHead(SRpcConn *pConn, SRpcHead *pHead) {
pConn->retry = 0;
if (pHead->code == TSDB_CODE_RPC_AUTH_REQUIRED && pRpc->spi) {
- tTrace("%s, authentication shall be restarted", pConn->info);
+ tDebug("%s, authentication shall be restarted", pConn->info);
pConn->secured = 0;
rpcSendMsgToPeer(pConn, pConn->pReqMsg, pConn->reqMsgLen);
- pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl);
+ if (pConn->connType != RPC_CONN_TCPC)
+ pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl);
return TSDB_CODE_RPC_ALREADY_PROCESSED;
}
if (pHead->code == TSDB_CODE_RPC_ACTION_IN_PROGRESS) {
if (pConn->tretry <= tsRpcMaxRetry) {
- tTrace("%s, peer is still processing the transaction, retry:%d", pConn->info, pConn->tretry);
+ tDebug("%s, peer is still processing the transaction, retry:%d", pConn->info, pConn->tretry);
pConn->tretry++;
rpcSendReqHead(pConn);
- pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl);
+ if (pConn->connType != RPC_CONN_TCPC)
+ pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl);
return TSDB_CODE_RPC_ALREADY_PROCESSED;
} else {
// peer still in processing, give up
- tTrace("%s, server processing takes too long time, give up", pConn->info);
+ tDebug("%s, server processing takes too long time, give up", pConn->info);
pHead->code = TSDB_CODE_RPC_TOO_SLOW;
}
}
@@ -853,19 +857,19 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
sid = htonl(pHead->destId);
if (pHead->msgType >= TSDB_MSG_TYPE_MAX || pHead->msgType <= 0) {
- tTrace("%s sid:%d, invalid message type:%d", pRpc->label, sid, pHead->msgType);
+ tDebug("%s sid:%d, invalid message type:%d", pRpc->label, sid, pHead->msgType);
terrno = TSDB_CODE_RPC_INVALID_MSG_TYPE; return NULL;
}
if (sid < 0 || sid >= pRpc->sessions) {
- tTrace("%s sid:%d, sid is out of range, max sid:%d, %s discarded", pRpc->label, sid,
+ tDebug("%s sid:%d, sid is out of range, max sid:%d, %s discarded", pRpc->label, sid,
pRpc->sessions, taosMsg[pHead->msgType]);
terrno = TSDB_CODE_RPC_INVALID_SESSION_ID; return NULL;
}
pConn = rpcGetConnObj(pRpc, sid, pRecv);
if (pConn == NULL) {
- tTrace("%s %p, failed to get connection obj(%s)", pRpc->label, (void *)pHead->ahandle, tstrerror(terrno));
+ tDebug("%s %p, failed to get connection obj(%s)", pRpc->label, (void *)pHead->ahandle, tstrerror(terrno));
return NULL;
}
@@ -896,8 +900,12 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
terrno = rpcProcessReqHead(pConn, pHead);
pConn->connType = pRecv->connType;
- // client shall send the request within tsRpcTime again, double it
- taosTmrReset(rpcProcessIdleTimer, tsRpcTimer*2, pConn, pRpc->tmrCtrl, &pConn->pIdleTimer);
+ // stop idle timer
+ taosTmrStopA(&pConn->pIdleTimer);
+
+ // client shall send the request within tsRpcTime again for UDP, double it
+ if (pConn->connType != RPC_CONN_TCPS)
+ pConn->pIdleTimer = taosTmrStart(rpcProcessIdleTimer, tsRpcTimer*2, pConn, pRpc->tmrCtrl);
} else {
terrno = rpcProcessRspHead(pConn, pHead);
}
@@ -914,7 +922,7 @@ static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
// if there are pending request, notify the app
rpcAddRef(pRpc);
- tTrace("%s, notify the server app, connection is gone", pConn->info);
+ tDebug("%s, notify the server app, connection is gone", pConn->info);
SRpcMsg rpcMsg;
rpcMsg.pCont = pConn->pReqMsg; // pReqMsg is re-used to store the APP context from server
@@ -931,7 +939,7 @@ static void rpcReportBrokenLinkToServer(SRpcConn *pConn) {
static void rpcProcessBrokenLink(SRpcConn *pConn) {
if (pConn == NULL) return;
SRpcInfo *pRpc = pConn->pRpc;
- tTrace("%s, link is broken", pConn->info);
+ tDebug("%s, link is broken", pConn->info);
rpcLockConn(pConn);
@@ -952,7 +960,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
SRpcInfo *pRpc = (SRpcInfo *)pRecv->shandle;
SRpcConn *pConn = (SRpcConn *)pRecv->thandle;
- tDump(pRecv->msg, pRecv->msgLen);
+ tTraceDump(pRecv->msg, pRecv->msgLen);
// underlying UDP layer does not know it is server or client
pRecv->connType = pRecv->connType | pRpc->connType;
@@ -965,7 +973,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
terrno = 0;
pConn = rpcProcessMsgHead(pRpc, pRecv);
- tTrace("%s %p %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x",
+ tDebug("%s %p %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x",
pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType], pRecv->ip, pRecv->port, terrno,
pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->code);
@@ -974,7 +982,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) {
if (code != 0) { // parsing error
if (rpcIsReq(pHead->msgType)) {
rpcSendErrorMsgToPeer(pRecv, code);
- tTrace("%s %p %p, %s is sent with error code:%x", pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType+1], code);
+ tDebug("%s %p %p, %s is sent with error code:%x", pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType+1], code);
}
} else { // msg is passed to app only parsing is ok
rpcProcessIncomingMsg(pConn, pHead);
@@ -1024,7 +1032,8 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
rpcAddRef(pRpc); // add the refCount for requests
// start the progress timer to monitor the response from server app
- pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pRpc->tmrCtrl);
+ if (pConn->connType != RPC_CONN_TCPS)
+ pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pRpc->tmrCtrl);
// notify the server app
(*(pRpc->cfp))(&rpcMsg, NULL);
@@ -1052,13 +1061,15 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
if (pHead->code == TSDB_CODE_RPC_REDIRECT) {
pContext->numOfTry = 0;
memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet));
- tTrace("%s, redirect is received, numOfIps:%d", pConn->info, pContext->ipSet.numOfIps);
+ tDebug("%s, redirect is received, numOfIps:%d", pConn->info, pContext->ipSet.numOfIps);
for (int i=0; iipSet.numOfIps; ++i)
pContext->ipSet.port[i] = htons(pContext->ipSet.port[i]);
rpcSendReqToServer(pRpc, pContext);
+ rpcFreeCont(rpcMsg.pCont);
} else if (pHead->code == TSDB_CODE_RPC_NOT_READY) {
pContext->code = pHead->code;
rpcProcessConnError(pContext, NULL);
+ rpcFreeCont(rpcMsg.pCont);
} else {
rpcNotifyClient(pContext, &rpcMsg);
}
@@ -1187,7 +1198,8 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) {
pConn->pContext = pContext;
rpcSendMsgToPeer(pConn, msg, msgLen);
- taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer);
+ if (pConn->connType != RPC_CONN_TCPC)
+ taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer);
rpcUnlockConn(pConn);
}
@@ -1199,12 +1211,12 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
msgLen = rpcAddAuthPart(pConn, msg, msgLen);
if ( rpcIsReq(pHead->msgType)) {
- tTrace("%s, %s is sent to %s:%hu, len:%d sig:0x%08x:0x%08x:%d",
+ tDebug("%s, %s is sent to %s:%hu, len:%d sig:0x%08x:0x%08x:%d",
pConn->info, taosMsg[pHead->msgType], pConn->peerFqdn, pConn->peerPort,
msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
} else {
if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured
- tTrace("%s, %s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d",
+ tDebug("%s, %s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d",
pConn->info, taosMsg[pHead->msgType], pConn->peerIp, pConn->peerPort,
htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
}
@@ -1216,7 +1228,7 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
tError("%s, failed to send, msgLen:%d written:%d, reason:%s", pConn->info, msgLen, writtenLen, strerror(errno));
}
- tDump(msg, msgLen);
+ tTraceDump(msg, msgLen);
}
static void rpcProcessConnError(void *param, void *id) {
@@ -1228,7 +1240,7 @@ static void rpcProcessConnError(void *param, void *id) {
return;
}
- tTrace("%s %p, connection error happens", pRpc->label, pContext->ahandle);
+ tDebug("%s %p, connection error happens", pRpc->label, pContext->ahandle);
if (pContext->numOfTry >= pContext->ipSet.numOfIps) {
rpcMsg.msgType = pContext->msgType+1;
@@ -1253,17 +1265,17 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) {
rpcLockConn(pConn);
if (pConn->outType && pConn->user[0]) {
- tTrace("%s, expected %s is not received", pConn->info, taosMsg[(int)pConn->outType + 1]);
+ tDebug("%s, expected %s is not received", pConn->info, taosMsg[(int)pConn->outType + 1]);
pConn->pTimer = NULL;
pConn->retry++;
if (pConn->retry < 4) {
- tTrace("%s, re-send msg:%s to %s:%hu", pConn->info, taosMsg[pConn->outType], pConn->peerFqdn, pConn->peerPort);
+ tDebug("%s, re-send msg:%s to %s:%hu", pConn->info, taosMsg[pConn->outType], pConn->peerFqdn, pConn->peerPort);
rpcSendMsgToPeer(pConn, pConn->pReqMsg, pConn->reqMsgLen);
pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl);
} else {
// close the connection
- tTrace("%s, failed to send msg:%s to %s:%hu", pConn->info, taosMsg[pConn->outType], pConn->peerFqdn, pConn->peerPort);
+ tDebug("%s, failed to send msg:%s to %s:%hu", pConn->info, taosMsg[pConn->outType], pConn->peerFqdn, pConn->peerPort);
if (pConn->pContext) {
pConn->pContext->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
taosTmrStart(rpcProcessConnError, 0, pConn->pContext, pRpc->tmrCtrl);
@@ -1271,7 +1283,7 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) {
}
}
} else {
- tTrace("%s, retry timer not processed", pConn->info);
+ tDebug("%s, retry timer not processed", pConn->info);
}
rpcUnlockConn(pConn);
@@ -1283,11 +1295,11 @@ static void rpcProcessIdleTimer(void *param, void *tmrId) {
rpcLockConn(pConn);
if (pConn->user[0]) {
- tTrace("%s, close the connection since no activity", pConn->info);
+ tDebug("%s, close the connection since no activity", pConn->info);
if (pConn->inType) rpcReportBrokenLinkToServer(pConn);
rpcReleaseConn(pConn);
} else {
- tTrace("%s, idle timer:%p not processed", pConn->info, tmrId);
+ tDebug("%s, idle timer:%p not processed", pConn->info, tmrId);
}
rpcUnlockConn(pConn);
@@ -1300,11 +1312,11 @@ static void rpcProcessProgressTimer(void *param, void *tmrId) {
rpcLockConn(pConn);
if (pConn->inType && pConn->user[0]) {
- tTrace("%s, progress timer expired, send progress", pConn->info);
+ tDebug("%s, progress timer expired, send progress", pConn->info);
rpcSendQuickRsp(pConn, TSDB_CODE_RPC_ACTION_IN_PROGRESS);
pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pRpc->tmrCtrl);
} else {
- tTrace("%s, progress timer:%p not processed", pConn->info, tmrId);
+ tDebug("%s, progress timer:%p not processed", pConn->info, tmrId);
}
rpcUnlockConn(pConn);
@@ -1338,7 +1350,7 @@ static int32_t rpcCompressRpcMsg(char* pCont, int32_t contLen) {
memcpy(pCont + overhead, buf, compLen);
pHead->comp = 1;
- //tTrace("compress rpc msg, before:%d, after:%d", contLen, compLen);
+ //tDebug("compress rpc msg, before:%d, after:%d", contLen, compLen);
finalLen = compLen + overhead;
} else {
finalLen = contLen;
@@ -1462,7 +1474,7 @@ static int rpcCheckAuthentication(SRpcConn *pConn, char *msg, int msgLen) {
code = TSDB_CODE_RPC_INVALID_TIME_STAMP;
} else {
if (rpcAuthenticateMsg(pHead, msgLen-TSDB_AUTH_LEN, pDigest->auth, pConn->secret) < 0) {
- tTrace("%s, authentication failed, msg discarded", pConn->info);
+ tDebug("%s, authentication failed, msg discarded", pConn->info);
code = TSDB_CODE_RPC_AUTH_FAILURE;
} else {
pHead->msgLen = (int32_t)htonl((uint32_t)pHead->msgLen) - sizeof(SRpcDigest);
@@ -1471,7 +1483,7 @@ static int rpcCheckAuthentication(SRpcConn *pConn, char *msg, int msgLen) {
}
}
} else {
- tTrace("%s, auth spi:%d not matched with received:%d", pConn->info, pConn->spi, pHead->spi);
+ tDebug("%s, auth spi:%d not matched with received:%d", pConn->info, pConn->spi, pHead->spi);
code = pHead->spi ? TSDB_CODE_RPC_AUTH_FAILURE : TSDB_CODE_RPC_AUTH_REQUIRED;
}
@@ -1497,12 +1509,12 @@ static void rpcUnlockConn(SRpcConn *pConn) {
static void rpcAddRef(SRpcInfo *pRpc)
{
- atomic_add_fetch_8(&pRpc->refCount, 1);
+ atomic_add_fetch_32(&pRpc->refCount, 1);
}
static void rpcDecRef(SRpcInfo *pRpc)
{
- if (atomic_sub_fetch_8(&pRpc->refCount, 1) == 0) {
+ if (atomic_sub_fetch_32(&pRpc->refCount, 1) == 0) {
taosHashCleanup(pRpc->hash);
taosTmrCleanUp(pRpc->tmrCtrl);
taosIdPoolCleanUp(pRpc->idPool);
@@ -1510,7 +1522,7 @@ static void rpcDecRef(SRpcInfo *pRpc)
tfree(pRpc->connList);
pthread_mutex_destroy(&pRpc->mutex);
- tTrace("%s rpc resources are released", pRpc->label);
+ tDebug("%s rpc resources are released", pRpc->label);
tfree(pRpc);
}
}
diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c
index 82168f0b0e..ff8d055fd4 100644
--- a/src/rpc/src/rpcTcp.c
+++ b/src/rpc/src/rpcTcp.c
@@ -152,7 +152,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
taosCleanUpTcpServer(pServerObj);
pServerObj = NULL;
} else {
- tTrace("%s TCP server is initialized, ip:0x%x port:%hu numOfThreads:%d", label, ip, port, numOfThreads);
+ tDebug("%s TCP server is initialized, ip:0x%x port:%hu numOfThreads:%d", label, ip, port, numOfThreads);
}
pthread_attr_destroy(&thattr);
@@ -197,7 +197,7 @@ void taosStopTcpServer(void *handle) {
if(pServerObj->fd >=0) shutdown(pServerObj->fd, SHUT_RD);
if(pServerObj->thread) pthread_join(pServerObj->thread, NULL);
- tTrace("%s TCP server is stopped", pServerObj->label);
+ tDebug("%s TCP server is stopped", pServerObj->label);
}
void taosCleanUpTcpServer(void *handle) {
@@ -211,7 +211,7 @@ void taosCleanUpTcpServer(void *handle) {
pthread_mutex_destroy(&(pThreadObj->mutex));
}
- tTrace("%s TCP server is cleaned up", pServerObj->label);
+ tDebug("%s TCP server is cleaned up", pServerObj->label);
tfree(pServerObj->pThreadObj);
tfree(pServerObj);
@@ -225,14 +225,14 @@ static void *taosAcceptTcpConnection(void *arg) {
SServerObj *pServerObj;
pServerObj = (SServerObj *)arg;
- tTrace("%s TCP server is ready, ip:0x%x:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
+ tDebug("%s TCP server is ready, ip:0x%x:%hu", pServerObj->label, pServerObj->ip, pServerObj->port);
while (1) {
socklen_t addrlen = sizeof(caddr);
connFd = accept(pServerObj->fd, (struct sockaddr *)&caddr, &addrlen);
if (connFd == -1) {
if (errno == EINVAL) {
- tTrace("%s TCP server stop accepting new connections, exiting", pServerObj->label);
+ tDebug("%s TCP server stop accepting new connections, exiting", pServerObj->label);
break;
}
@@ -249,7 +249,7 @@ static void *taosAcceptTcpConnection(void *arg) {
if (pFdObj) {
pFdObj->ip = caddr.sin_addr.s_addr;
pFdObj->port = htons(caddr.sin_port);
- tTrace("%s new TCP connection from %s:%hu, fd:%d FD:%p numOfFds:%d", pServerObj->label,
+ tDebug("%s new TCP connection from %s:%hu, fd:%d FD:%p numOfFds:%d", pServerObj->label,
inet_ntoa(caddr.sin_addr), pFdObj->port, connFd, pFdObj, pThreadObj->numOfFds);
} else {
close(connFd);
@@ -305,7 +305,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
return NULL;
}
- tTrace("%s TCP client is initialized, ip:%u:%hu", label, ip, port);
+ tDebug("%s TCP client is initialized, ip:%u:%hu", label, ip, port);
return pThreadObj;
}
@@ -314,7 +314,7 @@ void taosStopTcpClient(void *chandle) {
SThreadObj *pThreadObj = chandle;
if (pThreadObj == NULL) return;
- tTrace ("%s TCP client is stopped", pThreadObj->label);
+ tDebug ("%s TCP client is stopped", pThreadObj->label);
}
void taosCleanUpTcpClient(void *chandle) {
@@ -322,7 +322,7 @@ void taosCleanUpTcpClient(void *chandle) {
if (pThreadObj == NULL) return;
taosStopTcpThread(pThreadObj);
- tTrace ("%s TCP client is cleaned up", pThreadObj->label);
+ tDebug ("%s TCP client is cleaned up", pThreadObj->label);
tfree(pThreadObj);
}
@@ -347,7 +347,7 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, uint32_t ip, uin
pFdObj->thandle = thandle;
pFdObj->port = port;
pFdObj->ip = ip;
- tTrace("%s %p TCP connection to 0x%x:%hu is created, localPort:%hu FD:%p numOfFds:%d",
+ tDebug("%s %p TCP connection to 0x%x:%hu is created, localPort:%hu FD:%p numOfFds:%d",
pThreadObj->label, thandle, ip, port, localPort, pFdObj, pThreadObj->numOfFds);
} else {
close(fd);
@@ -362,7 +362,7 @@ void taosCloseTcpConnection(void *chandle) {
if (pFdObj == NULL) return;
SThreadObj *pThreadObj = pFdObj->pThreadObj;
- tTrace("%s %p TCP connection will be closed, FD:%p", pThreadObj->label, pFdObj->thandle, pFdObj);
+ tDebug("%s %p TCP connection will be closed, FD:%p", pThreadObj->label, pFdObj->thandle, pFdObj);
// pFdObj->thandle = NULL;
pFdObj->closedByApp = 1;
@@ -409,7 +409,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
headLen = taosReadMsg(pFdObj->fd, &rpcHead, sizeof(SRpcHead));
if (headLen != sizeof(SRpcHead)) {
- tTrace("%s %p read error, headLen:%d", pThreadObj->label, pFdObj->thandle, headLen);
+ tDebug("%s %p read error, headLen:%d", pThreadObj->label, pFdObj->thandle, headLen);
return -1;
}
@@ -418,6 +418,8 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
if ( NULL == buffer) {
tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen);
return -1;
+ } else {
+ // tDebug("malloc mem: %p", buffer);
}
msg = buffer + tsRpcOverhead;
@@ -461,7 +463,7 @@ static void *taosProcessTcpData(void *param) {
while (1) {
int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, -1);
if (pThreadObj->stop) {
- tTrace("%s TCP thread get stop event, exiting...", pThreadObj->label);
+ tDebug("%s TCP thread get stop event, exiting...", pThreadObj->label);
break;
}
if (fdNum < 0) continue;
@@ -470,19 +472,19 @@ static void *taosProcessTcpData(void *param) {
pFdObj = events[i].data.ptr;
if (events[i].events & EPOLLERR) {
- tTrace("%s %p FD:%p epoll errors", pThreadObj->label, pFdObj->thandle, pFdObj);
+ tDebug("%s %p FD:%p epoll errors", pThreadObj->label, pFdObj->thandle, pFdObj);
taosReportBrokenLink(pFdObj);
continue;
}
if (events[i].events & EPOLLRDHUP) {
- tTrace("%s %p FD:%p RD hang up", pThreadObj->label, pFdObj->thandle, pFdObj);
+ tDebug("%s %p FD:%p RD hang up", pThreadObj->label, pFdObj->thandle, pFdObj);
taosReportBrokenLink(pFdObj);
continue;
}
if (events[i].events & EPOLLHUP) {
- tTrace("%s %p FD:%p hang up", pThreadObj->label, pFdObj->thandle, pFdObj);
+ tDebug("%s %p FD:%p hang up", pThreadObj->label, pFdObj->thandle, pFdObj);
taosReportBrokenLink(pFdObj);
continue;
}
@@ -566,7 +568,7 @@ static void taosFreeFdObj(SFdObj *pFdObj) {
pthread_mutex_unlock(&pThreadObj->mutex);
- tTrace("%s %p TCP connection is closed, FD:%p numOfFds:%d",
+ tDebug("%s %p TCP connection is closed, FD:%p numOfFds:%d",
pThreadObj->label, pFdObj->thandle, pFdObj, pThreadObj->numOfFds);
tfree(pFdObj);
diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c
index a4c7d6c145..91324da474 100644
--- a/src/rpc/src/rpcUdp.c
+++ b/src/rpc/src/rpcUdp.c
@@ -126,7 +126,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
return NULL;
}
- tTrace("%s UDP connection is initialized, ip:%x:%hu threads:%d", label, ip, port, threads);
+ tDebug("%s UDP connection is initialized, ip:%x:%hu threads:%d", label, ip, port, threads);
return pSet;
}
@@ -149,7 +149,7 @@ void taosStopUdpConnection(void *handle) {
// tTrace("%s UDP thread is closed, index:%d", pConn->label, i);
}
- tTrace("%s UDP is stopped", pSet->label);
+ tDebug("%s UDP is stopped", pSet->label);
}
void taosCleanUpUdpConnection(void *handle) {
@@ -163,7 +163,7 @@ void taosCleanUpUdpConnection(void *handle) {
if (pConn->fd >=0) taosCloseSocket(pConn->fd);
}
- tTrace("%s UDP is cleaned up", pSet->label);
+ tDebug("%s UDP is cleaned up", pSet->label);
tfree(pSet);
}
@@ -175,7 +175,7 @@ void *taosOpenUdpConnection(void *shandle, void *thandle, uint32_t ip, uint16_t
SUdpConn *pConn = pSet->udpConn + pSet->index;
pConn->port = port;
- tTrace("%s UDP connection is setup, ip:%x:%hu localPort:%hu", pConn->label, ip, port, pConn->localPort);
+ tDebug("%s UDP connection is setup, ip:%x:%hu localPort:%hu", pConn->label, ip, port, pConn->localPort);
return pConn;
}
@@ -190,13 +190,13 @@ static void *taosRecvUdpData(void *param) {
memset(&sourceAdd, 0, sizeof(sourceAdd));
addLen = sizeof(sourceAdd);
- tTrace("%s UDP thread is created, index:%d", pConn->label, pConn->index);
+ tDebug("%s UDP thread is created, index:%d", pConn->label, pConn->index);
char *msg = pConn->buffer;
while (1) {
dataLen = recvfrom(pConn->fd, pConn->buffer, RPC_MAX_UDP_SIZE, 0, (struct sockaddr *)&sourceAdd, &addLen);
if(dataLen <= 0) {
- tTrace("%s UDP socket was closed, exiting(%s)", pConn->label, strerror(errno));
+ tDebug("%s UDP socket was closed, exiting(%s)", pConn->label, strerror(errno));
break;
}
@@ -211,6 +211,8 @@ static void *taosRecvUdpData(void *param) {
if (NULL == tmsg) {
tError("%s failed to allocate memory, size:%ld", pConn->label, dataLen);
continue;
+ } else {
+ // tTrace("malloc mem: %p", tmsg);
}
tmsg += tsRpcOverhead; // overhead for SRpcReqContext
diff --git a/src/rpc/test/rclient.c b/src/rpc/test/rclient.c
index d4e67fb1ec..1bc64b0825 100644
--- a/src/rpc/test/rclient.c
+++ b/src/rpc/test/rclient.c
@@ -34,7 +34,7 @@ typedef struct {
static void processResponse(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)pMsg->handle;
- tTrace("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code);
+ tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code);
if (pIpSet) pInfo->ipSet = *pIpSet;
@@ -48,7 +48,7 @@ static void *sendRequest(void *param) {
SInfo *pInfo = (SInfo *)param;
SRpcMsg rpcMsg;
- tTrace("thread:%d, start to send request", pInfo->index);
+ tDebug("thread:%d, start to send request", pInfo->index);
while ( pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) {
pInfo->num++;
@@ -56,14 +56,14 @@ static void *sendRequest(void *param) {
rpcMsg.contLen = pInfo->msgSize;
rpcMsg.handle = pInfo;
rpcMsg.msgType = 1;
- tTrace("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
+ tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
rpcSendRequest(pInfo->pRpc, &pInfo->ipSet, &rpcMsg);
if ( pInfo->num % 20000 == 0 )
- tPrint("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
+ tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
sem_wait(&pInfo->rspSem);
}
- tTrace("thread:%d, it is over", pInfo->index);
+ tDebug("thread:%d, it is over", pInfo->index);
tcount++;
return NULL;
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
return -1;
}
- tPrint("client is initialized");
+ tInfo("client is initialized");
gettimeofday(&systemTime, NULL);
startTime = systemTime.tv_sec*1000000 + systemTime.tv_usec;
@@ -184,8 +184,8 @@ int main(int argc, char *argv[]) {
endTime = systemTime.tv_sec*1000000 + systemTime.tv_usec;
float usedTime = (endTime - startTime)/1000.0; // mseconds
- tPrint("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs*appThreads);
- tPrint("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0*numOfReqs*appThreads/usedTime, msgSize);
+ tInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs*appThreads);
+ tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0*numOfReqs*appThreads/usedTime, msgSize);
getchar();
diff --git a/src/rpc/test/rsclient.c b/src/rpc/test/rsclient.c
index 01c7a353c5..266697d555 100644
--- a/src/rpc/test/rsclient.c
+++ b/src/rpc/test/rsclient.c
@@ -41,7 +41,7 @@ static void *sendRequest(void *param) {
SInfo *pInfo = (SInfo *)param;
SRpcMsg rpcMsg, rspMsg;
- tTrace("thread:%d, start to send request", pInfo->index);
+ tDebug("thread:%d, start to send request", pInfo->index);
while ( pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) {
pInfo->num++;
@@ -49,22 +49,22 @@ static void *sendRequest(void *param) {
rpcMsg.contLen = pInfo->msgSize;
rpcMsg.handle = pInfo;
rpcMsg.msgType = 1;
- tTrace("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
+ tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num);
rpcSendRecv(pInfo->pRpc, &pInfo->ipSet, &rpcMsg, &rspMsg);
// handle response
if (rspMsg.code != 0) terror++;
- tTrace("thread:%d, rspLen:%d code:%d", pInfo->index, rspMsg.contLen, rspMsg.code);
+ tDebug("thread:%d, rspLen:%d code:%d", pInfo->index, rspMsg.contLen, rspMsg.code);
rpcFreeCont(rspMsg.pCont);
if ( pInfo->num % 20000 == 0 )
- tPrint("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
+ tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num);
}
- tTrace("thread:%d, it is over", pInfo->index);
+ tDebug("thread:%d, it is over", pInfo->index);
tcount++;
return NULL;
@@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
return -1;
}
- tPrint("client is initialized");
+ tInfo("client is initialized");
gettimeofday(&systemTime, NULL);
startTime = systemTime.tv_sec*1000000 + systemTime.tv_usec;
@@ -185,8 +185,8 @@ int main(int argc, char *argv[]) {
endTime = systemTime.tv_sec*1000000 + systemTime.tv_usec;
float usedTime = (endTime - startTime)/1000.0; // mseconds
- tPrint("it takes %.3f mseconds to send %d requests to server, error num:%d", usedTime, numOfReqs*appThreads, terror);
- tPrint("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0*numOfReqs*appThreads/usedTime, msgSize);
+ tInfo("it takes %.3f mseconds to send %d requests to server, error num:%d", usedTime, numOfReqs*appThreads, terror);
+ tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0*numOfReqs*appThreads/usedTime, msgSize);
taosCloseLog();
diff --git a/src/rpc/test/rserver.c b/src/rpc/test/rserver.c
index 71e7c62b9e..1ac9409a57 100644
--- a/src/rpc/test/rserver.c
+++ b/src/rpc/test/rserver.c
@@ -40,14 +40,14 @@ void processShellMsg() {
continue;
}
- tTrace("%d shell msgs are received", numOfMsgs);
+ tDebug("%d shell msgs are received", numOfMsgs);
for (int i=0; i=0) {
if ( write(dataFd, pRpcMsg->pCont, pRpcMsg->contLen) <0 ) {
- tPrint("failed to write data file, reason:%s", strerror(errno));
+ tInfo("failed to write data file, reason:%s", strerror(errno));
}
}
}
@@ -55,11 +55,11 @@ void processShellMsg() {
if (commit >=2) {
num += numOfMsgs;
if ( fsync(dataFd) < 0 ) {
- tPrint("failed to flush data to file, reason:%s", strerror(errno));
+ tInfo("failed to flush data to file, reason:%s", strerror(errno));
}
if (num % 10000 == 0) {
- tPrint("%d request have been written into disk", num);
+ tInfo("%d request have been written into disk", num);
}
}
@@ -120,7 +120,7 @@ void processRequestMsg(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
pTemp = taosAllocateQitem(sizeof(SRpcMsg));
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
- tTrace("request is received, type:%d, contLen:%d, item:%p", pMsg->msgType, pMsg->contLen, pTemp);
+ tDebug("request is received, type:%d, contLen:%d, item:%p", pMsg->msgType, pMsg->contLen, pTemp);
taosWriteQitem(qhandle, TAOS_QTYPE_RPC, pTemp);
}
@@ -180,12 +180,12 @@ int main(int argc, char *argv[]) {
return -1;
}
- tPrint("RPC server is running, ctrl-c to exit");
+ tInfo("RPC server is running, ctrl-c to exit");
if (commit) {
dataFd = open(dataName, O_APPEND | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO);
if (dataFd<0)
- tPrint("failed to open data file, reason:%s", strerror(errno));
+ tInfo("failed to open data file, reason:%s", strerror(errno));
}
qhandle = taosOpenQueue(sizeof(SRpcMsg));
diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h
index 7365d7b151..d80df4c9c3 100644
--- a/src/tsdb/inc/tsdbMain.h
+++ b/src/tsdb/inc/tsdbMain.h
@@ -33,10 +33,12 @@ extern "C" {
extern int tsdbDebugFlag;
-#define tsdbError(...) { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR TDB ", tsdbDebugFlag, __VA_ARGS__); }}
-#define tsdbWarn(...) { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN TDB ", tsdbDebugFlag, __VA_ARGS__); }}
-#define tsdbTrace(...) { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }}
-#define tsdbPrint(...) { taosPrintLog("TDB ", 255, __VA_ARGS__); }
+#define tsdbFatal(...) { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", 255, __VA_ARGS__); }}
+#define tsdbError(...) { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", 255, __VA_ARGS__); }}
+#define tsdbWarn(...) { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", 255, __VA_ARGS__); }}
+#define tsdbInfo(...) { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB INFO ", 255, __VA_ARGS__); }}
+#define tsdbDebug(...) { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB DEBUG ", tsdbDebugFlag, __VA_ARGS__); }}
+#define tsdbTrace(...) { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB TRACE ", tsdbDebugFlag, __VA_ARGS__); }}
#define TSDB_MAX_TABLE_SCHEMAS 16
#define TSDB_FILE_HEAD_SIZE 512
diff --git a/src/tsdb/src/tsdbBuffer.c b/src/tsdb/src/tsdbBuffer.c
index 2084203814..dcc9d4ca1b 100644
--- a/src/tsdb/src/tsdbBuffer.c
+++ b/src/tsdb/src/tsdbBuffer.c
@@ -85,7 +85,7 @@ int tsdbOpenBufPool(STsdbRepo *pRepo) {
pPool->nBufBlocks++;
}
- tsdbTrace("vgId:%d buffer pool is opened! bufBlockSize:%d tBufBlocks:%d nBufBlocks:%d", REPO_ID(pRepo),
+ tsdbDebug("vgId:%d buffer pool is opened! bufBlockSize:%d tBufBlocks:%d nBufBlocks:%d", REPO_ID(pRepo),
pPool->bufBlockSize, pPool->tBufBlocks, pPool->nBufBlocks);
return 0;
@@ -110,7 +110,7 @@ void tsdbCloseBufPool(STsdbRepo *pRepo) {
}
}
- tsdbTrace("vgId:%d buffer pool is closed", REPO_ID(pRepo));
+ tsdbDebug("vgId:%d buffer pool is closed", REPO_ID(pRepo));
}
SListNode *tsdbAllocBufBlockFromPool(STsdbRepo *pRepo) {
@@ -134,7 +134,7 @@ SListNode *tsdbAllocBufBlockFromPool(STsdbRepo *pRepo) {
pBufBlock->offset = 0;
pBufBlock->remain = pBufPool->bufBlockSize;
- tsdbTrace("vgId:%d buffer block is allocated, blockId:%" PRId64, REPO_ID(pRepo), pBufBlock->blockId);
+ tsdbDebug("vgId:%d buffer block is allocated, blockId:%" PRId64, REPO_ID(pRepo), pBufBlock->blockId);
return pNode;
}
diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c
index 8ebb62f341..ed5f62d3da 100644
--- a/src/tsdb/src/tsdbFile.c
+++ b/src/tsdb/src/tsdbFile.c
@@ -114,7 +114,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
}
}
- tsdbTrace("vgId:%d file group %d init", REPO_ID(pRepo), fid);
+ tsdbDebug("vgId:%d file group %d init", REPO_ID(pRepo), fid);
pFileH->pFGroup[pFileH->nFGroups++] = fileGroup;
qsort((void *)(pFileH->pFGroup), pFileH->nFGroups, sizeof(SFileGroup), compFGroup);
diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c
index ce009f4089..6c6b313073 100644
--- a/src/tsdb/src/tsdbMain.c
+++ b/src/tsdb/src/tsdbMain.c
@@ -81,7 +81,7 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) {
if (tsdbSetRepoEnv(rootDir, pCfg) < 0) return -1;
- tsdbTrace(
+ tsdbDebug(
"vgId:%d tsdb env create succeed! cacheBlockSize %d totalBlocks %d maxTables %d daysPerFile %d keep "
"%d minRowsPerFileBlock %d maxRowsPerFileBlock %d precision %d compression %d",
pCfg->tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep,
@@ -128,7 +128,7 @@ TSDB_REPO_T *tsdbOpenRepo(char *rootDir, STsdbAppH *pAppH) {
// pRepo->state = TSDB_REPO_STATE_ACTIVE;
- tsdbTrace("vgId:%d open tsdb repository succeed!", REPO_ID(pRepo));
+ tsdbDebug("vgId:%d open tsdb repository succeed!", REPO_ID(pRepo));
return (TSDB_REPO_T *)pRepo;
@@ -157,7 +157,7 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
tsdbCloseBufPool(pRepo);
tsdbCloseMeta(pRepo);
tsdbFreeRepo(pRepo);
- tsdbTrace("vgId:%d repository is closed", vgId);
+ tsdbDebug("vgId:%d repository is closed", vgId);
}
int32_t tsdbInsertData(TSDB_REPO_T *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *pRsp) {
@@ -192,7 +192,7 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
struct stat fState;
- tsdbTrace("vgId:%d name:%s index:%d eindex:%d", pRepo->config.tsdbId, name, *index, eindex);
+ tsdbDebug("vgId:%d name:%s index:%d eindex:%d", pRepo->config.tsdbId, name, *index, eindex);
ASSERT(*index <= eindex);
char *sdup = strdup(pRepo->rootDir);
@@ -520,7 +520,7 @@ static int32_t tsdbSetRepoEnv(char *rootDir, STsdbCfg *pCfg) {
static int32_t tsdbUnsetRepoEnv(char *rootDir) {
taosRemoveDir(rootDir);
- tsdbTrace("repository %s is removed", rootDir);
+ tsdbDebug("repository %s is removed", rootDir);
return 0;
}
@@ -842,7 +842,7 @@ static int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression) {
int8_t ocompression = pRepo->config.compression;
pRepo->config.compression = compression;
- tsdbTrace("vgId:%d tsdb compression is changed from %d to %d", REPO_ID(pRepo), ocompression, compression);
+ tsdbDebug("vgId:%d tsdb compression is changed from %d to %d", REPO_ID(pRepo), ocompression, compression);
}
static int tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) {
@@ -884,7 +884,7 @@ static int tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) {
pthread_rwlock_unlock(&(pFileH->fhlock));
}
- tsdbTrace("vgId:%d keep is changed from %d to %d", REPO_ID(pRepo), okeep, keep);
+ tsdbDebug("vgId:%d keep is changed from %d to %d", REPO_ID(pRepo), okeep, keep);
return 0;
}
@@ -915,7 +915,7 @@ static int tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) {
sizeof(STableData *) * (maxTables - oldMaxTables));
}
- tsdbTrace("vgId:%d, tsdb maxTables is changed from %d to %d!", pRepo->config.tsdbId, oldMaxTables, maxTables);
+ tsdbDebug("vgId:%d, tsdb maxTables is changed from %d to %d!", pRepo->config.tsdbId, oldMaxTables, maxTables);
return 0;
}
@@ -973,7 +973,7 @@ static int tsdbCheckTableSchema(STsdbRepo *pRepo, SSubmitBlk *pBlock, STable *pT
if (pBlock->sversion == sversion) return 0;
if (pBlock->sversion > sversion) { // need to config
- tsdbTrace("vgId:%d table %s tid %d has version %d smaller than client version %d, try to config", REPO_ID(pRepo),
+ tsdbDebug("vgId:%d table %s tid %d has version %d smaller than client version %d, try to config", REPO_ID(pRepo),
TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), sversion, pBlock->sversion);
if (pRepo->appH.configFunc) {
void *msg = (*pRepo->appH.configFunc)(REPO_ID(pRepo), TABLE_TID(pTable));
@@ -1041,7 +1041,7 @@ static int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks) {
// pRepo->config.totalBlocks = totalBlocks;
// tsdbUnLockRepo((TsdbRepoT *)pRepo);
- // tsdbTrace("vgId:%d, tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks,
+ // tsdbDebug("vgId:%d, tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks,
// totalBlocks);
return 0;
}
diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c
index 1108340cf0..a8ec3b74b4 100644
--- a/src/tsdb/src/tsdbMemTable.c
+++ b/src/tsdb/src/tsdbMemTable.c
@@ -111,7 +111,7 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
ASSERT(pTableData->numOfRows == tSkipListGetSize(pTableData->pData));
}
- tsdbTrace("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
+ tsdbDebug("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), key);
return 0;
@@ -369,7 +369,7 @@ static void *tsdbCommitData(void *arg) {
ASSERT(pRepo->commit == 1);
ASSERT(pMem != NULL);
- tsdbPrint("vgId:%d start to commit! keyFirst %" PRId64 " keyLast %" PRId64 " numOfRows %" PRId64, REPO_ID(pRepo),
+ tsdbInfo("vgId:%d start to commit! keyFirst %" PRId64 " keyLast %" PRId64 " numOfRows %" PRId64, REPO_ID(pRepo),
pMem->keyFirst, pMem->keyLast, pMem->numOfRows);
// Create the iterator to read from cache
@@ -417,7 +417,7 @@ _exit:
tsdbDestroyTableIters(iters, pCfg->maxTables);
tsdbDestroyHelper(&whelper);
tsdbEndCommit(pRepo);
- tsdbPrint("vgId:%d commit over", pRepo->config.tsdbId);
+ tsdbInfo("vgId:%d commit over", pRepo->config.tsdbId);
return NULL;
}
@@ -509,7 +509,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
// Check if there are data to commit to this file
int hasDataToCommit = tsdbHasDataToCommit(iters, pCfg->maxTables, minKey, maxKey);
if (!hasDataToCommit) {
- tsdbTrace("vgId:%d no data to commit to file %d", REPO_ID(pRepo), fid);
+ tsdbDebug("vgId:%d no data to commit to file %d", REPO_ID(pRepo), fid);
return 0;
}
diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c
index 6b0224cad2..a31cb7efef 100644
--- a/src/tsdb/src/tsdbMeta.c
+++ b/src/tsdb/src/tsdbMeta.c
@@ -48,6 +48,8 @@ static int tsdbEncodeTable(void **buf, STable *pTable);
static void * tsdbDecodeTable(void *buf, STable **pRTable);
static int tsdbGetTableEncodeSize(int8_t act, STable *pTable);
static void * tsdbInsertTableAct(STsdbRepo *pRepo, int8_t act, void *buf, STable *pTable);
+static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable);
+static int tsdbRmTableFromMeta(STsdbRepo *pRepo, STable *pTable);
// ------------------ OUTER FUNCTIONS ------------------
int tsdbCreateTable(TSDB_REPO_T *repo, STableCfg *pCfg) {
@@ -117,13 +119,13 @@ int tsdbDropTable(TSDB_REPO_T *repo, STableId tableId) {
STable *pTable = tsdbGetTableByUid(pMeta, uid);
if (pTable == NULL) {
- tsdbError("vgId:%d failed to drop table since table not exists! tid:%d uid %" PRId64, REPO_ID(pRepo), tableId.tid,
+ tsdbError("vgId:%d failed to drop table since table not exists! tid:%d uid %" PRIu64, REPO_ID(pRepo), tableId.tid,
uid);
terrno = TSDB_CODE_TDB_INVALID_TABLE_ID;
return -1;
}
- tsdbTrace("vgId:%d try to drop table %s type %d", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), TABLE_TYPE(pTable));
+ tsdbDebug("vgId:%d try to drop table %s type %d", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), TABLE_TYPE(pTable));
tid = TABLE_TID(pTable);
tbname = strdup(TABLE_CHAR_NAME(pTable));
@@ -132,30 +134,26 @@ int tsdbDropTable(TSDB_REPO_T *repo, STableId tableId) {
return -1;
}
- if (TABLE_TYPE(pTable) == TSDB_STREAM_TABLE) {
- if (pTable->cqhandle) pRepo->appH.cqDropFunc(pTable->cqhandle);
+ // Write to KV store first
+ if (tsdbRemoveTableFromStore(pRepo, pTable) < 0) {
+ tsdbError("vgId:%d failed to drop table %s since %s", REPO_ID(pRepo), tbname, tstrerror(terrno));
+ goto _err;
}
- if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
- SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex);
- while (tSkipListIterNext(pIter)) {
- STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
- ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE);
- int tlen = tsdbGetTableEncodeSize(TSDB_DROP_META, tTable);
- void *buf = tsdbAllocBytes(pRepo, tlen);
- ASSERT(buf != NULL);
- tsdbInsertTableAct(pRepo, TSDB_DROP_META, buf, tTable);
- tsdbRemoveTableFromMeta(pRepo, tTable, false, true);
- }
- tSkipListDestroyIter(pIter);
+ // Remove table from Meta
+ if (tsdbRmTableFromMeta(pRepo, pTable) < 0) {
+ tsdbError("vgId:%d failed to drop table %s since %s", REPO_ID(pRepo), tbname, tstrerror(terrno));
+ goto _err;
}
- tsdbRemoveTableFromMeta(pRepo, pTable, true, true);
-
- tsdbTrace("vgId:%d, table %s is dropped! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, tbname, tid, uid);
+ tsdbDebug("vgId:%d, table %s is dropped! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, tbname, tid, uid);
free(tbname);
return 0;
+
+_err:
+ tfree(tbname);
+ return -1;
}
void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_t bytes) {
@@ -296,7 +294,7 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
}
if (schemaVersion(tsdbGetTableTagSchema(pTable)) < tversion) {
- tsdbTrace("vgId:%d server tag version %d is older than client tag version %d, try to config", REPO_ID(pRepo),
+ tsdbDebug("vgId:%d server tag version %d is older than client tag version %d, try to config", REPO_ID(pRepo),
schemaVersion(tsdbGetTableTagSchema(pTable)), tversion);
void *msg = (*pRepo->appH.configFunc)(pRepo->config.tsdbId, htonl(pMsg->tid));
if (msg == NULL) return -1;
@@ -402,7 +400,7 @@ int tsdbOpenMeta(STsdbRepo *pRepo) {
goto _err;
}
- tsdbTrace("vgId:%d open TSDB meta succeed", REPO_ID(pRepo));
+ tsdbDebug("vgId:%d open TSDB meta succeed", REPO_ID(pRepo));
tfree(fname);
return 0;
@@ -429,7 +427,7 @@ int tsdbCloseMeta(STsdbRepo *pRepo) {
listNodeFree(pNode);
}
- tsdbTrace("vgId:%d TSDB meta is closed", REPO_ID(pRepo));
+ tsdbDebug("vgId:%d TSDB meta is closed", REPO_ID(pRepo));
return 0;
}
@@ -553,10 +551,19 @@ int tsdbUnlockRepoMeta(STsdbRepo *pRepo) {
return 0;
}
-void tsdbRefTable(STable *pTable) { T_REF_INC(pTable); }
+void tsdbRefTable(STable *pTable) {
+ int16_t ref = T_REF_INC(pTable);
+ UNUSED(ref);
+ // tsdbDebug("ref table %"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
+}
void tsdbUnRefTable(STable *pTable) {
- if (T_REF_DEC(pTable) == 0) {
+ int16_t ref = T_REF_DEC(pTable);
+ tsdbDebug("unref table uid:%"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
+
+ if (ref == 0) {
+ // tsdbDebug("destory table name:%s uid:%"PRIu64", tid:%d", TABLE_CHAR_NAME(pTable), TABLE_UID(pTable), TABLE_TID(pTable));
+
if (TABLE_TYPE(pTable) == TSDB_CHILD_TABLE) {
tsdbUnRefTable(pTable->pSuper);
}
@@ -591,7 +598,7 @@ static int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
return -1;
}
- tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is restored from file", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
+ tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is restored from file", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
TABLE_TID(pTable), TABLE_UID(pTable));
return 0;
}
@@ -710,7 +717,7 @@ _err:
static void tsdbFreeTable(STable *pTable) {
if (pTable) {
- tsdbTrace("table %s is destroyed", TABLE_CHAR_NAME(pTable));
+ tsdbDebug("table %s is destroyed", TABLE_CHAR_NAME(pTable));
tfree(TABLE_NAME(pTable));
if (TABLE_TYPE(pTable) != TSDB_CHILD_TABLE) {
for (int i = 0; i < TSDB_MAX_TABLE_SCHEMAS; i++) {
@@ -764,7 +771,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx) {
} else {
if (TABLE_TYPE(pTable) == TSDB_CHILD_TABLE && addIdx) { // add STABLE to the index
if (tsdbAddTableIntoIndex(pMeta, pTable) < 0) {
- tsdbTrace("vgId:%d failed to add table %s to meta while add table to index since %s", REPO_ID(pRepo),
+ tsdbDebug("vgId:%d failed to add table %s to meta while add table to index since %s", REPO_ID(pRepo),
TABLE_CHAR_NAME(pTable), tstrerror(terrno));
goto _err;
}
@@ -792,7 +799,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx) {
pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, TABLE_UID(pTable), TABLE_TID(pTable), pTable->sql, tsdbGetTableSchema(pTable));
}
- tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
+ tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
TABLE_TID(pTable), TABLE_UID(pTable));
return 0;
@@ -851,7 +858,7 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
}
if (lock) tsdbUnlockRepoMeta(pRepo);
- tsdbTrace("vgId:%d table %s is removed from meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable));
+ tsdbDebug("vgId:%d table %s is removed from meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable));
tsdbUnRefTable(pTable);
}
@@ -1156,8 +1163,16 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
}
static int tsdbGetTableEncodeSize(int8_t act, STable *pTable) {
- int tlen = sizeof(SListNode) + sizeof(SActObj);
- if (act == TSDB_UPDATE_META) tlen += (sizeof(SActCont) + tsdbEncodeTable(NULL, pTable) + sizeof(TSCKSUM));
+ int tlen = 0;
+ if (act == TSDB_UPDATE_META) {
+ tlen = sizeof(SListNode) + sizeof(SActObj) + sizeof(SActCont) + tsdbEncodeTable(NULL, pTable) + sizeof(TSCKSUM);
+ } else {
+ if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
+ tlen = (sizeof(SListNode) + sizeof(SActObj)) * (tSkipListGetSize(pTable->pIndex) + 1);
+ } else {
+ tlen = sizeof(SListNode) + sizeof(SActObj);
+ }
+ }
return tlen;
}
@@ -1182,4 +1197,61 @@ static void *tsdbInsertTableAct(STsdbRepo *pRepo, int8_t act, void *buf, STable
tdListAppendNode(pRepo->mem->actList, pNode);
return pBuf;
+}
+
+static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
+ int tlen = tsdbGetTableEncodeSize(TSDB_DROP_META, pTable);
+ void *buf = tsdbAllocBytes(pRepo, tlen);
+ ASSERT(buf != NULL);
+
+ void *pBuf = buf;
+ if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
+ SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex);
+ if (pIter == NULL) {
+ terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
+ return -1;
+ }
+
+ while (tSkipListIterNext(pIter)) {
+ STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
+ ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE);
+ pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, pTable);
+ }
+
+ tSkipListDestroyIter(pIter);
+ }
+ pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, pTable);
+
+ ASSERT(POINTER_DISTANCE(pBuf, buf) == tlen);
+
+ return 0;
+}
+
+static int tsdbRmTableFromMeta(STsdbRepo *pRepo, STable *pTable) {
+ if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
+ SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex);
+ if (pIter == NULL) {
+ terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
+ return -1;
+ }
+
+ tsdbWLockRepoMeta(pRepo);
+
+ while (tSkipListIterNext(pIter)) {
+ STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
+ tsdbRemoveTableFromMeta(pRepo, tTable, false, false);
+ }
+
+ tsdbRemoveTableFromMeta(pRepo, pTable, false, false);
+
+ tsdbUnlockRepoMeta(pRepo);
+
+ tSkipListDestroyIter(pIter);
+
+ } else {
+ if ((TABLE_TYPE(pTable) == TSDB_STREAM_TABLE) && pTable->cqhandle) pRepo->appH.cqDropFunc(pTable->cqhandle);
+ tsdbRemoveTableFromMeta(pRepo, pTable, true, true);
+ }
+
+ return 0;
}
\ No newline at end of file
diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c
index 72a04b5411..70bd9880f7 100644
--- a/src/tsdb/src/tsdbRWHelper.c
+++ b/src/tsdb/src/tsdbRWHelper.c
@@ -176,8 +176,8 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
(void)remove(pHelper->files.nHeadF.fname);
} else {
if (rename(pHelper->files.nHeadF.fname, pHelper->files.headF.fname) < 0) {
- tsdbError("vgId:%d failed to rename file from %s to %s since %s", REPO_ID(pHelper->pRepo),
- pHelper->files.nHeadF.fname, pHelper->files.headF.fname, strerror(errno));
+ tsdbError("failed to rename file from %s to %s since %s", pHelper->files.nHeadF.fname,
+ pHelper->files.headF.fname, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
@@ -194,8 +194,8 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
(void)remove(pHelper->files.nLastF.fname);
} else {
if (rename(pHelper->files.nLastF.fname, pHelper->files.lastF.fname) < 0) {
- tsdbError("vgId:%d failed to rename file from %s to %s since %s", REPO_ID(pHelper->pRepo),
- pHelper->files.nLastF.fname, pHelper->files.lastF.fname, strerror(errno));
+ tsdbError("failed to rename file from %s to %s since %s", pHelper->files.nLastF.fname,
+ pHelper->files.lastF.fname, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
@@ -715,7 +715,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
pCompBlock->keyFirst = dataColsKeyFirst(pDataCols);
pCompBlock->keyLast = dataColsKeyAt(pDataCols, rowsToWrite - 1);
- tsdbTrace("vgId:%d tid:%d a block of data is written to file %s, offset %" PRId64
+ tsdbDebug("vgId:%d tid:%d a block of data is written to file %s, offset %" PRId64
" numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64,
REPO_ID(helperRepo(pHelper)), pHelper->tableInfo.tid, pFile->fname, (int64_t)(pCompBlock->offset),
(int)(pCompBlock->numOfRows), pCompBlock->len, pCompBlock->numOfCols, pCompBlock->keyFirst,
@@ -916,7 +916,7 @@ static int tsdbInsertSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
ASSERT(pHelper->pCompInfo->blocks[0].keyLast < pHelper->pCompInfo->blocks[1].keyFirst);
}
- tsdbTrace("vgId:%d tid:%d a super block is inserted at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid,
+ tsdbDebug("vgId:%d tid:%d a super block is inserted at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid,
blkIdx);
return 0;
@@ -1001,7 +1001,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
pIdx->maxKey = pHelper->pCompInfo->blocks[pIdx->numOfBlocks - 1].keyLast;
pIdx->hasLast = pHelper->pCompInfo->blocks[pIdx->numOfBlocks - 1].last;
- tsdbTrace("vgId:%d tid:%d a subblock is added at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid, blkIdx);
+ tsdbDebug("vgId:%d tid:%d a subblock is added at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid, blkIdx);
return 0;
@@ -1041,7 +1041,7 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
pIdx->maxKey = pHelper->pCompInfo->blocks[pIdx->numOfBlocks - 1].keyLast;
pIdx->hasLast = pHelper->pCompInfo->blocks[pIdx->numOfBlocks - 1].last;
- tsdbTrace("vgId:%d tid:%d a super block is updated at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid,
+ tsdbDebug("vgId:%d tid:%d a super block is updated at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid,
blkIdx);
return 0;
diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c
index e0438bfbfd..6dd17b1626 100644
--- a/src/tsdb/src/tsdbRead.c
+++ b/src/tsdb/src/tsdbRead.c
@@ -199,7 +199,7 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
}
}
- tsdbTrace("%p total numOfTable:%zu in query", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo));
+ tsdbDebug("%p total numOfTable:%zu in query", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo));
tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo);
tsdbInitCompBlockLoadInfo(&pQueryHandle->compBlockLoadInfo);
@@ -288,10 +288,10 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SDataRow row = SL_GET_NODE_DATA(node);
TSKEY key = dataRowKey(row); // first timestamp in buffer
- tsdbTrace("%p uid:%" PRId64", tid:%d check data in mem from skey:%" PRId64 ", order:%d, %p", pHandle,
+ tsdbDebug("%p uid:%" PRId64", tid:%d check data in mem from skey:%" PRId64 ", order:%d, %p", pHandle,
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo);
} else {
- tsdbTrace("%p uid:%" PRId64 ", tid:%d no data in mem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid);
+ tsdbDebug("%p uid:%" PRId64 ", tid:%d no data in mem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid);
}
if (!imemEmpty) {
@@ -300,10 +300,10 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SDataRow row = SL_GET_NODE_DATA(node);
TSKEY key = dataRowKey(row); // first timestamp in buffer
- tsdbTrace("%p uid:%" PRId64", tid:%d check data in imem from skey:%" PRId64 ", order:%d, %p", pHandle,
+ tsdbDebug("%p uid:%" PRId64", tid:%d check data in imem from skey:%" PRId64 ", order:%d, %p", pHandle,
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pHandle->qinfo);
} else {
- tsdbTrace("%p uid:%"PRId64", tid:%d no data in imem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid);
+ tsdbDebug("%p uid:%"PRId64", tid:%d no data in imem", pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid);
}
return true;
@@ -403,7 +403,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
}
pCheckInfo->lastKey = dataRowKey(row); // first timestamp in buffer
- tsdbTrace("%p uid:%" PRId64", tid:%d check data in buffer from skey:%" PRId64 ", order:%d, %p", pHandle,
+ tsdbDebug("%p uid:%" PRId64", tid:%d check data in buffer from skey:%" PRId64 ", order:%d, %p", pHandle,
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, pCheckInfo->lastKey, pHandle->order, pHandle->qinfo);
// all data in mem are checked already.
@@ -616,7 +616,7 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
tfree(data);
int64_t et = taosGetTimestampUs() - st;
- tsdbTrace("%p load file block into buffer, elapsed time:%"PRId64 " us", pQueryHandle, et);
+ tsdbDebug("%p load file block into buffer, elapsed time:%"PRId64 " us", pQueryHandle, et);
return blockLoaded;
}
@@ -1142,7 +1142,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
cur->rows = numOfRows;
cur->pos = pos;
- tsdbTrace("%p uid:%" PRIu64",tid:%d data block created, brange:%"PRIu64"-%"PRIu64" rows:%d, %p", pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->win.skey,
+ tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, brange:%"PRIu64"-%"PRIu64" rows:%d, %p", pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->win.skey,
cur->win.ekey, cur->rows, pQueryHandle->qinfo);
}
@@ -1309,12 +1309,12 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
memcpy(pQueryHandle->pDataBlockInfo, sup.pDataBlockInfo[0], sizeof(STableBlockInfo) * numOfBlocks);
cleanBlockOrderSupporter(&sup, numOfQualTables);
- tsdbTrace("%p create data blocks info struct completed for 1 table, %d blocks not sorted %p ", pQueryHandle, cnt,
+ tsdbDebug("%p create data blocks info struct completed for 1 table, %d blocks not sorted %p ", pQueryHandle, cnt,
pQueryHandle->qinfo);
return TSDB_CODE_SUCCESS;
}
- tsdbTrace("%p create data blocks info struct completed, %d blocks in %d tables %p", pQueryHandle, cnt,
+ tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %p", pQueryHandle, cnt,
numOfQualTables, pQueryHandle->qinfo);
assert(cnt <= numOfBlocks && numOfQualTables <= numOfTables); // the pTableQueryInfo[j]->numOfBlocks may be 0
@@ -1351,7 +1351,7 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
* }
*/
- tsdbTrace("%p %d data blocks sort completed", pQueryHandle, cnt);
+ tsdbDebug("%p %d data blocks sort completed", pQueryHandle, cnt);
cleanBlockOrderSupporter(&sup, numOfTables);
free(pTree);
@@ -1372,7 +1372,7 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) {
break;
}
- tsdbTrace("%p %d blocks found in file for %d table(s), fid:%d, %p", pQueryHandle, numOfBlocks,
+ tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %p", pQueryHandle, numOfBlocks,
numOfTables, pQueryHandle->pFileGroup->fileId, pQueryHandle->qinfo);
assert(numOfBlocks >= 0);
@@ -1696,7 +1696,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
TSKEY key = dataRowKey(row);
if ((key > maxKey && ASCENDING_TRAVERSE(pQueryHandle->order)) || (key < maxKey && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
- tsdbTrace("%p key:%"PRIu64" beyond qrange:%"PRId64" - %"PRId64", no more data in buffer", pQueryHandle, key, pQueryHandle->window.skey,
+ tsdbDebug("%p key:%"PRIu64" beyond qrange:%"PRId64" - %"PRId64", no more data in buffer", pQueryHandle, key, pQueryHandle->window.skey,
pQueryHandle->window.ekey);
break;
@@ -1729,7 +1729,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
}
int64_t elapsedTime = taosGetTimestampUs() - st;
- tsdbTrace("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d", pQueryHandle,
+ tsdbDebug("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d", pQueryHandle,
elapsedTime, numOfRows, numOfCols);
return numOfRows;
@@ -2032,7 +2032,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
size_t size = taosArrayGetSize(pTableList);
if (size == 0) {
- tsdbTrace("no qualified tables");
+ tsdbDebug("no qualified tables");
return pTableGroup;
}
@@ -2047,7 +2047,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
}
taosArrayPush(pTableGroup, &sa);
- tsdbTrace("all %zu tables belong to one group", size);
+ tsdbDebug("all %zu tables belong to one group", size);
} else {
STableGroupSupporter *pSupp = (STableGroupSupporter *) calloc(1, sizeof(STableGroupSupporter));
pSupp->numOfCols = numOfOrderCols;
@@ -2173,7 +2173,7 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, const char* pT
pGroupInfo->numOfTables = taosArrayGetSize(res);
pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols);
- tsdbTrace("%p no table name/tag condition, all tables belong to one group, numOfTables:%zu", tsdb, pGroupInfo->numOfTables);
+ tsdbDebug("%p no table name/tag condition, all tables belong to one group, numOfTables:%zu", tsdb, pGroupInfo->numOfTables);
taosArrayDestroy(res);
if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error;
@@ -2215,7 +2215,7 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, const char* pT
pGroupInfo->numOfTables = taosArrayGetSize(res);
pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols);
- tsdbTrace("%p stable tid:%d, uid:%"PRIu64" query, numOfTables:%zu, belong to %zu groups", tsdb, pTable->tableId.tid,
+ tsdbDebug("%p stable tid:%d, uid:%"PRIu64" query, numOfTables:%zu, belong to %zu groups", tsdb, pTable->tableId.tid,
pTable->tableId.uid, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList));
taosArrayDestroy(res);
@@ -2233,6 +2233,7 @@ int32_t tsdbGetOneTableGroup(TSDB_REPO_T* tsdb, uint64_t uid, STableGroupInfo* p
STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid);
if (pTable == NULL) {
terrno = TSDB_CODE_TDB_INVALID_TABLE_ID;
+ tsdbUnlockRepoMeta(tsdb);
goto _error;
}
diff --git a/src/util/inc/tlog.h b/src/util/inc/tlog.h
index 4e063c17bb..af4e6ae1c2 100644
--- a/src/util/inc/tlog.h
+++ b/src/util/inc/tlog.h
@@ -20,13 +20,15 @@
extern "C" {
#endif
-#define DEBUG_ERROR 1U
+#define DEBUG_FATAL 1U
+#define DEBUG_ERROR DEBUG_FATAL
#define DEBUG_WARN 2U
-#define DEBUG_TRACE 4U
-#define DEBUG_DUMP 8U
+#define DEBUG_INFO DEBUG_WARN
+#define DEBUG_DEBUG 4U
+#define DEBUG_TRACE 8U
-#define DEBUG_FILE 0x80
-#define DEBUG_SCREEN 0x40
+#define DEBUG_SCREEN 64U
+#define DEBUG_FILE 128U
int32_t taosInitLog(char *logName, int32_t numOfLogLines, int32_t maxFiles);
void taosCloseLog();
diff --git a/src/util/src/hash.c b/src/util/src/hash.c
index 4ad06791a6..5dff6286f0 100644
--- a/src/util/src/hash.c
+++ b/src/util/src/hash.c
@@ -463,7 +463,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
int32_t newSize = pHashObj->capacity << 1u;
if (newSize > HASH_MAX_CAPACITY) {
-// uTrace("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
+// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
// pHashObj->capacity, HASH_MAX_CAPACITY);
return;
}
@@ -471,7 +471,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
int32_t pointerSize = POINTER_BYTES;
void *pNewEntry = realloc(pHashObj->hashList, pointerSize * newSize);
if (pNewEntry == NULL) {// todo handle error
-// uTrace("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
+// uDebug("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
return;
}
@@ -523,7 +523,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
}
}
-// uTrace("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", pHashObj->capacity,
+// uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", pHashObj->capacity,
// ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
}
diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c
index 48603a014e..2dd641731c 100644
--- a/src/util/src/tcache.c
+++ b/src/util/src/tcache.c
@@ -119,7 +119,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
int32_t size = pNode->size;
taosHashRemove(pCacheObj->pHashTable, pNode->key, pNode->keySize);
- uTrace("key:%s is removed from cache,total:%" PRId64 ",size:%dbytes", pNode->key, pCacheObj->totalSize, size);
+ uDebug("key:%s is removed from cache,total:%" PRId64 ",size:%dbytes", pNode->key, pCacheObj->totalSize, size);
if (pCacheObj->freeFp) pCacheObj->freeFp(pNode->data);
free(pNode);
}
@@ -288,14 +288,14 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz
if (NULL != pNode) {
pCacheObj->totalSize += pNode->size;
- uTrace("key:%s %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", total:%" PRId64 ", size:%" PRId64 " bytes",
+ uDebug("key:%s %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", total:%" PRId64 ", size:%" PRId64 " bytes",
key, pNode, pNode->addedTime, pNode->expiredTime, pCacheObj->totalSize, dataSize);
} else {
uError("key:%s failed to added into cache, out of memory", key);
}
} else { // old data exists, update the node
pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, keyLen, pData, dataSize, duration * 1000L);
- uTrace("key:%s %p exist in cache, updated", key, pNode);
+ uDebug("key:%s %p exist in cache, updated", key, pNode);
}
__cache_unlock(pCacheObj);
@@ -321,10 +321,10 @@ void *taosCacheAcquireByName(SCacheObj *pCacheObj, const char *key) {
if (ptNode != NULL) {
atomic_add_fetch_32(&pCacheObj->statistics.hitCount, 1);
- uTrace("key:%s is retrieved from cache, %p refcnt:%d", key, (*ptNode), T_REF_VAL_GET(*ptNode));
+ uDebug("key:%s is retrieved from cache, %p refcnt:%d", key, (*ptNode), T_REF_VAL_GET(*ptNode));
} else {
atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1);
- uTrace("key:%s not in cache, retrieved failed", key);
+ uDebug("key:%s not in cache, retrieved failed", key);
}
atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1);
@@ -350,10 +350,10 @@ void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, const char *key, uin
if (ptNode != NULL) {
atomic_add_fetch_32(&pCacheObj->statistics.hitCount, 1);
- uTrace("key:%s expireTime is updated in cache, %p refcnt:%d", key, (*ptNode), T_REF_VAL_GET(*ptNode));
+ uDebug("key:%s expireTime is updated in cache, %p refcnt:%d", key, (*ptNode), T_REF_VAL_GET(*ptNode));
} else {
atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1);
- uTrace("key:%s not in cache, retrieved failed", key);
+ uDebug("key:%s not in cache, retrieved failed", key);
}
atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1);
@@ -372,7 +372,7 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) {
}
int32_t ref = T_REF_INC(ptNode);
- uTrace("%p acquired by data in cache, refcnt:%d", ptNode, ref)
+ uDebug("%p acquired by data in cache, refcnt:%d", ptNode, ref)
// the data if referenced by at least one object, so the reference count must be greater than the value of 2.
assert(ref >= 2);
@@ -416,7 +416,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
*data = NULL;
int16_t ref = T_REF_DEC(pNode);
- uTrace("%p data released, refcnt:%d", pNode, ref);
+ uDebug("%p data released, refcnt:%d", pNode, ref);
if (_remove) {
__cache_wr_lock(pCacheObj);
@@ -501,7 +501,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
pNode->inTrashCan = true;
pCacheObj->numOfElemsInTrash++;
- uTrace("key:%s %p move to trash, numOfElem in trash:%d", pNode->key, pNode, pCacheObj->numOfElemsInTrash);
+ uDebug("key:%s %p move to trash, numOfElem in trash:%d", pNode->key, pNode, pCacheObj->numOfElemsInTrash);
}
void taosRemoveFromTrashCan(SCacheObj *pCacheObj, STrashElem *pElem) {
@@ -549,7 +549,7 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
}
if (force || (T_REF_VAL_GET(pElem->pData) == 0)) {
- uTrace("key:%s %p removed from trash. numOfElem in trash:%d", pElem->pData->key, pElem->pData,
+ uDebug("key:%s %p removed from trash. numOfElem in trash:%d", pElem->pData->key, pElem->pData,
pCacheObj->numOfElemsInTrash - 1);
STrashElem *p = pElem;
@@ -588,7 +588,7 @@ void doCleanupDataCache(SCacheObj *pCacheObj) {
void* taosCacheRefresh(void *handle) {
SCacheObj *pCacheObj = (SCacheObj *)handle;
if (pCacheObj == NULL) {
- uTrace("object is destroyed. no refresh retry");
+ uDebug("object is destroyed. no refresh retry");
return NULL;
}
diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c
index 76772db4e0..74acb7ce35 100644
--- a/src/util/src/tconfig.c
+++ b/src/util/src/tconfig.c
@@ -346,8 +346,8 @@ bool taosReadGlobalCfg() {
}
void taosPrintGlobalCfg() {
- uPrint(" taos config & system info:");
- uPrint("==================================");
+ uInfo(" taos config & system info:");
+ uInfo("==================================");
for (int i = 0; i < tsGlobalConfigNum; ++i) {
SGlobalCfg *cfg = tsGlobalConfig + i;
@@ -364,18 +364,18 @@ void taosPrintGlobalCfg() {
switch (cfg->valType) {
case TAOS_CFG_VTYPE_INT16:
- uPrint(" %s:%s%d%s", cfg->option, blank, *((int16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
+ uInfo(" %s:%s%d%s", cfg->option, blank, *((int16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
case TAOS_CFG_VTYPE_INT32:
- uPrint(" %s:%s%d%s", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
+ uInfo(" %s:%s%d%s", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
case TAOS_CFG_VTYPE_FLOAT:
- uPrint(" %s:%s%f%s", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
+ uInfo(" %s:%s%f%s", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
break;
case TAOS_CFG_VTYPE_STRING:
case TAOS_CFG_VTYPE_IPSTR:
case TAOS_CFG_VTYPE_DIRECTORY:
- uPrint(" %s:%s%s%s", cfg->option, blank, (char *)cfg->ptr, tsGlobalUnit[cfg->unitType]);
+ uInfo(" %s:%s%s%s", cfg->option, blank, (char *)cfg->ptr, tsGlobalUnit[cfg->unitType]);
break;
default:
break;
diff --git a/src/util/src/tidpool.c b/src/util/src/tidpool.c
index 98df9a9e7e..3764c7966b 100644
--- a/src/util/src/tidpool.c
+++ b/src/util/src/tidpool.c
@@ -41,7 +41,7 @@ void *taosInitIdPool(int maxId) {
pthread_mutex_init(&pIdPool->mutex, NULL);
- uTrace("pool:%p is setup, maxId:%d", pIdPool, pIdPool->maxId);
+ uDebug("pool:%p is setup, maxId:%d", pIdPool, pIdPool->maxId);
return pIdPool;
}
@@ -91,7 +91,7 @@ void taosIdPoolCleanUp(void *handle) {
if (pIdPool == NULL) return;
- uTrace("pool:%p is cleaned", pIdPool);
+ uDebug("pool:%p is cleaned", pIdPool);
if (pIdPool->freeList) free(pIdPool->freeList);
diff --git a/src/util/src/tkvstore.c b/src/util/src/tkvstore.c
index 80f8bdbcee..42deb9494d 100644
--- a/src/util/src/tkvstore.c
+++ b/src/util/src/tkvstore.c
@@ -114,7 +114,7 @@ SKVStore *tdOpenKVStore(char *fname, iterFunc iFunc, afterFunc aFunc, void *appH
goto _err;
}
} else {
- uTrace("file %s exists, try to recover the KV store", pStore->fsnap);
+ uDebug("file %s exists, try to recover the KV store", pStore->fsnap);
if (tdLoadKVStoreHeader(pStore->sfd, pStore->fsnap, &info) < 0) {
if (terrno != TSDB_CODE_COM_FILE_CORRUPTED) goto _err;
} else {
@@ -500,7 +500,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
char *pBuf = tdDecodeKVRecord(tbuf, &rInfo);
ASSERT(POINTER_DISTANCE(pBuf, tbuf) == sizeof(SKVRecord));
- ASSERT(pStore->info.size == rInfo.offset);
+ ASSERT((rInfo.offset > 0) ? (pStore->info.size == rInfo.offset) : true);
if (rInfo.offset < 0) {
taosHashRemove(pStore->map, (void *)(&rInfo.uid), sizeof(rInfo.uid));
diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c
index 581c4e2e9f..c2c56f29db 100644
--- a/src/util/src/tlog.c
+++ b/src/util/src/tlog.c
@@ -153,7 +153,7 @@ static void *taosThreadToOpenNewFile(void *param) {
tsLogObj.logHandle->fd = fd;
tsLogObj.lines = 0;
tsLogObj.openInProgress = 0;
- uPrint("new log file is opened!!!");
+ uInfo("new log file is opened!!!");
taosCloseLogByFd(oldFd);
return NULL;
@@ -165,7 +165,7 @@ static int32_t taosOpenNewLogFile() {
if (tsLogObj.lines > tsLogObj.maxLines && tsLogObj.openInProgress == 0) {
tsLogObj.openInProgress = 1;
- uPrint("open new log file ......");
+ uInfo("open new log file ......");
pthread_t thread;
pthread_attr_t attr;
pthread_attr_init(&attr);
@@ -190,8 +190,8 @@ void taosResetLog() {
taosOpenNewLogFile();
(void)remove(lastName);
- uPrint("==================================");
- uPrint(" reset log file ");
+ uInfo("==================================");
+ uInfo(" reset log file ");
}
static bool taosCheckFileIsOpen(char *logFileName) {
@@ -328,7 +328,7 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
curTime = timeSecs.tv_sec;
ptm = localtime_r(&curTime, &Tm);
- len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d 0x%" PRIx64 " ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
+ len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d 0x%08" PRIx64 " ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetPthreadId());
len += sprintf(buffer + len, "%s", flags);
@@ -415,7 +415,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
curTime = timeSecs.tv_sec;
ptm = localtime_r(&curTime, &Tm);
- len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d 0x%" PRIx64 " ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
+ len = sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d 0x%08" PRIx64 " ", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour,
ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetPthreadId());
len += sprintf(buffer + len, "%s", flags);
diff --git a/src/util/src/tmempool.c b/src/util/src/tmempool.c
index 5fe00c87a2..f5329800f3 100644
--- a/src/util/src/tmempool.c
+++ b/src/util/src/tmempool.c
@@ -88,7 +88,7 @@ char *taosMemPoolMalloc(mpool_h handle) {
pthread_mutex_unlock(&(pool_p->mutex));
- if (pos == NULL) uTrace("mempool: out of memory");
+ if (pos == NULL) uDebug("mempool: out of memory");
return pos;
}
diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c
index 7e9392f410..34396c9c29 100644
--- a/src/util/src/tqueue.c
+++ b/src/util/src/tqueue.c
@@ -95,7 +95,7 @@ void *taosAllocateQitem(int size) {
void taosFreeQitem(void *param) {
if (param == NULL) return;
- uTrace("item:%p is freed", param);
+ uDebug("item:%p is freed", param);
char *temp = (char *)param;
temp -= sizeof(STaosQnode);
free(temp);
@@ -119,7 +119,7 @@ int taosWriteQitem(taos_queue param, int type, void *item) {
queue->numOfItems++;
if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1);
- uTrace("item:%p is put into queue:%p, type:%d items:%d", item, queue, type, queue->numOfItems);
+ uDebug("item:%p is put into queue:%p, type:%d items:%d", item, queue, type, queue->numOfItems);
pthread_mutex_unlock(&queue->mutex);
@@ -145,7 +145,7 @@ int taosReadQitem(taos_queue param, int *type, void **pitem) {
queue->numOfItems--;
if (queue->qset) atomic_sub_fetch_32(&queue->qset->numOfItems, 1);
code = 1;
- uTrace("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
+ uDebug("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
}
pthread_mutex_unlock(&queue->mutex);
@@ -201,7 +201,7 @@ int taosGetQitem(taos_qall param, int *type, void **pitem) {
*pitem = pNode->item;
*type = pNode->type;
num = 1;
- uTrace("item:%p is fetched, type:%d", *pitem, *type);
+ uDebug("item:%p is fetched, type:%d", *pitem, *type);
}
return num;
@@ -339,7 +339,7 @@ int taosReadQitemFromQset(taos_qset param, int *type, void **pitem, void **phand
queue->numOfItems--;
atomic_sub_fetch_32(&qset->numOfItems, 1);
code = 1;
- uTrace("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
+ uDebug("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
}
pthread_mutex_unlock(&queue->mutex);
diff --git a/src/util/src/tsched.c b/src/util/src/tsched.c
index 6fc767fd3b..39155bc0fd 100644
--- a/src/util/src/tsched.c
+++ b/src/util/src/tsched.c
@@ -101,7 +101,7 @@ void *taosInitScheduler(int queueSize, int numOfThreads, const char *label) {
++pSched->numOfThreads;
}
- uTrace("%s scheduler is initialized, numOfThreads:%d", label, pSched->numOfThreads);
+ uDebug("%s scheduler is initialized, numOfThreads:%d", label, pSched->numOfThreads);
return (void *)pSched;
}
@@ -125,7 +125,7 @@ void *taosProcessSchedQueue(void *param) {
if (tsem_wait(&pSched->fullSem) != 0) {
if (errno == EINTR) {
/* sem_wait is interrupted by interrupt, ignore and continue */
- uTrace("wait %s fullSem was interrupted", pSched->label);
+ uDebug("wait %s fullSem was interrupted", pSched->label);
continue;
}
uError("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
@@ -168,7 +168,7 @@ int taosScheduleTask(void *qhandle, SSchedMsg *pMsg) {
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
break;
}
- uTrace("wait %s emptySem was interrupted", pSched->label);
+ uDebug("wait %s emptySem was interrupted", pSched->label);
}
if (pthread_mutex_lock(&pSched->queueMutex) != 0)
@@ -224,7 +224,7 @@ void taosDumpSchedulerStatus(void *qhandle, void *tmrId) {
int32_t size = ((pSched->emptySlot - pSched->fullSlot) + pSched->queueSize) % pSched->queueSize;
if (size > 0) {
- uTrace("scheduler:%s, current tasks in queue:%d, task thread:%d", pSched->label, size, pSched->numOfThreads);
+ uDebug("scheduler:%s, current tasks in queue:%d, task thread:%d", pSched->label, size, pSched->numOfThreads);
}
taosTmrReset(taosDumpSchedulerStatus, DUMP_SCHEDULER_TIME_WINDOW, pSched, pSched->pTmrCtrl, &pSched->pTimer);
diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c
index 2394adc6f3..f3c0babe6b 100644
--- a/src/util/src/tskiplist.c
+++ b/src/util/src/tskiplist.c
@@ -38,7 +38,7 @@ static FORCE_INLINE int32_t getSkipListNodeRandomHeight(SSkipList *pSkipList) {
const uint32_t factor = 4;
int32_t n = 1;
- while ((taosRand() % factor) == 0 && n <= pSkipList->maxLevel) {
+ while ((rand() % factor) == 0 && n <= pSkipList->maxLevel) {
n++;
}
diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c
index e19d91837f..bd2606d5fb 100644
--- a/src/util/src/tsocket.c
+++ b/src/util/src/tsocket.c
@@ -224,7 +224,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
int sockFd;
int bufSize = 1024000;
- uTrace("open udp socket:0x%x:%hu", ip, port);
+ uDebug("open udp socket:0x%x:%hu", ip, port);
memset((char *)&localAddr, 0, sizeof(localAddr));
localAddr.sin_family = AF_INET;
@@ -356,7 +356,7 @@ int taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
int sockFd;
int reuse;
- uTrace("open tcp server socket:0x%x:%hu", ip, port);
+ uDebug("open tcp server socket:0x%x:%hu", ip, port);
bzero((char *)&serverAdd, sizeof(serverAdd));
serverAdd.sin_family = AF_INET;
diff --git a/src/util/src/ttime.c b/src/util/src/ttime.c
index dfec632012..176f9be7fb 100644
--- a/src/util/src/ttime.c
+++ b/src/util/src/ttime.c
@@ -48,23 +48,21 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec)
{
- unsigned int mon = mon0, year = year0;
+ unsigned int mon = mon0, year = year0;
- /* 1..12 -> 11,12,1..10 */
- if (0 >= (int) (mon -= 2)) {
- mon += 12; /* Puts Feb last since it has leap day */
- year -= 1;
- }
+ /* 1..12 -> 11,12,1..10 */
+ if (0 >= (int) (mon -= 2)) {
+ mon += 12; /* Puts Feb last since it has leap day */
+ year -= 1;
+ }
- //int64_t res = (((((int64_t) (year/4 - year/100 + year/400 + 367*mon/12 + day) +
- // year*365 - 719499)*24 + hour)*60 + min)*60 + sec);
- int64_t res;
- res = 367*((int64_t)mon)/12;
- res += year/4 - year/100 + year/400 + day + year*365 - 719499;
+ int64_t res = 367*((int64_t)mon)/12;
+
+ res += ((int64_t)(year/4 - year/100 + year/400 + day + year*365) - 719499); // this value may be less than 0
res = res*24;
res = ((res + hour) * 60 + min) * 60 + sec;
- return (res + timezone);
+ return (res + timezone);
}
// ==== mktime() kernel code =================//
static int64_t m_deltaUtc = 0;
diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c
index a7b3bfb818..62aa2007b2 100644
--- a/src/util/src/ttimer.c
+++ b/src/util/src/ttimer.c
@@ -20,20 +20,14 @@
#include "ttimer.h"
#include "tutil.h"
-#define tmrError(...) \
- do { if (tmrDebugFlag & DEBUG_ERROR) { \
- taosPrintLog("ERROR TMR ", tmrDebugFlag, __VA_ARGS__); \
- } } while(0)
+extern int32_t tscEmbedded;
-#define tmrWarn(...) \
- do { if (tmrDebugFlag & DEBUG_WARN) { \
- taosPrintLog("WARN TMR ", tmrDebugFlag, __VA_ARGS__); \
- } } while(0)
-
-#define tmrTrace(...) \
- do { if (tmrDebugFlag & DEBUG_TRACE) { \
- taosPrintLog("TMR ", tmrDebugFlag, __VA_ARGS__); \
- } } while(0)
+#define tmrFatal(...) { if (tmrDebugFlag & DEBUG_FATAL) { taosPrintLog("TMR FATAL ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
+#define tmrError(...) { if (tmrDebugFlag & DEBUG_ERROR) { taosPrintLog("TMR ERROR ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
+#define tmrWarn(...) { if (tmrDebugFlag & DEBUG_WARN) { taosPrintLog("TMR WARN ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
+#define tmrInfo(...) { if (tmrDebugFlag & DEBUG_INFO) { taosPrintLog("TMR INFO ", tscEmbedded ? 255 : tmrDebugFlag, __VA_ARGS__); }}
+#define tmrDebug(...) { if (tmrDebugFlag & DEBUG_DEBUG) { taosPrintLog("TMR DEBUG ", tmrDebugFlag, __VA_ARGS__); }}
+#define tmrTrace(...) { if (tmrDebugFlag & DEBUG_TRACE) { taosPrintLog("TMR TRACE ", tmrDebugFlag, __VA_ARGS__); }}
#define TIMER_STATE_WAITING 0
#define TIMER_STATE_EXPIRED 1
@@ -267,13 +261,13 @@ static void processExpiredTimer(void* handle, void* arg) {
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
if (state == TIMER_STATE_WAITING) {
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] execution start.";
- tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
+ tmrDebug(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
(*timer->fp)(timer->param, (tmr_h)timer->id);
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] execution end.";
- tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
+ tmrDebug(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
}
removeTimer(timer->id);
timerDecRef(timer);
@@ -285,7 +279,7 @@ static void addToExpired(tmr_obj_t* head) {
while (head != NULL) {
uintptr_t id = head->id;
tmr_obj_t* next = head->next;
- tmrTrace(fmt, head->ctrl->label, id, head->fp, head->param);
+ tmrDebug(fmt, head->ctrl->label, id, head->fp, head->param);
SSchedMsg schedMsg;
schedMsg.fp = NULL;
@@ -295,7 +289,7 @@ static void addToExpired(tmr_obj_t* head) {
schedMsg.thandle = NULL;
taosScheduleTask(tmrQhandle, &schedMsg);
- tmrTrace("timer[id=%" PRIuPTR "] has been added to queue.", id);
+ tmrDebug("timer[id=%" PRIuPTR "] has been added to queue.", id);
head = next;
}
}
@@ -310,7 +304,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon
addTimer(timer);
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] started";
- tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
+ tmrDebug(fmt, ctrl->label, timer->id, timer->fp, timer->param);
if (mseconds == 0) {
timer->wheel = tListLen(wheels);
@@ -403,7 +397,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
reusable = true;
}
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] is cancelled.";
- tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
+ tmrDebug(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
return reusable;
}
@@ -423,7 +417,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
// BUT this may result in dead lock if current thread are holding a lock which
// the timer callback need to acquire. so, we HAVE TO return directly.
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] is executing and cannot be stopped.";
- tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
+ tmrDebug(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
return false;
}
@@ -432,7 +426,7 @@ bool taosTmrStop(tmr_h timerId) {
tmr_obj_t* timer = findTimer(id);
if (timer == NULL) {
- tmrTrace("timer[id=%" PRIuPTR "] does not exist", id);
+ tmrDebug("timer[id=%" PRIuPTR "] does not exist", id);
return false;
}
@@ -459,7 +453,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
bool stopped = false;
tmr_obj_t* timer = findTimer(id);
if (timer == NULL) {
- tmrTrace("%s timer[id=%" PRIuPTR "] does not exist", ctrl->label, id);
+ tmrDebug("%s timer[id=%" PRIuPTR "] does not exist", ctrl->label, id);
} else {
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
if (!doStopTimer(timer, state)) {
@@ -474,7 +468,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
return stopped;
}
- tmrTrace("%s timer[id=%" PRIuPTR "] is reused", ctrl->label, timer->id);
+ tmrDebug("%s timer[id=%" PRIuPTR "] is reused", ctrl->label, timer->id);
// wait until there's no other reference to this timer,
// so that we can reuse this timer safely.
@@ -534,7 +528,7 @@ static void taosTmrModuleInit(void) {
tmrQhandle = taosInitScheduler(10000, taosTmrThreads, "tmr");
taosInitTimer(taosTimerLoopFunc, MSECONDS_PER_TICK);
- tmrTrace("timer module is initialized, number of threads: %d", taosTmrThreads);
+ tmrDebug("timer module is initialized, number of threads: %d", taosTmrThreads);
}
void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) {
@@ -554,7 +548,7 @@ void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* lab
}
tstrncpy(ctrl->label, label, sizeof(ctrl->label));
- tmrTrace("%s timer controller is initialized, number of timer controllers: %d.", label, numOfTmrCtrl);
+ tmrDebug("%s timer controller is initialized, number of timer controllers: %d.", label, numOfTmrCtrl);
return ctrl;
}
@@ -564,7 +558,7 @@ void taosTmrCleanUp(void* handle) {
return;
}
- tmrTrace("%s timer controller is cleaned up.", ctrl->label);
+ tmrDebug("%s timer controller is cleaned up.", ctrl->label);
ctrl->label[0] = 0;
pthread_mutex_lock(&tmrCtrlMutex);
@@ -598,6 +592,6 @@ void taosTmrCleanUp(void* handle) {
free(timerMap.slots);
free(tmrCtrls);
- tmrTrace("timer module is cleaned up");
+ tmrDebug("timer module is cleaned up");
}
}
diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c
index 481cf498ca..cc720eb5f7 100644
--- a/src/util/src/tutil.c
+++ b/src/util/src/tutil.c
@@ -784,14 +784,14 @@ void taosRemoveDir(char *rootDir) {
taosRemoveDir(filename);
} else {
(void)remove(filename);
- uPrint("file:%s is removed", filename);
+ uInfo("file:%s is removed", filename);
}
}
closedir(dir);
rmdir(rootDir);
- uPrint("dir:%s is removed", rootDir);
+ uInfo("dir:%s is removed", rootDir);
}
int tmkdir(const char *path, mode_t mode) {
diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h
index d5a7dbfd2e..e428eae688 100644
--- a/src/vnode/inc/vnodeInt.h
+++ b/src/vnode/inc/vnodeInt.h
@@ -27,10 +27,12 @@ extern "C" {
extern int32_t vDebugFlag;
-#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR VND ", 255, __VA_ARGS__); }}
-#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("WARN VND ", vDebugFlag, __VA_ARGS__); }}
-#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }}
-#define vPrint(...) { taosPrintLog("VND ", 255, __VA_ARGS__); }
+#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", 255, __VA_ARGS__); }}
+#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", 255, __VA_ARGS__); }}
+#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", 255, __VA_ARGS__); }}
+#define vInfo(...) { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND INFO ", 255, __VA_ARGS__); }}
+#define vDebug(...) { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND DEBUG ", vDebugFlag, __VA_ARGS__); }}
+#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND TRACE ", vDebugFlag, __VA_ARGS__); }}
typedef struct {
int32_t vgId; // global vnode group ID
diff --git a/src/vnode/inc/vnodeLog.h b/src/vnode/inc/vnodeLog.h
deleted file mode 100644
index d6794202da..0000000000
--- a/src/vnode/inc/vnodeLog.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * 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 .
- */
-
-#ifndef TDENGINE_VNODE_LOG_H
-#define TDENGINE_VNODE_LOG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "tlog.h"
-
-extern int32_t dDebugFlag;
-
-#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR DND ", 255, __VA_ARGS__); }}
-#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); }}
-#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
-#define dPrint(...) { taosPrintLog("DND ", 255, __VA_ARGS__); }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c
index 6c8f23b424..89af7b988d 100644
--- a/src/vnode/src/vnodeMain.c
+++ b/src/vnode/src/vnodeMain.c
@@ -71,7 +71,7 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
SVnodeObj *pTemp = (SVnodeObj *)taosHashGet(tsDnodeVnodesHash, (const char *)&pVnodeCfg->cfg.vgId, sizeof(int32_t));
if (pTemp != NULL) {
- vPrint("vgId:%d, vnode already exist, pVnode:%p", pVnodeCfg->cfg.vgId, pTemp);
+ vInfo("vgId:%d, vnode already exist, pVnode:%p", pVnodeCfg->cfg.vgId, pTemp);
return TSDB_CODE_SUCCESS;
}
@@ -129,7 +129,7 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
return TSDB_CODE_VND_INIT_FAILED;
}
- vPrint("vgId:%d, vnode is created, clog:%d", pVnodeCfg->cfg.vgId, pVnodeCfg->cfg.walLevel);
+ vInfo("vgId:%d, vnode is created, clog:%d", pVnodeCfg->cfg.vgId, pVnodeCfg->cfg.walLevel);
code = vnodeOpen(pVnodeCfg->cfg.vgId, rootDir);
return code;
@@ -137,18 +137,18 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
int32_t vnodeDrop(int32_t vgId) {
if (tsDnodeVnodesHash == NULL) {
- vTrace("vgId:%d, failed to drop, vgId not exist", vgId);
+ vDebug("vgId:%d, failed to drop, vgId not exist", vgId);
return TSDB_CODE_VND_INVALID_VGROUP_ID;
}
SVnodeObj **ppVnode = (SVnodeObj **)taosHashGet(tsDnodeVnodesHash, (const char *)&vgId, sizeof(int32_t));
if (ppVnode == NULL || *ppVnode == NULL) {
- vTrace("vgId:%d, failed to drop, vgId not find", vgId);
+ vDebug("vgId:%d, failed to drop, vgId not find", vgId);
return TSDB_CODE_VND_INVALID_VGROUP_ID;
}
SVnodeObj *pVnode = *ppVnode;
- vTrace("vgId:%d, vnode will be dropped", pVnode->vgId);
+ vTrace("vgId:%d, vnode will be dropped, refCount:%d", pVnode->vgId, pVnode->refCount);
pVnode->status = TAOS_VN_STATUS_DELETING;
vnodeCleanUp(pVnode);
@@ -172,7 +172,7 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) {
if (code != TSDB_CODE_SUCCESS) return code;
pVnode->status = TAOS_VN_STATUS_READY;
- vTrace("vgId:%d, vnode is altered", pVnode->vgId);
+ vDebug("vgId:%d, vnode is altered", pVnode->vgId);
return TSDB_CODE_SUCCESS;
}
@@ -282,7 +282,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode->events = NULL;
pVnode->status = TAOS_VN_STATUS_READY;
- vTrace("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode);
+ vDebug("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode);
taosHashPut(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t), (char *)(&pVnode), sizeof(SVnodeObj *));
@@ -303,7 +303,7 @@ int32_t vnodeClose(int32_t vgId) {
if (ppVnode == NULL || *ppVnode == NULL) return 0;
SVnodeObj *pVnode = *ppVnode;
- vTrace("vgId:%d, vnode will be closed", pVnode->vgId);
+ vDebug("vgId:%d, vnode will be closed", pVnode->vgId);
pVnode->status = TAOS_VN_STATUS_CLOSING;
vnodeCleanUp(pVnode);
@@ -354,7 +354,7 @@ void vnodeRelease(void *pVnodeRaw) {
free(pVnode);
int32_t count = atomic_sub_fetch_32(&tsOpennedVnodes, 1);
- vTrace("vgId:%d, vnode is released, vnodes:%d", vgId, count);
+ vDebug("vgId:%d, vnode is released, vnodes:%d", vgId, count);
if (count <= 0) {
taosHashCleanup(tsDnodeVnodesHash);
@@ -369,7 +369,7 @@ void *vnodeGetVnode(int32_t vgId) {
SVnodeObj **ppVnode = (SVnodeObj **)taosHashGet(tsDnodeVnodesHash, (const char *)&vgId, sizeof(int32_t));
if (ppVnode == NULL || *ppVnode == NULL) {
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
- vPrint("vgId:%d, not exist", vgId);
+ vInfo("vgId:%d, not exist", vgId);
return NULL;
}
@@ -439,7 +439,7 @@ void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes) {
if (pVnode != NULL) {
pVnode->accessState = pAccess[i].accessState;
if (pVnode->accessState != TSDB_VN_ALL_ACCCESS) {
- vTrace("vgId:%d, access state is set to %d", pAccess[i].vgId, pVnode->accessState)
+ vDebug("vgId:%d, access state is set to %d", pAccess[i].vgId, pVnode->accessState)
}
vnodeRelease(pVnode);
}
@@ -456,6 +456,8 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
pVnode->sync = NULL;
}
+ vTrace("vgId:%d, vnode will cleanup, refCount:%d", pVnode->vgId, pVnode->refCount);
+
// release local resources only after cutting off outside connections
vnodeRelease(pVnode);
}
@@ -488,7 +490,7 @@ static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) {
static void vnodeNotifyRole(void *ahandle, int8_t role) {
SVnodeObj *pVnode = ahandle;
- vPrint("vgId:%d, sync role changed from %d to %d", pVnode->vgId, pVnode->role, role);
+ vInfo("vgId:%d, sync role changed from %d to %d", pVnode->vgId, pVnode->role, role);
pVnode->role = role;
if (pVnode->role == TAOS_SYNC_ROLE_MASTER)
@@ -499,7 +501,7 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) {
static void vnodeNotifyFileSynced(void *ahandle, uint64_t fversion) {
SVnodeObj *pVnode = ahandle;
- vTrace("vgId:%d, data file is synced, fversion:%" PRId64, pVnode->vgId, fversion);
+ vDebug("vgId:%d, data file is synced, fversion:%" PRId64, pVnode->vgId, fversion);
pVnode->fversion = fversion;
pVnode->version = fversion;
@@ -576,7 +578,7 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) {
fclose(fp);
free(content);
- vPrint("vgId:%d, save vnode cfg successed", pVnodeCfg->cfg.vgId);
+ vInfo("vgId:%d, save vnode cfg successed", pVnodeCfg->cfg.vgId);
return TSDB_CODE_SUCCESS;
}
@@ -774,9 +776,9 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
terrno = TSDB_CODE_SUCCESS;
- vPrint("vgId:%d, read vnode cfg successfully, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica);
+ vInfo("vgId:%d, read vnode cfg successfully, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica);
for (int32_t i = 0; i < pVnode->syncCfg.replica; i++) {
- vPrint("vgId:%d, dnode:%d, %s:%d", pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId,
+ vInfo("vgId:%d, dnode:%d, %s:%d", pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId,
pVnode->syncCfg.nodeInfo[i].nodeFqdn, pVnode->syncCfg.nodeInfo[i].nodePort);
}
@@ -808,7 +810,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
fwrite(content, 1, len, fp);
fclose(fp);
- vPrint("vgId:%d, save vnode version:%" PRId64 " succeed", pVnode->vgId, pVnode->fversion);
+ vInfo("vgId:%d, save vnode version:%" PRId64 " succeed", pVnode->vgId, pVnode->fversion);
return TSDB_CODE_SUCCESS;
}
@@ -853,7 +855,7 @@ static int32_t vnodeReadVersion(SVnodeObj *pVnode) {
pVnode->version = version->valueint;
terrno = TSDB_CODE_SUCCESS;
- vPrint("vgId:%d, read vnode version successfully, version:%" PRId64, pVnode->vgId, pVnode->version);
+ vInfo("vgId:%d, read vnode version successfully, version:%" PRId64, pVnode->vgId, pVnode->version);
PARSE_OVER:
tfree(content);
diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c
index 91c6d28e22..32bbfb1605 100644
--- a/src/vnode/src/vnodeRead.c
+++ b/src/vnode/src/vnodeRead.c
@@ -24,7 +24,6 @@
#include "tdataformat.h"
#include "vnode.h"
#include "vnodeInt.h"
-#include "vnodeLog.h"
#include "query.h"
static int32_t (*vnodeProcessReadMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *pVnode, SReadMsg *pReadMsg);
@@ -41,18 +40,18 @@ int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) {
int msgType = pReadMsg->rpcMsg.msgType;
if (vnodeProcessReadMsgFp[msgType] == NULL) {
- vTrace("vgId:%d, msgType:%s not processed, no handle", pVnode->vgId, taosMsg[msgType]);
+ vDebug("vgId:%d, msgType:%s not processed, no handle", pVnode->vgId, taosMsg[msgType]);
return TSDB_CODE_VND_MSG_NOT_PROCESSED;
}
if (pVnode->status == TAOS_VN_STATUS_DELETING || pVnode->status == TAOS_VN_STATUS_CLOSING) {
- vTrace("vgId:%d, msgType:%s not processed, vnode status is %d", pVnode->vgId, taosMsg[msgType], pVnode->status);
+ vDebug("vgId:%d, msgType:%s not processed, vnode status is %d", pVnode->vgId, taosMsg[msgType], pVnode->status);
return TSDB_CODE_VND_INVALID_VGROUP_ID;
}
// TODO: Later, let slave to support query
if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) {
- vTrace("vgId:%d, msgType:%s not processed, replica:%d role:%d", pVnode->vgId, taosMsg[msgType], pVnode->syncCfg.replica, pVnode->role);
+ vDebug("vgId:%d, msgType:%s not processed, replica:%d role:%d", pVnode->vgId, taosMsg[msgType], pVnode->syncCfg.replica, pVnode->role);
return TSDB_CODE_RPC_NOT_READY;
}
@@ -68,7 +67,7 @@ static int32_t vnodeNotifyCurrentQhandle(void* handle, void* qhandle, int32_t vg
killQueryMsg->header.vgId = htonl(vgId);
killQueryMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg));
- vTrace("QInfo:%p register qhandle to connect:%p", qhandle, handle);
+ vDebug("QInfo:%p register qhandle to connect:%p", qhandle, handle);
return rpcReportProgress(handle, (char*) killQueryMsg, sizeof(SRetrieveTableMsg));
}
@@ -121,16 +120,16 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
return pRsp->code;
}
- vTrace("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
+ vDebug("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
} else {
assert(pCont != NULL);
pQInfo = pCont;
code = TSDB_CODE_VND_ACTION_IN_PROGRESS;
- vTrace("vgId:%d, QInfo:%p, dnode query msg in progress", pVnode->vgId, pQInfo);
+ vDebug("vgId:%d, QInfo:%p, dnode query msg in progress", pVnode->vgId, pQInfo);
}
if (pQInfo != NULL) {
- vTrace("vgId:%d, QInfo:%p, do qTableQuery", pVnode->vgId, pQInfo);
+ vDebug("vgId:%d, QInfo:%p, do qTableQuery", pVnode->vgId, pQInfo);
qTableQuery(pQInfo, vnodeRelease, pVnode); // do execute query
}
@@ -148,7 +147,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
memset(pRet, 0, sizeof(SRspRet));
if (pRetrieve->free == 1) {
- vTrace("vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle", pVnode->vgId, pQInfo);
+ vDebug("vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle", pVnode->vgId, pQInfo);
int32_t ret = qKillQuery(pQInfo, vnodeRelease, pVnode);
pRet->rsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
@@ -163,7 +162,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
return ret;
}
- vTrace("vgId:%d, QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo);
+ vDebug("vgId:%d, QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo);
int32_t code = qRetrieveQueryResultInfo(pQInfo);
if (code != TSDB_CODE_SUCCESS) {
@@ -182,6 +181,6 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
}
}
- vTrace("vgId:%d, QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo);
+ vDebug("vgId:%d, QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo);
return code;
}
diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c
index 769ef03bf6..f43d10a7a3 100644
--- a/src/vnode/src/vnodeWrite.c
+++ b/src/vnode/src/vnodeWrite.c
@@ -25,7 +25,6 @@
#include "tdataformat.h"
#include "vnode.h"
#include "vnodeInt.h"
-#include "vnodeLog.h"
#include "tcq.h"
static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *, SRspRet *);
@@ -95,7 +94,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
// save insert result into item
- vTrace("vgId:%d, submit msg is processed", pVnode->vgId);
+ vDebug("vgId:%d, submit msg is processed", pVnode->vgId);
pRet->len = sizeof(SShellSubmitRspMsg);
pRet->rsp = rpcMallocCont(pRet->len);
@@ -124,7 +123,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
SMDDropTableMsg *pTable = pCont;
int32_t code = TSDB_CODE_SUCCESS;
- vTrace("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId);
+ vDebug("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId);
STableId tableId = {.uid = htobe64(pTable->uid), .tid = htonl(pTable->sid)};
if (tsdbDropTable(pVnode->tsdb, tableId) < 0) code = terrno;
@@ -139,7 +138,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
// if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) code = terrno;
// tsdbClearTableCfg(pCfg);
- vTrace("vgId:%d, alter table msg is received", pVnode->vgId);
+ vDebug("vgId:%d, alter table msg is received", pVnode->vgId);
return TSDB_CODE_SUCCESS;
}
@@ -147,13 +146,13 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
SMDDropSTableMsg *pTable = pCont;
int32_t code = TSDB_CODE_SUCCESS;
- vTrace("vgId:%d, stable:%s, start to drop", pVnode->vgId, pTable->tableId);
+ vDebug("vgId:%d, stable:%s, start to drop", pVnode->vgId, pTable->tableId);
STableId stableId = {.uid = htobe64(pTable->uid), .tid = -1};
if (tsdbDropTable(pVnode->tsdb, stableId) < 0) code = terrno;
- vTrace("vgId:%d, stable:%s, drop stable result:%s", pVnode->vgId, pTable->tableId, tstrerror(code));
+ vDebug("vgId:%d, stable:%s, drop stable result:%s", pVnode->vgId, pTable->tableId, tstrerror(code));
return code;
}
diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c
index 41669fc691..e079653ab3 100644
--- a/src/wal/src/walMain.c
+++ b/src/wal/src/walMain.c
@@ -30,10 +30,13 @@
#include "tqueue.h"
#define walPrefix "wal"
-#define wError(...) if (wDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR WAL ", wDebugFlag, __VA_ARGS__);}
-#define wWarn(...) if (wDebugFlag & DEBUG_WARN) {taosPrintLog("WARN WAL ", wDebugFlag, __VA_ARGS__);}
-#define wTrace(...) if (wDebugFlag & DEBUG_TRACE) {taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__);}
-#define wPrint(...) {taosPrintLog("WAL ", 255, __VA_ARGS__);}
+
+#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", 255, __VA_ARGS__); }}
+#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", 255, __VA_ARGS__); }}
+#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", 255, __VA_ARGS__); }}
+#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL INFO ", 255, __VA_ARGS__); }}
+#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL DEBUG ", wDebugFlag, __VA_ARGS__); }}
+#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL TRACE ", wDebugFlag, __VA_ARGS__); }}
typedef struct {
uint64_t version;
@@ -48,8 +51,6 @@ typedef struct {
pthread_mutex_t mutex;
} SWal;
-int wDebugFlag = 135;
-
static uint32_t walSignature = 0xFAFBFDFE;
static int walHandleExistingFiles(const char *path);
static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp);
@@ -92,7 +93,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
pWal = NULL;
}
- if (pWal) wTrace("wal:%s, it is open, level:%d", path, pWal->level);
+ if (pWal) wDebug("wal:%s, it is open, level:%d", path, pWal->level);
return pWal;
}
@@ -109,11 +110,11 @@ void walClose(void *handle) {
if (remove(pWal->name) <0) {
wError("wal:%s, failed to remove", pWal->name);
} else {
- wTrace("wal:%s, it is removed", pWal->name);
+ wDebug("wal:%s, it is removed", pWal->name);
}
}
} else {
- wTrace("wal:%s, it is closed and kept", pWal->name);
+ wDebug("wal:%s, it is closed and kept", pWal->name);
}
pthread_mutex_destroy(&pWal->mutex);
@@ -132,7 +133,7 @@ int walRenew(void *handle) {
if (pWal->fd >=0) {
close(pWal->fd);
pWal->id++;
- wTrace("wal:%s, it is closed", pWal->name);
+ wDebug("wal:%s, it is closed", pWal->name);
}
pWal->num++;
@@ -144,7 +145,7 @@ int walRenew(void *handle) {
wError("wal:%s, failed to open(%s)", pWal->name, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
} else {
- wTrace("wal:%s, it is created", pWal->name);
+ wDebug("wal:%s, it is created", pWal->name);
if (pWal->num > pWal->max) {
// remove the oldest wal file
@@ -153,7 +154,7 @@ int walRenew(void *handle) {
if (remove(name) <0) {
wError("wal:%s, failed to remove(%s)", name, strerror(errno));
} else {
- wTrace("wal:%s, it is removed", name);
+ wDebug("wal:%s, it is removed", name);
}
pWal->num--;
@@ -242,7 +243,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
wError("wal:%s, messed up, count:%d max:%d min:%d", opath, count, maxId, minId);
terrno = TSDB_CODE_WAL_APP_ERROR;
} else {
- wTrace("wal:%s, %d files will be restored", opath, count);
+ wDebug("wal:%s, %d files will be restored", opath, count);
for (index = minId; index<=maxId; ++index) {
snprintf(pWal->name, sizeof(pWal->name), "%s/%s%d", opath, walPrefix, index);
@@ -321,7 +322,7 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
return terrno;
}
- wTrace("wal:%s, start to restore", name);
+ wDebug("wal:%s, start to restore", name);
while (1) {
int ret = read(fd, pHead, sizeof(SWalHead));
@@ -395,7 +396,7 @@ int walHandleExistingFiles(const char *path) {
}
}
- wTrace("wal:%s, %d files are moved for restoration", path, count);
+ wDebug("wal:%s, %d files are moved for restoration", path, count);
}
closedir(dir);
diff --git a/tests/pytest/crash_gen.py b/tests/pytest/crash_gen.py
index c88683aa09..cc41fd5e7d 100755
--- a/tests/pytest/crash_gen.py
+++ b/tests/pytest/crash_gen.py
@@ -14,6 +14,7 @@
from __future__ import annotations # For type hinting before definition, ref: https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel
import sys
+import os
import traceback
# Require Python 3
if sys.version_info[0] < 3:
@@ -32,6 +33,7 @@ import textwrap
from typing import List
from typing import Dict
+from typing import Set
from util.log import *
from util.dnodes import *
@@ -42,7 +44,10 @@ import crash_gen
import taos
# Global variables, tried to keep a small number.
-gConfig = None # Command-line/Environment Configurations, will set a bit later
+
+# Command-line/Environment Configurations, will set a bit later
+# ConfigNameSpace = argparse.Namespace
+gConfig = argparse.Namespace() # Dummy value, will be replaced later
logger = None
def runThread(wt: WorkerThread):
@@ -64,7 +69,7 @@ class WorkerThread:
# self._curStep = -1
self._pool = pool
self._tid = tid
- self._tc = tc
+ self._tc = tc # type: ThreadCoordinator
# self.threadIdent = threading.get_ident()
self._thread = threading.Thread(target=runThread, args=(self,))
self._stepGate = threading.Event()
@@ -156,13 +161,13 @@ class WorkerThread:
if ( gConfig.per_thread_db_connection ):
return self._dbConn.execute(sql)
else:
- return self._tc.getDbState().getDbConn().execute(sql)
+ return self._tc.getDbManager().getDbConn().execute(sql)
def getDbConn(self):
if ( gConfig.per_thread_db_connection ):
return self._dbConn
else:
- return self._tc.getDbState().getDbConn()
+ return self._tc.getDbManager().getDbConn()
# def querySql(self, sql): # not "execute", since we are out side the DB context
# if ( gConfig.per_thread_db_connection ):
@@ -171,12 +176,12 @@ class WorkerThread:
# return self._tc.getDbState().getDbConn().query(sql)
class ThreadCoordinator:
- def __init__(self, pool, dbState):
+ def __init__(self, pool, dbManager):
self._curStep = -1 # first step is 0
self._pool = pool
# self._wd = wd
self._te = None # prepare for every new step
- self._dbState = dbState
+ self._dbManager = dbManager
self._executedTasks: List[Task] = [] # in a given step
self._lock = threading.RLock() # sync access for a few things
@@ -186,8 +191,8 @@ class ThreadCoordinator:
def getTaskExecutor(self):
return self._te
- def getDbState(self) -> DbState :
- return self._dbState
+ def getDbManager(self) -> DbManager :
+ return self._dbManager
def crossStepBarrier(self):
self._stepBarrier.wait()
@@ -211,7 +216,7 @@ class ThreadCoordinator:
# At this point, all threads should be pass the overall "barrier" and before the per-thread "gate"
try:
- self._dbState.transition(self._executedTasks) # at end of step, transiton the DB state
+ self._dbManager.getStateMachine().transition(self._executedTasks) # at end of step, transiton the DB state
except taos.error.ProgrammingError as err:
if ( err.msg == 'network unavailable' ): # broken DB connection
logger.info("DB connection broken, execution failed")
@@ -284,8 +289,8 @@ class ThreadCoordinator:
# logger.debug(" (dice:{}/{}) ".format(i, nTasks))
# # return copy.copy(tasks[i]) # Needs a fresh copy, to save execution results, etc.
# return tasks[i].clone() # TODO: still necessary?
- taskType = self.getDbState().pickTaskType() # pick a task type for current state
- return taskType(self.getDbState(), self._execStats) # create a task from it
+ taskType = self.getDbManager().getStateMachine().pickTaskType() # pick a task type for current state
+ return taskType(self.getDbManager(), self._execStats) # create a task from it
def resetExecutedTasks(self):
self._executedTasks = [] # should be under single thread
@@ -296,16 +301,12 @@ class ThreadCoordinator:
# We define a class to run a number of threads in locking steps.
class ThreadPool:
- def __init__(self, dbState, numThreads, maxSteps, funcSequencer):
+ def __init__(self, numThreads, maxSteps):
self.numThreads = numThreads
self.maxSteps = maxSteps
- self.funcSequencer = funcSequencer
# Internal class variables
- # self.dispatcher = WorkDispatcher(dbState) # Obsolete?
self.curStep = 0
self.threadList = []
- # self.stepGate = threading.Condition() # Gate to hold/sync all threads
- # self.numWaitingThreads = 0
# starting to run all the threads, in locking steps
def createAndStartThreads(self, tc: ThreadCoordinator):
@@ -319,7 +320,8 @@ class ThreadPool:
logger.debug("Joining thread...")
workerThread._thread.join()
-# A queue of continguous POSITIVE integers
+# A queue of continguous POSITIVE integers, used by DbManager to generate continuous numbers
+# for new table names
class LinearQueue():
def __init__(self):
self.firstIndex = 1 # 1st ever element
@@ -595,9 +597,9 @@ class StateEmpty(AnyState):
]
def verifyTasksToState(self, tasks, newState):
- if ( self.hasSuccess(tasks, CreateDbTask) ): # at EMPTY, if there's succes in creating DB
- if ( not self.hasTask(tasks, DropDbTask) ) : # and no drop_db tasks
- self.assertAtMostOneSuccess(tasks, CreateDbTask) # we must have at most one. TODO: compare numbers
+ if ( self.hasSuccess(tasks, TaskCreateDb) ): # at EMPTY, if there's succes in creating DB
+ if ( not self.hasTask(tasks, TaskDropDb) ) : # and no drop_db tasks
+ self.assertAtMostOneSuccess(tasks, TaskCreateDb) # we must have at most one. TODO: compare numbers
class StateDbOnly(AnyState):
def getInfo(self):
@@ -609,20 +611,20 @@ class StateDbOnly(AnyState):
]
def verifyTasksToState(self, tasks, newState):
- if ( not self.hasTask(tasks, CreateDbTask) ):
- self.assertAtMostOneSuccess(tasks, DropDbTask) # only if we don't create any more
- self.assertIfExistThenSuccess(tasks, DropDbTask)
+ if ( not self.hasTask(tasks, TaskCreateDb) ):
+ self.assertAtMostOneSuccess(tasks, TaskDropDb) # only if we don't create any more
+ self.assertIfExistThenSuccess(tasks, TaskDropDb)
# self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # not true in massively parrallel cases
# Nothing to be said about adding data task
- if ( self.hasSuccess(tasks, DropDbTask) ): # dropped the DB
+ # if ( self.hasSuccess(tasks, DropDbTask) ): # dropped the DB
# self.assertHasTask(tasks, DropDbTask) # implied by hasSuccess
- self.assertAtMostOneSuccess(tasks, DropDbTask)
+ # self.assertAtMostOneSuccess(tasks, DropDbTask)
# self._state = self.STATE_EMPTY
- elif ( self.hasSuccess(tasks, CreateFixedSuperTableTask) ): # did not drop db, create table success
+ if ( self.hasSuccess(tasks, TaskCreateSuperTable) ): # did not drop db, create table success
# self.assertHasTask(tasks, CreateFixedTableTask) # tried to create table
- if ( not self.hasTask(tasks, DropFixedSuperTableTask) ):
- self.assertAtMostOneSuccess(tasks, CreateFixedSuperTableTask) # at most 1 attempt is successful, if we don't drop anything
- self.assertNoTask(tasks, DropDbTask) # should have have tried
+ if ( not self.hasTask(tasks, TaskDropSuperTable) ):
+ self.assertAtMostOneSuccess(tasks, TaskCreateSuperTable) # at most 1 attempt is successful, if we don't drop anything
+ # self.assertNoTask(tasks, DropDbTask) # should have have tried
# if ( not self.hasSuccess(tasks, AddFixedDataTask) ): # just created table, no data yet
# # can't say there's add-data attempts, since they may all fail
# self._state = self.STATE_TABLE_ONLY
@@ -645,8 +647,8 @@ class StateSuperTableOnly(AnyState):
]
def verifyTasksToState(self, tasks, newState):
- if ( self.hasSuccess(tasks, DropFixedSuperTableTask) ): # we are able to drop the table
- self.assertAtMostOneSuccess(tasks, DropFixedSuperTableTask)
+ if ( self.hasSuccess(tasks, TaskDropSuperTable) ): # we are able to drop the table
+ self.assertAtMostOneSuccess(tasks, TaskDropSuperTable)
# self._state = self.STATE_DB_ONLY
# elif ( self.hasSuccess(tasks, AddFixedDataTask) ): # no success dropping the table, but added data
# self.assertNoTask(tasks, DropFixedTableTask) # not true in massively parrallel cases
@@ -670,35 +672,139 @@ class StateHasData(AnyState):
def verifyTasksToState(self, tasks, newState):
if ( newState.equals(AnyState.STATE_EMPTY) ):
- self.hasSuccess(tasks, DropDbTask)
- self.assertAtMostOneSuccess(tasks, DropDbTask) # TODO: dicy
+ self.hasSuccess(tasks, TaskDropDb)
+ if ( not self.hasTask(tasks, TaskCreateDb) ) :
+ self.assertAtMostOneSuccess(tasks, TaskDropDb) # TODO: dicy
elif ( newState.equals(AnyState.STATE_DB_ONLY) ): # in DB only
- if ( not self.hasTask(tasks, CreateDbTask)): # without a create_db task
- self.assertNoTask(tasks, DropDbTask) # we must have drop_db task
- self.hasSuccess(tasks, DropFixedSuperTableTask)
+ if ( not self.hasTask(tasks, TaskCreateDb)): # without a create_db task
+ self.assertNoTask(tasks, TaskDropDb) # we must have drop_db task
+ self.hasSuccess(tasks, TaskDropSuperTable)
# self.assertAtMostOneSuccess(tasks, DropFixedSuperTableTask) # TODO: dicy
elif ( newState.equals(AnyState.STATE_TABLE_ONLY) ): # data deleted
- self.assertNoTask(tasks, DropDbTask)
- self.assertNoTask(tasks, DropFixedSuperTableTask)
- self.assertNoTask(tasks, AddFixedDataTask)
+ self.assertNoTask(tasks, TaskDropDb)
+ self.assertNoTask(tasks, TaskDropSuperTable)
+ self.assertNoTask(tasks, TaskAddData)
# self.hasSuccess(tasks, DeleteDataTasks)
- else:
- self.assertNoTask(tasks, DropDbTask)
- self.assertNoTask(tasks, DropFixedSuperTableTask)
- self.assertIfExistThenSuccess(tasks, ReadFixedDataTask)
+ else: # should be STATE_HAS_DATA
+ self.assertNoTask(tasks, TaskDropDb)
+ if (not self.hasTask(tasks, TaskCreateSuperTable)) : # if we didn't create the table
+ self.assertNoTask(tasks, TaskDropSuperTable) # we should not have a task that drops it
+ # self.assertIfExistThenSuccess(tasks, ReadFixedDataTask)
+class StateMechine :
+ def __init__(self, dbConn):
+ self._dbConn = dbConn
+ self._curState = self._findCurrentState() # starting state
+ self._stateWeights = [1,3,5,15] # transitition target probabilities, indexed with value of STATE_EMPTY, STATE_DB_ONLY, etc.
+
+ def getCurrentState(self):
+ return self._curState
-# State of the database as we believe it to be
-class DbState():
-
+ # May be slow, use cautionsly...
+ def getTaskTypes(self): # those that can run (directly/indirectly) from the current state
+ allTaskClasses = StateTransitionTask.__subclasses__() # all state transition tasks
+ firstTaskTypes = []
+ for tc in allTaskClasses:
+ # t = tc(self) # create task object
+ if tc.canBeginFrom(self._curState):
+ firstTaskTypes.append(tc)
+ # now we have all the tasks that can begin directly from the current state, let's figure out the INDIRECT ones
+ taskTypes = firstTaskTypes.copy() # have to have these
+ for task1 in firstTaskTypes: # each task type gathered so far
+ endState = task1.getEndState() # figure the end state
+ if endState == None: # does not change end state
+ continue # no use, do nothing
+ for tc in allTaskClasses: # what task can further begin from there?
+ if tc.canBeginFrom(endState) and (tc not in firstTaskTypes):
+ taskTypes.append(tc) # gather it
+
+ if len(taskTypes) <= 0:
+ raise RuntimeError("No suitable task types found for state: {}".format(self._curState))
+ logger.debug("[OPS] Tasks found for state {}: {}".format(self._curState, taskTypes))
+ return taskTypes
+
+ def _findCurrentState(self):
+ dbc = self._dbConn
+ ts = time.time() # we use this to debug how fast/slow it is to do the various queries to find the current DB state
+ if dbc.query("show databases") == 0 : # no database?!
+ # logger.debug("Found EMPTY state")
+ logger.debug("[STT] empty database found, between {} and {}".format(ts, time.time()))
+ return StateEmpty()
+ dbc.execute("use db") # did not do this when openning connection
+ if dbc.query("show tables") == 0 : # no tables
+ # logger.debug("Found DB ONLY state")
+ logger.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time()))
+ return StateDbOnly()
+ if dbc.query("SELECT * FROM db.{}".format(DbManager.getFixedSuperTableName()) ) == 0 : # no regular tables
+ # logger.debug("Found TABLE_ONLY state")
+ logger.debug("[STT] SUPER_TABLE_ONLY found, between {} and {}".format(ts, time.time()))
+ return StateSuperTableOnly()
+ else: # has actual tables
+ # logger.debug("Found HAS_DATA state")
+ logger.debug("[STT] HAS_DATA found, between {} and {}".format(ts, time.time()))
+ return StateHasData()
+
+ def transition(self, tasks):
+ if ( len(tasks) == 0 ): # before 1st step, or otherwise empty
+ return # do nothing
+
+ self._dbConn.execute("show dnodes") # this should show up in the server log, separating steps
+
+ # Generic Checks, first based on the start state
+ if self._curState.canCreateDb():
+ self._curState.assertIfExistThenSuccess(tasks, TaskCreateDb)
+ # self.assertAtMostOneSuccess(tasks, CreateDbTask) # not really, in case of multiple creation and drops
+
+ if self._curState.canDropDb():
+ self._curState.assertIfExistThenSuccess(tasks, TaskDropDb)
+ # self.assertAtMostOneSuccess(tasks, DropDbTask) # not really in case of drop-create-drop
+
+ # if self._state.canCreateFixedTable():
+ # self.assertIfExistThenSuccess(tasks, CreateFixedTableTask) # Not true, DB may be dropped
+ # self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # not really, in case of create-drop-create
+
+ # if self._state.canDropFixedTable():
+ # self.assertIfExistThenSuccess(tasks, DropFixedTableTask) # Not True, the whole DB may be dropped
+ # self.assertAtMostOneSuccess(tasks, DropFixedTableTask) # not really in case of drop-create-drop
+
+ # if self._state.canAddData():
+ # self.assertIfExistThenSuccess(tasks, AddFixedDataTask) # not true actually
+
+ # if self._state.canReadData():
+ # Nothing for sure
+
+ newState = self._findCurrentState()
+ logger.debug("[STT] New DB state determined: {}".format(newState))
+ self._curState.verifyTasksToState(tasks, newState) # can old state move to new state through the tasks?
+ self._curState = newState
+
+ def pickTaskType(self):
+ taskTypes = self.getTaskTypes() # all the task types we can choose from at curent state
+ weights = []
+ for tt in taskTypes:
+ endState = tt.getEndState()
+ if endState != None :
+ weights.append(self._stateWeights[endState.getValIndex()]) # TODO: change to a method
+ else:
+ weights.append(10) # read data task, default to 10: TODO: change to a constant
+ i = self._weighted_choice_sub(weights)
+ # logger.debug(" (weighted random:{}/{}) ".format(i, len(taskTypes)))
+ return taskTypes[i]
+
+ def _weighted_choice_sub(self, weights): # ref: https://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/
+ rnd = random.random() * sum(weights) # TODO: use our dice to ensure it being determinstic?
+ for i, w in enumerate(weights):
+ rnd -= w
+ if rnd < 0:
+ return i
+
+# Manager of the Database Data/Connection
+class DbManager():
def __init__(self, resetDb = True):
self.tableNumQueue = LinearQueue()
self._lastTick = self.setupLastTick() # datetime.datetime(2019, 1, 1) # initial date time tick
self._lastInt = 0 # next one is initial integer
self._lock = threading.RLock()
-
- self._state = StateInvalid() # starting state
- self._stateWeights = [1,3,5,10] # indexed with value of STATE_EMPTY, STATE_DB_ONLY, etc.
# self.openDbServerConnection()
self._dbConn = DbConn()
@@ -706,7 +812,7 @@ class DbState():
self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected
except taos.error.ProgrammingError as err:
# print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err))
- if ( err.msg == 'disconnected' ): # cannot open DB connection
+ if ( err.msg == 'client disconnected' ): # cannot open DB connection
print("Cannot establish DB connection, please re-run script without parameter, and follow the instructions.")
sys.exit()
else:
@@ -717,13 +823,17 @@ class DbState():
if resetDb :
self._dbConn.resetDb() # drop and recreate DB
- self._state = self._findCurrentState()
+ self._stateMachine = StateMechine(self._dbConn) # Do this after dbConn is in proper shape
+
def getDbConn(self):
return self._dbConn
- def getState(self):
- return self._state
+ def getStateMachine(self):
+ return self._stateMachine
+
+ # def getState(self):
+ # return self._stateMachine.getCurrentState()
# We aim to create a starting time tick, such that, whenever we run our test here once
# We should be able to safely create 100,000 records, which will not have any repeated time stamp
@@ -750,7 +860,8 @@ class DbState():
tIndex = self.tableNumQueue.push()
return tIndex
- def getFixedSuperTableName(self):
+ @classmethod
+ def getFixedSuperTableName(cls):
return "fs_table"
def releaseTable(self, i): # return the table back, so others can use it
@@ -782,122 +893,6 @@ class DbState():
def cleanUp(self):
self._dbConn.close()
- # May be slow, use cautionsly...
- def getTaskTypesAtState(self):
- allTaskClasses = StateTransitionTask.__subclasses__() # all state transition tasks
- firstTaskTypes = []
- for tc in allTaskClasses:
- # t = tc(self) # create task object
- if tc.canBeginFrom(self._state):
- firstTaskTypes.append(tc)
- # now we have all the tasks that can begin directly from the current state, let's figure out the INDIRECT ones
- taskTypes = firstTaskTypes.copy() # have to have these
- for task1 in firstTaskTypes: # each task type gathered so far
- endState = task1.getEndState() # figure the end state
- if endState == None:
- continue
- for tc in allTaskClasses: # what task can further begin from there?
- if tc.canBeginFrom(endState) and (tc not in firstTaskTypes):
- taskTypes.append(tc) # gather it
-
- if len(taskTypes) <= 0:
- raise RuntimeError("No suitable task types found for state: {}".format(self._state))
- logger.debug("[OPS] Tasks found for state {}: {}".format(self._state, taskTypes))
- return taskTypes
-
- # tasks.append(ReadFixedDataTask(self)) # always for everybody
- # if ( self._state == self.STATE_EMPTY ):
- # tasks.append(CreateDbTask(self))
- # tasks.append(CreateFixedTableTask(self))
- # elif ( self._state == self.STATE_DB_ONLY ):
- # tasks.append(DropDbTask(self))
- # tasks.append(CreateFixedTableTask(self))
- # tasks.append(AddFixedDataTask(self))
- # elif ( self._state == self.STATE_TABLE_ONLY ):
- # tasks.append(DropFixedTableTask(self))
- # tasks.append(AddFixedDataTask(self))
- # elif ( self._state == self.STATE_HAS_DATA ) : # same as above. TODO: adjust
- # tasks.append(DropFixedTableTask(self))
- # tasks.append(AddFixedDataTask(self))
- # else:
- # raise RuntimeError("Unexpected DbState state: {}".format(self._state))
- # return tasks
-
- def pickTaskType(self):
- taskTypes = self.getTaskTypesAtState() # all the task types we can choose from at curent state
- weights = []
- for tt in taskTypes:
- endState = tt.getEndState()
- if endState != None :
- weights.append(self._stateWeights[endState.getValIndex()]) # TODO: change to a method
- else:
- weights.append(10) # read data task, default to 10: TODO: change to a constant
- i = self._weighted_choice_sub(weights)
- # logger.debug(" (weighted random:{}/{}) ".format(i, len(taskTypes)))
- return taskTypes[i]
-
- def _weighted_choice_sub(self, weights): # ref: https://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/
- rnd = random.random() * sum(weights) # TODO: use our dice to ensure it being determinstic?
- for i, w in enumerate(weights):
- rnd -= w
- if rnd < 0:
- return i
-
- def _findCurrentState(self):
- dbc = self._dbConn
- ts = time.time()
- if dbc.query("show databases") == 0 : # no database?!
- # logger.debug("Found EMPTY state")
- logger.debug("[STT] empty database found, between {} and {}".format(ts, time.time()))
- return StateEmpty()
- dbc.execute("use db") # did not do this when openning connection
- if dbc.query("show tables") == 0 : # no tables
- # logger.debug("Found DB ONLY state")
- logger.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time()))
- return StateDbOnly()
- if dbc.query("SELECT * FROM db.{}".format(self.getFixedSuperTableName()) ) == 0 : # no data
- # logger.debug("Found TABLE_ONLY state")
- logger.debug("[STT] SUPER_TABLE_ONLY found, between {} and {}".format(ts, time.time()))
- return StateSuperTableOnly()
- else:
- # logger.debug("Found HAS_DATA state")
- logger.debug("[STT] HAS_DATA found, between {} and {}".format(ts, time.time()))
- return StateHasData()
-
- def transition(self, tasks):
- if ( len(tasks) == 0 ): # before 1st step, or otherwise empty
- return # do nothing
-
- self._dbConn.execute("show dnodes") # this should show up in the server log, separating steps
-
- # Generic Checks, first based on the start state
- if self._state.canCreateDb():
- self._state.assertIfExistThenSuccess(tasks, CreateDbTask)
- # self.assertAtMostOneSuccess(tasks, CreateDbTask) # not really, in case of multiple creation and drops
-
- if self._state.canDropDb():
- self._state.assertIfExistThenSuccess(tasks, DropDbTask)
- # self.assertAtMostOneSuccess(tasks, DropDbTask) # not really in case of drop-create-drop
-
- # if self._state.canCreateFixedTable():
- # self.assertIfExistThenSuccess(tasks, CreateFixedTableTask) # Not true, DB may be dropped
- # self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # not really, in case of create-drop-create
-
- # if self._state.canDropFixedTable():
- # self.assertIfExistThenSuccess(tasks, DropFixedTableTask) # Not True, the whole DB may be dropped
- # self.assertAtMostOneSuccess(tasks, DropFixedTableTask) # not really in case of drop-create-drop
-
- # if self._state.canAddData():
- # self.assertIfExistThenSuccess(tasks, AddFixedDataTask) # not true actually
-
- # if self._state.canReadData():
- # Nothing for sure
-
- newState = self._findCurrentState()
- logger.debug("[STT] New DB state determined: {}".format(newState))
- self._state.verifyTasksToState(tasks, newState) # can old state move to new state through the tasks?
- self._state = newState
-
class TaskExecutor():
def __init__(self, curStep):
self._curStep = curStep
@@ -923,8 +918,8 @@ class Task():
# logger.debug("Allocating taskSN: {}".format(Task.taskSn))
return Task.taskSn
- def __init__(self, dbState: DbState, execStats: ExecutionStats):
- self._dbState = dbState
+ def __init__(self, dbManager: DbManager, execStats: ExecutionStats):
+ self._dbManager = dbManager
self._workerThread = None
self._err = None
self._curStep = None
@@ -940,7 +935,7 @@ class Task():
return self._err == None
def clone(self): # TODO: why do we need this again?
- newTask = self.__class__(self._dbState, self._execStats)
+ newTask = self.__class__(self._dbManager, self._execStats)
return newTask
def logDebug(self, msg):
@@ -966,7 +961,7 @@ class Task():
self._executeInternal(te, wt) # TODO: no return value?
except taos.error.ProgrammingError as err:
self.logDebug("[=] Taos library exception: errno={:X}, msg: {}".format(err.errno, err))
- self._err = err
+ self._err = err
except:
self.logDebug("[=] Unexpected exception")
raise
@@ -976,7 +971,7 @@ class Task():
self._execStats.incExecCount(self.__class__.__name__, self.isSuccess()) # TODO: merge with above.
def execSql(self, sql):
- return self._dbState.execute(sql)
+ return self._dbManager.execute(sql)
class ExecutionStats:
@@ -1043,20 +1038,22 @@ class ExecutionStats:
class StateTransitionTask(Task):
- # @classmethod
- # def getAllTaskClasses(cls): # static
- # return cls.__subclasses__()
@classmethod
def getInfo(cls): # each sub class should supply their own information
raise RuntimeError("Overriding method expected")
+ _endState = None
+ @classmethod
+ def getEndState(cls): # TODO: optimize by calling it fewer times
+ raise RuntimeError("Overriding method expected")
+
# @classmethod
# def getBeginStates(cls):
# return cls.getInfo()[0]
- @classmethod
- def getEndState(cls): # returning the class name
- return cls.getInfo()[0]
+ # @classmethod
+ # def getEndState(cls): # returning the class name
+ # return cls.getInfo()[0]
@classmethod
def canBeginFrom(cls, state: AnyState):
@@ -1066,15 +1063,10 @@ class StateTransitionTask(Task):
def execute(self, wt: WorkerThread):
super().execute(wt)
-
-
-class CreateDbTask(StateTransitionTask):
+class TaskCreateDb(StateTransitionTask):
@classmethod
- def getInfo(cls):
- return [
- # [AnyState.STATE_EMPTY], # can begin from
- StateDbOnly() # end state
- ]
+ def getEndState(cls):
+ return StateDbOnly()
@classmethod
def canBeginFrom(cls, state: AnyState):
@@ -1083,13 +1075,10 @@ class CreateDbTask(StateTransitionTask):
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
wt.execSql("create database db")
-class DropDbTask(StateTransitionTask):
+class TaskDropDb(StateTransitionTask):
@classmethod
- def getInfo(cls):
- return [
- # [AnyState.STATE_DB_ONLY, AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA],
- StateEmpty()
- ]
+ def getEndState(cls):
+ return StateEmpty()
@classmethod
def canBeginFrom(cls, state: AnyState):
@@ -1099,122 +1088,140 @@ class DropDbTask(StateTransitionTask):
wt.execSql("drop database db")
logger.debug("[OPS] database dropped at {}".format(time.time()))
-class CreateFixedSuperTableTask(StateTransitionTask):
+class TaskCreateSuperTable(StateTransitionTask):
@classmethod
- def getInfo(cls):
- return [
- # [AnyState.STATE_DB_ONLY],
- StateSuperTableOnly()
- ]
+ def getEndState(cls):
+ return StateSuperTableOnly()
@classmethod
def canBeginFrom(cls, state: AnyState):
return state.canCreateFixedSuperTable()
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- tblName = self._dbState.getFixedSuperTableName()
+ tblName = self._dbManager.getFixedSuperTableName()
wt.execSql("create table db.{} (ts timestamp, speed int) tags (b binary(200), f float) ".format(tblName))
# No need to create the regular tables, INSERT will do that automatically
-class ReadFixedDataTask(StateTransitionTask):
+class TaskReadData(StateTransitionTask):
@classmethod
- def getInfo(cls):
- return [
- # [AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA],
- None # meaning doesn't affect state
- ]
+ def getEndState(cls):
+ return None # meaning doesn't affect state
@classmethod
def canBeginFrom(cls, state: AnyState):
return state.canReadData()
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- sTbName = self._dbState.getFixedSuperTableName()
+ sTbName = self._dbManager.getFixedSuperTableName()
dbc = wt.getDbConn()
dbc.query("select TBNAME from db.{}".format(sTbName)) # TODO: analyze result set later
- rTables = dbc.getQueryResult()
- # print("rTables[0] = {}, type = {}".format(rTables[0], type(rTables[0])))
- for rTbName in rTables : # regular tables
- dbc.query("select * from db.{}".format(rTbName[0])) # TODO: check success failure
+ if random.randrange(5) == 0 : # 1 in 5 chance, simulate a broken connection. TODO: break connection in all situations
+ dbc.close()
+ dbc.open()
+ else:
+ rTables = dbc.getQueryResult()
+ # print("rTables[0] = {}, type = {}".format(rTables[0], type(rTables[0])))
+ for rTbName in rTables : # regular tables
+ dbc.query("select * from db.{}".format(rTbName[0])) # TODO: check success failure
# tdSql.query(" cars where tbname in ('carzero', 'carone')")
-class DropFixedSuperTableTask(StateTransitionTask):
+class TaskDropSuperTable(StateTransitionTask):
@classmethod
- def getInfo(cls):
- return [
- # [AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA],
- StateDbOnly() # meaning doesn't affect state
- ]
+ def getEndState(cls):
+ return StateDbOnly()
@classmethod
def canBeginFrom(cls, state: AnyState):
return state.canDropFixedSuperTable()
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- tblName = self._dbState.getFixedSuperTableName()
+ tblName = self._dbManager.getFixedSuperTableName()
wt.execSql("drop table db.{}".format(tblName))
-class AddFixedDataTask(StateTransitionTask):
+class TaskAlterTags(StateTransitionTask):
@classmethod
- def getInfo(cls):
- return [
- # [AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA],
- StateHasData()
- ]
+ def getEndState(cls):
+ return None # meaning doesn't affect state
+
+ @classmethod
+ def canBeginFrom(cls, state: AnyState):
+ return state.canDropFixedSuperTable() # if we can drop it, we can alter tags
+
+ def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
+ tblName = self._dbManager.getFixedSuperTableName()
+ dice = Dice.throw(4)
+ if dice == 0 :
+ wt.execSql("alter table db.{} add tag extraTag int".format(tblName))
+ elif dice == 1 :
+ wt.execSql("alter table db.{} drop tag extraTag".format(tblName))
+ elif dice == 2 :
+ wt.execSql("alter table db.{} drop tag newTag".format(tblName))
+ else: # dice == 3
+ wt.execSql("alter table db.{} change tag extraTag newTag".format(tblName))
+
+class TaskAddData(StateTransitionTask):
+ activeTable : Set[int] = set() # Track which table is being actively worked on
+ LARGE_NUMBER_OF_TABLES = 35
+ SMALL_NUMBER_OF_TABLES = 3
+ LARGE_NUMBER_OF_RECORDS = 50
+ SMALL_NUMBER_OF_RECORDS = 3
+
+ # We use these two files to record operations to DB, useful for power-off tests
+ fAddLogReady = None
+ fAddLogDone = None
+
+ @classmethod
+ def prepToRecordOps(cls):
+ if gConfig.record_ops :
+ if ( cls.fAddLogReady == None ):
+ logger.info("Recording in a file operations to be performed...")
+ cls.fAddLogReady = open("add_log_ready.txt", "w")
+ if ( cls.fAddLogDone == None ):
+ logger.info("Recording in a file operations completed...")
+ cls.fAddLogDone = open("add_log_done.txt", "w")
+
+ @classmethod
+ def getEndState(cls):
+ return StateHasData()
@classmethod
def canBeginFrom(cls, state: AnyState):
return state.canAddData()
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- ds = self._dbState
+ ds = self._dbManager
wt.execSql("use db") # TODO: seems to be an INSERT bug to require this
- for i in range(10): # 0 to 9
- for j in range(10) :
- sql = "insert into db.reg_table_{} using {} tags ('{}', {}) values ('{}', {});".format(
- i,
+ tblSeq = list(range(self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES))
+ random.shuffle(tblSeq)
+ for i in tblSeq:
+ if ( i in self.activeTable ): # wow already active
+ # logger.info("Concurrent data insertion into table: {}".format(i))
+ # print("ct({})".format(i), end="", flush=True) # Concurrent insertion into table
+ print("x", end="", flush=True)
+ else:
+ self.activeTable.add(i) # marking it active
+ # No need to shuffle data sequence, unless later we decide to do non-increment insertion
+ for j in range(self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS) : # number of records per table
+ nextInt = ds.getNextInt()
+ regTableName = "db.reg_table_{}".format(i)
+ if gConfig.record_ops:
+ self.prepToRecordOps()
+ self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName))
+ self.fAddLogReady.flush()
+ os.fsync(self.fAddLogReady)
+ sql = "insert into {} using {} tags ('{}', {}) values ('{}', {});".format(
+ regTableName,
ds.getFixedSuperTableName(),
ds.getNextBinary(), ds.getNextFloat(),
- ds.getNextTick(), ds.getNextInt())
+ ds.getNextTick(), nextInt)
wt.execSql(sql)
-
-
-#---------- Non State-Transition Related Tasks ----------#
-
-class CreateTableTask(Task):
- def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- tIndex = self._dbState.addTable()
- self.logDebug("Creating a table {} ...".format(tIndex))
- wt.execSql("create table db.table_{} (ts timestamp, speed int)".format(tIndex))
- self.logDebug("Table {} created.".format(tIndex))
- self._dbState.releaseTable(tIndex)
-
-class DropTableTask(Task):
- def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- tableName = self._dbState.getTableNameToDelete()
- if ( not tableName ): # May be "False"
- self.logInfo("Cannot generate a table to delete, skipping...")
- return
- self.logInfo("Dropping a table db.{} ...".format(tableName))
- wt.execSql("drop table db.{}".format(tableName))
-
-
-
-class AddDataTask(Task):
- def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- ds = self._dbState
- self.logInfo("Adding some data... numQueue={}".format(ds.tableNumQueue.toText()))
- tIndex = ds.pickAndAllocateTable()
- if ( tIndex == None ):
- self.logInfo("No table found to add data, skipping...")
- return
- sql = "insert into db.table_{} values ('{}', {});".format(tIndex, ds.getNextTick(), ds.getNextInt())
- self.logDebug("[SQL] Executing SQL: {}".format(sql))
- wt.execSql(sql)
- ds.releaseTable(tIndex)
- self.logDebug("[OPS] Finished adding data")
+ if gConfig.record_ops:
+ self.fAddLogDone.write("Wrote {} to {}\n".format(nextInt, regTableName))
+ self.fAddLogDone.flush()
+ os.fsync(self.fAddLogDone)
+ self.activeTable.discard(i) # not raising an error, unlike remove
# Deterministic random number generator
@@ -1301,10 +1308,14 @@ def main():
2. You run the server there before this script: ./build/bin/taosd -c test/cfg
'''))
- parser.add_argument('-p', '--per-thread-db-connection', action='store_true',
- help='Use a single shared db connection (default: false)')
parser.add_argument('-d', '--debug', action='store_true',
help='Turn on DEBUG mode for more logging (default: false)')
+ parser.add_argument('-l', '--larger-data', action='store_true',
+ help='Write larger amount of data during write operations (default: false)')
+ parser.add_argument('-p', '--per-thread-db-connection', action='store_true',
+ help='Use a single shared db connection (default: false)')
+ parser.add_argument('-r', '--record-ops', action='store_true',
+ help='Use a pair of always-fsynced fils to record operations performing + performed, for power-off tests (default: false)')
parser.add_argument('-s', '--max-steps', action='store', default=100, type=int,
help='Maximum number of steps to run (default: 100)')
parser.add_argument('-t', '--num-threads', action='store', default=10, type=int,
@@ -1328,12 +1339,12 @@ def main():
# resetDb = False # DEBUG only
# dbState = DbState(resetDb) # DBEUG only!
- dbState = DbState() # Regular function
+ dbManager = DbManager() # Regular function
Dice.seed(0) # initial seeding of dice
tc = ThreadCoordinator(
- ThreadPool(dbState, gConfig.num_threads, gConfig.max_steps, 0),
+ ThreadPool(gConfig.num_threads, gConfig.max_steps),
# WorkDispatcher(dbState), # Obsolete?
- dbState
+ dbManager
)
# # Hack to exercise reading from disk, imcreasing coverage. TODO: fix
@@ -1381,7 +1392,7 @@ def main():
tc.run()
tc.logStats()
- dbState.cleanUp()
+ dbManager.cleanUp()
# logger.info("Crash_Gen execution finished")
diff --git a/tests/pytest/random-test/random-test-multi-threading-3.py b/tests/pytest/random-test/random-test-multi-threading-3.py
index 47c4228a8f..7079a5c118 100644
--- a/tests/pytest/random-test/random-test-multi-threading-3.py
+++ b/tests/pytest/random-test/random-test-multi-threading-3.py
@@ -24,19 +24,23 @@ last_tb = ""
last_stb = ""
written = 0
last_timestamp = 0
+colAdded = False
+killed = False
class Test (Thread):
- def __init__(self, threadId, name, events):
+ def __init__(self, threadId, name, events, q):
Thread.__init__(self)
self.threadId = threadId
self.name = name
self.dataEvent, self.dbEvent, self.queryEvent = events
+ self.q = q
def create_table(self):
tdLog.info("create_table")
global last_tb
global written
+ global killed
current_tb = "tb%d" % int(round(time.time() * 1000))
@@ -51,8 +55,14 @@ class Test (Thread):
current_tb)
last_tb = current_tb
written = 0
+ killed = False
except Exception as e:
- tdLog.info(repr(e))
+ tdLog.info("killed: %d error: %s" % (killed, e.args[0]))
+ if killed and (e.args[0] == 'network unavailable'):
+ tdLog.info("database killed, expect failed")
+ return 0
+ return -1
+ return 0
def insert_data(self):
tdLog.info("insert_data")
@@ -74,22 +84,33 @@ class Test (Thread):
for j in range(0, insertRows):
if (last_tb == ""):
tdLog.info("no table, return")
- return
- tdSql.execute(
- 'insert into %s values (%d + %da, %d, "test")' %
- (last_tb, start_time, last_timestamp, last_timestamp))
- written = written + 1
- last_timestamp = last_timestamp + 1
+ return 0
+ try:
+ tdSql.execute(
+ 'insert into %s values (%d + %da, %d, "test")' %
+ (last_tb, start_time, last_timestamp, last_timestamp))
+ written = written + 1
+ last_timestamp = last_timestamp + 1
+ except Exception as e:
+ if killed:
+ tdLog.info(
+ "database killed, expect failed %s" %
+ e.args[0])
+ return 0
+ tdLog.info(repr(e))
+ return -1
+ return 0
def query_data(self):
tdLog.info("query_data")
global last_tb
- global written
+ global killed
- if (written > 0):
+ if not killed and last_tb != "":
tdLog.info("query data from table")
tdSql.query("select * from %s" % last_tb)
tdSql.checkRows(written)
+ return 0
def create_stable(self):
tdLog.info("create_stable")
@@ -123,6 +144,7 @@ class Test (Thread):
(last_tb, start_time, last_timestamp))
written = written + 1
last_timestamp = last_timestamp + 1
+ return 0
def drop_stable(self):
tdLog.info("drop_stable")
@@ -139,22 +161,57 @@ class Test (Thread):
last_stb = ""
last_tb = ""
written = 0
+ return 0
+
+ def alter_table_to_add_col(self):
+ tdLog.info("alter_table_to_add_col")
+ global last_stb
+ global colAdded
+
+ if last_stb != "" and colAdded == False:
+ tdSql.execute(
+ "alter table %s add column col binary(20)" %
+ last_stb)
+ colAdded = True
+ return 0
+
+ def alter_table_to_drop_col(self):
+ tdLog.info("alter_table_to_drop_col")
+ global last_stb
+ global colAdded
+
+ if last_stb != "" and colAdded:
+ tdSql.execute("alter table %s drop column col" % last_stb)
+ colAdded = False
+ return 0
def restart_database(self):
tdLog.info("restart_database")
global last_tb
global written
+ global killed
tdDnodes.stop(1)
+ killed = True
tdDnodes.start(1)
+ tdLog.sleep(10)
+ killed = False
+ return 0
def force_restart_database(self):
tdLog.info("force_restart_database")
global last_tb
global written
+ global killed
tdDnodes.forcestop(1)
+ last_tb = ""
+ written = 0
+ killed = True
tdDnodes.start(1)
+# tdLog.sleep(10)
+ killed = False
+ return 0
def drop_table(self):
tdLog.info("drop_table")
@@ -167,6 +224,7 @@ class Test (Thread):
tdSql.execute("drop table %s" % last_tb)
last_tb = ""
written = 0
+ return 0
def query_data_from_stable(self):
tdLog.info("query_data_from_stable")
@@ -178,6 +236,7 @@ class Test (Thread):
else:
tdLog.info("will query data from super table")
tdSql.execute('select * from %s' % last_stb)
+ return 0
def reset_query_cache(self):
tdLog.info("reset_query_cache")
@@ -187,39 +246,45 @@ class Test (Thread):
tdLog.info("reset query cache")
tdSql.execute("reset query cache")
tdLog.sleep(1)
+ return 0
def reset_database(self):
tdLog.info("reset_database")
global last_tb
global last_stb
global written
+ global killed
tdDnodes.forcestop(1)
+ killed = True
tdDnodes.deploy(1)
tdDnodes.start(1)
tdSql.prepare()
- last_tb = ""
- last_stb = ""
- written = 0
+ killed = False
+ return 0
def delete_datafiles(self):
tdLog.info("delete_data_files")
global last_tb
global last_stb
global written
+ global killed
dnodesDir = tdDnodes.getDnodesRootDir()
tdDnodes.forcestop(1)
+ killed = True
dataDir = dnodesDir + '/dnode1/data/*'
deleteCmd = 'rm -rf %s' % dataDir
os.system(deleteCmd)
-
- tdDnodes.start(1)
- tdSql.prepare()
last_tb = ""
last_stb = ""
written = 0
+ tdDnodes.start(1)
+ tdSql.prepare()
+ killed = False
+ return 0
+
def run(self):
dataOp = {
1: self.insert_data,
@@ -235,6 +300,8 @@ class Test (Thread):
7: self.reset_database,
8: self.delete_datafiles,
9: self.drop_stable,
+ 10: self.alter_table_to_add_col,
+ 11: self.alter_table_to_drop_col,
}
queryOp = {
@@ -247,16 +314,28 @@ class Test (Thread):
self.dataEvent.wait()
tdLog.notice("first thread")
randDataOp = random.randint(1, 1)
- dataOp.get(randDataOp, lambda: "ERROR")()
- self.dataEvent.clear()
- self.queryEvent.clear()
- self.dbEvent.set()
+ ret1 = dataOp.get(randDataOp, lambda: "ERROR")()
+
+ if ret1 == -1:
+ self.q.put(-1)
+ tdLog.exit("first thread failed")
+ else:
+ self.q.put(1)
+
+ if (self.q.get() != -2):
+ self.dataEvent.clear()
+ self.queryEvent.clear()
+ self.dbEvent.set()
+ else:
+ self.q.put(-1)
+ tdLog.exit("second thread failed, first thread exit too")
+
elif (self.threadId == 2):
while True:
self.dbEvent.wait()
tdLog.notice("second thread")
- randDbOp = random.randint(1, 9)
+ randDbOp = random.randint(1, 11)
dbOp.get(randDbOp, lambda: "ERROR")()
self.dbEvent.clear()
self.dataEvent.clear()
@@ -298,6 +377,10 @@ class TDTestCase:
test2.join()
test3.join()
+ while not q.empty():
+ if (q.get() != 0):
+ tdLog.exit("failed to end of test")
+
tdLog.info("end of test")
def stop(self):
diff --git a/tests/pytest/random-test/random-test-multi-threading.py b/tests/pytest/random-test/random-test-multi-threading.py
index 65b6dcd948..81862edcf1 100644
--- a/tests/pytest/random-test/random-test-multi-threading.py
+++ b/tests/pytest/random-test/random-test-multi-threading.py
@@ -14,6 +14,7 @@
import sys
import random
import threading
+import queue
from util.log import *
from util.cases import *
@@ -24,13 +25,16 @@ last_tb = ""
last_stb = ""
written = 0
last_timestamp = 0
+colAdded = False
+killed = False
class Test (threading.Thread):
- def __init__(self, threadId, name):
+ def __init__(self, threadId, name, q):
threading.Thread.__init__(self)
self.threadId = threadId
self.name = name
+ self.q = q
self.threadLock = threading.Lock()
@@ -38,11 +42,12 @@ class Test (threading.Thread):
tdLog.info("create_table")
global last_tb
global written
+ global killed
current_tb = "tb%d" % int(round(time.time() * 1000))
if (current_tb == last_tb):
- return
+ return 0
else:
tdLog.info("will create table %s" % current_tb)
@@ -52,8 +57,14 @@ class Test (threading.Thread):
current_tb)
last_tb = current_tb
written = 0
+ killed = False
except Exception as e:
- tdLog.info(repr(e))
+ tdLog.info("killed: %d error: %s" % (killed, e.args[0]))
+ if killed and (e.args[0] == 'network unavailable'):
+ tdLog.info("database killed, expect failed")
+ return 0
+ return -1
+ return 0
def insert_data(self):
tdLog.info("insert_data")
@@ -75,22 +86,34 @@ class Test (threading.Thread):
for j in range(0, insertRows):
if (last_tb == ""):
tdLog.info("no table, return")
- return
- tdSql.execute(
- 'insert into %s values (%d + %da, %d, "test")' %
- (last_tb, start_time, last_timestamp, last_timestamp))
- written = written + 1
- last_timestamp = last_timestamp + 1
+ return 0
+
+ try:
+ tdSql.execute(
+ 'insert into %s values (%d + %da, %d, "test")' %
+ (last_tb, start_time, last_timestamp, last_timestamp))
+ written = written + 1
+ last_timestamp = last_timestamp + 1
+ except Exception as e:
+ if killed:
+ tdLog.info(
+ "database killed, expect failed %s" %
+ e.args[0])
+ return 0
+ tdLog.info(repr(e))
+ return -1
+ return 0
def query_data(self):
tdLog.info("query_data")
global last_tb
- global written
+ global killed
- if (written > 0):
+ if not killed and last_tb != "":
tdLog.info("query data from table")
tdSql.query("select * from %s" % last_tb)
tdSql.checkRows(written)
+ return 0
def create_stable(self):
tdLog.info("create_stable")
@@ -101,9 +124,7 @@ class Test (threading.Thread):
current_stb = "stb%d" % int(round(time.time() * 1000))
- if (current_stb == last_stb):
- return
- else:
+ if (current_stb != last_stb):
tdLog.info("will create stable %s" % current_stb)
tdLog.info(
'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))' %
@@ -131,6 +152,8 @@ class Test (threading.Thread):
written = written + 1
last_timestamp = last_timestamp + 1
+ return 0
+
def drop_stable(self):
tdLog.info("drop_stable")
global last_stb
@@ -139,31 +162,63 @@ class Test (threading.Thread):
if (last_stb == ""):
tdLog.info("no super table")
- return
else:
- tdLog.info("will drop last super table")
+ tdLog.info("will drop last super table %s" % last_stb)
tdSql.execute('drop table %s' % last_stb)
last_stb = ""
last_tb = ""
written = 0
+ return 0
+
+ def alter_table_to_add_col(self):
+ tdLog.info("alter_table_to_add_col")
+ global last_stb
+ global colAdded
+
+ if last_stb != "" and not colAdded:
+ tdSql.execute(
+ "alter table %s add column col binary(20)" %
+ last_stb)
+ colAdded = True
+ return 0
+
+ def alter_table_to_drop_col(self):
+ tdLog.info("alter_table_to_drop_col")
+ global last_stb
+ global colAdded
+
+ if last_stb != "" and colAdded:
+ tdSql.execute("alter table %s drop column col" % last_stb)
+ colAdded = False
+ return 0
def restart_database(self):
tdLog.info("restart_database")
global last_tb
global written
+ global killed
tdDnodes.stop(1)
+ killed = True
tdDnodes.start(1)
-# tdLog.sleep(5)
+ tdLog.sleep(10)
+ killed = False
+ return 0
def force_restart_database(self):
tdLog.info("force_restart_database")
global last_tb
global written
+ global killed
tdDnodes.forcestop(1)
+ last_tb = ""
+ written = 0
+ killed = True
tdDnodes.start(1)
# tdLog.sleep(10)
+ killed = False
+ return 0
def drop_table(self):
tdLog.info("drop_table")
@@ -176,6 +231,7 @@ class Test (threading.Thread):
tdSql.execute("drop table %s" % last_tb)
last_tb = ""
written = 0
+ return 0
def query_data_from_stable(self):
tdLog.info("query_data_from_stable")
@@ -183,10 +239,10 @@ class Test (threading.Thread):
if (last_stb == ""):
tdLog.info("no super table")
- return
else:
tdLog.info("will query data from super table")
tdSql.execute('select * from %s' % last_stb)
+ return 0
def reset_query_cache(self):
tdLog.info("reset_query_cache")
@@ -196,39 +252,45 @@ class Test (threading.Thread):
tdLog.info("reset query cache")
tdSql.execute("reset query cache")
# tdLog.sleep(1)
+ return 0
def reset_database(self):
tdLog.info("reset_database")
global last_tb
global last_stb
global written
+ global killed
tdDnodes.forcestop(1)
+ killed = True
tdDnodes.deploy(1)
tdDnodes.start(1)
tdSql.prepare()
- last_tb = ""
- last_stb = ""
- written = 0
+ killed = False
+ return 0
def delete_datafiles(self):
tdLog.info("delete_data_files")
global last_tb
global last_stb
global written
+ global killed
dnodesDir = tdDnodes.getDnodesRootDir()
tdDnodes.forcestop(1)
+ killed = True
dataDir = dnodesDir + '/dnode1/data/*'
deleteCmd = 'rm -rf %s' % dataDir
os.system(deleteCmd)
-
- tdDnodes.start(1)
- tdSql.prepare()
last_tb = ""
last_stb = ""
written = 0
+ tdDnodes.start(1)
+ tdSql.prepare()
+ killed = False
+ return 0
+
def run(self):
dataOp = {
1: self.insert_data,
@@ -246,6 +308,8 @@ class Test (threading.Thread):
7: self.reset_database,
8: self.delete_datafiles,
9: self.drop_stable,
+ 10: self.alter_table_to_add_col,
+ 11: self.alter_table_to_drop_col,
}
if (self.threadId == 1):
@@ -253,16 +317,38 @@ class Test (threading.Thread):
self.threadLock.acquire()
tdLog.notice("first thread")
randDataOp = random.randint(1, 3)
- dataOp.get(randDataOp, lambda: "ERROR")()
- self.threadLock.release()
+ ret1 = dataOp.get(randDataOp, lambda: "ERROR")()
+
+ if ret1 == -1:
+ self.q.put(-1)
+ tdLog.exit("first thread failed")
+ else:
+ self.q.put(1)
+
+ if (self.q.get() != -2):
+ self.threadLock.release()
+ else:
+ self.q.put(-1)
+ tdLog.exit("second thread failed, first thread exit too")
elif (self.threadId == 2):
while True:
- tdLog.notice("second thread")
self.threadLock.acquire()
- randDbOp = random.randint(1, 9)
- dbOp.get(randDbOp, lambda: "ERROR")()
- self.threadLock.release()
+ tdLog.notice("second thread")
+ randDbOp = random.randint(1, 11)
+ ret2 = dbOp.get(randDbOp, lambda: "ERROR")()
+
+ if ret2 == -1:
+ self.q.put(-2)
+ tdLog.exit("second thread failed")
+ else:
+ self.q.put(2)
+
+ if (self.q.get() != -1):
+ self.threadLock.release()
+ else:
+ self.q.put(-2)
+ tdLog.exit("first thread failed, second exit too")
class TDTestCase:
@@ -273,14 +359,19 @@ class TDTestCase:
def run(self):
tdSql.prepare()
- test1 = Test(1, "data operation")
- test2 = Test(2, "db operation")
+ q = queue.Queue()
+ test1 = Test(1, "data operation", q)
+ test2 = Test(2, "db operation", q)
test1.start()
test2.start()
test1.join()
test2.join()
+ while not q.empty():
+ if (q.get() != 0):
+ tdLog.exit("failed to end of test")
+
tdLog.info("end of test")
def stop(self):
diff --git a/tests/pytest/random-test/random-test.py b/tests/pytest/random-test/random-test.py
index 38cefb3eec..cecefe379d 100644
--- a/tests/pytest/random-test/random-test.py
+++ b/tests/pytest/random-test/random-test.py
@@ -25,6 +25,7 @@ class Test:
self.last_tb = ""
self.last_stb = ""
self.written = 0
+ self.colAdded = False
def create_table(self):
tdLog.info("create_table")
@@ -39,6 +40,7 @@ class Test:
current_tb)
self.last_tb = current_tb
self.written = 0
+ self.colAdded = False
def insert_data(self):
tdLog.info("insert_data")
@@ -50,28 +52,52 @@ class Test:
insertRows = 10
tdLog.info("insert %d rows to %s" % (insertRows, self.last_tb))
for i in range(0, insertRows):
- ret = tdSql.execute(
- 'insert into %s values (now + %dm, %d, "%s")' %
- (self.last_tb, i, i, "->" + str(i)))
+ if self.colAdded:
+ ret = tdSql.execute(
+ 'insert into %s values (now + %dm, %d, "%s", "%s")' %
+ (self.last_tb, i, i, "->" + str(i)), "col")
+ else:
+ ret = tdSql.execute(
+ 'insert into %s values (now + %dm, %d, "%s")' %
+ (self.last_tb, i, i, "->" + str(i)))
+
self.written = self.written + 1
tdLog.info("insert earlier data")
- tdSql.execute(
- 'insert into %s values (now - 5m , 10, " - 5m")' %
- self.last_tb)
- self.written = self.written + 1
- tdSql.execute(
- 'insert into %s values (now - 6m , 10, " - 6m")' %
- self.last_tb)
- self.written = self.written + 1
- tdSql.execute(
- 'insert into %s values (now - 7m , 10, " - 7m")' %
- self.last_tb)
- self.written = self.written + 1
- tdSql.execute(
- 'insert into %s values (now - 8m , 10, " - 8m")' %
- self.last_tb)
- self.written = self.written + 1
+ if self.colAdded:
+ tdSql.execute(
+ 'insert into %s values (now - 5m , 10, " - 5m", "col")' %
+ self.last_tb)
+ self.written = self.written + 1
+ tdSql.execute(
+ 'insert into %s values (now - 6m , 10, " - 6m", "col")' %
+ self.last_tb)
+ self.written = self.written + 1
+ tdSql.execute(
+ 'insert into %s values (now - 7m , 10, " - 7m", "col")' %
+ self.last_tb)
+ self.written = self.written + 1
+ tdSql.execute(
+ 'insert into %s values (now - 8m , 10, " - 8m", "col")' %
+ self.last_tb)
+ self.written = self.written + 1
+ else:
+ tdSql.execute(
+ 'insert into %s values (now - 5m , 10, " - 5m")' %
+ self.last_tb)
+ self.written = self.written + 1
+ tdSql.execute(
+ 'insert into %s values (now - 6m , 10, " - 6m")' %
+ self.last_tb)
+ self.written = self.written + 1
+ tdSql.execute(
+ 'insert into %s values (now - 7m , 10, " - 7m")' %
+ self.last_tb)
+ self.written = self.written + 1
+ tdSql.execute(
+ 'insert into %s values (now - 8m , 10, " - 8m")' %
+ self.last_tb)
+ self.written = self.written + 1
def query_data(self):
tdLog.info("query_data")
@@ -88,21 +114,48 @@ class Test:
return
else:
tdLog.info("will create stable %s" % current_stb)
+
+ db = "db"
+ tdSql.execute("drop database if exists %s" % (db))
+ tdSql.execute("reset query cache")
+ tdSql.execute("create database %s maxrows 200 maxtables 30" % (db))
+ tdSql.execute("use %s" % (db))
+
tdSql.execute(
'create table %s(ts timestamp, c1 int, c2 nchar(10)) tags (t1 int, t2 nchar(10))' %
current_stb)
self.last_stb = current_stb
+ self.colAdded = False
- current_tb = "tb%d" % int(round(time.time() * 1000))
- sqlcmd = "create table %s using %s tags (1, 'test')" %(current_tb, self.last_stb)
- tdSql.execute(sqlcmd)
- self.last_tb = current_tb
- self.written = 0
+ for k in range(1, 300):
+ current_tb = "tb%d" % int(round(time.time() * 1000))
+ sqlcmd = "create table %s using %s tags (1, 'test')" % (
+ current_tb, self.last_stb)
+ tdSql.execute(sqlcmd)
+ self.last_tb = current_tb
+ self.written = 0
+ for j in range(1, 100):
+ tdSql.execute(
+ "insert into %s values (now + %da, 27, 'wsnchar')" %
+ (self.last_tb, j))
+ self.written = self.written + 1
+
+ def alter_table_to_add_col(self):
+ tdLog.info("alter_table_to_add_col")
+
+ if self.last_stb != "" and not self.colAdded:
tdSql.execute(
- "insert into %s values (now, 27, 'wsnchar')" %
- self.last_tb)
- self.written = self.written + 1
+ "alter table %s add column col binary(20)" %
+ self.last_stb)
+ self.colAdded = True
+
+ def alter_table_to_drop_col(self):
+ tdLog.info("alter_table_to_drop_col")
+
+ if self.last_stb != "" and self.colAdded:
+ tdSql.execute("alter table %s drop column col" % self.last_stb)
+ self.colAdded = False
def drop_stable(self):
tdLog.info("drop_stable")
@@ -126,16 +179,16 @@ class Test:
tdSql.execute('select * from %s' % self.last_stb)
def restart_database(self):
- tdLog.info("restart_databae")
+ tdLog.info("restart_database")
tdDnodes.stop(1)
tdDnodes.start(1)
- tdLog.sleep(5)
+ tdLog.sleep(10)
def force_restart_database(self):
tdLog.info("force_restart_database")
tdDnodes.forcestop(1)
tdDnodes.start(1)
- tdLog.sleep(5)
+ tdLog.sleep(10)
tdSql.prepare()
self.last_tb = ""
self.last_stb = ""
@@ -161,7 +214,7 @@ class Test:
self.last_tb = ""
self.written = 0
tdDnodes.start(1)
- tdLog.sleep(5)
+ tdLog.sleep(10)
tdSql.prepare()
self.last_tb = ""
self.last_stb = ""
@@ -209,10 +262,12 @@ class TDTestCase:
10: test.delete_datafiles,
11: test.query_data_from_stable,
12: test.drop_stable,
+ 13: test.alter_table_to_add_col,
+ 14: test.alter_table_to_drop_col,
}
for x in range(1, 1000):
- r = random.randint(1, 12)
+ r = random.randint(1, 14)
tdLog.notice("iteration %d run func %d" % (x, r))
switch.get(r, lambda: "ERROR")()
diff --git a/tests/pytest/stable/query_after_reset.py b/tests/pytest/stable/query_after_reset.py
index 2bc171ae5d..61f6558b83 100644
--- a/tests/pytest/stable/query_after_reset.py
+++ b/tests/pytest/stable/query_after_reset.py
@@ -126,7 +126,7 @@ class Test:
def delete_datafiles(self):
tdLog.info("delete data files")
dnodesDir = tdDnodes.getDnodesRootDir()
- dataDir = dnodesDir + '/dnode1/*'
+ dataDir = dnodesDir + '/dnode1/data/*'
deleteCmd = 'rm -rf %s' % dataDir
os.system(deleteCmd)
diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py
index 3b86a53343..e282298b7c 100644
--- a/tests/pytest/util/sql.py
+++ b/tests/pytest/util/sql.py
@@ -41,16 +41,12 @@ class TDSql:
def prepare(self):
tdLog.info("prepare database:db")
s = 'reset query cache'
- print(s)
self.cursor.execute(s)
s = 'drop database if exists db'
- print(s)
self.cursor.execute(s)
s = 'create database db'
- print(s)
self.cursor.execute(s)
s = 'use db'
- print(s)
self.cursor.execute(s)
def error(self, sql):
@@ -74,7 +70,6 @@ class TDSql:
def query(self, sql):
self.sql = sql
- print(sql)
self.cursor.execute(sql)
self.queryResult = self.cursor.fetchall()
self.queryRows = len(self.queryResult)
@@ -191,7 +186,6 @@ class TDSql:
def execute(self, sql):
self.sql = sql
- print(sql)
self.affectedRows = self.cursor.execute(sql)
return self.affectedRows
diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/general/parser/auto_create_tb.sim
index 6065daa6d3..64fec4b56d 100644
--- a/tests/script/general/parser/auto_create_tb.sim
+++ b/tests/script/general/parser/auto_create_tb.sim
@@ -153,13 +153,13 @@ print $rows $data00 $data10 $data20
if $rows != 3 then
return -1
endi
-if $data00 != tb3 then
+if $data00 != tb1 then
return -1
endi
if $data10 != tb2 then
return -1
endi
-if $data20 != tb1 then
+if $data20 != tb3 then
return -1
endi
@@ -221,13 +221,13 @@ sql show tables
if $rows != 3 then
return -1
endi
-if $data00 != tb3 then
+if $data00 != tb1 then
return -1
endi
if $data10 != tb2 then
return -1
endi
-if $data20 != tb1 then
+if $data20 != tb3 then
return -1
endi
diff --git a/tests/script/general/parser/nchar.sim b/tests/script/general/parser/nchar.sim
index c0de6f5058..8d4e468f0e 100644
--- a/tests/script/general/parser/nchar.sim
+++ b/tests/script/general/parser/nchar.sim
@@ -76,7 +76,7 @@ endi
# insert nchar data with a pair of single quotes
$col = 'NCHAR'
$col_ = NCHAR
-sql insert into $tb values (now, $col )
+sql insert into $tb values (now+1s, $col )
sql select * from $tb order by ts desc
print expected: $col_
print returned: $data01
@@ -87,7 +87,7 @@ endi
# insert nchar data with a pair of double quotes
$col = "NCHAR"
$col_ = NCHAR
-sql insert into $tb values (now, $col )
+sql insert into $tb values (now+2s, $col )
sql select * from $tb order by ts desc
print expected: $col_
print returned: $data01
@@ -98,7 +98,7 @@ endi
# insert nchar data without quotes
$col = NCHAR
$col_ = nchar
-sql_error insert into $tb values (now, $col )
+sql_error insert into $tb values (now+3s, $col )
sql select * from $tb order by ts desc
#print expected: $col_
#print returned: $data01
@@ -107,10 +107,10 @@ sql select * from $tb order by ts desc
#endi
# insert nchar data with space and no quotes
-sql_error insert into $tb values (now, n char )
+sql_error insert into $tb values (now+4s, n char )
# insert nchar data with space and a pair of single quotes
-sql insert into $tb values (now, 'NCHAR' )
+sql insert into $tb values (now+5s, 'NCHAR' )
sql select * from $tb order by ts desc
print expected: NCHAR
print returned: $data01
@@ -126,7 +126,7 @@ endi
label1:
# insert nchar data with space and a pair of double quotes
-sql insert into $tb values (now, "NCHAR" )
+sql insert into $tb values (now+6s, "NCHAR" )
sql select * from $tb order by ts desc
print expected: N CHAR
print returned: $data01
@@ -141,7 +141,7 @@ else
endi
label2:
-sql insert into $tb values (now, "涛思" )
+sql insert into $tb values (now+7s, "涛思" )
sql select * from $tb order by ts desc
print expected: 涛思
print returned: $data01
@@ -150,9 +150,9 @@ if $data01 != 涛思 then
endi
# insert nchar data with a single quote and a double quote
-#sql insert into $tb values (now, 'NCHAR")
-sql_error insert into $tb values (now, 'NCHAR")
-sql_error insert into $tb values (now, 'NCHAR])
+#sql insert into $tb values (now+8s, 'NCHAR")
+sql_error insert into $tb values (now+9s, 'NCHAR")
+sql_error insert into $tb values (now+10s, 'NCHAR])
sql drop table $tb
sql drop table $mt
diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim
index 5f006d0eb7..2b89946ef8 100644
--- a/tests/script/general/parser/projection_limit_offset.sim
+++ b/tests/script/general/parser/projection_limit_offset.sim
@@ -80,6 +80,7 @@ print $rows
sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 0;
if $rows != 4008 then
+ print expect 4008, actual:$rows
return -1
endi
diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt
index 8bce1db6c6..e2ebd9af63 100644
--- a/tests/script/jenkins/basic.txt
+++ b/tests/script/jenkins/basic.txt
@@ -334,9 +334,10 @@ cd ../../../debug; make
./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim
./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
-./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
-./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
-./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
+#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
+#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
+#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
+#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim
./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim
diff --git a/tests/script/loop.sh b/tests/script/loop.sh
index adafe2ed60..b435eef123 100755
--- a/tests/script/loop.sh
+++ b/tests/script/loop.sh
@@ -11,8 +11,9 @@ set -e
CMD_NAME=
LOOP_TIMES=5
+SLEEP_TIME=0
-while getopts "f:t:" arg
+while getopts "f:t:s:" arg
do
case $arg in
f)
@@ -21,6 +22,9 @@ do
t)
LOOP_TIMES=$OPTARG
;;
+ s)
+ SLEEP_TIME=$OPTARG
+ ;;
?)
echo "unknow argument"
;;
@@ -29,11 +33,17 @@ done
echo LOOP_TIMES ${LOOP_TIMES}
echo CMD_NAME ${CMD_NAME}
+echo SLEEP_TIME ${SLEEP_TIME}
+
+GREEN='\033[1;32m'
+GREEN_DARK='\033[0;32m'
+GREEN_UNDERLINE='\033[4;32m'
+NC='\033[0m'
for ((i=0; i<$LOOP_TIMES; i++ ))
do
- echo loop $i
- echo cmd $CMD_NAME
+ echo -e $GREEN loop $i $NC
+ echo -e $GREEN cmd $CMD_NAME $NC
$CMD_NAME
- sleep 2
+ sleep ${SLEEP_TIME}
done
diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh
index 5837cf5a1a..ee7093a2ca 100755
--- a/tests/script/sh/deploy.sh
+++ b/tests/script/sh/deploy.sh
@@ -110,18 +110,23 @@ echo "second ${HOSTNAME}:7200" >> $TAOS_CFG
echo "serverPort ${NODE}" >> $TAOS_CFG
echo "dataDir $DATA_DIR" >> $TAOS_CFG
echo "logDir $LOG_DIR" >> $TAOS_CFG
-echo "dDebugFlag 135" >> $TAOS_CFG
echo "mDebugFlag 135" >> $TAOS_CFG
echo "sdbDebugFlag 135" >> $TAOS_CFG
+echo "dDebugFlag 135" >> $TAOS_CFG
+echo "vDebugFlag 143" >> $TAOS_CFG
+echo "cDebugFlag 135" >> $TAOS_CFG
+echo "jnidebugFlag 135" >> $TAOS_CFG
+echo "odbcdebugFlag 135" >> $TAOS_CFG
+echo "httpDebugFlag 135" >> $TAOS_CFG
+echo "monitorDebugFlag 131" >> $TAOS_CFG
+echo "mqttDebugFlag 131" >> $TAOS_CFG
+echo "qdebugFlag 135" >> $TAOS_CFG
echo "rpcDebugFlag 135" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "cDebugFlag 135" >> $TAOS_CFG
-echo "httpDebugFlag 135" >> $TAOS_CFG
-echo "monitorDebugFlag 131" >> $TAOS_CFG
echo "udebugFlag 135" >> $TAOS_CFG
-echo "jnidebugFlag 135" >> $TAOS_CFG
echo "sdebugFlag 135" >> $TAOS_CFG
-echo "qdebugFlag 135" >> $TAOS_CFG
+echo "wdebugFlag 135" >> $TAOS_CFG
echo "monitor 0" >> $TAOS_CFG
echo "monitorInterval 1" >> $TAOS_CFG
echo "http 0" >> $TAOS_CFG
diff --git a/tests/script/test.sh b/tests/script/test.sh
index a6d57e548a..cba0a0fe4b 100755
--- a/tests/script/test.sh
+++ b/tests/script/test.sh
@@ -112,7 +112,7 @@ echo "numOfLogLines 100000000" >> $TAOS_CFG
echo "dDebugFlag 135" >> $TAOS_CFG
echo "mDebugFlag 135" >> $TAOS_CFG
echo "sdbDebugFlag 135" >> $TAOS_CFG
-echo "rpcDebugFlag 151" >> $TAOS_CFG
+echo "rpcDebugFlag 143" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "cDebugFlag 135" >> $TAOS_CFG
echo "httpDebugFlag 135" >> $TAOS_CFG
diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
index 77dbdb0c4c..13c3517e24 100644
--- a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
+++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
@@ -149,7 +149,7 @@ if $dnode3Vtatus != master then
goto wait_dnode4_vgroup_offline
endi
-system echo "haha, nothing......" > ../../../sim/dnode4/data/vnode/vnode2/tsdb/data/f1643.data
+system echo "haha, nothing......" > ../../../sim/dnode4/data/vnode/vnode2/tsdb/data/v2f1643.data
#system rm -rf ../../../sim/dnode4/data/vnode/*
sleep 1000
diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
index 50d9bbbecb..0b4e385785 100644
--- a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
+++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
@@ -174,7 +174,7 @@ if $system_content != 3 then
return -1
endi
-system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/f1643.data
+system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v2f1643.data
print ============== step3-1: insert some news data for let version changed
sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x )
diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
index a526192b15..c464d4023f 100644
--- a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
+++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
@@ -47,7 +47,7 @@ system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect
-print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data
+print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data to can fall disc
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
#system sh/exec.sh -n dnode4 -s start
@@ -56,18 +56,18 @@ sql create dnode $hostname3
#sql create dnode $hostname4
sleep 3000
-$totalTableNum = 10
+$totalTableNum = 4
$sleepTimer = 3000
$db = db
-sql create database $db replica 2 maxTables $totalTableNum
+sql create database $db cache 1 replica 2 maxTables $totalTableNum
sql use $db
# create table , insert data
$stb = stb
sql create table $stb (ts timestamp, c1 int) tags(t1 int)
-$rowNum = 100
-$tblNum = $totalTableNum
+$rowNum = 128 * 1024
+$tblNum = 1
$totalRows = 0
$tsStart = 1420041600000
@@ -81,6 +81,7 @@ while $i < $tblNum
$ts = $tsStart + $x
sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x )
$x = $x + 60
+ $tsLast = $ts + 60
endw
$totalRows = $totalRows + $x
print info: inserted $x rows into $tb and totalRows: $totalRows
@@ -95,7 +96,7 @@ if $data00 != $totalRows then
endi
print ============== step3: corrupt vnode data file in dnode3, not stop dnode3
-system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/f1643.data
+system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v2f1643.data
sleep 1000
print ============== step4: insert new data, and run query
@@ -108,6 +109,43 @@ if $data00 != $totalRows then
return -1
endi
+print show dnodes
+sql show dnodes
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
+
+print show vgroups
+sql show vgroups
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3
+
+
+$tsStart = $tsLast + 1
+$i = 0
+while $i < $tblNum
+ $tb = tb . $i
+ #sql create table $tb using $stb tags( $i )
+
+ $x = 0
+ while $x < $rowNum
+ $ts = $tsStart + $x
+ sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x )
+ $x = $x + 60
+ $tsLast = $ts + 60
+ endw
+ $totalRows = $totalRows + $x
+ print info: inserted $x rows into $tb and totalRows: $totalRows
+ $i = $i + 1
+endw
+
+sql select count(*) from $stb
+print data00 $data00
+if $data00 != $totalRows then
+ return -1
+endi
+
print ============== step5: stop dnode2, and check if dnode3 sync ok
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer
@@ -242,7 +280,8 @@ if $dnode3Vtatus != offline then
goto wait_dnode3_vgroup_offline
endi
-print ============== step7: restart dnode3, and run query
+print ============== step7: restart dnode2/dnode3, and run query
+system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
sleep $sleepTimer
$loopCnt = 0
@@ -288,7 +327,7 @@ print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $dat
$dnode2Vtatus = $data7_2
$dnode3Vtatus = $data4_2
-if $dnode2Vtatus != offline then
+if $dnode2Vtatus != slave then
sleep 2000
goto wait_dnode3_vgroup_master_1
endi
diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim
new file mode 100644
index 0000000000..f2aa000170
--- /dev/null
+++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim
@@ -0,0 +1,315 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/deploy.sh -n dnode2 -i 2
+system sh/deploy.sh -n dnode3 -i 3
+system sh/deploy.sh -n dnode4 -i 4
+
+system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
+system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
+system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
+system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
+
+system sh/cfg.sh -n dnode1 -c walLevel -v 2
+system sh/cfg.sh -n dnode2 -c walLevel -v 2
+system sh/cfg.sh -n dnode3 -c walLevel -v 2
+system sh/cfg.sh -n dnode4 -c walLevel -v 2
+
+system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
+system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
+system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
+system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
+
+system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
+system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
+system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
+system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
+
+system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
+system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
+system sh/cfg.sh -n dnode3 -c alternativeRole -v 2
+system sh/cfg.sh -n dnode4 -c alternativeRole -v 2
+
+system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
+system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
+system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
+system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
+
+system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
+system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
+system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
+system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
+
+print ============== step0: start tarbitrator
+system sh/exec_tarbitrator.sh -s start
+
+print ============== step1: start dnode1, only deploy mnode
+system sh/exec.sh -n dnode1 -s start
+sleep 3000
+sql connect
+
+print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data
+system sh/exec.sh -n dnode2 -s start
+system sh/exec.sh -n dnode3 -s start
+#system sh/exec.sh -n dnode4 -s start
+sql create dnode $hostname2
+sql create dnode $hostname3
+#sql create dnode $hostname4
+sleep 3000
+
+$totalTableNum = 10
+$sleepTimer = 3000
+
+$db = db
+sql create database $db replica 2 maxTables $totalTableNum
+sql use $db
+
+# create table , insert data
+$stb = stb
+sql create table $stb (ts timestamp, c1 int) tags(t1 int)
+$rowNum = 100
+$tblNum = $totalTableNum
+$totalRows = 0
+$tsStart = 1420041600000
+
+$i = 0
+while $i < $tblNum
+ $tb = tb . $i
+ sql create table $tb using $stb tags( $i )
+
+ $x = 0
+ while $x < $rowNum
+ $ts = $tsStart + $x
+ sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x ) ( $ts + 10a , $x ) ( $ts + 11a , $x ) ( $ts + 12a , $x ) ( $ts + 13a , $x ) ( $ts + 14a , $x ) ( $ts + 15a , $x ) ( $ts + 16a , $x ) ( $ts + 17a , $x ) ( $ts + 18a , $x ) ( $ts + 19a , $x ) ( $ts + 20a , $x ) ( $ts + 21a , $x ) ( $ts + 22a , $x ) ( $ts + 23a , $x ) ( $ts + 24a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 25a , $x ) ( $ts + 26a , $x ) ( $ts + 27a , $x ) ( $ts + 28a , $x ) ( $ts + 29a , $x ) ( $ts + 30a , $x ) ( $ts + 31a , $x ) ( $ts + 32a , $x ) ( $ts + 33a , $x ) ( $ts + 34a , $x ) ( $ts + 35a , $x ) ( $ts + 36a , $x ) ( $ts + 37a , $x ) ( $ts + 38a , $x ) ( $ts + 39a , $x ) ( $ts + 40a , $x ) ( $ts + 41a , $x ) ( $ts + 42a , $x ) ( $ts + 43a , $x ) ( $ts + 44a , $x ) ( $ts + 45a , $x ) ( $ts + 46a , $x ) ( $ts + 47a , $x ) ( $ts + 48a , $x ) ( $ts + 49a , $x ) ( $ts + 50a , $x ) ( $ts + 51a , $x ) ( $ts + 52a , $x ) ( $ts + 53a , $x ) ( $ts + 54a , $x ) ( $ts + 55a , $x ) ( $ts + 56a , $x ) ( $ts + 57a , $x ) ( $ts + 58a , $x ) ( $ts + 59a , $x )
+ $x = $x + 60
+ endw
+ $totalRows = $totalRows + $x
+ print info: inserted $x rows into $tb and totalRows: $totalRows
+ $i = $i + 1
+endw
+
+sql select count(*) from $stb
+sleep 1000
+print data00 $data00
+if $data00 != $totalRows then
+ return -1
+endi
+
+print ============== step3: corrupt vnode data file in dnode3, not stop dnode3
+system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v2f1643.data
+sleep 1000
+
+print ============== step4: insert new data, and run query
+sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x )
+$totalRows = $totalRows + 3
+
+sql select count(*) from $stb
+print data00 $data00
+if $data00 != $totalRows then
+ return -1
+endi
+
+print ============== step5: stop dnode2, and check if dnode3 sync ok
+system sh/exec.sh -n dnode2 -s stop -x SIGINT
+sleep $sleepTimer
+
+$loopCnt = 0
+wait_dnode2_offline_0:
+$loopCnt = $loopCnt + 1
+if $loopCnt == 10 then
+ return -1
+endi
+
+sql show dnodes
+if $rows != 3 then
+ sleep 2000
+ goto wait_dnode2_offline_0
+endi
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
+#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
+#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5
+#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6
+#$dnode1Status = $data4_1
+$dnode2Status = $data4_2
+$dnode3Status = $data4_3
+$dnode4Status = $data4_4
+#$dnode5Status = $data4_5
+
+if $dnode2Status != offline then
+ sleep 2000
+ goto wait_dnode2_offline_0
+endi
+
+$loopCnt = 0
+wait_dnode3_vgroup_master:
+$loopCnt = $loopCnt + 1
+if $loopCnt == 10 then
+ return -1
+endi
+
+sql show vgroups
+if $rows != 1 then
+ sleep 2000
+ goto wait_dnode3_vgroup_master
+endi
+print show vgroups:
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3
+$dnode2Vtatus = $data7_2
+$dnode3Vtatus = $data4_2
+
+if $dnode2Vtatus != offline then
+ sleep 2000
+ goto wait_dnode3_vgroup_master
+endi
+if $dnode3Vtatus != master then
+ sleep 2000
+ goto wait_dnode3_vgroup_master
+endi
+
+sql select count(*) from $stb
+print data00 $data00
+if $data00 != $totalRows then
+ return -1
+endi
+
+print ============== step6: stop dnode3 for falling disc
+system sh/exec.sh -n dnode3 -s stop -x SIGINT
+sleep $sleepTimer
+
+$loopCnt = 0
+wait_dnode3_offline_0:
+$loopCnt = $loopCnt + 1
+if $loopCnt == 10 then
+ return -1
+endi
+
+sql show dnodes
+if $rows != 3 then
+ sleep 2000
+ goto wait_dnode3_offline_0
+endi
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
+#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
+#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5
+#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6
+#$dnode1Status = $data4_1
+$dnode2Status = $data4_2
+$dnode3Status = $data4_3
+$dnode4Status = $data4_4
+#$dnode5Status = $data4_5
+
+if $dnode2Status != offline then
+ sleep 2000
+ goto wait_dnode3_offline_0
+endi
+
+if $dnode3Status != offline then
+ sleep 2000
+ goto wait_dnode3_offline_0
+endi
+
+
+$loopCnt = 0
+wait_dnode3_vgroup_offline:
+$loopCnt = $loopCnt + 1
+if $loopCnt == 10 then
+ return -1
+endi
+
+sql show vgroups
+if $rows != 1 then
+ sleep 2000
+ goto wait_dnode3_vgroup_offline
+endi
+print show vgroups:
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3
+$dnode2Vtatus = $data7_2
+$dnode3Vtatus = $data4_2
+
+if $dnode2Vtatus != offline then
+ sleep 2000
+ goto wait_dnode3_vgroup_offline
+endi
+if $dnode3Vtatus != offline then
+ sleep 2000
+ goto wait_dnode3_vgroup_offline
+endi
+
+print ============== step7: restart dnode2/dnode3, and run query
+system sh/exec.sh -n dnode2 -s start
+system sh/exec.sh -n dnode3 -s start
+sleep $sleepTimer
+$loopCnt = 0
+wait_dnode3_reready:
+$loopCnt = $loopCnt + 1
+if $loopCnt == 10 then
+ return -1
+endi
+
+sql show dnodes
+if $rows != 3 then
+ sleep 2000
+ goto wait_dnode3_reready
+endi
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
+$dnode1Status = $data4_1
+$dnode2Status = $data4_2
+$dnode3Status = $data4_3
+
+if $dnode3Status != ready then
+ sleep 2000
+ goto wait_dnode3_reready
+endi
+
+$loopCnt = 0
+wait_dnode3_vgroup_master_1:
+$loopCnt = $loopCnt + 1
+if $loopCnt == 10 then
+ return -1
+endi
+
+sql show vgroups
+if $rows != 1 then
+ sleep 2000
+ goto wait_dnode3_vgroup_master_1
+endi
+print show vgroups:
+print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1
+print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2
+print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3
+$dnode2Vtatus = $data7_2
+$dnode3Vtatus = $data4_2
+
+if $dnode2Vtatus != slave then
+ sleep 2000
+ goto wait_dnode3_vgroup_master_1
+endi
+if $dnode3Vtatus != master then
+ sleep 2000
+ goto wait_dnode3_vgroup_master_1
+endi
+
+sql select count(*) from $stb
+print data00 $data00
+if $data00 != $totalRows then
+ return -1
+endi
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim
index e092eec205..f5ceced668 100644
--- a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim
+++ b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim
@@ -370,21 +370,20 @@ sql alter table stb drop column c1
sql alter table stb add tag t2 int
sql alter table stb add tag t3 int
-sql alter table stb add tag t4 int
sql_error alter table stb drop tag t1
$ts = $tsEnd + 10000
-sql insert into tb2 values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
-sql insert into tb3 values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
-sql insert into tb4 values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
-sql insert into tb5 values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
+sql insert into tb2 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
+sql insert into tb3 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
+sql insert into tb4 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
+sql insert into tb5 values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
$ts = $tsStart
-sql insert into tb14 using stb tags(14) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
-sql insert into tb15 using stb tags(15) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
-sql insert into tb16 using stb tags(16) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
-sql insert into tb17 using stb tags(17) values ( $ts + 0a , $x ) ( $ts + 1a , $x ) ( $ts + 2a , $x ) ( $ts + 3a , $x ) ( $ts + 4a , $x ) ( $ts + 5a , $x ) ( $ts + 6a , $x ) ( $ts + 7a , $x ) ( $ts + 8a , $x ) ( $ts + 9a , $x )
+sql insert into tb14 using stb tags(14, 14, 14) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
+sql insert into tb15 using stb tags(15, 15, 15) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
+sql insert into tb16 using stb tags(16, 16, 16) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
+sql insert into tb17 using stb tags(17, 17, 17) values ( $ts + 0a , $x , $x , $x ) ( $ts + 1a , $x , $x , $x ) ( $ts + 2a , $x , $x , $x ) ( $ts + 3a , $x , $x , $x ) ( $ts + 4a , $x , $x , $x ) ( $ts + 5a , $x , $x , $x ) ( $ts + 6a , $x , $x , $x ) ( $ts + 7a , $x , $x , $x ) ( $ts + 8a , $x , $x , $x ) ( $ts + 9a , $x , $x , $x )
$totalRows = $totalRows + 80
sql select count(*) from $stb
diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt
index d40db5ee40..4717a4f769 100644
--- a/tests/test/c/CMakeLists.txt
+++ b/tests/test/c/CMakeLists.txt
@@ -7,15 +7,21 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
- add_executable(insertPerTable insertPerTable.c)
- target_link_libraries(insertPerTable taos_static pthread)
+ #add_executable(insertPerTable insertPerTable.c)
+ #target_link_libraries(insertPerTable taos_static pthread)
- add_executable(insertPerRow insertPerRow.c)
- target_link_libraries(insertPerRow taos_static pthread)
+ #add_executable(insertPerRow insertPerRow.c)
+ #target_link_libraries(insertPerRow taos_static pthread)
- add_executable(importOneRow importOneRow.c)
- target_link_libraries(importOneRow taos_static pthread)
+ #add_executable(importOneRow importOneRow.c)
+ #target_link_libraries(importOneRow taos_static pthread)
- add_executable(importPerTable importPerTable.c)
- target_link_libraries(importPerTable taos_static pthread)
+ #add_executable(importPerTable importPerTable.c)
+ #target_link_libraries(importPerTable taos_static pthread)
+
+ #add_executable(hashPerformance hashPerformance.c)
+ #target_link_libraries(hashPerformance taos_static tutil common pthread)
+
+ add_executable(createTablePerformance createTablePerformance.c)
+ target_link_libraries(createTablePerformance taos_static tutil common pthread)
ENDIF()
diff --git a/tests/test/c/createTablePerformance.c b/tests/test/c/createTablePerformance.c
new file mode 100644
index 0000000000..4ab6f98423
--- /dev/null
+++ b/tests/test/c/createTablePerformance.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * 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 .
+ */
+
+#define _DEFAULT_SOURCE
+#include "os.h"
+#include "taos.h"
+#include "tulog.h"
+#include "ttime.h"
+#include "tutil.h"
+#include "tglobal.h"
+#include "hash.h"
+
+#define MAX_RANDOM_POINTS 20000
+#define GREEN "\033[1;32m"
+#define NC "\033[0m"
+
+char dbName[32] = "db";
+char stableName[64] = "st";
+int32_t numOfThreads = 30;
+int32_t numOfTables = 100000;
+int32_t maxTables = 5000;
+int32_t numOfColumns = 2;
+
+typedef struct {
+ int32_t tableBeginIndex;
+ int32_t tableEndIndex;
+ int32_t threadIndex;
+ char dbName[32];
+ char stableName[64];
+ float createTableSpeed;
+ pthread_t thread;
+} SThreadInfo;
+
+void shellParseArgument(int argc, char *argv[]);
+void *threadFunc(void *param);
+void createDbAndSTable();
+
+int main(int argc, char *argv[]) {
+ shellParseArgument(argc, argv);
+ taos_init();
+ createDbAndSTable();
+
+ pPrint("%d threads are spawned to create table", numOfThreads);
+
+ pthread_attr_t thattr;
+ pthread_attr_init(&thattr);
+ pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
+ SThreadInfo *pInfo = (SThreadInfo *)calloc(numOfThreads, sizeof(SThreadInfo));
+
+ int32_t numOfTablesPerThread = numOfTables / numOfThreads;
+ numOfTables = numOfTablesPerThread * numOfThreads;
+ for (int i = 0; i < numOfThreads; ++i) {
+ pInfo[i].tableBeginIndex = i * numOfTablesPerThread;
+ pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread;
+ pInfo[i].threadIndex = i;
+ strcpy(pInfo[i].dbName, dbName);
+ strcpy(pInfo[i].stableName, stableName);
+ pthread_create(&(pInfo[i].thread), &thattr, threadFunc, (void *)(pInfo + i));
+ }
+
+ taosMsleep(300);
+ for (int i = 0; i < numOfThreads; i++) {
+ pthread_join(pInfo[i].thread, NULL);
+ }
+
+ float createTableSpeed = 0;
+ for (int i = 0; i < numOfThreads; ++i) {
+ createTableSpeed += pInfo[i].createTableSpeed;
+ }
+
+ pPrint("%s total speed:%.1f tables/second, threads:%d %s", GREEN, createTableSpeed, numOfThreads, NC);
+
+ pthread_attr_destroy(&thattr);
+ free(pInfo);
+}
+
+void createDbAndSTable() {
+ pPrint("start to create db and stable");
+ char qstr[64000];
+
+ TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
+ if (con == NULL) {
+ pError("failed to connect to DB, reason:%s", taos_errstr(con));
+ exit(1);
+ }
+
+ sprintf(qstr, "create database if not exists %s maxtables %d", dbName, maxTables);
+ TAOS_RES *pSql = taos_query(con, qstr);
+ int32_t code = taos_errno(pSql);
+ if (code != 0) {
+ pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(con), taos_errstr(con));
+ exit(0);
+ }
+ taos_free_result(pSql);
+
+ sprintf(qstr, "use %s", dbName);
+ pSql = taos_query(con, qstr);
+ code = taos_errno(pSql);
+ if (code != 0) {
+ pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con));
+ exit(0);
+ }
+ taos_free_result(pSql);
+
+ int len = sprintf(qstr, "create table if not exists %s(ts timestamp", stableName);
+ for (int32_t f = 0; f < numOfColumns - 1; ++f) {
+ len += sprintf(qstr + len, ", f%d double", f);
+ }
+ sprintf(qstr + len, ") tags(t int)");
+
+ pSql = taos_query(con, qstr);
+ code = taos_errno(pSql);
+ if (code != 0) {
+ pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con));
+ exit(0);
+ }
+ taos_free_result(pSql);
+
+ taos_close(con);
+}
+
+void *threadFunc(void *param) {
+ SThreadInfo *pInfo = (SThreadInfo *)param;
+ char qstr[65000];
+ int code;
+
+ TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
+ if (con == NULL) {
+ pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con));
+ exit(1);
+ }
+
+ sprintf(qstr, "use %s", pInfo->dbName);
+ TAOS_RES *pSql = taos_query(con, qstr);
+ taos_free_result(pSql);
+
+ int64_t startMs = taosGetTimestampMs();
+
+ for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) {
+ sprintf(qstr, "create table if not exists %s%d using %s tags(%d)", stableName, t, stableName, t);
+ TAOS_RES *pSql = taos_query(con, qstr);
+ code = taos_errno(pSql);
+ if (code != 0) {
+ pError("failed to create table %s%d, reason:%s", stableName, t, taos_errstr(con));
+ }
+ taos_free_result(pSql);
+ }
+
+ float createTableSpeed = 0;
+ for (int i = 0; i < numOfThreads; ++i) {
+ createTableSpeed += pInfo[i].createTableSpeed;
+ }
+
+ int64_t endMs = taosGetTimestampMs();
+ int32_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex;
+ float seconds = (endMs - startMs) / 1000.0;
+ float speed = totalTables / seconds;
+ pInfo->createTableSpeed = speed;
+
+ pPrint("thread:%d, time:%.2f sec, speed:%.1f tables/second, ", pInfo->threadIndex, seconds, speed);
+ taos_close(con);
+
+ return 0;
+}
+
+void printHelp() {
+ char indent[10] = " ";
+ printf("Used to test the performance while create table\n");
+
+ printf("%s%s\n", indent, "-c");
+ printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir);
+ printf("%s%s\n", indent, "-d");
+ printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName);
+ printf("%s%s\n", indent, "-s");
+ printf("%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName);
+ printf("%s%s\n", indent, "-t");
+ printf("%s%s%s%d\n", indent, indent, "numOfThreads, default is ", numOfThreads);
+ printf("%s%s\n", indent, "-n");
+ printf("%s%s%s%d\n", indent, indent, "numOfTables, default is ", numOfTables);
+ printf("%s%s\n", indent, "-columns");
+ printf("%s%s%s%d\n", indent, indent, "numOfColumns, default is ", numOfColumns);
+ printf("%s%s\n", indent, "-tables");
+ printf("%s%s%s%d\n", indent, indent, "Database parameters tables, default is ", maxTables);
+
+ exit(EXIT_SUCCESS);
+}
+
+void shellParseArgument(int argc, char *argv[]) {
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
+ printHelp();
+ exit(0);
+ } else if (strcmp(argv[i], "-d") == 0) {
+ strcpy(dbName, argv[++i]);
+ } else if (strcmp(argv[i], "-c") == 0) {
+ strcpy(configDir, argv[++i]);
+ } else if (strcmp(argv[i], "-s") == 0) {
+ strcpy(stableName, argv[++i]);
+ } else if (strcmp(argv[i], "-t") == 0) {
+ numOfThreads = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-n") == 0) {
+ numOfTables = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-tables") == 0) {
+ maxTables = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-columns") == 0) {
+ numOfColumns = atoi(argv[++i]);
+ } else {
+ }
+ }
+
+ pPrint("%s dbName:%s %s", GREEN, dbName, NC);
+ pPrint("%s stableName:%s %s", GREEN, stableName, NC);
+ pPrint("%s configDir:%s %s", GREEN, configDir, NC);
+ pPrint("%s numOfTables:%d %s", GREEN, numOfTables, NC);
+ pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC);
+ pPrint("%s numOfColumns:%d %s", GREEN, numOfColumns, NC);
+ pPrint("%s dbPara maxTables:%d %s", GREEN, maxTables, NC);
+
+ pPrint("%s start create table performace test %s", GREEN, NC);
+}
diff --git a/tests/test/c/hashPerformance.c b/tests/test/c/hashPerformance.c
new file mode 100644
index 0000000000..fa3612d6e8
--- /dev/null
+++ b/tests/test/c/hashPerformance.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * 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 .
+ */
+
+#define _DEFAULT_SOURCE
+#include "os.h"
+#include "taos.h"
+#include "tulog.h"
+#include "ttime.h"
+#include "tutil.h"
+#include "hash.h"
+
+#define MAX_RANDOM_POINTS 20000
+#define GREEN "\033[1;32m"
+#define NC "\033[0m"
+
+int32_t capacity = 100000;
+int32_t q1Times = 1;
+int32_t q2Times = 1;
+int32_t keyNum = 100000;
+int32_t printInterval = 10000;
+
+typedef struct HashTestRow {
+ int32_t size;
+ void * ptr;
+} HashTestRow;
+
+void shellParseArgument(int argc, char *argv[]);
+
+void testHashPerformance() {
+ int64_t initialMs = taosGetTimestampMs();
+ _hash_fn_t hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
+ void * hashHandle = taosHashInit(capacity, hashFp, true);
+
+ int64_t startMs = taosGetTimestampMs();
+ float seconds = (startMs - initialMs) / 1000.0;
+ pPrint("initial time %.2f sec", seconds);
+
+ for (int32_t t = 1; t <= keyNum; ++t) {
+ HashTestRow row = {0};
+ char key[100] = {0};
+ int32_t keySize = sprintf(key, "0.db.st%d", t);
+
+ for (int32_t q = 0; q < q1Times; q++) {
+ taosHashGet(hashHandle, &key, keySize);
+ }
+
+ taosHashPut(hashHandle, key, keySize, &row, sizeof(HashTestRow));
+
+ for (int32_t q = 0; q < q2Times; q++) {
+ taosHashGet(hashHandle, &key, keySize);
+ }
+
+ if (t % printInterval == 0) {
+ int64_t endMs = taosGetTimestampMs();
+ int64_t hashSize = taosHashGetSize(hashHandle);
+ float seconds = (endMs - startMs) / 1000.0;
+ float speed = printInterval / seconds;
+ pPrint("time:%.2f sec, speed:%.1f rows/second, hashSize:%ld", seconds, speed, hashSize);
+ startMs = endMs;
+ }
+ }
+
+ int64_t endMs = taosGetTimestampMs();
+ int64_t hashSize = taosHashGetSize(hashHandle);
+ seconds = (endMs - initialMs) / 1000.0;
+ float speed = hashSize / seconds;
+
+ pPrint("total time:%.2f sec, avg speed:%.1f rows/second, hashSize:%ld", seconds, speed, hashSize);
+ taosHashCleanup(hashHandle);
+}
+
+int main(int argc, char *argv[]) {
+ shellParseArgument(argc, argv);
+ testHashPerformance();
+}
+
+void printHelp() {
+ char indent[10] = " ";
+ printf("Used to test the performance of cache\n");
+
+ printf("%s%s\n", indent, "-k");
+ printf("%s%s%s%d\n", indent, indent, "key num, default is ", keyNum);
+ printf("%s%s\n", indent, "-p");
+ printf("%s%s%s%d\n", indent, indent, "print interval while put into hash, default is ", printInterval);
+ printf("%s%s\n", indent, "-c");
+ printf("%s%s%s%d\n", indent, indent, "the initial capacity of hash ", capacity);
+ printf("%s%s\n", indent, "-q1");
+ printf("%s%s%s%d\n", indent, indent, "query times before put into hash", q1Times);
+ printf("%s%s\n", indent, "-q2");
+ printf("%s%s%s%d\n", indent, indent, "query times after put into hash", q2Times);
+
+ exit(EXIT_SUCCESS);
+}
+
+void shellParseArgument(int argc, char *argv[]) {
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
+ printHelp();
+ exit(0);
+ } else if (strcmp(argv[i], "-k") == 0) {
+ keyNum = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-p") == 0) {
+ printInterval = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-c") == 0) {
+ capacity = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-q1") == 0) {
+ q1Times = atoi(argv[++i]);
+ } else if (strcmp(argv[i], "-q2") == 0) {
+ q2Times = atoi(argv[++i]);
+ } else {
+ }
+ }
+
+ pPrint("%s capacity:%d %s", GREEN, capacity, NC);
+ pPrint("%s printInterval:%d %s", GREEN, printInterval, NC);
+ pPrint("%s q1Times:%d %s", GREEN, q1Times, NC);
+ pPrint("%s q2Times:%d %s", GREEN, q2Times, NC);
+ pPrint("%s keyNum:%d %s", GREEN, keyNum, NC);
+}