Sync_Gateway is going loop infinite when PouchDB intially tries to replicae documents from couchbase via syncgateway


#1

We are facing issue when initial replication call made from PouchDB to couchbase via syncgw. SyncGW Goes in loop infinite.
Steps:
Client is using PouchDB 5.0
Using PouchDB replicaiton API and trying to sync documents from couchbase via syncgw.
Observed syncgateway is going in loop and documents wont be synced. Sync complete event is not triggered.

Suspecting Sequence number
"seq":“330985::332047"
from below response is confusing syncgw.
Documents with this sequence number causing syncgw to respond in loop?
{“results”:[
{“seq”:“159211”,“id”:“dcuvgz3x1s0gtz_rehctaps”,“changes”:[{“rev”:“1-23216b0a1b2f9cfb639049c849a9146c”}]}
,{“seq”:“159212”,“id”:“dcuvgz3x1s0gtz_spuorgm”,“changes”:[{“rev”:“1-166a8d25909eb8ed3753d7a7e9c186f5”}]}
,{“seq”:“159213”,“id”:“dcuvgz3x1s0gtz_gol”,“changes”:[{“rev”:“1-5b52f4aeb801dab695e5d72e0a36363d”}]}
,{“seq”:“159214”,“id”:“dcuvgz3x1s0gtz_tidua”,“changes”:[{“rev”:“1-cb414754def7adf0c3eb55436875a4f1”}]}
,{“seq”:“159215”,“id”:“dcuvgz3x1s0gtz_trela”,“changes”:[{“rev”:“1-1156b9086fe9242a170c97accf5f5e55”}]}
,{“seq”:“159216”,“id”:“dcuvgz3x1s0gtz_detacoltsal”,“changes”:[{“rev”:“1-d9a4d6c8a48904f63203511d6085d99a”}]}
,{“seq”:“167957:159440”,“id”:“co8_s919591803652_abcd.doc”,“changes”:[{“rev”:“1-4d36ef1f86ad72757a3abd33a2670530”}]}
,{“seq”:“167957:159443”,“id”:“s919591803652_abcd1234567.doc”,“changes”:[{“rev”:“1-fb013cbb8f50b66b1381cb7645fb2295”}]}
,{“seq”:“167957:159513”,“id”:“co8_s919591803654_abcd.doc”,“changes”:[{“rev”:“1-3b8555994be3aedaa8b4fd46a45e6cdb”}]}
,{“seq”:“167957:159516”,“id”:“s919591803654_abcd1234567.doc”,“changes”:[{“rev”:“1-3eb1f79336ef2aeb0ae6d7cc8c83c749”}]}
,{“seq”:“167957:159552”,“id”:“co8_s919591803655_abcd.doc”,“changes”:[{“rev”:“1-70690ccf22880a9b854226c25c2df221”}]}
,{“seq”:“167957:159555”,“id”:“s919591803655_abcd1234567.doc”,“changes”:[{“rev”:“1-3e3af1b1f5463fe567a74d6d9be1d580”}]}
,{“seq”:“167957:159602”,“id”:“co8_s919591803657_abcd.doc”,“changes”:[{“rev”:“1-afed6c717283ac26034055f7c5ba1670”}]}
,{“seq”:“167957:159605”,“id”:“s919591803657_abcd1234567.doc”,“changes”:[{“rev”:“1-a58ae42b3814819f2478bbb7793cbab4”}]}
,{“seq”:“183956”,“id”:“co8_s919591803651_abcd.doc”,“changes”:[{“rev”:“3-f6cfe7bbfb7467e573af91f4444e2f73”}]}
,{“seq”:“195313”,“id”:“s919591803651_abcd1234567.doc”,“changes”:[{“rev”:“10-82d4cc1d91c2ca0154a4ffa1f6c0bb24”}]}
,{“seq”:“277437”,“id”:”_user/919591803672",“changes”:[]}
,{“seq”:“277440”,“id”:“group1.doc”,“changes”:[{“rev”:“1-230b8233ca2ca97973ff653b6a0d585f”}]}
,{“seq”:“328905”,“id”:“s919591803672_pro.doc”,“removed”:[“s919591803672_private-CH”],“changes”:[{“rev”:“2-37325961dcdbf47c4d5b92c470667af8”}]}
,{“seq”:“330985::331045”,“id”:“s919591803672_1234567avail.doc”,“changes”:[{“rev”:“50-283170f096d6915609dd892a3fc5d775”},{“rev”:“21-7cd3529e9a00a7a0a76e78dbd6bc0e8b”}]}
,{“seq”:“330985::332047”,“id”:“s919591803672_prof.doc”,“changes”:[{“rev”:“8-554984f239465b097a03b7916d900e31”}]}
],
“last_seq”:“330985::332047”}


#2

I think I have the same problem, see my comments:

http://blog.couchbase.com/cross-platform-storage-and-sync-with-ionic-framework-couchbase-and-pouchdb

You can try with PouchDB 4.0.3

Let me know if that works for you, at least I will know that we have the same problem…


#3

That sequence number should be valid. A few questions:

  • What build of Sync Gateway are you using?
  • What changes request is being issuing (when it gets the above response)?

#4

SyncGW Release version: 1.1.1-10
Couchbase Release version: 4.0.0-4047

  1. Client requests the list of docs “since=0”.
  2. Sync GW responds with list of changes and last_seq as “371875::372157”

Below sync gateway output for the client request

GET
http://13.9.4.28:8080/pttdata/_changes?timeout=25000&style=all_docs&since=0&limit=100&_nonce=1448256264603

{“seq”:“362546”,“id”:“co11_s919591803622_Contact.doc”,“changes”:[{“rev”:“6-8379d536b2859d2b6669149283a9aadd”}]}
,{“seq”:“362816”,“id”:“co11_s919591803623_Contact.doc”,“changes”:[{“rev”:“3-deb937bf0cee4e0c0a0e37fd7ba433ea”}]}
,{“seq”:“369575”,“id”:“co11_s919591803621_Contact.doc”,“changes”:[{“rev”:“7-fa8837db4a0056594493fe424538f5d0”}]}
,{“seq”:“371557”,“id”:“s919591803633_ClientProfile.doc”,“changes”:[{“rev”:“12-737881cacba0b632ce275758f7ebca89”}]}
,{“seq”:“371632”,“id”:“s919591803621_ContactPresence.doc”,“changes”:[{“rev”:“42-36ddafcddca723a3c97e34454b2e2cc2”}]}
,{“seq”:“371875::371926”,“id”:“s919591803623_ContactPresence.doc”,“changes”:[{“rev”:“20-8fdf291fadb1db16daa9db0ad8406ba4”}]}
,{“seq”:“371875::372028”,“id”:“dc1k1ugvxt9sbxh_CCallLog”,“changes”:[{“rev”:“89-08eaf6a1e7e8421e71d14b3fb67a7f43”}]}
,{“seq”:“371875::372054”,“id”:“dc1k1ugvxt9sbxh_CAlertLog”,“changes”:[{“rev”:“48-43e51e3be56d91cd668dd377ffe94412”}]}
,{“seq”:“371875::372119”,“id”:“s919591803621_Location.doc”,“changes”:[{“rev”:“104-48223a30a399e60accb3e7416ece4adc”}]}
,{“seq”:“371875::372142”,“id”:“s919591803622_Location.doc”,“changes”:[{“rev”:“66-96f677efdf49593e01ce8c6801f69613”}]}
,{“seq”:“371875::372157”,“id”:“s919591803622_ContactPresence.doc”,“changes”:[{“rev”:“38-ecb957965c1a6d7f1791117971e43a17”}]}
],
“last_seq”:“371875::372157”}

  1. Client requests again with the last seq number

GET
http://13.9.4.28:8080/pttdata/_changes?timeout=25000&style=all_docs&since=371875%3A%3A372157&limit=100&_nonce=1448256265344

200 OK Response

{“seq”:“371875::371926”,“id”:“s919591803623_ContactPresence.doc”,“changes”:[{“rev”:“20-8fdf291fadb1db16daa9db0ad8406ba4”}]}
,{“seq”:“371875::372028”,“id”:“dc1k1ugvxt9sbxh_CCallLog”,“changes”:[{“rev”:“89-08eaf6a1e7e8421e71d14b3fb67a7f43”}]}
,{“seq”:“371875::372054”,“id”:“dc1k1ugvxt9sbxh_CAlertLog”,“changes”:[{“rev”:“48-43e51e3be56d91cd668dd377ffe94412”}]}
,{“seq”:“371875::372119”,“id”:“s919591803621_Location.doc”,“changes”:[{“rev”:“104-48223a30a399e60accb3e7416ece4adc”}]}
,{“seq”:“371875::372142”,“id”:“s919591803622_Location.doc”,“changes”:[{“rev”:“66-96f677efdf49593e01ce8c6801f69613”}]}
,{“seq”:“371875::372157”,“id”:“s919591803622_ContactPresence.doc”,“changes”:[{“rev”:“38-ecb957965c1a6d7f1791117971e43a17”}]}
],
“last_seq”:“371875::372157”

Sync Gw logs as below
2015-11-22T23:26:54.195-06:00 HTTP: #523919: GET /pttdata/_changes?timeout=25000&style=all_docs&since=371875%3A%3A372157&limit=100&_nonce=1448256410641 (as 919591803633)
2015-11-22T23:26:54.195-06:00 Changes: MultiChangesFeed({*}, {Since:371875::372157 Limit:100 Conflicts:true IncludeDocs:false Wait:false Continuous:false Terminator:0xc217607ce0 HeartbeatMs:0 TimeoutMs:25000}) … (to 919591803633)

  1. With the last_seq in (3), client is in loop requesting GET similar to (3).

Question is why sync GW is responding with a list of documents starting with 371875 when client has specifically requested “371875::372157". Expectation is to return the doc with just one value i.e
{“seq”:“371875::372157”,“id”:“s919591803622_ContactPresence.doc”,“changes”:[{“rev”:“38-ecb957965c1a6d7f1791117971e43a17”}]}