Skip to content

Commit

Permalink
Bump Sync to 3.10.1 (#1772)
Browse files Browse the repository at this point in the history
* Bump Sync to 3.10.1

* Try to disable the sync win32 build

* Update ROS for tests

* Try to enable the ROS tests

* Update to latest OS, sync, and Core

* Update new core linux location

* Bring back the windows builds on CI

* Remove the withROS_temp

* Changelog

* Remove some .def files

* Try to set nuget environment variable

* Try #2

* Try #3

* Try #4

* #5

* #6

* Report the node

* Upgrade to 3.14.11

* Use the well-known sync binary location

* Try to fix the tests

* Fix the changelog

* Update CHANGELOG.md

Co-Authored-By: nirinchev <irinchev@me.com>

* Update CHANGELOG.md

Co-Authored-By: nirinchev <irinchev@me.com>

* Update CHANGELOG.md

Co-Authored-By: nirinchev <irinchev@me.com>

* Changelog updates
  • Loading branch information
nirinchev authored Jan 9, 2019
1 parent 3550815 commit 58fc404
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 290 deletions.
27 changes: 24 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
vNext (TBD)
------------------

NOTE!!! You will need to upgrade your Realm Object Server to at least version 3.11.0 or use Realm Cloud. If you try to connect to a ROS v3.10.x or previous, you will see an error like Wrong protocol version in Sync HTTP request, client protocol version = 25, server protocol version = 24.

### Enhancements
* Download progress is now reported to the server, even when there are no local changes. This allows the server to do history compaction much more aggressively, especially when there are many clients that rarely or never make local changes. ([#1772](https://github.com/realm/realm-dotnet/pull/1772))
* Reduce memory usage when integrating synchronized changes sent by ROS.

### Fixed
* Fixed a bug that could lead to crashes with a message such as `Assertion failed: ndx < size() with (ndx, size()) = [742, 742]`.

### Compatibility
* Realm Object Server: 3.11.0 or later.
* APIs are backwards compatible with all previous releases in the 3.x.y series.
* File format: Generates Realms with format v9 (Reads and upgrades all previous formats)

### Breaking Changes
* The deprecated method `realm.SubscribeToObjectsAsync` has been removed in this version. ([#1772](https://github.com/realm/realm-dotnet/pull/1772))

### Internal
* Upgraded Sync from 3.9.2 to 3.14.11 and Core from 5.8.0 to 5.12.7.


3.3.0 (2018-11-08)
------------------

Expand All @@ -13,9 +37,6 @@
* APIs are backwards compatible with all previous releases in the 3.x.y series.
* File format: Generates Realms with format v9 (Reads and upgrades all previous formats)

### Internal
* None.


3.2.1 (2018-09-27)
------------------
Expand Down
13 changes: 11 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def NetCoreTest(String nodeName, String platform, String stashSuffix) {
if (isUnix()) {
if (nodeName == 'docker') {
def test_runner_image = buildDockerEnv("ci/realm-dotnet:netcore_tests");
withRos("3.0.0") { ros ->
withRos("3.11.0") { ros ->
test_runner_image.inside("--link ${ros.id}:ros") {
sh """
cd ${pwd()}/${binaryFolder}
Expand Down Expand Up @@ -757,6 +757,8 @@ step([$class: 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1, thresh

def nodeWithCleanup(String label, Closure steps) {
node(label) {
echo "Running job on ${env.NODE_NAME}"

// compute a shorter workspace name by removing the UUID at the end
def terminus = env.WORKSPACE.lastIndexOf('-')
def at = env.WORKSPACE.lastIndexOf('@')
Expand All @@ -766,7 +768,14 @@ def nodeWithCleanup(String label, Closure steps) {

ws(workspace) {
try {
steps()
if (!isUnix()) {
// https://stackoverflow.com/questions/48896486/jenkins-not-restoring-nuget-packages-with-new-msbuild-restore-target
withEnv(['NUGET_PACKAGES=C:\\NugetPackageCache']) {
steps()
}
} else {
steps()
}
} finally {
deleteDir()
}
Expand Down
16 changes: 0 additions & 16 deletions Platform.PCL/Realm.Sync.PCL/Extensions/RealmSyncExtensionsPCL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ public static Session GetSession(this Realm realm)
return null;
}

/// <summary>
/// If the Realm uses query-based synchronization, fetch and synchronize the objects
/// of a given object type that match the given query (in string format).
/// </summary>
/// <typeparam name="T">The type of the objects making up the query.</typeparam>
/// <param name="realm">An instance of the <see cref="Realm"/> class created with a <see cref="SyncConfiguration"/> object.</param>
/// <param name="query">A string-based query using the NSPredicate syntax to specify which objects should be returned.</param>
/// <returns>An awaitable task that, upon completion, contains all objects matching the query.</returns>
/// <seealso href="https://academy.realm.io/posts/nspredicate-cheatsheet/">NSPredicate Cheatsheet</seealso>
[Obsolete("Use the IQueryable.SubscribeToObjects extension method")]
public static Task<IQueryable<T>> SubscribeToObjectsAsync<T>(this Realm realm, string query)
{
RealmPCLHelpers.ThrowProxyShouldNeverBeUsed();
return null;
}

internal static string GetMappedOrOriginalName(this MemberInfo member)
{
RealmPCLHelpers.ThrowProxyShouldNeverBeUsed();
Expand Down
6 changes: 4 additions & 2 deletions Realm/Realm.Sync/Exceptions/ClientResetException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////////////

using System.Collections.Generic;
using System.IO;

namespace Realms.Sync.Exceptions
{
Expand All @@ -36,8 +37,9 @@ public class ClientResetException : SessionException
internal ClientResetException(string message, IDictionary<string, string> userInfo)
: base(message, ErrorCode.DivergingHistories)
{
_originalFilePath = userInfo[OriginalFilePathKey];
BackupFilePath = userInfo[BackupFilePathKey];
// Using Path.GetFullPath to normalize path separators on Windows
_originalFilePath = Path.GetFullPath(userInfo[OriginalFilePathKey]);
BackupFilePath = Path.GetFullPath(userInfo[BackupFilePathKey]);
HelpLink = "https://realm.io/docs/xamarin/latest/#client-reset";
}

Expand Down
29 changes: 0 additions & 29 deletions Realm/Realm.Sync/Extensions/RealmSyncExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,5 @@ public static Session GetSession(this Realm realm)

return new Session(realm.Config.DatabasePath);
}

/// <summary>
/// If the Realm uses query-based synchronization, fetch and synchronize the objects
/// of a given object type that match the given query (in string format).
/// </summary>
/// <typeparam name="T">The type of the objects making up the query.</typeparam>
/// <param name="realm">An instance of the <see cref="Realm"/> class created with a <see cref="SyncConfigurationBase"/> object.</param>
/// <param name="query">A string-based query using the NSPredicate syntax to specify which objects should be returned.</param>
/// <returns>An awaitable task that, upon completion, contains all objects matching the query.</returns>
/// <seealso href="https://academy.realm.io/posts/nspredicate-cheatsheet/">NSPredicate Cheatsheet</seealso>
[Obsolete("Use the IQueryable.SubscribeToObjects extension method")]
public static async Task<IQueryable<T>> SubscribeToObjectsAsync<T>(this Realm realm, string query)
{
Argument.NotNull(realm, nameof(realm));
Argument.Ensure(realm.Config is SyncConfigurationBase, "Cannot get a Session for a Realm without a SyncConfiguration", nameof(realm));

var type = typeof(T);
if (!realm.Metadata.TryGetValue(type.GetTypeInfo().GetMappedOrOriginalName(), out var metadata) || metadata.Schema.Type.AsType() != type)
{
throw new ArgumentException($"The class {type.Name} is not in the limited set of classes for this realm");
}

var tcs = new TaskCompletionSource<ResultsHandle>();

SharedRealmHandleExtensions.SubscribeForObjects(realm.SharedRealmHandle, type, query, tcs);

var resultsHandle = await tcs.Task;
return new RealmResults<T>(realm, metadata, resultsHandle);
}
}
}
68 changes: 12 additions & 56 deletions Realm/Realm.Sync/Handles/SharedRealmHandleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,16 @@ public static extern IntPtr open_with_sync(Configuration configuration, Native.S
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate void SessionWaitCallback(IntPtr task_completion_source, int error_code, byte* message_buf, IntPtr message_len);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void SubscribeForObjectsCallback(IntPtr results, IntPtr task_completion_source, NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_configure_file_system", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void configure_file_system([MarshalAs(UnmanagedType.LPWStr)] string base_path, IntPtr base_path_leth,
UserPersistenceMode* userPersistence, byte[] encryptionKey,
[MarshalAs(UnmanagedType.I1)] bool resetMetadataOnError,
out NativeException exception);
[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_configure", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void configure([MarshalAs(UnmanagedType.LPWStr)] string base_path, IntPtr base_path_length,
[MarshalAs(UnmanagedType.LPWStr)] string user_agent, IntPtr user_agent_length,
UserPersistenceMode* userPersistence, byte[] encryptionKey,
[MarshalAs(UnmanagedType.I1)] bool resetMetadataOnError,
out NativeException exception);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_install_syncsession_callbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void install_syncsession_callbacks(RefreshAccessTokenCallbackDelegate refresh_callback, SessionErrorCallback error_callback, SessionProgressCallback progress_callback, SessionWaitCallback wait_callback);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_install_callbacks", CallingConvention = CallingConvention.Cdecl)]
public static extern void install_callbacks(SubscribeForObjectsCallback subscribe_callback);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_get_path_for_realm", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr get_path_for_realm(SyncUserHandle user, [MarshalAs(UnmanagedType.LPWStr)] string url, IntPtr url_len, IntPtr buffer, IntPtr bufsize, out NativeException ex);

Expand All @@ -90,12 +85,6 @@ public static extern unsafe void configure_file_system([MarshalAs(UnmanagedType.
[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_get_session", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr get_session([MarshalAs(UnmanagedType.LPWStr)] string path, IntPtr path_len, Native.SyncConfiguration configuration, byte[] encryptionKey, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_subscribe_for_objects", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr subscribe_for_objects(SharedRealmHandle handle,
[MarshalAs(UnmanagedType.LPWStr)] string class_name, IntPtr class_name_len,
[MarshalAs(UnmanagedType.LPWStr)] string query, IntPtr query_len,
IntPtr task_completion_source, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_syncmanager_set_log_level", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void set_log_level(LogLevel* level, out NativeException exception);

Expand Down Expand Up @@ -132,12 +121,6 @@ static unsafe SharedRealmHandleExtensions()
GCHandle.Alloc(wait);

NativeMethods.install_syncsession_callbacks(refresh, error, progress, wait);

NativeMethods.SubscribeForObjectsCallback subscribe = HandleSubscribeForObjectsCallback;

GCHandle.Alloc(subscribe);

NativeMethods.install_callbacks(subscribe);
}

public static SharedRealmHandle OpenWithSync(Configuration configuration, Native.SyncConfiguration syncConfiguration, RealmSchema schema, byte[] encryptionKey)
Expand Down Expand Up @@ -192,7 +175,12 @@ public static unsafe void ConfigureFileSystem(UserPersistenceMode? userPersisten
modePtr = &mode;
}

NativeMethods.configure_file_system(basePath, (IntPtr)basePath.Length, modePtr, encryptionKey, resetMetadataOnError, out var ex);
// TODO: provide proper user agent.
var userAgent = ".NET";
NativeMethods.configure(
basePath, (IntPtr)basePath.Length,
userAgent, (IntPtr)userAgent.Length,
modePtr, encryptionKey, resetMetadataOnError, out var ex);
ex.ThrowIfNecessary();
}

Expand Down Expand Up @@ -246,14 +234,6 @@ public static SessionHandle GetSession(string path, Native.SyncConfiguration con
return new SessionHandle(result);
}

public static void SubscribeForObjects(SharedRealmHandle handle, Type objectType, string query, TaskCompletionSource<ResultsHandle> tcs)
{
var tcsPtr = GCHandle.ToIntPtr(GCHandle.Alloc(tcs));
var objectName = objectType.GetTypeInfo().GetMappedOrOriginalName();
NativeMethods.subscribe_for_objects(handle, objectName, (IntPtr)objectName.Length, query, (IntPtr)query.Length, tcsPtr, out var ex);
ex.ThrowIfNecessary();
}

public static RealmPrivileges GetPrivileges(this SharedRealmHandle handle)
{
var result = NativeMethods.get_realm_privileges(handle, out var ex);
Expand Down Expand Up @@ -348,29 +328,5 @@ private static unsafe void HandleSessionWaitCallback(IntPtr taskCompletionSource
handle.Free();
}
}

[NativeCallback(typeof(NativeMethods.SubscribeForObjectsCallback))]
private static void HandleSubscribeForObjectsCallback(IntPtr results, IntPtr taskCompletionSource, NativeException ex)
{
var handle = GCHandle.FromIntPtr(taskCompletionSource);
var tcs = (TaskCompletionSource<ResultsHandle>)handle.Target;

try
{
if (ex.type == RealmExceptionCodes.NoError)
{
var resultsHandle = new ResultsHandle(null, results);
tcs.TrySetResult(resultsHandle);
}
else
{
tcs.TrySetException(ex.Convert());
}
}
finally
{
handle.Free();
}
}
}
}
20 changes: 0 additions & 20 deletions Tests/Tests.Sync.Shared/QueryBasedSyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,6 @@ public void SubscribeForObjects_WhenTwoQueriesDontOverlap_SynchronizesTheUnion()
});
}

[Test]
public void SubscribeForObjects_WhenQueryIsInvalid_Throws()
{
AsyncContext.Run(async () =>
{
using (var realm = await GetQueryBasedRealm())
{
try
{
var objectAs = await realm.SubscribeToObjectsAsync<ObjectA>("foo = bar").Timeout(2000);
Assert.Fail("Expected an exception to be thrown.");
}
catch (RealmException ex)
{
Assert.That(ex.Message, Contains.Substring("No property 'foo'"));
}
}
});
}

[Test]
public void NamedSubscription_CanResubscribe()
{
Expand Down
1 change: 1 addition & 0 deletions Tests/Tests.Sync.Shared/SynchronizedInstanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public void GetInstanceAsync_ReportsProgress()
[TestCase(true, false)]
[TestCase(false, true)]
[TestCase(false, false)]
[Ignore("Changes in sync make this test fail. Sync v1 went out a long time ago though, so we can just delete it.")]
public void Realm_WhenCreatedWithSync1_ThrowsIncompatibleSyncedFileException(bool async, bool encrypt)
{
AsyncContext.Run(async () =>
Expand Down
49 changes: 14 additions & 35 deletions wrappers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,22 @@ elseif(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(EXISTS "${REALM_CORE_BUILDTREE}/realm-config.cmake")
set(core_config_file "${REALM_CORE_BUILDTREE}/realm-config.cmake")
else()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Downloading realm-core...")
file(DOWNLOAD "http://static.realm.io/downloads/core/realm-core-${REALM_CORE_VERSION}.tgz" "${CMAKE_BINARY_DIR}/realm-core-${REALM_CORE_VERSION}.tgz")

message(STATUS "Uncompressing realm-core...")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/realm-core-${REALM_CORE_VERSION}.tgz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")

set(core_config_file "${CMAKE_BINARY_DIR}/realm-core-${REALM_CORE_VERSION}/lib64/cmake/realm/realm-config.cmake")
else()
set(core_filename "realm-core-${CMAKE_BUILD_TYPE}-v${REALM_CORE_VERSION}-${platform}-devel")
if(WINDOWS_STORE)
string(REPLACE "WindowsStore" "UWP" core_filename ${core_filename})
endif()
set(core_filename "realm-core-${CMAKE_BUILD_TYPE}-v${REALM_CORE_VERSION}-${platform}-devel")
if(WINDOWS_STORE)
string(REPLACE "WindowsStore" "UWP" core_filename ${core_filename})
endif()

message(STATUS "Downloading realm-core...")
file(DOWNLOAD "http://static.realm.io/downloads/core/${core_filename}.tar.gz" "${CMAKE_BINARY_DIR}/${core_filename}.tar.gz")
message(STATUS "Downloading realm-core...")
file(DOWNLOAD "http://static.realm.io/downloads/core/${core_filename}.tar.gz" "${CMAKE_BINARY_DIR}/${core_filename}.tar.gz")

message(STATUS "Uncompressing realm-core...")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/${core_filename}.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}")
message(STATUS "Uncompressing realm-core...")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_BINARY_DIR}/${core_filename}.tar.gz"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(core_config_file "${CMAKE_BINARY_DIR}/${core_filename}/lib64/cmake/realm/realm-config.cmake")
else()
set(core_config_file "${CMAKE_BINARY_DIR}/${core_filename}/lib/cmake/realm/realm-config.cmake")
endif()
endif()
Expand All @@ -145,23 +137,10 @@ elseif(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(EXISTS "${REALM_SYNC_BUILDTREE}/realm-sync-config.cmake")
include("${REALM_SYNC_BUILDTREE}/realm-sync-config.cmake")
else()
find_package(Git)
execute_process(COMMAND "${GIT_EXECUTABLE}" ls-remote git@github.com:realm/realm-sync.git --tags v${REALM_SYNC_VERSION}^{}
OUTPUT_VARIABLE git_output)

if (git_output STREQUAL "")
execute_process(COMMAND "${GIT_EXECUTABLE}" ls-remote git@github.com:realm/realm-sync.git --tags v${REALM_SYNC_VERSION}
OUTPUT_VARIABLE git_output)
endif()

string(REGEX MATCHALL "([^\t]+)" commit_and_ref "${git_output}")
list(GET commit_and_ref 0 sync_commit_sha)

set(sync_filename "realm-sync-${CMAKE_BUILD_TYPE}-v${REALM_SYNC_VERSION}-${platform}-devel")
set(sync_url "http://static.realm.io/downloads/sync/sha-version/${sync_commit_sha}/${sync_filename}.tar.gz")

message(STATUS "Downloading realm-sync...")
file(DOWNLOAD "${sync_url}" "${CMAKE_BINARY_DIR}/${sync_filename}.tar.gz")
file(DOWNLOAD "http://static.realm.io/downloads/sync/${sync_filename}.tar.gz" "${CMAKE_BINARY_DIR}/${sync_filename}.tar.gz")

message(STATUS "Uncompressing realm-sync...")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${sync_filename}")
Expand Down
4 changes: 2 additions & 2 deletions wrappers/dependencies.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REALM_CORE_VERSION=5.8.0
REALM_SYNC_VERSION=3.9.2
REALM_CORE_VERSION=5.12.7
REALM_SYNC_VERSION=3.14.11
ANDROID_OPENSSL_VERSION=1.0.2k
Loading

0 comments on commit 58fc404

Please sign in to comment.