From a5c1b9a054953f0be77b853bcdd95fcea966d92d Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Fri, 19 May 2023 17:10:24 +0800 Subject: [PATCH] cache/commit: skip batch write if empty --- source/dnode/vnode/src/tsdb/tsdbCache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 845fd2f304..eba5d1b0e1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -210,12 +210,13 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) { static void rocksMayWrite(STsdb *pTsdb, bool force) { rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; - - if (force || rocksdb_writebatch_count(wb) >= 1024) { + int count = rocksdb_writebatch_count(wb); + if ((force && count > 0) || count >= 1024) { char *err = NULL; rocksdb_write(pTsdb->rCache.db, pTsdb->rCache.writeoptions, wb, &err); if (NULL != err) { - tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, err); + tsdbError("vgId:%d, %s failed at line %d, count: %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, count, + err); rocksdb_free(err); } -- GitLab