Hey folks,
one of your former Realmies here. Lovely to see btw. that there are still some familiar faces around from back in the day.
Well, I wanted to give MongoDB Realm a spin and use it to build a product myself for once. But I keep hitting walls and I cannot find why.
Context and Stumblings
For context, I’m trying to use the Cocoa bindings from a macOS app in beta-2. I tried the tag which is published on CocoaPods, but saw that there are some not-yet-published improvements on the branch v10
, so I hoped maybe if I go bleeding edge it will be better, but no dice. )
I’ve my MongoDB Realm sync in development mode and my sync permissions are true
for read and write, which should be as permissive as it gets.
Note:
The UI around could give a little intro in what these expressions actually mean, at least provide a direct links to the docs and the semantics are totally unclear as is. But also the documentation around this is lacking a good intro in what’s going on really. But maybe this is all subject to change?)
I’ve tried to change the type of the partition key, the name of the partition key (_partitionKey
and _partition
, tried to stay close with the docs ), I read a lot of docs, tutorials, examples, read some code diffs to catch up with what has changed and I could be missing*, … But there is almost nothing around this particular error, which is really frustrating. I diffed my exported server config with the tutorial app, but nothing stand out which should be problematic.
Note:
By reading the cocoa bindings code, I first found out aboutEmbeddedObject
, which is pretty awesome and made me very happy, but it is not even mentioned with a single word in the MongoDB Realm docs. I think it would be good to give an explanation on how this affects sync and maps to MongoDB Atlas. This whole latter part is very opaque right now and it would help a lot, if this would be laid out better to the user imho.
About my error:
I get the following error in the MongoDB Realm UI in the logs:
Ending session with error: failed to validate upload changesets: instruction had incorrect partition value for key "_partition" (ProtocolErrorCode=212)
This maps to what I see in the macOS client in the logs. That is logLevel to .debug
, plus one print line custom logging from the error handler. (starting with , as seen in the log attached below) What (I think) I can recognise is that this must be something related to some validation on the server-side, as given by the error class. Partitioning was before my time and I’m sure a lot has changed around that since the MongoDB integration, so I don’t really know what’s going on there. I feel like I’m holding it wrong. Just not sure how, where or why.
Server Log
Summary
BadChangeset Error
Error:
Ending session with error: failed to validate upload changesets: instruction had incorrect partition value for key "_partition" (ProtocolErrorCode=212)
Partition:
master
Session Metrics:
{}
SDK:
Realm Cocoa v10.0.0-beta.2
Platform Version:
Version 10.15.5 (Build 19F101)
Client Log
Summary
2020-08-16 13:22:59.799380+0200 Editor[99805:16209519] Sync: Realm sync client ([realm-core-10.0.0-beta.1], [realm-sync-10.0.0-beta.2])
2020-08-16 13:22:59.799460+0200 Editor[99805:16209519] Sync: Supported protocol versions: 1-1
2020-08-16 13:22:59.799514+0200 Editor[99805:16209519] Sync: Platform: macOS Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
2020-08-16 13:22:59.799556+0200 Editor[99805:16209519] Sync: Build mode: Release
2020-08-16 13:22:59.799593+0200 Editor[99805:16209519] Sync: Config param: max_open_files = 256
2020-08-16 13:22:59.799629+0200 Editor[99805:16209519] Sync: Config param: one_connection_per_session = 1
2020-08-16 13:22:59.799667+0200 Editor[99805:16209519] Sync: Config param: connect_timeout = 120000 ms
2020-08-16 13:22:59.799701+0200 Editor[99805:16209519] Sync: Config param: connection_linger_time = 30000 ms
2020-08-16 13:22:59.799733+0200 Editor[99805:16209519] Sync: Config param: ping_keepalive_period = 60000 ms
2020-08-16 13:22:59.799765+0200 Editor[99805:16209519] Sync: Config param: pong_keepalive_timeout = 120000 ms
2020-08-16 13:22:59.799797+0200 Editor[99805:16209519] Sync: Config param: fast_reconnect_limit = 60000 ms
2020-08-16 13:22:59.799829+0200 Editor[99805:16209519] Sync: Config param: disable_upload_compaction = 0
2020-08-16 13:22:59.799860+0200 Editor[99805:16209519] Sync: Config param: tcp_no_delay = 0
2020-08-16 13:22:59.799892+0200 Editor[99805:16209519] Sync: Config param: disable_sync_to_disk = 0
2020-08-16 13:22:59.799927+0200 Editor[99805:16209519] Sync: User agent string: ‘RealmSync/10.0.0-beta.2 (macOS Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64) RealmObjectiveC/10.0.0-beta.2 $appId’
2020-08-16 13:22:59.801140+0200 Editor[99805:16211279] Sync: Connection[1]: WebSocket::Websocket()
2020-08-16 13:22:59.801243+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Binding ‘$path’ to ‘“master”’
2020-08-16 13:22:59.801299+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Activating
2020-08-16 13:22:59.801370+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, async open = false, client reset = false
2020-08-16 13:22:59.801418+0200 Editor[99805:16211279] Sync: Opening Realm file: $path
2020-08-16 13:22:59.801816+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: client_file_ident = 0, client_file_ident_salt = 0
2020-08-16 13:22:59.801892+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Progress handler called, downloaded = 0, downloadable(total) = 0, uploaded = 0, uploadable = 0, reliable_download_progress = 0, snapshot version = 1
2020-08-16 13:22:59.801958+0200 Editor[99805:16211279] Sync: Connection[1]: Resolving ‘ws.eu-west-1.aws.realm.mongodb.com:443’
2020-08-16 13:22:59.831549+0200 Editor[99805:16211279] Sync: Connection[1]: Connecting to endpoint ‘99.83.185.35:443’ (1/2)
2020-08-16 13:22:59.840666+0200 Editor[99805:16211279] Sync: Connection[1]: Connected to endpoint ‘99.83.185.35:443’ (from ‘192.168.178.65:60858’)
2020-08-16 13:22:59.864231+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Progress handler called, downloaded = 0, downloadable(total) = 0, uploaded = 0, uploadable = 2216, reliable_download_progress = 0, snapshot version = 2
2020-08-16 13:22:59.951901+0200 Editor[99805:16211279] Sync: Connection[1]: WebSocket::initiate_client_handshake()
2020-08-16 13:23:00.025554+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Progress handler called, downloaded = 0, downloadable(total) = 0, uploaded = 0, uploadable = 2318, reliable_download_progress = 0, snapshot version = 3
2020-08-16 13:23:00.090092+0200 Editor[99805:16211279] Sync: Connection[1]: WebSocket::handle_http_response_received()
2020-08-16 13:23:00.090171+0200 Editor[99805:16211279] Sync: Connection[1]: Negotiated protocol version: 1
2020-08-16 13:23:00.090222+0200 Editor[99805:16211279] Sync: Connection[1]: Will emit a ping in 20117 milliseconds
2020-08-16 13:23:00.090268+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Sending: BIND(path=‘“master”’, signed_user_token_size=469, need_client_file_ident=1, is_subserver=0)
2020-08-16 13:23:01.349524+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Received: IDENT(client_file_ident=5, client_file_ident_salt=387383682228219102)
2020-08-16 13:23:01.350739+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Sending: IDENT(client_file_ident=5, client_file_ident_salt=387383682228219102, scan_server_version=0, scan_client_version=0, latest_server_version=0, latest_server_version_salt=0)
2020-08-16 13:23:01.350905+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Sending: MARK(request_ident=1)
2020-08-16 13:23:01.605823+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Received: DOWNLOAD(download_server_version=1, download_client_version=0, latest_server_version=1, latest_server_version_salt=3644857074679688014, upload_client_version=0, upload_server_version=0, downloadable_bytes=0, num_changesets=1, …)
2020-08-16 13:23:01.606233+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Finished changeset indexing (incoming: 1 changeset(s) / 6 instructions, local: 2 changeset(s) / 128 instructions, conflict group(s): 2)
2020-08-16 13:23:01.606478+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Finished transforming 2 local changesets through 1 incoming changesets (128 vs 6 instructions, in 2 conflict groups)
2020-08-16 13:23:01.607236+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: 1 remote changeset integrated, producing client version 5
2020-08-16 13:23:01.607313+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Progress handler called, downloaded = 105, downloadable(total) = 105, uploaded = 0, uploadable = 2318, reliable_download_progress = 1, snapshot version = 5
2020-08-16 13:23:01.748902+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Received: MARK(request_ident=1)
2020-08-16 13:23:01.749017+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Sending: UPLOAD(progress_client_version=5, progress_server_version=1, locked_server_version=1, num_changesets=2)
2020-08-16 13:23:01.749137+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Upload compaction: original size = 2216, compacted size = 2216
2020-08-16 13:23:01.749204+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Upload compaction: original size = 102, compacted size = 102
2020-08-16 13:23:01.790901+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Received: ERROR(error_code=212, message_size=22, try_again=0)
2020-08-16 13:23:01.791019+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Suspended
2020-08-16 13:23:01.791269+0200 Editor[99805:16211279] Sync: Connection[1]: Session[1]: Sending: UNBIND
Unhandled sync error: io.realm.sync:4 Bad changeset (UPLOAD)2020-08-16 13:23:01.791541+0200 Editor[99805:16211279] Sync: Connection[1]: Disconnected