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

stephen mallette commented on TINKERPOP-2132:
---------------------------------------------

unfortunately, this is a complicated problem to solve with out introducing a 
breaking change. i'm not even completely sure that there is a satisfactory 
workaround that i can offer. preventing this problem 100% of the time forces 
configurations of the driver that severely limit its capabilities. ultimately, 
i think that the safest thing to do for now would be to assume that {{Client}} 
is not thread-safe when using authentication (works fine without it). If you 
create one {{Client}} per thread, be sure to configure the {{Cluster}} to 
create a much smaller number of connections because if you have a ton of 
threads each creating large pools of connections which likely won't get used, 
you're going to end up with unecessary resources being used on client and 
server.

i'm still trying to think of a way to implement a fix for this without it 
creating a breaking change - expect to see the fix for 3.3.6 and 3.4.1 
irrespective of what the implementation is.

> Authentication when using multiple threads fails
> ------------------------------------------------
>
>                 Key: TINKERPOP-2132
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2132
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: driver
>    Affects Versions: 3.3.2
>            Reporter: kaiyangzhang
>            Assignee: stephen mallette
>            Priority: Major
>
> *Scenes:*
>    1. Gremlin Server  Kerberos Authentication
>    2. Multithreading using the same client
>  
> {code:java}
>        DriverRemoteConnection connection = 
> DriverRemoteConnection.using(cluster,"graphbase");
>         GraphTraversalSource g = graph.traversal().withRemote(connection);
>       Thread demo1 = new Thread(new ThreadDemo1(g));
>        Thread demo2 = new Thread(new ThreadDemo1(g));
>        Thread demo3 = new Thread(new ThreadDemo1(g));
>        Thread demo4 = new Thread(new ThreadDemo1(g));
>        Thread demo5 = new Thread(new ThreadDemo1(g));
>       Thread demo6 = new Thread(new ThreadDemo1(g));
>        Thread demo7 = new Thread(new ThreadDemo1(g)); 
>        Thread demo8 = new Thread(new ThreadDemo1(g));
>        Thread demo9 = new Thread(new ThreadDemo1(g));
>        Thread demo10 = new Thread(new ThreadDemo1(g));
> {code}
>  
> *ERROR INFO*
> {code:java}
> Exception in thread "Thread-4" java.util.concurrent.CompletionException: 
> org.apache.tinkerpop.gremlin.driver.exception.ResponseException: Failed to 
> authenticate
>  at 
> java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
>  at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
>  at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:107)
>  at 
> org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:159)
>  at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:166)
>  at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:153)
>  at 
> org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:142)
>  at 
> org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:127)
>  at 
> org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal.nextTraverser(DriverRemoteTraversal.java:108)
>  at 
> org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.processNextStart(RemoteStep.java:80)
>  at 
> org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
>  at 
> org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)
>  at com.huawei.graphbase.gremlin.ThreadDemo1.println(ThreadDemo1.java:48)
>  at com.huawei.graphbase.gremlin.ThreadDemo1.run(ThreadDemo1.java:32)
>  at java.lang.Thread.run(Thread.java:748)
>  Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: 
> Failed to authenticate
>  at 
> org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:246)
>  at 
> org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:197)
>  at 
> io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
>  at 
> org.apache.tinkerpop.gremlin.driver.Handler$GremlinSaslAuthenticationHandler.channelRead0(Handler.java:123)
>  at 
> org.apache.tinkerpop.gremlin.driver.Handler$GremlinSaslAuthenticationHandler.channelRead0(Handler.java:67)
>  at 
> io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
>  at 
> io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
>  at 
> org.apache.tinkerpop.gremlin.driver.handler.WebSocketClientHandler.channelRead0(WebSocketClientHandler.java:94)
>  at 
> io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
>  at 
> io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
>  at 
> io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)v[2072680]
>  at 
> io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
>  at 
> io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
>  at 
> io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
>  at 
> io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
>  at 
> io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
>  at 
> io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:651)
>  at 
> io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:574)
>  at 
> io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:488)
>  at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:450)
>  at 
> io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
>  ... 1 more{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to