Repository: ignite Updated Branches: refs/heads/ignite-6825 [created] f6399b467
IGNITE-6825: SQL: Fixed GridH2Table unlock in case of interrupt. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f6399b46 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f6399b46 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f6399b46 Branch: refs/heads/ignite-6825 Commit: f6399b46770a11beb0fb131bf0ce87162f052f1e Parents: ef4d576 Author: devozerov <[email protected]> Authored: Fri Nov 3 09:45:44 2017 +0300 Committer: devozerov <[email protected]> Committed: Fri Nov 3 09:45:44 2017 +0300 ---------------------------------------------------------------------- .../processors/query/h2/opt/GridH2Table.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f6399b46/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java index ac70c54..c299075 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java @@ -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; }
