Nic Cottrell
Nic Cottrell

Reputation: 9695

Why do reads in MongoDB sometimes wait for lock?

While using db.currentOp(), I sometimes see operations like:

{
        "opid" : 1238664,
        "active" : false,
        "lockType" : "read",
        "waitingForLock" : true,
        "op" : "query",
        .....
        "desc" : "conn"
    }

Why does a read operation need to wait for a lock? Is there a way to tell a query to ignore any pending writes and just go ahead and read anyway?

Upvotes: 1

Views: 1491

Answers (1)

Andrew Orsich
Andrew Orsich

Reputation: 53705

You can't tell a query ignore pending writes because of mongodb indexes working in synchronous way. And this is by design.

For example indexes in RavenDB can work in async and sync way. So may be you need ravendb (if you on windows) ;)

Why do reads in MongoDB sometimes wait for lock?

They are waiting for index rebuild.

Upvotes: 2

Related Questions