CN-121979619-A - Sequence object generation method, device, computer equipment and readable storage medium
Abstract
The application relates to a sequence object generation method, a sequence object generation device, computer equipment and a readable storage medium. The method comprises the steps of responding to a creation request for a sequence object, creating the sequence object based on the first sequence service subprocess to obtain a sequence object creation result, generating a switching creation request for the sequence object under the condition that the sequence object creation result indicates that the first sequence service subprocess fails to create the sequence object, and sending the switching creation request to the standby coordination node so that the standby coordination node creates the sequence object based on the second sequence service subprocess according to the switching creation request. By adopting the method, the single point fault risk in the global sequence generation process can be avoided.
Inventors
- GUO MINGJIAN
Assignees
- 天翼云科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251222
Claims (15)
- 1. A sequence object generation method is characterized by being applied to a main coordination node in a distributed database cluster, wherein the distributed database cluster further comprises a standby coordination node, the main coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the method comprises the following steps: Responding to a creation request for a sequence object, and creating the sequence object based on the first sequence service subprocess to obtain a sequence object creation result; Generating a switching creation request for the sequence object under the condition that the sequence object creation result indicates that the first sequence service subprocess fails to create the sequence object; and sending the switching creation request to the standby coordination node so that the standby coordination node creates the sequence object based on the second sequence service subprocess according to the switching creation request.
- 2. The method according to claim 1, wherein the method further comprises: And under the condition that the creation of the sequence object is successful, the metadata of the sequence object is persisted into a system table of the distributed database cluster, wherein the metadata comprises at least one of an object value, a step size and a cache size.
- 3. The method according to claim 1, wherein the method further comprises: And under the condition that the creation of the sequence object is successful, caching metadata of the sequence object in a local memory or a coordination node, wherein the coordination node comprises any one of the main coordination node and the standby coordination node.
- 4. The method according to claim 1, wherein the method further comprises: and under the condition that the standby coordination node receives an acquisition request of the object value of the target sequence object, returning the object value of the target sequence object to the standby coordination node based on the first sequence service sub-process.
- 5. The method of claim 4, wherein the target sequence object comprises a next sequence object after the current sequence object, wherein after returning the object value of the target sequence object to the backup coordination node based on the first sequence service sub-process, the method further comprises: and updating the next sequence object in the system table to be a new current sequence object.
- 6. The method according to claim 1, wherein the method further comprises: And under the condition that the creation of the sequence object is successful, generating a global identifier of the sequence object, wherein the global identifier comprises any one of a permanent identifier and a temporary identifier.
- 7. The method of claim 6, wherein generating the global identification of the sequence object comprises: Acquiring a database name and a naming space corresponding to the sequence object; generating a sequence name of the sequence object; The permanent identification of the sequence object is generated based on the database name, the namespace, and the sequence name.
- 8. The method of claim 6, wherein generating the global identification of the sequence object comprises: Acquiring a database name, a name space and a session identifier corresponding to the sequence object; generating a sequence name of the sequence object; the temporary identification of the sequence object is generated based on the database name, the namespace, the sequence name, and the session identification.
- 9. A sequence object generation method is characterized by being applied to a standby coordination node in a distributed database cluster, wherein the distributed database cluster further comprises a main coordination node, the main coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the method comprises the following steps: The method comprises the steps of receiving a switching creation request sent by a main coordination node, wherein the main coordination node is used for responding to the creation request for a sequence object, creating the sequence object based on a first sequence service subprocess to obtain a sequence object creation result, and generating the switching creation request for the sequence object under the condition that the sequence object creation result indicates that the first sequence service subprocess fails to create the sequence object; and creating the sequence object based on the second sequence service subprocess according to the switching creation request.
- 10. The method according to claim 9, wherein the method further comprises: Responsive to an acquisition request for an object value of a target sequence object, routing the acquisition request to the master coordinator node; the object value of the target sequence object returned by the main coordination node based on the first sequence service subprocess is received.
- 11. The sequence object generating device is applied to a main coordination node in a distributed database cluster, the distributed database cluster further comprises a standby coordination node, the main coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the device comprises: the first creating module is used for responding to a creating request for the sequence object, creating the sequence object based on the first sequence service subprocess and obtaining a sequence object creating result; the information generation module is used for generating a switching creation request aiming at the sequence object under the condition that the creation result of the sequence object indicates that the first sequence service subprocess fails to create the sequence object; And the information sending module is used for sending the switching creation request to the standby coordination node so that the standby coordination node creates the sequence object based on the second sequence service subprocess according to the switching creation request.
- 12. The sequence object generating device is applied to a standby coordination node in a distributed database cluster, the distributed database cluster further comprises a main coordination node, the main coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the device comprises: The system comprises an information receiving module, a sequence object creating module and a sequence object creating module, wherein the information receiving module is used for receiving a switching creating request sent by a main coordination node, the main coordination node is used for responding to the creating request for a sequence object, creating the sequence object based on the first sequence service subprocess to obtain a sequence object creating result, and generating the switching creating request for the sequence object under the condition that the sequence object creating result indicates that the first sequence service subprocess fails to create the sequence object; and the second creating module is used for creating the sequence object based on the second sequence service subprocess according to the switching creation request.
- 13. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 10 when the computer program is executed.
- 14. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 10.
- 15. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the method of any one of claims 1 to 10.
Description
Sequence object generation method, device, computer equipment and readable storage medium Technical Field The present application relates to the field of database technologies, and in particular, to a method, an apparatus, a computer device, and a readable storage medium for generating a sequence object. Background In a distributed database system, generation and management of globally unique sequences is one of the key technologies to support business continuity and data consistency. In view of the performance bottleneck and single point failure risk of the traditional single point sequence generation scheme in a distributed scene, most distributed databases uniformly coordinate the distribution and management of sequences by adopting a global transaction manager (Global Transaction Manager, GTM). However, since the GTM adopts a centralized architecture design, all sequence requests need to be processed and synchronized by the GTM node, once the GTM node fails, the sequence generation function of the entire distributed database will be immediately interrupted, resulting in the unavailability of the service system. In addition, the GTM node needs to simultaneously carry multiple functions such as sequence service, global timestamp allocation, and distributed transaction coordination, and the architecture of the multifunctional coupling makes the availability of the sequence service susceptible to the stability of other services, thereby increasing the uncertainty risk of the system. Thus, existing sequence generation techniques have the problem of a single point of failure. Disclosure of Invention In view of the foregoing, it is desirable to provide a more reliable sequence object generating method, apparatus, computer device, computer readable storage medium and computer program product. In a first aspect, the present application provides a method for generating a sequence object, where the method is applied to a master coordination node in a distributed database cluster, where the distributed database cluster further includes a standby coordination node, where the master coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the method includes: Responding to a creation request for a sequence object, and creating the sequence object based on the first sequence service subprocess to obtain a sequence object creation result; Generating a switching creation request for the sequence object under the condition that the sequence object creation result indicates that the first sequence service subprocess fails to create the sequence object; and sending the switching creation request to the standby coordination node so that the standby coordination node creates the sequence object based on the second sequence service subprocess according to the switching creation request. In a second aspect, the present application further provides a sequence object generating method, where the method is applied to a standby coordination node in a distributed database cluster, where the distributed database cluster further includes a main coordination node, the main coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the method includes: The method comprises the steps of receiving a switching creation request sent by a main coordination node, wherein the main coordination node is used for responding to the creation request for a sequence object, creating the sequence object based on a first sequence service subprocess to obtain a sequence object creation result, and generating the switching creation request for the sequence object under the condition that the sequence object creation result indicates that the first sequence service subprocess fails to create the sequence object; and creating the sequence object based on the second sequence service subprocess according to the switching creation request. In a third aspect, the present application further provides a sequence object generating device, where the device is applied to a master coordination node in a distributed database cluster, the distributed database cluster further includes a standby coordination node, the master coordination node is configured with a first sequence service sub-process, and the standby coordination node is configured with a second sequence service sub-process, and the device includes: the first creating module is used for responding to a creating request for the sequence object, creating the sequence object based on the first sequence service subprocess and obtaining a sequence object creating result; the information generation module is used for generating a switching creation request aiming at the sequence object under the condition that the creation result of the sequence object indicates that the first sequence ser