fix lock for read hang when row_scn invalid

This commit is contained in:
obdev
2023-05-30 09:23:51 +00:00
committed by ob-robot
parent 697656a856
commit f76fbc4eea
4 changed files with 15 additions and 5 deletions

View File

@ -51,6 +51,7 @@ public:
tx_scn_(-1),
write_flag_(),
handle_start_time_(OB_INVALID_TIMESTAMP),
is_standby_read_(false),
lock_wait_start_ts_(0)
{}
~ObMvccAccessCtx() {
@ -64,6 +65,7 @@ public:
tx_scn_ = -1;
write_flag_.reset();
handle_start_time_ = OB_INVALID_TIMESTAMP;
is_standby_read_ = false;
}
void reset() {
if (is_write() && OB_UNLIKELY(tx_ctx_)) {
@ -81,6 +83,7 @@ public:
tx_scn_ = -1;
write_flag_.reset();
handle_start_time_ = OB_INVALID_TIMESTAMP;
is_standby_read_ = false;
}
bool is_valid() const {
switch(type_) {
@ -256,6 +259,8 @@ public: // NOTE: those field should only be accessed by txn relative routine
// this was used for runtime mertic
int64_t handle_start_time_;
bool is_standby_read_;
protected:
int64_t lock_wait_start_ts_;
};

View File

@ -228,6 +228,7 @@ int ObMvccValueIterator::lock_for_read_inner_(const ObQueryFlag &flag,
// snapshot
int counter = 0;
while (OB_SUCC(ret)
&& !ctx_->is_standby_read_
&& is_determined_state
&& !(iter->is_committed() || iter->is_aborted() || iter->is_elr())) {
if (OB_FAIL(try_cleanout_tx_node_(iter))) {

View File

@ -1440,8 +1440,8 @@ OB_INLINE int ObReadRow::iterate_row_value_(
const ObTransID snapshot_tx_id = value_iter.get_snapshot_tx_id();
const ObTransID reader_tx_id = value_iter.get_reader_tx_id();
row_scn = tx_node->trans_version_.get_val_for_tx();
if (!(snapshot_tx_id == tx_node->get_tx_id() || reader_tx_id == tx_node->get_tx_id())
&& tx_node->trans_version_.is_max()) {
if (!value_iter.get_mvcc_acc_ctx()->is_standby_read_ && (!(snapshot_tx_id == tx_node->get_tx_id() || reader_tx_id == tx_node->get_tx_id())
&& tx_node->trans_version_.is_max())) {
TRANS_LOG(ERROR, "meet row scn with undecided value", KPC(tx_node),
K(is_committed), K(trans_version), K(value_iter));
}

View File

@ -375,9 +375,13 @@ int LockForReadFunctor::operator()(const ObTxData &tx_data, ObTxCCCtx *tx_cc_ctx
int LockForReadFunctor::check_for_standby(const transaction::ObTransID &tx_id)
{
return MTL(transaction::ObTransService *)->check_for_standby(ls_id_, tx_id,
lock_for_read_arg_.mvcc_acc_ctx_.snapshot_.version_,
can_read_, trans_version_, is_determined_state_);
int ret = OB_SUCCESS;
if (OB_SUCC(MTL(transaction::ObTransService *)->check_for_standby(ls_id_, tx_id,
lock_for_read_arg_.mvcc_acc_ctx_.snapshot_.version_,
can_read_, trans_version_, is_determined_state_))) {
lock_for_read_arg_.mvcc_acc_ctx_.is_standby_read_ = true;
}
return ret;
}
int CleanoutTxStateFunctor::operator()(const ObTxData &tx_data, ObTxCCCtx *tx_cc_ctx)