[4.2.1>master] finetune ENABLE_SERIALIZATION_CHECK
This commit is contained in:
		| @ -55,14 +55,17 @@ if(ENABLE_SMART_VAR_CHECK) | |||||||
|   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SMART_VAR_CHECK") |   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SMART_VAR_CHECK") | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| if(ENABLE_SERIALIZATION_CHECK) |  | ||||||
|   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_SERIALIZATION_CHECK") |  | ||||||
|   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SERIALIZATION_CHECK") |  | ||||||
| endif() |  | ||||||
|  |  | ||||||
| if(ENABLE_DEBUG_LOG) | if(ENABLE_DEBUG_LOG) | ||||||
|   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_DEBUG_LOG") |   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_DEBUG_LOG") | ||||||
|   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_DEBUG_LOG") |   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_DEBUG_LOG") | ||||||
|  |   if(NOT DEFINED ENABLE_SERIALIZATION_CHECK) | ||||||
|  |     set(ENABLE_SERIALIZATION_CHECK ${ENABLE_DEBUG_LOG}) | ||||||
|  |   endif() | ||||||
|  | endif() | ||||||
|  |  | ||||||
|  | if(ENABLE_SERIALIZATION_CHECK) | ||||||
|  |   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_SERIALIZATION_CHECK") | ||||||
|  |   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SERIALIZATION_CHECK") | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| if (OB_GPERF_MODE) | if (OB_GPERF_MODE) | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ ob_define(ENABLE_MEMORY_DIAGNOSIS OFF) | |||||||
| ob_define(ENABLE_OBJ_LEAK_CHECK OFF) | ob_define(ENABLE_OBJ_LEAK_CHECK OFF) | ||||||
| ob_define(ENABLE_FATAL_ERROR_HANG ON) | ob_define(ENABLE_FATAL_ERROR_HANG ON) | ||||||
| ob_define(ENABLE_SMART_VAR_CHECK OFF) | ob_define(ENABLE_SMART_VAR_CHECK OFF) | ||||||
| ob_define(ENABLE_SERIALIZATION_CHECK OFF) |  | ||||||
| ob_define(ENABLE_COMPILE_DLL_MODE OFF) | ob_define(ENABLE_COMPILE_DLL_MODE OFF) | ||||||
| ob_define(OB_CMAKE_RULES_CHECK ON) | ob_define(OB_CMAKE_RULES_CHECK ON) | ||||||
| ob_define(OB_STATIC_LINK_LGPL_DEPS ON) | ob_define(OB_STATIC_LINK_LGPL_DEPS ON) | ||||||
|  | |||||||
| @ -291,11 +291,6 @@ const char *to_cstring<int64_t>(const int64_t &v) | |||||||
|   return to_cstring<int64_t>(v, BoolType<false>()); |   return to_cstring<int64_t>(v, BoolType<false>()); | ||||||
| } | } | ||||||
|  |  | ||||||
| const char *to_cstring(const int64_t v) |  | ||||||
| { |  | ||||||
|   return to_cstring<int64_t>(v, BoolType<false>()); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| //////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
| int databuff_printf(char *buf, const int64_t buf_len, const char *fmt, ...) | int databuff_printf(char *buf, const int64_t buf_len, const char *fmt, ...) | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								deps/oblib/src/lib/utility/ob_print_utils.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								deps/oblib/src/lib/utility/ob_print_utils.h
									
									
									
									
										vendored
									
									
								
							| @ -272,8 +272,6 @@ const char *to_cstring<const char *>(const char *const &str); | |||||||
| template <> | template <> | ||||||
| const char *to_cstring<int64_t>(const int64_t &v); | const char *to_cstring<int64_t>(const int64_t &v); | ||||||
|  |  | ||||||
| const char *to_cstring(const int64_t v); |  | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| const char *to_cstring(T *obj) | const char *to_cstring(T *obj) | ||||||
| { | { | ||||||
|  | |||||||
| @ -22,19 +22,19 @@ void begin_record_serialization() | |||||||
| { | { | ||||||
|   ser_diag_record.count = 0; |   ser_diag_record.count = 0; | ||||||
|   ser_diag_record.check_index = 0; |   ser_diag_record.check_index = 0; | ||||||
|   ser_diag_record.flag = 1; |   ser_diag_record.flag = CHECK_STATUS_RECORDING; | ||||||
| } | } | ||||||
|  |  | ||||||
| void finish_record_serialization() | void finish_record_serialization() | ||||||
| { | { | ||||||
|   ser_diag_record.flag = 0; |   ser_diag_record.flag = CHECK_STATUS_WATING; | ||||||
| } | } | ||||||
|  |  | ||||||
| void begin_check_serialization() | void begin_check_serialization() | ||||||
| { | { | ||||||
|   ser_diag_record.check_index = 0; |   ser_diag_record.check_index = 0; | ||||||
|   if (ser_diag_record.count > 0) { |   if (ser_diag_record.count > 0) { | ||||||
|     ser_diag_record.flag = 2; |     ser_diag_record.flag = CHECK_STATUS_COMPARING; | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -42,8 +42,9 @@ void finish_check_serialization() | |||||||
| { | { | ||||||
|   ser_diag_record.count = -1; |   ser_diag_record.count = -1; | ||||||
|   ser_diag_record.check_index = -1; |   ser_diag_record.check_index = -1; | ||||||
|   ser_diag_record.flag = 0; |   ser_diag_record.flag = CHECK_STATUS_WATING; | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace lib | }  // namespace lib | ||||||
| }  // namespace oceanbase | }  // namespace oceanbase | ||||||
| #endif | #endif | ||||||
							
								
								
									
										28
									
								
								deps/oblib/src/lib/utility/ob_unify_serialize.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								deps/oblib/src/lib/utility/ob_unify_serialize.h
									
									
									
									
										vendored
									
									
								
							| @ -21,13 +21,19 @@ namespace lib | |||||||
| { | { | ||||||
|  |  | ||||||
| #ifdef ENABLE_SERIALIZATION_CHECK | #ifdef ENABLE_SERIALIZATION_CHECK | ||||||
|  | enum ObSerializationCheckStatus | ||||||
|  | { | ||||||
|  |   CHECK_STATUS_WATING = 0, | ||||||
|  |   CHECK_STATUS_RECORDING = 1, | ||||||
|  |   CHECK_STATUS_COMPARING = 2 | ||||||
|  | }; | ||||||
| static constexpr int MAX_SERIALIZE_RECORD_LENGTH = 256; | static constexpr int MAX_SERIALIZE_RECORD_LENGTH = 256; | ||||||
| struct SerializeDiagnoseRecord | struct SerializeDiagnoseRecord | ||||||
| { | { | ||||||
|   uint8_t encoded_lens[MAX_SERIALIZE_RECORD_LENGTH]; |   uint8_t encoded_lens[MAX_SERIALIZE_RECORD_LENGTH]; | ||||||
|   int count = -1; |   int count = -1; | ||||||
|   int check_index = -1; |   int check_index = -1; | ||||||
|   int flag = 0; |   int flag = CHECK_STATUS_WATING; | ||||||
| }; | }; | ||||||
| RLOCAL_EXTERN(SerializeDiagnoseRecord, ser_diag_record); | RLOCAL_EXTERN(SerializeDiagnoseRecord, ser_diag_record); | ||||||
| void begin_record_serialization(); | void begin_record_serialization(); | ||||||
| @ -78,21 +84,31 @@ void finish_check_serialization(); | |||||||
|   } |   } | ||||||
|  |  | ||||||
| #ifdef ENABLE_SERIALIZATION_CHECK | #ifdef ENABLE_SERIALIZATION_CHECK | ||||||
|  |  | ||||||
|  | #define IF_TYPE_MATCH(obj, type) \ | ||||||
|  |         std::is_same<type, decltype(obj)>::value || std::is_same<type &, decltype(obj)>::value | ||||||
|  |  | ||||||
|  | #define IF_NEED_TO_CHECK_SERIALIZATION(obj)       \ | ||||||
|  |         !(std::is_const<decltype(obj)>::value ||  \ | ||||||
|  |         IF_TYPE_MATCH(obj, uint8_t) ||            \ | ||||||
|  |         IF_TYPE_MATCH(obj, int8_t) ||             \ | ||||||
|  |         IF_TYPE_MATCH(obj, bool) ||               \ | ||||||
|  |         IF_TYPE_MATCH(obj, char)) | ||||||
|  |  | ||||||
| #define OB_UNIS_ADD_LEN(obj)                                                                                        \ | #define OB_UNIS_ADD_LEN(obj)                                                                                        \ | ||||||
|   {                                                                                                                 \ |   {                                                                                                                 \ | ||||||
|     int64_t this_len = NS_::encoded_length(obj);                                                                    \ |     int64_t this_len = NS_::encoded_length(obj);                                                                    \ | ||||||
|     if (!(std::is_same<uint8_t, decltype(obj)>::value || std::is_same<int8_t, decltype(obj)>::value ||              \ |     if (IF_NEED_TO_CHECK_SERIALIZATION(obj)) {                                                                      \ | ||||||
|             std::is_same<bool, decltype(obj)>::value || std::is_same<char, decltype(obj)>::value)) {                \ |       if (oceanbase::lib::CHECK_STATUS_RECORDING == oceanbase::lib::ser_diag_record.flag &&                         \ | ||||||
|       if (1 == oceanbase::lib::ser_diag_record.flag &&                                                              \ |  | ||||||
|           oceanbase::lib::ser_diag_record.count < oceanbase::lib::MAX_SERIALIZE_RECORD_LENGTH) {                    \ |           oceanbase::lib::ser_diag_record.count < oceanbase::lib::MAX_SERIALIZE_RECORD_LENGTH) {                    \ | ||||||
|         oceanbase::lib::ser_diag_record.encoded_lens[oceanbase::lib::ser_diag_record.count++] =                     \ |         oceanbase::lib::ser_diag_record.encoded_lens[oceanbase::lib::ser_diag_record.count++] =                     \ | ||||||
|             static_cast<uint8_t>(this_len);                                                                         \ |             static_cast<uint8_t>(this_len);                                                                         \ | ||||||
|       } else if (2 == oceanbase::lib::ser_diag_record.flag &&                                                       \ |       } else if (oceanbase::lib::CHECK_STATUS_COMPARING == oceanbase::lib::ser_diag_record.flag &&                  \ | ||||||
|                  oceanbase::lib::ser_diag_record.check_index < oceanbase::lib::ser_diag_record.count) {             \ |                  oceanbase::lib::ser_diag_record.check_index < oceanbase::lib::ser_diag_record.count) {             \ | ||||||
|         int ret = OB_ERR_UNEXPECTED;                                                                                \ |         int ret = OB_ERR_UNEXPECTED;                                                                                \ | ||||||
|         int record_len = oceanbase::lib::ser_diag_record.encoded_lens[oceanbase::lib::ser_diag_record.check_index]; \ |         int record_len = oceanbase::lib::ser_diag_record.encoded_lens[oceanbase::lib::ser_diag_record.check_index]; \ | ||||||
|         if (this_len != record_len) {                                                                               \ |         if (this_len != record_len) {                                                                               \ | ||||||
|           OB_LOG(ERROR, "encoded length not match", "name", MSTR(obj), K(this_len), K(record_len), K(obj));                 \ |           OB_LOG(ERROR, "encoded length not match", "name", MSTR(obj), K(this_len), K(record_len), "value", obj);   \ | ||||||
|         }                                                                                                           \ |         }                                                                                                           \ | ||||||
|         oceanbase::lib::ser_diag_record.check_index++;                                                              \ |         oceanbase::lib::ser_diag_record.check_index++;                                                              \ | ||||||
|       }                                                                                                             \ |       }                                                                                                             \ | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ | |||||||
| #include <gtest/gtest.h> | #include <gtest/gtest.h> | ||||||
| #include <iostream> | #include <iostream> | ||||||
| #include <cstdlib> | #include <cstdlib> | ||||||
|  | #include "lib/utility/ob_print_utils.h"                // TO_STRING_KV | ||||||
| #include "lib/utility/ob_unify_serialize.h" | #include "lib/utility/ob_unify_serialize.h" | ||||||
| #include "lib/random/ob_random.h" | #include "lib/random/ob_random.h" | ||||||
|  |  | ||||||
| @ -73,6 +74,7 @@ struct CVirtualTest { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| struct CEmptyTest { | struct CEmptyTest { | ||||||
|  |   TO_STRING_KV(KP(this)); | ||||||
|   OB_UNIS_VERSION(1); |   OB_UNIS_VERSION(1); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @ -165,6 +167,7 @@ public: | |||||||
|   uint32_t vu32_; |   uint32_t vu32_; | ||||||
|   int64_t vi64_; |   int64_t vi64_; | ||||||
|   uint64_t vu64_; |   uint64_t vu64_; | ||||||
|  |   TO_STRING_KV(K_(b), K_(vi8), K_(vu8), K_(vi16), K_(vu16), K_(vi32), K_(vu32), K_(vi64), K_(vu64)); | ||||||
| }; // end of class TestObUnifySerialize | }; // end of class TestObUnifySerialize | ||||||
|  |  | ||||||
| OB_SERIALIZE_MEMBER(CIntTest, b_, vi8_, vu8_, vi16_, vu16_, vi32_, vu32_, vi64_, vu64_); | OB_SERIALIZE_MEMBER(CIntTest, b_, vi8_, vu8_, vi16_, vu16_, vi32_, vu32_, vi64_, vu64_); | ||||||
| @ -220,7 +223,7 @@ public: | |||||||
|     n.buf_[rlen] = 0; |     n.buf_[rlen] = 0; | ||||||
|     return n; |     return n; | ||||||
|   } |   } | ||||||
|  |   TO_STRING_KV(K_(buf)); | ||||||
| private: | private: | ||||||
|   char buf_[32]; |   char buf_[32]; | ||||||
| }; | }; | ||||||
| @ -268,6 +271,7 @@ public: | |||||||
|     } |     } | ||||||
|     return right; |     return right; | ||||||
|   } |   } | ||||||
|  |   TO_STRING_KV(K_(ia), K_(uia), K_(i64a), K_(ui64a), K_(ita)); | ||||||
|  |  | ||||||
|   static const CArrayTest RAND() |   static const CArrayTest RAND() | ||||||
|   { |   { | ||||||
| @ -318,7 +322,7 @@ public: | |||||||
|  |  | ||||||
|     return et; |     return et; | ||||||
|   } |   } | ||||||
|  |   TO_STRING_KV(K(eval)); | ||||||
| private: | private: | ||||||
|   enum Eval { E0, E1, E2, E3, EMAX } eval; |   enum Eval { E0, E1, E2, E3, EMAX } eval; | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -53,7 +53,8 @@ public: | |||||||
|   ObString location_; |   ObString location_; | ||||||
|   ObString pattern_; |   ObString pattern_; | ||||||
|   sql::ObExprRegexpSessionVariables regexp_vars_; |   sql::ObExprRegexpSessionVariables regexp_vars_; | ||||||
|   TO_STRING_KV(K_(location)); | public: | ||||||
|  |   TO_STRING_KV(K_(location), K_(pattern), K_(regexp_vars)); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class ObLoadExternalFileListRes | class ObLoadExternalFileListRes | ||||||
|  | |||||||
| @ -30,6 +30,7 @@ namespace sql | |||||||
| { | { | ||||||
|  |  | ||||||
| struct ObExprRegexpSessionVariables { | struct ObExprRegexpSessionVariables { | ||||||
|  |   TO_STRING_KV(K_(regexp_stack_limit), K_(regexp_time_limit)); | ||||||
|   ObExprRegexpSessionVariables(): |   ObExprRegexpSessionVariables(): | ||||||
|     regexp_stack_limit_(0), |     regexp_stack_limit_(0), | ||||||
|     regexp_time_limit_(0) |     regexp_time_limit_(0) | ||||||
|  | |||||||
| @ -77,6 +77,7 @@ public: | |||||||
|   // and we should fill (min, max) for c3 |   // and we should fill (min, max) for c3 | ||||||
|   ObFixedArray<int64_t, common::ObIAllocator> prefix_col_idxs_; |   ObFixedArray<int64_t, common::ObIAllocator> prefix_col_idxs_; | ||||||
|   ObFixedArray<ObObjMeta, common::ObIAllocator> prefix_col_obj_metas_; |   ObFixedArray<ObObjMeta, common::ObIAllocator> prefix_col_obj_metas_; | ||||||
|  |   TO_STRING_KV(K_(table_id), K_(range_column_cnt), K_(prefix_col_idxs), K_(prefix_col_obj_metas)); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } //end name space sql | } //end name space sql | ||||||
|  | |||||||
| @ -205,6 +205,7 @@ public: | |||||||
|     inline int add_row(ObCompactRow *new_row, int64_t row_size); |     inline int add_row(ObCompactRow *new_row, int64_t row_size); | ||||||
|     int create_and_add_row(const common::ObIArray<ObExpr *> &exprs, const RowMeta &row_meta, |     int create_and_add_row(const common::ObIArray<ObExpr *> &exprs, const RowMeta &row_meta, | ||||||
|         const int64_t row_size, ObEvalCtx &ctx, ObCompactRow *&new_row, uint64_t hash_val); |         const int64_t row_size, ObEvalCtx &ctx, ObCompactRow *&new_row, uint64_t hash_val); | ||||||
|  |     TO_STRING_KV(K(get_row_cnt()), K_(row_sizes), K_(serial_rows)) | ||||||
|   private: |   private: | ||||||
|     common::ObIAllocator &allocator_; |     common::ObIAllocator &allocator_; | ||||||
|     ObSArray<ObCompactRow *> serial_rows_; |     ObSArray<ObCompactRow *> serial_rows_; | ||||||
|  | |||||||
| @ -487,6 +487,7 @@ protected: | |||||||
|     struct COMPAT_FOR_EXEC { |     struct COMPAT_FOR_EXEC { | ||||||
|       uint64_t v_; |       uint64_t v_; | ||||||
|       uint64_t get_serialize_v_() const; |       uint64_t get_serialize_v_() const; | ||||||
|  |       TO_STRING_KV(K_(v)); | ||||||
|       NEED_SERIALIZE_AND_DESERIALIZE; |       NEED_SERIALIZE_AND_DESERIALIZE; | ||||||
|     } compat_for_exec_; |     } compat_for_exec_; | ||||||
|     struct |     struct | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 zhjc1124
					zhjc1124