What happens to an order ID when a transaction rolls back?
One service stores orders in PostgreSQL 16 and generates primary keys using GENERATED ALWAYS AS IDENTITY. Another uses an InnoDB table in MySQL 8.4 with AUTO_INCREMENT. The database allocates an ID for a new order, but the transaction later rolls back. What happens to that value, and which ID will the next order receive? Can gaps in order IDs tell you whether an order was lost? How would you assign accounting document numbers if the business requires strictly consecutive numbering with no gaps?
ExplainTransactions and locksMiddleBackendData EngineerQA