我有一个启用搜索的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>
任何人都知道可能导致这样的事情?这只是数据损坏吗?
答案 0 :(得分:0)
所以我在RIAK邮件列表的帮助下解决了这个问题。事实证明,使用了一个隐藏的搜索存储桶,并且它的设置是基于基础存储桶设置的。
很好地发布了您的搜索存储区必须将其allow_mult属性设置为false,但由于隐藏存储区和搜索存储区属性未自动同步,因此仅此一项是不够的。
我的问题是我将基础存储桶上的allow_mult设置为false,但隐藏的搜索存储桶仍设置为true。
因此,解决方案是在您的存储桶上将allow_mult设置为false,并在riaks私人搜索存储桶上将其设置为false,该存储桶与您的存储桶同名但以“ rsid为前缀” '所以对于桶'foo'你必须在'foo'和'_rsid_foo'上将allow_mult设置为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>