geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-3937) Fix NPE when executing removeFromDisk
Date Wed, 06 Dec 2017 11:43:01 GMT

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

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

dineshpune2006 closed pull request #1002: GEODE-3937:Fix NPE when executing removeFromDisk
URL: https://github.com/apache/geode/pull/1002
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/entries/DiskEntry.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/entries/DiskEntry.java
index 210d76bca8..3eee43a341 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/entries/DiskEntry.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/entries/DiskEntry.java
@@ -713,7 +713,6 @@ public static boolean wrapOffHeapReference(Object o) {
       if (o instanceof StoredObject) {
         StoredObject so = (StoredObject) o;
         if (so.hasRefCount()) {
-          //
           return true;
         }
       }
@@ -1382,8 +1381,9 @@ public static void handleFullAsyncQueue(DiskEntry entry, LocalRegion
region, Ver
     }
 
     public static void doAsyncFlush(VersionTag tag, LocalRegion region) {
-      if (region.isThisRegionBeingClosedOrDestroyed())
+      if (region.isThisRegionBeingClosedOrDestroyed()) {
         return;
+      }
       DiskRegion dr = region.getDiskRegion();
       if (!dr.isBackup()) {
         return;
@@ -1415,8 +1415,9 @@ public static void doAsyncFlush(DiskEntry entry, LocalRegion region,
VersionTag
      */
     private static void writeEntryToDisk(DiskEntry entry, LocalRegion region, VersionTag
tag,
         boolean asyncQueueWasFull) {
-      if (region.isThisRegionBeingClosedOrDestroyed())
+      if (region.isThisRegionBeingClosedOrDestroyed()) {
         return;
+      }
       DiskRegion dr = region.getDiskRegion();
       if (!asyncQueueWasFull) {
         dr.setClearCountReference();
@@ -1510,6 +1511,9 @@ public static void removeFromDisk(DiskEntry entry, LocalRegion region,
boolean i
         throws RegionClearedException {
       DiskRegion dr = region.getDiskRegion();
       DiskId did = entry.getDiskId();
+      if (dr == null) {
+        return;
+      }
       Object syncObj = did;
       if (did == null) {
         syncObj = entry;
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
index c9251660f3..f50c775983 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
@@ -226,4 +226,13 @@ public long getNumEntriesOverflowOnDiskTestOnly() {
     return ((ParallelGatewaySenderQueue) (processors[0].getQueue()))
         .getNumEntriesOverflowOnDiskTestOnly();
   }
+
+  public void clearQueueTestOnly() {
+    for (int i = 0; i < processors.length; i++) {
+
+      ((ParallelGatewaySenderQueue) this.processors[i].getQueue()).clearQueueTestOnly();
+    }
+
+
+  }
 }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
index f8771f761a..d17c8c713a 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java
@@ -87,6 +87,10 @@
 import org.apache.geode.internal.size.SingleObjectSizer;
 import org.apache.geode.internal.util.concurrent.StoppableCondition;
 import org.apache.geode.internal.util.concurrent.StoppableReentrantLock;
+import org.apache.geode.cache.partition.PartitionRegionHelper;
+import org.apache.geode.internal.cache.LocalDataSet;
+import org.apache.geode.internal.cache.ProxyBucketRegion;
+import org.apache.geode.internal.cache.partitioned.Bucket;
 
 public class ParallelGatewaySenderQueue implements RegionQueue {
 
@@ -1781,4 +1785,40 @@ ParallelGatewaySenderQueueMetaRegion newMetataRegion(InternalCache
cache, final
       return meta;
     }
   }
+
+
+
+  public void clearQueueTestOnly() {
+
+    this.sender.pause();// it wil take internal read-write-lock
+    try {
+      for (PartitionedRegion prQ : this.userRegionNameToshadowPRMap.values()) {
+        clearPartitionedRegionTestOnly((PartitionedRegion) prQ);
+      }
+    } finally {
+      if (this.sender.isPaused())
+        this.sender.resume();
+    }
+  }
+
+  // clear the partition region
+  private void clearPartitionedRegionTestOnly(PartitionedRegion partitionedRegion) {
+    LocalDataSet lds = (LocalDataSet) PartitionRegionHelper.getLocalPrimaryData(partitionedRegion);
+    Set<Integer> set = lds.getBucketSet(); // this returns bucket ids in the function
context
+    for (Integer bucketId : set) {
+      Bucket bucket = partitionedRegion.getRegionAdvisor().getBucket(bucketId);
+      if ((bucket instanceof ProxyBucketRegion == false) && bucket instanceof BucketRegion)
{
+        BucketRegion bucketRegion = (BucketRegion) bucket;
+        clearBucketRegionTestOnly(bucketRegion);
+      }
+    }
+  }
+
+  private void clearBucketRegionTestOnly(BucketRegion bucketRegion) {
+    Set keySet = bucketRegion.keySet();
+    for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+      Object key = iterator.next();
+      bucketRegion.remove(key);
+    }
+  }
 }
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
index f3d035824a..ee6d67b039 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/WANTestBase.java
@@ -298,6 +298,35 @@ public static Integer createFirstPeerLocator(int dsId) {
     return port;
   }
 
+  public static void clearGatewaySender(String senderId) {
+
+    Set<GatewaySender> senders = cache.getGatewaySenders();
+    AbstractGatewaySender sender = null;
+    for (GatewaySender s : senders) {
+      if (s.getId().equals(senderId)) {
+        sender = (AbstractGatewaySender) s;
+        ConcurrentParallelGatewaySenderQueue r =
+            (ConcurrentParallelGatewaySenderQueue) sender.getQueue();
+        r.clearQueueTestOnly();
+        break;
+      }
+    }
+  }
+
+  public static Boolean isSenderPaused(String senderId) {
+    Boolean isPaused = false;
+    Set<GatewaySender> senders = cache.getGatewaySenders();
+    AbstractGatewaySender sender = null;
+    for (GatewaySender s : senders) {
+      if (s.getId().equals(senderId)) {
+        sender = (AbstractGatewaySender) s;
+        isPaused = sender.isPaused();
+        break;
+      }
+    }
+    return isPaused;
+  }
+
   public static Integer createSecondLocator(int dsId, int locatorPort) {
     stopOldLocator();
     WANTestBase test = new WANTestBase();
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ClearParallelSenderQueueWhenReceiverNotStartedRegressionTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ClearParallelSenderQueueWhenReceiverNotStartedRegressionTest.java
new file mode 100644
index 0000000000..44932a4b8e
--- /dev/null
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/parallel/ClearParallelSenderQueueWhenReceiverNotStartedRegressionTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.geode.internal.cache.wan.parallel;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.geode.internal.cache.wan.WANTestBase;
+import org.apache.geode.test.dunit.Wait;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * DUnit for ClearParallelSenderQueueWhenReceiverNotStartedRegressionTest operations. GEODE-3937
+ */
+@Category(DistributedTest.class)
+public class ClearParallelSenderQueueWhenReceiverNotStartedRegressionTest extends WANTestBase
{
+
+  @Test
+  public void testParallelSenderQueueEventsOverflow_NoDiskStoreSpecified() throws Exception
{
+    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
+    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2,
lnPort));
+
+    createCacheInVMs(nyPort, vm2);// backup-vm is not started in this regression
+    createReceiverInVMs(vm2);
+
+    createCacheInVMs(lnPort, vm4);// backup-vm is not started in this regression
+
+    vm4.invoke(() -> WANTestBase.createSenderWithoutDiskStore("ln", 2, 10, 10, false,
true));
+
+    vm4.invoke(
+        () -> WANTestBase.createPartitionedRegion(getTestMethodName(), "ln", 1, 100, isOffHeap()));
+
+    startSenderInVMs("ln", vm4);
+
+    vm4.invoke(() -> WANTestBase.pauseSender("ln"));
+
+    // give some time for the senders to pause
+    Awaitility.await().atMost(1, TimeUnit.MINUTES)
+        .until(() -> vm4.invoke(() -> WANTestBase.isSenderPaused("ln")));
+
+    vm2.invoke(
+        () -> WANTestBase.createPartitionedRegion(getTestMethodName(), null, 1, 100, isOffHeap()));
+
+    int numEventPuts = 50;
+    vm4.invoke(() -> WANTestBase.doHeavyPuts(getTestMethodName(), numEventPuts));
+
+    long numOvVm4 = (Long) vm4.invoke(() -> WANTestBase.getNumberOfEntriesOverflownToDisk("ln"));
+    long numMemVm4 = (Long) vm4.invoke(() -> WANTestBase.getNumberOfEntriesInVM("ln"));
+
+    assertEquals("Total number of entries  in VM4 is incorrect", (numEventPuts * 1),
+        (numOvVm4 + numMemVm4));
+
+    // clear the queue
+    vm4.invoke(() -> WANTestBase.clearGatewaySender("ln"));
+
+    vm4.invoke(() -> WANTestBase.resumeSender("ln"));
+
+    Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+
+      int numMemVm2 = vm2.invoke(() -> WANTestBase.getRegionSize(getTestMethodName()));
+
+      assertEquals("Total number of entries  in VM2 is incorrect", 0, numMemVm2);
+
+    });
+
+  }
+
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> Fix NPE when executing  removeFromDisk
> --------------------------------------
>
>                 Key: GEODE-3937
>                 URL: https://issues.apache.org/jira/browse/GEODE-3937
>             Project: Geode
>          Issue Type: Bug
>          Components: wan
>            Reporter: dinesh akhand
>            Priority: Trivial
>
> While executing the test case or clearQueueTestOnly method. we can see exception
> [vm4] java.lang.NullPointerException
> [vm4] 	at org.apache.geode.internal.cache.entries.DiskEntry$Helper.removeFromDisk(DiskEntry.java:1519)
> [vm4] 	at org.apache.geode.internal.cache.entries.AbstractOplogDiskRegionEntry.removePhase1(AbstractOplogDiskRegionEntry.java:50)
> [vm4] 	at org.apache.geode.internal.cache.entries.AbstractRegionEntry.destroy(AbstractRegionEntry.java:914)
> [vm4] 	at org.apache.geode.internal.cache.AbstractRegionMap.destroyEntry(AbstractRegionMap.java:3100)
> [vm4] 	at org.apache.geode.internal.cache.AbstractRegionMap.destroy(AbstractRegionMap.java:1429)
> [vm4] 	at org.apache.geode.internal.cache.LocalRegion.mapDestroy(LocalRegion.java:6465)
> [vm4] 	at org.apache.geode.internal.cache.LocalRegion.mapDestroy(LocalRegion.java:6439)
> [vm4] 	at org.apache.geode.internal.cache.BucketRegion.basicDestroy(BucketRegion.java:1167)
> [vm4] 	at org.apache.geode.internal.cache.AbstractBucketRegionQueue.basicDestroy(AbstractBucketRegionQueue.java:352)
> [vm4] 	at org.apache.geode.internal.cache.BucketRegionQueue.basicDestroy(BucketRegionQueue.java:366)
> [vm4] 	at org.apache.geode.internal.cache.LocalRegion.validatedDestroy(LocalRegion.java:1101)
> [vm4] 	at org.apache.geode.internal.cache.DistributedRegion.validatedDestroy(DistributedRegion.java:942)
> [vm4] 	at org.apache.geode.internal.cache.LocalRegion.destroy(LocalRegion.java:1086)
> [vm4] 	at org.apache.geode.internal.cache.AbstractRegion.destroy(AbstractRegion.java:315)
> [vm4] 	at org.apache.geode.internal.cache.LocalRegion.remove(LocalRegion.java:8870)
> [vm4] 	at org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueue.clearPartitionedRegion(ParallelGatewaySenderQueue.java:1820)
> [vm4] 	at org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueue.clearQueue(ParallelGatewaySenderQueue.java:1795)
> [vm4] 	at org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue.clearQueue(ConcurrentParallelGatewaySenderQueue.java:236)
> [vm4] 	at org.apache.geode.internal.cache.wan.WANTestBase.clearGatewaySender(WANTestBase.java:256)
> [vm4] 	at org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueueOverflowDUnitTest.lambda$8(ParallelGatewaySenderQueueOverflowDUnitTest.java:96)
> [vm4] 	at org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueueOverflowDUnitTest$$Lambda$42/144498586.run(Unknown
Source)
> [vm4] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message