there is an application processing system, there is a form for it. when creating an application, its id (autoincrement) is issued. it may happen that the form will work, and the system will not be available, it must be done so that it would look as if everything works. system and form on different servers

How best to organize data storage with the ability to issue a future identifier in a system that is not available?

I thought about the following: storing json data in a local server database with a form with reservation id for requests that are not exactly busy, but MySQL (5.5.6) does not allow creating arbitrary id (autoincrement counter changes to maximum + 1 immediately), t. e. When creating these applications in the system, I immediately "break" the autoincrement. Is it possible to get around this?

Or are there any other options?

  • one
    Somehow use the UUID, for example - andreymal
  • You can not predict the ID in the form of auto-increment in a similar system, it is better to use the UUID and sort by the date the application was made. - Alex Krass
  • UUID представляет собой 16-байтный (128-битный) номер , the problem is that I need to give out some number in the form, I have numbers in the form of 6 digits, it turns out I will have to show instead of 6 and 16 characters and nothing else? - Maximmka
  • one
    As an option, you can start a separate (micro) service that will only deal with issuing id (resolving all collisions) and nothing else, if it is possible to organize its permanent availability. And then put the issued id in MySQL without any auto - increments - andreymal
  • one
    @Maximmka Norm is an idea, so you answered your question :) Still as an option, issue with a prefix that this is a local id (as in your version), and save on the server with the form separately, at least in MySQL, at least in some Redis which local id which server eventually was issued - Mike

1 answer 1

Thanks to everyone who comments.

how did:

when the system is unavailable, the data is saved to the local database in json format, an additional field is added which contains an arbitrary identifier with a prefix. Crown (on the side of the referral system) checks the existence of saved records on the server with a form every day.

the search will be carried out either by the standard identifier or by the field, depending on the presence of the prefix in the requested identifier.