From 23848d45b03f880b16564f2be420fd87c9355f9d Mon Sep 17 00:00:00 2001 From: wpan Date: Mon, 2 Aug 2021 10:34:20 +0800 Subject: [PATCH 1/5] add connection info to cache when taosd reboot while taos remains open --- src/mnode/src/mnodeShow.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index 5fe22826b7..570f5c344b 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -253,11 +253,15 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) { int32_t connId = htonl(pHBMsg->connId); SConnObj *pConn = mnodeAccquireConn(connId, connInfo.user, connInfo.clientIp, connInfo.clientPort); + if (pConn == NULL) { + pHBMsg->pid = htonl(pHBMsg->pid); + pConn = mnodeCreateConn(connInfo.user, connInfo.clientIp, connInfo.clientPort, pHBMsg->pid, pHBMsg->appName); + } if (pConn == NULL) { // do not close existing links, otherwise // mError("failed to create connId, close connect"); - // pRsp->killConnection = 1; + // pRsp->killConnection = 1; } else { pRsp->connId = htonl(pConn->connId); mnodeSaveQueryStreamList(pConn, pHBMsg); From f73506be5645dd7a68515f6df513eb2416813c23 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 2 Aug 2021 15:32:18 +0800 Subject: [PATCH 2/5] [td-5654]: fix the bug caused by unexpected error code. --- src/client/src/tscParseInsert.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 40092c5860..114b74ae03 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -582,9 +582,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SSq sToken = tStrGetToken(*str, &index, false); *str += index; if (sToken.n == 0 || sToken.type != TK_RP) { - tscSQLSyntaxErrMsg(pCmd->payload, ") expected", *str); - code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; - return -1; + return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", *str); } (*numOfRows)++; From 2e9e8434b4f6031cc25b6114b9ca86fd6ff188a3 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 2 Aug 2021 15:44:28 +0800 Subject: [PATCH 3/5] [td-5707]: fix bug in interp query while only one row exists in a table. --- src/tsdb/src/tsdbRead.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 0892182f03..be686fcffd 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -2373,7 +2373,7 @@ static void destroyHelper(void* param) { free(param); } -static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) { +static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) { if (pQueryHandle->checkFiles) { // check if the query range overlaps with the file data block bool exists = true; @@ -2385,6 +2385,7 @@ static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) { } if (exists) { + tsdbRetrieveDataBlock((TsdbQueryHandleT) pQueryHandle, NULL); if (pQueryHandle->currentLoadExternalRows && pQueryHandle->window.skey == pQueryHandle->window.ekey) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, 0); assert(*(int64_t*)pColInfo->pData == pQueryHandle->window.skey); From 98472086d112f9371040b2668dfc8d25b6f8eadf Mon Sep 17 00:00:00 2001 From: Zhiyu Yang <69311263+zyyang-taosdata@users.noreply.github.com> Date: Mon, 2 Aug 2021 17:39:31 +0800 Subject: [PATCH 4/5] [TD-5614]: handle client and server time not synchronized (#7109) --- .../jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 051eca7e10..4fdbb308c5 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -80,7 +80,8 @@ public class TSDBJNIConnector { this.taos = this.connectImp(host, port, dbName, user, password); if (this.taos == TSDBConstants.JNI_NULL_POINTER) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + String errMsg = this.getErrMsg(0); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, errMsg); } // invoke connectImp only here taosInfo.conn_open_increment(); From f5a9b37c28ef92afa3c42e68d7c90939f28b64d6 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 3 Aug 2021 14:14:52 +0800 Subject: [PATCH 5/5] [TD-5702]: taosdemo remove memory operation. (#7116) * [td-5654]: fix the bug caused by unexpected error code. * [td-5707]: fix bug in interp query while only one row exists in a table. * [TD-5702]: taosdemo remove memory operation. * [TD-5702]: taosdemo remove memory operation. * add remainderBufLen to check row data generation. * row data generation with remainder buffer length checking. Co-authored-by: Haojun Liao Co-authored-by: Haojun Liao Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 773506c5ae..f9fe66f466 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -5094,7 +5094,9 @@ static int getRowDataFromSample( static int64_t generateStbRowData( SSuperTable* stbInfo, - char* recBuf, int64_t timestamp) + char* recBuf, + int64_t remainderBufLen, + int64_t timestamp) { int64_t dataLen = 0; char *pstr = recBuf; @@ -5122,6 +5124,7 @@ static int64_t generateStbRowData( rand_string(buf, stbInfo->columns[i].dataLen); dataLen += snprintf(pstr + dataLen, maxLen - dataLen, "\'%s\',", buf); tmfree(buf); + } else { char *tmp; @@ -5178,6 +5181,9 @@ static int64_t generateStbRowData( tstrncpy(pstr + dataLen, ",", 2); dataLen += 1; } + + if (dataLen > remainderBufLen) + return 0; } dataLen -= 1; @@ -5384,7 +5390,7 @@ static int32_t generateDataTailWithoutStb( int32_t k = 0; for (k = 0; k < batch;) { - char data[MAX_DATA_SIZE]; + char *data = pstr; memset(data, 0, MAX_DATA_SIZE); int64_t retLen = 0; @@ -5408,7 +5414,7 @@ static int32_t generateDataTailWithoutStb( if (len > remainderBufLen) break; - pstr += sprintf(pstr, "%s", data); + pstr += retLen; k++; len += retLen; remainderBufLen -= retLen; @@ -5464,14 +5470,14 @@ static int32_t generateStbDataTail( int32_t k; for (k = 0; k < batch;) { - char data[MAX_DATA_SIZE]; - memset(data, 0, MAX_DATA_SIZE); + char *data = pstr; int64_t lenOfRow = 0; if (tsRand) { if (superTblInfo->disorderRatio > 0) { lenOfRow = generateStbRowData(superTblInfo, data, + remainderBufLen, startTime + getTSRandTail( superTblInfo->timeStampStep, k, superTblInfo->disorderRatio, @@ -5479,6 +5485,7 @@ static int32_t generateStbDataTail( ); } else { lenOfRow = generateStbRowData(superTblInfo, data, + remainderBufLen, startTime + superTblInfo->timeStampStep * k ); } @@ -5491,11 +5498,15 @@ static int32_t generateStbDataTail( pSamplePos); } + if (lenOfRow == 0) { + data[0] = '\0'; + break; + } if ((lenOfRow + 1) > remainderBufLen) { break; } - pstr += snprintf(pstr , lenOfRow + 1, "%s", data); + pstr += lenOfRow; k++; len += lenOfRow; remainderBufLen -= lenOfRow; @@ -6247,7 +6258,7 @@ static int32_t generateStbProgressiveData( assert(buffer != NULL); char *pstr = buffer; - memset(buffer, 0, *pRemainderBufLen); + memset(pstr, 0, *pRemainderBufLen); int64_t headLen = generateStbSQLHead( superTblInfo, @@ -6641,7 +6652,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) { return NULL; } - int64_t remainderBufLen = maxSqlLen; + int64_t remainderBufLen = maxSqlLen - 2000; char *pstr = pThreadInfo->buffer; int len = snprintf(pstr, @@ -6823,10 +6834,14 @@ static void callBack(void *param, TAOS_RES *res, int code) { && rand_num < pThreadInfo->superTblInfo->disorderRatio) { int64_t d = pThreadInfo->lastTs - (taosRandom() % pThreadInfo->superTblInfo->disorderRange + 1); - generateStbRowData(pThreadInfo->superTblInfo, data, d); + generateStbRowData(pThreadInfo->superTblInfo, data, + MAX_DATA_SIZE, + d); } else { generateStbRowData(pThreadInfo->superTblInfo, - data, pThreadInfo->lastTs += 1000); + data, + MAX_DATA_SIZE, + pThreadInfo->lastTs += 1000); } pstr += sprintf(pstr, "%s", data); pThreadInfo->counter++; @@ -7051,6 +7066,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, for (int i = 0; i < threads; i++) { threadInfo *pThreadInfo = infos + i; pThreadInfo->threadID = i; + tstrncpy(pThreadInfo->db_name, db_name, TSDB_DB_NAME_LEN); pThreadInfo->time_precision = timePrec; pThreadInfo->superTblInfo = superTblInfo;