-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Dapper 2.1.35
Dapper.Contrib 2.0.78
We have two pods running the same image in K8s that query a table and map to an object using Dapper. Both will work fine for a while, then one will start consistently getting this error. The object has the four properties show in the constructor in the error message and two properties with [Compute]. We are using select * in the query and are going to remove that and see if that helps.
System.InvalidOperationException: A parameterless default constructor or one matching signature (System.Int32 Id, System.String Name, System.Boolean IsActive, System.DateTime LastUsedDate) is required for Reputation.Core.Models.Schema.Tag materialization
File "/_/Dapper/SqlMapper.cs", line 3473, col 25, in void SqlMapper.GenerateDeserializerFromMap(Type type, DbDataReader reader, int startBound, int length, bool returnNullIfFirstMissing, ILGenerator il)
File "/_/Dapper/SqlMapper.cs", line 3304, col 17, in Func<DbDataReader, object> SqlMapper.GetTypeDeserializerImpl(Type type, DbDataReader reader, int startBound, int length, bool returnNullIfFirstMissing)
File "/_/Dapper/SqlMapper.TypeDeserializerCache.cs", line 151, col 17, in Func<DbDataReader, object> TypeDeserializerCache.GetReader(DbDataReader reader, int startBound, int length, bool returnNullIfFirstMissing)
File "/_/Dapper/SqlMapper.TypeDeserializerCache.cs", line 50, col 17, in Func<DbDataReader, object> TypeDeserializerCache.GetReader(Type type, DbDataReader reader, int startBound, int length, bool returnNullIfFirstMissing)
File "/_/Dapper/SqlMapper.cs", line 1941, col 17, in Func<DbDataReader, object> SqlMapper.GetDeserializer(Type type, DbDataReader reader, int startBound, int length, bool returnNullIfFirstMissing)
File "/_/Dapper/SqlMapper.Async.cs", line 442, col 21, in async Task<IEnumerable<T>> SqlMapper.QueryAsync<T>(IDbConnection cnn, Type effectiveType, CommandDefinition command)
File "/app/Reputation.Core/Repositories/LookupDataRepository.cs", line 28, col 9, in async Task<IEnumerable<Tag>> LookupDataRepository.GetTagsAsync(string clientId)
File "/app/Reputation.Core/Services/TagService.cs", line 29, col 9, in async Task<IEnumerable<Tag>> TagService.GetAllAsync()
File "Controllers/TagController.cs", line 37, col 13, in async Task<ActionResult<IEnumerable<LookupData>>> TagController.GetTags()+GetTagData(?)
File "Controllers/ReputationBaseController.cs", line 21, col 13, in async Task<ActionResult<T>> ReputationBaseController.DoActionAsync<T>(AsyncActionDelegate<T> asyncAction)
We have a constructor that maps the signature. To try to fix it, we added a default constructor and now it doesn't error out, but we get back n objects with default values.
The other pod running the same image continues to work and will return n objects with values from the db. Recycling the pod fixes it -- for a while.
It's as if the generated mapping worked, then got regenerated, but fails.
To Reproduce
I wish I could tell you more. Running locally it never happens. Only in prod (of course) in AKS. Non-prod AKS doesn't seem to have the problem.
Expected and actual behavior
The mapping to the object should not throw an exception and fill out the object
Additional context
Add any other context about the problem here:
- Azure SQL
- ASP.NET 8.0 base image
- AKS on node running Ubuntu 22.04.4 LTS