Add BatchSize parameter to MongoDB source to prevent cursor timeouts on large collections#234
Add BatchSize parameter to MongoDB source to prevent cursor timeouts on large collections#234
Conversation
…rrors Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
|
@copilot Is this a good solution for largo MongoDB collecitons? Does the MongoDB drive/sdk support this scenario already? |
Yes, this is a good solution for large MongoDB collections. The MongoDB C# driver (v2.30.0) natively supports the How it works:
Why this solves the problem:
Alternative approaches considered:
The implementation follows MongoDB best practices and leverages native driver functionality. |
|
@markjbrown / @bowencode , this is an older issue, but it enables a scenario where there's large data coming from MongoDB. It allows the user to specify the BatchSize against the source. dmt already supported against the sink. |
Migrating MongoDB collections with 250k+ documents fails with
MongoCursorNotFoundExceptionbecause cursors timeout before all documents are fetched.Changes
BatchSizeproperty to control documents per batchFindAsyncto applyBatchSizeviaFindOptionswhen specifiedFindAsyncwith batch size support (previously unfiltered reads usedAsQueryable()which doesn't support batching)Usage
{ "ConnectionString": "mongodb://localhost:27017", "DatabaseName": "mydb", "Collection": "large_collection", "BatchSize": 1000 }If not specified, MongoDB's default batch size applies. Negative or zero values are silently ignored to prevent migration failures.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.