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 ff95fc8 commit c48b75b
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/storage/txn/txn_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,39 +360,33 @@ bool TxnTableStore::CheckConflict(Catalog *catalog, Txn *txn) const {

Optional<String> TxnTableStore::CheckConflict(const TxnTableStore *other_table_store) const {
{
Set<std::string_view> txn_indexes_set;
Map<std::string_view, Set<SegmentID>> txn_indexes_store_map;
Set<std::string_view> other_txn_indexes_set;
Map<std::string_view, Set<SegmentID>> other_txn_indexes_store_map;
for (const auto &index_entry : std::views::keys(other_table_store->txn_indexes_)) {
txn_indexes_set.insert(*index_entry->GetIndexName());
other_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];
auto &segment_set = other_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)) {
if (const auto &index_name = *index_entry->GetIndexName(); other_txn_indexes_set.contains(index_name)) {
return fmt::format("{}: txn_indexes_ containing Index {} conflict with other_table_store->txn_indexes_",
__func__,
index_name);
}
if (txn_indexes_store_map.contains(index_name)) {
return fmt::format("{}: txn_indexes_ containing Index {} conflict with other_table_store->txn_indexes_store_",
__func__,
index_name);
}
}
for (const auto &[index_name, index_store] : txn_indexes_store_) {
if (txn_indexes_set.contains(index_name)) {
if (other_txn_indexes_set.contains(index_name)) {
return fmt::format("{}: txn_indexes_store_ containing Index {} conflict with other_table_store->txn_indexes_",
__func__,
index_name);
}
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)) {
if (const auto iter = other_txn_indexes_store_map.find(index_name); iter != other_txn_indexes_store_map.end()) {
for (const auto &other_segment_set = iter->second; const auto segment_id : std::views::keys(index_store->index_entry_map_)) {
if (other_segment_set.contains(segment_id)) {
return fmt::format(
"{}: txn_indexes_store_ containing Index {} Segment {} conflict with other_table_store->txn_indexes_store_",
__func__,
Expand Down Expand Up @@ -687,6 +681,10 @@ Optional<String> TxnStore::CheckConflict(const TxnStore &other_txn_store) {
}

const TxnTableStore *other_table_store = other_iter->second.get();
if (table_store->GetTableEntry() != other_table_store->GetTableEntry()) {
// TODO: different table entry?
continue;
}
if (const auto conflict_reason = table_store->CheckConflict(other_table_store); conflict_reason) {
return fmt::format("txn_tables_store_ containing table_name {} conflict with other_txn_store.txn_tables_store_: {}",
table_name,
Expand Down

0 comments on commit c48b75b

Please sign in to comment.