Transaction log processing method of database, storage medium and equipment
By storing page mirror data and other data in the transaction log separately and storing page mirror data in the page mirror data storage table, the problem of low efficiency in database transaction log processing in the prior art is solved, and the synchronization efficiency and security of the database are improved.
Patent Information
- Application Number
- CN202311864235.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-08
AI Technical Summary
In the prior art, it is relatively inconvenient to use transaction logs in databases, which affects the processing efficiency of the database.
Store page mirror data and other data in the transaction log separately, and store page mirror data in the preset page mirror data storage table, reducing the amount of data synchronization between the main and spare databases, improving synchronization efficiency, and ensuring the security and stability of the database.
On the basis of not affecting the synchronization of the primary and secondary databases, the amount of data synchronization is reduced, the database processing efficiency is improved, and the difficulty of managing page mirroring data on disk is reduced.
Smart Images

Figure CN120277149A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and particularly to a method for processing transaction logs of a database, a storage medium, and a device. Background Art
[0002] During the use of a database, transaction logs are recorded. The transaction logs record historical operation information of the database data and are important data of the database. Transaction logs are essential data for various tasks of the database, such as fault recovery and primary and standby database construction. However, in the prior art, the use of transaction logs in a database is rather inconvenient, which affects the processing efficiency of the database. Summary of the Invention
[0003] An object of the present invention is to provide a method for processing transaction logs of a database, a storage medium, and a device that can solve any of the above problems.
[0004] In particular, the present invention provides a method for processing transaction logs of a database, including:
[0005] Obtaining a trigger event for flushing the transaction logs in the cache, where the transaction logs include an assembly linked list and a page data linked list separately stored in the cache. The page data linked list is a linked list composed of page mirror data in the transaction logs, the assembly linked list is a linked list composed of other data except page mirror data in the transaction logs, and the page data linked list is stored in a preset global page data linked list;
[0006] Obtaining the transaction logs that need to be flushed, denoted as flushable logs;
[0007] Searching for the corresponding page data linked list in the global page data linked list according to the log sequence number of the flushable logs, denoted as the flushable page data linked list;
[0008] Storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table.
[0009] Optionally, before the step of obtaining the transaction logs that need to be flushed, it includes:
[0010] Sorting the page data linked lists in the global page data linked list in ascending order according to the log sequence number.
[0011] Optionally, the step of obtaining the transaction logs that need to be flushed includes:
[0012] Obtaining the range of the log sequence number of the flushable logs;
[0013] The steps of searching for the corresponding page data linked list in the global page data linked list according to the log sequence number of the diskable log include:
[0014] Search for the page data linked list in the global page data linked list whose log sequence number is greater than or equal to the minimum value of the log sequence number range and less than or equal to the maximum value of the log sequence number range.
[0015] Optionally, the steps of obtaining the transaction log that needs to be disked include:
[0016] Obtain the transaction logs that meet the preset disk rules in the cache, and record them as the diskable logs. The transaction logs that meet the preset disk rules are at least one transaction log that has been completely written into the cache and whose log sequence numbers are consecutive starting from the log sequence number of the last transaction log completed in the previous disk.
[0017] Optionally, the steps of storing the page mirror data in the diskable page data linked list into a preset page mirror data storage table include:
[0018] Store the page mirror data in the diskable page data linked list at the end of the page mirror data storage table in the arrangement order in the global page data linked list.
[0019] Optionally, the page mirror data storage table has a log sequence number field, and the log sequence number field is used to store the log sequence number of the page mirror data.
[0020] Optionally, after the steps of storing the page mirror data in the diskable page data linked list into a preset page mirror data storage table include:
[0021] Store the assembled linked list part of the diskable log into the disk.
[0022] Optionally, after the steps of storing the page mirror data in the diskable page data linked list into a preset page mirror data storage table include:
[0023] Remove the diskable page data linked list from the global page data linked list.
[0024] In another aspect of the present invention, there is also provided a machine-readable storage medium, on which a machine-executable program is stored. When the machine-executable program is executed by a processor, it implements the transaction log processing method of the database according to any one of the above.
[0025] In another aspect of the present invention, a computer device is further provided, including a memory, a processor, and a machine-executable program stored on the memory and running on the processor. When the processor executes the machine-executable program, it implements the transaction log processing method of the database according to any one of the above.
[0026] The transaction log processing method, storage medium, and device of the present invention obtain a trigger event for flushing the transaction log in the cache, obtain the transaction log that needs to be flushed, denoted as the flushing-enabled log, search for the corresponding page data linked list in the global page data linked list according to the log sequence number of the flushing-enabled log, denoted as the flushing-enabled page data linked list, and store the page mirror data in the flushing-enabled page data linked list into a preset page mirror data storage table. That is to say, the page mirror data of the transaction log and the data other than the page mirror data are flushed separately, and the page mirror data is stored in the page mirror data storage table. Therefore, when this database synchronizes the transaction log to other standby databases, it can synchronize only the data other than the page mirror data. On the basis of not affecting the synchronization between the primary and standby databases, the amount of data synchronization between the primary and standby databases is reduced, which helps to improve the synchronization efficiency. Moreover, the page mirror data of the transaction log is still stored on the disk, which can also ensure the security and stability of this database. In addition, the page mirror data is stored in the page mirror data storage table. Because the database has a better management ability for tables, it helps to reduce the management difficulty of the page mirror data on the disk. Therefore, it makes the application of the transaction log in the database more convenient and improves the database processing efficiency in some aspects.
[0027] Based on the following detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more clear about the above and other objects, advantages, and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Some specific embodiments of the present invention will be described in detail hereinafter with reference to the accompanying drawings in an exemplary and non-limiting manner. The same reference numerals in the drawings denote the same or similar components or parts. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:
[0029] Figure 1 is a schematic diagram of a transaction log in the prior art;
[0030] Figure 2 is a schematic flowchart of a transaction log processing method according to an embodiment of the present invention;
[0031] Figure 3 is a first schematic diagram of a transaction log according to an embodiment of the present invention;
[0032] Figure 4It is the second schematic diagram of the transaction log according to an embodiment of the present invention;
[0033] Figure 5 It is the schematic diagram of the page data chain of the transaction log according to an embodiment of the present invention;
[0034] Figure 6 It is the schematic diagram of the page mirror data content of the transaction log according to an embodiment of the present invention;
[0035] Figure 7 It is the third schematic diagram of the transaction log according to an embodiment of the present invention;
[0036] Figure 8 It is the schematic diagram of the global page data linked list according to an embodiment of the present invention;
[0037] Figure 9 It is the schematic diagram of the page mirror data storage table according to an embodiment of the present invention;
[0038] Figure 10 It is the schematic flowchart of the transaction log processing method according to another embodiment of the present invention;
[0039] Figure 11 It is the schematic flowchart of the transaction log processing method according to yet another embodiment of the present invention;
[0040] Figure 12 It is the schematic diagram of the machine-readable storage medium according to an embodiment of the present invention;
[0041] Figure 13 It is the schematic diagram of the computer device according to an embodiment of the present invention. Detailed implementation manners
[0042] Those skilled in the art should understand that the embodiments described below are only a part of the embodiments of the present invention, rather than all the embodiments of the present invention. This part of the embodiments is intended to explain the technical principle of the present invention, rather than to limit the protection scope of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts should still fall within the protection scope of the present invention.
[0043] 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 definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor, or other systems that can fetch instructions from the instruction execution system, apparatus or device and execute the instructions), or used in combination with these instruction execution systems, apparatus or devices.
[0044] The flowcharts provided by the present invention are not intended to indicate that the operations of the method will be executed in any specific order, or that all operations of the method are included in every case. In addition, the method may include additional operations. Within the scope of the technical concept provided by the method of this embodiment, additional changes may be made to the above method.
[0045] To facilitate the understanding of this solution, the operation mode of the database in the prior art will be described. First, during the process of modifying the database data, the table stored on the disk is not directly modified. Instead, the data in the table is extracted into the cache in units of data pages (the data to be modified is located in the data pages), modified in the cache, and then written to disk later.
[0046] Furthermore, when modifying the data pages in the cache, transaction logs will be generated. As Figure 1 shown, the existing transaction logs generally include two parts: a header and a data area. The data area records various modification operations on the data pages. At the same time, there is a kind of data in the data area that is page mirror data. The page mirror data is the data formed after recording the complete page information of a data page in the transaction log. In the prior art, usually after the log redo point (the log redo point is a log sequence number. Before this log sequence number, the transaction logs have all been written to disk and the information reflected by the written logs and all the data in the actual database on the disk is the same), if the data of a data page in the cache is modified for the first time, then the entire page information of the data page after the first modification will be recorded in the transaction log, and then page mirror data will be generated.
[0047] Because during the process of writing a data page to disk, it is possible that a data page crashes during the write process, resulting in a situation where the written data page contains a mixture of old and new data. Therefore, by generating page mirror data, the data page information recorded in the page mirror data can be used to replace the broken page with a mixture of old and new data, and then the subsequent operations recorded in the transaction log can be replayed to complete the recovery of the data page. Therefore, the page mirror data is important data to ensure the security and stability of the database.
[0048] As Figure 2 shown, in one embodiment, the transaction log processing method generally includes:
[0049] Step S201, obtaining a trigger event for writing the transaction log in the cache to disk. The transaction log includes an assembled linked list and a page data linked list separately stored in the cache. The page data linked list is a linked list composed of page mirror data in the transaction log, and the assembled linked list is a linked list composed of other data in the transaction log except for the page mirror data. And the page data linked list is stored in a preset global page data linked list.
[0050] Specifically, the start signal may be a signal triggered at fixed intervals, or may be a signal triggered when the amount of transaction log data in the cache reaches a certain threshold, etc. In simple terms, it is detected that the transaction log in the cache needs to be written to the disk.
[0051] Reference Figures 3 to 7 Specifically, taking a transaction log with two page mirroring data nodes as an example, Figure 3 An example of a linked list of the original transaction log with page mirror data is shown below. Figure 4 for Figure 3 An example of the linked list form after the page mirror data is removed from the linked list in , where next indicates pointing to the next node; len indicates the len function, which is used to calculate the length of the corresponding data; head data is the header data of the transaction log; page data is all the page mirror data in the transaction log; tupledata and main data are other data in the transaction log except the page mirror data. Figure 5 This is a simplified example of a linked list of two page mirror data nodes in a transaction log. wal1 page data1 and wal1 page data2 are only used to represent two different page mirror data nodes belonging to the same transaction log, and do not represent specific content. Figure 6 This is an example of the specific content of a page mirror data node. RelFileNode indicates the location information of the table to which the data page corresponding to this page mirror data belongs on the disk. BlockNumber indicates the block number of the data page corresponding to this page mirror data in the table to which it belongs. Therefore, RelFileNode and BlockNumber can determine the location of the data page corresponding to the page mirror data on the disk. LSN indicates the log sequence number of the transaction log to which the page mirror data belongs. Page data is the complete information of the data page recorded by this page mirror data node. Next indicates pointing to the next node. Figure 7 This is an example of the final transaction log.
[0052] During the assembly of the transaction log, the page image data in the transaction log is first removed, such as Figures 3 to 4 Then the page mirror data is organized into a page data linked list according to the order in the transaction log, as shown in Figure 5 Then, the page data linked list is connected to the back of the linked list composed of other data in the transaction log, so that the transaction log is assembled into a structure consisting of an assembly linked list and a page data linked list connected to the assembly linked list, as shown in Figure 7 That is, Figure 6 It can be seen as Figure 5 A schematic diagram of the specific contents of a page mirror data node in . Figure 7The assembled linked list representation in Figure 4 The linked list of the transaction log in , that is, the linked list formed by other data of the transaction log except for the page mirror data.
[0053] Then, during the process of writing the transaction log into the cache, the assembled linked list and the page data linked list are stored separately. Moreover, the page data linked list is stored in the global page data linked list. Specifically, the global page data linked list is located in the shared memory, that is, the cache. During the process of writing the transaction log into the cache, after moving out the page data linked list of the transaction log, the page data linked list is stored into the global page data linked list. In other words, the global page data linked list is a linked list formed by connecting the page data linked lists of multiple transaction logs.
[0054] Refer to Figure 8 As shown, it is a simple schematic diagram of the global page data linked list storing two page data linked lists. page_data_list_local represents the page data linked list of a transaction log, and page_data_list_global represents the global page data linked list. Among them, wal1 and wal2 are only used to indicate that the two page data linked lists belong to different transaction logs.
[0055] Step S202, obtain the transaction log that needs to be flushed to disk, denoted as the flushing log. Specifically, that is to say, the complete transaction log formed between the previous flushing point and the current flushing point in the cache.
[0056] Step S203, search for the corresponding page data linked list in the global page data linked list according to the log sequence number of the flushing log, denoted as the flushing page data linked list. Specifically, because the transaction log is stored in the cache in the form of an assembled linked list and a page data linked list respectively, this step is to find the page data linked list corresponding to the flushing log in the global page data linked list. Refer to Figure 6 As shown, each page mirror data records the log sequence number of the belonging transaction log, so the corresponding page data linked list can be found according to the log sequence number.
[0057] Step S204, store the page mirror data in the flushing page data linked list into a preset page mirror data storage table. Refer to Figure 9 As shown, it is an example of a page mirror data storage table. Specifically, a page mirror data storage table is pre-created in the disk. After obtaining the flushing page data linked list, copy the content of the page mirror data in the flushing page data linked list to the page mirror data storage table, and the flushing work of the flushing page data linked list is completed.
[0058] In the solution of this embodiment, by obtaining a trigger event for flushing the transaction log in the cache, the transaction log that needs to be flushed is obtained, which is denoted as the flushing-available log. According to the log sequence number of the flushing-available log, the corresponding page data linked list is searched in the global page data linked list, which is denoted as the flushing-available page data linked list. The page mirror data in the flushing-available page data linked list is stored in a preset page mirror data storage table. That is to say, the page mirror data of the transaction log and the data other than the page mirror data are flushed separately, and the page mirror data is stored in the page mirror data storage table. Therefore, when this database synchronizes the transaction log to other standby databases, it can synchronize only the data other than the page mirror data. On the basis of not affecting the synchronization between the master and standby databases, the data synchronization volume between the master and standby databases is reduced, which helps to improve the synchronization efficiency. Moreover, the page mirror data of the transaction log is still stored in the disk, which can also ensure the security and stability of this database. In addition, the page mirror data is stored in the page mirror data storage table. Because the database has better management capabilities for tables, it helps to reduce the management difficulty of the page mirror data in the disk. Therefore, it makes the application of the transaction log by the database more convenient and improves the database processing efficiency in some aspects.
[0059] As Figure 10 shown, in one embodiment, the transaction log processing method generally includes:
[0060] Step S1001, obtaining a trigger event for flushing the transaction log in the cache.
[0061] Step S1002, sorting the page data linked lists in the global page data linked list in ascending order according to the log sequence number. Specifically, that is, sorting all the page data linked lists in the global page data linked list from smallest to largest according to the log sequence number.
[0062] By sorting the page data linked lists in the global page data linked list in ascending order according to the log sequence number, the page data linked lists in the global page data linked list are arranged regularly. On the one hand, it can improve the convenience of searching the page data linked lists in the global page data linked list. On the other hand, it also makes the page mirror data arranged regularly in the page mirror data storage table, which helps to further reduce the management difficulty of the page mirror data.
[0063] Further, the step of obtaining the transaction log that needs to be flushed includes: obtaining the transaction log in the cache that meets the preset flushing rule.
[0064] Step S1003, obtaining the transaction log in the cache that meets the preset flushing rule, which is denoted as the flushing-available log. The transaction log that meets the preset flushing rule is at least one transaction log that has been completely written into the cache and whose log sequence number is continuous starting from the log sequence number of the last transaction log completed in the previous flushing.
[0065] Specifically, the preset disk dropping rule can be configured to use all transaction logs with consecutive log sequence numbers starting from the log sequence number of the last transaction log completed in the previous disk dropping as the transaction logs that can be dropped this time. Or it can also be configured to use a set number (such as one, two, ten, one hundred, etc.) of transaction logs with consecutive log sequence numbers starting from the log sequence number of the last transaction log completed in the previous disk dropping as the transaction logs that can be dropped this time.
[0066] Exemplarily, if the transaction logs with log sequence numbers 3, 4, 5, 8, 9 (the numbers are only for illustration and do not represent actual complete log sequence numbers) are completely stored in the current cache, and the log sequence number of the last transaction log completed in the previous disk dropping is 2.
[0067] Taking the preset disk dropping rule configured to use all transaction logs with consecutive log sequence numbers starting from the log sequence number of the last transaction log completed in the previous disk dropping as the transaction logs that can be dropped this time: starting from 2, 3, 4 are all transaction logs with consecutive log sequence numbers. Since 6 and 7 are missing between 5 and 8, they are no longer consecutive. Then the transaction logs with log sequence numbers 3, 4, 5 conform to the preset disk dropping rule.
[0068] Taking the preset disk dropping rule configured to use two transaction logs with consecutive log sequence numbers starting from the log sequence number of the last transaction log completed in the previous disk dropping as the transaction logs that can be dropped this time: starting from 2, 3, 4 are all transaction logs with consecutive log sequence numbers.
[0069] Step S1004, find the corresponding page data linked list in the global page data linked list according to the log sequence number of the log that can be dropped, denoted as the page data linked list that can be dropped. Specifically, the steps to obtain the transaction logs that need to be dropped include: obtaining the log sequence number range of the log that can be dropped. Specifically, the log sequence number range is greater than or equal to the minimum log sequence number in the log that can be dropped and less than or equal to the maximum log sequence number in the log that can be dropped.
[0070] The steps to find the corresponding page data linked list in the global page data linked list according to the log sequence number of the log that can be dropped include: finding the page data linked list in the global page data linked list whose log sequence number is greater than or equal to the minimum value of the log sequence number range and less than or equal to the maximum value of the log sequence number range.
[0071] Specifically, since the page data linked lists in the global page data linked list are arranged in ascending order of the log sequence number, it is only necessary to find the page data linked list with the first log sequence number greater than or equal to the minimum value of the log sequence number range from front to back, denoted as lsn_s, and find the page data linked list with the first log sequence number greater than or equal to the maximum value of the log sequence number range from front to back, denoted as lsn_f. Then, directly obtain the page data linked lists between lsn_s and lsn_f (including lsn_f if lsn_f is equal to the maximum value of the log sequence number range, and not including lsn_f if lsn_f is greater than the maximum value of the log sequence number range).
[0072] Therefore, it is avoided to compare the log sequence numbers of the disk-writable logs one by one with those in the global page data linked list, improving the search efficiency.
[0073] Further, the step of storing the page mirror data in the page data linked list to be disk-written into a preset page mirror data storage table includes: storing the page mirror data in the page data linked list to be disk-written at the end of the page mirror data storage table in the arrangement order in the global page data linked list.
[0074] Step S1005: Store the page mirror data in the page data linked list to be disk-written at the end of the page mirror data storage table in the arrangement order in the global page data linked list. Specifically, since the page data linked list is arranged in ascending order of the log sequence number, and when obtaining the transaction logs that need to be disk-written, the transaction logs that meet the preset disk-writing rules in the cache are obtained. Therefore, after storing the page mirror data at the end of the page mirror data storage table in the arrangement order in the global page data linked list, the page mirror data must also be arranged in ascending order of the log sequence number in the page mirror data storage table, which helps to further reduce the management difficulty of the page mirror data storage table.
[0075] Refer to Figure 9 As shown, specifically, the page mirror data storage table has a log sequence number field, and the log sequence number field is used to store the log sequence number of the page mirror data. Specifically, one row of the page mirror data storage table is used to store all the contents of a page mirror data, and one field of the page mirror data storage table, that is, one column, is the log sequence number field, that is, to store the log sequence number of the page mirror data. By setting the log sequence number field in the page mirror data storage table to store the log sequence number of the page mirror data, the log sequence number field can be used to search for the page mirror data in the page mirror data storage table. Since the log sequence numbers are sorted in ascending order, the search is more convenient.
[0076] As Figure 11 shown, in one embodiment, the transaction log processing method generally includes:
[0077] Step S1101: Obtain a trigger event for flushing the transaction logs in the cache to disk.
[0078] Step S1102: Obtain the transaction logs that need to be flushed to disk, denoted as flushable logs.
[0079] Step S1103: Search for the corresponding page data linked list in the global page data linked list according to the log sequence number of the flushable logs, denoted as the flushable page data linked list.
[0080] Step S1104: Store the page mirror data in the flushable page data linked list into a preset page mirror data storage table.
[0081] After the step of storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table, the following steps are included:
[0082] Step S1105: Store the assembled linked list part of the flushable logs into the disk. Specifically, it is to find the assembled linked list part of the transaction logs that need to be flushed from the cache according to the log sequence number, and then flush the found assembled linked list part that needs to be flushed. Thus, the page data linked list and the assembled linked list of the transaction logs that need to be flushed in this disk flushing operation are both flushed to disk, that is, the complete transaction logs are flushed to disk.
[0083] Further, after the step of storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table, the following steps are included:
[0084] Step S1106: Remove the flushable page data linked list from the global page data linked list. Specifically, it is to delete the page data linked list that has been flushed in the global page data linked list, so as to free up storage space.
[0085] This embodiment also provides a machine-readable storage medium and a computer device. Figure 12 It is a schematic diagram of a machine-readable storage medium 10 according to an embodiment of the present invention. Figure 13 It is a schematic diagram of a computer device 20 according to an embodiment of the present invention.
[0086] The machine-readable storage medium 10 stores a machine-executable program 11 thereon. When the machine-executable program 11 is executed by a processor, it implements the transaction log processing method of the database in any of the above embodiments.
[0087] The computer device 20 may include a memory 210, a processor 220, and a machine-executable program 11 stored on the memory 210 and running on the processor 220. And when the processor 220 executes the machine-executable program 11, it implements the transaction log processing method of the database in any of the above embodiments.
[0088] 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 by or in connection with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the machine-readable storage medium 10 can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing as appropriate, and then stored in a computer memory.
[0089] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0090] The computer device 20 can be, for example, a server, a desktop computer, a laptop computer, a tablet computer, or a smartphone. In some examples, the computer device 20 can be a cloud computing node. The computer device 20 can be described in the general context of computer system-executable instructions, such as program modules, executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 20 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0091] The computer device 20 can include a processor 220 adapted to execute stored instructions and a memory 210 that provides temporary storage space for the operation of the instructions during operation. The processor 220 can be a single-core processor, a multi-core processor, a computing cluster, or any other number of other configurations. The memory 210 can include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.
[0092] The processor 220 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) through a system interconnect (such as PCI, PCI-Express, etc.). The I / O devices may include, for example, a keyboard and a pointing device, where the pointing device may include a touchpad 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.
[0093] The processor 220 may also be linked to a display interface suitable for connecting the computer device 20 to a display device through a system interconnect. The display device may include a display screen as a built-in component of the computer device 20. The display device may also include a computer monitor, a television, a projector, etc. externally connected to the computer device 20. In addition, a network interface controller (NIC) may be suitable for connecting the computer device 20 to a network through a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as Internet Small Computer System Interface, etc.) to transmit data. The network may be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, etc. Remote devices may be connected to the computing device through the network.
[0094] The solution of the present invention is applicable to relational databases, and particularly applicable to the KingbaseES database (abbreviated as KES database), enriching the functions of the database and improving the efficiency of the database.
[0095] 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 from 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 determined to cover all these other variations or modifications.
Claims
1. A method for processing transaction logs of a database, comprising: Obtaining a trigger event for flushing the transaction logs in the cache, wherein the transaction logs include an assembled linked list and a page data linked list separately stored in the cache, the page data linked list is a linked list composed of page mirror data in the transaction logs, the assembled linked list is a linked list composed of other data except the page mirror data in the transaction logs, and the page data linked list is stored in a preset global page data linked list; Obtaining the transaction logs that need to be flushed, denoted as flushable logs; Searching for the corresponding page data linked list in the global page data linked list according to the log sequence number of the flushable logs, denoted as the flushable page data linked list; Storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table.
2. The method for processing a transaction log of a database according to claim 1, wherein, Before the step of obtaining the transaction logs that need to be flushed, it includes: Sorting the page data linked lists in the global page data linked list in ascending order according to the log sequence number.
3. The method for processing a transaction log of a database according to claim 2, wherein, The step of obtaining the transaction logs that need to be flushed includes: Obtaining the log sequence number range of the flushable logs; The step of searching for the corresponding page data linked list in the global page data linked list according to the log sequence number of the flushable logs includes: Searching for the page data linked list in the global page data linked list whose log sequence number is greater than or equal to the minimum value of the log sequence number range and less than or equal to the maximum value of the log sequence number range.
4. The method for processing a transaction log of a database according to claim 2, wherein, The step of obtaining the transaction logs that need to be flushed includes: Obtaining the transaction logs in the cache that meet the preset flushing rules, denoted as the flushable logs, and the transaction logs that meet the preset flushing rules are at least one transaction log that has been completely written into the cache and whose log sequence numbers are continuous starting from the log sequence number of the last transaction log completed in the previous flush.
5. The method for processing a transaction log of a database according to claim 4, wherein, The step of storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table includes: Storing the page mirror data in the flushable page data linked list at the end of the page mirror data storage table in the arrangement order in the global page data linked list.
6. The method for processing a transaction log of a database according to claim 5, wherein, The page mirror data storage table has a log sequence number field, and the log sequence number field is used to store the log sequence number of the page mirror data.
7. The method for processing a transaction log of a database according to claim 1, wherein, After the step of storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table, it includes: Storing the assembled linked list part of the flushable logs into the disk.
8. The method for processing a transaction log of a database according to claim 1, wherein, After the step of storing the page mirror data in the flushable page data linked list into a preset page mirror data storage table, it includes: Removing the flushable page data linked list from the global page data linked list.
9. A machine-readable storage medium, on which a machine-executable program is stored, and when the machine-executable program is executed by a processor, it implements the method for processing transaction logs of a database according to any one of claims 1 to 8.
10. A computer device, comprising a memory, a processor, and a machine-executable program stored on the memory and running on the processor, and when the processor executes the machine-executable program, implementing the transaction log processing method of the database according to any one of claims 1 to 8.