Mongodump randomly throwing CursorNotFound

Hi everyone,
I have been using mongodump in order to backup my entire db. I do it once a day.
However, since switching to mongodb 4.2.2 I have been having random errors on my backup job:

Failed: archive writer: error writing data for collection geo.geos to disk: error reading collection: (CursorNotFound) cursor id 7535000083817651709 not found / Mux ending but selectCases still open 3
Some days it will work, others it won’t at all. The crash will occur on different collections everytime, I cannot understand what is happening.
Do you have any idea ?

For more context here is my stack: I run mongodb 4.2.2 in a replicaset inside a kubernetes cluster.
I use a kubernetes scheduled job that launches a simple shell script:
Here is the information of mongorestore inside the container

mongorestore version: r4.2.2
git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
Go version: go1.12.13
os: linux
arch: amd64
compiler: gc

Thanks for your help

Hi Andre
I’m having exactly the same issue, did you find the reason?

Hi David,
No I haven’t found the solution yet. However I think the issue might be coming from the fact that mongodump seems to be accessing all the members of my replicaset. From what I read it should only access the primary member of the replicaset.
I doing a few tests. I will post a comment if I ever found what’s going on.

Hi David,
So as I exposed the other day I have found the solution. Because I was using a kubernetes service to access my replicaset, mongodump requests were being redirected to all the members of the replicaset and not only the master one.
All I did was point mongodump directly to the master and since then all the backups have been working fine.
Hope it helps you


Thank you very much @Andre_Paulos! I will use this approach too :slight_smile:

Thank you. You saved my date. I finally worked when I tried to use directly the podId of Mongodb Primary node in my StatefulSet, something like this:

 mongodump --gzip --host --port 27017 ...