Description
I used a short (i16) for the artifact ID, thinking "we only have a couple thousand artifacts, we're not overflowing a ~35k integer anytime soon". It turns out that postgres ended up skipping a bunch of artifact IDs, so despite having ~2500 rows we have already exceeded the limit. I temporarily bumped the sequence down manually, but that's a short-term fix at best.
I think we need to run some sort of compaction, but every option I've seen so far is going to take a long time to run against the production database and is likely to cause locks or other problems -- in particular, https://dba.stackexchange.com/questions/111823/compacting-a-sequence-in-postgresql seems to not contain anything easily viable for us.
A possible alternative is to switch the column to an integer ID, but that seems likely to just offset the problem -- I am surprised to see how quickly we hit the 35k limit; maybe we're doing something wrong.
I am also somewhat annoyed that there doesn't appear to be a good way to convince postgres to locate the next empty slot in the column (i.e., finding unused integers). That would be just fine for our use case.
cc @rust-lang/infra -- I am inexperience with postgres or databases in general, would be happy to hear advice on how to best deal with this problem. The database schema is mostly visible in the migrations, and I am happy to run specific queries if it helps.
I manually tried to migrate a few rows by resetting the sequence and then doing update artifact set id = default where id = XXX;
but that takes a long time and seems to lock out some queries (not quite sure, site went down though I think).
Edit: here is a CSV dump of the artifact table: https://gist.github.com/Mark-Simulacrum/e38783c6cb7e93bfc220cfd37c00aedd