chaoyli closed pull request #525: Fix inconsistency of three replicas belongs to one tablet (#523) URL: https://github.com/apache/incubator-doris/pull/525
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/be/src/olap/olap_header.cpp b/be/src/olap/olap_header.cpp index da79c039..f8d6d439 100644 --- a/be/src/olap/olap_header.cpp +++ b/be/src/olap/olap_header.cpp @@ -460,6 +460,48 @@ void OLAPHeader::add_delete_condition(const DeleteConditionMessage& delete_condi LOG(INFO) << "add delete condition. version=" << version; } +void OLAPHeader::delete_cond_by_version(const Version& version) { + DCHECK(version.first == version.second); + google::protobuf::RepeatedPtrField<DeleteConditionMessage>* delete_conditions + = mutable_delete_data_conditions(); + int index = 0; + for (; index < delete_conditions->size(); ++index) { + const DeleteConditionMessage& temp = delete_conditions->Get(index); + if (temp.version() == version.first) { + // log delete condtion + string del_cond_str; + const RepeatedPtrField<string>& sub_conditions = temp.sub_conditions(); + + for (int i = 0; i != sub_conditions.size(); ++i) { + del_cond_str += sub_conditions.Get(i) + ";"; + } + + LOG(INFO) << "delete one condition. version=" << temp.version() + << ", condition=" << del_cond_str; + + // remove delete condition from PB + delete_conditions->SwapElements(index, delete_conditions->size() - 1); + delete_conditions->RemoveLast(); + } + } +} + +bool OLAPHeader::is_delete_data_version(Version version) { + if (version.first != version.second) { + return false; + } + + google::protobuf::RepeatedPtrField<DeleteConditionMessage>::const_iterator it; + it = delete_data_conditions().begin(); + for (; it != delete_data_conditions().end(); ++it) { + if (it->version() == version.first) { + return true; + } + } + + return false; +} + const PPendingDelta* OLAPHeader::get_pending_delta(int64_t transaction_id) const { for (int i = 0; i < pending_delta_size(); i++) { if (pending_delta(i).transaction_id() == transaction_id) { diff --git a/be/src/olap/olap_header.h b/be/src/olap/olap_header.h index f29bffc1..23f97efa 100644 --- a/be/src/olap/olap_header.h +++ b/be/src/olap/olap_header.h @@ -79,6 +79,8 @@ class OLAPHeader : public OLAPHeaderMessage { bool empty, const std::vector<KeyRange>* column_statistics); void add_delete_condition(const DeleteConditionMessage& delete_condition, int64_t version); + void delete_cond_by_version(const Version& version); + bool is_delete_data_version(Version version); const PPendingDelta* get_pending_delta(int64_t transaction_id) const; const PPendingSegmentGroup* get_pending_segment_group(int64_t transaction_id, int32_t pending_segment_group_id) const; diff --git a/be/src/olap/olap_table.cpp b/be/src/olap/olap_table.cpp index 0ff94875..ecdd9448 100644 --- a/be/src/olap/olap_table.cpp +++ b/be/src/olap/olap_table.cpp @@ -1307,6 +1307,9 @@ OLAPStatus OLAPTable::clone_data(const OLAPHeader& clone_header, << " version=" << version.first << "-" << version.second << "]"; break; } + if (new_local_header.is_delete_data_version(version)) { + new_local_header.delete_cond_by_version(version); + } LOG(INFO) << "delete version from new local header when clone. [table='" << full_name() << "', version=" << version.first << "-" << version.second << "]"; } diff --git a/be/src/olap/olap_table.h b/be/src/olap/olap_table.h index ec2f4f52..b1621957 100644 --- a/be/src/olap/olap_table.h +++ b/be/src/olap/olap_table.h @@ -528,19 +528,7 @@ class OLAPTable : public std::enable_shared_from_this<OLAPTable> { } bool is_delete_data_version(Version version) { - if (version.first != version.second) { - return false; - } - - google::protobuf::RepeatedPtrField<DeleteConditionMessage>::const_iterator it; - it = _header->delete_data_conditions().begin(); - for (; it != _header->delete_data_conditions().end(); ++it) { - if (it->version() == version.first) { - return true; - } - } - - return false; + return _header->is_delete_data_version(version); } bool is_load_delete_version(Version version); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org