Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mongolink/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,16 @@ func (c *Clone) cloneCollection(ctx context.Context, db, coll string) error {
}()

const initialBufferSize = 1000
const maxBufferSize = 10000
docs := make([]any, 0, initialBufferSize)
batch := 1
batchSize := 0

targetColl := c.target.Database(db).Collection(spec.Name)

for cur.Next(ctx) {
if batchSize+len(cur.Current) > config.MaxCollectionCloneBatchSize {
if batchSize+len(cur.Current) > config.MaxCollectionCloneBatchSize ||
len(docs) == maxBufferSize {
_, err = targetColl.InsertMany(ctx, docs)
if err != nil {
return errors.Wrap(err, "insert documents")
Expand Down
Loading