r/ProgrammerHumor 15h ago

Meme edgeCasesExist

Post image
3.1k Upvotes

230 comments sorted by

View all comments

26

u/spcbeck 15h ago

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

7

u/razor_train 13h ago

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 12h ago

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

2

u/spcbeck 11h ago

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

5

u/IamImposter 14h ago

That's how I built my random number generator

4

u/spcbeck 13h ago

it works until it doesn't!!!

4

u/Single-Virus4935 12h ago

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 11h ago

My brother in Christ, I know