Riak Client Resources, Deleting a Key Doesn't Remove it from bucket.keys

Keith Bennett keith.bennett at lmnsolutions.com
Thu May 26 10:29:22 EDT 2011


All -

I just started working with Riak, and am using the riak-client Ruby gem.

When I delete a key from a bucket, and try to fetch the value associated with that key, I get a 404 error (which is reasonable).  However, it remains in the bucket's list of keys (i.e. the value returned by bucket.keys().  Why is the key still reported to exist in the bucket? Is bucket.keys cached, and therefore unaware of the deletion? Here's a riak-client Ruby script and its output in irb that illustrates this:

ree-1.8.7-2010.02 :001 > require 'riak'
 => true 
ree-1.8.7-2010.02 :002 > 
ree-1.8.7-2010.02 :003 >   client = Riak::Client.new
 => #<Riak::Client http://127.0.0.1:8098> 
ree-1.8.7-2010.02 :004 > bucket = client['links']
 => #<Riak::Bucket {links}> 
ree-1.8.7-2010.02 :005 > key = bucket.keys.first
 => "4000-17.xml" 
ree-1.8.7-2010.02 :006 > object = bucket[key]
 => #<Riak::RObject {links,4000-17.xml} [text/xml]:(6430 bytes)> 
ree-1.8.7-2010.02 :007 > object.delete
 => #<Riak::RObject {links,4000-17.xml} [text/xml]:(6430 bytes)> 
ree-1.8.7-2010.02 :008 > bucket.keys.first
 => "4000-17.xml" 
ree-1.8.7-2010.02 :009 > object = bucket[key]
Riak::HTTPFailedRequest: Expected [200, 300] from Riak but received 404. not found

	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/client/net_http_backend.rb:55:in `perform'
	from /Users/kbennett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/net/http.rb:1054:in `request'
	from /Users/kbennett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/net/http.rb:2142:in `reading_body'
	from /Users/kbennett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/net/http.rb:1053:in `request'
	from /Users/kbennett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/net/http.rb:1037:in `request'
	from /Users/kbennett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/net/http.rb:543:in `start'
	from /Users/kbennett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/net/http.rb:1035:in `request'
	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/client/net_http_backend.rb:47:in `perform'
	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/client/net_http_backend.rb:46:in `tap'
	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/client/net_http_backend.rb:46:in `perform'
	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/client/http_backend/transport_methods.rb:59:in `get'
	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/client/http_backend.rb:72:in `fetch_object'
	from /Users/kbennett/.rvm/gems/ree-1.8.7-2010.02/gems/riak-client-0.9.4/lib/riak/bucket.rb:101:in `[]'
	from riak-delete-failure.rb:9

Thanks,
Keith






More information about the riak-users mailing list