realm.syncSession disconnects upon completion

Hi there,

When a user switches device and logs in, I have a block of code to synchronously sync the data with the servers before progressing:

Code looks something like this:

let session = realm.syncSession
notificationToken = session!.addProgressNotification(for: .download, mode: .forCurrentlyOutstandingWork) { [weak self] progress in
    DispatchQueue.main.async {
        progressView.setProgress(Float(progress.fractionTransferred), animated: true)
        if progress.isTransferComplete {
            // Continue

However, as soon as it completes, the completion handler is never called and we never progress. This block of code used to work for me (~1.5 weeks ago), but for some reason has stopped working. I know it was synced successfully because when I restart the app and log-in, the data is now successfully loaded locally.

In my logs I see this, but otherwise no errors.


  "Session closed after receiving UNBIND event",
  "Session was active for: 9s"


@Roger_Cheng What version of the SDK are you using? I believe we just fixed some behavior related to this in the latest version


Realm Cocoa v10.7.2
Platform Version:
Version 14.3 (Build 18C66)

I will say that about 1.5 weeks ago, when we were testing, realm sync was working just fine for us, but we did migrate to a new, atlas cluster in anticipation of moving to production (from M0 to M2 simply by clicking through the Atlas GUI) and have since struggled with our syncs.

Since this post yesterday, we dropped all the data in the underlying databases, terminated the sync and restarted the sync, and while have seen some syncs come through (though not as cleanly with the progress bar as before), are still seeing recurring errors in the logs, with the most recent one being, on repeat:

Failed to integrate download after attempting the maximum number of tries: error applying downloaded changesets to mongodb: (NoSuchTransaction) error performing bulk write to MongoDB

Here is my url if you’re able to take a look - appreciate you investigating:

For any performance related issues we really would recommend being on a dedicated tier, especially if you are looking to go into production. Any time you upgrade from a shared tier or drop collections you will need to terminate and re-enable sync to regenerate the history - make sure to wait a bit before re-enabling as it cleans up the old history. The re-enabling of sync causes an Initial Sync event which puts a lot of load on your server - doubly so if you are a shared tier user.

Thanks - that must have been what caused the cascade of errors / problems. Very helpful.

@Roger_Cheng Do the performance problems persist? Have you tried upgrading to a M10, atleast temporarily to see if it improves your workload?

The sync has begun working again ever since fully terminating the sync and dropping all the databases. Obviously a sub-ideal solution, but fortunately we’re not live yet. Haven’t had a chance to try M10 yet, but that suggestion is duly noted for the future.