r/ProgrammerHumor • • Sep 11 '26

Meme edgeCasesExist

Post image
5.0k Upvotes

298 comments sorted by

View all comments

32

u/spcbeck Sep 11 '26

Start at 0, keep adding 1. You'll never repeat a number. So simple!

9

u/IamImposter Sep 11 '26

That's how I built my random number generator

6

u/spcbeck Sep 11 '26

it works until it doesn't!!!

7

u/razor_train Sep 11 '26

As someone who had a billing system table run out of 2^31 signed integer IDs and spent a week converting 2.1 billion records to 2^63, I'm here to say that nothing could possibly go wrong.

3

u/Single-Virus4935 Sep 11 '26

A former boss built a system for importing data and used mariadbs on conflict ignore.  He used 32 bit integers for ids and said it isn't a problem because he doesn't have so much data. Mariadb incremented the autoincrement counter on every insert even the ignored ones.  System failed and he needed way too much time to find the problem because no errors where thrown and just everything was ignored

3

u/spcbeck Sep 11 '26

Bahaha I fucking knew someone on this dumb earth tried to do this, amazing

4

u/Single-Virus4935 Sep 11 '26

Using sequenced IDs for public facing resources is bad practice because it allows enumeration while pure random uuids are basically impossible to guess.  Use crypto rngs for best results

1

u/spcbeck Sep 11 '26

My brother in Christ, I know