Blog Archive

Life Lately and infinite loops

I may have kindof recreated a bug at work that ran an infinite loop that created 40k++ records on our PROD database and impacted a page on my MANAGER'S timesheet.

It's not that bad though, my manager knows of the issue. We've worked out a plan to prevent the issue from happening again (implement better data validation both on UI and backend), but the problem also piqued our curiosity on how infinite loops work.

Being that I'm more interested in the mystery of these loops, I want to uncover what happens during an infinite loop first before I actually apply the bug fixes. I'm sorry! But in my defense, my boss was also curious! Scenario:
I submitted a form that inserts records on a database based on the date range I provided on the UI form. Date range starts on December 14, 2018 and ends on September 21, 2018. Yep it's backwards and that's the issue because the backend took it. Please don't comment on the quality of our code. HAHA

Now, backend logic would loop through the dates on a daily increment and run an insert statement per date. Problem is, since the end date is a past date, the loop will never reach it, thus creating an infinite loop.

The bug created 41,046 records that dates back to December 14, 1901 all the way to January 19, 2038. And for some reason it left out April 1995 to December 2018. So what the hell happened?

Thank God for Google because all of my questions were answered.

I learned that January 19, 2038 is an important date in software development.

January 19, 2038 would be the maximum value a datetime variable in a 32bit integer data type can handle.

Now adding 1 day to that would be an abomination. Datetime couldn't read January 20, 2038. The variable would overflow, wrapping it in a negative value, which the system would interpret as... *drumroll please*

December 14 freaking 1901.

So that's what happened.

The infinite loop started on December 14, 2018 (input start date) and inserted records all the way to January 19, 2038. When it got past that day, December 14, 1901 came next on the calendar and on and on it went until April 1995. Or more accurately, after 10mins of running over the loop -- which is the default remote query timeout value set on our SQL server.

So today... I learned about the 2038 bug, a remake of the Y2K bug where 32bit datatypes storing datetime values would overflow and reset to 1901. Hopefully we already know what to do. Google has a lot of info on it already. And it's still 20 years from now, I wonder what I'd be doing then hehe.

Case closed.

Back to the real life lately...

I, uhhh, have a new bag!

My new everyday bag with Velma from my old Kipling

I'm retiring my 2-year old bag because the fabric tore somehow huhu. My husband bought me a new bag, and it's the most expensive bag I've owned so far (even more expensive than my luggage, apparently). Thank youuuuu my love! This counts as my anniv, birthday, and Christmas gift already so a girl shall ask no more hahahaha.


I was so torn when I found my everyday bag got torn (pun intended). I kept looking for the same model in Kipling stores but I couldn't find it. Either it's phased out or I may have actually brought an imitation one haha. It's a Kipling Anette I bought from TJ Maxx in Minnesota, it's kindof an outlet store for overrun things but I can't be so sure hahaha. Anyway. No luck finding something similar here so I looked at other stores. Never found something I liked at SM Dept store except for those parang Pac-safe anti-theft bags that are overly expensive, so pass. The next day I tried looking at the The Travel Club just to spy on cute bags to search on Shopee/Lazada, I don't care for imitation I just want something nice and sturdy haha. Then I found this...


I've love the functional aesthetic of Hedgren bags but it's one of those super unjustifiably expensive things I'll only get to mindlessly buy if my pay grade was at 6-digits you know? But there it was looking all nice and perfect. So I took it to Shopee, Lazada, Zalora (baka may discount), and FB Marketplace to look for this one model I like. It's Hedgren Appeal, the one with a 13inch compartment. But to no luck. Nobody sells a good enough replica of it. :(

I went to the store for the second time before heading home just to take a final look at it and decide if it's worth the occasional splurge. This is an item I definitely cannot afford without maxing myself out, you know what I mean? Like you have extra but it's not meant for such kinda bags. So my husband rescued me! YEHEY! I have a new bag!

.
.
.

Uhhh, so that's the highlight of my week lol.
Share: