Skip to content

Commit

Permalink
plugin: fix audit plugin will cause tidb panic (#23803) (#23823)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Apr 19, 2021
1 parent e776461 commit 653b6ee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ func (s *Server) onConn(conn *clientConn) {
conn.Run(ctx)

err = plugin.ForeachPlugin(plugin.Audit, func(p *plugin.Plugin) error {
// Audit plugin may be disabled before a conn is created, leading no connectionInfo in sessionVars.
if sessionVars.ConnectionInfo == nil {
sessionVars.ConnectionInfo = conn.connectInfo()
}
authPlugin := plugin.DeclareAuditManifest(p.Manifest)
if authPlugin.OnConnectionEvent != nil {
sessionVars.ConnectionInfo.Duration = float64(time.Since(connectedTime)) / float64(time.Millisecond)
Expand Down

0 comments on commit 653b6ee

Please sign in to comment.