乐观锁

推荐文章:http://tiro-li.iteye.com/blog/1908379

可以在数据库中模拟整个过程

SELECT @@tx_isolation;

SET SESSION TRANSACTION ISOLATION LEVEL  SERIALIZABLE; 

start transaction;  
select * from `serializable`;

update `serializable` set maxid = '1603196' where  tablename = '_order';
-- update `serializable` set maxid = '1603196', version = 8 where  tablename = '_order' and version < 8;

COMMIT;

模拟方式是:新建2个事务,分别顺序执行到COMMIT之前,看数据更新情况
重点是理解,乐观锁的version字段起到的作用

关于innodb事务机制 http://xin3336019-sina-com.iteye.com/admin/blogs/2009103

猜你喜欢

转载自xin3336019-sina-com.iteye.com/blog/2000247