Hello Team,
I am getting below error after I upgraded Mongo form 4.4.16 to 5.0.23 ( I am using mongodb along with opensearch and graylog)
com.mongodb.DuplicateKeyException: Write failed with error code 11000 and error message ‘Index build failed: 86186019-10e4-462d-ac4f-24895467fad8: Collection graylog.users ( d3f3f594-8493-4349-9a3a-c48709ac57a0 ) :: caused by :: E11000 duplicate key error collection: graylog.users index: unique_username dup key: { username: “haryko” }’
at com.mongodb.internal.operation.CreateIndexesOperation.checkForDuplicateKeyError(CreateIndexesOperation.java:266) ~[graylog.jar:?]
at com.mongodb.internal.operation.CreateIndexesOperation.access$200(CreateIndexesOperation.java:70) ~[graylog.jar:?]
since I was having backup and when checked for help over the internet I found that we need to do below steps
use mydb
db.users.drop()
Do we have any alternative rather dropping db or its absolutely file to drop since it will re genrate that but I am not sure.
I need guidance why this issue has occurred and what the best way to resolve this, also db.users.drop() is safe command if this issue occurs again
Please guide,
Regards,
Sam