diff --git a/src/storage/meta/entry/base_entry.cpp b/src/storage/meta/entry/base_entry.cpp index 746bc547de..0ecae7d7b1 100644 --- a/src/storage/meta/entry/base_entry.cpp +++ b/src/storage/meta/entry/base_entry.cpp @@ -20,18 +20,24 @@ import stl; import txn_manager; import txn_state; import txn; +import infinity_exception; +import third_party; namespace infinity { bool BaseEntry::CheckVisible(Txn *txn) const { TxnTimeStamp begin_ts = txn->BeginTS(); - TxnManager *txn_mgr = txn->txn_mgr(); TransactionID txn_id = txn_id_.load(); - if (begin_ts < commit_ts_ || txn_id_ == txn->TxnID()) { + if (begin_ts >= commit_ts_ || txn_id == txn->TxnID()) { return true; } + TxnManager *txn_mgr = txn->txn_mgr(); if (txn_mgr == nullptr) { // when replay - return false; + UnrecoverableError(fmt::format("Replay should not reach here. begin_ts: {}, commit_ts_: {} txn_id: {}, txn_id_: {}", + begin_ts, + commit_ts_, + txn->TxnID(), + txn_id)); } return txn_mgr->CheckIfCommitting(txn_id, begin_ts); } diff --git a/src/storage/meta/entry/segment_index_entry.cpp b/src/storage/meta/entry/segment_index_entry.cpp index 9d5808322c..31d9aca30c 100644 --- a/src/storage/meta/entry/segment_index_entry.cpp +++ b/src/storage/meta/entry/segment_index_entry.cpp @@ -242,16 +242,18 @@ void SegmentIndexEntry::MemIndexInsert(SharedPtr block_entry, const IndexFullText *index_fulltext = static_cast(index_base.get()); if (memory_indexer_.get() == nullptr) { String base_name = fmt::format("ft_{:016x}", begin_row_id.ToUint64()); - std::unique_lock lck(rw_locker_); - memory_indexer_ = MakeUnique(*table_index_entry_->index_dir(), - base_name, - begin_row_id, - index_fulltext->flag_, - index_fulltext->analyzer_, - table_index_entry_->GetFulltextByteSlicePool(), - table_index_entry_->GetFulltextBufferPool(), - table_index_entry_->GetFulltextInvertingThreadPool(), - table_index_entry_->GetFulltextCommitingThreadPool()); + { + std::unique_lock lck(rw_locker_); + memory_indexer_ = MakeUnique(*table_index_entry_->index_dir(), + base_name, + begin_row_id, + index_fulltext->flag_, + index_fulltext->analyzer_, + table_index_entry_->GetFulltextByteSlicePool(), + table_index_entry_->GetFulltextBufferPool(), + table_index_entry_->GetFulltextInvertingThreadPool(), + table_index_entry_->GetFulltextCommitingThreadPool()); + } table_index_entry_->UpdateFulltextSegmentTs(commit_ts); } else { RowID exp_begin_row_id = memory_indexer_->GetBaseRowId() + memory_indexer_->GetDocCount();