Download your favorite Linux distribution at LQ ISO.
Go Back > Blogs > Musings on technology, philosophy, and life in the corporate world
User Name


Hi. I'm a Unix Administrator, mathematics enthusiast, and amateur philosopher. This is where I rant about that which upsets me, laugh about that which amuses me, and jabber about that which holds my interest most: Unix.
Rate this Entry

The Squareroot of Negative Fun

Posted 08-08-2014 at 08:48 PM by rocket357
Updated 08-08-2014 at 08:56 PM by rocket357

Every now and then, you have one of those days. One of those days where a customer reports that something weird is happening...their database contains *negative* client ids...even though you know for a fact that the client id is an identity column that begins at 1 and counts *up* to MAX_INT (or whatever SQL Server's max integer is). One of those days where you dig through thousands of lines of PHP code to discover that another intern decided to check in a revision where two numeric variables were stuck together with a dash into a string, and a race condition existed such that the variables getting plastered together would always happen, but every now and then the planets would align and the requisite *unplastering* back into integer variables would not occur, and the string would be passed to SQL Server, who would promptly note that this was, indeed, NOT a valid integer. But SQL Server is helpful! Rather than give you a nasty error to cry over, SQL Server interprets the dash to mean *minus*, and subtracts the right, larger integer value from the left, smaller integer value. By golly! How swell is that! So you end up with a stupid bug where a rare race condition could, approximately one time out of tens of thousands, cause a seriously invalid value to be inserted into a table. A table that, quite unfortunately, does NOT contain a proper foreign key reference to the client id, so AGAIN no ugly error message would pop up...just a simple, little, unmistakable, stupid negative client id that cannot be referenced back to a real client id. A stupid little error that stabs your customer in the face when he/she sees it, and makes him/her go "OHMahGerdWTFYo!" and call you violently complaining that negative client ids violate all of the laws of positive integer definitions as held by the universe's concept of math, and that this needs to be fixed immediately because this report (now prominently displaying negative client ids) needs to be turned in TOMORROW to file for their federal funding. Egads. What a day.

Yes, sometimes you have those types of days...but that wasn't today. Today, on the contrary, was an awesome day.

### Disclaimer: This unrepentant series of events occurred at a previous employer many years ago, so not Amazon (and not Rackspace, for that matter).
Posted in Uncategorized
Views 705 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 09:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration