Reputation: 922
I Have created a keyspace
CREATE KEYSPACE xyz WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '1', 'datacenter1': '1'} AND durable_writes = true;
I have only two nodes and both DC1 as well as datacenter1 nodes are up. Now when i'm trying to execute an batch of insert statements
Insert insert = QueryBuilder.insertInto(keyspace, table).ifNotExists()
.value("home", fieldsToUpdate.getHome())
.value("subCategoryName", fieldsToUpdate.getSubCategoryName())
.value("id", fieldsToUpdate.getId());
batch.add(insert);
session.execute(batch);
I get an exception saying
Caused by: com.datastax.driver.core.exceptions.UnavailableException: Not enough replica available for query at consistency QUORUM (2 required but only 1 alive)
When i remove .ifNotExists() clause batch executes without any exception.
Using datastax driver version 2.1.7 .
What should i do to resolve the issue?
Edit: Nodetool Status
abhisheks-MacBook-Pro:bin abhishekagarwal$ sudo ./nodetool status
objc[3398]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 192.168.1.111 19.81 MB 256 ? f2651124-abdf-486a-a6d7-53327bc2d98c RAC1
UN 192.168.1.5 5.22 MB 256 ? d0c72798-1186-4bcb-9e0f-634964a3d083 rack1
Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless
Upvotes: 1
Views: 412
Reputation: 9475
The problem is you have defined the keyspace to keep one replica in 'datacenter1' and one replica in datacenter 'DC1'. But you don't have a data center called 'DC1', so it is not possible to get a quorum of replicas in the two data centers for the if not exists
clause.
So you should have defined the keyspace like this:
CREATE KEYSPACE xyz WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '1'}
Upvotes: 2