I was doing some experiments to understand Riak. Here's something intersting I found:
I have a cluster of 2 nodes and a bucket type that has n_val
of 2
[root@co-riak002 ~]# riak-admin ring-status
================================== Claimant ===================================
Claimant: 'riak@10.172.48.68'
Status: up
Ring Ready: true
============================== Ownership Handoff ==============================
No pending changes.
============================== Unreachable Nodes ==============================
All nodes are up and reachable
[root@co-riak002 ~]# riak-admin bucket-type create testBucket '{"props":{"n_val":2}}'
testBucket created
[root@co-riak002 ~]# riak-admin bucket-type activate testBucket
testBucket has been activated
And then I wrote something into it:
[root@co-riak002 ~]# curl -XPUT -d '{"bar":"foo"}' -H "Content-Type: application/json" http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?w=2&returnbody=true
[1] 10890
[root@co-riak002 ~]#
[1]+ Done curl -XPUT -d '{"bar":"foo"}' -H "Content-Type: application/json" http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?w=2
Now I can read it fine with both r=2
and pr=2
:
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?r=2
{"bar":"foo"}
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?pr=2
{"bar":"foo"}
After I killed one of the nodes, r=2
still reads fine but not pr=2
[root@co-riak002 ~]# riak-admin ring-status
================================== Claimant ===================================
Claimant: 'riak@10.172.48.68'
Status: up
Ring Ready: true
============================== Ownership Handoff ==============================
No pending changes.
============================== Unreachable Nodes ==============================
The following nodes are unreachable: ['riak@10.172.48.66']
With r=2
:
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?r=2
{"bar":"foo"}
With pr=2
:
[root@co-riak002 ~]# curl http://localhost:8098/types/testBucket/buckets/stuff/keys/hello?pr=2
PR-value unsatisfied: 1/2
I am confused - shouldn't the Quorum number r
used in reading operation mean the number of replicas/physical nodes that need to agree before returning data? Why is it not working in this case? And why is pr
working in this case when it should mean the number of vnodes?
Am pretty new to this space. Much appreciated for any pointers.