Skip to content

Commit 80ddc47

Browse files
obdevwyfanxiaoxiebaoma
authored andcommitted
fix: deserialize snap data
Co-authored-by: wyfanxiao <wyfanxiao@163.com> Co-authored-by: xiebaoma <2402583447@qq.com>
1 parent 80b1279 commit 80ddc47

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

src/share/vector_index/ob_plugin_vector_index_adaptor.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,17 @@ int ObVectorQueryAdaptorResultContext::init_bitmaps()
198198
if (OB_ISNULL(tmp_allocator_)) {
199199
ret = OB_INVALID_ARGUMENT;
200200
LOG_WARN("ctx allocator invalid.", K(ret));
201+
} else if (OB_NOT_NULL(bitmaps_)) {
202+
// bitmap has already been initialized
201203
} else {
202204
ObVectorIndexRoaringBitMap *bitmaps = nullptr;
203205
if (OB_ISNULL(bitmaps = static_cast<ObVectorIndexRoaringBitMap*>
204206
(tmp_allocator_->alloc(sizeof(ObVectorIndexRoaringBitMap))))) {
205207
ret = OB_ALLOCATE_MEMORY_FAILED;
206208
LOG_WARN("failed to create vbitmap msg", K(ret));
207209
} else {
210+
bitmaps->insert_bitmap_ = nullptr;
211+
bitmaps->delete_bitmap_ = nullptr;
208212
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(tenant_id_, "VIBitmapADPC"));
209213
ROARING_TRY_CATCH(bitmaps->insert_bitmap_ = roaring::api::roaring64_bitmap_create());
210214
if (OB_SUCC(ret) && OB_ISNULL(bitmaps->insert_bitmap_)) {
@@ -221,7 +225,25 @@ int ObVectorQueryAdaptorResultContext::init_bitmaps()
221225
bitmaps->delete_bitmap_ = nullptr;
222226
}
223227
}
224-
bitmaps_ = bitmaps;
228+
if (OB_FAIL(ret)) {
229+
if (OB_NOT_NULL(bitmaps)) {
230+
if (OB_NOT_NULL(bitmaps->insert_bitmap_)) {
231+
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(tenant_id_, "VIBitmapADPA"));
232+
roaring::api::roaring64_bitmap_free(bitmaps->insert_bitmap_);
233+
bitmaps->insert_bitmap_ = nullptr;
234+
}
235+
if (OB_NOT_NULL(bitmaps->delete_bitmap_)) {
236+
lib::ObMallocHookAttrGuard malloc_guard(lib::ObMemAttr(tenant_id_, "VIBitmapADPB"));
237+
roaring::api::roaring64_bitmap_free(bitmaps->delete_bitmap_);
238+
bitmaps->delete_bitmap_ = nullptr;
239+
}
240+
tmp_allocator_->free(bitmaps);
241+
bitmaps = nullptr;
242+
}
243+
bitmaps_ = nullptr;
244+
} else {
245+
bitmaps_ = bitmaps;
246+
}
225247
}
226248
return ret;
227249
}
@@ -4166,7 +4188,17 @@ int ObPluginVectorIndexAdaptor::query_result(ObLSID &ls_id,
41664188
LOG_INFO("query result need refresh adapter, ls leader",
41674189
K(ret), K(ls_id), K(ctx->get_ls_leader()), K(snapshot_tablet_id_), K(get_snapshot_key_prefix()), K(row->storage_datums_[0].get_string()));
41684190
} else if (OB_FAIL(deserialize_snap_data(query_cond, row))) {
4169-
LOG_WARN("failed to deserialize snap data", K(ret));
4191+
if (ret == OB_ERR_VSAG_RETURN_ERROR) {
4192+
// snapshot data may be transiently incomplete under concurrent DDL/DML;
4193+
// trigger refresh path and let upper layer retry with refreshed memdata.
4194+
ctx->status_ = PVQ_REFRESH;
4195+
ret = OB_SUCCESS;
4196+
LOG_INFO("deserialize snap data got vsag transient error, mark refresh",
4197+
K(ls_id), K(snapshot_tablet_id_), K(get_snapshot_key_prefix()),
4198+
K(row->storage_datums_[0].get_string()));
4199+
} else {
4200+
LOG_WARN("failed to deserialize snap data", K(ret));
4201+
}
41704202
}
41714203
}
41724204
}

0 commit comments

Comments
 (0)