You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "acelyc111 (via GitHub)" <gi...@apache.org> on 2025/04/03 02:30:33 UTC

Re: [PR] fix(checkpoint): When loading the replica in the replica_server, the assertion !missing_meta_cf failed [incubator-pegasus]

acelyc111 commented on code in PR #2216:
URL: https://github.com/apache/incubator-pegasus/pull/2216#discussion_r2025924549


##########
src/server/pegasus_server_impl.cpp:
##########
@@ -184,6 +184,48 @@ const std::unordered_map<std::string, cf_opts_getter> cf_opts_getters = {
      }},
 };
 
+bool pegasus_server_impl::is_checkpoint_complete(const std::string &checkpoint_dir)
+{
+    rocksdb::DB *snapshot_db = nullptr;
+    std::vector<rocksdb::ColumnFamilyHandle *> handles_opened;
+    auto cleanup = [&]() {
+        if (snapshot_db != nullptr) {
+            for (auto *handle : handles_opened) {
+                if (handle != nullptr) {
+                    snapshot_db->DestroyColumnFamilyHandle(handle);
+                    handle = nullptr;
+                }
+            }
+            delete snapshot_db;
+            snapshot_db = nullptr;
+        }
+    };
+
+    // Because of RocksDB's restriction, we have to to open default column family even though
+    // not use it
+    std::vector<rocksdb::ColumnFamilyDescriptor> column_families(
+        {{meta_store::DATA_COLUMN_FAMILY_NAME, rocksdb::ColumnFamilyOptions()},
+         {meta_store::META_COLUMN_FAMILY_NAME, rocksdb::ColumnFamilyOptions()}});
+    auto status = rocksdb::DB::OpenForReadOnly(
+        _db_opts, checkpoint_dir, column_families, &handles_opened, &snapshot_db);
+    if (!status.ok()) {
+        LOG_ERROR_PREFIX(
+            "OpenForReadOnly from {} failed, error = {}", checkpoint_dir, status.ToString());
+        snapshot_db = nullptr;
+        cleanup();

Review Comment:
   use defer to execute `cleanup()` automatically



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org