A database repair method and repair device
By monitoring the database blocking incident and adjusting the relevant parameters, the database systems may cause delay and blocking problems that may be caused during the writing and merger, and ensure the normal operation of the database.
Patent Information
- Application Number
- CN202210557425.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-20
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2042-05-20
AI Technical Summary
The database system may cause system delays and write blockage during data writing and merging, affecting the normal operation of the database.
Through monitoring database blocking incidents, obtaining system logs, determining the type of blocking event (blocking or merging obstruction), and adjusting the relevant database parameters according to the preset adjustment strategy to repair the database.
It effectively solves the problem of database blocking, ensures the normal operation of the database system, and avoids delays and write blocking.
Smart Images

Figure CN114817224B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of databases, and in particular to a method and device for repairing a database. Background Art
[0002] With the continuous development of Internet technology, databases have been widely used in various business fields.
[0003] Currently, many database management systems manage the underlying data of the database through a log-structured merge tree (LMS-tree) structure. That is, in an LMS-tree, there are two levels of tree structures, the primary structure is specifically stored in memory, and the secondary structure is specifically stored in disk.
[0004] When the database management system writes data to the database, the data can be stored in the memory first. When the data stored in the memory is large, the data can be transferred to the disk and stored on the disk. The secondary structure also has multiple levels. The amount of data that can be stored in the nth level in the secondary structure is much larger than that in the n-1th level. Therefore, when a large amount of data is stored in one level, the data can be merged and stored in the next level.
[0005] Therefore, when there is a lot of data that needs to be stored in the database, a lot of data will be transferred from the memory to the disk for storage, and on the disk, a lot of data will be merged from the previous level to the next level, which may cause system delays, database write blockages, etc.
[0006] Therefore, how to ensure the normal operation of the database system is an urgent problem to be solved. Summary of the invention
[0007] This specification provides a database repair method and a repair device to ensure the normal operation of the database system.
[0008] This manual adopts the following technical solutions:
[0009] This manual provides a method for repairing a database, including:
[0010] If a blocking event is detected in the database, obtain the database system log;
[0011] Determine, according to the database system log, an event type of the blocking event, the event type including at least one of a disk-to-disk blocking type and a merge blocking type, the disk-to-disk blocking type is used to indicate a blocking caused by transferring data from a memory to a disk, and the merge blocking type is used to indicate a blocking caused by merging data in the disk;
[0012] According to a preset adjustment strategy, adjusting parameters in the database parameters that are associated with the event type of the blocking event;
[0013] The database is repaired according to the adjusted parameters.
[0014] Optionally, determining the event type of the blocking event according to the database system log specifically includes:
[0015] According to the database system log, determine the number of fixed memory allocation tables Immemtable generated by the database, where the fixed memory allocation table is used to record data in the memory allocation table Memtable that needs to be transferred from the memory to the disk, and the Memtable is a data table that is allowed to be stored in the memory;
[0016] If it is determined that the number exceeds the set number, the event type of the blocking event is determined to be a disk drop blocking type.
[0017] Optionally, determining the event type of the blocking event according to the database system log specifically includes:
[0018] Determine, based on the database system log, the amount of data generated by the database that needs to be merged on the disk;
[0019] If it is determined that the data volume exceeds the preset data volume, it is determined that the event type of the blocking event is a merge blocking type.
[0020] Optionally, adjusting parameters in the database parameters that are associated with the event type of the blocking event specifically includes:
[0021] If the event type is a disk-falling blocking type, the parameters corresponding to the disk-falling blocking type included in the database parameters are adjusted, wherein the parameters corresponding to the disk-falling blocking type include: at least one of the number of threads required to transfer data from memory to disk, the number of memory allocation tables Memtables, and the capacity of Memtables, wherein the Memtable is a data table allowed to be stored in memory.
[0022] Optionally, adjusting the parameters corresponding to the disk drop blocking type included in the database parameters specifically includes:
[0023] At least one of the number of Memtables, the capacity of the Memtables, and the number of threads required to transfer data from memory to disk is increased.
[0024] Optionally, adjusting parameters in the database parameters that are associated with the event type of the blocking event specifically includes:
[0025] If the event type is a merge blocking type, the parameters corresponding to the merge blocking type included in the database parameters are adjusted, wherein the parameters corresponding to the merge blocking type include: at least one of the maximum merge data volume, the number of threads required to merge the data in the disk, and the storage capacity of each level of storage structure in the disk.
[0026] Optionally, adjusting the parameters corresponding to the merge blocking type included in the database parameters specifically includes:
[0027] The maximum merged data amount is reduced.
[0028] Optionally, adjusting the parameters corresponding to the merge blocking type included in the database parameters specifically includes:
[0029] At least one of the storage capacity of each hierarchical storage structure in the disk and the number of threads required for merging the data in the disk is increased.
[0030] Optionally, the method further comprises:
[0031] If after the database is repaired according to the adjusted parameters, it is monitored that no blocking event occurs again in the database, the adjusted parameters are restored to the parameters before the adjustment.
[0032] This specification provides a database repair device, including:
[0033] The monitoring module is used to obtain the database system log if a blocking event is detected in the database;
[0034] a determination module, configured to determine, according to the database system log, an event type of the blocking event, wherein the event type includes at least one of a disk-to-disk blocking type and a merge blocking type, wherein the disk-to-disk blocking type is used to indicate a blocking caused by transferring data from a memory to a disk, and the merge blocking type is used to indicate a blocking caused by merging data in the disk;
[0035] An adjustment module, used for adjusting parameters in the database parameters associated with the event type of the blocking event according to a preset adjustment strategy;
[0036] The repair module is used to repair the database according to the adjusted parameters.
[0037] Optionally, the determination module is specifically used to determine the number of solidified memory allocation tables Immemtable generated by the database according to the database system log, the solidified memory allocation table is used to record the data in the memory allocation table Memtable that needs to be transferred from the memory to the disk, and the Memtable is a data table allowed to be stored in the memory; if it is determined that the number exceeds the set number, the event type of the blocking event is determined to be a disk blocking type.
[0038] Optionally, the determination module is specifically used to determine the amount of data generated by the database that needs to be merged on the disk based on the database system log; if it is determined that the data amount exceeds a preset data amount, determine that the event type of the blocking event is a merge blocking type.
[0039] Optionally, the adjustment module is specifically used to adjust the parameters corresponding to the disk blocking type included in the database parameters if the event type is a disk blocking type, wherein the parameters corresponding to the disk blocking type include: at least one of the number of threads required to transfer data from memory to disk, the number of memory allocation tables Memtables, and the capacity of the Memtable, wherein the Memtable is a data table allowed to be stored in the memory.
[0040] Optionally, the adjustment module is specifically used to increase at least one of the number of Memtables, the capacity of the Memtables, and the number of threads required to transfer data from the memory to the disk.
[0041] Optionally, the adjustment module is specifically used to adjust the parameters corresponding to the merge blocking type included in the database parameters if the event type is a merge blocking type, wherein the parameters corresponding to the merge blocking type include: the maximum merge data volume, the number of threads required to merge the data in the disk, and at least one of the storage capacity of each level of storage structure in the disk.
[0042] Optionally, the adjustment module is specifically used to reduce the maximum merged data amount.
[0043] Optionally, the adjustment module is specifically used to increase at least one of the storage capacity of each hierarchical storage structure in the disk and the number of threads required for merging the data in the disk.
[0044] Optionally, the device further comprises:
[0045] The restoration module is used to restore the adjusted parameters to the parameters before the adjustment if it is detected that no blocking event occurs again in the database after the database is repaired according to the adjusted parameters.
[0046] This specification provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned database repair method is implemented.
[0047] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned database repair method when executing the program.
[0048] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0049] It can be seen from the above database repair method that if a blocking event is detected in the database, the database system log can be obtained, and the event type of the blocking event can be determined based on the database system log. The event type includes at least one of the disk blocking type and the merge blocking type. The disk blocking type is used to indicate the blocking caused by transferring data from the memory to the disk, and the merge blocking type is used to indicate the blocking caused by merging data on the disk. Then, according to the preset adjustment strategy, the parameters in the database parameters associated with the event type of the blocking event can be adjusted, and the database can be repaired based on the adjusted parameters.
[0050] It can be seen from the above content that the database repair method provided in this specification can determine the reason why the database is blocked when the database is blocked, that is, whether the database is blocked due to the transfer of data from the memory to the disk, or due to the merging of data on the disk. When the reason (that is, the event type of the blocking event) is determined, the parameters associated with the event type of the blocking event can be adjusted to make the blockage disappear. Therefore, this method can repair the database in time after the database is blocked to ensure the normal operation of the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:
[0052] Figure 1 A schematic diagram of a method for repairing a database in this specification;
[0053] Figure 2 A flowchart of adjusting database parameters to solve database blocking problems provided in this specification;
[0054] Figure 3 A schematic diagram of a database repair device provided in this specification;
[0055] Figure 4 A method corresponding to the Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0057] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0058] Figure 1 The following is a flowchart of a method for repairing a database in this specification, which specifically includes the following steps:
[0059] S100: If a blocking event is detected in the database, obtain the database system log.
[0060] S102: Determine the event type of the blocking event according to the database system log, the event type including at least one of a disk-to-disk blocking type and a merge blocking type. The disk-to-disk blocking type is used to indicate a blockage caused by transferring data from memory to disk, and the merge blocking type is used to indicate a blockage caused by merging data on the disk.
[0061] In actual applications, during the operation of the database, the amount of data that needs to be written to the database may be too large, which may cause database blocking (or write blocking). When the data is in the LMS-tree structure, both disk flushing (data transfer from memory to disk) and merging (data merging on disk) may cause write blocking, that is:
[0062] For disk flushing, as data is continuously written, the memory allocation table (Memtable) will be converted into a solidified memory allocation table (Immemtable) and then flushed to disk. The maximum number of solidified memory allocation tables in the system is controlled by system parameters. When the maximum number is reached, the system will block the writing of new data until the solidified memory table is flushed to disk. At this time, the system may experience a short-term delay increase, resulting in glitches. For merging, as the amount of data on the disk accumulates, data is continuously merged from low layers to high layers on the disk, and the size of a single file increases as the number of layers increases. When large files at high layers are merged, the amount of accumulated data is large, which will occupy most of the IO bandwidth resources in the system, thereby possibly blocking the writing of new data and causing glitches.
[0063] Therefore, in the above situation, the database needs to be repaired as soon as possible so that the database can run normally, thereby ensuring that the server can perform business normally. Based on this, the server can monitor whether a blocking event has occurred in the database. Specifically, the server can determine whether a blocking event has occurred in the database by monitoring the system event table of the database.
[0064] If the server detects that a blocking event has occurred in the database, it can obtain the database system log and determine the event type of the blocking event based on the database system log, where the event type of the blocking event may include at least one of a disk-to-disk blocking type and a merge blocking type. The disk-to-disk blocking type is used to indicate a blockage caused by transferring data from memory to disk, and the merge blocking type is used to indicate a blockage caused by merging data on the disk.
[0065] There are many ways to determine the event type of the blocking event.
[0066] For example, when determining whether the event type of the blocking event is a disk blocking type. The number of fixed memory allocation tables Immemtable generated by the database can be determined through the database system log. If it is determined that the number of fixed memory allocation tables Immemtable exceeds the set number, it can be determined that the event type of the blocking event is a disk blocking type, wherein the fixed memory allocation table is used to record the data in the memory allocation table (Memtable) that needs to be transferred from the memory to the disk. Memtable is a data table that is allowed to be stored in the memory, that is, the fixed memory allocation table can represent the data table that needs to be transferred from the memory to the disk. When there are too many fixed memory allocation tables, there are more data that need to be dropped on the disk, which may cause blocking. Of course, there can also be other ways to determine whether the event type of the blocking event is a disk blocking type. For example, the database system log can be used to determine whether there is a warning that there are too many Immemtables at present. If so, it can be determined that the event type of the blocking event is a disk blocking type. Among them, the set number mentioned above can be set manually.
[0067] When determining whether the event type of the blocking event is a merge blocking type, the amount of data generated by the database that needs to be merged on the disk can be determined based on the database system log. If it is determined that the amount of data exceeds the preset data amount, the event type of the blocking event can be determined to be a merge blocking type. Of course, there can also be other ways to determine whether the event type of the blocking event is a merge blocking type. For example, the database system log can be used to determine whether there is currently a warning that there is too much merged data on the disk. If so, it can be determined that the event type of the blocking event is a merge blocking type. The preset data amount mentioned here can also be set manually.
[0068] S104: According to a preset adjustment strategy, the parameters in the database parameters that are associated with the event type of the blocking event are adjusted.
[0069] S106: Repair the database according to the adjusted parameters.
[0070] After determining the event type of the blocking event, the parameters associated with the determined event type of the blocking event contained in the database parameters of the above-mentioned database can be adjusted according to the preset adjustment strategy, and the database can be repaired according to the adjusted parameters so that the server can continue to execute database transactions according to the adjusted parameters.
[0071] Specifically, if the event type is a disk blocking type, the parameters corresponding to the disk blocking type included in the database parameters can be adjusted, wherein the parameters corresponding to the disk blocking type may include: the number of threads required to transfer data from memory to disk, the number of memory allocation tables (Memtable), the capacity of the memory allocation table (Memtable), etc., wherein the memory allocation table is a data table allowed to be stored in the memory, wherein the number of threads required to transfer data from memory to disk can be used to represent the specified number of threads for transferring data from memory to disk, or the specified maximum number of threads for transferring data from memory to disk.
[0072] Specifically, at least one of the number of memory allocation tables, the capacity of the memory allocation tables, and the number of threads required to transfer data from the memory to the disk can be increased. Specifically, when increasing the number of threads required to transfer data from the memory to the disk, the number of memory allocation tables (Memtable), and the capacity of the memory allocation table (Memtable), etc., the parameters can be increased according to the target parameter values preset for these parameters. Of course, these parameters can also be increased according to the parameter change values preset for these parameters. For example, the parameter change values set for each parameter can be 2, and when increasing these parameters, these parameters can be increased by +2.
[0073] If the event type of the above-mentioned blocking event is a merge blocking type, the server can adjust the parameters corresponding to the merge blocking type included in the database parameters, wherein the parameters corresponding to the merge blocking type may include: the maximum merged data volume, the number of threads required to merge the data on the disk, the storage capacity of each level of the storage structure on the disk, the storage capacity multiple of the nth level on the disk compared to the n-1th level, whether to automatically trigger a merge event, etc., wherein the maximum merged data volume is used to indicate the amount of data allowed for a one-time data merge in the database, and whether to automatically trigger a merge event is used to indicate whether the data merge task on the disk in the database can be automatically started.
[0074] Specifically, the maximum amount of merged data can be reduced, the number of threads required for merging data on the disk and at least one of the storage capacity of each level of storage structure on the disk can be increased, the parameter of whether to automatically trigger a merge event can be adjusted to no, and the storage capacity of the nth level on the disk can be increased multiple times compared to the n-1th level. Of course, in practice, there can be more database parameters, so there can be many specific adjustment strategies, which will not be elaborated here.
[0075] When adjusting the parameters corresponding to the above-mentioned merged blocking types, the parameters may also be adjusted according to target parameter values preset for these parameters, or the parameters may be adjusted according to parameter change values preset for these parameters.
[0076] It should be noted that after adjusting the parameters and repairing the database according to the adjusted parameters, it is possible to monitor whether the blocking event does not occur again, that is, whether the blocking event disappears. If so, the adjusted parameters can be restored to the parameters before the adjustment.
[0077] This is because the database blocking may be caused by a sudden increase in data writes, which can be understood as a sudden problem. Therefore, after temporarily adjusting the database parameters to solve the cause of the blocking problem and the blocking problem is solved, the adjusted parameters can be restored to the parameters of the database under normal operation, so that the restored parameters are suitable for the normal operation of the database.
[0078] It should be noted that no blocking event occurs again may mean that the same blocking event as mentioned above does not occur again. Of course, it may also mean that any blocking event does not occur again. That is to say, if a blocking event different from the type of blocking event occurs again, the parameters may not be restored temporarily, and the above method may be continued to be used to adjust the parameters of the database according to the type of blocking event that occurs again. If any blocking event does not occur again after the parameter adjustment, all previously adjusted parameters may be restored.
[0079] Of course, if a blocking event is detected again, and the event type of the blocking event detected again is the same as that of the previous blocking event, it is possible that the adjustment of the parameters is small. In this case, the parameters associated with the event type of this blocking event can be adjusted with a larger amplitude until the database is monitored to be free of blockage.
[0080] The following is an example to illustrate the method of adjusting the parameters of the database provided in this specification. Figure 2 shown.
[0081] Figure 2 The present invention provides a flow chart of adjusting the parameters of a database to solve the problem of database blocking.
[0082] from Figure 2 It can be seen that initially, it is possible to monitor whether a blocking event has started. When a blocking event occurs, the event type of the blocking event can be determined, which is also the event cause of the blocking event. Then, after determining that the blocking event is a merge blocking type or a disk blocking type, the relevant parameters of the corresponding event type can be adjusted. After adjusting the parameters, it can be determined whether the blocking disappears, that is, whether the blocking does not continue to occur. If the blocking disappears, the adjusted parameters can be restored. If the blocking does not disappear, the parameter adjustment can continue.
[0083] It can be seen from the above method that this method can determine the reason why the database is blocked when the database is blocked, that is, whether the database is blocked due to the transfer of data from the memory to the disk, or due to the merging of data on the disk. When the reason (that is, the event type of the blocking event) is determined, the parameters associated with the event type of the blocking event can be adjusted to make the blockage disappear. If the parameters associated with the event type of the blocking event are adjusted and the database is repaired, and it is monitored that no blocking event occurs, the adjusted parameters can be restored so that the parameters can adapt to the subsequent normal operation of the database. Therefore, this method can repair the database in time after the database is blocked to ensure the normal operation of the database.
[0084] Moreover, most existing solutions are highly invasive to the system, such as RocksDB's auto-tuning rate limiter, which allocates bandwidth by priority through a token bucket algorithm; WiscKey's key-value separation method, which reduces the movement of data in merge operations, etc. All of them require a high degree of invasiveness to the system. For mature systems that have already been launched, the optimization risk is too high and the migration cost is huge. The present invention can be adapted to use a system with an LSM-tree architecture in the form of an upper-layer application, without modifying the code of the system itself, and solves the problems of increased delay caused by glitches in the LSM-tree system (i.e., database blocking (write blocking)) in a non-invasive manner.
[0085] The above is a database repair method provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a database repair device, such as Figure 3 shown.
[0086] Figure 3 A schematic diagram of a database repair device provided in this specification specifically includes:
[0087] The monitoring module 301 is used to obtain the database system log if a blocking event occurs in the database;
[0088] A determination module 302 is used to determine the event type of the blocking event according to the database system log, where the event type includes at least one of a disk-to-disk blocking type and a merge blocking type, where the disk-to-disk blocking type is used to indicate a blocking caused by transferring database data from a memory to a disk, and the merge blocking type is used to indicate a blocking caused by merging data in the disk;
[0089] An adjustment module 303, configured to adjust parameters in the database parameters that are associated with the event type of the blocking event according to a preset adjustment strategy;
[0090] The repair module 304 is used to repair the database according to the adjusted parameters.
[0091] Optionally, the determination module 302 is specifically used to determine the number of solidified memory allocation tables Immemtable generated by the database according to the database system log, and the solidified memory allocation table is used to record the data in the memory allocation table Memtable that needs to be transferred from the memory to the disk, and the Memtable is a data table allowed to be stored in the memory; if it is determined that the number exceeds the set number, the event type of the blocking event is determined to be a disk blocking type.
[0092] Optionally, the determination module 302 is specifically used to determine the amount of data generated by the database that needs to be merged on the disk based on the database system log; if it is determined that the data amount exceeds a preset data amount, determine that the event type of the blocking event is a merge blocking type.
[0093] Optionally, the adjustment module 303 is specifically used to adjust the parameters corresponding to the disk blocking type included in the database parameters if the event type is a disk blocking type, wherein the parameters corresponding to the disk blocking type include: at least one of the number of threads required to transfer data from memory to disk, the number of memory allocation tables Memtables, and the capacity of Memtables, and the Memtable is a data table allowed to be stored in memory.
[0094] Optionally, the adjustment module 303 is specifically used to increase at least one of the number of the Memtables, the capacity of the Memtables, and the number of threads required to transfer data from the memory to the disk.
[0095] Optionally, the adjustment module 303 is specifically used to adjust the parameters corresponding to the merge blocking type included in the database parameters if the event type is a merge blocking type, wherein the parameters corresponding to the merge blocking type include: the maximum merge data volume, the number of threads required to merge the data in the disk, and at least one of the storage capacity of each level of storage structure in the disk.
[0096] Optionally, the adjustment module 303 is specifically configured to reduce the maximum merged data amount.
[0097] Optionally, the adjustment module 303 is specifically configured to increase at least one of the storage capacity of each hierarchical storage structure in the disk and the number of threads required for merging the data in the disk.
[0098] Optionally, the device further comprises:
[0099] The restoration module 305 is used to restore the adjusted parameters to the parameters before the adjustment if it is detected that no blocking event occurs again in the database after the database is repaired according to the adjusted parameters.
[0100] The present specification also provides a computer-readable storage medium, which stores a computer program. The computer program can be used to execute the above database repair method.
[0101] This manual also provides Figure 4 The schematic structure diagram of the electronic device shown in FIG. Figure 4 As described above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above-mentioned database repair method. Of course, in addition to the software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0102] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0103] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0104] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0105] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0106] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0107] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0108] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0109] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0110] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0111] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0112] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0114] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0115] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0116] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0117] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A method for repairing a database, comprising: If a blocking event is detected in the database, obtain the database system log; Determine, according to the database system log, an event type of the blocking event, the event type including at least one of a disk-to-disk blocking type and a merge blocking type, the disk-to-disk blocking type is used to indicate a blocking caused by transferring data from a memory to a disk, and the merge blocking type is used to indicate a blocking caused by merging data in the disk; According to a preset adjustment strategy, the parameters in the database parameters associated with the event type of the blocking event are adjusted, wherein when the event type is a disk blocking type, at least one of the number of memory allocation tables Memtable, the capacity of the Memtable, and the number of threads required to transfer data from the memory to the disk is increased, and the Memtable is a data table allowed to be stored in the memory; when the event type is a merge blocking type, the parameters in the database parameters corresponding to the merge blocking type are adjusted, including reducing the maximum merge data amount; The database is repaired according to the adjusted parameters.
2. The method according to claim 1, determining the event type of the blocking event according to the database system log, specifically comprising: According to the database system log, determine the number of fixed memory allocation tables Immemtable generated by the database, where the fixed memory allocation table is used to record data in the memory allocation table Memtable that needs to be transferred from the memory to the disk, and the Memtable is a data table that is allowed to be stored in the memory; If it is determined that the number exceeds the set number, the event type of the blocking event is determined to be a disk drop blocking type.
3. The method according to claim 1, determining the event type of the blocking event according to the database system log, specifically comprising: Determine, based on the database system log, the amount of data generated by the database that needs to be merged on the disk; If it is determined that the data volume exceeds the preset data volume, it is determined that the event type of the blocking event is a merge blocking type.
4. The method according to claim 1, wherein the parameters in the database parameters associated with the event type of the blocking event are adjusted according to a preset adjustment strategy, specifically comprising: If the event type is a merge blocking type, adjust the parameters corresponding to the merge blocking type included in the database parameters, wherein the parameters corresponding to the merge blocking type include: the number of threads required to merge the data in the disk, and at least one of the storage capacity of each level of storage structure in the disk.
5. The method according to claim 4, wherein the parameter corresponding to the merge blocking type included in the database parameter is adjusted, specifically comprising: At least one of the storage capacity of each hierarchical storage structure in the disk and the number of threads required for merging the data in the disk is increased.
6. The method of claim 1, further comprising: If after the database is repaired according to the adjusted parameters, it is monitored that no blocking event occurs again in the database, the adjusted parameters are restored to the parameters before the adjustment.
7. A database repair device, comprising: The monitoring module is used to obtain the database system log if a blocking event is detected in the database; A determination module, used for determining the event type of the blocking event according to the database system log, the event type including at least one of a disk blocking type and a merge blocking type, the disk blocking type is used to indicate the blocking caused by transferring data from the memory to the disk, and the merge blocking type is used to indicate the blocking caused by merging data in the disk, wherein, when the event type is a disk blocking type, at least one of the number of memory allocation tables Memtable, the capacity of the Memtable, and the number of threads required for transferring data from the memory to the disk is increased, the Memtable is a data table allowed to be stored in the memory, and when the event type is a merge blocking type, the parameter corresponding to the merge blocking type in the database parameter is adjusted, including reducing the maximum merged data amount; An adjustment module, used for adjusting parameters in the database parameters associated with the event type of the blocking event according to a preset adjustment strategy; The repair module is used to repair the database according to the adjusted parameters.
8. In the device as described in claim 7, the determination module is specifically used to determine the number of solidified memory allocation tables Immemtable generated by the database according to the database system log, the solidified memory allocation table is used to record the data in the memory allocation table Memtable that needs to be transferred from the memory to the disk, and the Memtable is a data table allowed to be stored in the memory; if it is determined that the number exceeds the set number, the event type of the blocking event is determined to be a disk blocking type.
9. In the device as described in claim 7, the determination module is specifically used to determine the amount of data generated by the database that needs to be merged on the disk based on the database system log; if it is determined that the data amount exceeds the preset data amount, determine that the event type of the blocking event is a merge blocking type.
10. The device according to claim 7, wherein the adjustment module is specifically used to adjust the parameters corresponding to the merge blocking type included in the database parameters if the event type is a merge blocking type, wherein: The parameters corresponding to the merge blocking type include: at least one of the number of threads required to merge the data in the disk and the storage capacity of each hierarchical storage structure in the disk.
11. The device according to claim 10, wherein the adjustment module is specifically used to increase at least one of the storage capacity of each hierarchical storage structure in the disk and the number of threads required for merging the data in the disk.
12. The apparatus of claim 7, further comprising: The restoration module is used to restore the adjusted parameters to the parameters before the adjustment if it is detected that no blocking event occurs again in the database after the database is repaired according to the adjusted parameters.
13. A computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the program.
Citation Information
Patent Citations
Database management method and database system
CN108319602A
A fault-tolerant method and equipment in distributed processing
CN109783273A