Race condition at my bank

I have a bank account that’s set up so when I withdraw funds from that account by wire or check or whatever, if there’s less in the account than the amount I’m spending, the money is automatically pulled from my line of credit. I keep a balance of $0.00 in the account to avoid confusion on my part.

Monday morning, I wired $5,000 from that account. 

On the same day, that money was received by the recipient and then wired back. (It’s a long story.)

The net result at the end of the day should have been $5,000 in the account, and a charge against my line of credit of $5,000.

But something went wrong. Yesterday I was at the bank and saw the account transaction screen for that account. It showed that $5,000 had been wired into the account, then $5,000 had been wired from the account, leading to a balance of $0.00. My line of credit was not tapped, so I won’t be charged interest on the one-day loan.

What happened?

My theory is this: The bank does a reconciliation once a day. But apparently the order of operations isn’t set according to the time the events happen. As a result, the two events went in with a random order — the bank recorded that $5,000 came INTO the account, and then was wired OUT of the account, rather than the truth (that $5,000 was wired OUT of the account, and then came back IN to the account).

In essence, according to the bank, $5,000 that did not yet exist appeared in the account, then was spent and went to a place where it never arrived. Time travel!

The bank was quite confused. I explained my theory to them, and told them it was likely what’s called a “race condition” — a programming term for dealing incorrectly with apparently simultaneous events. This kind of programming error can be very expensive to a bank…if I had a $1 billion line of credit, and I wired the full amount and this had happened, the bank would have lost the interest they should have gotten for a one-day loan of $1 billion (at my 7.5% rate, about $205,479).

I’ve encountered this sort of behavior before with various banks (often involving my moving money into an account to make payroll, then the payroll charge coming in later that afternoon, and the bank bouncing payroll because funds weren’t available) so my suspicion is that it’s not an isolated problem. I’ve rarely seen it so clearly-defined before, and so much to the detriment of the bank!

One solution is for the bank to always record withdrawals before recording deposits. This would lead to a fair number of bounced checks, and that would be good for the bank and bad for customer service. Doing it the other way (deposits before withdrawals) would be bad for the bank in some cases and neutral in others, but never good for the bank.

The best solution is probably to write better code so either
(a) a whole day’s activities aren’t tallied all at once, or
(b) using a predicate (where it checks for “current” information before implementing the change).