如何产生幻像读取? [英] How to produce phantom reads?

查看:165
本文介绍了如何产生幻像读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用可重复读取应该可以产生幻影读取,但如何?

Using "repeatable read" it should be possible to produce a phantom read, but how? I need it for an example teaching CS-students.

我认为我必须在非索引字段上做一个SELECT ... WHERE x <= 888 x,上限888不存在,然后在另一个连接上插入一个值低于888的新行。

I think that I must make a "SELECT ... WHERE x<=888" on a non-indexed field x, with an upperlimit 888 not present, and then on another connection insert a new row with a value just below 888.

除非它不工作。我需要一个非常大的表吗?或其他?

Except it doesn't work. Do I need a very large table? Or something else?

推荐答案

Erik,

用非常大量的行测试它。

I come just from test it with a very large number of rows.

您将永远不会在InnoDB mysql上发现带有读取提交或更多受限隔离级别的模板。它在文档中解释:

You will never found phantoms on InnoDB mysql with read commited or more restricted isolation level. It is explained on documentation:

REPEATABLE READ:对于一致的读取,与READ COMMITTED隔离级别有一个重要的区别:同一事务中的所有一致性读取读取由第一次读取建立的快照。这个约定意味着,如果在同一个事务中发出多个明文(非锁定)SELECT语句,这些SELECT语句相对于彼此也是一致的。参见第13.6.8.2节一致性非锁定读取。

REPEATABLE READ: For consistent reads, there is an important difference from the READ COMMITTED isolation level: All consistent reads within the same transaction read the snapshot established by the first read. This convention means that if you issue several plain (nonlocking) SELECT statements within the same transaction, these SELECT statements are consistent also with respect to each other. See Section 13.6.8.2, "Consistent Nonlocking Reads".

但是你也不能在读提交隔离级别中找到幻像:这是必要的,因为幻影行必须阻止MySQL复制和恢复工作。

But you can't also found phantoms in read commited isolation level: This is necessary because "phantom rows" must be blocked for MySQL replication and recovery to work.

更多详细信息: http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html

我想你会需要移动到另一个数据库品牌来向你的学生显示幻影。我同时使用 MSSQLSERVER Oracle

I think you will need to move to another database brand to show phantoms to your students. I use both MSSQLSERVER and Oracle.

好吧...对你的第一个问题很遗憾。

Well ... its a pity for your first question.

这篇关于如何产生幻像读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆