Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit d2a4d55e18e2a85f5e8c5bfeaf6231dc8e8386e4 1 parent 958d492
Robert Newson authored
2  src/main/java/com/github/rnewson/couchdb/lucene/DatabaseIndexer.java
View
@@ -178,7 +178,7 @@ private void blockForLatest(final boolean staleOk) throws IOException, JSONExcep
if (staleOk) {
return;
}
- final UpdateSequence latest = database.getInfo().getUpdateSequence();
+ final UpdateSequence latest = database.getLastSequence();
synchronized (this) {
long timeout = getSearchTimeout();
while (pending_seq.isEarlierThan(latest)) {
6 src/main/java/com/github/rnewson/couchdb/lucene/couchdb/Database.java
View
@@ -98,6 +98,12 @@ public DatabaseInfo getInfo() throws IOException, JSONException {
url)));
}
+ 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) + "/"
Please sign in to comment.
Something went wrong with that request. Please try again.