From cd9798ae429cbe803bbbfab8d41acb957a02210d Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 26 Jul 2023 09:12:47 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dobrowkey=E5=8F=8D=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96bug=E5=AF=BC=E8=87=B4=E5=BB=BA=E5=A4=9A?= =?UTF-8?q?=E5=88=86=E5=8C=BA=E8=A1=A8=E5=86=85=E5=AD=98=E8=86=A8=E8=83=80?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deps/oblib/src/common/rowkey/ob_rowkey.cpp | 5 ++++- deps/oblib/src/common/rowkey/ob_rowkey.h | 2 +- src/share/schema/ob_schema_struct.cpp | 16 +++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/deps/oblib/src/common/rowkey/ob_rowkey.cpp b/deps/oblib/src/common/rowkey/ob_rowkey.cpp index ae0a84dbd5..ddfcedafc2 100644 --- a/deps/oblib/src/common/rowkey/ob_rowkey.cpp +++ b/deps/oblib/src/common/rowkey/ob_rowkey.cpp @@ -294,7 +294,7 @@ int ObRowkey::serialize(char *buf, const int64_t buf_len, int64_t &pos) const return ret; } -int ObRowkey::deserialize(const char *buf, const int64_t buf_len, int64_t &pos) +int ObRowkey::deserialize(const char *buf, const int64_t buf_len, int64_t &pos, bool check_zero /*= false*/) { int ret = OB_SUCCESS; int64_t obj_cnt = 0; @@ -332,6 +332,9 @@ int ObRowkey::deserialize(const char *buf, const int64_t buf_len, int64_t &pos) KP(buf), K(buf_len), K(pos), K(obj_cnt), K(ret)); } } + } else if (check_zero && obj_cnt == 0) { + // Prevent the reserved obj array not aware the obj is empty when obj_cnt = 0 + obj_cnt_ = obj_cnt; } return ret; } diff --git a/deps/oblib/src/common/rowkey/ob_rowkey.h b/deps/oblib/src/common/rowkey/ob_rowkey.h index e841d3e06e..177a308783 100644 --- a/deps/oblib/src/common/rowkey/ob_rowkey.h +++ b/deps/oblib/src/common/rowkey/ob_rowkey.h @@ -101,7 +101,7 @@ public: int serialize(char *buf, const int64_t buf_len, int64_t &pos) const; int64_t get_serialize_size(void) const; - int deserialize(const char *buf, const int64_t buf_len, int64_t &pos); + int deserialize(const char *buf, const int64_t buf_len, int64_t &pos, bool check_zero = false); int serialize_objs(char *buf, const int64_t buf_len, int64_t &pos) const; int64_t get_serialize_objs_size(void) const; diff --git a/src/share/schema/ob_schema_struct.cpp b/src/share/schema/ob_schema_struct.cpp index d2aece07a3..7a22e43065 100644 --- a/src/share/schema/ob_schema_struct.cpp +++ b/src/share/schema/ob_schema_struct.cpp @@ -5550,7 +5550,11 @@ OB_DEF_DESERIALIZE(ObBasePartition) } LST_DO_CODE(OB_UNIS_DECODE, tenant_id_, table_id_, part_id_, - schema_version_, name, high_bound_val, status_); + schema_version_, name); + if (FAILEDx(high_bound_val.deserialize(buf, data_len, pos, true))) { + LOG_WARN("fail to deserialize high_bound_val", KR(ret)); + } + LST_DO_CODE(OB_UNIS_DECODE, status_); if (OB_FAIL(ret)) { LOG_WARN("Fail to deserialize data, ", K(ret)); } else if (OB_FAIL(deep_copy_str(name, name_))) { @@ -5594,11 +5598,13 @@ OB_DEF_DESERIALIZE(ObBasePartition) part_idx_, is_empty_partition_name_, tablespace_id_, - partition_type_, - low_bound_val, - tablet_id_); + partition_type_); + if (FAILEDx(low_bound_val.deserialize(buf, data_len, pos, true))) { + LOG_WARN("fail to deserialze low_bound_val", KR(ret)); + } + LST_DO_CODE(OB_UNIS_DECODE, tablet_id_); if (OB_SUCC(ret) && OB_FAIL(set_low_bound_val(low_bound_val))) { - LOG_WARN("Fail to deep copy high_bound_val", K(ret), K(low_bound_val)); + LOG_WARN("Fail to deep copy low_bound_val", K(ret), K(low_bound_val)); } return ret; }