mongodb-js / compass

The GUI for MongoDB.
https://mongodb.com/compass
Other
1.15k stars 176 forks source link

Mongo Compass compatibility with MongoDB server version #3207

Closed 1Mark closed 6 months ago

1Mark commented 2 years ago

How can I know what's the latest version of MongoCompass I can use with MongoDB server. E.g if i'm using MongoDB 4.2.11 Community. What's the latest version of Compass I can use? I've searched a lot online and found no sort of document which explains this.

big-pang commented 2 years ago

I have the same problem

addaleax commented 2 years ago

From https://www.mongodb.com/docs/compass/current/install/:

Compass requires […] MongoDB 3.6 or later

All current versions of Compass work with 3.6 or above. Currently, only MongoDB 4.2 and above are still receiving support as server versions, so please be aware of that when using older servers. You can expect that Compass will always work with the officially supported server versions at the time of the Compass release.

1Mark commented 2 years ago

I tried the latest version of mongo compass, and it's not working with MongoDB 4.4.0 it just shows all collections as empty

addaleax commented 2 years ago

@1Mark Do you have a screenshot? Logs (Help → Open Log File → Extract and open as .txt)? Do you have the required permissions to see the collection contents?

1Mark commented 2 years ago

I definitely have permission since when I downgraded compass version it worked.

addaleax commented 2 years ago

@1Mark Which versions did you try? Can you share log files for both cases to compare?

1Mark commented 2 years ago

OK that bug went away after updating. The only thing left is, I get the following error

Current topology does not support sessions

I'm using Compass Version 1.32.2 (1.32.2)

Server version: MongoDB 4.0.22 Community

addaleax commented 2 years ago

Current topology does not support sessions

This typically indicates that your server is older than 3.6.

1Mark commented 2 years ago

image

addaleax commented 2 years ago

@1Mark Thank you for the screenshot! Is there any chance that you would be able to share a log file as described above? Is there anything special about your server endpoint? What kind of topology are your server(s) configured in?

1Mark commented 2 years ago
{"t":{"$date":"2022-06-24T15:17:10.341Z"},"s":"I","c":"COMPASS-CRUD-UI","id":1001000073,"ctx":"Documents","msg":"Refreshing documents","attr":{"_inspected":"{\n  ns: 'local.me',\n  withFilter: false,\n  findOptions: {\n    sort: null,\n    projection: null,\n    skip: 0,\n    limit: 20,\n    collation: null,\n    maxTimeMS: 60000,\n    promoteValues: false,\n    bsonRegExp: true,\n    session: A {\n      _events: [Object: null prototype],\n      _eventsCount: 1,\n      _maxListeners: undefined,\n      topology: [A],\n      sessionPool: [N],\n      hasEnded: false,\n      clientOptions: [Object: null prototype],\n      explicit: true,\n      supports: [Object],\n      clusterTime: undefined,\n      operationTime: undefined,\n      owner: undefined,\n      defaultTransactionOptions: {},\n      transaction: [Object],\n      [Symbol(kCapture)]: false,\n      [Symbol(snapshotEnabled)]: false,\n      [Symbol(serverSession)]: [k],\n      [Symbol(txnNumberIncrement)]: 0,\n      [Symbol(kSessionClientType)]: 'CRUD'\n    }\n  },\n  countOptions: {\n    skip: 0,\n    maxTimeMS: 5000,\n    session: A {\n      _events: [Object: null prototype],\n      _eventsCount: 1,\n      _maxListeners: undefined,\n      topology: [A],\n      sessionPool: [N],\n      hasEnded: false,\n      clientOptions: [Object: null prototype],\n      explicit: true,\n      supports: [Object],\n      clusterTime: undefined,\n      operationTime: undefined,\n      owner: undefined,\n      defaultTransactionOptions: {},\n      transaction: [Object],\n      [Symbol(kCapture)]: false,\n      [Symbol(snapshotEnabled)]: false,\n      [Symbol(serverSession)]: [k],\n      [Symbol(txnNumberIncrement)]: 0,\n      [Symbol(kSessionClientType)]: 'CRUD'\n    },\n    hint: '_id_'\n  }\n}"}}
{"t":{"$date":"2022-06-24T15:17:10.344Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000041,"ctx":"Connection 0","msg":"Running aggregation","attr":{"ns":"local.me","stages":["$match","$count"]}}
{"t":{"$date":"2022-06-24T15:17:10.348Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000043,"ctx":"Connection 0","msg":"Running raw find","attr":{"ns":"config.collections"}}
{"t":{"$date":"2022-06-24T15:17:10.349Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000043,"ctx":"Connection 0","msg":"Running raw find","attr":{"ns":"local.me"}}
{"t":{"$date":"2022-06-24T15:17:10.581Z"},"s":"W","c":"cancellable-queries","id":1001000075,"ctx":"Documents","msg":"Failed to fetch sharding keys","attr":{"stack":"MongoCompatibilityError: Current topology does not support sessions\n    at file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:929224\n    at t.maybePromise (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:1030185)\n    at e (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:928658)\n    at m._initialize (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:856575)\n    at m.[kInit] (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:851609)\n    at x (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:852260)\n    at r (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:849536)\n    at file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:849719\n    at t.maybePromise (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:1030185)\n    at m.toArray (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:849500)","name":"MongoCompatibilityError","message":"Current topology does not support sessions","code":null}}
{"t":{"$date":"2022-06-24T15:17:10.585Z"},"s":"E","c":"COMPASS-CRUD-UI","id":1001000074,"ctx":"Documents","msg":"Failed to refresh documents","attr":{"stack":"MongoCompatibilityError: Current topology does not support sessions\n    at file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:929224\n    at t.maybePromise (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:1030185)\n    at e (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:928658)\n    at m._initialize (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:856575)\n    at m.[kInit] (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:851609)\n    at x (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:852260)\n    at r (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:849536)\n    at file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:849719\n    at t.maybePromise (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:1030185)\n    at m.toArray (file:///Applications/MongoDB%20Compass.app/Contents/Resources/app.asar/build/358.063d7e3171dad632d754.renderer.js:2:849500)","name":"MongoCompatibilityError","message":"Current topology does not support sessions","code":null}}
{"t":{"$date":"2022-06-24T15:17:10.627Z"},"s":"D2","c":"COMPASS-DATA-SERVICE","id":1001000029,"ctx":"Connection 0","msg":"Driver command succeeded","attr":{"address":"MASKED:27017","serverConnectionId":5,"duration":27,"commandName":"count"}}
{"t":{"$date":"2022-06-24T15:17:10.627Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000034,"ctx":"Connection 0","msg":"Running estimatedCount","attr":{"ns":"local.me","result":1}}
{"t":{"$date":"2022-06-24T15:17:10.627Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000041,"ctx":"Connection 0","msg":"Running aggregation","attr":{"ns":"local.me","stages":["$limit"]}}
{"t":{"$date":"2022-06-24T15:17:10.629Z"},"s":"D2","c":"COMPASS-DATA-SERVICE","id":1001000029,"ctx":"Connection 0","msg":"Driver command succeeded","attr":{"address":"MASKED:27017","serverConnectionId":1,"duration":21,"commandName":"listIndexes"}}
{"t":{"$date":"2022-06-24T15:17:10.631Z"},"s":"D2","c":"COMPASS-DATA-SERVICE","id":1001000029,"ctx":"Connection 0","msg":"Driver command succeeded","attr":{"address":"MASKED:27017","serverConnectionId":2,"duration":23,"commandName":"aggregate"}}
{"t":{"$date":"2022-06-24T15:17:10.647Z"},"s":"D2","c":"COMPASS-DATA-SERVICE","id":1001000029,"ctx":"Connection 0","msg":"Driver command succeeded","attr":{"address":"MASKED:27017","serverConnectionId":5,"duration":18,"commandName":"aggregate"}}
{"t":{"$date":"2022-06-24T15:17:10.655Z"},"s":"D2","c":"COMPASS-DATA-SERVICE","id":1001000029,"ctx":"Connection 0","msg":"Driver command succeeded","attr":{"address":"MASKED:27017","serverConnectionId":4,"duration":46,"commandName":"collStats"}}
{"t":{"$date":"2022-06-24T15:17:10.655Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000047,"ctx":"Connection 0","msg":"Listing indexes","attr":{"ns":"local.me"}}
1Mark commented 2 years ago
{"t":{"$date":"2022-06-24T15:15:19.631Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 0","msg":"Topology description changed","attr":{"isWritable":false,"isMongos":false,"previousType":"Unknown","newType":"Single"}}

{"t":{"$date":"2022-06-24T15:15:19.728Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 0","msg":"Topology description changed","attr":{"isWritable":false,"isMongos":false,"previousType":"Single","newType":"Single"}}

{"t":{"$date":"2022-06-24T15:23:49.094Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 1","msg":"Topology description changed","attr":{"isWritable":false,"isMongos":false,"previousType":"Unknown","newType":"ReplicaSetNoPrimary"}}

{"t":{"$date":"2022-06-24T15:23:49.175Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 1","msg":"Topology description changed","attr":{"isWritable":false,"isMongos":false,"previousType":"ReplicaSetNoPrimary","newType":"ReplicaSetNoPrimary"}}

{"t":{"$date":"2022-06-24T15:23:49.184Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 1","msg":"Topology description changed","attr":{"isWritable":true,"isMongos":false,"previousType":"ReplicaSetNoPrimary","newType":"ReplicaSetWithPrimary"}}

{"t":{"$date":"2022-06-24T15:23:49.385Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 1","msg":"Topology description changed","attr":{"isWritable":true,"isMongos":false,"previousType":"ReplicaSetWithPrimary","newType":"ReplicaSetWithPrimary"}}

{"t":{"$date":"2022-06-24T15:25:52.629Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 2","msg":"Topology description changed","attr":{"isWritable":false,"isMongos":false,"previousType":"Unknown","newType":"Single"}}

{"t":{"$date":"2022-06-24T15:25:52.884Z"},"s":"I","c":"COMPASS-DATA-SERVICE","id":1001000021,"ctx":"Connection 2","msg":"Topology description changed","attr":{"isWritable":false,"isMongos":false,"previousType":"Single","newType":"Single"}}
addaleax commented 2 years ago

@1Mark Usually, when requesting log files, it is also the initial connection attempt log lines that are helpful.

Can you open the embedded shell in Compass (at the bottom of the screen), or alternatively, connect with the MongoDB Shell and report the output of db.isMaster() (in particular the logicalSessionTimeoutMinutes field) and db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 }).featureCompatibilityVersion (in particular, whether the FCV is set to at least 3.6)?

Compass may not be able to work correctly if the featureCompatibilityVersion value is set to an older version, even if the server version is otherwise sufficiently recent.

1Mark commented 2 years ago
{
    setVersion: 31,
    ismaster: false,
    secondary: true,
    passive: true,
    hidden: true,
    logicalSessionTimeoutMinutes: 30,
    minWireVersion: 0,
    maxWireVersion: 7,
    readOnly: false,
    ok: 1,
    isWritablePrimary: false
  }

image

addaleax commented 2 years ago

@1Mark Where did you download the MongoDB Server binaries from? The isMaster response does not look like a typical MongoDB 4.0.22 Community isMaster response. Are you connecting against individual nodes with directConnection enabled?

addaleax commented 2 years ago

(We ask for log files because a full log files, even if redacted, typically contains a lot of this information without the need for extra round-trips asking for info.)

1Mark commented 2 years ago

I'm connected to a single node with direct connection. But is isMaster["hosts"] returns a list of nodes; the node that I connect to is a relay node (that allows me to connect to other nodes but in a separate cluster so I don't impact their performance). Not sure of the official term for this

addaleax commented 2 years ago

@1Mark I think the mismatch between directConnection and it being a relay to a cluster might be tripping up Compass.

I don’t know what exactly “relay” means here for you, and it might be important to clarify that; the only type of relays that are provided by MongoDB would be mongos, which is typically used in sharding but can also be used for other purposes, or load balancers. Those would generate different isMaster responses, though.

1Mark commented 2 years ago

@addaleax it's just a replicaset with https://www.mongodb.com/docs/manual/tutorial/configure-secondary-only-replica-set-member/#prevent-secondary-from-becoming-primary this enabled.

replicaset that cannot be promoted to writer

addaleax commented 2 years ago

@1Mark

But is isMaster["hosts"] returns a list of nodes

There’s nothing like that listed in the isMaster reply snippet above, though. Are you always connecting to the same host with the same configuration options here?

it's just a replicaset with https://www.mongodb.com/docs/manual/tutorial/configure-secondary-only-replica-set-member/#prevent-secondary-from-becoming-primary this enabled.

and you are connecting with directConnection=true to this specific node?

1Mark commented 2 years ago

and you are connecting with directConnection=true to this specific node? Yes that's correct

1Mark commented 2 years ago
{
  hosts: [
    'host1:27017',
    'host2:27017',
    'host3:27017'
  ],
  setName: 'someName',
  setVersion: 31,
  ismaster: false,
  secondary: true,
  primary: 'host1:27017',
  passive: true,
  hidden: true,
  tags: {
    fqdn: 'someURI',
    dc: 'something'
  },
  me: 'someURI:27017',
  lastWrite: {
    opTime: { ts: Timestamp({ t: 1656333709, i: 40 }), t: Long("38") },
    lastWriteDate: 2022-06-27T12:41:49.000Z,
    majorityOpTime: { ts: Timestamp({ t: 1656333709, i: 40 }), t: Long("38") },
    majorityWriteDate: 2022-06-27T12:41:49.000Z
  },
  maxBsonObjectSize: 16777216,
  maxMessageSizeBytes: 48000000,
  maxWriteBatchSize: 100000,
  localTime: 2022-06-27T12:41:49.826Z,
  logicalSessionTimeoutMinutes: 30,
  minWireVersion: 0,
  maxWireVersion: 7,
  readOnly: false,
  ok: 1,
  operationTime: Timestamp({ t: 1656333709, i: 40 }),
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1656333709, i: 40 }),
    signature: {
      hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
      keyId: Long("0")
    }
  },
  isWritablePrimary: false
}

I apologise for the over redaction the first time I sent the copy of db.isMaster() that contained some deleted keys.

addaleax commented 2 years ago

@1Mark Can you share a redacted version of the connection string from the log? Which readPreference value are you using? Which other options are you setting when connecting?

1Mark commented 2 years ago

mongodb://someURI/?readPreference=secondary&directConnection=true That's it. The rest is just default from Compass

ZhigunovSemen commented 2 years ago

Hi, the similar issue appears since last year. https://jira.mongodb.org/browse/COMPASS-5304 Why this ticket closed without any explanation?

Howewer, this problem forces me to use 1.28.4 with disabled automatic updating.

Anemy commented 2 years ago

@ZhigunovSemen I do see an explanation for the closing of that ticket:

Compass requires MongoDB 3.6+. In 1.29 we start using some session-related features only available in 3.6+ that allow us to let users terminate queries. Are you using a MongoDB Version less than 3.6?

I'm not quite sure on the cause of @1Mark's issue. It looks like you're on a > 3.6 version but something isn't letting the sessions. Are you able to start a session manually when you're connected?

const db2 = db.getMongo().startSession({retryWrites: true, causalConsistency: true}).getDatabase(db.getName());
db.test.find();
1Mark commented 2 years ago

Will this change the state/settings of the DB or only client session settings?

ZhigunovSemen commented 2 years ago

I'm not quite sure on the cause of @1Mark's issue. It looks like you're on a > 3.6 version but something isn't letting the sessions. Are you able to start a session manually when you're connected?

db.version()
3.6.11

We have server version 3.6.11.

const db2 = db.getMongo().startSession({retryWrites: true, causalConsistency: true}).getDatabase(db.getName());
db.test.find();

I run this without any problems/errors.

Compass requires MongoDB 3.6+. In 1.29 we start using some session-related features only available in 3.6+ that allow us to let users terminate queries.

Could you please add this information for Compass download page, so the people will have able to right choice which version need to download for older version of database ?

1Mark commented 2 years ago

@ZhigunovSemen I do see an explanation for the closing of that ticket:

Compass requires MongoDB 3.6+. In 1.29 we start using some session-related features only available in 3.6+ that allow us to let users terminate queries. Are you using a MongoDB Version less than 3.6?

I'm not quite sure on the cause of @1Mark's issue. It looks like you're on a > 3.6 version but something isn't letting the sessions. Are you able to start a session manually when you're connected?

const db2 = db.getMongo().startSession({retryWrites: true, causalConsistency: true}).getDatabase(db.getName());
db.test.find();

I got an error

[MongoCompatibilityError:](https://github.com/mongodb-js/compass/issues/3207#) Current topology does not support sessions
    at /Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:172647
    at t.maybePromise (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:18756)
    at e (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:171834)
    at FindCursor._initialize (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:1335679)
    at FindCursor.[kInit] (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:199554)
    at O (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:200187)
    at /Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:196985
    at t.maybePromise (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:18756)
    at FindCursor.tryNext (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:196910)
    at Cursor.tryNext (/Applications/MongoDB Compass 2.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:880753)

The commands I ran were

const db2 = db.getMongo().startSession({retryWrites: true, causalConsistency: true}).getDatabase(db.getName());
db2.test.find();
1Mark commented 2 years ago

The advice on SO for just using Compass 1.28.4 is the only workaround for now https://stackoverflow.com/a/70298708/5506988