Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions be/src/cloud/cloud_meta_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ static std::string debug_info(const Request& req) {
return fmt::format(" tablet_id={}", req.rowset_meta().tablet_id());
} else if constexpr (is_any_v<Request, RemoveDeleteBitmapRequest>) {
return fmt::format(" tablet_id={}", req.tablet_id());
} else if constexpr (is_any_v<Request, RemoveDeleteBitmapUpdateLockRequest>) {
return fmt::format(" table_id={}, tablet_id={}, lock_id={}", req.table_id(),
req.tablet_id(), req.lock_id());
} else {
static_assert(!sizeof(Request));
}
Expand Down Expand Up @@ -1105,6 +1108,25 @@ Status CloudMetaMgr::get_delete_bitmap_update_lock(const CloudTablet& tablet, in
return st;
}

Status CloudMetaMgr::remove_delete_bitmap_update_lock(const CloudTablet& tablet, int64_t lock_id,
int64_t initiator) {
VLOG_DEBUG << "remove_delete_bitmap_update_lock , tablet_id: " << tablet.tablet_id()
<< ",lock_id:" << lock_id;
RemoveDeleteBitmapUpdateLockRequest req;
RemoveDeleteBitmapUpdateLockResponse res;
req.set_cloud_unique_id(config::cloud_unique_id);
req.set_tablet_id(tablet.tablet_id());
req.set_lock_id(lock_id);
req.set_initiator(initiator);
auto st = retry_rpc("remove delete bitmap update lock", req, &res,
&MetaService_Stub::remove_delete_bitmap_update_lock);
if (!st.ok()) {
LOG(WARNING) << "remove delete bitmap update lock fail,tablet_id=" << tablet.tablet_id()
<< " lock_id=" << lock_id << " st=" << st.to_string();
}
return st;
}

Status CloudMetaMgr::remove_old_version_delete_bitmap(
int64_t tablet_id,
const std::vector<std::tuple<std::string, uint64_t, uint64_t>>& to_delete) {
Expand Down
3 changes: 3 additions & 0 deletions be/src/cloud/cloud_meta_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class CloudMetaMgr {
Status get_delete_bitmap_update_lock(const CloudTablet& tablet, int64_t lock_id,
int64_t initiator);

Status remove_delete_bitmap_update_lock(const CloudTablet& tablet, int64_t lock_id,
int64_t initiator);

Status remove_old_version_delete_bitmap(
int64_t tablet_id,
const std::vector<std::tuple<std::string, uint64_t, uint64_t>>& to_delete);
Expand Down
2 changes: 2 additions & 0 deletions cloud/src/common/bvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ BvarLatencyRecorderWithTag g_bvar_ms_get_delete_bitmap("ms", "get_delete_bitmap"
BvarLatencyRecorderWithTag g_bvar_ms_get_delete_bitmap_update_lock("ms",
"get_delete_bitmap_update_lock");
BvarLatencyRecorderWithTag g_bvar_ms_remove_delete_bitmap("ms", "remove_delete_bitmap");
BvarLatencyRecorderWithTag g_bvar_ms_remove_delete_bitmap_update_lock(
"ms", "remove_delete_bitmap_update_lock");
BvarLatencyRecorderWithTag g_bvar_ms_get_instance("ms", "get_instance");
BvarLatencyRecorderWithTag g_bvar_ms_get_rl_task_commit_attach("ms", "get_rl_task_commit_attach");
BvarLatencyRecorderWithTag g_bvar_ms_reset_rl_progress("ms", "reset_rl_progress");
Expand Down
1 change: 1 addition & 0 deletions cloud/src/common/bvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ extern BvarLatencyRecorderWithTag g_bvar_ms_update_delete_bitmap;
extern BvarLatencyRecorderWithTag g_bvar_ms_get_delete_bitmap;
extern BvarLatencyRecorderWithTag g_bvar_ms_get_delete_bitmap_update_lock;
extern BvarLatencyRecorderWithTag g_bvar_ms_remove_delete_bitmap;
extern BvarLatencyRecorderWithTag g_bvar_ms_remove_delete_bitmap_update_lock;
extern BvarLatencyRecorderWithTag g_bvar_ms_get_cluster_status;
extern BvarLatencyRecorderWithTag g_bvar_ms_set_cluster_status;
extern BvarLatencyRecorderWithTag g_bvar_ms_get_instance;
Expand Down
52 changes: 52 additions & 0 deletions cloud/src/meta-service/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,58 @@ void MetaServiceImpl::get_delete_bitmap_update_lock(google::protobuf::RpcControl
}
}

void MetaServiceImpl::remove_delete_bitmap_update_lock(
google::protobuf::RpcController* controller,
const RemoveDeleteBitmapUpdateLockRequest* request,
RemoveDeleteBitmapUpdateLockResponse* response, ::google::protobuf::Closure* done) {
RPC_PREPROCESS(remove_delete_bitmap_update_lock);
std::string cloud_unique_id = request->has_cloud_unique_id() ? request->cloud_unique_id() : "";
if (cloud_unique_id.empty()) {
code = MetaServiceCode::INVALID_ARGUMENT;
msg = "cloud unique id not set";
return;
}

instance_id = get_instance_id(resource_mgr_, cloud_unique_id);
if (instance_id.empty()) {
code = MetaServiceCode::INVALID_ARGUMENT;
msg = "empty instance_id";
LOG(INFO) << msg << ", cloud_unique_id=" << cloud_unique_id;
return;
}

RPC_RATE_LIMIT(remove_delete_bitmap_update_lock)
std::unique_ptr<Transaction> txn;
TxnErrorCode err = txn_kv_->create_txn(&txn);
if (err != TxnErrorCode::TXN_OK) {
code = cast_as<ErrCategory::CREATE>(err);
msg = "failed to init txn";
return;
}
if (!check_delete_bitmap_lock(code, msg, ss, txn, instance_id, request->table_id(),
request->lock_id(), request->initiator())) {
LOG(WARNING) << "failed to check delete bitmap tablet lock"
<< " table_id=" << request->table_id() << " tablet_id=" << request->tablet_id()
<< " request lock_id=" << request->lock_id()
<< " request initiator=" << request->initiator() << " msg " << msg;
return;
}
std::string lock_key =
meta_delete_bitmap_update_lock_key({instance_id, request->table_id(), -1});
txn->remove(lock_key);
err = txn->commit();
if (err != TxnErrorCode::TXN_OK) {
code = cast_as<ErrCategory::COMMIT>(err);
ss << "failed to remove delete bitmap tablet lock , err=" << err;
msg = ss.str();
return;
}

LOG(INFO) << "remove delete bitmap table lock table_id=" << request->table_id()
<< " tablet_id=" << request->tablet_id() << " lock_id=" << request->lock_id()
<< ", key=" << hex(lock_key) << ", initiator=" << request->initiator();
}

void MetaServiceImpl::remove_delete_bitmap(google::protobuf::RpcController* controller,
const RemoveDeleteBitmapRequest* request,
RemoveDeleteBitmapResponse* response,
Expand Down
13 changes: 13 additions & 0 deletions cloud/src/meta-service/meta_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ class MetaServiceImpl : public cloud::MetaService {
RemoveDeleteBitmapResponse* response,
::google::protobuf::Closure* done) override;

void remove_delete_bitmap_update_lock(google::protobuf::RpcController* controller,
const RemoveDeleteBitmapUpdateLockRequest* request,
RemoveDeleteBitmapUpdateLockResponse* response,
::google::protobuf::Closure* done) override;

// cloud control get cluster's status by this api
void get_cluster_status(google::protobuf::RpcController* controller,
const GetClusterStatusRequest* request,
Expand Down Expand Up @@ -647,6 +652,14 @@ class MetaServiceProxy final : public MetaService {
call_impl(&cloud::MetaService::remove_delete_bitmap, controller, request, response, done);
}

void remove_delete_bitmap_update_lock(google::protobuf::RpcController* controller,
const RemoveDeleteBitmapUpdateLockRequest* request,
RemoveDeleteBitmapUpdateLockResponse* response,
::google::protobuf::Closure* done) override {
call_impl(&cloud::MetaService::remove_delete_bitmap_update_lock, controller, request,
response, done);
}

// cloud control get cluster's status by this api
void get_cluster_status(google::protobuf::RpcController* controller,
const GetClusterStatusRequest* request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ public Cloud.GetDeleteBitmapUpdateLockResponse getDeleteBitmapUpdateLock(
return blockingStub.getDeleteBitmapUpdateLock(request);
}

public Cloud.RemoveDeleteBitmapUpdateLockResponse removeDeleteBitmapUpdateLock(
Cloud.RemoveDeleteBitmapUpdateLockRequest request) {
if (!request.hasCloudUniqueId()) {
Cloud.RemoveDeleteBitmapUpdateLockRequest.Builder builder = Cloud.RemoveDeleteBitmapUpdateLockRequest
.newBuilder();
builder.mergeFrom(request);
return blockingStub.removeDeleteBitmapUpdateLock(builder.setCloudUniqueId(Config.cloud_unique_id).build());
}
return blockingStub.removeDeleteBitmapUpdateLock(request);
}

public Cloud.GetInstanceResponse getInstance(Cloud.GetInstanceRequest request) {
if (!request.hasCloudUniqueId()) {
Cloud.GetInstanceRequest.Builder builder = Cloud.GetInstanceRequest.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ public Cloud.GetDeleteBitmapUpdateLockResponse getDeleteBitmapUpdateLock(
return w.executeRequest((client) -> client.getDeleteBitmapUpdateLock(request));
}

public Cloud.RemoveDeleteBitmapUpdateLockResponse removeDeleteBitmapUpdateLock(
Cloud.RemoveDeleteBitmapUpdateLockRequest request)
throws RpcException {
return w.executeRequest((client) -> client.removeDeleteBitmapUpdateLock(request));
}

public Cloud.AlterObjStoreInfoResponse alterObjStoreInfo(Cloud.AlterObjStoreInfoRequest request)
throws RpcException {
return w.executeRequest((client) -> client.alterObjStoreInfo(request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import org.apache.doris.cloud.proto.Cloud.MetaServiceCode;
import org.apache.doris.cloud.proto.Cloud.PrecommitTxnRequest;
import org.apache.doris.cloud.proto.Cloud.PrecommitTxnResponse;
import org.apache.doris.cloud.proto.Cloud.RemoveDeleteBitmapUpdateLockRequest;
import org.apache.doris.cloud.proto.Cloud.RemoveDeleteBitmapUpdateLockResponse;
import org.apache.doris.cloud.proto.Cloud.SubTxnInfo;
import org.apache.doris.cloud.proto.Cloud.TableStatsPB;
import org.apache.doris.cloud.proto.Cloud.TabletIndexPB;
Expand Down Expand Up @@ -637,7 +639,13 @@ private void calcDeleteBitmapForMow(long dbId, List<OlapTable> tableList, long t
Map<Long, List<TCalcDeleteBitmapPartitionInfo>> backendToPartitionInfos = getCalcDeleteBitmapInfo(
backendToPartitionTablets, partitionVersions, baseCompactionCnts, cumulativeCompactionCnts,
cumulativePoints);
sendCalcDeleteBitmaptask(dbId, transactionId, backendToPartitionInfos);
try {
sendCalcDeleteBitmaptask(dbId, transactionId, backendToPartitionInfos);
} catch (UserException e) {
LOG.warn("failed to sendCalcDeleteBitmaptask for txn=" + transactionId + ",exception=" + e.getMessage());
removeDeleteBitmapUpdateLock(tableToPartitions, transactionId);
throw e;
}
}

private void getPartitionInfo(List<OlapTable> tableList,
Expand Down Expand Up @@ -858,6 +866,33 @@ private void getDeleteBitmapUpdateLock(Map<Long, Set<Long>> tableToParttions, lo
}
}

private void removeDeleteBitmapUpdateLock(Map<Long, Set<Long>> tableToParttions, long transactionId) {
for (Map.Entry<Long, Set<Long>> entry : tableToParttions.entrySet()) {
RemoveDeleteBitmapUpdateLockRequest.Builder builder = RemoveDeleteBitmapUpdateLockRequest.newBuilder();
builder.setTableId(entry.getKey())
.setLockId(transactionId)
.setInitiator(-1);
final RemoveDeleteBitmapUpdateLockRequest request = builder.build();
RemoveDeleteBitmapUpdateLockResponse response = null;
try {
response = MetaServiceProxy.getInstance().removeDeleteBitmapUpdateLock(request);
if (LOG.isDebugEnabled()) {
LOG.debug("remove delete bitmap lock, transactionId={}, Request: {}, Response: {}",
transactionId, request, response);
}
Preconditions.checkNotNull(response);
Preconditions.checkNotNull(response.getStatus());
if (response.getStatus().getCode() != MetaServiceCode.OK) {
LOG.warn("remove delete bitmap lock failed, transactionId={}, response:{}",
transactionId, response);
}
} catch (Exception e) {
LOG.warn("ignore get delete bitmap lock exception, transactionId={}, exception={}",
transactionId, e);
}
}
}

private void sendCalcDeleteBitmaptask(long dbId, long transactionId,
Map<Long, List<TCalcDeleteBitmapPartitionInfo>> backendToPartitionInfos)
throws UserException {
Expand Down
13 changes: 13 additions & 0 deletions gensrc/proto/cloud.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,18 @@ message GetDeleteBitmapUpdateLockResponse {
repeated int64 cumulative_points = 4;
}

message RemoveDeleteBitmapUpdateLockRequest {
optional string cloud_unique_id = 1; // For auth
optional int64 table_id = 2;
optional int64 tablet_id = 3;
optional int64 lock_id = 4;
optional int64 initiator = 5;
}

message RemoveDeleteBitmapUpdateLockResponse {
optional MetaServiceResponseStatus status = 1;
}

message GetRLTaskCommitAttachRequest {
optional string cloud_unique_id = 1; // For auth
optional int64 db_id = 2;
Expand Down Expand Up @@ -1563,6 +1575,7 @@ service MetaService {
rpc update_delete_bitmap(UpdateDeleteBitmapRequest) returns(UpdateDeleteBitmapResponse);
rpc get_delete_bitmap(GetDeleteBitmapRequest) returns(GetDeleteBitmapResponse);
rpc get_delete_bitmap_update_lock(GetDeleteBitmapUpdateLockRequest) returns(GetDeleteBitmapUpdateLockResponse);
rpc remove_delete_bitmap_update_lock(RemoveDeleteBitmapUpdateLockRequest) returns(RemoveDeleteBitmapUpdateLockResponse);
rpc remove_delete_bitmap(RemoveDeleteBitmapRequest) returns(RemoveDeleteBitmapResponse);

// routine load progress
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --

-- !sql --
5 e 90
6 f 100

Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ suite("test_cloud_mow_broker_load_with_retry", "nonConcurrent") {
++i
}
} finally {
GetDebugPoint().disableDebugPointForAllFEs("CloudEngineCalcDeleteBitmapTask.execute.enable_wait")
GetDebugPoint().disableDebugPointForAllBEs("CloudEngineCalcDeleteBitmapTask.execute.enable_wait")
sql "DROP TABLE IF EXISTS ${table};"
GetDebugPoint().clearDebugPointsForAllBEs()
}
Expand Down
Loading
Loading