Skip to content

鎖的相關使用心得 #12

Answered by kevinkuo39781
Ban921 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, 我整理一下你的問題:
1.你想知道的應該是 "線上交易的正確性" 這個課題
2.隔離階層是指 MSSQL 的 isolation levels 嗎? 有下列等級區分的Read uncommitted、Read committed、Repeatable read、Snapshot、Serializable

這個問題會有以下的延伸:

  1. 你的金流服務的流量是否超過 RDBMS 所提供的 SQL Transaction,這個方法較為普遍被使用

示意 SQL

-- 開啟交易
BEGIN TRANSACTION;  

-- 資料處理
do something...

-- 資料確認
do something...

-- 判斷資料是否正確
do something...

-- 成功 
COMMIT;

-- 失敗
ROLLBACK TRANSACTION

這種做法透過反正規化的設計,省去 JOIN 與合理的 Index 設計可以處理大部分的場景

  1. 如果你的量超過 RDBMS 叢集可以處理的量,你就需要考慮實作分散鎖(distributed lock)
    這部分的問題點會比較多,安排時間彙整出來再供參考

有任何問題歡迎提出討論 @jim515jim

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MilesChou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1 on December 26, 2021 16:01.