Skip to content

Commit ea05913

Browse files
committed
enh: qdrant_migrator retry capabilities
1 parent e7642bb commit ea05913

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

core/bin/qdrant_migrator.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,34 @@ fn main() -> Result<()> {
344344

345345
let mut page_offset: Option<PointId> = None;
346346
let mut total: usize = 0;
347+
let mut retry: usize = 0;
347348
loop {
348349
let now = utils::now();
349-
let scroll_results = qdrant_client
350+
let scroll_results = match qdrant_client
350351
.scroll(&ScrollPoints {
351352
collection_name: ds.qdrant_collection(),
352353
with_vectors: Some(true.into()),
353354
with_payload: Some(true.into()),
354355
limit: Some(points_per_request as u32),
355-
offset: page_offset,
356+
offset: page_offset.clone(),
356357
..Default::default()
357358
})
358-
.await?;
359+
.await
360+
{
361+
Ok(r) => r,
362+
Err(e) => {
363+
if retry < 3 {
364+
retry += 1;
365+
utils::error(&format!(
366+
"Error migrating points (read): retry={} error={:?}",
367+
retry, e
368+
));
369+
continue;
370+
} else {
371+
Err(e)?
372+
}
373+
}
374+
};
359375

360376
let count = scroll_results.result.len();
361377

@@ -371,9 +387,24 @@ fn main() -> Result<()> {
371387
})
372388
.collect::<Vec<_>>();
373389

374-
shadow_write_qdrant_client
390+
match shadow_write_qdrant_client
375391
.upsert_points(ds.qdrant_collection(), points, None)
376-
.await?;
392+
.await
393+
{
394+
Ok(_) => (),
395+
Err(e) => {
396+
if retry < 3 {
397+
retry += 1;
398+
utils::error(&format!(
399+
"Error migrating points (write): retry={} error={:?}",
400+
retry, e
401+
));
402+
continue;
403+
} else {
404+
Err(e)?
405+
}
406+
}
407+
}
377408

378409
total += count;
379410
utils::info(&format!(
@@ -387,6 +418,7 @@ fn main() -> Result<()> {
387418
if page_offset.is_none() {
388419
break;
389420
}
421+
retry = 0;
390422
}
391423

392424
utils::info(&format!("Done migrating: total={}", total));

0 commit comments

Comments
 (0)