A log submission method and device, a storage medium and an electronic device
By determining the latest submission time in the distributed database system and filtering operation logs earlier than that time, the problem of inconsistent log playback order in different data center nodes is solved, and data consistency is achieved.
Patent Information
- Application Number
- CN202211739339.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-31
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-12-31
AI Technical Summary
In a distributed database system, due to network delays and other reasons, the operation log playback order of the master and slave nodes in different data centers for the same data is inconsistent, affecting data consistency.
By obtaining the operation log written by the second node on the first node, determining the latest submission time, and filtering out the operation logs earlier than this time as the second logs, waiting for all second logs to receive the indication message, the logs are submitted and replayed in the order of submission time.
This ensures that the log playback order of the same data by nodes in different data centers is consistent, thus guaranteeing the data consistency of the distributed database system.
Smart Images

Figure CN115982190B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the technical field of distributed database, and particularly relates to a log submission method and device, a storage medium and an electronic equipment. BACKGROUND
[0002] At present, distributed database systems are widely used in various industries to better protect users' private data. Among them, a distributed database system can be composed of multiple data centers, and a data center can be composed of a plurality of database devices in the same geographic area.
[0003] In order to deal with the problem of data loss caused by node failure of the distributed database system, it is necessary to back up the data in the node, therefore, for any two nodes in the distributed database system that store the same data, the same data needs to be updated based on the operation log. Among them, the two nodes are located in different data centers.
[0004] The process of updating the same data stored by nodes in different data centers in the prior art is as shown in Figure 1
[0005] Suppose that data A needs to be modified now, and the master node a in data center 1 and the slave node b in data center 2 both store data A. The master node a in data center 1 can first send the operation log corresponding to data A to the slave node b, then the master node a can first lock itself, after locking, the master node a writes the operation log corresponding to data A into the local memory. At the same time, the slave node b writes the received operation log corresponding to data A into the local memory. After writing the log, the slave node b returns the write completion information to the master node a. After receiving the write completion information, the master node a determines the submission time of the operation log corresponding to data A to the task queue, and sends the submission time to the slave node b. After sending the submission time, the master node a submits the operation log corresponding to data A to the task queue according to the submission time, and then unlocks the master node a. At the same time, after the slave node b receives the submission time, it submits the operation log corresponding to data A to the task queue according to the submission time, and then sends the submission completion information to the master node a. Finally, the master node a and the slave node b perform log replay according to the submission order of each operation log in the respective task queue to update data A.
[0006] However, due to network delay and other reasons, the time when the slave node submits the operation log may not be consistent with the time when the master node submits the operation log, so that at a certain moment, when the master node and the slave node replay the operation logs in the respective task queues, the operation logs that can originally be replayed cannot participate in the replay because they are not submitted to the task queue, thereby causing the replay order to be inconsistent when the master node and the slave node in different data centers replay the operation logs of the same data. SUMMARY
[0007] Embodiments of the present specification provide a log submission method, device, storage medium and electronic equipment to partially solve the problems existing in the prior art.
[0008] Embodiments of the present specification adopt the following technical solutions:
[0009] The log submission method provided by the present specification comprises:
[0010] The first node obtains each operation log for the same data written by the second node, the first node and the second node being different nodes in a distributed database system, and the first node and the second node being located in different data centers in the distributed database system;
[0011] For each operation log, if it is determined that the indication message sent by the second node for the operation log has been received, the operation log is taken as a first log, and the indication message carries a submission time for the operation log;
[0012] A latest submission time is determined from the submission times corresponding to the first logs;
[0013] Other operation logs in the operation logs except the first logs are determined, and operation logs whose writing time by the second node is earlier than the latest submission time are selected from the other operation logs as second logs;
[0014] After waiting until the indication messages corresponding to all second logs sent by the second node are received, the operation logs are submitted according to the submission time corresponding to each operation log.
[0015] Optionally, after the operation logs whose writing time by the second node is earlier than the latest submission time are selected from the other operation logs as second logs, the method further comprises:
[0016] The log identifiers corresponding to the second logs are added to a first array;
[0017] For each second log, if an indication message sent by the second node for the second log is received, a log identifier corresponding to the second log is removed from the first array and stored in a second array, the second array being used to store log identifiers of operation logs corresponding to commit time.
[0018] Optionally, the method further comprises:
[0019] When it is monitored that log identifiers corresponding to all second logs have been removed from the first array, it is determined that indication messages sent by the second node for all second logs are received, and operation logs corresponding to log identifiers stored in the second array are committed according to the order of commit time.
[0020] Optionally, the method further comprises:
[0021] For each second log, if it is determined that the second log has been rolled back, the log commit is not performed on the second log.
[0022] The present specification provides a log commit device, comprising:
[0023] An obtaining module is configured to obtain, by a first node, operation logs for the same data written by a second node, the first node and the second node being different nodes in a distributed database system, and the first node and the second node being located in different data centers in the distributed database system;
[0024] A first determining module is configured to, for each operation log, if it is determined that an indication message sent by the second node for the operation log has been received, take the operation log as a first log, and the indication message carries a commit time for the operation log;
[0025] A second determining module is configured to determine, from commit times corresponding to all first logs, a latest commit time;
[0026] A screening module is configured to determine operation logs other than the first logs from all operation logs, and screen, from the operation logs other than the first logs, operation logs whose write time by the second node is earlier than the latest commit time as second logs;
[0027] A commit module is configured to, when indication messages sent by the second node for all second logs are received, commit all operation logs according to commit times corresponding to the operation logs, and perform log replay in the order of committing the operation logs.
[0028] The filtering module is further configured to filter, from the other operation logs, operation logs of the second node write operation logs whose time points are earlier than the latest commit time point, as second logs, and add log identifiers corresponding to the second logs to a first array; and for each second log, if an indication message corresponding to the second log is received from the second node, remove the log identifier corresponding to the second log from the first array and store the log identifier in a second array, the second array being configured to store log identifiers of operation logs corresponding to commit time points.
[0029] Optionally, the commit module is specifically configured to, when it is monitored that the log identifiers corresponding to the second logs have all been removed from the first array, determine that the indication messages corresponding to all the second logs are received from the second node, and commit the operation logs corresponding to the log identifiers stored in the second array in the order of the commit time points.
[0030] Optionally, the commit module is further configured to, for each second log, if it is determined that the second log has been rolled back, not perform log commit on the second log.
[0031] The present specification provides a computer readable storage medium, the storage medium stores a computer program, and the computer program is executed by a processor to implement the log commit method.
[0032] The present specification provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the log commit method when executing the program.
[0033] The above at least one technical solution adopted by the embodiments of the present specification can achieve the following beneficial effects:
[0034] After the first node obtains the operation logs of the second node for the same data in the embodiment of the present specification, the operation log receiving the indication message carrying the commit time is taken as the first log, and the latest commit time is determined from the commit time corresponding to each first log. Then, the operation log whose writing time is earlier than the latest commit time is selected from the operation log other than the first log as the second log. After all the second logs receive the indication message, the operation logs are committed according to the commit time. The first node and the second node are located in different data centers. In this method, after the operation logs without receiving the prompt message all receive the indication message, the operation logs are committed according to the commit time and played back in turn, which can avoid the problem that the log playback order of the nodes in different data centers for the same data is inconsistent, so as to ensure the data consistency of the distributed database system. BRIEF DESCRIPTION OF DRAWINGS
[0035] The drawings described herein are used to provide further understanding of the present specification, constitute a part of the present specification, the illustrative embodiments of the present specification and the description thereof are used to explain the present specification, and do not constitute improper limitation on the present specification. In the drawings:
[0036] Figure 1 A process diagram for updating the same data stored by the nodes in different data centers in the prior art is shown;
[0037] Figure 2 A process diagram for updating the same data stored by the nodes in different data centers in the prior art based on transaction concurrency scenario is shown;
[0038] Figure 3 A flowchart of the log commit method provided by the embodiment of the present specification is shown;
[0039] Figure 4 A structure diagram of the log commit device provided by the embodiment of the present specification is shown;
[0040] Figure 5 A structure diagram of the electronic device provided by the embodiment of the present specification is shown. DETAILED DESCRIPTION
[0041] Based on the commit step and playback step of the operation log of the transaction shown in the prior art, the following problems may occur: Figure 1
[0042] 1. Before the master node a in the data center 1 is locked, the slave node b in the data center 2 has written the operation log for the data A.
[0043] 2. After unlocking the master node a in data center 1, the slave node b in data center 2 submits the operation log to the task queue.
[0044] Regarding the first problem: In a transaction concurrency scenario, since the operation logs corresponding to multiple transactions are sent to the slave nodes in advance and then locked, it is possible that the master node only selects one transaction from multiple transactions and locks it based on the selected transaction. In this way, for a certain transaction, before the master node a locks the transaction, the slave node b may write other operation logs for data A, resulting in inconsistent order in which the master node a and the slave node b write the operation logs for the same data. Similarly, regarding the second problem: if the slave node b submits the operation log to the local task queue a long time later, there may be other operation logs for data A after the master node a unlocks it and before the slave node b submits the operation log, resulting in inconsistent order in which the master node a and the slave node b write the operation logs for the same data.
[0045] To address the above two issues, the existing technology provides a logical diagram of the inconsistent order of log writing between master and slave nodes in a transaction concurrency scenario, such as Figure 2 As shown. Among them, Figure 2 In this example, two concurrent transactions that update data B are transaction 1 and transaction 2. Data B is stored in the master node a of data center 1 and the slave node b of data center 2. The data B stored in the slave node b is a copy of the data B stored in the master node a. Figure 2 In this example, the master node a is the proxy node of data center 1, and the slave node b is the proxy node of data center 2. The writing process and submission process of the operation log corresponding to the concurrent transaction are explained.
[0046] exist Figure 2 In Figure 1, the time sequence of executing transactions for nodes in data center 1 and data center 2 increases from left to right. Figure 2 The figure only shows the process of transactions 1 and 2 locking, writing to the log, committing to the log, and unlocking data B. It does not show the log replay process. Here, locki, logi, c_logi, and unlocki represent the locking, writing to the log, committing to the log, and unlocking of data B by transaction i, respectively.
[0047] In addition, the structure of the operation log corresponding to the transaction includes at least: status, write time, commit time, operation data, etc. Figure 2The operation data is not shown. Among them, the state of the log at least includes: initial empty state, written, committed, rolled back, played back, etc. The writing time can refer to the time when the operation log is saved to the local memory, and the committing time can refer to the time when the operation log is committed to the local task queue.
[0048] In order to distinguish the operation log committing process of transaction 1 and transaction 2, transaction 1 is represented by a solid line, and transaction 2 is represented by a dashed line.
[0049] From Figure 2 It can be seen that the master node a of the data center 1 sends the operation log corresponding to transaction 1 to the slave node b of the data center 2 at T1 time, and writes it into the slave node b, and sends the operation log corresponding to transaction 2 to the slave node b at T2 time, and writes it into the slave node b. Then, the master node a locks the master node b in the data center 1 based on transaction 2, and writes the operation log of transaction 2 to the master node a. At the same time, the slave node b writes the operation log of transaction 2, and returns the write completion information to the data center 1. The master node a determines the committing time of transaction 2, i.e. T3 time, according to the received write completion information for transaction 2, and sends T3 time to the slave node b. After that, the state of the operation log of transaction 2 of the master node b is changed to committed, and T3 time is recorded as the committing time of the operation log, and then the master node a is unlocked. Next, the master node a locks the master node a based on transaction 1, and writes the operation log corresponding to transaction 1 to the master node a. After that, the master node a receives the write completion information for transaction 1 sent by the slave node b of the data center 2, determines the committing time of transaction 1, T6 time, and sends T6 time to the slave node b. The master node a changes the state of the operation log corresponding to transaction 1 to committed, and records T6 time as the committing time of the operation log of transaction 1, and then unlocks the master node a.
[0050] For the data center 2, after receiving T6 time, the state of the operation log corresponding to transaction 1 in the slave node b is changed to committed, and T6 time is recorded as the committing time of the operation log corresponding to transaction 1. After that, the slave node b returns the information that transaction 1 has been committed to the master node a. Then, the state of the operation log corresponding to transaction 2 in the slave node b is changed to committed, and T3 time is recorded as the committing time of the operation log corresponding to transaction 2. After that, the slave node b returns the information that the operation log corresponding to transaction 2 has been committed to the master node a.
[0051] For the master node a, since the master node a has locking and unlocking for each transaction, the writing order and the committing order of the master node a for transaction 1 and transaction 2 are standard. The correct order of the master node a executing the transaction is: writing the operation log of transaction 2, committing the operation log of transaction 2, writing the operation log of transaction 1, and committing the operation log of transaction 1.
[0052] However, for the slave node b, the order of executing the transactions is: writing the operation log of transaction 1, writing the operation log of transaction 2, committing the operation log of transaction 1, and committing the operation log of transaction 2.
[0053] When all the operation logs in the slave node b are replayed asynchronously, if the replay is performed according to the order in which the operation logs are written to the slave node b, there is a problem that the order of writing the operation logs of transactions 1 and 2 is inconsistent between the master node a and the slave node b; if the replay is performed according to the order of the commit time of the operation logs committed before a certain time, there is a situation that part of the operation logs written to the slave node b before the time are not committed, and the uncommitted logs cannot be sorted according to the commit time, which may cause the replay order of the operation logs of transactions 1 and 2 to be inconsistent between the master node a and the slave node b. That is, in Figure 2 , if the operation logs before the T6 time are replayed according to the commit time of the operation logs, since the operation logs of transaction 2 are not committed at the T6 time, the replay cannot be performed according to the commit time, so that the operation logs of transaction 1 are replayed before the operation logs of transaction 2, and the master node a replays the operation logs corresponding to transaction 2 first, and then replays the operation logs corresponding to transaction 1. It can be seen that the replay order of the logs of the same data is inconsistent between the master node a and the slave node b.
[0054] For the purposes, technical solutions and advantages of the present specification to be clearer, the technical solutions of the present specification will be described clearly and completely in the following with reference to the specific embodiments of the present specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present specification, rather than all the embodiments. Based on the embodiments in the present specification, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the scope of protection of the present specification.
[0055] The technical solutions provided by the embodiments of the present specification will be described in detail below with reference to the drawings.
[0056] The present specification provides a flow diagram of a log commit method, as shown in Figure 3 The log commit method can be applied to each node of a distributed database system, and the log commit method comprises:
[0057] S300: A first node acquires each operation log for the same data written by a second node, the first node and the second node being different nodes in a distributed database system, and the first node and the second node being located in different data centers in the distributed database system.
[0058] In the embodiments of the present specification, the distributed database system is composed of multiple data centers, each data center contains a proxy node, and multiple proxy nodes can also be set in a data center for load balancing. Among them, a data center can be composed of several database devices in the same geographic area, that is, the nodes of the distributed database system can refer to the database devices. The proxy node is used to send operation logs and indication messages to any node in the data center where the proxy node is located through Remote Direct Memory Access (RDMA). For any two data centers, the proxy nodes of the two data centers communicate through a TCP / IP network, that is, the proxy node of one data center sends operation logs and indication messages to the proxy node of another data center through a TCP / IP network.
[0059] Among them, the indication message can be used to indicate the submission time of the operation log local to the node to the task queue, and the operation log in the task queue is used to perform log replay. The submission time can be determined by the time when the operation logs for the same data are written to all nodes storing the data. In addition, the submission time carried by the operation log in the indication message can be determined by the node initiating the transaction corresponding to the operation log, wherein the node initiating the transaction corresponding to the operation log can include: the proxy node, the node storing the original data for the same data (hereinafter referred to as the master node). In addition, the node storing the copy data corresponding to the same data can be regarded as a slave node.
[0060] Next, taking the first node as an example, the log submission of each operation log for the same data is explained, wherein the first node can be a slave node.
[0061] In the embodiments of the present specification, after the second node writes each operation log for the same data to the memory of the first node, the first node can obtain each operation log for the same data written by the second node. Among them, the first node and the second node are different nodes in the distributed database system, and the first node and the second node are located in different data centers in the distributed database system. The first node can be a slave node storing a copy of data for the same data, and the slave node can be a proxy node in the data center where the first node is located. The second node can refer to a master node storing the original data for the same data, and the master node can be a proxy node in the data center where the second node is located.
[0062] After the operation logs for the same data are written in the memory area of the first node, all the operation logs of the memory area of the first node can be determined based on the head pointer and the tail pointer of the memory area of the first node. Then, the operation logs for the same data can be determined according to the data to be operated by each operation log. The operation can refer to a read operation and / or a write operation. The head pointer points to the memory address of the memory storing the logs, and the tail pointer points to the memory address of the memory to be written with the logs. The memory area can refer to a ring buffer.
[0063] In addition, for each operation log written in the first node, the operation log corresponds to a log state, a time when the node is written, operation data, and the like. The log state of the operation log at least includes: written, committed, rolled back, played back, and the like. The operation data can refer to the data content for updating the data to be updated. When the log state of the operation log is committed, the operation log corresponds to a commit time that should be committed to the task queue.
[0064] S302: For each operation log, if it is determined that the indication message sent by the second node for the operation log has been received, the operation log is taken as a first log, and the commit time for the operation log is carried in the indication message.
[0065] In the embodiments of the present application, for each operation log for the same data, it is determined whether the operation log receives the indication message sent by the second node for the operation log. If it is determined that the operation log receives the indication message sent by the second node for the operation log, the operation log is taken as a first log. The commit time for the operation log is carried in the indication message for the operation log. Therefore, the first log can refer to the operation log with the log state of committed and the commit time.
[0066] When it is determined whether the operation log receives the indication message, for each operation log for the same data, the log state of the operation log can be monitored. If the log state of the operation log is committed, it is determined that the operation log receives the indication message sent by the second node for the operation log.
[0067] S304: From the commit times corresponding to the first logs, the latest commit time is determined.
[0068] S306: The operation logs other than the first logs in the operation logs are determined, and the operation logs with the time when the second node writes the operation logs earlier than the latest commit time are selected from the other operation logs as second logs.
[0069] In the embodiments of the present disclosure, after the first logs are determined, the latest commit time can be determined from the commit times corresponding to the first logs, and then other operation logs of the same data except the first logs are determined, and then the operation logs of the second node writing operation logs whose time is earlier than the latest commit time are filtered from the other operation logs of the same data except the first logs as the second logs according to the latest commit time. The second logs can refer to the operation logs of the second node whose time is earlier than the latest commit time and whose log state is written. That is, the node receives the indication message of each second log.
[0070] In addition to the above method, after the first logs are determined, the operation logs whose log state is written can be filtered from the operation logs of the same data as the target operation logs according to the log state. Then, for each target operation log, the time of the second node writing the target operation log is compared with the commit time corresponding to each first log. If the time of the second node writing the target operation log is earlier than the commit time corresponding to all first logs, the target operation log is taken as the second log.
[0071] In the embodiments of the present disclosure, the reason for filtering the second logs whose time of the second node is earlier than the latest commit time is that the node does not receive the indication message of each second log, so as to determine the order of the commit of the second logs and the first logs. Therefore, in order to determine the order of the commit of the second logs and the first logs, it is necessary to receive the indication message of the second logs and then reorder according to the commit time.
[0072] In order to clearly distinguish the first logs and the second logs, after the second logs are filtered, the log identifiers corresponding to the second logs are added to the first array. For each second log, if the indication message corresponding to the second log sent by the second node is received, the log identifier corresponding to the second log is removed from the first array, and the log identifier corresponding to the second log is stored in the second array. The second array is used to store the log identifiers of the operation logs corresponding to the commit time.
[0073] In short, the first array stores the log identifiers of the operation logs that have been written by the second node and have not been committed, and the second array stores the log identifiers of the operation logs that have been committed.
[0074] S308: Wait until the indication messages corresponding to all second logs sent by the second node are received, and then commit the operation logs according to the commit time corresponding to each operation log.
[0075] In the embodiments of the present application, when waiting to receive the indication message corresponding to all the second logs sent by the second node, the operation logs corresponding to the same data can be committed according to the commit time of each operation log.
[0076] Specifically, when the log state of all the second logs is changed to committed, it is determined that the node receives the indication message corresponding to all the second logs sent by the second node. Then, the operation logs corresponding to the same data are submitted to the task queue in the order of the commit time. Finally, the same data is updated according to the operation data corresponding to each operation log in the order of the commit time.
[0077] In addition, when it is monitored that the log identifiers corresponding to each second log have been removed from the first array, it is determined that the indication message corresponding to all the second logs sent by the second node is received. Then, the operation logs corresponding to the log identifiers stored in the second array are submitted in the order of the commit time.
[0078] In addition, during the process of waiting for the indication message of each second log sent by the second node, if the distributed database system fails, no operation is required for the data.
[0079] During the process of waiting for the indication message of each second log sent by the second node, for each second log, if it is determined that the log state of the second log is rolled back, the log commit of the second log is not performed. Wherein, the log state of the second log can be changed from rolled back to played back.
[0080] After the playback of the operation logs corresponding to the same data is completed, the log state of the played back operation log can be set to played back, and the head pointer is updated. Then, each operation log corresponding to the same data can be reacquired, and the second log can be re-screened, and the process of waiting to receive the indication message corresponding to the re-screened second log is continued. Finally, the reacquired operation logs are played back in the order of the commit time.
[0081] To solve the problem of inconsistent log playback order in the prior art, based on Figure 3The provided log submission method can be used to determine the operation logs (i.e., the operation log of transaction 1 and the operation log of transaction 2) written to the slave node b at T6. Among them, the operation log corresponding to transaction 1 receives the submission time point, and the operation log of transaction 1 is taken as the first log. Then, the latest submission time point corresponding to each operation log is determined, that is, the T6 time point corresponding to the operation log of transaction 1. Then, the operation log with a write time earlier than the latest submission time point is screened out, that is, the operation log of transaction 2. After waiting for the operation log of transaction 2 to receive the submission time point, the submission time point of the operation log of transaction 2 is determined, that is, the T3 time point. The operation log of transaction 2 and the operation log of transaction 1 are submitted to the task queue in the order of the submission time point from small to large, and the operation log of transaction 2 and the operation log of transaction 1 are played back in turn. That is, the operation log of transaction 2 is played back first and then the operation log of transaction 1. In this way, the log playback order of the same data of the slave node b is consistent with the log playback order of the master node a, so that the same data records stored by the slave node b and the master node a are consistent, thereby ensuring the data consistency of the distributed database system.
[0082] According to the method shown in the above Figure 3 As can be seen from the method, after the first node obtains the operation logs of the same data written by the second node, the operation log receiving the indication message carrying the submission time point in the operation logs is taken as the first log, and the latest submission time point is determined from the submission time points corresponding to the first logs. Then, the operation log with a write operation log time earlier than the latest submission time point is screened out from the operation logs other than the first logs as the second log. After all the second logs receive the indication message, the operation logs are submitted according to the submission time point. The first node and the second node are located in different data centers. In this method, the operation logs that do not receive the prompt information are submitted and played back in turn according to the submission time point after all the operation logs receive the indication message, which can avoid the problem that the log playback order of the same data of the nodes located in different data centers is inconsistent, thereby ensuring the data consistency of the distributed database system.
[0083] The log submission method provided by the embodiment of the present application is based on the same idea, and the present application also provides a corresponding device, a storage medium and an electronic equipment.
[0084] Figure 4 The structure diagram of a log submission device provided by the embodiment of the present application, the device comprises:
[0085] The acquisition module 401 is configured to acquire, by a first node, operation logs for the same data written by a second node, the first node and the second node being different nodes in a distributed database system, and the first node and the second node being located in different data centers in the distributed database system.
[0086] The first determination module 402 is configured to, for each operation log, if it is determined that the indication message sent by the second node for the operation log has been received, taking the operation log as a first log, and the indication message carries a commit time for the operation log.
[0087] The second determination module 403 is configured to determine a latest commit time from the commit times corresponding to the first logs.
[0088] The screening module 404 is configured to determine other operation logs in the operation logs except the first logs, and screen, from the other operation logs, operation logs with a write time of the operation logs by the second node earlier than the latest commit time as second logs.
[0089] The commit module 405 is configured to wait until the indication messages sent by the second node for all the second logs are received, commit the operation logs according to the commit times corresponding to the operation logs, and perform log replay in the order of committing the operation logs.
[0090] Optionally, after screening, from the other operation logs, the operation logs with the write time of the operation logs by the second node earlier than the latest commit time as the second logs, the screening module 404 is further configured to add log identifiers corresponding to the second logs to a first array, and for each second log, if the indication message sent by the second node for the second log is received, remove the log identifier corresponding to the second log from the first array and store the log identifier in a second array, the second array being configured to store log identifiers of operation logs with commit times.
[0091] Optionally, the commit module 405 is specifically configured to, when it is monitored that the log identifiers corresponding to the second logs have all been removed from the first array, determine that the indication messages sent by the second node for all the second logs have been received, and commit the operation logs corresponding to the log identifiers stored in the second array in the order of the commit times.
[0092] Optionally, the commit module 405 is further configured to, for each second log, if it is determined that the second log has been rolled back, not perform log commit on the second log.
[0093] This specification also provides a computer-readable storage medium, wherein the storage medium stores a computer program, which can be used to perform the above-mentioned Figure 3 Provided log submission method.
[0094] based on Figure 3 The log submission method shown in this specification also provides Figure 5 The structural diagram of unmanned equipment is shown in FIG. Figure 5 At the hardware level, the unmanned equipment includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 3 Log submission method shown.
[0095] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0096] In the 1990s, it was quite obvious to distinguish whether an improvement in a technology was in hardware (e.g., improvement in circuit structures of diodes, transistors, switches, etc.) or in software (improvement in method flow). However, as technology has evolved, many improvements in method flow today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flow into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented by hardware entity modules. For example, a programmable logic device (PLD) such as a field programmable gate array (FPGA) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming it, rather than by ordering a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented by "logic compiler" software, which is similar to software compilers used in program development, and the original code before compilation must also be written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit that implements the logical method flow can be easily obtained.
[0097] The controller can be implemented in any suitable way, e.g. the controller can take the form of a microprocessor or processor and a computer readable medium storing computer readable program code, e.g. software or firmware, executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller and an embedded microcontroller, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91 SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to being implemented in pure computer readable program code form, the controller can perfectly well be implemented by means of logic programmed into logic gates, switches, application specific integrated circuits, programmable logic controllers and embedded microcontrollers, etc. to perform the same functions. The controller can thus be considered as a hardware component, and the means comprised therein for performing various functions can be considered as structures within the hardware component. Alternatively, or even, the means for performing various functions can be considered as both a software module implementing a method and a structure within a hardware component.
[0098] The systems, apparatuses, modules or units illustrated by the above embodiments can be implemented by computer chips or entities, or products with certain functions. A typical implementation device is a computer. Specifically, the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0099] For the sake of description, the above apparatuses are described in various units by functions respectively. Of course, the functions of each unit can be implemented in the same or multiple software and / or hardware in implementing the present specification.
[0100] Those skilled in the art will understand that the embodiments of the present specification can be provided as a method, a system, or a computer program product. Therefore, the present specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0101] The specification is presented with reference to flow diagrams and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing element or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 one or more flow or multiple flows and / or blocks Figure 1 one or more flow or multiple flows and / or blocks
[0102] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 one or more flow or multiple flows and / or blocks Figure 1 one or more flow or multiple flows and / or blocks
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 one or more flow or multiple flows and / or blocks Figure 1 one or more flow or multiple flows and / or blocks
[0104] In one typical configuration, the computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0105] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory, etc. The memory is an example of computer readable media.
[0106] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.
[0107] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not only include those elements, but can also include other elements not expressly listed or inherent to such process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.
[0108] Those skilled in the art will appreciate that embodiments of the present specification can be provided as methods, systems or computer program products. Therefore, the present specification can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0109] The present specification can be described in the general context of computer-executable instructions, such as program modules, executed by computers. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The present specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
[0110] The various embodiments described in this specification are described using a numbering of embodiments approach: these are each individually integrated contributions pertaining to different aspects of the description. For each embodiment, the description focuses on the differences from the other embodiments. In particular, the description of the system embodiments is relatively brief, as the system embodiments are largely analogous to the method embodiments. The relevant parts of the description of the method embodiments are referred to.
[0111] The above only describes the embodiments of the present specification and is not intended to limit the present specification. The present specification can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of claims of the present specification.
Claims
1. A log committing method, comprising: obtaining, by a first node, operation logs for a same data written by a second node, the first node and the second node being different nodes in a distributed database system, and the first node and the second node being located in different data centers in the distributed database system; for each operation log, if it is determined that an indication message sent by the second node for the operation log has been received, taking the operation log as a first log, the indication message carrying a committing time for the operation log; determining a latest committing time from the committing times of the first logs; determining operation logs other than the first logs from the operation logs, and selecting, from the operation logs other than the first logs, operation logs whose writing time by the second node is earlier than the latest committing time as second logs; waiting until indication messages sent by the second node for all the second logs are received, and committing the operation logs according to the committing times of the operation logs. 2.The method of claim 1, after the operation logs whose writing time by the second node is earlier than the latest committing time are selected from the operation logs other than the first logs as second logs, the method further comprises: adding log identifiers corresponding to the second logs to a first array; for each second log, if an indication message sent by the second node for the second log is received, removing the log identifier corresponding to the second log from the first array and storing the log identifier in a second array, the second array being used to store log identifiers of operation logs corresponding to committing times. 3.The method of claim 2, waiting until indication messages sent by the second node for all the second logs are received, and committing the operation logs according to the committing times of the operation logs, specifically comprising: when it is monitored that the log identifiers corresponding to the second logs have all been removed from the first array, it is determined that the indication messages sent by the second node for all the second logs are received, and the operation logs corresponding to the log identifiers stored in the second array are committed according to the order of the committing times. 4.The method of claim 1, the method further comprises: for each second log, if it is determined that the second log has been rolled back, not performing log committing on the second log. 5.A log committing apparatus, comprising: an obtaining module, configured to obtain, by a first node, operation logs for a same data written by a second node, the first node and the second node being different nodes in a distributed database system, and the first node and the second node being located in different data centers in the distributed database system; a first determining module, configured to, for each operation log, if it is determined that an indication message sent by the second node for the operation log has been received, take the operation log as a first log, the indication message carrying a committing time for the operation log; determine a latest commit time from commit times corresponding to the first logs; determine other operation logs in the operation logs except the first logs, and filter, from the other operation logs, operation logs whose write time by the second node is earlier than the latest commit time, as second logs; commit the operation logs according to the commit times corresponding to the operation logs, when receiving indication messages corresponding to all the second logs from the second node.
6. The apparatus of claim 5, after filtering, from the other operation logs, operation logs whose write time by the second node is earlier than the latest commit time, as second logs, the filtering module is further configured to add log identifiers corresponding to the second logs to a first array; for each second log, if receiving an indication message corresponding to the second log from the second node, remove the log identifier corresponding to the second log from the first array and store the log identifier in a second array, the second array is used to store log identifiers of operation logs corresponding to commit times.
7. The apparatus of claim 6, the commit module is specifically configured to determine that the indication messages corresponding to all the second logs are received from the second node when monitoring that log identifiers corresponding to the second logs are all removed from the first array, and commit operation logs corresponding to log identifiers stored in the second array according to commit times in chronological order.
8. The apparatus of claim 5, the commit module is further configured to, for each second log, if determining that the second log is rolled back, not perform log commit on the second log.
9. A computer readable storage medium, the storage medium stores a computer program, the computer program is executed by a processor to implement the method in any one of claims 1-4.
10. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implements the method in any one of claims 1-4 when executing the program.
Citation Information
Patent Citations
Transaction log processing method, device and system
CN112162833A
Multi-replica asynchronous table replication
US20160371357A1