Transaction management method and device, equipment, storage medium and program product

By judging whether the transaction is a large transaction based on the computing power cost in the cloud database, and creating a computing copy for the large transaction for separate processing, the problems of the limitations of the existing cloud database resource management and the slow data processing speed are solved, and resource utilization is maximized and data processing efficiency is improved.

CN119938233APending Publication Date: 2025-05-06CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411788924.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

Existing cloud databases have limitations in resource management, resulting in limited resource utilization and slow data processing speed.

Method used

By receiving the transaction sent by the client, it determines its computing power cost. If the computing power cost reaches the preset threshold, classify the transaction as a large transaction, create a computed copy to handle the large transaction separately, and delete the computed copy when the large transaction is completed.

Benefits of technology

It maximizes resource utilization, improves data processing efficiency, avoids resource waste caused by long-term occupation of underlying resources, and ensures that large transactions and ordinary transactions do not affect each other.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938233A_ABST
    Figure CN119938233A_ABST
Patent Text Reader

Abstract

The invention discloses a transaction management method and device, equipment, a storage medium and a program product, and the method comprises the steps: receiving a transaction sent by a client, and determining the computing power cost of the transaction; if it is judged that the computing power cost of the transaction reaches a preset threshold value, classifying the transaction into a first type of transaction; determining a first processing copy of the first type of transactions, and executing transaction operation on the first type of transactions based on the first processing copy; and if it is judged that the transaction operation process of the first type of transactions is ended, deleting the first processing copy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing and big data, and in particular to a transaction management method, device, equipment, storage medium and program product. Background Art

[0002] As user business needs change, current cloud databases are always facing resource shortages, resulting in the emergence of serverless computing and other elastically scalable cloud database products to manage computing resources to cope with the peaks and troughs of user services. However, the computing resource management methods provided by related technologies still have limitations in improving resource utilization, and the speed of processing data is slow. Summary of the invention

[0003] To solve the above technical problems, embodiments of the present invention provide a transaction management method, apparatus, device, storage medium and program product.

[0004] The transaction management method provided in the embodiment of the present application is applied to a cloud database, including:

[0005] Receive transactions sent by clients and determine the computing power cost of the transactions;

[0006] If it is determined that the computing power cost of the transaction reaches a preset threshold, the transaction is classified as a first-category transaction;

[0007] Determine a first processing copy of the first type of transaction, and perform a transaction operation on the first type of transaction based on the first processing copy; if it is determined that the transaction operation process of the first type of transaction is completed, delete the first processing copy.

[0008] The transaction management device provided in the embodiment of the present application is applied to a cloud database, including:

[0009] A receiving unit, used for receiving transactions sent by a client;

[0010] A determination unit, configured to determine a computing power cost of the transaction;

[0011] A classification unit, configured to classify the transaction as a first-category transaction if it is determined that the computing power cost of the transaction reaches a preset threshold;

[0012] The determining unit is further configured to determine a first processing copy of the first type of transaction;

[0013] A processing unit is used to perform a transaction operation on the first type of transaction based on the first processing copy; if it is determined that the transaction operation process of the first type of transaction is completed, the first processing copy is deleted.

[0014] The processing device provided in the embodiment of the present application includes: a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any one of the above-mentioned transaction management methods.

[0015] The computer-readable storage medium provided in the embodiment of the present application is used to store a computer program, and the computer program enables a computer to execute any one of the above-mentioned transaction management methods.

[0016] The computer program product provided in the embodiments of the present application includes computer program instructions, which enable a computer to execute any one of the above-mentioned transaction management methods.

[0017] In the technical solution of the embodiment of the present application, the transaction sent by the client is received, and the computing power cost of the transaction is determined; if the computing power cost of the transaction is determined to reach a preset threshold, the transaction is classified as a first-category transaction; the first processing copy of the first-category transaction is determined, and the transaction operation is performed on the first-category transaction based on the first processing copy; if the transaction operation process of the first-category transaction is determined to be completed, the first processing copy is deleted. In this way, it is determined whether the transaction is a large transaction based on the computing power cost of the transaction. When the transaction is determined to be a large transaction, the underlying computing layer can be expanded, and a computing copy can be created for the large transaction to process the large transaction separately. When the transaction operation of the large transaction is completed, the underlying computing layer is reduced and the computing copy is deleted. This can not only achieve a plug-and-play effect and avoid occupying the underlying resources for a long time, resulting in a waste of resources, but also maximize resource utilization and improve data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a flowchart of a transaction management method applied to a cloud database provided in an embodiment of the present application;

[0019] Figure 2 It is a schematic diagram of the overall process of the transaction management method provided in the embodiment of the present application;

[0020] Figure 3 It is a structural diagram of a transaction management device applied to a cloud database provided in an embodiment of the present application;

[0021] Figure 4 It is a schematic diagram of the structure of the processing device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0022] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0023] In the embodiments of the present application, the term "corresponding" may indicate that there is a direct or indirect correspondence between the two, or an association relationship between the two, or a relationship of indication and being indicated, configuration and being configured, etc.

[0024] To facilitate understanding of the technical solutions of the embodiments of the present application, the relevant technologies of the embodiments of the present application are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.

[0025] Resource cloud services are the foundation of cloud services. As user business needs change, current cloud databases are always facing resource shortages. As a result, various cloud vendors have launched elastically scalable cloud database products such as serverless to manage computing resources in order to cope with the peaks and troughs of user services. Among them, the computing resource management method provided by the relevant technology usually first makes a basic prediction of transactions, and expands computing resources when encountering business peaks, so that both large transactions and ordinary SQL can be processed. Specifically, according to the load request, the current load capacity range of the cloud database is determined. If the current load capacity is not within the load capacity range, the expected load capacity is obtained according to the load capacity range, and the cloud database is expanded and shrunk and responds to the load request.

[0026] However, when expanding the capacity of underlying resources, the above method does not distinguish between large transactions and ordinary SQL. Both types of requests are mixed and calculated on the same resource. Therefore, if multiple ordinary SQLs continue to come in during the processing of large transactions, there will still be problems such as transaction jams or cloud database crashes, resulting in limited improvement in resource utilization and slow data processing speed.

[0027] To solve the above technical problems, the present application proposes a transaction management method. When the cloud database receives a transaction sent by a client, it determines whether the transaction is a large transaction based on the computing power cost of the transaction. When the transaction is judged to be a large transaction, a new processing copy is created for the transaction to process the large transaction separately. When the large transaction is completed, the processing copy is deleted to achieve plug-and-play and resource-saving effects. At the same time, large transactions and ordinary transactions do not affect each other and are processed separately. If the configuration required for large transactions is high, it will not occupy the underlying resources for a long time, and resource utilization can be maximized.

[0028] To facilitate understanding of the technical solutions of the embodiments of the present application, the technical solutions of the present application are described in detail below through specific embodiments. The above related technologies can be combined arbitrarily with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application. The embodiments of the present application include at least part of the following contents.

[0029] The present application embodiment proposes a transaction management method applied to a cloud database. Figure 1 is a flow chart of a transaction management method applied to a cloud database provided in an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:

[0030] Step 101: Receive a transaction sent by a client and determine the computing cost of the transaction.

[0031] In the embodiment of the present application, when a user has a business need, the user can send a business-related transaction to the cloud database through the client. After the cloud database receives the transaction sent by the client, it will calculate the computing power cost of the transaction, that is, calculate the computing resources and processing power required for the transaction to execute / read the data in the cloud database. Specifically, the computing power cost of the transaction includes two parts: input / output (Input / Output) cost and central processing unit (CPU) cost. The I / O cost mainly refers to the cost of the transaction reading the data page from the disk, and the CPU cost is usually proportional to the number of record rows that need to be processed.

[0032] Here, a transaction consists of a set of cloud database operations (such as add, delete, and modify), that is, a transaction consists of one or more SQL statements, which are executed together as a logical unit. The operations in these statements are either all successful or all failed, thereby avoiding data anomalies or inconsistencies. Among them, transactions have ACID properties: atomicity, consistency, isolation, and durability to ensure the consistency and integrity of cloud databases.

[0033] In some implementations, step 101 may specifically include:

[0034] Determine a first cost required for a transaction to sequentially read data in the cloud database, and determine a second cost required for a transaction to randomly read data in the cloud database;

[0035] A computing power cost of the transaction is determined based on the first cost and the second cost.

[0036] Here, the first cost required for a transaction to sequentially read data in the cloud database and the second cost required for a transaction to randomly read data in the cloud database can be determined. The sum of the first cost and the second cost is the computing cost of the transaction. Sequential reading refers to reading data pages in the physical order stored on the disk. In a cloud database, it usually refers to reading data in the physical storage order or index order of the data in the table; random reading refers to randomly accessing data pages as needed instead of in the physical storage order of the data. In a cloud database, it usually refers to finding specific data based on an index or performing non-continuous data retrieval. Among them, the data page is the basic unit of data storage in the cloud database, and the data page is the smallest unit for performing I / O operations on the disk. The cloud database reads or writes data on a page basis.

[0037] Specifically, the sum of the first I / O cost and the first CPU cost required for the transaction to sequentially read data in the cloud database can be determined, as well as the sum of the second I / O cost and the second CPU cost required for the transaction to randomly read data in the cloud database. The result of multiplying the sum of the first I / O cost and the first CPU cost by the sequential read coefficient is added to the result of multiplying the sum of the second I / O cost and the second CPU cost by the random read coefficient to obtain the computing power cost of the transaction, wherein the result of multiplying the sum of the first I / O cost and the first CPU cost by the sequential read coefficient is the first cost, and the result of multiplying the sum of the second I / O cost and the second CPU cost by the random read coefficient is the second cost.

[0038] For example, suppose there is a data table containing 100,000 rows, which occupies 1,000 data pages. The coefficient of a transaction executing a sequential read is 1, and the coefficient of a transaction executing a random read is 4. Then, when the transaction sequentially reads the data table in the cloud database, if the cost of each page is 1.0, the number of data pages 1,000 multiplied by the cost of each page 1.0 can be obtained as the first I / O cost required for sequentially reading the data table is 1,000. If the processing cost of each record is 0.2, the number of records to be processed 100,000 multiplied by the processing cost of each record 0.2 can be obtained as the first CPU cost required for sequentially reading the data table is 20,000. The first I / O cost 1,000 is added to the first CPU cost 20,000 and multiplied by the coefficient of sequential reading 1, that is, the first cost of sequentially reading the data table is 21,000. When the transaction is a random read of the data table in the cloud database, if random read is required, Take 100 data pages, and the cost of each page is 1.0. The number of data pages 100 multiplied by the cost of each page 1.0 can be obtained as the second I / O cost required for random reading of the data table is 100. If the processing cost of each record is 0.2, the number of records to be processed is 100,000 multiplied by the processing cost of each record 0.2, and the second CPU cost required for random reading of the data table is 20,000. Add the second I / O cost 100 and the second CPU cost 20,000 and multiply by the random reading coefficient 4, and the second cost of random reading of the data table is 80,400; add the first cost 21,000 and the second cost 80,400 to get the computing power cost of the transaction is 101,400.

[0039] It should be noted that when performing a full table scan, sequential reading is usually more efficient because the physical layout of the data can be used to quickly access all row data; when querying using an index, the cloud database will perform random reading because it is necessary to jump to the data page based on the index key value, and may need to perform further random reading to obtain the complete row data.

[0040] Step 102: If it is determined that the computing cost of the transaction reaches a preset threshold, the transaction is classified as a first-category transaction.

[0041] In the embodiment of the present application, after calculating the computing power cost of the transaction, the computing power cost of the transaction can be compared with the preset large transaction threshold. If the computing power cost of the transaction is greater than or equal to the large transaction threshold, the transaction can be classified as a first-class transaction, which is a large transaction. A large transaction refers to a transaction that has been running for a long time in the cloud database and has not been submitted for a long time. The large transaction threshold can be flexibly adjusted according to different application scenarios and is not limited here.

[0042] Step 103: Determine a first processing copy of the first type of transaction, and perform a transaction operation on the first type of transaction based on the first processing copy.

[0043] In the embodiment of the present application, after determining that the transaction is a first-class transaction, the cloud database can expand the underlying computing layer, create a new copy for the first-class transaction, namely the first processing copy, to process the first-class transaction separately, and perform transaction operations on the first-class transaction based on the first processing copy, that is, the first-class transaction is executed based on the first processing copy, and the first processing copy, as an instance of the cloud database service, is responsible for processing and executing transaction operations of the first-class transaction. Among them, the specifications of the first processing copy are only applicable to the first-class transaction, and the specifications of the first processing copy can be modified dynamically.

[0044] Here, the first processing copy refers to the pod copy in the Kubernetes environment. The pod is the smallest scheduling logic (deployment) unit in Kubernetes, which is used to place containers. The pod copy refers to the shell of the container, that is, the abstract encapsulation of the pod. For stateful applications such as cloud databases, pod copies are usually managed by stateful service sets (StatefulSets). StatefulSets allocates stable persistent storage and host names to pod copies to ensure that the pod copies can be restored to their previous state after restart.

[0045] Here, in the context of cloud database transactions, the pod replica is an instance of the cloud database service that is responsible for handling transactions. Transaction operations are defined and executed at the cloud database level, not at the pod level. As a running instance of the cloud database service, the pod replica executes transaction operations defined by the cloud database. For example, in MongoDB, transactions can span multiple documents and collections, providing atomicity guarantees. Clients use the MongoDB driver to interact with the cloud database, start transactions, perform a series of read and write operations, and commit or rollback transactions. These operations are defined at the cloud database level, and the Pod replica (MongoDB instance) is the service endpoint that executes these operations.

[0046] In some implementations, step 103 may specifically include:

[0047] Get a stateful service collection; the stateful service collection is used to manage the cloud database;

[0048] Based on the stateful service set, determine the replica set;

[0049] A replica that matches the attributes of the first type of transaction is selected from the replica set as the first processing replica.

[0050] Here, we first obtain a stateful service set, i.e., StatefulSets. Since StatefulSets is used to manage pod replicas, we can determine the replica set based on the stateful service set, and then select a pod replica that matches the first type of transaction attributes from the replica set as the first processing replica according to the attributes of the first type of transaction. The attributes of the first type of transaction may include information such as transaction isolation, transaction rollback attributes, transaction read-only attributes, and transaction timeout attributes.

[0051] Here, in the Kubernetes environment, the selection of pod replicas is usually implemented through replica sets (ReplicaSets). ReplicaSets ensure that the specified number of pod replicas are always in a running state and can filter and manage pod replicas based on label selectors.

[0052] In some implementations, selecting a replica that matches the attributes of the first type of transaction from the replica set as the first processing replica may specifically include:

[0053] Based on the attributes of the first-category transactions, determining routing rules for the first-category transactions;

[0054] Determine the status of each replica in the replica set;

[0055] A first processing replica is determined based on a routing rule for the first type of transaction and a state of each replica.

[0056] Here, based on the attributes of the first-class transactions, the routing rules of the first-class transactions can be determined, that is, to which pod replica in the replica set the first-class transactions can be routed. These rules can be isolation-level routing rules, read-write separation routing rules, etc. For transactions that require a high isolation level, routing rules that need to be routed to pod replicas configured with corresponding isolation levels can be formulated for them. For scenarios with more reads and fewer writes, routing rules that need to be routed to pod replicas with optimized read performance can be formulated for them. After determining the routing rules for the first-class transactions, since the status (load and health) of the pod replica will also affect the transaction execution, it is also necessary to determine the status of each pod replica in the replica set, so as to filter out the first processing replica based on the routing rules of the first-class transactions and the status of each pod replica.

[0057] For example, if a transaction requires the SERIALIZABLE isolation level, a routing rule can be set to send all transaction requests marked as SERIALIZABLE to the Pod replica configured with the corresponding isolation level. If a transaction is in a scenario with more reads than writes, the transaction can be routed to a specific read-only Pod replica based on the read-only attribute of the transaction.

[0058] In some implementations, determining the first processing replica based on the routing rule of the first type of transaction and the state of each replica may specifically include:

[0059] Based on the status of each replica, a label is generated for each replica to obtain multiple labels;

[0060] Based on the routing rules, multiple labels are matched to obtain the target label;

[0061] The copy corresponding to the target tag is determined as the first processing copy.

[0062] Here, to determine the status of each pod replica in the replica set, the status information of each pod replica can be obtained through the monitoring tool in Kubernetes. The status information includes whether the pod replica is in a running state, whether it is ready, and the resource usage. The corresponding label is set for each pod replica according to the status information, and multiple labels corresponding to multiple pod replicas are obtained; after obtaining the label corresponding to each pod replica, a label selector can be defined in the replica set according to the routing rules of the first type of transaction, and the label selector is used to match multiple labels to obtain a target label that matches the routing rules. The pod replica corresponding to the target label is the first processing replica of the first type of transaction. For example, if the first type of transaction needs to be routed to a pod replica with a specific state, a state label can be set for each pod replica, and a corresponding label selector can be defined in the service to match these pod replicas.

[0063] It should be noted that if the pod replica corresponding to the target label is overloaded or fails, other pod replicas that are the same as or similar to the pod replica corresponding to the target label can be updated as the first processing replica for the first type of transaction.

[0064] Step 104: If it is determined that the transaction operation process of the first type of transaction is completed, the first processing copy is deleted.

[0065] In the embodiment of the present application, after executing the transaction operation on the first type of transaction based on the first processing copy, it can be determined whether the transaction operation process of the first type of transaction is completed after the preset time. If it is determined that the transaction operation process of the first type of transaction is completed, the underlying computing layer is scaled down and the first processing copy is deleted, thereby achieving plug-and-play and avoiding the problem of occupying the underlying resources for a long time and causing resource waste. Among them, the preset time can be flexibly adjusted according to different scenarios and is not limited here.

[0066] Here, the method for determining whether the transaction operation process of the first type of transaction is completed may include one or more of the following:

[0067] If it is determined that the first type of transaction is committed, then it is determined that the transaction operation process of the first type of transaction is completed;

[0068] If it is determined that the first type of transaction is rolled back to the initial state, then it is determined that the transaction operation process of the first type of transaction is completed;

[0069] During the execution of the first type of transaction, if the client connected to the cloud database is closed or disconnected, it is determined that the transaction operation process of the first type of transaction is terminated.

[0070] Here, after a preset time, the execution status of the first type of transaction can be queried by checking the transaction log. If the first type of transaction is committed (COMMIT), it can be determined that the transaction operation process of the first type of transaction is completed; if the first type of transaction is rolled back (ROLLBACK) to the initial state, it can be determined that the transaction operation process of the first type of transaction is completed; if the client connected to the cloud database is closed or disconnected, it can be indirectly determined that the actual operation process of the first type of transaction is completed.

[0071] Here, you can also set the timeout of the first type of transaction in the cloud database. If the first type of transaction is not completed within the specified time, the cloud database will automatically roll back the first type of transaction. Therefore, by checking the timeout setting and the current time, you can determine whether the transaction operation process of the first type of transaction is completed.

[0072] Here, a callback function may also be registered after the execution of the first type of transaction is completed. When the first type of transaction is committed or rolled back, the corresponding callback function will be called, so that it can be determined that the transaction operation process of the first type of transaction is completed.

[0073] Here, a lock mechanism can also be set for the first type of transaction in the cloud database. During the execution of the first type of transaction, the lock in the lock mechanism will lock the data to maintain consistency. When the execution of the first type of transaction ends, the lock in the lock mechanism will be released. Therefore, by checking the corresponding lock status in the first type of transaction, it can be determined whether the transaction operation process of the first type of transaction is completed.

[0074] In some embodiments, the above method further comprises:

[0075] If the transaction is judged not to have reached the preset threshold, the transaction is classified as a second-category transaction;

[0076] Determine a second processing copy of the second type of transaction, and perform transaction operations on the second type of transaction based on the second processing copy; the specification of the first processing copy is greater than the specification of the second processing copy, and the transaction operations corresponding to the first processing copy and the transaction operations corresponding to the second processing copy are processed in parallel.

[0077] Here, the computing power cost of the transaction is compared with the preset large transaction threshold. If the computing power cost of the transaction is less than the large transaction threshold, the transaction can be classified as a second-class transaction, which is an ordinary transaction. At this time, there is no need to expand the underlying computing layer or create a new copy. Instead, the second-class transaction only needs to be directed to the second processing copy that processes ordinary transactions, and the transaction operation is performed on the second-class transaction based on the second processing copy. Among them, the second processing copy is a pod copy used to process ordinary transactions in the cloud database. The specifications of the first processing copy corresponding to the first-class transaction are greater than the specifications of the second processing copy corresponding to the second-class transaction. The first-class transaction and the second-class transaction do not affect each other and are processed separately, that is, the transaction operation corresponding to the first-class transaction and the transaction operation corresponding to the second-class transaction are processed in parallel.

[0078] It should be noted that the computing resources of the first and second types of transactions use different service (SVC) connections, that is, the first type of transaction is issued to the large transaction SVC, and the second type of transaction is issued to the ordinary transaction SVC. After the first and second types of transactions are executed, the results (data) of these transaction operations will be persisted in the cloud database. Among them, by allocating large and ordinary transaction operations to different SVCs, it can be ensured that large transactions will not occupy the resources of ordinary transaction operations, thereby avoiding affecting the execution of ordinary transactions.

[0079] In the technical solution of the embodiment of the present application, the transaction sent by the client is received, and the computing power cost of the transaction is determined; if the computing power cost of the transaction is determined to reach a preset threshold, the transaction is classified as a first-category transaction; the first processing copy of the first-category transaction is determined, and the transaction operation is performed on the first-category transaction based on the first processing copy; if the transaction operation process of the first-category transaction is determined to be completed, the first processing copy is deleted. In this way, it is determined whether the transaction is a large transaction based on the computing power cost of the transaction. When the transaction is determined to be a large transaction, the underlying computing layer can be expanded, and a computing copy can be created for the large transaction to process the large transaction separately. When the transaction operation of the large transaction is completed, the underlying computing layer is reduced and the computing copy is deleted. This can not only achieve a plug-and-play effect and avoid occupying the underlying resources for a long time, resulting in a waste of resources, but also maximize resource utilization and improve data processing efficiency.

[0080] Figure 2 is an overall flow chart of the transaction management method provided in the embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:

[0081] Step 201: The user business system sends an SQL statement to the management module in the cloud database.

[0082] Step 202: The management module in the cloud database determines whether the transaction consisting of the SQL statement is a large transaction.

[0083] Step 203: If the SQL statement is determined to be a large transaction, the SQL statement is directed to the large transaction processing node; or, if the SQL statement is determined to be a common transaction, the SQL statement is directed to processing node 1 or processing node 2.

[0084] Step 204: After the SQL statement is executed, the execution result is persistently stored in the cloud database.

[0085] Here, the user will send business-related SQL statements to the management module in the cloud database through the user business system. When the management module receives the SQL statement, it will calculate the computing cost of the SQL statement. For example, the coefficient of sequentially reading a data page is 1, and the coefficient of randomly reading a page is 4. If an SQL statement reads 10 pages sequentially and 2 pages randomly, then the cost of the SQL statement is:

[0086] cost = 1*10+4*2 = 18 (1)

[0087] If the cost of the SQL statement reaches the large transaction threshold (the large transaction threshold is preset in the configuration file), the management module will expand the underlying computing layer and create a separate 1C2G replica to process the transaction (SQL statement). 1C2G refers to 1 CPU core (1C) and 2GB of memory (2G). 1C means requesting the computing resources of 1 CPU core, and 2G means requesting 2GB of memory resources. Among them, the specifications of the replica (1C2G) are written in the configuration file, and the specifications of the replica can be modified dynamically. If the large transactions related to the user's business needs are energy-intensive, this configuration can be appropriately increased to ensure that the replica opened can meet the current large transaction processing. Here, a replica refers to a resource in Kubernetes. The computing processing module is usually composed of more than two replicas, including a master-slave relationship, such as two statefulsets (a2eheb00, a2eheb01) with one master and one slave.

[0088] When the management module determines that the SQL statement is a large transaction, it will expand the underlying computing layer and create a new statefulset (a2eheb10) to handle the large transaction alone. When the large transaction is completed, the underlying computing layer will be reduced and the statefulset will be deleted. The statefulset and large transaction thresholds are configurable. If the resource limit is not high but the performance requirement is high, the large transaction threshold can be appropriately lowered so that most transactions can be processed separately by corresponding copies without affecting the execution of ordinary SQL statements (ordinary transactions), which can greatly improve performance and resource utilization.

[0089] When the management module determines that the SQL statement is a normal transaction, there is no need to expand the underlying computing layer. It only needs to divert the normal transaction to computing node 1 or computing node 2 for normal processing. Among them, the two types of computing resources (large transactions and ordinary transactions) use different SVC connections, and the two do not affect each other. Large transactions are issued to large transaction SVCs, and ordinary transactions are issued to ordinary transaction SVCs. After the SQL statement is executed, the corresponding execution results are persistently stored in the cloud database.

[0090] In the technical solution of the embodiment of the present application, large transactions will be processed separately, that is, when the management module determines that a transaction is a large transaction, it will immediately pull up a new statefulset and create a new pod copy. The new pod copy will be used only to process the large transaction. When the large transaction is completed, the management module will scale down and delete the statefulset to achieve plug-and-play and save resources. At the same time, large transactions and ordinary transactions do not affect each other and are processed separately. If the configuration required for large transactions is high, it will not occupy the underlying resources for a long time, and resource utilization can be maximized.

[0091] The present application also provides a transaction management device for a cloud database. Figure 3 is a schematic diagram of the structure of a transaction management device applied to a cloud database provided in an embodiment of the present application, such as Figure 3 As shown, the device comprises:

[0092] The receiving unit 301 is used to receive a transaction sent by a client.

[0093] The determination unit 302 is used to determine the computing cost of the transaction.

[0094] The classification unit 303 is used to classify the transaction as a first-category transaction if it is determined that the computing cost of the transaction reaches a preset threshold;

[0095] The determination unit 303 is further configured to determine a first processing copy of the first type of transaction.

[0096] The processing unit 304 is configured to perform a transaction operation on the first type of transaction based on the first processing copy; if it is determined that the transaction operation process of the first type of transaction is completed, the first processing copy is deleted.

[0097] In some embodiments, the determination unit 302 is specifically used to determine a first cost required for a transaction to sequentially read data in a cloud database, and to determine a second cost required for a transaction to randomly read data in a cloud database; based on the first cost and the second cost, the computing power cost of the transaction is determined.

[0098] In some embodiments, the determination unit 302 is further specifically used to obtain a stateful service set; the stateful service set is used to manage the cloud database; based on the stateful service set, a replica set is determined; and a replica that is compatible with the attributes of the first type of transaction is selected from the replica set as the first processing replica.

[0099] In some embodiments, the determination unit 302 is further specifically used to determine the routing rules of the first type of transactions based on the attributes of the first type of transactions; determine the status of each replica in the replica set; and determine the first processing replica based on the routing rules of the first type of transactions and the status of each replica.

[0100] In some embodiments, the determination unit 302 is further specifically used to generate a label for each replica based on the state of each replica to obtain multiple labels; match multiple labels based on routing rules to obtain a target label; and determine the replica corresponding to the target label as the first processing replica.

[0101] In some implementations, the classification unit 303 is further configured to classify the transaction as a second category transaction if it is determined that the transaction does not reach a preset threshold.

[0102] In some embodiments, the processing unit 304 is also used to determine a second processing copy of the second type of transaction, and perform transaction operations on the second type of transaction based on the second processing copy; the specifications of the first processing copy are greater than the specifications of the second processing copy, and the transaction operations corresponding to the first processing copy are processed in parallel with the transaction operations corresponding to the second processing copy.

[0103] In some embodiments, the device further includes a judgment unit; wherein,

[0104] The judgment unit is used for one or more of the following: if it is determined that the first type of transaction is committed, then it is judged that the transaction operation process of the first type of transaction is ended; if it is determined that the first type of transaction is rolled back to the initial state, then it is judged that the transaction operation process of the first type of transaction is ended; during the execution of the first type of transaction, if the client connected to the cloud database is closed or disconnected, then it is judged that the transaction operation process of the first type of transaction is ended.

[0105] In the technical solution of the embodiment of the present application, the transaction sent by the client is received, and the computing power cost of the transaction is determined; if the computing power cost of the transaction is determined to reach a preset threshold, the transaction is classified as a first-category transaction; the first processing copy of the first-category transaction is determined, and the transaction operation is performed on the first-category transaction based on the first processing copy; if the transaction operation process of the first-category transaction is determined to be completed, the first processing copy is deleted. In this way, it is determined whether the transaction is a large transaction based on the computing power cost of the transaction. When the transaction is determined to be a large transaction, the underlying computing layer can be expanded, and a computing copy can be created for the large transaction to process the large transaction separately. When the transaction operation of the large transaction is completed, the underlying computing layer is reduced and the computing copy is deleted. This can not only achieve a plug-and-play effect and avoid occupying the underlying resources for a long time, resulting in a waste of resources, but also maximize resource utilization and improve data processing efficiency.

[0106] Those skilled in the art should understand that Figure 3 The implementation functions of each unit in the transaction management device shown can be understood by referring to the relevant description of the aforementioned method. Figure 3 The functions of each unit in the transaction management device shown can be implemented by a program running on a processor, or by a specific logic circuit.

[0107] Figure 4 is a schematic diagram of the structure of a processing device provided in an embodiment of the present application. The processing device may be a terminal device or a network device. Figure 4 The processing device shown includes a processor 401, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.

[0108] Alternatively, if Figure 4 As shown, the processing device may further include a memory 402. The processor 401 may call and run a computer program from the memory 402 to implement the method in the embodiment of the present application.

[0109] The memory 402 may be a separate device independent of the processor 401 , or may be integrated into the processor 401 .

[0110] Alternatively, if Figure 4 As shown, the processing device may further include a transceiver 403, and the processor 401 may control the transceiver 403 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.

[0111] The transceiver 403 may include a transmitter and a receiver. The transceiver 403 may further include an antenna, and the number of the antennas may be one or more.

[0112] The processing device may specifically be a transaction management device (such as a cloud database) of an embodiment of the present application, and the processing device may implement the corresponding processes of the various methods implemented in the embodiments of the present application, which will not be described in detail here for the sake of brevity.

[0113] It should be understood that the processor of the embodiment of the present application may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and performed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0114] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0115] It should be understood that the above-mentioned memory is exemplary but not restrictive. For example, the memory in the embodiments of the present application may also be static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synch link DRAM, SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DR RAM), etc. That is to say, the memory in the embodiments of the present application is intended to include but not limited to these and any other suitable types of memory.

[0116] The embodiment of the present application also provides a computer-readable storage medium for storing a computer program. The computer-readable storage medium can be applied to the processing device in the embodiment of the present application, and the computer program enables the computer to execute the corresponding process of each method implemented in the embodiment of the present application, which will not be described here for the sake of brevity.

[0117] The embodiment of the present application also provides a computer program product, including computer program instructions. The computer program product can be applied to the processing device in the embodiment of the present application, and the computer program instructions enable the computer to execute the corresponding process of each method implemented in the embodiment of the present application, which will not be described here for the sake of brevity.

[0118] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0119] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0120] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0123] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory,) ROM, random access memory (RandomAccess Memory, RAM), disk or optical disk and other media that can store program codes.

[0124] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A transaction management method, characterized in that: Applied to a cloud database, the method includes: Receive transactions sent by clients and determine the computing power cost of the transactions; If it is determined that the computing power cost of the transaction reaches a preset threshold, the transaction is classified as a first-category transaction; Determine a first processing copy of the first type of transaction, and perform a transaction operation on the first type of transaction based on the first processing copy; if it is determined that the transaction operation process of the first type of transaction is completed, delete the first processing copy.

2. The method according to claim 1, characterized in that Determining the computing power cost of the transaction includes: Determine a first cost required for the transaction to sequentially read the data in the cloud database, and determine a second cost required for the transaction to randomly read the data in the cloud database; Based on the first cost and the second cost, a computing power cost of the transaction is determined.

3. The method according to claim 1, characterized in that The determining a first processing copy of the first type of transaction comprises: Acquire a stateful service set; the stateful service set is used to manage the cloud database; Based on the stateful service set, determining a replica set; A replica that matches the attribute of the first type of transaction is selected from the replica set as the first processing replica.

4. The method according to claim 3, characterized in that The selecting a replica that matches the attribute of the first type of transaction from the replica set as the first processing replica includes: Determining a routing rule for the first-category transaction based on the attributes of the first-category transaction; Determining a status of each replica in the set of replicas; The first processing replica is determined based on the routing rule of the first type of transactions and the state of each of the replicas.

5. The method according to claim 4, characterized in that The determining the first processing replica based on the routing rule of the first type of transaction and the state of each replica includes: Based on the state of each replica, generate a label for each replica to obtain multiple labels; Based on the routing rule, the multiple labels are matched to obtain a target label; The copy corresponding to the target tag is determined as the first processed copy.

6. The method according to claim 1, characterized in that The method further comprises: If it is determined that the transaction does not reach the preset threshold, classifying the transaction as a second category transaction; Determine a second processing copy of the second type of transaction, and perform transaction operations on the second type of transaction based on the second processing copy; the specification of the first processing copy is greater than the specification of the second processing copy, and the transaction operations corresponding to the first processing copy are processed in parallel with the transaction operations corresponding to the second processing copy.

7. The method according to any one of claims 1 to 5, characterized in that The method may further include one or more of the following: If it is determined that the first-type transaction is committed, then determining that the transaction operation process of the first-type transaction is completed; If it is determined that the first-type transaction is rolled back to the initial state, then determining that the transaction operation process of the first-type transaction is completed; During the execution of the first type of transaction, if the client connected to the cloud database is closed or disconnected, it is determined that the transaction operation process of the first type of transaction is terminated.

8. A transaction management device, characterized in that: Applied to a cloud database, the device comprises: A receiving unit, used for receiving transactions sent by a client; A determination unit, configured to determine a computing power cost of the transaction; A classification unit, configured to classify the transaction as a first-category transaction if it is determined that the computing power cost of the transaction reaches a preset threshold; The determining unit is further configured to determine a first processing copy of the first type of transaction; A processing unit is used to perform a transaction operation on the first type of transaction based on the first processing copy; if it is determined that the transaction operation process of the first type of transaction is completed, the first processing copy is deleted.

9. A processing device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program causes a computer to execute the method according to any one of claims 1 to 7.

11. A computer program product, characterized in that The method comprises computer program instructions which cause a computer to execute the method as claimed in any one of claims 1 to 7.