weblab-tw / ddia-study-group

Designing Data-Intensive Applications Study Group
36 stars 5 forks source link

第七章:書中關於 SQL Server 快照隔離的小錯誤? - Sam #89

Open samwu4166 opened 2 years ago

samwu4166 commented 2 years ago

裡面提到快照隔離沒有辦法避免 Write Skew & Phantom Read,並提到:

不幸的是,在一些快照隔離的實現中,自動檢測丟失更新對此並沒有幫助。在 PostgreSQL 的可重複讀,MySQL/InnoDB 的可重複讀,Oracle 可序列化或 SQL Server 的快照隔離級別中,都不會自動檢測寫入偏差【23】。自動防止寫入偏差需要真正的可序列化隔離 ...

但是其實在 2019 SQL Server 中,快照隔離已經預設有 optimistic concurrency & select statement lock 的支援 XD (也就是文中的 SSI)

Snapshot isolation uses an optimistic concurrency model. If a snapshot transaction attempts to commit modifications to data that has changed since the transaction began, the transaction will roll back and an error will be raised. You can avoid this by using UPDLOCK hints for SELECT statements that access data to be modified.

ref: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/snapshot-isolation-in-sql-server

不知道還有沒有 DB 是在這本書(2017)寫完後有比較大的 Isolation 改變!?

jxiu0129 commented 2 years ago

pg