AdSense

網頁

2023/4/10

系統設計 遠端資源狀態一致性問題 - 遠端資源已建立但本地紀錄更新失敗

在本地紀錄建立後(狀態為「建構中(building)」)並成功建立遠端資源,但更新本地記錄狀態為「已建立(created)」時更新失敗(e.g. 資料庫連線失敗)。



plantuml

@startuml
participant client
participant app
database    db
participant remote
skinparam sequenceMessageAlign center
skinparam ParticipantPadding 50

client ->> app : create request
activate app
app -->> client : accepted
app -> db : CREATE record\nwith state 'building'
activate db
db -->> app : success
deactivate db
|||
app -> remote : CREATE resource
activate remote
remote -->> app : success
deactivate remote
|||
app -[#red]>x db : UPDATE record state\n to 'created'
note right : transaction failed\n due to network failure
activate db
db -->> app : failed
deactivate db
app ->> client : failed message
deactivate app
note over db : record state remains 'building',\n but resources existed.
@enduml

同「資源已建立但系統失效」的處理。

且在本地服務的資料庫未回復正常以前,健康偵測應將應用程式功能關閉避免使用者持續操作發生重複的錯誤,「系統維護中請稍候再試」。

沒有留言:

AdSense