miningcore icon indicating copy to clipboard operation
miningcore copied to clipboard

topMinersRange - An unhandled exception was thrown by the application. System.InvalidOperationException: Nullable object must have a value.

Open blackmennewstyle opened this issue 3 years ago • 6 comments

I am facing this error with the dev-branch, it's probably normal since it is the dev-branch but because of it i have an API which does not work properly:

[2022-11-27 10:50:52.4166] [D] [DefaultViewCompiler] Initializing Razor view compiler with no compiled views. 
[2022-11-27 10:50:52.4606] [D] [Diagnostics] Loaded hosting startup assembly Miningcore 
[2022-11-27 10:50:53.4656] [D] [Connections] Connection id "0HMMGCL0N4RKP" accepted. 
[2022-11-27 10:50:53.4656] [D] [Connections] Connection id "0HMMGCL0N4RKP" started. 
[2022-11-27 10:50:53.4865] [I] [Diagnostics] Request starting HTTP/1.1 GET http://stratum.cedric-crispin.local:4000/api/pools/ccx1/ - - 
[2022-11-27 10:50:53.5378] [D] [TreeRouter] Request successfully matched the route with name '(null)' and template 'api/pools/{poolId}' 
[2022-11-27 10:50:53.5585] [D] [ParameterBinder] Attempting to bind parameter 'poolId' of type 'System.String' ... 
[2022-11-27 10:50:53.5606] [D] [SimpleTypeModelBinder] Attempting to bind parameter 'poolId' of type 'System.String' using the name 'poolId' in request data ... 
[2022-11-27 10:50:53.5606] [D] [SimpleTypeModelBinder] Done attempting to bind parameter 'poolId' of type 'System.String'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Done attempting to bind parameter 'poolId' of type 'System.String'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Attempting to validate the bound parameter 'poolId' of type 'System.String' ... 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Done attempting to validate the bound parameter 'poolId' of type 'System.String'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Attempting to bind parameter 'ct' of type 'System.Threading.CancellationToken' ... 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Done attempting to bind parameter 'ct' of type 'System.Threading.CancellationToken'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Attempting to validate the bound parameter 'ct' of type 'System.Threading.CancellationToken' ... 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Done attempting to validate the bound parameter 'ct' of type 'System.Threading.CancellationToken'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Attempting to bind parameter 'topMinersRange' of type 'System.UInt32' ... 
[2022-11-27 10:50:53.5606] [D] [SimpleTypeModelBinder] Attempting to bind parameter 'topMinersRange' of type 'System.UInt32' using the name '' in request data ... 
[2022-11-27 10:50:53.5606] [D] [SimpleTypeModelBinder] Could not find a value in the request with name '' for binding parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-27 10:50:53.5606] [D] [SimpleTypeModelBinder] Done attempting to bind parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Done attempting to bind parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Attempting to validate the bound parameter 'topMinersRange' of type 'System.UInt32' ... 
[2022-11-27 10:50:53.5606] [D] [ParameterBinder] Done attempting to validate the bound parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-27 10:50:53.6054] [E] [Kestrel] Connection id "0HMMGCL0N4RKP", Request id "0HMMGCL0N4RKP:00000002": An unhandled exception was thrown by the application. System.InvalidOperationException: Nullable object must have a value.
   at System.Nullable`1.get_Value()
   at Miningcore.Api.Controllers.PoolApiController.GetPoolInfoAsync(String poolId, CancellationToken ct, UInt32 topMinersRange) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Controllers/PoolApiController.cs:line 146
   at lambda_method1036(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Miningcore.Api.Middlewares.ApiRequestMetricsMiddleware.Invoke(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/ApiRequestMetricsMiddleware.cs:line 31
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
   at Miningcore.Api.Middlewares.IPAccessWhitelistMiddleware.Invoke(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/IPAccessWhitelistMiddleware.cs:line 40
   at Miningcore.Api.Middlewares.IPAccessWhitelistMiddleware.Invoke(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/IPAccessWhitelistMiddleware.cs:line 40
   at Miningcore.Api.Middlewares.ApiExceptionHandlingMiddleware.InvokeAsync(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/ApiExceptionHandlingMiddleware.cs:line 18
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in C:\Users\User\Documents\Github\AspNetCoreRateLimit\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 46
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)    at System.Nullable`1.get_Value()
   at Miningcore.Api.Controllers.PoolApiController.GetPoolInfoAsync(String poolId, CancellationToken ct, UInt32 topMinersRange) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Controllers/PoolApiController.cs:line 146
   at lambda_method1036(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Miningcore.Api.Middlewares.ApiRequestMetricsMiddleware.Invoke(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/ApiRequestMetricsMiddleware.cs:line 31
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
   at Miningcore.Api.Middlewares.IPAccessWhitelistMiddleware.Invoke(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/IPAccessWhitelistMiddleware.cs:line 40
   at Miningcore.Api.Middlewares.IPAccessWhitelistMiddleware.Invoke(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/IPAccessWhitelistMiddleware.cs:line 40
   at Miningcore.Api.Middlewares.ApiExceptionHandlingMiddleware.InvokeAsync(HttpContext context) in /home/ceedii/miningcore-dev/src/Miningcore/Api/Middlewares/ApiExceptionHandlingMiddleware.cs:line 18
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in C:\Users\User\Documents\Github\AspNetCoreRateLimit\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 46
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
[2022-11-27 10:50:53.6212] [D] [Sockets] Connection id "0HMMGCL0N4RKP" received FIN. 
[2022-11-27 10:50:53.6212] [D] [Sockets] Connection id "0HMMGCL0N4RKP" sending FIN because: "The client closed the connection." 
[2022-11-27 10:50:53.6212] [I] [Diagnostics] Request finished HTTP/1.1 GET http://stratum.cedric-crispin.local:4000/api/pools/ccx1/ - - - 500 0 - 137.1092ms 
[2022-11-27 10:50:53.6262] [D] [Connections] Connection id "0HMMGCL0N4RKP" disconnecting. 
[2022-11-27 10:50:53.6262] [D] [Connections] Connection id "0HMMGCL0N4RKP" stopped. 

blackmennewstyle avatar Nov 28 '22 05:11 blackmennewstyle

What happens with the master branch?

oliverw avatar Nov 28 '22 08:11 oliverw

What happens with the master branch?

On the master branch, it seems to go through without troubles despite some warnings:

2022-11-23 11:54:26.4550] [D] [TypeForwardingActivator] Forwarded activator type request from Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Culture=neutral, PublicKeyToken=adb9793829ddae60 
[2022-11-23 11:54:26.4550] [D] [ManagedAuthenticatedEncryptorFactory] Using managed symmetric algorithm 'System.Security.Cryptography.Aes'. 
[2022-11-23 11:54:26.4550] [D] [ManagedAuthenticatedEncryptorFactory] Using managed keyed hash algorithm 'System.Security.Cryptography.HMACSHA256'. 
[2022-11-23 11:54:26.4572] [D] [KeyRingProvider] Using key {262c3a11-f488-4a12-a041-99ab0fafc257} as the default key. 
[2022-11-23 11:54:26.4572] [D] [DataProtectionHostedService] Key ring with default key {262c3a11-f488-4a12-a041-99ab0fafc257} was loaded during application startup. 
[2022-11-23 11:54:26.4851] [D] [ModelBinderFactory] Registered model binder providers, in the following order: Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.HeaderModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FloatingPointTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.EnumTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DateTimeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CancellationTokenModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormFileModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.KeyValuePairModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DictionaryModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ArrayModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CollectionModelBinderProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexObjectModelBinderProvider 
[2022-11-23 11:54:26.4924] [D] [DefaultViewCompiler] Initializing Razor view compiler with no compiled views. 
[2022-11-23 11:54:26.5335] [D] [Diagnostics] Loaded hosting startup assembly Miningcore 
[2022-11-23 11:54:54.9517] [D] [Connections] Connection id "0HMMD964NVAD6" accepted. 
[2022-11-23 11:54:54.9517] [D] [Connections] Connection id "0HMMD964NVAD6" started. 
[2022-11-23 11:54:54.9741] [I] [Diagnostics] Request starting HTTP/1.1 GET http://stratum.cedric-crispin.local:4000/api/pools/ccx1/ - - 
[2022-11-23 11:54:55.0275] [D] [TreeRouter] Request successfully matched the route with name '(null)' and template 'api/pools/{poolId}' 
[2022-11-23 11:54:55.0562] [D] [ParameterBinder] Attempting to bind parameter 'poolId' of type 'System.String' ... 
[2022-11-23 11:54:55.0584] [D] [SimpleTypeModelBinder] Attempting to bind parameter 'poolId' of type 'System.String' using the name 'poolId' in request data ... 
[2022-11-23 11:54:55.0584] [D] [SimpleTypeModelBinder] Done attempting to bind parameter 'poolId' of type 'System.String'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Done attempting to bind parameter 'poolId' of type 'System.String'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Attempting to validate the bound parameter 'poolId' of type 'System.String' ... 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Done attempting to validate the bound parameter 'poolId' of type 'System.String'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Attempting to bind parameter 'ct' of type 'System.Threading.CancellationToken' ... 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Done attempting to bind parameter 'ct' of type 'System.Threading.CancellationToken'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Attempting to validate the bound parameter 'ct' of type 'System.Threading.CancellationToken' ... 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Done attempting to validate the bound parameter 'ct' of type 'System.Threading.CancellationToken'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Attempting to bind parameter 'topMinersRange' of type 'System.UInt32' ... 
[2022-11-23 11:54:55.0584] [D] [SimpleTypeModelBinder] Attempting to bind parameter 'topMinersRange' of type 'System.UInt32' using the name '' in request data ... 
[2022-11-23 11:54:55.0584] [D] [SimpleTypeModelBinder] Could not find a value in the request with name '' for binding parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-23 11:54:55.0584] [D] [SimpleTypeModelBinder] Done attempting to bind parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Done attempting to bind parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Attempting to validate the bound parameter 'topMinersRange' of type 'System.UInt32' ... 
[2022-11-23 11:54:55.0584] [D] [ParameterBinder] Done attempting to validate the bound parameter 'topMinersRange' of type 'System.UInt32'. 
[2022-11-23 11:54:55.1180] [D] [ResponseCompressionProvider] No matching response compression provider found. 
[2022-11-23 11:54:55.1267] [D] [Sockets] Connection id "0HMMD964NVAD6" received FIN. 
[2022-11-23 11:54:55.1267] [D] [Sockets] Connection id "0HMMD964NVAD6" sending FIN because: "The client closed the connection." 

blackmennewstyle avatar Nov 28 '22 13:11 blackmennewstyle

you have an entry in postgress that somehow glitched or corrupted. make a backup of your shares data in postgres, flush the database, restore share data then start pool. should be good after that. i never could find exactly what value in the database was causing the issue or how it got there so that's why i deleted everything in it then restored the share data so miners would still get accurate payouts on the next block

minershaven avatar Dec 04 '22 00:12 minershaven

you have an entry in postgress that somehow glitched or corrupted. make a backup of your shares data in postgres, flush the database, restore share data then start pool. should be good after that. i never could find exactly what value in the database was causing the issue or how it got there so that's why i deleted everything in it then restored the share data so miners would still get accurate payouts on the next block

I saw your message on Discord. I did not meet that critical error on production (yet) but mostly on my local testing environment, it would make sense indeed that i corrupted my database since i am doing a lot of integration/debugging without really flushing the data.

Thanks for the inputs :)

blackmennewstyle avatar Dec 04 '22 08:12 blackmennewstyle

please see my comment in #1530

jon4hz avatar Dec 05 '22 02:12 jon4hz

Could you try the dev branch?

oliverw avatar Dec 05 '22 10:12 oliverw