A wasted day of debugging
Imagine a program that parses log files for the previous day and
generates a summary report by hour of day and writes that to a
database. The key of the table is a datetime field, and that
works well because you'll only ever have one record for any given day
Now imagine that it stops working on Halloween. The error says,
"primary key constraint violation." So basically it tried to
write two rows with the same date and hour. What would be your
very first thought as to the problem?
Sadly, I'm not that smart. I looked through the code.
Traced through the code. Had it write various debugging
info. Put in some exception handling and had it dump the data it
was trying to write when the error occurred. I saw what it was
doing - trying to write "10/30 1:00" twice in a row. But I
couldn't for the life of me figure out where the bug was that caused
that to happen.
Then I noticed that the clock on the wall was an hour fast because nobody had adjusted it yet for daylight savings time.
Log files should really use GMT. You know? I wasted a good 4 hours on something that should have taken 30 seconds.
Or you shouldn't have used the date and time as a primary constraint solo being that time is variable.
If things don't work when they should, here's a checklist:
- typo, as in: brackets, endTheme vs endtheme, scope;
- no data displayed even though the output code is good: Is there any data to display?
- Strange errors: bad/unforeseen data input?
- Date things: daylight savings, leap years, 31/30 days, zero-based months, min date/max date, GMT offset;
- CSS not applying: cascade working properly? Notice: [#foo .plup] is bigger than [.plup] and [#foo] is bigger than [.plup]
- JS not executing: is the damn thing included?
For anything else, you're stuck with a 4 hour debugging time.
If you're using date as unique, at the very least go with the millisecond time and parse the date from that. Using a human date/time as identifier is setting yourself up for trouble. Saying "[exceptional condition] is not gonna happen" is not an argument, because, mark my words, it WILL happen.
my primary guess would be it happening due to daylight savings time.
This is an educated guess since DST ended the day before halloween.