提交 24f106c6 编写于 作者: S Shengliang Guan

Merge remote-tracking branch 'origin/develop' into feature/sim

......@@ -2,19 +2,39 @@
#
# This file is used to set config for core when taosd crash
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
set -e
# set -x
corePath=$1
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
#ulimit -c unlimited
if [[ ! -n ${corePath} ]]; then
echo -e -n "${GREEN}Please enter a file directory to save the coredump file${NC}:"
read corePath
while true; do
if [[ ! -z "$corePath" ]]; then
break
else
read -p "Please enter a file directory to save the coredump file:" corePath
fi
done
fi
ulimit -c unlimited
${csudo} sed -i '/ulimit -c unlimited/d' /etc/profile ||:
${csudo} sed -i '$a\ulimit -c unlimited' /etc/profile ||:
source /etc/profile
${csudo} mkdir -p /coredump ||:
${csudo} sysctl -w kernel.core_pattern='/coredump/core-%e-%p' ||:
${csudo} echo '/coredump/core-%e-%p' | ${csudo} tee /proc/sys/kernel/core_pattern ||:
${csudo} mkdir -p ${corePath} ||:
${csudo} sysctl -w kernel.core_pattern=${corePath}/core-%e-%p ||:
${csudo} echo "${corePath}/core-%e-%p" | ${csudo} tee /proc/sys/kernel/core_pattern ||:
......@@ -332,6 +332,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break;
case 'N':
arguments->data_batch = atoi(arg);
if (arguments->data_batch >= INT16_MAX) {
arguments->data_batch = INT16_MAX - 1;
}
break;
case 'L':
{
......
......@@ -67,7 +67,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto);
void tHistogramPrint(SHistogramInfo* pHisto);
//int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
SHeapEntry* tHeapCreate(int32_t numOfEntries);
void tHeapSort(SHeapEntry* pEntry, int32_t len);
......
......@@ -120,7 +120,6 @@
//}
static int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val);
static int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
SHistogramInfo* tHistogramCreate(int32_t numOfEntries) {
/* need one redundant slot */
......
......@@ -21,19 +21,19 @@ TEST(testCase, histogram_binary_search) {
pHisto->elems[i].val = i;
}
int32_t idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 1);
int32_t idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 1);
assert(idx == 1);
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 9);
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 9);
assert(idx == 9);
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 20);
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 20);
assert(idx == 10);
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, -1);
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, -1);
assert(idx == 0);
idx = vnodeHistobinarySearch(pHisto->elems, pHisto->numOfEntries, 3.9);
idx = histoBinarySearch(pHisto->elems, pHisto->numOfEntries, 3.9);
assert(idx == 4);
free(pHisto);
......
......@@ -161,6 +161,11 @@ _err:
static void tsdbEndCommit(STsdbRepo *pRepo, int eno) {
if (pRepo->appH.notifyStatus) pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_OVER, eno);
SMemTable *pIMem = pRepo->imem;
tsdbLockRepo(pRepo);
pRepo->imem = NULL;
tsdbUnlockRepo(pRepo);
tsdbUnRefMemTable(pRepo, pIMem);
sem_post(&(pRepo->readyToCommit));
}
......
......@@ -17,6 +17,7 @@
#include "tsdbMain.h"
#define TSDB_DATA_SKIPLIST_LEVEL 5
#define TSDB_MAX_INSERT_BATCH 512
static SMemTable * tsdbNewMemTable(STsdbRepo *pRepo);
static void tsdbFreeMemTable(SMemTable *pMemTable);
......@@ -205,7 +206,7 @@ void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) {
int tsdbAsyncCommit(STsdbRepo *pRepo) {
if (pRepo->mem == NULL) return 0;
SMemTable *pIMem = pRepo->imem;
ASSERT(pRepo->imem == NULL);
sem_wait(&(pRepo->readyToCommit));
......@@ -220,8 +221,6 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) {
tsdbScheduleCommit(pRepo);
if (tsdbUnlockRepo(pRepo) < 0) return -1;
if (tsdbUnRefMemTable(pRepo, pIMem) < 0) return -1;
return 0;
}
......@@ -606,19 +605,13 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
STable * pTable = NULL;
SSubmitBlkIter blkIter = {0};
SDataRow row = NULL;
void ** rows = NULL;
void * rows[TSDB_MAX_INSERT_BATCH] = {0};
int rowCounter = 0;
ASSERT(pBlock->tid < pMeta->maxTables);
pTable = pMeta->tables[pBlock->tid];
ASSERT(pTable != NULL && TABLE_UID(pTable) == pBlock->uid);
rows = (void **)calloc(pBlock->numOfRows, sizeof(void *));
if (rows == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1;
}
tsdbInitSubmitBlkIter(pBlock, &blkIter);
while ((row = tsdbGetSubmitBlkNext(&blkIter)) != NULL) {
if (tsdbCopyRowToMem(pRepo, row, pTable, &(rows[rowCounter])) < 0) {
......@@ -632,9 +625,18 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
if (rows[rowCounter] != NULL) {
rowCounter++;
}
if (rowCounter == TSDB_MAX_INSERT_BATCH) {
if (tsdbInsertDataToTableImpl(pRepo, pTable, rows, rowCounter) < 0) {
goto _err;
}
rowCounter = 0;
memset(rows, 0, sizeof(rows));
}
}
if (tsdbInsertDataToTableImpl(pRepo, pTable, rows, rowCounter) < 0) {
if (rowCounter > 0 && tsdbInsertDataToTableImpl(pRepo, pTable, rows, rowCounter) < 0) {
goto _err;
}
......@@ -642,11 +644,9 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
pRepo->stat.pointsWritten += points * schemaNCols(pSchema);
pRepo->stat.totalStorage += points * schemaVLen(pSchema);
free(rows);
return 0;
_err:
free(rows);
return -1;
}
......
......@@ -2224,22 +2224,25 @@ class ClientManager:
if svcMgr: # gConfig.auto_start_service:
svcMgr.stopTaosServices()
svcMgr = None
# Print exec status, etc., AFTER showing messages from the server
self.conclude()
# print("TC failed (2) = {}".format(self.tc.isFailed()))
# Linux return code: ref https://shapeshed.com/unix-exit-codes/
ret = 1 if self.tc.isFailed() else 0
self.tc.cleanup()
# Release global variables
gConfig = None
gSvcMgr = None
logger = None
thPool = None
dbManager.cleanUp() # destructor wouldn't run in time
dbManager = None
# Print exec status, etc., AFTER showing messages from the server
self.conclude()
# print("TC failed (2) = {}".format(self.tc.isFailed()))
# Linux return code: ref https://shapeshed.com/unix-exit-codes/
ret = 1 if self.tc.isFailed() else 0
self.tc.cleanup()
# Release variables here
self.tc = None
thPool = None
dbManager = None
gc.collect() # force garbage collection
# h = hpy()
......
......@@ -394,6 +394,7 @@ class DbManager():
cType == 'native') else DbConn.createRest(dbTarget)
try:
self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected
Logging.debug("DbManager opened DB connection...")
except taos.error.ProgrammingError as err:
# print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err))
if (err.msg == 'client disconnected'): # cannot open DB connection
......@@ -412,6 +413,10 @@ class DbManager():
# Moved to Database()
# self._stateMachine = StateMechine(self._dbConn)
def __del__(self):
''' Release the underlying DB connection upon deletion of DbManager '''
self.cleanUp()
def getDbConn(self):
return self._dbConn
......@@ -438,5 +443,8 @@ class DbManager():
return "table_{}".format(tblNum)
def cleanUp(self):
self._dbConn.close()
if self._dbConn:
self._dbConn.close()
self._dbConn = None
Logging.debug("DbManager closed DB connection...")
......@@ -2,6 +2,7 @@ import threading
import random
import logging
import os
import sys
import taos
......@@ -53,7 +54,7 @@ class Logging:
# global misc.logger
_logger = logging.getLogger('CrashGen') # real logger
_logger.addFilter(LoggingFilter())
ch = logging.StreamHandler()
ch = logging.StreamHandler(sys.stdout) # Ref: https://stackoverflow.com/questions/14058453/making-python-loggers-output-all-messages-to-stdout-in-addition-to-log-file
_logger.addHandler(ch)
# Logging adapter, to be used as a logger
......
......@@ -19,5 +19,5 @@ if __name__ == "__main__":
mExec.init()
exitCode = mExec.run()
print("Exiting with code: {}".format(exitCode))
print("\nCrash_Gen is now exiting with status code: {}".format(exitCode))
sys.exit(exitCode)
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -57,7 +57,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -57,7 +57,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -59,7 +59,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -60,7 +60,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -60,7 +60,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -62,7 +62,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -59,7 +59,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -59,7 +59,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -61,7 +61,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -59,7 +59,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -32,7 +32,7 @@ class TDTestCase:
tdDnodes.stop(1)
tdDnodes.deploy(1)
tdDnodes.start(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db')
......@@ -60,9 +60,9 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdLog.info("================= step5")
tdLog.info("import 10 data totally repetitive")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -57,7 +57,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -60,7 +60,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -57,9 +57,9 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdLog.info("================= step5")
tdLog.info("import 20 data later with partly overlap")
......
......@@ -57,7 +57,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -62,7 +62,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -54,7 +54,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -61,7 +61,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.stop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdLog.info("import 100 sequential data again")
......
......@@ -53,7 +53,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -53,7 +53,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -55,7 +55,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -53,7 +53,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -53,7 +53,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -57,7 +57,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -57,7 +57,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -59,7 +59,7 @@ class TDTestCase:
tdLog.info("================= step4")
tdDnodes.stop(1)
tdLog.sleep(5)
#tdLog.sleep(5)
tdDnodes.start(1)
tdLog.info("================= step5")
......
......@@ -64,7 +64,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -64,7 +64,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -64,7 +64,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -68,7 +68,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -61,7 +61,7 @@ class TDTestCase:
tdLog.info("================= step5")
tdDnodes.forcestop(1)
tdDnodes.start(1)
tdLog.sleep(10)
#tdLog.sleep(10)
tdLog.info("================= step6")
tdSql.query('select * from tb1')
......
......@@ -16,7 +16,7 @@ import taos
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
class TDTestCase:
def init(self, conn, logSql):
......@@ -44,6 +44,25 @@ class TDTestCase:
tdSql.query("select * from db.st where ts='2020-05-13 10:00:00.000'")
tdSql.checkRows(1)
## test case for https://jira.taosdata.com:18080/browse/TD-2488
tdSql.execute("create table m1(ts timestamp, k int) tags(a int)")
tdSql.execute("create table t1 using m1 tags(1)")
tdSql.execute("create table t2 using m1 tags(2)")
tdSql.execute("insert into t1 values('2020-1-1 1:1:1', 1)")
tdSql.execute("insert into t1 values('2020-1-1 1:10:1', 2)")
tdSql.execute("insert into t2 values('2020-1-1 1:5:1', 99)")
tdSql.query("select count(*) from m1 where ts = '2020-1-1 1:5:1' ")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.query("select count(*) from m1 where ts = '2020-1-1 1:5:1' ")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册