fix tx_op list concurrent reserve bug

This commit is contained in:
obdev
2024-08-05 08:41:48 +00:00
committed by ob-robot
parent f9ec86ef26
commit 64def4c4a7

View File

@ -127,11 +127,11 @@ int ObTxOpVector::try_extend_space(int64_t count, ObIAllocator &allocator)
STORAGE_LOG(WARN, "check_stat failed", KR(ret));
} else if (count == 0) {
// do nothing
} else if (count_ + count <= capacity_) {
// do nothing
} else {
ObTxOp *tx_op_ptr = nullptr;
if (OB_ISNULL(tx_op_ptr = (ObTxOp*)allocator.alloc((count_ + count) * sizeof(ObTxOp)))) {
// may concurrent reserve space so we use capacity_
int64_t new_capacity = capacity_ + count;
if (OB_ISNULL(tx_op_ptr = (ObTxOp*)allocator.alloc(new_capacity * sizeof(ObTxOp)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
if (count_ > 0) {
@ -141,7 +141,7 @@ int ObTxOpVector::try_extend_space(int64_t count, ObIAllocator &allocator)
allocator.free(tx_op_);
}
tx_op_ = tx_op_ptr;
capacity_ = count_ + count;
capacity_ = new_capacity;
}
}
return ret;