Live data from Hacker News

Times I've Messed Up as a Developer

medium.com

21–30 of 137 posts

Re: Times I've Messed Up as a Developer

#21
At my first job, guy in my group once su'd to system user that ran our infrastructure; and typed, cd && rm -rf * and went home.

I was sitting at my desk watching service after service slowly disappear in utter confusion, then hours spent cleaning...

Re: Times I've Messed Up as a Developer

#22
post #12
post #7

I was on my way out the door at my first job, and an SEO person stopped me and asked me if I could fix something. I just needed to delete a single row from a database. Easy enough. I get as far as “DELETE FROM table_name” and for some unknown reason run the damn thing without a WHERE. All the rows, gone! We did have nightly backups but the guy with access to them was notoriously hard to get the attention of and lived…

Always write DELETEs as SELECTs, and once you run the SELECT and it returns the rows you want, then swap out the SELECT * with a DELETE.

Also, open a transaction first.

Re: Times I've Messed Up as a Developer

#23
post #12
post #7

I was on my way out the door at my first job, and an SEO person stopped me and asked me if I could fix something. I just needed to delete a single row from a database. Easy enough. I get as far as “DELETE FROM table_name” and for some unknown reason run the damn thing without a WHERE. All the rows, gone! We did have nightly backups but the guy with access to them was notoriously hard to get the attention of and lived…

Always write DELETEs as SELECTs, and once you run the SELECT and it returns the rows you want, then swap out the SELECT * with a DELETE.

That works halfway for UPDATE statements as well. At the very least you can see which rows you’ll be updating.

Another tip is to write the WHERE clause and SET clause prior to filling in which table is being updated. That way you can’t accidentally run something prematurely.

Re: Times I've Messed Up as a Developer

#24
post #6
post #3

I've seen a DBA drop a production table as well, fortunately it was a small in memory table for non persisting data that could be quickly repopulated. Still lead to about 5 mins of downtime. I always have two terminals open, both running tmux. One is white text on black for dev work, the other is white text on red. I only ever ssh into production servers on the white on red terminal so there's a strong visual signal…

I used to do the same thing with RDPs to windows production servers. I'd set up a different colored color scheme on each computer, with prod being bright red :)

For Windows work, I made sure to have one regular user and one admin user. And set the desktop background of the admin user to red. An additional benefit is that the garish background is uncomfortable to work with, and so discourages being logged in as admin all the time...

Re: Times I've Messed Up as a Developer

#25
Not quite so disastrous, but still pretty dumb.

I was logged in over VPN to a client machine. I suspected the problem I was fixing was something to do with the network misbehaving. It was a Windows machine.

I thought "I know: I'll disable and reenable the network device!".

A few moments later: "Oh. Bugger.".

Shortly followed by an embarrassing call to the client's IT department to ask them to reenable the network device on that machine...

Re: Times I've Messed Up as a Developer

#26
post #12
post #7

I was on my way out the door at my first job, and an SEO person stopped me and asked me if I could fix something. I just needed to delete a single row from a database. Easy enough. I get as far as “DELETE FROM table_name” and for some unknown reason run the damn thing without a WHERE. All the rows, gone! We did have nightly backups but the guy with access to them was notoriously hard to get the attention of and lived…

Always write DELETEs as SELECTs, and once you run the SELECT and it returns the rows you want, then swap out the SELECT * with a DELETE.

Unless, like me, you then highlight the statement without the WHERE clause and run it, realizing your mistake a split second before you hear the key click...

Re: Times I've Messed Up as a Developer

#27
Our 3-year-old production server hard drive, containing all assets and a database for multiple customers, died. No backups. For a few hours I was picturing not only the anger of our customers, but the demise of the whole company. Luckily the other drive in the RAID was OK and we didn't lose any data.

Probably one of the stupidest, but also the most personally effective way to learn anything.

Re: Times I've Messed Up as a Developer

#29
After some bloopers early on in my career I developed a systematic "back it up" reflex if there's even the remotest chance of something being lost/broken. This has saved my bacon on countless of occasions... normally from problems I least expected.

Re: Times I've Messed Up as a Developer

#30
post #7

I was on my way out the door at my first job, and an SEO person stopped me and asked me if I could fix something. I just needed to delete a single row from a database. Easy enough. I get as far as “DELETE FROM table_name” and for some unknown reason run the damn thing without a WHERE. All the rows, gone! We did have nightly backups but the guy with access to them was notoriously hard to get the attention of and lived…

This 'default' behaviour strikes me as one of SQL's worst faults.

If you want to delete all rows, you should be made to explicitly type out that intention.

Post reply on HN