Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Similar to the question I read on Server Fault, what is the biggest mistake you've ever made in an IT related position. Some examples from friends:

I needed to do some work on a production site so I decided to copy over the live database to the beta site. Pretty standard, but when I went to the beta site it was still pulling out-of-date info. OOPS! I had copied the beta database over to the live site! Thank god for backups.

And for me, I created a form for an event that was to be held during a specific time range. Participants would fill out the form for a chance to win, and we would send the event organizers a CSV from the database. I went into the database, and found ONLY 1 ENTRY, MINE. Upon investigating, it appears as though I forgot an auto increment key, and because of the server setup there was no way to recover the lost data.

I am aware this question is similar to ones on Stack Overflow but the ones I found seemed to receive generic answers instead of actual stories :)

What is the biggest coding error/mistake ever…

share|improve this question

closed as not constructive by ChrisF Nov 15 '11 at 15:02

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

5  
guinness questions! –  Junior Mayhé Oct 25 '10 at 0:03

37 Answers 37

up vote 52 down vote accepted

Issuing a SQL UPDATE with a 'bad' WHERE Clause that matched everything.

Lesson Learned: Always issue a SELECT first to see what will be changed.

share|improve this answer
15  
Or set autocommit to false so you can see how many rows would be affected. –  Yevgeniy Brikman Oct 25 '10 at 5:09
2  
Oh, I've done that. Very nasty... –  glenatron Oct 25 '10 at 11:15
4  
Haha I think everyone with some SQL under their belt has done this at some time, me included –  billy.bob Oct 25 '10 at 11:55
3  
Which is why updates should be done on dev first! No hot fixes directly to prod. And be very grateful for audit tables if you have them when you do this. –  HLGEM Oct 25 '10 at 15:05
13  
I did that once to reset someone's password. After I set everyone's password to the same thing, I simply told my boss that tech support would be getting a lot of phone calls and that we should tell the caller we had to change their password for security reasons. –  Barry Brown Oct 25 '10 at 16:35

While working on designing a new website for a collegiate entity, I accidentally deleted the entire code base. There was no version control. Luckily, they took nightly backups so one quick email to the IT guys and 5 minutes later I was back in business, recovering maybe 25 minutes of lost work. Thank god it happened first thing in the morning and not right before I left...

share|improve this answer

Typo's

Spent three solid days on this chunk:

if($func == "remove")
{
    $p->comments[$index]->removed = true;
    $p->save();
}
else if($func == "approve");
{
    $p->comments[$index]->approved = true;
    $p->comments[$index]->removed = false;
    $p->save();
}

See the error? It's the semicolon at the end of the else if. I couldn't figure out why my removed comments weren't removing. Dug into the database, the AJAX request I was using, POST variables, had error_log's and alerts everywhere. Ended up re-writing the method and it worked. Then I did a diff with the original version and noticed the semicolon.

Typo's are the hardest to track down on a language that isn't compiled or pre-checked by something. Even errors like this would be difficult on a compiled language. Change a == to = and suddenly you have assignment inside an if.

share|improve this answer
8  
Here is where tools like Resharper can really pay back for themselves - it would have highlighted this as a warning and prompted you to remove it. –  Yaakov Ellis Oct 25 '10 at 7:57
23  
Is the title an (intended) pun? :o –  Agos Oct 25 '10 at 9:32
3  
@Rogue Coder: the difference between single and double quotes is vanishingly small. It's a misuse of time to spend brain cycles worrying about it. See the test at the bottom of phpbench.com –  Joeri Sebrechts Oct 25 '10 at 9:54
2  
@back2dos: Errr... right. So you recommend dropping all those mentioned languages in favor of haXe? Something that first appeared in 2005? Go right ahead with that. –  Josh K Oct 25 '10 at 15:06
10  
Thank you for the argument in favor of the One True Brace Style. +1 –  eswald Oct 25 '10 at 17:33

Several years ago in the army, I was in Company C (leaving out my full unit name so as not to embarrass them). Company B with about 30 soldiers had just spent the past month entering data on soldiers into a new system manually. I then accidentally deleted the DB and it was not recoverable and they had failed to make a backup the entire month (so partially their fault). But these 30 soldiers had to spend the next month repeating doing the same thing they had just done the previous month. They were not happy soldiers. I had to be careful where I went over the next few weeks as these other soldiers were ready to declare war on one of their own!

share|improve this answer

Argh, 11pm, lab shutting, quick, quick...

$ enscript -o midterm.hs midterm.hs
$ submit midterm.hs
Error: submission is empty

God no! FFS. I meant PS you ****!

share|improve this answer

This wasn't an error by me but by a coworker. He was programming on a remote server on a piece of code that wasn't under revision yet. He wrote around 600-800 lines of code in that day... He was programming in Vim or Emacs.

When he finished his work, he accidentally erased the content of the file and saved and exited the editor.

We got lucky and our sysadmin made a dump of the hardrive to recover saved data before that space get reused by an other program. Luckily he did save that file periodically and that means data was on the hardrive but not associated to the file.

share|improve this answer

I was working for a company who handles one of Sweden's biggest telecom companies customer support. On our server we had some software that regulated the incoming call queue, how many calls we could take and so forth. If it wasn't working we weren't getting any calls and customers weren't getting any support.

Aaaaanyway, I did a (minor) change to the software. I could have waited for a service window to change it but I thought "Hey, it's going to take one minute to restart the service, why bother. Fortune favors the bold". So I restarted it, unfortunately the thread was locked so I couldnt replace it. Starting to panick I decide to quickly reboot the machine (I was remoting in). Unfortunately in my panic I click "install updates and shutdown" instead :P

Needless to say there wasn't much customer support in Sweden to be had for the next half hour before we managed to restart it.

A colleague was worse then me though, he we debugging the automated voice response system one night and rerouted the number to his mobile. Only thing he forgot to switch it back, had the day off the next day and left his mobile at work. We we're wondering why it was ringing constantly that day :)

share|improve this answer

Was attempting to do a quick'n'dirty backup of a Solaris box and inadvertently replaced every file in the file system with a compressed version of itself. Solaris really hates you doing that in places like /etc!

This was actually part of a nightmare week for me - I blogged it a while ago - http://blog.superpat.com/2006/02/09/best-week-worst-week/

share|improve this answer

We were working around a problem in flagging exceptions in an ETL process. The solution I proposed was an ugly hack where we would delete a row from table A when that data was written to table B, where the exceptions would be logged. The code I wrote deleted everything from table A when a single row was added to table B. That resulted all data before the first exception being deleted on load.

It went into production. It ran for two weeks before someone caught the bug.

Doh!

share|improve this answer

We built an admin section on to a web application that shared messages between remote offices and the organization as a whole. Occasionally remote offices need to be shut down, or moved, renamed, etc. So we provided the standard CRUD operations for the list of offices. Sounds good so far, right?

When the application was going for acceptance testing in our client's staging area, our client started working with the admin section. They decided to remove one of the larger remote offices like "Paris" and the application started taking a looong time to respond. The client then attempted to readd the major office, and suddenly all the messages were no longer to be found.

The problem? We had cascading deletes turned on and thousands of important messages were suddenly gone forever! Well, we did have a backup, but had this gone into production it would have been a real embarrassment for both us and the client.

Back to the drawing board, and we basically had to build some protections to move the messages over to a new remote office or hold them in a temporary bin until they could figure out where to put them.

share|improve this answer

Accidentally deleted the database that stored all our customer info, order history and invoices going back to the start of the company (several years worth).

To be fair, my employer has to share some of the blame though. They had the only copy of that database stored on the Mac SE (yes this was a long time ago) that they gave me (a brand new employee, first job out of college) as my workstation and had never even considered making a backup.

So, thinking it was a copy of the DB I dragged it to the trash can. Because of the size of the file it deleted it immediately. We eventually got it back after paying an ungodly amount to a data restoration service, but for about 5 days we couldn't fulfill or bill any orders, and had no way to access information about any customer. It pretty much brought the (3 person company) to a standstill.

share|improve this answer
15  
Ouch. Note to self: Always take a backup: even if there is already supposed to be a backup. –  Kramii Oct 25 '10 at 10:58
1  
@Karmii: Best advice, hands down. –  Chris Oct 25 '10 at 14:18
3  
There was enough blame to go around. I was just a kid back then and probably more naive than I would be today about assuming that a real company would do anything so silly as putting the only copy of the DB on my desktop. Experience has shown me that it is foolish to overestimate my employer's preparedness, even at a big company. –  JohnFx Jan 14 '11 at 23:34

Thinking that programming is mostly about building cool new stuff from scratch.

share|improve this answer
1  
When I first started I too had this thought. Then I learnt there is far more maintenance of other peoples than anything. That's why I try now to write the best code (with comments) that I can. –  fortheworld Feb 11 '11 at 4:50
1  
There's still plenty of new code to write. A lot of open source projects require coding from scratch that implements the same functionality as a closed system. –  PP. Feb 11 '11 at 8:31

Using == instead of equals for string comparison in Java

share|improve this answer
11  
That is the biggest mistake you have ever made? –  Chris Oct 25 '10 at 14:19
2  
@Tim: that still doesn't answer how this was "the biggest mistake you've ever made"... Some more context about the consequences at least would be nice... –  Dean Harding Oct 26 '10 at 5:28

The biggest mistake I ever made was not having my work in source control off of my development machine. My hard drive crashed and I lost weeks of work. It's a lesson hard-learned and something I'll never let happen again.

share|improve this answer

Drop a production database by accident instead of a development version. I didn't see what server I was working. Fortunately, the last backup was produced 4 hour ago and the user didn't made a lot of changes on the system, so no big data loss.

share|improve this answer

At an internship, I was just learning SQL, performed an update without a where, affecting 17k+ rows instead of 10. Good news was that it was only the dev database. Bad news was that it couldn't be rolled back without the testers losing a lot of work, and a coworker was stuck fixing it for the rest of the day. I felt pretty bad.

share|improve this answer

My biggest mistake was to think that programming is easy money...

share|improve this answer
25  
If you got into programming for the money, you should get a new career. Not that the money isn't there, it is, but you need the obsessive love for programming that true developers have, or you will burn out very quickly –  johnc Oct 26 '10 at 0:02
1  
You made a good point. I really did not get into programming for the money, but I really thought that it would be a lot more easy to live from it. Programming is my passion and I would do that even if I have to pay for. –  Marcelo de Aguiar Oct 26 '10 at 16:42
4  
@johnc same would go for most professions. I honestly don't understand people who go to university to "learn programming". I started when I was 14 with K&R. I went to university to "learn electronics" - but guess what, I ended up as a programmer anyway. The very best musicians taught themselves. The very best programmers taught themselves. That's life. –  PP. Feb 11 '11 at 8:30

Definitely TSQL mishap - too many TSQL statements in one editor window. Was a bit tired, and people were interrupting me left and right, and I issued a command that updated 47,000 records address, city, state, and zip - oops. Had it fixed in about 25 minutes, though.

share|improve this answer

I wanted to create metadata files for each file in a directory (i.e. for every file somedir/foo.bin, I'd want to create a file somedir/foo.bin.meta). For some stupid reason I decided to create the files by opening and closing a file stream via Python:

for fn in os.listdir(path):
    open(os.path.join(path, fn), 'w').close()

For some even stupider reason I thought it was clever to test this script against a directory on my harddrive with several gigs of personal data on it. Only after running it I realized that I had forgot to actually modify the filename prior to passing it to open and that I had just truncated every single file in that directory (ouch).

Luckily that was on a personal computer and didn't cause any damage to anything important, but I still learned my lesson.

share|improve this answer

For a robot I work on, we keep a log file of every run. We have the robot and a simulator, both which generate these log folders. The simulator's log files are useless, but the robots log files are very useful and are stored forever.

Because the robot itself has limited hard drive space, they're transferred to another computer and stored there. This computer happens to be the main operating computer for communicating with the robot.

Well, I had just started working on the robot a couple months earlier and didn't know this. I thought the logs on the operating computer were the useless ones generated by the simulator and deleted them. We lost all of the old logs because there wasn't a proper backup.

share|improve this answer
8  
Damn... I want to work on robots! All I do all day is build lousy web sites. –  Dan Ray Oct 26 '10 at 12:14

On a manager's request, I copied /etc/sudoers from one machine to another (even though it wouldn't have fixed the problem at hand, but that's beside the point). Unfortunately, I used sudo to move the copied file into place, without noticing that its owner and permissions were completely wrong. At that point, nobody had a root shell open, nobody could sudo, and nobody could log in as root because its shell was set to /bin/false. And the machine was in a remote data warehouse...

share|improve this answer

I crashed a 100 000$ laser scanner.

The controller was storing positions as integer so I divided everything by 10000 to get the actual position in inches.

When the last digit was a 0, it was omitted so the Z axis was 10 times to far.

Hillarity ensued

share|improve this answer

I've done this:

rm -rf /bin

(Actually, I didn't do exactly that. That would be dumb and inexcusable. I did it in a more subtle, roundabout way that resulted in essentially that command being executed.)

Needless to say, the Unix system was unusable after that point and had to be re-installed. I was a beginning sysadmin at the time and the senior guy overseeing me was understanding.

Some good came of the experience. I learned how to list directories without having any of the /bin commands to use.

echo *
share|improve this answer
9  
+1 for the echo trick –  l0b0 Jan 14 '11 at 9:07

This happened to a colleague this month.

He was fixing a bug that occurred when you send an SMS to a lot of cellphones. Usually these messages won't actually be sent to save on costs but due to a misconfiguration in our database they did get sent.

Cost: one months wage of SMS traffic.

share|improve this answer

I made a site templating language, in an early version of which all HTTP parameters were implicitly expanded as variables. This meant that you could write a URL like:

page.vis?body=<body><p>Oh dear</p></body>

And it would do exactly what it looks like it does.

Luckily I have no users (sigh), so I guess it wasn't too much of a security risk.

share|improve this answer

"We need to do a rewrite."

On the otherhand, it was a five year old VB6 app.

share|improve this answer

The customer wants a mailout to their entire userbase that will basically send a personalised email about an event and when they click on a link in the email will automatically log them in to a form with half their data filled in.

I write the code, test the code, it works fine, the links work, it's pretty smooth. Having checked and double checked everything, I switch over to the live list and away we go.

The live list is significantly bigger than my sample data and the mail server falls over. I have to stop my console app, then realise I'll have to restart it from where it stopped. Fortunately this feature is not too hard to add and I have logged what users the mailout has already gone to, so having got the mailserver up and running again, and reconfigured the code to be able to restart from the point it failed previously and to pause to let the mailserver catch up, away we go.

Unfortunately I had somehow managed to not get all my code updating right. I don't remember the details of what I did, but the query to get the user data was getting one set of data, the query to generate the hash was getting another, so if a user clicked on the link they would get to a form that contained someone else's personal data from their account details. And this in a niche industry where there were lots of competetive small businesses on the list.

It didn't take long for the phone to start ringing at the customers' office...

That was the only mistake so far that has lead to me offering my resignation.

share|improve this answer

So far my only stomach-twisting, heart-rate-increasing, suddenly-get-hot-and-itchy mistake was running an UPDATE query without a WHERE clause. Luckily there was a backup from the last 15 minutes and the data didn't change very often which meant I was able to fully restore the data within 10 minutes without anybody knowing.

Nothing too bad but I've had some close calls. They are and remain close calls because I've heard enough horror stories in this industry that everything I do that could screw things up gets a good going over.

share|improve this answer
1  
Don't you guys making DB mistakes ever call rollback? –  Xepoch Oct 25 '10 at 23:02
1  
@Chad, should we generally not assume all data calls should be implicitly transactional? –  Xepoch Jan 13 '11 at 20:29
2  
@Xepoch, never assume. –  CaffGeek Jan 13 '11 at 20:56
1  
@Char, I have a personal preference for maintaining all DB interactions within transactions. Those who don't, they carry risk or have business cases which don't care. The specification assumption and MANDATEs are that we will begin and maintain code projects with transactional DB management. –  Xepoch Jan 13 '11 at 23:31

I was running Xenu's link sleuth on our intranet to try and clear up some of the many broken links that have built up over the years (most, unsurprisingly enough were links from the wiki to the shared network drive).

After about 30 minutes I started noticing some of the new items had some odd pictures, it looked like people had used some of the grainy old stock photos that were on the system but I ignored that thinking that maybe there just wasn't anything newer that had what they wanted.

Another 10 minutes later I noticed the featured items were changing randomly for some reason. At this point it dawned on me what was happening. The intranet uses windows authentication and some of the functions (such as selecting news images and featured items) were coded to response to HTTP GET requests. The link checker had been using my authentication and had crawled to pages on the admin side, loyally doing its job and following everylink it found including ones like

/admin/displayItems/icon_update.asp?image=eastereggs.jpg&itemID=3174

share|improve this answer
7  
This seems to be how a lot of people learn when it's appropriate to use GET and when it's appropriate to use POST –  Oli Oct 25 '10 at 12:08
1  
not really your mistake, but a good story nonetheless :-) –  Dean Harding Oct 26 '10 at 5:30

Seven years ago my boss & company owner, whom I'd not yet met I was so new to the job, was in another state doing a demo of our research web site to a couple of potential clients. Memberships fees ran in the low to mid five figures, so these demos were a big deal to our fledgling company.

In the middle of his demo, as I was doing some database work, I made a change to the live database and updated every survey question in every survey to the same text, something like "This is a test question" because of a flaw in the WHERE. My co-worker and I scrambled for the backup and cringed, hoping he wasn't demoing that section of the site right then but waiting for the email in all caps that gratefully never appeared.

The good side was the boss finally sprung for a development box.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.