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

Jay Doane jay.s.doane at gmail.com
Sat Feb 6 18:48:58 EST 2010


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: riak_test.py
Type: text/x-python-script
Size: 314 bytes
Desc: not available
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20100206/16688af0/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: riak.diff
Type: application/octet-stream
Size: 454 bytes
Desc: not available
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20100206/16688af0/attachment.diff>


More information about the riak-users mailing list