Database processing method, storage medium and equipment
By monitoring the operating status of the database, using shared memory and temporary files to record page data file information, the database's performance bottleneck and inefficient search efficiency are solved under high load, and the database's efficient operation and data integrity guarantee are achieved.
Patent Information
- Application Number
- CN202311865418.4
- 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, when the database is under great business pressure, the synchronous stream replication mode is prone to become a performance bottleneck, and the search efficiency of page data files is inefficient, lacking records of file usage, affecting the overall performance and data integrity of the database.
By monitoring the running status of the database, the information of the page data file is recorded in the shared memory during normal operation, and the temporary file is recorded in the temporary file when it is about to be closed, information is obtained from the temporary file during restart, and the shared memory is updated during normal operation, ensuring the safe and efficient recording of file information.
It improves the overall performance and data processing efficiency of the database, ensures the integrity and reliability of the data, and ensures the rapid response and stability of the database system.
Smart Images

Figure CN120277108A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data synchronization, and particularly to a method for processing a database, a storage medium, and a device. Background Art
[0002] Currently, database clusters usually adopt the synchronous streaming replication mode to strictly keep the data of the primary and standby databases consistent. However, when the primary database is under heavy business pressure, a large amount of XLOG logs will be generated. At this time, the synchronous streaming replication mode is likely to become a performance bottleneck of the database.
[0003] Therefore, those skilled in the art may separate the page data of the transaction log and continuously store it in a page data file, and then convert the disk write I / O of a large number of small and random page data files into fewer and sequential disk write I / Os to improve the disk write efficiency of the page data of the XLOG.
[0004] The inventor realizes that when searching for a page data in a page data file, it is only possible to traverse from the first page data area of the page data file until the target page data is found or until the last page data area of this file (if the target page data is not found in the current file). Such search efficiency is very low.
[0005] Although adding header information to the page data file can improve the search efficiency of the file content, it is impossible to know where the file was written last time after the database is closed, and there is a lack of a function for recording the usage of the page data file. Therefore, there is still room for improvement.
[0006] The above information disclosed in this background art is only used to increase the understanding of the background art of the present application. Therefore, it may include prior art that is not known to those of ordinary skill in the art. Summary of the Invention
[0007] In view of the above problems, the present invention provides a method for processing a database, a storage medium, and a device that can overcome or partially solve the above problems.
[0008] An object of the first aspect of the present invention is to provide a method for processing a database to effectively record the file information of the page data file.
[0009] Another object of the first aspect of the present invention is to improve the overall performance of the database.
[0010] Another object of the first aspect of the present invention is to ensure the integrity and reliability of the data.
[0011] In particular, according to the first aspect of the present invention, the present invention provides a method for processing a database, wherein a page data file is pre-created in the database, and the page data file is used to store page data separated from the transaction log of the database. The processing method includes:
[0012] Monitoring the running state of the database;
[0013] When the running state is normal operation, recording the file information of the page data file into the shared memory;
[0014] When the running state is about to be closed, recording the file information of the page data file into a temporary file;
[0015] When the running state is restart, obtaining the file information of the page data file from the temporary file;
[0016] If the obtaining is successful, determining that the database was normally closed before restart, and recording the obtained file information into the shared memory.
[0017] Optionally, the file information of the page data file includes: file name, file path, end address of the last disk-written data area in the file, and remaining storage space of the file.
[0018] Optionally, after the step of recording the obtained file information into the shared memory, it further includes:
[0019] Clearing the file information of the page data file from the temporary file.
[0020] Optionally, after the step of obtaining the file information of the page data file from the temporary file, it further includes:
[0021] If the obtaining fails, determining that the database was abnormally closed before restart;
[0022] Checking whether there is a page data file in use;
[0023] If there is, checking whether the page data file in use has completed the write task;
[0024] If completed, switching to a new page data file;
[0025] Recording the file information of the new page data file into the shared cache.
[0026] Optionally, after the step of checking whether there is a page data file in use, it further includes:
[0027] If not, performing the step of switching to a new page data file.
[0028] Optionally, the steps of switching to a new page data file include:
[0029] Modify the file name of the page data file being used;
[0030] Create a new page data file;
[0031] Use the new page data file as the page data file being used.
[0032] Optionally, the steps of modifying the file name of the page data file being used include:
[0033] Obtain the log time line of the page data file being used, the log sequence number stored in the first data area, and the log sequence number stored in the last data area;
[0034] Use the string composed of the log time line, the log sequence number stored in the first data area, and the log sequence number stored in the last data area as the file name of the page data file being used.
[0035] Optionally, after the step of checking whether the page data file being used has completed the write task, it further includes:
[0036] If not completed, check whether there is a data area in the page data file being used;
[0037] If there is, switch to a new page data file;
[0038] If not, delete the page data file being used.
[0039] According to the second aspect of the present invention, the present invention provides a machine-readable storage medium, on which a machine-executable program is stored, and when the machine-executable program is executed by a processor, the above-mentioned database processing method is implemented.
[0040] According to the third aspect of the present invention, the present invention provides a computer device, including 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, the above-mentioned database processing method is implemented.
[0041] The processing method of the database of the present invention monitors the running state of the database. When the database is running normally, it records the file information of the page data file into the shared memory. When the database is about to be closed, it records the file information of the page data file into a temporary file. When the database is restarted, it obtains the file information of the page data file from the temporary file. If the acquisition is successful, it can indicate that the database was normally closed before restarting, and then records the obtained file information into the shared memory. Thus, the file information of the page data file can be recorded safely and efficiently, and the content of the shared memory is updated using the file information in the temporary file, which is beneficial to clearly understand the usage of the page data file.
[0042] Further, for the processing method of the database of the present invention, in the case where the database was abnormally closed before restarting, if there is a page data file in use, it can check whether the write task of the page data file is completed. If it is completed, it indicates that the switching opportunity of the page data file is met at this time, and a new page data file can be switched, and the file information of the new page data file is recorded into the shared cache and then written into the shared memory by the shared cache. In this way, the data processing efficiency can be improved, and the overall performance and response speed of the database system can be enhanced.
[0043] Furthermore, for the processing method of the database of the present invention, if it is found that the write task of the page data file in use is not completed, it can further check whether there is a data area in the page data file. If there is, it indicates that the page data file has been partially occupied, and a new page data file can be switched to ensure the integrity and reliability of the data. If not, the page data file in use can be directly deleted to save the storage space occupied by the temporary file.
[0044] Based on the following detailed description of the specific embodiments of the present invention in conjunction with the drawings, those skilled in the art will become more clear about the above and other purposes, advantages and features of the present invention. Description of the Drawings
[0045] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0046] Figure 1 is a schematic structural diagram of a page data file according to an embodiment of the present invention;
[0047] Figure 2 is a schematic structural diagram of a page data file according to another embodiment of the present invention;
[0048] Figure 3It is a flowchart of a method for processing a database according to an embodiment of the present invention;
[0049] Figure 4 It is a flowchart of a method for processing a database when the file information acquisition of the page data file fails;
[0050] Figure 5 It is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention;
[0051] Figure 6 It is a schematic diagram of a computer device according to an embodiment of the present invention.
[0052] Reference numerals:
[0053] 10. Machine-readable storage medium; 11. Machine-executable program; 20. Computer device; 210. Processor; 220. Memory. Detailed implementation manners
[0054] 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.
[0055] 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 fixed 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 in combination with these instruction execution systems, apparatus or devices.
[0056] In a database, the transaction log actually refers to the XLOG log, also called the WAL (write ahead log) log. A very important function of the XLOG log is to be used to construct a primary and standby database cluster. When the primary machine fails, the standby machine can immediately become the primary and take over the primary machine to continue providing services externally.
[0057] In the present invention, to reduce the data volume of the XLOG log, a page data file, that is, a pagedata file, can be pre-created in the database. In the assembly stage of the XLOG log, the page data in the XLOG log is separated and stored in the page data file.
[0058] Figure 1 It is a schematic structural diagram of a page data file according to an embodiment of the present invention, Figure 2 and is a schematic structural diagram of a page data file according to another embodiment of the present invention;
[0059] As Figure 1 and Figure 2 shown, the page data file mainly consists of two parts: a file header and a data area.
[0060] The file header may include minLsn, maxLsn, lsn[N], ptr[N], N, and totalLen, where:
[0061] (1) minLsn: The lsn (Log Sequence Number) recorded in the first page data data area in the current file. Here, it is the sequence number of the XLOG log corresponding to the page data;
[0062] (2) maxLsn: The lsn recorded in the last page data data area in the current file;
[0063] (3) lsn[N]: There may be multiple page data data areas in a page data file. According to minLsn and maxLsn, it can be determined whether the target page data is in the current file. When it is found that the lsn of the XLOG log corresponding to the target page data is between minLsn and maxLsn, then this page data file needs to be traversed to try to find the target page data. To speed up this process, in the page data file, except for the file header, the lsn value of the XLOG log to which the page data data area is located at a fixed distance (such as 1MB) is recorded every other fixed distance. This lsn value is stored in the lsn[N] array.
[0064] (4) ptr[N]: ptr[i] is the starting address of the page data data area (pd_i) corresponding to lsn[i] in the page data file (i = 0, 1,..., N - 1). Its purpose is to quickly locate the starting position of the specified page data data area in the file.
[0065] (5) N: The maximum length of the lsn[] and ptr[] arrays. For example, if the page data file size is 64MB and the interval is 1MB, then N = 64MB / 1MB = 64. It can be seen that after the page data file size and interval are fixed, N is a fixed value.
[0066] (6) totalLen: The total length of the current file's valid data area plus the header, that is, the total length of each independent page data area plus the file header length.
[0067] The data area is divided into two parts: the valid data area and the unused area. The valid data area stores the page data area, while the unused area has no page data related data. There are two main reasons for the unused part: first, when the remaining space of the current file is not enough to store a complete page data area, it will switch to a new file to store this page data area; second, in some scenarios, the page data file will be forced to switch, which will also cause unused areas in the page data file.
[0068] The file header is at the front of the file, followed by the page data areas. It should be noted that the page data areas are stored in ascending order of their LSNs. In the XLOG log assembly phase, a page_data_list_local linked list node is created for each pagedata, and then the page data and related information are placed in the page_data_list_local linked list nodes respectively. Finally, these linked list nodes are connected in the order of their page data in the XLOG log to form the page_data_list_local linked list of the current XLOG log, and then the page_data_list_local linked list is connected to the end of the current XLOG log assembly linked list.
[0069] The content of each linked list node may include: RelFileNode, BlockNumber, page data header, page data, len and lsn.
[0070] (1)RelFileNode: The location information of the table where the data disk page corresponding to the page data is located.
[0071] (2) BlockNumber: The block number of the data disk page corresponding to the page data in the corresponding table. BlockNumber and RelFileNode together determine the location of the page in the data disk. When searching, these two values are used to determine whether a version of the target page data is found.
[0072] (3) Page data header: The header information corresponding to page data in the XLOG log. This part of information will also be recorded in the XLOG log that needs to record pagedata. This part is mainly reserved for subsequent support of block repair.
[0073] (4) Page data: The page data in the XLOG log.
[0074] (5) Len: The total length of the current page data data area (including RelFileNode, BlockNumber, page data header, page data, lsn, len). It can be used to calculate the starting address of the next page data data area in the file and is used when traversing the file.
[0075] (6) Lsn: The starting position of the XLOG log where the page data is located.
[0076] The creation of the page data file may include the following content:
[0077] 1. Creation timing
[0078] (1) When the database is initialized, the first page data file is created.
[0079] (2) When the previous page data file is used up, a new file is created.
[0080] (3) When the use of the previous page data file is forcibly ended and there is new page data to be written to disk, a new file is created.
[0081] 2. Creation process
[0082] (1) Confirm the N value (such as 64MB / 1MB).
[0083] (2) Initialize the file header and fill in the N field.
[0084] 3. Creation optimization
[0085] Introduce a pre-creation mechanism, similar to the pre-creation of XLOG log files.
[0086] Switching of page data files:
[0087] 1. Switching timing
[0088] (1) When the space of the current page data file is used up, switch the page data file.
[0089] (2) Before performing a basic backup, switch the page data file.
[0090] (3) Manually and forcibly switch the page data file.
[0091] 2. Switching process
[0092] (1) Fill in the totalLen and maxLsn fields in the online_page_data_file file header. The minLsn field can be filled when the first page data is written.
[0093] (2) Rename the online_page_data_file file name to a string composed of timeline, minLsn, and maxLsn, such as 00000001_0_45000098_0_46000098.
[0094] (3) Obtain the new file.
[0095] (4) Update the usage information of the online_page_data_file file (including the disk write position, etc.).
[0096] It should be noted here that a file naming method can be selected to distinguish between historical page data files and online page data files. For example:
[0097] When the page data file is just created, the name is online_page_data_file.
[0098] When the page data file is normally switched, the name is changed to a string composed of timeline, minLsn, and maxLsn, such as 00000001_0_45000098_0_46000098.
[0099] timeline: The XLOG log timeline, such as 00000001. Since the XLOG logs on different timelines may have the same lsn value, it is necessary to distinguish them by the timeline;
[0100] minLsn: The lsn stored in the first page data data area of the page data file, such as 0_45000098. The 32 high bits of the lsn are in front of the underscore, and the 32 low bits of the lsn are behind the underscore;
[0101] maxLsn: The lsn stored in the last page data data area of the page data file, such as 0_46000098. The 32 bits before the underscore are the high 32 bits of the lsn, and the 32 bits after the underscore are the low 32 bits of the lsn.
[0102] Figure 3 It is a schematic diagram of a method for processing a database according to an embodiment of the present invention. As Figure 3 shown, the method for processing the database may include the following steps S302 to step S310.
[0103] Step S302, monitor the running state of the database.
[0104] Step S304, when the running state is normal operation, record the file information of the page data file into the shared memory.
[0105] Step S306, when the running state is about to be closed, record the file information of the page data file into a temporary file.
[0106] Step S308, when the running state is restarted, obtain the file information of the page data file from the temporary file.
[0107] Step S310, if the acquisition is successful, determine that the database was normally closed before restarting, and record the acquired file information into the shared memory.
[0108] The method for processing the database in this embodiment can understand whether the database is operating normally, about to be closed, or restarted by monitoring the running state of the database.
[0109] When the database is operating normally, record the file information of the page data file into the shared memory. At this time, the content in the temporary file is empty. The shared memory is an area shared by multiple processes. Recording the file information into the shared memory can ensure that other processes or components can quickly access this information.
[0110] When the database is about to be closed, record the file information of the page data file into a temporary file. The temporary file is used to temporarily store the file information so that these information can be reloaded and used after the database is restarted.
[0111] When the database is restarted, the file information of the page data file can be obtained from the temporary file. If the acquisition is successful, it means that the database was normally closed before restarting. At this time, the acquired file information can be recorded into the shared memory.
[0112] Thus, the file information of the page data file can be recorded safely and efficiently, and the content of the shared memory can be updated using the file information in the temporary file, which is beneficial to clearly understand the usage of the page data file.
[0113] The file information of the page data file may include: file name, file path, the end address of the last disk-written data area in the file, and the remaining storage space of the file.
[0114] In an alternative embodiment, the file name of the temporary file may be recorded as page_data_file_control, the file name of the page data file being used may be recorded as online_page_data_file, the path of the directory where the file is located may be recorded as sys_wal / wal_pagedata, the end address of the last disk-written page data area of the file may be recorded as flushed_to, and the remaining storage space of the file may be recorded as remained_len.
[0115] In this way, in practical applications, after the database restarts, by obtaining the file information in the temporary file, the position information where the last file writing was aborted can be accurately known to ensure data consistency and integrity.
[0116] After recording the obtained file information into the shared memory, the file information of the page data file can also be cleared from the temporary file. Thus, the storage space occupied by the temporary file can be released, and it can be ensured that the temporary file only contains the file information of the currently active page data file.
[0117] By clearing the file information of the old page data file from the temporary file, the temporary file can be kept updated and streamlined, only retaining the information related to the current status of the page data file. This can improve the efficiency and performance of the system and ensure that only the necessary storage space is used.
[0118] In an alternative embodiment, after obtaining the file information of the page data file from the temporary file, if the acquisition fails, it indicates that the database was abnormally shut down before restarting. At this time, it can be checked whether there is a page data file being used. If there is, it is further checked whether the page data file being used has completed the write task. If it has, a new page data file is switched, and then the file information of the new page data file is recorded into the shared cache.
[0119] That is to say, in the case where the database was abnormally shut down before restarting, if there is a page data file being used, it can be checked whether the page data file has completed the write task. If it has, it means that the switching opportunity of the page data file is met at this time, a new page data file can be switched, the file information of the new page data file is recorded into the shared cache, and then written from the shared cache into the shared memory. In this way, the data processing efficiency can be improved, and the overall performance and response speed of the database system can be enhanced.
[0120] For example, when a new page data file is just created and its content is empty, the file information recorded in the shared cache may include flushed_to (which is the file header length at this time) and remained_len (which is 64MB - the file header length at this time).
[0121] In one example, the step of checking whether the page data file in use has completed the write task can be: checking whether minLsn (the lsn recorded in the first page data data area) and maxLsn (the lsn recorded in the last page data data area) exist in the file header of the page number file. If both exist, it can indicate that the page data file has completed the write task at this time.
[0122] Further, after checking whether there is a page data file in use, if it is found that there is no page data file in use, the step of switching to a new page data file can be executed to store the newly generated page data using the new page data file.
[0123] In an alternative embodiment, the step of switching to a new page data file can be to modify the file name of the page data file in use, then create a new page data file, and use the new page data file as the page data file in use. By modifying the file name, it is convenient to distinguish between the historical page data file and the online page data file (i.e., the page data file in use).
[0124] Specifically, the step of modifying the file name of the page data file in use can be to obtain the log timeline of the page data file in use, the log sequence number stored in the first data area, and the log sequence number stored in the last data area, and then use the string composed of the log timeline, the log sequence number stored in the first data area, and the log sequence number stored in the last data area as the file name of the page data file in use. That is: change the file name in use from online_page_data_file to the string composed of minLsn + maxLsn + timeline, while the file name of the new page data file is online_page_data_file.
[0125] In an alternative embodiment, if the page data file in use has not completed the write task, it can be further checked whether there is a data area in the positive page data file. If it exists, it indicates that the page data file has been partially occupied. To ensure the integrity and reliability of the data, a new page data file can be switched. If it does not exist, the page data file in use can be directly deleted.
[0126] In one example, when checking whether there is a data area in the page data file being used, if a data area is found, the page data areas in the file can be traversed, and then the minLsn (the lsn recorded in the first page data area), maxLsn (the lsn recorded in the last page data area), and totalLen (the total length of each independent page data area plus the file header length) of this file can be obtained and set. Then, the file name of the page data file is changed to the string composed of minLsn + maxLsn + timeline, and finally, a new page data file is switched to.
[0127] Figure 4 It is a flowchart of the processing method of the database when the file information acquisition of the page data file fails. As Figure 4 shown, the processing method at least includes the following steps S402 to step S414.
[0128] Step S402, the file information acquisition fails, and it is determined that the database was abnormally shut down before restarting.
[0129] Step S404, check whether there is a page data file being used. If there is, execute step S406. If not, execute step S408.
[0130] Step S406, check whether the page data file being used has completed the write task. If so, execute step S408. If not, execute step S412.
[0131] Step S408, switch to a new page data file.
[0132] Step S410, record the file information of the new page data file into the shared cache.
[0133] Step S412, check whether there is a data area in the page data file being used. If there is, execute step S408. If not, execute step S414.
[0134] Step S414, delete the page data file being used.
[0135] Thus, it can be ensured that the database can correctly recover and manage the page data file after abnormal shutdown, ensuring data integrity and system stability.
[0136] This embodiment also provides a machine-readable storage medium 10 and a computer device 20. Figure 5 It is a schematic diagram of the machine-readable storage medium 10 according to an embodiment of the present invention, Figure 6 It is a schematic diagram of the computer device 20 according to an embodiment of the present invention.
[0137] A machine-readable storage medium 10 stores a machine-executable program 11. When the machine-executable program 11 is executed by a processor 210, it implements the processing method of the database in any of the above embodiments.
[0138] The computer device 20 may include a memory 220, a processor 210, and a machine-executable program 11 stored in the memory 220 and running on the processor 210. When the processor 210 executes the machine-executable program 11, it implements the processing method of the database in any of the above embodiments.
[0139] 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 machine-readable storage medium 10 for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor 210, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or used in combination with these instruction execution systems, apparatus, or devices.
[0140] 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 an instruction execution system, apparatus, or device or in combination with these instruction execution systems, apparatus, or devices. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection part with one or more wirings (electronic device), a portable computer disk cartridge (magnetic device), a random access memory 220 (RAM), a read-only memory 220 (ROM), an erasable programmable read-only memory 220 (EPROM or flash memory 220), an optical fiber device, and a portable compact disc read-only memory 220 (CDROM). Additionally, the machine-readable storage medium 10 can even be paper or other suitable media on which a program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other appropriate processing when necessary, and then stored in the computer memory 220.
[0141] It should be understood that various parts 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 the memory 220 and executed by a suitable instruction execution system.
[0142] The computer device 20 can be, for example, a server, a desktop computer, a laptop computer, a tablet computer, or a smart phone. 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 particular tasks or implement particular 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.
[0143] The computer device 20 can include a processor 210 adapted to execute stored instructions and a memory 220 that provides temporary storage space for the operation of the instructions during operation. The processor 210 can be a single-core processor 210, a multi-core processor 210, a computing cluster, or any number of other configurations. The memory 220 can include random access memory 220 (RAM), read-only memory 220, flash memory, or any other suitable storage system.
[0144] The processor 210 can be connected through a system interconnect (such as PCI, PCI-Express, etc.) to an I / O interface (input / output interface) adapted to connect the computer device 20 to one or more I / O devices (input / output devices). The I / O devices can include, for example, a keyboard and a pointing device, where the pointing device can include a touchpad or a touch screen, etc. The I / O devices can be built-in components of the computer device 20, or can be devices externally connected to the computing device.
[0145] The processor 210 can also be linked through a system interconnect to a display interface adapted to connect the computer device 20 to a display device. The display device can include a display screen as a built-in component of the computer device 20. The display device can also include a computer monitor, a television, a projector, etc. externally connected to the computer device 20. In addition, a network interface controller (NIC) can be adapted to connect the computer device 20 to a network through a system interconnect. In some embodiments, the 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. The remote device can be connected to the computing device through the network.
[0146] The flowcharts provided in this embodiment are not intended to indicate that the operations of the method will be performed 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.
[0147] 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 such other variations or modifications.
Claims
1. A processing method for a database, wherein a page data file is pre-created in the database, and the page data file is used to store page data separated from the transaction log of the database. The processing method includes: Monitoring the running state of the database; When the running state is normal operation, recording the file information of the page data file into the shared memory; When the running state is about to be closed, recording the file information of the page data file into a temporary file; When the running state is restart, obtaining the file information of the page data file from the temporary file; If the obtaining is successful, determining that the database was normally closed before restart, and recording the obtained file information into the shared memory.
2. The processing method according to claim 1, wherein The file information of the page data file includes: file name, file path, the end address of the last disk-written data area in the file, and the remaining storage space of the file.
3. The processing method according to claim 1, wherein After the step of recording the obtained file information into the shared memory, it further includes: Clearing the file information of the page data file from the temporary file.
4. The processing method according to claim 1, wherein, After the step of obtaining the file information of the page data file from the temporary file, it further includes: If the obtaining fails, determining that the database was abnormally closed before restart; Checking whether there is a page data file being used; If there is, checking whether the page data file being used has completed the write task; If it has completed, switching to a new page data file; Recording the file information of the new page data file into the shared cache.
5. The processing method according to claim 4, wherein, After the step of checking whether there is a page data file being used, it further includes: If there is none, performing the step of switching to a new page data file.
6. The processing method according to claim 4, wherein, The step of switching to a new page data file includes: Modifying the file name of the page data file being used; Creating a new page data file; Taking the new page data file as the page data file being used.
7. The processing method according to claim 6, wherein, The step of modifying the file name of the page data file being used includes: Obtaining the log timeline of the page data file being used, the log sequence number stored in the first data area, and the log sequence number stored in the last data area; Taking the string composed of the log timeline, the log sequence number stored in the first data area, and the log sequence number stored in the last data area as the file name of the page data file being used.
8. The processing method according to claim 4, wherein After the step of checking whether the page data file being used has completed the write task, it further includes: If it has not completed, checking whether there is a data area in the page data file being used; If there is, switching to a new page data file; If there is none, deleting the page data file being used.
9. 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 processing method for the 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, it implements the processing method of the database according to any one of claims 1 to 8.