Graylog2 / Graylog2/graylog2-server

Cannot connect to MongoDB on restart after mongo 4.2 upgrade

Open
#8,237 1 comment 0 reactions 0 assignees View on GitHub
to-verify
Dominant language
Java
Stars
8.1k
Forks
1.1k
Avg merge
1d 20h
Merged PRs (30d)
217

Description

## Expected Behavior

When starting, Graylog should be connecting to MongoDB.

## Current Behavior

After mongodb upgrade from 3.6 to 4.2 (with compatibility mode set to 4.0), restarted Graylog master node cannot connect to mongo servers.
The second node is still running and connected to mongo. It hasn't been restarted.

## Possible Solution

From [mongodb doc](https://docs.mongodb.com/manual/reference/command/createIndexes/#index-names):
```
Starting in version 4.2, the createIndexes command and the mongo shell helpers db.collection.createIndex() and db.collection.createIndexes() report an error if you create an index with one name, and then try to create the same index again but with another name.
```

## Steps to Reproduce (for bugs)

1. Have an existing Graylog 3.2 cluster connected to mongodb 3.6
2. Upgrade mongodb to 4.0 then to 4.2
3. Set mongodb setFeatureCompatibilityVersion to 4.0
4. Fail to restart one node.

## Context

```
modb-in-1-rs1:PRIMARY> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{
"featureCompatibilityVersion" : {
"version" : "4.0"
},
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1590745108, 40),
"signature" : {
"hash" : BinData(0,"JnCLnwAItCoQPwjRXKG7cYOSRe0="),
"keyId" : NumberLong("6831582114958278664")
}
},
"operationTime" : Timestamp(1590745108, 40)
}
```
Many errors like this:
```
[CmdLineTool] Guice error (more detail on log level debug): Error injecting constructor, com.mongodb.MongoCommandException: Command failed with error 85: 'Index with name: unique_type already exists with a different name' on server modb-in-1-p1:27010. The full response is { "operationTime" : { "$timestamp" : { "t" : 1590746360, "i" : 222 } }, "ok" : 0.0, "errmsg" : "Index with name: unique_type already exists with a different name", "code" : 85, "codeName" : "IndexOptionsConflict", "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1590746360, "i" : 222 } }, "signature" : { "hash" : { "$binary" : "iWStb4VDB3qyNon9mMd5DAmW92g=", "$type" : "00" }, "keyId" : { "$numberLong" : "6831582114958278664" } } } }
```

Exit error:
```
ERROR: Unable to connect to MongoDB. Is it running and the configuration correct?
Details: Command failed with error 85: 'Index with name: unique_type already exists with a different name' on server modb-in-1-p1:27010. The full response is { "operationTime" : { "$timestamp" : { "t" : 1590746359, "i" : 100 } }, "ok" : 0.0, "errmsg" : "Index with name: unique_type already exists with a different name", "code" : 85, "codeName" : "IndexOptionsConflict", "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1590746359, "i" : 100 } }, "signature" : { "hash" : { "$binary" : "T21s+aiVmFyF4DWFeWL2zhT2TUE=", "$type" : "00" }, "keyId" : { "$numberLong" : "6831582114958278664" } } } }
```

## Your Environment

* 2 Graylog nodes; master node failed to restart
* Graylog Version: 3.2.4
* MongoDB Version: 4.2.6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.