From f20b28bc9f2a515bf2baa09c037bd14424088b75 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 4 May 2023 14:29:56 +0000 Subject: [PATCH] fix mem leak --- source/libs/stream/src/streamBackendRocksdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index cd2b01d50a..ee8fbf7785 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -70,6 +70,7 @@ void* streamBackendInit(const char* path) { rocksdb_options_set_max_total_wal_size(opts, 128 << 20); rocksdb_options_set_recycle_log_file_num(opts, 6); rocksdb_options_set_max_write_buffer_number(opts, 3); + rocksdb_options_set_info_log_level(opts, 0); pHandle->env = env; pHandle->dbOpt = opts; @@ -98,7 +99,8 @@ _EXIT: return NULL; } void streamBackendCleanup(void* arg) { - SBackendHandle* pHandle = (SBackendHandle*)arg; + SBackendHandle* pHandle = (SBackendHandle*)arg; + rocksdb_flushoptions_t* flushOpt = rocksdb_flushoptions_create(); char* err = NULL; rocksdb_flush(pHandle->db, flushOpt, &err); @@ -1175,6 +1177,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pSta SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; int len = stateSessionKeyEncode(&sKey, buf); if (!streamStateIterSeekAndValid(pCur->iter, buf, len)) { + streamStateFreeCur(pCur); return NULL; } while (rocksdb_iter_valid(pCur->iter) && iterValueIsStale(pCur->iter)) rocksdb_iter_prev(pCur->iter);