Efcore: Profile EnableDetailedErrors

Created on 13 Mar 2020  路  9Comments  路  Source: dotnet/efcore

In tracking query statemanager would throw such exception. For non-tracking we just skip it and return null instead.

area-perf area-query punted-for-5.0 type-enhancement

All 9 comments

I investigated this. Tracking or not, we throw exception early while trying to read value.

Message: 
    System.Data.SqlTypes.SqlNullValueException : Data is Null. This method or property cannot be called on Null values.
  Stack Trace: 
    SqlBuffer.ThrowIfNull()
    SqlBuffer.get_String()
    SqlDataReader.GetString(Int32 i)
    lambda_method(Closure , DbDataReader , Int32[] )
    BufferedDataRecord.ReadObject(DbDataReader reader, Int32 ordinal, ReaderColumn column) line 1297
    BufferedDataRecord.ReadRow() line 897
    BufferedDataRecord.Initialize(DbDataReader reader, IReadOnlyList`1 columns) line 605
    BufferedDataReader.Initialize(IReadOnlyList`1 columns) line 117
    RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) line 423
    Enumerator.InitializeReader(DbContext _, Boolean result) line 236
    ExecutionStrategy.ExecuteImplementation[TState,TResult](Func`3 operation, Func`3 verifySucceeded, TState state) line 173
    ExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded) line 159
    Enumerator.MoveNext() line 185
    LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
    EnumerableHelpers.ToArray[T](IEnumerable`1 source)
    Enumerable.ToArray[TSource](IEnumerable`1 source)
    FromSqlQueryTestBase`1.Key_entity_with_null_key_value() line 987

We should wrap it in a better exception, at least indicating the column name

Notes from team triage: handle by bringing back EnableDetailedErrors. We should re-investigate the perf and determine whether to switch it on or off by default.

We had existing issue #15751 to bring this back. I am going to use that issue to bring it back. Re-purposed this to profile it to determine default.

Not sure how to vote for an issue, but I +1 this. It would be SUPER helpful to be able to identify which column is causing issues.

@michaelakin - That is already possible by using this API

This issue is about if the exception catching mechanism be default or opt-in by user.

@smitpatel I just tried that and there was no difference in the output of the exception. It still didn't give me the property name that has an issue.

@michaelakin - Then you may not be selecting a property. The exception can tell name of the property only when property is being projected out. Please file a new issue with detailed repro steps and exception details. This discussion deviates from the purpose of this specific issue.

Was this page helpful?
0 / 5 - 0 ratings