Slashdot Mirror


Database Error Detection and Recovery

CowboyRobot writes "ACM Queue has an interview by Steve Bourne with Bruce Lindsay, responsible for a lot of the SQL and RDBMS we use today, in which they discuss error detection and recovery. My favorite part other than the photos is the definition of Heisenbugs - those problems that disappear only when you explicitly look for them."

163 comments

  1. Now we'll see by Anonymous Coward · · Score: 0

    Whether one of the problems they prepared for was a Slashdotting. Database driven sites beware!

  2. Now where's that article again? by Alwin+Henseler · · Score: 1
    I know it must be here somewhere... saw it here just a couple of seconds ago...

    Where is it?

    1. Re:Now where's that article again? by nadadogg · · Score: 1

      I'm not sure, but it was moving at about 40m/second.

      --
      i use linux and windows oh god how can i have an opinion
  3. Rite of Passage by beldraen · · Score: 4, Interesting

    Heisenburg bugs are a rite of passage in the computer world. They result from the production environment being different from the development environment. For instance, a debugger may initialize all memory in the process space to zero. An errant loop control now happens to be set properly, so no error occurs; however, in the production environment, whatever is left over in memory is used, which means the loop wanders off into nomansland and crashes. Always initialize your variables, period! Even in languages that automatically do it for you so that you are aware to what they are initialized.

    --
    Bel, the mostly sane.. "Of course I can't see anything! I'm standing on the shoulders of idiots." -- Me
    1. Re:Rite of Passage by quamaretto · · Score: 2, Interesting

      I have been dealing recently with a Heisenbug in Internet Explorer while trying to design a web page with floats. (Wed designers, weep with me.) The trouble is that a certain page renders wrong (what I think is wrong), the first time you look at it after opening Internet Explorer, and then displays correctly every time you look at it afterward, even with 'refresh'.

      And yes, I really do have to design it for Internet Explorer.

      Also, early on in the development of the page, I was encountering a similar situation with VS.Net 2004 where, when it "corrected the formatting" of my HTML (which happens when you switch to design view), it would introduce the same display glitch into the page.

      At some point in the cycle of figuring all of that out, I even came across variations of the page where IE, on every individual view, would randomly choose one of two ways to display the same page.

      (For reference, I was trying to float a div tag to the left of another div as a menu. The trouble is, sometimes the div would pop entirely outside the containing div to the left. I'm still not sure what causes it, after fixing it some dozen times.)

      --
      *is run over by rotten tomatoes*
    2. Re:Rite of Passage by thepoch · · Score: 2, Interesting

      This probably resulted in the quote: "If you can't repeat it, it's not a bug" End-User : Look at this bug! Developer: What bug? End-User : This bug! Developer: Oh? Try it out on my development computer. End-User : Developer: See, it's not a bug. Must be your Windows or something. Have your IT department support it. Manager : All right, no bugs, pay up. If only development was like this little play I wrote.

    3. Re:Rite of Passage by Anonymous Coward · · Score: 1, Informative

      The trouble is that a certain page renders wrong (what I think is wrong), the first time you look at it after opening Internet Explorer, and then displays correctly every time you look at it afterward, even with 'refresh'.

      That sounds like one of these bugs. I've had even worse - all the text on the page disappearing, but minimising and then maximising the window fixes it! Internet Explorer really is a piece of shit.

    4. Re:Rite of Passage by IO+ERROR · · Score: 1

      Don't forget the unintentional stack smashing, which is all too easy to do when you're writing tricky pointer code in C, and damned hard to find, especially when you barely understand the code you just wrote in the first place.

      --
      How am I supposed to fit a pithy, relevant quote into 120 characters?
    5. Re:Rite of Passage by Jeremi · · Score: 4, Informative
      Don't forget the unintentional stack smashing, which is all too easy to do when you're writing tricky pointer code in C, and damned hard to find, especially when you barely understand the code you just wrote in the first place.


      For stuff like this, a wonderful debugging tool is valgrind -- it takes about 5 minutes to download and install (GPL, Linux/x86), and will find all kinds of memory-usage bugs in your program that you never even knew existed.

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    6. Re:Rite of Passage by leoval · · Score: 3, Interesting

      Nothing like putting extra printf's to get rid of an error. Thankfully the universe is a better place since the invention of Purify, (since most of the Heisenbugs are memory problems --evil pointers--). However the most challenging heisenbugs are the timing related ones, specially in networked applications. Those @#%'s are really hard to debug.I remember a project in particular where the heisenbug will only occur in Windows (not flame intended), but it would go away whenever we put a fprintf just before sending any packets trhu the socket. I think that the developer could not figure out the problem on time for the production deadline, so the fprintf to a bogus file is still there (about 6 years after the fact).

    7. Re:Rite of Passage by mikael · · Score: 3, Interesting

      Oh man, I remember those. The worst case was when I was trying to fix a SLIP (the model protocol) bug in an Ethernet probe. You could step through the code and everything worked correctly. The Token Ring network version worked correctly without failing. But run the system normally, and it failed to connect. The quickest solution was to compare the two code segments of each system; the only difference. was a 15 millisecond wait. Once replaced the system worked correctly (This was a requirement specified in the back page appendix of the modem chip specification).

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    8. Re:Rite of Passage by quamaretto · · Score: 1

      Thank you, bookmarked. (Register! plzkthx)

      --
      *is run over by rotten tomatoes*
    9. Re:Rite of Passage by Alsee · · Score: 1

      when you barely understand the code you just wrote in the first place.

      Debugging code is harder than writing code. If you write the most complex code you are capable of, you are by definition not smart enough to debug it. :)

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
    10. Re:Rite of Passage by bsgenerator · · Score: 2, Interesting

      I once worked at company on a program in qbasic. The small procedure I was working on was ok when used in a test-program, but when it was used in the 'real' program it barfed. After I looked for hours for non-existing bugs in only 10 lines of code, questioning my own sanity in the proces, I asked for help. It turned out to be the compiler we run afterwards who messed up, and was 'corrected' by a dummy if-statement at the right place.

      if (1=0)
      print("The end of the world...");

      Of course, another senior programmer saw the statemnent and removed it just before it was shipped to the customer...

      Nowadays, I use JUnit to test portions of code, but it won't save me for this kind of problems.

    11. Re:Rite of Passage by Anonymous Coward · · Score: 0

      Like many debugging tools that try to tell you what the bugs are (lint comes to mind), Valgrind also automatically find a lot of stuff that aren't bugs, but intentional behavior, at least in the kind of fancy system-busting code I like to write. It's a fine tool, but like compiler warnings, a naive user that treats everything that the tool spews at you as an OMG-must-fix bug is just going to cause themselves a lot of unnecessary trouble trying to fix stuff to satisfy Valgrind. I actually find memory leaks are a tolerable problem in most cases (modern software probably wouldn't be able to run at all if it weren't), and that the effort spent fixing unimportant leaks is often outweighed by the amount of time spent on other aspects of code quality. Now, dangling pointers are just evil, but that's because they cause the problem to behave incorrectly, not because of resource failures. And most programs crash if this is the case, so it's all good.

    12. Re:Rite of Passage by Anonymous Coward · · Score: 0

      Just as a side note, if resource exhaustion is that big a problem, I would suggest just plain using a safer language, rather than relying on a tool like Valgrind, which is only going to uncover the problems if you have proper code coverage in your test cases.

    13. Re:Rite of Passage by whereiswaldo · · Score: 1

      Always initialize your variables, period! Even in languages that automatically do it for you so that you are aware to what they are initialized.

      So for example, perl initializes variables to 'undef' by default. I am already aware of this without setting the value explicitly. How do you justify setting the value to undef explicitly?

    14. Re:Rite of Passage by Anonymous Coward · · Score: 2, Insightful
      Of course, another senior programmer saw the statemnent and removed it just before it was shipped to the customer...

      As well he should have. If you need something like that to stay, you need a comment explaining its purpose. "The following statement is never executed but necessary to work around a compiler bug" would be helpful. You could even describe the bug so they could check if it's still necessary once the next version of the compiler is released.

    15. Re:Rite of Passage by DrSkwid · · Score: 1


      my least favourite in internet explorer is that if you have a site that is delivered chunked via mod_gzip and press refresh IE decides that you only wanted the last chunk !

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    16. Re:Rite of Passage by DrSkwid · · Score: 1

      you could at least attribute it :

      Debugging is twice as hard as writing the code in the first place. Therefore,if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

      -- Brian W. Kernighan

      more here

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    17. Re:Rite of Passage by Alsee · · Score: 1

      Attributing a quote is twice as hard as (mis-)quoting it in the first place. Therefore, if you write the witty quotes as cleverly as possible, you are, by definition, not smart enough to attribute it.

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
    18. Re:Rite of Passage by Matchstick · · Score: 1

      A senior programmer should know that very little justifies a useless change just before one ships. Removing dead code -- especially suspicious looking dead code -- does not help a project in any appreciable way. So shame on the junior programmer for not putting in a comment, and shame on the senior programmer for taking the bait.

      The proper endgame mindset should be, "Does this change (or more generally, this action) help me ship the product? If not, I won't do it."

    19. Re:Rite of Passage by Matchstick · · Score: 1

      That's as bad as that browser rendering bug that shows up on slashdot all the time. Most of the text except for the left bar disappears, but shrinking and then increasing the text size fixes it! The browser that displays that bug really is a piece of shit.

      (Note: I don't actually think Firefox is a piece of shit)

    20. Re:Rite of Passage by Anonymous Coward · · Score: 0

      Your point would have merit if it wasn't for a few things:

      a) Internet Explorer has a whole range of these bugs.

      b) The bug in Firefox affects old-fashioned table-based layouts, while the bug in Internet Explorer affects proper CSS layouts.

      c) Firefox is under active development and that bug has already been fixed. Internet Explorer is dead software that has had these bugs for over three years.

      d) The bug you are talking about in Firefox is very difficult to reproduce, as it varies with the precise timing of the packets involved. The bugs in Internet Explorer are easy to reproduce and have had test cases for years.

      e) As a web developer, Firefox doesn't soak up my time with bug fixes like Internet Explorer does.

      f) Firefox isn't produced by the world's largest software company with billions of dollars at its disposal.

      g) I don't have to work around absolutely 100% of Firefox bugs or lose clients.

      h) The sole reason for Firefox's existence isn't to put a company out of business.

      I agree if it was a simple case of "bug == POS", then I'd be engaged in double standards. However there are very significant differences between the two situations.

  4. this is to test a bug in slashcode by EnVisiCrypt · · Score: 3, Funny

    ignore this response.

    --


    *everything* is Orwellian to cats.
    1. Re:this is to test a bug in slashcode by Anonymous Coward · · Score: 0

      This is a further test.

    2. Re:this is to test a bug in slashcode by Anonymous Coward · · Score: 0

      When you are not looking at this post, its data is corrupt.

      And its in French.

    3. Re:this is to test a bug in slashcode by Anonymous Coward · · Score: 0

      Foo.

    4. Re:this is to test a bug in slashcode by sporty · · Score: 1

      Maybe that's why we get dupe stories..

      --

      -
      ping -f 255.255.255.255 # if only

  5. Heisenbugs by base_chakra · · Score: 4, Funny

    "Heisenbug as originally defined--and I was there when it happened--are bugs in which clearly the behavior of the system is incorrect, and when you try to look to see why it's incorrect, the problem goes away.

    This is a really cool article, but it was especially fun to see the heisenbug mention. Years ago, some fellow CS people and myself conjectured a similar phenomenon that seemed to manifest once in a while, in which a computer malfunction goes away after one "proves" that there's no cause for the error to exist.

    Here's a list of heisenbug anecdotes, but note that some of these submissions aren't strictly heisenbugs.

    1. Re:Heisenbugs by JaredOfEuropa · · Score: 4, Funny

      I remember compaints about a Windows NT server slowing down to a crawl even when there weren't that many people using it. So the SysOp would fire up a few performance monitors and keep an eye on the thing. Sure enough: no slowdowns, no performance issues, normal operation. But every time when the guy would leave, the system would slow down again after 5 minutes or so. For a few days this had us stumped.

      Then someone figured out that the system had the 'pipes' screensaver on that came with NT3.51. Of course, as soon as we started to diagnose the machine, the screensaver would disappear. And yes... the screensaver turned out to be the culprit, sucking all the system resources away. We removed it and all was well.

      Does anyone know who coined the term 'heisenbug' by the way?

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    2. Re:Heisenbugs by gstoddart · · Score: 1
      Years ago, some fellow CS people and myself conjectured a similar phenomenon that seemed to manifest once in a while, in which a computer malfunction goes away after one "proves" that there's no cause for the error to exist.


      I think what you're describing is a corollary to the well-known fact that when the support person is investigating the problem it never manifests again until after they're gone.

      Proving there is no cause for the error is like all of the passengers believing the plane will fly (the real reason for powered flight =). Once those who have convinced themselves there is no bug leave, the bug will continue to believe it exists and re-appear.

      [ or in my experience, the user re-does the one thing they never pointed out to you that they actualy did ] :-P

      --
      Lost at C:>. Found at C.
    3. Re:Heisenbugs by kfg · · Score: 1

      This is an example the Schroedinbug, a bug defined as one that doesn't exist until someone reads the code and proves that it can't run, and then everyone's system crashes, even though they were all running fine until then.

      Some programs die, but some programs live, I guess.

      KFG

    4. Re:Heisenbugs by Anonymous Coward · · Score: 1, Informative

      Fome Heisenberg's Uncertainty Principle ?

    5. Re:Heisenbugs by operagost · · Score: 1

      This problem also occurred with NT 4.0. The safe way of locking the console was to use either "blank" or "logon" as the screen saver. Even the stupid "Marquee" could suck up half the CPU.

      --

      Gamingmuseum.com: Give your 3D accelerator a rest.
    6. Re:Heisenbugs by DNS-and-BIND · · Score: 1

      Oh, man. Any screensaver other than "blank screen" on a production machine is a mark of a fucking idiot admin. I saw that problem too many freaking times to count. I also got "but I like that screensaver" in reply too many times. Fucking NT admins.

      --
      Shutting down free speech with violence isn't fighting fascism. It IS fascism!
    7. Re:Heisenbugs by imroy · · Score: 1

      A 3D screensaver on a server? Now that's the sort of innovative shit that Linux needs to succeed in the marketplace ;)

      (Yes, I know about Xscreensaver)

    8. Re:Heisenbugs by syukton · · Score: 1

      There's this lady I used to work for who is a naturopathic doctor. I used to fix her computers. Everything would work fine as soon as I got there, everything would work fine while I was there, and then suddenly not more than an hour or two after I left, things would cease working. It has always kind of bothered me. I'm glad I have a real job now, and I don't have to worry about those possessed computers.

      --
      Reinvent the wheel only at either a lower cost, greater effectiveness, or your own personal enrichment and satisfaction.
    9. Re:Heisenbugs by Donny+Smith · · Score: 1

      >Fucking NT admins.

      Yeah, like Linux admins are all Einsteins.

      It's even worse that on Windows - while screensaver on Windows had to be liked by a particularly stupid admin in order to be enabled, on Linux it was enabled by the manufacturer - how fucking stupid is that?

      As recently as Red Hat 8.0, they had screensaver activated by default, and it was known to cause system freeze-ups. Not to mention that X-Windows shouldn't have been installed by default anyway.

      It's inexcusable to be stupid, but how stupid one has to be to knowingly make stupidity a system default?

    10. Re:Heisenbugs by DNS-and-BIND · · Score: 1

      Who the hell said anything about linux???

      --
      Shutting down free speech with violence isn't fighting fascism. It IS fascism!
    11. Re:Heisenbugs by Donny+Smith · · Score: 1

      Doesn't "NT admins" mean Windows server administrators?

      My point is that a stupid admin is a stupid admin and will always be a stupid admin no matter what OS he or she uses.
      I know some stupid admins who used to be stupid NT admins and their company has switched to Linux lately. They're now stupid Linux admins. Same people. There's no need to single out Windows users.

    12. Re:Heisenbugs by Anonymous Coward · · Score: 0

      The question was who coined the term 'heisenbug'. While there may be a person called "Fome Heisenberg's Uncertainty Principle" who coined the term I'm almost 100 percent sure (with a little uncertainty ;) you where making reference to non-commuting measurement operators in quantum mechanics. Please feel free to correct me and post appropriate references.

  6. What about the Hindenbugs? by Anonymous Coward · · Score: 0

    I'm less afraid of the heisenbugs as I am of the Hindenbugs, which bring down an app in a most spectacular fashion. Oh the humanity!

  7. The Heart Monitor Case... by Anonymous Coward · · Score: 4, Funny

    BL: In the heart monitor case, you better keep the heart going, whereas in the Microsoft Word case, you can just give them a blue screen and everybody is used to that.

    SB: But also in the heart monitor case, it?s hard to ask users if they want to keep the heart going because the answer is pretty obvious, whereas in the Word case, you can ask the user in some cases what to do about it.


    New Microsoft Pace - Heart Monitor and Pacemaker

    STOP: 0x0000000A (0x0000015a, 0x0000001c, 0x00000000, 0x80116bf4)
    IRQL_NOT_LESS_OR_EQUAL - Beat.exe
    Please hold your breath while a dump file is created...

    1. Re:The Heart Monitor Case... by Tablizer · · Score: 1

      New Microsoft Pace - Heart Monitor and Pacemaker....Please hold your breath while a dump file is created...

      Technology where the screen and the user become the same color. Now that's bonding.

    2. Re:The Heart Monitor Case... by DNS-and-BIND · · Score: 1

      True story - I went in for an X-ray a few years back, and the tech was fiddling around with a computer. I was shocked to see she was using Windows 3.1 to run a Visual Basic applicaion that controlled the X-ray machine. As I watched, she got several errors from the program, which she clicked through. "Oh, it always does that," she said when I expressed my...er...dismay. This was back when there wasn't much you could do to a Windows box other than WINNUKE.EXE...these days you can take the whole box hostage.

      --
      Shutting down free speech with violence isn't fighting fascism. It IS fascism!
  8. Picture by bonzoesc · · Score: 4, Funny

    That picture is really something. I didn't know Gandalf wrote bsh.

    1. Re:Picture by base_chakra · · Score: 1

      That picture is really something. I didn't know Gandalf wrote bsh.

      That's what it looks like when the beard/pipe/suspenders crowd groom themselves. Sort of like an aged flower child version of Bill Gaines a la R. Crumb.

    2. Re:Picture by Dark$ide · · Score: 1

      If Gandalf wrote it ...
      ... wouldn't it be gsh rather than bsh

      --

      Sigs. We don't need no steenking sigs.

    3. Re:Picture by SnowZero · · Score: 2, Informative

      The picture is Lindsay, not Bourne. See here for an earlier picture. I admit its a bit disturbing, but some CS people don't want to "waste" time shaving and getting their hair cut. I also need a haircut and a shave, but not nearly as bad as him. This picture has helped motivate me :)

    4. Re:Picture by bonzoesc · · Score: 1

      Oh dis!


      That reminds me, I'm only a week or so from a mullet. And I can't have that happen, I don't want people thinking I'm McGyver with glasses.

    5. Re:Picture by Anonymous Coward · · Score: 0

      Based on the picture, Lindsay looks like it's not just laziness; it looks like he actually takes care of his hair. Having long hair and/or beard can be a matter of personal choice and style.

      Do you have any idea what it takes for most people to keep their hair long without it becoming a total mess?

  9. Heisenbugs - Oh my gawd by Anonymous Coward · · Score: 1, Interesting

    I have worked on electronic hardware for forty years. Over that period, I have experienced many such bugs. You carefully trace the problem and get to the point where you say: "It must be this!" So you go there and the signal is correct but now the equipment works properly. It stays working properly. I'm used to problems that are sometimes there and sometimes aren't; this is different. The working condition stays.

    It's like the equipment is playing hide and seek with you. You found the problem and the game is over. Maybe this proves that the 'great electron' has a sense of humor.

    1. Re:Heisenbugs - Oh my gawd by Webmoth · · Score: 1

      The only thing more frustrating than trying to figure out why something doesn't work when it should -- is trying to figure out why something works when it shouldn't.

      --
      Give me my freedom, and I'll take care of my own security, thank you.
  10. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  11. Dumbledore by Anonymous Coward · · Score: 0

    Actually, the wiz in the pic has a more friendly Dumbledore look, rather than that of a driven Istari.

  12. This is why MySQL ignites flamewars by Anonymous Coward · · Score: 5, Insightful

    A good design principle is: either do what you're told to do or tell us you didn't do it and why, but don't do something completely different.

    Exactly. Compare and contrast with MySQL's behaviour.

    • NULL inserted into a NOT NULL column silently alters the data to fit.
    • VARCHAR values have trailing whitespace silently removed without asking.
    • Dividing by zero is not an error.
    • Inserting a value into a column that violates its constraints doesn't result in an error; MySQL guesses at the "correct" value instead. For example, limiting an integer column to 4 digits, and attempting to insert 99999 will result in 9999 being inserted without any error.
    • If MySQL finds that it can't create certain table types, it simply ignores referential integrity.

    That's why there are loads of people who point out that you can't trust MySQL for important data, or that it isn't a "real" database. A real database tells you when it fails, which is something that is necessary for trusting it with data integrity.

    The key point here is that if you go to sea with only one clock, you can't tell whether it's telling you the right time.

    Ahh... but a man with one clock always knows the time - but a man with two is never quite sure :).

    1. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 1, Interesting

      And when the two meet, they go looking for a third guy who has a clock so they can settle the argument. And then they all go looking for another guy since none of them agree.

      All data is imperfect without proper reference, and all reference data is external. See the art of calibration.

      Even a room full of atomic clocks will not reflect the correct time in 100 years because the earth-sun system isn't slave to the rhythms of any process other than it (at least in any quantifiable sense). They could be several seconds off from any continuous measure of solar time.

      The more mechanistically you design your system to not need the external reference the more error you introduce until (at the limit) you can't be certain of anything at all.

      And considering our universe was created by a divide by zero, I think you are jumping to conclusions calling the performance of the function an error.

    2. Re:This is why MySQL ignites flamewars by ajs · · Score: 1, Insightful

      Welcome to the obligatory MySQL flame that must be attached to all database-related postings.

      Any second now, the parent is going to be modded down, right? Everything noted in the parent is well documented functionality in MySQL, which takes the approach of not generating application-breaking exceptions, and allowing you to split of data validation as either a pre-processing step or a more macroscopic endevor.

      You may not like this approach. If you don't, then don't use MySQL. There are lots of other (very good) choices. Slashdot doesn't need your redundant and off-topic flames.

      Mods, please start swinging that clue-bat.

    3. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 4, Insightful

      Everything noted in the parent is well documented functionality in MySQL

      Well documented, perhaps, but nevertheless utterly wrong and often in violation of the SQL specifications.

      Slashdot doesn't need your redundant and off-topic flames.

      Try reading the article. I was pointing out that MySQL's behaviour goes 100% in opposition to what the article calls a "good design principle". How on earth is that off-topic?

    4. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 1, Interesting

      > split of data validation as either a pre-processing step or a more macroscopic endevor.

      You're right that pre-processing is a good way to do constraints. We gave-up on using Oracle contraints, because they aren't very featureful. Well, that's not Oracle's fault. It's the fault of the SQL-standard. You can do *much* better error checking with a turing-complete programming language than you can with SQL. That's what we do with our applications even though we use Oracle. The biggest problem is that you must have good programmers.

      It's funny how that idiot isn't smart enough to argue the philosophical differences, but the kiddies here with mod points still give his post points. He posted a poorly thought-out rant, and that's the type of thing the 15 year-olds enjoy. Since most of the moderators here have no clue, they tend to blindly give points to any post like that. Instead, the moderators should only moderate posts they understand. This type of crap that has kept /. from being truely useful.

    5. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 1, Insightful

      It's funny how that idiot isn't smart enough to argue the philosophical differences

      Before calling me and everybody who agrees with me names, go back and read what I posted. Most of it's a case of asking MySQL to do something, MySQL being unable to do it, and instead of throwing an error, doing something completely different.

      Whether you prefer your data integrity checks in your database or in your application is irrelevent to the point I was making. The person claiming that MySQL's trying not to generate "application breaking" exceptions (how fragile are these applications that they can't handle a database error?) - if they were doings things as you prefer - the errors wouldn't occur in the database layer at all, as the application layer would have already caught them.

    6. Re:This is why MySQL ignites flamewars by justins · · Score: 1, Troll
      You can do *much* better error checking with a turing-complete programming language than you can with SQL. That's what we do with our applications even though we use Oracle. The biggest problem is that you must have good programmers.

      Which you obviously don't...

      You're right that pre-processing is a good way to do constraints.

      If your database has one user.
      --
      Now before I get modded down, I be to remind whoever might read this that what I am saying is FACT. - bogaboga
    7. Re:This is why MySQL ignites flamewars by Duncan3 · · Score: 1, Funny

      This article is about databases, why are you talking about MySQL... stay on topic please.

      --
      - Adam L. Beberg - The Cosm Project - http://www.mithral.com/
    8. Re:This is why MySQL ignites flamewars by Squeebee · · Score: 0, Troll

      MySQL will always ignite slashdot flamewars because there is always a Postgres troll standing by to start one.

    9. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 0

      MySQL will always start flame wars because there are RDBMS people and there are MySQL people.

      Don't worry, features that other real databases have had for years should be available in MySQL in the next year or two. Then you'll show them.

      By the way, my phpBB message board will surpass 100 posts in the next week or two. ( http://www.iliveinmyparentsbasement.com/ )

      Linux!

    10. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 0

      The MySQL rant had nothing to do with Contraints. You don't know what you are talking about.

    11. Re:This is why MySQL ignites flamewars by Tablizer · · Score: 1

      verything noted in the parent is well documented functionality in MySQL, which takes the approach of not generating application-breaking exceptions, and allowing you to split [off] data validation as either a pre-processing step or a more macroscopic endevor.

      It would be nice if such option was a system setting (or database-scope setting) somewhere. However, I rarely see apps where truncating numbers to fit is considered a good thing. COBOL does that and it has been the source of many bad bugs, such as wrong paychecks.

    12. Re:This is why MySQL ignites flamewars by kpharmer · · Score: 1

      > Everything noted in the parent is well documented functionality in MySQL, which takes the approach of
      > not generating application-breaking exceptions, and allowing you to split of data validation as
      > either a pre-processing step or a more macroscopic endevor.

      Failing to provide exceptions to obvious errors is now 'well documented functionality'? Really? Exactly where? I remember when MySQL listed most of these issues as 'known problems'.

      I think you're just misinterpreting the cause of these errors: they're *NOT* a part of a deliberate exception handling strategy. They go beyond input validation, and affect database configuration itself. They're simply shoddy workmanship that MySQL needs to clean up quickly.

      > You may not like this approach. If you don't, then don't use MySQL. There are lots of other (very good)
      > choices. Slashdot doesn't need your redundant and off-topic flames.

      Ah, the topic is: "Database Error Detection and Recovery", right? And the OP mentioned that this is the main reason cause of MySQL complaints these days, right?

      Hmmm, seems 100% on topic.

    13. Re:This is why MySQL ignites flamewars by ahmusch · · Score: 1
      We gave-up on using Oracle contraints, because they aren't very featureful.


      Exactly what about Oracle's constraints do you not consider featureful?

      (and further, logic too complicated for a simple constraint, such as if column A = 1 then column B's value must be a key in table foo, else it must be a key in table bar, can be implemented fairly simple as a PL/SQL trigger).

      And on the moderation-front... the fact that you cannot moderate a thread where you participate functionally selects for ignorant moderators, as the informed speak and the ignorant try to determine who's right.
    14. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 0

      VARCHAR values have trailing whitespace silently removed without asking

      That's probably an oversite from the SQL standard. If you have a varchar and you stuff a string that is too long into it with trailing whitespace, the standard says the database is supposed to cut off the whitespace in order to (try to) make it fit.

      I'd say that at least when mysql always truncates it you quickly know what to expect instead of the harder to debug problem of ONLY trucating the spaces if the string is too large.

    15. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 0
      (and further, logic too complicated for a simple constraint, such as if column A = 1 then column B's value must be a key in table foo, else it must be a key in table bar, can be implemented fairly simple as a PL/SQL trigger).

      Those cross-table constraints are hard to get right, whether you do it in the database or in the application. You need "on insert or update" logic in the first table, and "on update or delete" logic in tables "foo" and "bar". People usually omit one half of that, as you just did.

      If only PostgreSQL would hurry up and fix the referential integrity for table inheritance, that would be easy. It's been on the to-do list forever.

    16. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 1
      Everything noted in the parent is well documented functionality in MySQL, which takes the approach of not generating application-breaking exceptions, and allowing you to split of data validation as either a pre-processing step or a more macroscopic endevor.

      If you actually do data validation as a pre-processing step, you'd be grateful for the database server being as strict as possible. It would point out bugs in your data validation code.

      What the hell does "as a more macroscopic endevor [sic]" mean? I'm guessing it means "never". Since once your bad data get past the "guess a value that meets the constraints" logic in MySQL, there's no way to know that they were bad or what was intended.

      The only reason you'd want this behavior is if you just don't care about your data.

    17. Re:This is why MySQL ignites flamewars by Tony-A · · Score: 0

      A good design principle is: either do what you're told to do or tell us you didn't do it and why, but don't do something completely different.

      As applied to taking a two hour final.
      If you can't finish it accurately, then don't turn in your test paper.
      A zero score is preferable to something not quite perfect.

      And a man with three clocks has a pretty good idea which one is wrong.

      As for data integrity, having NONE of the intended data is not exactly my idea of integrity.

    18. Re:This is why MySQL ignites flamewars by ahmusch · · Score: 1
      Those cross-table constraints are hard to get right, whether you do it in the database or in the application. You need "on insert or update" logic in the first table, and "on update or delete" logic in tables "foo" and "bar". People usually omit one half of that, as you just did.

      An excellent point -- however, I was quick-and-dirtying the logic.

      Further, IIRC, each of the tables foo/bar/baz could have a single trigger which fires under different conditions (insert/update on baz, update/delete on foo) so that you don't have to have multiple triggers.

      Of course, you could also have multiple triggers on a single table, each of which only fires on insert/update/delete of a specified column -- then you wouldn't have "all or nothing" if your RI is being administered through triggers.

      I agree that it's hard to get right -- generally, such issues are design-related, as a cleaner or simpler design eliminates if-then-else RI.
    19. Re:This is why MySQL ignites flamewars by Tony-A · · Score: 0

      However, I rarely see apps where truncating numbers to fit is considered a good thing. COBOL does that and it has been the source of many bad bugs, such as wrong paychecks.

      Wrong paychecks as opposed to no paychecks for anybody.
      Those are really the choices that you have with any constraints on the storage and manipulation of values.
      You get to choose where you make the errors.
      You do not get to choose to not make any errors.

      For any storage mechanism, there exists at least one x for which x+1=x or x+1 is very wrong or the systems halts or creates an exception. Creating an exception is not a solution, unless you consider nobody gets a paycheck a solution.

    20. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 0

      Wrong paychecks as opposed to no paychecks for anybody.

      Paychecks were a bad example. What about online orders? Would you rather mistakenly sell something for $999 when it should have been $9999, or would you rather have the server notify you that there's a problem?

      You get to choose where you make the errors.

      An incorrect value being sneaked into a large database is far, far harder to detect and correct than your query coming back with an error.

      Creating an exception is not a solution

      No, but it aids in solving the problem as you immediately know there is one. In what world is entering incorrect data an acceptable solution?

    21. Re:This is why MySQL ignites flamewars by Anonymous Coward · · Score: 0

      As applied to taking a two hour final.

      Taking tests is nothing at all like storing data in a database. You are using a false analogy.

      As for data integrity, having NONE of the intended data is not exactly my idea of integrity.

      Why do you think the only alternative to inserting incorrect data is throwing away all the data? What's wrong with, say, emailing the relevent data to the administrators with a description of the error?

      Oh, and you need to correct your definition of integrity. Not storing incorrect records is practically the definition of data integrity.

    22. Re:This is why MySQL ignites flamewars by Tony-A · · Score: 1

      In what world is entering incorrect data an acceptable solution?
      To some degree or another, essentially everything. Are you aware of any systems which have absolutely no errors, including errors of omission?

      An incorrect value being sneaked into a large database is far, far harder to detect and correct than your query coming back with an error.
      True. If you attempt to put a gallon of worms into a half-pint container, you should expect troubles. Assuming that the table has any variable-length column, there is no advantage in defining cramped and limited columns. The stuff that might exist but doesn't does not occupy disk space. There is no reason for a price column to be defined as DECIMAL(2) as in the example you state. DECIMAL(18,2) would be more realistic. In terms of sneaking incorrect values into a large database, what is the value of $1234.56 discouted at 4.5%? Where does the half-cent rounding error go?

      MySQL is not anything like an Oracle-lite. They use an entirely different focus and division of labor. It is designed for processing large volumes of information under time constraints and with limited resources. The design tradeoffs are not the same as for say Oracle. Having had to remove foot and inch marks from descriptions for some dBASE records to be acceptable to an Oracle system, I'm inclined to believe that Oracle is the toy system, and a rich man's toy.

  13. heisenbugs by hoborocks · · Score: 1

    Heisenbugs are those bugs whose position in the source file you can see, and whose effects you can see, but never at the same time. God, it's like a bad pthread project....

    --
    AccountKiller
  14. Cats !! by Anonymous Coward · · Score: 0

    Somebody set up us the bomb!

  15. Good god, that picture! by Anonymous Coward · · Score: 4, Funny

    The guy looks like he's covered in coke dust.

    1. Re:Good god, that picture! by Anonymous Coward · · Score: 0

      He looks like they found him frozen in a cave.

    2. Re:Good god, that picture! by Anonymous Coward · · Score: 0

      Must be that magic server pixie dust they're always bragging about.

    3. Re:Good god, that picture! by Anonymous Coward · · Score: 1, Funny

      He looks like they found him frozen in a cave.
      That was my first thought too! Unfrozen, caveman database genius.

  16. Article Text by krumms · · Score: 0

    Designing for failure may be the key to success.
    Engineering for Failure

    If you were looking for an expert in designing database management systems, you couldn't find many more qualified than IBM Fellow Bruce Lindsay. He has been involved in the architecture of RDBMS (relational database management systems) practically since before there were such systems. In 1978, fresh out of graduate school at the University of California at Berkeley with a Ph.D. in computer science, he joined IBM's San Jose Research Laboratory, where researchers were then working on what would become the foundation for IBM's SQL and DB2 database products. Lindsay has had a guiding hand in the evolution of RDBMS ever since.

    In the late 1980s he helped define the DRDA (Distributed Relational Database Architecture) protocol and later was the principal architect of Starburst, an extensible database system that eventually became the query optimizer and interpreter for IBM's DB2 on Unix, Windows, and Linux. Lindsay developed the concept of database extenders, which treat multimedia data--images, voice, and audio--as objects that are extensions of standard relational database and can be queried using standard SQL (Structured Query Language). Today he is still at work deep in the data management lab at IBM's Almaden Research Center, helping to create the next generation in database management products.

    Our interviewer this month is Steve Bourne, of Unix "Bourne Shell" fame. He has spent 20 years in senior engineering management positions at Cisco Systems, Sun Microsystems, Digital Equipment, and Silicon Graphics, and is now chief technology officer at the venture capital partnership El Dorado Ventures in Menlo Park, California. Earlier in his career he spent nine years at Bell Laboratories as a member of the Seventh Edition Unix team. While there, he designed the Unix Command Language ("Bourne Shell"), which is used for scripting in the Unix programming environment, and he wrote the ADB debugger tool. Bourne graduated with a degree in mathematics from King's College, London, and has a Ph.D. in mathematics from Trinity College in Cambridge, England.

    Photography by Tom Upton

    STEVE BOURNE Why don't we start off with the thought that you can't recover from an error until you've detected the error.

    BRUCE LINDSAY Let's think a little bit about how errors happen--and they happen at all the different levels of the system, from an alpha particle discharging a capacitor in your memory to a fire, flood, or insurrection wiping out the entire site. From program logic blunders to the disk coming back with data from the wrong sector, things go wrong. You have to engineer for failure at all the different levels of the system, from the circuit level on up through subsystems like the database or the file system and on into the application programs themselves.

    "Engineering for failure" sounds like a bad phrase, but that's really what's required to deliver reliable and dependable information processing.

    SB It's certainly true that one of the mind-sets you have to have when you're writing code and designing systems is: What's going to break? There's a broad range of possibilities for approaching this, depending on the type of application or software. If you're writing a Microsoft Word-type program, the way you approach this might be different from if you're designing a heart monitor.

    BL In the heart monitor case, you better keep the heart going, whereas in the Microsoft Word case, you can just give them a blue screen and everybody is used to that.

    SB But also in the heart monitor case, it's hard to ask users if they want to keep the heart going because the answer is pretty obvious, whereas in the Word case, you can ask the user in some cases what to do about it.

    BL You can sometimes ask the user, although it is better to ask the subsystem what it is going to do to get itself as healthy as it can, or abandon as the case may be, depending on its analysis of the situation.

    SB Are you

  17. Too much slashdot. by Linuxathome · · Score: 1

    Are Heisenbugs anything like the slashdot memory relapse? You know you've been reading too much /. when you say to yourself, "Wait, I think I saw that in /. somewhere." Then goto slashdot search to try to find it. You end up pulling 20000 articles -- like finding a needle in a haystack.

    Perhaps /. needs better database tools.

    1. Re:Too much slashdot. by Anonymous Coward · · Score: 2, Insightful

      And /. needs better thread handling too. When there's to much posts, the thread is splited in 72 pages. Pages 1, 2, and 3 are the same post reappearing over and over, then page 4 skipped a couple messages. You have to manually change the startat= parameter in the URL to see thoses missing posts. This is nuts. I mean, how difficult is it to code message threading? It's not rocket science. This makes /. look like ass when they are complaining about Microsoft bugs.

    2. Re:Too much slashdot. by DavidTC · · Score: 1

      I'm glad I'm not the only person who noticed that.

      --
      If corporations are people, aren't stockholders guilty of slavery?
  18. Heisenpages by Anonymous Coward · · Score: 2, Funny

    Web pages that disappear when you try to look at them....

  19. A man with one clock only thinks he knows the time by Anonymous Coward · · Score: 1, Funny

    A man with two clocks that agree has a much higher degree of certainty.

  20. Make error message meaningful! by martyb · · Score: 4, Insightful

    One of the things that is addressed to some extent in the article is the need to make error messages meaningful! There is nothing more frustrating to me than to encounter an error message like "syntax error."

    At a minimum, an error message should have a Unique ID of where in the code this message is coming from, what was expected, what was actually found, and the context where it was found.

    EXAMPLE:

    for (i=1;i<=10;i++) {printf "%d\n', i}
    Which would you prefer:
    1. Syntax error in line 1.
    2. ERROR [ID=WXY1234] found "'" where expected """ in statement: "{printf "%d\n', i}" on line: 1.

    In my experience, meaningful error messages save more debugging time than it takes to put them in.

    1. Re:Make error message meaningful! by Anonymous Coward · · Score: 1, Interesting

      Damn, if only you worked for Microsoft. This is a major reason I absolutely hate diagnosing any problem on a Microsoft system. "Unable to connect to server." What the hell does that mean? A DNS failure? Connection timed out? Connection refused? No route?

    2. Re:Make error message meaningful! by Anonymous Coward · · Score: 1, Funny

      This mean you have reboot Windows and the problem will magically solves itself.

    3. Re:Make error message meaningful! by Anonymous Coward · · Score: 4, Insightful
      I agree with your sentiment, but I think that this particular example can be used to describe why error messages are exactly the way they are. The compiler has no way of knowing that you DIDN'T want a single quote, comma, space, letter i, and closed curly brace to be part of your string literal -- they're all valid characters for inside a string literal, after all. It has no idea that you typed a single quote in error instead of a double quote -- Maybe you want the output to look like:
      1
      ',i}2
      ',i}3
      ...
      and your only mistake was forgetting a final ",i); It is only when it gets to something that is clearly wrong (like the NEXT double quote in the file, which is followed by something that doesn't look like the proper token -- or maybe the end of the file itself) that it knows something was wrong. It would take a lot of guessing to scan through the mess that looks like a string literal and arbitrarily decide that it must have been the single quote (also used as an apostrophe) where you went wrong. I think the best thing it could have told you was that it found an error immediately after parsing the string literal that starts on line 1, show you the line, and point to the character that starts the literal. Anything beyond that is mere speculation.

      I hand crafted a (simple) C compiler when an undergrad, and figuring out where the stream of good tokens turns to mush is very hard. Often by the time you realize there's a problem, you already missed the real problem.

      I agree you should be as explicit and precise as you can in telling the user, but there are so many ways to screw things up, and they look so much like unusual-but-legal syntax that it's probably better to tell the user / developer what you actually do know, rather than guess about what might have been wrong.

      Now, on the other hand, if your statement was

      int y = ;
      the compiler should probably be able to tell that the equals operator needs an operand of some kind on the right, and there was none. It ought to tell you immediately that the problem was a missing right hand operand for the equals operator, and it should be able to tell you the exact position of the equals that is missing the operand. Just spitting out "syntax error" in a case like that is a little weak.
    4. Re:Make error message meaningful! by Jimmy_B · · Score: 1

      No, I'd rather have just "syntax error". Because when compilers attempt to be more detailed than that, they almost always produce details that are wrong. It's just the way parsers work; they can tell you something's wrong, but they can't tell *what* is wrong. In your example, the actual error would be "newline not allowed in string constant", because it has no way of knowing that ' was supposed to be a ".

    5. Re:Make error message meaningful! by Anonymous Coward · · Score: 1, Interesting

      Which would you prefer
      1. Syntax error in line 1.
      2. ERROR [ID=WXY1234] found "'" where expected """ in statement: "{printf "%d\n', i}" on line: 1.


      I would prefer an error message indicating the real source of the problem, an unterminated string literal. What you list as the 2nd option doesn't describe the problem that the compiler runs into when trying to compile that code.

      I submit to you option #3:

      3. ERROR [ID=123123] Unterminated string literal in line 1

    6. Re:Make error message meaningful! by iabervon · · Score: 1

      In the programming environment I use, the close brace is highlighted in bright pink to indicate that something's probably wrong. Also, the ", i}" is in blue to indicate that it is still part of a string constant. If I actually try to compile the code despite the editor telling me exactly what the compiler will think of the code, I get 'temp.c:6:38: missing terminating " character', which is quite explanitory and is undoubtedly true (unlike your message; I often put single quotes around things inside double-quoted strings to mark the edges of a value).

      I only get an uninformative message on the next line, when the compiler determines that it is completely lost, but I know to resolve the clear error messages before working on the ones I don't understand.

      (This is with emacs and gcc; I don't know if less mature IDEs still give bad feedback).

      In fact, giving helpful error messages is a highly tricky art. You need a good understanding of what people will actually try to write and of what mistakes people make. For the first five years or so, meaningful compiler error messages are generally misleading more often than helpful, because they reflect a misunderstanding of the user's intent. Sun's javac is just recently getting to the point where it tells you useful things about mistakes in using the original language.

    7. Re:Make error message meaningful! by Anonymous Coward · · Score: 0

      "It's just the way parsers work;"

      No, it's just the way parsers for languages with nightmarish syntax like C++ work. One thing that you notice after switching from Java to C++ are the vastly inferior compiler error messages. Also, compilers for the same language differ in the quality of produced error messages. Saying that bad error messages are "just the way parsers work" is an oversimplification.

    8. Re:Make error message meaningful! by NetNifty · · Score: 1

      Hmm, that's true it seems :/ My father was trying to connect through dialup on his laptop (our broadband had died at the time), and it kept saying that there was no dialtone, even though plugging a phone into the same socket he was trying to connect using and listening showed there was a dialtone. We replaced the cable and it still said there was no dialtone.

      Moved the laptop to a different socket, and still no dialtone. Dialed up on my laptop using the socket he was trying to use, using the same cable he tried and it worked. Deleted his dialup settings and re-entered them and still no dialtone!

      Rebooted laptop and it worked fine.

    9. Re:Make error message meaningful! by Anonymous Coward · · Score: 0

      Interestingly, I think the situation reflects the fact that parsing algorithms were developed in academia. There is a strong emphasis on being 'correct', ie. detecting exactly which programs follow the syntax rules, but a lot less work on graceful handling of errors, which in the real world is just as important.

    10. Re:Make error message meaningful! by davegaramond · · Score: 1

      God, Microsoft Frontpage client is my favorite. Error messages like "Could not find a web server at 'your.host.name' on port 80. Please check to make sure that the web server name is valid and your proxy settings are set correctly. If you are sure that everything is correct, the web server may be temporarily out of service." Long, verbose, completely useless. "Could not find"? Why? "Out of service?" WTF?

    11. Re:Make error message meaningful! by Anonymous Coward · · Score: 0
      Sun's javac is just recently getting to the point where it tells you useful things about mistakes in using the original language.

      If you want a Java compiler that's already at that point, try Jikes.

    12. Re:Make error message meaningful! by stanmann · · Score: 1

      So you're blaming windows for a hardware issue.

      And it was a hardware issue. Your PCMCIA Modem needed to be resynced. There are ways(under certain versions of windows) to do this, but a soft reboot is the most efficient way.

      YES PCMCIA IS SUPPOSED TO BE HOT PLUGGABLE AND SWAPPABLE, IT ISN'T ALWAYS, DEAL WITH IT.

      --
      Food not Bombs is a nice platitude but it breaks down when you notice that the Bombees are usually well fed
    13. Re:Make error message meaningful! by NetNifty · · Score: 1

      It is an on-board modem, not PCMCIA.

    14. Re:Make error message meaningful! by stanmann · · Score: 1

      OH, so you're blaming windows for the crappy onboard modem. Try blaming the laptop manufacturer.

      --
      Food not Bombs is a nice platitude but it breaks down when you notice that the Bombees are usually well fed
    15. Re:Make error message meaningful! by NetNifty · · Score: 1

      No, I'm blaming Windows for telling me theres no dialtone when something else is the problem (although admittidly it COULD be a driver or hardware problem telling windows that theres no dialtone but I have had the same happen on two other machines with 3 different modems).

    16. Re:Make error message meaningful! by Anonymous Coward · · Score: 0

      Which would you prefer:

      1. Syntax error in line 1.
      2. ERROR [ID=WXY1234] found "'" where expected """ in statement: "{printf "%d\n', i}" on line: 1.

      Hmmm... The first one at least doesn't make my eyes bleed when I try to stare wondering what the hell is the difference between "'" and """ though I guess I should be grateful that it wasn't found "''" where expected """.

  21. Some languages do have support for error detection by Rich · · Score: 1

    Some languages do have support for error detection, for example the express data modelling language (and express-c its executable counterpart). http://www.ap210.org/tiki/tiki-index.php?page=EXPR ESS has some information on express for anyone interested. Basically, it lets you specify integrity constrains on the model it defines.

  22. Heisen-whats? by Nom+du+Keyboard · · Score: 1
    Heisenbugs.

    Are there Heisen-features as well?

    --
    "It's the height of ridiculousness to say for those 9 lines you get hundreds of millions."
    1. Re:Heisen-whats? by fforw · · Score: 3, Funny
      Heisenbugs. Are there Heisen-features as well?
      yes. they exist but disappear once you try to use them. A direct result of featuritis.
      --
      while (!asleep()) sheep++
    2. Re:Heisen-whats? by Alsee · · Score: 1

      The question is, is Windows one big Heisenbug or one big Heisenfeature?

      Or is that another aspect of duality where it's really both at the same time?

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
    3. Re:Heisen-whats? by Anonymous Coward · · Score: 0

      Features that exist for demo purposes, but turn out not to be usable after the cheque is written.

  23. Some one call the Ministry of Magic quick! by Anonymous Coward · · Score: 0

    Dumbledore's been talking to Muggles!

  24. Exception Handling by Joe+U · · Score: 3, Interesting

    Not quite on topic, but, I once tried writing code in SQL (in this case for ColdFusion) by using stored procedures and exception handling.

    What a nightmare.

    Many people code unique inserts like this.

    Check for duplicate record.
    if not found, then insert.
    else, prompt user.

    Using exception handling, you code like this.

    insert.
    if error thrown, prompt user.

    One less query, lots less code.

    One problem, the web application language treated all db errors as fatal. When asked, I was told this was by design.

    Thinking about it, I feel that Macromedia didn't want me to code efficiently. You don't sell extra ColdFusion servers if you can offload all your data logic to the SQL server. (Where it belongs)

    1. Re:Exception Handling by Tablizer · · Score: 1

      in this case for ColdFusion....One problem, the web application language treated all db errors as fatal. When asked, I was told this was by design.

      I don't think that is the case. ColdFusion can capture DB errors. For example, it has a statement something like <cfCatch errorType="database">....

      Whether it always works or not is perhaps another matter.

    2. Re:Exception Handling by Joe+U · · Score: 1

      It would, but that's not what I wanted. All errors were fatal, including informative errors, it made EH inside the procedures impossible.

      A simple example.

      Insert record
      If duplicate record error then update record instead
      if other error throw exception

      Now, a duplicate record would throw a fatal error to coldfusion. I could then catch that error in CF, but now I have to code for 2 possible outcomes, a fatal error that isn't fatal, and a fatal error that is fatal. At that point, you might as well split it into individual statements.

    3. Re:Exception Handling by Tablizer · · Score: 1

      I don't know about your setup, but in my experience CF can supply the error message and error code that the DB gives. You can use this error to decide what to do next in the code.

    4. Re:Exception Handling by Joe+U · · Score: 1

      It's possible it was added in in later versions.

      I have not used it much since 4.5. cfstoredprocedure never really worked well for me.

    5. Re:Exception Handling by TheLink · · Score: 1

      "Many people code unique inserts like this.

      Check for duplicate record.
      if not found, then insert.
      else, prompt user."

      There's a race condition in this- a window between the checks and the insert.

      So you could get an error anyway- a DB error if there's a unique constraint, data corruption if there isn't.

      What you could do is lock (prevent other checks and inserts) then check, then insert if would be unique. But the lock could signifcantly affect performance - depends on the locking and the database.

      As you say: many people seem to do it wrong. And so confident that it's the right way to do it.

      While SQL has a "SELECT ... FOR UPDATE" there does not appear to be a "SELECT ... FOR INSERT", or a "put row" feature (update if there, insert if not there).

      SQL doesn't appear to be that well designed. But it's the defacto standard.

      --
  25. Fix it like this.... by fred911 · · Score: 1

    pack
    reindex

    restore backup.....

    repeat

    --
    09 F9 11 02 9D 74 E3 5B - D8 41 56 C5 63 56 88 C0 45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
  26. Ahah! by Infinityis · · Score: 1

    So this Heisenburg guy is to blame for the errors. So...does he work for Microsoft or something?

    1. Re:Ahah! by Anonymous Coward · · Score: 0

      Its Heisenberg you god damn stinkin american

  27. Java does exactly what Bruce wants by chaves · · Score: 4, Insightful
    "That's one of the real problems in today's programming language architecture for exception handling. Each component should list the exceptions that were"That's one of the real problems in today's programming language architecture for exception handling. Each component should list the exceptions that were raised: typically if I call you and you say that you can raise A, B, and C, but you can call Joe who can raise D, E, and F, and you ignore D, E, and F, then I'm suddenly faced with D, E, and F at my level and there's nothing in your interface that said D, E, and F errors were things you caused. That seems to be ubiquitous in the programming and the language facilities. You are never required to say these are all the errors that might escape from a call to me. And that's because you're allowed to ignore errors."

    I bet he didn't look into Java. Java (at least) allows and enforces that. A method will only throw an exception if declares to do so. A caller is forced to provide appropriate handlers or to declare it throws the exceptions not handled at its level. If a method can throw A, B or C but gets D during its execution, it has to in some way map D to either A, B or C (or not throw an exception at all).

    Of course, I am talking here about checked exceptions. Unchecked exceptions are supposed to represent *bugs*, and nobody should be trying to capture those.

    The sad thing is that even seasoned Java programmers do not understand how to write code w.r.t. exception handling. And beginners are usually turned off by the verbosity required by exception handling, so it is usual to see code where people capture (because they are forced by the language) and ignore exceptions (because they are too lazy and/or stupid to understand the consequences).

    1. Re:Java does exactly what Bruce wants by koreth · · Score: 5, Insightful
      it is usual to see code where people capture (because they are forced by the language) and ignore exceptions (because they are too lazy and/or stupid to understand the consequences).
      Ignoring exceptions completely is almost always a bad idea (though what do you do to handle, say, the InterruptedException that can be thrown by Thread.sleep(), or a CloneNotSupportedException from one of your own classes that you know is cloneable?) But there is some legitimate difference of opinion about whether Java's checked exceptions were a good idea or not.

      In my Java code I'm pretty paranoid about catching exceptions and handling them in as intelligent a way as I can, and even so I've run into plenty of situations where there's really no good way to recover from an underlying error and I end up just repackaging the exception into a higher-semantic-level one and tossing it upstream, where the upstream code does the same thing, all the way back out to the UI code, which displays an error message. At which point all I've achieved is cluttering up the intermediate layers of code with useless exception handlers when I could have gotten exactly the same effect by just catching a superclass exception in the UI code and displaying the same error message. (In addition to catching any specific exceptions that would cause a different result, of course.)

      Most likely anyone who's written a Java app of any appreciable size has run into exactly the same thing. In theory, and in small sample snippets of code, checked exceptions seem great. In practice, even some experienced Java gurus find them more hassle than they're worth. I'm quite certain that over the years I've spent far more time writing code to handle checked exceptions than they've saved me in debugging or diagnosis time. That to me is not the sign of a helpful language feature.

    2. Re:Java does exactly what Bruce wants by Spaceman40 · · Score: 0
      That's just what I thought:
      try {
      ...
      } catch (Exception e) { e.printStackTrace(); }

      or WORSE:
      try {
      ...
      } catch (Exception e) { }

      But it's a good mechanism, and just bad programmer practice.
      --
      I [may] disapprove of what you say, but I will defend to the death your right to say it.
    3. Re:Java does exactly what Bruce wants by slamb · · Score: 1
      Ignoring exceptions completely is almost always a bad idea (though what do you do to handle, say, the InterruptedException that can be thrown by Thread.sleep(), or a CloneNotSupportedException from one of your own classes that you know is cloneable?)

      When a seemingly-impossible thing happens, I wrap it in a RuntimeException. Something like this:

      File f = blah;
      try {
      ....InputSource src = new InputSource(f.toURL().toString());
      } catch (MalformedURLException e) {
      ....throw new RuntimeException("java.io.File gave malformed URL.", e); // Unlikely.
      }

      I keep the whole stack trace (including the MalformedURLException's section; JDK 1.4's exception wrapping functionality is nice for this). I describe the impossible thing that appears to have just happened. And I do it in a RuntimeException so I don't have to have throws clauses all the way down the stack for every bizarre thing that could theoretically happen.

      This method is pretty easy, and it puts you in a fairly good situation for debugging things, should the (nearly) impossible happen.

    4. Re:Java does exactly what Bruce wants by qkan · · Score: 1

      Just a thought. May be, the checked exceptions belong to some other level than the code itself? Like, the autodoc or IDE level. So that a coder or maintainer can instantly see the exceptions flow if he wants to, but does not have to mess with it if he does not feel like doing some extra typing today.

    5. Re:Java does exactly what Bruce wants by Anonymous Coward · · Score: 1, Interesting

      Koreth, you are no doubt aware that Java already solves this problem. If you repackage your exception into one derived from RuntimeException, then it becomes an unchecked exception. So you can treat checked exceptions as an 'optional' feature of Java, and avoid them in the (IMO rare) situations where they make no sense.

      Repackaging at every higher semantic level is often worth doing. The power of abstraction comes through treating each class and method as a little black box. Higher level code cannot make assumptions about what goes on lower down, therefore you can change what goes on lower down, without penalty.

      If you are throwing a specific exception, say SQLException, up to higher level code, then if you later want to change your low level code to using XML or something else instead, the higher level code will break.

      (of course, handily, the higher level code will break at compile time, not at runtime - if you are using checked exceptions).

    6. Re:Java does exactly what Bruce wants by a1291762 · · Score: 1

      I've always thought a compiler option should turn off checked exceptions. It would basically turn all Exceptions into RuntimeExceptions, letting you deal with it at runtime (which is really useful when you don't want to just repackage the exceptions but you also don't want to deal with them).

  28. Cool! by Anonymous Coward · · Score: 2, Funny

    I just found my new avatar picture. :)

    ps: not a troll, this guy's a freakin genius. I hope I look like that in 20+ years.

    1. Re:Cool! by EugeneK · · Score: 1

      Take off the glasses, give him a wizard's staff and he's ready for a 3 way battle with Gandalf and Saruman.

  29. Re:A man with one clock only thinks he knows the t by Anonymous Coward · · Score: 1, Funny

    Of course, both clocks could be totally broken but have been set to the same (unchanging) time by obsessive/compulsive someone "tidying up". Then the clocks are each right twice a day but not when you think.

  30. Heisenbugs by Sebby · · Score: 1
    maybe they need some comensators

    --

    AC comments get piped to /dev/null
  31. Whats new with this? by McNihil · · Score: 0

    It is called testers paradox in statistics.

  32. No, it can mean something more by Anonymous Coward · · Score: 0

    It can mean that either the production or development environment isn't stable. For example there could be a bug in the program which depends on precise timings. Even on the same system with the same software it may show up sometimes but not other times.

  33. ROFL! by brunson · · Score: 1

    SB It's certainly true that one of the mind-sets you have to have when you're writing code and designing systems is: What's going to break? There's a broad range of possibilities for approaching this, depending on the type of application or software. If you're writing a Microsoft Word-type program, the way you approach this might be different from if you're designing a heart monitor.

    BL In the heart monitor case, you better keep the heart going, whereas in the Microsoft Word case, you can just give them a blue screen and everybody is used to that.

    --
    09F911029D74E35BD84156C5635688C0
    Jesus loves you, I think you suck
    1. Re:ROFL! by Wilk4 · · Score: 1
      ... or 'what incredibly dumb things can the user input?' or even, 'how is that user going to try to hack my design by inputting 'incorrectly?'

      verify all input, then try to figure out if any 'hostile but perhaps generally valid' inputs could cause trouble...

  34. Oh my heart! by Tablizer · · Score: 1

    In the heart monitor case, you better keep the heart going, whereas in the Microsoft Word case, you can just give them a blue screen and everybody is used to that.

    But blue screens probably cause a lot of stress heart-attacks, so that the end result is the same.

  35. Has language in CS matured? by sapgau · · Score: 2, Funny

    I couldn't help noticing Mr. Lindsay explanations of what a process would or could do. He kept describing it in the first person:

    - "You asked me to do X, I didn't do it."
    - "Aha, this seems like I should go further."
    - "Oh, I see this as one of those really bad ones."
    - "I'm going to initiate the massive dumping now."

    Obviously he is an expert in his field but I'm not sure if he talks this way because of his personality or because there isn't a vocabulary big enough to describe it.

    Would you imagine a medical doctor talking this way?

    - "So the white blood cells fight with the cancer cells: die evil cell, die!!"

    Or an engineer:

    - "The little peg ask it's big brother : can you help me convert this energy into circular motion?"

    1. Re:Has language in CS matured? by zuzulo · · Score: 3, Interesting

      Strangely, this is a phenomenon i have noticed with experts in many different fields who *really* understand what they are doing. They really do have an internal model of what is happening that essentially boils down to this sort of simplicity.

      In fact, the correlation is so strong that I am suspicious of folks who *cannot* boil an arbitrarily complex interaction into an easily understood metaphor.

      Jargon does in no way denote true understanding.

      --
      "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."
    2. Re:Has language in CS matured? by aka.Daniel'Z · · Score: 2, Interesting

      I've talked about some unrelated stuff with some friends once and we came to the conclusion that when you observe something, you compare it to yourself.

      Applying that idea to coding, it would mean that talking like that in relation to code (.. so I will ask the other component ..) would be like understanding and agreeing with what the code is doing. Talking about the code in other ways (.. so it will ask the user ..) may mean that you don't understand it (so you should observe it more as to understand it better) or that you don't agree with the way it works (in this case, if the responsability is yours, you should think about changing the code).

      I always thought of it as an interesting idea - my own experiences working as a programmer and working with other people on a project seems to lead to this.

    3. Re:Has language in CS matured? by Anonymous Coward · · Score: 0

      One thing to remember is that a computer process is a lot more like a human thought process than almost any other mechanical (in the literary, not physical sense) system that human beings have developed, so it makes a lot more sense to think of the computer as going through a set of steps than it is for a reciprocating engine, which is generally actually doing a million things at once. This may be more of a limitation of our imaginations than computers themselves, though, as while we write serial programs, for the most part, hardware designers use all sorts of tricks to parallelize the actual execution.

  36. Heisensoftware by Webmoth · · Score: 1

    Heisensoftware: Programs that are believed to exist but no one seems to know where. Such as Duke Nukem Forever.

    --
    Give me my freedom, and I'll take care of my own security, thank you.
  37. Moderators on drugs? by Anonymous Coward · · Score: 0

    Someone asks someone about a term they used, and it's a troll? Hey, how about not moderating posts if you don't have a clue? I swear all of the kids with moderator points are trying to ruin the site.

    1. Re:Moderators on drugs? by Anonymous Coward · · Score: 0

      You've used SQL for "almost 20 years", and yet you can't guess that "contraints" was a typo for "constraints"? Give me a break. My guess is you aren't old enough to have used anything for 20 years.

  38. Schroedinbugs by Ann+Coulter · · Score: 1
    A design or implementation bug in a program that doesn't manifest until someone reading source or using the program in an unusual way notices that it never should have worked, at which point the program promptly stops working for everybody until fixed. Though (like bit rot) this sounds impossible, it happens; some programs have harbored latent schroedinbugs for years.

    The on-line hacker Jargon File, version 4.1.0

  39. Your sig by TheAntiCrust · · Score: 1

    I think its funny that both problems are easily solvable simply by throwing enough momey at them. Alas, the world makes some sort of sick sense.

    1. Re:Your sig by stanmann · · Score: 1

      Or simply by asking someone(anyone) to take a look at it and help you figure it out, before they even get to the code, miraculously the problem becomes clear.

      --
      Food not Bombs is a nice platitude but it breaks down when you notice that the Bombees are usually well fed
  40. With apologies to Aerosmith... by ahmusch · · Score: 1

    ... dude looks like a yet-ti...

    Perhaps if he shaved occasionally UDB for Unix/Linux/Windows wouldn't be the crufty mess it is today.

  41. old news by jbaltz · · Score: 1

    dayum, youse guys must have slow mail. this was in last month's Queue.

    --
    I am the Lorvax, I speak for the machines.
    1. Re:old news by Anonymous Coward · · Score: 0

      Not everybody reads the same obscure material as you do. You're SOOO up-to-date. Do you watch television as well?

    2. Re:old news by jbaltz · · Score: 1
      Not everybody reads the same obscure material as you do.

      Um, Queue is obscure only to people who don't read.
      You're SOOO up-to-date. Do you watch television as well?
      Yes, and no.
      --
      I am the Lorvax, I speak for the machines.
  42. This thread is a Heisenbug by Anonymous Coward · · Score: 0

    ERROR: You've forgotten that most Slashdotters are initialized with the value of Linux.

  43. Only on slashdot... by pkhuong · · Score: 1

    is the ACM Queue obscure.

    Not everybody reads the same obscure material as you do. You're SOOO up-to-date. Do you watch television as well?

    --
    Try Corewar @ www.koth.org - rec.games.corewar
  44. it'll be back by Wilk4 · · Score: 1
    The problem is that those problems that disappear mysteriously without you knowing why they stopped are very likely to return at the least convenient time, generally after the system is shipped, or during a customer demo.

    That's why I hate to leave those kinds of problems unsolved, where 'solved' is defined as "I know why it went away"

    FWIW, in hardware design Heisenbugs often occur due to things like metastability, race conditions, or noise. There are plenty of boards that will work when you put them on an extender to trouble-shoot them. That often means adding some length or capacitance to i/o just changed things enough to work... yes, they suck as much as software heisenbugs... ;-(

  45. Language in CS? by Anonymous Coward · · Score: 0

    I couldn't help noticing Mr. Lindsay explanations of what a process would or could do. He kept describing it in the first person:

    - "You asked me to do X, I didn't do it."
    - "Aha, this seems like I should go further."
    - "Oh, I see this as one of those really bad ones."
    - "I'm going to initiate the massive dumping now."

    Obviously he is an expert in his field but I'm not sure if he talks this way because of his personality or because there isn't a vocabulary big enough to describe it.


    Expert in his field? Language in CS? I was sure that he was talking about his experience in anilingus with coprophilic overtones...