[SERVER-25500] Collection drops can cause busy applications to stall Created: 09/Aug/16  Updated: 23/Nov/16  Resolved: 11/Aug/16

Status: Closed
Project: Core Server
Component/s: Storage, WiredTiger
Affects Version/s: 3.2.8, 3.3.10
Fix Version/s: 3.2.9, 3.3.11

Type: Bug Priority: Critical - P2
Reporter: Michael Cahill (Inactive) Assignee: Michael Cahill (Inactive)
Resolution: Done Votes: 1
Labels: code-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test.js    
Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Participants:

 Description   

The reason drops are problematic is that WiredTiger makes a table drop fail if there are any open cursors on the table. MongoDB caches cursors because opening them can be expensive (as we see here). That means the low-level drop operation often fails, and in that case, the MongoDB session cache will close all cached sessions and cursors to allow the drop to succeed.

A lot of the impact of drops is caused by contention for the mutex in WiredTiger that protects the list of handles, because the new sessions need to acquire that lock to open a cursor on a table for the first time.

Calling closeAll in the session cache when a drop fails is overly aggressive. There is no need to close all sessions, and in fact only cursors on tables we are trying to drop need to be closed. Even if we switch to closing all cursors in that case, the impact will be substantially lower, because a WiredTiger session can reopen a cursor on a table it has cached without acquiring any locks.



 Comments   
Comment by Michael Cahill (Inactive) [ 11/Aug/16 ]

We are still waiting for confirmation that this change is sufficient to fix the original problem as reported, but resolving this ticket because the changes considered here have now been committed (and backported to v3.2).

Comment by Githook User [ 11/Aug/16 ]

Author:

{u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'}

Message: SERVER-25500 Close cursors rather than sessions when a drop fails.
Branch: master
https://github.com/mongodb/mongo/commit/fb99b3a9a1ea15e3df1b2545970a47df97703895

Comment by Githook User [ 10/Aug/16 ]

Author:

{u'username': u'michaelcahill', u'name': u'Michael Cahill', u'email': u'michael.cahill@mongodb.com'}

Message: SERVER-25500 If drop fails, close cursors, not sessions.
Branch: v3.2
https://github.com/mongodb/mongo/commit/22ec9e93b40c85fc7cae7d56e7d6a02fd811088c

Generated at Thu Feb 08 04:09:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.