Hi guys, we needed to duplicate a legacy meteorJS app recently, onto a new server and a new database.
So we cloned the server, created a new database and pointed the cloned server to the new database.
The meteorJS app works, everything appears fine.
However we noticed that the logs is showing error like MongoError: no primary server available, everytime when restarting:
2024-02-01T06:37:06.151478+00:00 heroku[web.1]: Restarting
2024-02-01T06:37:06.217824+00:00 heroku[web.1]: State changed from up to starting
2024-02-01T06:37:06.969254+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2024-02-01T06:37:07.074219+00:00 heroku[web.1]: Process exited with status 143
2024-02-01T06:37:45.658856+00:00 heroku[web.1]: Starting process with command `.meteor/heroku_build/bin/node $NODEJS_PARAMS .meteor/heroku_build/app/main.js`
2024-02-01T06:38:00.149936+00:00 app[web.1]: Got exception while polling query MongoError: no primary server available
2024-02-01T06:38:00.149991+00:00 app[web.1]: at ReplSetState.pickServer (/app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/topologies/replset_state.js:780:12)
2024-02-01T06:38:00.149991+00:00 app[web.1]: at Timeout._selectServer [as _onTimeout] (/app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/topologies/replset.js:1142:43)
2024-02-01T06:38:00.149992+00:00 app[web.1]: at listOnTimeout (internal/timers.js:549:17)
2024-02-01T06:38:00.149992+00:00 app[web.1]: at processTimers (internal/timers.js:492:7)
2024-02-01T06:38:00.149993+00:00 app[web.1]: => awaited here:
2024-02-01T06:38:00.149993+00:00 app[web.1]: at Function.Promise.await (/app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)
2024-02-01T06:38:00.149994+00:00 app[web.1]: at packages/mongo/mongo_driver.js:1073:14
2024-02-01T06:38:00.149994+00:00 app[web.1]: at /app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40
2024-02-01T06:38:00.149994+00:00 app[web.1]: => awaited here:
2024-02-01T06:38:00.149995+00:00 app[web.1]: at Promise.await (/app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:60:12)
2024-02-01T06:38:00.149995+00:00 app[web.1]: at SynchronousCursor._nextObject (packages/mongo/mongo_driver.js:1122:38)
2024-02-01T06:38:00.149995+00:00 app[web.1]: at SynchronousCursor.forEach (packages/mongo/mongo_driver.js:1136:22)
2024-02-01T06:38:00.149995+00:00 app[web.1]: at Cursor.<computed> [as forEach] (packages/mongo/mongo_driver.js:918:44)
2024-02-01T06:38:00.149996+00:00 app[web.1]: at OplogObserveDriver._runQuery (packages/mongo/oplog_observe_driver.js:729:16)
2024-02-01T06:38:00.149996+00:00 app[web.1]: at OplogObserveDriver._runInitialQuery (packages/mongo/oplog_observe_driver.js:658:10)
2024-02-01T06:38:00.149996+00:00 app[web.1]: at packages/mongo/oplog_observe_driver.js:191:10
2024-02-01T06:38:00.149996+00:00 app[web.1]: at packages/mongo/oplog_observe_driver.js:15:9
2024-02-01T06:38:00.149997+00:00 app[web.1]: at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
2024-02-01T06:38:00.149997+00:00 app[web.1]: at packages/meteor.js:550:25
2024-02-01T06:38:00.149997+00:00 app[web.1]: at runWithEnvironment (packages/meteor.js:1286:24) {
2024-02-01T06:38:00.149997+00:00 app[web.1]: name: 'MongoError',
2024-02-01T06:38:00.149997+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2024-02-01T06:38:00.149998+00:00 app[web.1]: }
So it appears that oplogs may not be working on the new server. Since the server shares the exact same codebase, we thought it must be something related to the new database. But we couldn’t be sure what was wrong as we were not the one who configured the oplog in the legacy original server.
Both the old and new servers has the following environment variables configured:
OLD SERVER
MONGO_OPLOG_URL
mongodb+srv://user:password@oldclusterxxx.gogvv.mongodb.net/local
MONGO_URL
mongodb+srv://user:password@oldclusterxxx.gogvv.mongodb.net/database_name
NEW SERVER
MONGO_OPLOG_URL
mongodb+srv://user:password@newclusteryyy.gogvv.mongodb.net/local
MONGO_URL
mongodb+srv://user:password@newclusteryyy.gogvv.mongodb.net/databse_name
Also checked the networking IP address restrictions, which has no restrict so we can rule out the possibilities that the new database has IP restrictions.
So what could be the problem in the new database that causes this MongoError: no primary server available in oplog operations?
OLD APP
MongoDB 4.4.28
Meteor 1.10.2
mongo@1.10.0
NEW APP
MongoDB 5.0.24
Meteor 1.10.2
mongo@1.10.0