Page transmission method and device, page operation method and device, equipment and medium
By obtaining and identifying the rollback log status of the data block page in the shared cluster database, asynchronously flushing the disk and broadcasting the update log sequence number, the problem of low transmission efficiency when the data block is frequently modified is solved, and the high efficiency of the data block page is achieved. Transmission and data consistency guarantees.
Patent Information
- Application Number
- CN202410795350.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In a shared cluster database, when data blocks are frequently modified, the traditional method requires waiting for the rollback log to be persisted to disk before transmitting the data blocks, resulting in reduced performance.
By obtaining the rollback log placement status of the data block page, the data block page is identified and sent. If it is not placed, the disk is asynchronously flushed and the update log sequence number is broadcast, allowing the data block page to be transmitted and operated when it is not placed.
It improves the transmission efficiency of data block pages, reduces waiting time, ensures data consistency after database instance failure recovery, and solves the problem of data loss.
Smart Images

Figure CN118733341A_ABST
Abstract
Description
Technical Field
[0001] The present application is applicable to the field of database technology, and in particular relates to a page transmission method, a page operation method, an apparatus, a device and a medium. Background Art
[0002] In order to ensure that the database system can be restored to a consistent state in the event of a crash or other failure, the database system usually uses a log mechanism (for example, a redo log) to record data modification operations. In a shared cluster database system, data blocks often need to be transferred between multiple database instances. When a data block is a dirty page (i.e., a data page that has been modified in memory but not yet written to disk), in order to ensure data consistency after the database instance fails, the traditional method is to wait for the log recording the dirty page modification operation to be persisted to disk before sending the dirty page to other database instances. However, in the above traditional method, when a data block is frequently modified between various database instances, each modification operation generates a dirty page. Each data block transmission needs to wait until the log corresponding to the dirty page is persisted to disk before the data block is transmitted, which greatly affects the performance of the database system. Therefore, how to improve the transmission efficiency of data block pages in a shared cluster database has become an urgent problem to be solved. Summary of the invention
[0003] In view of this, embodiments of the present application provide a page transmission method, a page operation method, an apparatus, a device and a medium to solve the problem of how to improve the transmission efficiency of data block pages in a shared cluster database.
[0004] In a first aspect, an embodiment of the present application provides a page transmission method of a shared cluster database, the page transmission method being applied to a first database instance in the shared cluster database, comprising:
[0005] When a page request sent by a second database instance in the shared cluster database is obtained, determining a data block page corresponding to the page request;
[0006] Obtaining the disk-written status of the rollback log of the data block page, marking the data page according to the disk-written status, obtaining the marked data block page, and sending the marked data block page to the second database instance;
[0007] If the disk-stacked state is not stacked, the rollback log is flushed, and after the rollback log is flushed, the current log sequence number is updated to obtain the update log sequence number;
[0008] The update log sequence number is broadcasted to the second database instance. After receiving the update log sequence number, the second database instance updates the local log sequence number to decide whether to perform an operation on the data block page according to the local log sequence number.
[0009] In a second aspect, an embodiment of the present application provides a page operation method of a shared cluster database, wherein the page operation method is applied to a second database instance in the shared cluster database, and includes:
[0010] After sending a page request to a first database instance in the shared cluster database, obtaining a data block page with an identifier corresponding to the page request fed back by the first database instance;
[0011] When performing a modification operation on the data block page with an identifier, if the identifier in the data block page with an identifier indicates that the log corresponding to the data block page with an identifier has not been written to the disk, a local log sequence number is obtained, and the second database instance is used to update the local log sequence number using the update log sequence number after receiving the update log sequence number broadcasted by the first database instance;
[0012] According to the local log sequence number, it is detected whether the log corresponding to the identified data block page is written to the disk. If it is detected that it is written to the disk, the modification operation is performed; if it is detected that it is not written to the disk, the modification operation is not performed.
[0013] In a third aspect, an embodiment of the present application provides a page transmission device for a shared cluster database, wherein the page transmission device is applied to a first database instance in the shared cluster database, and comprises:
[0014] A page determination module, configured to determine a data block page corresponding to a page request when a page request sent by a second database instance in the shared cluster database is obtained;
[0015] a page sending module, configured to obtain the disk-written status of the rollback log of the data block page, mark the data page according to the disk-written status, obtain the marked data block page, and send the marked data block page to the second database instance;
[0016] A disk flushing module is used for flushing the rollback log if the disk-falling state is not flushed, and after the rollback log is flushed, updating the current log sequence number to obtain the update log sequence number;
[0017] The broadcast module is used to broadcast the update log sequence number to the second database instance. After receiving the update log sequence number, the second database instance updates the local log sequence number to decide whether to perform an operation on the data block page based on the local log sequence number.
[0018] In a fourth aspect, an embodiment of the present application provides a page operation device for a shared cluster database, characterized in that the page operation device is applied to a second database instance in the shared cluster database, comprising:
[0019] A page acquisition module, configured to, after sending a page request to a first database instance in the shared cluster database, acquire a data block page with an identifier corresponding to the page request fed back by the first database instance;
[0020] A first sequence number acquisition module is used to acquire a local log sequence number when performing a modification operation on the identified data block page, if the identifier in the identified data block page indicates that the log corresponding to the identified data block page has not been written to the disk, and the second database instance is used to update the local log sequence number using the update log sequence number after receiving the update log sequence number broadcasted by the first database instance;
[0021] The disk verification module is used to detect whether the log corresponding to the identified data block page is written to the disk according to the local log sequence number. If it is detected that it has been written to the disk, the modification operation is performed; if it is detected that it has not been written to the disk, the modification operation is not performed.
[0022] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the split-brain repair method for a database cluster as described in the first aspect or the split-brain repair method for a database cluster as described in the second aspect is implemented.
[0023] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the page transmission method of the shared cluster database as described in the first aspect, or the page operation method of the shared cluster database as described in the second aspect is implemented.
[0024] Compared with the prior art, the embodiments of the present application have the following beneficial effects: when the first database instance of the present application obtains a page request sent by the second database instance, it sends the identified data block page to the second database instance without waiting for the rollback log corresponding to the data block page to be written to the disk. Compared with the prior art of waiting for the disk writing operation before executing the sending of the data block page, the waiting time is reduced and the transmission efficiency of the data block page is improved. If the data block page is not written to the disk, the rollback log is asynchronously flushed to the disk in the background. After the flushing is completed, the update log sequence number is broadcast to the second database instance. The second database instance obtains the identified data block page fed back by the first database instance. When performing a modification operation on the identified data block page, if the log corresponding to the identified data block page has not been written to the disk, it detects whether the log corresponding to the identified data block page has been written to the disk based on the local log sequence number. If it has been written to the disk, the modification operation is performed; if it has not been written to the disk, the modification operation is not performed. The local log sequence number is updated according to the update log sequence number broadcasted by the received first database instance, thereby realizing the disk verification of the log corresponding to the received identified data block page, solving the problem of data loss in the failure scenario, and ensuring the data consistency after the database instance fails and recovers. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0026] Figure 1 It is a flow chart of a page transmission method of a shared cluster database provided in Example 1 of the present application;
[0027] Figure 2 It is a flow chart of a page transmission method of a shared cluster database provided in Embodiment 2 of the present application;
[0028] Figure 3 It is a flow chart of a page operation method of a shared cluster database provided in Embodiment 3 of the present application;
[0029] Figure 4 It is a flow chart of a page operation method of a shared cluster database provided in Embodiment 4 of the present application;
[0030] Figure 5 It is a flowchart of a page operation method of a shared cluster database provided in Embodiment 5 of the present application;
[0031] Figure 6It is a structural diagram of a page transmission device for a shared cluster database provided in Embodiment 6 of the present application;
[0032] Figure 7 It is a structural diagram of a page operation device for a shared cluster database provided in Embodiment 7 of the present application;
[0033] Figure 8 It is a structural diagram of a computer device provided in Example 8 of the present application. DETAILED DESCRIPTION
[0034] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0035] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0036] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0037] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0038] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0039] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0040] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0041] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0042] See also Figure 1 , is a flow chart of a page transmission method of a shared cluster database provided in Embodiment 1 of the present application, such as Figure 1 As shown, the page transmission method is applied to the first database instance in the shared cluster database, and may include the following steps:
[0043] Step S101 : when a page request sent by a second database instance in a shared cluster database is obtained, a data block page corresponding to the page request is determined.
[0044] In an embodiment of the present application, a shared cluster database may refer to a database cluster system that allows multiple database instances to simultaneously access and operate the same storage medium, a database instance may refer to a software process or component that can access and operate database resources, a data block page may refer to a basic unit for storing data in a database, and a page request may refer to a request to obtain a data block page.
[0045] In order to realize the sharing of data block pages between multiple database instances in a database system, the database system usually adopts memory fusion technology to build a shared cluster database. In a shared cluster database environment, memory fusion allows each database instance to directly share data block pages. When a database instance (i.e., the second database instance) wants to access a data block page, if the data block page is in an invalid state locally, it is necessary to send a page request to the database instance (i.e., the first database instance) that holds the data block page. When the first database instance receives the page request sent by the second database instance, it determines the data block page corresponding to the page request and sends the data block page to the second database instance through the network. The first database instance is the sender of the data block page, and the second database instance is the receiver of the data block page.
[0046] Step S102, obtaining the disk-written status of the rollback log of the data block page, marking the data block page according to the disk-written status, obtaining the marked data block page, and sending the marked data block page to the second database instance.
[0047] In an embodiment of the present application, a rollback log may refer to a log that records modification operations on data block pages. The rollback log may be a Redo log. The disk status may refer to a status that indicates whether the rollback log is persisted to the disk. If the rollback log has been persisted to the disk, the disk status of the rollback log is "already persisted". If the rollback log has not been persisted to the disk, the disk status of the rollback log is "not persisted".
[0048] Specifically, the log sequence number and disk status of the rollback log of the data block page are obtained, the data block page is marked using the log sequence number and the disk status, the marked data block page is obtained, and the marked data block page is sent to the second database instance.
[0049] Step S103, if the disk-stacked state is not yet disk-stacked, the rollback log is flushed to disk, and after the rollback log is flushed to disk, the current log sequence number is updated to obtain the update log sequence number.
[0050] In an embodiment of the present application, the current log sequence number may refer to the log sequence number of the latest rollback log of the first database instance before the disk flush, and the update log sequence number may refer to the log sequence number of the latest rollback log of the first database instance after the disk flush is completed.
[0051] Specifically, if the disk status of the rollback log of the identified data block page is not yet written to disk, then when the identified data block page is sent to the second database instance, the rollback log is asynchronously flushed in the background. After the rollback log is flushed to disk, the log sequence number of the latest rollback log written to disk by the first database instance is updated to obtain the updated log sequence number.
[0052] Step S104: broadcast the update log sequence number to the second database instance.
[0053] Specifically, after obtaining the update log sequence number, the first database instance broadcasts the update log sequence number to the shared cluster database, and after receiving the update log sequence number broadcast by the first database instance, each second database instance uses the update log sequence number to update the local log sequence number, so as to decide whether to perform operations on the identified data block page based on the local log sequence number, wherein the local log sequence number may refer to the log sequence number of the latest rollback log of the first database instance stored locally in the second database instance.
[0054] For example, in a shared cluster database system, there are two database instances, namely, a first database instance and a second database instance. The first database instance modifies the data block page b and generates a corresponding Redo log. Then, the overall process of page transmission and page operation between the first database instance and the second database instance can be:
[0055] 1) The second database instance sends a page request to the first database instance to obtain the data block page b. When the first database instance obtains the page request, it obtains the disk-falling status of the Redo log of the data block page b, identifies the data block page b according to the disk-falling status, and sends the identified data block page b to the second database instance; 2) If the disk-falling status of the Redo log is not fallen, the Redo log is asynchronously flushed in the background. After the flushing is completed, the update log sequence number of the latest disk-falling of the first database instance is obtained, and the update log sequence number is broadcast to the second database instance;
[0056] 3) When the second database instance obtains the identified data block page b fed back by the first database instance, if it wants to perform a read operation on the identified data block page b, it can directly perform the read operation; 4) If it wants to modify the identified data block page b, if the identifier in the identified data block page b indicates that the Redo log corresponding to the identified data block page b has been written to the disk, then the modification operation is directly performed; if the identifier in the identified data block page b indicates that the Redo log corresponding to the identified data block page b has not been written to the disk, then the local log sequence number corresponding to the first database instance is obtained from the local sequence number mapping table, wherein, after receiving the update log sequence number broadcasted by the first database instance, the second database instance uses the update log sequence number to modify the local log sequence number corresponding to the first database instance. The sequence number updates the local log sequence number corresponding to the first database instance in the local sequence number mapping table; 5) compares the local log sequence number with the log sequence number identified in the identified data block page. If the local log sequence number is greater than or equal to the log sequence number identified in the identified data block page, it is determined that the log corresponding to the identified data block page has been written to the disk, and the modification operation is performed; if the local log sequence number is less than the log sequence number identified in the identified data block page, it is determined that the log corresponding to the identified data block page has not been written to the disk, and the modification operation is not performed. A write-to-disk notification is sent to the first database instance to instruct the first database instance to perform a write-to-disk operation on the Redo log corresponding to the identified data block page b according to the write-to-disk notification.
[0057] In the embodiment of the present application, when the first database instance obtains the page request sent by the second database instance, it sends the marked data block page to the second database instance without waiting for the rollback log corresponding to the data block page to be dropped on the disk. Compared with the prior art of waiting for the drop operation before executing the sending of the data block page, the waiting time is reduced and the transmission efficiency of the data block page is improved. If the data block page is not dropped on the disk, the rollback log is asynchronously flushed in the background. After the flush is completed, the update log sequence number is broadcast to the second database instance. The second database instance obtains the marked data block page fed back by the first database instance. When modifying the marked data block page, if the log corresponding to the marked data block page is not dropped on the disk, it detects whether the log corresponding to the marked data block page is dropped on the disk according to the local log sequence number. If it is dropped on the disk, the modification operation is performed. If it is not dropped on the disk, the modification operation is not performed. The local log sequence number is updated according to the update log sequence number broadcast by the first database instance, which realizes the drop verification of the log corresponding to the received marked data block page, solves the data loss problem in the fault scenario, and ensures the data consistency after the database instance fails to recover.
[0058] See also Figure 2 , is a flow chart of a page transmission method of a shared cluster database provided in Embodiment 2 of the present application. Figure 2As shown, in the above step S102, the data block page is marked according to the disk-falling status to obtain the marked data block page, which may include the following steps:
[0059] Step S201, obtaining the log sequence number of the rollback log of the data block page.
[0060] Step S202: Mark the data page according to the disk-written state and the log sequence number of the rollback log of the data block page to obtain the marked data page.
[0061] Specifically, the log sequence number of the rollback log that records the modification operation on the data block page is obtained, and the data page is marked according to the disk status of the rollback log, that is, whether it has been written to the disk or not, and the log sequence number of the rollback log to obtain the marked data page.
[0062] In the embodiment of the present application, the data page is identified according to the disk-falling state and log sequence number of the rollback log of the data block page, and the identified data block page is obtained. The identified data page can be directly sent to the second database instance without waiting for the rollback log corresponding to the data block page to fall to the disk, which reduces the waiting time and improves the transmission efficiency of the data block page.
[0063] See also Figure 3 , is a flow chart of a page operation method of a shared cluster database provided in Example 3 of the present application, such as Figure 3 As shown, the page operation method is applied to the second database instance in the shared cluster database, and may include the following steps:
[0064] Step S301: after sending a page request to a first database instance in a shared cluster database, obtaining a data block page with an identifier corresponding to the page request fed back by the first database instance.
[0065] Step S302, when performing a modification operation on the data block page with the identifier, if the identifier in the data block page with the identifier indicates that the log corresponding to the data block page with the identifier has not been written to the disk, then obtain the local log sequence number.
[0066] Step S303, based on the local log sequence number, detect whether the log corresponding to the identified data block page is written to the disk. If it is detected that it has been written to the disk, perform the modification operation; if it is detected that it has not been written to the disk, do not perform the modification operation.
[0067] In an embodiment of the present application, the identified data block page may refer to a data block page with a disk status and log sequence number identification for a rolled-back log, and the local log sequence number may refer to the log sequence number of the latest rolled-back log of the first database instance stored locally in the second database instance.
[0068] Specifically, after sending a page request to the first database instance in the shared cluster database, the identified data block page corresponding to the page request fed back by the first database instance is obtained. If an access operation is performed on the identified data block page, the access can be performed directly. If a modification operation is performed on the identified data block page, it is determined whether the log corresponding to the identified data block page is written to the disk represented by the identifier in the identified data block page. If the corresponding log has been written to the disk, the modification operation can be performed directly. If the corresponding log has not been written to the disk, the local log sequence number corresponding to the first database instance is obtained locally in the second database instance. According to the local log sequence number, it is detected whether the log corresponding to the identified data block page is written to the disk. If it is detected that it has been written to the disk, the modification operation is performed. If it is detected that it has not been written to the disk, the modification operation is not performed.
[0069] Optionally, if it is detected that the data has not been flushed to disk and the modification operation is not performed, a flush notification may be sent to the first database instance to instruct the first database instance to perform a flush operation on the log corresponding to the data block page with the identifier according to the flush notification.
[0070] In the embodiment of the present application, when the first database instance obtains the page request sent by the second database instance, it sends the marked data block page to the second database instance without waiting for the rollback log corresponding to the data block page to be dropped on the disk. Compared with the prior art of waiting for the drop operation before executing the sending of the data block page, the waiting time is reduced and the transmission efficiency of the data block page is improved. If the data block page is not dropped on the disk, the rollback log is asynchronously flushed in the background. After the flush is completed, the update log sequence number is broadcast to the second database instance. The second database instance obtains the marked data block page fed back by the first database instance. When modifying the marked data block page, if the log corresponding to the marked data block page is not dropped on the disk, it detects whether the log corresponding to the marked data block page is dropped on the disk according to the local log sequence number. If it is dropped on the disk, the modification operation is performed. If it is not dropped on the disk, the modification operation is not performed. The local log sequence number is updated according to the update log sequence number broadcast by the first database instance, which realizes the drop verification of the log corresponding to the received marked data block page, solves the data loss problem in the fault scenario, and ensures the data consistency after the database instance fails to recover.
[0071] See also Figure 4 , is a flow chart of a page operation method of a shared cluster database provided in Embodiment 4 of the present application, such as Figure 4 As shown, the page operation method may also include the following steps:
[0072] Step S401, obtaining a sequence number mapping table in a second database instance.
[0073] In an embodiment of the present application, a sequence number mapping table may refer to a table structure used to record the mapping relationship between any database instance in a shared cluster database and its local log sequence number. For example, if the shared cluster database includes three database instances, namely instance 1, instance 2 and instance 3, where the local log sequence number of instance 1 that has been most recently written to disk is 1000, the local log sequence number of instance 2 that has been most recently written to disk is 900, and the local log sequence number of instance 3 that has been most recently written to disk is 1100, then a sequence number mapping table is respectively stored in instance 1, instance 2 and instance 3, for recording the mapping relationship between instance 1 and the local log sequence number 1000 of instance 1, the mapping relationship between instance 2 and the local log sequence number 900 of instance 2, and the mapping relationship between instance 3 and the local log sequence number 1100 of instance 3.
[0074] Step S402: Use the received update log sequence number broadcasted by the first database instance to update the local log sequence number corresponding to the first database instance in the sequence number mapping table.
[0075] Step S403, obtaining a local log sequence number, includes: obtaining a local log sequence number corresponding to the first database instance from a sequence number mapping table.
[0076] Specifically, when receiving the update log sequence number broadcast by the first database instance, locate the mapping row between the first database instance and its local log sequence number in the local sequence number mapping table, and use the received update log sequence number to update the local log sequence number in the mapping row. When obtaining the local log sequence number and detecting whether the log corresponding to the identified data block page is written to the disk based on the local log sequence number, the local log sequence number corresponding to the first database instance can be obtained from the sequence mapping table.
[0077] In the embodiment of the present application, when the update log sequence number broadcasted by the first database instance is received, the sequence number mapping table in the second database instance is obtained, and the local log sequence number corresponding to the first database instance in the sequence number mapping table is updated using the update log sequence number broadcasted by the first database instance received, and when detecting whether the log corresponding to the identified data block page is written to the disk, the local log sequence number corresponding to the first database instance can be obtained from the sequence number mapping table. This ensures that each database instance in the cluster can know the latest log sequence number written to the disk of other database instances based on the local sequence number mapping table, ensures data consistency after database instance failure recovery, and improves the performance of the database system.
[0078] See also Figure 5 , is a flow chart of a page operation method of a shared cluster database provided in Example 5 of the present application. Figure 5As shown, in the above step S303, according to the local log sequence number, whether the log corresponding to the data block page with the identification is written to the disk is detected, if it is detected that it has been written to the disk, the modification operation is performed, and if it is detected that it has not been written to the disk, the modification operation is not performed, which may include the following steps:
[0079] Step S501, compare the local log sequence number with the log sequence number identified in the identified data block page. If the local log sequence number is greater than or equal to the log sequence number identified in the identified data block page, it is determined that the log corresponding to the identified data block page has been written to the disk, and a modification operation is performed.
[0080] Step S502: If the local log sequence number is smaller than the log sequence number identified in the data block page with the identifier, it is determined that the log corresponding to the data block page with the identifier has not been written to the disk, and the modification operation is not performed.
[0081] For example, if the local log sequence number of the first database instance locally saved in the second database instance is 1000, that is, the latest log sequence number of the first database instance written to the disk is 1000, and the log sequence number of the corresponding log identified in the identified data block page is 900, then a comparison is performed, and it can be seen that the local log sequence number 1000 is greater than the log sequence number 900 identified in the identified data block page, then it is determined that the log corresponding to the identified data block page has been written to the disk, and the modification operation can be performed; if the log sequence number of the corresponding log identified in the identified data block page is 1100, then it can be seen that the local log sequence number 1000 is less than the log sequence number 1100 identified in the identified data block page, then it is determined that the log corresponding to the identified data block page has not been written to the disk, and the modification operation is not performed.
[0082] In an embodiment of the present application, by comparing the local log sequence number with the log sequence number identified in the identified data block page, if the local log sequence number is greater than or equal to the log sequence number identified in the identified data block page, it is determined that the log corresponding to the identified data block page has been written to the disk, and a modification operation is performed; if the local log sequence number is less than the log sequence number identified in the identified data block page, it is determined that the log corresponding to the identified data block page has not been written to the disk, and the modification operation is not performed, thereby implementing disk verification of the log corresponding to the received identified data block page, solving the problem of data loss in fault scenarios, and ensuring data consistency after database instance failure recovery.
[0083] Corresponding to the page transmission method of the shared cluster database in the above embodiment, Figure 6 The structure block diagram of the page transmission device of the shared cluster database provided by the sixth embodiment of the present application is shown, and the page transmission device is applied to the first database instance in the shared cluster database. For the convenience of description, only the part related to the embodiment of the present application is shown.
[0084] See also Figure 6 , the page transmission device comprises:
[0085] A page determination module 61 is used to determine a data block page corresponding to a page request when a page request sent by a second database instance in the shared cluster database is obtained;
[0086] The page sending module 62 is used to obtain the disk-written status of the rollback log of the data block page, mark the data block page according to the disk-written status, obtain the marked data block page, and send the marked data block page to the second database instance;
[0087] The disk flushing module 63 is used to flush the rollback log if the disk flushing status is not flushed, and after the rollback log flushing is completed, update the current log sequence number to obtain the update log sequence number;
[0088] The broadcast module 64 is used to broadcast the update log sequence number to the second database instance. After receiving the update log sequence number, the second database instance updates the local log sequence number to decide whether to perform the operation on the marked data block page according to the local log sequence number.
[0089] Optionally, the page sending module 62 includes:
[0090] A second sequence number obtaining unit, used to obtain a log sequence number of a rollback log of the data block page;
[0091] The identification unit is used to identify the data page according to the disk-falling state and the log sequence number of the rollback log of the data block page to obtain the identified data page.
[0092] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0093] Corresponding to the page operation method of the shared cluster database in the above embodiment, Figure 7 The structure block diagram of the page operation device of the shared cluster database provided by the seventh embodiment of the present application is shown, and the page operation device is applied to the second database instance in the shared cluster database. For the convenience of description, only the part related to the embodiment of the present application is shown.
[0094] See also Figure 7 , the page operation device includes:
[0095] A page acquisition module 71 is used for acquiring a data block page with an identifier corresponding to the page request fed back by the first database instance after sending a page request to the first database instance in the shared cluster database;
[0096] A first serial number acquisition module 72 is configured to acquire a local log serial number when performing a modification operation on the identified data block page, if the identifier in the identified data block page indicates that the log corresponding to the identified data block page has not been written to the disk, and the second database instance is configured to update the local log serial number using the update log serial number after receiving the update log serial number broadcasted by the first database instance;
[0097] The disk verification module 73 is used to detect whether the log corresponding to the identified data block page is stored on the disk according to the local log sequence number. If it is detected that it has been stored on the disk, the modification operation is performed; if it is detected that it has not been stored on the disk, the modification operation is not performed.
[0098] Optionally, the page operation device further includes:
[0099] A mapping table acquisition module, used to acquire a sequence number mapping table in the second database instance, wherein the sequence number mapping table is used to record a mapping relationship between any database instance in the shared cluster database and its local log sequence number;
[0100] An updating module, configured to update a local log sequence number corresponding to the first database instance in the sequence number mapping table using the received update log sequence number broadcasted by the first database instance;
[0101] The third sequence number acquisition module is used for acquiring the local log sequence number, including: acquiring the local log sequence number corresponding to the first database instance from the sequence number mapping table.
[0102] Optionally, the above-mentioned disk landing verification module 73 includes:
[0103] A first verification unit is used to compare the local log sequence number with the log sequence number identified in the data block page with identification, and if the local log sequence number is greater than or equal to the log sequence number identified in the data block page with identification, it is determined that the log corresponding to the data block page with identification has been written to the disk, and the modification operation is performed;
[0104] The second verification unit is used to determine that the log corresponding to the data block page with the identification is not written to the disk and not perform the modification operation if the local log sequence number is smaller than the log sequence number identified in the data block page with the identification.
[0105] Optionally, the page operation device further includes:
[0106] The notification sending module is used to send a disk write notification to the first database instance to instruct the first database instance to execute a disk write operation on the log corresponding to the identified data block page according to the disk write notification.
[0107] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0108] Figure 8 This is a schematic diagram of the structure of a computer device provided in Example 8 of the present application. Figure 8 As shown, the computer device of this embodiment includes: at least one processor ( Figure 8 Only one is shown), a memory, and a computer program stored in the memory and executable on at least one processor. When the processor executes the computer program, the steps in any of the above-mentioned embodiments of the page transmission method for the shared cluster database are implemented, or the steps in any of the above-mentioned embodiments of the page operation method for the shared cluster database are implemented.
[0109] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 8 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0110] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0111] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of an operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments may also be an external storage device of a computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on a computer device. Further, the memory may also include both an internal storage unit of a computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of computer programs, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0112] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiment when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0113] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.
[0114] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0115] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0116] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0117] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0118] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A page transmission method for a shared cluster database, It is characterized in that The page transmission method is applied to a first database instance in the shared cluster database, comprising: When a page request sent by a second database instance in the shared cluster database is obtained, determining a data block page corresponding to the page request; Obtaining the disk-written status of the rollback log of the data block page, marking the data block page according to the disk-written status, obtaining the marked data block page, and sending the marked data block page to the second database instance; If the disk-stacked state is not stacked, the rollback log is flushed, and after the rollback log is flushed, the current log sequence number is updated to obtain the update log sequence number; The update log sequence number is broadcast to the second database instance. After receiving the update log sequence number, the second database instance updates the local log sequence number to decide whether to perform an operation on the identified data block page according to the local log sequence number.
2. The page transmission method of the shared cluster database according to claim 1, It is characterized in that The step of marking the data block page according to the disk-stacked state to obtain the marked data block page includes: Obtaining the log sequence number of the rollback log of the data block page; The data page is identified according to the disk-written state and the log sequence number of the rollback log of the data block page to obtain the identified data page.
3. A page operation method for a shared cluster database, It is characterized in that The page operation method is applied to the second database instance in the shared cluster database, and includes: After sending a page request to a first database instance in the shared cluster database, obtaining a data block page with an identifier corresponding to the page request fed back by the first database instance; When performing a modification operation on the data block page with an identifier, if the identifier in the data block page with an identifier indicates that the log corresponding to the data block page with an identifier has not been written to the disk, a local log sequence number is obtained, and the second database instance is used to update the local log sequence number using the update log sequence number after receiving the update log sequence number broadcasted by the first database instance; According to the local log sequence number, it is detected whether the log corresponding to the identified data block page is written to the disk. If it is detected that it is written to the disk, the modification operation is performed; if it is detected that it is not written to the disk, the modification operation is not performed.
4. The page operation method of the shared cluster database according to claim 3, It is characterized in that The page operation method also includes: Obtaining a sequence number mapping table in the second database instance, wherein the sequence number mapping table is used to record a mapping relationship between any database instance in the shared cluster database and its local log sequence number; Using the received update log sequence number broadcasted by the first database instance, updating the local log sequence number corresponding to the first database instance in the sequence number mapping table; The obtaining of the local log sequence number includes: Obtain a local log sequence number corresponding to the first database instance from the sequence number mapping table.
5. The page operation method of the shared cluster database according to claim 3, It is characterized in that The step of detecting whether the log corresponding to the identified data block page is written to disk according to the local log sequence number, and executing the modification operation if it is detected that the log has been written to disk, and not executing the modification operation if it is detected that the log has not been written to disk, includes: Compare the local log sequence number with the log sequence number identified in the data block page with the identifier, and if the local log sequence number is greater than or equal to the log sequence number identified in the data block page with the identifier, determine that the log corresponding to the data block page with the identifier has been written to the disk, and perform the modification operation; If the local log sequence number is smaller than the log sequence number identified in the data block page with the identifier, it is determined that the log corresponding to the data block page with the identifier has not been written to the disk, and the modification operation is not performed.
6. The page operation method of the shared cluster database according to claim 3, It is characterized in that After not performing the modification operation if it is detected that the data has not been written to the disk, the page operation method further includes: A write-to-disk notification is sent to the first database instance to instruct the first database instance to execute a write-to-disk operation on the log corresponding to the identified data block page according to the write-to-disk notification.
7. A page transmission device for a shared cluster database, It is characterized in that The page transmission device is applied to a first database instance in the shared cluster database, and includes: A page determination module, configured to determine a data block page corresponding to a page request when a page request sent by a second database instance in the shared cluster database is obtained; a page sending module, configured to obtain the disk-written status of the rollback log of the data block page, mark the data block page according to the disk-written status, obtain the marked data block page, and send the marked data block page to the second database instance; A disk flushing module is used for flushing the rollback log if the disk-falling state is not flushed, and after the rollback log is flushed, updating the current log sequence number to obtain the update log sequence number; The broadcast module is used to broadcast the update log sequence number to the second database instance. After receiving the update log sequence number, the second database instance updates the local log sequence number to decide whether to perform an operation on the data block page based on the local log sequence number.
8. A page operation device for a shared cluster database, It is characterized in that The page operation device is applied to the second database instance in the shared cluster database, and includes: A page acquisition module, configured to, after sending a page request to a first database instance in the shared cluster database, acquire a data block page with an identifier corresponding to the page request fed back by the first database instance; A first sequence number acquisition module is used to acquire a local log sequence number when performing a modification operation on the identified data block page, if the identifier in the identified data block page indicates that the log corresponding to the identified data block page has not been written to the disk, and the second database instance is used to update the local log sequence number using the update log sequence number after receiving the update log sequence number broadcasted by the first database instance; The disk verification module is used to detect whether the log corresponding to the identified data block page is written to the disk according to the local log sequence number. If it is detected that it has been written to the disk, the modification operation is performed; if it is detected that it has not been written to the disk, the modification operation is not performed.
9. A computer device, It is characterized in that The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the page transmission method of the shared cluster database as described in any one of claims 1 to 2 or the page operation method of the shared cluster database as described in any one of claims 3 to 6 is implemented.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the page transmission method of the shared cluster database according to any one of claims 1 to 2 or the page operation method of the shared cluster database according to any one of claims 3 to 6 is implemented.
Citation Information
Patent Citations
Data processing method and device for shared storage database, equipment and medium
CN111046024A
Transaction processing method and device, server, database management system and medium
CN113377502A
Consistent read queries from a secondary compute node
US20200050692A1
Cited By
Cold and hot data separation method and device
CN119415526A
