Skip to content

Commit 410e8c7

Browse files
authored
Update to Core 13.24.0 (#1439)
* Update to Core 13.24.0 * Regenerate ffi bindings * Retry calling the client reset function
1 parent 2355f74 commit 410e8c7

File tree

4 files changed

+63
-39
lines changed

4 files changed

+63
-39
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55

66
### Fixed
77
* Fixed an issue where connections to Atlas App Services would fail on Android with a certificate expiration error. (Issue [#1430](https://github.com/realm/realm-dart/issues/1430))
8+
* Errors encountered while reapplying local changes for client reset recovery on partition-based sync Realms would result in the client reset attempt not being recorded, possibly resulting in an endless loop of attempting and failing to automatically recover the client reset. Flexible sync and errors from the server after completing the local recovery were handled correctly. (Core 13.24.0)
9+
* During a client reset with recovery when recovering a move or set operation on a `List` that operated on indices that were not also added in the recovery, links to an object which had been deleted by another client while offline would be recreated by the recovering client. But the objects of these links would only have the primary key populated and all other fields would be default values. Now, instead of creating these zombie objects, the lists being recovered skip such deleted links. (Core 13.24.0)
10+
* During a client reset recovery a Set of objects could be missing items, or an exception could be thrown that prevents recovery ex: "Requested index 1 calling get() on set 'source.collection' when max is 0". (Core 13.24.0)
11+
* Automatic client reset recovery would duplicate insertions in a list when recovering a write which made an unrecoverable change to a list (i.e. modifying or deleting a pre-existing entry), followed by a subscription change, followed by a write which added an entry to the list. (Core 13.24.0)
812

913
### Compatibility
1014
* Realm Studio: 13.0.0 or later.
1115
* Flutter: ^3.13.0
1216
* Dart: ^3.1.0
1317

1418
### Internal
15-
* Using Core 13.23.2.
19+
* Using Core 13.24.0.
1620

1721
## 1.6.0 (2023-11-15)
1822

@@ -55,7 +59,7 @@
5559
* Sync protocol version bumped to 10. (Core upgrade)
5660
* Handle `badChangeset` error when printing changeset contents in debug. (Core upgrade)
5761

58-
* Using Core 13.23.2.
62+
* Using Core 13.23.4.
5963

6064
## 1.5.0 (2023-09-18)
6165

lib/src/native/realm_bindings.dart

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,37 @@ class RealmLibrary {
30533053
bool Function(
30543054
ffi.Pointer<realm_t>, ffi.Pointer<ffi.Char>, realm_binary_t, bool)>();
30553055

3056+
/// Helper method for making it easier to to convert SDK input to the underlying
3057+
/// `realm_key_path_array_t`.
3058+
///
3059+
/// @return A pointer to the converted key path array. NULL in case of an error.
3060+
ffi.Pointer<realm_key_path_array_t> realm_create_key_path_array(
3061+
ffi.Pointer<realm_t> realm,
3062+
int object_class_key,
3063+
int num_key_paths,
3064+
ffi.Pointer<ffi.Pointer<ffi.Char>> user_key_paths,
3065+
) {
3066+
return _realm_create_key_path_array(
3067+
realm,
3068+
object_class_key,
3069+
num_key_paths,
3070+
user_key_paths,
3071+
);
3072+
}
3073+
3074+
late final _realm_create_key_path_arrayPtr = _lookup<
3075+
ffi.NativeFunction<
3076+
ffi.Pointer<realm_key_path_array_t> Function(
3077+
ffi.Pointer<realm_t>,
3078+
realm_class_key_t,
3079+
ffi.Size,
3080+
ffi.Pointer<ffi.Pointer<ffi.Char>>)>>(
3081+
'realm_create_key_path_array');
3082+
late final _realm_create_key_path_array =
3083+
_realm_create_key_path_arrayPtr.asFunction<
3084+
ffi.Pointer<realm_key_path_array_t> Function(ffi.Pointer<realm_t>,
3085+
int, int, ffi.Pointer<ffi.Pointer<ffi.Char>>)>();
3086+
30563087
/// Get a thread-safe reference representing the same underlying object as some
30573088
/// API object.
30583089
///
@@ -3925,14 +3956,14 @@ class RealmLibrary {
39253956
ffi.Pointer<realm_dictionary_t> arg0,
39263957
ffi.Pointer<ffi.Void> userdata,
39273958
realm_free_userdata_func_t userdata_free,
3928-
ffi.Pointer<realm_key_path_array_t> arg3,
3959+
ffi.Pointer<realm_key_path_array_t> key_path_array,
39293960
realm_on_dictionary_change_func_t on_change,
39303961
) {
39313962
return _realm_dictionary_add_notification_callback(
39323963
arg0,
39333964
userdata,
39343965
userdata_free,
3935-
arg3,
3966+
key_path_array,
39363967
on_change,
39373968
);
39383969
}
@@ -5498,14 +5529,14 @@ class RealmLibrary {
54985529
ffi.Pointer<realm_list_t> arg0,
54995530
ffi.Pointer<ffi.Void> userdata,
55005531
realm_free_userdata_func_t userdata_free,
5501-
ffi.Pointer<realm_key_path_array_t> arg3,
5532+
ffi.Pointer<realm_key_path_array_t> key_path_array,
55025533
realm_on_collection_change_func_t on_change,
55035534
) {
55045535
return _realm_list_add_notification_callback(
55055536
arg0,
55065537
userdata,
55075538
userdata_free,
5508-
arg3,
5539+
key_path_array,
55095540
on_change,
55105541
);
55115542
}
@@ -6553,14 +6584,14 @@ class RealmLibrary {
65536584
ffi.Pointer<realm_object_t> arg0,
65546585
ffi.Pointer<ffi.Void> userdata,
65556586
realm_free_userdata_func_t userdata_free,
6556-
ffi.Pointer<realm_key_path_array_t> arg3,
6587+
ffi.Pointer<realm_key_path_array_t> key_path_array,
65576588
realm_on_object_change_func_t on_change,
65586589
) {
65596590
return _realm_object_add_notification_callback(
65606591
arg0,
65616592
userdata,
65626593
userdata_free,
6563-
arg3,
6594+
key_path_array,
65646595
on_change,
65656596
);
65666597
}
@@ -7407,14 +7438,14 @@ class RealmLibrary {
74077438
ffi.Pointer<realm_results_t> arg0,
74087439
ffi.Pointer<ffi.Void> userdata,
74097440
realm_free_userdata_func_t userdata_free,
7410-
ffi.Pointer<realm_key_path_array_t> arg3,
7441+
ffi.Pointer<realm_key_path_array_t> key_path_array,
74117442
realm_on_collection_change_func_t arg4,
74127443
) {
74137444
return _realm_results_add_notification_callback(
74147445
arg0,
74157446
userdata,
74167447
userdata_free,
7417-
arg3,
7448+
key_path_array,
74187449
arg4,
74197450
);
74207451
}
@@ -8195,14 +8226,14 @@ class RealmLibrary {
81958226
ffi.Pointer<realm_set_t> arg0,
81968227
ffi.Pointer<ffi.Void> userdata,
81978228
realm_free_userdata_func_t userdata_free,
8198-
ffi.Pointer<realm_key_path_array_t> arg3,
8229+
ffi.Pointer<realm_key_path_array_t> key_path_array,
81998230
realm_on_collection_change_func_t on_change,
82008231
) {
82018232
return _realm_set_add_notification_callback(
82028233
arg0,
82038234
userdata,
82048235
userdata_free,
8205-
arg3,
8236+
key_path_array,
82068237
on_change,
82078238
);
82088239
}
@@ -11688,33 +11719,10 @@ final class realm_index_range extends ffi.Struct {
1168811719

1168911720
typedef realm_index_range_t = realm_index_range;
1169011721

11691-
final class realm_key_path extends ffi.Struct {
11692-
@ffi.Size()
11693-
external int nb_elements;
11694-
11695-
external ffi.Pointer<realm_key_path_elem_t> path_elements;
11696-
}
11697-
11698-
final class realm_key_path_array extends ffi.Struct {
11699-
@ffi.Size()
11700-
external int nb_elements;
11701-
11702-
external ffi.Pointer<realm_key_path_t> paths;
11703-
}
11722+
final class realm_key_path_array extends ffi.Opaque {}
1170411723

1170511724
typedef realm_key_path_array_t = realm_key_path_array;
1170611725

11707-
final class realm_key_path_elem extends ffi.Struct {
11708-
@realm_class_key_t()
11709-
external int object;
11710-
11711-
@realm_property_key_t()
11712-
external int property;
11713-
}
11714-
11715-
typedef realm_key_path_elem_t = realm_key_path_elem;
11716-
typedef realm_key_path_t = realm_key_path;
11717-
1171811726
final class realm_link extends ffi.Struct {
1171911727
@realm_class_key_t()
1172011728
external int target_table;

src/realm-core

Submodule realm-core updated 59 files

test/client_reset_test.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,20 @@ Future<void> triggerClientReset(Realm realm, {bool restartSession = true}) async
653653
final userId = config.user.id;
654654
final appId = baasApps.values.firstWhere((element) => element.clientAppId == config.user.app.id).appId;
655655

656-
final result = await config.user.functions.call('triggerClientResetOnSyncServer', [userId, appId]) as Map<String, dynamic>;
657-
expect(result['status'], 'success');
656+
for (var i = 0; i < 5; i++) {
657+
try {
658+
final result = await config.user.functions.call('triggerClientResetOnSyncServer', [userId, appId]) as Map<String, dynamic>;
659+
expect(result['status'], 'success');
660+
break;
661+
} catch (e) {
662+
if (i == 4) {
663+
rethrow;
664+
}
665+
666+
print('Failed to trigger client reset: $e');
667+
await Future.delayed(Duration(seconds: i));
668+
}
669+
}
658670

659671
if (restartSession) {
660672
session.resume();

0 commit comments

Comments
 (0)