winstont77 / winstont77.github.io

0 stars 0 forks source link

2024/05/11/feat-concurency/ #1

Open utterances-bot opened 3 months ago

utterances-bot commented 3 months ago

資料庫設計與併發問題 - 併發情況下使用預設隔離層級欄位的交易 | Hexo

前言.打算將下面兩個主題分開來闡述:併發情況下使用預設隔離層級欄位的交易如何防止庫存超扣-樂觀鎖先打下來免得之後忘掉… 併發情況下使用預設隔離層級欄位的交易.先使用SQL建立商品Id及庫存數量 12345678910CREATE TABLE dbo.Product( ProductID INT NOT NULL, /商品Id/ Quantity INT NOT NULL

http://winstont77.github.io/2024/05/11/feat-concurency/

CHI-KEKE commented 3 months ago

以這個例子來說,假如我們的transaction如下

Allen : Read Committed 阿冠 : Repeatable Read

我是不是會被阿冠罵

winstont77 commented 3 months ago

Read Committed允許Non-repeatable reads以及Phantom reads。 Repeatable Read允許Phantom reads。 但是如果是你先開始交易,則只要考慮阿冠的交易類型,Read Committed。 並且這次的例子沒有超過一筆資料被更動,因此不會發生Phantom reads。 阿冠要更新資料前,你更新了阿冠要更新的資料並且你的交易committed,這就是Non-repeatable reads ->被罵

gtpan0418 commented 3 months ago

我那麼兇會罵人喔😠

gtpan0418 commented 3 months ago

爛貓貓 手機不能玩

winstont77 commented 3 months ago

上班的時候用電腦玩