开发者

How to translate transaction dependant code into non transaction dependant code?

I've heard a couple months ago that Amazon was inclined to change all of its transactional shipping code (which also has another problem, they are distributed aka "sharde开发者_运维百科d") into non transactional code.

some_buy_method()

  check_item_stock()

  remove_item_from_stock()

  add_to_order()

end


First answer: With difficulty.

Second answer: With potentially disastrous results.

I doubt Amazon wants to eliminate all transactions. What they probably want to do is relax the ACID conditions to improve scalability and availability: they're still going to want atomicity and durability, but will have to refactor their operations for commutativity and idempotence and add compensating transactions to deal with reduced consistency and isolation.


I heard that eBay also was running without transactions, maybe Amazon will follow a similar approach.

From The eBay Architecture (slide 18, 23):

Absolutely no client side transactions

How do we pull it off?

– Careful ordering of DB operations
– Recovery through
• Asynchronous recovery events
• Reconciliation batch • Failover to async flow

Rationale

– Avoid deadlocks
– Avoid coupling availability
– Update concurrency – Seamless handling of splits eBay

(Sorry for the formatting)

To me, it looks like if there are not ACID transaction, you need to check, recover or compensate thing manually. But the exact business logic is known, so a proper error handling or conflict strategy can be devised. That also makes me thing of error handling in BPEL where things are asynchronous and we write compensation handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜