This is an automated email from the ASF dual-hosted git repository. kangkaisen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new a592205 [Fix] Fix bug that rowset meta is deleted after compaction (#3451) a592205 is described below commit a5922051c9bee4d75599847838596abcd8b0bd3b Author: Mingyu Chen <morningman....@gmail.com> AuthorDate: Mon May 4 09:45:25 2020 +0800 [Fix] Fix bug that rowset meta is deleted after compaction (#3451) * [Fix] Fix bug that rowset meta is deleted after compaction After compaction, the tablet rowset meta will be modified by adding to new output rowsets and deleting the old input rowsets. The output version may equals to the input version. So we should delete the "input" version from _rs_version_map before adding the "output" version to _rs_version_map. Otherwise, the new "output" version will be lost in _rs_version_map. --- be/src/olap/tablet.cpp | 17 +++++++++++------ be/src/olap/tablet_manager.cpp | 2 +- .../org/apache/doris/common/PropertyAnalyzerTest.java | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 04ce8db..96f1de4 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -234,6 +234,17 @@ OLAPStatus Tablet::add_rowset(RowsetSharedPtr rowset, bool need_persist) { void Tablet::modify_rowsets(const vector<RowsetSharedPtr>& to_add, const vector<RowsetSharedPtr>& to_delete) { + // the compaction process allow to compact the single version, eg: version[4-4]. + // this kind of "single version compaction" has same "input version" and "output version". + // which means "to_add->version()" equals to "to_delete->version()". + // So we should delete the "to_delete" before adding the "to_add", + // otherwise, the "to_add" will be deleted from _rs_version_map, eventually. + vector<RowsetMetaSharedPtr> rs_metas_to_delete; + for (auto& rs : to_delete) { + rs_metas_to_delete.push_back(rs->rowset_meta()); + _rs_version_map.erase(rs->version()); + } + vector<RowsetMetaSharedPtr> rs_metas_to_add; for (auto& rs : to_add) { rs_metas_to_add.push_back(rs->rowset_meta()); @@ -241,12 +252,6 @@ void Tablet::modify_rowsets(const vector<RowsetSharedPtr>& to_add, ++_newly_created_rowset_num; } - vector<RowsetMetaSharedPtr> rs_metas_to_delete; - for (auto& rs : to_delete) { - rs_metas_to_delete.push_back(rs->rowset_meta()); - _rs_version_map.erase(rs->version()); - } - _tablet_meta->modify_rs_metas(rs_metas_to_add, rs_metas_to_delete); _rs_graph.reconstruct_rowset_graph(_tablet_meta->all_rs_metas()); } diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp index 053d2f7..24244bc 100644 --- a/be/src/olap/tablet_manager.cpp +++ b/be/src/olap/tablet_manager.cpp @@ -680,7 +680,7 @@ void TabletManager::get_tablet_stat(TTabletStatResult* result) { TabletSharedPtr TabletManager::find_best_tablet_to_compaction(CompactionType compaction_type, DataDir* data_dir) { int64_t now_ms = UnixMillis(); - const string& compaction_type_str = CompactionType::BASE_COMPACTION ? "base" : "cumulative"; + const string& compaction_type_str = compaction_type == CompactionType::BASE_COMPACTION ? "base" : "cumulative"; uint32_t highest_score = 0; TabletSharedPtr best_tablet; for (int32 i = 0; i < _tablet_map_lock_shard_size; i++) { diff --git a/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java b/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java index 48e0d7b..81c883e 100644 --- a/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java +++ b/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java @@ -19,16 +19,16 @@ package org.apache.doris.common; import org.apache.doris.catalog.AggregateType; import org.apache.doris.catalog.Column; -import org.apache.doris.catalog.ScalarType; -import org.apache.doris.catalog.PrimitiveType; import org.apache.doris.catalog.DataProperty; +import org.apache.doris.catalog.PrimitiveType; +import org.apache.doris.catalog.ScalarType; import org.apache.doris.common.util.PropertyAnalyzer; +import org.apache.doris.thrift.TStorageMedium; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import org.apache.doris.thrift.TStorageMedium; import org.junit.Assert; import org.junit.Test; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org