This is an automated email from the ASF dual-hosted git repository.

gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 2523fbd3781 [fix](cloud) Fill schema table cluster_snapshots (#56575)
2523fbd3781 is described below

commit 2523fbd3781b9ea77a20383fc906d68f1edc5b65
Author: walter <[email protected]>
AuthorDate: Mon Sep 29 01:05:17 2025 +0800

    [fix](cloud) Fill schema table cluster_snapshots (#56575)
---
 be/src/cloud/cloud_meta_mgr.cpp                    |  2 +-
 .../schema_cluster_snapshot_properties_scanner.cpp | 28 +++++++++++++++++-----
 .../schema_cluster_snapshots_scanner.cpp           |  6 ++---
 .../exec/schema_scanner/schema_scanner_helper.cpp  |  2 +-
 be/src/exec/schema_scanner/schema_scanner_helper.h |  5 ++--
 cloud/src/meta-service/meta_service_helper.h       |  4 +++-
 .../java/org/apache/doris/catalog/SchemaTable.java |  4 ++--
 7 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/be/src/cloud/cloud_meta_mgr.cpp b/be/src/cloud/cloud_meta_mgr.cpp
index cc2440e1b2e..74df7e6ea5b 100644
--- a/be/src/cloud/cloud_meta_mgr.cpp
+++ b/be/src/cloud/cloud_meta_mgr.cpp
@@ -2184,7 +2184,7 @@ Status 
CloudMetaMgr::list_snapshot(std::vector<SnapshotInfoPB>& snapshots) {
     req.set_cloud_unique_id(config::cloud_unique_id);
     req.set_include_aborted(true);
     RETURN_IF_ERROR(retry_rpc("list snapshot", req, &res, 
&MetaService_Stub::list_snapshot));
-    for (auto& snapshot : snapshots) {
+    for (auto& snapshot : res.snapshots()) {
         snapshots.emplace_back(snapshot);
     }
     return Status::OK();
diff --git 
a/be/src/exec/schema_scanner/schema_cluster_snapshot_properties_scanner.cpp 
b/be/src/exec/schema_scanner/schema_cluster_snapshot_properties_scanner.cpp
index 59bac7d74ff..3eded9782b2 100644
--- a/be/src/exec/schema_scanner/schema_cluster_snapshot_properties_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_cluster_snapshot_properties_scanner.cpp
@@ -35,8 +35,8 @@ class Block;
 } // namespace vectorized
 
 std::vector<SchemaScanner::ColumnDesc> 
SchemaClusterSnapshotPropertiesScanner::_s_tbls_columns = {
-        {"SNAPSHOT_ENABLED", TYPE_BOOLEAN, sizeof(int8_t), true},
-        {"AUTO_SNAPSHOT_ENABLED", TYPE_BOOLEAN, sizeof(int8_t), true},
+        {"SNAPSHOT_ENABLED", TYPE_STRING, sizeof(StringRef), true},
+        {"AUTO_SNAPSHOT", TYPE_BOOLEAN, sizeof(int8_t), true},
         {"MAX_RESERVED_SNAPSHOTS", TYPE_BIGINT, sizeof(int64_t), true},
         {"SNAPSHOT_INTERVAL_SECONDS", TYPE_BIGINT, sizeof(int64_t), true},
 };
@@ -73,10 +73,26 @@ Status 
SchemaClusterSnapshotPropertiesScanner::get_next_block_internal(vectorize
 
 Status 
SchemaClusterSnapshotPropertiesScanner::_fill_block_impl(vectorized::Block* 
block) {
     SCOPED_TIMER(_fill_block_timer);
-    bool ready = _switch_status != 
cloud::SnapshotSwitchStatus::SNAPSHOT_SWITCH_DISABLED;
-    bool enabled = _switch_status == 
cloud::SnapshotSwitchStatus::SNAPSHOT_SWITCH_ON;
-    SchemaScannerHelper::insert_bool_value(0, ready, block);
-    SchemaScannerHelper::insert_bool_value(1, enabled, block);
+    bool auto_snapshot_enabled =
+            _switch_status == cloud::SnapshotSwitchStatus::SNAPSHOT_SWITCH_ON 
&&
+            _max_reserved_snapshots > 0;
+    std::string_view snapshot_enable_status;
+    switch (_switch_status) {
+    case cloud::SnapshotSwitchStatus::SNAPSHOT_SWITCH_ON:
+        snapshot_enable_status = "YES";
+        break;
+    case cloud::SnapshotSwitchStatus::SNAPSHOT_SWITCH_OFF:
+        snapshot_enable_status = "NO";
+        break;
+    case cloud::SnapshotSwitchStatus::SNAPSHOT_SWITCH_DISABLED:
+        snapshot_enable_status = "DISABLED";
+        break;
+    default:
+        snapshot_enable_status = "UNKNOWN";
+        break;
+    }
+    SchemaScannerHelper::insert_string_value(0, snapshot_enable_status, block);
+    SchemaScannerHelper::insert_bool_value(1, auto_snapshot_enabled, block);
     SchemaScannerHelper::insert_int64_value(2, _max_reserved_snapshots, block);
     SchemaScannerHelper::insert_int64_value(3, _snapshot_interval_seconds, 
block);
     return Status::OK();
diff --git a/be/src/exec/schema_scanner/schema_cluster_snapshots_scanner.cpp 
b/be/src/exec/schema_scanner/schema_cluster_snapshots_scanner.cpp
index 067ce7e896a..0e6c8d0b1ed 100644
--- a/be/src/exec/schema_scanner/schema_cluster_snapshots_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_cluster_snapshots_scanner.cpp
@@ -174,9 +174,9 @@ Status 
SchemaClusterSnapshotsScanner::_fill_block_impl(vectorized::Block* block)
     }
     // status
     {
-        std::string prepare_status = "SNAPSHOT_PREPARE";
-        std::string normal_status = "SNAPSHOT_NORMAL";
-        std::string aborted_status = "SNAPSHOT_ABORTED";
+        std::string prepare_status = "PREPARE";
+        std::string normal_status = "NORMAL";
+        std::string aborted_status = "ABORTED";
         for (int i = 0; i < row_num; ++i) {
             auto& snapshot = _snapshots[i];
             if (snapshot.has_status()) {
diff --git a/be/src/exec/schema_scanner/schema_scanner_helper.cpp 
b/be/src/exec/schema_scanner/schema_scanner_helper.cpp
index 3e253aa7f95..c3d9ecfee9d 100644
--- a/be/src/exec/schema_scanner/schema_scanner_helper.cpp
+++ b/be/src/exec/schema_scanner/schema_scanner_helper.cpp
@@ -29,7 +29,7 @@
 
 namespace doris {
 
-void SchemaScannerHelper::insert_string_value(int col_index, std::string 
str_val,
+void SchemaScannerHelper::insert_string_value(int col_index, std::string_view 
str_val,
                                               vectorized::Block* block) {
     vectorized::MutableColumnPtr mutable_col_ptr;
     mutable_col_ptr = 
block->get_by_position(col_index).column->assume_mutable();
diff --git a/be/src/exec/schema_scanner/schema_scanner_helper.h 
b/be/src/exec/schema_scanner/schema_scanner_helper.h
index d2969b0b327..0ea67291834 100644
--- a/be/src/exec/schema_scanner/schema_scanner_helper.h
+++ b/be/src/exec/schema_scanner/schema_scanner_helper.h
@@ -20,7 +20,7 @@
 
 #include <stdint.h>
 
-#include <string>
+#include <string_view>
 #include <vector>
 
 #include "cctz/time_zone.h"
@@ -34,7 +34,8 @@ class Block;
 } // namespace vectorized
 class SchemaScannerHelper {
 public:
-    static void insert_string_value(int col_index, std::string str_val, 
vectorized::Block* block);
+    static void insert_string_value(int col_index, std::string_view str_val,
+                                    vectorized::Block* block);
     static void insert_datetime_value(int col_index, const std::vector<void*>& 
datas,
                                       vectorized::Block* block);
     static void insert_datetime_value(int col_index, int64_t timestamp, const 
cctz::time_zone& ctz,
diff --git a/cloud/src/meta-service/meta_service_helper.h 
b/cloud/src/meta-service/meta_service_helper.h
index 0c209be2ae7..4aedab5dc72 100644
--- a/cloud/src/meta-service/meta_service_helper.h
+++ b/cloud/src/meta-service/meta_service_helper.h
@@ -216,7 +216,9 @@ void finish_rpc(std::string_view func_name, 
brpc::Controller* ctrl, const Reques
                   << " status=" << res->status().ShortDebugString();
     } else if constexpr (std::is_same_v<Response, GetObjStoreInfoResponse> ||
                          std::is_same_v<Response, GetStageResponse> ||
-                         std::is_same_v<Response, GetInstanceResponse>) {
+                         std::is_same_v<Response, GetInstanceResponse> ||
+                         std::is_same_v<Response, BeginSnapshotResponse> ||
+                         std::is_same_v<Response, CloneInstanceResponse>) {
         std::string debug_string = encryt_sk(res->DebugString());
         debug_string = hide_ak(debug_string);
         TEST_SYNC_POINT_CALLBACK("sk_finish_rpc", &debug_string);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
index 37b3fdd8d26..491d19c581b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
@@ -739,8 +739,8 @@ public class SchemaTable extends Table {
                             .build()))
             .put("cluster_snapshot_properties",
                     new SchemaTable(SystemIdGenerator.getNextId(), 
"cluster_snapshot_properties", TableType.SCHEMA,
-                        builder().column("SNAPSHOT_ENABLED", 
ScalarType.createType(PrimitiveType.BOOLEAN))
-                            .column("AUTO_SNAPSHOT_ENABLED", 
ScalarType.createType(PrimitiveType.BOOLEAN))
+                        builder().column("SNAPSHOT_ENABLED", 
ScalarType.createType(PrimitiveType.STRING))
+                            .column("AUTO_SNAPSHOT", 
ScalarType.createType(PrimitiveType.BOOLEAN))
                             .column("MAX_RESERVED_SNAPSHOTS", 
ScalarType.createType(PrimitiveType.BIGINT))
                             .column("SNAPSHOT_INTERVAL_SECONDS", 
ScalarType.createType(PrimitiveType.BIGINT))
                             .build()))


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

Reply via email to