Skip to content

Commit

Permalink
[fix](cloud-mow) Fix clear GetDeleteBitmapResponse problem when getin…
Browse files Browse the repository at this point in the history
…g delete bitmap fail and retry (#43358)

Problem Summary:
pr #43261 doesn't clear GetDeleteBitmapResponse correctly, this pr fix
this problem
  • Loading branch information
hust-hhb authored Nov 6, 2024
1 parent 8c67af6 commit a586bac
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
7 changes: 7 additions & 0 deletions be/src/cloud/cloud_meta_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,13 @@ Status CloudMetaMgr::sync_tablet_delete_bitmap(CloudTablet* tablet, int64_t old_
const auto& segment_ids = res.segment_ids();
const auto& vers = res.versions();
const auto& delete_bitmaps = res.segment_delete_bitmaps();
if (rowset_ids.size() != segment_ids.size() || rowset_ids.size() != vers.size() ||
rowset_ids.size() != delete_bitmaps.size()) {
return Status::Error<ErrorCode::INTERNAL_ERROR, false>(
"get delete bitmap data wrong,"
"rowset_ids.size={},segment_ids.size={},vers.size={},delete_bitmaps.size={}",
rowset_ids.size(), segment_ids.size(), vers.size(), delete_bitmaps.size());
}
for (size_t i = 0; i < rowset_ids.size(); i++) {
RowsetId rst_id;
rst_id.init(rowset_ids[i]);
Expand Down
5 changes: 5 additions & 0 deletions cloud/src/meta-service/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,11 @@ void MetaServiceImpl::get_delete_bitmap(google::protobuf::RpcController* control
last_ver = ver;
last_seg_id = seg_id;
} else {
TEST_SYNC_POINT_CALLBACK("get_delete_bitmap_code", &code);
if (code != MetaServiceCode::OK) {
msg = "test get get_delete_bitmap fail,code=" + MetaServiceCode_Name(code);
return;
}
response->mutable_segment_delete_bitmaps()->rbegin()->append(v);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cloud/src/meta-service/meta_service_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void finish_rpc(std::string_view func_name, brpc::Controller* ctrl, Response* re
res->clear_rowset_ids();
res->clear_segment_ids();
res->clear_versions();
res->segment_delete_bitmaps();
res->clear_segment_delete_bitmaps();
}
LOG(INFO) << "finish " << func_name << " from " << ctrl->remote_side()
<< " status=" << res->status().ShortDebugString()
Expand Down
71 changes: 71 additions & 0 deletions cloud/test/meta_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5036,6 +5036,77 @@ TEST(MetaServiceTest, DeleteBimapCommitTxnTest) {
}
}

TEST(MetaServiceTest, GetDeleteBitmapWithRetryTest) {
auto meta_service = get_meta_service();
SyncPoint::get_instance()->enable_processing();
size_t index = 0;
SyncPoint::get_instance()->set_call_back("get_delete_bitmap_code", [&](auto&& args) {
LOG(INFO) << "GET_DELETE_BITMAP_CODE,index=" << index;
if (++index < 2) {
*doris::try_any_cast<MetaServiceCode*>(args[0]) = MetaServiceCode::KV_TXN_TOO_OLD;
}
});

// get delete bitmap update lock
brpc::Controller cntl;
GetDeleteBitmapUpdateLockRequest get_lock_req;
GetDeleteBitmapUpdateLockResponse get_lock_res;
get_lock_req.set_cloud_unique_id("test_cloud_unique_id");
get_lock_req.set_table_id(100);
get_lock_req.add_partition_ids(123);
get_lock_req.set_expiration(5);
get_lock_req.set_lock_id(888);
get_lock_req.set_initiator(-1);
meta_service->get_delete_bitmap_update_lock(
reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &get_lock_req,
&get_lock_res, nullptr);
ASSERT_EQ(get_lock_res.status().code(), MetaServiceCode::OK);

//first update new key
UpdateDeleteBitmapRequest update_delete_bitmap_req;
UpdateDeleteBitmapResponse update_delete_bitmap_res;
update_delete_bitmap_req.set_cloud_unique_id("test_cloud_unique_id");
update_delete_bitmap_req.set_table_id(100);
update_delete_bitmap_req.set_partition_id(123);
update_delete_bitmap_req.set_lock_id(888);
update_delete_bitmap_req.set_initiator(-1);
update_delete_bitmap_req.set_tablet_id(333);
std::string large_value = generate_random_string(300 * 1000 * 3);
update_delete_bitmap_req.add_rowset_ids("456");
update_delete_bitmap_req.add_segment_ids(0);
update_delete_bitmap_req.add_versions(2);
update_delete_bitmap_req.add_segment_delete_bitmaps(large_value);
meta_service->update_delete_bitmap(reinterpret_cast<google::protobuf::RpcController*>(&cntl),
&update_delete_bitmap_req, &update_delete_bitmap_res,
nullptr);
ASSERT_EQ(update_delete_bitmap_res.status().code(), MetaServiceCode::OK);

GetDeleteBitmapRequest get_delete_bitmap_req;
GetDeleteBitmapResponse get_delete_bitmap_res;
get_delete_bitmap_req.set_cloud_unique_id("test_cloud_unique_id");
get_delete_bitmap_req.set_tablet_id(333);

get_delete_bitmap_req.add_rowset_ids("456");
get_delete_bitmap_req.add_begin_versions(2);
get_delete_bitmap_req.add_end_versions(2);

meta_service->get_delete_bitmap(reinterpret_cast<google::protobuf::RpcController*>(&cntl),
&get_delete_bitmap_req, &get_delete_bitmap_res, nullptr);
ASSERT_EQ(get_delete_bitmap_res.status().code(), MetaServiceCode::OK);
ASSERT_EQ(get_delete_bitmap_res.rowset_ids_size(), 1);
ASSERT_EQ(get_delete_bitmap_res.segment_ids_size(), 1);
ASSERT_EQ(get_delete_bitmap_res.versions_size(), 1);
ASSERT_EQ(get_delete_bitmap_res.segment_delete_bitmaps_size(), 1);

ASSERT_EQ(get_delete_bitmap_res.rowset_ids(0), "456");
ASSERT_EQ(get_delete_bitmap_res.segment_ids(0), 0);
ASSERT_EQ(get_delete_bitmap_res.versions(0), 2);
ASSERT_EQ(get_delete_bitmap_res.segment_delete_bitmaps(0), large_value);

SyncPoint::get_instance()->disable_processing();
SyncPoint::get_instance()->clear_all_call_backs();
}

TEST(MetaServiceTest, GetVersion) {
auto service = get_meta_service();

Expand Down

0 comments on commit a586bac

Please sign in to comment.