Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: setup connection info in session when audit plugin be enabled #10923

Merged
merged 3 commits into from
Jun 27, 2019
Merged

plugin: setup connection info in session when audit plugin be enabled #10923

merged 3 commits into from
Jun 27, 2019

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Jun 24, 2019

What problem does this PR solve?

audit plugin need using extra connection info for every log record, connInfo is static data for every session, but tidb instance without plugin doesn't need it.

What is changed and how it works?

  • add IsEnable method to plugin
  • setup connInfo when connection coming if audit is enable

Check List

Tests

  • Manual test
compile & load the plugin, plugin CI will be setup after this one be fixed

Code changes

  • impl changes

Side effects

  • n/a

Related changes

  • Need to cherry-pick to the release 3.0

This change is Reviewable

@lysu
Copy link
Contributor Author

lysu commented Jun 24, 2019

/run-all-tests

@codecov
Copy link

codecov bot commented Jun 24, 2019

Codecov Report

Merging #10923 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #10923   +/-   ##
===========================================
  Coverage   80.9115%   80.9115%           
===========================================
  Files           418        418           
  Lines         89384      89384           
===========================================
  Hits          72322      72322           
  Misses        11827      11827           
  Partials       5235       5235

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lysu lysu added status/all tests passed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 26, 2019
@@ -385,6 +385,9 @@ type SessionVars struct {

// Killed is a flag to indicate that this query is killed.
Killed uint32

// ConnectionInfo indicates current connection info used by current session, only be lazy assigned by plugin.
ConnectionInfo *ConnectionInfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about saving it to clientConn?
It's not used in sessionVars anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiancaiamao clientConn is not easy to obtain in the later process phase(e.g. write audit log after a query finished - - ), it will be used in audit plugin's OnGeneralEvent

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 27, 2019
@lysu lysu merged commit 98274cc into pingcap:master Jun 27, 2019
@lysu lysu deleted the dev-conn-info-audit branch June 27, 2019 03:29
ngaut pushed a commit that referenced this pull request Jul 15, 2019
#11189)

* plugin: add unit test for plugin (#10506)

* plugin: setup connection info in session when audit plugin be enabled (#10923)

*  plugin: support dynamic enable/disable plugins (#11122)

* update parser version & fix cp compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/plugin status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants