KamoCRM

Mint an opaque UUID token, in one insert

FeatureMediaService
Shipped
20 ஆகஸ்ட், 2026 அன்று 2:43 PM UTC
Author
Kamo
Commit
3bd5e82

createCode generates the token itself, so there is nothing to read first and nothing for two tabs to collide over. That removes the whole apparatus the old sequential token needed: the max(iteration) + 1 read, the collision-detecting retry, and the REQUIRES_NEW TransactionTemplate that retry needed because a unique_violation aborts the transaction it happened in on YSQL. One save, done. A UUID collision is not a case worth writing code for; the unique index on CODE stays as the backstop so an impossible one fails loudly rather than quietly attributing two members' traffic to one row.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing