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

Forward SELECTs on LAST_INSERT_ID #1421

Closed
renecannao opened this issue Mar 18, 2018 · 2 comments
Closed

Forward SELECTs on LAST_INSERT_ID #1421

renecannao opened this issue Mar 18, 2018 · 2 comments

Comments

@renecannao
Copy link
Contributor

When an application executes SELECT LAST_INSERT_ID() , ProxySQL doesn't execute this query on any backend, but replies returning the value of last_insert_id sent in the OK packet
Although this is ok in many circumstances, this is not always correct.
Details, similarities and differences about the two are listed here

For this reason, ProxySQL should try to not send incorrect data when they do not match.
To return the correct value of LAST_INSERT_ID() and not last_insert_id, ProxySQL should execute the query on the same backend connection. This is possible only if multiplexing is disabled.

A possible workaround that should work on most of the use cases is:

  • track the the last HG where affected_rows is not 0
  • if the HG has already a connection attached (multiplexing is disabled) execute the query on the same connection
  • if the HG doesn't have a connection attached, fall back on old algorithm and return last_insert_id
@renecannao
Copy link
Contributor Author

Issue seems to be fixed in 1.4.8 .
It will probably need some change to be applied to 2.0

@renecannao
Copy link
Contributor Author

Applied to 2.0 too .
Closing

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

No branches or pull requests

1 participant