Blocking N1QL requests

I am trying to use the ruby library to do some N1QL requests.
My problem is with N1QL requests that requires long time since they block the system until they are resolved or timeout.

My API uses Fiber and Eventmachine to handle the change of IO, so the structure that I generally use is the following:

result = EM::S.defer do

This code is working fine with old version of Couchbase v1.3.15, but with the newer version this blocks other requests to continue.
What am I doing wrong? And how do you suggest I handle N1QL request to not have this blocking issue?

Thank you a lot for your attention.

Hi @Stefano the new SDK doesn’t come with queries at bucket level. Instead the query operation has moved to the cluster and scope level.

Please refer to this doc N1QL Queries from the SDK | Couchbase Docs
for more answers.

Thank you for you answer. Probably the formulation of my question was not well done.
I am aware that the n1ql request are made at the cluster level, but the issue is the same.

Here the above example updated by using the correct wording.

result = EM::S.defer do

I am sorry for the misunderstanding.

Hi @Stefano, I’m aware of this issue, and this is temporary limitation. The asynchronous solution is in progress.

1 Like

Thank you @avsej . I am looking forward on this improvement. It is really crucial for our API.

On master branch I’ve just merged the fix, which releases GVL every time we schedule IO operation, and acquire it back once the response is ready, so it should help with the code like you have (fibers and EventMachine). You can try snapshots from our nightly repository. Here is a snippet for the Gemfile.

# use official repository
gem "couchbase", "3.1.0.snapshot.1074", :source => ""

## precompiled binaries (uncomment line with effective ABI version of ruby)
# gem "couchbase", "3.1.0.snapshot.1074", :platforms => :mri_30, :source => ""
# gem "couchbase", "3.1.0.snapshot.1074", :platforms => :mri_27, :source => ""
# gem "couchbase", "3.1.0.snapshot.1074", :platforms => :mri_26, :source => ""
# gem "couchbase", "3.1.0.snapshot.1074", :platforms => :mri_25, :source => ""

@Stefano, 3.1.0 has been published, and it does not keep GVL lock during IO.

You were really fast to correct the issue. Thank you a lot! I will test it as soon as possibile.

I did my tests and it seems to work as expected. Thank you really a lot to handle this issue.
Have a great Easter!