Hello everyone
How can I enable tracing on .Net 8 webapi application that uses IBM.EntityFrameworkCore nuget, webapi fails intermittently with following error; i.e. 500 requests with 10-15 fails. I need to understand what is causing below error, on DB2 side there is no noise(i.e. error, warning etc), all calls are logged and can be traced through.
Exception message:
len ('-940671020') must be a non-negative value. (Parameter 'len') Actual value was -940671020.
The numeric value changes.
Sacktrace:
at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr, Int32 len)
at IBM.Data.Db2.DB2Parameter.MarshalToManaged(DB2ParamInfo& paramInfo)
at IBM.Data.Db2.DB2ParameterCollection.GetOutputValues()
at IBM.Data.Db2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method, DB2CursorType reqCursorType, Boolean abortOnOptValueChg, Boolean skipDeleted, Boolean isResultSet, Int32 maxRows, Boolean skipInitialValidation)
at IBM.Data.Db2.DB2Command.ExecuteReader()
Solution Setup:
- Webapi is recently upgraded to .Net 8 and uses following nuget packages, legacy webapi was using .Net Framework 4.6.1 (with appropriate Db2 drivers) and never had any issue, have been running for atleast 4 years.
- Webapi (legacy and new) has a dataaccess layer that calls a stored proc in DB2, stored proc has not been changed for at least 4 years, stored proc has handful of the parameters, some are input, some are output and some are both inputoutput type.
- Legacy Webapi used Autofac for dependencyInjection with InstancePerRequest, .Net 8 uses MS Extenstions for DependencyInjection with AddScoped.
DB2 Connectivity and license:
There are no issues with DB2 connectivity, as most of the calls works and some don't. I have also verified using "db2cli validate" commands to make sure there are no license issues.
db2cli validate -database "123:XXXX:12354" -connect -user BOB -passwd ****** -displaylic
Code Setup:
- Create Db2Connection (con) using constring
- Create DB2Command (db2Cmd)
- db2Cmd.Connection = con
- db2Cmd.CommandType=CommandType.StoredProcedure
- db2Cmd.CommandText="storedprocedure name"
- Add Parameters to the db2Cmd.Parameters collection.
- Open connection (if not opened)
- Call ExecuteReader (have tried db2Cmd.ExecuteRow() with same error)
- var dataReader = db2Cmd.ExecuteReader(); <- this is where the error is
Nuget Packages:
Microsoft.EntityFrameworkCore 8.0.0.8
IBM.EntityFrameworkCore 8.0.0.300
Net.IBM.Data.Db2 8.0.0.300
Trace command:
db2trc cfcli on
db2trc cfcli on -l 8m -i 8m
Error: "Trace could not allocate the necessary IPC resources. Please retry
using a smaller buffer size."
Any and all help is appreciated.
Regards
KA