SQL: Fixed GridH2Table unlock in case of interrupt. This closes
@@ -243,14 +243,13 @@ public class GridH2Table extends TableBase {
/** {@inheritDoc} */
@Override public boolean lock(Session ses, boolean exclusive, boolean force) {
- Boolean putRes = sessions.putIfAbsent(ses, exclusive);
+ // In accordance with base method semantics, we'll return true if we were already exclusively locked.
+ Boolean res = sessions.get(ses);
- // In accordance with base method semantics, we'll return true if we were already exclusively locked
- if (putRes != null)
- return putRes;
-
- ses.addLock(this);
+ if (res != null)
+ return res;
+ // Acquire the lock.
lock(exclusive);
if (destroyed) {
@@ -259,6 +258,11 @@ public class GridH2Table extends TableBase {
throw new IllegalStateException("Table " + identifierString() + " already destroyed.");
}
+ // Mutate state.
+ sessions.put(ses, exclusive);
+
+ ses.addLock(this);
+
return false;
}
