Trouble trying to remove doc from channel

62 views
Skip to first unread message

thomas....@teckeezy.com

unread,
Dec 18, 2014, 2:51:00 PM12/18/14
to mobile-c...@googlegroups.com
Hello,

I am having a trouble trying to remove a doc from a channel.

My doc is of type story and has a property named "channels".
My sync function says : if (doc.model_type == 'Story') {channel(doc.channels);}

At first : channels = ["public"] and my doc is only in the "public" channel

Then, I change (programmatically) the channels property and adds "preload", then channels = ["public","preload"] in my database. My doc is in both channels : "public" & "preload"

Then I removes "preload" from channels property meaning channels = ["public"] in my database

But it seems that the sync function does not apply and does not remove the doc from the "preload" channel. I can check this by calling the URL /sync_gateway/_all_docs?channels=true' keys:='["AC4BF703-19F8-41FA-8A4C-2EB8C9E50797"]' on my doc and I get 

{

    "rows": [

        {

            "id": "AC4BF703-19F8-41FA-8A4C-2EB8C9E50797"

            "key": "AC4BF703-19F8-41FA-8A4C-2EB8C9E50797"

            "value": {

                "channels": [

                    "preload"

                    "public"

                ], 

                "rev": "40-e48f0af2d05ae75bd6c027556031ed4a"

            }

        }

    ], 

    "total_rows": 183649

    "update_seq": 642207

}

I can see that there is a new revision but the channels property (on sync gateway side) keeps "preload" in it !!!!

I have been banging my heads on this for hours. Please help !!!!!

Thank you very much.

Jens Alfke

unread,
Dec 18, 2014, 2:59:03 PM12/18/14
to mobile-c...@googlegroups.com

On Dec 18, 2014, at 11:51 AM, thomas....@teckeezy.com wrote:

Then I removes "preload" from channels property meaning channels = ["public"] in my database
But it seems that the sync function does not apply and does not remove the doc from the "preload" channel. 

Check that the document has the revision you expect — on the admin interface do a GET /db/AC4BF703-19F8-41FA-8A4C-2EB8C9E50797

It's possible you have a conflict in your document, and the revision on which you removed "preload" from the "channels" property isn't the default/winning revision. If so, you'll need to resolve the conflict.

—Jens

thomas....@teckeezy.com

unread,
Dec 18, 2014, 3:07:49 PM12/18/14
to mobile-c...@googlegroups.com
Thanks Jens for your quick answer. I did what you asked for and I received as an answer the same revision number as the POST command and a channels=["public"]...

I am a bit (actually completely) lost. It's as if the sync function did not apply...

HTTP/1.1 200 OK

Content-Encoding: gzip

Content-Length: 1235

Content-Type: application/json

Date: Thu, 18 Dec 2014 20:02:10 GMT

Etag: 40-e48f0af2d05ae75bd6c027556031ed4a

Server: Couchbase Sync Gateway/1.00


{

    "_attachments": {

        "detail.jpg": {

            "content_type": "image/jpg"

            "digest": "sha1-B3MFW15vZaSfARYt16PvxWP+Gp0="

            "length": 22881

            "revpos": 31

            "stub": true

        }, 

        "det...@2x.jpg": {

            "content_type": "image/jpg"

            "digest": "sha1-Hrc4xhI2X2J8+HP/PRgKjmpD63g="

            "length": 76167

            "revpos": 31

            "stub": true

        }

    }, 

    "_id": "AC4BF703-19F8-41FA-8A4C-2EB8C9E50797"

    "_rev": "40-e48f0af2d05ae75bd6c027556031ed4a"

    "age": 3

    "authors": [

        "CA2902E6-324E-4B06-AC0F-E4DA5068CA5F"

        "CE7D5438-CD3F-4756-B376-6E70813671AC"

    ], 

    "channels": [

        "public"

    ], 

    "editor": "DD4979A0-E322-4E5B-A005-FC332BB71A81"

    "indexPreview1": 1

    "indexPreview2": 2

    "indexPreview3": 3

    "isbn": null

    "model_type": "Story"

    "pageCount": 14

    "pages": [

        "BD62F022-2F55-480A-9232-B462E39C2F44"

        "ADC63669-EE85-40E5-A0D8-39EC88F1D597"

        "E8712DC8-F9AE-4318-BD75-E9FE01910D72"

        "AB30BE2A-C085-42F5-897C-04AE3BD975EA"

        "4D47C1FC-19AB-44FF-A0CF-9469A46334D0"

        "BB79BE9B-1CFA-4436-B19F-B028068BDD25"

        "A071D57B-FA47-403B-ACE8-BD2EA2A92A7F"

        "A52D4AB7-8603-4A36-AF58-AC09357D7D1F"

        "523DC366-FBE6-43A3-9F64-26D7367283D5"

        "7B9E1CE9-9148-4B19-96E6-4FABC9CBD50B"

        "F0EE028E-0444-42C6-8547-0A63CA95F1F6"

        "DA8C555E-4452-4EB6-899B-4A8678817329"

        "FBB7237A-EBB5-42E3-853C-F03DEA842CF6"

        "0AB50FD5-BE53-492E-8375-27FD5E75C332"

    ], 

    "permalink": "a-l-heure-du-dejeuner"

    "publicationStatus": 1

    "summary": "Le crapaud à trois taches attend, immobile, au milieu de l'étang. C'est qu'il a faim. Une faim de loup ! Et ça, c'est énorme pour un crapaud. \r\nQuel mets assez raffiné sera digne de son palais délicat ? \r\nUne histoire drôle où la chute ne laisse personne sur sa faim.\r\n"

    "tags": [

        "187FAAD0-8781-4526-A734-6433843BAE00"

        "1F7ABDDE-67BD-49FB-9A63-39D3E45DBBB1"

        "388CBE06-75FF-451E-8E69-1AC424184F6C"

        "77D64991-C157-41E4-9757-630DD53733C7"

        "A25F5228-8EC0-4862-9736-3223BA564DC0"

        "A9AFB268-A334-4C03-B372-B90E85534164"

        "BF930092-59EB-4B6B-B97C-AC72B5FF8F24"

    ], 

    "text": null

    "title": "A l'heure du déjeunerraaaa"

}

Jens Alfke

unread,
Dec 18, 2014, 3:33:36 PM12/18/14
to mobile-c...@googlegroups.com
Hm. Just to make sure: You're changing the document through the Gateway REST API (or client replication), not modifying the bucket directly, right?

Could you show your entire sync function, please?

Also, please get the raw form of the document in the bucket, either through the Couchbase Server admin UI or by GET /db/_raw/docid on the admin port. (This is likely to be big since there are a lot of revisions, so it'd be best to upload it to gist or pastebin or something like that.)

—Jens

thomas....@teckeezy.com

unread,
Dec 18, 2014, 3:44:35 PM12/18/14
to mobile-c...@googlegroups.com
I have a shadow bucket config. I am changing my doc in my web bucket and changes are "shadowed" in the sync bucket. It works perfectly fine for all other operations (including adding doc to new channels).


Cheers

Thomas

Jens Alfke

unread,
Dec 18, 2014, 4:04:30 PM12/18/14
to mobile-c...@googlegroups.com
The raw view of the doc shows it's only in the "public" channel, not "preload", so it's in the correct state. Weird. Maybe this is a bug in the _all_docs handler?

Are there other indications besides _all_docs that the doc is in the wrong channels? Have you checked the _changes feed for the "preload" channel?

—Jens

thomas....@teckeezy.com

unread,
Dec 18, 2014, 6:38:37 PM12/18/14
to mobile-c...@googlegroups.com
Other indications is my iOS app which still gets the doc when interrogating the preload channel

I am quite a newbie with sync gateway and I find the doc sometimes hard to find. Anyway, to get the _changes feed, I did a GET on /sync_gateway/_changes?feed=preload... Is that right ?

I got a gzip file that Mac (even with cmd line) cannot unzip...

Jens Alfke

unread,
Dec 19, 2014, 2:39:24 PM12/19/14
to mobile-c...@googlegroups.com
On Dec 18, 2014, at 3:38 PM, thomas....@teckeezy.com wrote:

I am quite a newbie with sync gateway and I find the doc sometimes hard to find. Anyway, to get the _changes feed, I did a GET on /sync_gateway/_changes?feed=preload... Is that right ?

No, to get a specific channel it would be
/sync_gateway/_changes?filter=sync_gateway/bychannel&channels=preload

I got a gzip file that Mac (even with cmd line) cannot unzip…

Weird. Sounds like whatever HTTP client you used sent an Accept header claiming to accept gzip, but then didn't decode the response for you. (And it is standard gzip. Although the HTTP response headers come first, of course, which may be why the gunzip tool couldn't parse it.)

I recommend using 'curl' or 'httpie', neither of which have this problem. (httpie is especially awesome.)

—Jens
Reply all
Reply to author
Forward
0 new messages