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 Oracle-style NOWAIT, WAIT n, and SKIP LOCKED to FOR UPDATE clause #3831

Merged
merged 2 commits into from
Jul 3, 2023

Conversation

katzyn
Copy link
Contributor

@katzyn katzyn commented Jul 2, 2023

No description provided.

Copy link
Contributor

@grandinj grandinj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, now we can build a message queue using H2 :-)

h2/src/main/org/h2/mvstore/tx/Transaction.java Outdated Show resolved Hide resolved
h2/src/main/org/h2/mvstore/tx/TransactionMap.java Outdated Show resolved Hide resolved
if (mapName == null) {
mapName = map.getName();
}
} while (transaction.waitFor(blockingTransaction, mapName, key));
} while (timeoutMillis != 0 && transaction.waitFor(blockingTransaction, mapName, key, timeoutMillis));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeoutMillis != -1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 is used for NOWAIT, with NOWAIT we shouldn't wait for anything and loop needs to be aborted.

-1 is used for plain FOR UPDATE and Transaction.waitFor() uses its own default timeout (taken from the session).

h2/src/main/org/h2/mvstore/tx/TransactionMap.java Outdated Show resolved Hide resolved
h2/src/main/org/h2/command/Parser.java Outdated Show resolved Hide resolved
@katzyn katzyn merged commit 578cb6d into h2database:master Jul 3, 2023
4 checks passed
@katzyn katzyn deleted the for_update branch July 3, 2023 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants