From 55f5454c236bc173b8791a1e2fced0becf4a8500 Mon Sep 17 00:00:00 2001 From: lichuang Date: Sat, 9 Oct 2021 16:55:16 +0800 Subject: [PATCH] [fix][TS-417]fix cachelast core --- src/tsdb/src/tsdbMain.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index c2021963e0..7d302a24ff 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -859,12 +859,12 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) { TSKEY lastKey = tsdbGetTableLastKeyImpl(pTable); SBlockIdx *pIdx = readh.pBlkIdx; if (pIdx && lastKey < pIdx->maxKey) { - pTable->lastKey = pIdx->maxKey; - if (CACHE_LAST_ROW(pCfg) && tsdbRestoreLastRow(pRepo, pTable, &readh, pIdx) != 0) { tsdbDestroyReadH(&readh); return -1; } + + pTable->lastKey = pTable->lastRow ? memRowKey(pTable->lastRow) : pIdx->maxKey; } // restore NULL columns @@ -976,12 +976,11 @@ int tsdbCacheLastData(STsdbRepo *pRepo, STsdbCfg* oldCfg) { SBlockIdx *pIdx = readh.pBlkIdx; if (pIdx && cacheLastRowTableNum > 0 && pTable->lastRow == NULL) { - pTable->lastKey = pIdx->maxKey; - if (tsdbRestoreLastRow(pRepo, pTable, &readh, pIdx) != 0) { tsdbDestroyReadH(&readh); return -1; } + pTable->lastKey = pTable->lastRow ? memRowKey(pTable->lastRow) : pIdx->maxKey; cacheLastRowTableNum -= 1; } -- GitLab