ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [15/21] ignite git commit: ignite-4173 IgniteSemaphore with failoverSafe enabled doesn't release permits in case permits owner node left topology
Date Thu, 13 Apr 2017 13:31:02 GMT
ignite-4173 IgniteSemaphore with failoverSafe enabled doesn't release permits in case permits
owner node left topology


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/76485fc3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/76485fc3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/76485fc3

Branch: refs/heads/ignite-3477-master
Commit: 76485fc3eb4baf9c1e1e60e77dd904330db837b4
Parents: 4078432
Author: vladisav <vladisavj@gmail.com>
Authored: Thu Apr 13 13:24:42 2017 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Thu Apr 13 13:24:42 2017 +0300

----------------------------------------------------------------------
 .../datastructures/GridCacheSemaphoreImpl.java          | 12 ++++++++++++
 .../SemaphoreFailoverSafeReleasePermitsTest.java        |  9 ++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/76485fc3/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index 159e735..c96894b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -571,6 +571,18 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx,
Exter
 
     /** {@inheritDoc} */
     @Override public void onNodeRemoved(UUID nodeId) {
+        try {
+            initializeSemaphore();
+        }
+        catch (IgniteCheckedException e) {
+            U.error(log, "Failed to recover from failover because distributed semaphore cannot
be initialized " +
+                "(Ignore if this node is failing also)." );
+
+            // Degrade gracefully, no exception is thrown
+            // because other semaphores might also attempt to recover from failover.
+            return;
+        }
+
         int numPermits = sync.getPermitsForNode(nodeId);
 
         if (numPermits > 0) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/76485fc3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java
index 733b797..210b234 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java
@@ -92,6 +92,9 @@ public class SemaphoreFailoverSafeReleasePermitsTest extends GridCommonAbstractT
 
             IgniteSemaphore sem = ignite.semaphore("sem", 1, true, true);
 
+            // Initialize second semaphore before the first one is broken.
+            IgniteSemaphore sem2 = grid(1).semaphore("sem", 1, true, true);
+
             assertEquals(1, sem.availablePermits());
 
             sem.acquire(1);
@@ -102,11 +105,7 @@ public class SemaphoreFailoverSafeReleasePermitsTest extends GridCommonAbstractT
 
             awaitPartitionMapExchange();
 
-            ignite = grid(1);
-
-            sem = ignite.semaphore("sem", 1, true, true);
-
-            assertTrue(sem.tryAcquire(1, 5000, TimeUnit.MILLISECONDS));
+            assertTrue(sem2.tryAcquire(1, 5000, TimeUnit.MILLISECONDS));
         }
         finally {
             stopAllGrids();


Mime
View raw message