Java client: frequent SSLExceptions

Hi there!

We are using Fauna’s latest Java client 3.0.0 in a Kotlin 1.3 app that runs on AWS Lambda on JDK 11.

It works most of the time, but fairly regularly (a few times per hour) requests to Fauna fail with the exception below. The exception is thrown upon invoking get() on the result of an invocation of FaunaClient.query().

Has anybody else experienced this? Are these exceptions indications of outages on Fauna’s side? Are we using the client wrong? Is it a bug in the client? Any pointers will be greatly appreciated!

Cheers,

Felix

java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: SSLEngine closed already
    at java.util.concurrent.CompletableFuture.reportGet
    at java.util.concurrent.CompletableFuture.get
    at <our application code>

caused by: javax.net.ssl.SSLException: SSLEngine closed already
    at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:829)
    at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:792)
    at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:773)
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:748)
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:740)
    at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:726)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:531)
    at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:125)
    at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:356)
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:748)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:763)
    at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1089)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run

@Felix I am not aware of this exception and definitely not an indication of Faunadb outage. Probably something related to driver + load + payload size. Let me dig around to see if we can repro this. Meanwhile appreciate if you could share how your workloads are ? any load test ? TPS, payload size etc.

Hi Jay, thank you for your response. The load is low (a few requests per minute). Most of those errors occur when we Create single documents that each are about 1 kB in size when encoded as JSON. The app runs on AWS Lambda and runs Fauna queries synchronously, so there should be no possibility of client-side concurrency issues. The problem appears only sporadically, so I don’t think I have a reliable way of reproducing it.

Could it be related to this ?

1 Like

Sure sounds like it! I’ll change our Lambdas to reinstantiate FaunaClient for every run and report back here. Thanks!

So it seems that instantiating a new FaunaClient for each Lambda invocation fixes it (also probably-related exceptions like UnavailableException, NoSuchElementException, and ClosedChannelException). Thanks,@Jay-Fauna!

And a note for posterity: If you don’t FaunaClient.close() after you’re done with it, you may end up with IOExceptions or SocketExceptions about too many open files (i.e. sockets).