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 2021/01/20 00:28:51 UTC

[GitHub] [geode] jchen21 opened a new pull request #5925: First attempt to fix the bug

jchen21 opened a new pull request #5925:
URL: https://github.com/apache/geode/pull/5925


   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] upthewaterspout commented on pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

Posted by GitBox <gi...@apache.org>.
upthewaterspout commented on pull request #5925:
URL: https://github.com/apache/geode/pull/5925#issuecomment-764889906


   Minor nitpick - can you please provide a description of what you changed and why in the final commit message. I don't see one in this PR or the individual commits, but maybe I missed something. Thanks!


----------------------------------------------------------------
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] kirklund edited a comment on pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

Posted by GitBox <gi...@apache.org>.
kirklund edited a comment on pull request #5925:
URL: https://github.com/apache/geode/pull/5925#issuecomment-789321362


   > Looks like you have a few small changes to make but I'll give my approval now. Please consider adding unit test coverage for the changes in LocalRegion. There is an existing `LocalRegionTest` that uses Mockito. I also suggest you remove the `tearDown` since it's doing the same thing that the `DistributedBlackboard` Rule does after every test method.
   
   By the way, I verified that you don't need to invoke `DUnitBlackboard.initBlackboard()` in the `tearDown`. The Rule completely dereferences the instance of `DUnitBlackboard` and so it becomes available to GC. The Rule effectively handles the initialization and cleanup of `DUnitBlackboard` so that a test doesn't need to do this.


----------------------------------------------------------------
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 #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

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



##########
File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
     assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
   }
 
+  @Test
+  public void getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+      throws Exception {
+    String regionName = getClass().getSimpleName();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.setPdxReadSerialized(true);
+    cacheRule.createCache(cacheFactory);
+    InternalCache cache = cacheRule.getCache();
+    cache.setCopyOnRead(true);
+    Region region = cache.createRegionFactory(PARTITION)

Review comment:
       The compiler warning here (and elsewhere in the file) can be avoided by using `Region<Object, Object>`.

##########
File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
     assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
   }
 
+  @Test
+  public void getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+      throws Exception {
+    String regionName = getClass().getSimpleName();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.setPdxReadSerialized(true);
+    cacheRule.createCache(cacheFactory);
+    InternalCache cache = cacheRule.getCache();
+    cache.setCopyOnRead(true);
+    Region region = cache.createRegionFactory(PARTITION)
+        .create(regionName);
+
+    // Keep doing this concurrency test for 30 seconds.
+    long endTime = Duration.ofSeconds(30).toMillis() + System.currentTimeMillis();
+
+    while (System.currentTimeMillis() < endTime) {
+      Callable<Object> getValue = () -> {
+        while (true) {
+          Object value = region.get(key);
+          if (value != null) {
+            return value;
+          }
+        }
+      };
+
+      // In this test, two threads are doing gets. One thread puts the value
+      // We expect that the threads will *always* get different PdxInstance values
+      Future get1 = executorServiceRule.submit(getValue);
+      Future get2 = executorServiceRule.submit(getValue);
+      Future put = executorServiceRule.submit(() -> region.put(key, new TestValue()));

Review comment:
       Compiler warnings here (and elsewhere in the file) can be avoided by using `Future<Object>`.




----------------------------------------------------------------
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] kirklund commented on a change in pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

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



##########
File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
     assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
   }
 
+  @Test
+  public void getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+      throws Exception {
+    String regionName = getClass().getSimpleName();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.setPdxReadSerialized(true);
+    cacheRule.createCache(cacheFactory);
+    InternalCache cache = cacheRule.getCache();
+    cache.setCopyOnRead(true);
+    Region region = cache.createRegionFactory(PARTITION)
+        .create(regionName);
+
+    // Keep doing this concurrency test for 30 seconds.
+    long endTime = Duration.ofSeconds(30).toMillis() + System.currentTimeMillis();
+
+    while (System.currentTimeMillis() < endTime) {
+      Callable<Object> getValue = () -> {
+        while (true) {
+          Object value = region.get(key);
+          if (value != null) {
+            return value;
+          }
+        }
+      };
+
+      // In this test, two threads are doing gets. One thread puts the value
+      // We expect that the threads will *always* get different PdxInstance values
+      Future get1 = executorServiceRule.submit(getValue);
+      Future get2 = executorServiceRule.submit(getValue);
+      Future put = executorServiceRule.submit(() -> region.put(key, new TestValue()));

Review comment:
       If the Future is not going to have a result then go with `Future<Void>`.




----------------------------------------------------------------
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] kirklund commented on a change in pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

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



##########
File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -61,9 +63,14 @@ private static DUnitBlackboard getBlackboard() {
   @Rule
   public ExecutorServiceRule executorServiceRule = new ExecutorServiceRule();
 
+  @Rule
+  public DistributedBlackboard blackboard = new DistributedBlackboard();
+
   @After
   public void tearDown() {
-    blackboard.initBlackboard();
+    if (blackboard != null) {

Review comment:
       You can delete this `tearDown`. The `DistributedBlackboard` Rule handles this for you. (If it doesn't, that's a bug that I need to know about.)




----------------------------------------------------------------
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] jchen21 merged pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

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


   


----------------------------------------------------------------
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] upthewaterspout commented on pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

Posted by GitBox <gi...@apache.org>.
upthewaterspout commented on pull request #5925:
URL: https://github.com/apache/geode/pull/5925#issuecomment-764889906


   Minor nitpick - can you please provide a description of what you changed and why in the final commit message. I don't see one in this PR or the individual commits, but maybe I missed something. Thanks!


----------------------------------------------------------------
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] kirklund commented on pull request #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

Posted by GitBox <gi...@apache.org>.
kirklund commented on pull request #5925:
URL: https://github.com/apache/geode/pull/5925#issuecomment-789321362


   > Looks like you have a few small changes to make but I'll give my approval now. Please consider adding unit test coverage for the changes in LocalRegion. There is an existing `LocalRegionTest` that uses Mockito. I also suggest you remove the `tearDown` since it's doing the same thing that the `DistributedBlackboard` Rule does after every test method.
   
   By the way, I verified that you don't need to invoke `DUnitBlackboard.initBlackboard()` in the `tearDown`. The Rule completely dereferences the instance of `DUnitBlackboard` and so it becomes available to GC. The Rule handles the initialization and cleanup of `DUnitBlackboard`.


----------------------------------------------------------------
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 #5925: GEODE-8671: Two threads calling get and retrieve the same PdxInstance, resulting in corruption

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



##########
File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
     assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
   }
 
+  @Test
+  public void getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+      throws Exception {
+    String regionName = getClass().getSimpleName();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.setPdxReadSerialized(true);
+    cacheRule.createCache(cacheFactory);
+    InternalCache cache = cacheRule.getCache();
+    cache.setCopyOnRead(true);
+    Region region = cache.createRegionFactory(PARTITION)

Review comment:
       The compiler warning here (and elsewhere in the file) can be avoided by using `Region<Object, Object>`.

##########
File path: geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RegionConcurrentOperationDUnitTest.java
##########
@@ -131,6 +140,49 @@ public void getOnPreLoadedRegionFromMultipleThreadsReturnSameObject() throws Exc
     assertThat(cacheRule.getCache().getRegion(regionName).size()).isEqualTo(1);
   }
 
+  @Test
+  public void getOnPartitionedRegionFromMultipleThreadsReturnsDifferentPdxInstances()
+      throws Exception {
+    String regionName = getClass().getSimpleName();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.setPdxReadSerialized(true);
+    cacheRule.createCache(cacheFactory);
+    InternalCache cache = cacheRule.getCache();
+    cache.setCopyOnRead(true);
+    Region region = cache.createRegionFactory(PARTITION)
+        .create(regionName);
+
+    // Keep doing this concurrency test for 30 seconds.
+    long endTime = Duration.ofSeconds(30).toMillis() + System.currentTimeMillis();
+
+    while (System.currentTimeMillis() < endTime) {
+      Callable<Object> getValue = () -> {
+        while (true) {
+          Object value = region.get(key);
+          if (value != null) {
+            return value;
+          }
+        }
+      };
+
+      // In this test, two threads are doing gets. One thread puts the value
+      // We expect that the threads will *always* get different PdxInstance values
+      Future get1 = executorServiceRule.submit(getValue);
+      Future get2 = executorServiceRule.submit(getValue);
+      Future put = executorServiceRule.submit(() -> region.put(key, new TestValue()));

Review comment:
       Compiler warnings here (and elsewhere in the file) can be avoided by using `Future<Object>`.




----------------------------------------------------------------
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