Skip to content

Commit 30141bc

Browse files
committed
changes for review. upsertWithRetry function used in the batchProcess function
1 parent e41ade5 commit 30141bc

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

cmd/migrate_from_qdrant.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020
)
2121

2222
const (
23-
// MAX_RETRIES is the maximum number of retries for upsert operations on transient errors.
24-
MAX_RETRIES = 3
2523
// SAMPLE_SIZE_PER_WORKER is the number of points to sample per worker to determine ranges for parallel migration.
2624
SAMPLE_SIZE_PER_WORKER = 10
2725
)
@@ -356,19 +354,8 @@ func (r *MigrateFromQdrantCmd) processBatch(ctx context.Context, points []*qdran
356354
// Specify the shard key for the upsert request.
357355
req.ShardKeySelector = &qdrant.ShardKeySelector{ShardKeys: []*qdrant.ShardKey{shardKeyObjs[key]}}
358356
}
359-
var err error
360-
// Upsert with retries.
361-
// This is to handle Qdrant's transient consistency errors during parallel writes
362-
for attempt := 0; attempt < MAX_RETRIES; attempt++ {
363-
_, err = targetClient.Upsert(ctx, req)
364-
if err == nil || !strings.Contains(err.Error(), "Please retry") {
365-
break
366-
}
367-
// Exponential backoff for retries.
368-
time.Sleep(time.Duration(attempt+1) * 100 * time.Millisecond)
369-
}
370-
if err != nil {
371-
return fmt.Errorf("failed to insert data into target: %w", err)
357+
if err := upsertWithRetry(ctx, targetClient, req); err != nil {
358+
return err
372359
}
373360
}
374361
return nil

0 commit comments

Comments
 (0)