fix "Unexpected old row update or delete a non exist index row"

This commit is contained in:
zx0
2021-09-24 13:31:03 +08:00
committed by wangzelin.wzl
parent 0a794fcaad
commit feb6c0e7c8
2 changed files with 30 additions and 26 deletions

View File

@ -43,6 +43,7 @@ int ObMvccValueIterator::init(const ObIMvccCtx& ctx, const ObTransSnapInfo& snap
{
int ret = OB_SUCCESS;
skip_compact_ = skip_compact;
bool can_read_by_sql_no = false;
reset();
int64_t lock_for_read_start = ObClockGenerator::getClock();
// snapshot version equal INT64_MAX is unexpected
@ -62,7 +63,10 @@ int ObMvccValueIterator::init(const ObIMvccCtx& ctx, const ObTransSnapInfo& snap
value_ = value;
is_inited_ = true;
version_iter_ = value->get_list_head();
} else if (read_by_sql_no(ctx, snapshot_info, const_cast<ObMvccRow*>(value), query_flag)) {
} else if (OB_FAIL(read_by_sql_no(ctx, snapshot_info, const_cast<ObMvccRow*>(value), query_flag, can_read_by_sql_no))) {
//do nothing
} else {
if (can_read_by_sql_no) {
ctx_ = &ctx;
value_ = value;
is_inited_ = true;
@ -86,6 +90,7 @@ int ObMvccValueIterator::init(const ObIMvccCtx& ctx, const ObTransSnapInfo& snap
is_inited_ = true;
}
}
}
// stat lock for read time
const_cast<ObIMvccCtx&>(ctx).add_lock_for_read_elapse(ObClockGenerator::getClock() - lock_for_read_start);
return ret;
@ -273,11 +278,10 @@ void ObMvccValueIterator::move_to_next_node()
}
// check if read self transaction when fetch cursor
bool ObMvccValueIterator::read_by_sql_no(
const ObIMvccCtx& ctx, const ObTransSnapInfo& snapshot_info, ObMvccRow* value, const ObQueryFlag& query_flag)
int ObMvccValueIterator::read_by_sql_no(
const ObIMvccCtx& ctx, const ObTransSnapInfo& snapshot_info, ObMvccRow* value, const ObQueryFlag& query_flag, bool& can_read_by_sql_no)
{
int ret = OB_SUCCESS;
bool can_read_by_sql_no = false;
bool is_locked = false;
ObMvccTransNode* iter = value->get_list_head();
@ -343,7 +347,7 @@ bool ObMvccValueIterator::read_by_sql_no(
if (is_locked) {
value->latch_.unlock();
}
return can_read_by_sql_no;
return ret;
}
void ObMvccValueIterator::reset()

View File

@ -115,8 +115,8 @@ public:
{
return version_iter_;
}
bool read_by_sql_no(const ObIMvccCtx& ctx, const transaction::ObTransSnapInfo& snapshot_info, ObMvccRow* value,
const ObQueryFlag& query_flag);
int read_by_sql_no(const ObIMvccCtx& ctx, const transaction::ObTransSnapInfo& snapshot_info, ObMvccRow* value,
const ObQueryFlag& query_flag, bool& can_read_by_sql_no);
private:
int find_start_pos(const int64_t read_snapshot);