hello-stephen commented on code in PR #71394:
URL: https://github.com/apache/doris/pull/71394#discussion_r4794072748


##########
cloud/test/meta_service_test.cpp:
##########
@@ -5107,338 +5107,18 @@ TEST(MetaServiceTest, GetTxnTest) {
 }
 //
 
-TEST(MetaServiceTest, CopyJobTest) {
-    auto meta_service = get_meta_service();
-    brpc::Controller cntl;
-    auto cloud_unique_id = "test_cloud_unique_id";
-    auto stage_id = "test_stage_id";
-    int64_t table_id = 100;
-    std::string instance_id = "copy_job_test_instance_id";
-
-    [[maybe_unused]] auto sp = SyncPoint::get_instance();
-    DORIS_CLOUD_DEFER {
-        SyncPoint::get_instance()->clear_all_call_backs();
-    };
-    sp->set_call_back("get_instance_id", [&](auto&& args) {
-        auto* ret = try_any_cast_ret<std::string>(args);
-        ret->first = instance_id;
-        ret->second = true;
-    });
-    sp->enable_processing();
-
-    // generate a begin copy request
-    BeginCopyRequest begin_copy_request;
-    begin_copy_request.set_cloud_unique_id(cloud_unique_id);
-    begin_copy_request.set_stage_id(stage_id);
-    begin_copy_request.set_stage_type(StagePB::EXTERNAL);
-    begin_copy_request.set_table_id(table_id);
-    begin_copy_request.set_copy_id("test_copy_id");
-    begin_copy_request.set_group_id(0);
-    begin_copy_request.set_start_time_ms(200);
-    begin_copy_request.set_timeout_time_ms(300);
-    for (int i = 0; i < 20; ++i) {
-        ObjectFilePB object_file_pb;
-        object_file_pb.set_relative_path("obj_" + std::to_string(i));
-        object_file_pb.set_etag("obj_" + std::to_string(i) + "_etag");
-        begin_copy_request.add_object_files()->CopyFrom(object_file_pb);
-    }
-
-    // generate a finish copy request
-    FinishCopyRequest finish_copy_request;
-    finish_copy_request.set_cloud_unique_id(cloud_unique_id);
-    finish_copy_request.set_stage_id(stage_id);
-    finish_copy_request.set_stage_type(StagePB::EXTERNAL);
-    finish_copy_request.set_table_id(table_id);
-    finish_copy_request.set_copy_id("test_copy_id");
-    finish_copy_request.set_group_id(0);
-    finish_copy_request.set_action(FinishCopyRequest::COMMIT);
-
-    // generate a get copy files request
-    GetCopyFilesRequest get_copy_file_req;
-    get_copy_file_req.set_cloud_unique_id(cloud_unique_id);
-    get_copy_file_req.set_stage_id(stage_id);
-    get_copy_file_req.set_table_id(table_id);
-
-    // generate a get copy job request
-    GetCopyJobRequest get_copy_job_request;
-    get_copy_job_request.set_cloud_unique_id(cloud_unique_id);
-    get_copy_job_request.set_stage_id(stage_id);
-    get_copy_job_request.set_table_id(table_id);
-    get_copy_job_request.set_copy_id("test_copy_id");
-    get_copy_job_request.set_group_id(0);
-
-    // get copy job
-    {
-        GetCopyJobResponse res;
-        
meta_service->get_copy_job(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                   &get_copy_job_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.has_copy_job(), false);
-    }
-    // begin copy
-    {
-        BeginCopyResponse res;
-        
meta_service->begin_copy(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                 &begin_copy_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.filtered_object_files_size(), 20);
-    }
-    // get copy files
-    {
-        GetCopyFilesResponse res;
-        
meta_service->get_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                     &get_copy_file_req, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files_size(), 20);
-    }
-    // get copy job
-    {
-        GetCopyJobResponse res;
-        
meta_service->get_copy_job(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                   &get_copy_job_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.copy_job().object_files().size(), 20);
-    }
-    // begin copy with duplicate files
-    {
-        begin_copy_request.set_copy_id("test_copy_id_1");
-        begin_copy_request.clear_object_files();
-        for (int i = 15; i < 30; ++i) {
-            ObjectFilePB object_file_pb;
-            object_file_pb.set_relative_path("obj_" + std::to_string(i));
-            object_file_pb.set_etag("obj_" + std::to_string(i) + "_etag");
-            begin_copy_request.add_object_files()->CopyFrom(object_file_pb);
-        }
-
-        BeginCopyResponse res;
-        
meta_service->begin_copy(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                 &begin_copy_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.filtered_object_files_size(), 10);
-    }
-    // get copy files
-    {
-        GetCopyFilesResponse res;
-        
meta_service->get_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                     &get_copy_file_req, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files_size(), 30);
-    }
-    // finish the first copy job
-    {
-        FinishCopyResponse res;
-        
meta_service->finish_copy(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                  &finish_copy_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-    }
-    // get copy files
-    {
-        GetCopyFilesResponse res;
-        
meta_service->get_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                     &get_copy_file_req, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files_size(), 30);
-    }
-    // abort the second copy job
-    {
-        finish_copy_request.set_copy_id("test_copy_id_1");
-        finish_copy_request.set_action(FinishCopyRequest::ABORT);
-
-        FinishCopyResponse res;
-        
meta_service->finish_copy(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                  &finish_copy_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-    }
-    // get copy files
-    {
-        GetCopyFilesResponse res;
-        
meta_service->get_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                     &get_copy_file_req, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files_size(), 20);
-    }
-    {
-        // begin a copy job whose files are all loaded, the copy job key 
should not be created
-        begin_copy_request.set_copy_id("tmp_id");
-        begin_copy_request.clear_object_files();
-        for (int i = 0; i < 20; ++i) {
-            ObjectFilePB object_file_pb;
-            object_file_pb.set_relative_path("obj_" + std::to_string(i));
-            object_file_pb.set_etag("obj_" + std::to_string(i) + "_etag");
-            begin_copy_request.add_object_files()->CopyFrom(object_file_pb);
-        }
-        BeginCopyResponse res;
-        
meta_service->begin_copy(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                 &begin_copy_request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.filtered_object_files_size(), 0);
-        // get copy job
-        get_copy_job_request.set_copy_id("tmp_id");
-        GetCopyJobResponse res2;
-        
meta_service->get_copy_job(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                   &get_copy_job_request, &res2, nullptr);
-        ASSERT_EQ(res2.status().code(), MetaServiceCode::OK);
-        ASSERT_FALSE(res2.has_copy_job());
-    }
-    // scan fdb
-    {
-        std::unique_ptr<Transaction> txn;
-        std::string get_val;
-        ASSERT_EQ(meta_service->txn_kv()->create_txn(&txn), 
TxnErrorCode::TXN_OK);
-        // 20 copy files
-        {
-            CopyFileKeyInfo key_info0 {instance_id, stage_id, table_id, "", 
""};
-            CopyFileKeyInfo key_info1 {instance_id, stage_id, table_id + 1, 
"", ""};
-            std::string key0;
-            std::string key1;
-            copy_file_key(key_info0, &key0);
-            copy_file_key(key_info1, &key1);
-            std::unique_ptr<RangeGetIterator> it;
-            int file_cnt = 0;
-            while (it == nullptr /* may be not init */ || it->more()) {
-                ASSERT_EQ(txn->get(key0, key1, &it), TxnErrorCode::TXN_OK);
-                while (it->has_next()) {
-                    auto [k, v] = it->next();
-                    CopyFilePB copy_file;
-                    ASSERT_TRUE(copy_file.ParseFromArray(v.data(), v.size()));
-                    ASSERT_EQ(copy_file.copy_id(), "test_copy_id");
-                    ++file_cnt;
-                    if (!it->has_next()) {
-                        key0 = k;
-                    }
-                }
-                key0.push_back('\x00');
-            }
-            ASSERT_EQ(file_cnt, 20);
-        }
-        // 1 copy job with finish status
-        {
-            CopyJobKeyInfo key_info0 {instance_id, stage_id, table_id, "", 0};
-            CopyJobKeyInfo key_info1 {instance_id, stage_id, table_id + 1, "", 
0};
-            std::string key0;
-            std::string key1;
-            copy_job_key(key_info0, &key0);
-            copy_job_key(key_info1, &key1);
-            std::unique_ptr<RangeGetIterator> it;
-            int job_cnt = 0;
-            while (it == nullptr /* may be not init */ || it->more()) {
-                ASSERT_EQ(txn->get(key0, key1, &it), TxnErrorCode::TXN_OK);
-                while (it->has_next()) {
-                    auto [k, v] = it->next();
-                    CopyJobPB copy_job;
-                    ASSERT_EQ(copy_job.ParseFromArray(v.data(), v.size()), 
true);
-                    ASSERT_EQ(copy_job.object_files_size(), 20);
-                    ASSERT_EQ(copy_job.job_status(), CopyJobPB::FINISH);
-                    ++job_cnt;
-                    if (!it->has_next()) {
-                        key0 = k;
-                    }
-                }
-                key0.push_back('\x00');
-            }
-            ASSERT_EQ(job_cnt, 1);
-        }
-    }
-}
-
-TEST(MetaServiceTest, FilterCopyFilesTest) {
-    auto meta_service = get_meta_service();
-    brpc::Controller cntl;
-    auto cloud_unique_id = "test_cloud_unique_id";
-    std::string instance_id = "stage_test_instance_id";
-    auto stage_id = "test_stage_id";
-    int64_t table_id = 100;
-    [[maybe_unused]] auto sp = SyncPoint::get_instance();
-    DORIS_CLOUD_DEFER {
-        sp->disable_processing();
-        sp->clear_all_call_backs();
-    };
-    sp->set_call_back("get_instance_id", [&](auto&& args) {
-        auto* ret = try_any_cast_ret<std::string>(args);
-        ret->first = instance_id;
-        ret->second = true;
-    });
-    sp->set_call_back("encrypt_ak_sk:get_encryption_key", [](auto&& args) {
-        auto* ret = try_any_cast<int*>(args[0]);
-        *ret = 0;
-        auto* key = try_any_cast<std::string*>(args[1]);
-        *key = "test";
-        auto* key_id = try_any_cast<int64_t*>(args[2]);
-        *key_id = 1;
-    });
-    sp->set_call_back("decrypt_ak_sk:get_encryption_key", [](auto&& args) {
-        auto* key = try_any_cast<std::string*>(args[0]);
-        *key = "test";
-        auto* ret = try_any_cast<int*>(args[1]);
-        *ret = 0;
-    });
-    sp->enable_processing();
-
-    FilterCopyFilesRequest request;
-    request.set_cloud_unique_id(cloud_unique_id);
-    request.set_stage_id(stage_id);
-    request.set_table_id(table_id);
-    for (int i = 0; i < 10; ++i) {
-        ObjectFilePB object_file;
-        object_file.set_relative_path("file" + std::to_string(i));
-        object_file.set_etag("etag" + std::to_string(i));
-        request.add_object_files()->CopyFrom(object_file);
-    }
-
-    // all files are not loaded
-    {
-        FilterCopyFilesResponse res;
-        
meta_service->filter_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                        &request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files().size(), 10);
-    }
-
-    // some files are loaded
-    {
-        std::unique_ptr<Transaction> txn;
-        ASSERT_EQ(meta_service->txn_kv()->create_txn(&txn), 
TxnErrorCode::TXN_OK);
-        for (int i = 0; i < 4; ++i) {
-            CopyFileKeyInfo key_info {instance_id, stage_id, table_id, "file" 
+ std::to_string(i),
-                                      "etag" + std::to_string(i)};
-            std::string key;
-            copy_file_key(key_info, &key);
-            CopyFilePB copy_file;
-            copy_file.set_copy_id("test_copy_id");
-            std::string val;
-            copy_file.SerializeToString(&val);
-            txn->put(key, val);
-        }
-        ASSERT_EQ(txn->commit(), TxnErrorCode::TXN_OK);
-        FilterCopyFilesResponse res;
-        
meta_service->filter_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                        &request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files().size(), 6);
-        ASSERT_EQ(res.object_files().at(0).relative_path(), "file4");
-    }
-
-    // all files are loaded
-    {
-        std::unique_ptr<Transaction> txn;
-        ASSERT_EQ(meta_service->txn_kv()->create_txn(&txn), 
TxnErrorCode::TXN_OK);
-        for (int i = 4; i < 10; ++i) {
-            CopyFileKeyInfo key_info {instance_id, stage_id, table_id, "file" 
+ std::to_string(i),
-                                      "etag" + std::to_string(i)};
-            std::string key;
-            copy_file_key(key_info, &key);
-            CopyFilePB copy_file;
-            copy_file.set_copy_id("test_copy_id");
-            std::string val;
-            copy_file.SerializeToString(&val);
-            txn->put(key, val);
-        }
-        ASSERT_EQ(txn->commit(), TxnErrorCode::TXN_OK);
-        FilterCopyFilesResponse res;
-        
meta_service->filter_copy_files(reinterpret_cast<::google::protobuf::RpcController*>(&cntl),
-                                        &request, &res, nullptr);
-        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
-        ASSERT_EQ(res.object_files().size(), 0);
+TEST(MetaServiceTest, RetiredCopyRpcsRejectRequests) {
+    auto service = get_meta_service();
+    for (const char* name : {"begin_copy", "finish_copy", "get_copy_job", 
"get_copy_files",
+                             "filter_copy_files", "create_stage", "get_stage", 
"drop_stage"}) {

Review Comment:
   [P1] Keep old FE DROP USER/replay working during the rolling upgrade. On the 
old FE, `Auth.dropUserInternal` calls `dropStage(INTERNAL, ..., ifExists=true)` 
for every dropped cloud user (including replay and users who never used COPY). 
`CloudInternalCatalog.dropStage` accepts OK or STAGE_NOT_FOUND, but an 
unimplemented RPC causes it to throw a DdlException; the outer Auth loop sleeps 
and retries up to 86,400 times by default (minimum 300). If MS is upgraded 
while an old FE remains, ordinary DROP USER and synchronous OP_NEW_DROP_USER 
journal replay can stall for a day or longer, even with COPY drained. Keep an 
idempotent compatibility response for validated legacy internal-drop requests 
during the upgrade window, and cover an old FE against the new MS (or enforce 
and test that every FE is upgraded before MS).



-- 
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