Skip to content

Commit

Permalink
[BugFix] Fix automatic partition write data into wrong partition when…
Browse files Browse the repository at this point in the history
… many partition created concurrency (#34731)

Signed-off-by: meegoo <meegoo.sr@gmail.com>
(cherry picked from commit 2095a85)

# Conflicts:
#	be/src/runtime/lake_tablets_channel.cpp
  • Loading branch information
meegoo authored and mergify[bot] committed Nov 10, 2023
1 parent 155e2f8 commit eb03a78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions be/src/runtime/lake_tablets_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,25 @@ Status LakeTabletsChannel::_create_delta_writers(const PTabletWriterOpenRequest&
_delta_writers.emplace(tablet.tablet_id(), std::move(writer));
tablet_ids.emplace_back(tablet.tablet_id());
}
<<<<<<< HEAD
DCHECK_EQ(_delta_writers.size(), params.tablets_size());
// In order to get sorted index for each tablet
std::sort(tablet_ids.begin(), tablet_ids.end());
for (size_t i = 0; i < tablet_ids.size(); ++i) {
_tablet_id_to_sorted_indexes.emplace(tablet_ids[i], i);
=======
if (!tablet_ids.empty()) { // has new tablets added, need rebuild the sorted index
tablet_ids.reserve(tablet_ids.size() + _tablet_id_to_sorted_indexes.size());
for (auto& iter : _tablet_id_to_sorted_indexes) {
tablet_ids.emplace_back(iter.first);
}
// In order to get sorted index for each tablet
std::sort(tablet_ids.begin(), tablet_ids.end());
DCHECK_EQ(_delta_writers.size(), tablet_ids.size());
for (size_t i = 0; i < tablet_ids.size(); ++i) {
_tablet_id_to_sorted_indexes[tablet_ids[i]] = i;
}
>>>>>>> 2095a85b42 ([BugFix] Fix automatic partition write data into wrong partition when many partition created concurrency (#34731))
}
return Status::OK();
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/runtime/local_tablets_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ Status LocalTabletsChannel::incremental_open(const PTabletWriterOpenRequest& par
DCHECK_EQ(_delta_writers.size(), tablet_ids.size());
std::sort(tablet_ids.begin(), tablet_ids.end());
for (size_t i = 0; i < tablet_ids.size(); ++i) {
_tablet_id_to_sorted_indexes.emplace(tablet_ids[i], i);
_tablet_id_to_sorted_indexes[tablet_ids[i]] = i;
}
}

Expand Down

0 comments on commit eb03a78

Please sign in to comment.