[TD-3963]fix cache_last_row bug

This commit is contained in:
lichuang 2021-06-04 11:23:01 +08:00
parent 97b0ca05e4
commit e81c7324db
2 changed files with 1 additions and 3 deletions

View File

@ -907,13 +907,12 @@ int tsdbCacheLastData(STsdbRepo *pRepo, STsdbCfg* oldCfg) {
atomic_store_8(&pRepo->hasCachedLastColumn, 0); atomic_store_8(&pRepo->hasCachedLastColumn, 0);
} }
tsdbInfo("free cache last data since cacheLast option changed"); tsdbInfo("free cache last data since cacheLast option changed");
for (int i = 1; i < maxTableIdx; i++) { for (int i = 1; i <= maxTableIdx; i++) {
STable *pTable = pMeta->tables[i]; STable *pTable = pMeta->tables[i];
if (pTable == NULL) continue; if (pTable == NULL) continue;
if (need_free_last_row) { if (need_free_last_row) {
taosTZfree(pTable->lastRow); taosTZfree(pTable->lastRow);
pTable->lastRow = NULL; pTable->lastRow = NULL;
pTable->lastKey = TSKEY_INITIAL_VAL;
} }
if (need_free_last_col) { if (need_free_last_col) {
tsdbFreeLastColumns(pTable); tsdbFreeLastColumns(pTable);

View File

@ -1030,7 +1030,6 @@ static int tsdbUpdateTableLatestInfo(STsdbRepo *pRepo, STable *pTable, SDataRow
taosTZfree(pTable->lastRow); taosTZfree(pTable->lastRow);
TSDB_WLOCK_TABLE(pTable); TSDB_WLOCK_TABLE(pTable);
pTable->lastRow = NULL; pTable->lastRow = NULL;
pTable->lastKey = TSKEY_INITIAL_VAL;
TSDB_WUNLOCK_TABLE(pTable); TSDB_WUNLOCK_TABLE(pTable);
} }