[BUGFIX] fix repeat update lob in one stmt wrong

This commit is contained in:
skylhd
2024-01-23 08:42:23 +00:00
committed by ob-robot
parent c53b733cd2
commit 39510c2722
7 changed files with 95 additions and 10 deletions

View File

@ -299,6 +299,13 @@ DEF_TO_STRING(ObLobLocatorV2)
J_KV(K(*location_info));
J_COMMA();
}
if (buf_len > pos && extern_header->flags_.has_retry_info_
&& size_ >= offset + MEM_LOB_EXTERN_RETRYINFO_LEN) {
ObMemLobRetryInfo *retry_info = reinterpret_cast<ObMemLobRetryInfo *>(ptr_ + offset);
offset += MEM_LOB_EXTERN_RETRYINFO_LEN;
J_KV(K(*retry_info));
J_COMMA();
}
if (buf_len > pos) {
ObString rowkey_str(MIN(extern_header->rowkey_size_, buf_len - pos), ptr_ + offset);
offset += extern_header->rowkey_size_;
@ -346,6 +353,9 @@ uint32_t ObLobLocatorV2::calc_locator_full_len(const ObMemLobExternFlags &flags,
if (flags.has_location_info_) {
loc_len += MEM_LOB_EXTERN_LOCATIONINFO_LEN;
}
if (flags.has_retry_info_) {
loc_len += MEM_LOB_EXTERN_RETRYINFO_LEN;
}
loc_len += MEM_LOB_ADDR_LEN; //ToDo:@gehao server address.
loc_len += rowkey_size;
}
@ -426,6 +436,10 @@ int ObLobLocatorV2::fill(ObMemLobType type,
offset += MEM_LOB_EXTERN_LOCATIONINFO_LEN;
*extern_len += MEM_LOB_EXTERN_LOCATIONINFO_LEN;
}
if (flags.has_retry_info_) {
offset += MEM_LOB_EXTERN_RETRYINFO_LEN;
*extern_len += MEM_LOB_EXTERN_RETRYINFO_LEN;
}
if ((offset + rowkey_str.length()) && OB_UNLIKELY(offset > size_)) {
ret = OB_BUF_NOT_ENOUGH;
@ -749,6 +763,28 @@ int ObLobLocatorV2::get_location_info(ObMemLobLocationInfo *&location_info) cons
return ret;
}
int ObLobLocatorV2::get_retry_info(ObMemLobRetryInfo *&retry_info) const
{
int ret = OB_SUCCESS;
ObMemLobExternHeader *extern_header = NULL;
if (OB_SUCC(get_extern_header(extern_header))) {
char *cur_pos = extern_header->data_ + MEM_LOB_EXTERN_SIZE_LEN;
if (extern_header->flags_.has_tx_info_) {
cur_pos += MEM_LOB_EXTERN_TXINFO_LEN;
}
if (extern_header->flags_.has_location_info_) {
cur_pos += MEM_LOB_EXTERN_LOCATIONINFO_LEN;
}
if (extern_header->flags_.has_retry_info_) {
retry_info = reinterpret_cast<ObMemLobRetryInfo *>(cur_pos);
} else {
ret = OB_ERR_NULL_VALUE;
COMMON_LOG(WARN, "Lob: does not have retry info", K(this), K(ret));
}
}
return ret;
}
int ObLobLocatorV2::get_real_locator_len(int64_t &real_len) const
{
int ret = OB_SUCCESS;
@ -883,6 +919,17 @@ int ObLobLocatorV2::set_location_info(const ObMemLobLocationInfo &location_info)
return ret;
}
int ObLobLocatorV2::set_retry_info(const ObMemLobRetryInfo &retry_info)
{
validate_has_lob_header(has_lob_header_);
int ret = OB_SUCCESS;
ObMemLobRetryInfo *retry_info_ptr = NULL;
if (OB_SUCC(get_retry_info(retry_info_ptr))) {
*retry_info_ptr = retry_info;
}
return ret;
}
OB_DEF_SERIALIZE(ObLobLocatorV2)
{
int ret = OB_SUCCESS;

View File

@ -781,11 +781,11 @@ struct ObMemLobCommon
struct ObMemLobExternFlags
{
ObMemLobExternFlags() :
has_tx_info_(1), has_location_info_(1), reserved_(0)
has_tx_info_(1), has_location_info_(1), has_retry_info_(1), reserved_(0)
{}
ObMemLobExternFlags(bool enable) :
has_tx_info_(enable), has_location_info_(enable), reserved_(0)
has_tx_info_(enable), has_location_info_(enable), has_retry_info_(enable), reserved_(0)
{}
ObMemLobExternFlags(const ObMemLobExternFlags &flags) { *this = flags; }
@ -800,11 +800,12 @@ struct ObMemLobExternFlags
return (*(reinterpret_cast<uint16_t *>(this)) = 0);
}
TO_STRING_KV(K_(has_tx_info), K_(has_location_info), K_(reserved));
TO_STRING_KV(K_(has_tx_info), K_(has_location_info), K_(has_retry_info), K_(reserved));
uint16_t has_tx_info_ : 1; // Indicate whether tx info exists
uint16_t has_location_info_ : 1; // Indicate whether has cid exists (reserved)
uint16_t reserved_ : 14;
uint16_t has_retry_info_ : 1; // Indicate whether has retry info exists
uint16_t reserved_ : 13;
};
// Memory Locator V2, Extern Header:
@ -873,6 +874,16 @@ struct ObMemLobLocationInfo
char data_[0];
};
struct ObMemLobRetryInfo
{
ObMemLobRetryInfo() : is_select_leader_(true), read_latest_(false), addr_(), timeout_(0) {}
TO_STRING_KV(K_(is_select_leader), K_(read_latest), K_(addr), K_(timeout));
bool is_select_leader_;
bool read_latest_;
ObAddr addr_;
uint64_t timeout_;
};
OB_INLINE void validate_has_lob_header(const bool &has_header)
{
#ifdef VALIDATE_LOB_HEADER
@ -897,6 +908,7 @@ public:
static const uint32_t MEM_LOB_EXTERN_HEADER_LEN = sizeof(ObMemLobExternHeader);
static const uint32_t MEM_LOB_EXTERN_TXINFO_LEN = sizeof(ObMemLobTxInfo);
static const uint32_t MEM_LOB_EXTERN_LOCATIONINFO_LEN = sizeof(ObMemLobLocationInfo);
static const uint32_t MEM_LOB_EXTERN_RETRYINFO_LEN = sizeof(ObMemLobRetryInfo);
static const uint16_t MEM_LOB_EXTERN_SIZE_LEN = sizeof(uint16_t);
static const uint32_t MEM_LOB_ADDR_LEN = 0; // reserved for temp lob address
@ -1008,6 +1020,7 @@ public:
int set_payload_data(const ObLobCommon *lob_comm, const ObString& payload);
int set_tx_info(const ObMemLobTxInfo &tx_info);
int set_location_info(const ObMemLobLocationInfo &location_info);
int set_retry_info(const ObMemLobRetryInfo &retry_info);
// interfaces for read
// Notice: all the following functions should be called after is_valid() or fill()
@ -1022,6 +1035,7 @@ public:
int get_table_info(uint64_t &table_id, uint32_t &column_idex);
int get_tx_info(ObMemLobTxInfo *&tx_info) const;
int get_location_info(ObMemLobLocationInfo *&location_info) const;
int get_retry_info(ObMemLobRetryInfo *&retry_info) const;
int get_real_locator_len(int64_t &real_len) const;
bool is_empty_lob() const;