diff --git a/examples/JDBC/taosdemo/pom.xml b/examples/JDBC/taosdemo/pom.xml
index 68224bbad5f719b74ff7ed103d4024985bbb2887..4731d8e2370687a0fce0cb68d09ff4948266c30b 100644
--- a/examples/JDBC/taosdemo/pom.xml
+++ b/examples/JDBC/taosdemo/pom.xml
@@ -10,7 +10,7 @@
Demo project for TDengine
- 5.3.20
+ 5.3.26
diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h
index 0b38ce6d240dbda045bef53d585fd998a0116adb..452b1f6c0b8c04bfde1e3f32cc33e6d1aa6fb7c1 100644
--- a/source/dnode/vnode/src/inc/tsdb.h
+++ b/source/dnode/vnode/src/inc/tsdb.h
@@ -687,6 +687,8 @@ typedef struct SSttBlockLoadInfo {
STSchema *pSchema;
int16_t *colIds;
int32_t numOfCols;
+ bool checkRemainingRow;
+ bool isLast;
bool sttBlockLoaded;
int32_t numOfStt;
diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c
index 3d01184e7849b116266bed6b27cc007dfdda781f..6fc8ad8be647c5331f7c31f1e373d891997ece6a 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCache.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCache.c
@@ -590,6 +590,7 @@ typedef struct {
SDataFReader **pDataFReader;
TSDBROW row;
+ bool checkRemainingRow;
SMergeTree mergeTree;
SMergeTree *pMergeTree;
SSttBlockLoadInfo *pLoadInfo;
@@ -600,7 +601,6 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
int nCols) {
SFSLastNextRowIter *state = (SFSLastNextRowIter *)iter;
int32_t code = 0;
- bool checkRemainingRow = true;
switch (state->state) {
case SFSLASTNEXTROW_FS:
@@ -633,12 +633,25 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
if (code) goto _err;
}
- state->pLoadInfo->colIds = aCols;
- state->pLoadInfo->numOfCols = nCols;
+ for (int i = 0; i < state->pLoadInfo->numOfStt; ++i) {
+ state->pLoadInfo[i].colIds = aCols;
+ state->pLoadInfo[i].numOfCols = nCols;
+ state->pLoadInfo[i].isLast = isLast;
+ }
tMergeTreeOpen(&state->mergeTree, 1, *state->pDataFReader, state->suid, state->uid,
&(STimeWindow){.skey = state->lastTs, .ekey = TSKEY_MAX},
&(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, state->pLoadInfo, false, NULL, true);
state->pMergeTree = &state->mergeTree;
+ state->state = SFSLASTNEXTROW_BLOCKROW;
+ }
+ case SFSLASTNEXTROW_BLOCKROW: {
+ if (nCols != state->pLoadInfo->numOfCols) {
+ for (int i = 0; i < state->pLoadInfo->numOfStt; ++i) {
+ state->pLoadInfo[i].numOfCols = nCols;
+
+ state->pLoadInfo[i].checkRemainingRow = state->checkRemainingRow;
+ }
+ }
bool hasVal = tMergeTreeNext(&state->mergeTree);
if (!hasVal) {
if (tMergeTreeIgnoreEarlierTs(&state->mergeTree)) {
@@ -649,76 +662,23 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa
state->state = SFSLASTNEXTROW_FILESET;
goto _next_fileset;
}
- state->state = SFSLASTNEXTROW_BLOCKROW;
- checkRemainingRow = false;
- }
- case SFSLASTNEXTROW_BLOCKROW: {
- bool skipRow = false;
- do {
- bool hasVal = false;
- state->row = tMergeTreeGetRow(&state->mergeTree);
- *ppRow = &state->row;
- if (nCols != state->pLoadInfo->numOfCols) {
- state->pLoadInfo->numOfCols = nCols;
- }
- hasVal = tMergeTreeNext(&state->mergeTree);
- if (TSDBROW_TS(&state->row) <= state->lastTs) {
- *pIgnoreEarlierTs = true;
- *ppRow = NULL;
- return code;
- }
-
- *pIgnoreEarlierTs = false;
- if (!hasVal) {
- state->state = SFSLASTNEXTROW_FILESET;
- break;
- }
-
- if (checkRemainingRow) {
- bool skipBlock = true;
-
- SBlockData *pBlockData = state->row.pBlockData;
+ state->row = tMergeTreeGetRow(&state->mergeTree);
+ *ppRow = &state->row;
- for (int inputColIndex = 0; inputColIndex < nCols; ++inputColIndex) {
- for (int colIndex = 0; colIndex < pBlockData->nColData; ++colIndex) {
- SColData *pColData = &pBlockData->aColData[colIndex];
- int16_t cid = pColData->cid;
-
- if (cid == aCols[inputColIndex]) {
- if (isLast && (pColData->flag & HAS_VALUE)) {
- skipBlock = false;
- break;
- } else if (pColData->flag & (HAS_VALUE | HAS_NULL)) {
- skipBlock = false;
- break;
- }
- }
- }
- }
- /*
- for (int colIndex = 0; colIndex < pBlockData->nColData; ++colIndex) {
- SColData *pColData = &pBlockData->aColData[colIndex];
- int16_t cid = pColData->cid;
-
- if (inputColIndex < nCols && cid == aCols[inputColIndex]) {
- if (isLast && (pColData->flag & HAS_VALUE)) {
- skipBlock = false;
- break;
- } else if (pColData->flag & (HAS_VALUE | HAS_NULL)) {
- skipBlock = false;
- break;
- }
+ if (TSDBROW_TS(&state->row) <= state->lastTs) {
+ *pIgnoreEarlierTs = true;
+ *ppRow = NULL;
+ return code;
+ }
- ++inputColIndex;
- }
- }
- */
- if (skipBlock) {
- skipRow = true;
- }
- }
- } while (skipRow);
+ *pIgnoreEarlierTs = false;
+ if (!hasVal) {
+ state->state = SFSLASTNEXTROW_FILESET;
+ }
+ if (!state->checkRemainingRow) {
+ state->checkRemainingRow = true;
+ }
return code;
}
default:
diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
index 943b16116c20e18130dbe63fd0c44db0109f5e75..fa8870835c5fc6b914663a2d76c9202e1410e52f 100644
--- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
@@ -504,9 +504,34 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
pIter->iRow += step;
while (1) {
+ bool skipBlock = false;
+
findNextValidRow(pIter, idStr);
- if (pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) {
+ if (pIter->pBlockLoadInfo->checkRemainingRow) {
+ skipBlock = true;
+ int16_t *aCols = pIter->pBlockLoadInfo->colIds;
+ int nCols = pIter->pBlockLoadInfo->numOfCols;
+ bool isLast = pIter->pBlockLoadInfo->isLast;
+ for (int inputColIndex = 0; inputColIndex < nCols; ++inputColIndex) {
+ for (int colIndex = 0; colIndex < pBlockData->nColData; ++colIndex) {
+ SColData *pColData = &pBlockData->aColData[colIndex];
+ int16_t cid = pColData->cid;
+
+ if (cid == aCols[inputColIndex]) {
+ if (isLast && (pColData->flag & HAS_VALUE)) {
+ skipBlock = false;
+ break;
+ } else if (pColData->flag & (HAS_VALUE | HAS_NULL)) {
+ skipBlock = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (skipBlock || pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) {
tLDataIterNextBlock(pIter, idStr);
if (pIter->pSttBlk == NULL) { // no more data
goto _exit;
diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c
index 29b7fa740c85e9ea74def8e53d47edd69c76b743..5ea9be63dbf7bb9415668d232324ca1272b49db6 100644
--- a/source/libs/tdb/src/db/tdbPager.c
+++ b/source/libs/tdb/src/db/tdbPager.c
@@ -947,6 +947,12 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return 0;
}
+static int32_t txnIdCompareDesc(const void *pLeft, const void *pRight) {
+ int64_t lhs = *(int64_t *)pLeft;
+ int64_t rhs = *(int64_t *)pRight;
+ return lhs > rhs ? -1 : 1;
+}
+
int tdbPagerRestoreJournals(SPager *pPager) {
tdbDirEntryPtr pDirEntry;
tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName);
@@ -955,23 +961,33 @@ int tdbPagerRestoreJournals(SPager *pPager) {
return -1;
}
+ SArray *pTxnList = taosArrayInit(16, sizeof(int64_t));
+
while ((pDirEntry = tdbReadDir(pDir)) != NULL) {
char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry));
if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) {
- char jname[TD_PATH_MAX] = {0};
- int dirLen = strlen(pPager->pEnv->dbName);
- memcpy(jname, pPager->pEnv->dbName, dirLen);
- jname[dirLen] = '/';
- memcpy(jname + dirLen + 1, name, strlen(name));
- if (tdbPagerRestore(pPager, jname) < 0) {
- tdbCloseDir(&pDir);
-
- tdbError("failed to restore file due to %s. jFileName:%s", strerror(errno), name);
- return -1;
- }
+ int64_t txnId = -1;
+ sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId);
+ taosArrayPush(pTxnList, &txnId);
+ }
+ }
+ taosArraySort(pTxnList, txnIdCompareDesc);
+ for (int i = 0; i < TARRAY_SIZE(pTxnList); ++i) {
+ int64_t *pTxnId = taosArrayGet(pTxnList, i);
+ char jname[TD_PATH_MAX] = {0};
+ int dirLen = strlen(pPager->pEnv->dbName);
+ memcpy(jname, pPager->pEnv->dbName, dirLen);
+ jname[dirLen] = '/';
+ sprintf(jname + dirLen + 1, TDB_MAINDB_NAME "-journal.%" PRId64, *pTxnId);
+ if (tdbPagerRestore(pPager, jname) < 0) {
+ tdbCloseDir(&pDir);
+
+ tdbError("failed to restore file due to %s. jFileName:%s", strerror(errno), jname);
+ return -1;
}
}
+ taosArrayDestroy(pTxnList);
tdbCloseDir(&pDir);
return 0;
diff --git a/tests/system-test/0-others/check_assert.py b/tests/system-test/0-others/check_assert.py
index 59fb223528bf2351ca5cd5a8a6af1d317558c26a..ff69b9eeec02caddfe989eacfe3a4a16a5e6d656 100644
--- a/tests/system-test/0-others/check_assert.py
+++ b/tests/system-test/0-others/check_assert.py
@@ -28,10 +28,10 @@ import os
NO_FOUND = 0 # not found assert or ASSERT
FOUND_OK = 1 # found ASSERT and valid usage
FOUND_NOIF = 2 # found ASSERT but no if like ASSERT(...)
-FOUND_LOWER = 3 # found assert write with lower letters
+FOUND_LOWER = 3 # found assert write with system assert
FOUND_HAVENOT = 4 # found ASSERT have if but have not like if(!ASSERT)
-code_strs = ["not found", "valid", "found but no if", "lower assert","found but have not"]
+code_strs = ["not found", "valid", "found but no if", "system assert","found but have not"]
#