A method, device and computer-readable storage medium for updating hotspot rows in a database

By performing pre-logical operations before transaction submission and applying for row locks only at submission, the lock competition problem caused by hot spot row updates under high concurrency is solved, and the concurrent processing performance and system performance of the database are improved.

CN114185913BActive Publication Date: 2024-11-08CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111640201.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2024-11-08
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

In high concurrency scenarios, the update request of hot spot rows leads to row lock competition and waiting, affecting database performance. Especially in scenarios such as purchase restrictions and flash sale, the update request of a single hot spot row is executed serially, resulting in a significant decline in system performance.

Method used

Perform pre-logical operations before transaction submission to determine whether the target data meets the transaction's update requirements. Only apply for actual updates when transaction submission is submitted, and release the lock after update. The sequential operations between concurrent transactions are achieved through atomic locks to reduce the number of operations in order to reduce Lock competition.

Benefits of technology

It significantly improves the concurrent processing performance of hot spot rows, reduces lock blocking time, and improves the system's transaction processing capability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114185913B_ABST
    Figure CN114185913B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device and computer-readable storage medium for updating hotspot rows in a database. The method comprises: after a transaction is started and before the transaction is committed, a pre-logical operation is performed on the target data pointed to by the transaction in the database, and the pre-logical operation is used to determine whether the target data meets the expected update requirements of the transaction, wherein the transaction is used to request to update the hotspot row corresponding to the target data in the database; when the transaction is committed, a row lock is applied to lock the hotspot row corresponding to the target data, and an actual logical operation is performed on the target data based on the expected update requirements to update the hotspot row; and after the hotspot row is updated, the row lock corresponding to the target data is released. The above method can significantly improve the concurrent processing performance of hotspot rows.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of databases, and in particular relates to a method and device for updating hotspot rows of a database, and a computer-readable storage medium. Background Art

[0002] This section is intended to provide a background or context to embodiments of the invention that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.

[0003] The rows in the database that are frequently added, deleted, modified, and queried are called hot rows. When a transaction updates a row of data, it locks the target row until the transaction is committed or rolled back. During the same period, only one transaction can update the same row of data, and other transactions need to wait. This shows that update requests for a single hot row are actually executed serially.

[0004] In high-concurrency scenarios such as purchase restrictions and flash sales, a large number of update requests for hot rows arrive at the backend database system in a very short time interval, which will inevitably cause serious row lock contention and waiting, affecting system performance. If the waiting time for an update request to be executed becomes longer, it will have a significant negative impact on the business level. Summary of the invention

[0005] In view of the above problems existing in the prior art, a method, an apparatus and a computer-readable storage medium are proposed. The above problems can be solved by using this method, an apparatus and a computer-readable storage medium.

[0006] The present invention provides the following solutions.

[0007] In a first aspect, a method for updating hot rows in a database is provided, comprising: after a transaction is started and before the transaction is committed, performing a pre-logical operation on target data pointed to by the transaction in the database, the pre-logical operation is used to determine whether the target data meets the expected update requirements of the transaction, wherein the transaction is used to request an update of a hot row corresponding to the target data in the database; when the transaction is committed, applying for a row lock to lock the hot row corresponding to the target data, performing an actual logical operation on the target data based on the expected update requirements to update the hot row; and, after the hot row is updated, releasing the row lock corresponding to the target data.

[0008] In some embodiments, performing a pre-logical operation on the target data pointed to by the transaction in the database also includes: judging whether the expected update requirement of the transaction meets the execution conditions based on the actual information of the target data and the update information to be submitted; if the execution conditions are met, updating the update information to be submitted based on the expected update requirement; if the execution conditions are not met, suspending the transaction.

[0009] In some embodiments, when there are multiple concurrent transactions, the method further includes: the database responds to the start requests of the multiple concurrent transactions and executes the pre-commit actions of each transaction in parallel; the database responds to the commit requests of the multiple concurrent transactions and executes the commit phase actions of each transaction in serial.

[0010] In some implementations, atomic locks are used to implement sequential operations of pre-logic operations between multiple concurrent transactions.

[0011] In some implementations, a transaction log is recorded after a pre-logic operation is performed on the target data and before the transaction is committed.

[0012] In some implementations, after performing a pre-logical operation on the target data and before the transaction is committed, the row corresponding to the user data in the database is updated, and the user data is the initiator of the transaction.

[0013] In a second aspect, a database hot row update device is provided, including: a pre-logical operation module, which is used to perform a pre-logical operation on the target data pointed to by the transaction in the database after the transaction is started and before the transaction is committed, and the pre-logical operation is used to determine whether the target data meets the expected update requirements of the transaction, wherein the transaction is used to request an update of the hot row corresponding to the target data in the database; a row update module, which is used to apply for a row lock to lock the hot row corresponding to the target data when the transaction is committed, and perform an actual logical operation on the target data to update the hot row; and, after the hot row is updated, release the row lock corresponding to the target data.

[0014] In some embodiments, the pre-logic operation module is also used to: determine whether the expected update requirements of the transaction meet the execution conditions based on the actual information of the target data and the update information to be submitted; if the execution conditions are met, update the update information to be submitted based on the expected update requirements; if the execution conditions are not met, suspend the transaction.

[0015] In some embodiments, when there are multiple concurrent transactions, the database is also used to: respond to the start requests of the multiple concurrent transactions, execute the pre-commit actions of each transaction in parallel; respond to the commit requests of the multiple concurrent transactions, execute the commit phase actions of each transaction serially.

[0016] In some implementations, the pre-logic operation module is further used to implement sequential operations of pre-logic operations between multiple concurrent transactions through atomic locks.

[0017] In some embodiments, the device is further used to: record a transaction log after performing a pre-logical operation on the target data and before the transaction is committed.

[0018] In some embodiments, the device is further used to: after performing a pre-logical operation on the target data and before the transaction is committed, update the row corresponding to the user data in the database, where the user data is the initiator of the transaction.

[0019] In a third aspect, a database hotspot row updating device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute: the method of the first aspect.

[0020] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program, and when the program is executed by a multi-core processor, the multi-core processor executes the method of the first aspect.

[0021] One of the advantages of the above embodiment is that by applying for row locks only in the transaction commit phase, the concurrent processing performance of hotspot rows can be significantly improved.

[0022] Other advantages of the present invention will be explained in more detail with reference to the following description and accompanying drawings.

[0023] It should be understood that the above description is only an overview of the technical solution of the present invention, so that the technical means of the present invention can be more clearly understood and implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described below by way of example. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The advantages and benefits described herein and other advantages and benefits will be apparent to those of ordinary skill in the art by reading the detailed description of the exemplary embodiments below. The accompanying drawings are only used for the purpose of illustrating exemplary embodiments and are not to be considered as limiting the present invention. Moreover, the same reference numerals are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0025] Figure 1 A hardware structure diagram of a database hotspot row updating device according to an embodiment of the present invention;

[0026] Figure 2 A schematic diagram of a flow chart of a method for updating a database hotspot row according to an embodiment of the present invention;

[0027] Figure 3 A schematic diagram of an interactive process of a method for updating a database hotspot row according to an embodiment of the present invention;

[0028] Figure 4 It is another interactive flow diagram of a method for updating a database hotspot row according to an embodiment of the present invention;

[0029] Figure 5 A hardware structure diagram of a database hotspot row updating device according to an embodiment of the present invention;

[0030] Figure 6 FIG. 4 is a hardware structure diagram of a database hotspot row updating device according to an embodiment of the present invention.

[0031] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION

[0032] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0033] In the description of the embodiments of the present application, it should be understood that terms such as "including" or "having" are intended to indicate the presence of features, numbers, steps, behaviors, components, parts, or a combination thereof disclosed in this specification, and are not intended to exclude the possibility of the presence of one or more other features, numbers, steps, behaviors, components, parts, or a combination thereof.

[0034] Unless otherwise specified, “ / ” means or. For example, A / B can mean A or B. The “and / or” in this article is merely a way to describe the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0035] The terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0036] All codes in this application are exemplary, and those skilled in the art may think of various modifications based on the programming language used, specific needs, personal habits and other factors without departing from the concept of this application.

[0037] It should also be noted that, in the absence of conflict, the embodiments and features of the embodiments of the present invention can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0038] like Figure 1 As shown, Figure 1It is a structural diagram of the hardware operating environment involved in the embodiment of the present invention.

[0039] It should be noted that Figure 1 That is, it is a schematic diagram of the structure of the hardware operating environment of the database hotspot row updating device. The database hotspot row updating device of the embodiment of the present invention can be a terminal device such as a PC, a portable computer, etc.

[0040] like Figure 1 As shown, the database hotspot row update 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. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0041] Those skilled in the art will understand that Figure 1 The database hotspot row update device structure shown in the figure does not constitute a limitation on the database hotspot row update device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0042] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a data hotspot row update program. The operating system is a program that manages and controls the hardware and software resources of the database hotspot row update device, and supports the operation of the database hotspot row update program and other software or programs.

[0043] exist Figure 1 In the database hotspot row update device shown, the user interface 1003 is mainly used to receive requests, data, etc. sent by the first terminal, the second terminal and the supervision terminal; the network interface 1004 is mainly used to connect the backend server to communicate data with the backend server; and the processor 1001 can be used to call the database hotspot row update program stored in the memory 1005, and perform the following operations:

[0044] Before a transaction is committed, a pre-logical operation is performed on the target data pointed to by the transaction in the database. The pre-logical operation is used to determine whether the target data meets the expected update requirements of the transaction without locking the hot row corresponding to the target data. Other businesses associated with the transaction can be freely executed during this process. Then, when the transaction is committed, a row lock is applied to lock the hot row corresponding to the target data, and an actual logical operation is performed on the target data to update the hot row. And, after the hot row is updated, the row lock corresponding to the target data is released.

[0045] As a result, the concurrent processing performance of hotspot rows can be significantly improved.

[0046] Figure 2 The flowchart of the method for updating a database hotspot row according to an embodiment of the present application is used for: in this process, from the perspective of the device, the execution subject can be one or more electronic devices; from the perspective of the program, the execution subject can be the program installed on these electronic devices. In this embodiment, the execution subject of the method can be Figure 1 The processor in the illustrated embodiment.

[0047] like Figure 2 As shown, the method provided in this embodiment may include the following steps 202-206:

[0048] 202. After the transaction is started and before the transaction is committed, a pre-logical operation is performed on the target data pointed to by the transaction in the database;

[0049] The above transaction is used to request to update the hotspot row corresponding to the target data in the database. The pre-logical operation is used to determine whether the target data meets the expected update requirements of the transaction. For example, if the amount of funds in the target data in the database is 5, and the fund balance of the required data must be greater than 0, then the target data does not meet the transaction with the expected update requirement of -10.

[0050] In some embodiments, the above 202 performs a pre-logical operation on the target data pointed to by the transaction in the database, and also includes: judging whether the expected update requirement of the transaction meets the execution conditions based on the actual information of the target data and the update information to be submitted; if the execution conditions are met, updating the update information to be submitted based on the expected update requirement; if the execution conditions are not met, suspending the transaction.

[0051] The pending update information refers to the expected update information of the uncommitted transactions that are also used to update the hot row corresponding to the target data. Specifically, the expected update requirements corresponding to these uncommitted transactions can be accumulated to obtain the pending update information. For example, if the amount of funds in the target data in the database is 20, the accumulated expected update requirements corresponding to the current uncommitted transactions are (-18), and the fund balance of the required data must be greater than 0, then the target data does not meet the expected update requirement of -(-10).

[0052] After the pre-logic operation is performed on the target data and before the transaction is committed, other business processing associated with the update business may be executed.

[0053] In some embodiments, a transaction log may be recorded after performing a pre-logical operation on the target data and before the transaction is committed.

[0054] In some embodiments, after performing a pre-logical operation on the target data and before the transaction is committed, a row corresponding to user data in the database is updated, and the user data is the initiator of the transaction.

[0055] 204. When a transaction is committed, a row lock is applied to lock the hot row corresponding to the target data, and actual logical operations are performed on the target data to update the hot row; transaction commit refers to the transaction commit stage.

[0056] 206. After the hot row is updated, the row lock corresponding to the target data is released.

[0057] See also Figure 3, the information interaction between the user's database session and the database is as follows: S01, the database session starts a transaction; S02, the database returns confirmation information to the database session; S03, the database session requests the database to update the amount of funds for the target institution data, for example, the expected update requirement can be (amount of funds - 10); S04, the database performs a pre-logical operation on the target institution data to determine whether the target institution data meets the expected update requirements of the transaction, for example, the actual amount of funds in the target institution data is 100, the expected update amount of other transactions to be submitted is -20, and the expected update amount of the transaction is -10, thereby determining the expected update requirement and the expected update amount of other transactions to be submitted. The accumulation is still less than the actual amount of funds, so the target data meets the expected update requirements of the transaction; S05, the database returns confirmation information to the database session; S06, the database session can perform other business processing; S07, the database session updates the fund amount of user A's data to the database, such as (A data's actual fund amount + 10); S08, the database returns confirmation information to the database session; S09, the database session commits the transaction; S10, applies for a row lock to lock the row corresponding to the target institution data, calculates the expected update requirements of the transaction and the actual amount of funds of the target institution data, updates the row based on this, and releases the row lock; S11, the database returns confirmation information to the database session.

[0058] Therefore, row locks are competed for and data is actually updated only when the transaction is committed. At this time, the lock plunger of the hot row will only affect a very small stage because it is already in the last stage of transaction submission. For example, only other sessions are blocked at the above S10, and business processing is not involved, so the blocking time is short, which can significantly improve processing performance.

[0059] In some embodiments, when there are multiple concurrent transactions, the method further includes: the database responds to the start requests of the multiple concurrent transactions and executes the pre-commit actions of each transaction in parallel; the database responds to the commit requests of the multiple concurrent transactions and executes the commit phase actions of each transaction in serial.

[0060] The following is an illustrative description of the embodiments of the present application using a marketing campaign as an example. However, it should be understood that the present application can also be used in various other types of database update scenarios.

[0061] In the traditional solution, when user A and user B participate in marketing activities at the same time, the system will generate the first database session and the second database session accordingly, and the two will compete for the fund deduction of the organization data (i.e., the target data). When the second database session of user B grabs the lock, it will get the lock of the organization row (i.e., the hot row corresponding to the target data), and block the fund deduction action of the first database session of user A on the organization data. Only when user B completes all operations (such as log records, other business operations, and red envelope fund recharge of user B's personal data) and submits the transaction, user A can execute the fund deduction of the organization data. Obviously, this causes the two parties to serialize the entire operation because of the competition for the hot row, which seriously affects the transaction processing.

[0062] refer to Figure 4In the same scenario, in this embodiment, the information interaction between the first database session and the second database session of user A and user B and the database is as follows: S1-01, the first database session starts the first transaction; S1-02, the database returns confirmation information to the first database session; S1-03, the first database session requests the database to update the amount of funds of the target institution data, for example, the expected update requirement may be (amount of funds - 10); S1-04, the database performs a pre-logical operation on the target institution data to determine whether the target institution data meets the expected update requirement of the first transaction, for example, the actual amount of funds of the target institution data is 100, the expected update amount of other transactions to be submitted is -20, and the expected update amount of the first transaction is -10, thereby determining the expected update requirement and other transactions to be submitted. The cumulative expected update amount is still less than the actual amount of funds, so the target data meets the expected update requirements of the first transaction; S1-05, the database returns confirmation information to the first database session; S1-06, the first database session can perform other business processing; S1-07, the first database session updates the amount of funds of user A's data to the database, such as (A data actual amount of funds + 10); S1-08, the database returns confirmation information to the first database session; S1-09, the first database session commits the first transaction; S1-10, apply for a row lock to lock the row corresponding to the target institution data, calculate the expected update requirements of the first transaction and the actual amount of funds of the target institution data, update the row based on this, and release the row lock; S1-11, the database returns confirmation information to the first database session. Similarly, S2-01 to S2-11 are the same or similar to the above steps, and the only difference is that the subject is the second database session. It can be seen that the above steps S1-01 to S1-09 and the above steps S2-01 to S2-09 can be executed in parallel. To update the fund field of the same fund data, only pre-logic operations are performed on the fund data, such as pre-increment or pre-decrement, and the obtained value is cached for subsequent reading, which avoids locking the row record. In this way, the corresponding sessions of user A and user B will not cause row locks (nor will they be actually committed) when executing marketing fund deductions. Only when the transaction is committed will the row lock be competed for and the data is actually updated. At this time, the lock plunger of the hot row will only affect a very small stage, because it is already in the last stage of transaction submission and does not involve business processing, so the blocking time is short, from Figure 4 As can be seen from the figure, the serial execution stage is significantly reduced, which can significantly improve the processing performance.

[0063] In some embodiments, the sequential operation of the pre-logic operation between multiple concurrent transactions is implemented by atomic locks. Figure 4In S1-04 and S2-04, atomic locks can be used to ensure the order of pre-logical operations. For example, if the actual amount of funds is 100, atomic locks can be used to record the expected update requirements of pre-logical operations of multiple transactions in sequence, thereby avoiding conflicts and truly judging whether the target data meets the expected update requirements of each transaction.

[0064] In the description of this specification, the description with reference to the terms "some possible implementations", "some embodiments", "examples", "specific examples", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0065] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0066] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.

[0067] About the method flow chart of the embodiment of the present application, some operations are described as different steps performed in a certain order.Such flow chart belongs to illustrative and non-restrictive.Some steps described in this article can be grouped together and performed in a single operation, some steps can be divided into multiple sub-steps, and some steps can be performed in an order different from that shown in this article.The various steps shown in the flow chart can be realized in any way by any circuit structure and / or tangible mechanism (for example, by software, hardware (for example, the logical function realized by processor or chip) etc. running on computer equipment and / or any combination thereof).

[0068] Based on the same technical concept, an embodiment of the present invention further provides a database hotspot row updating device, which is used to execute the method provided by any of the above embodiments. Figure 5 A schematic diagram of the structure of a database hotspot row updating device provided by an embodiment of the present invention.

[0069] As shown in the figure, the database hotspot row updating device 500 includes:

[0070] The pre-logic operation module 501 is used to perform a pre-logic operation on the target data pointed to by the transaction in the database after the transaction is started and before the transaction is committed. The pre-logic operation is used to determine whether the target data meets the expected update requirements of the transaction, wherein the transaction is used to request to update the hot row corresponding to the target data in the database;

[0071] The row update module 502 is used to apply for a row lock to lock the hot row corresponding to the target data when the transaction is committed, and perform actual logical operations on the target data to update the hot row; and, after the hot row is updated, release the row lock corresponding to the target data.

[0072] In some embodiments, the pre-logical operation module 501 is also used to: determine whether the expected update requirements of the transaction meet the execution conditions based on the actual information of the target data and the update information to be submitted; if the execution conditions are met, update the update information to be submitted based on the expected update requirements; if the execution conditions are not met, suspend the transaction.

[0073] In some embodiments, when there are multiple concurrent transactions, the database is also used to: respond to the start requests of the multiple concurrent transactions, execute the pre-commit actions of each transaction in parallel; respond to the commit requests of the multiple concurrent transactions, execute the commit phase actions of each transaction serially.

[0074] In some implementations, the pre-logic operation module 501 is further used to implement sequential operations of pre-logic operations between multiple concurrent transactions through atomic locks.

[0075] In some embodiments, the device is further used to: record a transaction log after performing a pre-logical operation on the target data and before the transaction is committed.

[0076] In some embodiments, the device is further used to: after performing a pre-logical operation on the target data and before the transaction is committed, update the row corresponding to the user data in the database, where the user data is the initiator of the transaction.

[0077] It should be noted that the device in the embodiment of the present application can implement the various processes of the embodiment of the aforementioned method and achieve the same effects and functions, which will not be repeated here.

[0078] Figure 6A database hotspot row updating device according to an embodiment of the present application is used to execute Figure 2 The database hotspot row updating method shown in the figure comprises: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the above embodiment.

[0079] According to some embodiments of the present application, a non-volatile computer storage medium of a database hotspot row update method is provided, on which computer executable instructions are stored, and the computer executable instructions are configured to execute the method described in the above embodiments when executed by a processor.

[0080] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, their descriptions are simplified, and the relevant parts can be referred to the partial description of the method embodiments.

[0081] The apparatus, device and computer-readable storage medium provided in the embodiments of the present application correspond one-to-one to the method. Therefore, the apparatus, device and computer-readable storage medium also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the apparatus, device and computer-readable storage medium will not be repeated here.

[0082] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0083] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0084] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0086] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0087] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0088] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. In addition, although the operations of the method of the present invention are described in a particular order in the accompanying drawings, this does not require or imply that these operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.

[0089] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims.

Claims

1. A method for updating hotspot rows in a database, characterized in that: include: After a transaction is started and before the transaction is committed, a pre-logical operation is performed on the target data pointed to by the transaction in the database, wherein the pre-logical operation is used to determine whether the target data meets the expected update requirements of the transaction, wherein the transaction is used to request an update of a hotspot row corresponding to the target data in the database; When the transaction is committed, a row lock is applied to lock the hot row corresponding to the target data, and actual logical operations are performed on the target data based on the expected update requirements to update the hot row; and After the hot row is updated, releasing the row lock corresponding to the target data; Wherein, when there are multiple concurrent transactions, the method further includes: the database responds to the start requests of the multiple concurrent transactions and executes the pre-commit actions of each transaction in parallel; the database responds to the commit requests of the multiple concurrent transactions and executes the commit phase actions of each transaction in serial.

2. The method according to claim 1, characterized in that Performing a pre-logic operation on the target data pointed to by the transaction in the database also includes: Determining whether the expected update requirement of the transaction meets the execution condition according to the actual information of the target data and the update information to be submitted; If the execution conditions are met, the update information to be submitted is updated based on the expected update requirements; If the execution conditions are not met, the transaction is suspended.

3. The method according to claim 2, characterized in that The sequential operation of the pre-logical operation between multiple concurrent transactions is achieved through atomic locks.

4. The method according to claim 1, characterized in that After performing a pre-logic operation on the target data and before the transaction is committed, a transaction log is recorded.

5. The method according to claim 1, characterized in that After performing a pre-logical operation on the target data and before the transaction is committed, a row corresponding to the user data in the database is updated, and the user data is the initiator of the transaction.

6. A database hotspot row update device, characterized in that: include: A pre-logic operation module, used to perform a pre-logic operation on the target data pointed to by the transaction in the database after the transaction is opened and before the transaction is committed, wherein the pre-logic operation is used to determine whether the target data meets the expected update requirements of the transaction, wherein the transaction is used to request to update the hotspot row corresponding to the target data in the database; A row update module, used for applying for a row lock to lock the hot row corresponding to the target data when the transaction is committed, and performing actual logical operations on the target data to update the hot row; and, after the hot row is updated, releasing the row lock corresponding to the target data; Wherein, when there are multiple concurrent transactions, the database is also used for: the database responds to the start requests of the multiple concurrent transactions and executes the pre-commit actions of each transaction in parallel; the database responds to the commit requests of the multiple concurrent transactions and executes the commit phase actions of each transaction in serial.

7. The device according to claim 6, characterized in that The pre-logic operation module is also used for: Determining whether the expected update requirement of the transaction meets the execution condition according to the actual information of the target data and the update information to be submitted; If the execution conditions are met, the update information to be submitted is updated based on the expected update requirements; If the execution conditions are not met, the transaction is suspended.

8. The device according to claim 6, characterized in that The pre-logic operation module is also used to: implement sequential operations of the pre-logic operations between multiple concurrent transactions through atomic locks.

9. The device according to claim 6, characterized in that The device is also used for recording a transaction log after performing a pre-logic operation on the target data and before the transaction is committed.

10. The device according to claim 6, characterized in that The device is also used to: after performing a pre-logic operation on the target data and before the transaction is committed, update the row corresponding to the user data in the database, the user data being the initiator of the transaction.

11. A database hotspot row update device, characterized in that: include: at least one processor; And, a memory communicatively connected to at least one processor; wherein the memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor to enable at least one processor to execute: a method as described in any one of claims 1-5.

12. A computer-readable storage medium storing a program, wherein when the program is executed by a multi-core processor, the multi-core processor executes the method according to any one of claims 1 to 5.