Notifier.StartAsync fails with Realm Cloud

cloud

#1

I cannot get the RealmNotifier to work with our Realm Cloud. It fails on both linux and mac os x.

Running it locally on a Mac, I get a “dotnet quit unexpectedly” with the log below.

The code executing is the following:

void StartNotifier()
{
AsyncContext.Run(startNotifier);

        async Task startNotifier()
        { 
            try
            {
                var admin = await RealmHelper.UserLoginAsync(RealmCloudConfig.ADMINUSR, RealmCloudConfig.ADMINPASS);
                var config = new NotifierConfiguration(admin)
                {
                    // Add all handlers that this notifier will invoke
                    Handlers = { new CommonRealmHandler() }
                };
            
                _notifier = await Notifier.StartAsync(config); => this is where the crash happens
                
                _cancellationToken.Register(StopNotifier);
                
                Log.Information("** Realm notifier background service is started");
            }
            catch (Exception e)
            {
                Log.Error(e, $"Problem when starting notifier service");
            }
        }
    }

which is located in an ASP.NET Core IHostedService.

Please note that the ASP.NET server successfully uses FullSyncConfiguration and a local realm database. It assigns permissions and do a lot of other advanced stuff. No problems there.

But I cannot get the Notifier to work.

@nirinchev, do you have an idea why? Where to look? What to try?

----- Crash log —
Process: dotnet [6139]
Path: /usr/local/share/dotnet/dotnet
Identifier: dotnet
Version: 0
Code Type: X86-64 (Native)
Parent Process: vsdbg-ui [6138]
Responsible: dotnet [6139]
User ID: 501

Date/Time: 2019-01-03 11:47:14.036 +0100
OS Version: Mac OS X 10.14.2 (18C54)
Report Version: 12
Anonymous UUID: 4BE540DB-8A35-9E5F-EE38-C02A50F92CE1

Time Awake Since Boot: 10000 seconds

System Integrity Protection: enabled

Crashed Thread: 30

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [6139]



.

Thread 29:
0 libsystem_kernel.dylib 0x00007fff6ac9f1ce ftruncate + 10
1 librealm-wrappers.dylib 0x0000000108930bdc realm::util::File::prealloc(unsigned long) + 460
2 librealm-wrappers.dylib 0x0000000108832fc9 realm::SharedGroup::do_open(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, bool, bool, realm::SharedGroupOptions) + 3561
3 librealm-wrappers.dylib 0x0000000108951f37 realm::SharedGroup::open(realm::Replication&, realm::SharedGroupOptions) + 215
4 librealm-wrappers.dylib 0x0000000108951b20 realm::SharedGroup::SharedGroup(realm::Replication&, realm::SharedGroupOptions) + 1552
5 librealm-wrappers.dylib 0x00000001085c0e43 realm::realm::open_with_config(realm::realm::Config const&, std::__1::unique_ptr<realm::Replication, std::__1::default_deleterealm::Replication >&, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_deleterealm::SharedGroup >&, std::__1::unique_ptr<realm::Group, std::__1::default_deleterealm::Group >&, realm::Realm*) + 1043
6 librealm-wrappers.dylib 0x00000001085c0721 realm::realm::Realm(realm::realm::Config, std::__1::shared_ptrrealm::_impl::RealmCoordinator) + 321
7 librealm-wrappers.dylib 0x00000001085c83de realm::realm::make_shared_realm(realm::realm::Config, std::__1::shared_ptrrealm::_impl::RealmCoordinator)::make_shared_enabler::make_shared_enabler(realm::realm::Config, std::__1::shared_ptrrealm::_impl::RealmCoordinator) + 94
8 librealm-wrappers.dylib 0x00000001085c822f std::__1::shared_ptr<realm::realm::make_shared_realm(realm::realm::Config, std::__1::shared_ptrrealm::_impl::RealmCoordinator)::make_shared_enabler> std::__1::shared_ptr<realm::realm::make_shared_realm(realm::realm::Config, std::__1::shared_ptrrealm::_impl::RealmCoordinator)::make_shared_enabler>::make_shared<realm::realm::Config, std::__1::shared_ptrrealm::_impl::RealmCoordinator >(realm::realm::Config&&, std::__1::shared_ptrrealm::_impl::RealmCoordinator&&) + 159
9 librealm-wrappers.dylib 0x00000001085e2eda realm::_impl::RealmCoordinator::get_realm(realm::realm::Config) + 906
10 librealm-wrappers.dylib 0x00000001085c33a2 realm::realm::get_shared_realm(realm::realm::Config) + 114
11 librealm-wrappers.dylib 0x0000000108584228 shared_realm_open + 1320
12 ??? 0x000000010febe996 0 + 4562086294
13 ??? 0x000000010feb8af4 0 + 4562062068
14 ??? 0x000000010feb84c4 0 + 4562060484
15 ??? 0x000000010fea987e 0 + 4561999998
16 ??? 0x000000010fea86a2 0 + 4561995426
17 ??? 0x000000010ad6605b 0 + 4476788827
18 ??? 0x000000010fea6171 0 + 4561985905
19 ??? 0x000000010fea569a 0 + 4561983130
20 ??? 0x000000010ad6605b 0 + 4476788827
21 ??? 0x000000010fea535c 0 + 4561982300
22 ??? 0x000000010ad60070 0 + 4476764272
23 ??? 0x000000010acccfad 0 + 4476161965
24 ??? 0x000000010ad0f69c 0 + 4476434076
25 ??? 0x000000010ad0f456 0 + 4476433494
26 ??? 0x000000010fea3db9 0 + 4561976761
27 ??? 0x000000010fea24b4 0 + 4561970356
28 ??? 0x000000010fea1da0 0 + 4561968544
29 ??? 0x000000010acccfad 0 + 4476161965
30 ??? 0x000000010ad65991 0 + 4476787089
31 ??? 0x000000010ad6578e 0 + 4476786574
32 ??? 0x000000010ad96f2b 0 + 4476989227
33 libcoreclr.dylib 0x0000000104545187 CallDescrWorkerInternal + 124
34 libcoreclr.dylib 0x00000001043b194d MethodDescCallSite::CallTargetWorker(unsigned long const*, unsigned long*, int) + 909
35 libcoreclr.dylib 0x00000001043cd273 AppDomainTimerCallback_Worker(void*) + 179
36 libcoreclr.dylib 0x0000000104375e11 ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) + 385
37 libcoreclr.dylib 0x00000001043763e3 ManagedThreadBase::ThreadPool(ADID, void ()(void), void*) + 51
38 libcoreclr.dylib 0x00000001043cd37a AppDomainTimerCallback(void*, unsigned char) + 218
39 libcoreclr.dylib 0x00000001043991f0 ThreadpoolMgr::AsyncTimerCallbackCompletion(void*) + 160
40 libcoreclr.dylib 0x000000010436ac66 UnManagedPerAppDomainTPCount::DispatchWorkItem(bool*, bool*) + 422
41 libcoreclr.dylib 0x0000000104395975 ThreadpoolMgr::WorkerThreadStart(void*) + 1301
42 libcoreclr.dylib 0x00000001041f5638 CorUnix::CPalThread::ThreadEntry(void*) + 328
43 libsystem_pthread.dylib 0x00007fff6ad56305 _pthread_body + 126
44 libsystem_pthread.dylib 0x00007fff6ad5926f _pthread_start + 70
45 libsystem_pthread.dylib 0x00007fff6ad55415 thread_start + 13

Thread 30 Crashed:
0 libc++.1.dylib 0x00007fff68233777 std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::basic_string(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) + 27
1 librealm-wrappers.dylib 0x0000000108618661 std::__1::__tree_iterator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, void*>, long> std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > >::__emplace_hint_unique_key_args<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > const&>(std::__1::__tree_const_iterator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, void>, long>, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > const&&&) + 81
2 librealm-wrappers.dylib 0x00000001086183d2 realm::SyncConfig::SyncConfig(realm::SyncConfig const&) + 770
3 librealm-wrappers.dylib 0x0000000108616d30 realm::SyncManager::get_session(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, realm::SyncConfig const&) + 320
4 librealm-server-wrappers.dylib 0x000000010853a41a realm::AdminRealmListener::start(std::__1::function<void (std::__1::error_code)>, std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)>) + 74
5 librealm-server-wrappers.dylib 0x000000010853e7ef realm::GlobalNotifier::start(std::__1::function<void (std::__1::error_code)>) + 207
6 librealm-server-wrappers.dylib 0x000000010854419b realm_server_global_notifier_start + 59
7 ??? 0x000000011065b81d 0 + 4570069021
8 ??? 0x000000011065970f 0 + 4570060559
9 ??? 0x000000011065954b 0 + 4570060107
10 ??? 0x00000001106594c9 0 + 4570059977
11 ??? 0x000000010ad60070 0 + 4476764272
12 ??? 0x000000010acccfad 0 + 4476161965
13 ??? 0x000000010ad0f69c 0 + 4476434076
14 ??? 0x000000010ad0f456 0 + 4476433494
15 ??? 0x000000010fea3db9 0 + 4561976761
16 ??? 0x0000000110659260 0 + 4570059360
17 ??? 0x000000010acccfad 0 + 4476161965
18 ??? 0x000000010ad0f69c 0 + 4476434076
19 ??? 0x000000010acccfad 0 + 4476161965
20 libcoreclr.dylib 0x0000000104545187 CallDescrWorkerInternal + 124
21 libcoreclr.dylib 0x00000001043b194d MethodDescCallSite::CallTargetWorker(unsigned long const
, unsigned long*, int) + 909
22 libcoreclr.dylib 0x00000001043c555f ThreadNative::KickOffThread_Worker(void*) + 431
23 libcoreclr.dylib 0x0000000104375e11 ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) + 385
24 libcoreclr.dylib 0x00000001043763a3 ManagedThreadBase::KickOff(ADID, void ()(void), void*) + 51
25 libcoreclr.dylib 0x00000001043c5741 ThreadNative::KickOffThread(void*) + 289
26 libcoreclr.dylib 0x00000001041f5638 CorUnix::CPalThread::ThreadEntry(void*) + 328
27 libsystem_pthread.dylib 0x00007fff6ad56305 _pthread_body + 126
28 libsystem_pthread.dylib 0x00007fff6ad5926f _pthread_start + 70
29 libsystem_pthread.dylib 0x00007fff6ad55415 thread_start + 13

Thread 31:
0 libsystem_kernel.dylib 0x00007fff6aca2716 kevent + 10
1 librealm-wrappers.dylib 0x000000010896fb3b realm::util::network::Service::IoReactor::wait_and_activate(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) + 75
2 librealm-wrappers.dylib 0x0000000108970aee realm::util::network::Service::Impl::run() + 894
3 librealm-wrappers.dylib 0x000000010861bead void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_deleterealm::util::Logger >, realm::sync::Client::ReconnectMode, bool)::‘lambda’()> >(void*) + 45
4 libsystem_pthread.dylib 0x00007fff6ad56305 _pthread_body + 126
5 libsystem_pthread.dylib 0x00007fff6ad5926f _pthread_start + 70
6 libsystem_pthread.dylib 0x00007fff6ad55415 thread_start + 13

Thread 30 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007ffbec56a9f0 rcx: 0x0000000000000000 rdx: 0x0000000000000004
rdi: 0x00007ffbec56a9f0 rsi: 0x00676e696b636192 rbp: 0x000070000294ff60 rsp: 0x000070000294ff40
r8: 0x00000000bec56a9e r9: 0x00007ffbec500000 r10: 0x000000003fffffff r11: 0x00000000000006a8
r12: 0x00676e696b636192 r13: 0x00007ffbec56a9f0 r14: 0x0000700002950230 r15: 0x0000700002950238
rip: 0x00007fff68233777 rfl: 0x0000000000010246 cr2: 0x00007000029d3f78


(Nikola Irinchev) #2

What version of the Realm package are you using? The current server package does not support the 3.x versions, so you’ll need to rollback to a previous version if you have upgraded it.


#3

Aha, when will it be supported?


(Nikola Irinchev) #4

We’re working on it but can’t provide a timeframe at this time. If you have specific requirements (e.g. a product or a feature launch), please open a support ticket and our team will work with you on a solution.


(vogeler) #5

Hello,
is there any solution for this?
i´m also trying a server-notification handler with the cloud-instance - but .net and node-solutions in documentation are not working.

best regards

Volkhard


(Nikola Irinchev) #6

This has been resolved with the release of Realm.NET 4.0. All packages in the 4.x branch are compatible with Realm Cloud. Can you provide more information on the issue that you’re seeing?


(vogeler) #7

Hello,

thanks for the hint.
now when i try the .net example https://docs.realm.io/sync/backend-integration/data-change-events#creating-an-event-handler the program stops after NOtifier.StartAsync without a message …
do you have an idea?.

best regards

Volkhard


(Nikola Irinchev) #8

Do you have a minimum repro you can share that I can run locally and debug?


(vogeler) #9

I Think this independend from the realm. but i use this program:
class Program
{
static void Main(string[] args) => MainAsync(args[0]).Wait();

    private static async Task MainAsync(string regex)
    {
        Realms.Sync.User user = await Realms.Sync.User.LoginAsync(Realms.Sync.Credentials.UsernamePassword("XYZ", "XYZ", false), new Uri("https://XYZ"));
        var config = new NotifierConfiguration(user)
        {
            WorkingDirectory=Environment.CurrentDirectory,
            Handlers = { new ServerHandler(regex) }
            
        };
        using (INotifier notifier = await Notifier.StartAsync(config))
        {

            do
            {
                Console.WriteLine("type 'exit' to quit");
            }
            while (Console.ReadLine() != "exit");
        }
    }
}

internal class ServerHandler : RegexNotificationHandler
{
    public ServerHandler(string regex) : base(regex)
    {
        Console.WriteLine("ctor ServerHandler");
    }
    public async override Task HandleChangeAsync(IChangeDetails details)
    {
        Console.WriteLine( "Event");
    }

    public bool ShouldHandle(string path)
    {
        Console.WriteLine($"ShouldHandle {path}");
        return true;
    }
}