You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Manu Chadha <ma...@hotmail.com> on 2020/06/12 10:17:31 UTC
Do I understand the working of RF and CL correctly?
Hi
Just want to confirm whether I understand RF and CL correctly.
I have got 2 Cassandra nodes up
C:\Users\manuc\Documents\manu\codingjedi>docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1923093e84f3 app:30may2020 "/bin/sh -c 'codingj…" 21 hours ago Up 22 minutes 0.0.0.0:9000->9000/tcp hardcore_bardeen
381fd5996008 app:30may2020 "/bin/sh -c 'codingj…" 21 hours ago Exited (255) 24 minutes ago stupefied_wozniak
85dd140e19dd ca795bbd8fd7 "docker-entrypoint.s…" 21 hours ago Up 24 minutes 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp cassandra2
f70caa70fe81 ca795bbd8fd7 "docker-entrypoint.s…" 21 hours ago Up 25 minutes 7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:9042->9042/tcp cassandra1
The Replication Factor for my Keyspace is 3
cqlsh> describe keyspace mykeyspace;
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;
But when I run a query to add in the database, it successfully gets executed. I thought that the query will fail as RF is 3.
I suppose I am getting confused between Replication Factor (RF) and Consistency Level (CL). If less no. of nodes are up then the query will still work as long as Consistency Level is satisfied. The Consistency Level is one (by default) so the code works. If I change CL to 3 then the query fails. Regarding RF, when the 3rd node comes up then it gets the data from other 2 nodes.
Thanks
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
Re: Do I understand the working of RF and CL correctly?
Posted by manish khandelwal <ma...@gmail.com>.
Yes Manu you are correct in your understanding. Consistency level defines
minimum number of nodes that must acknowledge a read or write operation
before the operation can be considered as successful. In your case, since
two nodes were up and you queried with CL 1, your request was successful.
That is the reason your queries failed with CL ALL or CL 3, since enough
replicas are not available for acknowledging read or write request.
Replication factor defines how many replicas of data you need to keep.
On Fri, Jun 12, 2020 at 3:47 PM Manu Chadha <ma...@hotmail.com> wrote:
> Hi
>
>
>
> Just want to confirm whether I understand RF and CL correctly.
>
>
>
> I have got 2 Cassandra nodes up
>
> C:\Users\manuc\Documents\manu\codingjedi>docker container ps -a
>
> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
>
> 1923093e84f3 app:30may2020 "/bin/sh -c 'codingj…" 21 hours ago Up 22 minutes 0.0.0.0:9000->9000/tcp hardcore_bardeen
>
> 381fd5996008 app:30may2020 "/bin/sh -c 'codingj…" 21 hours ago Exited (255) 24 minutes ago stupefied_wozniak
>
> 85dd140e19dd ca795bbd8fd7 "docker-entrypoint.s…" 21 hours ago Up 24 minutes 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp cassandra2
>
> f70caa70fe81 ca795bbd8fd7 "docker-entrypoint.s…" 21 hours ago Up 25 minutes 7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:9042->9042/tcp cassandra1
>
>
>
> The Replication Factor for my Keyspace is 3
>
> cqlsh> describe keyspace mykeyspace;
>
>
>
> CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;
>
>
>
> But when I run a query to add in the database, it successfully gets
> executed. I thought that the query will fail as RF is 3.
>
> I suppose I am getting confused between Replication Factor (RF) and
> Consistency Level (CL). If less no. of nodes are up then the query will
> still work as long as Consistency Level is satisfied. The Consistency Level
> is one (by default) so the code works. If I change CL to 3 then the query
> fails. Regarding RF, when the 3rd node comes up then it gets the data from
> other 2 nodes.
>
>
>
> Thanks
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>