Description:
The documentation in https://dev.mysql.com/doc/refman/5.7/en/savepoint.html states that:
> Modifications that the current transaction made to rows after the savepoint was set are undone in the rollback, but InnoDB does not release the row locks that were stored in memory after the savepoint.
However, when I tried to rollback a modified row with "ROLLBACK TO", the modified row is not locked and can be modified directly.
How to repeat:
Assume that there are 2 transactions: left and right, I executed the following SQL commands:
# connect command
connect: mysql -ujohnlinp -psecret somedb
# create table and populate data
left: DROP TABLE IF EXISTS person;
left: CREATE TABLE person (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, age INT NOT NULL, PRIMARY KEY (id));
left: INSERT INTO person (name, age) VALUES ('John Lin', 29);
# start left transaction
left: BEGIN;
left: SAVEPOINT somepoint;
left: UPDATE person SET age = 30 WHERE id = 1;
left: ROLLBACK TO somepoint;
# start right transaction
right: BEGIN;
right: UPDATE person SET age = 40 WHERE id = 1;
I expected the last SQL command on the right should freeze until timeout, but it was successfully executed right away.
Note: the code block above can be executed by duosql: https://github.com/johnlinp/duosql
Suggested fix:
The documentation and the actual behavior seem not matched. However, I am not sure whether we should modify the documentation or the actual behavior. Please advice. Thanks.