jorgebay / node-cassandra-cql

Node.js driver for Apache Cassandra
MIT License
144 stars 42 forks source link

Default Consistency needs mandatory override? #74

Open PrithivirajDamodaran opened 10 years ago

PrithivirajDamodaran commented 10 years ago

As wiki and NPM description says default consistency is QUORUM and it is optional for as shown client.execute(query, [params], [consistency], callback).

How come for default consistency Simple Select queries not working throwing consistency issues. I had to use var consistency = cql.types.consistencies.one; to help get my simple select query working.

Even client.execute examples shown in wiki/npm uses default consistency, am i missing something ?

Please advice.

jorgebay commented 10 years ago

A Cassandra cluster can respond with "Can not achieve consistency quorum" when some of the nodes are down, this is an expected behaviour.

For example, you have a keyspace with replication factor 2 and one of the nodes it is not responding.

If this is what is happening, then is an expected behaviour. You should tune the consistency level per query, the default values are just that...

PrithivirajDamodaran commented 10 years ago

Thanks for the inputs,

Here are my values

  1. I have a key space with replication factor 1.
  2. I have only one cassandra node and it was up (as the nodetool said)

Should i look for anything else?

jorgebay commented 10 years ago

Using quorum on one node cluster should not be a problem. If you are getting an error, could you post it?

PrithivirajDamodaran commented 10 years ago

Sure. attached screen shot

screen shot 2014-03-30 at 10 29 33 pm

In the above code, i need uncomment the consistency declaration and use it along with query everything works fine.

jorgebay commented 10 years ago

Its a PoolConnectionError, it means that the connection could not be established to any of the nodes (in your case 1).

You should check if your node... Have you tried using cqlsh tool?

PrithivirajDamodaran commented 10 years ago

Does a PoolConnectionError go away if i introduce consistency override ?

ivarconr commented 10 years ago

Should the consistency level not default to ONE? http://www.datastax.com/docs/1.0/references/cql/index#specifying-consistency-level

asilvas commented 10 years ago

Changing that default would be very bad. Rely on a wrapper to provide YOUR default consistency, like priam: https://github.com/godaddy/node-priam

ivarconr commented 10 years ago

Agreed. Too bad it wasn't the expected default from the beginning.