Ruby SDK 1.2 Problem with views
Hello
It seems that view access kills the connection
The following code works with Couch.client.reconnect, not otherwise
tst = Couch.client.design_docs['geoidx'].arrival(:body => {:endkey => 1000, :stale => false}).inject([]) { |vect, doc| vect << doc } item = tst.first Couch.client.reconnect tst1 = Couch.client.get(item.id)
An idea or explanation ?
Regards,
Philippe
I've filed http://www.couchbase.com/issues/browse/RCBC-68 . If you can add some details on that issue, that'd be great!
Hi pretif
What is 'Couch.client' here? Just a connection instance?
I've just tried to setup couchbase server dp4 and latest couchbase gem (1.2.0.dp6). After that I generated 100 documents
100.times{|t| Couchbase.bucket.set("foo-%03d" % t, :idx => t)}
And executed simple map function (default on admin console)
function (doc) { emit(doc._id, null); }
Couchbase.bucket.design_docs["test"].test.to_a Couchbase.bucket.get("foo-001")
All seems working. Could you describe your environment a bit more and maybe you have minimal script reproducing the issue?
Thanks a lot
I'm having a similar problem with the Ruby 1.2 SDK talking to Couchbase 2.0 DP4. I've followed the directions for installation and am running with the following config (on OSX 10.8):
$ brew info libcouchbase libcouchbase: stable 1.0.4 http://couchbase.com/develop/c/current Depends on: libevent, libvbucket /usr/local/Cellar/libcouchbase/9 (17 files, 460K) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/libcouchbase.rb
And in my Gemfile:
gem 'couchbase', '~> 1.2.0.dp'
I'm running with the following Ruby code:
url = "http://127.0.0.1:8091/pools/default" bucket = "somebucket" password = "somepassword" couch = Couchbase.connect(url, :bucket => bucket, :username => bucket, :password => password) docs = couch.client.design_docs["mydocs"] # <-- app just stalls on this line here
Any ideas on why it's stalling on getting the design_docs entry? Everything else works in the library (gets, sets, etc). I'm wondering if my homebrew installation of libcouchbase is broken.
Thanks,
-- Joel
interesting case. because DP version requires preview of libcouchbase Wich isn't available in main bombers repository and should. be installed from couchbase/homebrew.
could you post list of active gems, are you sure the gemfile is loading?
The right gems are loading for sure (excerpt from 'gem list'):
couchbase (1.2.0.dp6, 1.1.3, 1.1.2)
When I step through the code as well, it has all the right 1.2.0 methods (it'd throw an exception otherwise).
I think my version of libcouchbase is incorrect though. I removed all of them through brew and manually changed the recipe to be the one from https://raw.github.com/couchbase/homebrew/preview/Library/Formula/libcou.... 'brew info libcouchbase' now looks like this:
$ brew info libcouchbase libcouchbase: stable 9 http://couchbase.com/develop/c/next Depends on: libevent, libvbucket /usr/local/Cellar/libcouchbase/9 (17 files, 460K) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/libcouchbase.rb
Outside of restarting the app... is there anything else I need to do?
Hi again.
There are two issues actually: one on the server and another one on the client.
1) The ruby client doesn't react on HTTP error codes during view result fetching. I've fixed that in this change http://review.couchbase.org/19436
Given this patch applied, you will get something like this one you will try to access views on protected bucket on DP4 server:
> Couchbase.connect(:bucket => 'protected', :password => 'secret').all_docs.to_a
Couchbase::Error::View: http_error: failed to execute couch request (key="_all_docs", status="401" (Unauthorized), error=0x15)
from /home/avsej/code/couchbase/couchbase-ruby/lib/couchbase/view.rb:281:in `block in fetch'
from /home/avsej/code/couchbase/couchbase-ruby/lib/couchbase/view.rb:273:in `loop'
from /home/avsej/code/couchbase/couchbase-ruby/lib/couchbase/view.rb:273:in `fetch'
from /home/avsej/code/couchbase/couchbase-ruby/lib/couchbase/view.rb:88:in `each'
from (irb):2:in `to_a'
from (irb):2
from /home/avsej/.rbenv/versions/1.9.2-p320/bin/irb:12:in `<main>'Therefore we came to another issue:
2) In old versions like Couchbase Server DP4, the basic authentication wasn't required for views, moreover as you can see above, the server rejects all queries even they have correct Authorization header. This behaviour was fixed in recent versions, so the auth is always required for protected buckets and latest version of the libcouchbase has appropriate patch applied.
As the solution, you should either use previous couchbase ruby client (with previous version of the libcouchbase), or install more recent version of ther server http://www.couchbase.com/downloads-all#couchbase-server-2-0-builds
Thanks
2) In old versions like Couchbase Server DP4, the basic authentication wasn't required for views, moreover as you can see above, the server rejects all queries even they have correct Authorization header. This behaviour was fixed in recent versions, so the auth is always required for protected buckets and latest version of the libcouchbase has appropriate patch applied.
As the solution, you should either use previous couchbase ruby client (with previous version of the libcouchbase), or install more recent version of ther server http://www.couchbase.com/downloads-all#couchbase-server-2-0-builds
I've tried a few of the builds (1495, 1482, 1468) and they all complain about there being an error starting up when I try to run them. My only option is to quit or view error logs. From what I can see:
[Fri, 10 Aug 2012 01:06:51 GMT] [info] [<0.185.0>] Apache CouchDB has started on http://0.0.0.0:8092/
[Fri, 10 Aug 2012 01:06:53 GMT] [error] [<0.572.0>] {error_report,<0.63.0>,
{<0.572.0>,crash_report,
[[{initial_call,
{mc_tcp_listener,init,['Argument__1']}},
{pid,<0.572.0>},
{registered_name,[]},
{error_info,
{exit,badarg,
[{gen_tcp,listen,2},
{mc_tcp_listener,init,1},
{proc_lib,init_p_do_apply,3}]}},
{ancestors,
[mc_sup,ns_server_sup,ns_server_cluster_sup,
<0.64.0>]},
{messages,[]},
{links,[<0.569.0>]},
{dictionary,[]},
{trap_exit,false},
{status,running},
{heap_size,233},
{stack_size,24},
{reductions,185}],
[]]}}Any thoughts?
There is issue ticket, linked to this post, please reopen it if the problem still exists. http://www.couchbase.com/issues/browse/RCBC-68
At the moment, no. Which version are you using? We just recently had some updates.