You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2018/03/26 17:20:46 UTC

[geode] 01/01: GEODE-4928 DistributedLockService doesn't work as expected while the dlock grantor is initialized

This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-4928b
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 3c65d9b296569cc2a769187881ab14c6fe3c9a93
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Mon Mar 26 10:19:17 2018 -0700

    GEODE-4928 DistributedLockService doesn't work as expected while the dlock grantor is initialized
    
    Moved setting of the in-process state to a point before we launch the
    background thread to do the cleanup.  Added in-line cleanup with a warning
    message if background execution is rejected and we aren't shutting down.
    
    If we _are_ shutting down the in-process state is left being set to true
    so that lockers won't get a spurious conflict exception from the grantor
    and will retry their commits with a new grantor when one is created.
---
 .../cache/locks/TXLessorDepartureHandler.java      | 56 ++++++++++++----------
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLessorDepartureHandler.java b/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLessorDepartureHandler.java
index 53f998e..3da3008 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLessorDepartureHandler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLessorDepartureHandler.java
@@ -83,34 +83,42 @@ public class TXLessorDepartureHandler implements DLockLessorDepartureHandler {
 
   private void sendRecoveryMsgs(final DistributionManager dm, final DLockBatch[] batches,
       final InternalDistributedMember owner, final DLockGrantor grantor) {
-    try {
-      dm.getWaitingThreadPool().execute(new Runnable() {
-        public void run() {
-          synchronized (stateLock) {
-            processingDepartures = true;
-          }
-          try {
-            for (int i = 0; i < batches.length; i++) {
-              TXLockBatch batch = (TXLockBatch) batches[i];
-              // send TXOriginatorDepartureMessage
-              Set participants = batch.getParticipants();
-              TXOriginatorRecoveryProcessor.sendMessage(participants, owner, batch.getTXLockId(),
-                  grantor, dm);
-            }
-          } finally {
-            synchronized (stateLock) {
-              processingDepartures = false;
-              stateLock.notifyAll();
-            }
-          }
+
+    synchronized (stateLock) {
+      processingDepartures = true;
+    }
+    Runnable recoverTx = () -> {
+      try {
+        for (int i = 0; i < batches.length; i++) {
+          TXLockBatch batch = (TXLockBatch) batches[i];
+          // send TXOriginatorDepartureMessage
+          Set participants = batch.getParticipants();
+          TXOriginatorRecoveryProcessor.sendMessage(participants, owner, batch.getTXLockId(),
+              grantor, dm);
         }
-      });
+      } finally {
+        clearProcessingDepartures();
+      }
+    };
+
+    try {
+      dm.getWaitingThreadPool().execute(recoverTx);
     } catch (RejectedExecutionException e) {
-      if (logger.isDebugEnabled()) {
-        logger.debug("Rejected sending recovery messages for departure of tx originator {}", owner,
-            e);
+      // this shouldn't happen unless we're shutting down or someone has set a size constraint
+      // on the waiting-pool using a system property
+      if (!dm.getCancelCriterion().isCancelInProgress()) {
+        logger.warn("Unable to schedule background cleanup of transactions for departed member {}."
+            + "  Performing in-line cleanup of the transactions.");
+        recoverTx.run();
       }
     }
   }
 
+  private void clearProcessingDepartures() {
+    synchronized (stateLock) {
+      processingDepartures = false;
+      stateLock.notifyAll();
+    }
+  }
+
 }

-- 
To stop receiving notification emails like this one, please contact
bschuchardt@apache.org.