23
23
#include " lib/alloc/alloc_assist.h"
24
24
#include " lib/alloc/abit_set.h"
25
25
#include " lib/allocator/ob_mod_define.h"
26
+ #include " lib/list/ob_dlink_node.h"
26
27
27
28
#ifndef NDEBUG
28
29
#define MEMCHK_LEVEL 1
@@ -119,15 +120,24 @@ struct ObLabel
119
120
const char *str_;
120
121
};
121
122
123
+ struct ObMemVersionNode : public ObDLinkBase <ObMemVersionNode>
124
+ {
125
+ static uint32_t global_version;
126
+ static __thread bool tl_ignore_node;
127
+ static __thread ObMemVersionNode* tl_node;
128
+ uint32_t version_ = UINT32_MAX;
129
+ };
130
+
122
131
struct ObMemAttr
123
132
{
124
- friend ObMemAttr DoNotUseMe (ObMemAttr &attr, bool expect_500);
133
+ friend ObMemAttr DoNotUseMe (ObMemAttr &attr);
134
+ friend ObMemAttr UseUnexpected500 (ObMemAttr &attr);
135
+ friend ObMemAttr IgnoreVersion (ObMemAttr &attr);
125
136
uint64_t tenant_id_;
126
137
ObLabel label_;
127
138
uint64_t ctx_id_;
128
139
uint64_t sub_ctx_id_;
129
140
ObAllocPrio prio_;
130
-
131
141
explicit ObMemAttr (
132
142
uint64_t tenant_id = common::OB_SERVER_TENANT_ID,
133
143
ObLabel label = ObLabel(),
@@ -137,42 +147,73 @@ struct ObMemAttr
137
147
label_(label),
138
148
ctx_id_(ctx_id),
139
149
sub_ctx_id_(ObSubCtxIds::MAX_SUB_CTX_ID),
140
- prio_(prio) {}
150
+ prio_(prio),
151
+ use_500_(false ),
152
+ expect_500_(true ),
153
+ ignore_version_(ObMemVersionNode::tl_ignore_node)
154
+ {}
141
155
int64_t to_string (char * buf, const int64_t buf_len) const ;
142
156
bool use_500 () const { return use_500_; }
143
157
bool expect_500 () const { return expect_500_; }
158
+ bool ignore_version () const { return ignore_version_; }
144
159
private:
145
- bool use_500_ = false ;
146
- bool expect_500_ = true ;
160
+ union {
161
+ char padding__[4 ];
162
+ struct {
163
+ struct {
164
+ uint8_t use_500_ : 1 ;
165
+ uint8_t expect_500_ : 1 ;
166
+ uint8_t ignore_version_ : 1 ;
167
+ };
168
+ };
169
+ };
147
170
};
148
171
149
- inline ObMemAttr DoNotUseMe (ObMemAttr &attr, bool expect_500 )
172
+ inline ObMemAttr DoNotUseMe (ObMemAttr &attr)
150
173
{
151
174
attr.use_500_ = true ;
152
- attr.expect_500_ = expect_500 ;
175
+ attr.ignore_version_ = true ;
153
176
return attr;
154
177
}
155
178
156
- inline ObMemAttr DoNotUseMe ( const ObMemAttr && attr, const bool expect_500 )
179
+ inline ObMemAttr UseUnexpected500 ( ObMemAttr &attr)
157
180
{
158
- ObMemAttr attr_cpy = attr;
159
- return DoNotUseMe (attr_cpy, expect_500);
181
+ attr.use_500_ = true ;
182
+ attr.expect_500_ = false ;
183
+ attr.ignore_version_ = true ;
184
+ return attr;
160
185
}
161
186
162
- inline ObMemAttr DoNotUseMe ( const ObLabel &label, const bool expect_500 )
187
+ inline ObMemAttr IgnoreVersion (ObMemAttr &attr )
163
188
{
164
- ObMemAttr attr (OB_SERVER_TENANT_ID, label) ;
165
- return DoNotUseMe ( attr, expect_500) ;
189
+ attr. ignore_version_ = true ;
190
+ return attr;
166
191
}
167
192
168
- inline ObMemAttr DoNotUseMe (const ObLabel &label, const uint64_t ctx_id, const bool expect_500)
169
- {
170
- ObMemAttr attr (OB_SERVER_TENANT_ID, label, ctx_id);
171
- return DoNotUseMe (attr, expect_500);
172
- }
193
+ #define ObMemAttrFriendFunc (func_name ) \
194
+ inline ObMemAttr func_name (const ObMemAttr &&attr) \
195
+ { \
196
+ ObMemAttr attr_cpy = attr; \
197
+ return func_name (attr_cpy); \
198
+ } \
199
+ inline ObMemAttr func_name (const ObLabel &label) \
200
+ { \
201
+ ObMemAttr attr (OB_SERVER_TENANT_ID, label); \
202
+ return func_name (attr); \
203
+ } \
204
+ inline ObMemAttr func_name (const ObLabel &label, const uint64_t ctx_id) \
205
+ { \
206
+ ObMemAttr attr (OB_SERVER_TENANT_ID, label, ctx_id); \
207
+ return func_name (attr); \
208
+ }
209
+
210
+ ObMemAttrFriendFunc (DoNotUseMe);
211
+ ObMemAttrFriendFunc (UseUnexpected500);
212
+ ObMemAttrFriendFunc (IgnoreVersion);
173
213
174
- #define SET_USE_500 (args... ) ::oceanbase::lib::DoNotUseMe(args, true )
175
- #define SET_USE_UNEXPECTED_500 (args... ) ::oceanbase::lib::DoNotUseMe(args, false )
214
+ #define SET_USE_500 (args... ) ::oceanbase::lib::DoNotUseMe(args)
215
+ #define SET_USE_UNEXPECTED_500 (args... ) ::oceanbase::lib::UseUnexpected500(args)
216
+ #define SET_IGNORE_MEM_VERSION (args... ) ::oceanbase::lib::IgnoreVersion(args)
176
217
177
218
struct AllocHelper
178
219
{
@@ -274,16 +315,18 @@ struct AObject {
274
315
uint16_t obj_offset_;
275
316
276
317
uint32_t alloc_bytes_;
277
- uint64_t tenant_id_ ;
318
+ uint32_t version_ ;
278
319
char label_[AOBJECT_LABEL_SIZE + 1 ];
279
320
280
321
// padding to ensure data_ is 16x offset
281
322
union {
282
- char padding__[4 ];
323
+ char padding__[16 ];
283
324
struct {
284
325
struct {
285
326
uint8_t on_leak_check_ : 1 ;
286
327
uint8_t on_malloc_sample_ : 1 ;
328
+ uint8_t ignore_version_ : 1 ;
329
+
287
330
};
288
331
};
289
332
};
@@ -522,8 +565,7 @@ char *ABlock::data() const
522
565
AObject::AObject ()
523
566
: MAGIC_CODE_(FREE_AOBJECT_MAGIC_CODE),
524
567
nobjs_ (0 ), nobjs_prev_(0 ), obj_offset_(0 ),
525
- alloc_bytes_(0 ), tenant_id_(0 ),
526
- on_leak_check_(false ), on_malloc_sample_(false )
568
+ alloc_bytes_(0 ), on_leak_check_(false ), on_malloc_sample_(false )
527
569
{
528
570
}
529
571
0 commit comments