News for hackers. Stuff that matters.
Re:Why HN was down by sehugg on Monday February 18, 2013 @02:31PM (#5240119)
Great postmortem and good lessons to learn here:

* Don't manually modify database without a well-tested procedure and another pair of eyes

* Don't leave persistent problems (e.g. memory problems) uninvestigated so that you miss new problems with similar symptoms

* Don't push new code to production while operational problem is ongoing (unless it addresses the operational problem)

I'm pretty sure I've repeated this exact same sequence before with similar results...

Re:Why HN was down by JonM on Monday February 18, 2013 @03:44PM (#5240519)
* Don't push new code to production while operational problem is ongoing (unless it addresses the operational problem) ^^ absolutely!
Re:Why HN was down by scotty79 on Monday February 18, 2013 @03:42PM (#5240507)
* while you are displaying a tree keep track of the items you already displayed so you can detect a cycle
Re:Why HN was down by sukuriant on Monday February 18, 2013 @04:01PM (#5240607)
I think the assumption there was that it was safe, since the code disallowed this from happening, naturally.
Re:Why HN was down by scotty79 on Monday February 18, 2013 @05:10PM (#5241074)
Assumption is the mother of all screw ups.

Even if you think that the code that creates and modifies your data will not put it in some undesired state, the code that uses this data should assume that the data may be in all undesired states you can dream up and should do its best not to do something seriously bad when that happens (like landing in endless loop/recursion or executing possibly user provided strings).

Re:Why HN was down by zzzeek on Monday February 18, 2013 @05:08PM (#5241064)
use CHECK constraints to prevent invalid data patterns when possible.
Re:Why HN was down by erichocean on Monday February 18, 2013 @05:18PM (#5241121)
Sadly, even that isn't enough.

In our production database, I used CHECK constraints religiously. Worked great.

Then one day, I was no longer able to commit ANY transactions to a particular table, even completely innocuous ones.

The problem? The database itself had violated its own CHECK constraint on a previous commit, but was enforcing it on all subsequent commits, causing them to fail. Brilliant.

Moral: not even CHECK constraints will save you.

----

P.s. This was a proprietary database, and when I reported the problem to the vendor (eventually, I figured out how to reproduce it), the vendor actually refunded our (expensive) support contract rather than fix the bug -- they couldn't figure out how to fix it despite having a small bug report that reproduced the problem.

In the end, I actually had to remove the CHECK constraint altogether. :(

Re:Why HN was down by zzzeek on Monday February 18, 2013 @05:32PM (#5241206)
> The problem? The database itself had violated its own CHECK constraint on a previous commit, but was enforcing it on all subsequent commits, causing them to fail. Brilliant.

I've never heard of that, and unless you're using a really buggy, broken database, it should not be possible.

> P.s. This was a proprietary database, and when I reported the problem to the vendor

well there you go. I think in practice, a simple CHECK constraint like the one we'd do here (literally, comment_id > parent_comment_id) is pretty easy to put one's faith into.

Re:Why HN was down by papsosouid on Tuesday February 19, 2013 @10:03AM (#5244610)
That's hard to do when you are afraid of databases and just store everything in files.