A real deploy gone wrong: an old flag, one forgotten server and no off button. What the SEC report says, and what to do differently.
212 small orders went in. Over 4 million trades came out. About 45 minutes later, a trading firm had lost more than $460 million, with no hacker and no crash. Just a normal morning deploy.
That was Knight Capital on 1 August 2012. Knight bought and sold shares for other people, using software. The US market regulator, the SEC, wrote a long official order about it in 2013. I read it, and it teaches deploying code better than most tutorials.
Let's see how it happened, one step at a time.
The SEC reports that Knight's router (the program that sends orders to the stock market) received just 212 small orders from customers. It turned them into millions of orders, which led to over 4 million trades in 154 stocks, for more than 397 million shares. All in about 45 minutes.
The SEC's wording is "lost over 440 million. I'm using the SEC's number.
So the loss was huge. But what actually went wrong in the code?
Knight was adding support for a new stock exchange program. The new code was meant to replace some old, unused code called Power Peg. Power Peg had been switched off for many years, but it was still sitting in the program.
Here is the sneaky part. The new feature reused the same flag (a flag is just an on/off switch in the code) that used to turn Power Peg on.
Why this matters: a flag with two meanings is a trap waiting for one wrong machine. So was there one?
The router ran on eight servers (computers). The SEC reports that a technician did not copy the new code to one of them. No second person checked the deployment, and Knight had no written rule that required it.
Imagine telling 7 of 8 team members that a meeting moved to Tuesday. The eighth shows up on Monday. Here, the eighth server also starts spending money.
Next question: why did the old code on server 8 go wild instead of just doing nothing?
When Power Peg was alive, it counted how many shares were already bought and stopped when the order was done. In 2005 Knight moved that counter elsewhere in the code. The SEC reports they never retested Power Peg after that.
So on server 8, the old code had lost its "stop" counter. It kept sending orders again and again, even though the orders were already filled.
Click Next and follow one customer order through the system. Watch which node lights up at step 3.
A small order arrives carrying the flag
Did you see step 5? The loop has no exit. That is how 212 orders became millions.
Before the market even opened, Knight's system sent 97 automated emails with an error message reading "Power Peg disabled". The SEC reports these weren't designed as alerts, and people generally did not read them.
It is like an inbox with 400 unread messages, where the one that mattered was buried inside. So the warning existed. What about stopping it?
Once the trades started, Knight had no quick way to stop. The SEC reports that Knight had no procedures to halt the router "in response to its own aberrant activity". Their monitoring tool needed a human to watch it and did not stop orders by itself.
Then the team tried a fix: they uninstalled the new code from the seven good servers. The SEC reports this made it worse, because now those servers could also wake up Power Peg.
So what should a normal team copy from this?
The SEC fined Knight $12 million (and ordered an outside review of its controls). But the better question is for us.
You can try the small version on a side project. Add a feature flag, deploy to one test server, then check a dashboard before you roll it out everywhere. And ask yourself the Knight question: if this goes wrong right now, which button do I press?