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

Don't abort connection in mysql after encoding error #535

Merged
merged 5 commits into from
May 11, 2022

Conversation

G1gg1L3s
Copy link
Contributor

@G1gg1L3s G1gg1L3s commented May 10, 2022

This PR implements flushing of db-packets till the end of response after the encoding error. This is done to clear the connection so it can be reused for other queries (like rollback for example).

This also adds a couple of tests that show the correctness of the execution. I also wanted to add test with query which produces mysql error after a couple of data packets, so we can check that acra throws "encoding error" earlier and eats the mysql one. But I just couldn't craft such query ._.
Mysql returns null in almost every error case (division by zero, unable to allocate REPEAT('A', 1TB), etc). In cases where I could trigger a runtime error it is not possible to use acra, because query is complex. Maybe you can come up with an idea?

Checklist

why waste time say lot word when few word do trick
Right now it just replaces the `firstPacket` variable with a
separate state. But in the future it can be extended to support other
states to model a state machine if needed.
[skip ci]
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

lgtm

and eats the mysql one.

i don't understand for what and what it explain or verify?

@G1gg1L3s
Copy link
Contributor Author

lgtm

and eats the mysql one.

i don't understand for what and what it explain or verify?

I tested the normal workflow. like this:

     +----+ +----+ +----+ +----+
  db |row1| |row2| |row3| | ok |
     +----+ +----+ +----+ +----+

     +----+ +----+ +----+
acra |row1| |row2| |err |
     +----+ +----+ +----+

Where Encoding error happens on the third data packet, so other packets are discarded by acra.

But I also wanted to test this workflow:

     +----+ +----+ +----+ +--------+
  db |row1| |row2| |row3| |mysqlerr|
     +----+ +----+ +----+ +--------+

     +----+ +----+ +-------+
acra |row1| |row2| |acraerr|
     +----+ +----+ +-------+

Where encoding error happens before some mysql one. In that case, the mysql error is also discarded by acra.
But this scenario is really hard to simulate ._.

@G1gg1L3s G1gg1L3s merged commit 30d12e4 into master May 11, 2022
@G1gg1L3s G1gg1L3s deleted the G1gg1L3s/T2561-mysql-do-not-abort-connection branch May 11, 2022 11:32
@Lagovas
Copy link
Collaborator

Lagovas commented May 11, 2022

Where encoding error happens before some mysql one. In that case, the mysql error is also discarded by acra.
But this scenario is really hard to simulate ._.

yes. I think it should be some transaction that fails on commit. and there is should be Parse("BEGIN") + Execute + Parse("insert ...") + Execute + Parse("COMMIT") in same TCP packet. Then database probably will return responses one by one or it will fail on their side and return only error )))

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

Successfully merging this pull request may close these issues.

None yet

2 participants