From 04c20b25ad22ebc843a82bacc0b9f766cd6ea56f Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 21 Sep 2020 18:28:36 +0800 Subject: [PATCH 1/6] fix binary length --- src/connector/go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/go b/src/connector/go index 8c58c512b6..f4f6b76812 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit 8c58c512b6acda8bcdfa48fdc7140227b5221766 +Subproject commit f4f6b768124a634b3c2408351c4d91df20f8de3f From 67efcff7adab751b043c6ad5c3762ff5fbf40a1d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Sep 2020 13:47:18 +0800 Subject: [PATCH 2/6] [td-225] fix bugs in regression test. --- src/client/src/tscSql.c | 5 +++-- src/util/src/tcache.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 598ec7e546..8b79b0278b 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -264,12 +264,13 @@ void taos_close(TAOS *taos) { } SSqlObj* pHb = pObj->pHb; - if (pHb != NULL) { + if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) { if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode rpcCancelRequest(pHb->pRpcCtx); + pHb->pRpcCtx = NULL; } - pObj->pHb = NULL; + tscDebug("%p, HB is freed", pHb); taos_free_result(pHb); } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index a6376e49ad..337513940a 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -266,7 +266,6 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen if (taosHashGetSize(pCacheObj->pHashTable) == 0) { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); - uError("cache:%s, key:%p, not in cache, retrieved failed, reason: empty cache", pCacheObj->name, key); return NULL; } From 7b2fbddfa7b4dae4a9c1e9b9627e2543fa8c808d Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 22 Sep 2020 14:06:22 +0800 Subject: [PATCH 3/6] [TD-1386] add test case for retention --- tests/pytest/insert/retentionpolicy.py | 108 +++++++++++++++++++++++++ tests/pytest/test.sh | 1 + 2 files changed, 109 insertions(+) create mode 100644 tests/pytest/insert/retentionpolicy.py diff --git a/tests/pytest/insert/retentionpolicy.py b/tests/pytest/insert/retentionpolicy.py new file mode 100644 index 0000000000..bd294a24f3 --- /dev/null +++ b/tests/pytest/insert/retentionpolicy.py @@ -0,0 +1,108 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +import datetime +sys.path.insert(0, os.getcwd()) +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestRetetion: + def init(self): + self.queryRows=0 + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + print(tdDnodes.getDnodesRootDir()) + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + def checkRows(self, expectRows,sql): + if self.queryRows == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, self.queryRows, expectRows)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, self.queryRows, expectRows) + os.system("timedatectl set-ntp true") + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + + def run(self): + + tdLog.info("=============== step1") + tdSql.execute('create database test keep 3 days 1;') + tdSql.execute('use test;') + tdSql.execute('create table test(ts timestamp,i int);') + + cmd = 'insert into test values(now-2d,11)(now-1d,11)(now,11)(now+1d,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(4) + + tdLog.info("=============== step2") + tdDnodes.stop(1) + os.system("timedatectl set-ntp false") + os.system("date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + tdDnodes.start(1) + cmd = 'insert into test values(now,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(5) + + tdLog.info("=============== step3") + tdDnodes.stop(1) + os.system("date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + tdDnodes.start(1) + cmd = 'insert into test values(now-1d,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(6) + tdLog.info("=============== step4") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd = 'insert into test values(now,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(7) + + tdLog.info("=============== step5") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd='select * from test where ts > now-1d' + queryRows=tdSql.query('select * from test where ts > now-1d') + self.checkRows(1,cmd) + + def stop(self): + os.system("timedatectl set-ntp true") + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +clients = TDTestRetetion() +clients.init() +clients.run() +clients.stop() + diff --git a/tests/pytest/test.sh b/tests/pytest/test.sh index fbb9ba9879..d76c88c6ea 100755 --- a/tests/pytest/test.sh +++ b/tests/pytest/test.sh @@ -12,6 +12,7 @@ else TAOS_DIR=$CURR_DIR/../.. fi TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` +TAOS_BIN_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/bin LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR From 5fe097a4022677ac94d6fe9092f32f2b0854619c Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 22 Sep 2020 14:18:30 +0800 Subject: [PATCH 4/6] [TD-1386] add test case for retention --- tests/pytest/fulltest.sh | 1 + tests/pytest/test.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 9ebf1584e2..1ed2f688a8 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -16,6 +16,7 @@ python3 ./test.py -f insert/nchar.py python3 ./test.py -f insert/nchar-unicode.py python3 ./test.py -f insert/multi.py python3 ./test.py -f insert/randomNullCommit.py +python3 insert/retentionpolicy.py python3 ./test.py -f table/column_name.py python3 ./test.py -f table/column_num.py diff --git a/tests/pytest/test.sh b/tests/pytest/test.sh index d76c88c6ea..fbb9ba9879 100755 --- a/tests/pytest/test.sh +++ b/tests/pytest/test.sh @@ -12,7 +12,6 @@ else TAOS_DIR=$CURR_DIR/../.. fi TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` -TAOS_BIN_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/bin LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR From eb0f6a1e45504ffa54f28418252965c65a612e49 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Sep 2020 14:22:45 +0800 Subject: [PATCH 5/6] [td-1544] --- src/mnode/src/mnodeShow.c | 6 ++++-- src/util/src/tcache.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index f66ef6b7a3..f2caf30564 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -65,7 +65,7 @@ int32_t mnodeInitShow() { mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mnodeProcessConnectMsg); mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mnodeProcessUseMsg); - tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 5, false, mnodeFreeShowObj, "show"); + tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 5, true, mnodeFreeShowObj, "show"); return 0; } @@ -389,10 +389,12 @@ static bool mnodeAccquireShowObj(SShowObj *pShow) { } static void* mnodePutShowObj(SShowObj *pShow) { + const int32_t DEFAULT_SHOWHANDLE_LIFE_SPAN = tsShellActivityTimer * 6 * 1000; + if (tsMnodeShowCache != NULL) { pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1); uint64_t handleVal = (uint64_t)pShow; - SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(int64_t), &pShow, sizeof(int64_t), 6000); + SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(int64_t), &pShow, sizeof(int64_t), DEFAULT_SHOWHANDLE_LIFE_SPAN); pShow->ppShow = (void**)ppShow; mDebug("%p, show is put into cache, data:%p index:%d", pShow, ppShow, pShow->index); return pShow; diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 337513940a..49b9996cf4 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -279,7 +279,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData, T_REF_VAL_GET(ptNode)); } else { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); - uError("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); + uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); } atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1); From 8f610e98d124dea16306d4ec84d19d2a1f6c0132 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 22 Sep 2020 14:54:25 +0800 Subject: [PATCH 6/6] [TD-1465] --- src/connector/go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/go b/src/connector/go index f4f6b76812..06ec30a0f1 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit f4f6b768124a634b3c2408351c4d91df20f8de3f +Subproject commit 06ec30a0f1762e8169bf6b9045c82bcaa52bcdf0