From 163224f4e2fb0053bf0d6a3eb78b6cd66adcf787 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 7 Mar 2023 19:42:05 +0800 Subject: [PATCH] fix: taosd crash when modify the schema and query last_row --- source/dnode/vnode/src/tsdb/tsdbCache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 3e34c3b048..c92967f7f4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -1305,6 +1305,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo int16_t iCol = 0; int16_t noneCol = 0; bool setNoneCol = false; + bool hasRow = false; SArray *pColArray = NULL; SColVal *pColVal = &(SColVal){0}; @@ -1327,6 +1328,8 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo break; } + hasRow = true; + code = updateTSchema(TSDBROW_SVERSION(pRow), pr, uid); if (TSDB_CODE_SUCCESS != code) { goto _err; @@ -1418,6 +1421,9 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo //*ppColArray = NULL; // taosArrayDestroy(pColArray); //} else { + if (!hasRow) { + taosArrayClear(pColArray); + } *ppColArray = pColArray; //} -- GitLab