From 58a23f5f7bbe316e5d172d735cae8ea38e1e72da Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 16 Dec 2022 04:07:57 +0000 Subject: [PATCH] [bugfix] fix compatibility of log_block_header --- src/logservice/palf/log_block_header.cpp | 2 +- src/share/scn.cpp | 12 +++++++++++- src/share/scn.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/logservice/palf/log_block_header.cpp b/src/logservice/palf/log_block_header.cpp index 7a5ee70af..d0bc1a345 100644 --- a/src/logservice/palf/log_block_header.cpp +++ b/src/logservice/palf/log_block_header.cpp @@ -149,7 +149,7 @@ DEFINE_DESERIALIZE(LogBlockHeader) || OB_FAIL(serialization::decode_i32(buf, data_len, new_pos, &flag_)) || OB_FAIL(min_lsn_.deserialize(buf, data_len, new_pos)) || OB_FAIL(min_scn_.fixed_deserialize(buf, data_len, new_pos)) - || OB_FAIL(max_scn_.fixed_deserialize(buf, data_len, new_pos)) + || OB_FAIL(max_scn_.fixed_deserialize_without_transform(buf, data_len, new_pos)) || OB_FAIL(serialization::decode_i64(buf, data_len, new_pos, reinterpret_cast(&curr_block_id_))) || OB_FAIL(serialization::decode_i64(buf, data_len, new_pos, &palf_id_)) || OB_FAIL(serialization::decode_i64(buf, data_len, new_pos, &checksum_))) { diff --git a/src/share/scn.cpp b/src/share/scn.cpp index cd26ddaba..582967a36 100644 --- a/src/share/scn.cpp +++ b/src/share/scn.cpp @@ -476,7 +476,7 @@ int SCN::to_yson(char *buf, const int64_t buf_len, int64_t &pos) const return oceanbase::yson::databuff_encode_elements(buf, buf_len, pos, OB_ID(scn_val), val_); } -int SCN::fixed_deserialize(const char* buf, const int64_t data_len, int64_t& pos) +int SCN::fixed_deserialize_without_transform(const char* buf, const int64_t data_len, int64_t& pos) { int ret = OB_SUCCESS; int64_t new_pos = pos; @@ -488,6 +488,16 @@ int SCN::fixed_deserialize(const char* buf, const int64_t data_len, int64_t& pos PALF_LOG(WARN, "failed to decode val_", K(buf), K(data_len), K(new_pos), K(ret)); } else { pos = new_pos; + } + return ret; +} + +int SCN::fixed_deserialize(const char* buf, const int64_t data_len, int64_t& pos) +{ + int ret = OB_SUCCESS; + if (OB_FAIL(fixed_deserialize_without_transform(buf, data_len, pos))) { + PALF_LOG(WARN, "failed to fixed_deserialize_without_transform", K(buf), K(data_len), K(pos), K(ret)); + } else { (void)transform_max_(); } return ret; diff --git a/src/share/scn.h b/src/share/scn.h index 396321d1a..8ad912f7b 100644 --- a/src/share/scn.h +++ b/src/share/scn.h @@ -109,6 +109,8 @@ public: //fixed length serialization int fixed_serialize(char* buf, const int64_t buf_len, int64_t& pos) const; + //used for checksum with old value of INT64_MAX, if transforming max value, checksum will change; + int fixed_deserialize_without_transform(const char* buf, const int64_t data_len, int64_t& pos); int fixed_deserialize(const char* buf, const int64_t data_len, int64_t& pos); int64_t get_fixed_serialize_size(void) const;