1

我有一个启用了搜索的 riak 存储桶。大多数情况下,它似乎工作得相当好,但对于某些资源,它现在失败了。我看不到失败的资源有什么特别之处。

这是我得到的一个真正的例外:

>>> key = '/data/v2/search_show/TMS.Person.1485'
>>> item = b.get(key)
>>> item.get_data()
{u'type': u'person', u'expires': u'9999999999', u'subject_name': u'Paul Rodriguez', u'sub_type': u'__None__', u'topic': u'__ref--/data/v2/topic/TMS.Person.1485:r1382637028.194730', u'person': u'__None__', u'searchable_key': u'rodriguez paulrodriguez paul', u'date': u'0000-00-00', u'sport': u'__None__', u'genre': u'__None__', u'id': u'/data/v2/search_show/TMS.Person.1485'}
>>> item.get_siblings()
[]
>>> item.store()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/riak/riak_object.py", line 438, in store
    if_none_match=if_none_match)
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http.py", line 173, in put
    key=robj.get_key())
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http.py", line 182, in do_put
    return self.parse_body(response, [200, 201, 300])
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http.py", line 383, in parse_body
    self.check_http_code(response, expected_statuses)
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http.py", line 369, in check_http_code
    (expected_statuses, status, response[1]))
Exception: Expected status [200, 201, 300], received 500 : <html><head><title>500 Internal Server Error</title></head><body><h1>Internal Server Error</h1>The server encountered an error while processing this request:<br><pre>{error,
    {error,badarg,
        [{erlang,iolist_to_binary,
             [{hook_crashed,
                  {riak_search_kv_hook,precommit,error,
                      {badmatch,
                          [{{dict,3,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 []},
                                {{[],[],[],[],[],[],[],[],[],[],
                                  [[<<"X-Riak-VTag">>,51,57,117,77,117,89,54,
                                    81,83,81,89,67,98,52,84,80,86,50,99,115,
                                    55,116]],
                                  [[<<"index">>]],
                                  [],
                                  [[<<"X-Riak-Last-Modified">>|
                                    {1382,637028,329550}]],
                                  [],[]}}},
                            {riak_idx_doc,<<"ctv_tvdata">>,
                                <<"/data/v2/search_show/TMS.Person.1485">>,
                                [{<<"date">>,<<"0000-00-00">>,
                                  [{<<"0000-00-00">>,[0]}]},
                                 {<<"expires">>,<<"9999999999">>,
                                  [{<<"9999999999">>,[0]}]},
                                 {<<"genre">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"id">>,
                                  <<"/data/v2/search_show/TMS.Person.1485">>,
                                  [{<<"/data/v2/search_show/TMS.Person.1485">>,
                                    [0]}]},
                                 {<<"person">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"searchable_key">>,
                                  <<"rodriguez paulrodriguez paul">>,
                                  [{<<"paulrodriguez">>,[1]},
                                   {<<"paul">>,[2]},
                                   {<<"rodriguez">>,[0]}]},
                                 {<<"sport">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"sub_type">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"subject_name">>,<<"Paul Rodriguez">>,
                                  [{<<"Paul">>,[0]},{<<"Rodriguez">>,[1]}]},
                                 {<<"topic">>,
                                  <<"__ref--/data/v2/topic/TMS.Person.1485:r1382637028.194730">>,
                                  [{<<"__ref--/data/v2/topic/TMS.Person.1485:r1382637028.194730">>,
                                    [0]}]},
                                 {<<"type">>,<<"person">>,
                                  [{<<"person">>,[0]}]}],
                                [],
                                [{<<"expires">>,<<"9999999999">>,
                                  [<<"9999999999">>]},
                                 {<<"type">>,<<"person">>,[<<"person">>]}],
                                true}},
                           {{dict,3,16,16,8,80,48,
                                {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
                                 []},
                                {{[],[],[],[],[],[],[],[],[],[],
                                  [[<<"X-Riak-VTag">>,113,51,102,55,90,82,113,
                                    56,73,51,90,69,116,53,115,68,51,49,52,75,
                                    115]],
                                  [[<<"index">>]],
                                  [],
                                  [[<<"X-Riak-Last-Modified">>|
                                    {1382,637028,329664}]],
                                  [],[]}}},
                            {riak_idx_doc,<<"ctv_tvdata">>,
                                <<"/data/v2/search_show/TMS.Person.1485">>,
                                [{<<"date">>,<<"0000-00-00">>,
                                  [{<<"0000-00-00">>,[0]}]},
                                 {<<"expires">>,<<"9999999999">>,
                                  [{<<"9999999999">>,[0]}]},
                                 {<<"genre">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"id">>,
                                  <<"/data/v2/search_show/TMS.Person.1485">>,
                                  [{<<"/data/v2/search_show/TMS.Person.1485">>,
                                    [0]}]},
                                 {<<"person">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"searchable_key">>,
                                  <<"rodriguez paulrodriguez paul">>,
                                  [{<<"paulrodriguez">>,[1]},
                                   {<<"paul">>,[2]},
                                   {<<"rodriguez">>,[0]}]},
                                 {<<"sport">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"sub_type">>,<<"__None__">>,
                                  [{<<"__None__">>,[0]}]},
                                 {<<"subject_name">>,<<"Paul Rodriguez">>,
                                  [{<<"Paul">>,[0]},{<<"Rodriguez">>,[1]}]},
                                 {<<"topic">>,
                                  <<"__ref--/data/v2/topic/TMS.Person.1485:r1382637028.194730">>,
                                  [{<<"__ref--/data/v2/topic/TMS.Person.1485:r1382637028.194730">>,
                                    [0]}]},
                                 {<<"type">>,<<"person">>,
                                  [{<<"person">>,[0]}]}],
                                [],
                                [{<<"expires">>,<<"9999999999">>,
                                  [<<"9999999999">>]},
                                 {<<"type">>,<<"person">>,[<<"person">>]}],
                                true}}]}}}],
             []},
         {wrq,append_to_response_body,2,[{file,"src/wrq.erl"},{line,210}]},
         {riak_kv_wm_object,handle_common_error,3,
             [{file,"src/riak_kv_wm_object.erl"},{line,1046}]},
         {webmachine_resource,resource_call,3,
             [{file,"src/webmachine_resource.erl"},{line,186}]},
         {webmachine_resource,do,3,
             [{file,"src/webmachine_resource.erl"},{line,142}]},
         {webmachine_decision_core,resource_call,1,
             [{file,"src/webmachine_decision_core.erl"},{line,48}]},
         {webmachine_decision_core,accept_helper,1,
             [{file,"src/webmachine_decision_core.erl"},{line,615}]},
         {webmachine_decision_core,decision,1,
             [{file,"src/webmachine_decision_core.erl"},{line,518}]}]}}</pre><P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></body></html>

任何人都知道什么会导致这样的事情?仅仅是数据损坏吗?

4

1 回答 1

0

所以我在 RIAK 邮件列表的帮助下解决了这个问题。事实证明,使用了一个隐藏的搜索桶,并且它的设置是基于基本桶设置的。

已经很好地发布了您的搜索存储桶必须将其 allow_mult 属性设置为 false 但这还不够,因为隐藏存储桶和搜索存储桶属性不会自动同步。

我的问题是我已将基本存储桶上的 allow_mult 设置为 false,但隐藏的搜索存储桶仍将其设置为 true。

因此,解决方案是在您的存储桶上将 allow_mult 设置为 false,并在 riaks 私有搜索存储桶上将其设置为 false,该存储桶与您的存储桶同名但前缀为“ rsid ”,因此对于存储桶“foo”,您必须将 allow_mult 设置为'foo' 和 '_rsid_foo' 都为 false

#The bucket had allow_mult set to true:
$ curl 'http://10.1.2.95:8098/buckets/_rsid_ctv_tvdata/props'
{"props": "name":"_rsid_ctv_tvdata","allow_mult":true,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"dw":0,"last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"n_val":3,"notfound_ok":false,"old_vclock":86400,"postcommit":[],"pr":0,"precommit":[],"pw":0,"r":1,"rw":1,"small_vclock":50,"w":1,"young_vclock":20}}

#I fixed it in the python console since that is where I'm more comfortable.  And just to be sure I attempted the same riak PUT both before and after.

>>> import riak
>>> r = riak.RiakClient()
>>> b = r.bucket('ctv_tvdata')
>>> o = b.get('/data/v2/search_show/TMS.Show.9838380')
>>> o.store()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/riak/riak_object.py", line 281, in store
timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/riak/client/transport.py", line 127, in wrapper
    return self._with_retries(pool, thunk)
  File "/usr/local/lib/python2.7/dist-packages/riak/client/transport.py", line 69, in _with_retries
return fn(transport)
  File "/usr/local/lib/python2.7/dist-packages/riak/client/transport.py", line 125, in thunk
return fn(self, transport, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/riak/client/operations.py", line 289, in put
timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http/transport.py", line 144, in put
return self._parse_body(robj, response, [200, 201, 204, 300])
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http/codec.py", line 64, in _parse_body
self.check_http_code(status, expected_statuses)
  File "/usr/local/lib/python2.7/dist-packages/riak/transports/http/transport.py", line 446, in check_http_code
    (expected_statuses, status))
Exception: Expected status [200, 201, 204, 300], received 500
>>> b2 = r.bucket('_rsid_ctv_tvdata')
>>> b2.get_properties()
{'old_vclock': 86400, 'pr': 0, 'allow_mult': True, 'big_vclock': 50, 'name': '_rsid_ctv_tvdata', 'chash_keyfun': {'fun': 'chash_std_keyfun', 'mod': 'riak_core_util'}, 'n_val': 3, 'notfound_ok': False, 'linkfun': {'fun': 'mapreduce_linkfun', 'mod': 'riak_kv_wm_link_walker'}, 'pw': 0, 'last_write_wins': False, 'r': 1, 'small_vclock': 50, 'rw': 1, 'basic_quorum': False, 'postcommit': [], 'dw': 0, 'w': 1, 'young_vclock': 20, 'precommit': []}
>>> b2.set_property('allow_mult', False)
>>> o = b.get('/data/v2/search_show/TMS.Show.9838380')
>>> o.store()
<riak.riak_object.RiakObject object at 0x250ca10>
于 2014-01-07T18:58:47.403 回答