When I run a query with a large resultset (60k documents for some kind of export) I am getting an error like this:
Error: java.lang.IllegalStateException: The content of this Observable (queryRow. / 0169c97b-99da-4ff0-90f1-569dfd5b08e1) is already released. Subscribe earlier or tune the CouchbaseEnvironment#autoreleaseAfter() setting.
This is how I execute the query with adhoc=false: N1qlQuery q = N1qlQuery.parameterized(queryString, params, N1qlParams.build().pretty(false).adhoc(false));
When I switch adhoc=true then everything is fine and I do not get this error.
Couchbase Sever Version: "4.6.0-3453-enterprise" Java SDK: v2.3.5
Any hints on why this happens and what I can do to use adhoc=false and use prepared statements?
Hi @synesty, It happens if there wasn’t a subscription, but for blocking sync api we should be consuming as the response comes in. Lets try this, can you increase autoreleaseAfter timeout using environment builder, it is 2 seconds by default and see if it helps
It is not specific to adhoc. Adhoc as false uses a different path to query as it is prepared, sdk would prepare and cache the query plans and execute the query with the plan. All the query response observables have auto release timeout set. It is possible that in your case, observables during prepare phase run into timeouts. It should not happen per se if there weren’t delays in consuming the response, so let’s see if increasing the timeout fixes it, else debug/trace logs may help diagnose it.
autoReleaseAfter=50000 has helped. 5000 was too small, probably because the query takes longer.
env = DefaultCouchbaseEnvironment
// autoReleaseAfter is to avoid "The content of this Observable is already released." errors
// see https://www.couchbase.com/forums/t/n1ql-query-with-adhoc-false-query-runs-into-illegalstateexception-the-content-of-this-observable-is-already-released/11004/4?u=synesty