Skip to content

Null Reference in GetServerTransactionLevel  #1121

Closed

Description

@ShaneCourtrille

I'm investigating an exception occurring when our system is under load and wanted to know if anyone has any idea what could cause the following? From reading the code it looks like the _innerConnection.Owner must be null but not sure what would cause that?

System.NullReferenceException:
   at Microsoft.Data.SqlClient.SqlInternalTransaction.GetServerTransactionLevel (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.SqlClient.SqlInternalTransaction.CheckTransactionLevelAndZombie (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.SqlClient.SqlInternalTransaction.Commit (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at Microsoft.Data.SqlClient.SqlTransaction.Commit (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
   at YesSql.Session.CommitTransaction (YesSql.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=51cdb8c1938e4789)
   at YesSql.Session+<CommitAsync>d__39.MoveNext (YesSql.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=51cdb8c1938e4789)

Activity

  1. sebastienros commented on Jun 16, 2021

    @sebastienros
    Member

    Could also show a race in the pooling logic since reports of this issue seem to relate to high load.

  2. Wraith2 commented on Jun 16, 2021

    @Wraith2
    Contributor

    use of WeakReference should be converted to WeakReference<T> if possible because the generic version has a usage pattern designed to avoid this sort of problem with time of check time of use dsparity.

  3. ShaneCourtrille commented on Jun 17, 2021

    @ShaneCourtrille
    Author

    The current code also loses the original exception which from our point of view is the most important one.

  4. ShaneCourtrille commented on Jun 17, 2021

    @ShaneCourtrille
    Author

    FYI the problem went away after we 1) increased the Min threads in ThreadPool 2) fixed Redis timeouts.. I'm not yet sure if 2) was causing the db transaction to timeout/fail which might be the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions