我正在使用连接进行交易。每当第二个连接立即尝试更新刚刚插入的行时,都不会找到这些行。即使事务是在发出UPDATE之前提交的。
我有描述情况的mysql查询日志。
最后一条语句失败,受影响的行数为0(UPDATE refresh_token...
):
2018-08-03T13:31:24.829038Z 1150 Query START TRANSACTION
2018-08-03T13:31:24.830026Z 1150 Prepare INSERT INTO account (<redacted>) VALUES (<redacted>)
2018-08-03T13:31:24.830493Z 1150 Execute INSERT INTO account (<redacted>) VALUES (<redacted>)
2018-08-03T13:31:24.831345Z 1150 Close stmt
2018-08-03T13:31:24.833228Z 1150 Prepare INSERT INTO refresh_token (<redacted>) VALUES (<redacted>)
2018-08-03T13:31:24.833666Z 1150 Execute INSERT INTO refresh_token (<redacted>) VALUES (<redacted>)
2018-08-03T13:31:24.834356Z 1150 Close stmt
2018-08-03T13:31:24.834477Z 1150 Prepare INSERT INTO another (<redacted>) VALUES (<redacted>)
2018-08-03T13:31:24.835155Z 1150 Execute INSERT INTO another (<redacted>) VALUES (<redacted>)
2018-08-03T13:31:24.835621Z 1150 Close stmt
2018-08-03T13:31:24.835747Z 1150 Query COMMIT
2018-08-03T13:31:24.840374Z 1150 Prepare UPDATE refresh_token SET accessed = ? WHERE token = ?
2018-08-03T13:31:24.840799Z 1150 Execute UPDATE refresh_token SET accessed = '<redacted>' WHERE token = '<redacted>'
2018-08-03T13:31:24.843346Z 1150 Close stmt
如果我在发出UPDATE refresh_token SET...
之前等待500毫秒,则会找到记录。
这是事务隔离级别:
SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
'REPEATABLE-READ', 'REPEATABLE-READ'
答案 0 :(得分:0)
OK确定DATETIME
列的粒度以秒为单位。因此,使用NOW()
进行插入和更新会使记录看起来完全一样,因此mysql报告0 rows updated
。