You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/07/09 22:59:13 UTC

[GitHub] [geode] gesterzhou opened a new pull request #5365: GEODE-8334: PR.clear should sync with putAll or removeAll on rvvLock

gesterzhou opened a new pull request #5365:
URL: https://github.com/apache/geode/pull/5365


       Co-authored-by: Xiaojian Zhou <gz...@pivotal.io>
       Co-authored-by: Anil <ag...@pivotal.io>
   
   Thank you for submitting a contribution to Apache Geode.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   ### Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] agingade commented on a change in pull request #5365: GEODE-8334: PR.clear should sync with putAll or removeAll on rvvLock

Posted by GitBox <gi...@apache.org>.
agingade commented on a change in pull request #5365:
URL: https://github.com/apache/geode/pull/5365#discussion_r452542790



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PutAllPRMessageTest.java
##########
@@ -119,4 +122,34 @@ public void removeAndNotifyKeysIsNotInvokedIfKeysNotLocked() throws Exception {
         eq(regionDestroyedException));
   }
 
+  @Test
+  public void rvvLockedAfterKeysAreLockedAndUnlockRVVBeforeKeys() throws Exception {
+    PutAllPRMessage message = spy(new PutAllPRMessage(bucketId, 1, false, false, false, null));
+    message.addEntry(entryData);
+    doReturn(keys).when(message).getKeysToBeLocked();
+    when(bucketRegion.waitUntilLocked(keys)).thenReturn(true);
+    when(bucketRegion.doLockForPrimary(false)).thenThrow(new PrimaryBucketException());
+    doNothing().when(bucketRegion).lockRVVForBulkOp();
+    doNothing().when(bucketRegion).unlockRVVForBulkOp();
+
+    InternalCache cache = mock(InternalCache.class);
+    InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
+    when(bucketRegion.getCache()).thenReturn(cache);
+    when(cache.getDistributedSystem()).thenReturn(ids);
+    when(ids.getOffHeapStore()).thenReturn(null);
+
+    try {
+      message.doLocalPutAll(partitionedRegion, mock(InternalDistributedMember.class), 1);
+      fail("Expect PrimaryBucketException");
+    } catch (Exception e) {
+      assertThat(e instanceof PrimaryBucketException);
+    }

Review comment:
       +1




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] agingade commented on a change in pull request #5365: GEODE-8334: PR.clear should sync with putAll or removeAll on rvvLock

Posted by GitBox <gi...@apache.org>.
agingade commented on a change in pull request #5365:
URL: https://github.com/apache/geode/pull/5365#discussion_r452543360



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PutAllPRMessageTest.java
##########
@@ -119,4 +122,34 @@ public void removeAndNotifyKeysIsNotInvokedIfKeysNotLocked() throws Exception {
         eq(regionDestroyedException));
   }
 
+  @Test
+  public void rvvLockedAfterKeysAreLockedAndUnlockRVVBeforeKeys() throws Exception {
+    PutAllPRMessage message = spy(new PutAllPRMessage(bucketId, 1, false, false, false, null));
+    message.addEntry(entryData);
+    doReturn(keys).when(message).getKeysToBeLocked();
+    when(bucketRegion.waitUntilLocked(keys)).thenReturn(true);
+    when(bucketRegion.doLockForPrimary(false)).thenThrow(new PrimaryBucketException());
+    doNothing().when(bucketRegion).lockRVVForBulkOp();
+    doNothing().when(bucketRegion).unlockRVVForBulkOp();
+
+    InternalCache cache = mock(InternalCache.class);
+    InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
+    when(bucketRegion.getCache()).thenReturn(cache);
+    when(cache.getDistributedSystem()).thenReturn(ids);
+    when(ids.getOffHeapStore()).thenReturn(null);
+
+    try {
+      message.doLocalPutAll(partitionedRegion, mock(InternalDistributedMember.class), 1);
+      fail("Expect PrimaryBucketException");
+    } catch (Exception e) {
+      assertThat(e instanceof PrimaryBucketException);
+    }
+
+    InOrder inOrder = inOrder(bucketRegion);
+    inOrder.verify(bucketRegion).waitUntilLocked(keys);
+    inOrder.verify(bucketRegion).lockRVVForBulkOp();
+    inOrder.verify(bucketRegion).unlockRVVForBulkOp();

Review comment:
       Having the actual operation "put" in between the lock and unlock makes sure the operation is operated under expected locking.

##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java
##########
@@ -131,4 +134,35 @@ public void removeAndNotifyKeysIsNotInvokedIfKeysNotLocked() throws Exception {
     verify(dataStore).checkRegionDestroyedOnBucket(eq(bucketRegion), eq(true),
         eq(regionDestroyedException));
   }
+
+  @Test
+  public void rvvLockedAfterKeysAreLockedAndUnlockRVVBeforeKeys() throws Exception {
+    RemoveAllPRMessage message =
+        spy(new RemoveAllPRMessage(bucketId, 1, false, false, false, null));
+    message.addEntry(entryData);
+    doReturn(keys).when(message).getKeysToBeLocked();
+    when(bucketRegion.waitUntilLocked(keys)).thenReturn(true);
+    when(bucketRegion.doLockForPrimary(false)).thenThrow(new PrimaryBucketException());
+    doNothing().when(bucketRegion).lockRVVForBulkOp();
+    doNothing().when(bucketRegion).unlockRVVForBulkOp();
+
+    InternalCache cache = mock(InternalCache.class);
+    InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
+    when(bucketRegion.getCache()).thenReturn(cache);
+    when(cache.getDistributedSystem()).thenReturn(ids);
+    when(ids.getOffHeapStore()).thenReturn(null);
+
+    try {
+      message.doLocalRemoveAll(partitionedRegion, mock(InternalDistributedMember.class), true);
+      fail("Expect PrimaryBucketException");
+    } catch (Exception e) {
+      assertThat(e instanceof PrimaryBucketException);
+    }
+
+    InOrder inOrder = inOrder(bucketRegion);
+    inOrder.verify(bucketRegion).waitUntilLocked(keys);
+    inOrder.verify(bucketRegion).lockRVVForBulkOp();
+    inOrder.verify(bucketRegion).unlockRVVForBulkOp();

Review comment:
       Having the actual operation "remove" in between the lock and unlock makes sure the operation is operated under expected locking.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] DonalEvans commented on a change in pull request #5365: GEODE-8334: PR.clear should sync with putAll or removeAll on rvvLock

Posted by GitBox <gi...@apache.org>.
DonalEvans commented on a change in pull request #5365:
URL: https://github.com/apache/geode/pull/5365#discussion_r452538880



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java
##########
@@ -131,4 +134,35 @@ public void removeAndNotifyKeysIsNotInvokedIfKeysNotLocked() throws Exception {
     verify(dataStore).checkRegionDestroyedOnBucket(eq(bucketRegion), eq(true),
         eq(regionDestroyedException));
   }
+
+  @Test
+  public void rvvLockedAfterKeysAreLockedAndUnlockRVVBeforeKeys() throws Exception {
+    RemoveAllPRMessage message =
+        spy(new RemoveAllPRMessage(bucketId, 1, false, false, false, null));
+    message.addEntry(entryData);
+    doReturn(keys).when(message).getKeysToBeLocked();
+    when(bucketRegion.waitUntilLocked(keys)).thenReturn(true);
+    when(bucketRegion.doLockForPrimary(false)).thenThrow(new PrimaryBucketException());
+    doNothing().when(bucketRegion).lockRVVForBulkOp();
+    doNothing().when(bucketRegion).unlockRVVForBulkOp();
+
+    InternalCache cache = mock(InternalCache.class);
+    InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
+    when(bucketRegion.getCache()).thenReturn(cache);
+    when(cache.getDistributedSystem()).thenReturn(ids);
+    when(ids.getOffHeapStore()).thenReturn(null);
+
+    try {
+      message.doLocalRemoveAll(partitionedRegion, mock(InternalDistributedMember.class), true);
+      fail("Expect PrimaryBucketException");
+    } catch (Exception e) {
+      assertThat(e instanceof PrimaryBucketException);
+    }

Review comment:
       This can be replaced with `assertThatThrownBy(() -> message.doLocalRemoveAll(partitionedRegion, mock(InternalDistributedMember.class), true)).isInstanceOf(PrimaryBucketException.class);` to make things a bit neater.

##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PutAllPRMessageTest.java
##########
@@ -119,4 +122,34 @@ public void removeAndNotifyKeysIsNotInvokedIfKeysNotLocked() throws Exception {
         eq(regionDestroyedException));
   }
 
+  @Test
+  public void rvvLockedAfterKeysAreLockedAndUnlockRVVBeforeKeys() throws Exception {
+    PutAllPRMessage message = spy(new PutAllPRMessage(bucketId, 1, false, false, false, null));
+    message.addEntry(entryData);
+    doReturn(keys).when(message).getKeysToBeLocked();
+    when(bucketRegion.waitUntilLocked(keys)).thenReturn(true);
+    when(bucketRegion.doLockForPrimary(false)).thenThrow(new PrimaryBucketException());
+    doNothing().when(bucketRegion).lockRVVForBulkOp();
+    doNothing().when(bucketRegion).unlockRVVForBulkOp();
+
+    InternalCache cache = mock(InternalCache.class);
+    InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
+    when(bucketRegion.getCache()).thenReturn(cache);
+    when(cache.getDistributedSystem()).thenReturn(ids);
+    when(ids.getOffHeapStore()).thenReturn(null);
+
+    try {
+      message.doLocalPutAll(partitionedRegion, mock(InternalDistributedMember.class), 1);
+      fail("Expect PrimaryBucketException");
+    } catch (Exception e) {
+      assertThat(e instanceof PrimaryBucketException);
+    }

Review comment:
       This can be replaced with `assertThatThrownBy(() -> message.doLocalPutAll(partitionedRegion, mock(InternalDistributedMember.class), 1)).isInstanceOf(PrimaryBucketException.class);` to make things a bit neater.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] gesterzhou commented on a change in pull request #5365: GEODE-8334: PR.clear should sync with putAll or removeAll on rvvLock

Posted by GitBox <gi...@apache.org>.
gesterzhou commented on a change in pull request #5365:
URL: https://github.com/apache/geode/pull/5365#discussion_r452547691



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessageTest.java
##########
@@ -131,4 +134,35 @@ public void removeAndNotifyKeysIsNotInvokedIfKeysNotLocked() throws Exception {
     verify(dataStore).checkRegionDestroyedOnBucket(eq(bucketRegion), eq(true),
         eq(regionDestroyedException));
   }
+
+  @Test
+  public void rvvLockedAfterKeysAreLockedAndUnlockRVVBeforeKeys() throws Exception {
+    RemoveAllPRMessage message =
+        spy(new RemoveAllPRMessage(bucketId, 1, false, false, false, null));
+    message.addEntry(entryData);
+    doReturn(keys).when(message).getKeysToBeLocked();
+    when(bucketRegion.waitUntilLocked(keys)).thenReturn(true);
+    when(bucketRegion.doLockForPrimary(false)).thenThrow(new PrimaryBucketException());
+    doNothing().when(bucketRegion).lockRVVForBulkOp();
+    doNothing().when(bucketRegion).unlockRVVForBulkOp();
+
+    InternalCache cache = mock(InternalCache.class);
+    InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
+    when(bucketRegion.getCache()).thenReturn(cache);
+    when(cache.getDistributedSystem()).thenReturn(ids);
+    when(ids.getOffHeapStore()).thenReturn(null);
+
+    try {
+      message.doLocalRemoveAll(partitionedRegion, mock(InternalDistributedMember.class), true);
+      fail("Expect PrimaryBucketException");
+    } catch (Exception e) {
+      assertThat(e instanceof PrimaryBucketException);
+    }
+
+    InOrder inOrder = inOrder(bucketRegion);
+    inOrder.verify(bucketRegion).waitUntilLocked(keys);
+    inOrder.verify(bucketRegion).lockRVVForBulkOp();
+    inOrder.verify(bucketRegion).unlockRVVForBulkOp();

Review comment:
       doLockForPrimary acts as the operation to save a lot of trouble of mocking. The test expects this exception to happen.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [geode] gesterzhou merged pull request #5365: GEODE-8334: PR.clear should sync with putAll or removeAll on rvvLock

Posted by GitBox <gi...@apache.org>.
gesterzhou merged pull request #5365:
URL: https://github.com/apache/geode/pull/5365


   


----------------------------------------------------------------
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:
users@infra.apache.org