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

Support mysql prepare statement command #8084

Merged
merged 29 commits into from
Jan 15, 2019

Conversation

adriansr
Copy link
Contributor

This is a cleanup of #5663 (Support mysql prepare statement command by @ggg-geyi)

@adriansr adriansr added enhancement in progress Pull request is currently in progress. Packetbeat labels Aug 24, 2018
@ggg-geyi
Copy link

I have checked these commits. Thanks for your help.

@adriansr adriansr requested a review from cwurm August 27, 2018 10:27
Copy link
Contributor

@cwurm cwurm left a comment

Choose a reason for hiding this comment

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

I left some suggestions.

In general, I think we should try to remove most or all binary shifts from mysql.go. The binary package should have most functionality and we can add anything that's missing.

Since I don't know much about the MySQL wire protocol I think @andrewkroh or @urso should have a look as well.

packetbeat/protos/mysql/config.go Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Outdated Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Outdated Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Outdated Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Outdated Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Outdated Show resolved Hide resolved
packetbeat/protos/mysql/mysql.go Outdated Show resolved Hide resolved
@adriansr
Copy link
Contributor Author

@ggg-geyi I am currently working in some problems I found with the mysql parser (not caused by your code), I will fix them and then take care of the changes requested in this PR and merging it.

@ggg-geyi
Copy link

If it's possible I can do some help.

@andrewkroh
Copy link
Member

I believe this addresses both of these issues and they can be closed by this PR.

@andrewkroh andrewkroh closed this Sep 18, 2018
@andrewkroh andrewkroh reopened this Sep 18, 2018
@adriansr
Copy link
Contributor Author

@cwurm I addressed all your comments, do you mind to give it another look?

@adriansr adriansr added review and removed in progress Pull request is currently in progress. labels Dec 18, 2018
self.render_config_template(
mysql_ports=[3307]
)
self.run_packetbeat(pcap="mysql_prepare_statement.pcap",
Copy link
Member

Choose a reason for hiding this comment

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

👍

@adriansr adriansr requested review from a team as code owners January 8, 2019 16:25
@@ -140,6 +152,10 @@ type mysqlPlugin struct {
transactions *common.Cache
transactionTimeout time.Duration

// prepare statements cache
prepareStatements *common.Cache
prepareStatementTimeout time.Duration
Copy link

Choose a reason for hiding this comment

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

Prepared statements are accessed via address tuple. A mysql connection is allowed to only have this many prepared statements (applications requiring more or dynamic set of prepared statements tend to implement a Cache of active statements).

Why store the statements globally and time them out globally? I wonder if we want to move the statements to the TCP connection state.
Advantage is: if the connection is gone all known prepared statements are gone as well
Disadvantage: if connection is dropped (internal timeout or parse error after gaps), then we loose the current state.

Alternatively bind to connections + timeout only if connection is dropped/errored:

  • If TCP connection is properly closed we can can drop the state
  • If connection is dropped we put the connection it's statements on timeout
  • If new connection without TCP handshake is found we check if set of prepared statements is available for address pair and assign it to the current connection (stopping timeout).

@cwurm
Copy link
Contributor

cwurm commented Jan 11, 2019

@cwurm I addressed all your comments, do you mind to give it another look?

LGTM. Sorry I took so long to get to this.

See @urso's comment though - sounds like a good idea to me, but not sure if it's worth putting into this already very long running PR or if it should rather be handled as a follow-up. Anything is good with me.

@urso
Copy link

urso commented Jan 12, 2019

See @urso's comment though - sounds like a good idea to me, but not sure if it's worth putting into this already very long running PR or if it should rather be handled as a follow-up. Anything is good with me.

This might also need some improvements in signaling a plugin about connection state. +1 for changes/improvements to come later. Let's open an issue, though.

@adriansr
Copy link
Contributor Author

Thanks @urso I will follow up with a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants