Galeria-Kaufhof / pillar

Pillar manages migrations for your Cassandra data stores.

Home Page:https://github.com/Galeria-Kaufhof/pillar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to configure a different ConsistencyLevel than QUORUM

julienmoumne opened this issue · comments

In a development/test context, having a cluster with more than one node is not necessarily possible.

Would it be possible to add a config entry to set the consistency to ONE in order to avoid having the error bellow?

Not enough replicas available for query at consistency QUORUM (2 required but only 1 alive)))

Did you use de.kaufhof.pillar.CassandraMigrator#initialize without passing a ReplicationStrategy? In this case a default SimpleStrategy instance with 'replication_factor': '3' will be created.
This will not work on a single node cassandra.

Use desc keyspace on a cqlsh to check your keyspace
Should produce output like the following

CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;

If replication_factor is > 1, that's the root cause of your error. So you either need to pass SimpleStrategy(replicationFactor = 1) to the initialize method or create the keyspace manually beforehand.

Regarding Consistency Level: QUORUM is not the problem here for the above mentioned reasons (QUORUM works fine on a single node cassandra if the replication_factor matches), but if you still want to change it, this has to be set when building the cluster which is used to create the session used by pillar.

val queryOptions = new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM)
    val cluster: Cluster = new Builder()
      .withQueryOptions(queryOptions)
      ...

Thanks it worked!