neo4j-javascript-driver icon indicating copy to clipboard operation
neo4j-javascript-driver copied to clipboard

"Index out of range" exception on buffer

Open omerbn opened this issue 8 years ago • 14 comments

This happens sporadically, but reproduced every few minutes.

Exception stack: RangeError: Index out of range at checkOffset (buffer.js:977:11) at Buffer.readUInt8 (buffer.js:1015:5) at NodeBuffer.getUInt8 (.\node_modules\neo4j-driver\lib\v1\internal\buf.js:713:27) at NodeBuffer.readUInt8 (.\node_modules\neo4j-driver\lib\v1\internal\buf.js:245:19) at Unpacker.unpack (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:406:27) at Unpacker._unpackListWithSize (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:521:25) at Unpacker._unpackList (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:505:21) at Unpacker.unpack (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:429:23) at path (.\node_modules\neo4j-driver\lib\v1\internal\connector.js:164:25) at Unpacker._unpackStructWithSize (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:591:16) at Unpacker._unpackStruct (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:576:21) at Unpacker.unpack (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:444:25) at Unpacker._unpackListWithSize (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:521:25) at Unpacker._unpackList (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:505:21) at Unpacker.unpack (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:429:23) at Unpacker._unpackStructWithSize (.\node_modules\neo4j-driver\lib\v1\internal\packstream.js:595:34)

omerbn avatar Feb 21 '18 12:02 omerbn

Hi @omerbn,

Thanks for reporting this problem.

Could you please provide the following info:

  • NodeJS and npm version you are using
  • neo4j-driver version
  • neo4j database version

Do you know a way for us to reproduce the problem? Which query/parameters trigger it?

lutovich avatar Feb 21 '18 14:02 lutovich

nodejs: 8.9.4 neo4j-driver: 1.5.3 npm: 5.6.0 neo4j: 3.3.1

I couldn't find a specific query(ies) that cause that. :(

omerbn avatar Feb 21 '18 15:02 omerbn

I ran all our tests with specified software versions and issue did not show up :( Stacktrace tells us that driver fails to unpack a path. Do many of your queries return paths? Are there any errors logged by the database in neo4j.log or debug.log?

lutovich avatar Feb 22 '18 09:02 lutovich

:(

I'm looking at debug.log:

I see lots of connection reset by peer: (they appear every 0.5-1 seconds.)

2018-02-21 11:57:05.250+0000 ERROR [o.n.b.t.SocketTransportHandler] Fatal error occurred when handling a client connection: syscall:read(..) failed: Connection reset by peer syscall:read(..) failed: Connection reset by peer io.netty.channel.unix.Errors$NativeIoException: syscall:read(..) failed: Connection reset by peer

I also found this error: (which can be related to times where I stopped the 'client', but it can also be a clue to the error I reported):

2018-02-21 12:46:18.412+0000 ERROR [o.n.b.v.t.BoltMessagingProtocolV1Handler] Failed to write response to driver Network channel towards /10.1.1.213:63903 is closed. Client has probably been stopped. org.neo4j.bolt.v1.packstream.PackOutputClosedException: Network channel towards /10.1.1.213:63903 is closed. Client has probably been stopped. at org.neo4j.bolt.v1.transport.ChunkedOutput.ensure(ChunkedOutput.java:166) at org.neo4j.bolt.v1.transport.ChunkedOutput.writeShort(ChunkedOutput.java:95) at org.neo4j.bolt.v1.packstream.PackStream$Packer.packStructHeader(PackStream.java:440) at org.neo4j.bolt.v1.messaging.BoltResponseMessageWriter.onSuccess(BoltResponseMessageWriter.java:89) at org.neo4j.bolt.v1.messaging.MessageProcessingHandler.onFinish(MessageProcessingHandler.java:100) at org.neo4j.bolt.v1.runtime.BoltStateMachine.after(BoltStateMachine.java:109) at org.neo4j.bolt.v1.runtime.BoltStateMachine.pullAll(BoltStateMachine.java:240) at org.neo4j.bolt.v1.messaging.BoltMessageRouter.lambda$onPullAll$6(BoltMessageRouter.java:114) at org.neo4j.bolt.v1.runtime.concurrent.RunnableBoltWorker.execute(RunnableBoltWorker.java:152) at org.neo4j.bolt.v1.runtime.concurrent.RunnableBoltWorker.executeBatch(RunnableBoltWorker.java:145) at org.neo4j.bolt.v1.runtime.concurrent.RunnableBoltWorker.run(RunnableBoltWorker.java:110) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) at org.neo4j.helpers.NamedThreadFactory$2.run(NamedThreadFactory.java:109)

I can send you the files if you want, as there's a chance I've missed something.

Thanks :)

omerbn avatar Feb 22 '18 10:02 omerbn

Yes, could you please attach files to this issue?

What about queries that return paths? Do you have many of those?

lutovich avatar Feb 22 '18 10:02 lutovich

Logs are full of IO errors, like you said. They all come from Epoll native transport that is by default enabled on unix. It would be nice to disable Epoll and see if error persists. It can be disabled by adding the following line to neo4j.conf:

dbms.jvm.additional=-Dorg.neo4j.bolt.transport.NettyServer.useEpoll=false

Database restart is required for this config to apply.

I've also found bunch of queries that return paths in logs. They are all listed here. Could you please run these queries manually either through neo4j-browser or simple node app to see if they trigger the unpacking issue?

lutovich avatar Feb 22 '18 12:02 lutovich

Hey, The queries you have sent me runs with no errors.

I'll disable the epoll and report back.

Thanks :)

omerbn avatar Feb 22 '18 13:02 omerbn

Hey, For few days the error doesn't reproduce, although I didn't disable epoll yet.

omerbn avatar Feb 26 '18 07:02 omerbn

@lutovich The errors are back, while running a heavy load. Are you still addressing this issue?

omerbn avatar Mar 21 '18 14:03 omerbn

Unfortunately we do not know a way to reproduce the error. I'm currently working on an issue that might be related. Error during streaming of records might result in a protocol violation and incorrect response message.

Do you have transaction timeout enabled in the database? Have you ever seen queries failing because they took too long?

Did you manage to try turning epoll off?

lutovich avatar Mar 21 '18 14:03 lutovich

Hey, thanks for the response.

  1. I have transaction timeout enabled, and I had queries that failed due to timeout only when running a big load. Unfortunately the timeout error and the reported error doesn't happen together.
  2. I disabled epoll on config.

omerbn avatar Mar 22 '18 10:03 omerbn

Is it possible for you to temporarily increase the transaction timeout value? If issue happens less with higher timeout and under high load, then problem is most likely caused by termination of transactions during result serialization in Bolt. This PR https://github.com/neo4j/neo4j/pull/11336 will be the fix.

lutovich avatar Mar 22 '18 10:03 lutovich

Hi @omerbn,

I believe this issue is resolved with the mentioned database fix. It should be available starting from neo4j 3.4.0. Please feel free to update this issue if the problem persists.

lutovich avatar Jun 05 '18 12:06 lutovich