Strange behavior about getting documents after making updates on database

Hi,

I have a field which is called accessPermits in my specific type of documents. That field holds an array which is filled by usernames. In my sync gateway function, depending on that field some users can access those documents through on channels. I also added a control to reject user updates whose accessPermits are empty.

The strange behaviour is the following: when I make a change to that array manually through on database (not sync gw api) to make it empty, the document is updated. However, after making a get call though on postman, I still get the previous revision of that document. (Normally I expect not to fetch that document) Its like the update never occured.

My db version is 5.0 beta by the way.

Thanks a lot.

Can you please clarify what you mean by “manually”? Did you use the Query workbench on the server or did you use one of the SDKs.

Which version of SGW are you using ? Did you enable shared bucket access ?

Hi Priya,

My sync gw version is 1.5.0(494;5b6b5b9). I didn’t enable any shared bucked access property. I just have the following codes roughly:

"unsupported": {
      "enable_extended_attributes": true,
    "replicator_2":true
  },
  "import_docs": "continuous"

What I meant is just chancing the document data on web ui with 8091 port. I know that its not the way to make some changes if we are using couchbase server version less than 5.0 but in this case it shouldn’t cause any problem I guess.

Thanks.

OK. And can you share your Sync Gateway config to ensure that it is set up for shared bucket access.

Hi again,

I just added that shared bucket access feature to my bucket and nothing changed. In the logs, I have seen that:

Unable to import doc “Task_1” - external update will not be accessible via Sync Gateway. Reason: 403 Invalid Task document: item “accessPermits” must not be empty – db.(*changeCache).DocChanged.func1() at change_cache.go:376

So sync gateway didn’t allow the update but when I list the documents in couchbase web ui panel, I see that the document updated. So, in this case, should we prohibit to make any change through on web ui?

Moreover, in my sync gw config file, i had “unsupported”: { “enable_extended_attributes”: true} line. Isn’t it same with putting enable_shared_bucket_access: true in terms of functionality? Since the aim is enabling usage of xattr and this has been already handled by the enable_extended_attributes feature. Please correct me if my assumption is wrong.

Thanks.

Did you configure the RBAC user for the Couchbase server bucket ? In this [doc]9http://docs.couchbase.com/tutorials/travel-sample/develop/swift#/0/2/0), scroll to the section on configuring RBAC user .

If you did that, did you ensure that your SGW config file is configured with the right credentials to access the bucket. What is the username and password that you have configured in your Sync Gateway config file ?

Please share relevant snippet of your sync gateway config file.

That’s not true. enable_extended_attributes was pre-GA release flag and for that reason is listed in “unsupported” section. That is superseded by enable_shared_bucket_access which is what GA supports and which is what you should be using.

Hi Priya,

I just created the RBAC user as it was defined in the tutorial, however still I couldn’t get the revision update after making _all_docs api call although the document seemed updated on server ui.

Another problem is that, when I added enable_shared_bucket_access (and removed enable_extended_attributes ) to my sync gw function, the revision of all the documents in database was resetted to 1. And some fields such as _sync, cas, _id, _rev were added to each of those documents. When I try to make any update, sync gw rejected, it said documents which have fields starts with _(undescore) not allowed to be synced. Therefore, for each document I had to delete that new coming meta fields and undo the changes I did to sync gateway.

Is it ok to have that meta fields inside of documents? Should I move on by adding enable_shared_bucket_access & removing enable_extended_attributes feature?

Thanks.

“dev-db”: {
“username”:“admin”,
“password”:“123456”,
“server”: “http://...:8091”,
“unsupported”: {
“enable_extended_attributes”: true
},
“import_docs”: “continuous”,
“sync”: `

Just noticed that

Can you please use the GA releases of the Server and Sync Gateway.

Hi,

Ok then, I will update both services and test through on the latest ga releases.

Hi,
We successfuly upgraded both couchbase server & sync gateway to their GA releases and change the sync gateway function accordingly by adding enable_shared_bucket_access & import_docs. But still the situation goes on and the document on web ui and the document that sync gw sends differ.

Anyway, we decided not to make any changes on web ui and ban that access based on role. The problem is that there is no way to use a role which can see inside of the documents but not enabled for editing. So I guess it would be a good feature to define that kind of role.

Thank you for your interest.

Well - if you have your sync gateway & sync function configured correctly, there shouldn’t be a reason why updates made via the SDK are not propagated to the mobile clients.

I would recommend that you file a ticket against the Sync Gateway repo with specifics of your sync gateway config file (including sync function)