r/programming • • Jul 26 '16

A DevOps Cautionary Tale or how a company with nearly $400 million in assets went bankrupt in 45-minutes because of a failed deployment.

https://dougseven.com/2014/04/17/knightmare-a-devops-cautionary-tale/
2.6k Upvotes

448 comments sorted by

519

u/[deleted] Jul 26 '16 edited Jul 26 '16

Why were they unable to power down or kill the system?

There were 8 servers, all of which they apparently had access to so why were they uninstalling software?

edit: I am reminded of this scene.

257

u/jalons Jul 26 '16

As I remember it, they didn't know there were eight. They thought there were seven, and the eighth was feeding and being fed by the others, creating a loop due to the reused feature toggle meaning two different things to the two different revisions.

45

u/[deleted] Jul 26 '16 edited Jul 26 '16

I would have turned everything off. You might be out of a job, but if the company goes down, you are for sure. I admit that it's easy to second guess with the benefit of hindsight, and I wasn't there at the time.

I actually also don't understand why they don't have an 'oh shit switch' in case they get hacked or something.

74

u/jalons Jul 26 '16

It's common to have a "big red button" in trading, so it's kind of surprising they didn't at the time. As you said, hindsight is 20/20.

42

u/TCL987 Jul 26 '16

This incident might be why it's common to have one now.

47

u/ElectroNeutrino Jul 27 '16

This only happened 4 years ago. "Oh, Shit" switches have been used for decades.

25

u/skylarmt Jul 27 '16

Heck, I have one in my workshop (remodeled barn). It's the master breaker. If that fails, I can run to the house and shut off the other end of the wire. If that fails, I'll sit back and enjoy the fireworks. Or the skynet, depending on what I was doing at the time.

→ More replies (1)
→ More replies (2)

7

u/bradfordmaster Jul 27 '16

Yeah... or literally just pull the plugs from the servers. like... somewhere theres an ethernet or fiber line going out of that building, just chop the whole fucking thing in half with a fire axe....

8

u/lally Jul 27 '16

The servers are usually at colos near the exchanges. No physical access in the near term.

→ More replies (1)

3

u/real_jeeger Jul 27 '16

The servers are probably very close due the stock exchange, in order to get minimum latencies. High-speed trading is bonkers that way.

→ More replies (4)
→ More replies (3)

10

u/JD-King Jul 26 '16

What a cluster-fuck.

94

u/the_red_scimitar Jul 26 '16

That's... stunning. They didn't know about an entire SERVER, yet somebody managed to (wrongfully) update it. The eff-up that that requires is a bit staggering.

236

u/yoniroit Jul 26 '16

the issue is that it wasn't updated

→ More replies (33)

71

u/[deleted] Jul 26 '16

At large scales this is normal if you dont work from a centralized datasource whichs knows all the things.

7

u/hurenkind5 Jul 26 '16

Large scale is eight?

52

u/mcilrain Jul 26 '16

Eight message routers at one stage in the pipeline is large scale, yes.

12

u/TommyROAR Jul 26 '16

If they're anything like the Solace messaging backbone I used to work with, yeah. They can handle topic routing at millions of messages per second and cost upwards of $1M per server

10

u/[deleted] Jul 27 '16

Is that just SW costs? What hardware do you get that would justify $1M for a server?

→ More replies (3)
→ More replies (2)

6

u/[deleted] Jul 26 '16

Why would you work in such an ad hoc manner at large scales.

49

u/[deleted] Jul 26 '16 edited Jul 26 '16

Have you worked at many places? All of them are doing this.

At Google i was the first person to build a system that actually had all the correct stuff and it was for the network elements (35k elements). The hosts were still in a DB that had bad and missing data in it, back in 2007.

Not sure of their current state, but everyone else is still doing this wrong and is vulnerable to this exact problem.

8

u/Farobek Jul 26 '16

Could you ELI5 please?

→ More replies (11)
→ More replies (7)

17

u/agentgreasy Jul 26 '16

You wouldn't. But you are rarely individual in these things.

I can't tell you how many times I've been sabotaged by people before me, management impeding the required time to effect proper control, another department ignoring requirements, people simply lying, incapable people, laziness, disorganization, piles of shit under piles of shit piled under more piles of shit.

The solution is always easier to say in hindsight but far more difficult to implement.

17

u/experts_never_lie Jul 26 '16

I've been at organizations that have hundreds of lost servers. When you have tens of thousands of servers, controlled by dozens of teams, there'll always be some floating around.

However, normally there are systems preventing rogue servers from doing anything, especially with regards to external systems.

20

u/orangesunshine Jul 27 '16

I've been blown away by the sheer stupidity of pretty much every "devops" person I've had the pleasure of working with.

The last one I worked with called me to come fix something that was causing an outage on a Friday evening. The very first thing I asked him was "did you change the number of worker daemons for our celery cluster?". I insisted this looked like the problem was the result of a change there. He told me no, I asked "are you sure" ... and he again affirmed that "no he definitely did not change anything there".

Fucking 16 hours later after exhausting every possible other thing that might in the most remotest gone wrong ... I decided to log into the servers and look with my own eyes. Sure enough, he'd set the daemons to max out the CPU on the cluster of machines ... which was in turn completely decimating our cluster of SQL boxes.

Worse still the next morning he had the audacity to explain why the mistake he made was really my fault ... and had all dev's credentials pulled. So we refused to help him again, and after successfully shifting blame on countless more blow-ups ... he lost his job after a major launch that he botched that really couldn't be anyone lesser's fault.

It was just insult upon injury.

That was a pretty useless individual, but really there should never be a separate team. If your dev-ops team isn't competent enough to write application code, they aren't competent enough to write dev-ops code ... and if the application team isn't competent enough to write dev-ops code they aren't competent enough to write application code.

That and it leads to experts in systems on said teams not doing work they really should be. So if you hired an app-developer that's worked 10+ years with sharded SQL systems ... you shouldn't have the guy that barely understands how to spin up a master/slave doing that job merely because you hired guy X for X and guy Y for Y.

... well and it leads to one hand not knowing what the other is doing.

5

u/ReidZB Jul 27 '16

Monitoring! The number of active worker threads (or some similar metric) should be a metric you collect. The number of database connections should be a metric you collect. Database node statistics should be collected (CPU, memory, IO, network). Having these things on a dashboard (in combination with smart alerting rules) can make hunting down problems like this much much easier.

That said, separate teams are fine - but yes, your 'DevOps' engineers and 'software' engineers should have enough skill that they could perform on either team. I think that's just the general principle of hiring good people, though...

4

u/Gotebe Jul 27 '16

Having seen it a couple times before, I explicitly tell people, when they claim that "nothing has changed", that I do not believe them and ask to look for myself.

2

u/megablast Jul 27 '16

If your dev-ops team isn't competent enough to write application code, they aren't competent enough to write dev-ops code

Sure, but you won't find many people that are devs, and want to write devops code. I sure don't. Devops sucks.

→ More replies (3)

0

u/[deleted] Jul 27 '16

[deleted]

→ More replies (2)

5

u/cyberst0rm Jul 26 '16

theres no somebody these days, only everybody or no one

→ More replies (4)

12

u/RagingOrangutan Jul 26 '16

7 is such an odd number; I would think just seeing "7" would make the engineers scratch their heads and wonder if there was another somewhere.

43

u/kooroo Jul 26 '16

not really. Any system requiring a quorum of something will have an odd number of machines, so units of 3, 5, and 7 aren't as "uncommon" as they used to be.

3

u/qsxpkn Jul 27 '16

Quorum needs more than half of the votes (split brain) so odd numbers are very common.

→ More replies (1)
→ More replies (1)

89

u/LainIwakura Jul 26 '16

I'm guessing that shutting off systems that trade a large portion of stock volume would be an even worse idea - they probably assumed it was something to do with the new code and just uninstalled it without a real understanding of what was happening. I'd say this story is also a cautionary tale about code rot and the importance of cleaning up old crap.

115

u/jalons Jul 26 '16

And not to reuse feature toggle bits.

31

u/Dr_Legacy Jul 26 '16 edited Jul 26 '16

My gods, this. Back in the mid 20th century mainframe days, when every bit had a cost, reusing every one made sense - but in 2012? Seriously?

EDIT: Apparently so, per the replies. If there aren't any bits to spare in a fixed length record that has to be short to support processing speeds, that's what you have to do.

Kind of explains why they left the old code for that bit to stay live, too. If record real estate is that precious, you can't just have idle bits laying about.

10

u/rtkwe Jul 26 '16

This is on HFT systems though so efficiency and speed are a big part of the design.

→ More replies (1)

9

u/jalons Jul 26 '16

Bits are still very precious in HFT. You're already paying an interrupt penalty to process this toggle, so eating through it as fast as possible with as little overhead can be critical.

7

u/mirhagk Jul 26 '16

I see this all the time. People have a natural tendency to want to see consecutive numbers so they have the desire to renumber stuff or re-use numbers that no longer exist. It's very dangerous though and provides basically no benefit

3

u/CheshireSwift Jul 26 '16 edited Jul 28 '16

The message formats in use for some of these things may well not be that far off mid century mainframe days.

0

u/[deleted] Jul 26 '16

[deleted]

15

u/khold_stare Jul 27 '16 edited Jul 27 '16

Speed is important to HFT, but the there are a lot of crazy myths floating around. Noone is fighting over floor-space, as all exchanges rent out space for firms in their data centers - they make sure everyone's cables are the same length to the exchange matching engine.

Regarding bits in a message - the time it takes to deserialize a bit is inconsequential given the bandwidth of the networks inside a data center (typically 10G). Also, some exchange protocols are still text-based, where you have to do conversion to and from string representations! (FIX protocol) Imagine trading with JSON. A bit doesn't matter in this scenario.

Finally, the system in question looks like it was handling retail orders - speed helps, but is not essential. The main purpose of these systems is to trade smart, and not give away intent of a large order. E.g. E-Trade sends a gigantic bulk order to represent many client orders, and then Knight breaks it up into smaller orders not to spook the market, and move the price against them.

Disclaimer, I work in HFT.

9

u/jandrese Jul 27 '16

I'd be surprised if they're using interconnects as pedestrian as Gig-E. When the nanoseconds matter and you're dealing in billions of dollars every hour you can afford to splurge for the 10G or 40G links just to shave down the time it takes to clock the bits out.

7

u/[deleted] Jul 27 '16

Yeah, I've worked in HFT networking and people use 10G for lower latency, for sure.

Last I checked, 40 gig network gear had higher latency than 10G so the faster bit-times wasn't worth it.

→ More replies (17)

45

u/djk29a_ Jul 26 '16

There's all sorts of takeaways possible from this story depending upon what you want to emphasize as a personal agenda. I use this story most often to talk about why we need to put in circuitbreakers in code to react faster than any workflow that includes humans because your business now operates faster than humans can comprehend and react. I mostly invoke it when people insist on adding more people and written down processes to an incident response process as a way of improving communication and reducing MTTR instead of asking for more / better automation.

10

u/K3wp Jul 26 '16

I mostly invoke it when people insist on adding more people and written down processes to an incident response process as a way of improving communication and reducing MTTR instead of asking for more / better automation.

I have never wanted to send a beer over the Internet more! You are doing God's work, son.

It's amazing how often you see stuff like this in InfoSec. We spend millions on 10G fiber-optic and wireless networks. And what's our incident response process? Send a schmuck in a golf cart across campus with a screwdriver and a portable hard drive to manually image the system. Then burn a week of engineering time picking over access times and file fragments.

7

u/djk29a_ Jul 26 '16

Merely complaining about what goes on and how things should be is a pretty fast track to getting fired from engagements in my experience, so I can't really let my own rant stand as a professional.

In defense of manual processes, if you do not know how to do something manually then you cannot do it in code either. This is where both historical evidence as well as collective, personal experience are useful for creating the start of automated processes. It's ok and a fact of life if the reason for an outage happens once, but, for example, if your RCA winds up saying "we need to monitor our cross-datacenter network links at layer 2 - 4 and proactively test and identify configurations that result in degenerate behavior like X, Y, Z" and nothing happens to propagate the message higher and across silos, you are entrenching defects.

If you have problems with defining scenarios and problem categories defined, that's also fine as long as you practice the incident response workflow and can be realistic about expectations (InfoSec has red / blue team exercises in theory). This is explained as what Google does in the Site Reliability Engineering book, and while some Googlers seem to have some gripes here and there, few of them seem to have witnessed the abysmal 2+ hour response times I've seen common when people don't practice incident response in enterprise.

→ More replies (5)

1

u/the_red_scimitar Jul 26 '16

And only uninstalled on 7 of the 8. An earlier post in this thread mentioned that somehow they thought there was only 7 servers (yet somehow also updated the 8th). Hard to imagine.

20

u/Goz3rr Jul 26 '16

No, only 7 out of 8 servers got the update which caused them to start using the repurposed flag again, which activated the old code on the 8th server instead of the new code since it hadn't gotten the update. When they rolled back the 7 updated servers they now also had the old code and all started doing the wrong thing

2

u/the_red_scimitar Jul 26 '16

Aaaaah, I see. Something about this flag was triggered, because the others were now using the flag? Interesting. And sounds like further design errors than the obvious ones.

9

u/Kapow751 Jul 26 '16

In the previous version, flag X meant "activate Power Peg". In the new version, flag X meant "activate RLP processing". They were sending orders with flag X enabled to all of the servers, so the updated servers activated RLP and the overlooked server activated Power Peg (which hadn't been used in 8 years and no longer functioned correctly).

→ More replies (4)
→ More replies (14)

83

u/reptar-rawr Jul 26 '16

I've often found that some of my best code work is done when another person and I are furiously typing on the same keyboard.

6

u/Narrative_Causality Jul 26 '16

The scene is a result of the writers of TV shows trying to outdo each other in how ridiculous they could make hacking seem. Looks like they succeeded.

3

u/[deleted] Jul 26 '16

What's the problem with that? It works on a piano. I've never used one of these new fangled computer things - said most NCIS viewers.

→ More replies (25)

3

u/mclamb Jul 26 '16

"Since they were unable to determine what was causing the erroneous orders they reacted by uninstalling the new code from the servers it was deployed to correctly. In other words, they removed the working code and left the broken code. This only amplified the issues causing additional parent orders to activate the Power Peg code on all servers, not just the one that wasn’t deployed to correctly."

2

u/phpdevster Jul 27 '16

I feel extreme physical discomfort every time I watch that scene. This must be how doctors feel when they watch Grey's Anatomy, or lawyers/police feel when they watch Law & Order.

2

u/PotatoMusicBinge Jul 27 '16

everyone blindly smashes keys

hurr looks like were getting HACKED!

yeah, better take a fucking sledgehammer to that keyboard, i'm not feeling like i SMASH DOSE KEYS ENOUGH

BLEEP BLOOP BEEP SUPER MARIO

murrhurr? whats going on here? dat sum halo? jk whitey, oh you and your silly cyberstuffs

OUR ULTRONFLUX IS GETTING FLORKED, GLIBB SOME ROBOWATTS INTO THAT GIGAFLEX BEFORE THE HUBBERNERTS OVERDERP!

errbody chill you cuhrazy dorks, i just pulled the plug. the pentagon is now safe!

2

u/S00rabh Jul 27 '16

I like how two were using same keyboard. It's like one never wanted to press Enter and other never wanted to use caps or shift

1

u/jandrese Jul 27 '16

I'm guessing the same kind of cowboy development house that screwed up the deployment this badly also failed to implement a big red button.

1

u/bpm195 Jul 27 '16

Was that intentionally hilarious, or is that just how the show interprets advanced computering?

3

u/[deleted] Jul 27 '16 edited Jul 27 '16

Their audience demographic is age 60+ and highly conservative. The show is about a wise old man who babysits loyal but naive kid agents (remember, to him anyone under 30 is a kid). Draw your own conclusions.

1

u/[deleted] Jul 27 '16

I thought you were gonna link to the silicon valley tequila-on-the-keyboard scene

1

u/DustinBrett Jul 27 '16

That scene makes me cringe.

1

u/creepy_doll Jul 27 '16

The article clearly states that they reverted the new servers to the old version that used to work(but had unused code behind the flag that would cause shit to go wrong). The problem was they had enabled a repurposed flag that got used by shit on the old server. So the bug was actually exposed in the old system when they thought it was in the new one.

1

u/ChristopherBurr Jul 27 '16

I'm familiar with Knight, as I was interviewing there at the Time that this happened. The trades were occurring at several million trades per second so, you don't have very much time to react, and when you do react you still have to go through the normal troubleshooting procedures to figure out 1) where the issue is coming from and 2) stop it.

As market makers, Knight was responsible for any position they were left holding the bag on if they stopped trading entirely. At the time, it probably seemed like a very bad idea to just pull the plug.

As for the uninstall - in low latency environments I've worked in, the software is often burned onto an FPGA card so you need to go all in.

As a side note, they merged with another firm and are still around as KCG (http://www.kcg.com). The engineer that made the mistake wasn't fired, though I don't know if he still works there.

1

u/[deleted] Jul 27 '16

I am annoyed by the guy with the sandwich. LOOK he hardly even take a bite! Who eats a sandwich like that.

→ More replies (34)

249

u/wanderingbilby Jul 26 '16

Odds are the admins on duty weren't empowered to take the whole system down or didn't have the right access.

If you're going to do high speed trading, your response level needs to be as fast as possible - if that means keeping a VP on site on duty during all "up" hours, so be it. It's not like these places run on thin margins.

135

u/[deleted] Jul 26 '16

As much as Knight screwed the pooch on this, this wasn't the case. It is more related to poor deployment practices and Ops staff that were either having a bad day, or were poorly trained (I haven't met anyone who was working on it that day, so I don't like to armchair quarterback on what specifically happened).

JessiArr's post, point 15, pretty clearly highlights what happened. I think this one is safely in the camp of "Oh shit, we had no idea that was happening" until it was too late. Almost any trading company (who I've had a chance to chat with) will fully permit their ops guys the ability to flat out stop trading from happening if they identify something is wrong.

27

u/wanderingbilby Jul 26 '16

Ah, cool. I'll go back and read, thanks. I don't work in the industry but I've worked in plenty that emasculated their IT admins to the point where they couldn't cut production for anything short of a fire.

24

u/CyclonusRIP Jul 26 '16

I doubt the OPS guys really understood what was happening anyways. If you're in a situation where the company is going to die if you don't shut down production, then you are probably not super worried about exceeding your authority. If you do nothing you definitely lose your job, if you exceed your authority maybe you lose your job.

12

u/[deleted] Jul 26 '16

Sometimes that's the case, yep. I'm speculating here (because I have no inside knowledge), but it was likely a low-staffing period (Aug 1; summer is traditionally a dead period for trading; everyone is on holiday). Likely you had someone who was overworked, or under trained (or both).

Here the problem though seems to be more about how long it took anyone to notice there was a problem, and their choices (related to how to recover the system) after they saw they had an issue, not empowerment.

9

u/swattz101 Jul 26 '16

You would think if they were deploying out new software updates that would have a major impact on a new exchange program, that they would have someone on site in case something went wrong.

Of course, 45 minutes doesn't seem that long to me, but I don't work in that kind of high paced environment.

7

u/[deleted] Jul 26 '16 edited Jul 26 '16

Depends on whether or not they thought it was a high impact change. For all we know (and I say this specifically about Knight) they could have thought it was rather innocuous (and so pushing it specifically during this period wouldn't have been a big deal).

Just in case you're curious (since you mentioned not working in the space), typically there are additional systems built on top of the "Is the harddrive working?"/"Did we get this log alert?" HP Openview-kinds of things you'd expect in a typical tech deployment. Usually these monitor the "business logic"...how many orders there are outstanding, what the total invested and potential invested exposure is, are orders being responded to in a timely fashion (by the markets you are sending the orders to). If you read the SEC notice there's mention of an email stating an issue, that were ignored, that are of a similar vein (though for trading ops email alerts are typically too slow). Typical problem identification should be under 2 1/2-5 minutes. MTTR should be under 15 minutes (but I'd say that's even a bit slow; shouldn't be much longer than 5 minutes after identifying you have an issue). At the very least you should be plugging the gusher as quickly as possible, and simply not trading until you can reliably sort things out.

The summer months are sometimes the most dangerous because trading is slow, and so your volume of alerts/issues is drastically lower than normal, and people are focused on project work. Depending on how well tuned your team is, it's quite possible to miss something like this for longer.

12

u/flee_market Jul 26 '16

In many companies, the IT admins would be quite seriously expected to physically throw themselves onto the fire in an attempt to smother it, because pulling the HALON system would cost money.

5

u/wanderingbilby Jul 26 '16

And people wonder why there's so much burn out in this industry...

5

u/skepticalDragon Jul 26 '16

No, they know exactly why they just don't give a fuck.

25

u/[deleted] Jul 26 '16 edited Jul 26 '16

No, you're totally right. And I've had to suggest to certain companies within the finance space (I moonlighted in an advisory capacity for a bit) that emaciated ops guys would end up causing them far more harm. You need to empower your staff to perform the steps necessary to mitigate risk.

The problem is, this often requires more training than most firms are willing to commit to. And, more importantly, in this sort of environment if your Ops guys don't feel invested in the company (or the work) their apathy is going to flat out screw you. Not to mention the burn out rate is higher because of the added responsibility and stress. It makes managing operations a much more hands on process, and for many firms the cost isn't worth it (because they often don't fully understand the risks; or the risk is deemed insignificant relative to the cost of managing ops/other errors).

→ More replies (1)

2

u/corobo Jul 27 '16

I think in that situation I'd have lit a fire if a fire was needed..

If I'm ever in the situation of designing these systems I think the emergency red button will release a physical cut off - little guillotines that can sever the network cables.

→ More replies (2)

2

u/Krillo90 Jul 26 '16

JessiArr's post, point 15, pretty clearly highlights what happened

For goodness' sake Reddit, can we please read at least some of the articles before we comment? Point 15 from that post is also quoted in full with the exact same words in the OP's original post.

2

u/[deleted] Jul 26 '16 edited Jul 26 '16

Yes, sorry, it was easier to point to that one because I felt it was a good write up. Next time this comes up in /r/programming I'll be sure to just link to the SEC Order which is the source of all of these articles.

Appreciate you calling me out for lacking reading skills though. Admittedly I did not read the posted article, because this thing is years old and anyone who has run financial systems before has read the order end-to-end multiple times.

→ More replies (1)

1

u/toaster13 Jul 27 '16

As someone who has worked in finance technology and other tech sectors.... Honestly, many of them aren't that good. Very strict siloing tends to let subpar engineers have more influence than they should and that tends to chase away some of the best talent. I don't think I've ever hired someone out of finance for all the times I've interviewed people in that sector. There must be a few good people but they are super rare.

→ More replies (1)

38

u/randomguy186 Jul 26 '16

And I'd bet my annual paycheck that the company culture didn't reward acknowledging mistakes. I know a few folks who work in financial programming; it's a high-stakes job and they hire excellent people. I can't see any way for a deployment on a server to be missed without the person doing the deployment being aware, and a safe culture would have allowed that person to acknowledge their mistake at 9:31 AM rather than after the company was bankrupt.

3

u/[deleted] Jul 27 '16

Admit when you have failed, and own up to your mistakes. Doing so makes you an adult. I've noticed that a lot of developers are barely adults, though. I guess I wasnt very mature at 25 either, but I was delivering pizzas and boning waitresses back then, so... I always wonder what it must be like to be fast tracked through the ivy league and hired into a financial firm right out of college. My guess: terrifying.

1

u/Jonne Jul 27 '16

If he didn't realise he made the mistake in the first place he wouldn't even know to own up to it.

0

u/[deleted] Jul 26 '16

[deleted]

13

u/randomguy186 Jul 26 '16

Spot on. It's why I believe that it's necessary to actually reward people for acknowledging mistakes.

4

u/foobar5678 Jul 27 '16

The company needs to foster an environment where people are willing to admit their mistakes. You can have "honest folk" who are willing to admit and own up to their mistakes, but when the boss berates you and humiliates you every time, those "honest folk" are going to be reluctant to come forward next time.

Point is, it has nothing to do with honesty. If the company has a toxic environment where people aren't willing to admit their mistakes, then the blame lies on the company. It doesn't mean the employees are dishonest.

5

u/jonjonbee Jul 27 '16

If the company has a toxic environment where people aren't willing to admit their mistakes, then the blame lies on the company. It doesn't mean the employees are dishonest.

This, multiple times this. I got into the mistake-coverup mindset at my last employer because they worked on fixed cost/fixed time contracts and thus anything that required additional work (mistakes, refactoring) was seen as waste. (Unsurprisingly, most of the devs were the lowest common denominator and the codebases were utter shit.) My current employer is a big corporate but the dev environment is a lot friendlier; mistakes are accepted as part of the development cycle and aren't frowned upon unless they remain uncorrected.

→ More replies (1)

6

u/toomanybeersies Jul 26 '16

You would think that once you realised what was going on, you would start taking a fireaxe to the servers if need be in order to get it to stop.

1

u/jonjonbee Jul 27 '16

The problem was that they didn't realise what was going on until far too late.

1

u/wanderingbilby Jul 26 '16

A disadvantage to "the cloud". No way to just pull the damned plug, already.

6

u/never_safe_for_life Jul 26 '16

I run 60 servers in EC2 and can send any number of shutdown signals to them in one command: stop the process, shut down the box, kill the virtual machine entirely.

3

u/Decyde Jul 26 '16

My friend works as an admin at a place during the night shift. The place works from 9-5 normally with 2 techs.

They require a person to be there around the clock in the event something happens one day so something like this does not happen.

He said the most he does is pull cable or rerun some things a couple hours a week. Other than that, he just brings things to do and gets on Reddit all night.

2

u/Gotebe Jul 27 '16

It's all about where the margins are going :-)

89

u/kairos Jul 26 '16

I'd put the emphasis on the Dev part... It seems wrong to me that they'd repurpose a flag from code which hasn't been used in ~8 years for something not related to its intended use.

65

u/notafuckingcakewalk Jul 26 '16

Yeah, as soon as I read "repurposed a flag" all kinds of warning bells went off. You want it to be really really difficult for people to accidentally do something they don't mean to do.

If you're replacing x with y and x and y are very different things, a good way to avoid problems is to have y demand very different input from x.

Like, if for some reason you decided your new variant of Linux is going to have a "new" command, completelypulverize (or cp for short — the normal cp will be replaced with a new copy command) that deletes and then zeroes out a file, you'd better make sure it doesn't allow any input that's accepted by the familiar cp command. So anything in the format cp oldfile newfile should break, hard.

21

u/liveoneggs Jul 26 '16

I'm pretty sure this is how systemd works

6

u/jonjonbee Jul 27 '16

systemd works

That's funny.

59

u/tankfox Jul 26 '16

I love how similar Power Peg is to Powder Keg

13

u/marvin02 Jul 26 '16

Wow. Until I read this comment, I thought they actually called it "Powder Keg". How could you know that code was so dangerous that you actually named it Powder Keg but then not be more careful with it?!>?

→ More replies (1)

36

u/Chandon Jul 26 '16

When you're packing bits for performance, repurposing flags is a pretty likely outcome.

The real problem is having code that understands the old meaning of the flag anywhere near production when you start to deploy the new version. This is a "remove old code, replace with version that aborts if the flag is set, test the abort, wait a month and several versions, then deploy new meaning for flag" sort of situation.

14

u/Dr_Legacy Jul 26 '16

" ... replace with version that aborts if the flag is set, test the abort, wait a month and several versions"

Simple best practice policy. Often you don't even need to abort; just log the problem and carry on.

26

u/immerc Jul 26 '16 edited Jul 26 '16

There are so damn many things they did wrong:

  • Alerting via emails

  • Repurposing a flag

  • Not purging dead code from the source control system

  • No kill switch, either in the software or something in front of it

  • Manual upgrades to a production system

  • Upgrading servers in a unknown state rather than wiping them and starting from a known good clean install

  • No incremental rollout / AB testing / canarying

  • No dark / simulated launch

  • Using shitty names like "Power Peg"

Edit: another one

  • No algorithmic cut off, i.e. something that watches trading traffic and automatically pulls the plug / engages the brake and sounds an alarm (not via email) when the volume or other characteristics are far different than normal

8

u/Fhajad Jul 26 '16

Alerting via emails

What methods are better than e-mails?

15

u/elHuron Jul 27 '16

text, phone call, dashboards, a literal klaxon

9

u/RICHUNCLEPENNYBAGS Jul 27 '16

I'm guessing these guys have thousands of meaningless alerts a day, so that'd have to be fixed first.

→ More replies (5)

2

u/immerc Jul 27 '16

When hundreds of millions of dollars are at stake, all those at the same time.

→ More replies (6)
→ More replies (4)

1

u/keef_hernandez Jul 26 '16

The linked article indicates that they did in fact do a partial rollout.

2

u/immerc Jul 27 '16

A partial rollout only counts when every system you're using is identical. When you're hand-installing things onto systems that haven't been wiped, you can't guarantee that.

6

u/zanidor Jul 26 '16

From a DevOps perspective, you have to assume some dev mistakes can make it to the production pipeline, and you need to have procedures to mitigate. That's a huge part of the DevOps job description.

The developers made a boneheaded mistake, and the DevOps people had systemic failures that let the mistake do maximal damage. Not sure it's right to emphasize either party, but I would say the DevOps mistake was much larger in scope -- their entire system was broken.

9

u/ismtrn Jul 26 '16

This is HFT. They rent servers in specific locations because they have lower latency to the exchange. They can't just keep adding bits to their message format.

2

u/[deleted] Jul 27 '16 edited Jul 27 '16

They own the servers, and the racks (depending on which of the three facilities), and they just rent the space (sorry for being pedantic). Not sure on the adding another bit bit. Depends on how many flag bytes they had to spare. Clearly they thought they were being economical by reusing one they believed was fully dead.

This system was routing retail orders, so depending on how much load it was carrying for other Knight strategies an extra 8 bit flag flag field probably wouldn't have killed them.

124

u/JessieArr Jul 26 '16

46

u/uep Jul 26 '16

If a larger firm had this kind of bug, wouldn't they just roll back the transactions? I know erroneous trades have been rolled back in the past.

Actually, in searching for a link, the one I found above is perfect. It specifically discusses Knight capital and how questionable selective rollbacks are.

57

u/JessieArr Jul 26 '16

I'm sure it's very tricky. No firm would bother to report a computer trading error if it made good trades on their behalf. So they will only request that the transactions be rolled back in the event of bad/illegal trades being made. And being able to undo bad trades after the fact is the most exploitable ability you could have in the stock market.

8

u/immibis Jul 26 '16

It's not really relevant to KCG, but this reminds me of the recent Ethereum rollback.

13

u/[deleted] Jul 26 '16

Well, Knight was a pretty substantially sized firm to begin with. The problem here unfortunately wasn't as easy as traditional clearly erroneous trades. When these orders made it down to market they were marketable, executable, and in terms of price bands on the market totally within bounds. Typical CEEs are in a single instrument and often represent a horribly mispriced order, and the subsequent market impact (people trading at that level assuming they missed a news event). It's very easy to say "These trades at 10% away from the last 'sane' price, and shall be undone".

With Knight though these were a high number of trades, in a range of instruments, priced at normal levels. Counterparties would have not questioned the transactions at all, and would have moved on to commit capital or shares elsewhere. It would have kneecapped the market while people tried to figure out what in the hell was going on.

On a more "administrative" basis, the exchange did not have the authority to issue CEEs because the trades did not meet their rulebook criteria. They would have had to reach out for voluntary busts to every single counterparty (a not insignificant task), and the counterparties would have been under no obligation to accept.

→ More replies (2)

20

u/short_vix Jul 26 '16

Not sure why this isn't upvoted more, this is the most accurate analysis next to the official report https://www.sec.gov/litigation/admin/2013/34-70694.pdf

8

u/RyanSmith Jul 26 '16

The best part is the fine: $12m, despite the resulting audit also revealing that the system was systematically sending naked shorts.

→ More replies (2)

16

u/curious_skeptic Jul 26 '16

I remember almost buying a few hundred shares of their stock in the days leading up to this. phew

5

u/foobar5678 Jul 27 '16

They got $400 million in investment the next day and were later purchased by a larger trading company. I'm sure the stock has bounced back by now.

8

u/curious_skeptic Jul 27 '16

No, they dropped from $10 to $3-4, and never really recovered before being bought out for not much more.

27

u/[deleted] Jul 26 '16

(BTW – if there is an SEC filing about your deployment something may have gone terribly wrong).

That is a fair point.

7

u/[deleted] Jul 26 '16

My worst nightmare....

69

u/WhisperSecurity Jul 26 '16

The code that that was updated repurposed an old flag

What?

Do not do this. Never do this.

Never, never, never, never allow any variable in code, message field, or protocol flag to have more than one meaning. Never.

3

u/IcarusByNight Jul 27 '16

Dude this is HFT where optimization of message format is critical to being faster than your competitors...

1

u/[deleted] Jul 27 '16

Yes and no. It depends on how much system overlap there was at Knight. The orders that kicked this whole fiasco off were retail orders, so by their very nature they were significantly less time sensitive than what most people would consider to be a HFT strategy (never mind that it was 212 orders, so hardly high frequency).

0

u/[deleted] Jul 26 '16

[deleted]

8

u/WhisperSecurity Jul 26 '16

Well, they sure went broke fast.

0

u/[deleted] Jul 26 '16

[deleted]

23

u/ismtrn Jul 26 '16

There is a huge difference between having bloat, in the form of dead code, in the code which runs on your servers and bloat in the messages you pass between servers. Only one of those makes the system slower.

3

u/[deleted] Jul 26 '16 edited Jul 26 '16

If they decided to repurpose it, wouldn't that mean it was being passed along all those years? The performance race is kind of already lost here.

Foresight is 20:20, but with stuff like this it's better to sacrifice performance if it can result in this kind of a catastrophe.

12

u/ismtrn Jul 26 '16

I obviously don't know the technical details, but I imagine they had a fixed length, say 8 bit, field containing configuration flags. If all the flags have been used their choice is to increase the size of the data format by adding an extra byte, slowing the system down and costing profit, or repurposed one of the old unused flags provided there was one.

→ More replies (5)
→ More replies (2)

7

u/[deleted] Jul 26 '16

I like the DevOps culture, hell it's part of my title, but I don't see how this is a "DevOps cautionary tale". Basic Software Development and ITIL practices would've prevented this from happening.

13

u/[deleted] Jul 26 '16

I once was deployed to a foreign office for a remote deployment that sucked ass. After 17 hours I was asked to patch some web.configs with some new handlers. I messed that up and we were loosing $20K an hour. Someone figured out I fucked up after 2 hours.

Never again will I work those hours. As a comparison I recently got a loan for a house of $60k which I will pay in 30 years.

8

u/merreborn Jul 26 '16

Never again will I work those hours.

Yes, I always push hard to avoid long hours or off-hours work. We need to be working at peak alertness; the increased error-rate of off-hours work is too risky.

→ More replies (4)

17

u/[deleted] Jul 26 '16

One day I will talk of my front row seat to a server crash that cost a company $300,000,000

6

u/Blimey85 Jul 27 '16

For the love of God don't just tease us!

3

u/[deleted] Jul 27 '16

Haha I would love to, but it's too soon. I don't think I can get into this story for another year or two, sadly. I can't wait to post it though. As it was going on I was thinking of this sub. There are a lot of details of incompetency across the board that this sub would enjoy.

→ More replies (1)

5

u/mrdotkom Jul 26 '16

Knight capital is still around. I work with them occasionally

1

u/jonjonbee Jul 27 '16

Are they still run by incompetents?

9

u/DJDavio Jul 26 '16

Does anyone know why they spell out seven as well as using the digit?

The seven (7) servers

16

u/Kapow751 Jul 26 '16 edited Jul 26 '16

It's used in legal/formal documents to make any alterations or errors more apparent. It's generally much harder to tell from context if a number is wrong, and much easier to alter it, as opposed to a word or phrase.

Not sure why it's used in this article, but that's where the convention originated. Some people seem to think it looks fancier or more authoritative or something.

7

u/isorfir Jul 26 '16

Just a guess here, but maybe it's due to the fact that it's more proper to spell out the number (if I remember my English classes correctly) but more difficult to compare a spelled out number versus a digit?

0

u/[deleted] Jul 27 '16

[deleted]

→ More replies (1)

4

u/tardyscholar Jul 26 '16

Probably for emphasis.

6

u/AlGoreBestGore Jul 26 '16

Should've done Se7en.

3

u/tardyscholar Jul 26 '16

Se7en ser7ers

4

u/llIIlIllIIllIIIllIIl Jul 26 '16

Manual file copies during a critical deployment?

They were asking for it.

6

u/LiberalSexist Jul 26 '16

Can someone explain why the company was not using continious deployment in the first place?

12

u/llIIlIllIIllIIIllIIl Jul 26 '16

There's nothing more reliable than the human touch of engineers while copying deployment artifacts manually.

4

u/LiberalSexist Jul 26 '16

I guess the senior programmer was more a fan of 'handmade' stuff.

2

u/[deleted] Jul 27 '16

Incompetence and resistance by those in control of the SDLC.

2

u/jonjonbee Jul 27 '16

This is the correct answer. Management will say "it works fine right now, we won't invest time and money in changing it", when it breaks they'll say "why didn't you take measures to prevent it from breaking?" The problem is never them, always the devs.

→ More replies (1)

1

u/nomercy400 Jul 27 '16

Maybe 2012 has something to do with it? Maybe it is too critical to automatically update your production servers as they could bring down your company? Maybe you are not allowed by the SEC? I wonder if continuous deployment would have caught the missing 8th server.

→ More replies (1)

3

u/ekobeko Jul 26 '16

Any more of these stories?

3

u/stmfreak Jul 27 '16

Automated deployment is no panacea. There are other stories of bad deployments rolling out automatically and tanking many, many, if not all clients.

Test your code better, folks.

4

u/LetMeClearYourThroat Jul 26 '16

Just a few months prior to OP's article a similar fortune-melting code debacle crippled another high volume trader here in Kansas City. It was in March 2012. I used to work with the CEO (Joe Ratterman) at an earlier position and got a pretty personal detail of the event through a mutual friend. It was absolutely brutal for them and he's still personally recovering financially and emotionally.

There are tons of articles but here's a couple that came up first:

http://www.bloomberg.com/news/articles/2012-03-23/bats-the-epic-fail-of-the-worst-ipo-ever

http://www.huffingtonpost.com/2012/03/25/joe-ratterman-bats-ceo_n_1378597.html

1

u/jonjonbee Jul 27 '16

That is some epic failure right there.

2

u/Dragonsoul Jul 26 '16

Okay, call me an idiot...but what stopped someone from just..idk? Unplugging the server/turning it off/cutting the internet supply? Fuck, if they knew where the servers were, just rip the wires out the back. You're losing millions a minute! You can buy a new server.

2

u/s1lv3rbug Jul 26 '16

correct, they should have called the data centre have that server unplugged ASAP or kill the n/w connection to it. I'm not sure why it took 45 mins.

2

u/Mr-Yellow Jul 27 '16

Probably fear that "being down costs us a lot and you lose your job"

2

u/[deleted] Jul 26 '16

Knight handled the hand-held computers traders used on the floor of the stock exchange. Always found them to be arrogant and rude and unprofessional. Not surprised, in my experience those attitudes trickle down from the top.

2

u/[deleted] Jul 27 '16

trading over 21 billion dollars…daily.

On July 31, 2012 Knight had approximately $365 million in cash and equivalents

And that's the real problem, not the DevOps failure. If you're involved in a high-risk, high-leverage operation like they are, any kind of hiccup can bankrupt your company.

2

u/[deleted] Jul 27 '16

Looks like they...

*puts on sunglasses*

...automated themselves out of business.

2

u/RedSpikeyThing Jul 27 '16

Good lord, so many things wrong here. This is literally the reason why you don't repurpose flags. The rollout procedure looks like a mess. No canaries? No dry runs? Surely you would run it with a version that logs what it would have done without actually doing it.

And then this gem

they were left trying to diagnose the issue

Well there's the last problem. Don't diagnose. Mitigate. When things are burning you make them stop burning and let the forensics team the over after. Shut off the power, pull the plugs, bang it with a hammer, whatever. All of that will cost less than $385 million.

4

u/PlNG Jul 26 '16 edited Jul 26 '16

Oh yeah, I remember this story.

Edit: that wasn't the link but I remember it being big news at the time.

1

u/merreborn Jul 26 '16

Looks like the SEC filing was dated October 16, 2013 -- so I'd wager the story initially broke somewhere around then.

2

u/elfdom Jul 26 '16 edited Jul 26 '16

8 years prior, a similar type of bug at a similar financial cost, resulted in the self-destruction of Ariane 5, Flight 501, 39s after launch.

In short, a "dead code" calculation resulted in an unchecked conversion from a 64-bit number into a 16-bit number. The overflow killed the guidance computers, including the backup, caused the onboard computer to mistakingly course-correct, and engage an automatic self-destruct.

Wiki: https://en.wikipedia.org/wiki/Cluster_(spacecraft)#Launch_failure

1

u/argv_minus_one Jul 26 '16

Good. If the rest of the HFT crooks could also go bankrupt, that'd be great.

1

u/[deleted] Jul 26 '16

Give the job to the lowest bidder.

1

u/dankwartrustow Jul 26 '16

Reminds me of an old client of mine migrating ERPs which had major EDI components (80% of their business). They were annoyed that purchasers would charge them $X,XXX fees in per EDI Test order, but the cost of not testing them and assuming the XML would take would be business-ending. Never did hear if they were successful or not.

1

u/s1lv3rbug Jul 26 '16

That is just terrible. The whole operations dept should be canned. There was just so many failures at all levels. Most importantly, if they are going live with such an important code upgrade, why not have someone be there in the data centre. They could have removed the touble machine immediately.

3

u/[deleted] Jul 27 '16

Why wasn't someone manually unplugging the servers within 5 minutes of market open?

1

u/HopeFox Jul 27 '16

Well, the physical servers were probably in a building right next to the stock exchange itself, and the company may not have been allowed into that building.

But "why weren't they on the phone to their agent in that building and telling him to unplug the server?" is a very good question. They should have had their agent's finger on the killswitch throughout the entire first day of deployment.

2

u/cparen Jul 27 '16

The whole operations dept should be canned

I wouldn't be so sure. The way I remember reading it was that the ops team objected to the change, but were forced by upper management. I can't find a source though, but my point is to caution against jumping to conclusions.

There was just so many failures at all levels.

Spot on about this once though.

1

u/mex1can Jul 27 '16

If it would be in my home country there would be a bunch if people of "unknown location" involved in the event.

Here? I'm expecting a movie to come in a few years.

1

u/jones77 Jul 27 '16

they reacted by uninstalling the new code

Instead of running ls -l on 8 machines.

1

u/cowardlydragon Jul 27 '16

Ah, yes, because having to dictate commands to admins and watch them fat fingering them is much safer...

Of course a good devops strategy should allow rollback...

1

u/1234567890123456789x Jul 27 '16

I suppose it's because I am still fairly new to programming but I am really impressed that 8 year old code, possible with new devs comming and going, was able to run and not crash. And communicate with whatever system is used for stock selling / buying with 8 year old api code.

1

u/gospelwut Jul 27 '16

Seriously. IDC if it's a shell/powershell script wrapping an ENV variable + rsync/robocopy; you need a process that isn't people manually copying code. Jenkins and Teamcity (limited) are free.

The problem with manual deployments isn't that scripted/automated ones don't fail; they do. They fail confusingly sometimes. But they are (hopefully) consistent and can be audited. You also want to recover faster from a failure during those "45 minutes of hell" when your fight-or-flight instincts are going to 11.

I also concur with peoples' notions of a ripcord for Ops.

1

u/Jonathon662 Jul 27 '16

I knew it was about this before I even clicked it... I lost quite a bit of money on this stock!

1

u/SpaceToaster Jul 27 '16

Later today at 4-8

1

u/ajd187 Jul 26 '16

I would be curious to see if anyone who decided it was a good idea to leave 8 year old code running in a system that handled high speed trading and moved billions of dollars was fired. I would hope so. That's the definition of "stupid".

7

u/Dr_Legacy Jul 26 '16

In high-volume, big-money applications, there's a strong motivation to change as little as possible with each update.

But as shown in this story, there is hell to pay when that technical debt catches up.

1

u/IronWolve Jul 26 '16

As an Ops guy, a detailed nagios alarming system that shows 8 actual servers in a group, test harness alarms on transactions, transaction queue too high/low alarms, and failed processing, has helped me run telecom services that have tens of thousands of transactions a sec during commute hours, and pinpoint issues asap. And hit the stop button if needed.

-18

u/BigPeteB Jul 26 '16

/r/devops is that way.

From the sidebar: "Just because it has a computer in it doesn't make it programming. If there is no code in your link, it probably doesn't belong here."

16

u/dsn0wman Jul 26 '16

The main issue here is developers not cleaning up old code, and not developing automated deployment methods.

13

u/awj Jul 26 '16

...and reusing a feature flag. If you want to make a list of "simple things that can royally screw you over", that should definitely go on it.

13

u/[deleted] Jul 26 '16

[removed] — view removed comment

2

u/HandshakeOfCO Jul 26 '16

Yeah, I'm sure all the developers on that doomed team were saying "hey this code is totally well maintained! We don't need any time for a refactor!"

This is kinda like blaming the guys who built the bridge when it collapses, due to neglect, 200 years later. "Well they should have engineered it better!" Um no.

-3

u/[deleted] Jul 26 '16

They should have used ethereum!

-2

u/remimorin Jul 26 '16

I'm always surprised that this don't happen more often at smaller scales, probably it does but CIE are able to cover up.
In big CIE softwares "priority and maintenance" are guided by budget, by business goal, by CEO vision etc. What developpers think of it is not very important. That why the biggest corporation have the biggest technological dept.
That's why you have deprecated technologies running deprecated dirty code maintained by... not my kind of devs.
They see the upgrade/refactor as a risk (and it is) but don't see the weight of the latent risk raising over their heads.
Many of these system are huge only to deal with the said depts. They build bridges applications around them, maintenance script, emergency procedure, man-made data fix, etc. But the whole system is actually quite simple if rewritten from scratch using modern technology. Instead of night batch, flat-files-as-transaction-queues, record fixing script, bridge application, you can have a real time server, replicated, scalable, cloudable, with 10% of the code. With 100 times mores qualified dev on the market (and available for more than 10 years). Better tools, better machines (that big machine the size of 10 home frigo can be emulated on this 200$ desktop linux...)
This is kind of sad.

18

u/[deleted] Jul 26 '16

The cost of rewriting a huge codebase from scratch is quite large, and is a very difficult and risky process. Many such efforts have failed. I don't think the solution to the issue is nearly as clean as you make it out to be.

4

u/[deleted] Jul 26 '16

Agreed, full rewrites are often wishful thinking in my opinion. I think it's a way of avoiding the actual problem, why the codebase got to this point in the first place. The key take away I think is that we should see codebases as living, evolving entities that should be maintained, and improved over time. That means tracking, quantifying and addressing technical debt. With that said, the best course of action in dealing with a large nasty legacy codebase is to try and decouple/replace 1 piece at a time.

4

u/dccorona Jul 26 '16

This is one of the great advantages of service-oriented architectures...you can ground-up rewrite individual components far more easily. Though perhaps the latency demands of HFT systems are incompatible with such a network-heavy system architecture.

→ More replies (3)
→ More replies (1)