mongo locking

40 views
Skip to first unread message

Jim Largent

unread,
Jan 4, 2018, 12:56:19 PM1/4/18
to mongodb-user
I have a scala process that writes a lot of data to mongo.  Periodically, the database interface (shell) will freeze up.  If I open another shell, and run currentOp() I can see a lot of jobs with "waitingForLock" : true attribute and the "op" is "update"
I am able to find one job where the waitForLock is false and the lockStats show the following:
Global : {
               acquirecount : {
                      "r" : numberLong(1),
                      "w" : numberLong(1)
              }
     },
Database: {
               acquirecount: {
                      "w": numberLong(1)
               }
},
Collection: {
               acquirecount: {
                       "w": numberLong(1)
              }
}

Tell me if I'm wrong, but to me it looks like there is a write lock on the entire database, and the collection.  I was under the impression that mongo (using wiredtiger) only locks the collection.  The operation is an update so I don't understand why the global database would
need to be locked.

Any insight on what might be going on, or suggestions about what to look at are greatly appreciated.  I didn't actually write the scala code so I don't know if something else is going on somewhere else in the code, but if you can suggest things to look at that's fine too.
Thanks

Kevin Adistambha

unread,
Jan 22, 2018, 11:10:33 PM1/22/18
to mongodb-user

Hi Jim

I have a scala process that writes a lot of data to mongo. Periodically, the database interface (shell) will freeze up.

How much data are you writing? If I have to guess, I would think that the issue has nothing to do with locking. Rather, you’re writing more data than what your hardware can handle. WiredTiger would need to write all that data into disk, so it is possible that the stalls you’re observing is WiredTiger waiting for the disk to finish writing.

If this is correct, you should see:

  • Saturated disk IO in the output of a tool e.g. iostat
  • High percentage of WiredTiger cache usage, ~90% or more under the used column in mongostat

If you have further question, could you post:

  • Your MongoDB version and your OS version
  • Your hardware specification, and whether MongoDB is running on a VM/container
  • Your deployment topology (standalone, replica set, sharded cluster)
  • The output of db.serverCmdLineOpts()
  • The output of iostat and mongostat during this stall period

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages