Unique ID generation method and device, equipment and storage medium

By judging clock callbacks in the target service on the server and redistributing the target machine ID, the problem of unique ID duplication caused by clock callbacks is solved, and the uniqueness and stability of the ID are achieved.

CN119814765APending Publication Date: 2025-04-11BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411865827.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

Clock callback causes the generated unique ID to be duplicated, and the prior art is difficult to effectively solve this problem.

Method used

In the target service on the server, it is determined whether a clock callback has occurred. If it occurs, the machine ID distribution operation is triggered to obtain the target machine ID, and a unique ID is determined based on the ID and the current machine clock.

Benefits of technology

By redistributing the target machine ID, the possibility of generating a duplicate unique ID is reduced, and the ID duplication problem caused by clock callback is effectively solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814765A_ABST
    Figure CN119814765A_ABST
Patent Text Reader

Abstract

The invention provides a unique ID generation method and device, equipment and a storage medium, and relates to the technical field of data processing, in particular to the technical field of ID generation. According to the specific implementation scheme, the method comprises the following steps: in response to a received unique ID allocation request for a target object, judging whether clock callback occurs on a server; if so, triggering a target operation for performing machine ID distribution for the target service to obtain a target machine ID; and based on the target machine ID and the current machine clock of the server, determining a unique ID needing to be allocated for the target object. Visibly, according to the scheme of the invention, the situation that a repeated unique ID is generated due to clock callback can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, in particular to the field of ID generation technology, and specifically to a unique ID generation method, device, equipment and storage medium. Background Art

[0002] Generally, there is a need to assign a unique ID to a target object to identify the target object, and the target object may be a painting, a video, a file, etc. The generation of the unique ID depends on the machine clock and the machine ID provided by the device that assigns the unique ID to the target object. However, if the clock is dialed back, the generated unique ID may be repeated. Among them, the clock dials back means that the current machine time of the device is different from the standard time, so the current machine time of the device is corrected based on the standard time, causing the machine time of the device to return to an earlier time than the current machine time. The device may be a server or other device that can perform the operation of generating a unique ID. Summary of the invention

[0003] The present disclosure provides a unique ID generation method, apparatus, device and storage medium for effectively reducing the situation where duplicate unique IDs are generated due to clock dial-back.

[0004] According to one aspect of the present disclosure, a unique ID generation method is provided, which is applied to a target service on a server side, comprising:

[0005] In response to receiving a unique ID allocation request for a target object, determining whether a clock dialback occurs on the server;

[0006] If it occurs, a target operation for distributing a machine ID to the target service is triggered to obtain a target machine ID; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service;

[0007] Based on the target machine ID and the current machine clock of the server, a unique ID to be allocated to the target object is determined.

[0008] Optionally, before determining whether the server has a clock dialback, the method further includes:

[0009] Detecting whether there is a machine ID distributed for the target service in the target cache file; wherein the target cache file is a file used to record the machine ID distributed for each service;

[0010] If it is detected that there is, the step of determining whether the clock of the server is dialed back is triggered;

[0011] If it is detected that the target machine ID does not exist, a target operation for distributing the machine ID to the target service is triggered to obtain the target machine ID.

[0012] Optionally, the method further includes:

[0013] If the clock is not dialed back, if the machine ID distributed for the target service exists in the target cache file, obtaining the machine ID distributed for the target service existing in the target cache file;

[0014] Based on the acquired machine ID and the current machine clock of the server, a unique ID to be allocated to the target object is determined.

[0015] Optionally, determining whether a clock dialback occurs on the server includes:

[0016] Determine whether the time represented by the current machine clock of the server is earlier than the most recent writing time of the machine ID in the target cache file; wherein the target cache file is a file for recording the machine IDs distributed for each service, and each machine ID existing in the target cache file is periodically rewritten;

[0017] If it is earlier, it is determined that the clock of the server is dialed back; otherwise, it is determined that the clock of the server is not dialed back.

[0018] Optionally, the triggering of a target operation for distributing a machine ID for the target service to obtain a target machine ID includes:

[0019] Triggering a predetermined machine ID generation module to generate a machine ID, and obtaining a current machine ID;

[0020] Instructing the predetermined machine ID generation module to perform a specified detection to obtain a detection result; wherein the specified detection includes detecting whether the current machine ID is set with a target lock; the setting time of any machine ID set with a target lock includes after being distributed to a service for the first time;

[0021] Based on the detection result, determining whether the current machine ID meets the conditions for being used as the target machine ID;

[0022] If satisfied, the current machine ID is used as the target machine ID; otherwise, the step of triggering the predetermined machine ID generation module to generate a machine ID to obtain the current machine ID is executed.

[0023] Optionally, there is an increasing relationship between the machine ID generated by the predetermined machine ID generating module at any time and the machine ID generated last time corresponding to the any time;

[0024] And, when the machine ID generated by the predetermined machine ID generation module reaches a predetermined maximum ID value, the predetermined machine ID generation module is initialized, and the initialization is used to enable the generation of the machine ID to start from a predetermined minimum value.

[0025] Optionally, the method further includes:

[0026] After obtaining the target machine ID, a lock request is sent to the predetermined machine ID generation module, so that the predetermined machine ID generation module sets a target lock for the machine ID distributed to the target service.

[0027] Optionally, the target lock set for any machine ID has an expiration time;

[0028] The method further comprises:

[0029] After sending a lock request to the predetermined machine ID generation module, in response to reaching an expiration time, a specified request for renewing the lock is sent to the predetermined machine ID generation module so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service.

[0030] Optionally, the target machine ID is a machine ID of another service that has not been distributed to the functional service to which the target service belongs before being distributed to the target service.

[0031] Optionally, the determining, based on the target machine ID and the current machine clock of the server, a unique ID to be allocated to the target object includes:

[0032] The triggering number issuing module executes an operation of determining a unique ID to be allocated to the target object by using the target machine ID and the current machine clock of the server.

[0033] According to another aspect of the present disclosure, a unique ID generation device is provided, which is applied to a target service on a server side, comprising:

[0034] A determination module, configured to determine whether a clock is dialed back on the server in response to receiving a unique ID allocation request for a target object;

[0035] A trigger module, for triggering a target operation for distributing a machine ID to the target service to obtain a target machine ID if it occurs; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service;

[0036] The determination module is used to determine the unique ID required to be allocated to the target object based on the target machine ID and the current machine clock of the server.

[0037] Optionally, the judgment module is further used to detect whether there is a machine ID distributed for the target service in the target cache file before judging whether the clock is dialed back on the server; wherein the target cache file is a file used to record the machine ID distributed for each service;

[0038] If it is detected that there is, the step of determining whether the clock of the server is dialed back is triggered;

[0039] If it is detected that the target machine ID does not exist, a target operation for distributing the machine ID to the target service is triggered to obtain the target machine ID.

[0040] Optionally, the device further comprises:

[0041] an acquisition module, for acquiring the machine ID distributed for the target service in the target cache file if the clock is not dialed back and the machine ID distributed for the target service exists in the target cache file;

[0042] The determination module is used to determine the unique ID required to be allocated to the target object based on the acquired machine ID and the current machine clock of the server.

[0043] Optionally, the judging module includes:

[0044] A judging unit, used to judge whether the time represented by the current machine clock of the server is earlier than the most recent writing time of the machine ID in the target cache file; wherein the target cache file is a file used to record the machine IDs distributed for each service, and each machine ID existing in the target cache file is periodically rewritten;

[0045] If it is earlier, it is determined that the clock of the server is dialed back; otherwise, it is determined that the clock of the server is not dialed back.

[0046] Optionally, the trigger module includes:

[0047] A trigger unit, used to trigger a predetermined machine ID generation module to generate a machine ID, and obtain a current machine ID;

[0048] An instruction unit, used to instruct the predetermined machine ID generation module to perform a designated detection and obtain a detection result; wherein the designated detection includes detecting whether the current machine ID is set with a target lock; the setting time of any machine ID set with a target lock includes after it is first distributed to a service;

[0049] a determination unit, configured to determine whether the current machine ID satisfies a condition for being a target machine ID based on the detection result;

[0050] If satisfied, the current machine ID is used as the target machine ID; otherwise, the step of triggering the predetermined machine ID generation module to generate a machine ID to obtain the current machine ID is executed.

[0051] Optionally, there is an increasing relationship between the machine ID generated by the predetermined machine ID generating module at any time and the machine ID generated last time corresponding to the any time;

[0052] And, when the machine ID generated by the predetermined machine ID generation module reaches a predetermined maximum ID value, the predetermined machine ID generation module is initialized, and the initialization is used to enable the generation of the machine ID to start from a predetermined minimum value.

[0053] Optionally, the device further comprises:

[0054] The first sending module is used to send a lock request to the predetermined machine ID generating module after obtaining the target machine ID, so that the predetermined machine ID generating module sets a target lock for the machine ID distributed to the target service.

[0055] Optionally, the target lock set for any machine ID has an expiration time;

[0056] The device also includes:

[0057] The second sending module is used to send a specified request for renewing the lock to the predetermined machine ID generation module in response to reaching an expiration time after sending a lock request to the predetermined machine ID generation module, so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service.

[0058] Optionally, the target machine ID is a machine ID of another service that has not been distributed to the functional service to which the target service belongs before being distributed to the target service.

[0059] Optionally, the determining module includes:

[0060] The determination unit is used to trigger the number issuing module to perform an operation of determining the unique ID required to be allocated to the target object by using the target machine ID and the current machine clock of the server.

[0061] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0062] at least one processor; and

[0063] a memory communicatively connected to the at least one processor; wherein,

[0064] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the unique ID generation methods described above.

[0065] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any of the above-mentioned unique ID generation methods.

[0066] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned methods for generating a unique ID.

[0067] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0069] Figure 1 It is a flowchart of a first unique ID generation method provided by an embodiment of the present disclosure;

[0070] Figure 2 is a flow chart of a second unique ID generation method provided by an embodiment of the present disclosure;

[0071] Figure 3 is a flowchart of a third unique ID generation method provided by an embodiment of the present disclosure;

[0072] Figure 4 is a flowchart of a fourth unique ID generation method provided by an embodiment of the present disclosure;

[0073] Figure 5 A schematic diagram of the structure of a unique ID generating device provided by an embodiment of the present disclosure;

[0074] Figure 6 The block diagram is a block diagram of an electronic device used to implement a unique ID generation method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0075] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0076] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0077] In order to effectively reduce the situation where duplicate unique IDs are generated due to clock rollback, the embodiments of the present disclosure provide a unique ID generation method, apparatus, device, and storage medium.

[0078] The following first introduces a unique ID generation method provided by an embodiment of the present disclosure.

[0079] A unique ID generation method provided in an embodiment of the present disclosure is applied to a target service on the server side; wherein the target service may be a sub-service of a functional service, that is, the target service may belong to a functional service and may implement the functions of the functional service; in addition, any functional service may start multiple sub-services to process requests from different clients, such as a unique ID allocation request, that is, each sub-service may provide different clients with the functions that the same functional service may implement. In addition, in a specific application, a sub-service may also be referred to as a service instance, and the specific form of a sub-service may be a thread or a coroutine, etc., which is not limited in the present disclosure.

[0080] Furthermore, it should be noted that any sub-service used to allocate a unique ID for an object can be used as the target service of the present disclosure; in addition, for the same functional service in the server, there can be one or more sub-services. Generally, each sub-service belonging to the same functional service can achieve the same function, and each sub-service can be used as the target service of the present disclosure. For example, for the order service, the order service, as a functional service, can allocate an order ID for each order, that is, allocate a unique ID for each order to distinguish different orders. The order service can have one or more sub-services, and each sub-service can be used as a target service to generate a unique ID for the order; for another example, for the painting scanning service, the painting scanning service, as a functional service, can allocate a painting ID for each painting obtained by scanning, that is, allocate a unique ID for each painting to distinguish different paintings. The painting scanning service can have one or more sub-services, and each sub-service can be used as a target service to generate a unique ID for the painting.

[0081] In addition, it is understandable that the server may only run the sub-service of one functional service, or may run the sub-services of at least two functional services, which is not limited in the present disclosure.

[0082] Among them, a unique ID generation method provided by an embodiment of the present disclosure may include:

[0083] In response to receiving a unique ID allocation request for a target object, determining whether a clock dialback occurs on the server;

[0084] If it occurs, a target operation for distributing a machine ID to the target service is triggered to obtain a target machine ID; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service;

[0085] Based on the target machine ID and the current machine clock of the server, a unique ID to be allocated to the target object is determined.

[0086] It can be seen from the above that, through the scheme of the present disclosure, after the clock is dialed back, the target operation for distributing the machine ID for the target service can be triggered to obtain the target machine ID, and the unique ID required to be allocated for the target object can be determined based on the target machine ID and the current machine clock of the server. Since the target machine ID is not distributed to the machine ID of any service before being distributed to the target service, the target machine ID is not used to generate a unique ID. Therefore, in the case of determining that a clock dial back has occurred, by redistributing the obtained target machine ID, the possibility that the machine clock and machine ID on which the current generation of the unique ID depends are the same as those on which the unique ID was generated before the clock was dialed back can be reduced; thus, the scheme can effectively reduce the possibility of generating duplicate unique IDs. It can be seen that the scheme of the present disclosure can effectively reduce the situation where duplicate unique IDs are generated due to clock dial back.

[0087] like Figure 1 As shown, a unique ID generation method provided by an embodiment of the present disclosure is applied to a target service on a server side; the method comprises:

[0088] S101, in response to receiving a unique ID allocation request for a target object, determining whether a clock dialback occurs on the server;

[0089] The unique ID (Identity) allocation request may be sent by any request sending object. For example, the request sending object may be any client or server, etc. This disclosure does not limit this.

[0090] The target object may be a painting, a video, a file, etc. The above embodiment introduces that the target service of the present disclosure is a sub-service of a functional service. And in the present disclosure, the target service and other services are all sub-services of the functional service. Usually, the sub-services belonging to the same functional service are used to perform service operations for the same type of target objects. For example, a unique ID allocation request service for a painting includes various sub-services for performing a unique ID allocation service for a target object of the painting type. It should be emphasized that in the present disclosure, any sub-service of the server for allocating a unique ID to an object can be used as the above-mentioned target service of the present disclosure.

[0091] In the present disclosure, each time a unique ID allocation request for a target object is received, a step of determining whether a clock rollback occurs on the server side can be executed. Therefore, the step of determining whether a clock rollback occurs on the server side can be the most recent clock rollback that occurred at the current time.

[0092] The present disclosure may have multiple implementations for determining whether the server has a clock rollback. The present disclosure does not limit the implementation of determining whether the server has a clock rollback.

[0093] In one implementation, clock rollback record information may be obtained. If the record information indicates that the duration from the time of the latest clock rollback to the current time is less than a specified duration, it is determined that a clock rollback has occurred.

[0094] The clock rollback record information of the device may be recorded in data such as log information, so the latest clock rollback record information may be obtained from the data such as log information.

[0095] It is understandable that if the time when the clock is rolled back is far from the current time, it may not affect the current generation of the unique ID. Therefore, if the time from the latest clock rollback to the current time is not less than the specified time, it is not necessary to determine that the clock is rolled back. The specified time can be set according to the specific application scenario.

[0096] In one implementation, determining whether the server has a clock dialback may include:

[0097] Determine whether the time represented by the current machine clock of the server is earlier than the most recent writing time of the machine ID in the target cache file; wherein the target cache file is a file for recording the machine IDs distributed for each service, and each machine ID existing in the target cache file is periodically rewritten;

[0098] If it is earlier, it is determined that the clock of the server is dialed back; otherwise, it is determined that the clock of the server is not dialed back.

[0099] The services are sub-services of one or more functional services. Usually, a machine ID is a string generated by the operating system to identify a computer; it is automatically generated when the system starts and remains unchanged throughout the life cycle of the system. In the present disclosure, the machine ID of any sub-service can be used to identify the sub-service in the server, so as to serve as a dimension of information used in the process of assigning a unique ID to the sub-service. The machine ID of each sub-service can be recorded in the target cache file.

[0100] This implementation method periodically rewrites the machine ID recorded in the target cache file in order to make the most recent writing time of the machine ID used to determine whether a clock rollback has occurred a newer time, thereby accurately determining whether a clock rollback has occurred, and reducing the inaccurate determination of whether a clock rollback has occurred due to the fact that the machine ID has not been written for a long time and the most recent writing time of the machine ID is earlier. For example, if the most recent writing time is 9:00 on December 11; a clock rollback occurs and the current time is rolled back from 10:00 on December 11 to 9:59 on December 11, but because the most recent writing time of the machine ID is earlier, it is impossible to determine that a clock rollback has occurred.

[0101] It is understandable that when each machine ID in the target cache file is periodically rewritten, the smaller the period, the greater the accuracy of determining whether the server has a clock dialback. For example, the period may be 3 seconds.

[0102] Optional, Figure 2 is a flow chart of a second unique ID generation method provided by an embodiment of the present disclosure, such as Figure 2 As shown, before determining whether the server has a clock dialback, the method further includes:

[0103] S201, detecting whether there is a machine ID distributed for the target service in the target cache file; wherein the target cache file is a file used to record the machine ID distributed for each service;

[0104] S202, if existence is detected, triggering the step of determining whether clock dialback occurs on the server;

[0105] S203: If it is detected that the target machine ID does not exist, triggering a target operation for distributing the machine ID for the target service to obtain the target machine ID.

[0106] The target cache file records the machine IDs distributed to each service, where each service refers to each sub-service of one or more functional services. In the present disclosure, a service that does not have a distributed machine ID may generally be a newly added service in the functional service, or a problem with the service, thereby eliminating the corresponding relationship between the service and the machine ID distributed to it, resulting in the service not having a corresponding machine ID.

[0107] After the service is assigned a corresponding machine ID, if there is no problem with the service, the corresponding machine ID can be used all the time when determining the unique ID to be allocated to the target object. Moreover, since the possibility of problems with the service is small, the machine ID corresponding to the service is relatively fixed after allocation.

[0108] When non-existence is detected, the target machine ID obtained by the target operation triggered for machine ID distribution for the target service is a machine ID that has not been assigned to the service, that is, no unique ID has been generated using the machine ID. Therefore, even if the clock is rolled back, a duplicate unique ID will not be generated.

[0109] If it is detected that it exists, a step of determining whether a clock dial back occurs on the server can be performed.

[0110] Through the solution of this embodiment, it can be effectively determined whether to further execute the step of triggering the step of determining whether the clock is dialed back at the server.

[0111] S102, if it occurs, triggering a target operation for distributing a machine ID for the target service to obtain a target machine ID; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service.

[0112] If the clock is not rolled back, the unique ID generated will be different because the machine clock used when determining the unique ID to be allocated to the target object is different.

[0113] If the clock is rolled back, the machine ID and machine clock used when the unique ID was generated in the past may be the same as the machine ID and machine clock used when the unique ID is currently generated, which will cause the currently generated unique ID to be the same as the historically generated unique ID.

[0114] Therefore, in the case of clock dialing back, a target operation for distributing a machine ID for the target service can be triggered to obtain a target machine ID. Thus, a machine ID that is not assigned to any service can be obtained. The arbitrary service can be any sub-service.

[0115] Optionally, the target machine ID is a machine ID of another service that has not been distributed to the functional service to which the target service belongs before being distributed to the target service.

[0116] It is understandable that, since the methods and data used to generate the unique ID may be different between different functional services, for example, the data used to generate the unique ID may include the code corresponding to the functional service, the unique IDs generated by different functional services are different even if the machine ID and machine clock are the same. Therefore, the present disclosure can avoid allocating the same machine ID to each service belonging to the same functional service, that is, each sub-service of the same functional service, to reduce the possibility of generating the same unique ID.

[0117] S103: Determine a unique ID to be allocated to the target object based on the target machine ID and the current machine clock of the server.

[0118] There are many ways to determine the unique ID that needs to be allocated to the target object. For example, the data including the target machine ID and the current machine clock may be concatenated to obtain the unique ID that needs to be allocated to the target object. Alternatively, the data including the target machine ID and the current machine clock may be hashed and the resulting hash value may be used as the unique ID that needs to be allocated to the target object.

[0119] The present disclosure can also use the sonyflake algorithm (a unique ID generation algorithm) to generate the unique ID required to be assigned to the target object, which is a variant of the snowflake algorithm (a unique ID generation algorithm). Compared with snowflake, the sonyflake algorithm has higher processing power, supports a higher upper limit of deployment instances, and has a longer number issuance time. The sonyflake algorithm generates a unique ID by combining data including timestamps, machine IDs, and other data (such as serial numbers).

[0120] In addition, each unique ID generated by the solution of the present disclosure may have an incremental relationship between them, thereby facilitating the management of each target object based on the incremental relationship between the unique IDs.

[0121] Optionally, the determining, based on the target machine ID and the current machine clock of the server, a unique ID to be allocated to the target object includes:

[0122] The triggering number issuing module executes an operation of determining a unique ID to be allocated to the target object by using the target machine ID and the current machine clock of the server.

[0123] The present disclosure may be provided with a numbering module for generating and allocating a unique ID, and the target service may trigger the numbering module to determine the unique ID required to be allocated to the target object by using the target machine ID and the current machine clock of the server.

[0124] It can be understood that the present disclosure determines that the unique ID to be allocated to the target object can be executed by the number issuing module or by the target service, and the present disclosure does not limit this.

[0125] In addition, it is understandable that after the unique ID of the target object is generated based on the target machine ID, the target machine ID can be recorded as the new machine ID of the target service to act on the subsequent unique ID generation process of other rounds, for example: the target machine ID is recorded in the target cache file, so that when the unique ID is generated next time, when it is determined that the clock has not been dialed back, the machine ID can be obtained from the target cache file. Of course, in other implementations, when the machine ID of the target service is stored in the target cache file, after the unique ID of the target object is generated based on the target machine ID, the target machine ID can be cleared, so that the machine ID of the target service stored in the target cache file can be used in subsequent rounds.

[0126] It can be seen from the above that, through the scheme of the present disclosure, after the clock is dialed back, the target operation for distributing the machine ID for the target service can be triggered to obtain the target machine ID, and the unique ID required to be allocated for the target object can be determined based on the target machine ID and the current machine clock of the server. Since the target machine ID is not distributed to the machine ID of any service before being distributed to the target service, the target machine ID is not used to generate a unique ID. Therefore, in the case of determining that a clock dial back has occurred, by redistributing the obtained target machine ID, the possibility that the machine clock and machine ID on which the current generation of the unique ID depends are the same as those on which the unique ID was generated before the clock was dialed back can be reduced; thus, the scheme can effectively reduce the possibility of generating duplicate unique IDs. It can be seen that the scheme of the present disclosure can effectively reduce the situation where duplicate unique IDs are generated due to clock dial back.

[0127] Optional, Figure 3 is a flow chart of a third unique ID generation method provided by an embodiment of the present disclosure, Figure 3 The steps S101-S103 are introduced in the above embodiment and will not be described in detail here. Figure 3 As shown, after S101, the method may further include:

[0128] S301, if the clock is not dialed back, if the machine ID distributed for the target service exists in the target cache file, obtain the machine ID distributed for the target service existing in the target cache file;

[0129] S302: Determine a unique ID to be allocated to the target object based on the acquired machine ID and the current machine clock of the server.

[0130] In the absence of clock rollback, the unique ID will not be repeated due to the repetition of the machine clock, so there is no need to process the machine ID. The machine ID distributed to the target service in the target cache file can be directly used to quickly determine the unique ID required to be allocated to the target object. The specific implementation method of determining the unique ID required to be allocated to the target object based on the acquired machine ID and the current machine clock of the server is similar to the specific implementation method of step S103 above, except that the machine ID used is different.

[0131] Optionally, the triggering of a target operation for distributing a machine ID for the target service to obtain a target machine ID comprises steps A1-A4;

[0132] Step A1, triggering a predetermined machine ID generation module to generate a machine ID, and obtaining a current machine ID;

[0133] The machine ID generation module may generate a machine ID.

[0134] The machine ID generation module may be a cache middleware, which may be used to generate a machine ID.

[0135] Optionally, there is an increasing relationship between the machine ID generated by the predetermined machine ID generating module at any time and the machine ID generated last time corresponding to the any time;

[0136] And, when the machine ID generated by the predetermined machine ID generation module reaches a predetermined maximum ID value, the predetermined machine ID generation module is initialized, and the initialization is used to enable the generation of the machine ID to start from a predetermined minimum value.

[0137] In the present disclosure, there is an increasing relationship between the machine ID generated at any time and the machine ID generated last time corresponding to the same time. For example, if the machine ID of this time is 0008, the last time is 0007. In addition, under the premise of having an increasing relationship, the step length of the increase is not limited in the present disclosure.

[0138] The machine ID of the present invention can be set with a maximum ID value. When the maximum ID value is reached, the service example, or the machine ID generation module can trigger the initialization of the predetermined machine ID generation module, so that the machine ID generation module generates a machine ID next time, starting from the predetermined minimum value.

[0139] In the present disclosure, when a maximum ID value is set, the number of machine IDs is limited, and the number of machine IDs may correspond to the number of sub-services corresponding to the functional service. For example, if a functional service has 1000 sub-services, the number of machine IDs may correspond to 1000.

[0140] It can be seen that the solution of this embodiment can effectively utilize the machine IDs through the above strategy when the number of machine IDs is limited.

[0141] Of course, the present disclosure may not set a maximum ID value for the machine ID. In addition, the present disclosure does not limit the specific form of the machine ID, such as the number of digits and constituent elements such as letters and numbers, and the specific form of the machine ID can be set according to the specific usage scenario.

[0142] Step A2, instructing the predetermined machine ID generation module to perform a specified detection to obtain a detection result; wherein, the specified detection includes detecting whether the current machine ID is set with a target lock; the setting time of any machine ID set with a target lock includes after it is first distributed to a service.

[0143] The machine ID to which the target lock is set is the machine ID that has been assigned to the service.

[0144] The specific method of locking the target machine ID may be:

[0145] After obtaining the target machine ID, a lock request is sent to the predetermined machine ID generation module, so that the predetermined machine ID generation module sets a target lock for the machine ID distributed to the target service.

[0146] The solution of this embodiment can realize setting a target lock for the target machine ID to indicate that the target machine ID has been allocated to the service.

[0147] Optionally, the target lock set for any machine ID has an expiration time;

[0148] The method further comprises:

[0149] After sending a lock request to the predetermined machine ID generation module, in response to reaching an expiration time, a specified request for renewing the lock is sent to the predetermined machine ID generation module so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service.

[0150] The present disclosure can set an expiration time for the target lock, such as 1 day or 1 week, and the expiration time can be set according to the specific application scenario. For each machine ID, when the expiration time of the target lock of the machine ID is reached, it can be determined whether to send a specified request for renewing the lock to the predetermined machine ID generation module based on the status of the service corresponding to the machine ID. If there is a problem with the service, the specified request for renewing the lock will not be sent to the predetermined machine ID generation module. Therefore, the service will have no corresponding machine ID after the expiration time.

[0151] Step A3: Based on the detection result, determine whether the current machine ID meets the conditions for being used as the target machine ID.

[0152] Step A4, if satisfied, taking the current machine ID as the target machine ID, otherwise, executing the step of triggering the predetermined machine ID generation module to generate a machine ID to obtain the current machine ID.

[0153] If the current machine ID is not set with a target lock, the condition for being the target machine ID is satisfied, otherwise the condition for being the target machine ID is not satisfied.

[0154] After obtaining the target machine ID, the target machine ID can be recorded in the target cache file, that is, the machine ID distributed to the target service is recorded. The recording step can be performed by the target service or by the machine ID generation module.

[0155] The method of this embodiment can effectively determine the target machine ID for generating a unique ID for the target service.

[0156] like Figure 4 As shown, another unique ID generation method provided by an embodiment of the present disclosure includes:

[0157] S401, service starts.

[0158] S401 corresponds to the above S101 and can indicate service initiation in response to receiving a unique ID allocation request for a target object.

[0159] S402, searching whether the local file has a machine ID.

[0160] The local file corresponds to the target cache file. S402 corresponds to the step of detecting whether there is a machine ID distributed for the target service in the target cache file, which is used to determine whether there is a machine ID allocated for the service of the current function in the local file.

[0161] If it exists, execute S406; if it does not exist, execute S403.

[0162] S403, obtain the machine ID from Redis incr.

[0163] Incr (a method in Redis) in Redis (Remote Dictionary Server) is used to increment the value of a specified key by 1 and return the incremented value. In this embodiment, the specified key refers to the machine ID. S403 corresponds to S102 above and will not be described in detail here.

[0164] S404, obtaining a global lock of the machine ID.

[0165] S404 corresponds to the above step of sending a lock request to the predetermined machine ID generation module after obtaining the target machine ID, so that the predetermined machine ID generation module sets a target lock for the machine ID distributed to the target service, and will not be elaborated here.

[0166] If it fails, execute S403, if it succeeds, execute S405.

[0167] S405, the machine ID is saved locally.

[0168] The obtained machine ID is saved to the local file.

[0169] S406, reading the saved time and determining whether the clock is set back.

[0170] S406 corresponds to the above-mentioned content of determining whether the clock of the server is dialed back, and will not be described in detail here.

[0171] If the judgment is yes, execute S403, if not, execute S407.

[0172] S407, using the machine ID to initialize the number issuing module to issue a number.

[0173] S407 corresponds to the above step S103, and can realize the generation of a unique ID by using the number issuing module.

[0174] S408, a separate coroutine, regularly renews the machine lock in Redis and regularly writes local file updates.

[0175] S408 corresponds to the above-mentioned sending of a lock request to the predetermined machine ID generation module, in response to reaching the expiration time, of sending a specified request for renewing the lock to the predetermined machine ID generation module, so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service, and the periodic rewriting of each machine ID existing in the target cache file, and will not be elaborated here.

[0176] The implementation of this embodiment can re-acquire the machine ID to generate a unique ID after the clock is dialed back, which can effectively avoid generating a unique ID that is repeated with the unique ID generated in the past. It can be seen that the solution disclosed in this disclosure can effectively reduce the situation where duplicate unique IDs are generated due to clock dialing back.

[0177] The embodiment of the present disclosure also provides a unique ID generation device, which is applied to a target service at a server end, such as Figure 5 As shown, the device comprises:

[0178] A determination module 501 is used to determine whether a clock is dialed back at the server in response to receiving a unique ID allocation request for a target object;

[0179] A trigger module 502 is used for triggering a target operation for distributing a machine ID to the target service to obtain a target machine ID if it occurs; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service;

[0180] The determination module 503 is used to determine the unique ID that needs to be allocated to the target object based on the target machine ID and the current machine clock of the server.

[0181] It can be seen from the above that, through the scheme of the present disclosure, after the clock is dialed back, the target operation for distributing the machine ID for the target service can be triggered to obtain the target machine ID, and the unique ID required to be allocated for the target object can be determined based on the target machine ID and the current machine clock of the server. Since the target machine ID is not distributed to the machine ID of any service before being distributed to the target service, the target machine ID is not used to generate a unique ID. Therefore, in the case of determining that a clock dial back has occurred, by redistributing the obtained target machine ID, the possibility that the machine clock and machine ID on which the current generation of the unique ID depends are the same as those on which the unique ID was generated before the clock was dialed back can be reduced; thus, the scheme can effectively reduce the possibility of generating duplicate unique IDs. It can be seen that the scheme of the present disclosure can effectively reduce the situation where duplicate unique IDs are generated due to clock dial back.

[0182] Optionally, the device further comprises:

[0183] The determination module is further configured to detect whether there is a machine ID distributed for the target service in the target cache file before determining whether the server has a clock dialback; wherein the target cache file is a file for recording the machine ID distributed for each service;

[0184] If it is detected that there is, the step of determining whether the clock of the server is dialed back is triggered;

[0185] If it is detected that the target machine ID does not exist, a target operation for distributing the machine ID to the target service is triggered to obtain the target machine ID.

[0186] Optionally, the device further comprises:

[0187] an acquisition module, for acquiring the machine ID distributed for the target service in the target cache file if the clock is not dialed back and the machine ID distributed for the target service exists in the target cache file;

[0188] The determination module is used to determine the unique ID required to be allocated to the target object based on the acquired machine ID and the current machine clock of the server.

[0189] Optionally, the judging module includes:

[0190] A judging unit, used to judge whether the time represented by the current machine clock of the server is earlier than the most recent writing time of the machine ID in the target cache file; wherein the target cache file is a file used to record the machine IDs distributed for each service, and each machine ID existing in the target cache file is periodically rewritten;

[0191] If it is earlier, it is determined that the clock of the server is dialed back; otherwise, it is determined that the clock of the server is not dialed back.

[0192] Optionally, the trigger module includes:

[0193] A trigger unit, used to trigger a predetermined machine ID generation module to generate a machine ID, and obtain a current machine ID;

[0194] An instruction unit, used to instruct the predetermined machine ID generation module to perform a designated detection and obtain a detection result; wherein the designated detection includes detecting whether the current machine ID is set with a target lock; the setting time of any machine ID set with a target lock includes after it is first distributed to a service;

[0195] a determination unit, configured to determine whether the current machine ID satisfies a condition for being a target machine ID based on the detection result;

[0196] If satisfied, the current machine ID is used as the target machine ID; otherwise, the step of triggering the predetermined machine ID generation module to generate a machine ID to obtain the current machine ID is executed.

[0197] Optionally, there is an increasing relationship between the machine ID generated by the predetermined machine ID generating module at any time and the machine ID generated last time corresponding to the any time;

[0198] And, when the machine ID generated by the predetermined machine ID generation module reaches a predetermined maximum ID value, the predetermined machine ID generation module is initialized, and the initialization is used to enable the generation of the machine ID to start from a predetermined minimum value.

[0199] Optionally, the device further comprises:

[0200] The first sending module is used to send a lock request to the predetermined machine ID generating module after obtaining the target machine ID, so that the predetermined machine ID generating module sets a target lock for the machine ID distributed to the target service.

[0201] Optionally, the target lock set for any machine ID has an expiration time;

[0202] The device also includes:

[0203] The second sending module is used to send a specified request for renewing the lock to the predetermined machine ID generation module in response to reaching an expiration time after sending a lock request to the predetermined machine ID generation module, so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service.

[0204] Optionally, the target machine ID is a machine ID of another service that has not been distributed to the functional service to which the target service belongs before being distributed to the target service.

[0205] Optionally, the determining module includes:

[0206] The determination unit is used to trigger the number issuing module to perform an operation of determining the unique ID required to be allocated to the target object by using the target machine ID and the current machine clock of the server.

[0207] According to the above embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0208] The present disclosure provides an electronic device, comprising:

[0209] at least one processor; and

[0210] A memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned unique ID generation method.

[0211] The present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the above-mentioned unique ID generation method.

[0212] The present disclosure provides a computer program product, including a computer program, which implements the above-mentioned unique ID generation method when executed by a processor.

[0213] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0214] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0215] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0216] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as a unique ID generation method. For example, in some embodiments, a unique ID generation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of a unique ID generation method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform a unique ID generation method in any other appropriate manner (e.g., by means of firmware).

[0217] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0218] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0219] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0220] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0221] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0222] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0223] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0224] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A unique ID generation method, applied to a target service on a server side, comprising: In response to receiving a unique ID allocation request for a target object, determining whether a clock dialback occurs on the server; If it occurs, a target operation for distributing a machine ID to the target service is triggered to obtain a target machine ID; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service; Based on the target machine ID and the current machine clock of the server, a unique ID to be allocated to the target object is determined.

2. The method according to claim 1, wherein: Before determining whether the server has a clock dialback, the method further includes: Detecting whether there is a machine ID distributed for the target service in the target cache file; wherein the target cache file is a file used to record the machine ID distributed for each service; If it is detected that there is, the step of determining whether the clock of the server is dialed back is triggered; If it is detected that the target machine ID does not exist, a target operation for distributing the machine ID to the target service is triggered to obtain the target machine ID.

3. The method according to claim 1 or 2, wherein: The method further comprises: If the clock is not dialed back, if the machine ID distributed for the target service exists in the target cache file, obtaining the machine ID distributed for the target service existing in the target cache file; Based on the acquired machine ID and the current machine clock of the server, a unique ID to be allocated to the target object is determined.

4. The method according to claim 1 or 2, wherein: The determining whether the server has a clock dialback includes: Determine whether the time represented by the current machine clock of the server is earlier than the most recent writing time of the machine ID in the target cache file; wherein the target cache file is a file for recording the machine IDs distributed for each service, and each machine ID existing in the target cache file is periodically rewritten; If it is earlier, it is determined that the clock of the server is dialed back; otherwise, it is determined that the clock of the server is not dialed back.

5. The method according to claim 1 or 2, wherein: The triggering of a target operation for performing machine ID distribution for the target service to obtain a target machine ID includes: Triggering a predetermined machine ID generation module to generate a machine ID, and obtaining a current machine ID; Instructing the predetermined machine ID generation module to perform a specified detection to obtain a detection result; wherein the specified detection includes detecting whether the current machine ID is set with a target lock; the setting time of any machine ID set with a target lock includes after being distributed to a service for the first time; Based on the detection result, determining whether the current machine ID meets the conditions for being used as the target machine ID; If satisfied, the current machine ID is used as the target machine ID; otherwise, the step of triggering the predetermined machine ID generation module to generate a machine ID to obtain the current machine ID is executed.

6. The method according to claim 5, wherein: There is an increasing relationship between the machine ID generated by the predetermined machine ID generating module at any time and the machine ID generated last time corresponding to the any time; And, when the machine ID generated by the predetermined machine ID generation module reaches a predetermined maximum ID value, the predetermined machine ID generation module is initialized, and the initialization is used to enable the generation of the machine ID to start from a predetermined minimum value.

7. The method according to claim 5, wherein: The method further comprises: After obtaining the target machine ID, a lock request is sent to the predetermined machine ID generation module, so that the predetermined machine ID generation module sets a target lock for the machine ID distributed to the target service.

8. The method according to claim 7, wherein: The target lock set for any machine ID has an expiration time; The method further comprises: After sending a lock request to the predetermined machine ID generation module, in response to reaching an expiration time, a specified request for renewing the lock is sent to the predetermined machine ID generation module so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service.

9. The method according to claim 1 or 2, wherein: The target machine ID is a machine ID of another service that has not been distributed to the functional service to which the target service belongs before being distributed to the target service.

10. The method according to claim 1 or 2, wherein: The determining, based on the target machine ID and the current machine clock of the server, the unique ID to be allocated to the target object comprises: The triggering number issuing module executes an operation of determining a unique ID to be allocated to the target object by using the target machine ID and the current machine clock of the server.

11. A unique ID generating device, applied to a target service at a server end, comprising: A determination module, configured to determine whether a clock is dialed back on the server in response to receiving a unique ID allocation request for a target object; A trigger module, for triggering a target operation for distributing a machine ID to the target service to obtain a target machine ID if it occurs; wherein the target machine ID is a machine ID that has not been distributed to any service before being distributed to the target service; The determination module is used to determine the unique ID required to be allocated to the target object based on the target machine ID and the current machine clock of the server.

12. The device according to claim 11, wherein The determination module is further configured to detect whether there is a machine ID distributed for the target service in the target cache file before determining whether the server has a clock dialback; wherein the target cache file is a file for recording the machine ID distributed for each service; If it is detected that there is, the step of determining whether the clock of the server is dialed back is triggered; If it is detected that the target machine ID does not exist, a target operation for distributing the machine ID to the target service is triggered to obtain the target machine ID.

13. The device according to claim 11 or 12, wherein: The device also includes: an acquisition module, for acquiring the machine ID distributed for the target service in the target cache file if the clock is not dialed back and the machine ID distributed for the target service exists in the target cache file; The determination module is used to determine the unique ID required to be allocated to the target object based on the acquired machine ID and the current machine clock of the server.

14. The device according to claim 11 or 12, wherein: The judging module comprises: A judging unit, used to judge whether the time represented by the current machine clock of the server is earlier than the most recent writing time of the machine ID in the target cache file; wherein the target cache file is a file used to record the machine IDs distributed for each service, and each machine ID existing in the target cache file is periodically rewritten; If it is earlier, it is determined that the clock of the server is dialed back; otherwise, it is determined that the clock of the server is not dialed back.

15. The device according to claim 11 or 12, wherein: The trigger module comprises: A trigger unit, used to trigger a predetermined machine ID generation module to generate a machine ID, and obtain a current machine ID; An instruction unit, used to instruct the predetermined machine ID generation module to perform a designated detection and obtain a detection result; wherein the designated detection includes detecting whether the current machine ID is set with a target lock; the setting time of any machine ID set with a target lock includes after it is first distributed to a service; a determination unit, configured to determine whether the current machine ID satisfies a condition for being a target machine ID based on the detection result; If satisfied, the current machine ID is used as the target machine ID; otherwise, the step of triggering the predetermined machine ID generation module to generate a machine ID to obtain the current machine ID is executed.

16. The device according to claim 15, wherein: There is an increasing relationship between the machine ID generated by the predetermined machine ID generating module at any time and the machine ID generated last time corresponding to the any time; And, when the machine ID generated by the predetermined machine ID generation module reaches a predetermined maximum ID value, the predetermined machine ID generation module is initialized, and the initialization is used to enable the generation of the machine ID to start from a predetermined minimum value.

17. The device according to claim 15, wherein: The device also includes: The first sending module is used to send a lock request to the predetermined machine ID generating module after obtaining the target machine ID, so that the predetermined machine ID generating module sets a target lock for the machine ID distributed to the target service.

18. The device according to claim 17, wherein: The target lock set for any machine ID has an expiration time; The device also includes: The second sending module is used to send a specified request for renewing the lock to the predetermined machine ID generation module in response to reaching an expiration time after sending a lock request to the predetermined machine ID generation module, so that the predetermined machine ID generation module resets the target lock for the machine ID distributed to the target service.

19. The device according to claim 11 or 12, wherein: The target machine ID is a machine ID of another service that has not been distributed to the functional service to which the target service belongs before being distributed to the target service.

20. The device according to claim 11 or 12, wherein: The determination module comprises: The determination unit is used to trigger the number issuing module to perform an operation of determining the unique ID required to be allocated to the target object by using the target machine ID and the current machine clock of the server.

21. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.

22. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.

23. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.