sync_gateway
sync_gateway copied to clipboard
Ignoring specific collection name (and scope) from config file
Sync Gateway version
3.1
Operating system
Running on docker (my laptop is Win 11)
Config file
{
"interface":":4984",
"logging": {
"log_file_path": "/var/tmp/sglogs",
"console": {
"log_level": "debug",
"log_keys": ["*"]
},
"error": {
"enabled": true,
"rotation": {
"max_size": 20,
"max_age": 180
}
},
"warn": {
"enabled": true,
"rotation": {
"max_size": 20,
"max_age": 90
}
},
"info": {
"enabled": false
},
"debug": {
"enabled": false
}
},
"databases": {
"demobucket": {
"import_docs": "continuous",
"enable_shared_bucket_access":true,
"name": "db",
"bucket": "default",
"scopes" : {
"_default": {
"collections": {
"specific_collection" : {
"sync": `
function(doc, oldDoc, meta) {
channel("legacy")
}
`,
"import_filter": `
function(doc) {
return doc.type == "mobile"
}
`
}
}
}
},
"num_index_replicas": 0,
"server": "http://cb-server:8091",
"username": "username",
"password": "password",
"num_index_replicas":0,
"users":{
"admin": {"password": "password", "admin_channels": ["*"]}
},
"revs_limit":20
}
}
}
Log output
When going to "http://localhost:4985/demobucket._default.specific_collection/_changes" I get: { "error": "not_found", "reason": "keyspace demobucket._default.specific_collection not found" }
Expected behavior
I expect to see the changes in the specific collection that I configured in the config file
Actual behavior
What actually happened?
Steps to reproduce
- Create new collection named "specific_collection".
- Change your config to the config I provided.
- Run it on docker.
- Go to "http://localhost:4985/demobucket._default.specific_collection/_changes". --
I think this is because in the file "bootstrap.go" the collection name that being delivered is "DefaultCollection()" instead of the collection that is been provided in the config.
This works OK for me (after a few config migration hiccups with allowing non-TLS bootstrap URL)
Can you verify that the database config stored in the bucket contains the expected collection?
Here's mine:
Now it works because I've updated the database config with an API call (PUT) "http://localhost:4985/demobucket/_config". So I do see it, but when I initially deployed the Sync Gateway (before the API update call), the collections didn't appear in the file. Am I missing something in my steps? maybe you did a specific step or command that I didn't do?
You're steps look fine to me. I also had a go at reproducing this and I also couldn't repro your issue. My steps were:
- Create bucket titled 'default' in Couchbase Server, add collection called specific_collection to the _default scope
- Launch sync gateway 3.1 with your config but with the addition of "use_tls_server": false to the config to avoid TLS error
- Sync gateway will upgrade the legacy config to new config and the db specified is created
- I can successfully call operations the keyspace created in the db. (Keyspace demobucket._default.specific_collection)
I would advise you move away from legacy config like yours above and use the REST API to create and manage databases in sync gateway if possible.
In step 3, please show me your legacy config and the new upgraded config. I see it's being upgraded, but there is no mention of the specific_collection.
My upgraded config looks like the following:
{
"bootstrap": {
"server": "couchbase://127.0.0.1",
"username": "couchbase",
"password": "couchbase",
"use_tls_server": false
},
"api": {
"public_interface": ":4984",
"https": {}
},
"logging": {
"log_file_path": "/var/tmp/sglogs",
"console": {
"rotation": {},
"log_level": "debug",
"log_keys": [
"*"
]
},
"error": {
"enabled": true,
"rotation": {
"max_size": 20,
"max_age": 180
}
},
"warn": {
"enabled": true,
"rotation": {
"max_size": 20,
"max_age": 90
}
},
"info": {
"enabled": false,
"rotation": {}
},
"debug": {
"enabled": false,
"rotation": {}
},
"trace": {
"rotation": {}
},
"stats": {
"rotation": {}
}
},
"auth": {},
"replicator": {},
"unsupported": {
"serverless": {}
}
}
The db config will not show here. This upgraded config is the persistent config startup config. The db specified in your original file will have been created and the config persisted to the default collection in the bucket the db is made on. See below: