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


##########
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:
   Okay, thank you for your advice !



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to