I have some code which was working before I upgraded to Couchbase 4.6dp this morning. In doing so, I was forced to upgrade my Java Client to 2.3.5/1.3.5 and I also updated ReactiveX to 1.2.3.
There is now a much more subtle bug in this setup which appears to be connected to trying to merge the results of two asynchronous queries. I’ve managed to reproduce it in a relatively simple example based on the beer-sample, extraneous code deleted:
SimpleN1qlQuery q1 = N1qlQuery.simple("select name from `beer-sample` where code = '94017'"); SimpleN1qlQuery q2 = N1qlQuery.simple("select name from `beer-sample` where code = '94107'"); { Observable<N1qlMetrics> mt = Observable.merge(bucket.async().query(q1), bucket.async().query(q2)).flatMap(x -> x.info()); BlockingObservable<Integer> map = mt.map(i -> i.resultCount()).toBlocking(); Iterator<Integer> it = map.getIterator(); while (it.hasNext()) System.out.println("forward, have " + it.next()); } { Observable<N1qlMetrics> mt = Observable.merge(bucket.async().query(q2), bucket.async().query(q1)).flatMap(x -> x.info()); BlockingObservable<Integer> map = mt.map(i -> i.resultCount()).toBlocking(); Iterator<Integer> it = map.getIterator(); while (it.hasNext()) System.out.println("reversed, have " + it.next()); }
The output from this in my environment is:
forward, have 0
forward, have 3
reversed, have 0
reversed, have 0
That is, with the queries one way around in merge()
, the results come back as you would expect; with the queries the other way around, both come back as “no results found”.
I’ve tagged this primarily “Couchbase Server” because I suspect the 4.6dp, but it could be part of the Java client library or even ReactiveX.