From 6836524d4827a46841d8a0992201b08b48e6b483 Mon Sep 17 00:00:00 2001 From: git-hulk Date: Sun, 6 Aug 2023 23:57:34 +0800 Subject: [PATCH] Fix shouldn't try to create column familes when opening with the readonly mode Currently, kvrocks2redis will read and parse data from local DB with openning in readonly mode, and it will be failed if the Kvrocks is running on the same DB dir. The root cause is the running Kvrocks would acquire the DB lock and kvrocks2redis would try to acquire this DB lock as well when creating column familes. --- src/storage/storage.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 8b651a0d351..4e06743acfd 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -253,8 +253,10 @@ Status Storage::Open(bool read_only) { } rocksdb::Options options = InitRocksDBOptions(); - if (auto s = CreateColumnFamilies(options); !s.IsOK()) { - return s.Prefixed("failed to create column families"); + if (!read_only) { + if (auto s = CreateColumnFamilies(options); !s.IsOK()) { + return s.Prefixed("failed to create column families"); + } } std::shared_ptr shared_block_cache = rocksdb::NewLRUCache(block_cache_size, -1, false, 0.75);