I have this sg config with test webhook filter to confirm if it is being triggered by document changes:
{
"adminInterface": ":4985",
"interface": ":4984",
"log":["REST+","CRUD+","Events","Events+","HTTP+"],
"databases": {
"db": {
"server": "some_url:8091",
"bucket": "default",
"username": "Administrator",
"password": "Password",
"enable_shared_bucket_access": true,
"import_docs": true,
"num_index_replicas": 0,
"users": {
"GUEST": { "disabled": false, "admin_channels": ["*"] },
"sync_gateway": {"password": "pass1234"}
},
"event_handlers":{
"document_changed":[
{
"handler":"webhook",
"url":"some_url",
"filter":`function(doc){
if(doc.docType=="Test"){
console.log("Webhook triggered by docType: " + doc.docType);
return true;
}
else return false
}`
}
]
}
}
}
}
It worked as expected but upon restarting the sync gateway service it crashed. This happened before also by restarting sync gateway service by 3 times with 15 minutes interval. Rebooting the server somehow solved the issue but this time rebooting the server doesn’t help.
Got plenty of this on error log:
2021-01-07T00:21:38.603+08:00 [WRN] Error creating index sg_allDocs_x1: Error creating index with statement: CREATE INDEX `sg_allDocs_x1` ON `default`(meta().xattrs._sync.sequence, meta().xattrs._sync.rev, meta().xattrs._sync.flags, meta().xattrs._sync.deleted) WHERE META().id NOT LIKE '\\_sync:%' with {"retain_deleted_xattr":true,"defer_build":true}. Error: [3000] Expression not indexable: (((meta().`xattrs`).`_sync`).`sequence`) - at ,
Expression not indexable: (((meta().`xattrs`).`_sync`).`rev`) - at ,
Expression not indexable: (((meta().`xattrs`).`_sync`).`flags`) - at ,
Expression not indexable: (((meta().`xattrs`).`_sync`).`deleted`) - at ) - will retry. -- db.(*SGIndex).createIfNeeded.func1() at indexes.go:256