dataroaring commented on code in PR #48024:
URL: https://github.com/apache/doris/pull/48024#discussion_r1992865709
##########
cloud/src/meta-service/meta_service_job.cpp:
##########
@@ -479,92 +478,167 @@ static bool
check_and_remove_delete_bitmap_update_lock(MetaServiceCode& code, st
code = MetaServiceCode::LOCK_EXPIRED;
return false;
}
- bool found = false;
- auto initiators = lock_info.mutable_initiators();
- for (auto iter = initiators->begin(); iter != initiators->end(); iter++) {
- if (*iter == lock_initiator) {
- initiators->erase(iter);
- found = true;
- break;
+ if (lock_id == COMPACTION_DELETE_BITMAP_LOCK_ID) {
+ // when upgrade ms, prevent old ms get delete bitmap update lock
+ if (lock_info.initiators_size() > 0) {
+ ss << "compaction lock has " << lock_info.initiators_size() << "
initiators";
+ msg = ss.str();
+ code = MetaServiceCode::LOCK_EXPIRED;
+ return false;
}
- }
- if (!found) {
- ss << "lock initiator " << lock_initiator << " not exist";
- msg = ss.str();
- code = MetaServiceCode::LOCK_EXPIRED;
- return false;
- }
- if (initiators->empty()) {
- INSTANCE_LOG(INFO) << "remove delete bitmap lock, table_id=" <<
table_id
- << " lock_id=" << lock_id << " key=" <<
hex(lock_key);
- txn->remove(lock_key);
+ std::string tablet_compaction_key =
+ mow_tablet_compaction_key({instance_id, table_id,
lock_initiator});
+ std::string tablet_compaction_val;
+ err = txn->get(tablet_compaction_key, &tablet_compaction_val);
+ if (err == TxnErrorCode::TXN_KEY_NOT_FOUND) {
+ ss << "lock initiator " << lock_initiator << " not exist";
+ msg = ss.str();
+ code = MetaServiceCode::LOCK_EXPIRED;
+ return false;
+ } else if (err != TxnErrorCode::TXN_OK) {
+ ss << "failed to get tablet compaction key, instance_id=" <<
instance_id
+ << " table_id=" << table_id << " tablet_id=" << tablet_id
+ << " initiator=" << lock_initiator << " key=" <<
hex(tablet_compaction_key)
+ << " err=" << err;
+ msg = ss.str();
+ code = cast_as<ErrCategory::READ>(err);
+ return false;
+ }
+ MowTabletCompactionPB mow_tablet_compaction;
+ if (!mow_tablet_compaction.ParseFromString(tablet_compaction_val))
[[unlikely]] {
+ code = MetaServiceCode::PROTOBUF_PARSE_ERR;
+ msg = "failed to parse MowTabletCompactionPB";
+ return false;
+ }
+ using namespace std::chrono;
+ int64_t now =
duration_cast<seconds>(system_clock::now().time_since_epoch()).count();
+ if (mow_tablet_compaction.expiration() > 0 &&
mow_tablet_compaction.expiration() < now) {
Review Comment:
Because expiration is used to avoid lost lock owners blocking system and
correctness is not guaranteed by expiration, so we should skip check expiration
here.
--
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]