[MDEV-29565] Inconsistent read and write, which use the same predicate (WHERE clause) Created: 2022-09-18 Updated: 2022-09-22 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Update, Documentation, Locking, Storage Engine - InnoDB |
| Affects Version/s: | 10.3.36, 10.10.1, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Zuming Jiang | Assignee: | Ian Gilfillan |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | consistency | ||
| Environment: |
Ubuntu 20.04 |
||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
I used my fuzzing tool to test MariaDB and found a transaction-related bug that make the server produce different results. Mariadb installation Setup the environment Reproduce bug /usr/local/mysql/bin/mysql -uroot -Dtestdb # set up for the transaction T0 T0> SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; T1> START TRANSACTION;
T0> update t_rpjlsd set wkey = 63 where t_rpjlsd.c_pfd8ab <= (select min(wkey) from t_g6ckkb);
T0> select * from t_rpjlsd where wkey = 63;
T0> COMMIT; Analysis Based on the analysis, I think it might be a bug triggering inconsistent read (first SELECT in T0) and write (UPDATE in T0). |
| Comments |
| Comment by Daniel Black [ 2022-09-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
confirmed on 10.3.37-beffef9f0019d4519447339564d2cf18bebb8401 too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here is a simpler version of the test:
I looked up another reported read view anomaly MDEV-26642, but that scenario is different. Here, the subquery executed during the UPDATE will use a locking read, which is essentially a combination of READ UNCOMMITTED and a lock. The locking read was enabled by the SQL layer:
I am not sure what the correct fix should be. Like in MDEV-26642, a locking read has probably been used for the ‘read’ part since the beginning of MySQL, and some applications could break if this were changed. MDEV-24813 lists some other statements that should suffer from the same. These include INSERT…SELECT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-09-22 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is intentional and expected behavior. May be it's not sufficiently clear documented in KB, we need to correct that. MySQL manual, though, clearly says
This is an inherent part (or limitation?) of InnoDB design. |