博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql中的事务和锁_MySQL - 事务和锁中的互斥?
阅读量:5899 次
发布时间:2019-06-19

本文共 1584 字,大约阅读时间需要 5 分钟。

bd96500e110b49cbb3cd949968f18be7.png

I am currently learning about MySQL's transaction and lock features.

Are transactions with the isolation-level SERIALIZABLE and statements between a LOCK and UNLOCK statement on the same table executed mutually exclusive?

EDIT 1: For the transaction thing with isolation level SERIALIZABLE, is it even possible to determine whether the transaction is actually mutually exclusive or just the requirements like no phantom reads are fulfilled? Or do these two properties imply the same behavior?

EDIT 2: Oh, and are the mechanisms that provide the given isolation-level of a transaction only active if two or more transactions actually work on the same data so that the read phenomena could actually happen?

解决方案

In InnoDB, all SERIALIZABLE does is turn a SELECT into an implicit SELECT...LOCK IN SHARE MODE. So this only affects INSERT/UPDATE/DELETE against the same row(s).

You can observe the locks in SHOW ENGINE INNODB STATUS:

---TRANSACTION 14594, ACTIVE 5 sec

2 lock struct(s), heap size 360, 8 row lock(s)

MySQL thread id 24, OS thread handle 0x7f65c8624700, query id 324 192.168.56.1 root cleaning up

TABLE LOCK table `imdb`.`kind_type` trx id 14594 lock mode IS

RECORD LOCKS space id 24 page no 4 n bits 80 index `kind` of table `imdb`.`kind_type` trx id 14594 lock mode S

All I did was SELECT * FROM imdb.kind_type after setting tx_isolation=SERIALIZABLE and autcommit=0.

You see that it holds an IS table lock, which will block a LOCK TABLES kind_type WRITE.

But if you're executing the transaction autocommit mode, it doesn't even do that; it just acts like REPEATABLE-READ.

转载地址:http://yrqsx.baihongyu.com/

你可能感兴趣的文章
使用C#进行图像处理的几种方法(转)
查看>>
Ajax原理学习
查看>>
sap scriptfom 多语言翻译
查看>>
实现超级简单的bug管理系统
查看>>
[LeetCode] Find Anagram Mappings 寻找异构映射
查看>>
--Too small initial heap for new size specified
查看>>
黄聪:3分钟学会sessionStorage用法
查看>>
Entity Framework 全面教程详解(转)
查看>>
Windows上Python2.7安装Scrapy过程
查看>>
Chapter 3:Code Style in Django
查看>>
FIDO联盟拥抱政府监管,全面打造安全可信网络
查看>>
BlackNurse新型DoS攻击 15M流量就可以打瘫思科防火墙 思科做出了回应
查看>>
Interop 2015:思科为其SDN架构做好安全防护
查看>>
第19届亚太反病毒研究者联盟(AVAR)国际大会开幕在即
查看>>
挖掘数据金矿 领军协同创新 曙光荣膺“2016大数据创新应用领袖企业”称号
查看>>
国内WiFi厂商公关客户常说的三句话!
查看>>
《大数据分析原理与实践》一一 3.2 关联规则分析
查看>>
Fast通道获得Win10 Mobile Build 14977更新
查看>>
GAN专题阅读小组 | 每周一起读 #05
查看>>
AMD与天津海光合资生产x86服务器芯片
查看>>