a dumb programming mistake
I had a couple of dumb development mistakes come and bite me in the butt this week, and I thought I'd share them here - well, at least one for now.
Without going in to the type of data too much here - the specifics aren't important - the system I've got needed to show a list of data to a user.A Initially we just showed all the data to the one user.A Later, we added other user types.A However, my controller code (MVC-style) simply defined different views to use based on user type, but never changed the query.A So, whether you were an admin, or an area user, or a distinct individual which should only have seen a few items from the list, your view was passed all of the data.A The views simply filtered out which ones to display during a loop.
Stupid?A Yes.A Noticeable?A Not at all.A I looked at this code yesterday and remember thinking at the time a€oyeah, I'll go back and make this better latera€¯ - I was planning on overhauling the user/role system, and I'd fix it all later.A That never happened, and over the past couple years, this has become slower and slower.
Fast forwards to yesterday, and we had 80 processes each being handed *290,000* objects ina view, in most cases to filter and display, say, 60.A Even getting new updated software on the server today was a pain, because we were continually hitting loads of 40-70 (unix loads, 15 min avg of 60 was where we were at most of today).
This came to a head the past couple days because our usage patterns changed - user load spiked both because of timing in the month and the user base has grown.A It was a perfect storm, and I was caught in the middle.A The upside is that I found this major issue and it's resolved.A The downside is that it took almost 2 days (mon and tue) because I was finding other things I thought were the culprits; they were issues, but had no major impact given the 800lb gorilla in the room.
Lessons learned?A I'm not immune to even basic stupid oversights.A The moment I saw this code, I knew the issue, but I've not looked at it ina€¦ 3 years?A There was no need to, so I never went back to audit for stupid code.A Perhaps I need to budget more time for stupidity audits?
Any major faux pas you care to share or admit to?