A database consistency checking method and device

By directly determining the check value based on the data length and location information of user data in the database, the problem of long database consistency verification time in existing technologies is solved, and the speed and system efficiency of database consistency verification are improved.

CN115952177BActive Publication Date: 2026-02-03CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211439548.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-17
Publication Date
2026-02-03
Estimated Expiration
2042-11-17

AI Technical Summary

Technical Problem

Existing technologies require a significant amount of time to perform consistency checks on the data in the heap table files stored in the primary and backup databases.

Method used

By directly determining the first and second check values ​​based on the data length and location information of each user data in the first and second databases, the extraction and multiple accesses of user data are avoided, and the consistency of the database is directly calculated.

Benefits of technology

It improves the speed of database consistency verification, reduces disk random read latency and frequent buffer pool eviction, and enhances the operating efficiency of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115952177B_ABST
    Figure CN115952177B_ABST
Patent Text Reader

Abstract

The application provides a database consistency verification method and device, relates to the field of data verification, and can effectively improve the rate of determining the consistency of a first database and a second database. The method comprises the following steps: determining a first verification value according to the data length of each user data in the first database and the position information of each user data in the corresponding page in the first database; determining a second verification value according to the data length of each user data in the second database and the position information of each user data in the corresponding page in the second database; and finally determining the consistency of the first database and the second database according to the first verification value and the second verification value. The embodiment of the application is used in the process of continuously verifying the consistency of the database.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data verification, in particular to a database consistency verification method and device. BACKGROUND

[0002] For a database system with high reliability requirements, in order to ensure the normal operation of the system, the database system adopts the mode of establishing two sets of master and backup databases. During the operation of the database system, the master database and the backup database need to be periodically or real-time synchronized. However, due to unstable network or time delay and other reasons, it is difficult to ensure the consistency of the master database and the backup database. Therefore, it is necessary to verify the consistency of the master database and the backup database.

[0003] At present, when verifying the consistency of the data stored in the heap table files of the master database and the backup database, the target row data is first extracted from the heap table files of the master database (or the backup database) according to the query statement, then the data verification value of the heap table files of the master database (or the backup database) is determined according to the verification values of the extracted row data, and finally the consistency of the data stored in the heap table files of the master database and the backup database is verified according to the determined data verification value of the heap table files of the master database and the data verification value of the heap table files of the backup database. This method needs to spend a lot of time in implementation. SUMMARY

[0004] In view of the fact that a lot of time is spent in the prior art when verifying the consistency of the data stored in the heap table files of the master database and the backup database, the present application provides a database consistency verification method and device, which can speed up the verification of the consistency of the master and backup databases.

[0005] To achieve the above-mentioned purpose, the present application adopts the following technical solutions:

[0006] In a first aspect, the present application provides a database consistency verification method, which comprises:

[0007] determining a first verification value according to the data length of each user data in the first database and the position information of each user data in the corresponding page in the first database; the first database comprises a plurality of pages.

[0008] determining a second verification value according to the data length of each user data in the second database and the position information of each user data in the corresponding page in the second database; the second database comprises a plurality of pages.

[0009] determining the consistency of the first database and the second database according to the first verification value and the second verification value.

[0010] According to the technical solution, the database consistency verification method provided by the embodiment of the application can determine the first verification value according to the data length of each user data in the first database and the position information of each user data in the corresponding page in the first database, determine the second verification value according to the data length of each user data in the second database and the position information of each user data in the corresponding page in the second database, and finally determine the consistency of the first database and the second database according to the first verification value and the second verification value. The first database and the second database each include multiple pages. Through the above method, the verification values of the first database and the second database, i.e., the first verification value and the second verification value, can be determined directly according to the data length of each user data and the position information of each user data in the corresponding page, without extracting the user data included in the first database and the second database and then calculating the verification values of the first database and the second database. Therefore, the rate of determining the consistency of the first database and the second database can be effectively improved.

[0011] Optionally, determining the first verification value according to the data length of each user data in the first database and the position information of each user data in the corresponding page in the first database includes:

[0012] Each page included in the first database is sequentially taken as a current page, and the following operations are performed until all the pages included in the first database are traversed:

[0013] From each user data included in the current page, a current user data is determined.

[0014] A user data verification value of the current user data is determined according to the data length of the current user data and the position information of the current user data in the current page until all the user data included in the current page is traversed.

[0015] After all the pages included in the first database are traversed, the first verification value is determined according to the determined multiple user data verification values.

[0016] Through the above method, when the current page is operated, the verification value of the current user data can be determined according to the data length of the current user data and the position information of the current user data in the current page until all the user data included in the current page is traversed. That is, only when the user data included in each page is traversed, the next page can be traversed, that is, each page only needs to be traversed once. Therefore, the page does not need to be accessed multiple times, effectively reducing the problem of increasing the disk random read delay.

[0017] Optionally, the current user data is determined from each user data included in the current page in the following manner:

[0018] sequentially taking each user data in the current page as the current user data.

[0019] Alternatively, sequentially taking multiple user data of a first type of data in the current page as the current user data; the first type of data refers to data whose contained data amount is less than or equal to a data amount threshold.

[0020] If all user data contained in the current page has not been traversed, sequentially taking multiple user data of a second type of data in the current page as the current user data; the second type of data refers to data whose contained data amount is greater than the data amount threshold.

[0021] Optionally, the data length of the current user data is obtained in the following manner:

[0022] If the current user data is of the first type of data, the data length of the current user data is determined according to the length of the current user data in the current page; the first type of data refers to data whose contained data amount is less than or equal to the data amount threshold.

[0023] If the current user data is of the second type of data, the current user data is found according to the index value of the current user data contained in the current page, and the data length of the current user data is determined; the second type of data refers to data whose contained data amount is greater than the data amount threshold.

[0024] Optionally, the position information of the current user data is determined in the following manner:

[0025] The position information of the first character in the current user data is taken as the position information of the current user data.

[0026] In a second aspect, the present application provides a database consistency verification device, which comprises:

[0027] A first determining unit is configured to determine a first verification value according to the data length of each user data in the first database and the position information of each user data in the corresponding page in the first database; the first database contains multiple pages.

[0028] A second determining unit is configured to determine a second verification value according to the data length of each user data in the second database and the position information of each user data in the corresponding page in the second database; the second database contains multiple pages.

[0029] A comparison unit is configured to determine the consistency of the first database and the second database according to the first verification value and the second verification value.

[0030] Optionally, the first determining unit is specifically configured to:

[0031] Each page contained in the first database is taken as a current page in turn, and the following operations are performed until all the pages contained in the first database are traversed:

[0032] From each user data contained in the current page, current user data is determined.

[0033] According to the data length of the current user data and the position information of the current user data in the current page, a user data check value of the current user data is determined until all the user data contained in the current page is traversed.

[0034] After all the pages contained in the first database are traversed, a first check value is determined according to the plurality of user data check values determined.

[0035] Optionally, the current user data is determined from each user data contained in the current page in the following manner:

[0036] Each user data in the current page is taken as the current user data in turn.

[0037] Alternatively, a plurality of user data of a first type of data in the current page is taken as the current user data in turn; the first type of data refers to data whose contained data amount is less than or equal to a data amount threshold.

[0038] If all the user data contained in the current page is not traversed, a plurality of user data of a second type of data in the current page is taken as the current user data in turn; the second type of data refers to data whose contained data amount is greater than the data amount threshold.

[0039] Optionally, the data length of the current user data is obtained in the following manner:

[0040] If the current user data is the first type of data, the data length of the current user data is determined according to the length of the current user data in the current page; the first type of data refers to data whose contained data amount is less than or equal to the data amount threshold.

[0041] If the current user data is the second type of data, the current user data is found according to an index value of the current user data contained in the current page, and the data length of the current user data is determined; the second type of data refers to data whose contained data amount is greater than the data amount threshold.

[0042] Optionally, the position information of the current user data is determined in the following manner:

[0043] The position information of the first character in the current user data is taken as the position information of the current user data.

[0044] Thirdly, this application provides a database consistency verification device, which includes: a processor and a communication interface; the communication interface and the processor are coupled, and the processor is used to run computer programs or instructions to implement the database consistency verification method as described in the first aspect and any possible implementation of the first aspect.

[0045] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a terminal, cause the terminal to perform a database consistency verification method as described in the first aspect and any possible implementation thereof.

[0046] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a database consistency verification device, cause the database consistency verification device to execute the database consistency verification method as described in the first aspect and any possible implementation thereof.

[0047] In a sixth aspect, embodiments of this application provide a chip, which includes a processor and a communication interface coupled to the processor. The processor is used to run computer programs or instructions to implement the database consistency verification method as described in the first aspect and any possible implementation thereof.

[0048] Specifically, the chip provided in this application embodiment also includes a memory for storing computer programs or instructions.

[0049] The database consistency verification method provided in this application can directly determine the verification values ​​of the first database and the second database, i.e., the first verification value and the second verification value, based on the data length of each user data and the position information of each user data in the corresponding page; without needing to first extract the user data contained in the first database and the second database and then calculate the verification values ​​of the first database and the second database. Therefore, it can effectively improve the speed of determining the consistency of the first database and the second database. Attached Figure Description

[0050] Figure 1 A schematic diagram of a database system for which a database consistency verification method is applied, as provided in an embodiment of this application;

[0051] Figure 2 A flowchart illustrating a database consistency verification method provided in this application embodiment;

[0052] Figure 3 A schematic diagram of a database page format provided in an embodiment of this application;

[0053] Figure 4This application provides a schematic diagram of the internal structure of row tuple data.

[0054] Figure 5 This application provides a schematic diagram of a process for determining a first verification value.

[0055] Figure 6 A structural block diagram of a database consistency verification device provided in this application embodiment;

[0056] Figure 7 This is a schematic diagram of the structure of a database consistency verification device provided in an embodiment of this application. Detailed Implementation

[0057] The database consistency verification method and apparatus provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0058] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0059] The terms "first" and "second," etc., used in the specification and drawings of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.

[0060] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.

[0061] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0062] Figure 1This illustration shows a database system diagram of a database consistency verification method provided in an embodiment of this application. Taking a primary-secondary architecture as an example, the database system includes a primary database server 101 and a secondary database server 102 connected to it via a network. Depending on actual application requirements, the database system can also be a primary-multiple-secondary architecture containing multiple secondary database servers. The method of performing primary-secondary database consistency verification between any secondary database server and the primary database server is similar to the primary-secondary architecture in this application.

[0063] Those skilled in the art will understand that the primary database server 101 and the backup database server 102 in the database system may include, but are not limited to, user equipment, network equipment, or devices formed by integrating user equipment and network equipment through a network. User equipment includes, but is not limited to, personal computers, touch terminals, etc.; network equipment includes, but is not limited to, network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, etc. Here, the cloud consists of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing, consisting of a virtual computer composed of a group of loosely coupled computer sets.

[0064] For large-scale database systems with high reliability requirements, a primary and backup database setup is typically used to ensure normal system operation. Simultaneously, to guarantee efficient database access, the system caches data for fast access and maintains real-time consistency between the cached and primary database data.

[0065] During the operation of a database system, the primary and backup databases need to perform periodic or real-time data synchronization. However, due to network instability or latency, it is difficult to guarantee the consistency between the primary and backup databases. When the primary database fails, the backup database needs to take over the data and provide data services. However, due to the inconsistency between the primary and backup databases, the database system cannot function properly.

[0066] Currently, when performing consistency checks on the data in the heap table files stored in the primary and secondary databases, it is necessary to first read the target row data from the heap table file of the primary or secondary database according to the query statement, and then determine the check value of the target row data through aggregate functions; then, determine the data check value of the heap table file of the primary or secondary database based on the obtained check values; finally, perform consistency checks on the data in the heap table files stored in the primary and secondary databases based on the data check values ​​of the heap table files of the primary and secondary databases. This method requires a lot of time to implement.

[0067] To address the technical problem, this application provides a database consistency verification method. This method determines a first verification value based on the data length of each user data item in a first database and its position on a corresponding page. It then determines a second verification value based on the data length of each user data item in a second database and its position on a corresponding page. Finally, the consistency between the first and second databases is determined based on the first and second verification values. Both the first and second databases contain multiple pages. This method directly determines the verification values ​​(first and second verification values) for the first and second databases based on the data length and position of each user data item on its corresponding page, eliminating the need to first extract the user data from the first and second databases and then calculate the verification values. Therefore, it effectively improves the speed of determining the consistency between the first and second databases.

[0068] Figure 2 A flowchart of a database consistency verification method provided in this application embodiment is shown below. Figure 2 As shown, the method includes the following steps:

[0069] Step S201: Determine the first verification value based on the data length of each user data in the first database and the position information of each user data in the first database on the corresponding page.

[0070] Step S202: Determine the second verification value based on the data length of each user data in the second database and the position information of each user data in the second database on the corresponding page.

[0071] In the embodiments of this application, the first database may be the primary database and the second database may be the backup database; or the second database may be the primary database and the first database may be the backup database. This application does not limit this.

[0072] In the embodiments of this application, the database can be an OpenGauss database, a MySQL database, a PostgreSQL database, etc. This application does not limit it. The following description uses the OpenGauss database as an example.

[0073] Figure 3 The page format for storing heap table files in the openGauss database, such as... Figure 3 As shown, this page format includes three parts: a header information area, a data indicator array, and a row tuple data area.

[0074] The header information area can contain the following types of information:

[0075] (1) pd_lsn: used to indicate the end position of the write-ahead log of the last modification operation on the current page.

[0076] (2) pd_checksum: used to indicate the CRC checksum of the current page.

[0077] (3) pd_flags: Used to store various auxiliary information related to the current page.

[0078] (4) pd_lower: used to indicate the end of the array of tuple pointers currently in use on the page.

[0079] (5) pd_upper: used to indicate the starting position of the next insertable tuple on the current page.

[0080] (6) pd_special: Used to indicate the starting position of a special area at the end of the current page.

[0081] (7) pd_pagesize_version: used to indicate the size and version number of the current page.

[0082] (8) pd_prune_xid: Used to indicate the cleanup auxiliary transaction number of the current page.

[0083] (9) pd_xid_base: Used to indicate the base transaction number of all tuples in the current page.

[0084] (10) pd_multi_base: When locking the current page, it is used to indicate the transaction number holding the lock on the current page.

[0085] The data indicator array can contain the offset position of each row tuple data in the current page. For example, lp1 can be used to indicate the head index position of row tuple data tuple1, lp2 can be used to indicate the head index position of row tuple data tuple2, and lp3 can be used to indicate the head index position of row tuple data tuple3.

[0086] Figure 4 This is a schematic diagram of the internal structure of a row tuple data, such as... Figure 4 As shown, a row tuple can include header data (HeapTupleHeadeData) and user data (encoded user data). The header data can include the following information:

[0087] (1) t_xmin, used to indicate the transaction number of the inserted tuple.

[0088] (2) t_xmax, used to indicate the transaction number of the tuple to be deleted.

[0089] (3) t_cid, used to indicate the command number for inserting or deleting tuples.

[0090] (4) t_ctid is used to indicate the page of the current tuple and the pointers to tuples within the page.

[0091] (5) t_infomask2, used to indicate the attribute mask of the tuple.

[0092] (6) t_infomask, used to indicate another attribute mask of the tuple.

[0093] (7) t_hoff is used to indicate the offset of the tuple data from the starting position of the tuple header structure.

[0094] (8) t_bits, used to indicate the NULL value bitmap for all fields.

[0095] Because the user data portion of the row tuple data does not change when updating the row tuple data, the checksum can be determined based on the user data.

[0096] Specifically, a first verification value can be determined based on the data length of each user data in the first database and the position information of each user data in the first database on the corresponding page. Then, a second verification value can be determined based on the data length of each user data in the second database and the position information of each user data in the second database on the corresponding page.

[0097] Step S203: Determine the consistency between the first database and the second database based on the first check value and the second check value.

[0098] After determining the first check value and the second check value through steps S201 and S202, the consistency between the first database and the second database can be further determined based on the first check value and the second check value.

[0099] For example, in one embodiment, if the first verification value is equal to the second verification value, it indicates that the data in the first database and the second database are consistent; if the first verification value is not equal to the second verification value, it indicates that the data in the first database and the second database are inconsistent.

[0100] Using the method described above, the checksums of the first and second databases can be determined directly based on the data length of each user's data and its position on the corresponding page; that is, the first checksum and the second checksum. This eliminates the need to first extract the user data from the first and second databases and then calculate their checksums. Therefore, the speed of determining the consistency between the first and second databases can be effectively improved.

[0101] In an optional implementation, in step S201 above, during the process of determining the first check value, reference can be made to... Figure 5 The method shown is as follows: Figure 5 As shown, the method includes:

[0102] Step S501: Sequentially select each page contained in the first database as the current page.

[0103] Step S502: Determine the current user data from the various user data contained in the current page.

[0104] In one alternative implementation, the determination of current user data can continue in the following two ways:

[0105] (1) Sequentially use each user data in the current page as the current user data.

[0106] (2) First, take multiple user data of type 1 data in the current page as the current user data in turn. If not all user data in the current page has been traversed, then take multiple user data of type 2 data in the current page as the current user data in turn. Here, type 1 data refers to data whose data volume is less than or equal to the data volume threshold, and type 2 data refers to data whose data volume is greater than the data volume threshold.

[0107] In this application embodiment, the first type of data may include, but is not limited to, data that can be obtained by reading the current snapshot. That is, for user data whose data volume is less than or equal to the data volume threshold, all data of the current user data can be directly obtained from the current page. The second type of data may include, but is not limited to, data that cannot be obtained by reading the current snapshot, such as Toast type data. The following description takes the first type of data as data that can be obtained by reading the current snapshot and the second type of data as Toast type data as an example.

[0108] For example, in one embodiment, the current snapshot can be read first to use multiple user data contained in the current page as the current user data. Then, the following operations are performed on the current user data. After the operations are completed, if all user data contained in the current page has been traversed, it indicates that the current page does not contain data of type Toast. Therefore, the next page of the current page can be processed as the current page. If all user data contained in the current page has not been traversed, it indicates that the current page contains data of type Toast. Therefore, multiple user data of type second data in the current page can be processed as the current user data in turn.

[0109] In the embodiments of this application, the data volume can be used to indicate the number of characters contained in the data. For example, if the current user data is "ghku / 452", then the data volume contained in the current user data is 8. The data volume threshold can be set according to the actual situation, or a default data volume threshold can be used. This application does not limit this.

[0110] Step S503: Obtain the data length of the current user data.

[0111] Specifically, in one optional implementation, if the current user data is of the first type, the data length of the current user data can be determined based on the length of the current user data in the current page; if the current user data is of the second type, the current user data can be found based on the index value of the current user data contained in the current page, and the data length of the current user data can be determined.

[0112] For example, in one embodiment, assuming the current user data is of the first type, the data length of the current user data can be directly obtained through the current snapshot read.

[0113] In another embodiment, assuming the current user data is of the second type, the current user data can be found in the Toast table based on the index value of the current user data contained in the current page, and the data length of the current user data can be determined based on the amount of current user data contained in the Toast table.

[0114] Step S504: Obtain the location information of the current user data on the current page.

[0115] Specifically, in one optional implementation, the position information of the first character in the current user data can be used as the position information of the current user data on the current page.

[0116] In another alternative implementation, the position information of the last character in the current user data can also be used as the position information of the current user data on the current page.

[0117] Step S505: Determine the user data verification value of the current user data based on the data length of the current user data and the position information of the current user data on the current page.

[0118] In the embodiments of this application, the verification value may include, but is not limited to, the CRC32 check value, and this application does not limit it.

[0119] For example, in one embodiment, after determining the data length of the current user data and the position information of the current user data in the current page through steps S503 and S504, the CRC32 check value of the current user data can be determined by "RowCRC = COMP_CRC32(DataPtr, Len)", where RowCRC represents the CRC32 check value of the current user data, DataPtr represents the position information of the current user data in the current page, and Len represents the data length of the current user data.

[0120] Step S506: Have all user data contained in the current page been traversed? If yes, proceed to step S507; if no, proceed to step S508.

[0121] Step S507: Have all pages contained in the first database been traversed? If yes, proceed to step S510; if no, proceed to step S509.

[0122] Step S508: Use the next piece of user data as the current user data;

[0123] Step S509: Set the next page of the current page as the current page;

[0124] Step S510: Determine the first verification value based on the determined multiple user data verification values.

[0125] Specifically, after determining multiple user data verification values ​​using the above method, the first verification value corresponding to the first database can be determined based on the cumulative value of each user data verification value.

[0126] The process of determining the second verification value based on the data length of each user data item in the second database and the position information of each user data item in the second database on the corresponding page is similar to the above. Figure 5 The process of determining the first verification value based on the data length of each user data in the first database and the position information of each user data in the first database on the corresponding page is similar and will not be described in detail here.

[0127] Using the above method, when operating on the current page, the checksum of the current user data can be determined based on the data length and position of the current user data within the current page, until all user data contained in the current page has been traversed. That is, only after all user data in each page has been traversed can the next page be traversed, meaning each page only needs to be traversed once. Therefore, multiple accesses to a single page are unnecessary, effectively reducing the increased latency of random disk reads and mitigating the problem of frequent eviction and replacement of the database shared buffer pool.

[0128] In this embodiment, the first database (or the second database) may contain multiple pages. Therefore, in an optional implementation, the first database may be locked during the determination of the first verification value, and the second database may be locked during the determination of the second verification value.

[0129] For example, in one embodiment, during the process of determining the first verification value, an access shared lock can be added to the first database. This access shared lock can not only prevent updates to the data on the current page, but also will not block update operations on other pages besides the current page.

[0130] Figure 6 This is a schematic diagram of the structure of a database consistency verification device provided in an embodiment of this application, as shown below. Figure 6 As shown, the device includes:

[0131] The first determining unit 601 is used to determine a first verification value based on the data length of each user data in the first database and the position information of each user data in the first database on the corresponding page; the first database contains multiple pages.

[0132] The second determining unit 602 is used to determine the second verification value based on the data length of each user data in the second database and the position information of each user data in the second database on the corresponding page; the second database contains multiple pages.

[0133] The comparison unit 603 is used to determine the consistency between the first database and the second database based on the first check value and the second check value.

[0134] Optionally, the first determining unit 601 is specifically used for:

[0135] Each page in the first database is treated as the current page, and the following operations are performed sequentially until all pages in the first database have been traversed:

[0136] Determine the current user data from the various user data contained on the current page;

[0137] Based on the data length of the current user data and the position information of the current user data on the current page, determine the user data verification value of the current user data until all user data contained in the current page has been traversed.

[0138] After traversing all the pages contained in the first database, the first verification value is determined based on the determined multiple user data verification values.

[0139] Optionally, the current user data can be determined from the various user data contained on the current page in the following way:

[0140] Use each user data item on the current page as the current user data in turn; or,

[0141] The system sequentially selects multiple user data items of type 1 data from the current page as the current user data; type 1 data refers to data whose data volume is less than or equal to the data volume threshold.

[0142] If not all user data contained in the current page has been traversed, then multiple user data items of type 2 data in the current page will be used as the current user data in turn; type 2 data refers to data whose data volume is greater than the data volume threshold.

[0143] Optionally, the data length of the current user data can be obtained in the following way:

[0144] If the current user data is of type 1, then the data length of the current user data is determined based on the length of the current user data on the current page; type 1 data refers to data whose data volume is less than or equal to the data volume threshold.

[0145] If the current user data is of the second type, then the current user data is found based on the index value of the current user data contained in the current page, and the data length of the current user data is determined; the second type of data refers to data containing a data volume greater than the data volume threshold.

[0146] Optionally, the location information of the current user data can be determined in the following way:

[0147] Use the position information of the first character in the current user data as the position information of the current user data.

[0148] Figure 7This diagram illustrates another possible structural design of the database consistency verification device described in the above embodiments. The database consistency verification device includes a processor 701 and a communication interface 702. The processor 701 controls and manages the operation of the database consistency verification device, and the communication interface 702 supports communication between the database consistency verification device and other network entities. The database consistency verification device may also include a memory 703 and a bus 704. The memory 703 stores the program code and data of the database consistency verification device.

[0149] The memory 703 may be the memory in a database consistency verification device, and the memory may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include a combination of the above types of memory.

[0150] The processor 701 described above can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0151] The 704 bus can be an Extended Industry Standard Architecture (EISA) bus, etc. The 704 bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0152] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0153] This application provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the database consistency verification method in the above method embodiments.

[0154] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the database consistency verification method in the method flow shown in the above method embodiments.

[0155] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires; portable computer disks; hard disks; random access memory (RAM); read-only memory (ROM); erasable programmable read-only memory (EPROM); registers; hard disks; optical fibers; portable compact disc read-only memory (CD-ROM); optical storage devices; magnetic storage devices; or any suitable combination thereof; or any other form of computer-readable storage medium known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may reside in an application-specific integrated circuit (ASIC). In the embodiments of this application, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0156] Embodiments of the present invention provide a computer program product containing instructions that, when executed on a computer, cause the computer to perform actions such as... Figures 2 to 5 The database consistency verification method described in [the document].

[0157] Since the database consistency verification device, computer-readable storage medium, and computer program product in the embodiments of the present invention can be applied to the above method, the technical effects obtained can also be referred to the above method embodiments. The embodiments of the present invention will not be described again here.

[0158] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0159] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0160] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0161] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A database consistency verification method, characterized in that, The method includes: Each page in the first database is treated as the current page, and the following operations are performed sequentially until all pages in the first database have been traversed: Determine the current user data from the various user data contained in the current page; Based on the data length of the current user data and the position information of the current user data in the current page, determine the user data verification value of the current user data until all user data contained in the current page has been traversed; After traversing all the pages contained in the first database, the cumulative value of each user data verification value is determined based on the determined multiple user data verification values ​​to obtain the first verification value; the first database contains multiple pages; The second verification value is determined based on the data length of each user data in the second database and the position information of each user data in the second database on the corresponding page; the second database contains multiple pages; Based on the first verification value and the second verification value, the consistency between the first database and the second database is determined.

2. The method according to claim 1, characterized in that, The current user data is determined from the various user data contained in the current page in the following manner: Each piece of user data in the current page is used as the current user data in turn; or, Multiple user data items of the first type of data in the current page are sequentially used as the current user data; the first type of data refers to data whose data volume is less than or equal to a data volume threshold. If not all user data contained in the current page has been traversed, then multiple user data items of the second type of data in the current page are sequentially used as the current user data; the second type of data refers to data whose data volume is greater than the data volume threshold.

3. The method according to claim 1, characterized in that, The data length of the current user data is obtained in the following way: If the current user data is of the first type, then the data length of the current user data is determined according to the length of the current user data in the current page; the first type of data refers to data whose data volume is less than or equal to a data volume threshold. If the current user data is the second type of data, then the current user data is located according to the index value of the current user data contained in the current page, and the data length of the current user data is determined; the second type of data refers to data containing a data volume greater than the data volume threshold.

4. The method according to claim 1, characterized in that, The location information of the current user data is determined in the following manner: The position information of the first character in the current user data is used as the position information of the current user data.

5. A database consistency verification device, characterized in that, The device includes: The first determining unit is used to sequentially take each page contained in the first database as the current page and perform the following operations until all pages contained in the first database have been traversed: The first determining unit is further configured to determine the current user data from the various user data contained in the current page; The first determining unit is further configured to determine the user data verification value of the current user data based on the data length of the current user data and the position information of the current user data in the current page, until all user data contained in the current page has been traversed; The first determining unit is further configured to, after traversing all the pages contained in the first database, determine the sum of the multiple user data verification values ​​based on the determined multiple user data verification values, and obtain the first verification value; The second determining unit is used to determine the second verification value based on the data length of each user data in the second database and the position information of each user data in the second database on the corresponding page; the second database contains multiple pages; The comparison unit is used to determine the consistency between the first database and the second database based on the first verification value and the second verification value.

6. The apparatus according to claim 5, characterized in that, The current user data is determined from the various user data contained in the current page in the following manner: Each piece of user data in the current page is used as the current user data in turn; or, Multiple user data items of the first type of data in the current page are sequentially used as the current user data; the first type of data refers to data whose data volume is less than or equal to a data volume threshold. If not all user data contained in the current page has been traversed, then multiple user data items of the second type of data in the current page are sequentially used as the current user data; the second type of data refers to data whose data volume is greater than the data volume threshold.

7. The apparatus according to claim 5, characterized in that, The data length of the current user data is obtained in the following way: If the current user data is of the first type, then the data length of the current user data is determined according to the length of the current user data in the current page; the first type of data refers to data whose data volume is less than or equal to a data volume threshold. If the current user data is the second type of data, then the current user data is located according to the index value of the current user data contained in the current page, and the data length of the current user data is determined; the second type of data refers to data containing a data volume greater than the data volume threshold.

8. The apparatus according to claim 5, characterized in that, The location information of the current user data is determined in the following manner: The position information of the first character in the current user data is used as the position information of the current user data.

9. A database consistency verification device, characterized in that, include: A processor and a communication interface; the communication interface is coupled to the processor, the processor being used to run computer programs or instructions to implement the database consistency verification method as described in any one of claims 1-4.

10. A computer-readable storage medium storing instructions, characterized in that, When the computer executes the instruction, the computer performs the database consistency verification method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Data management implementation method, storage medium and equipment

    CN110442824A

  • Business data verification method, device and equipment, and storage medium

    CN111506578A