dschneider-pivotal commented on a change in pull request #6470:
URL: https://github.com/apache/geode/pull/6470#discussion_r631938580



##########
File path: 
geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockGrantor.java
##########
@@ -602,18 +609,20 @@ public DLockBatch getLockBatch(Object batchId) throws 
InterruptedException {
     if (isTraceEnabled_DLS) {
       logger.trace(LogMarker.DLS_VERBOSE, "[DLockGrantor.getLockBatch] enter: 
{}", batchId);
     }
-    synchronized (this.batchLocks) {
-      waitWhileInitializing();
-      if (!acquireDestroyReadLock(0)) {
-        waitUntilDestroyed();
-        checkDestroyed();
-      }
-      try {
-        checkDestroyed();
-        ret = (DLockBatch) this.batchLocks.get(batchId);
-      } finally {
-        releaseDestroyReadLock();
+
+    waitWhileInitializing();
+    if (acquireDestroyReadLock(0)) {
+      synchronized (batchLocks) {
+        try {
+          checkDestroyed();
+          ret = batchLocks.get(batchId);
+        } finally {
+          releaseDestroyReadLock();

Review comment:
       this should be done after the sync is released

##########
File path: 
geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockGrantor.java
##########
@@ -483,46 +484,51 @@ void handleLockBatch(DLockRequestMessage request) throws 
InterruptedException {
     // when the member-departure is announced.
     handler.waitForInProcessDepartures();
 
-    synchronized (this.batchLocks) { // assures serial processing
-      waitWhileInitializing();
-      if (request.checkForTimeout()) {
-        cleanupSuspendState(request);
-        return;
-      }
-
-      final boolean isTraceEnabled_DLS = 
logger.isTraceEnabled(LogMarker.DLS_VERBOSE);
-      if (isTraceEnabled_DLS) {
-        logger.trace(LogMarker.DLS_VERBOSE, "[DLockGrantor.handleLockBatch]");
-      }
-      if (!acquireDestroyReadLock(0)) {
-        waitUntilDestroyed();
-        checkDestroyed();
-      }
-      try {
-        checkDestroyed();
+    waitWhileInitializing();
+    if (request.checkForTimeout()) {
+      cleanupSuspendState(request);
+      return;
+    }
+    if (acquireDestroyReadLock(0)) {
+      synchronized (batchLocks) { // assures serial processing
+        final boolean isTraceEnabled_DLS = 
logger.isTraceEnabled(LogMarker.DLS_VERBOSE);
         if (isTraceEnabled_DLS) {
-          logger.trace(LogMarker.DLS_VERBOSE, "[DLockGrantor.handleLockBatch] 
request: {}",
-              request);
+          logger.trace(LogMarker.DLS_VERBOSE, 
"[DLockGrantor.handleLockBatch]");
         }
 
-        DLockBatch batch = (DLockBatch) request.getObjectName();
-        checkIfHostDeparted(batch.getOwner());
-        resMgr.makeReservation((IdentityArrayList) batch.getReqs());
-        if (isTraceEnabled_DLS) {
-          logger.trace(LogMarker.DLS_VERBOSE, "[DLockGrantor.handleLockBatch] 
granting {}",
-              batch.getBatchId());
+        try {
+          checkDestroyed();
+          if (isTraceEnabled_DLS) {
+            logger.trace(LogMarker.DLS_VERBOSE, 
"[DLockGrantor.handleLockBatch] request: {}",
+                request);
+          }
+
+          DLockBatch batch = (DLockBatch) request.getObjectName();
+          checkIfHostDeparted(batch.getOwner());
+          makeReservation(batch);
+          if (isTraceEnabled_DLS) {
+            logger.trace(LogMarker.DLS_VERBOSE, 
"[DLockGrantor.handleLockBatch] granting {}",
+                batch.getBatchId());
+          }
+          batchLocks.put(batch.getBatchId(), batch);
+          request.respondWithGrant(Long.MAX_VALUE);
+        } catch (CommitConflictException ex) {
+          request.respondWithTryLockFailed(ex.getMessage());
+        } finally {
+          releaseDestroyReadLock();

Review comment:
       this should be done after the sync is released

##########
File path: 
geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockGrantor.java
##########
@@ -639,21 +649,23 @@ public void updateLockBatch(Object batchId, DLockBatch 
newBatch) throws Interrup
     if (isTraceEnabled_DLS) {
       logger.trace(LogMarker.DLS_VERBOSE, "[DLockGrantor.updateLockBatch] 
enter: {}", batchId);
     }
-    synchronized (this.batchLocks) {
-      waitWhileInitializing();
-      if (!acquireDestroyReadLock(0)) {
-        waitUntilDestroyed();
-        checkDestroyed();
-      }
-      try {
-        checkDestroyed();
-        final DLockBatch oldBatch = (DLockBatch) this.batchLocks.get(batchId);
-        if (oldBatch != null) {
-          this.batchLocks.put(batchId, newBatch);
+    waitWhileInitializing();
+    if (acquireDestroyReadLock(0)) {
+
+      synchronized (batchLocks) {
+        try {
+          checkDestroyed();
+          final DLockBatch oldBatch = batchLocks.get(batchId);
+          if (oldBatch != null) {
+            batchLocks.put(batchId, newBatch);
+          }
+        } finally {
+          releaseDestroyReadLock();

Review comment:
       this should be done after the sync is released

##########
File path: 
geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockGrantor.java
##########
@@ -674,24 +687,30 @@ public void releaseLockBatch(Object batchId, 
InternalDistributedMember owner)
     if (logger.isTraceEnabled(LogMarker.DLS_VERBOSE)) {
       logger.trace(LogMarker.DLS_VERBOSE, "[DLockGrantor.releaseLockBatch]");
     }
-    synchronized (this.batchLocks) {
-      waitWhileInitializing();
-      if (!acquireDestroyReadLock(0)) {
-        waitUntilDestroyed();
-        checkDestroyed();
-      }
-      try {
-        checkDestroyed();
-        DLockBatch batch = (DLockBatch) this.batchLocks.remove(batchId);
-        if (batch != null) {
-          this.resMgr.releaseReservation((IdentityArrayList) batch.getReqs());
+    waitWhileInitializing();
+    if (acquireDestroyReadLock(0)) {
+      synchronized (batchLocks) {
+        try {
+          checkDestroyed();
+          DLockBatch batch = batchLocks.remove(batchId);
+          if (batch != null) {
+            releaseReservation(batch);
+          }
+        } finally {
+          releaseDestroyReadLock();

Review comment:
       this should be done after the sync is released




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to