3 ms·
I don't think it is not possible to enforce perfectly sequential numbers at the application level. This is the same problem as multiple threads trying to incre
by vivekseth 6y ago
I don't think it is not possible to enforce perfectly sequential numbers at the application level.
This is the same problem as multiple threads trying to increment the same global variable. Unless there is mutual exclusion while the variable is being read/incremented there will be race conditions.
I think the only way to enforce mutual exclusion for applications would be at the database layer (or any other layer where there is 1 resource that is shared between each application peer).
- dkhenry 6y agoI think by "application level" they are saying "using transactions at the application level". If you require a strict sequence of numbers then you BEGIN, READ, INSERT, COMMIT, that is really what you want so just do it explicitly. If the COMMIT fails because of a duplicate key then you start over.