Search code examples
mongodbmongorestore

"An existing connection was forcibly closed by the remote host" while executing mongorestore on localhost


What I have:

  1. Mongodb 3.0.2 running on localhost (Windows 7 Pro)
  2. Local .bson file (~60GB)
  3. 32 GB RAM

What I do:

C:\Program Files\MongoDB\Server\3.0\bin>mongorestore --collection collection_name --db db_name F:\path_to_bson\archive.bson

Result:

  1. 100% RAM utilization when 30% is done
  2. A lot of errors like this: "error: WSARecv tcp 127.0.0.1:49587: An existing connection was forcibly closed by the remote host." appear when ~60% is done
  3. Not all documents restored as result.

If I use another archive to restore (which is smaller, ~ 6GB) - it is OK

Question: How to get all documents restored from .bson ? Thanks in advance.


Solution

  • I was having this problem on windows a moment ago (client and server on same machine). Same code works fine on Linux.

    I got around the problem by decreasing the number of items inserted / updated per bulk operation.

    I'm doing this in an app. I don't see an option in mongorestore docs for reducing per bulk operation entry count.