Skip to content

Commit d243ed8

Browse files
committed
Fix InvalidOperationException adding activity tags. Fixes #1074
If connecting with the preferred TLS version fails, the socket is closed and a new connection is established. Since the activity tags collection was reused, adding the new connection's details fails.
1 parent 68b30bb commit d243ed8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,8 @@ private void ShutdownSocket()
16531653
#else
16541654
Utility.Dispose(ref m_clientCertificate);
16551655
#endif
1656+
m_activityTags.Clear();
1657+
m_activityTags.Add(ActivitySourceHelper.DatabaseSystemTagName, ActivitySourceHelper.DatabaseSystemValue);
16561658
}
16571659

16581660
/// <summary>
@@ -1871,6 +1873,7 @@ protected override void OnStatementBegin(int index)
18711873
readonly object m_lock;
18721874
readonly object?[] m_logArguments;
18731875
readonly ArraySegmentHolder<byte> m_payloadCache;
1876+
readonly ActivityTagsCollection m_activityTags;
18741877
State m_state;
18751878
TcpClient? m_tcpClient;
18761879
Socket? m_socket;
@@ -1886,6 +1889,5 @@ protected override void OnStatementBegin(int index)
18861889
bool m_supportsSessionTrack;
18871890
CharacterSet m_characterSet;
18881891
PayloadData m_setNamesPayload;
1889-
ActivityTagsCollection m_activityTags;
18901892
Dictionary<string, PreparedStatements>? m_preparedStatements;
18911893
}

0 commit comments

Comments
 (0)