Browse files

Use last_seq not update_seq

I had assumed that the update_seq value from GET /dbname would always
match the last_seq value in the changes feed. It turns out that some
changes, like PUT /dbname/_revs_limit and PUT /dbname/_security can
increase update_seq without making an entry in the changes feed.

The upshot of this discrepancy is that c-l will hang waiting for an
update that will never arrive.

The fix is to read the last_seq value from the changes feed instead
and then wait for the indexer to catch up to that value.
  • Loading branch information...
Robert Newson
Robert Newson committed Jan 7, 2012
1 parent 958d492 commit d2a4d55e18e2a85f5e8c5bfeaf6231dc8e8386e4
@@ -178,7 +178,7 @@ private void blockForLatest(final boolean staleOk) throws IOException, JSONExcep
if (staleOk) {
- final UpdateSequence latest = database.getInfo().getUpdateSequence();
+ final UpdateSequence latest = database.getLastSequence();
synchronized (this) {
long timeout = getSearchTimeout();
while (pending_seq.isEarlierThan(latest)) {
@@ -98,6 +98,12 @@ public DatabaseInfo getInfo() throws IOException, JSONException {
+ public UpdateSequence getLastSequence() throws IOException, JSONException {
+ final JSONObject result = new JSONObject(HttpUtils.get(httpClient, url
+ + "_changes?limit=0&descending=true"));
+ return UpdateSequence.parseUpdateSequence(result.getString("last_seq"));
+ }
public <T> T handleAttachment(final String doc, final String att,
final ResponseHandler<T> handler) throws IOException {
final HttpGet get = new HttpGet(url + "/" + Utils.urlEncode(doc) + "/"

0 comments on commit d2a4d55

Please sign in to comment.