Tube anarchy! 14 'fare dodgers' push past barriers as staff are nowhere to be seen
CodeSOD: One Last ID
Chris's company has an unusual deployment. They had a MySQL database hosted on Cloud Provider A. They hired a web development company, which wanted to host their website on Cloud Provider B. Someone said, "Yeah, this makes sense," and wrote the web dev company a sizable check. They app was built, tested, and released, and everyone was happy.
Everyone was happy until the first bills came in. They expected the data load for the entire month to be in the gigabytes range, based on their userbase and expected workloads. But for some reason, the data transfer was many terabytes, blowing up their operational budget for the year in a single month.
Chris fired up a traffic monitor and saw that, yes, huge piles of data were getting shipped around with every request. Well, not every request. Every insert operation ended up retrieving a huge pile of data. A little more research was able to find the culprit:
SELECT last_insert_id() FROM some_table_nameThe last_insert_id function is a useful one- it returns the last autogenerated ID in your transaction. So you can INSERT, and then check what ID was assigned to the inserted record. Great. But the way it's meant to be used is like so: SELECT last_insert_id(). Note the lack of a FROM clause.
By adding the FROM, what the developers were actually saying were "grab all rows from this table, and select the last_insert_id once for each one of them". The value of last_insert_id() just got repeated once for each row, and there were a lot of rows. Many millions. So every time a user inserted a row into most tables, the database sent back a single number, repeated millions and millions of times. Each INSERT operation caused a 30MB reply. And when you have high enough traffic, that adds up quickly.
On a technical level, it was an easy fix. On a practical one, it took six weeks to coordinate with the web dev company and their hosting setup to make the change, test the change, and deploy the change. Two of those weeks were simply spent convincing the company that yes, this was in fact happening, and yes, it was in fact their fault.
Married At First Sight UK fans blast experts for 'ANOTHER mismatch' as bride Grace flees the ceremony in tears just minutes after meeting 'lovely' groom Stephen
Why did an SS officer choose to defy Hitler and save the life of an heir to the British throne?
I never want my daughter to see Made In Chelsea. I was walked all over: BINKY FELSTEAD reveals behind-the-scenes heartache, scars she's still in therapy for - and the diagnosis that changed everything
Expert reveals five 'pain free' symptoms of bowel cancer - as cases surge in young people
EV charging biz zaps customers with data leak scare
An electric vehicle charging point provider is telling users that their data may be compromised, following a recent security "incident" at a service provider.…
The 5 Essex villages estate agents say are the best places to live in the county
One of TikTok’s network boffins says it causes ‘massive data wastage’
Before Larry Ellison, Michael Dell and Rupert Murdoch put pen to paper to take over TikTok’s US operations from ByteDance, they might want to consider that one of the Chinese company’s network boffins thinks the app and others like it create “massive data wastage”.…
China tells grumps, trolls, and AIs to stop emoting online
China’s Cyberspace Administration yesterday announced a two-month campaign to quash netizens who “maliciously incite negative emotions”.…
Beloved actress who played loud, loving matriarch in 2002 romcom makes rare outing in LA...can you guess who?
Speed limit set to be reduced on busy accident hotspot road
Bus firm issues apology after causing 'unbelievable stress' for parents and pupils
Two men arrested and police searching for third after Tiptree cannabis raid
Little House on the Prairie star responds to Jason Bateman claiming he was HAZED on set of beloved show
MI6 Launches Dark Web Portal To Attract Spies In Russia
Read more of this story at Slashdot.