HBase-based data rollback methods, systems, devices, and media
By receiving data query requests in the HBase database, identifying and rolling back dirty data row key ranges, the reliability problem of the HBase database under data anomaly conditions is solved, and the accuracy and reliability of data query results are achieved.
Patent Information
- Application Number
- CN202110440310.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-22
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2041-04-22
AI Technical Summary
HBase databases lack transaction rollback mechanisms in the event of data anomalies, leading to data unreliability issues.
By receiving data query requests, obtaining the account and date to be queried, determining whether rollback is needed, obtaining the dirty data row key range, rolling back the HBase database, and outputting an empty response message, the dirty data output is avoided.
It improves the reliability of the HBase database, ensures the accuracy and reliability of data query results, and prevents abnormal data from being presented to users.
Smart Images

Figure CN113076378B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of financial technology (Fintech), and in particular to a data rollback method, system, device, and computer storage medium based on HBase. Background Technology
[0002] With the development of computer technology, more and more technologies (big data, distributed systems, artificial intelligence, etc.) are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and universality requirements of the financial industry, higher demands are also being placed on data rollback technology.
[0003] For relational databases, performing SQL queries on a table with 250 million records is extremely inefficient. To solve this problem, non-relational distributed storage systems have emerged. HBase is a highly reliable, high-performance, column-oriented, and scalable distributed storage system. Large-scale structured storage clusters built using HBase technology provide an excellent solution for real-time response systems for massive amounts of data with ultra-large scale and high concurrency.
[0004] However, in real-world applications, it is inevitable that there will be instances where the data in the database is abnormal on a particular day or several days. In such cases, rollback is often required to restore the data in the database to its state before the modification. The more mature rollback solution for traditional relational databases is transaction rollback, but HBase does not have the concept of transactions, so transaction rollback is not applicable in HBase-based scenarios. Summary of the Invention
[0005] The main objective of this invention is to propose a data rollback method, system, device, and computer storage medium based on HBase, aiming to provide a data rollback solution based on HBase, thereby improving the reliability of HBase database operation.
[0006] To achieve the above objectives, this invention provides a data rollback method based on HBase, which includes the following steps:
[0007] Receive a data query request and obtain the account to be queried and the date to be queried carried in the data query request;
[0008] If it is determined that data rollback is required based on the date to be queried, then obtain the dirty data row key range corresponding to the account to be queried;
[0009] Based on the dirty data row key range, the corresponding dirty data in the HBase database is rolled back so that when the data query process is executed according to the data query request, a response message indicating that the data query result is empty is output.
[0010] Optionally, after the step of obtaining the account and date to be queried carried in the data query request, the method further includes:
[0011] Retrieve the first batch of dates with the latest timestamp from the batch date table in the HBase database, and the second batch of dates with the largest timestamp from the batch date table;
[0012] If the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, then it is determined that data rollback is required, and the following steps are executed: obtain the dirty data row key range corresponding to the account to be queried.
[0013] Optionally, the step of obtaining the dirty data row key range corresponding to the account to be queried includes:
[0014] The lower limit of the interval is determined based on the account to be queried and the first batch date, and the upper limit of the interval is determined based on the account to be queried and the second batch date;
[0015] The dirty data row key range is determined based on the lower limit and the upper limit of the range.
[0016] Optionally, before the step of obtaining the first batch date with the latest timestamp in the batch date table based on the HBase database, and the second batch date with the largest date in the batch date table, the method further includes:
[0017] When it is detected that the business system stores the business data of the day into the HBase database, the batch date corresponding to the business data of the day is added to the batch date table, and the timestamp when the batch date of the day is added to the batch date table is associated with the batch date of the day and added to the batch date table.
[0018] Optionally, after the step of rolling back the corresponding dirty data in the HBase database based on the dirty data row key range, so as to output a response message indicating that the data query result is empty when executing the data query process according to the data query request, the method further includes:
[0019] When it is detected that the business system has updated and stored normal data of the first batch date and subsequent batch dates to the HBase database, the first batch date and subsequent batch dates are added to the batch date table again, and a new timestamp is added accordingly.
[0020] Optionally, the step of determining that data rollback is needed if the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, includes:
[0021] If the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, and a rollback flag is detected, then it is determined that data rollback is required.
[0022] Optionally, the step of rolling back the corresponding dirty data in the HBase database based on the dirty data row key range includes:
[0023] Determine the first timestamp of the dirty data corresponding to the dirty data row key range in the HBase database, and determine the second timestamp based on the first timestamp, wherein the second timestamp is greater than or equal to the first timestamp;
[0024] The HBase database is associated with a second timestamp and a deletion tag for writing the dirty data. The second timestamp and the deletion tag are used to instruct the HBase database to delete the dirty data.
[0025] Furthermore, to achieve the above objectives, the present invention also provides an HBase-based data rollback system, the HBase-based data rollback system comprising:
[0026] The request receiving module is used to receive data query requests and obtain the account to be queried and the date to be queried carried in the data query request;
[0027] The interval determination module is used to obtain the dirty data row key interval corresponding to the account to be queried if it is determined that data rollback is required based on the date to be queried.
[0028] The rollback query module is used to roll back the corresponding dirty data in the HBase database based on the dirty data row key range, so as to output a response message that the data query result is empty when the data query process is executed according to the data query request.
[0029] Furthermore, to achieve the above objectives, the present invention also provides an HBase-based data rollback device, which includes: a memory, a processor, and an HBase-based data rollback program stored in the memory and executable on the processor. When the HBase-based data rollback program is executed by the processor, it implements the steps of the HBase-based data rollback method described above.
[0030] In addition, to achieve the above objectives, the present invention also provides a computer storage medium storing an HBase-based data rollback program, wherein the HBase-based data rollback program, when executed by a processor, implements the steps of the HBase-based data rollback method as described above.
[0031] This invention improves the reliability of the HBase database by intercepting and performing rollback checks on data query requests. Upon receiving a data query request, the system retrieves the account and date to be queried from the request. If data rollback is required based on the date, the system obtains the dirty data row key range corresponding to the account. The system then rolls back the corresponding dirty data in the HBase database based on this range, resulting in an empty data query result when the data query process is executed according to the request. By intercepting and performing rollback checks on data query requests from the business layer, dirty data-related data is rolled back before the query is allowed, preventing dirty data from being output to the business layer. This achieves business-level data rollback and improves the reliability of the HBase database. Attached Figure Description
[0032] Figure 1 This is a schematic diagram of the HBase-based data rollback device structure in the hardware operating environment involved in the embodiments of the present invention;
[0033] Figure 2 This is a flowchart illustrating the first embodiment of the HBase-based data rollback method of the present invention;
[0034] Figure 3 This is a schematic diagram of the system modules of the HBase-based data rollback system of the present invention.
[0035] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0036] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0037] like Figure 1 As shown, Figure 1 This is a schematic diagram of the HBase-based data rollback device structure in the hardware operating environment involved in the embodiments of the present invention.
[0038] In this embodiment of the invention, the data rollback device based on HBase can be a PC or a server device on which a virtual machine runs.
[0039] like Figure 1As shown, the HBase-based data rollback device may include: a processor 1001, such as a CPU; a network interface 1004; a user interface 1003; a memory 1005; and a communication bus 1002. The communication bus 1002 is used to establish communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or stable non-volatile memory, such as disk storage. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0040] Those skilled in the art will understand that Figure 1 The HBase-based data rollback device structure shown in the diagram does not constitute a limitation on the device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0041] like Figure 1 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an HBase-based data rollback program.
[0042] exist Figure 1 In the HBase-based data rollback device shown, the network interface 1004 is mainly used to connect to the backend server and communicate with the backend server; the user interface 1003 is mainly used to connect to the client (user end) and communicate with the client; and the processor 1001 can be used to call the HBase-based data rollback program stored in the memory 1005 and execute the operations in the following HBase-based data rollback method.
[0043] Based on the above hardware structure, an embodiment of the data rollback method based on HBase of the present invention is proposed.
[0044] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the HBase-based data rollback method of the present invention. The method includes:
[0045] Step S10: Receive a data query request and obtain the account to be queried and the date to be queried carried in the data query request;
[0046] This embodiment applies the HBase-based data rollback method to an HBase-based data rollback device, which can be a terminal, robot, or PC.
[0047] In existing technologies, in real-world applications, it is inevitable that data anomalies will occur on a particular day or several days in the database. In such cases, rollback is often required to restore the data in the database to its state before the modification. The more mature rollback solution for traditional relational databases is transaction rollback. However, HBase does not have the concept of transactions, so transaction rollback is not applicable in HBase-based scenarios.
[0048] Against this backdrop, this embodiment provides a data rollback scheme based on HBase, which enables the rollback of HBase data and improves the flexibility of HBase database operation.
[0049] HBase is essentially a key-value database. Its key is the row key, and the value is the collection of all actual key-value pairs. HBase can be abstracted as a four-dimensional table, with the four dimensions being the row key, column family, column, and timestamp.
[0050] Regarding RowKey, HBase sorts the data in the table in ascending lexicographical order. RowKey is the primary key used to query data records in HBase; that is, to query a row in HBase, you must locate it through RowKey or a range of RowKeys, otherwise a full table scan is required. Regarding Column Family and Column, as the names suggest, each column in an HBase table belongs to a column family. A column family is part of the table's schema, while a column is not. Regarding Timestamp, a storage unit in HBase defined by RowKey and Column is called a Cell. Each Cell stores multiple versions of the same data, indexed by timestamps. Timestamps can be automatically assigned by HBase when data is written, and in this case, the timestamp is accurate to milliseconds of the current system time. Timestamps can also be explicitly assigned by the client. Furthermore, within each Cell, different versions of data are sorted in descending chronological order, meaning the newest data is at the top. Unless otherwise specified, HBase will default to returning the latest version (the one with the newest timestamp) during a query.
[0051] This embodiment is applied in a financial business scenario, in which the HBase database stores transaction data of different accounts at different times. Specifically, the RowKey in the HBase database is in the form of "account + date".
[0052] When a user needs to query the transaction data of an account on a certain day or several days, they will send a data query request to the HBase-based data rollback system. The query instruction carries the account and date that the user wants to query, i.e., the account to be queried and the date to be queried. The date to be queried can be a specific date or a time range.
[0053] Furthermore, following step S10 above, the following is also included:
[0054] Step S101: Obtain the first batch date with the latest timestamp in the batch date table of the HBase database, and the second batch date with the largest date in the batch date table;
[0055] If the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, then it is determined that data rollback is required, and step S20 is executed.
[0056] In this embodiment, to avoid reporting any dirty data (i.e., abnormal data) that may exist in the HBase database for the account to be queried to the user, the HBase-based data rollback system, after obtaining the account and date to be queried, will not directly query the corresponding transaction data in the HBase database and output it. That is, it will not directly execute the data query process, but will first intercept the data query request to determine whether the data corresponding to the data query request needs to be rolled back. If not, the data query process will be executed; if so, the data rollback will be performed first, and then the data query process will be executed.
[0057] In this embodiment, the data rollback system maintains a batch date table based on the HBase database. This batch date table is generated based on the data synchronization status between the business system and the HBase database. Whenever it is detected that the business system has successfully stored the business data of the day into the HBase database, a new record is added to the batch date table. The new record includes the batch date of the day and the timestamp when the batch date of the day is added to the batch date table. The batch date of the day is stored in association with the timestamp. It can be understood that if there are no abnormalities in the data in the HBase database, the batch date associated with the latest timestamp in the batch date table is the batch date with the largest date.
[0058] However, when anomalies occur in the HBase database, the HBase data rollback system or database maintenance personnel will insert a rollback record into the batch date table after detecting anomalies in the data on or after a certain date in the HBase database. This rollback record includes the earliest batch date with anomalies (i.e., the rollback start date) and the timestamp when the batch date was added to the batch date table. This will cause the batch date with the latest timestamp in the batch date table (i.e., the first batch date) to not be the batch date with the largest date (i.e., the second batch date), but rather the batch date with the latest timestamp will be less than the batch date with the largest date. If this happens, it means that the data in the HBase database on or after the batch date with the latest timestamp is anomaly and needs to be rolled back.
[0059] Therefore, when determining whether the data corresponding to the query date needs to be rolled back, it is necessary to obtain the first batch date with the latest timestamp in the batch date table and the second batch date with the largest date in the batch date table, compare the size of the first batch date and the second batch date, and determine whether the data corresponding to the query date needs to be rolled back based on the comparison result; if the first batch date < the second batch date, and the query date ∈ [first batch date, second batch date], it means that the data corresponding to the query date needs to be rolled back, and then step S20 is executed; if the first batch date = the second batch date, or the query date [First batch date, second batch date] indicates that the data corresponding to the query date does not involve dirty data and does not require rollback. Therefore, the corresponding transaction data can be directly queried from the HBase database based on the account and query date, and the result will be output as the query result. It should be noted that for a query date that is a date range, any value within this date range ∈ [First batch date, second batch date] is considered to be within that range.
[0060] Furthermore, to avoid misjudgments of rollback due to erroneous operations, this embodiment adds a new condition to the aforementioned judgment conditions when performing rollback judgment: detecting the rollback flag (rollback-flag). A rollback is only determined to be necessary if the first batch date is less than the second batch date, the query date is ∈ [first batch date, second batch date], and the rollback flag is detected. The rollback flag can be set by the data rollback system or database maintenance personnel after detecting anomalies in data on or after a certain date in the HBase database. This rollback flag can be associated with the rollback start date.
[0061] Step S20: If it is determined that data rollback is required based on the date to be queried, then obtain the dirty data row key range corresponding to the account to be queried;
[0062] In this embodiment, after determining that data rollback is necessary, directly rolling back all dirty data in the HBase database (i.e., transaction data of all accounts between the first batch date and the second batch date) would involve an immeasurable amount of data computation, and the rollback would take several days or even longer. Moreover, dirty data for accounts that the user has not queried will not be provided to the user in the normal query process. Therefore, it is only necessary to roll back the dirty data corresponding to the account to be queried, without the need to globally roll back the dirty data of all accounts.
[0063] Furthermore, in step S20 above, the step of obtaining the dirty data row key range corresponding to the account to be queried includes:
[0064] Step S21: Determine the lower limit of the interval based on the account to be queried and the first batch date, and determine the upper limit of the interval based on the account to be queried and the second batch date;
[0065] Step S22: Determine the dirty data row key range based on the lower limit and the upper limit of the range.
[0066] Since RowKeys in HBase databases are in the form of "account + date", and rows in HBase must be located through RowKeys to query them, otherwise a full table scan would be required, the "account + date" format is also needed when locating dirty data that needs to be rolled back in HBase databases.
[0067] In one embodiment, the dirty data row key range can be directly determined by the account to be queried and the date to be queried. In this case, the dirty data corresponding to the dirty data row key range in the HBase database is only the transaction data of the account to be queried on the date to be queried. For example, if the account to be queried is zhangsan and the date to be queried is 2021-3-2, then the upper limit and lower limit of the dirty data row key range are the same, so the dirty data row key range is zhangsan2021-3-2.
[0068] It should be noted that, to avoid the need for further rollback when querying other dates involving dirty data for the same account, this embodiment can determine the dirty data row key range based on the first batch date, the second batch date, and the account to be queried in the batch date table. This ensures that all dirty data for the account to be queried in the HBase database can be rolled back in a single rollback operation, reducing the number of rollbacks for the same account. For example, if the account to be queried is zhangsan, the first batch date is 2021-3-1, and the second batch date is 2021-3-7, then the dirty data row key range is [zhangsan2021-3-1, zhangsan2021-3-7].
[0069] Furthermore, since a new record is added to the batch date table only when the business system successfully stores all business data for the day into the HBase database, the maximum date in the batch date table lags behind the data update status in the HBase database. If only part of the data for day T is stored in the HBase database, there will be no batch date record for day T in the batch date table. In this case, the maximum batch date in the batch date table is day T-1. To roll back the data for day T and prevent erroneous data from being missed, the upper limit of the interval can be determined by using the second batch date to determine the third batch date, which is equal to the second batch date plus 1. The upper limit of the interval is then determined based on the account to be queried and the third batch date. The lower limit of the interval is the same as in the aforementioned embodiment. For example, if the account to be queried is zhangsan, the first batch date is 2021-3-1, the second batch date is 2021-3-7, and the second batch date can be determined to be 2021-3-8, then the dirty data row key range is [zhangsan2021-3-1, zhangsan2021-3-8].
[0070] Step S30: Roll back the corresponding dirty data in the HBase database according to the dirty data row key range, so as to output a response message that the data query result is empty when the data query process is executed according to the data query request.
[0071] In this embodiment, after determining the dirty data row key range, the corresponding dirty data in the HBase database can be rolled back based on the dirty data row key range.
[0072] The above step S30 specifically includes:
[0073] Step S31: Determine the first timestamp of the dirty data corresponding to the dirty data row key range in the HBase database, and determine the second timestamp based on the first timestamp, wherein the second timestamp is greater than or equal to the first timestamp;
[0074] Step S32: Associate the second timestamp and deletion tag of the dirty data written into the HBase database. The second timestamp and deletion tag are used to instruct the HBase database to delete the dirty data.
[0075] Once the row key range of dirty data is determined, the corresponding dirty data in the HBase database can be obtained based on the row key range of dirty data. This also includes the first timestamp of the dirty data. If there are multiple versions of dirty data, the first timestamp is the timestamp of the latest version of the dirty data, that is, the latest timestamp of the dirty data.
[0076] Because HBase databases, unless otherwise specified, will return the data with the latest timestamp when executing a data query process, if the latest timestamp data is tagged with a delete label (type=delete), HBase will not output this latest timestamp data as a query result, but will instead output a response message indicating that the data query result is empty. Based on this operating principle of HBase, the specific operation for rolling back dirty data corresponding to the row key range of dirty data in this embodiment is as follows: Write a record with a timestamp (i.e., the second timestamp) that is newer than or the same as the first timestamp to the corresponding dirty data in the HBase database, and tag this record with a delete label. This will achieve the effect that HBase will output an empty query result when querying the dirty data.
[0077] The latest timestamp and deletion tag can, on the one hand, ensure that the HBase database outputs an empty query result when querying the dirty data, thus preventing the HBase database from presenting abnormal dirty data to the user and realizing data rollback at the user and business levels; on the other hand, the latest timestamp and deletion tag can also be used to instruct the HBase database to completely delete these dirty data tagged with deletion in subsequent data update processes.
[0078] This embodiment obtains the account and date to be queried from the data query request when it is received; if data rollback is required based on the date, it obtains the dirty data row key range corresponding to the account to be queried; and rolls back the corresponding dirty data in the HBase database based on the dirty data row key range, so that when the data query process is executed according to the data query request, a response message indicating that the data query result is empty is output. By intercepting and performing rollback judgment on data query requests from the business layer, for data query requests involving dirty data, the dirty data will be rolled back first before the data query request is allowed, thus avoiding the output of dirty data to the business layer, achieving data rollback at the business layer, and thereby improving the reliability of the HBase database.
[0079] Furthermore, based on the above embodiments, a second embodiment of the HBase-based data rollback method of the present invention is proposed.
[0080] Furthermore, following step S30 above, the following steps are also included:
[0081] Step a: When it is detected that the business system has updated and stored normal data of the first batch date and subsequent batch dates to the HBase database, the first batch date and subsequent batch dates are added to the batch date table again, and a new timestamp is added accordingly.
[0082] In this embodiment, for dirty data that has been rolled back, the HBase database may completely delete this dirty data in the subsequent data update process, or it may retain this dirty data, but will store the normal data updates corresponding to this dirty data pushed by the business system to the HBase database. The timestamps of these normal data are newer than the timestamps of the dirty data. In addition, after the normal data pushed by the business system is successfully stored in the HBase database, an update record will be added to the batch date table. This update record includes the batch date corresponding to the normal data (i.e., the first batch date and subsequent batch dates), as well as the timestamp when the batch date is added to the batch date table again.
[0083] Understandably, after adding an update record to the batch date table, the batch date with the latest timestamp in the table will be equal to the batch date with the largest timestamp. Therefore, if other data query requests are received subsequently, since the latest batch date in the batch date table is equal to the largest timestamp, data rollback will not be triggered; instead, the data query process will be executed directly.
[0084] This embodiment ensures the accuracy of the rollback determination step by simultaneously updating the batch date table when updating and storing normal data in the HBase database.
[0085] Furthermore, to confirm that the dirty data has indeed been successfully rolled back and to ensure that the dirty data is not output to the business layer or users, this embodiment adds a rollback result verification process. In step S30 above, after the step of rolling back the corresponding dirty data in the HBase database based on the dirty data row key range, the following is also included:
[0086] The query row key is determined based on the account and date to be queried. The HBase database is then queried based on this query row key. If the query result is empty, it means that the dirty data rollback was successful, and the data query process corresponding to the data query request is executed. If the query result is not empty, the process returns to step S20, the dirty data row key range is determined again, and the data is rolled back again for the dirty data row key range until the query result of the HBase database based on the query row key is empty.
[0087] Furthermore, to prevent data deletion from being irrecoverable or unrecoverable during accidental rollback, this embodiment adds a dirty data backup process. After step S20 above, the dirty data backup corresponding to the dirty data row key range in the HBase database can also be saved to a preset storage space.
[0088] This invention also provides a data rollback system based on HBase, referring to... Figure 3 The HBase-based data rollback system includes:
[0089] The request receiving module 10 is used to receive a data query request and obtain the account to be queried and the date to be queried carried in the data query request;
[0090] The interval determination module 20 is used to obtain the dirty data row key interval corresponding to the account to be queried if it is determined that data rollback is required based on the date to be queried.
[0091] The rollback query module 30 is used to roll back the corresponding dirty data in the HBase database according to the dirty data row key range, so as to output a response message that the data query result is empty when the data query process is executed according to the data query request.
[0092] Optionally, the HBase-based data rollback system further includes:
[0093] The batch date acquisition module is used to acquire the first batch date with the latest timestamp based on the batch date table in the HBase database, and the second batch date with the largest date in the batch date table;
[0094] The interval determination module is further configured to determine that data rollback is required if the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, and execute the following steps: obtain the dirty data row key interval corresponding to the account to be queried.
[0095] Optionally, the batch date acquisition module is further configured to:
[0096] The lower limit of the interval is determined based on the account to be queried and the first batch date, and the upper limit of the interval is determined based on the account to be queried and the second batch date;
[0097] The dirty data row key range is determined based on the lower limit and the upper limit of the range.
[0098] Optionally, the HBase-based data rollback system also includes
[0099] The first batch date table update module is used to add the batch date corresponding to the business data of the day to the batch date table when it is detected that the business system stores the business data of the day to the HBase database, and associate the timestamp of the batch date when it is added to the batch date table with the batch date of the day and add it to the batch date table.
[0100] Optionally, the HBase-based data rollback system also includes
[0101] The second batch date table update module is used to add the first batch date and subsequent batch dates back to the batch date table and associate a new timestamp when it detects that the business system has updated and stored normal data of the first batch date and subsequent batch dates to the HBase database.
[0102] Optionally, the interval determination module is further configured to:
[0103] If the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, and a rollback flag is detected, then it is determined that data rollback is required.
[0104] Optionally, the rollback query module is further configured to:
[0105] Determine the first timestamp of the dirty data corresponding to the dirty data row key range in the HBase database, and determine the second timestamp based on the first timestamp, wherein the second timestamp is greater than or equal to the first timestamp;
[0106] The HBase database is associated with a second timestamp and a deletion tag for writing the dirty data. The second timestamp and the deletion tag are used to instruct the HBase database to delete the dirty data.
[0107] The methods executed by the above-mentioned program units can be referred to in the various embodiments of the HBase-based data rollback method of this invention, and will not be repeated here.
[0108] The present invention also provides an HBase-based data rollback device, which includes: a memory, a processor, and an HBase-based data rollback program stored in the memory and capable of running on the processor. The method implemented by the HBase-based data rollback program when executed by the processor can be referred to in various embodiments of the HBase-based data rollback method of the present invention, which will not be repeated here.
[0109] The present invention also provides a computer storage medium.
[0110] The present invention stores an HBase-based data rollback program on a computer storage medium. When the HBase-based data rollback program is executed by the processor, it implements the steps of the HBase-based data rollback method described above.
[0111] The method implemented when the HBase-based data rollback program running on the processor is executed can be referred to in various embodiments of the HBase-based data rollback method of the present invention, and will not be repeated here.
[0112] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0113] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0115] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A data rollback method based on HBase, characterized in that, The HBase-based data rollback method includes the following steps: Receive a data query request and obtain the account to be queried and the date to be queried carried in the data query request; Retrieve the first batch of dates with the latest timestamp from the batch date table based on the HBase database, and the second batch of dates with the largest timestamp from the batch date table; If the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, and a rollback flag is detected, then it is determined that data rollback is required, and the dirty data row key range corresponding to the account to be queried is obtained; Based on the dirty data row key range, the corresponding dirty data in the HBase database is rolled back so that when the data query process is executed according to the data query request, a response message indicating that the data query result is empty is output. The step of rolling back the corresponding dirty data in the HBase database based on the dirty data row key range includes: determining a first timestamp of the dirty data corresponding to the dirty data row key range in the HBase database; determining a second timestamp based on the first timestamp, wherein the second timestamp is greater than or equal to the first timestamp; associating a second timestamp of the dirty data being written and a deletion tag in the HBase database, wherein the second timestamp and the deletion tag are used to instruct the HBase database to delete the dirty data.
2. The data rollback method based on HBase as described in claim 1, characterized in that, The step of obtaining the dirty data row key range corresponding to the account to be queried includes: The lower limit of the interval is determined based on the account to be queried and the first batch date, and the upper limit of the interval is determined based on the account to be queried and the second batch date; The dirty data row key range is determined based on the lower limit and the upper limit of the range.
3. The data rollback method based on HBase as described in claim 1, characterized in that, Before the step of obtaining the first batch of dates with the latest timestamp in the batch date table based on the HBase database, and the second batch of dates with the largest timestamp in the batch date table, the method further includes: When it is detected that the business system stores the business data of the day into the HBase database, the batch date corresponding to the business data of the day is added to the batch date table, and the timestamp when the batch date of the day is added to the batch date table is associated with the batch date of the day and added to the batch date table.
4. The HBase-based data rollback method as described in claim 3, characterized in that, After the step of rolling back the corresponding dirty data in the HBase database based on the dirty data row key range, so as to output a response message indicating that the data query result is empty when the data query process is executed according to the data query request, the method further includes: When it is detected that the business system has updated and stored normal data of the first batch date and subsequent batch dates to the HBase database, the first batch date and subsequent batch dates are added to the batch date table again, and a new timestamp is added accordingly.
5. A data rollback system based on HBase, characterized in that, The HBase-based data rollback system includes: The request receiving module is used to receive data query requests and obtain the account to be queried and the date to be queried carried in the data query request; The interval determination module is used to obtain the first batch date with the latest timestamp in the batch date table based on the HBase database, and the second batch date with the largest date in the batch date table; if the first batch date is less than the second batch date, and the date to be queried is greater than or equal to the first batch date and less than or equal to the second batch date, and a rollback flag is detected, then it is determined that data rollback is required, and the dirty data row key interval corresponding to the account to be queried is obtained; The rollback query module is used to roll back the corresponding dirty data in the HBase database according to the dirty data row key range, so as to output a response message that the data query result is empty when the data query process is executed according to the data query request; The step of rolling back the corresponding dirty data in the HBase database based on the dirty data row key range includes: determining a first timestamp of the dirty data corresponding to the dirty data row key range in the HBase database; determining a second timestamp based on the first timestamp, wherein the second timestamp is greater than or equal to the first timestamp; associating a second timestamp of the dirty data being written and a deletion tag in the HBase database, wherein the second timestamp and the deletion tag are used to instruct the HBase database to delete the dirty data.
6. A data rollback device based on HBase, characterized in that, The HBase-based data rollback device includes: a memory, a processor, and an HBase-based data rollback program stored in the memory and executable on the processor. When the HBase-based data rollback program is executed by the processor, it implements the steps of the HBase-based data rollback method as described in any one of claims 1 to 4.
7. A computer storage medium, characterized in that, The computer storage medium stores an HBase-based data rollback program, which, when executed by the processor, implements the steps of the HBase-based data rollback method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method for processing high-concurrency transactions
CN107274162A
Financial data storage method and device based on HBase and storage medium
CN109829015A