How I learned to stop worrying and love the datacenter
Comment The UK has bitterly expensive power, an energy minister who sees electricity as bad, a lethargic planning system, and a grid with a backlog for connections running to 2039.…
Inside controversy that's devastated Zara McDermott: As her Thailand documentary is branded 'repulsive', insiders reveal why BBC's to blame, say she's their 'puppet' and tell what happened behind the scenes
Madeleine McCann suspect 'boasts about knowing the scandal of the century' as he tries to buy untraceable phone... after 'being seen wearing a beard and buying takeaways'
The Army cost my daughter her life: Jaysley, 19, killed herself after she was harassed by her manager and sexually assaulted by her superior. Now, as he's convicted, her mother describes her fight to stop other women in uniform suffering the same fate
Thomas Skinner suffers fresh blow amid cheating scandal as 'huge company takes legal action to prevent Strictly star from using Bosh catchphrase to launch new brand'
Don't despair. iFixit says you can still repair that iPhone Air
iFixit has given Apple's slimline new smartphone, the iPhone Air, a thumbs-up for repairability, praising its easy access to key components, despite being the thinnest handset Cupertino has built so far.…
Hot priest under fire after promoting health supplements on social media because 'prayer is not enough'
One pair of jeans is £540, the other is £34.99 from New Look - so can you spot the dupe? Fashion snob LIZ JONES road tests the High Street's best designer lookalikes
Taylor Swift has man arrested at fiancé Travis Kelce's home while trying to serve her deposition papers from Justin Baldoni
Michelin-starred chef sparks authenticity row after adding unlikely ingredient to Bolognese recipe - but he claims it's the traditional way
NASA Introduces 10 New Astronaut Candidates
Read more of this story at Slashdot.
MAFS UK's latest series is the most explosive yet with 'more sex than ever' and producers forced to intervene after 'incredibly shocking' behaviour that left experts 'on the edge of their seats'
I'm a vascular surgeon and there are VERY early signs something is wrong in your body: 'It's whispering to you'
MARTIN BECKFORD: A very bold move, but can Farage's migrant benefits plan really save £230billion?
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.