Database Mystery (Mongo)
-
@baris My highest ID as category was 17, and when I created a new one, the ID was 11. So I created fake categories to get up to number 18 and the category was finally empty when I created it. But as soon as I posted a new topic inside, old posts where linked to this first new post.
When I did the mongorestore should I have dropped the existing database (it was empty and only had the admin user account)?Here is what I get
> db.objects.findOne({_key: "global"}); { "_id" : ObjectId("5dd298e8eb7500a3dd086e72"), "_key" : "global", "nextEid" : 202, "nextCid" : 18, "nextUid" : 1, "userCount" : 1, "nextTid" : 18, "topicCount" : 15, "nextPid" : 24, "postCount" : 3574, "uniqueIPCount" : 16, "nextNsEmbedRule" : 7, "nextPollId" : 1 }
-
It looks like I was right and your database didn't have the global object. It shows nextUid as 1 which isn't correct. Do you have a back up of your database before upgrade? You can restore it into another database and check the correct global object.
-
@baris you're the man! Thanks so much for taking the time and your help.
This is the result on my snapsnot for my fresh install of nodebb v1.10.1 and with only the mongorestore on it.
Not better, I'm afraid...> db.objects.findOne({_key: "global"}); { "_id" : ObjectId("5dd298e8eb7500a3dd086e72"), "_key" : "global", "nextEid" : 84, "nextCid" : 4, "nextUid" : 1, "userCount" : 1, "nextTid" : 1, "topicCount" : 0, "nextPid" : 1, "postCount" : -1, "uniqueIPCount" : 11 }
-
Did you mongorestore to the same database or a different one?
-
@PitaJ Hi PitaJ, I'm afraid that I don't have anymore the original Nodebb setup. Before I was centOS and Mongo and with a nodeBB on v1.10.1.
Now I started a new droplet on DigitalOcean with Ubuntu and Mongo. I only have my Mongo dump left for my old setup.
So to answer your question this is a mongorestore in a new database. -
Also, did you run
./nodebb setup
before or after the restore?I think what baris was saying is to setup a fresh nodebb with database
foo
, mongorestore to databasenodebb
, and then change the DB name in config.json to point to the latter -
@PitaJ ok I see what you mean.
I followed this https://www.rosehosting.com/blog/how-to-install-nodebb-on-ubuntu-18-04/
I created a new database on this new setup when everything was up and running, I did the mongorestore into that new database then did a./nodebb setup
and then proceed with the update to v1.12.2.
I tried to set up a new nodeBB with a regular database, dump the old one into another database and do the switch in the config.json then. -
@PitaJ Did a new setup with database1, created database 2, did a mongorestore on database 2, changed the config.json to switch to database2 and now I'm trying to run
./nodebb setup
but I get the following messageIndex with name: _key_1_value_-1 already exists with different options
MongoError: Index with name: _key_1_value_-1 already exists with different options at /var/www/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:598:61 at authenticateStragglers (/var/www/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:516:16) at Connection.messageHandler (/var/www/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:552:5) at emitMessageHandler (/var/www/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:309:10) at Socket.<anonymous> (/var/www/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:452:17) at Socket.emit (events.js:198:13) at addChunk (_stream_readable.js:287:12) at readableAddChunk (_stream_readable.js:268:11) at Socket.Readable.push (_stream_readable.js:223:10) at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
-
No you don't need to run
./nodebb setup
more than once. Just switch to database 2 and restart.