A page full-text index recovery method, device, storage medium and electronic equipment
By generating update logs with additional safe reclamation boundaries and performing replay operations in the standby database, and calculating the global reclamation water level, the problems of unordered replay and premature reclamation of old segment page chains in page-based full-text indexes in primary-standby high-availability clusters are solved, thus achieving continuous availability and reliability of the index.
Patent Information
- Application Number
- CN202611015397.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-11-06
AI Technical Summary
In existing technologies for master-slave high-availability clusters, when page-based full-text indexes rely on logs for master-slave replication and fault recovery, there are problems such as unordered replay of segmented indexes, premature recycling of old segment page chains, and index inconsistency after failover, which lead to abnormal index queries and service unavailability.
By generating update logs with additional safe reclamation boundaries, replay operations are performed in the backup database using replay rules for different log categories. The global reclamation level is calculated based on the replay confirmation points to ensure that physical page release is performed when the global reclamation level is greater than the safe reclamation boundary, thus restoring the paged full-text index.
It resolves index anomalies caused by out-of-order replay, prevents old segment pages from being released prematurely, ensures the continued availability of the index after failover, and improves the reliability of the database full-text index.
Smart Images

Figure CN123048530A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database page-based full-text index recovery technology, and particularly to a page-based full-text index recovery method, apparatus, storage medium, and electronic device. Background Technology
[0002] With the increasing demand for built-in full-text search in databases, incorporating inverted indexes and segmented indexes into the database's page-based storage kernel has become the mainstream approach. In master-slave high-availability clusters, page-based full-text indexes rely on log files for master-slave replication and fault recovery. Existing technologies have the following unresolved technical defects: 1. General log replication is unaware of segmented index semantics: Existing solutions treat index changes as ordinary data page modifications, failing to design segment-level atomic operation logs for segment creation, replacement, and merging, and also failing to specify the replay order in the standby database. This easily leads to "segments becoming visible before pages are restored," resulting in abnormal index queries. 2. Old segment page chains are easily prematurely reclaimed under asynchronous replication: The master database only determines reclamation based on local commit points, without considering the replay lag in the standby database. After old segment pages are physically released, if the master database fails or the standby database is promoted, the new master database's segment metadata still references the released pages, causing index page chains to break and service unavailability. Traditional database replication slots only protect log files and cannot protect the physical page chain of the index, thus failing to solve this problem. 3. Lack of index-specific consistency verification during failover: The existing failover process only verifies the general data dictionary, without verifying the index segment hierarchy, candidate status for recycling, or segment version continuity. This can easily lead to hidden damage after failover, requiring index rebuilding and severely impacting business continuity. Summary of the Invention
[0003] In view of this, the present invention provides a page-based full-text index recovery method, apparatus, storage medium, and electronic device, the main purpose of which is to solve the problems of disordered replay, premature recycling of old pages, and index inconsistency after switching in the current page-based segmented full-text index master-slave replication.
[0004] To address the aforementioned problems, this application provides a page-based full-text index recovery method, comprising: In response to receiving an update operation for the segmented full-text index, the main database generates an update log for the segmented full-text index based on the segment update content, and the update log carries an additional safe reclamation boundary. At least one backup database is used to replay the update logs based on replay rules corresponding to different log categories, and the replay confirmation points after the replay operation are recorded. The master database calculates the global recovery level based on the replay confirmation points received from each of the backup databases; When the global reclamation level is greater than or equal to the additional safe reclamation boundary, a physical page release operation is performed to restore the page-based full-text index.
[0005] Optionally, in response to receiving an update operation for the segmented full-text index, the main database generates an update log for the segmented full-text index based on the page update content, specifically including: In response to receiving an update operation for the segmented full-text index, the main database writes the segment update content to a predetermined storage area and generates a first type of log record and a first log sequence number corresponding to the first type of log record; Based on the segment update content, the original segment data of the segment metadata chain in the metadata page storage area is replaced by the element replacement method to generate a second type of log record and a second log sequence number corresponding to the second type of log record; The original segment data is stored in the recycling candidate chain of the metadata page storage area to generate a third type of log record and the additional safe recycling boundary corresponding to the third type of log record; The update log includes the first type of log records, the second type of log records, and the third type of log records.
[0006] Optionally, the step of using at least one backup database to replay the update logs based on replay rules corresponding to different log categories specifically includes: Determine the log type of the update log and obtain the determination result; When the judgment result indicates that the log type is the first type of log record, the segment data page chain content is restored; When the determination result indicates that the log type is the second type of log record, the local segment metadata directory of the backup database is updated; When the judgment result indicates that the log type is a third type of log record, the original segment data of the segment metadata chain in the metadata page storage area is written into the local reclamation candidate set of the backup database and the additional safe reclamation boundary is recorded.
[0007] Optionally, the master database calculates the global recovery level based on the replay confirmation points received from each of the backup databases, specifically including: The replay confirmation sites of each of the backup databases are compared, and the smallest replay confirmation site among the replay confirmation sites is determined as the global recovery level.
[0008] Optionally, the method further includes: In response to the target backup database being upgraded to a new primary database, the replay completed segment metadata version, the local reclamation candidate chain, and the replay confirmation point of the new primary database are read. The verification results are obtained by verifying the segment metadata version, the local recycling candidate chain of the new master database, and the replay confirmation point; When the verification result does not meet any of the multi-dimensional preset verification conditions, it is determined that the new master database switch has failed, and the index in the new master database is marked as unavailable. When the verification result meets the multi-dimensional preset verification conditions, it is determined that the switch to the new master database is successful, and an available index view of the new master database is constructed to provide index services.
[0009] Optionally, the multi-dimensional preset verification conditions include: Verify the page chain integrity of each segment in the currently visible segment set in the new master database; Verify that the candidate segments for recycling in the new main library can still be located in the page space, or verify that the candidate segments for recycling meet the recycling conditions. Verify that the old segments prior to the most recent atomic switch in the new master library have not been reclaimed out of bounds; Verify the consistency between the set of visible segments in the new master database and the submitted index version.
[0010] Optionally, if the primary database fails before the original segment data has been physically reclaimed, and the target standby database is upgraded to a new primary database, the method further includes, after confirming that the switchover to the new primary database was successful, the method: Obtain the current first additional security reclamation boundary of the new primary database and obtain the current first global reclamation level of the primary database; If the current first additional safe reclamation boundary is less than the current first global reclamation level and the original segment data page chain is found to be intact and located in the reclamation candidate chain when the new master database verification is used, the original segment data will be retained as a historical reserved segment and reclamation will not be performed. When the current first additional safety recycling boundary is greater than or equal to the current first global recycling level, the original segment data is retained in the recycling candidate chain and recycling is not performed; After the new primary database is built and the available index view is constructed, the new primary database calculates the current second global reclamation level based on the current second additional safety reclamation boundary of each backup database. When the current second global recovery level is greater than or equal to the current second additional safe recovery boundary, a physical page release operation is performed.
[0011] To address the aforementioned problems, this application provides a page-based full-text index recovery device, comprising: The generation module is used to respond to the received update operation of the segmented full-text index. The main database generates an update log of the segmented full-text index based on the segment update content. The update log carries an additional safe reclamation boundary. The replay module is used to replay the update log using at least one backup database based on replay rules corresponding to different log categories and record the replay confirmation points after the replay operation. The calculation module is used by the main database to calculate the global recovery water level based on the replay confirmation points received from each of the backup databases; The recovery module is used to perform a physical page release operation to restore the paged full-text index when the global reclamation level is greater than or equal to the additional safe reclamation boundary.
[0012] To address the aforementioned problems, this application provides a storage medium storing a computer program that, when executed by a processor, implements the steps of the page-based full-text index recovery method described above.
[0013] To address the aforementioned problems, this application provides an electronic device, comprising at least a memory and a processor. The memory stores a computer program, and the processor, when executing the computer program in the memory, implements the steps of the page-based full-text index recovery method described above.
[0014] The beneficial effects of this application are as follows: This application achieves deep adaptation between segmented indexes and the log mechanism, resolving index anomalies caused by out-of-order replay. Through safe reclamation boundaries and global watermarks, it completely avoids the premature release of old segment pages under asynchronous replication. No index rebuilding is required after failover, ensuring continuous index availability in high-availability scenarios. It achieves safe decoupling of segment logical deletion and physical reclamation, significantly improving the reliability of full-text indexing in the database.
[0015] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0016] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A flowchart illustrating a page-based full-text index recovery method provided in an embodiment of this application is shown. Figure 2 A flowchart illustrating a page-based full-text index recovery method according to another embodiment of this application is shown; Figure 3 A structural block diagram of a page-based full-text index recovery device according to another embodiment of this application is shown. Detailed Implementation
[0017] Various embodiments and features of this application are described herein with reference to the accompanying drawings.
[0018] It should be understood that various modifications can be made to the embodiments described herein. Therefore, the above description should not be considered as limiting, but merely as an example of embodiments. Other modifications within the scope and spirit of this application will be apparent to those skilled in the art.
[0019] The accompanying drawings, which are included in and form part of this specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.
[0020] These and other features of this application will become apparent from the following description of preferred forms of embodiments given as non-limiting examples, with reference to the accompanying drawings.
[0021] It should also be understood that although this application has been described with reference to some specific examples, those skilled in the art can certainly implement many other equivalent forms of this application.
[0022] The above and other aspects, features and advantages of this application will become more apparent when taken in conjunction with the accompanying drawings and in view of the following detailed description.
[0023] Specific embodiments of this application are described thereafter with reference to the accompanying drawings; however, it should be understood that the claimed embodiments are merely examples of this application, which may be implemented in various ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that would obscure this application. Therefore, the specific structural and functional details claimed herein are not intended to be limiting, but merely to teach those skilled in the art to use this application in a variety of substantially any suitable detailed structures.
[0024] This specification may use the phrases “in one embodiment,” “in another embodiment,” “in yet another embodiment,” or “in other embodiments,” all of which may refer to one or more of the same or different embodiments according to this application.
[0025] This application provides a page-based full-text index recovery method, such as... Figure 1 As shown, it includes: Step S101: In response to receiving an update operation of the segmented full-text index, the main database generates an update log of the segmented full-text index based on the segment update content, and the update log carries an additional safe reclamation boundary; In this step, the main database generates three types of log records in a fixed order for updates to the segmented full-text index, with the log sequence numbers of these three types of log records strictly increasing: the first type records changes to the segment data page chain, the second type records atomic switching of segment visibility, and the third type registers the old segment to be replaced in the recycling candidate structure and binds it to the safe recycling log sequence number boundary. Specifically, in response to receiving an update operation of the segmented full-text index, the main database writes the segment update content to a predetermined storage area, generating the first type of log record and a first log sequence number corresponding to the first type of log record; based on the segment update content, the original segment data in the segment metadata chain of the metadata page storage area is replaced using a sub-substitution method, generating the second type of log record and a second log sequence number corresponding to the second type of log record; the original segment data is stored in the recycling candidate chain of the metadata page storage area, generating the third type of log record and the safe recycling boundary corresponding to the third type of log record; wherein, the update log includes the first type of log record, the second type of log record, and the third type of log record. The segment update includes generating new segments and generating incremental segment data. The first type of log record represents a change in page content; the second type of log record represents a segment visibility switch; and the third type of log record represents the original segment data being moved into the recycling candidate chain. The log sequence numbers of the three types of logs maintain a strict order: first type log sequence number < second type log sequence number < third type log sequence number. Each time a recycling record is generated, a corresponding log sequence number code is generated.
[0026] Step S102: Use at least one backup database to replay the update log based on the replay rules corresponding to different log categories and record the replay confirmation points after the replay operation; In this step, the log type of the update log is determined to obtain a determination result. When the determination result indicates that the log type is a first type of log record, the segment data page chain content is restored. When the determination result indicates that the log type is a second type of log record, the local segment metadata directory of the backup database is updated. When the determination result indicates that the log type is a third type of log record, the original segment data of the segment metadata chain in the metadata page storage area is written into the local reclamation candidate set of the backup database and the safe reclamation boundary is recorded.
[0027] Step S103: The main database calculates the global recovery water level based on the replay confirmation points received from each of the backup databases; In the specific implementation process of this step, the replay confirmation sites of each backup database are compared, and the smallest replay confirmation site among the replay confirmation sites is determined as the global recovery water level.
[0028] Step S104: When the global recycling level is greater than or equal to the additional safe recycling boundary, perform a physical page release operation to restore the page-based full-text index.
[0029] In the specific implementation process of this step, the replay confirmation points of all backup database nodes are collected, the global recovery water level is calculated, and the global recovery water level is the minimum value among the replay confirmation points. It can also be calculated in combination with the local submission points of the master database. The recovery candidate chain is scanned, and physical page release is performed on segments whose safe recovery boundary is less than or equal to the global recovery water level in order to restore the page-based full-text index.
[0030] This application achieves deep integration of segmented indexing with the logging mechanism, resolving index anomalies caused by out-of-order replay. Through safe reclamation boundaries and global watermarks, it completely prevents the premature release of old segment pages under asynchronous replication. No index rebuilding is required after failover, ensuring continuous index availability in high-availability scenarios. It achieves safe decoupling of logical segment deletion and physical reclamation, significantly improving the reliability of full-text indexing in the database.
[0031] Another embodiment of this application provides a different page-based full-text index recovery method, applicable to scenarios such as inverted full-text indexes, BM25 indexes, dictionary column retrieval indexes, or segmented retrieval indexes containing column-based auxiliary structures, etc. Figure 2 As shown, it includes: Step S201: In response to receiving an update operation of the segmented full-text index, the main database writes the segment update content to a predetermined storage area and generates a first type of log record and a first log sequence number corresponding to the first type of log record; In this step, in response to receiving an update operation for the segmented full-text index, the main database writes the segment update content to a predetermined storage area, generating a first type of log record and a first log sequence number corresponding to the first type of log record. The first type of log record includes at least one of the following: a full-page mirror of the new page, incremental write information of the segment page chain, the page chain entry page number, and the file component identifier within the segment. For the index initialization process, a set of new pages is first written, and then the full-text index initialization is completed using a combination of batch page mirror logs and segment metadata switching logs. Physical release of old version segments is not allowed before initialization is complete.
[0032] Step S202: Based on the segment update content, the original segment data of the segment metadata chain in the metadata page storage area is replaced by the element replacement method to generate a second type of log record and a second log sequence number corresponding to the second type of log record; In this step, each segment description item in the segment metadata must include at least a segment identifier, page chain entry, version boundary, deletion status, and reclamation status. The second type of log record must include at least: a new visible segment set identifier, an old segment set identifier, an atomic switch sequence number, and the corresponding commit transaction identifier or commit log sequence number. For the segment merging process, the merged new segment is first generated and the page chain is persisted. Then, the old segment to be replaced is added to the reclamation candidate structure. Physical page reclamation is performed after the global reclamation watermark condition is met.
[0033] Step S203: Store the original segment data into the recycling candidate chain of the metadata page storage area, and generate a third type of log record and the additional safe recycling boundary corresponding to the third type of log record; In the specific implementation of this step, the third type of log record shall include at least: the segment identifier entering the reclamation candidate set, the corresponding page chain entry, the additional safe reclamation boundary, the reason for the reclamation delay, or the unconfirmed status of the replica. The additional safe reclamation boundary shall at least include the log sequence number when the primary database generated the reclamation registration, or include a combination of the log sequence number and the confirmation points of all standby database nodes.
[0034] Step S204: Use at least one backup database to replay the update log based on the replay rules corresponding to different log categories and record the additional safe reclamation boundary after the replay operation; In this step, the log type of the update log is determined, and a determination result is obtained. When the determination result is that the log type is a first type of log record, the segment data page chain content is restored. When the determination result is that the log type is a second type of log record, the local segment metadata directory of the backup database is updated. When the determination result is that the log type is a third type of log record, the original segment data of the segment metadata chain in the metadata page storage area is written into the local reclamation candidate set of the backup database and the additional safe reclamation boundary is recorded.
[0035] Step S205: The master database calculates the global recovery level based on the additional security recovery boundaries received from each of the backup databases; In this step, the replay confirmation points of each backup database are compared, and the smallest replay confirmation point among them is determined as the global recovery level. The global recovery level is then adjusted using one or more of the following: the primary database local commit point, replication slot status, and synchronous replication confirmation status.
[0036] Step S206: When the global recycling level is greater than or equal to the safe recycling boundary, perform a physical page release operation to restore the page-based full-text index; In the specific implementation process of this step, the replay confirmation points of all backup database nodes are collected, the global recovery water level is calculated, and the global recovery water level is the minimum value among the replay confirmation points. It can also be calculated in combination with the local submission points of the master database. The recovery candidate chain is scanned, and physical page release is performed on segments whose safe recovery boundary is less than or equal to the global recovery water level in order to restore the page-based full-text index.
[0037] Step S207: In response to the target standby database being upgraded to a new primary database, read the replay completed segment metadata version of the new primary database, the local reclamation candidate chain of the new primary database, and the replay confirmation point; In the specific implementation process, in response to the target backup database being upgraded to a new primary database, this step reads the replay completed segment metadata version of the new primary database, the local recycling candidate chain of the new primary database, and the replay confirmation point.
[0038] Step S208: Verify based on the segment metadata version, the local recycling candidate chain of the new master database, and the replay confirmation point to obtain the verification result; In the specific implementation of this step, the multi-dimensional preset verification conditions include: verifying the page chain integrity of each segment in the currently visible segment set in the new master database; verifying that the candidate segments for reclamation in the new master database can still be located in the page space or verifying that the candidate segments for reclamation have met the reclamation conditions; verifying that the old segments before the most recent atomic switch in the new master database have not been reclaimed out of bounds; and verifying the consistency between the visible segment set in the new master database and the submitted index version.
[0039] Step S209: When the verification result does not meet any of the multi-dimensional preset verification conditions, it is determined that the new master database switchover has failed, and the indexes in the new master database are marked as unavailable. In the specific implementation of this step, if the verification result does not meet any of the following conditions: page chain integrity, reclamation conditions, old segments before the most recent atomic switch not being reclaimed out of bounds, or consistency between the set of visible segments in the new master database and the committed index version, the new master database switch is determined to have failed, and the indexes in the new master database are marked as unavailable.
[0040] Step S210: When the verification result meets the multi-dimensional preset verification conditions, it is determined that the new master database switch is successful, and a new master database available index view is constructed to provide index services.
[0041] In the specific implementation process of this step, when the verification result meets the multi-dimensional preset verification conditions of page chain integrity, reclamation conditions, old segments before the most recent atomic switch not being reclaimed out of bounds, and consistency between the set of visible segments in the new master database and the submitted index version, it is determined that the switch to the new master database is successful, and a usable index view of the new master database is constructed to provide index services. When the primary database fails before the original segment data has been physically reclaimed, the target backup database is upgraded to a new primary database. The current first additional safe reclamation boundary of the new primary database and the current first global reclamation level of the primary database are obtained. If the current first additional safe reclamation boundary is less than the current first global reclamation level, and the original segment data page chain is found to be intact and located in the reclamation candidate chain when verified by the new primary database, the original segment data is retained as a historical retention segment and reclamation is not performed. If the current first additional safe reclamation boundary is greater than or equal to the current first global reclamation level, the original segment data is retained in the reclamation candidate chain and reclamation is not performed. During query execution, the segment metadata structure and reclamation candidate structure are jointly parsed based on transaction snapshots or failover recovery snapshots to determine the current readable segment set. When it is detected that the current query falls within the failover window period, if a historical segment has not yet met the reclamation conditions, it is allowed to participate in the query as a read-only rollback segment. The reclamation candidate structure is implemented using a linked list, an array of page directories, a tree directory, or a combination thereof. The safe reclamation boundary is a single log sequence number, a composite log boundary, or a version boundary calculated based on the replica confirmation status. After the new primary database is built into an available index view, the new primary database calculates the current second global reclamation level based on the current second additional security reclamation boundary of each backup database; when the current second global reclamation level is greater than or equal to the current second additional security reclamation boundary, a physical page release operation is performed.
[0042] This application achieves deep integration of segmented indexing with the logging mechanism, resolving index anomalies caused by out-of-order replay. Through safe reclamation boundaries and global watermarks, it completely prevents the premature release of old segment pages under asynchronous replication. No index rebuilding is required after failover, ensuring continuous index availability in high-availability scenarios. It achieves safe decoupling of logical segment deletion and physical reclamation, significantly improving the reliability of full-text indexing in the database.
[0043] Another embodiment of this application provides a page-based full-text index recovery device 300, such as... Figure 3 As shown, it includes: The generation module 301 is used to respond to the received update operation of the segmented full-text index, and the main database generates an update log of the segmented full-text index according to the segment update content. The update log carries a safe reclamation boundary. The replay module 302 is used to replay the update log using at least one backup database based on the replay rules corresponding to different log categories and record the additional safe reclamation boundary after the replay operation. Calculation module 303 is used by the main database to calculate the global recovery level based on the additional safe recovery boundaries received from each of the backup databases; The recovery module 304 is used to perform a physical page release operation to restore the page-based full-text index when the global recycling level is greater than or equal to the safe recycling boundary.
[0044] In specific implementation, the generation module 301 is specifically used to: respond to receiving an update operation of the segmented full-text index; write the segment update content into a predetermined storage area, generating a first type of log record and a first log sequence number corresponding to the first type of log record; replace the original segment data of the segment metadata chain in the metadata page storage area with the original segment data based on the segment update content using a sub-substitution method, generating a second type of log record and a second log sequence number corresponding to the second type of log record; store the original segment data into the recycling candidate chain in the metadata page storage area, generating a third type of log record and the additional safe recycling boundary corresponding to the third type of log record; wherein, the update log includes the first type of log record, the second type of log record, and the third type of log record.
[0045] In specific implementation, the replay module 302 is used to determine the log type of the update log and obtain a determination result; when the determination result is that the log type is a first type of log record, the segment data page chain content is restored; when the determination result is that the log type is a second type of log record, the local segment metadata directory of the backup database is updated; when the determination result is that the log type is a third type of log record, the original segment data of the segment metadata chain in the metadata page storage area is written into the local reclamation candidate set of the backup database and the additional safe reclamation boundary is recorded.
[0046] In the specific implementation process, the calculation module 303 is specifically used to compare the replay confirmation sites of each of the backup databases, and determine the smallest replay confirmation site among the replay confirmation sites as the global recovery water level.
[0047] In specific implementation, the device further includes a verification module. This verification module is specifically used to, in response to the target backup database being upgraded to a new primary database, read the replayed segment metadata version of the new primary database, the local reclamation candidate chain of the new primary database, and the replay confirmation point; perform verification based on the segment metadata version, the local reclamation candidate chain of the new primary database, and the replay confirmation point to obtain a verification result; when the verification result does not meet any of the multi-dimensional preset verification conditions, it is determined that the new primary database switchover has failed, and the indexes in the new primary database are marked as unavailable; when the verification result meets the multi-dimensional preset verification conditions, it is determined that the new primary database switchover has succeeded, and a view of available indexes in the new primary database is constructed to provide index services.
[0048] In the specific implementation process, the verification module is also used to verify the page chain integrity of each segment in the currently visible segment set in the new master database; verify that the candidate segments for reclamation in the new master database can still be located in the page space or verify that the candidate segments for reclamation have met the reclamation conditions; verify that the old segments before the most recent atomic switch in the new master database have not been reclaimed out of bounds; and verify the consistency between the visible segment set in the new master database and the submitted index version.
[0049] In specific implementation, the device further includes a failover module, which is specifically used to obtain the current first additional security reclamation boundary of the new primary database and the current first global reclamation level of the primary database; if the current first additional security reclamation boundary is less than the current first global reclamation level and the original segment data page chain is found to be intact and located in the reclamation candidate chain when the new primary database is used for verification, the original segment data is retained as a historical retention segment and reclamation is not performed; if the current first additional security reclamation boundary is greater than or equal to the current first global reclamation level, the original segment data is retained in the reclamation candidate chain and reclamation is not performed; after the new primary database is constructed with an available index view, the new primary database calculates the current second global reclamation level based on the current second additional security reclamation boundary of each backup database; if the current second global reclamation level is greater than or equal to the current second additional security reclamation boundary, a physical page release operation is performed.
[0050] This application achieves deep integration of segmented indexing with the logging mechanism, resolving index anomalies caused by out-of-order replay. Through safe reclamation boundaries and global watermarks, it completely prevents the premature release of old segment pages under asynchronous replication. No index rebuilding is required after failover, ensuring continuous index availability in high-availability scenarios. It achieves safe decoupling of logical segment deletion and physical reclamation, significantly improving the reliability of full-text indexing in the database.
[0051] Another embodiment of this application provides a storage medium storing a computer program, which, when executed by a processor, implements the following method steps: Step 1: In response to receiving an update operation for the segmented full-text index, the main database generates an update log for the segmented full-text index based on the segment update content. The update log carries an additional safe reclamation boundary. Step 2: Use at least one backup database to replay the update logs based on the replay rules corresponding to different log categories and record the replay confirmation points after the replay operation; Step 3: The main database calculates the global recovery water level based on the replay confirmation points received from each of the backup databases; Step 4: When the global recycling level is greater than or equal to the additional safe recycling boundary, perform a physical page release operation to restore the page-based full-text index.
[0052] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0053] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0054] For details on the implementation of the above methods and steps, please refer to the embodiments of the above arbitrary page full-text index recovery method. These embodiments will not be repeated here.
[0055] This application achieves deep integration of segmented indexing with the logging mechanism, resolving index anomalies caused by out-of-order replay. Through safe reclamation boundaries and global watermarks, it completely prevents the premature release of old segment pages under asynchronous replication. No index rebuilding is required after failover, ensuring continuous index availability in high-availability scenarios. It achieves safe decoupling of logical segment deletion and physical reclamation, significantly improving the reliability of full-text indexing in the database.
[0056] Another embodiment of this application provides an electronic device, which can be a server. The electronic device includes a processor, a memory, a network interface, and a database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the program is executed by the processor, it implements the functions or steps of a page-based full-text index recovery method on the server side.
[0057] In one embodiment, an electronic device is provided, which can be a client. The electronic device includes a processor, memory, a network interface, a display screen, and an input device connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with an external server via a network connection. When the program of the electronic device is executed by the processor, it implements the functions or steps of a page-based full-text index recovery method on the client side.
[0058] Another embodiment of this application provides an electronic device, including at least a memory and a processor. The memory stores a computer program, and the processor, when executing the computer program in the memory, performs the following method steps: Step 1: In response to receiving an update operation for the segmented full-text index, the main database generates an update log for the segmented full-text index based on the segment update content. The update log carries an additional safe reclamation boundary. Step 2: Use at least one backup database to replay the update logs based on the replay rules corresponding to different log categories and record the replay confirmation points after the replay operation; Step 3: The main database calculates the global recovery water level based on the replay confirmation points received from each of the backup databases; Step 4: When the global recycling level is greater than or equal to the additional safe recycling boundary, perform a physical page release operation to restore the page-based full-text index.
[0059] For details on the implementation of the above methods and steps, please refer to the embodiments of the above arbitrary page full-text index recovery method. These embodiments will not be repeated here.
[0060] This application achieves deep integration of segmented indexing with the logging mechanism, resolving index anomalies caused by out-of-order replay. Through safe reclamation boundaries and global watermarks, it completely prevents the premature release of old segment pages under asynchronous replication. No index rebuilding is required after failover, ensuring continuous index availability in high-availability scenarios. It achieves safe decoupling of logical segment deletion and physical reclamation, significantly improving the reliability of full-text indexing in the database.
[0061] The above embodiments are merely exemplary embodiments of this application and are not intended to limit this application. Those skilled in the art can make various modifications or equivalent substitutions to this application within the scope and nature of this application, and such modifications or equivalent substitutions should also be considered to fall within the scope of protection of this application.
Claims
1. A method for recovering a page-based full-text index, the method comprising: include: In response to receiving an update operation for the segmented full-text index, the main database generates an update log for the segmented full-text index based on the segment update content, and the update log carries an additional safe reclamation boundary. At least one backup database is used to replay the update logs based on replay rules corresponding to different log categories, and the replay confirmation points after the replay operation are recorded. The master database calculates the global recovery level based on the replay confirmation points received from each of the backup databases; When the global reclamation level is greater than or equal to the additional safe reclamation boundary, a physical page release operation is performed to restore the page-based full-text index.
2. The method of claim 1, wherein, In response to receiving an update operation for the segmented full-text index, the main database generates an update log for the segmented full-text index based on the page update content, specifically including: In response to receiving an update operation for the segmented full-text index, the main database writes the segment update content to a predetermined storage area and generates a first type of log record and a first log sequence number corresponding to the first type of log record; Based on the segment update content, the original segment data of the segment metadata chain in the metadata page storage area is replaced by the element replacement method to generate a second type of log record and a second log sequence number corresponding to the second type of log record; The original segment data is stored in the recycling candidate chain of the metadata page storage area to generate a third type of log record and the additional safe recycling boundary corresponding to the third type of log record; The update log includes the first type of log records, the second type of log records, and the third type of log records.
3. The method of claim 1, wherein, The step of replaying the update logs using at least one backup database based on replay rules corresponding to different log categories specifically includes: Determine the log type of the update log and obtain the determination result; When the judgment result indicates that the log type is the first type of log record, the segment data page chain content is restored; When the determination result indicates that the log type is the second type of log record, the local segment metadata directory of the backup database is updated; When the judgment result indicates that the log type is a third type of log record, the original segment data of the segment metadata chain in the metadata page storage area is written into the local reclamation candidate set of the backup database and the additional safe reclamation boundary is recorded.
4. The method of claim 1, wherein, The master database calculates the global recovery level based on the replay confirmation points received from each of the backup databases, specifically including: The replay confirmation sites of each of the backup databases are compared, and the smallest replay confirmation site among the replay confirmation sites is determined as the global recovery level.
5. The method of claim 1, wherein, The method further includes: In response to the target backup database being upgraded to a new primary database, the replay completed segment metadata version, the local reclamation candidate chain, and the replay confirmation point of the new primary database are read. The verification results are obtained by verifying the segment metadata version, the local recycling candidate chain of the new master database, and the replay confirmation point; When the verification result does not meet any of the multi-dimensional preset verification conditions, it is determined that the new master database switch has failed, and the index in the new master database is marked as unavailable. When the verification result meets the multi-dimensional preset verification conditions, it is determined that the switch to the new master database is successful, and an available index view of the new master database is constructed to provide index services.
6. The method of claim 5, wherein, The multi-dimensional preset verification conditions include: Verify the page chain integrity of each segment in the currently visible segment set in the new master database; Verify that the candidate segments for recycling in the new main library can still be located in the page space, or verify that the candidate segments for recycling meet the recycling conditions. Verify that the old segments prior to the most recent atomic switch in the new master library have not been reclaimed out of bounds; Verify the consistency between the set of visible segments in the new master database and the submitted index version.
7. The method of claim 5, wherein, When the primary database fails before the original segment data has been physically reclaimed, the target standby database is upgraded to the new primary database. After confirming that the switchover to the new primary database is successful, the method further includes: Obtain the current first additional security reclamation boundary of the new primary database and obtain the current first global reclamation level of the primary database; If the current first additional safe reclamation boundary is less than the current first global reclamation level and the original segment data page chain is found to be intact and located in the reclamation candidate chain when the new master database verification is used, the original segment data will be retained as a historical reserved segment and reclamation will not be performed. When the current first additional safety recycling boundary is greater than or equal to the current first global recycling level, the original segment data is retained in the recycling candidate chain and recycling is not performed; After the new primary database is built and the available index view is constructed, the new primary database calculates the current second global reclamation level based on the current second additional safety reclamation boundary of each backup database. When the current second global recovery level is greater than or equal to the current second additional safe recovery boundary, a physical page release operation is performed.
8. A page full-text index recovery apparatus, characterized by comprising: include: The generation module is used to respond to the received update operation of the segmented full-text index. The main database generates an update log of the segmented full-text index based on the segment update content. The update log carries a safe reclamation boundary. The replay module is used to replay the update logs using at least one backup database based on replay rules corresponding to different log categories and to record the additional safe reclamation boundary after the replay operation. The calculation module is used by the main database to calculate the global recovery level based on the additional safe recovery boundaries received from each of the backup databases; The recovery module is used to perform a physical page release operation to restore the page-based full-text index when the global recycling level is greater than or equal to the safe recycling boundary.
9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the page-based full-text index recovery method according to any one of claims 1-7.
10. An electronic device, characterized in that, It includes at least a memory and a processor, wherein the memory stores a computer program, and the processor, when executing the computer program in the memory, implements the steps of the page-based full-text index recovery method according to any one of claims 1-7.
