Information processing method, information processing device, electronic device, medium
Patent Information
- Application Number
- CN202310574258.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-19
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2043-05-19
AI Technical Summary
[0004]本公开提供一种信息处理方法、信息处理装置、电子设备、计算机可读存储介质及计算机程序产品,以至少解决相关技术中对热点账户的资源数据进行操作时出现错误或延时的问题
[0026] In one embodiment of the information processing method provided by this disclosure, a transaction insertion request can be received, a transaction can be inserted into a first type database, and when the transaction is successfully inserted into the first type database, data is updated in a second type database according to the transaction. When the data is successfully updated in the second type database, the transaction is committed in the first type database. This embodiment of the disclosure can combine two databases to process transactions, maintaining the transaction in one database and caching the corresponding data in the other database. This separation of the transaction from its corresponding data improves the stability of data management, supports high-concurrency operations, avoids operation failures or delays for hot accounts, and thus ensures the accuracy of account-related data.
Smart Images

Figure CN116644075B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to an information processing method, an information processing apparatus, an electronic device, a computer-readable storage medium, and a computer program product. Background Technology
[0002] With the advent of the big data era, data storage has become extremely important. A database is a repository for organizing, storing, and managing data according to a data structure; it is a large, organized, shareable, and uniformly managed collection of data stored permanently on a computer. As an effective technology for data management, databases play an increasingly important role.
[0003] In existing technologies, using a single database for data management can lead to data anomalies in certain scenarios. For example, with frequently accessed accounts, multiple operations on their related resource data may be required within a short period, easily reaching system performance bottlenecks and causing operations on account-related resource data to fail or be delayed, or resulting in errors in the account-related resource data. Summary of the Invention
[0004] This disclosure provides an information processing method, an information processing apparatus, an electronic device, a computer-readable storage medium, and a computer program product to at least solve the problems of errors or delays that occur when operating on resource data of hot accounts in related technologies. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, an information processing method is provided, comprising: receiving a transaction insertion request and inserting a transaction into a first type database; wherein the first type database is used to maintain transactions; when a transaction is successfully inserted into the first type database, updating data in a second type database according to the transaction; wherein the second type database is used to cache data corresponding to the transaction; and when the data is successfully updated in the second type database, committing the transaction in the first type database.
[0006] Optionally, the method further includes: rolling back the transaction when the data update fails in the second type of database; wherein the rollback process restores the state to that before the update in the second type of database.
[0007] Optionally, if a transaction reduces the resource data corresponding to an account, and the transaction has a reduction value, the data update in the second type database may fail, including when the resource data corresponding to the account is less than the reduction value.
[0008] Optionally, the method further includes: searching for resource data corresponding to the account and transaction identifier corresponding to the account in the second type database; obtaining the transaction corresponding to the account in the first type database based on the transaction identifier corresponding to the account, and calculating the verification resource data corresponding to the account based on the transaction corresponding to the account; comparing the resource data corresponding to the account with the verification resource data corresponding to the account; and updating the resource data table in the first type database with the resource data corresponding to the account when the resource data corresponding to the account and the verification resource data corresponding to the account are the same.
[0009] Optionally, the method further includes: deleting the resource data corresponding to the account in the second type database when the resource data corresponding to the account is different from the verification resource data corresponding to the account; and loading the verification resource data corresponding to the account into the second type database.
[0010] Optionally, the method further includes: receiving a resource query request, querying resource data corresponding to the account in the second type database; and returning the resource data corresponding to the account if the resource data corresponding to the account exists in the second type database.
[0011] Optionally, the method further includes: when the resource data corresponding to the account does not exist in the second type database, acquiring a distributed lock for calculating the resource data corresponding to the account; when the distributed lock for calculating the resource data corresponding to the account is acquired, acquiring the transaction corresponding to the account in the first type database, calculating the resource data corresponding to the account based on the transaction corresponding to the account, and returning the resource data corresponding to the account.
[0012] According to a second aspect of the present disclosure, an information processing apparatus is provided, comprising: a transaction insertion unit configured to receive a transaction insertion request and insert a transaction into a first type database; wherein the first type database is used to maintain transactions; a data update unit configured to update data in a second type database according to the transaction when the transaction is successfully inserted into the first type database; wherein the second type database is used to cache data corresponding to the transaction; and a transaction commit unit configured to commit the transaction in the first type database when the data is successfully updated in the second type database.
[0013] Optionally, the apparatus further includes: a rollback processing unit configured to perform a rollback of the transaction when the data update fails in the second type database; wherein the rollback processing restores the state to that prior to the update in the second type database.
[0014] Optionally, if the transaction reduces the resource data corresponding to an account, and the transaction has a reduction value, and the data update fails in the second type database, the device further includes: an update failure unit, configured to execute the update failure in the second type database when the resource data corresponding to the account is less than the reduction value.
[0015] Optionally, the apparatus further includes: a transaction identifier acquisition unit, configured to perform a search for resource data corresponding to an account and a transaction identifier corresponding to the account in a second type database; a verification resource data calculation unit, configured to perform a search for a transaction corresponding to an account in a first type database based on the transaction identifier corresponding to the account, and to calculate verification resource data corresponding to the account based on the transaction corresponding to the account; a resource data comparison unit, configured to perform a comparison between the resource data corresponding to the account and the verification resource data corresponding to the account; and a resource data table update unit, configured to update the resource data table in the first type database with the resource data corresponding to the account when the resource data corresponding to the account and the verification resource data corresponding to the account are the same.
[0016] Optionally, the apparatus further includes: a resource data deletion unit configured to delete the resource data corresponding to the account in the second type database when the resource data corresponding to the account is different from the verification resource data corresponding to the account; and a resource data loading unit configured to load the verification resource data corresponding to the account into the second type database.
[0017] Optionally, the device further includes: a resource data query unit configured to receive a resource query request and query resource data corresponding to an account in a second type database; and a resource data return unit configured to return the resource data corresponding to an account when the resource data corresponding to the account exists in the second type database.
[0018] Optionally, the apparatus further includes: a distributed lock acquisition unit, configured to acquire a distributed lock for calculating the resource data corresponding to the account when the resource data corresponding to the account does not exist in the second type database; and a resource data calculation unit, configured to acquire the transaction corresponding to the account in the first type database when the distributed lock for calculating the resource data corresponding to the account is acquired, calculate the resource data corresponding to the account based on the transaction corresponding to the account, and return the resource data corresponding to the account.
[0019] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0020] processor;
[0021] Memory used to store processor-executable instructions;
[0022] The processor is configured to execute executable instructions to implement the information processing method described above.
[0023] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the above-described information processing method.
[0024] According to a fifth aspect of the present disclosure, a computer program product is provided, a computer program / instruction, characterized in that the computer program / instruction implements the above-described information processing method when executed by a processor.
[0025] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0026] In one embodiment of the information processing method provided by this disclosure, a transaction insertion request can be received, a transaction can be inserted into a first type database, and when the transaction is successfully inserted into the first type database, data is updated in a second type database according to the transaction. When the data is successfully updated in the second type database, the transaction is committed in the first type database. This embodiment of the disclosure can combine two databases to process transactions, maintaining the transaction in one database and caching the corresponding data in the other database. This separation of the transaction from its corresponding data improves the stability of data management, supports high-concurrency operations, avoids operation failures or delays for hot accounts, and thus ensures the accuracy of account-related data.
[0027] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0028] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0029] Figure 1 This schematic diagram illustrates an exemplary system architecture for implementing an information processing method in an exemplary embodiment of the present disclosure;
[0030] Figure 2 This is a flowchart illustrating an information processing method according to an exemplary embodiment;
[0031] Figure 3 This is a flowchart illustrating another information processing method according to an exemplary embodiment;
[0032] Figure 4 This is a flowchart illustrating an exemplary embodiment of updating a resource data table in a first type database using the resource data corresponding to the account when the resource data corresponding to the account is the same as the verification resource data corresponding to the account.
[0033] Figure 5 This is a flowchart illustrating, according to an exemplary embodiment, a process of deleting resource data corresponding to an account in a second type database and loading verification resource data corresponding to the account into the second type database;
[0034] Figure 6 This is a schematic diagram illustrating, according to an exemplary embodiment, whether the corresponding resource data is the same as the verification resource data corresponding to the account;
[0035] Figure 7 This is a flowchart illustrating, according to an exemplary embodiment, a method for returning resource data corresponding to an account when resource data corresponding to an account exists in a second type of database;
[0036] Figure 8 This is a flowchart illustrating, according to an exemplary embodiment, a method for calculating resource data corresponding to an account based on the transaction corresponding to the account and returning the resource data corresponding to the account;
[0037] Figure 9 This is a schematic diagram illustrating a method for querying resource data corresponding to an account in a second type of database, according to an exemplary embodiment.
[0038] Figure 10 This is a schematic diagram illustrating the composition of an information processing apparatus according to an exemplary embodiment;
[0039] Figure 11 This is a schematic diagram illustrating the structure of an electronic device suitable for implementing exemplary embodiments of the present disclosure, according to an exemplary embodiment. Detailed Implementation
[0040] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0041] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0042] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, or in one or more software-hardened modules, or in different network and / or processor devices and / or microcontroller devices.
[0043] Figure 1 A schematic diagram of an exemplary system architecture to which the information processing method of the present disclosure embodiments can be applied is shown.
[0044] like Figure 1 As shown, system architecture 1000 may include one or more of terminal devices 1001, 1002, and 1003, network 1004, and server 1005. Network 1004 is used as a medium to provide a communication link between terminal devices 1001, 1002, and 1003 and server 1005. Network 1004 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0045] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included. For example, server 1005 could be a server cluster composed of multiple servers.
[0046] Users can use terminal devices 1001, 1002, and 1003 to interact with server 1005 via network 1004 to receive or send messages, etc. Terminal devices 1001, 1002, and 1003 can be various electronic devices with displays, including but not limited to smartphones, tablets, laptops, and desktop computers. Additionally, server 1005 can be a server providing various services.
[0047] In one embodiment, the execution entity of the information processing method disclosed herein may be a server 1005. The server 1005 may obtain transaction insertion requests sent by terminal devices 1001, 1002, and 1003, and insert transactions into a first type database. When a transaction is successfully inserted into the first type database, data is updated in a second type database according to the transaction. When the data is successfully updated in the second type database, the transaction is committed in the first type database.
[0048] In addition, the information processing method disclosed herein can also be executed through terminal devices 1001, 1002, 1003, etc., to receive transaction insertion requests, insert transactions into the first type database, update data in the second type database according to the transactions when the transactions are successfully inserted into the first type database, and commit the transactions in the first type database when the data is successfully updated in the second type database.
[0049] Furthermore, the implementation process of this information processing method can also be jointly implemented by terminal devices 1001, 1002, and 1003 and server 1005. For example, terminal devices 1001, 1002, and 1003 can receive transaction insertion requests, insert transactions into the first type database, update data in the second type database according to the transactions when the transactions are successfully inserted into the first type database, and commit the transactions in the first type database when the data is successfully updated in the second type database. The processing result is then returned to server 1005.
[0050] With the advent of the big data era, data storage has become extremely important. A database is a repository for organizing, storing, and managing data according to a data structure; it is a large, organized, shareable, and uniformly managed collection of data stored permanently on a computer. As an effective technology for data management, databases play an increasingly important role.
[0051] In existing technologies, using a single database for data management can lead to data anomalies in certain scenarios. For example, with frequently accessed accounts, multiple operations on their related resource data may be required within a short period, easily reaching system performance bottlenecks and causing operations on account-related resource data to fail or be delayed, or resulting in errors in the account-related resource data.
[0052] Figure 2 This is a flowchart illustrating an information processing method according to an exemplary embodiment, such as... Figure 2 As shown, the information processing method may include the following steps.
[0053] In step S210, a transaction insertion request is received, and a transaction is inserted into the first type database; wherein, the first type database is used to maintain transactions;
[0054] In step S220, when a transaction successfully inserts data into the first type database, the data is updated in the second type database according to the transaction; wherein, the second type database is used to cache the data corresponding to the transaction;
[0055] In step S230, when the data is successfully updated in the second type database, the transaction is committed in the first type database.
[0056] In one embodiment of the information processing method provided by this disclosure, a transaction insertion request can be received, a transaction can be inserted into a first type database, and when the transaction is successfully inserted into the first type database, data is updated in a second type database according to the transaction. When the data is successfully updated in the second type database, the transaction is committed in the first type database. This embodiment of the disclosure can combine two databases to process transactions, maintaining the transaction in one database and caching the corresponding data in the other database. This separation of the transaction from its corresponding data improves the stability of data management, supports high-concurrency operations, avoids operation failures or delays for hot accounts, and thus ensures the accuracy of account-related data.
[0057] Below, we will combine Figure 2 The embodiments will provide a more detailed description of steps S210 to S240 of the information processing method in this exemplary embodiment.
[0058] Step S210: Receive a transaction insertion request and insert a transaction into the first type of database;
[0059] In one example embodiment of this disclosure, a transaction insert request can be received to insert a transaction into a first type of database. The first type of database is used to maintain transactions. Specifically, the transaction insert request can be used to insert a transaction into the first type of database. For example, the transaction insert request can be an insert operation in the first type of database.
[0060] It should be noted that this disclosure does not impose any special restrictions on the specific form of the transaction insertion request.
[0061] In one example embodiment of this disclosure, after receiving a transaction insertion request, a transaction can be inserted into a first type of database. Specifically, a transaction may include adding, deleting, or modifying data corresponding to the transaction.
[0062] For example, a transaction can delete a portion of an account's resource data.
[0063] It should be noted that this disclosure does not impose any special restrictions on the specific method of inserting transactions into the first type of database.
[0064] In one example embodiment of this disclosure, the first type of database can be a database that uses a relational model to organize data, such as a relational database, which stores data in the form of rows and columns. This series of rows and columns is called a table, and a set of tables constitutes a database. Users retrieve data from the database through queries, and a query is a piece of executable code used to limit certain areas of the database. The relational model can be simply understood as a two-dimensional table model, and a first type of database is a data organization composed of two-dimensional tables and the relationships between them. For example, an account details table can be maintained in a first type of database.
[0065] In one example embodiment of this disclosure, the first type of database may be an OceanBase database (a distributed first type of database).
[0066] It should be noted that this disclosure does not impose any special restrictions on the specific type of the first type of database.
[0067] In one example embodiment of this disclosure, the second type of database refers to a database that stores data in key-value pairs, achieving high-speed data caching, improving application responsiveness, and greatly alleviating the pressure on the backend database. Based on the data storage method, it can be divided into three types: temporary, permanent, and a combination of both.
[0068] In one example embodiment of this disclosure, the second type of database may be a Redis (RemoteDictionary Server) database.
[0069] It should be noted that this disclosure does not impose any special restrictions on the specific type of the second type of database.
[0070] Step S220: When the transaction successfully inserts data into the first type of database, update the data in the second type of database according to the transaction.
[0071] In one example embodiment of this disclosure, after inserting a transaction into the first type database through the above steps, it can be determined whether the transaction was successfully inserted. When the transaction is successfully inserted into the first type database, data is updated in the second type database according to the transaction. The second type database is used to cache the data corresponding to the transaction. Specifically, a successful insertion of a transaction into the first type database indicates that the data corresponding to that transaction needs to be updated in the second type database.
[0072] For example, if a transaction is to delete some resource data of an account, and the transaction is successfully inserted into the first type of database, the account can be found in the second type of database, and some of the account's resource data can be deleted.
[0073] It should be noted that this disclosure does not impose any special restrictions on the specific methods of updating data in the second type of database based on transactions.
[0074] In one example embodiment of this disclosure, when a transaction fails to insert data into the first type of database, an operation failure message can be returned. Specifically, a transaction failure to insert data into the first type of database indicates that the transaction could not be successfully inserted into the first type of database, and in this case, an operation failure message can be returned.
[0075] For example, if the response time is longer than the preset time when inserting a transaction into the first type of database, it indicates that the transaction failed to be inserted into the first type of database, and an operation failure message can be returned.
[0076] In one example embodiment of this disclosure, the second database may be a cached database.
[0077] It should be noted that this disclosure does not specifically limit the type of failure of a transaction to insert data into a first-type database.
[0078] In one example embodiment of this disclosure, an operation failure message may be returned to the upstream account.
[0079] Step S230: When the data is successfully updated in the second type database, commit the transaction in the first type database.
[0080] In one example embodiment of this disclosure, after updating data in the second type database according to the above steps, it can be determined whether the update was successful. When the data is successfully updated in the second type database, the transaction is committed in the first type database. Specifically, when the data is successfully updated in the second type database, it indicates that the data has been updated in the second type database for the transaction. At this time, the transaction can be committed in the first type database, indicating that the transaction has been completed. Specifically, committing means committing all operations of the transaction, that is, all updates to the database in the transaction are written to the disk, and the transaction ends normally.
[0081] It should be noted that this disclosure does not impose any special restrictions on the specific method of submitting transactions in the first type of database.
[0082] In one example embodiment of this disclosure, when data updates fail in the second type of database, the transaction is rolled back. Rollback means restoring the data to its state before the update in the second type of database. Specifically, data update failure in the second type of database indicates that the data update was unsuccessful, meaning the transaction was not executed in the second type of database, and a rollback can be performed in this case. More specifically, rollback refers to the act of restoring the program or data to its previous correct state after a program or data processing error. Rollback includes types such as program rollback and data rollback.
[0083] In one example embodiment of this disclosure, the data update in the second type of database fails when the resource data corresponding to the account is less than the reduction value. Specifically, the transaction reduces the resource data corresponding to the account, and the transaction has a reduction value. The reduction operation can only be performed when the resource data corresponding to the account is less than the reduction value.
[0084] For example, if a transaction reduces the resource data corresponding to an account, and the resource data in that account is less than the reduction value corresponding to the transaction, the transaction cannot be executed, and the data update fails in the second type of database. In this case, the transaction needs to be rolled back.
[0085] It should be noted that this disclosure does not specifically limit the type of data update failure in the second type of database.
[0086] In one exemplary embodiment of this disclosure, such as Figure 3 As shown, transaction processing can be performed in multiple threads (thread 1, thread 2, thread 3). It can receive transaction insertion requests, insert transactions into the first type database, and determine whether the insertion was successful (whether the transaction was successfully inserted into the first type database). If the insertion is successful, the data is updated in the second type database according to the transaction. If the insertion fails, an operation failure message is returned. It also determines whether the update was successful (whether the data was successfully updated in the second type database). If the update is successful, the transaction is committed in the first type database. If the update fails, the transaction is rolled back.
[0087] In one example embodiment of this disclosure, Lua scripts (scripting languages) can be used to update transactions to ensure atomicity.
[0088] In one example embodiment of this disclosure, resource data corresponding to an account and transaction identifier corresponding to the account can be searched in a second type database. The transaction corresponding to the account is retrieved from the first type database based on the transaction identifier. Verification resource data corresponding to the account is calculated based on the transaction. The resource data corresponding to the account is compared with the verification resource data. If the resource data and verification resource data are the same, the resource data corresponding to the account is used to update the resource data table in the first type database. (Refer to...) Figure 4 As shown, when the resource data corresponding to an account is the same as the verification resource data corresponding to the account, updating the resource data table in the first type database with the resource data corresponding to the account may include the following steps S410 to S440:
[0089] Step S410: Search for the resource data corresponding to the account and the transaction identifier corresponding to the account in the second type database;
[0090] In one example embodiment of this disclosure, resource data corresponding to an account and transaction identifiers corresponding to the account can be searched in a second type of database. Specifically, the second type of database can store resource data corresponding to an account and transaction identifiers corresponding to the account. Specifically, the transaction identifiers corresponding to an account can be used to search for transactions related to the transaction identifiers corresponding to that account in a first type of database.
[0091] For example, the transaction identifier corresponding to an account can be the primary key ID of the detail table maintained in the first type of database.
[0092] It should be noted that this disclosure does not impose any special restrictions on the specific form of the transaction identifier corresponding to the account.
[0093] Furthermore, the resource data corresponding to the account and the transaction identifier corresponding to the account can be found in the second type database based on the identifier corresponding to the account.
[0094] For example, the identifier corresponding to an account can be an account ID.
[0095] It should be noted that this disclosure does not impose any special restrictions on the specific form of account identification.
[0096] Step S420: Obtain the transaction corresponding to the account from the first type database according to the transaction identifier corresponding to the account, and calculate the verification resource data corresponding to the account based on the transaction corresponding to the account.
[0097] In one example embodiment of this disclosure, after obtaining the resource data and transaction identifier corresponding to the account through the above steps, the transaction corresponding to the account can be retrieved from the first type database based on the transaction identifier. Specifically, the transaction identifier can be used to search for transactions related to the transaction identifier of the account in the first type database. Therefore, the transaction corresponding to the account can be searched in the first type database using the transaction identifier, and the transaction corresponding to the account can be used to indicate all operations performed by the account.
[0098] It should be noted that this disclosure does not impose any special restrictions on the specific method of obtaining the transaction corresponding to an account in the first type of database based on the transaction identifier corresponding to the account.
[0099] In one example embodiment of this disclosure, after obtaining the transactions corresponding to the account through the above steps, the verification resource data corresponding to the account can be calculated based on the transactions. Specifically, the transactions corresponding to the account can be summarized to obtain the verification resource data corresponding to the account.
[0100] It should be noted that this disclosure does not impose any special restrictions on the specific method for calculating the verification resource data corresponding to an account based on the transaction corresponding to the account.
[0101] Step S430: Compare the resource data corresponding to the account with the verification resource data corresponding to the account;
[0102] Step S440: When the resource data corresponding to the account is the same as the verification resource data corresponding to the account, update the resource data table in the first type database with the resource data corresponding to the account.
[0103] In one example embodiment of this disclosure, after obtaining the resource data corresponding to the account and the verification resource data corresponding to the account through the above steps, it is possible to compare whether the resource data corresponding to the account and the verification resource data corresponding to the account are the same. If the resource data corresponding to the account and the verification resource data corresponding to the account are the same, it means that the verification resource data corresponding to the account stored in the second type database is correct. At this time, the resource data corresponding to the account can be used to update the resource data table in the first type database.
[0104] It should be noted that this disclosure does not impose any special restrictions on the specific method of updating the resource data table in the first type of database using the resource data corresponding to the account.
[0105] Specifically, the resource data table in the first type of database is a table maintained by the first type of database, and the resource data table can be used to record resource data for multiple accounts.
[0106] It should be noted that this disclosure does not impose any special restrictions on the specific form of resource data tables in the first type of database.
[0107] The disclosed solution can perform consistency verification on both type 1 and type 2 databases.
[0108] Furthermore, the scheme of this embodiment can be executed at preset time intervals. For example, the scheme of this embodiment can be executed every 5 minutes.
[0109] Through the aforementioned steps S410-S440, resource data and transaction identifiers corresponding to the account can be retrieved in the second type database. The transaction corresponding to the account is then obtained from the first type database based on the transaction identifier. Verification resource data corresponding to the account is calculated based on the transaction. This resource data is compared with the verification resource data. If the two data match, the resource data in the first type database is used to update the resource data table. Through the embodiments of this disclosure, data in both the second and first type databases can be verified, ensuring the accuracy of the system under high-concurrency scenarios.
[0110] In one example embodiment of this disclosure, when the resource data corresponding to an account differs from the verification resource data corresponding to the account, the resource data corresponding to the account is deleted from the second type database, and the verification resource data corresponding to the account is loaded into the second type database. (Refer to...) Figure 5 As shown, deleting the resource data corresponding to the account in the second type database and loading the verification resource data corresponding to the account into the second type database may include the following steps S510 to S520:
[0111] Step S510: When the resource data corresponding to the account is different from the verification resource data corresponding to the account, delete the resource data corresponding to the account in the second type database.
[0112] In one example embodiment of this disclosure, after determining whether the resource data corresponding to the account is the same as the verification resource data corresponding to the account through the above steps, if the resource data corresponding to the account is different from the verification resource data corresponding to the account, it indicates that the resource data corresponding to the account stored in the second type database is incorrect, that is, there is dirty data in the second type database. At this time, the resource data corresponding to the account can be deleted from the second type database.
[0113] Step S520: Load the verification resource data corresponding to the account into the second type database.
[0114] In one example embodiment of this disclosure, after deleting the resource data corresponding to the account in the second type database through the above steps, the verification resource data corresponding to the account can be loaded into the second type database. Specifically, after deleting the resource data corresponding to the account in the second type database, the verification resource data corresponding to the account calculated through the above steps can be stored as the resource data corresponding to the account in the second type database.
[0115] It should be noted that this disclosure does not impose any special restrictions on the specific method of loading the verification resource data corresponding to the account into the second type of database.
[0116] In one exemplary embodiment of this disclosure, such as Figure 6 As shown, a verification task can be executed periodically. After a preset time is reached, the data verification task begins. It searches for the resource data and transaction identifier corresponding to the account in the second type database. Based on the transaction identifier, it retrieves the transaction corresponding to the account in the first type database. Based on the transaction, it calculates the verification resource data corresponding to the account and compares it with the verification resource data. It determines whether the resource data and the verification resource data are the same. If they are the same, the resource data table in the first type database is updated with the resource data corresponding to the account. If they are different, the resource data corresponding to the account is deleted from the second type database.
[0117] Through the aforementioned steps S510-S520, when the resource data corresponding to an account differs from the verification resource data corresponding to the account, the resource data corresponding to the account is deleted from the second type database, and the verification resource data corresponding to the account is loaded into the second type database. Through the embodiments of this disclosure, data in the second type database and the first type database can be verified, correcting data inconsistencies caused by hardware or network factors during system operation, and ensuring the accuracy of the system under high-concurrency scenarios.
[0118] In one example embodiment of this disclosure, a resource query request can be received, resource data corresponding to an account can be queried in a second type database, and if resource data corresponding to the account exists in the second type database, the resource data corresponding to the account can be returned. (Refer to...) Figure 7 As shown, when resource data corresponding to an account exists in the second type of database, returning the resource data corresponding to the account may include the following steps S710 to S720:
[0119] Step S710: Receive a resource query request and query the resource data corresponding to the account in the second type database;
[0120] Step S720: If resource data corresponding to the account exists in the second type database, return the resource data corresponding to the account.
[0121] In one example embodiment of this disclosure, a resource query request can be received to query resource data corresponding to an account in a second type database. Specifically, the resource query request can be used to query resource data corresponding to a specific account in the second type database. If resource data corresponding to the account exists in the second type database, the resource data corresponding to the account can be directly returned. More specifically, the resource query request includes an identifier corresponding to the account, and the resource data corresponding to the account can be queried in the second type database using this identifier.
[0122] It should be noted that this disclosure does not impose any special restrictions on the specific methods for querying resource data corresponding to an account in the second type of database.
[0123] Through the above steps S710 to S720, a resource query request can be received, the resource data corresponding to the account can be queried in the second type database, and if the resource data corresponding to the account exists in the second type database, the resource data corresponding to the account can be returned.
[0124] In one example embodiment of this disclosure, when resource data corresponding to an account does not exist in the second type database, a distributed lock for calculating the resource data corresponding to the account is acquired. Once the distributed lock for calculating the resource data corresponding to the account is acquired, the transaction corresponding to the account is retrieved from the first type database. The resource data corresponding to the account is calculated based on the transaction, and the resource data corresponding to the account is returned. (Refer to...) Figure 8 As shown, calculating the resource data corresponding to the account based on the transaction corresponding to the account and returning the resource data corresponding to the account may include the following steps S810 to S820:
[0125] Step S810: If the resource data corresponding to the account does not exist in the second type database, acquire the distributed lock for calculating the resource data corresponding to the account.
[0126] In one example embodiment of this disclosure, after querying the resource data corresponding to the account in the second type database through the above steps, if the resource data corresponding to the account does not exist in the second type database, it is necessary to calculate the resource data corresponding to the account based on the first type database. At this time, a distributed lock for calculating the resource data corresponding to the account can be acquired first. Specifically, a distributed lock refers to a lock in a distributed system, which can solve the problem of controlling access to shared resources in a distributed system. Specifically, a distributed lock has the following characteristics: in a distributed system environment, a method can only be executed by one thread on one machine at a time; highly available lock acquisition and release; high-performance lock acquisition and release; reentrancy; lock invalidation mechanism (automatic unlocking); deadlock prevention; and non-blocking lock characteristics (failure to acquire the lock will directly return a lock acquisition failure).
[0127] It should be noted that this disclosure does not impose any special restrictions on the specific implementation form of distributed locks.
[0128] Step S820: When the distributed lock for the resource data corresponding to the computing account is obtained, the transaction corresponding to the account is obtained from the first type database, the resource data corresponding to the account is calculated based on the transaction corresponding to the account, and the resource data corresponding to the account is returned.
[0129] In one example embodiment of this disclosure, when the distributed lock for calculating resource data corresponding to the account is obtained through the above steps, the transaction corresponding to the account can be retrieved from the first type database, the resource data corresponding to the account can be calculated based on the transaction, and the resource data corresponding to the account can be returned. Specifically, the transaction identifier corresponding to the account can be searched in the second type database, and the transaction corresponding to the account can be retrieved from the first type database based on the transaction identifier. Then, the resource data corresponding to the account can be calculated based on the transaction, and finally, the calculated resource data corresponding to the account can be returned.
[0130] It should be noted that this disclosure does not impose any special restrictions on the specific method of calculating the resource data corresponding to an account based on the transactions associated with that account.
[0131] Furthermore, if the distributed lock for the resource data corresponding to the calculation account is not acquired through the above steps, it indicates that another thread is already calculating the resource data corresponding to the account based on the transaction. At this point, the current thread can be terminated, that is, the task of calculating the resource data corresponding to the account can be terminated.
[0132] In one exemplary embodiment of this disclosure, such as Figure 9As shown, it can receive resource query requests, query resource data corresponding to an account in the second type database, determine whether resource data corresponding to an account exists in the second type database, and if it exists, return the resource data corresponding to the account; if it does not exist, acquire a distributed lock for calculating the resource data corresponding to the account. When the distributed lock for calculating the resource data corresponding to the account is not acquired, the current thread ends. When the distributed lock for calculating the resource data corresponding to the account is acquired, the resource data corresponding to the account can be calculated according to the transaction corresponding to the account, the resource data table in the first type database is updated according to the resource data corresponding to the account, and the resource data corresponding to the account is updated in the second type database.
[0133] Through the steps S810-S820 described above, when the resource data corresponding to an account does not exist in the second type of database, a distributed lock for calculating the resource data corresponding to the account can be acquired. Once the distributed lock for calculating the resource data corresponding to the account is acquired, the transaction corresponding to the account is retrieved from the first type of database, the resource data corresponding to the account is calculated based on the transaction, and the resource data corresponding to the account is returned. Through the solution of this embodiment, when querying resource data, a distributed lock can be used to control data access, avoiding data errors caused by accessing resource data in high-concurrency scenarios.
[0134] In one embodiment of the information processing method provided by this disclosure, a transaction insertion request can be received, a transaction can be inserted into a first type database, and when the transaction is successfully inserted into the first type database, data is updated in a second type database according to the transaction. When the data is successfully updated in the second type database, the transaction is committed in the first type database. This embodiment of the disclosure, by processing transactions through the first and second type databases, can support high-concurrency operations, avoid operation failures or delays for frequently accessed accounts, and thus ensure the accuracy of account-related data.
[0135] Figure 10 This is a block diagram of an information processing apparatus according to an exemplary embodiment. (Refer to...) Figure 10 The information processing device 1000 includes a transaction insertion unit 1010, a data update unit 1020, and a transaction submission unit 1030.
[0136] The transaction insertion unit is configured to receive a transaction insertion request and insert the transaction into a first type database, wherein the first type database is used to maintain transactions. The data update unit is configured to update the data in a second type database according to the transaction when the transaction is successfully inserted into the first type database, wherein the second type database is used to cache the data corresponding to the transaction. The transaction commit unit is configured to commit the transaction in the first type database when the data is successfully updated in the second type database.
[0137] Optionally, the apparatus further includes: a rollback processing unit configured to perform a rollback of the transaction when the data update fails in the second type database; wherein the rollback processing restores the state to that prior to the update in the second type database.
[0138] Optionally, if the transaction reduces the resource data corresponding to an account, and the transaction has a reduction value, and the data update fails in the second type database, the device further includes: an update failure unit, configured to execute the update failure in the second type database when the resource data corresponding to the account is less than the reduction value.
[0139] Optionally, the apparatus further includes: a transaction identifier acquisition unit, configured to perform a search for resource data corresponding to an account and a transaction identifier corresponding to the account in a second type database; a verification resource data calculation unit, configured to perform a search for a transaction corresponding to an account in a first type database based on the transaction identifier corresponding to the account, and to calculate verification resource data corresponding to the account based on the transaction corresponding to the account; a resource data comparison unit, configured to perform a comparison between the resource data corresponding to the account and the verification resource data corresponding to the account; and a resource data table update unit, configured to update the resource data table in the first type database with the resource data corresponding to the account when the resource data corresponding to the account and the verification resource data corresponding to the account are the same.
[0140] Optionally, the apparatus further includes: a resource data deletion unit configured to delete the resource data corresponding to the account in the second type database when the resource data corresponding to the account is different from the verification resource data corresponding to the account; and a resource data loading unit configured to load the verification resource data corresponding to the account into the second type database.
[0141] Optionally, the device further includes: a resource data query unit configured to receive a resource query request and query resource data corresponding to an account in a second type database; and a resource data return unit configured to return the resource data corresponding to an account when the resource data corresponding to the account exists in the second type database.
[0142] Optionally, the apparatus further includes: a distributed lock acquisition unit, configured to acquire a distributed lock for calculating the resource data corresponding to the account when the resource data corresponding to the account does not exist in the second type database; and a resource data calculation unit, configured to acquire the transaction corresponding to the account in the first type database when the distributed lock for calculating the resource data corresponding to the account is acquired, calculate the resource data corresponding to the account based on the transaction corresponding to the account, and return the resource data corresponding to the account.
[0143] One embodiment of this disclosure provides an information processing apparatus that can receive transaction insertion requests, insert transactions into a first type database, update data in a second type database based on the transactions when the transactions are successfully inserted into the first type database, and commit the transactions in the first type database when the data updates are successful in the second type database. This embodiment of the disclosure, by processing transactions through both the first and second type databases, can support high-concurrency operations, avoid operation failures or delays for frequently accessed accounts, and thus ensure the accuracy of account-related data.
[0144] Regarding the information processing apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0145] The following reference Figure 11 To describe an electronic device 1100 according to such an embodiment of the present disclosure. Figure 11 The electronic device 1100 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0146] like Figure 11 As shown, the electronic device 1100 is manifested in the form of a general-purpose computing device. The components of the electronic device 1100 may include, but are not limited to: at least one processing unit 1110, at least one storage unit 1120, a bus 1130 connecting different system components (including storage unit 1120 and processing unit 1110), and a display unit 1140.
[0147] The storage unit stores program code, which can be executed by the processing unit 1110 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 1110 can perform actions such as... Figure 2In step S210, a transaction insertion request is received, and a transaction is inserted into the first type database; wherein, the first type database is used to maintain transactions; in step S220, when the transaction is successfully inserted into the first type database, data is updated in the second type database according to the transaction; wherein, the second type database is used to cache the data corresponding to the transaction; in step S230, when the data is successfully updated in the second type database, the transaction is committed in the first type database.
[0148] Storage unit 1120 may include readable media in the form of volatile storage units, such as random access memory (RAM) 1121 and / or cache memory 1122, and may further include read-only memory (ROM) 1123.
[0149] Storage unit 1120 may also include a program / utility 1124 having a set (at least one) program module 1125, such program module 1125 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0150] Bus 1130 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0151] Electronic device 1100 can also communicate with one or more external devices 1170 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 1100, and / or with any device that enables electronic device 1100 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1150. Furthermore, electronic device 1100 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1160. As shown, network adapter 1160 communicates with other modules of electronic device 1100 via bus 1130. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 1100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0152] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0153] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions that can be executed by a processor of the device to perform the described method. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0154] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions, which, when executed by a processor, implement the information processing method described above.
[0155] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0156] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An information processing method, characterized in that, include: Receive a transaction insertion request and insert the transaction into a first type of database; wherein, the first type of database is used to maintain the transaction, and the first type of database is a database that uses a relational model to organize data; When the transaction is successfully inserted into the first type of database, the data is updated in the second type of database according to the transaction; wherein, the second type of database is used to cache the data corresponding to the transaction, and the second type of database refers to a database that stores data in the form of key-value pairs; When the data is successfully updated in the second type of database, the transaction is committed in the first type of database; Search the resource data corresponding to the account and the transaction identifier corresponding to the account in the second type of database; Retrieve the transaction corresponding to the account from the first type database based on the transaction identifier corresponding to the account, and calculate the verification resource data corresponding to the account based on the transaction corresponding to the account. Compare the resource data corresponding to the account with the verification resource data corresponding to the account; When the resource data corresponding to the account is the same as the verification resource data corresponding to the account, the resource data table in the first type of database is updated using the resource data corresponding to the account.
2. The information processing method according to claim 1, characterized in that, The method further includes: When the data update fails in the second type of database, the transaction is rolled back; wherein, the rollback process restores the state to that before the update in the second type of database.
3. The information processing method according to claim 2, characterized in that, The transaction involves reducing the resource data corresponding to an account. The transaction has a corresponding reduction value. The data update failure in the second type of database includes: When the resource data corresponding to the account is less than the reduction value, the data update in the second type of database fails.
4. The information processing method according to claim 1, characterized in that, The method further includes: When the resource data corresponding to the account is different from the verification resource data corresponding to the account, delete the resource data corresponding to the account in the second type database. Load the verification resource data corresponding to the account into the second type of database.
5. The information processing method according to claim 1, characterized in that, The method further includes: Receive a resource query request and query the resource data corresponding to the account in the second type of database; If the resource data corresponding to the account exists in the second type of database, return the resource data corresponding to the account.
6. The information processing method according to claim 5, characterized in that, The method further includes: If the resource data corresponding to the account does not exist in the second type of database, acquire the distributed lock for calculating the resource data corresponding to the account; When the distributed lock for calculating the resource data corresponding to the account is acquired, the transaction corresponding to the account is retrieved from the first type of database, the resource data corresponding to the account is calculated based on the transaction corresponding to the account, and the resource data corresponding to the account is returned.
7. An information processing device, characterized in that, include: The transaction insertion unit is configured to receive a transaction insertion request and insert a transaction into a first type of database; wherein the first type of database is used to maintain the transaction and is a database that uses a relational model to organize data. The data update unit is configured to update data in a second type database according to the transaction when the transaction is successfully inserted into the first type database; wherein the second type database is used to cache the data corresponding to the transaction; The transaction commit unit is configured to commit the transaction in the first type database when the data is successfully updated in the second type database. The second type database refers to a database that stores data in the form of key-value pairs. The transaction identifier acquisition unit is configured to search for the resource data corresponding to the account and the transaction identifier corresponding to the account in the second type database; the verification resource data calculation unit is configured to obtain the transaction corresponding to the account in the first type database according to the transaction identifier corresponding to the account, and calculate the verification resource data corresponding to the account according to the transaction corresponding to the account; the resource data comparison unit is configured to compare the resource data corresponding to the account with the verification resource data corresponding to the account; and the resource data table update unit is configured to update the resource data table in the first type database with the resource data corresponding to the account when the resource data corresponding to the account and the verification resource data corresponding to the account are the same.
8. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the executable instructions to implement the information processing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, wherein when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the information processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Computer-implemented hotspot account transaction processing method and device, and storage medium
CN116012002A