The thing is, iOS purchase list has a quantity plus one hand, reduce the function of the first hand, every addition and subtraction will asynchronously call the background interface, the background to determine if the SKU does not exist on the insertion, the existence of the update. Problem Description: When the iOS made multiple requests, at the time of the second request, the first request to insert the SKU program can not be found, but the database to find out later carefully studied, found that this is the so-called non-repeatable reading situation. Transaction-related modules in the Applicationcontext.xml configuration file commission The transaction isolation level to serializable. <!--purchase order plus minus one hand method there is a non-repeatable read situation, raising the transaction isolation level-<tx:method name= "changeshoppingcartskulist" propagation= "REQUIRED" isolation= "SERIALIZABLE" rollback-for= "Exception"/>
Here's the problem: Args: skuids[]=122890,122891,122892,122893,122894 timeid=4152 orderid=2733 num=1 sign=c30fc44b4a7681fbc19bd9c8c2de2237 authtime=2016-09-10 16:18:17 authid= 900000000000140exception:org.springframework.dao.deadlockloserdataaccessexception: ### error querying database. cause: com.mysql.jdbc.exceptions.jdbc4.mysqltransactionrollbackexception: deadlock found when Trying to get lock; try restarting transaction### the error may exist in com/itonghui/biz/shoppingcart/dao/mapper/OrderListSkuMapper.xml### The error may involve defaultparametermap### the error occurred while Setting parameters### sql: select * from order_list_sku t where t.sku_id = ? and order_id = ?### cause: com.mysql.jdbc.eXceptions.jdbc4.mysqltransactionrollbackexception: deadlock found when trying to get lock; try restarting transaction; sql []; deadlock found when trying to get lock; try restarting transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.mysqltransactionrollbackexception: deadlock found when trying to get lock; try restarting transaction at org.springframework.jdbc.support.sqlerrorcodesqlexceptiontranslator.dotranslate ( sqlerrorcodesqlexceptiontranslator.java:263) deadlock occurs, and the method is preceded by synchronized synchronization to resolve the problem. summarize, about asynchronous call non-repeatable READ problem Resolution: 1. Transaction-related modules in the Applicationcontext.xml configuration file commission The transaction isolation level to serializable. 2. Add synchronized synchronization to the front of the method
Bugs caused by the spring transaction isolation level