Bugs caused by the spring transaction isolation level

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.