Buffer out of bounds error when reading empty byte buffers

464 views
Skip to first unread message

Gim

unread,
Oct 18, 2018, 4:30:39 PM10/18/18
to DataStax Node.js Driver for Apache Cassandra Mailing List
Hi guys,

I'm looking for some help with an issue we are hitting reading empty byte buffer with the Node driver.


I have a table created with the following schema:

cqlsh> describe table "keyspace"."table"

CREATE TABLE keyspace."table" (
    key bigint,
    column1 bigint,
    value bigint,
    PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE


The value being written is via the Java driver and an empty byte buffer is being used as the value, e.g.

ByteBuffer.wrap(new byte[0])


Note, I can read the table fine with cqlsh:

cqlsh> select * from "keyspace"."table" limit 2;

 key    | column1  | value
--------+----------+-------
 1 | 3 |      
 2 | 4 |      


Here is the stack trace when reading it via the node driver:

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds
    at boundsError (internal/buffer.js:51:11)
    at Buffer.readInt32BE (internal/buffer.js:365:5)
    at Function.Long.fromBuffer (./node_modules/cassandra-driver/lib/types/index.js:505:25)
    at Encoder.decodeLong (./node_modules/cassandra-driver/lib/encoder.js:149:17)
    at Encoder.decode (./node_modules/cassandra-driver/lib/encoder.js:1260:18)
    at Parser.parseRows (./node_modules/cassandra-driver/lib/streams.js:378:36)
    at Parser.parseResult (./node_modules/cassandra-driver/lib/streams.js:336:10)
    at Parser.parseBody (./node_modules/cassandra-driver/lib/streams.js:185:19)
    at Parser._transform (./node_modules/cassandra-driver/lib/streams.js:137:10)
    at Parser.Transform._read (_stream_transform.js:190:10)
    at Parser.Transform._write (_stream_transform.js:178:12)
    at doWrite (_stream_writable.js:410:12)
    at writeOrBuffer (_stream_writable.js:394:5)
    at Parser.Writable.write (_stream_writable.js:294:11)
    at Protocol.ondata (_stream_readable.js:666:20)
    at Protocol.emit (events.js:182:13)
  (event loop)
    at RequestHandler.send (./node_modules/cassandra-driver/lib/request-handler.js:154:13)
    at Function.send (./node_modules/cassandra-driver/lib/request-handler.js:136:14)
    at Array.utils.series.next (./node_modules/cassandra-driver/lib/client.js:874:28)
    at ./node_modules/cassandra-driver/lib/utils.js:709:21


node-driver-screenshot1.png



node-driver-screenshot2.png


Also, if there's a process for opening a JIRA directly so I can be copied on the bug that'd be great. I think the JIRA project used to be available to the OSS community in the past?


Thanks!

-Gim


Jorge Bay Gondra

unread,
Oct 19, 2018, 3:11:56 AM10/19/18
to nodejs-dr...@lists.datastax.com
Hi Gim,
You can open a JIRA ticket here, we continue to have an open workflow while we continue to put a lot of effort into the open source Node.js driver.

About the issue, that zero-length buffer should have never been accepted as a valid value, the protocol defines a bigint as a "eight-byte two's complement integer", so the driver expects that. In any case, we can look for ways to tackle this server issue on the client side. Were you planning to create a ticket on the Cassandra side to validate and reject this type of values?

Thanks,
Jorge

--
You received this message because you are subscribed to the Google Groups "DataStax Node.js Driver for Apache Cassandra Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs-driver-u...@lists.datastax.com.

Gim Mahasintunan

unread,
Oct 19, 2018, 12:04:43 PM10/19/18
to nodejs-dr...@lists.datastax.com
Hi Jorge,

Thanks so much for the quick reply.

Yes, I'll a file a bug against the Node client to see if this can be handled. In this scenario, we'd like it to be consistent with the behavior of the other drivers and CLI.

I'll leave it up to you and your team if you want to file a bug against the server for this. We already have code that's depending on writing the empty buffer values, so we're probably not looking to make any changes in behavior there - just aiming to make this consistent. If you do file a bug, could you update the thread?

Thanks again for your help!
-Gim
Reply all
Reply to author
Forward
0 new messages