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

*: Audit plugin should handle errors and stmt start #27269

Merged
merged 15 commits into from
Aug 20, 2021

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Aug 16, 2021

What problem does this PR solve?

Issue Number: close #27268

Problem Summary:

The plugin API looks like it was intended to have multiple GeneralEvent types, but currently only the Log type is used. Log itself is ambiguous because it doesn't say if this means the event is complete, or is about to start. I thought it would be OK to rename, since it is already going to break the existing audit plugin by the next change, which is that the OnGeneralEvent will be called both before and after the statement executes. It will also be called on statement (dispatch) error.

What is changed and how it works?

What's Changed:

The audit plugin API can now log before statements start execution or result in errors.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility (API compatibility)

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

The audit plugin API can now log before statements start execution or result in errors.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 16, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lysu
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 16, 2021
@sre-bot
Copy link
Contributor

sre-bot commented Aug 16, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

@morgo morgo changed the title Plugin api example *: Audit plugin should handle errors and stmt start Aug 16, 2021
@morgo morgo requested a review from a team August 16, 2021 20:42
@morgo morgo added the sig/sql-infra SIG: SQL Infra label Aug 16, 2021
@morgo
Copy link
Contributor Author

morgo commented Aug 16, 2021

/run-check_title

@github-actions github-actions bot added the sig/execution SIG execution label Aug 16, 2021
Copy link
Contributor

@gregwebs gregwebs left a comment

Choose a reason for hiding this comment

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

It's almost always better to make a change backwards compatible. Doubly so for plugins. I think in this case a newer version of a plugin can either implement OnGeneralEvent2 or register as a v2 plugin.
For older plugins I think an adapter can be implemented to downgrade the new version to the previous version.

plugin/audit.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 18, 2021
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 18, 2021
@morgo morgo requested a review from djshow832 August 18, 2021 14:29
@morgo
Copy link
Contributor Author

morgo commented Aug 18, 2021

@djshow832 This has the Starting event after parse, but in #27268 you commented that it should be before parse. I don't have strong opinions, but in case you do.. I've added you as a reviewer.

@xiongjiwei
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 28a33e2

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 19, 2021
@ti-chi-bot
Copy link
Member

@morgo: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit 5f674e2 into pingcap:master Aug 20, 2021
@morgo morgo deleted the plugin-api-example branch August 24, 2021 16:39
bb7133 added a commit to bb7133/tidb that referenced this pull request Apr 20, 2022
ti-chi-bot pushed a commit that referenced this pull request Apr 21, 2022
bb7133 added a commit to bb7133/tidb that referenced this pull request May 13, 2022
ti-chi-bot pushed a commit that referenced this pull request May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit Plugin API enhancements
7 participants