Skip to content

IndexOptionsConflict when acquiring lock  #7

@martinVelicky

Description

@martinVelicky

Hello,

When I'm trying to use the distributed Mongo lock I always end up with IndexOptionsConflict :

Caused by: com.mongodb.MongoCommandException: Command failed with error 85 (IndexOptionsConflict): 'Index already exists with a different name: lockedBy' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "Index already exists with a different name: lockedBy", "code": 85, "codeName": "IndexOptionsConflict"}

The app starts correctly, but once it tries to obtain the lock it always fails here

Index indexToEnsure = (new Index("lockedBy", Direction.ASC)).named("Lock_lockedBy").unique();

Using auto-configuration (not configuring anything).

Versions :
distributed-lock-mongodb-spring-boot-starter : 2.7.18
spring-boot : 2.7.4

Any idea what I'm doing wrong ? Shouldn't it just use the index instead of trying to create new one ?

Thanks,
Martin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions