Self-WTF



  •  I got to work this morning to find an e-mail in my inbox from my boss informing me that the new search feature I had implemented for our customer database was giving "out of memory" errors.  Experimenting with the search led me to the conclusion that if I was putting more than one search condition in the WHERE clause of the SQL query, I would get the out of memory error.

    Well, I went through the following stages: 1) rewriting the SQL query (it actually is more efficient now), 2) blaming MySQL for epic failing, 3) blaming my web host for limiting my server process to 64MB of RAM, and 4) blaming PHP for epic failing.  This took about two hours.

    The problem, of course, was here in my own code:

    $query .= $conditions[0];

    $i = 1;

    while($i <  count($conditions))

    {

        $query .= ' AND '.$conditions[$i];

    }

     

    I decided after that that I'm no longer allowed to blame anyone besides myself until I've 1) actually read the error message, and 2) read through my code six times.

    (I later changed it to $query .= implode(' AND ', $conditions), if you're curious.)



  • That should have been caught in testing.  Blame the ass hole testers and continue on with your day.  Just like any good corporation, if you don't admit fault, you never caused the problem. 



  • It was caught in testing ;)  That is, production is testing, for this particular web application.

    That said, I should have tested the search functionality myself with more than one condition before I called the task done...



  • Been there, done that, bought the t-shirt, returned it because it was crap and now I've opened my own t-shirt store.

    Out of curiocity... is anyone here using unit testing with PHP and if so is there some realistic way of using it to catch exactly this kind of mistake?



  • But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.



  • @Mario and Luigi said:

    But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.

    I remember my first infinite loop in VB6 when I was young and naive. The only way to get out of the loop while in debug mode was to kill the VB6 IDE. So you would lose all not-saved work. This quickly teaches you to check if your exit conditions of your loops are ever reached before hitting F5. Of course, the option to "save changes when program starts" should have been enabled by default



  • @Heron said:

    production is testing, for this particular web application.
    RUN, MOTHERFUCKER!  RUN FAR AND RUN FAST!



  • @Mario and Luigi said:

    But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.
    Really?  Thank you for your endless insight.  You are an asset to these forums.



  • @bjolling said:

    I remember my first infinite loop in VB6 when I was young and naive. The only way to get out of the loop while in debug mode was to kill the VB6 IDE. So you would lose all not-saved work. This quickly teaches you to check if your exit conditions of your loops are ever reached before hitting F5. Of course, the option to "save changes when program starts" should have been enabled by default
    I remember I had one in PASCAL (yes!) where I was supposed to display a Calendar, given the number of days and the day the month started.  I chose x as my day-increment variable.  When I went to put the |  |  |  |  | to give space under the day numbers, I chose to use x as my loop variable (for x = 1 to 2).  So x always came out of the for loop as 3 and the program thought it should print day 3 as the Sunday for the next week.  From that day, I've always chosen variables with more descriptive names for my everything but loops.

    I guess I kinda triple-posted here.  There's so much to talk about in this thread, though.



  • @belgariontheking said:

    @Mario and Luigi said:

    But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.
    Really?  Thank you for your endless insight.  You are an asset to these forums.

    And thanks to you too for your insightful on-topic contribution to this thread </sarcasm>



  • @belgariontheking said:

    @Mario and Luigi said:

    But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.
    Really?  Thank you for your endless insight.  You are an asset to these forums.

    I am glad to hear that, Mr. Theking.

    Plus I am glad that you follow the school of replying to each post with exactly one corresponding post, instead of bundling them together. Bundling really decreases readability, and doesn't increment the post-count, which is a shame as your post count wouldn't yet have reached the 512.



  • @Mario and Luigi said:

    Plus I am glad that you follow the school of replying to each post with exactly one corresponding post, instead of bundling them together. Bundling really decreases readability, and doesn't increment the post-count, which is a shame as your post count wouldn't yet have reached the 512.
    The forum software stores posts as replies to replies, instead of replies to threads. This means that threads can be viewed as threads of conversation stemming from specific posts rather than one flat sequential thread. Replying to multiple inner threads in one post breaks the flow the forum software is designed to create and is generally frowned upon in this particular forum. You'll get used to it.



  •  Ahaaa, I see. Thanks!



  • @bjolling said:

    The only way to get out of the loop while in debug mode was to kill the VB6 IDE.
    Ctrl+Break



  • @dabean said:

    @bjolling said:

    The only way to get out of the loop while in debug mode was to kill the VB6 IDE.
    Ctrl+Break

    Oh man! Why didn't we meet sooner? I only tried <Break> and <Ctrl> + <C>



  • @bjolling said:

    @belgariontheking said:

    @Mario and Luigi said:

    But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.
    Really?  Thank you for your endless insight.  You are an asset to these forums.

    And thanks to you too for your insightful on-topic contribution to this thread </sarcasm>
     

    I'm sorry. Since when is it considered off-topic to criticize someone for pointing out the obvious? You know, like "Hey, look! They took a picture on a wooden table!"

    My thought was about the same as btk's, except I also wondered if it took both Mario and Luigi to figure out the problem in the original code, or if one of them was able to do it by himself.



  • @KenW said:

    I'm sorry. Since when is it considered off-topic to criticize someone for pointing out the obvious? You know, like "Hey, look! They took a picture on a wooden table!"

    My thought was about the same as btk's, except I also wondered if it took both Mario and Luigi to figure out the problem in the original code, or if one of them was able to do it by himself.

    Even my thought was the same as btk's but I didn't bother posting it because it found it too easy to critize M&L. Poor guys are new posters, why scare them away? Anyways, btk DID add value to the thread in his other posts, so I shouldn't have overreacted the way I did



  • @bjolling said:

    Even my thought was the same as btk's but I didn't bother posting it because it found it too easy to critize M&L.
    I wouldn't have mentioned anything if he hadn't done something stupid in another thread as well.  You get one free pass.  after that, you're a dumbass to me.  I don't always flame dumbasses, and sometimes when I flame, I'm dead wrong (yeah I know it ... I can't read), but I didn't feel like this could pass without a comment.  You're free to flame back.  Nothing wrong with that.  The way I see it, that's what the internet is for: discussions over who is the biggest dumbass.



  • @belgariontheking said:

    @bjolling said:

    Even my thought was the same as btk's but I didn't bother posting it because it found it too easy to critize M&L.
    I wouldn't have mentioned anything if he hadn't done something stupid in another thread as well.  You get one free pass.  after that, you're a dumbass to me.  I don't always flame dumbasses, and sometimes when I flame, I'm dead wrong (yeah I know it ... I can't read), but I didn't feel like this could pass without a comment.  You're free to flame back.  Nothing wrong with that.  The way I see it, that's what the internet is for: discussions over who is the biggest dumbass.
    You mean his coprocessor comment? He does seem a bit over ..er.. eager.

    I have indeed noticed your MO when posting: story flame flame apologize story flame story apologize etc... :-) I always try not to flame too much to avoid having to apologize. It takes a big man to apologize and I'm not.



  • @KenW said:

    @bjolling said:

    @belgariontheking said:

    @Mario and Luigi said:

    But the real problem is that you never incrementd $i in the loop, so of course you would run out of memory, or run out of execution time.
    Really?  Thank you for your endless insight.  You are an asset to these forums.

    And thanks to you too for your insightful on-topic contribution to this thread </sarcasm>
     

    I'm sorry. Since when is it considered off-topic to criticize someone for pointing out the obvious?

    Any time the topic isn't "Criticizing people for pointing out the obvious". 

    I would have thought that was obvious, but I guess it needs to be pointed out.



  • @belgariontheking said:

    @Heron said:

    production is testing, for this particular web application.
    RUN, MOTHERFUCKER!  RUN FAR AND RUN FAST!

     

    Yeah... I'm leaving in April, after I graduate.  I'm going to much greener pastures (both in terms of pay and in terms of company quality)... Amazon's keeping a seat warm for me.

     

    Oh, and off-topic, I just finished reading The Malloreon :)



  • @Heron said:

    Oh, and off-topic, I just finished reading The Malloreon :)
    Good times.  I need to whip those out again and read them.  Just like a million other books. Sadly, I've only read each of them once, and that was ten years ago now.



  • @Heron said:

    Oh, and off-topic, I just finished reading The Malloreon :)

     Man... that was a good series. Now go and check out the Axis trilogy by Sara Douglass :)



  • @DaEagle said:

    Now go and check out the Axis trilogy by Sara Douglass :)

     

    My next task is actually reading all of Brandon Sanderson's books before he finished book 12 of the Wheel of Time.  I'm going to his book signing on Saturday, too :)

    I'll put Sara Douglass on my (rather long) backlog, though.



  • @dabean said:

    @bjolling said:

    The only way to get out of the loop while in debug mode was to kill the VB6 IDE.
    Ctrl+Break

     

    After reading this message, I looked for the break button on my keyboard. Then I pressed it -- for the first time in my life -- to see what it would do. Nada.



  • @savar said:

    @dabean said:

    @bjolling said:

    The only way to get out of the loop while in debug mode was to kill the VB6 IDE.
    Ctrl+Break

     

    After reading this message, I looked for the break button on my keyboard. Then I pressed it -- for the first time in my life -- to see what it would do. Nada.

    NO DON'T DO THAT YOU'LL BREAK IT!!!  WHAT HAVE YOU DONE!?!?!



  • Try hitting Ctrl-Break in a console window.



  • @Heron said:

    @DaEagle said:

    Now go and check out the Axis trilogy by Sara Douglass :)

     

    My next task is actually reading all of Brandon Sanderson's books before he finished book 12 of the Wheel of Time.  I'm going to his book signing on Saturday, too :)

    I'll put Sara Douglass on my (rather long) backlog, though.

    After reading the Mallorean about 15 years ago, I accidentelly stumbled upon the "Lord Of the Rings" trilogy. After exploring all of that universe (anyone tried the Silmarilleon?) I bought some of Brandon Sanderson's books but they ended up unread on my bookshelf (right next to my "Teach yourself Visual C++ .NET in 24 hours") because Terry Pratchett's discworld series is way more fun.


  • @bjolling said:

    After reading the Mallorean about 15 years ago, I accidentelly stumbled upon the "Lord Of the Rings" trilogy. After exploring all of that universe (anyone tried the Silmarilleon?) I bought some of Brandon Sanderson's books but they ended up unread on my bookshelf (right next to my "Teach yourself Visual C++ .NET in 24 hours") because Terry Pratchett's discworld series is way more fun.

     

    I sort of have four entire rows on my bookshelf taken up by four different series: bottom shelf is the Wheel of Time, next up is the Lord of the Rings (including the History of Middle-earth), next up is the Shannara series, and on top is the Sword of Truth series by Terry Goodkind - that series was fantastic, I might add.



  • @bjolling said:

    I accidentelly stumbled upon the "Lord Of the Rings" trilogy. After exploring all of that universe (anyone tried the Silmarilleon?)
     

    I coudln't get through LOTR, but loved the Silmarillion. It's a different tone of writing, kind of epic/biblical, and I like that.

    If you liked the Silmarillion, you may very well enjoy Unfinished Tales, which descibes the general legendary events between the Silmarillion and LOTR, including Númenor.

    And if you liked the parts about Númenor, you will also enoy linkbrowsing on Wikipedia about Sumer and Babylon and their kings and histories etc. I've wasted so much time there.

    Actually I'm not sure anymore whether Númenor was described in Sil or UF. It's been a while.

    I should probably buy the lot.

    Yea.



  • @Heron said:

    @bjolling said:

    After reading the Mallorean about 15 years ago, I accidentelly stumbled upon the "Lord Of the Rings" trilogy. After exploring all of that universe (anyone tried the Silmarilleon?) I bought some of Brandon Sanderson's books but they ended up unread on my bookshelf (right next to my "Teach yourself Visual C++ .NET in 24 hours") because Terry Pratchett's discworld series is way more fun.

     

    I sort of have four entire rows on my bookshelf taken up by four different series: bottom shelf is the Wheel of Time, next up is the Lord of the Rings (including the History of Middle-earth), next up is the Shannara series, and on top is the Sword of Truth series by Terry Goodkind - that series was fantastic, I might add.

     

    I've heard the Wheel of time series is great, but how are the Terry Goodkind books?  Personally I am an R.A. Salvatore and Ed Greenwood kind of guy, just my taste.  Do you think I would like the Goodkind books?

     Another must, and no not because they made a half assed movie about it combining most of the series into one movie, is the hitchhiker's guid.  I don't see how it is possible to be a self respecting computer geek without it on your selves right next to "The C Programming Language" by K & R.



  • @amischiefr said:

    Do you think I would like the Goodkind books?
     

    If you're one of the people who thinks Ayn Rand is an inspired genius, you will love the Goodkind books. If not, then the first couple of books in the Sword of Truth series are still good, but the later books slip further and further into objectivist soapboxing at the expense of plot and quality, IMHO spoiling the (fantastic) setting. It loses the "high fantasy" feel you get from authors like Salvatore.



  •  @amischiefr said:

    I've heard the Wheel of time series is great, but how are the Terry Goodkind books?  Personally I am an R.A. Salvatore and Ed Greenwood kind of guy, just my taste.  Do you think I would like the Goodkind books?

    I'm not very familiar with  R.A. Salvatore or Ed Greenwood, but what durendal.mk3 says is probably fairly accurate.  (I've never read Ayn Rand though, so I can't vouch for that personally ;)



  • @Heron said:

    I'm not very familiar with  R.A. Salvatore or Ed Greenwood, but what durendal.mk3 says is probably fairly accurate.  (I've never read Ayn Rand though, so I can't vouch for that personally ;)
    I've read Ed Greenwood's "Cormyr Saga" and although I generally enjoyed the story, I got annoyed with the way he portrays the women in his books. Every single one of them is a geek's dream come true instead of a real character. But his story-telling is fantastic.



  • @bjolling said:

    I've read Ed Greenwood's "Cormyr Saga" and although I generally enjoyed the story, I got annoyed with the way he portrays the women in his books. Every single one of them is a geek's dream come true instead of a real character. But his story-telling is fantastic.

     

    My wife is reading the Wheel of Time right now, and her biggest complaint is that the women don't act like real women would act, so I know what you mean.



  •  @Heron said:

    @bjolling said:

    I've read Ed Greenwood's "Cormyr Saga" and although I generally enjoyed the story, I got annoyed with the way he portrays the women in his books. Every single one of them is a geek's dream come true instead of a real character. But his story-telling is fantastic.

     

    My wife is reading the Wheel of Time right now, and her biggest complaint is that the women don't act like real women would act, so I know what you mean.

    Come on guys, are we really complaining that a "fantasy" book about dragons and goblins isn't portraying how women act in reallity accurately?   o.O

    Yeah Ed makes TWO characters in the Cormyr Saga buff bitches that kick ass (kind of like that G4 geeks dream girl that brings you info and tech news), but the rest are conniving whores just like women in real life.  Personally I don't like the idea of a girl being buffer and a better fighter than me either but hey, that's why they call it "fantasy" right? 



  • @dabean said:

    @bjolling said:

    The only way to get out of the loop while in debug mode was to kill the VB6 IDE.
    Ctrl+Break

     

    That was one of the first keyboard shortcuts I learnt in 1993 when I started programming in QBASIC. :)

    Those were the days. I even figured out how to program with the mouse and I made mouse-driven QBASIC programs. Technology! I once got a book on how to access XMS from QBASIC but never really got into it as by then I had discovered Perl and my life was forever changed.

     



  • @Heron said:

    My wife is reading the Wheel of Time right now, and her biggest complaint is that the women don't act like real women would act, so I know what you mean.

    That's all she has to complain about? Wow. My biggest complaint is that the series was never finished, because the author up and died on us.



  • @Kyanar said:

    That's all she has to complain about? Wow. My biggest complaint is that the series was never finished, because the author up and died on us.
     

    I talked to Brandon Sanderson yesterday (yes, in person).  He's working on the last Wheel of Time book (well ok, it will be two books), he's 2/3 of the way done with the pair (he has 396,000 words written), and the first one should be published in November. And don't worry, he's obsessively referring to Robert Jordan's notes and recordings to make sure he gets the story right ;)



  • @Heron said:

    He's working on the last Wheel of Time book

    i've heard that one before ... for me the wheel of time series is kinda like the OPs loop ...



  • @Nelle said:

    i've heard that one before ... for me the wheel of time series is kinda like the OPs loop ...

    Indeed we have all heard it before; however, I'm inclined to believe Brandon...



  • @Heron said:

    Indeed we have all heard it before; however, I'm inclined to believe Brandon...
     

    i'll believe it when i see it...

    since we are already off topic, i have to say i was frrrrikin pissed a coupleof days ago when i got to the end of brisingr...

    as i ordered it i did see it is part of the inheritance cycle, but i thought it was just a fancy word for trilogy .... 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.