73
Root
2y

I’m surrounded by idiots.

I’m continually reminded of that fact, but today I found something that really drives that point home.

Gather ‘round, everybody, it’s story time!

While working on a slow query ticket, I perused the code, finding several causes, and decided to run git blame on the files to see what dummy authored the mental diarrhea currently befouling my screen. As it turns out, the entire feature was written by mister legendary Apple golden boy “Finder’s Keeper” dev himself.

To give you the full scope of this mess, let me start at the frontend and work my way backward.

He wrote a javascript method that tracks whatever row was/is under the mouse in a table and dynamically removes/adds a “.row_selected” class on it. At least the js uses events (jQuery…) instead of a `setTimeout()` so it could be worse. But still, has he never heard of :hover? The function literally does nothing else, and the `selectedRow` var he stores the element reference in isn’t used elsewhere.

This function allows the user to better see the rows in the API Calls table, for which there is a also search feature — the very thing I’m tasked with fixing.

It’s worth noting that above the search feature are two inputs for a date range, with some helpful links like “last week” and “last month” … and “All”. It’s also worth noting that this table is for displaying search results of all the API requests and their responses for a given merchant… this table is enormous.

This search field for this table queries the backend on every character the user types. There’s no debouncing, no submit event, etc., so it triggers on every keystroke. The actual request runs through a layer of abstraction to parse out and log the user-entered date range, figure out where the request came from, and to map out some column names or add additional ones. It also does some hard to follow (and amazingly not injectable) orm condition building. It’s a mess of functional ugly.

The important columns in the table this query ultimately searches are not indexed, despite it only looking for “create_order” records — the largest of twenty-some types in the table. It also uses partial text matching (again: on. every. single. keystroke.) across two varchar(255)s that only ever hold <16 chars — and of which users only ever care about one at a time. After all of this, it filters the results based on some uncommented regexes, and worst of all: instead of fetching only one page’s worth of results like you’d expect, it fetches all of them at once and then discards what isn’t included by the paginator. So not only is this a guaranteed full table scan with partial text matching for every query (over millions to hundreds of millions of records), it’s that same full table scan for every single keystroke while the user types, and all but 25 records (user-selectable) get discarded — and then requeried when the user looks at the next page of results.

What the bloody fucking hell? I’d swear this idiot is an intern, but his code does (amazingly) actually work.

No wonder this search field nearly crashed one of the servers when someone actually tried using it.

Asdfajsdfk.

Comments
  • 17
    ok, I honestly did not understand everything, but if a fucking search field starts to crash servers, you just know, that things are fucked up an a major scale.
  • 17
    Ivory Tower Mathematician

    Writes bug-free code which does exactly what it should in a glacial pace consuming all available RAM and CPU.

    Preferred phrase: "As everyone sees right away" followed by an hour-long monologue of gibberish.

    Place next to an enemy's Java Architect to double that opponents infrastructure costs.
  • 10
    An intern writing code like that would not get within shouting distance to any db code, and probably not any live project.

    I would expect an intern at that level to sit with a mentor, or if that is mot possible, get some side project to learn on.
  • 4
    Insert Ryan Reynolds in the Harold and Kumar movies gift of "but....why?"

    How is this person not being monitored like an intern whenever he submits a push??????! This is an absolute nightmare
  • 0
    bro what
  • 12
    @Voxera @AleCx04 He’s the lead dev. He wrote the first line of code at the company fifteen or so years ago, and works with the CTO directly. The only reason he’s not the CTO himself is because he has turned the offer down, repeatedly.

    And yet this is the quality of code he writes. He has also argued with me (during a security review) over exposing partially-redacted passwords to agents and how it’s not a security concern. (Exposing first 4 and length of all consumer passwords to agents.)

    I am absolutely baffled at how this guy still has a job, let alone why he’s held up as the best of the best for all others to strive towards. Then again, he’s close personal friends with the CEO and VP of engineering, which kind of explains it. 🤦🏻‍♀️

    I also think they’re completely oblivious to how terrible his work is. Only the VP is (was) a dev, and I firmly believe he was worse than this ten years ago when he still wrote code.

    Ergh.
    I really need to leave.
    But I also really need the bloody insurance. Fuck.
  • 5
    I have a personal project written in MERN stack that uses live search and a) debounces keystrokes perfectly b) does actual pagination (doing a full table query and dumping the rest is NOT actual pagination). I’m sure that’s just the tip of the iceberg as to the ways this app i did on my old laptop with charging issues is better than the crap this “legend” did on his expensive Apple machine! Hopefully by now he figured out how to use “skip” and “limit”
  • 4
    just memcache all the things and be done with it. You can't fix the unfixable, just add something that will cost even more CPU and RAM to this magnificent example of "I have the political pull l, and you don't" POS.
  • 2
    Reminds me of a search I made recently. It is debounced, mind you, and the indexes keep the CPU load very low. But every once in a while, a query just goes on forever (half an hour), and it kills the CPU. No clue why, so we're gathering logs and shit. Will have to add caching later as well.

    Anyway, my condolences. Sounds like a horrible place.
  • 1
    I’m somewhat forgiving the jquery thing where he switches the class (maybe he’s not a “front end type”) but if he’s OK with doing a full table query for a page of rows then this guy is going to have a really hard time finding a job if he loses his. He might have an impressive resume (he worked for Apple for reasons above me) but he’ll die at tech screens. I might seem harsh going by this one example but I doubt it’s the only turd he left in this toilet. And I’m a bit weirded out that he allowed this destructive problem to stick bc it’s an easy ten minute fix
  • 1
    Wait I’m an idiot! The system is probably so badly designed and fragile that changing the query will likely lead to a ton of other bugs. You couldn’t even change html on a web page without bringing down the ship. Adding anything to that complex pile of crap is like playing a bad game of Jenga
  • 1
    @TeachMeCode Yes indeed :)

    Except it wasn’t just changing the markup, it required changing things several layers of abstraction in.
  • 1
    No wonder these corporates now lead the charge against meritocracy and are all about "giving everyone a chance".

    But seriously, it's fascinating but just as worrying how consistently you manage to run into these situations
  • 1
    @RexGalilae Yeah…
    You and me both. It makes me wonder if it’s me, or if I just put up with crap because it’s what I’m used to.

    The only place I truly enjoyed working at was the game studios. Both one of my first few jobs, and the last studio I worked at. Everywhere else has been awful.
  • 0
    @Root Once I told my manager "we are surrounded by idiots" to which she responded "if we are surrounded, maybe we are one of them".

    Staying there or leaving, it is your call. If the insurance is worth it and makes you stay, still a choice you are making.
  • 0
    @Root
    I see. What made you change career paths? Working corporate has its perks but under shitty management, it can be a real pain
  • 0
    My thought goes to whoever accept his MR
  • 2
    @Root that insurance better cover every damn thing. Not just normal “good” insurance that doesn’t let a medical expense get too big. No this insurance better be covering some extra shit like plastic surgery, massages and house cleaning too!
  • 1
    @jeeper Ha. At the moment it’s paying for therapy and meds and similar expenses — amusingly, most are things I probably wouldn’t need if I didn’t work there.

    I’m not keeping this job permanently. Not a chance. Just until I stop dying so much.
  • 0
    Sucking the shit out your arse with a hoover works instead of going to the toilet.

    But would you do it?

    I think not.
  • 1
    I had the best laugh. Thank you.
Add Comment