Copying a entire database to other host with secondary preferred gets index error

Lucas Soares shared this problem 5 years ago
Not a Problem


I was trying to copy a entire database (with 6 collections) but all my connections are made with secondary preferred read preference. All documents got copied, but all indexes failed to build with this error:

#script:137:25  	+537.359s
{ MongoError: not master
    at C:\Users\lucas\AppData\Local\Programs\nosqlbooster4mongo\resources\app.asar\node_modules\mongodb-core\lib\connection\pool.js:580:63
    at authenticateStragglers (C:\Users\lucas\AppData\Local\Programs\nosqlbooster4mongo\resources\app.asar\node_modules\mongodb-core\lib\connection\pool.js:503:16)
    at Connection.messageHandler (C:\Users\lucas\AppData\Local\Programs\nosqlbooster4mongo\resources\app.asar\node_modules\mongodb-core\lib\connection\pool.js:539:5)
    at emitMessageHandler (C:\Users\lucas\AppData\Local\Programs\nosqlbooster4mongo\resources\app.asar\node_modules\mongodb-core\lib\connection\connection.js:309:10)
    at TLSSocket.<anonymous> (C:\Users\lucas\AppData\Local\Programs\nosqlbooster4mongo\resources\app.asar\node_modules\mongodb-core\lib\connection\connection.js:452:17)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at TLSSocket.Readable.push (_stream_readable.js:197:10)
    at TLSWrap.onread (net.js:589:20)
  name: 'MongoError',
  message: 'not master',
  ok: 0,
  errmsg: 'not master',
  code: 10107,
  codeName: 'NotMaster',
  [Symbol(mongoErrorContextSymbol)]: {} }

Replies (3)


Apparently with primary preferred read preference the same issue occurs. With primary all indexes have been copied.


This should not be considered a problem, it should belong to the normal program error handling.

issuing db.collection.createIndex() on the primary for a replica set



Why this should not be considered a problem?

I used the primary preferred read preference too and got the same error. I should be available to ensure indexes with primary preferred read preference, shouldn't I?

If this is a normal execution even so, thank you and got it!

Leave a Comment
Attach a file