zodern / meteor-up

Production Quality Meteor Deployment to Anywhere
http://meteor-up.com/
MIT License
1.28k stars 279 forks source link

Server at mongodb:27017 reports maximum wire version 5, but this version of the Node.js Driver requires at least 6 #1295

Open programthis opened 2 years ago

programthis commented 2 years ago

Mup version (mup --version): 1.5.5

Mup config

{
  "servers": {
    "one": {
      "host": "1.2.3.4",
      "username": "root",
      "password": "password"
    }
  },
  "proxy": {
    "domains": "host.com,subdomain.host.com",
    "ssl": {
      "letsEncryptEmail": "email@domain.com",
      "forceSSL": true
    }
  },
  "mongo": {
    "version": "3.4.1",
    "servers": {
      "one": {}
    },
    "dbName": "project_name"
  },
  "app": {
    "name": "my-app",
    "path": "../project_name",
    "volumes": {
      "/images": "/images"
    },
    "servers": {
      "one": {}
    },
    "buildOptions": {
      "serverOnly": true,
      "buildLocation": "/tmp/mup-meteor-46532786-03a5-4a6f-b9ab-8aac9105b59a",
      "cleanBuildLocation": true
    },
    "env": {
      "ROOT_URL": "https://host.com",
      "MONGO_URL": "mongodb://mongodb:27017/my-app",
      "VIRTUAL_HOST": "host.com,subdomain.host.com",
      "HTTPS_METHOD": "redirect",
      "LETSENCRYPT_HOST": "host.com,subdomain.host.com",
      "LETSENCRYPT_EMAIL": "email@domain.com",
      "VIRTUAL_PORT": 3000,
      "HTTP_FORWARDED_COUNT": 1
    },
    "docker": {
      "image": "zodern/meteor:latest",
      "stopAppDuringPrepareBundle": true,
      "imagePort": 3000,
      "args": [
        "--link=mongodb:mongodb"
      ]
    },
    "enableUploadProgressBar": true,
    "type": "meteor"
  }
}

Output of command

Started TaskList: Start Meteor
[159.203.61.14] - Start Meteor
[159.203.61.14] - Start Meteor: SUCCESS
[159.203.61.14] - Verifying Deployment
[159.203.61.14] x Verifying Deployment: FAILED

          ------------------------------------STDERR------------------------------------
           (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    curl: (7) Failed to connect to 172.17.0.2 port 3000: Connection refused
    => Logs:
    => Setting node version
    NODE_VERSION=14.18.3
    v14.18.3 is already installed.
    Now using node v14.18.3 (npm v6.14.15)
    default -> 14.18.3 (-> v14.18.3 *)
    => Starting meteor app on port 3000
    /built_app/programs/server/node_modules/fibers/future.js:313
                            throw(ex);
                            ^

    MongoServerSelectionError: Server at mongodb:27017 reports maximum wire version 5, but this version of the Node.js Driver requires at least 6 (MongoDB 3.6)
        at Timeout._onTimeout (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/sdam/topology.js:312:38)
        at listOnTimeout (internal/timers.js:557:17)
        at processTimers (internal/timers.js:500:7) {
      reason: TopologyDescription {
        type: 'Unknown',
        servers: Map(1) {
          'mongodb:27017' => ServerDescription {
            _hostAddress: HostAddress { isIPv6: false, host: 'mongodb', port: 27017 },
            address: 'mongodb:27017',
            type: 'Unknown',
            hosts: [],
            passives: [],
            arbiters: [],
            tags: {},
            minWireVersion: 0,
            maxWireVersion: 0,
            roundTripTime: -1,
            lastUpdateTime: 51406758209,
            lastWriteDate: 0,
            error: MongoCompatibilityError: Server at mongodb:27017 reports maximum wire version 5, but this version of the Node.js Driver requires at least 6 (MongoDB 3.6)
                at checkSupportedServer (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:62:12)
                at /built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:106:40
                at MessageStream.messageHandler (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connection.js:474:9)
                at MessageStream.emit (events.js:400:28)
                at processIncomingData (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
                at MessageStream._write (/built_app/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
                at writeOrBuffer (internal/streams/writable.js:358:12)
                at MessageStream.Writable.write (internal/streams/writable.js:303:10)
                at Socket.ondata (internal/streams/readable.js:731:22)
                at Socket.emit (events.js:400:28)
                at addChunk (internal/streams/readable.js:293:12)
                at readableAddChunk (internal/streams/readable.js:267:9)
                at Socket.Readable.push (internal/streams/readable.js:206:10)
                at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
          }
        },
        stale: false,
        compatible: true,
        heartbeatFrequencyMS: 10000,
        localThresholdMS: 15,
        logicalSessionTimeoutMinutes: undefined
      }
    }
    => Setting node version
    NODE_VERSION=14.18.3
    v14.18.3 is already installed.
    Now using node v14.18.3 (npm v6.14.15)
    default -> 14.18.3 (-> v14.18.3 *)
    => Starting meteor app on port 3000

    => Redeploying previous version of the app
philipmjohnson commented 2 years ago

I am in the same boat. The default mup.js sets Mongo to 3.4.1, but the latest release of Meteor forces an update.

I've been looking at:

http://meteor-up.com/docs.html#change-mongodb-version

Which led me to:

https://docs.mongodb.com/manual/release-notes/5.0-upgrade-standalone/

Which seems to indicate we have to update 3.4 to 3.6 to 4.0 to 4.2 to 4.4 to 5.0.

It seems like it would be better to simply dump the DB, re-install Mongo from scratch with 5.0, and then re-initialize the database

@zodern Any thoughts or hints on how to proceed?

philipmjohnson commented 2 years ago

Let me ask another question. If there are no other issues with the migration, is it enough to:

  1. Login into the server and stop the MongoDB process using db.shutdownServer().
  2. Update the version of MongoDB to use in mup.js to the "next" version (i.e. from 3.4 to 3.6)
  3. Invoke mup deploy

Or are there other steps I'm missing?

zodern commented 2 years ago

Those docs are a little out of date (they work, but there are now more convenient ways for some of the steps).

In your case if all you need to do is change the version, you can simplify the steps to:

  1. Change the MongoDB version in the config
  2. Run mup setup to restart MongoDB and switch to the new version

The full instructions would be:

  1. Go to the MongoDB manual > Release Notes > Current version of MongoDB > Upgrade a Standalone
  2. Follow the upgrade instructions. If needed, you can access the MongoDB shell by running mup mongo shell
  3. Instead of the step to replace binaries, you should change the version in your mup.js config and run mup setup.
jankapunkt commented 2 years ago

@philipmjohnson did you got it working? I already got a full crash when upgrading from 3.4.1 to 3.6.13 :sweat:

I got

onnecting to: mongodb://127.0.0.1:27017
        2022-02-22T10:00:08.994+0000 W NETWORK  [main] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
        2022-02-22T10:00:09.097+0000 E QUERY    [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
        connect@src/mongo/shell/mongo.js:234:13
        @(connect):1:6
        OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown

docker logs for the container say

2022-02-22T10:05:47.028+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=256M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2022-02-22T10:05:47.188+0000 E STORAGE  [initandlisten] WiredTiger error (-31802) [1645524347:188030][1:0x7fb318f09cc0], txn-recover: unsupported WiredTiger file version: this build  only supports major/minor versions up to 1/0,  and the file is version 3/0: WT_ERROR: non-specific WiredTiger error
2022-02-22T10:05:47.188+0000 E STORAGE  [initandlisten] WiredTiger error (0) [1645524347:188196][1:0x7fb318f09cc0], txn-recover: WiredTiger is unable to read the recovery log.
2022-02-22T10:05:47.188+0000 E STORAGE  [initandlisten] WiredTiger error (0) [1645524347:188233][1:0x7fb318f09cc0], txn-recover: This may be due to the log files being encrypted, being from an older version or due to corruption on disk
2022-02-22T10:05:47.188+0000 E STORAGE  [initandlisten] WiredTiger error (0) [1645524347:188285][1:0x7fb318f09cc0], txn-recover: You should confirm that you have opened the database with the correct options including all encryption and compression options
2022-02-22T10:05:47.188+0000 E STORAGE  [initandlisten] WiredTiger error (-31802) [1645524347:188354][1:0x7fb318f09cc0], txn-recover: Recovery failed: WT_ERROR: non-specific WiredTiger error
2022-02-22T10:05:47.195+0000 I -        [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2022-02-22T10:05:47.206+0000 I STORAGE  [initandlisten] exception in initAndListen: 28595 -31802: WT_ERROR: non-specific WiredTiger error, terminating
2022-02-22T10:05:47.206+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2022-02-22T10:05:47.206+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2022-02-22T10:05:47.206+0000 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2022-02-22T10:05:47.206+0000 I CONTROL  [initandlisten] now exiting
2022-02-22T10:05:47.206+0000 I CONTROL  [initandlisten] shutting down with code:100
jankapunkt commented 2 years ago

@zodern is there a way to simply "wipe" mongo from the system and do a fresh new install?

philipmjohnson commented 2 years ago

@jankapunkt Here's some documentation I wrote for our system. One section explains how to wipe mongo:

https://www.radgrad.org/docs/developers/deployment/howto/update-mongo-mup

Yes, we did get it working.

jankapunkt commented 2 years ago

@philipmjohnson thanks a lot that worked very well! One note though (for others reading this) - make sure to read the mongorestore documentation as the it behaves slightly different for Mongo 5, for example the --db and --collection options are now replaces by --nsInclude.

After correcting the mongorestore options the DB has been restored and everything is running as expected.