Log playback method and device
By assigning continuous log numbers to data operations and judging number continuity, the problem of failure to detect writes during log playback is solved, and the accuracy and consistency of log playback is achieved.
Patent Information
- Application Number
- CN202510121974.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-23
AI Technical Summary
The prior art cannot detect the failure of the data operation log writing during log playback, resulting in the inconsistent playback results with the actual data operation.
By assigning a continuous log number to each data operation, and determining whether the number of the log to be played back and the number of the previous successful playback log is continuous during the log playback request, if it is not continuous, playback will be stopped.
It effectively avoids log playback results errors caused by log writing failures, ensuring the accuracy and consistency of log playback.
Smart Images

Figure CN120029852A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more particularly to a log playback method and device. Background Art
[0002] Log playback is an important means of data processing. By recording and storing log information of data operations, users can replay these logs when needed to reproduce a series of operations performed on the data in the past. This technology is of great significance for debugging, troubleshooting, performance analysis, security auditing, and user behavior analysis.
[0003] In the process of writing logs to the log storage space, some data operations may fail to be written due to internal and external factors such as unstable network connection, hardware failure, and software configuration problems.
[0004] During log playback, the playback process often only plays back the logs that were written successfully, and cannot determine whether there are any data operation logs that failed to be written. Summary of the invention
[0005] This specification provides a log playback method and device to partially solve the above problems existing in the prior art.
[0006] This manual adopts the following technical solutions:
[0007] This manual provides a log playback method, including:
[0008] Based on the execution order of the current data operation and in accordance with the principle of continuous number allocation, a corresponding log number is allocated to the operation log generated by the current data operation; the log number is used to indicate the operation order when the data operation is executed on the operation log after the operation log is written to the log storage object distributed in sequence;
[0009] After receiving a log playback request, determine whether the log number corresponding to the current operation log to be played back is continuous with the log number corresponding to the last operation log that completed playback; if so, perform log playback according to the operation log to be played back; if not, stop log playback for the operation log to be played back.
[0010] Optionally, if the operation log generated by the current data operation is not successfully written into the log storage object, the method further includes:
[0011] When it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, the operation log generated by the current data operation and the operation log generated by the next data operation are sequentially written into the next log storage object.
[0012] Optionally, if the log number corresponding to the current operation log to be replayed is not continuous with the log number corresponding to the last operation log that has been replayed, the method further includes:
[0013] Determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number;
[0014] Determine whether the next log storage object after the log storage object where the operation log to be replayed is located stores both the operation log corresponding to the retry number and the operation log to be replayed;
[0015] If so, log playback is performed on the operation log corresponding to the retry number and the operation log to be replayed stored in the next log storage object in the order in which the operation log corresponding to the retry number and the operation log to be replayed are written to the next log storage object; otherwise, log playback is prohibited and log playback failure information is returned.
[0016] Optionally, if the operation log generated by the current data operation is not successfully written into the log storage object, the method further includes:
[0017] When it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, the operation log generated by the current data operation is written into the next log storage object; and
[0018] The log number corresponding to the operation log generated by the current data operation and the log number corresponding to the operation log generated by the next data operation are added to the log playback linked list; wherein the log playback linked list is used to indicate the log playback order corresponding to the operation logs stored in each log storage object when performing log playback.
[0019] Optionally, if the log number corresponding to the current operation log to be replayed is not continuous with the log number corresponding to the last operation log that has been replayed, the method further includes:
[0020] Determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number;
[0021] Determine whether the next log storage object after the log storage object where the operation log to be replayed is located stores the operation log corresponding to the retry number and does not store the operation log to be replayed;
[0022] If so, based on the log playback order indicated by the log playback linked list, the operation log corresponding to the retry number and the operation log to be played back are played back in sequence; otherwise, log playback is prohibited and log playback failure information is returned.
[0023] Optionally, if other operation logs whose log numbers are located before the operation log to be written are successfully written into the log storage object, the method further includes:
[0024] The log number corresponding to the last operation log successfully written into the log storage object is used as the auxiliary number corresponding to the operation log to be written.
[0025] Optionally, the method further comprises:
[0026] If there is no operation log that has been played back before the operation log to be played back, determining whether the log number of the operation log to be played back and the auxiliary number of the operation log to be played back are continuous;
[0027] If so, replay the operation log to be replayed; if not, determine the auxiliary number corresponding to the next operation log whose log number is after the operation log to be replayed; if the log number corresponding to the next operation log is continuous with the auxiliary number corresponding to the next operation log, replay the operation log to be replayed.
[0028] This specification provides a log playback device, including:
[0029] A numbering module, used to assign corresponding log numbers to the operation logs generated by the current data operation based on the execution order of the current data operation and in accordance with the principle of continuous number assignment; the log numbers are used to indicate the operation order of the operation logs when the data operation is executed after the operation logs are written to the log storage objects distributed in sequence;
[0030] The playback module is used to determine whether the log number corresponding to the current operation log to be played back is continuous with the log number corresponding to the last operation log that completed playback after receiving the log playback request; if so, log playback is performed according to the operation log to be played back; if not, log playback of the operation log to be played back is stopped.
[0031] Optionally, the device further comprises: a writing module, configured to write the operation log generated by the current data operation and the operation log generated by the next data operation sequentially into the next log storage object when detecting that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object;
[0032] Or, it is used to write the operation log generated by the current data operation into the next log storage object when it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object; and add the log number corresponding to the operation log generated by the current data operation and the log number corresponding to the operation log generated by the next data operation to the log playback linked list; wherein, the log playback linked list is used to indicate the corresponding log playback order of the operation logs stored in each log storage object when performing log playback.
[0033] Optionally, the numbering module is used to, if other operation logs whose log numbers are located before the operation log to be written are successfully written into the log storage object, use the log number corresponding to the last operation log successfully written into the log storage object as the auxiliary number corresponding to the operation log to be written;
[0034] and / or,
[0035] It is used to determine whether the log number of the operation log to be replayed and the auxiliary number of the operation log to be replayed are continuous if there is no operation log that has completed playback before the operation log to be replayed; if so, log replay is performed on the operation log to be replayed; if not, the auxiliary number corresponding to the next operation log whose log number is after the operation log to be replayed is determined; if the log number corresponding to the next operation log is continuous with the auxiliary number corresponding to the next operation log, log replay is performed on the operation log to be replayed.
[0036] The present application provides a machine-readable storage medium, which stores machine-executable instructions that can be executed by a processor; wherein the processor is used to execute the machine-executable instructions to implement the above-mentioned data protection method based on asynchronous group federated learning.
[0037] The present application provides a computer program, which is stored in a machine-readable storage medium. When a processor executes the computer program in the machine-readable storage medium, it prompts the processor to implement the above-mentioned data protection method based on asynchronous group federated learning.
[0038] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0039] This solution can assign log numbers to current data operations based on the execution order and the principle of consecutive assignment by number. In this way, when replaying the operation logs in each log storage object, it can be determined whether the previous operation log was successfully written to the log object based on whether the log number is consecutive with the previous successfully replayed operation log. That is, if the log numbers are consecutive, it indicates that both the current operation log and the previous operation log were successfully written to the log object, and there is no data write failure. Therefore, data replay can be performed, effectively avoiding the problem of incorrect log replay results caused by log write failures. Description of the Drawings
[0040] The drawings described herein are used to provide a further understanding of this specification and form a part of this specification. The schematic embodiments and descriptions thereof in this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:
[0041] Figure 1 is a schematic diagram of a log writing process provided in this specification;
[0042] Figure 2 is a schematic flowchart of a log replay method provided in this specification;
[0043] Figure 3 is a schematic diagram of an operation log writing process based on number assignment provided in this specification;
[0044] Figure 4 is a schematic diagram of a log writing failure process provided in this specification;
[0045] Figure 5 is a schematic diagram of a process for rewriting logs provided in this specification;
[0046] Figure 6 is a schematic diagram of a situation where log rewriting fails provided in this specification;
[0047] Figure 7 is a schematic diagram of a process for rewriting logs provided in this specification;
[0048] Figure 8 is a schematic diagram of a log replay chain provided in this specification;
[0049] Fig. 9 is a schematic diagram of a log writing process with auxiliary numbers provided in this specification;
[0050] Fig.10 is a schematic diagram of a log replay device provided in this specification;
[0051] Fig.11A method provided in this specification corresponding to Figure 2 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0053] Write Ahead Logging (WAL) is an important technology for improving the performance of storage systems, and is generally implemented as concurrent writing. However, there are often dependencies between upper-layer business requests, which means that log playback needs to be performed in order logically.
[0054] During the operation log writing process, if the operation log writing of a data operation fails, the failed log writing will not be perceived during the log playback process. However, if the subsequent log operation that depends on this data operation is successfully written to the log and then successfully played back, data inconsistency will occur. For ease of understanding, this manual provides a log writing process diagram, such as Figure 1 shown.
[0055] Among them, log101 and log102 are log storage objects in the log storage space. Each log storage object can store multiple operation logs. Data operation op1 and data operation op2 are for the same user object user_obj_a, and their corresponding operation logs are successively added to the log queue (log queue).
[0056] Assume that the initial size of user_obj_a is 1k, and the data operation op1 is to write 1k~2k. At this time, the size of user_obj_a will become 2k. The data operation op2 operates on the data in user_obj_a in the range of 0~1k. At this time, the size of user_obj_a is still 2k.
[0057] If the operation log of op1 (log_op1) is not successfully written to the log storage object, the process of changing the size of user_obj_a from 1k to 2k will not be replayed during data playback because log_op1 failed to be written. If only the operation log of op2 is written successfully, only the operation log of op2 will be replayed during log playback. After the log playback is completed, the actual size of user_obj_a should be 1k, but according to the log record in log_op2, the size is changed to 2k. This leads to inconsistency between the log playback result and the actual result of the data operation, so if log_op1 is not replayed, log_op2 cannot be replayed.
[0058] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0059] Figure 2 The following is a flow chart of a log playback method provided in this specification, including the following steps:
[0060] S201: Based on the execution order of the current data operation and in accordance with the principle of consecutive number assignment, a corresponding log number is assigned to the operation log generated by the current data operation; the log number is used to indicate the operation order when the data operation is executed on the operation log after the operation log is written to the log storage object distributed in sequence;
[0061] S202: After receiving the log playback request, determine whether the log number corresponding to the current operation log to be played back is continuous with the log number corresponding to the last operation log that completed playback; if so, perform log playback according to the operation log to be played back; if not, stop log playback of the operation log to be played back.
[0062] In this specification, the execution subject used to execute a log playback method can be a server of a database system, and of course, it can also be a memory device (such as a cache) in the server. For the sake of ease of description, the following will take the server as an execution subject as an example to illustrate a log playback method provided in this specification.
[0063] When a user performs a data operation (op) on data, the server may write an operation log generated by the data operation into a log storage object in the log storage space.
[0064] The log storage space is a linear logical structure composed of multiple log storage objects. Each log storage object in the log storage space has a serial number to ensure the playback order of the log storage object granularity. For each log storage object in the log storage space, the log storage object is written to the log shards of different operation logs in the form of appending. The operation log generated by a user's IO will be converted into a log shard and counted into the log storage object. The operation log records the operation information, including user object name, object metadata, data offset, data length, written data, etc.
[0065] It should be noted that the above log storage space and log storage objects are all located in non-volatile storage devices such as solid-state drives and flash memories. When the operation log is successfully written to the log storage object, it also means that the operation log is stored in the non-volatile storage device. If the operation log fails to be written to the log storage object, it means that the operation log has not been successfully stored in the non-volatile storage device.
[0066] In this specification, the operation log of each data operation can be written into the log storage space by means of WAL. For the currently executed data operation, the server can assign a log number (log_seg_seq) to the operation log generated by the current data operation according to the principle of continuous number allocation and the execution order of the current data operation. Thus, the operation log is written into the log storage space and the operation order of the executed data operation (such as reading, modifying, deleting and log playback, etc.) is indicated by the log number. That is, the smaller the log number of the operation log, the earlier the operation order of the executed data operation.
[0067] It should be noted that for each data operation, the log number of its operation log corresponds to its execution order. If two data operations are executed at the same time, the log numbers of the operation logs generated by the two data operations can be determined according to the preset logical order or dependency relationship between each other. In other words, even if two operation logs are written to a log storage object at the same time, the two operation logs still have different log numbers.
[0068] In actual applications, the log numbers of each operation log can be continuous and monotonically increasing. In addition, in order to avoid the infinite growth of log numbers, the log numbers can be reset, that is, when the previous operation log is played back or erased, its corresponding log number will also be released, and the subsequently generated operation log can reuse the previously released log number. For ease of understanding, this manual provides a schematic diagram of the operation log writing process based on number allocation, such as Figure 3 shown.
[0069] The data operation op1 is executed before the data operation op2. Therefore, for the operation log log_op1 of op1, log_seg_seq=1001, and for the operation log log_op2 of op2, log_seg_seq=1002.
[0070] If the operation log is not successfully written into the log storage object, the operation log of the next data operation (that is, the operation log of the next log number) is written when the next data operation is executed. Figure 4 shown.
[0071] Figure 4 The following is a schematic diagram of a log writing failure process provided in this manual.
[0072] Among them, when log_op0 is successfully written into the log storage object log101, and log_op1 is not successfully written into the log storage object log101, after executing op2, the server will write its corresponding operation log log_op2 into the next log storage object log102. At this time, only the log number log_seg_seq=1002 of log_op2 and the log number log_seg_seq=1000 of log_op0 exist in the log storage object.
[0073] When replaying logs, the replay process will parse the log shards in the log object one by one, read the log_seg_seq in the shards, and replay only when log_seg_seq is continuously increasing.
[0074] by Figure 4 For example, when replaying log_op2, its log_seg_seq=1002, but the log_seg_seq of the previous operation log log_op0=1000, and the two are not continuous, so log_op2 is not replayed.
[0075] Furthermore, in actual applications, operation logs often fail to be written due to a brief abnormal state of the device or network. In this case, when the device or network returns to normal after a short period of time, the operation log can still be successfully written. Therefore, this manual can further ensure the success rate of log writing by rewriting the log.
[0076] In this specification, the operation log can be written through at least one write strategy. During the log playback process, the server can determine whether the log playback conditions under the current write strategy are met based on the log number corresponding to each operation log. If so, the log is played back for the current operation log to be played back. If not, log playback is prohibited and playback failure information is returned.
[0077] In an embodiment provided in the present specification, if the operation log generated by the current data operation is not successfully written to the log storage object in the log storage space, when it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written to the log storage object, it means that the device or network has recovered from the abnormal state where the log cannot be written to a normal state, and the log can be written normally. Therefore, the operation log generated by the current data operation and the operation log generated by the next data operation can be written to the next log storage object in sequence.
[0078] During log playback, if the log number corresponding to the operation log to be played back is not continuous with the log number corresponding to the last operation log that completed log playback, the server can determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number.
[0079] Afterwards, it can be determined whether the next log storage object after the log storage object where the operation log to be replayed is located stores both the operation log corresponding to the retry number and the operation log to be replayed. If so, it means that the log rewrite is successful. At this time, the server can skip the current operation log to be replayed, and replay the operation log corresponding to the retry number and the operation log to be replayed stored in the next log storage object in the order in which the operation log corresponding to the retry number and the operation log to be replayed are written to the next log storage object.
[0080] If the next log storage object does not store both the operation log corresponding to the retry number and the operation log to be replayed, it means that the log rewrite has failed. In order to avoid data inconsistency after log replay, log replay can be prohibited at this time and log replay failure information will be returned.
[0081] For ease of understanding, this manual provides a schematic diagram of the process of rewriting logs, such as Figure 5 shown.
[0082] Among them, log_seg_seq of log_op0 is 1000, and the log_op1 log segment cannot be read during the playback process because of the log writing failure. When playing back to log102, the log number of log_op2 is log_seg_seq=1002, which is not continuous with log_seg_seq=1000, so the playback of log_op2 stored in log102 can be abandoned (that is, log_op2 in log102 can be skipped). At this time, the next log number of log_op0 is log_seg_seq=1001, so log_seg_seq=1001 is used as the retry number.
[0083] Then, the operation log log103 in the next log storage object can be further searched. At this time, the log storage object log103 contains both the operation log log log_op1 with log_seg_seq=1001 and the operation log log log_op2 with log_seg_seq=1002. Therefore, log playback can be started from log_op1 in the order in which log_op1 and log_op2 are written in log103. After log_op1 completes log playback, log_op2 in log103 can be played back.
[0084] If the operation log is still not rewritten into the log storage object during rewriting, the log will not be replayed. Figure 6 shown.
[0085] Figure 6 This is a schematic diagram of a log rewriting failure situation provided in this specification.
[0086] Among them, log_op1 and log_op2 fail to write to log103 during log rewriting. At this time, although log_op2 successfully writes to log102, log playback cannot be performed.
[0087] In another embodiment provided in the present specification, if the operation log generated by the current data operation is not successfully written into the log storage object, upon detecting that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, the server may only write the operation log generated by the current data operation into the next log storage object, without rewriting the operation log that has been written into the log storage object.
[0088] In this case, in order to ensure the correct playback order of the operation logs, the server can add the log number corresponding to the operation log generated by the current data operation and the log number corresponding to the operation log generated by the next data operation to the log playback linked list. The log playback linked list is used to indicate the corresponding log playback order of the operation logs stored in each log storage object when the log is played back.
[0089] During log playback, if the log number corresponding to the operation log to be played back is not continuous with the log number corresponding to the last operation log that completed log playback, the next log number that is continuous with the log number corresponding to the last operation log that completed playback will be used as the retry number.
[0090] The server can then determine whether the next log storage object after the log storage object where the operation log to be replayed is located stores the operation log corresponding to the retry number and does not store the operation log to be replayed. If so, it means that the log rewrite is successful. At this time, the server can replay the operation log corresponding to the retry number and the operation log to be replayed in sequence based on the log playback order indicated by the log playback linked list.
[0091] If the next log storage object after the log storage object where the operation log to be replayed is located does not store the operation log corresponding to the retry number, it means that the log rewrite has failed. In order to avoid data inconsistency after log replay, log replay can be prohibited at this time and log replay failure information will be returned.
[0092] For ease of understanding, this manual provides a schematic diagram of the process of rewriting logs, such as Figure 7 shown.
[0093] Figure 7 The following is a schematic diagram of a log rewriting process provided in this specification.
[0094] When log_op1 fails to be written, if log_op2 is written successfully, only log_op1 is rewritten to the subsequent log storage object log103.
[0095] Furthermore, since the log storage object where log_op1 is located is located after log_op2, in this case, if the log is directly played back, log_op2 will be played back first, and then log_op1. The wrong log playback order will still cause errors in the log playback result.
[0096] In order to avoid the above situation, the log can be inserted into the correct position by maintaining the log replay chain table (replay_pending) during log replay. For ease of understanding, this manual provides a log replay chain table diagram, such as Figure 8 shown.
[0097] Figure 8 The following is a schematic diagram of a log playback chain provided in this specification.
[0098] The log number of log_op1 is before log_op2, but the log storage object (log103) where log_op1 actually is located is after the log storage object (log102) where log_op2 actually is located. In order to prevent log_op2 in log102 from being replayed before log_op1, the actual log replay order can be determined according to the log number of each operation log through the replay_pending linked list, that is, log_op1 is replayed first, and then log_op2 is replayed.
[0099] Through the above method, when the operation log fails to be written but the subsequent operation log is successfully written, the operation log can be rewritten, and if it is judged that the rewriting of the log fails, the log playback is prohibited. By rewriting the log, the failure of log writing due to a short-term failure of the device can be effectively avoided, the success rate of log playback is improved, and the accuracy of the log playback result is further guaranteed.
[0100] In addition, during log playback, if the current operation log to be played back is the operation log in the first log storage object, since there are no other operation logs before the operation log, it is impossible to determine whether the operation log can be played back based on its own log number.
[0101] To avoid the above situation, during the operation log writing process, if other operation logs whose log numbers are before the operation log to be written are successfully written into the log storage object, the log number corresponding to the last operation log successfully written into the log storage object will be used as the auxiliary number (log_seg_ack) corresponding to the operation log to be written.
[0102] When performing log playback, if there is no operation log that has been completed before the operation log to be played back (that is, the current operation log to be played back is the first operation log to be played back), it can be determined whether the log number of the operation log to be played back and the auxiliary number of the operation log to be played back are continuous; if so, it means that the previous operation logs have been successfully written, and there must be operation logs with consecutive numbers before the operation log, so log playback can be performed on the operation log to be played back.
[0103] If not, it means that there is an operation log that has not been successfully written before the operation log to be replayed, or the operation log to be replayed is the first operation log in the first log storage object. At this time, the operation log to be replayed can be suspended, and the auxiliary number corresponding to the next operation log whose log number is after the operation log to be replayed can be determined.
[0104] If the log number corresponding to the next operation log is continuous with the auxiliary number corresponding to the next operation log, and the auxiliary number corresponding to the next operation log is greater than the log number corresponding to the operation log to be replayed, it means that the previous operation logs have been successfully written into the log storage object, so the operation log to be replayed can be replayed.
[0105] For ease of understanding, this manual provides a schematic diagram of the log writing process with auxiliary numbers, such as Fig. 9 shown.
[0106] Fig. 9 This is a schematic diagram of a log writing process with an auxiliary number provided in this specification.
[0107] Among them, the log_seg_ack of each operation log is less than log_seg_seq. If log_seg_seq=log_seg_ack+1, it means that when writing the current operation log, all the previous operation logs have been successfully written into the log storage object. If log_seg_seq>log_seg_ack+1, it means that when writing the current operation log, there is a previous operation log that has not been successfully written into the log storage object, or there is no previous operation log. In this case, it can be determined that the log shard corresponding to the current operation log is an in-flight log shard.
[0108] During log playback, if the operation log to be played back satisfies log_seg_seq=log_seg_ack+1, the operation log can be played back immediately. If log_seg_seq>log_seg_ack+1, it is necessary to suspend and determine whether the operation log can be played back based on the log number and auxiliary number of the subsequent operation log.
[0109] like Fig. 9 As shown, log_seg_seq=1000 and log_seg_ack=998 of log_op0, so log_op0 needs to be suspended and the playback of log_op0 is paused. When log_op1 is parsed, log_op1 is continuous with log_seg_seq of log_op0, and the log number log_seg_seq (log_seg_seq=1001) and the auxiliary number log_seg_ack (log_seg_ack=1000) of log_op1 are continuous, which means that the operation logs before log_seg_seq=1000 are successfully written into the log storage object, and log_op0 is included, so log_op0 can be played back.
[0110] If, as the log is parsed, it is found that the log with log_seg_ack>998 has not appeared, it can be considered that the log with log_seg_seq=999 has not been written successfully, so the log log_op0 (log_seg_seq=1000) cannot be played back.
[0111] It should be noted that in actual applications, the operation log that failed to be written for the first time may not be rewritten. In this case, when the log is played back, if the log number of the current operation log to be played back is not continuous with the log number of the last successfully played back operation log, the log playback can be directly prohibited and the log playback information can be put back.
[0112] It can be seen from the above method that this solution can solve the data inconsistency problem caused by log sharding failure in the log writing process through a relatively simple sequence number strategy, and build a set of verification and adjustment mechanisms on this basis, which can solve the orderly playback of log shards in most cases.
[0113] The above are one or more methods for implementing log playback in this specification. Based on the same idea, this specification also provides a corresponding log playback device, such as Fig.10 shown.
[0114] Fig.10 A schematic diagram of a log playback device provided for this specification includes:
[0115] The numbering module 1001 is used to assign corresponding log numbers to the operation logs generated by the current data operation based on the execution order of the current data operation and in accordance with the principle of continuous number assignment; the log numbers are used to indicate the operation order of the operation logs when the data operation is executed after the operation logs are written to the log storage objects distributed in sequence;
[0116] The playback module 1002 is used to determine whether the log number corresponding to the current operation log to be played back is continuous with the log number corresponding to the last operation log that completed playback after receiving the log playback request; if so, log playback is performed according to the operation log to be played back; if not, log playback of the operation log to be played back is stopped.
[0117] Optionally, the device further includes: a writing module 1003;
[0118] If the operation log generated by the current data operation is not successfully written into the log storage space, the writing module 1003 is further used to, when it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, write the operation log generated by the current data operation and the operation log generated by the next data operation into the next log storage object in sequence.
[0119] Optionally, if the log number corresponding to the current operation log to be replayed is not continuous with the log number corresponding to the last operation log that has been replayed, the replay module 1002 is further configured to:
[0120] Determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number; determine whether the operation log corresponding to the retry number and the operation log to be played back are stored in the next log storage object after the log storage object where the operation log to be played back is located; if so, replay the operation log corresponding to the retry number and the operation log to be played back stored in the next log storage object in the order in which the operation log corresponding to the retry number and the operation log to be played back are written to the next log storage object; otherwise, log playback is prohibited, and log playback failure information is returned.
[0121] If the operation log generated by the current data operation is not successfully written into the log storage space, the writing module 1003 is further used to, when it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, write the operation log generated by the current data operation into the next log storage object; and add the log number corresponding to the operation log generated by the current data operation and the log number corresponding to the operation log generated by the next data operation to the log playback linked list; wherein the log playback linked list is used to indicate the corresponding log playback order of the operation logs stored in each log storage object when performing log playback.
[0122] Optionally, if the log number corresponding to the current operation log to be replayed is not continuous with the log number corresponding to the last operation log that completed playback, the playback module 1002 is also used to determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number; determine whether the next log storage object after the log storage object where the operation log to be replayed is located stores the operation log corresponding to the retry number and does not store the operation log to be replayed; if so, based on the log playback order indicated by the log playback linked list, log playback is performed on the operation log corresponding to the retry number and the operation log to be replayed in sequence; otherwise, log playback is prohibited, and log playback failure information is returned.
[0123] Optionally, if other operation logs whose log numbers are located before the operation log to be written are successfully written into the log storage object, the numbering module 1001 is further used to:
[0124] The log number corresponding to the last operation log successfully written into the log storage object is used as the auxiliary number corresponding to the operation log to be written.
[0125] Optionally, the playback module 1002 is specifically configured to:
[0126] If there is no operation log that has completed playback before the operation log to be played back, determine whether the log number of the operation log to be played back and the auxiliary number of the operation log to be played back are continuous; if so, log playback is performed on the operation log to be played back; if not, determine the auxiliary number corresponding to the next operation log whose log number is after the operation log to be played back; if the log number corresponding to the next operation log is continuous with the auxiliary number corresponding to the next operation log, log playback is performed on the operation log to be played back.
[0127] Based on the same application concept as the above method, an embodiment of the present application further provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the log playback method disclosed in the above example of the present application can be implemented.
[0128] The above-mentioned machine-readable storage medium may be any electronic, magnetic, optical or other physical storage device, which may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as CD, DVD, etc.), or similar storage medium, or a combination thereof.
[0129] This manual also provides Fig.11 The hardware structure diagram of an electronic device is shown in FIG. Figure 1 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and 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 2 Log playback method shown.
[0130] Based on the same application concept as the above method, an embodiment of the present application further provides a computer program product, including a computer program, which implements the above log playback method when executed by a processor.
[0131] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0132] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A log playback method, characterized in that: include: Based on the execution order of the current data operation and in accordance with the principle of continuous number allocation, a corresponding log number is allocated to the operation log generated by the current data operation; the log number is used to indicate the operation order when the data operation is executed on the operation log after the operation log is written to the log storage object distributed in sequence; After receiving the log playback request, determine whether the log number corresponding to the current operation log to be played back is continuous with the log number corresponding to the last operation log that completed playback; If yes, log playback is performed according to the operation log to be played back; if no, log playback of the operation log to be played back is stopped.
2. The method according to claim 1, characterized in that If the operation log generated by the current data operation is not successfully written into the log storage object, the method further includes: When it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, the operation log generated by the current data operation and the operation log generated by the next data operation are sequentially written into the next log storage object.
3. The method according to claim 2, characterized in that If the log number corresponding to the current operation log to be replayed is not continuous with the log number corresponding to the last operation log that has been replayed, the method further includes: Determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number; Determine whether the next log storage object after the log storage object where the operation log to be replayed is located stores both the operation log corresponding to the retry number and the operation log to be replayed; If so, log playback is performed on the operation log corresponding to the retry number and the operation log to be replayed stored in the next log storage object in the order in which the operation log corresponding to the retry number and the operation log to be replayed are written to the next log storage object; otherwise, log playback is prohibited and log playback failure information is returned.
4. The method according to claim 1, characterized in that If the operation log generated by the current data operation is not successfully written into the log storage object, the method further includes: When it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, the operation log generated by the current data operation is written into the next log storage object; and The log number corresponding to the operation log generated by the current data operation and the log number corresponding to the operation log generated by the next data operation are added to the log playback linked list; wherein the log playback linked list is used to indicate the log playback order corresponding to the operation logs stored in each log storage object when performing log playback.
5. The method according to claim 4, characterized in that If the log number corresponding to the current operation log to be replayed is not continuous with the log number corresponding to the last operation log that has been replayed, the method further includes: Determine the next log number that is continuous with the log number corresponding to the last operation log that completed playback as the retry number; Determine whether the next log storage object after the log storage object where the operation log to be replayed is located stores the operation log corresponding to the retry number and does not store the operation log to be replayed; If so, based on the log playback order indicated by the log playback linked list, the operation log corresponding to the retry number and the operation log to be played back are played back in sequence; otherwise, log playback is prohibited and log playback failure information is returned.
6. The method according to claim 1, characterized in that If other operation logs whose log numbers are before the operation log to be written are successfully written into the log storage object, the method further includes: The log number corresponding to the last operation log successfully written into the log storage object is used as the auxiliary number corresponding to the operation log to be written.
7. The method according to claim 6, characterized in that The method further comprises: If there is no operation log that has been played back before the operation log to be played back, determining whether the log number of the operation log to be played back and the auxiliary number of the operation log to be played back are continuous; If so, replay the operation log to be replayed; if not, determine the auxiliary number corresponding to the next operation log whose log number is after the operation log to be replayed; if the log number corresponding to the next operation log is continuous with the auxiliary number corresponding to the next operation log, replay the operation log to be replayed.
8. A log playback device, characterized in that: include: A numbering module, used to assign corresponding log numbers to the operation logs generated by the current data operation based on the execution order of the current data operation and in accordance with the principle of continuous number assignment; the log numbers are used to indicate the operation order of the operation logs when the data operation is executed after the operation logs are written to the log storage objects distributed in sequence; The playback module is used to determine whether the log number corresponding to the current operation log to be played back is continuous with the log number corresponding to the last operation log that has been played back after receiving the log playback request; If yes, log playback is performed according to the operation log to be played back; if no, log playback of the operation log to be played back is stopped.
9. The device according to claim 8, characterized in that The device further comprises: a writing module, for, when detecting that an operation log generated by a next data operation continuous with a current data operation is successfully written into a log storage object, sequentially writing the operation log generated by the current data operation and the operation log generated by the next data operation into the next log storage object; Or, when it is detected that the operation log generated by the next data operation continuous with the current data operation is successfully written into the log storage object, the operation log generated by the current data operation is written into the next log storage object; and, the log number corresponding to the operation log generated by the current data operation and the log number corresponding to the operation log generated by the next data operation are added to the log playback linked list; wherein, the log playback linked list is used to indicate the corresponding log playback order of the operation logs stored in each log storage object when performing log playback.
10. The device according to claim 8, characterized in that The numbering module is used to, if other operation logs whose log numbers are located before the operation log to be written are successfully written into the log storage object, use the log number corresponding to the last operation log successfully written into the log storage object as the auxiliary number corresponding to the operation log to be written; and / or, It is used to determine whether the log number of the operation log to be replayed and the auxiliary number of the operation log to be replayed are continuous if there is no operation log that has completed playback before the operation log to be replayed; if so, log replay is performed on the operation log to be replayed; if not, the auxiliary number corresponding to the next operation log whose log number is after the operation log to be replayed is determined; if the log number corresponding to the next operation log is continuous with the auxiliary number corresponding to the next operation log, log replay is performed on the operation log to be replayed.