arshellium arshellium - 9 months ago 104
Apache Configuration Question

Cassandra : Error while using INSERT INTO with 'IF NOT EXISTS' from within cqlsh

I've created a Table called 'test'.

link text PRIMARY KEY,
title text,
descp text,
pubdate text,
ts timestamp

Then I insert a record into:

INSERT INTO test1(title,link,descp,pubdate, ts) VALUES('T3','','D3','date3', toTimestamp(now())) IF NOT EXISTS;

This results in an error (red colored text in cqlsh): NoHostAvailable

The Cassandra setup uses Cassandra version 3.9 on Mac OS El Capitain.
The key space is this:

CREATE KEYSPACE testkeyspace
WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};

This is configuration parameters I changed according to answers on stackoverflow:

start_rpc: true (from false)
start_native_transport: true (from false)

Still, I can't seem to pin-point why I can't run this statement of INSERT INTO usinf IF NOT EXISTS

Note that I started Cassandra using "cassandra -f"

Please help if you know what's wrong here.

Answer Source

A possibility to try, many of the drivers now use LOCAL_ONE as a default consistency level. With SimpleStrategy, you can get cases where even with all the nodes being up this can request can fail (CASSANDRA-12053) if none of the nodes in your DC has the data. That should be exposed as an UnavailableException, not a NoHostAvailable so but its worth a try to use the network topology RF instead.

Is this a 1 node cluster? Having a replication factor > number of nodes will doubtless cause issues, so per comment setting to 1 is a good idea.

Was cassandra still running at time of the query? with -f you need to keep Cassandra running in foreground or cqlsh will lose its connection and give a NoHostAvailable exception.