[MXS-2583] Make optimistic_trx=true work for SELECTs after set autocommit=0 Created: 2019-07-01 Updated: 2019-10-18 Resolved: 2019-10-16 |
|
| Status: | Closed |
| Project: | MariaDB MaxScale |
| Component/s: | readwritesplit |
| Affects Version/s: | 2.3 |
| Fix Version/s: | 2.5.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Valerii Kravchuk | Assignee: | markus makela |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Epic Link: | Router Improvements |
| Sprint: | MXS-SPRINT-92 |
| Description |
|
It seems optimistic_trx works only for transactions explicitly started with BEGIN ... or START TRANSACTION. It would be great to add read scaling support for sets of SELECTs executed after set autocommit=0; |
| Comments |
| Comment by markus makela [ 2019-07-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Took a quick look at the code and evaluated what needs to be done for this to work. The information about implicit transactions must be retained so that the next statement after a SET autocommit=0 or COMMIT is treated as the first statement of a new transaction. Since the first statement after the implicit transaction starts can be a write, the transaction should only be attempted on a slave if this statements is a read-only one. Here's a crude patch that seems to work based on the few minutes of testing I did:
I think it would be better to store the implicit transaction start inside the query classifier which means minor adjustments are still needed. |