Re: [請益] 交易方面的知識(DB)

看板Soft_Job作者 (System hacked)時間5年前 (2019/06/01 17:11), 編輯推噓1(101)
留言2則, 2人參與, 5年前最新討論串2/2 (看更多)
※ 引述《MOONY135 (脫俗仙子談無慾)》之銘言: : 最近要開始搞 DB了 : 不過對於交易這塊不知道要怎樣去寫CODE : EX 進入帳 : 錢匯進來 可能有兩處的DB的不同TABLE要更新資訊 : (兩個要一起成功 只要一個失敗就是得ROLLBACK) 能改架構就改看看,不行的話... : 但有張TABLE可能會經常被其他支程式LOCK住(需要頻繁的UPDATE) : 不知道關於這方面大家都是怎樣學的 : 是書上建議怎樣做就照著做了嗎? : 還是看前人的CODE這樣用就用了 如果改架構不是可能的選擇的話,這就是 distributed trx (或是 global trx) 在解決的問題,推文提到的 2PC 是底層演算法,在比較高階有被標準化: https://en.wikipedia.org/wiki/X/Open_XA To guarantee integrity, XA uses a two-phase commit (2PC) to ensure that all of a transaction's changes either take effect (commit) or do not (roll back), i.e., atomically. 常見的 database 都有實作:(拿 xa transaction 搜尋) https://docs.microsoft.com/en-us/sql/connect/jdbc/understanding-xa-transactions https://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_xa.htm https://dev.mysql.com/doc/refman/5.7/en/xa.html https://jdbc.postgresql.org/development/privateapi/org/postgresql/xa/PGXADataSource.html 沒用過但是看討論知道效能應該不是強項... -- Resistance is futile. https://blog.gslin.org/ & <gslin@gslin.org> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.116.104.21 ※ 文章網址: https://www.ptt.cc/bbs/Soft_Job/M.1559380267.A.6DC.html

06/01 18:14, 5年前 , 1F
感恩
06/01 18:14, 1F

06/02 10:48, 5年前 , 2F
推第 1 句。先天體質好,才不會後天顧得辛苦啊。
06/02 10:48, 2F
文章代碼(AID): #1Sya4hRS (Soft_Job)
文章代碼(AID): #1Sya4hRS (Soft_Job)