diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 9c28489a39dbb843dfd95e583b9d3b9a1b9046ae..6c72f8216e1b70351d60038e3c22e9000dd8f4ad 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -423,7 +423,7 @@ pipeline { echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}" } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 120, unit: 'MINUTES'){ + timeout(time: 130, unit: 'MINUTES'){ pre_test() script { sh ''' diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 366b026f8d2af86643d218f1a74ea484844b5b84..a158bbfa8dac8d31c61015b72128b664caca622e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -155,6 +155,7 @@ typedef struct SBlockInfoBuf { int32_t currentIndex; SArray* pData; int32_t numPerBucket; + int32_t numOfTables; } SBlockInfoBuf; struct STsdbReader { @@ -302,6 +303,47 @@ static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) { taosArrayPush(pBuf->pData, &p); } + pBuf->numOfTables = numOfTables; + + return TSDB_CODE_SUCCESS; +} + +static int32_t ensureBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) { + if (numOfTables <= pBuf->numOfTables) { + return TSDB_CODE_SUCCESS; + } + + if (pBuf->numOfTables > 0) { + STableBlockScanInfo **p = (STableBlockScanInfo**)taosArrayPop(pBuf->pData); + taosMemoryFree(*p); + pBuf->numOfTables /= pBuf->numPerBucket; + } + + int32_t num = (numOfTables - pBuf->numOfTables) / pBuf->numPerBucket; + int32_t remainder = (numOfTables - pBuf->numOfTables) % pBuf->numPerBucket; + if (pBuf->pData == NULL) { + pBuf->pData = taosArrayInit(num + 1, POINTER_BYTES); + } + + for (int32_t i = 0; i < num; ++i) { + char* p = taosMemoryCalloc(pBuf->numPerBucket, sizeof(STableBlockScanInfo)); + if (p == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + taosArrayPush(pBuf->pData, &p); + } + + if (remainder > 0) { + char* p = taosMemoryCalloc(remainder, sizeof(STableBlockScanInfo)); + if (p == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + taosArrayPush(pBuf->pData, &p); + } + + pBuf->numOfTables = numOfTables; + return TSDB_CODE_SUCCESS; } @@ -3876,8 +3918,13 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n clearBlockScanInfo(*p); } - // todo handle the case where size is less than the value of num - ASSERT(size >= num); + if (size < num) { + int32_t code = ensureBlockScanInfoBuf(&pReader->blockInfoBuf, num); + if (code) { + return code; + } + pReader->status.uidList.tableUidList = (uint64_t*)taosMemoryRealloc(pReader->status.uidList.tableUidList, sizeof(uint64_t) * num); + } taosHashClear(pReader->status.pTableMap); STableUidList* pUidList = &pReader->status.uidList; diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a24efeac5fcbdcda9257961d2bbccaead8ce54a4..c7b5e97234ae9ea4d28ba98a61e18df16f2c1f8c 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -181,7 +181,7 @@ ,,y,script,./test.sh -f tsim/query/groupby.sim ,,y,script,./test.sh -f tsim/query/event.sim ,,y,script,./test.sh -f tsim/query/forceFill.sim -,,n,script,./test.sh -f tsim/query/join.sim +,,y,script,./test.sh -f tsim/query/partitionby.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim diff --git a/tests/script/tsim/query/partitionby.sim b/tests/script/tsim/query/partitionby.sim new file mode 100644 index 0000000000000000000000000000000000000000..8babd1aa8de8e0ad943312e6712d297c3c5242b4 --- /dev/null +++ b/tests/script/tsim/query/partitionby.sim @@ -0,0 +1,39 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +$dbPrefix = db +$tbPrefix1 = tba +$tbPrefix2 = tbb +$mtPrefix = stb +$tbNum = 10 +$rowNum = 2 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt1 = $mtPrefix . $i +$i = 1 +$mt2 = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db vgroups 3 +sql use $db +sql create table $mt1 (ts timestamp, f1 int) TAGS(tag1 int, tag2 binary(500)) +sql create table tb0 using $mt1 tags(0, 'a'); +sql create table tb1 using $mt1 tags(1, 'b'); +sql create table tb2 using $mt1 tags(1, 'a'); +sql create table tb3 using $mt1 tags(1, 'a'); +sql create table tb4 using $mt1 tags(3, 'b'); +sql create table tb5 using $mt1 tags(3, 'a'); +sql create table tb6 using $mt1 tags(3, 'b'); +sql create table tb7 using $mt1 tags(3, 'b'); + +sql select * from $mt1 partition by tag1,tag2 limit 1; +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT