Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzq50 committed Dec 31, 2024
1 parent 1094cff commit dbcfe1c
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/storage/txn/txn_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

module;

#include <ranges>
#include <string>
#include <vector>

Expand Down Expand Up @@ -358,11 +359,45 @@ bool TxnTableStore::CheckConflict(Catalog *catalog, Txn *txn) const {
}

bool TxnTableStore::CheckConflict(const TxnTableStore *other_table_store) const {
for (const auto &[index_name, _] : txn_indexes_store_) {
for (const auto [index_entry, _] : other_table_store->txn_indexes_) {
if (index_name == *index_entry->GetIndexName()) {
{
Set<std::string_view> txn_indexes_set;
Map<std::string_view, Set<SegmentID>> txn_indexes_store_map;
for (const auto &index_entry : std::views::keys(other_table_store->txn_indexes_)) {
txn_indexes_set.insert(*index_entry->GetIndexName());
}
for (const auto &[index_name, index_store] : other_table_store->txn_indexes_store_) {
auto &segment_set = txn_indexes_store_map[index_name];
for (const auto segment_id : std::views::keys(index_store->index_entry_map_)) {
segment_set.insert(segment_id);
}
}
for (const auto &index_entry : std::views::keys(txn_indexes_)) {
const auto &index_name = *index_entry->GetIndexName();
if (txn_indexes_set.contains(index_name)) {
LOG_ERROR(fmt::format("{}: Index {} already exists in other table store txn_indexes_", __func__, index_name));
return true;
}
if (txn_indexes_store_map.contains(index_name)) {
LOG_ERROR(fmt::format("{}: Index {} already exists in other table store txn_indexes_store_", __func__, index_name));
return true;
}
}
for (const auto &[index_name, index_store] : txn_indexes_store_) {
if (txn_indexes_set.contains(index_name)) {
LOG_ERROR(fmt::format("{}: txn_indexes_store_ of Index {} already exists in other table store txn_indexes_", __func__, index_name));
return true;
}
if (const auto iter = txn_indexes_store_map.find(index_name); iter != txn_indexes_store_map.end()) {
for (auto &segment_set = iter->second; const auto segment_id : std::views::keys(index_store->index_entry_map_)) {
if (segment_set.contains(segment_id)) {
LOG_ERROR(fmt::format("{}: Segment {} already exists in other table store txn_indexes_store_ of Index {}",
__func__,
segment_id,
index_name));
return true;
}
}
}
}
}

Expand Down

0 comments on commit dbcfe1c

Please sign in to comment.