Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB dump from 3.2, restore with 3.4, error index safe = null

I get the following error (dump MongoDB 3.2) (restore MongoDB 3.4):

Failed: ngivr-dev.ledgerhelpers: error creating indexes for ngivr-dev.ledgerhelpers: **createIndex error:** **The field 'safe' is not valid for an index specification.** Specification: **{ unique: true, name: "ledgerId_1", safe: null, ns: "ngivr-dev.ledgerhelpers", background: true, key: { ledgerId: 1 } }** 

Looks like the safe index is null. But how can i use it with MongoDB 3.4? 3.2 is ok.

like image 213
Patrik Laszlo Avatar asked Dec 08 '16 09:12

Patrik Laszlo


2 Answers

safe=true is not an index specification.

In previous versions of MongoDB, lower than 3.4, extra indexes specifications can be added. Those were used by specific drivers.

In 3.4, mongodb added a validation on indexes specification:

Ensuring that the specified index options are valid. Previous versions ignored invalid options.

That's why you have this error. I am afraid you need to ensure that the index in your 3.2 version does not have invalid index specificaitons, and after that do the mongodump.

As kz_sergey says in his answer, you can mongorestore using --noIndexRestore, that should work fine.

like image 69
sergiuz Avatar answered Oct 10 '22 08:10

sergiuz


Why do you restore indexes? --noIndexRestore and create them again.

like image 23
kz_sergey Avatar answered Oct 10 '22 07:10

kz_sergey