Why does sending X-Riak-ClientId prevent subsequent updates?

Rusty Klophaus rusty at basho.com
Sat Feb 6 20:18:47 EST 2010


Hi Jay,

Interesting. While investigating this, I get different output for each store
statement:

>>> client.store('b', 'k', {'foo':0})
{'object': {'foo': 0}, '__riak_vclock__':
'a85hYGBgzGDKBVIsDL6y6zOYEhnzWBls2x8d4csCAA=='}

In the end though, I still see an object with foo=1 rather than foo=2.
I imagine what we're both seeing is that the foo=1 update is still running
when the foo=2 update starts. The default quorum settings in the Python
client _should_ prevent this, so I'm going to continue investigating, and
I'll let you know what I find.

In the meantime, can you answer some questions for me?
- Can you double check that you are running a fresh 0.8 install? Run an 'hg
tip', you should be at revision 839, and maybe do a make clean/make compile
for good measure.
- Are you running these tests on a single machine or in a cluster?
- Can you run "io:format("~p", [riak_ring_manager:get_my_ring()])." in the
Riak console and send me the output? (I'd like to double check that there
are no ghost nodes in the ring.)

Also, side note, you would normally want to re-use an object across updates,
which would prevent this problem, like this:

obj = client.store('b', 'k', {'foo':0})
obj["object"]["foo"] = 1
client.store('b', 'k', obj)
obj["object"]["foo"] = 2
client.store('b', 'k', obj)

Best,
Rusty

On Sat, Feb 6, 2010 at 6:48 PM, Jay Doane <jay.s.doane at gmail.com> wrote:

> I'm using the new (raw) riak.py client library, and testing multiple
> updates to the same object with the following doctest file (also attached):
>
> $ cat riak_test.py
>
> """
> >>> import riak
> >>> client = riak.Riak('127.0.0.1', 8098)
> >>> client.delete('b', 'k')
> >>> client.store('b', 'k', {'foo':0})
> {'object': {u'foo': 0}}
> >>> client.store('b', 'k', {'foo':1})
> {'object': {u'foo': 1}}
> >>> client.store('b', 'k', {'foo':2})
> {'object': {u'foo': 2}}
> """
>
> import doctest
> doctest.testmod()
>
>
> When run against the 0.8 release, the final store operation always fails:
>
> $ python riak_test.py
> **********************************************************************
> File "riak_test.py", line 9, in __main__
> Failed example:
>    client.store('b', 'k', {'foo':2})
> Expected:
>    {'object': {u'foo': 2}}
> Got:
>    {'object': {u'foo': 1}}
> **********************************************************************
> 1 items had failures:
>   1 of   6 in __main__
> ***Test Failed*** 1 failures.
>
>
> Usually, that's all there is to the failure, but sometimes, unpredictably,
> I see the following on the riak console:
>
> =ERROR REPORT==== 6-Feb-2010::14:53:48 ===
> webmachine error: path="/raw/b/k"
> {error,
>    {error,function_clause,
>        [{raw_http_resource,select_doc,
>             [{ctx,<<"b">>,<<"k">>,
>                  {riak_client,'riak at 127.0.0.1',<<1,11,16,235>>},
>                  2,2,2,2,"raw",local,
>                  {error,notfound},
>                  undefined,undefined,[]}]},
>         {raw_http_resource,produce_doc_body,2},
>         {raw_http_resource,accept_doc_body,2},
>         {webmachine_resource,resource_call,3},
>         {webmachine_resource,do,3},
>         {webmachine_decision_core,resource_call,1},
>         {webmachine_decision_core,accept_helper,0},
>         {webmachine_decision_core,decision,1}]}}
>
>
> However, if I alter riak.py so that it doesn't send the X-Riak_ClientId
> header, the tests all pass.  Here's the trivial diff (also attached)
>
> diff -r c4486329e4af client_lib/riak.py
> --- a/client_lib/riak.py        Wed Feb 03 15:51:26 2010 -0500
> +++ b/client_lib/riak.py        Sat Feb 06 15:31:36 2010 -0800
> @@ -135,8 +135,7 @@
>
>     @expect(200)
>     def store(self, bucket, key, obj, links=[], w=2, dw=2):
> -        uphead = {'Content-Type': 'application/json',
> -                  'X-Riak-ClientId': self.clientid}
> +        uphead = {'Content-Type': 'application/json'}
>         try:
>             uphead['X-Riak-Vclock'] = obj['__riak_vclock__']
>         except KeyError:
>
>
> Any ideas what's going on?
>
> Thanks,
> Jay
>
>
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20100206/7f4c5359/attachment.html>


More information about the riak-users mailing list