Iulian
03/10/2026, 7:27 AMkapa.ai
03/10/2026, 7:27 AMcopyTable function loads all documents into memory at once (without batching) when copying from the temporary collection to the permanent collection. With 4 million documents, this will cause a massive memory spike regardless of how much memory you allocate. [destination-mongodb OOM issue]
What's happening under the hood
The current code fetches all documents from the temp collection and inserts them into the permanent collection in one go, exhausting the JVM heap. The issue reporter proposed a fix using batched inserts: [destination-mongodb OOM issue]
private static void copyTable(final MongoDatabase mongoDatabase, final String collectionName, final String tmpCollectionName) {
final var tempCollection = mongoDatabase.getOrCreateNewCollection(tmpCollectionName);
final var collection = mongoDatabase.getOrCreateNewCollection(collectionName);
final int BATCH_SIZE = 1000;
final List<Document> batch = new ArrayList();
try (final MongoCursor<Document> cursor = tempCollection.find().projection(excludeId()).iterator()) {
while (cursor.hasNext()) {
batch.add(cursor.next());
if (batch.size() == BATCH_SIZE) {
collection.insertMany(new ArrayList(batch));
batch.clear();
}
}
if (!batch.isEmpty()) {
collection.insertMany(batch);
}
}
}
What you can do right now
Unfortunately, this is an open bug with no confirmed fix released yet. The workarounds available are limited:
1. Reduce batch size: Some users tried reducing the destination batch size (e.g., from 10,000 to 1,000), but reported it did not resolve the OOM issue during the copy phase. [destination-mongodb OOM issue]
2. Split your sync into smaller connections: You could create multiple connections targeting subsets of your data (e.g., by collection), which reduces the volume processed per sync job. [Source Postgres memory discussion]
3. Contribute the fix: The issue is open and the reporter has indicated willingness to contribute. If you have Java development experience, you could submit a pull request implementing the batched copyTable logic shown above. [destination-mongodb OOM issue]
In summary, simply increasing memory is not a solution because the problem is architectural ā the connector needs to be patched to use batched inserts during the copy phase. š 0 button š 0 button ā¹ļø Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.Iulian
03/10/2026, 9:35 AMkapa.ai
03/10/2026, 9:35 AMJOB_MAIN_CONTAINER_CPU_REQUEST=
JOB_MAIN_CONTAINER_CPU_LIMIT=
JOB_MAIN_CONTAINER_MEMORY_REQUEST=
JOB_MAIN_CONTAINER_MEMORY_LIMIT=
4. Split Into Multiple Connections
If your data spans multiple collections, splitting them into separate connections allows parallel syncing, which can reduce total wall-clock time. [sync performance tips]
5. Ensure Sufficient Kubernetes Resources
Make sure your Kubernetes cluster can schedule enough pods. A sync job uses two workers (one for source, one for destination), so ensure your cluster has headroom. [scaling Airbyte]
-------------------------
Important caveat: The knowledge sources do not explicitly confirm whether the MongoDB-to-MongoDB connector pair is among those covered by the faster sync speed initiative. You should verify this in the Airbyte documentation or changelog for your specific connector versions. š 0 button š 0 button ā¹ļø Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.