Sync gateway _bulk_get, _changes provide different values

Hey, I have a problem with my sync gateway. In my Android app I’m using Couchbase Lite for replication of data, however recently I’ve noticed stranger behaviour as document in the app is different from one in the server, though the revision IDs are same.

Let’s say we have a document with id docId and revision some_rev, when I make a GET request, I get a value for this document, same as return by call:
curl -X GET 'https://sync.gateway.host/db/_changes?active_only=true&style=all_docs
This call is done in Android implementation of Couchbase Lite, when replicating database.

Whereas this call returns different value for same revision of same document:
curl -X POST -H “Content-Type: application/json” ‘https://sync.gateway.url/db/_bulk_get?revs=true&attachments=true’ -d ‘{“docs”:[{“rev”:“some_rev”, “id”:“docId”}]}’

Is there a difference in those calls? My guess is that someone might have changed value in Couchbase Server directly, instead of using Sync Gateway, then it would mean that _bulk_get somehow goes around caching of sync gateway.

Please help me find a reason why this happens.

@marcin.bak

Looks like your looking for conflicts.

The document in the _changes that you do a bulk get for do you see one _revs in the array or just two like in the image below.

@househippo There is just one revision, it starts with 1-xxxx, and is same in all cases.

Ok, I know the background of the story:

  1. the bucket in Couchbase Server was removed (containing old content of document)
  2. then new bucket was created
  3. sync gateway was restarted connecting to new bucket (same name)
  4. new document content was pushed to sync gateway
  5. Sync gateway’s _bulk_get used by Couchabse Lite returns old content of the document.

There are no conflicts, there’s just one revision of the docs (1-xxx) in all cases.

What is going on??? How can we handle if such situation happens in production?

@marcin.bak

I did a put on the below json into SG.

{
"_id":"foo",
"test":"data"
} 

it hash to
"1-98c61c1180efa9a797def6c234d92d8d"

_CHANGES
I did a _changes feed and I see the _id and _rev(IMAGE BELOW).

BULK GET
I do a _bulk_get and see same _id , _rev and data.

GET
Here is a simple get with _id, _rev and data.
35 AM

If you do the same as above do you get something different?