Cannot get sync revision field sync gateway 2.0

n1ql

#1

Hello,
i update sync gateway from 1.5 to 2.0.
I’m using node sdk with couchbase 5.0 and sync gateway 2.0.
This is my sync.json

{
  "CORS": {
     "Origin":["*"],
     "Headers": ["Content-Type"]
  },
  "interface":":4984",
  "databases": {
    "default_cluster": {
      "bucket": "bucket_name",
      "password": "password",
      "username": "user",
      "server":"http://127.0.0.1:8091",
      "import_docs": true,
      "enable_shared_bucket_access": true,
      "users": {
        "GUEST": {"disabled": false, "admin_channels": ["*"]}
      },
      "sync": `function (doc, oldDoc) {
          channel(doc.channels);
      }`
    }
  }
}

From he previous version i add only enable_shared_bucket_access and i don’t knwo if could be the problem, but if i try to remove, i get this error:

2018-06-19T21:10:27.158+02:00 WARNING: Changes feed: error getting revision body for "dd513639a11218922cdc37cbc53503a6" (2-09cb264ace8d69547194b679c6ccc2e1): Unrecoverable GoCB error doing Get() on key: dd513639a11218922cdc37cbc53503a6: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
2018-06-19T21:10:27.158+02:00 WARNING: Changes feed: error getting revision body for "ddb9b2456e8e7f51ff04af68115873b0" (2-2c7c508f056740037d4b998231af6d92): Unrecoverable GoCB error doing Get() on key: ddb9b2456e8e7f51ff04af68115873b0: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
2018-06-19T21:10:27.158+02:00 WARNING: Changes feed: error getting revision body for "f4e5c71f65788520d8366f4519ae2261" (2-2816373c844cd26f5cd2d2cae3408ae6): Unrecoverable GoCB error doing Get() on key: f4e5c71f65788520d8366f4519ae2261: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
2018-06-19T21:10:27.158+02:00 WARNING: Changes feed: error getting revision body for "e94868429087c6d74f383130af2c859c" (4-8d017941fae26e617e52b70f298520bc): Unrecoverable GoCB error doing Get() on key: e94868429087c6d74f383130af2c859c: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
2018-06-19T21:10:27.158+02:00 WARNING: Changes feed: error getting revision body for "fbfa7e651cd3f4a5225fa65dac852557" (2-50cf7a7d841955419a205a8a2f35e8a6): Unrecoverable GoCB error doing Get() on key: fbfa7e651cd3f4a5225fa65dac852557: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
2018-06-19T21:10:27.158+02:00 WARNING: Changes feed: error getting revision body for "transport_2" (2-a4e6caf4584b3c822457cfe8ea5e117a): Unrecoverable GoCB error doing Get() on key: transport_2: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
2018-06-19T21:10:27.159+02:00 WARNING: Changes feed: error getting revision body for "transport_1" (43-c8d78b87ea123095ce261d073dd525d3): Unrecoverable GoCB error doing Get() on key: transport_1: key not found -- db.(*Database).addDocToChangeEntry() at changes.go:124
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x15b200b]

goroutine 64 [running]:
github.com/couchbase/sync_gateway/db.(*DatabaseContext).revCacheLoaderForDocument(0xc4202882c0, 0xc4201bab40, 0xc420241560, 0x22, 0xc4201bab40, 0x0, 0x0, 0xc4201d38e0, 0xc4204ac618)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/crud.go:204 +0x1fb
github.com/couchbase/sync_gateway/db.(*DatabaseContext).revCacheLoader(0xc4202882c0, 0xc420495040, 0x9, 0xc420241560, 0x22, 0x0, 0x1cd5460, 0xc42016a518, 0xc4204ac630, 0xc4204ac628, ...)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/crud.go:183 +0x83
github.com/couchbase/sync_gateway/db.(*DatabaseContext).(github.com/couchbase/sync_gateway/db.revCacheLoader)-fm(0xc420495040, 0x9, 0xc420241560, 0x22, 0x0, 0xc420495040, 0x9, 0xc420241560, 0x22, 0x0)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/database.go:193 +0x55
github.com/couchbase/sync_gateway/db.(*revCacheValue).load(0xc4202faf60, 0xc4201dbac0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/revision_cache.go:144 +0x1e5
github.com/couchbase/sync_gateway/db.(*RevisionCache).Get(0xc4201d38c0, 0xc420495040, 0x9, 0xc420241560, 0x22, 0xc4204ac768, 0xc4204ac8a0, 0x152fa44, 0x1e76fb0, 0x9)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/revision_cache.go:58 +0x9b
github.com/couchbase/sync_gateway/db.(*Database).GetRevWithHistory(0xc420428740, 0xc420495040, 0x9, 0xc420241560, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/crud.go:249 +0x8a
github.com/couchbase/sync_gateway/db.(*Database).AddDocToChangeEntryUsingRevCache(0xc420428740, 0xc420080750, 0xc420241560, 0x22, 0xc420256ce8, 0x0)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/changes.go:132 +0xb8
github.com/couchbase/sync_gateway/db.(*Database).addDocToChangeEntry(0xc420428740, 0xc420080750, 0x0, 0x0, 0x0, 0xcd, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/changes.go:122 +0x121
github.com/couchbase/sync_gateway/db.(*Database).SimpleMultiChangesFeed.func1(0x0, 0x0, 0xc420295e60, 0xc420428740, 0xc4204608c0, 0xc420240cf0)
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/changes.go:605 +0x1b27
created by github.com/couchbase/sync_gateway/db.(*Database).SimpleMultiChangesFeed
	/Users/jenkins/jenkins/workspace/sgw-unix-build/2.0.0/community/godeps/src/github.com/couchbase/sync_gateway/db/changes.go:700 +0x237


Everything works fine(with enable_shared_bucket_access), except that now i cannot find _sync field when i run queries.
If i create a document using admin sync gateway dashboard, i can see that the document has a _rev field.
Now, if i search through the document in the admin console of Couchbase i can see in the right section that has a revision field (but different from the sync gateway’s one).
The problem is that if a run a simple query, i cannot get anymore the _sync field, opposite from sync v1.5 that was retrieved during every query.
What should i do to get the last revision field?

Thanks in advance


#2

The _sync metadata has been moved to XAttrs instead of being stored as part of the same document.
I would recommend checking out this blog that discusses the implications of using enable-shared-bucket-access. It also discusses how you can get access to the sync data via the SGW REST API.