假设我有一个这样的存储过程:
CREATE PROCEDURE incrementSomeNum()
BEGIN
START TRANSACTION; # Not sure if this line is necessary.
DECLARE a INT;
SELECT someValue INTO a FROM someTable WHERE id = 1;
UPDATE someTable SET someValue = a + 1 WHERE id = 1;
COMMIT; # And this
END;
现在在我的客户端,我有这样的代码,在线程中运行。
connection = connectionPool.getConnection()
connection.query("CALL incrementSomeNum();");
connection.close();
这对竞争条件安全吗?
(假设我正在使用MySQL,该表使用InnoDB引擎。)