Message sending method, message processing method, device, equipment and medium

By writing identification information into messages in shared cluster databases and performing reverse order detection, the problem of out-of-order messages between database instances is solved, and orderly processing and efficient resource utilization are achieved.

CN118939453BActive Publication Date: 2025-05-06SHENZHEN INST OF COMPUTING SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411015176.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2025-05-06
Estimated Expiration
2044-07-26

AI Technical Summary

Technical Problem

In a shared cluster database, messages may be out of order when transmitted and processed between multiple database instances, resulting in inconsistent resource status of the database instance and the global resource status of the cluster, resulting in unpredictable resource errors.

Method used

By writing the session number, serial number and instance number of the sending thread in the message, an identification message is formed, and reverse order detection is performed in the receiving database instance to ensure orderly processing of the message.

Benefits of technology

In a multi-connection load balancing system, it ensures orderly reception and processing of message sources, reduces resource consumption, improves overall processing efficiency, and improves the efficiency of message request response.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939453B_ABST
    Figure CN118939453B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of database technology, and in particular, to a message sending method, message processing method, device, equipment and medium. The sending database instance identifies the message according to the session number of the sending thread that sends the message, the sequence number assigned to the message by the sending thread and the instance number of the sending database instance, obtains the identified message, and sends the identified message to the receiving database instance. When the receiving database instance receives the identified message sent by the sending database instance or forwarded by the intermediate database instance, it determines the received message with the same instance number and session number as the identified message. If the sequence number of the received message is greater than the sequence number of the identified message, the identified message is discarded. If the sequence number of the received message is less than the sequence number of the identified message, the identified message is placed in the message queue of the processing thread. This ensures the orderly reception and processing of messages of database instances in a shared cluster database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application is applicable to the field of database technology, and in particular relates to a message sending method, a message processing method, an apparatus, a device and a medium. Background Art

[0002] In a shared cluster database, there are a large number of message interactions between database instances. A database instance initiates a message request, which may span multiple database instances, and the last database instance or the resource master database instance replies to the message request. In the process of transmitting and processing the message request between multiple database instances, due to factors such as network delay and slow message processing, the message arriving at the last database instance may be out of order. If the message reception or processing of a database instance is out of order, it may cause the local resource state of the database instance to be inconsistent with the global resource state of the cluster, thereby causing unpredictable resource errors. In order to ensure the orderly reception and processing of messages in a shared cluster, the existing technology usually adopts a single connection and a single process for communication between database instances, but this single connection situation seriously affects the throughput of message communication between shared cluster database instances, and the ordinary message order preservation mechanism is only applicable to the commonly used client-server model and point-to-point message communication, and cannot solve the problem of message out of order when a database instance in a shared cluster database initiates a message request, spans multiple database instances for transmission, and the last database instance replies to the message request. Therefore, how to ensure the orderly reception and processing of messages of database instances in a shared cluster database has become an urgent problem to be solved. Summary of the invention

[0003] In view of this, embodiments of the present application provide a message sending method, a message processing method, an apparatus, a device and a medium to solve the problem of how to ensure the orderly reception and processing of messages of database instances in a shared cluster database.

[0004] In a first aspect, an embodiment of the present application provides a message sending method for a shared cluster database, wherein the message sending method is applied to a sending database instance in the shared cluster database, and the sending database instance is used to send a message, including:

[0005] When a sending thread is about to send a message, obtaining the session number of the sending thread and the sequence number assigned by the sending thread to the message, wherein the sequence number assigned by the sending thread increases with the number of messages sent;

[0006] Obtaining the instance number of the sending database instance, writing the session number, the sequence number and the instance number into the message to obtain a message with an identifier;

[0007] The identified message is sent to a receiving database instance in the shared cluster database that receives the message. After receiving the identified message, the receiving database instance performs a reverse order detection based on the instance number, session number and sequence number in the identified message to decide on the execution operation of the identified message.

[0008] In a second aspect, an embodiment of the present application provides a message processing method for a shared cluster database, the message processing method being applied to a receiving database instance in the shared cluster database, the receiving database instance being used to receive a message, including:

[0009] Upon receiving the identified message sent by the sending database instance or the identified message forwarded by the intermediate database instance as claimed in claim 1, determining a received message having the same instance number and session number as those in the identified message, wherein the intermediate database instance is a database instance in the shared cluster database that routes and forwards the identified message sent by the sending database instance;

[0010] If the sequence number of the received message is greater than the sequence number of the identified message, the identified message is discarded; if the sequence number of the received message is less than the sequence number of the identified message, the identified message is placed in the message queue of the processing thread to wait for the processing thread to process the identified message in the message queue.

[0011] In a third aspect, an embodiment of the present application provides a message sending device for a shared cluster database, wherein the message sending device is applied to a sending database instance in the shared cluster database, and the sending database instance is used to send a message, including:

[0012] An acquisition module, used for acquiring the session number of a sending thread and the sequence number assigned by the sending thread to the message when a sending thread is about to send a message, wherein the sequence number assigned by the sending thread increases with the number of messages sent;

[0013] An identification module, used for obtaining the instance number of the sending database instance, writing the session number, the sequence number and the instance number into the message, and obtaining an identified message;

[0014] A sending module is used to send the identified message to a receiving database instance in the shared cluster database that receives the message. After receiving the identified message, the receiving database instance performs a reverse order detection based on the instance number, session number and sequence number in the identified message to decide on the execution operation of the identified message.

[0015] In a fourth aspect, an embodiment of the present application provides a message processing device for a shared cluster database, wherein the message processing device is applied to a receiving database instance in the shared cluster database, and the receiving database instance is used to receive a message, including:

[0016] A first determination module is used to determine a received message having the same instance number and session number as those in the message with identification when receiving the message with identification sent by the sending database instance or the message with identification forwarded by the intermediate database instance as described in the first aspect above, wherein the intermediate database instance is a database instance in the shared cluster database that routes and forwards the message with identification sent by the sending database instance;

[0017] A processing module is used to discard the identified message if the sequence number of the received message is greater than the sequence number of the identified message, and to put the identified message into the message queue of the processing thread if the sequence number of the received message is less than the sequence number of the identified message, so as to wait for the processing thread to process the identified message in the message queue.

[0018] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for sending a message of a shared cluster database as described in the first aspect, or the method for processing a message of a shared cluster database as described in the second aspect is implemented.

[0019] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the message sending method of the shared cluster database as described in the first aspect, or the message processing method of the shared cluster database as described in the second aspect is implemented.

[0020] Compared with the prior art, the embodiments of the present application have the following beneficial effects: when a sending thread is about to send a message, the sending database instance of the present application writes the session number of the sending thread, the sequence number assigned by the sending thread to the message, and the instance number of the sending database instance into the message, obtains a message with an identifier, and sends the message with an identifier to the receiving database instance that receives the message. Among them, the message is identified by the sending database instance, and the message with an identifier is sent to the receiving database instance, so that even if the message with an identifier is routed and forwarded by multiple database instances in the network, the receiving database instance can also receive and process the message source in an orderly manner according to the information in the message with an identifier.

[0021] When receiving an identified message sent by a sending database instance or an identified message forwarded by an intermediate database instance, the receiving database instance of the present application determines a received message with the same instance number and session number as those in the identified message. If the sequence number of the received message is greater than the sequence number of the identified message, the identified message is discarded. If the sequence number of the received message is less than the sequence number of the identified message, the identified message is placed in the message queue of the processing thread to wait for the processing thread to process the identified message in the message queue. By comparing the sequence number in the identified message with the sequence number of the received message, discarding the identified message with a sequence number less than the sequence number of the received message, and putting the identified message with a sequence number greater than the sequence number of the received message into the message queue, the problem of message disorder in a multi-threaded, multi-connected and high-concurrency environment, in which a database instance in a shared cluster database initiates a message request, transmits across multiple database instances, and the last database instance replies to the message request, is solved. In a multi-connection load balancing system, orderly reception and processing of point-to-point message sources can be achieved without relying on the network. Received messages are filtered according to the sequence number of the identified message, ensuring that only valid messages are processed, reducing unnecessary resource consumption, and allowing the system to process valid messages faster, thereby improving overall processing efficiency. At the same time, the public message queue and private message queue set by the present application for the processing thread enable the retry message to be quickly and preferentially read and processed by the processing thread when a message retry generates a retry message, thereby improving the efficiency of message request response and the efficiency of message reading by the processing thread. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0023] Figure 1 It is a flowchart of a message sending method for a shared cluster database provided in Example 1 of the present application;

[0024] Figure 2 It is a flow chart of a message processing method for a shared cluster database provided in Embodiment 2 of the present application;

[0025] Figure 3 It is a flowchart of a message processing method for a shared cluster database provided in Embodiment 3 of the present application;

[0026] Figure 4 It is a structural diagram of a message sending device for a shared cluster database provided in Embodiment 4 of the present application;

[0027] Figure 5 It is a structural diagram of a message processing device for a shared cluster database provided in Embodiment 5 of the present application;

[0028] Figure 6 It is a structural diagram of a computer device provided in Example 6 of the present application. DETAILED DESCRIPTION

[0029] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0030] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0031] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0032] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0033] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0034] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0035] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0036] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.

[0037] See also Figure 1 , is a flow chart of a message sending method for a shared cluster database provided in Embodiment 1 of the present application, such as Figure 1 As shown, the message sending method is applied to a sending database instance in a shared cluster database, and the sending database instance is used to send messages, and may include the following steps:

[0038] Step S101, when a sending thread is about to send a message, the session number of the sending thread and the sequence number assigned by the sending thread to the message are obtained.

[0039] Step S102, obtaining the instance number of the sending database instance, writing the session number, sequence number and instance number into the message, and obtaining a message with an identifier.

[0040] In an embodiment of the present application, a shared cluster database may refer to a database cluster system that allows multiple database instances to simultaneously access and operate the same storage medium, a database instance may refer to a software process or component that can access and operate database resources, a sending database instance may refer to a database instance used to send messages, and the sending database instance refers to the original sender of the message, a thread may refer to the smallest unit that an operating system can perform computational scheduling, a sending thread may refer to a thread used to send messages, a session number may refer to an identifier used to identify a communication session or connection of a sending thread, a sequence number may refer to an identifier used to identify tracking messages, wherein the sequence number assigned to the sending thread increases with the number of messages sent, an instance number may refer to an identifier used to identify the sending database instance, and an identified message may refer to a message that has been identified with an instance number, a session number, and a sequence number.

[0041] Specifically, when the sending thread is about to send a message, the sending thread assigns a new serial number to the message, obtains the session number of the session connection used by the sending thread, the serial number assigned to the message by the sending thread, and the instance number of the sending database instance, writes the session number, serial number and instance number into the header of the message, and obtains an identified message.

[0042] Step S103: Send a message with an identifier to a receiving database instance in the shared cluster database that receives the message.

[0043] In the embodiment of the present application, the receiving database instance may refer to the last database instance that receives the message with the identifier.

[0044] Specifically, a message with an identifier is sent to a receiving database instance. After receiving the message with an identifier, the receiving database instance performs a reverse order detection on the message with an identifier based on the instance number, session number and sequence number in the message with an identifier, and decides on an execution operation on the message with an identifier based on the reverse order detection result, for example, deciding to discard the message with an identifier or to process the message with an identifier.

[0045] For example, in a shared cluster database system, there are three database instances, namely inst0, inst1, and inst2. Inst0 wants to access resources in inst2, and inst0 sends a request message to inst2. The request message is forwarded by inst1 and reaches inst2. In this case, inst0 is the sending database instance, inst1 is the intermediate database instance, and inst2 is the receiving database instance. The overall message sending process can be:

[0046] 1) When the sending thread in inst0 sends the identified message corresponding to the message for the first time, the sequence number assigned to the message is 1, and the session number of the sending thread, the instance number of inst0 and the sequence number 1 are written into the message to obtain the original type of identified message, which is recorded as the original message, and the original message is sent to inst2, and the response of inst2 to the original message with the sequence number 1 is waited for; 2) Within the preset time, inst0 does not receive the response of inst2 to the original message with the sequence number 1, and the sending thread sends the identified message corresponding to the message for the second time, and the sequence number assigned to the message is 2, and the session number of the sending thread, the instance number of inst0 and the sequence number 2 are written into the message to obtain the retry type of identified message, which is recorded as the retry message, and the retry message is sent to inst2, and the response of inst2 to the retry message with the sequence number 2 is waited for;

[0047] 3) When inst2 receives the identified message forwarded by inst1, it performs a reverse sequence check on the identified message to determine the received message with the same instance number and session number as the identified message. If there is any received message with a sequence number greater than the sequence number in the identified message, the identified message is discarded. If the sequence numbers of all received messages are less than the sequence number in the identified message, the message type of the identified message is determined; 4) If the identified message is the original message with sequence number 1, the identified message is placed in the public message queue; if the identified message is a retry message with sequence number 2, it is detected that the sequence number has been received. If the original message with sequence number 1 is in the state of being processed or has been processed, the identified message will be placed in the private message queue of the processing thread of the original message with sequence number 1; if the identified message is a retry message with sequence number 2, it is detected that the original message with sequence number 1 has been received, and the original message with sequence number 1 is in the state of not being processed, the original message with sequence number 1 will be deleted and the identified message will be placed in the public message queue; if the identified message is a retry message with sequence number 2, it is detected that the original message with sequence number 1 has not been received, the identified message will be placed in the public message queue.

[0048] In the embodiment of the present application, when a sending thread is about to send a message, the sending database instance writes the session number of the sending thread, the sequence number assigned by the sending thread to the message, and the instance number of the sending database instance into the message, obtains a message with an identifier, and sends the message with an identifier to the receiving database instance that receives the message. Among them, the message is identified by the sending database instance, and the message with an identifier is sent to the receiving database instance, so that even if the message with an identifier is routed and forwarded by multiple database instances in the network, the receiving database instance can also receive and process the message source in an orderly manner according to the information in the message with an identifier.

[0049] See also Figure 2 , is a flow chart of a message processing method for a shared cluster database provided in Embodiment 2 of the present application, such as Figure 2 As shown, the message processing method is applied to a receiving database instance in a shared cluster database, and the receiving database instance is used to receive messages, and may include the following steps:

[0050] Step S201: upon receiving a message with an identifier sent by a sending database instance or a message with an identifier forwarded by an intermediate database instance, determining a received message having the same instance number and session number as those in the message with an identifier.

[0051] In an embodiment of the present application, a sending database instance sends an identified message to a receiving database instance, which may be routed and forwarded by multiple database instances before reaching the receiving database instance, and the receiving database instance replies to the sending database instance. In this case, the database instance routed and forwarded in this process is the intermediate database instance, and the received message may refer to a message that has been received by the receiving database instance and has the same instance number and session number as in the identified message.

[0052] Specifically, when receiving an identified message sent by a sending database instance or an identified message forwarded by an intermediate database instance, the sending database instance that sends the identified message and the sending thread in the sending database instance are determined based on the instance number and session number identified in the identified message, and based on the determined sending thread in the sending database instance, the received message corresponding to the sending thread received locally is determined.

[0053] Step S202: if the sequence number of the received message is greater than the sequence number of the identified message, the identified message is discarded; if the sequence number of the received message is less than the sequence number of the identified message, the identified message is put into the message queue of the processing thread.

[0054] In the embodiment of the present application, the message queue may refer to a container for storing messages, and the message queue adopts the first-in-first-out principle.

[0055] Specifically, the sequence numbers of all received messages corresponding to the sending thread are obtained, and for any received message sequence number, the sequence number of the identified message is compared with the sequence number of the received message; if there is any received message whose sequence number is greater than the sequence number of the identified message, the identified message is discarded; if the sequence numbers of all received messages are less than the sequence number of the identified message, the identified message is put into the message queue of the processing thread to wait for the processing thread to process the identified message in the message queue.

[0056] Optionally, when receiving the identified message, the intermediate database instance may directly forward the identified message, or perform a reverse order detection according to the contents of the above steps S201 and S202 to decide on an execution operation for the identified message.

[0057] In an embodiment of the present application, by comparing the sequence number in the identified message with the sequence number of the received message, discarding the identified message with a sequence number less than the sequence number of the received message, and placing the identified message with a sequence number greater than the sequence number of the received message into a message queue, the problem of message disorder in a multi-threaded, multi-connected and high-concurrency environment, in which a database instance in a shared cluster database initiates a message request, transmits across multiple database instances, and the last database instance replies to the message request, is solved. This achieves point-to-point orderly reception and processing of message sources in a multi-connection load balancing system without relying on the network, and filters the received messages according to the sequence number of the identified message, ensuring that only valid messages are processed, reducing unnecessary resource consumption, and allowing the system to process valid messages faster, thereby improving overall processing efficiency.

[0058] See also Figure 3 , is a flow chart of a message processing method for a shared cluster database provided in Embodiment 3 of the present application, such as Figure 3 As shown, in the above step S202, placing the identified message into the message queue of the processing thread may include the following steps:

[0059] Step S301, determining the message type identified in the identified message.

[0060] Step S302: If the message type is the original type, the message with the identifier is placed in the public message queue of the receiving database instance.

[0061] Step S303: If the message type is a retry type, determine the state of the original message of the original type corresponding to the identified message, and put the identified message into the message queue of the processing thread according to the state of the original message.

[0062] In an embodiment of the present application, message types may include original types and retry types, wherein, for any message to be sent by any sending thread in a sending database instance, the identified message corresponding to the message sent for the first time is of the original type, and the identified message of the original type can be recorded as the original message. Within a preset waiting time, after no reply to the original message from the receiving database instance is received, the identified message corresponding to the message sent for the second time and thereafter is of the retry type, and the identified message of the retry type can be recorded as the retry message. This message type can be written into the header of the message together with the instance number, session number and sequence number when the sending database instance sends the message to obtain an identified message.

[0063] When the sending database instance receives the reply of the receiving database instance to the identified message, it only receives the reply of the receiving database instance to the identified message with the latest sequence number. For example, for a message to be sent by the sending database instance, the sequence number of the identified message corresponding to the message sent by the sending database instance for the first time is 1, and the identified message is the original message. Within the preset waiting time, after no reply to the original message from the receiving database instance is received, the sequence number of the identified message corresponding to the message sent for the second time is 2, and the identified message is the retry message. If within the waiting time, the receiving database instance replies to both the original message with sequence number 1 and the retry message with sequence number 2, the sending database instance only receives the reply to the retry message with sequence number 2, and discards the reply to the original message with sequence number 1.

[0064] The receiving database instance sets a common message queue for all processing threads in it, namely, a public message queue. All processing threads in the receiving database instance can read messages from the public message queue for processing, and a private message queue is set for each processing thread. Each processing thread can read messages from its private message queue for processing. Among them, when each processing thread reads messages in the message queue, it follows the following principle: first read the messages in the processing thread's own private message queue, if read, directly process, and then read the messages in the public message queue, if read, directly process.

[0065] Specifically, according to the message type identified in the identified message, the identified message is placed in the message queue of the processing thread, which may include the following processing situations:

[0066] 1) If the message type is the original type, the identified message is placed in the public message queue of the receiving database instance to wait for the processing thread to read the identified message from the public message queue and process it;

[0067] 2) If the message type is a retry type, it is detected that an original message of the original type corresponding to the identified message has been received, and the original message is in a processing state or has been processed, then the identified message is placed in the private message queue of the processing thread that processes the original message;

[0068] 3) If the message type is a retry type, it is detected that an original message of the original type corresponding to the identified message has been received, and the original message is in an unprocessed state, then the original message is deleted and the identified message is placed in the public message queue;

[0069] 4) If the message type is the original type and it is detected that the original message of the original type corresponding to the identified message has not been received, the identified message is placed in the public message queue.

[0070] In an embodiment of the present application, a public message queue and a private message queue are set for the processing thread. When a message retry occurs and a retry message is generated, the retry message is processed after the original message and is processed by the same processing thread for the above 2), thereby avoiding the problem of disordered message processing due to thread scheduling problems, so that the retry message can be read and processed by the processing thread quickly and preferentially, thereby improving the efficiency of message request response and the efficiency of processing thread reading messages; for the above 3), since the sending database instance only receives the reply to the identified message with the latest serial number when receiving the reply of the receiving database instance to the identified message, that is, this Only the reply to the retry message is received and the original message is deleted, which can reduce unnecessary thread processing resource consumption and the number of messages waiting in front of the retry message in the public message queue, so that the retry message can be quickly read by the processing thread, thereby improving the efficiency of message request response and the efficiency of processing thread reading messages; for the above 1) and 4), the identified message is put into the public message queue. Since each processing thread in the receiving database instance can read the message from the public message queue in parallel, the speed at which the identified message is read is accelerated, thereby improving the efficiency of message request response and the efficiency of processing thread reading messages.

[0071] Corresponding to the message sending method of the shared cluster database in the above embodiment, Figure 4 The structural block diagram of the message sending device of the shared cluster database provided in the fourth embodiment of the present application is shown, and the message sending device is applied to the sending database instance in the shared cluster database, and the sending database instance is used to send messages. For the convenience of explanation, only the part related to the embodiment of the present application is shown.

[0072] See also Figure 4 , the message sending device comprises:

[0073] The acquisition module 41 is used to acquire the session number of a sending thread and the sequence number assigned by the sending thread to the message when a sending thread is about to send a message, wherein the sequence number assigned by the sending thread increases with the number of messages sent;

[0074] An identification module 42, used to obtain the instance number of the sending database instance, write the session number, the sequence number and the instance number into the message, and obtain a message with an identification;

[0075] The sending module 43 is used to send the identified message to the receiving database instance in the shared cluster database that receives the message. After receiving the identified message, the receiving database instance performs a reverse order detection based on the instance number, session number and sequence number in the identified message to decide the execution operation of the identified message.

[0076] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0077] Corresponding to the message processing method of the shared cluster database in the above embodiment, Figure 5 The structural block diagram of the message processing device of the shared cluster database provided in the fifth embodiment of the present application is shown, and the message processing device is applied to the receiving database instance in the shared cluster database, and the receiving database instance is used to receive messages. For the convenience of explanation, only the part related to the embodiment of the present application is shown.

[0078] See also Figure 5 , the message processing device comprises:

[0079] A first determination module 51 is used to determine a received message having the same instance number and session number as those in the message with identification when receiving the message with identification sent by the sending database instance or the message with identification forwarded by the intermediate database instance, wherein the intermediate database instance is a database instance in the shared cluster database that routes and forwards the message with identification sent by the sending database instance;

[0080] The processing module 52 is used to discard the identified message if the sequence number of the received message is greater than the sequence number of the identified message, and to put the identified message into the message queue of the processing thread if the sequence number of the received message is less than the sequence number of the identified message, so as to wait for the processing thread to process the identified message in the message queue.

[0081] Optionally, the processing module 52 includes:

[0082] A second determining unit is used to determine a message type identified in the message with identification, wherein the message type includes an original type and a retry type, the message with identification corresponding to the message sent by the sending database instance for the first time is the original type, and the message with identification corresponding to the message sent by the sending database instance for the second time and thereafter is the retry type;

[0083] A first placing unit, configured to place the identified message into a public message queue of the receiving database instance if the message type is an original type;

[0084] The second placing unit is used to determine the state of the original message of the original type corresponding to the identified message if the message type is a retry type, and place the identified message into the message queue of the processing thread according to the state of the original message.

[0085] Optionally, the second placing unit comprises:

[0086] The third placing subunit is used to place the identified message into the private message queue of the processing thread that processes the original message if the original message has been received and the original message is in the processing state or has been processed state.

[0087] Optionally, the second placing unit comprises:

[0088] The fourth placing subunit is used to delete the original message and place the identified message into the public message queue if the original message has been received and is in an unprocessed state.

[0089] Optionally, the second placing unit comprises:

[0090] The fifth placing subunit is used to place the identified message into the public message queue if the original message is not received.

[0091] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0092] Figure 6 This is a schematic diagram of the structure of a computer device provided in Example 6 of the present application. Figure 6 As shown, the computer device of this embodiment includes: at least one processor ( Figure 6 Only one is shown), a memory, and a computer program stored in the memory and executable on at least one processor. When the processor executes the computer program, the steps in any of the above-mentioned message sending method embodiments for a shared cluster database are implemented, or the steps in any of the above-mentioned message processing method embodiments for a shared cluster database are implemented.

[0093] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 6 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.

[0094] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0095] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of an operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments may also be an external storage device of a computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on a computer device. Further, the memory may also include both an internal storage unit of a computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of computer programs, etc. The memory may also be used to temporarily store data that has been output or is to be output.

[0096] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiment when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0097] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.

[0098] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0099] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0100] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0101] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0102] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A message sending method for a shared cluster database, characterized in that: The message sending method is applied to a sending database instance in the shared cluster database, and the sending database instance is used to send a message, including: When a sending thread is about to send a message, obtaining the session number of the sending thread and the sequence number assigned by the sending thread to the message, wherein the sequence number assigned by the sending thread increases with the number of messages sent; Obtaining the instance number of the sending database instance, writing the session number, the sequence number and the instance number into the message to obtain a message with an identifier, wherein the sending database instance refers to the original sender of the message; The identified message is sent to a receiving database instance in the shared cluster database that receives the message. After receiving the identified message, the receiving database instance performs a reverse order detection based on the instance number, session number and sequence number in the identified message to decide on the execution operation of the identified message. The receiving database instance refers to the last database instance that receives the identified message.

2. A message processing method for a shared cluster database, characterized in that: The message processing method is applied to a receiving database instance in the shared cluster database, and the receiving database instance is used to receive a message, including: Upon receiving the identified message sent by the sending database instance or the identified message forwarded by the intermediate database instance as claimed in claim 1, determining a received message having the same instance number and session number as those in the identified message, wherein the intermediate database instance is a database instance in the shared cluster database that routes and forwards the identified message sent by the sending database instance; If the sequence number of the received message is greater than the sequence number of the identified message, the identified message is discarded; if the sequence number of the received message is less than the sequence number of the identified message, the identified message is placed in the message queue of the processing thread to wait for the processing thread to process the identified message in the message queue.

3. The message processing method of the shared cluster database according to claim 2, characterized in that: The step of placing the identified message into a message queue of a processing thread includes: Determine a message type identified in the identified message, wherein the message type includes an original type and a retry type, the identified message corresponding to the message sent by the sending database instance for the first time is the original type, and the identified message corresponding to the message sent by the sending database instance for the second time and thereafter is the retry type; If the message type is the original type, placing the identified message into the public message queue of the receiving database instance; If the message type is a retry type, the state of an original message of an original type corresponding to the identified message is determined, and the identified message is placed into a message queue of a processing thread according to the state of the original message.

4. The message processing method of the shared cluster database according to claim 3, characterized in that: The step of placing the identified message into a message queue of a processing thread according to the state of the original message comprises: If the original message has been received and is in a being processed state or has been processed state, the identified message is placed into a private message queue of a processing thread that processes the original message.

5. The message processing method of the shared cluster database according to claim 3, characterized in that: The step of placing the identified message into a message queue of a processing thread according to the state of the original message comprises: If the original message has been received and is in an unprocessed state, the original message is deleted and the identified message is placed in the public message queue.

6. The message processing method of the shared cluster database according to claim 3, characterized in that: The step of placing the identified message into a message queue of a processing thread according to the state of the original message comprises: If the original message is not received, the identified message is placed in the public message queue.

7. A message sending device for a shared cluster database, characterized in that: The message sending device is applied to a sending database instance in the shared cluster database, and the sending database instance is used to send a message, including: An acquisition module, used for acquiring the session number of a sending thread and the sequence number assigned by the sending thread to the message when a sending thread is about to send a message, wherein the sequence number assigned by the sending thread increases with the number of messages sent; an identification module, used to obtain the instance number of the sending database instance, write the session number, the sequence number and the instance number into the message, and obtain a message with an identification, wherein the sending database instance refers to the original sender of the message; A sending module is used to send the identified message to a receiving database instance in the shared cluster database that receives the message. After receiving the identified message, the receiving database instance performs a reverse order detection based on the instance number, session number and sequence number in the identified message to decide on the execution operation of the identified message. The receiving database instance refers to the last database instance that receives the identified message.

8. A message processing device for a shared cluster database, characterized in that: The message processing device is applied to a receiving database instance in the shared cluster database, and the receiving database instance is used to receive a message, including: A first determination module is used to determine a received message having the same instance number and session number as those in the message with identification when receiving the message with identification sent by the sending database instance or the message with identification forwarded by the intermediate database instance as claimed in claim 1, wherein the intermediate database instance is a database instance in the shared cluster database that routes and forwards the message with identification sent by the sending database instance; A processing module is used to discard the identified message if the sequence number of the received message is greater than the sequence number of the identified message, and to put the identified message into the message queue of the processing thread if the sequence number of the received message is less than the sequence number of the identified message, so as to wait for the processing thread to process the identified message in the message queue.

9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the message sending method of the shared cluster database according to claim 1 or the message processing method of the shared cluster database according to any one of claims 2 to 6 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the message sending method of the shared cluster database according to claim 1 or the message processing method of the shared cluster database according to any one of claims 2 to 6 is implemented.

Citation Information

Patent Citations

  • Data processing method and device

    CN114595245A

  • Message sending method, message receiving method, device and equipment

    CN116760510A