Unable to sync about 10mb worth of data?

I’m having about 30K of records totalling about 12mb being written to a realm in the background. They show up fine locally but can’t sync to Atlas in a reasonable time. I’m test driving a M10 cluster.

The record comes from a data import routine and they’re written to disk as they’re parsed. I’m using the Swift SDK btw.

I retried with isIdleTimerDisabled disabled and left the device on for long and killed the app after some time. Turns out it failed a few minutes in with a different message:

integrating changesets failed: retryable error while committing integrated changesets: failed to apply changesets: failed to apply to state store: error applying changes to the state store: error performing bulk write to MongoDB {table: "xxx", err: connection(xxx]) incomplete read of message header: context canceled} (ProtocolErrorCode=201)

Any ideas how to approach this?

Hi @anh ,

You’ve obscured all the significant details that could help understanding the issue in depth: one obvious issue in what we can see is that you’re trying to insert ~30K objects in a single transaction. This is indeed an issue: a transaction should ideally be the minimal change consistent in itself, and while it may be convenient to group some insertions/updates together, doing the whole import in one go is not advisable, especially when manipulating more than a couple hundred objects.

Can you split the import in more transactions, of no more than few hundred objects each, and check how it goes?

Gotcha. Indeed I overlooked that details. I thought the 30K objects have been all written to disk and show up fine in the UI, and that meant the issue was with the connection between the device and the Atlas cluster somehow. It didn’t occur to me that the amount of writes within each realm.write block corresponds to the number of changesets being uploaded.

Indeed this goes away when I separate them into 500-something writes a transaction.

Thanks for the help Paolo.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.