-- 通过事务复现Mysql数据库重复提交的问题:
-- (1)设置不自动提交事务
SET autocommit = 0
-- (2)锁表
begin;
select * from platf_user_bankcards for update;
-- (3)新开一个sql的tab,验证是否锁表
update platf_user_bankcards set remarks = '2' where _id = 3647;
-- (4)在terminal执行curl语句,且执行两次
curl -H 'authorization: Bearer:eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIwODE4OTEwNDMwMDMxIiwiZXhwIjoxNjc3NzM3ODcxfQ.EbS2IvUlVZVgQnBA9bDfaDaolM_VXi1eyY3a_c2FvGU-N5-v0mPFasJ_rS8ujvbX2gKjxKp9TVWyldfUC-CRNA' -H 'param-userId: 244131ce339b4adebf641fb41b4ff626' -H 'version: 2.4.0' -H 'User-Agent: Mozilla/5.0 (Linux; Android 12; TAS-AN00 Build/HUAWEITAS-AN00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.105 Mobile Safari/537.36' -H 'Host: XX.XX.XX.XX:8088' --data "bankCode=BNINIDJA&bankcardNum=199207250931&bankName=BNI" --compressed 'http://XX.XX.XX.XX:8088/v1/app/platfUserBankcards/add'
-- (5)提交事务
COMMIT
-- (6)去数据库中查看两条事务是否提交成功,如都成功的话说明数据可重复提交,问题复现