Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to make write lock requests interrupt other operations #1132

Closed
leifwalsh opened this issue May 14, 2014 · 0 comments
Closed

add option to make write lock requests interrupt other operations #1132

leifwalsh opened this issue May 14, 2014 · 0 comments
Assignees
Milestone

Comments

@leifwalsh
Copy link
Contributor

Currently (1.4.x), when a write lock request begins, it blocks behind all running read locks, and blocks new read lock requests behind it in the queue (greedy write lock). This means that write lock requests can introduce stalls, and is a general problem we've been dealing with incrementally for a while.

This adds a new option, --setParameter=forceWriteLocks=true, which makes it so that whenever a thread is waiting for a write lock, all read lock holders will treat this as an interrupt, so they bail out early (the application should retry their operations) and allow the write lock to proceed, eliminating the stall.

Whether a client agrees to be interrupted this way can be controlled with a new command, {setWriteLockYielding: false}. This sets, on a per-client connection basis, whether this thread allows itself to be interrupted by waiting write locks. To make a thread ignore waiting write locks, use db.runCommand({setWriteLockYielding: false}), and to make a thread interrupt itself when there is a pending write lock, use db.runCommand({setWriteLockYielding: true}).

The default for each new connection comes from the forceWriteLocks server parameter, which can also be set at runtime with db.setParameter('forceWriteLocks', <true|false>).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant