ArgumentNullException when unregistering reminder despite null check

88 views Asked by At

I am using Reminders in my Orleans application, and i have a JournaledGrain that does implement the IRemindable interface. At the end of the flow i make sure i use UnregisterAsync. The reminder gets registered with the grain's identity.The IReminder is not saved in the state but is retrieved by using the GetReminder method of the grain.

The problem: Even though i do a null check and then unregister the reminder i still get an ArgumentNullException when calling the UnregisterAsync method.

Grain

public PaymentGrain: JournaledGrain<Something, SomethingElse>,IRemindable,IGrainWithGuidKey
{
     public async Task Registering()
     {
             var reminder = await this.RegisterOrUpdateReminder(
                this.GetPrimaryKey().ToString(),
                TimeSpan.FromHours(3),
                TimeSpan.FromMinutes(10));
     }

    //the place where the reminder is unregistering...
    public async Task NotifyMerchant_PaymentNotificationSuccededAsync()
    {
         var reminder = await this.GetReminder(this.GetPrimaryKey().ToString());
         if (reminder != null) {           
          await this.UnregisterReminder(reminder); //this throws with argument null
         }                              //in the error the line 328 with thee error is here
    }
}

The Exception

>     warn: Orleans.Grain.InvokeException[100322]
>           Exception during Grain method call of message: OneWay S10.244.0.14:11111:390542859*grn/Notification.Grains.PaymentMerchantGrain/16528479710843@d70ef3b0->S10.244.0.14:11111:390542859*grn/Notification.Grains.PaymentGrain/16528479710843@df8bf09b
> InvokeMethodRequest
> Notification.Grains.IPaymentGrain:NotifyMerchant_PaymentNotificationSuccededAsync
> #1580601:
>           Exc level 0: System.ArgumentNullException: Value cannot be null. (Parameter 'reminder')
>              at Orleans.Grain.UnregisterReminder(IGrainReminder reminder) in /_/src/Orleans.Core.Abstractions/Core/Grain.cs:line 152
>              at Notification.Grains.PaymentGrain.NotifyMerchant_PaymentNotificationSuccededAsync(PaymentNotification_ToMerchant_SucceededMessage
> paymentSuccededDTO) in
> /src/Notification/Notification.Grains/Grain/Payment/Grains/PaymentGrain/PaymentGrain.cs:line
> 328
>              at Notification.Grains.OrleansCodeGenPaymentGrainMethodInvoker.Invoke(IAddressable
> grain, InvokeMethodRequest request) in
> /src/Notification/Notification.Grains/obj/Release/net6.0/Notification.Grains.orleans.g.cs:line
> 240 
>              at Orleans.Runtime.GrainMethodInvoker.Invoke() in /_/src/Orleans.Runtime/Core/GrainMethodInvoker.cs:line 104
>              at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target,
> IInvokable invokable, Message message) 
>     in /_/src/Orleans.Runtime/Core/InsideRuntimeClient.cs:line 469
>           System.ArgumentNullException: Value cannot be null. (Parameter 'reminder')
>              at Orleans.Grain.UnregisterReminder(IGrainReminder reminder) in /_/src/Orleans.Core.Abstractions/Core/Grain.cs:line 152
>              at Notification.Grains.PaymentGrain.NotifyMerchant_PaymentNotificationSuccededAsync(PaymentNotification_ToMerchant_SucceededMessage
> paymentSuccededDTO) in
> /src/Notification/Notification.Grains/Grain/Payment/Grains/PaymentGrain/PaymentGrain.cs:line
> 328
>              at Notification.Grains.OrleansCodeGenPaymentGrainMethodInvoker.Invoke(IAddressable
> grain, InvokeMethodRequest request) in
> /src/Notification/Notification.Grains/obj/Release/net6.0/Notification.Grains.orleans.g.cs:line
> 240 
>              at Orleans.Runtime.GrainMethodInvoker.Invoke() in /_/src/Orleans.Runtime/Core/GrainMethodInvoker.cs:line 104
>              at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target,
> IInvokable invokable, Message message) 
>     in /_/src/Orleans.Runtime/Core/InsideRuntimeClient.cs:line 469
>      04:26: 12[WRN] {EventId={Id=100322}, SourceContext="Orleans.Grain.InvokeException",
> ActionId="8fe38a88-4767-42ea-925c-31cdcf5338f4",
> ActionName="Notification.WebApi.PaymentController.PaymentNotificationAsync
> (Notification.WebApi)", RequestId="0HMHOGFQS74L4:00000266",
> RequestPath="/payment/", ConnectionId="0HMHOGFQS74L4",
> corellationId="fe11cbbe-d9f4-48a5-9760-1a962311f40e"} Exception during
> Grain method call of message: OneWay
> S10.244.0.14:11111:390542859*grn/Notification.Grains.PaymentMerchantGrain/16528479710843@d70ef3b0->S10.244.0.14:11111:390542859*grn/Notification.Grains.PaymentGrain/16528479710843@df8bf09b
> InvokeMethodRequest
> Notification.Grains.IPaymentGrain:NotifyMerchant_PaymentNotificationSuccededAsync
> #1580601:
>     Exc level 0: System.ArgumentNullException: Value cannot be null. (Parameter 'reminder')
>        at Orleans.Grain.UnregisterReminder(IGrainReminder reminder) in /_/src/Orleans.Core.Abstractions/Core/Grain.cs:line 152
>        at Notification.Grains.PaymentGrain.NotifyMerchant_PaymentNotificationSuccededAsync(PaymentNotification_ToMerchant_SucceededMessage
> paymentSuccededDTO) in
> /src/Notification/Notification.Grains/Grain/Payment/Grains/PaymentGrain/PaymentGrain.cs:line
> 328
>        at Notification.Grains.OrleansCodeGenPaymentGrainMethodInvoker.Invoke(IAddressable
> grain, InvokeMethodRequest request) in
> /src/Notification/Notification.Grains/obj/Release/net6.0/Notification.Grains.orleans.g.cs:line
> 240       
>        at Orleans.Runtime.GrainMethodInvoker.Invoke() in /_/src/Orleans.Runtime/Core/GrainMethodInvoker.cs:line 104    
>        at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message) in
> /_/src/Orleans.Runtime/Core/InsideRuntimeClient.cs:line 469
>     System.ArgumentNullException: Value cannot be null. (Parameter 'reminder')
>        at Orleans.Grain.UnregisterReminder(IGrainReminder reminder) in /_/src/Orleans.Core.Abstractions/Core/Grain.cs:line 152
>        at Notification.Grains.PaymentGrain.NotifyMerchant_PaymentNotificationSuccededAsync(PaymentNotification_ToMerchant_SucceededMessage
> paymentSuccededDTO) in
> /src/Notification/Notification.Grains/Grain/Payment/Grains/PaymentGrain/PaymentGrain.cs:line
> 328
>        at Notification.Grains.OrleansCodeGenPaymentGrainMethodInvoker.Invoke(IAddressable
> grain, InvokeMethodRequest request) in
> /src/Notification/Notification.Grains/obj/Release/net6.0/Notification.Grains.orleans.g.cs:line
> 240       
>        at Orleans.Runtime.GrainMethodInvoker.Invoke() in /_/src/Orleans.Runtime/Core/GrainMethodInvoker.cs:line 104    
>        at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message) in
> /_/src/Orleans.Runtime/Core/InsideRuntimeClient.cs:line 469
>      04:26: 12[INF] {corellationId="9edd7d8c-2770-4a13-b67f-57b52e91d6d0",
> ActionId="8fe38a88-4767-42ea-925c-31cdcf5338f4",
> ActionName="Notification.WebApi.PaymentController.PaymentNotificationAsync
> (Notification.WebApi)", RequestId="0HMHOGFQS74L2:00000279",
> RequestPath="/payment/", ConnectionId="0HMHOGFQS74L2"}
> ApplyUpdatesToStorage: etag 0 special-case write Initialized event
>      04:26: 12[WRN] {EventId={Id=100322}, SourceContext="Orleans.Grain.InvokeException",
> ActionId="8fe38a88-4767-42ea-925c-31cdcf5338f4",
> ActionName="Notification.WebApi.PaymentController.PaymentNotificationAsync
> (Notification.WebApi)", RequestId="0HMHOGFQS74L4:00000266",
> RequestPath="/payment/", ConnectionId="0HMHOGFQS74L4",
> corellationId="fe11cbbe-d9f4-48a5-9760-1a962311f40e"} Exception during
> Grain method call of message: OneWay
> S10.244.0.14:11111:390542859*grn/Notification.Grains.PaymentMerchantGrain/16528479710843@d70ef3b0->S10.244.0.14:11111:390542859*grn/Notification.Grains.PaymentGrain/16528479710843@df8bf09b
> InvokeMethodRequest
> Notification.Grains.IPaymentGrain:NotifyMerchant_PaymentNotificationSuccededAsync
> #1580601:
>     Exc level 0: System.ArgumentNullException: Value cannot be null. (Parameter 'reminder')
>        at Orleans.Grain.UnregisterReminder(IGrainReminder reminder) in /_/src/Orleans.Core.Abstractions/Core/Grain.cs:line 152
>        at Notification.Grains.PaymentGrain.NotifyMerchant_PaymentNotificationSuccededAsync(PaymentNotification_ToMerchant_SucceededMessage
> paymentSuccededDTO) in
> /src/Notification/Notification.Grains/Grain/Payment/Grains/PaymentGrain/PaymentGrain.cs:line
> 328
>        at Notification.Grains.OrleansCodeGenPaymentGrainMethodInvoker.Invoke(IAddressable
> grain, InvokeMethodRequest request) in
> /src/Notification/Notification.Grains/obj/Release/net6.0/Notification.Grains.orleans.g.cs:line
> 240       
>        at Orleans.Runtime.GrainMethodInvoker.Invoke() in /_/src/Orleans.Runtime/Core/GrainMethodInvoker.cs:line 104    
>        at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message) in
> /_/src/Orleans.Runtime/Core/InsideRuntimeClient.cs:line 469
>     System.ArgumentNullException: Value cannot be null. (Parameter 'reminder')
>        at Orleans.Grain.UnregisterReminder(IGrainReminder reminder) in /_/src/Orleans.Core.Abstractions/Core/Grain.cs:line 152
>        at Notification.Grains.PaymentGrain.NotifyMerchant_PaymentNotificationSuccededAsync(PaymentNotification_ToMerchant_SucceededMessage
> paymentSuccededDTO) in
> /src/Notification/Notification.Grains/Grain/Payment/Grains/PaymentGrain/PaymentGrain.cs:line
> 328
>        at Notification.Grains.OrleansCodeGenPaymentGrainMethodInvoker.Invoke(IAddressable
> grain, InvokeMethodRequest request) in
> /src/Notification/Notification.Grains/obj/Release/net6.0/Notification.Grains.orleans.g.cs:line
> 240       
>        at Orleans.Runtime.GrainMethodInvoker.Invoke() in /_/src/Orleans.Runtime/Core/GrainMethodInvoker.cs:line 104    
>        at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message) in
> /_/src/Orleans.Runtime/Core/InsideRuntimeClient.cs:line 469
>      04:26: 12[INF] {corellationId="c3beb36f-699f-4644-9468-2d1b7fec05fa",
> ActionId="8fe38a88-4767-42ea-925c-31cdcf5338f4",
> ActionName="Notification.WebApi.PaymentController.PaymentNotificationAsync
> (Notification.WebApi)", RequestId="0HMHOGFQS743R:00000033",
> RequestPath="/payment/", ConnectionId="0HMHOGFQS743R"}
> ApplyUpdatesToStorage: etag 0 special-case write Initialized event

UPDATE The problem appears only during heavy load on the application ! If i send a request the flow is ok i do not get the error. When i load test i get it. Can someone tell if there could be a problem with the reminder management or ?

0

There are 0 answers