this post was submitted on 06 Nov 2023
1207 points (98.6% liked)

Programmer Humor

32410 readers
1 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] magic_lobster_party@kbin.social 129 points 2 years ago (4 children)

Well at least we got a backup, right?

Right???

[–] andrew@lemmy.stuart.fun 54 points 2 years ago (2 children)

It last ran a week ago and we technically haven't tested it. Just our hot replicas which also just deleted all that data.

[–] TheGreenGolem@lemm.ee 10 points 2 years ago

And of course by now every downstream system replicated AND CACHED that data.

[–] Amends1782@lemmy.ca 3 points 2 years ago

Holy shit the truth with replication deleting the data you needed too true lmao

[–] Alexstarfire@lemmy.world 9 points 2 years ago (1 children)

Back up? No, we only go forward in this company

[–] _dev_null@lemmy.zxcvn.xyz 3 points 2 years ago

"That's why the windshield is bigger than the rear view mirror, we should be vigilant in remaining forward looking."

Said by an exec in my chain of command when he caused a huge cascading fuck up in the organization and there was no postmortem allowed.

[–] DudeDudenson@lemmings.world 5 points 2 years ago

Backup? What is this backup you speak of?

[–] saltnotsugar@lemm.ee 97 points 2 years ago (2 children)

This is what we in the industry refer to as a “big oof.”

[–] IHawkMike@lemmy.world 20 points 2 years ago

I thing the technical term for this is an RGE.

(Resume Generating Event)

[–] ultratiem@lemmy.ca 6 points 2 years ago* (last edited 2 years ago)

But it’s only, like, a handful of rows 🙃

[–] MyNameIsRichard@lemmy.ml 67 points 2 years ago (1 children)

It's a good way to wake yourself up in the morning

[–] toxic_cloud@lemmy.world 19 points 2 years ago

Doctors HATE this one simple trick! Lose up to 100% of MyChart data - and KEEP it off!

Can help reduce blood pressure, high cholesterol, weight, height, gender, name and more to NULL! Wake up feeling NULL and NULL!

[–] palordrolap@kbin.social 47 points 2 years ago* (last edited 2 years ago) (1 children)

8388409 = 2^23 - 199

I may have noticed this on a certain other aggregator site once upon a time, but I'm still none the wiser as to why.

199 rows kind of makes sense for whatever a legitimate query might have been, but if you're going to make up a number, why 2^23? Why subtract? Am I metaphorically barking up the wrong tree?

Is this merely a mistyping of 8388608 and it was supposed to be ±1 row? Still the wrong (B-)tree?

WHY DO I CARE

[–] driving_crooner@lemmy.eco.br 33 points 2 years ago* (last edited 2 years ago) (2 children)

Are you Ramanujam reborn or a nerd who put every number they found on wolfram alpha?

[–] palordrolap@kbin.social 22 points 2 years ago (1 children)

In a place for programmer humour, you've got to expect there's at least one person who knows their powers of two. (Though I am missing a few these days).

As for considering me to be Ramanujan reborn, if there's any of Srinivasa in here, he's not been given a full deck to work with this time around and that's not very karmic of whichever deity or deities sent him back.

load more comments (1 replies)
[–] LastYearsPumpkin@feddit.ch 12 points 2 years ago

Ramanujan reborn - the main protagonist from the Wheel of Maths books.

[–] Rhinoshock@lemmy.world 25 points 2 years ago (3 children)

In T-SQL:

BEGIN TRANSACTION

{query to update/delete records}

(If the query returned the expected amount of affected rows)

COMMIT TRANSACTION

(If the query did not return the expected amount of affected rows)

ROLLBACK TRANSACTION

Note: I’ve been told before that this will lock the affected table(s) until the changes made are committed or rolled back, but after looking it up it looks like it depends on a lot of minor details. Just be careful if you use it in production.

[–] jaybone@lemmy.world 7 points 2 years ago (1 children)

Lol why did I have to scroll so far to see ROLLBACK

[–] rwhitisissle@lemmy.ml 3 points 2 years ago

Because this is c/programmerhumor and the OP hasn't covered ROLLBACK yet in his sophomore DB class.

[–] tweeks@feddit.nl 4 points 2 years ago

If for example a client application is (accidentally) firing doubled requests to your API, you might get deadlocks in this case. Which is not bad per se, as you don't want to conform to that behaviour. But it might also happen if you have two client applications with updates to the same resource (patching different fields for example), in that case you're blocking one party so a retry mechanism in the client or server side might be a solution.

Just something we noticed a while ago when using transactions.

[–] joemo@lemmy.sdf.org 3 points 2 years ago

Transactions are the safe way of doing it.

You can also return * to see the changes, or add specific fields.

Like for example:

Begin; Update users Set first_name='John' Where first_name='john' Returning *;

Then your Rollback; Or Commit;

So you'd see all rows you just updated. You can get fancy and do a self join and see the original and updated data if you want. I like to run an identifying query first, so I know hey I should see 87 rows updated or whatever.

Haven't had any issues with table locks with this, but we use Postgres. YMMV.

[–] fushuan@lemm.ee 20 points 2 years ago (1 children)
[–] Blackmist@feddit.uk 15 points 2 years ago (2 children)

I don't understand environments that don't wrap things in transactions by default.

Especially since an update or delete without a where clause is considered valid.

[–] finestnothing@lemmy.world 9 points 2 years ago* (last edited 2 years ago)

I'm a data engineer that occasionally has to work in sql server, I use dbeaver and have our prod servers default to auto-wrap in transactions and I have to push a button and confirm I know it's prod before it commits changes there, it's great and has saved me when I accidentally had a script switch servers. For the sandbox server I don't have that on because the changes there don't matter except for testing, and we can always remake the thing from scratch in a few hours. I haven't had an oppsie yet and I hope to keep that streak

[–] Ultraviolet@lemmy.world 3 points 2 years ago

SQL Server technically does behind the scenes, but automatically commits, which kind of defeats the purpose.

[–] Sunforged@lemmy.ml 20 points 2 years ago

Legit have nightmares about this.

[–] kamen@lemmy.world 20 points 2 years ago

This is now the correct database.

[–] erogenouswarzone@lemmy.ml 17 points 2 years ago (2 children)

You can also do this by forgetting a WHERE clause. I know this because I ruined a production database in my early years.

Always write your where before your insert, kids.

[–] themusicman@lemmy.world 5 points 2 years ago

Always start every command with EXPLAIN and don't remove it until you've run it

load more comments (1 replies)
[–] meldrik@lemmy.wtf 17 points 2 years ago

This is missing NSFW tag!

[–] nuke@yah.lol 17 points 2 years ago

Just hit Ctrl+Z to Undo

[–] Naomikho@monyet.cc 15 points 2 years ago* (last edited 2 years ago)

I actually screwed up twice on dev environment. Luckily the second case was salvageable without using data from an old backup(I wasn't given one that time) and I managed to sweep it up fast.

I started testing my queries super carefully after the first incident, but I was too tired once that I forgot to restrict the update scope for testing and screwed up again.

[–] derfl007@lemmy.wtf 12 points 2 years ago

oopsie daisy moment

[–] SzethFriendOfNimi@lemmy.world 10 points 2 years ago* (last edited 2 years ago) (1 children)

Transactions are your friend here

Begin transaction;

Then

Your sql here

Double/triple check the messages/console for results. Look good?

Commit;

Worried?

Rollback;

Just be sure to mind your transaction logs for long running queries and by all things holy be sure you’re not doing this to a live db with a ton of transactions since you’re basically pausing any updates until the commit or rollback on the affected tables

[–] JoMiran@lemmy.ml 5 points 2 years ago

Me: "Ok. What's the big deal."

Also me: "Less than a million affected. That's nothing."

Still me: "Rule 1: Never let pesky details get in the way of a funny meme."

Ultimately me: 😱😂 "That guy is in for a rough Monday!"

[–] TangledHyphae@lemmy.world 10 points 2 years ago* (last edited 2 years ago) (1 children)

Looks like little bobby tables is at it again. (edit: for reference: https://xkcd.com/327/)

Edit #2: For lemmy app users: https://xkcd.com/327

And thanks to @Gestrid@lemmy.ca for the correction.

[–] Gestrid@lemmy.ca 3 points 2 years ago (2 children)

My Lemmy app doesn't like that parenthese. Fixed link in case anyone else is affected: https://xkcd.com/327/

load more comments (2 replies)
[–] Tenthrow@lemmy.world 8 points 2 years ago

This is giving me PTSD

[–] argo_yamato@lemm.ee 6 points 2 years ago

Had something like that happen to a local dev database (thankfully). A dev next me blurts out "how to I rollback an update in SQL server"? He was used to Oracle and how easy it is to rollback something. Had to explain that commit just happens in SQL server regardless of whether or not you put that commit line in.

[–] neosheo@discuss.tchncs.de 4 points 2 years ago

I'm dying lol

wasnt halloween last week. stop scarin me

[–] r00ty@kbin.life 3 points 2 years ago

For MS-SQL. If it is production, it has a full transaction log, right? I mean I know for development use I turn that off, but for live data you want that on. You should be able to roll back to any point since the last time it was truncated. Or right before hitting return to whatever level of accuracy you're comfortable with.

load more comments
view more: next ›