You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/07/31 15:34:17 UTC

[tinkerpop] branch master updated (38c94f4 -> 590fc20)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from 38c94f4  Merge branch 'tp34'
     new 56fc12e  Made iterator leak check a bit more relaxed CTR
     new df2055e  Explicitly closed traversal on interruption.
     new 199be4b  Merge branch 'tp33' into tp34
     new 590fc20  Merge branch 'tp34'

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../tinkerpop/gremlin/AbstractGremlinTest.java     | 17 ++++++---
 .../traversal/TraversalInterruptionTest.java       | 44 +++++++++++++---------
 2 files changed, 39 insertions(+), 22 deletions(-)


[tinkerpop] 01/04: Made iterator leak check a bit more relaxed CTR

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 56fc12eb09b9ca094ed1370271104f0755cc856d
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Wed Jul 31 11:31:45 2019 -0400

    Made iterator leak check a bit more relaxed CTR
---
 .../apache/tinkerpop/gremlin/AbstractGremlinTest.java   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
index 9bfbc7b..5d0faee 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
@@ -138,11 +138,6 @@ public abstract class AbstractGremlinTest {
         if (null != graphProvider) {
             graphProvider.getTestListener().ifPresent(l -> l.onTestEnd(this.getClass(), name.getMethodName()));
 
-            if (shouldTestIteratorLeak) {
-                final long openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
-                assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
-            }
-
             // GraphProvider that has implemented the clear method must check null for graph and config.
             graphProvider.clear(graph, config);
 
@@ -154,6 +149,18 @@ public abstract class AbstractGremlinTest {
             else
                 logger.warn("The {} is not of type ManagedGraphProvider and therefore graph instances may leak between test cases.", graphProvider.getClass());
 
+            if (shouldTestIteratorLeak) {
+                long wait = 300;
+                long[] tries = new long[] { 1, 3, 5, 7, 9, 18, 27, 36, 72, 144, 256, 512 };
+                long openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
+                for (int ix = 0; ix < tries.length && openItrCount > 0; ix++) {
+                    Thread.sleep(wait * tries[ix]);
+                    openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
+                }
+
+                assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
+            }
+
             g = null;
             graph = null;
             config = null;


[tinkerpop] 02/04: Explicitly closed traversal on interruption.

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit df2055e791444a10e166dcb87410d3ec7dabe832
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Wed Jul 31 11:32:25 2019 -0400

    Explicitly closed traversal on interruption.
    
    This seems to make sense even though it wasn't causing problems really. A traversal might not release resources on its own without an explicit close if the traversal does not complete iteration. Since we have an interruption of the traversal, an explicit close() seems like the right move here. CTR
---
 .../traversal/TraversalInterruptionTest.java       | 44 +++++++++++++---------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionTest.java
index 1fb54d4..6588a6b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionTest.java
@@ -27,6 +27,8 @@ import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.Arrays;
 import java.util.concurrent.CountDownLatch;
@@ -43,6 +45,7 @@ import static org.junit.Assert.assertThat;
  */
 @RunWith(Parameterized.class)
 public class TraversalInterruptionTest extends AbstractGremlinProcessTest {
+    private static final Logger logger = LoggerFactory.getLogger(TraversalInterruptionTest.class);
 
     @Parameterized.Parameters(name = "expectInterruption({0})")
     public static Iterable<Object[]> data() {
@@ -75,27 +78,34 @@ public class TraversalInterruptionTest extends AbstractGremlinProcessTest {
         final AtomicBoolean exceptionThrown = new AtomicBoolean(false);
         final CountDownLatch startedIterating = new CountDownLatch(1);
         final Thread t = new Thread(() -> {
-            try {
-                final Traversal traversal = traversalAfterPause.apply(traversalBeforePause.apply(g).sideEffect(traverser -> {
-                    // let the first iteration flow through
-                    if (startedIterating.getCount() == 0) {
-                        // ensure that the whole traversal doesn't iterate out before we get a chance to interrupt
-                        // the next iteration should stop so we can force the interrupt to be handled by VertexStep
-                        try {
-                            Thread.sleep(3000);
-                        } catch (Exception ignored) {
-                            // make sure that the interrupt propagates in case the interrupt occurs during sleep.
-                            // this should ensure VertexStep gets to try to throw the TraversalInterruptedException
-                            Thread.currentThread().interrupt();
-                        }
-                    } else {
-                        startedIterating.countDown();
+            final Traversal traversal = traversalAfterPause.apply(traversalBeforePause.apply(g).sideEffect(traverser -> {
+                // let the first iteration flow through
+                if (startedIterating.getCount() == 0) {
+                    // ensure that the whole traversal doesn't iterate out before we get a chance to interrupt
+                    // the next iteration should stop so we can force the interrupt to be handled by VertexStep
+                    try {
+                        Thread.sleep(3000);
+                    } catch (Exception ignored) {
+                        // make sure that the interrupt propagates in case the interrupt occurs during sleep.
+                        // this should ensure VertexStep gets to try to throw the TraversalInterruptedException
+                        Thread.currentThread().interrupt();
                     }
-                }));
+                } else {
+                    startedIterating.countDown();
+                }
+            }));
+            try {
                 traversal.iterate();
             } catch (Exception ex) {
                 exceptionThrown.set(ex instanceof TraversalInterruptedException);
+
+                try {
+                    traversal.close();
+                } catch (Exception iex) {
+                    logger.error("Error closing traversal after interruption", iex);
+                }
             }
+
         }, name);
 
         t.start();
@@ -110,4 +120,4 @@ public class TraversalInterruptionTest extends AbstractGremlinProcessTest {
         // ensure that some but not all of the traversal was iterated and that the right exception was tossed
         assertThat(exceptionThrown.get(), CoreMatchers.is(true));
     }
-}
+}
\ No newline at end of file


[tinkerpop] 03/04: Merge branch 'tp33' into tp34

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 199be4b546ca7f903835b7becfced2954351bbf4
Merge: 1aabcd6 df2055e
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Wed Jul 31 11:33:54 2019 -0400

    Merge branch 'tp33' into tp34

 .../tinkerpop/gremlin/AbstractGremlinTest.java     | 17 ++++++---
 .../traversal/TraversalInterruptionTest.java       | 44 +++++++++++++---------
 2 files changed, 39 insertions(+), 22 deletions(-)

diff --cc gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
index 69f53db,5d0faee..650dd38
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
@@@ -146,13 -138,7 +146,8 @@@ public abstract class AbstractGremlinTe
          if (null != graphProvider) {
              graphProvider.getTestListener().ifPresent(l -> l.onTestEnd(this.getClass(), name.getMethodName()));
  
-             if (shouldTestIteratorLeak) {
-                 final long openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
-                 assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
-             }
- 
              // GraphProvider that has implemented the clear method must check null for graph and config.
 +            // If #assumeRequirementsAreMetForTest returns false in #setup, graph and config will be null.
              graphProvider.clear(graph, config);
  
              // All GraphProvider objects should be an instance of ManagedGraphProvider, as this is handled by GraphManager


[tinkerpop] 04/04: Merge branch 'tp34'

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 590fc20c6fd8484906e7eaf1eabd364f30a96c81
Merge: 38c94f4 199be4b
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Wed Jul 31 11:34:02 2019 -0400

    Merge branch 'tp34'

 .../tinkerpop/gremlin/AbstractGremlinTest.java     | 17 ++++++---
 .../traversal/TraversalInterruptionTest.java       | 44 +++++++++++++---------
 2 files changed, 39 insertions(+), 22 deletions(-)