Description:
After returning 'MySQL Error (2000): Operation canceled' the add() can still succeed.
How to repeat:
SESSION 1:
mysql [localhost] {msandbox} (test) > lock tables t1 write;
Query OK, 0 rows affected (0.00 sec)
SESSION 2:
mysql-py> \use test
Schema `test` accessible through db.
mysql-py> db.t1.add({'foo': 'foobar'})
MySQL Error (2000): Operation canceled
(The error is returned after ~10s)
SESSION 1:
mysql [localhost] {msandbox} (test) > show processlist;
+----+----------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+----------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
| 47 | msandbox | localhost | test | Query | 0 | starting | show processlist |
| 48 | msandbox | localhost:60864 | test | Query | 14 | Waiting for table metadata lock | PLUGIN: INSERT INTO `test`.`t1` (doc) VALUES (JSON_OBJECT('_id','ca172de1506de611997fac87a3027d34',' |
+----+----------+-----------------+------+---------+------+---------------------------------+------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql [localhost] {msandbox} (test) > unlock tables;
Query OK, 0 rows affected (0.00 sec)
SESSION 3:
mysql-py> db.t1.find()
[
{
"_id": "1e9ceb4c4e6de6110e7eac87a3027d34",
"foo": "bar"
},
{
"_id": "54ca4c504e6de6110e7eac87a3027d34",
"foo2": "bar2"
},
{
"_id": "ca172de1506de611997fac87a3027d34",
"foo": "foobar"
}
]
3 documents in set (0.00 sec)
(Note that the {'foo': 'foobar'} was added...)
Suggested fix:
Cancel backend operations when returning an error.