String "seq" breaks CouchDB compatibility


#1

Hi,

I have been developing and testing with sync gateway and found that the “seq” identifiers in _changes are sometimes ints and sometimes strings with a pair of ints separated by two colons.

When they are strings if I restart the gateway they return to being ints.

Being strings seems to break the gateway web console but more crucially for me breaks compatibility with CouchDB which I guess expects ints. Could the additional int which seems to encode some state from the gateway (which is meant to be stateless) be included as a second attribute instead? This would preserve compatibility and be prettier. (What is the second int?)

I am using local CouchDB with the Sync Gateway as I haven’t managed to build a stand alone non android Java CBLite with both listener and js. Has anyone built one?

I’m using:

Couchbase Sync Gateway/master(1c6559c)
Server 3.0.1 Community Edition (build-1444)

Thanks

P


#2

CouchDB doesn’t require ints. It’s always been the case that sequences in the replication protocol are arbitrary JSON objects. Both BigCouch and Cloudant use long base64-format strings, for example.

SG should be compatible with CouchDB. If you’re having trouble, please post details of exactly what goes wrong.


#3

Hi Jens,

I’ve just been looking at this again.

I am adding a small number of docs to couchbase via the sync gateway and they all appear ok in couchbase, but when I replicate to a CouchDB database or use curl to get changes I am only seeing some of the docs. This seemed to coincide with the int/string seq identifiers but maybe this was coincidental. I have run this test again and this time I am not getting any string seq but both _changes via curl and replication only show docs up to 16 whereas they actually go higher in couchbase. There is an example of this below.

Looking at the sync gateway web ui it sees all the docs in couchbase ok but has failed to build the correct channels or to preview the sync function.

If I restart sync gateway the web UI works and _changes and replication works ok.

I have repeated this a few times, always curl changes gets the wrong last_seq, sometimes the gateway web UI partially fails and sometimes replication to CouchDB hangs

I will try and narrow this down to a more simple reproducible test

Thanks

Paul

Pauls-MacBook-Pro :: ~ » curl http://test:password@192.168.59.103:4985/sync_gateway/_changes?filter=“sync_gateway/bychannel”&channels=domain_test
{“results”:[
{“seq”:1,“id”:“person_test”,“changes”:[{“rev”:“1-a01b606dcacbe367b3c52b216c194b0e”}]}
,{“seq”:3,“id”:“network_test_default”,“changes”:[{“rev”:“1-11718ba6c5d731bf1b4bdce66f795d8e”}]}
,{“seq”:4,“id”:“node_test_default_default”,“changes”:[{“rev”:“1-b4e12fd0a26beb9a017efda88819be45”}]}
,{“seq”:6,“id”:“domain_test”,“changes”:[{“rev”:“2-c8daa349e4ddd2787978deea467441c8”}]}
,{“seq”:12,“id”:“project_65a88e18-20f2-4b8b-9cbe-e8bcae017230”,“changes”:[{“rev”:“1-1dc1ab7f4743ca326904782a2cde5990”}]}
,{“seq”:14,“id”:“9da8e718-dfb6-410b-b98e-223161c8b489”,“changes”:[{“rev”:“1-887cc382302f961c6f0ee452cfdfe38e”}]}
,{“seq”:15,“id”:“filestore_test_default_default_temp”,“changes”:[{“rev”:“1-cc0b8c25b752fc6014a93b732741bd2b”}]}
,{“seq”:16,“id”:“filestore_test_default_default_library”,“changes”:[{“rev”:“1-1b465ccdad900dcd5c732b725187844b”}]}
],
“last_seq”:“16”}
Pauls-MacBook-Pro :: ~ » curl http://test:password@192.168.59.103:4985/sync_gateway/_changes?filter=“sync_gateway/bychannel”&channels=domain_test&since=16
{“results”:[
],
“last_seq”:“16”}

but this is in the db and ought to show up too

{
"_sync": {
“rev”: “1-3b13e9634415d4c3fa3d6f2b99b6f8fc”,
“sequence”: 35,
“history”: {
“revs”: [
“1-3b13e9634415d4c3fa3d6f2b99b6f8fc”
],
“parents”: [
-1
],
“bodies”: [
""
],
“channels”: [
[
“domain_test”,
“project_83b7c934-5f03-40f5-83b7-50d2fcd83ed3”
]
]
},
“channels”: {
“domain_test”: null,
“project_83b7c934-5f03-40f5-83b7-50d2fcd83ed3”: null
},
“access”: {
“paul”: {
“project_83b7c934-5f03-40f5-83b7-50d2fcd83ed3”: 35
}
},
“time_saved”: “2015-05-20T18:45:04.104865177Z”
},
“access”: [
“paul”
],
“channels”: [
“project_83b7c934-5f03-40f5-83b7-50d2fcd83ed3”,
“domain_test”
],
“domain_id”: “domain_test”,
“name”: “test_project”,
“namespace”: “http://glowinthedark.co.uk/flotsam/1”,
“owner_id”: “test_person”,
“rackspacestore_id”: “rackspacestore_test_project_83b7c934-5f03-40f5-83b7-50d2fcd83ed3”,
“recipe”: “flotsam.apps.river.recipes.thumbnail.thumbnail_recipe”,
“type”: “project”
}


#4

Looks like the recent-changes cache gets out of date, since that doc should be showing up (and does after restarting the gateway, you say.)

Could you please file an issue against SG on Github?


#5

If you can include the Sync Gateway logs when making the _changes request (that doesn’t return the expected sequence 35) when you file the ticket, it will help us try to reproduce the issue.