Sync gateway crash

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

Adding “use_views”: true in configuration solved the issue.

I’m using Couchbase server 5.1 and it doesn’t supports GSI.

Any reason you cannot upgrade to a later version of server?

Multiple projects are sitting in the same cluster. Would it be a smooth transition 5.1 to 5.5?

I can’t authoritatively speak to server side upgrades but I would expect a smooth transition between minor releases. Here is the documentation - there are several options for doing upgrades that includes a rolling upgrade so there is no impact to running applications.

Would suspect you’d want to upgrade your dev/test cluster and confirm things work before rolling out to production.
But definitely encourage you to upgrade as 5.1 is a pretty old version.

Thanks Priya! I will encourage the team to upgrade soon.

1 Like