Reputation: 1531
I have a table called domains, which has 2 columns, one column is a string called domain which is the primary key, and the second column is named ip_addresses and is a set of inet addresses.
The code:
const cassandra = require('cassandra-driver');
const readline = require('readline');
const fs = require('fs');
const client = new cassandra.Client({
localDataCenter: 'us-east',
contactPoints: ['REDACTED'],
keyspace: 'default_keyspace'
});
const readInterface = readline.createInterface({
input: fs.createReadStream('./domains'),
output: null,
console: false
});
readInterface.on('line', async (line) => {
const splitLine = line.split(',')
const domain = splitLine[0]
splitLine.shift()
const query = `INSERT INTO domains (domain, ip_addresses) VALUES(?, ?);`;
const parsed = splitLine.map(e => `'${e}'`)
const ips = `{${parsed.join(',')}}`
console.log("IPS ", ips)
console.log('DOMAIN', domain)
client.execute(query, [ domain, ips ]).then((result) => console.log('User with email %s', result.rows[0])).catch(e => console.error(e))
});
console.log("DONE")
The values:
IPS: {'172.217.15.110'}
DOMAIN: google.com
The error says this:
ResponseError: marshaling error: read_simple_bytes - not enough bytes (requested 841888305, got 10) Backtrace: 0x326f94d
0xea40d6
0xea42a6
0xea44f1
0x17cba2e
0x17d1644
0x17d1a18
0x14ea92e
0x14ec4b6
0x15cd85e
0x15d2801
0x15aa827
0x15b1634
0x15b30fc
0x15b3f9f
0x15b5d8b
0x15b5dad
0x15baa48
0x2d7d4bc
0x2dda680
0x2dda88f
0x2e0f705
0x2d79e69
0x2d7af1e
0xd2ff96
/opt/scylladb/libreloc/libc.so.6+0x271a2
0xc5502d
What can I do to fix this?
Thanks
Upvotes: 0
Views: 387
Reputation: 576
It looks like the driver wasn't able to correctly serialize a set of IP addresses. I'm no node.js expert, but I assume that the driver simply isn't able to infer the correct type from a "{'172.217.15.110'}"
string and simply serializes it as a string.
Here's why I think the driver sent something that isn't actually a set of ip addresses: Scylla returned an error informing that the size of a buffer seems to be 841888305
. This number is represented in hex as 322E3231
, which in turn looks suspiciously like a part of an ASCII string... and it actually represents "2.21"
in ASCII, which is a substring of the string representation of the IP address you were trying to send.
In CQL, most types are serialized in the form of [4 bytes of length][data]
. Scylla definitely parsed part of your IP string as the length, which means that it expected a different data layout.
You should browse the documentation and look how to let the driver know that what you're actually trying to send is a set of IP addresses, which is a CQL type set<inet>
. Here's how I managed to put correct data from node.js into Scylla, based on your code (I hardcoded the address for simplicity, but you should get the idea):
readInterface.on('line', async (line) => {
const splitLine = line.split(',')
const domain = splitLine[0]
splitLine.shift()
const query = `INSERT INTO domains (domain, ip_addresses) VALUES(?, ?);`;
const ips = [cassandra.types.InetAddress.fromString('127.0.0.1')]
console.log("IPS ", ips)
console.log('DOMAIN', domain)
client.execute(query, [ domain, ips ]).then((result) => console.log('User with email %s', result.rows[0])).catch(e => console.error(e))
});
Upvotes: 5
Reputation: 870
Looks like Scylla crashed. What version do you run and what's the log msg? It's possible to get a stacktrace from this, you can follow the procedure on the wiki. If you run an old version, just upgrade to a supported one and retest.
Upvotes: 0