check offline read in revert_table_scan_iter
This commit is contained in:
@ -566,6 +566,20 @@ int ObTableScanIterator::get_next_rows(int64_t &count, int64_t capacity)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObTableScanIterator::check_ls_offline_after_read()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
|
||||||
|
auto &acc_ctx = ctx_guard_.get_store_ctx().mvcc_acc_ctx_;
|
||||||
|
|
||||||
|
if (acc_ctx.tx_table_guard_.check_ls_offline()) {
|
||||||
|
ret = OB_NOT_MASTER;
|
||||||
|
STORAGE_LOG(WARN, "ls offline during the read operation", K(ret), K(acc_ctx.snapshot_));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ObTableScanIterator::check_txn_status_if_read_uncommitted_()
|
int ObTableScanIterator::check_txn_status_if_read_uncommitted_()
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|||||||
@ -57,6 +57,10 @@ public:
|
|||||||
void reset_for_switch();
|
void reset_for_switch();
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
ObAccessService::ObStoreCtxGuard &get_ctx_guard() { return ctx_guard_; }
|
ObAccessService::ObStoreCtxGuard &get_ctx_guard() { return ctx_guard_; }
|
||||||
|
|
||||||
|
// A offline ls will disable replay status and kill all part_ctx on the follower.
|
||||||
|
// We can not read the uncommitted data which has not replay commit log yet.
|
||||||
|
int check_ls_offline_after_read();
|
||||||
public:
|
public:
|
||||||
static constexpr int64_t RP_MAX_FREE_LIST_NUM = 1024;
|
static constexpr int64_t RP_MAX_FREE_LIST_NUM = 1024;
|
||||||
static constexpr const char LABEL[] = "RPTableScanIter";
|
static constexpr const char LABEL[] = "RPTableScanIter";
|
||||||
|
|||||||
@ -1273,6 +1273,14 @@ int ObTransService::revert_store_ctx(storage::ObStoreCtx &store_ctx)
|
|||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
TRANS_LOG(ERROR, "unexpected store ctx type", K(ret), K(store_ctx));
|
TRANS_LOG(ERROR, "unexpected store ctx type", K(ret), K(store_ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret) && (acc_ctx.is_read())) {
|
||||||
|
if (acc_ctx.tx_table_guard_.check_ls_offline()) {
|
||||||
|
ret = OB_NOT_MASTER;
|
||||||
|
STORAGE_LOG(WARN, "ls offline during the read operation", K(ret), K(acc_ctx.snapshot_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TRANS_LOG(TRACE, "revert store ctx", K(ret), K(*this), K(lbt()));
|
TRANS_LOG(TRACE, "revert store ctx", K(ret), K(*this), K(lbt()));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1017,7 +1017,12 @@ int ObAccessService::revert_scan_iter(ObNewRowIterator *iter)
|
|||||||
} else if (OB_ISNULL(iter)) {
|
} else if (OB_ISNULL(iter)) {
|
||||||
//do nothing
|
//do nothing
|
||||||
} else if (iter->get_type() == ObNewRowIterator::ObTableScanIterator) {
|
} else if (iter->get_type() == ObNewRowIterator::ObTableScanIterator) {
|
||||||
sop_return(ObTableScanIterator, static_cast<ObTableScanIterator*>(iter));
|
ObTableScanIterator *table_scan_iter = nullptr;
|
||||||
|
table_scan_iter = static_cast<ObTableScanIterator *>(iter);
|
||||||
|
if (OB_FAIL(table_scan_iter->check_ls_offline_after_read())) {
|
||||||
|
LOG_WARN("discover ls offline after table scan", K(ret), KPC(table_scan_iter));
|
||||||
|
}
|
||||||
|
sop_return(ObTableScanIterator, table_scan_iter);
|
||||||
} else {
|
} else {
|
||||||
iter->~ObNewRowIterator();
|
iter->~ObNewRowIterator();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,5 +133,29 @@ int ObTxTableGuard::self_freeze_task()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObTxTableGuard::check_ls_offline()
|
||||||
|
{
|
||||||
|
bool discover_ls_offline = false;
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
|
||||||
|
if (OB_ISNULL(tx_table_)) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
discover_ls_offline = false;
|
||||||
|
STORAGE_LOG(WARN, "tx table is nullptr", K(ret), K(discover_ls_offline));
|
||||||
|
} else {
|
||||||
|
int64_t cur_epoch = tx_table_->get_epoch();
|
||||||
|
ObTxTable::TxTableState tx_table_state = tx_table_->get_state();
|
||||||
|
if (cur_epoch != epoch_ || tx_table_state == ObTxTable::TxTableState::PREPARE_OFFLINE
|
||||||
|
|| tx_table_state == ObTxTable::TxTableState::OFFLINE) {
|
||||||
|
discover_ls_offline = true;
|
||||||
|
|
||||||
|
STORAGE_LOG(INFO, "discover ls offline", K(discover_ls_offline), K(cur_epoch), K(epoch_),
|
||||||
|
K(tx_table_state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return discover_ls_offline;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace storage
|
} // namespace storage
|
||||||
} // end namespace oceanbase
|
} // end namespace oceanbase
|
||||||
|
|||||||
@ -92,6 +92,8 @@ public: // dalegate functions
|
|||||||
|
|
||||||
int self_freeze_task();
|
int self_freeze_task();
|
||||||
|
|
||||||
|
bool check_ls_offline();
|
||||||
|
|
||||||
void reuse() { mini_cache_.reset(); }
|
void reuse() { mini_cache_.reset(); }
|
||||||
|
|
||||||
TO_STRING_KV(KP_(tx_table), K_(epoch), K(mini_cache_));
|
TO_STRING_KV(KP_(tx_table), K_(epoch), K(mini_cache_));
|
||||||
|
|||||||
Reference in New Issue
Block a user