The problem that I ran into was that when closing the database in the thread, it resulted in stopping replication for all threads. However, using a 2nd manager instance instead of a copy, didn’t have that effect.
If you create a Replication in both the foreground and background Database instance, they end up triggering a single replicator task (because their parameters are the same.) Then if you close the background Database it stops its Replications, which in turn stop the replicator task.
The solution is not to do that Only create Replications on one thread.
(Or if you are only creating Replications on one thread, but are seeing this behavior, it sounds like a bug…)
I’m not creating a second replicator. I first tried closing the database on the background thread, then did the manager like advised, but it does close the replicators used on the main thread.
In the copyWithZone function in the manager source code, it is doing this: managerCopy.replicatorClassName = _replicatorClassName;, could this have anything to do with the background close wiping all replicators on all threads, since based on your really helpful description, could cause it to create a single replicator task even though I never explicitly do this?
I’m thinking of reverting back to backgroundTellDatabaseNamed, but I like having my database tasks spread across relevant queues, instead of overloading the Couchbase maintenance thread. Do I have to close the database there?