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

More than 2 lock modes #17

Open
pwnall opened this issue Oct 5, 2017 · 1 comment
Open

More than 2 lock modes #17

pwnall opened this issue Oct 5, 2017 · 1 comment
Milestone

Comments

@pwnall
Copy link

pwnall commented Oct 5, 2017

A recurring theme I've seen in database papers is extending the lock manager with new modes to get more parallelism. The most popular need is intent locks. At least BerkeleyDB [1] and MSSQL [2] implement more than S and X.

Fortunately, all extended lock schemes can be specified using a conflict matrix, as shown in [1]. I think it'd be more intuitive to use an inverted representation compared to [1]. Specifically, matrix[i][j] is 0 if there's a conflict when the lock has an owner in mode i and a new owner requests mode j.

We could offer IS/IX/S/X by default, and let apps register custom matrices. Each acquire would have an optional matrix name parameter, and it'd get bounced if the lock has exists and was created with a different matrix.

Registration seems a bit bulky, but each app (or, realistically, db library) would only make a couple of registration calls during initialization. Registration should be idempotent (registering the same matrix with an existing name would be OK, registering a different matrix with the same name would fail) so apps that (unknowingly) use multiple instances of the same DB library can work without problems.

[1] https://docs.oracle.com/cd/E17276_01/html/programmer_reference/lock_stdmode.html
[2] https://technet.microsoft.com/en-us/library/ms175519(v=sql.105).aspx#Intent Locks

@inexorabletash
Copy link
Member

Thanks! This is really cool. Looks like something we could layer on easily.

@inexorabletash inexorabletash added this to the v.Next milestone Feb 7, 2018
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

2 participants