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 2016/02/13 00:42:17 UTC

[1/3] incubator-tinkerpop git commit: Better handled commit and serialization errors in Gremlin Server.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/tp31 9aba32861 -> f06cf6647


Better handled commit and serialization errors in Gremlin Server.

Both types of errors were causing problems.  For commit errors, the last message from iteration was already sent back to the client as a terminating message so failure on commit after that was ignored by the driver because it had already received the terminator for that request.  Serialization errors didn't break the result iteration loop - they were being handled, but the result iteration was allowed to continue. I'm not so sure that those types of failures weren't leaking transactions either - that should be fixed now too.

This stuff is hard to write tests for with Gremlin Server as I dont' know how to force raise a commit exception for Neo4j.  I was able to test externally with graphs that were easier to force that condition.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/9f85d3ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/9f85d3ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/9f85d3ed

Branch: refs/heads/tp31
Commit: 9f85d3ed73e41313fc5f7981a1899ed0f8482fa6
Parents: 94ca074
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Feb 3 15:28:25 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Feb 3 15:28:25 2016 -0500

----------------------------------------------------------------------
 .../server/op/AbstractEvalOpProcessor.java      | 38 ++++++++++++--------
 1 file changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9f85d3ed/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
index aab9950..ca2e055 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
@@ -57,7 +57,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.function.Supplier;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
 import static com.codahale.metrics.MetricRegistry.name;
 
@@ -291,7 +290,15 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
                     // serialize here because in sessionless requests the serialization must occur in the same
                     // thread as the eval.  as eval occurs in the GremlinExecutor there's no way to get back to the
                     // thread that processed the eval of the script so, we have to push serialization down into that
-                    serializeResponseMessage(ctx, msg, serializer, useBinary, aggregate, code);
+                    Frame frame;
+                    try {
+                        frame = makeFrame(ctx, msg, serializer, useBinary, aggregate, code);
+                    } catch (Exception ex) {
+                        // exception is handled in makeFrame() - serialization error gets written back to driver
+                        // at that point
+                        if (manageTransactions) attemptRollback(msg, context.getGraphManager(), settings.strictTransactionManagement);
+                        break;
+                    }
 
                     // only need to reset the aggregation list if there's more stuff to write
                     if (toIterate.hasNext())
@@ -311,8 +318,10 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
                     }
 
                     // the flush is called after the commit has potentially occurred.  in this way, if a commit was
-                    // required then it will be 100% complete before the client receives it.
-                    ctx.flush();
+                    // required then it will be 100% complete before the client receives it. the "frame" at this point
+                    // should have completely detached objects from the transaction (i.e. serialization has occurred)
+                    // so a new one should not be opened on the flush down the netty pipeline
+                    ctx.writeAndFlush(frame);
                 }
             } else {
                 // don't keep triggering this warning over and over again for the same request
@@ -339,23 +348,21 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
         stopWatch.stop();
     }
 
-    private static void serializeResponseMessage(final ChannelHandlerContext ctx, final RequestMessage msg,
-                                                 final MessageSerializer serializer, final boolean useBinary, List<Object> aggregate,
-                                                 final ResponseStatusCode code) {
+    private static Frame makeFrame(final ChannelHandlerContext ctx, final RequestMessage msg,
+                                   final MessageSerializer serializer, final boolean useBinary, List<Object> aggregate,
+                                   final ResponseStatusCode code) throws Exception {
         try {
             if (useBinary) {
-                ctx.write(new Frame(
-                        serializer.serializeResponseAsBinary(ResponseMessage.build(msg)
-                        .code(code)
-                        .result(aggregate).create(), ctx.alloc())));
+                return new Frame(serializer.serializeResponseAsBinary(ResponseMessage.build(msg)
+                                .code(code)
+                                .result(aggregate).create(), ctx.alloc()));
             } else {
                 // the expectation is that the GremlinTextRequestDecoder will have placed a MessageTextSerializer
                 // instance on the channel.
                 final MessageTextSerializer textSerializer = (MessageTextSerializer) serializer;
-                ctx.write(new Frame(
-                        textSerializer.serializeResponseAsString(ResponseMessage.build(msg)
-                        .code(code)
-                        .result(aggregate).create())));
+                return new Frame(textSerializer.serializeResponseAsString(ResponseMessage.build(msg)
+                                .code(code)
+                                .result(aggregate).create()));
             }
         } catch (Exception ex) {
             logger.warn("The result [{}] in the request {} could not be serialized and returned.", aggregate, msg.getRequestId(), ex);
@@ -365,6 +372,7 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
                     .statusMessage(errorMessage)
                     .code(ResponseStatusCode.SERVER_ERROR_SERIALIZATION).create();
             ctx.writeAndFlush(error);
+            throw ex;
         }
     }
 


[3/3] incubator-tinkerpop git commit: Updated changelog.

Posted by sp...@apache.org.
Updated changelog.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/f06cf664
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/f06cf664
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/f06cf664

Branch: refs/heads/tp31
Commit: f06cf664737c2009d55cba27417a4d218e5082a5
Parents: f3ef0e0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 12 18:42:03 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Feb 12 18:42:03 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f06cf664/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ef8c606..f4d02f7 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -29,6 +29,7 @@ TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 * Fixed bug in "round robin" load balancing in `gremlin-driver` where requests were wrongly being sent to the same host.
 * Prevented the spawning of unneeded reconnect tasks in `gremlin-driver` when a host goes offline.
 * Fixed bug preventing `gremlin-driver` from reconnecting to Gremlin Server when it was restarted.
+* Better handled errors that occurred on commits and serialization in Gremlin Server to first break the result iteration loop and to ensure commit errors were reported to the client.
 * Added GraphSON serializers for the `java.time.*` classes.
 * Improved the logging of the Gremlin Server REST endpoint as it pertained to script execution failures.
 * `TraversalExplanation` is now `Serializable` and registered with `GryoMapper`.


[2/3] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP-1106' into tp31

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/TINKERPOP-1106' into tp31


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/f3ef0e0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/f3ef0e0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/f3ef0e0c

Branch: refs/heads/tp31
Commit: f3ef0e0cc9cf6ada2713390f4dba0bc5203ee9c3
Parents: 9aba328 9f85d3e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 12 18:24:16 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Feb 12 18:24:16 2016 -0500

----------------------------------------------------------------------
 .../server/op/AbstractEvalOpProcessor.java      | 38 ++++++++++++--------
 1 file changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f3ef0e0c/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
----------------------------------------------------------------------