Banking Example Again

I was reading through this yesterday on my way out of London. Go on take a minute and read it.

I do find it funny that the bitcoin exchanges were taken down by such things but the article is pretty ridiculous in how it presents its problem/solution. Banks don’t actually work as described in this post. There is not a column “balance” in an account table as presented unless the developers just had no clue what they were doing.

mybalance ="account-number") newbalance = mybalance - amount database.write("account-number", newbalance) dispense_cash(amount) // or send bitcoins to customer - See more at:

This is absurd your balance while perhaps being denormalized on your account is really the result of an equation (summation of the value of your transactions). All of these problems discussed would just go away if the system had been designed to record a journal properly (and as the journal is append only most other issues would go away).

I have always hated that the typical example of distributed transactions is transfering between two accounts. Banks don’t work this way!


  1. James McMahon
    Posted April 10, 2014 at 11:37 pm | Permalink | Reply

    It doesn’t matter whether the banks keep track of a balance or a log of transactions. As long as the underlying engine is eventually consistent, they are open to the kinds of problems cited in the article.

    • Posted April 11, 2014 at 7:06 am | Permalink | Reply

      This is not true. In the case cited a transaction is lost. With an append to a journal neither transaction gets lost.


      t1 read $50
      t2 read $50
      t1 -= $10
      t2 -= $25
      t2 update $25
      t1 update $40

      $25 is lost.

      t1 insert $10 deduction
      t2 insert $25 deduction

      neither is lost.

      Banks are at their core eventually consistent (its even in their business models).


  2. Posted April 11, 2014 at 10:11 am | Permalink | Reply

    Totally agree. Running distributed transactions between banks would be ridiculous.There’s no way a bank is going to allow third parties to issue transactions against it’s databases.
    Ever heard of the SWIFT network? Funds are moved out of the payer’s account, are in neither account while traveling over the SWIFT network, then are moved into the payee’s account. Any issues along the way are dealt with by compensating actions. Sometimes, instead of rolling back, there are options to roll forward (like a bank charging a fee for a failed transfer)

    • Posted April 11, 2014 at 10:13 am | Permalink | Reply

      There are also loads of intermediaries such as government clearing houses.

    • chrisbednarski
      Posted April 11, 2014 at 10:44 am | Permalink | Reply

      Also, because of eventual consistency, debit accounts can (and sometimes will) go into negative balance. This is undesired, however, perfectly normal.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 9,170 other followers

%d bloggers like this: