微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql事务级别可重复读取和序列化是否相同?

引自 http://www.postgresql.org/docs/9.4/static/transaction-iso.html

When you select the level Read Uncommitted you really get Read Committed,and phantom reads are not possible in the Postgresql implementation of Repeatable Read,so the actual isolation level might be stricter than what you select.

澄清一下:它是否意味着pg的可重复读取=可序列化?

解决方法

没有;差异在 the page you linked to中描述:

In fact,this isolation level works exactly the same as Repeatable Read except that it monitors for conditions which Could make execution of a concurrent set of serializable transactions behave in a manner inconsistent with all possible serial (one at a time) executions of those transactions.

文档继续给出一个示例,其中Repeatable Read和Serializable的行为不同. Serializable事务可以通过“序列化失败”中止,但不会阻止任何额外的事务完成.

您引用的部分解释了一些异常,因为标准sql隔离级别是围绕锁定数据设计的,但Postgresql是使用“MVCC”设计实现的,其中并发事务可以为数据提供独立的快照.因此,其他系统中存在的一些区别不适用,Postgres将隔离级别解释为“至少与…一样严格”.

正如Mark Hildreth在评论中指出的那样,这种区别仅在Postgresql 9.1之后才有效. documentation for 9.0指出:

But internally,there are only two distinct isolation levels,which correspond to the levels Read Committed and Serializable.

而在较新的版本中,这已被修改为:

But internally,there are only three distinct isolation levels,which correspond to the levels Read Committed,Repeatable Read,and Serializable.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐