[ 
https://issues.apache.org/jira/browse/GEODE-8334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17154992#comment-17154992
 ] 

ASF GitHub Bot commented on GEODE-8334:
---------------------------------------

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


> Primary and secondary bucket data mismatch with concurrent putAll/removeAll 
> and PR.clear 
> -----------------------------------------------------------------------------------------
>
>                 Key: GEODE-8334
>                 URL: https://issues.apache.org/jira/browse/GEODE-8334
>             Project: Geode
>          Issue Type: Sub-task
>          Components: regions
>    Affects Versions: 1.14.0
>            Reporter: Xiaojian Zhou
>            Assignee: Xiaojian Zhou
>            Priority: Major
>              Labels: GeodeOperationAPI
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to