@adamf and @bbrks I have just reviewed my sync_gateway.json after the above. Still not sure about the “import_docs” setting that does not seem to be consistent in the documentation. But one of the settings that was “left over” from my initial setup was the "use_views":true
- which I changed to “false”. Following the documentation related to that I also changed the “num_index_replicas” setting for my test environment (two Couchbase server nodes and one SyncGateway) - but “obviously” I now get this error as I’m using the Community edition:
May 02 11:34:27 sg1 bash[9185]: - will retry. -- db.(*SGIndex).createIfNeeded.func1() at indexes.go:242
May 02 11:34:38 sg1 bash[9185]: 2019-05-02T11:34:38.156+02:00 [WRN] Error creating index sg_tombstones_x1: Error creating index with statement: CREATE INDEX `sg_tombstones_x1` ON `data`(meta().xattrs._sync.tombstoned_at) with {"num_replica":1,"retain_deleted_xattr":true,"defer_build":true}. Error: [5000] GSI CreateIndex() - cause: Index Replica not supported in non-Enterprise Edition
Question: Should (could) I create this indexes manually on each db server (as I have code doing for the query indexes)? The formula is shown, so I can easily do it - but not sure if the SyncGateway server uses/benefits from it?
Oh, and it appears that I have to set num_replicas to 0… - or the SG server won’t start
For reference this is what my sync_gateway.json file looks like now:
{
"log": ["HTTP+"],
"adminInterface": "0.0.0.0:4985",
"interface": "0.0.0.0:4984",
"databases": {
"data": {
"use_views":false,
"num_index_replicas":0,
"bucket": "data",
"server": "http://db1,db2:8091",
"username": "xxxxxxx",
"password": "yyyyyyyyyyyy",
"enable_shared_bucket_access": true,
"import_docs": true,
"users": { "GUEST": { "disabled": true, "admin_channels": ["!"] } },
"sync": `function (doc, oldDoc) {
// Document type is mandatory
if (oldDoc._deleted){
// Server doc. deleted -> just propagate this!
return;
}
// Document type is mandatory
if (!doc.type){
throw({forbidden: "Document type is required."});
}
if ((doc.type == 'EnvLake' || doc.type == 'EnvMeasurement' || doc.type == 'Feedback' || doc.type == 'ActivityLog') && oldDoc){
throw({forbidden: "Document type not allowed to sync to mobile..."});
}
// All public docs are available in the app
if (doc.ispublic) {
channel('!');
// return;
}
// All non-club fishing trips and catches are available (for stats)
if ((doc.type == 'FishingTrip' || doc.type == 'Catch') && doc.clubonlykey == undefined) {
channel('!');
}
// All non-specific user info is available (for stats)
if (doc.type == 'User') {
channel('!');
}
// Only docs "owned" by user can be updated
var key;
if(doc.type == 'User'){
key = doc.key;
} else if(doc.type == 'FishingTrip' || doc.type == 'Catch' || doc.type == 'Photo' || doc.type == 'Private'){
key = doc.userkey;
}
if(key){
requireUser(key);
channel('channel.' + key);
access(key,'channel.' + key);
}
// Creation of new Feedback docs (perhaps without userkey)?
// Creation of new docs?
// Updates to existing docs?
// Readonly for all non-user specific docs...
}`,
"allow_conflicts": false,
"revs_limit": 20
}
}
}
Edit:
It seems that after I edited the config file in an external editor and uploaded it, stopped and started the sync gateway, took the db offline, ran resync, and put it back online - and then deleted local app and rebuild (and resync’ed data) it seems to be behaving more as expected
Still have the question about indexes for the sync gateway though… - and deletions not sent to mobile (but asked that as a separate question to avoid cluttering everything up)…