Skip to content

State Report Trace doesn't match the format string #939

Description

@lbargery

Describe the bug

I've been debugging an issue with MARs recently where despite MARs being set to false, the connections still seem to run with _pMarsPhysicalConObj. To try and get further information on this, I turned on verbose logging with a SQL listener and discovered your format string and output are mismatched.

Inside the method TraceString inside TdsParser.cs you have an extra "" for the log which throws things off and you see as the output I get

 _physicalStateObj = False
	         _pMarsPhysicalConObj = True
	         _state = OpenLoggedIn
	         _server = tcp:HIDDEN.database.windows.net,1433
	         _fResetConnection = False
	         _defaultCollation = (LCID=1033, Opts=25)
	         _defaultCodePage = 1252
	         _defaultLCID = 1033
	         _defaultEncoding = System.Text.SBCSCodePageEncoding
	         _encryptionOption = 
	         _currentTransaction = ON
	         _pendingTransaction = (null)
	         _retainedTransactionId = (null)
	         _nonTransactedOpenResultCount = 0
	         _connHandler = 0
	         _fMARS = 75
	         _sessionPool = False
	         _isYukon = (null)
	         _sniSpnBuffer = True
	         _errors = (null)
	         _warnings = (null)
	         _attentionErrors = (null)
	         _attentionWarnings = (null)
	         _statistics = (null)
	         _statisticsIsInTransaction = True
	         _fPreserveTransaction = False         _fParallel = False"

As you can see, _fMars is coming out as 75 and isYukon as (null). I believe they are all shifted by one.

To reproduce

Not needed really - bug is clear I hope!

Expected behavior

Log should print correctly

Further technical details

Microsoft.Data.SqlClient version: 2.1.1
.NET core: 3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions