Database transaction log parsing method and related products
By obtaining the breakpoint information of the transaction log and selectively parsing it, the problem that the database system needs to parse a large number of duplicate transaction logs after a crash is solved, improving the analysis efficiency, saving database computing power, and ensuring data consistency and performance.
Patent Information
- Application Number
- CN202411933807.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-08
AI Technical Summary
After a crash, an existing database system needs to parse a large number of duplicate transaction logs, resulting in an increase in the parsing time, consuming database computing power, and reducing performance.
By obtaining the breakpoint information of the transaction log, including the redo serial number and the commit end-of-transaction serial number, selectively parsing the transaction log starting from the redo serial number, and filtering the parsed transaction log.
Effectively skip repeated parsing transaction logs, improve the parsing efficiency of log parsing programs, reduce the computing power consumption of databases, and ensure data consistency and database performance.
Smart Images

Figure CN119782330A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database transaction log parsing, and in particular to a database transaction log parsing method and related products. Background Art
[0002] In a database management system, ensuring data consistency and reliability is crucial. To achieve this goal, most database systems use the WAL (Write-Ahead Logging) mechanism, that is, all database modification operations are first recorded in the transaction log file, and then the database operations are persisted to the database disk. This mechanism ensures that even if the system crashes, unfinished transactions can be recovered by redoing the log, thereby maintaining data consistency. However, this mechanism still has a problem, that is, the transaction log has many record entries, so the parsing task of the recovery program is very heavy.
[0003] At present, in order to solve the above problems, most database systems in the prior art also adopt a checkpoint mechanism. In the transaction log, it will periodically create a checkpoint after the transaction that has been persisted to the disk. When the database system crashes, it can parse the transaction log from the latest checkpoint to recover the data. In this way, the database system can reduce the amount of work required to be redone when recovering after a crash, ensuring that it can be quickly and reliably restored to a consistent state even in the event of a system failure. However, the parser may experience normal and abnormal stops during the parsing of the transaction log, and the parser needs to be restarted multiple times. In this way, the parser will repeatedly parse the transaction log that has already been parsed, which will increase the parsing time of the parser, unnecessarily consume the computing power of the database, and reduce the performance of the database. Summary of the invention
[0004] An object of the present invention is to provide a database transaction log parsing method and related products that can solve at least one technical defect in the above-mentioned prior art.
[0005] A further object of the present invention is to enable the log parsing program to skip at least part of the transaction logs that are repeatedly parsed, thereby improving the parsing efficiency of the log parsing program to ensure that the database can quickly recover the data, save the computing power of the database, ensure data consistency, and ensure the performance of the database.
[0006] In particular, the present invention provides a transaction log parsing method for a database, comprising:
[0007] Start the log parsing program;
[0008] In response to the log parsing program being started repeatedly, the breakpoint information of the transaction log is obtained, the breakpoint information includes a redo sequence number and a committed transaction end sequence number, the redo sequence number is an identification log sequence number (RedoLsn) corresponding to the latest checkpoint, the committed transaction end sequence number is an end identification log sequence number (commitLsn) of the committed transaction most recently parsed by the log parsing program, and the committed transaction end sequence number is greater than the redo sequence number;
[0009] The log parsing program starts parsing the transaction log from the redo sequence number, and selectively parses the transaction log between the redo sequence number and the end sequence number of the committed transaction during the parsing process.
[0010] Furthermore, the breakpoint information also includes an uncommitted transaction start sequence number, which is a start identification log sequence number (oldestLsn) of the longest uncommitted transaction, the uncommitted transaction start sequence number is greater than the redo sequence number, and the uncommitted transaction start sequence number is less than the committed transaction end sequence number; and,
[0011] The steps of selectively parsing the transaction log between the redo sequence number and the end sequence number of the committed transaction during the parsing process include:
[0012] For the transaction logs between the redo sequence number and the start sequence number of the uncommitted transaction, filter out the committed transactions except the change information of the database system table and the full-page write meta information;
[0013] For the transaction logs between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction, filter out the committed transactions except for the full-page write meta information.
[0014] Furthermore, for the transaction logs between the redo sequence number and the uncommitted transaction start sequence number, the step of filtering the committed transactions except the change information of the system table of the database and the full-page write meta information includes:
[0015] Read a log message after the redo sequence number in the transaction log;
[0016] Determine whether the read log information is full-page write meta information;
[0017] If so, load the full page write metadata into the cache page manager of the system table.
[0018] Furthermore, when the read log information is not full-page write meta information, for the transaction log between the redo sequence number and the uncommitted transaction start sequence number, the step of filtering the committed transactions except the change information of the system table of the database and the full-page write meta information also includes:
[0019] Determine whether the read log information is the record information of the submitted transaction;
[0020] If yes, determine whether the log sequence number of the start identifier of the committed transaction in the read log information is less than the start sequence number of the uncommitted transaction;
[0021] When the start identification log sequence number of the committed transaction in the read log information is less than the start sequence number of the uncommitted transaction, it is determined whether the read log information is the change information of the system table of the database;
[0022] In the case where the read log information is the change information of the system table of the database, the read log information is parsed by the log parsing program, and the next log information is read;
[0023] When the read log information is not the change information of the system table of the database, the read log information is skipped and the next log information is read.
[0024] Furthermore, for the transaction logs between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction, the step of filtering the committed transactions except the full-page write meta information includes:
[0025] If the log sequence number of the start identifier of the transaction in the read log information is greater than or equal to the start sequence number of the uncommitted transaction, determine whether the log sequence number of the end identifier of the committed transaction in the read log information is less than the end sequence number of the committed transaction;
[0026] If yes, execute the step of skipping the read log information.
[0027] Furthermore, when the log sequence number of the end identifier of the committed transaction in the log information is greater than or equal to the end sequence number of the committed transaction, the step of parsing the read log information by the log parsing program is executed.
[0028] Furthermore, after parsing each log information whose end identification log sequence number of a submitted transaction is greater than or equal to the end sequence number of the submitted transaction, the transaction log parsing method further includes:
[0029] Update the end sequence number of the committed transaction to the end identification log sequence number of the committed transaction in the parsed log information;
[0030] Determine whether the log sequence number of the start identifier of the committed transaction in the parsed log information is equal to the start sequence number of the uncommitted transaction;
[0031] If so, update the uncommitted transaction start sequence number;
[0032] If not, keep the uncommitted transaction start sequence number.
[0033] Furthermore, in the case where the read log information is not record information of a submitted transaction, the transaction log parsing method further includes:
[0034] Determine whether the read log information is the record information of the checkpoint;
[0035] If so, update the redo sequence number to the identification log sequence number of the checkpoint.
[0036] Furthermore, when the log parsing program is restarted for the first time, the transaction log parsing method includes:
[0037] Connect to the database and start a repeatable read transaction;
[0038] The log parsing program starts parsing the transaction log from the redo sequence number, and updates the end sequence number of the committed transaction after each log message of the committed transaction is parsed during the parsing process.
[0039] In particular, the present invention also provides a machine-readable storage medium on which a machine executable program is stored. When the machine executable program is executed by a processor, the above-mentioned database transaction log parsing method is implemented.
[0040] In particular, the present invention also provides a computer device, including a memory, a processor, and a machine executable program stored in the memory and running on the processor, and the processor implements the above-mentioned database transaction log parsing method when executing the machine executable program.
[0041] The transaction log parsing method of the database of the present invention can selectively parse the transaction logs between the redo sequence number and the end sequence number of the committed transaction when the log parsing program is repeatedly started. Furthermore, the transaction log parsing method of the present invention can filter out at least part of the transaction logs that have been parsed by the log parsing program last time. Therefore, the transaction log parsing method of the database of the present invention can enable the log parsing program to skip at least part of the transaction logs that have been parsed repeatedly, thereby improving the parsing efficiency of the log parsing program, so as to ensure that the database can quickly recover the data, save the computing power of the database, ensure data consistency, and ensure the performance of the database.
[0042] The machine-readable storage medium of the present invention can implement the above-mentioned database transaction log parsing method. Therefore, the machine-readable storage medium of the present invention also has the beneficial technical effects that can be achieved by the above-mentioned database transaction log parsing method.
[0043] The computer device of the present invention can implement the above-mentioned database transaction log parsing method. Therefore, the computer device of the present invention also has the beneficial technical effects that can be achieved by the above-mentioned database transaction log parsing method.
[0044] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:
[0046] Figure 1 is a flowchart of a transaction log parsing method for a database according to an embodiment of the present invention;
[0047] Figure 2 is a flowchart of a transaction log parsing method for a database according to another embodiment of the present invention;
[0048] Figure 3 is a flowchart of a transaction log parsing method for a database according to yet another embodiment of the present invention;
[0049] Figure 4 It is a flow chart of updating the end sequence number of a committed transaction and updating the start sequence number of an uncommitted transaction in a database transaction log parsing method according to an embodiment of the present invention;
[0050] Figure 5 It is a schematic diagram of parsing content of a log parsing program when the log parsing program is repeatedly started in a transaction log parsing method of a database according to an embodiment of the present invention;
[0051] Figure 6 is a schematic diagram of a structure of a machine-readable storage medium according to an embodiment of the present invention;
[0052] Figure 7 It is a structural block diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In the description of the present embodiment, the description with reference to the term "present embodiment" or the like means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0054] Combine the following Figures 1 to 4 The transaction log parsing method of the database of this embodiment is described in detail.
[0055] Figure 1 is a flow chart of a transaction log parsing method for a database according to an embodiment of the present invention, referring to Figure 1 In this embodiment, the transaction log parsing method of the database may include:
[0056] Step S101, start the log parsing program.
[0057] Step S102, in response to the log parsing program being restarted repeatedly, obtain the breakpoint information of the transaction log. The breakpoint information includes a redo sequence number and a commit transaction end sequence number, the redo sequence number is the identification log sequence number (RedoLsn) corresponding to the latest checkpoint, the commit transaction end sequence number is the end identification log sequence number (commitLsn) of the commit transaction most recently parsed by the log parsing program, and the commit transaction end sequence number is greater than the redo sequence number.
[0058] Step S103, the log parsing program parses the transaction log starting from the redo sequence number, and selectively parses the transaction log between the redo sequence number and the committed transaction end sequence number during the parsing process.
[0059] The transaction log parsing method of the database of this embodiment, when the log parsing program is repeatedly started, the log parsing program can selectively parse the transaction logs between the redo sequence number and the end sequence number of the committed transaction. Furthermore, the transaction log parsing method of this embodiment can filter out at least part of the transaction logs that have been parsed by the log parsing program last time. Therefore, the transaction log parsing method of the database of this embodiment can enable the log parsing program to skip at least part of the transaction logs that are repeatedly parsed, thereby improving the parsing efficiency of the log parsing program, so as to ensure that the database can quickly recover the data, save the computing power of the database, ensure data consistency, and ensure the performance of the database. At the same time, the coherence of the recovered data is guaranteed.
[0060] In addition, the step of selectively parsing the transaction log between the redo sequence number and the committed transaction end sequence number during the parsing process may include step S203 and step S204 of the following embodiment.
[0061] Figure 2 is a flow chart of a transaction log parsing method for a database according to another embodiment of the present invention. Figure 5 1 is a schematic diagram of the parsing content of the log parsing program when the log parsing program is repeatedly started in the transaction log parsing method of the database according to an embodiment of the present invention. Figure 2 and Figure 5 In this embodiment, the transaction log parsing method of the database may include:
[0062] Step S201, start the log parsing program.
[0063] Step S202, in response to the log parsing program being restarted repeatedly, the breakpoint information of the transaction log is obtained. The breakpoint information includes a redo sequence number, a committed transaction end sequence number, and an uncommitted transaction start sequence number. The redo sequence number is the identification log sequence number (RedoLsn) corresponding to the latest checkpoint, the committed transaction end sequence number is the end identification log sequence number (commitLsn) of the committed transaction most recently parsed by the log parsing program; the uncommitted transaction start sequence number is the start identification log sequence number (oldestLsn) of the longest uncommitted transaction, and the committed transaction end sequence number is greater than the uncommitted transaction start sequence number, and the uncommitted transaction start sequence number is greater than the redo sequence number.
[0064] Step S203, for the transaction logs between the redo sequence number and the uncommitted transaction start sequence number, filter the committed transactions except the modification information of the system table of the database and the full-page write meta information.
[0065] Step S204, filtering the committed transactions except the full-page write meta information for the transaction logs between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction.
[0066] It should be understood that in the transaction log within the interval from the redo sequence number to the uncommitted transaction start sequence number, there may be records of transactions that have been started but not executed (committed between the uncommitted transaction start sequence number and the committed transaction end sequence number, that is, the transaction should be persisted to the database disk) and / or transactions that have been executed but not yet committed (committed between the uncommitted transaction start sequence number and the committed transaction end sequence number, that is, the transaction should be persisted to the database disk). In order to ensure the consistency and integrity of the data, in step S203, the database transaction log parsing method can read the change information of the system table of the database within the interval and the full-page write meta information, so as to realize the persistence of the unexecuted transactions and / or the executed but not yet committed transactions to the database disk, complete the data reconstruction, and realize data recovery. In addition, the log parsing program has already parsed the change information of the database system table and the committed transactions other than the full-page write meta information during the last operation. Then, in step S203, the database transaction log parsing method can directly filter the committed transactions that have been parsed and no longer parse them, so as to skip at least part of the transaction logs that are repeatedly parsed, thereby improving the parsing efficiency of the log parsing program, ensuring that the database can quickly restore the data, and saving the computing power of the database.
[0067] It should also be understood that in the transaction log within the interval from the start sequence number of the uncommitted transaction to the end sequence number of the committed transaction, uncommitted transactions and committed transactions may be recorded. In step S204, for uncommitted transactions, since they do not need to be persisted to the disk of the database, the log parsing program does not need to parse them; for committed transactions, the log parsing program has been parsed during the last operation, and the log parsing program does not need to parse them again. Therefore, when parsing the transaction log parsing method of the database of this embodiment, when parsing the transaction log within the interval from the start sequence number of the uncommitted transaction to the end sequence number of the committed transaction, at least part of the transaction logs that are repeatedly parsed can be skipped to improve the parsing efficiency of the log parsing program, ensuring that the database can quickly restore the data and save the computing power of the database. However, for the full-page write meta information within the interval from the start sequence number of the uncommitted transaction to the end sequence number of the committed transaction, the log parsing program also needs to read it. Even if these transactions are eventually rolled back, it is necessary to ensure that the page will not be in an inconsistent state due to partial modification, and then these full-page write meta information can ensure that the pages involved in the uncommitted transaction can maintain consistency during the recovery process.
[0068] In this embodiment, for the transaction log after the end sequence number of the committed transaction, the transaction log parsing method of the database can prompt the log parsing program to normally parse the committed transaction.
[0069] The transaction log parsing method of the database of the present embodiment divides the transaction log into different processing intervals by constructing breakpoints (the starting sequence number of uncommitted transactions, the redo sequence number, and the end sequence number of committed transactions). Different processing intervals use different parsing methods to parse and / or obtain important information in the transaction log, and filter unimportant / repeated parsed information. Therefore, the transaction log parsing method of the database of the present embodiment can avoid data loss and parsing errors, ensure data consistency and coherence, and improve the parsing efficiency of the log parsing program, ensuring that the database can quickly recover data, saving database computing power and ensuring database performance.
[0070] Reference Figure 5 In this embodiment, when executing the step of filtering the committed transactions except the full-page write meta information for the transaction log between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction, that is, when executing step S204, the transaction log parsing method of the database can also include parsing the change information of the uncommitted ordinary table between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction.
[0071] It should be understood that in the transaction log within the interval from the start sequence number of the uncommitted transaction to the end sequence number of the committed transaction, there is record information of the uncommitted transaction. Although the transaction is not committed within the interval from the start sequence number of the uncommitted transaction to the end sequence number of the committed transaction, it may be committed in the transaction log after the end sequence number of the committed transaction. Therefore, the transaction log parsing method of the database of this embodiment ensures the consistency and coherence of the data by parsing the records of the uncommitted transactions that are the change information of the ordinary table within the interval from the start sequence number of the uncommitted transaction to the end sequence number of the committed transaction.
[0072] In addition, step S203, for transaction logs between the redo sequence number and the uncommitted transaction start sequence number, filtering the committed transactions except the change information of the system table of the database and the full-page write meta information may include steps S303 to S310 in the following embodiments. Step S204, for transaction logs between the uncommitted transaction start sequence number and the committed transaction end sequence number, filtering the committed transactions except the full-page write meta information may include step S311 in the following embodiments. The step of parsing the uncommitted common table change information between the uncommitted transaction start sequence number and the committed transaction end sequence number may include steps S315 to S316 in the following embodiments.
[0073] Figure 3 FIG. 1 is a flow chart of a transaction log parsing method for a database according to another embodiment of the present invention. Figure 3 and Figure 5 In this embodiment, the transaction log parsing method of the database may include:
[0074] Step S301, start the log parsing program.
[0075] Step S302, determining whether the log parsing program is restarted repeatedly; if so, that is, in response to the log parsing program being restarted repeatedly; if not, that is, in response to the log parsing program being restarted for the first time, step S317 can be executed.
[0076] Step S303, obtain the breakpoint information of the transaction log. The breakpoint information includes the redo sequence number, the end sequence number of the committed transaction, and the start sequence number of the uncommitted transaction. The redo sequence number is the identification log sequence number (RedoLsn) corresponding to the latest checkpoint, the end sequence number of the committed transaction is the end identification log sequence number (commitLsn) of the committed transaction most recently parsed by the log parser, and the start sequence number of the uncommitted transaction is the start identification log sequence number (oldestLsn) of the longest uncommitted transaction. The end sequence number of the committed transaction is greater than the start sequence number of the uncommitted transaction, and the start sequence number of the uncommitted transaction is greater than the redo sequence number.
[0077] Step S304, reading a log message after the redo sequence number in the transaction log;
[0078] Step S305 , determining whether the read log information is full-page write meta information; if so, executing step S306 ; if not, that is, when the read log information is not full-page write meta information, executing step S307 .
[0079] Step S306, loading the full page write meta information into the cache page manager of the system table; and after this step is executed, reading the next log information, and returning to execute step S304.
[0080] Step S307, determining whether the read log information is record information of a submitted transaction; if so, executing step S308; if not, that is, when the read log information is not record information of a submitted transaction, executing step S313.
[0081] Step S308, determine whether the start identification log sequence number of the committed transaction in the read log information is less than the start sequence number of the uncommitted transaction; if the start identification log sequence number of the committed transaction in the read log information is less than the start sequence number of the uncommitted transaction, execute step S309; if the start identification log sequence number of the transaction in the read log information is greater than or equal to the start sequence number of the uncommitted transaction, execute step S312.
[0082] Step S309, determining whether the read log information is the change information of the system table of the database; if the read log information is the change information of the system table of the database, executing step S310; if the read log information is not the change information of the system table of the database, executing step S311.
[0083] Step S310: The log parsing program parses the read log information and reads the next log information. After this step is completed, step S305 can be executed.
[0084] Step S311, skip the read log information, and read the next log information. After executing this step, step S305 can be executed.
[0085] Step S312, determine whether the end identifier log sequence number of the submitted transaction in the read log information is less than the end sequence number of the submitted transaction; if so, execute the step of skipping the read log information, that is, execute step S311. If not, that is, when the end identifier log sequence number of the submitted transaction in the log information is greater than or equal to the end sequence number of the submitted transaction, execute the step of parsing the read log information by the log parsing program, that is, execute step S310.
[0086] Step S313, determining whether the read log information is the record information of the checkpoint; if so, executing step S314; if not, that is, when the read log information is the record information of an uncommitted transaction, step S315 can be executed.
[0087] Step S314, update the redo sequence number to the identification log sequence number of the checkpoint; and after executing this step S314, the next log information can be read and step S305 can be executed.
[0088] Step S315, determine whether the start identification log sequence number of the uncommitted transaction in the read log information is greater than or equal to the start sequence number of the uncommitted transaction and less than the end sequence number of the committed transaction; if so, execute step S316; if not, you can execute step S311.
[0089] Step S316, determine whether the read log information is the change information of the ordinary table of the database; when the read log information is the change information of the ordinary table of the database, execute the step of parsing the read log information by the log parsing program, that is, execute step S310; when the read log information is not the change information of the ordinary table of the database, execute the step of skipping the read log information, that is, execute step S311.
[0090] Step S317, connect to the database and start a repeatable read transaction.
[0091] Step S318, the log parsing program starts parsing the transaction log from the redo sequence number, and updates the end sequence number of the committed transaction after each log information of the committed transaction is parsed during the parsing process.
[0092] It can be understood that steps S304 to S311 can realize the above-mentioned embodiment, for the transaction log between the redo sequence number and the uncommitted transaction start sequence number, the change information of the system table of the database and the reading and / or parsing of the full-page write meta information, and filtering the remaining committed transactions. Steps S304 to S308, step S310 and step S311 can realize the above-mentioned embodiment, for the transaction log between the uncommitted transaction start sequence number and the committed transaction end sequence number, the reading of the full-page write meta information, and the filtering of the remaining committed transactions. Therefore, the transaction log parsing method of the database of this embodiment can improve the parsing efficiency, ensure that the database can quickly recover the data, save the computing power of the database, ensure data consistency, and ensure the performance of the database.
[0093] In this embodiment, for step S305 and step S306, when the read log information is full-page write meta information, the transaction log parsing method of the database of this embodiment can load the full-page write meta information into the cache page manager of the system table to ensure page consistency and enable the database to be maintained normally afterwards.
[0094] In this embodiment, in the transaction log, the database transaction log parsing method did not parse the log information after the last sequence number of the submitted transaction in the last operation. Therefore, for the submitted transaction after the last sequence number of the submitted transaction, the database transaction log parsing method of this embodiment can perform normal parsing through steps S310 and S312 to ensure data consistency.
[0095] In this embodiment, when the log parsing program is restarted for the first time, it is necessary to parse the submitted transactions in the transaction log normally without filtering operations to ensure data consistency. Therefore, the transaction log parsing method of the database of this embodiment can implement normal parsing of the submitted transactions in the transaction log through steps S317 to S318. In addition, the execution of step S317 can ensure the stability of the operation of the transaction log parsing method of the database of this embodiment.
[0096] Figure 4 The present invention is a flowchart of updating the end sequence number of a committed transaction and updating the start sequence number of an uncommitted transaction in a transaction log parsing method of a database according to another embodiment of the present invention. In this embodiment, after parsing each log information whose end identification log sequence number of a committed transaction is greater than or equal to the end sequence number of the committed transaction, the transaction log parsing method may further include:
[0097] Step S401, updating the end sequence number of the committed transaction to the end identification log sequence number of the committed transaction in the parsed log information.
[0098] Step S402, determining whether the start identification log sequence number of the committed transaction in the parsed log information is equal to the start sequence number of the uncommitted transaction; if so, executing step S403; if not, executing step S404.
[0099] Step S403: Update the starting sequence number of the uncommitted transaction.
[0100] Step S404, retaining the starting sequence number of the uncommitted transaction.
[0101] It can be understood that in steps S401 to S404 of the present embodiment, steps S313 and S314 of the above embodiment, and step S316 of the above embodiment, the transaction log parsing method of the database can implement the update of the end sequence number of the committed transaction, the start sequence number of the uncommitted transaction, and the redo sequence number to ensure the operation of the transaction log parsing method of the database of the present embodiment.
[0102] Combine the following Figure 6 The machine-readable storage medium of this embodiment is described in detail. Figure 6 is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention, referring to Figure 6 In this embodiment, a machine executable program 11 is stored on the machine-readable storage medium, and when the machine executable program 11 is executed by the processor, the above-mentioned database transaction log parsing method is implemented.
[0103] The machine-readable storage medium of this embodiment can implement the above-mentioned database transaction log parsing method. Therefore, the machine-readable storage medium of this embodiment also has the beneficial technical effects that can be achieved by the above-mentioned database transaction log parsing method.
[0104] Combine the following Figure 7 The computer device of this embodiment will be described in detail. Figure 7 is a schematic diagram of a computer device according to an embodiment of the present invention, referring to Figure 7 In this embodiment, the computer device includes a memory, a processor, and a machine executable program 11 stored in the memory and running on the processor, and the processor implements the above-mentioned database transaction log parsing method when executing the machine executable program 11.
[0105] The computer device of this embodiment can implement the above-mentioned database transaction log parsing method. Therefore, the computer device of this embodiment also has the beneficial technical effects that can be achieved by the above-mentioned database transaction log parsing method.
[0106] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by an instruction execution system, device or equipment (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or equipment and execute instructions), or used in combination with these instruction execution systems, devices or equipment.
[0107] For the description of this embodiment, the machine-readable storage medium 10 can be any device that can contain, store, communicate, propagate or transmit a program for use with an instruction execution system, device or equipment or in conjunction with these instruction execution systems, devices or equipment. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the machine-readable storage medium 10 can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting or processing in other suitable ways as necessary, and then stored in a computer memory.
[0108] It should be understood that each part of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0109] The computer device 20 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 20 may be a cloud computing node. The computer device 20 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, target programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 20 may be implemented in a distributed cloud computing environment where remote processing devices linked through a communication network perform tasks. In a distributed cloud computing environment, program modules may be located on a local or remote computing system storage medium including a storage device.
[0110] The computer device 20 may include a processor 22 adapted to execute stored instructions, and a memory 21 that provides temporary storage space for the operation of the instructions during operation. The processor 22 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 21 may include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.
[0111] The processor 22 may be connected to an I / O interface (input / output interface) suitable for connecting the computer device 20 to one or more I / O devices (input / output devices) via a system interconnect (e.g., PCI, PCI-Express, etc.). The I / O devices may include, for example, a keyboard and a pointing device, wherein the pointing device may include a touch pad or a touch screen, etc. The I / O devices may be built-in components of the computer device 20, or may be devices externally connected to the computing device.
[0112] Processor 22 can also be linked to a display interface suitable for connecting computer device 20 to a display device through a system interconnect. Display device can include a display screen as a built-in component of computer device 20. Display device can also include a computer monitor, a television or a projector, etc., which are externally connected to computer device 20. In addition, a network interface controller (NIC) can be suitable for connecting computer device 20 to a network through a system interconnect. In some embodiments, NIC can use any suitable interface or protocol (such as Internet Small Computer System Interface, etc.) to transmit data. The network can be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN) or the Internet, etc. Remote devices can be connected to computing devices through a network.
[0113] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.
Claims
1. A transaction log parsing method for a database, comprising: Start the log parsing program; In response to the log parsing program being repeatedly started, obtaining breakpoint information of the transaction log, the breakpoint information including a redo sequence number and a committed transaction end sequence number, the redo sequence number being an identification log sequence number corresponding to a latest checkpoint, the committed transaction end sequence number being an end identification log sequence number of a committed transaction most recently parsed by the log parsing program, and the committed transaction end sequence number being greater than the redo sequence number; The log parsing program starts parsing the transaction log from the redo sequence number, and selectively parses the transaction log between the redo sequence number and the committed transaction end sequence number during the parsing process.
2. The database transaction log parsing method according to claim 1, wherein: The breakpoint information also includes an uncommitted transaction start sequence number, which is a start identification log sequence number of the longest uncommitted transaction, is greater than the redo sequence number, and is less than the end sequence number of the committed transaction; and, The step of selectively parsing the transaction log between the redo sequence number and the committed transaction end sequence number during the parsing process includes: For the transaction logs between the redo sequence number and the uncommitted transaction start sequence number, filtering the committed transactions except the change information of the system table of the database and the full-page write meta information; For the transaction logs between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction, the committed transactions except the full-page write meta information are filtered.
3. The transaction log parsing method of a database according to claim 2, wherein: The step of filtering the transaction logs between the redo sequence number and the uncommitted transaction start sequence number, except for the change information of the system table of the database and the full-page write meta information, comprises: Reading a log message after the redo sequence number in the transaction log; Determine whether the read log information is full-page write meta information; If so, the full page write meta information is loaded into the cache page manager of the system table.
4. The database transaction log parsing method according to claim 3, wherein: In the case that the read log information is not full-page write meta information, the step of filtering the committed transactions except the change information of the system table of the database and the full-page write meta information for the transaction log between the redo sequence number and the uncommitted transaction start sequence number further includes: Determine whether the read log information is record information of a submitted transaction; If yes, determine whether the start identification log sequence number of the committed transaction in the read log information is less than the start sequence number of the uncommitted transaction; In the case that the start identification log sequence number of the committed transaction in the read log information is less than the start sequence number of the uncommitted transaction, determining whether the read log information is the change information of the system table of the database; In the case that the read log information is the change information of the system table of the database, the log parsing program parses the read log information and reads the next log information; In the case that the read log information is not the change information of the system table of the database, the read log information is skipped and the next log information is read.
5. The database transaction log parsing method according to claim 4, wherein: The step of filtering the committed transactions except the full-page write meta information for the transaction logs between the start sequence number of the uncommitted transaction and the end sequence number of the committed transaction comprises: In the case that the log sequence number of the start identifier of the transaction in the read log information is greater than or equal to the start sequence number of the uncommitted transaction, determining whether the log sequence number of the end identifier of the committed transaction in the read log information is less than the end sequence number of the committed transaction; If yes, execute the step of skipping the read log information.
6. The database transaction log parsing method according to claim 5, wherein: In the case where the end identification log sequence number of the committed transaction in the log information is greater than or equal to the end sequence number of the committed transaction, the step of parsing the log information read by the log parsing program is executed.
7. The database transaction log parsing method according to claim 6, wherein: After parsing each log information whose end identification log sequence number of a submitted transaction is greater than or equal to the end sequence number of the submitted transaction, the transaction log parsing method further includes: Update the end sequence number of the submitted transaction to the end identification log sequence number of the submitted transaction in the parsed log information; Determine whether the start identification log sequence number of the committed transaction in the parsed log information is equal to the start sequence number of the uncommitted transaction; If yes, update the uncommitted transaction start sequence number; If not, keep the uncommitted transaction start sequence number.
8. The database transaction log parsing method according to claim 3, wherein: In the case where the read log information is not record information of a submitted transaction, the transaction log parsing method further includes: Determine whether the read log information is record information of a checkpoint; If so, update the redo sequence number to the identification log sequence number of the checkpoint.
9. The database transaction log parsing method according to claim 1, wherein: When the log parsing program is restarted for the first time, the transaction log parsing method includes: Connect to the database and start a repeatable read transaction; The log parsing program starts parsing the transaction log from the redo sequence number, and updates the committed transaction end sequence number after each parsed log message of a committed transaction is completed during the parsing process.
10. A machine-readable storage medium having a machine executable program stored thereon, wherein the machine executable program, when executed by a processor, implements the transaction log parsing method for a database according to any one of claims 1 to 9.
11. A computer device comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, wherein the processor implements the transaction log parsing method of a database according to any one of claims 1 to 9 when executing the machine executable program.
Citation Information
Cited By
Database log analysis method and system based on multi-level cache
CN120560953A