Method and device for processing affairs
By establishing connections with multiple database nodes in a distributed database and directly transmitting transaction statements, the problem of low efficiency in non-read-only transaction processing is solved and more efficient database operations and system stability are achieved.
Patent Information
- Application Number
- CN202210575633.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-01-17
AI Technical Summary
The existing technology is inefficient when processing non-read-only transactions involving multiple database nodes, resulting in excessive pressure on the database nodes, performance degradation and increase in remote execution overhead, affecting system stability.
When processing non-read-only transactions, establish multiple database connections with multiple database nodes, directly transmit transaction-related database statements, reduce remote transaction execution, and receive and forward control information to reduce remote execution overhead.
It improves the processing efficiency of non-read-only transactions, relieves the pressure on database nodes, reduces the overhead of remote execution, and improves system performance and stability.
Smart Images

Figure CN114880401B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of distributed databases, and more specifically, to a method and device for processing transactions. Background Art
[0002] Distributed data includes multiple database nodes. When processing non-read-only transactions involving multiple database nodes, the prior art will first establish a database connection with one of the database nodes, and then the database node will forward the transaction to other database nodes within the database, so that remote transaction execution is performed on other database nodes. Too many remote transaction executions will reduce the processing efficiency of non-read-only transactions. Summary of the invention
[0003] The present disclosure provides a transaction processing method and device to improve the processing efficiency of non-read-only transactions in a distributed database.
[0004] In a first aspect, a method for processing transactions is provided, including: receiving a first transaction, the first transaction being a non-read-only transaction, the first transaction including a first database statement and a second database statement, the first database statement and the second database statement being respectively used to operate a first database node and a second database node in a distributed database; establishing a first database connection with the first database node; sending the first database statement to the first database node through the first database connection; establishing a second database connection with the second database node; and sending the second database statement to the second database node through the second database connection.
[0005] Optionally, the method further includes: receiving feedback information from the first database regarding the first database statement, the feedback information including control information of the first transaction; and sending the control information to a database node corresponding to the second database statement.
[0006] Optionally, the control information of the first transaction includes an execution result of the first database statement and / or a status of the first transaction.
[0007] Optionally, before establishing the second database connection with the second database node, the method further includes: disconnecting the first database connection.
[0008] Optionally, the database statement in the first transaction is a SQL statement.
[0009] In a second aspect, a device for processing transactions is provided, including: a receiving unit, configured to receive a first transaction, the first transaction is a non-read-only transaction, the first transaction includes a first database statement and a second database statement, the first database statement and the second database statement are respectively used to operate a first database node and a second database node in a distributed database; a first connection unit, configured to establish a first database connection with the first database node; a first sending unit, configured to send the first database statement to the first database node through the first database connection; a second connection unit, configured to establish a second database connection with the second database node; and a second sending unit, configured to send the second database statement to the second database node through the second database connection.
[0010] Optionally, the receiving unit is further configured to: receive feedback information from the first database regarding the first database statement, the feedback information including control information of the first transaction; and the second sending unit is further configured to: send the control information to a database node corresponding to the second database statement.
[0011] Optionally, the control information of the first transaction includes an execution result of the first database statement and / or a status of the first transaction.
[0012] Optionally, before establishing the second database connection with the second database node, the first connection unit is further configured to: disconnect the first database connection.
[0013] Optionally, the database statement in the first transaction is a SQL statement.
[0014] According to a third aspect, a device for processing transactions is provided, comprising a memory and a processor, wherein the memory stores executable code, and the processor is configured to execute the executable code to implement the method according to the first aspect.
[0015] According to a fourth aspect, a computer-readable storage medium is provided, on which an executable code is stored. When the executable code is executed, the method described in the first aspect can be implemented.
[0016] According to a fifth aspect, a computer program product is provided, comprising an executable code, which, when executed, can implement the method described in the first aspect.
[0017] In the related art, if a non-read-only transaction involves multiple database nodes, a connection is often established with only one of the database nodes. Different from the related art, when processing non-read-only transactions, the embodiments of the present disclosure can establish multiple database connections with multiple database nodes, and directly transmit transaction-related database statements to the multiple database nodes through the multiple database connections. This can avoid the execution of a large number of remote transactions caused by only establishing one database connection, thereby improving the processing efficiency of non-read-only transactions.
[0018] In addition, in the present disclosure, control information of the first transaction returned by the first database can be received, and the control information can be forwarded to the database node corresponding to the second database statement, so that the database node corresponding to the second database statement can obtain the control information of the first transaction, thereby avoiding the need for the database node corresponding to the second database statement to obtain the control information of the first transaction through remote execution in the traditional solution, which is beneficial to reducing the overhead occupied by remote execution in the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flowchart of transaction processing provided by related technologies.
[0020] Figure 2 It is a flowchart of a method for processing transactions provided in one embodiment of the present disclosure.
[0021] Figure 3 It is a flowchart of a method for processing transactions provided by yet another embodiment of the present disclosure.
[0022] Figure 4 It is a flowchart of a method for processing transactions provided by yet another embodiment of the present disclosure.
[0023] Figure 5 It is a structural diagram of an apparatus for processing transactions provided in one embodiment of the present disclosure.
[0024] Figure 6 It is a structural diagram of an apparatus for processing transactions provided in yet another embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] The technical solution in the present disclosure will be described below in conjunction with the accompanying drawings. In order to facilitate understanding of the present disclosure, the following first introduces the terms involved in the embodiments of the present disclosure.
[0026] Distributed Database
[0027] A database is a warehouse that organizes, stores, and manages data according to data structures. A database is a collection of large amounts of data that is stored in a computer for a long time, organized, shareable, and uniformly managed. A distributed database is a technology that combines database and distribution. A distributed database combines database nodes that are geographically dispersed but logically belong to the same computer system.
[0028] Structured Query Language
[0029] Structured query language (SQL) is a special programming language used to access data and query, update and manage database systems.
[0030] Structured Query Language is a high-level non-procedural programming language that allows users to work on high-level data structures. It does not require users to specify how to store data, nor does it require users to understand the specific data storage method. Therefore, different database systems with completely different underlying structures can use the same structured query language as an interface for data input and management. Statements in structured query language can be nested, which makes it extremely flexible and powerful.
[0031] Transactions
[0032] A transaction is a set of operations on a database. A transaction can consist of one or more database statements. A transaction is an indivisible execution unit in a database. Statements related to transactions include start transaction, end transaction, commit transaction, rollback transaction, etc.
[0033] Transactions need to have ACID, which stands for atomicity, consistency, isolation, and durability.
[0034] Atomicity means that statements in a transaction need to be committed or rolled back together. For example, a transaction in which user A transfers 100 yuan to user B includes two operations: deducting 100 yuan from user A's account balance and increasing 100 yuan from user B's account balance. Both operations need to be executed successfully or neither needs to be executed.
[0035] Consistency means that the integrity constraints of the database are not violated before and after a transaction. For example, in the above transfer transaction, the total balance of user A and user B's account is 2,000 yuan before the transfer begins. Consistency means that after the transfer transaction ends, the total balance of user A and user B's account is still 2,000 yuan.
[0036] Isolation means that multiple transactions will not interfere with each other when executed concurrently, that is, the data within a transaction is isolated from other transactions.
[0037] Persistence means that after a transaction is completed (for example, committed), the operations performed by the transaction on the database are persisted in the database and will not be rolled back.
[0038] When a transaction needs to be completed in a distributed database system, it can also be called a distributed transaction. During the processing of a distributed transaction, it may be necessary to operate on data located in different database nodes.
[0039] For read-only transactions, since the state of the database does not need to be modified during the transaction execution, the database management system (such as a database client or a database agent) can directly send the read-only transaction request to the corresponding database node.
[0040] However, during the execution of non-read-only transactions, there are modifications to the data or status of the database. Therefore, non-read-only transactions have their own particularities. Figure 1 A brief introduction to the processing of non-read-only transactions.
[0041] Figure 1 It is a flowchart of transaction processing provided by related technologies. Figure 1 The system includes a database management system 110 and a distributed database 120. The distributed database 120 includes three database nodes (database node 121, database node 122 and database node 123). Figure 1 The distributed database 120 having three database nodes is shown as an example. In practice, a distributed database may include any number of database nodes.
[0042] like Figure 1 As shown, after receiving transaction 1, the database management system 110 needs to first establish a database connection (or session) with a database node in the distributed database 120. A database connection can also be called a database session. During the transaction execution process, all generated information can be recorded in the database connection.
[0043] Transaction 1 may include three database statements (a first database statement, a second database statement, and a third database statement).
[0044] The database management system 110 analyzes that the execution node of the first database statement is the database node 122. Therefore, in step S101, the database management system 110 can establish a first database connection with the database node 122, and send the database statements in transaction 1 to the database node 122 through the first database connection. The database management system 110 can send all database statements in transaction 1 (for example, the first database statement to the third database statement) to the database node 122 at the same time. Alternatively, the next database statement can be sent to the database node 122 after each database statement is executed.
[0045] After executing the first database statement, database node 122 determines that the second database statement should be executed on database node 121. Therefore, in step S102, database node 122 sends the second database statement to database node 121 through remote execution. After executing the second database statement, database node 121 may also execute step S103 to send the execution result of the second database statement to database node 122 through remote execution.
[0046] Remote execution refers to an operation in which the database statement to be executed cannot be executed on the current database node and needs to be forwarded to other database nodes for execution. For example, the operation in which database node 122 forwards the second database statement to database node 121 is a remote execution.
[0047] After receiving the execution result of the second database statement, the database node 122 may execute step S104 to send the execution result to the database management system 110 through the first database connection. The database management system 110 may determine the execution node of the next database statement according to the execution result of the database statement.
[0048] After receiving the execution result of the second database statement, the database node 122 analyzes that the execution node of the third database statement is the database node 123. In step S105, the database node 122 sends the third database statement to the database node 123 through remote execution.
[0049] In step S106 , the database node 123 sends the execution result of the third database statement to the database node 122 through remote execution.
[0050] In step S107 , the database node 122 sends the execution result of the third database statement to the database management system 110 through the first database connection.
[0051] According to the above introduction, it can be seen that when the database management system 110 manages non-read-only transactions, all database statements in a transaction need to be sent to the corresponding execution node (the execution node includes the database node 122 itself) via the database node (for example, database node 122) that establishes a connection with the database management system 110.
[0052] When a non-read-only transaction contains a large number of database statements, the database node (such as database node 122) that establishes a database connection with the management system 110 needs to receive all database statements, and needs to send all database statements not executed by this node to the corresponding execution node through remote execution.
[0053] Therefore, the database node (such as database node 122) may be overloaded. Excessive pressure on the database node may cause the database node performance to degrade or become abnormal, thereby affecting the stability of the database system. That is, the database node (such as database node 122) under pressure may become the performance bottleneck of the database system due to the centralization phenomenon.
[0054] In addition, distributed transactions usually involve multiple database nodes, and all database statements that need to be executed on nodes other than database node 122 need to be forwarded through database node 122, resulting in remote execution. Remote execution increases database overhead, increases transaction execution time, and reduces database performance.
[0055] In summary, when distributed databases process non-read-only transactions, their processing efficiency is low.
[0056] In view of this, an embodiment of the present disclosure provides a method for processing transactions to improve the processing efficiency of non-read-only transactions.
[0057] The following is combined with Figure 2 , the method for processing transactions provided by the embodiment of the present disclosure is described in detail.
[0058] Figure 2 The method can be used in a database management system. The database management system is used to manage a database. The database management system can refer to, for example, a database application (such as a database client) or a database agent. Figure 2 The method may include steps S210 to S250.
[0059] In step S210, a first transaction is received. The first transaction may be a non-read-only transaction. The so-called non-read-only transaction means that the execution of the transaction will cause one or some data in the database to be modified. The first transaction may include multiple database statements. For example, the first transaction may include a first database statement and a second database statement. It is understandable that the first transaction may include a larger number of database statements, and the following mainly uses the first database statement and the second database statement as examples for illustration.
[0060] Database statements are a programming language used to operate databases. They generally have the functions of accessing data, querying, updating, and managing databases. Each database statement can be a simple statement or a compound statement.
[0061] The specific language type used by the database statement can be determined according to business needs. For example, the database statement can be implemented using structured query language (SQL).
[0062] In a distributed database, different data may be stored on different database nodes. For example, the first transaction refers to the purchase of a handbag on Taobao Mall. The first transaction may include two operations: an operation of increasing the order quantity by one and an operation of decreasing the inventory quantity by one. The two operations may correspond to a first database statement and a second database statement, respectively. The first database statement may be used to execute the operation of increasing the order quantity by one, and the second database statement may be used to execute the operation of decreasing the inventory quantity by one.
[0063] For Taobao Mall, order data may be stored on a first database node (eg, an order database), and inventory data may be stored on a second database node (eg, an inventory database).
[0064] The first database statement and the second data statement can respectively operate on the first database node and the second database node, for example, respectively operate on the data on the first database node and the second database node.
[0065] After receiving the first transaction, the database management system may determine the database nodes used to execute the first database statement and the second database statement, and establish database connections with the corresponding database nodes respectively.
[0066] Database connection can refer to physical database connection or database session connection. All operations of the database management system on the database need to be completed through database connection.
[0067] The database management system determines that the first database statement should be executed on the first database node. Therefore, in steps S220 and S230, a first database connection is established with the first database node, and the first database statement is sent to the first database node through the first database connection.
[0068] The first database node may store the first data. The first database statement may be used to operate the first data. For example, the first database statement may delete a record in the first data. For another example, the first database statement may query a record in the first data. For another example, the first database statement may add a record in the first data.
[0069] In some embodiments, when the first database node determines that the received first database statement needs to be executed on other database nodes, the first database node may forward the first database statement to the corresponding database node.
[0070] Since the data in a distributed database may be relocated, forwarding database statements within the database node can improve the fault tolerance of the database, ensure the correct execution of database statements, and further ensure the correct execution of transactions.
[0071] For example, the first data is originally stored in the first database node, but when the database management system sends the first database statement to the first database node, the first data is just moved to the second database node. At this time, the first database node can forward the first database statement to the second database node to ensure the execution of the first database statement.
[0072] In some other embodiments, the first database statement may be a complex sentence. The first database statement needs to be executed in multiple database nodes, and the first database node is one of the multiple database nodes that execute the first database statement. After receiving the first database statement, the first database node may forward the first database statement to all nodes that need to execute the first database statement, so that the first database statement can be correctly executed.
[0073] In step S240 to step S250, a second database connection is established with the second database node, and a second database statement is sent to the second database node through the second database connection.
[0074] The interaction between the database management system and the second database node is similar to the interaction between the database management system and the first database node. For a detailed description, see step S220 referring to step S230, which will not be described in detail here.
[0075] It should be understood that the first database node and the second database node are used in this embodiment only to make the solution clearer. The distributed database may include any number of database nodes. The first database node and the second database node may refer to any nodes in the distributed database. The first database node and the second database node may be two different database nodes or the same database node.
[0076] The transaction processing method provided by the present disclosure can establish connections with multiple database nodes when processing non-read-only transactions. During the execution of the database statements of the transaction, it is not necessary to send all of them to the same database node. Therefore, the method reduces the number of remote executions within the database and effectively improves the processing efficiency of non-read-only transactions.
[0077] In addition, since database statements do not need to be forwarded through a specific database node (for example, a database node that establishes a connection with the database management system), the problem of performance bottlenecks in the entire database due to excessive pressure on a certain database node is alleviated.
[0078] In some embodiments, before step S240, Figure 3 As shown, the method for processing transactions provided by the embodiment of the present disclosure may further include step S310 and step S320.
[0079] In step S310 and step S320, feedback information from the first database for the first database statement is received, the feedback information including control information of the first transaction, and control information is sent to a database node corresponding to the second database statement.
[0080] The feedback information may include control information of the first transaction. The control information of the first transaction is used to control the execution process of the first transaction. The control information of the first transaction may include the state of the first transaction.
[0081] The state of a transaction may refer to the current execution state of the transaction, such as an active state, a partially committed state, a failed state, a committed state, or an aborted state.
[0082] The active state refers to the state of a transaction while it is being executed. The partially committed state refers to the state after the last database statement in a transaction has been executed. The failed state refers to the state in which a transaction cannot be executed normally. The committed state refers to the state after the last piece of information is written to the database after a transaction is partially committed. After the committed state is completed, a transaction is successfully completed. The aborted state refers to the state in which a transaction is rolled back and the database has been restored to the state before the transaction started executing.
[0083] The state information of a transaction may also refer to the state information generated during the execution of a database statement in the transaction. A database statement may generate a lot of state information during the execution. The state information may include time zone information, encoding information, etc. The state information may also include variables defined during the execution of a database statement.
[0084] The status information generated by the execution of a database statement may affect the execution of the next database statement. For example, after the first database statement is executed, the status information generated includes time zone information. The time zone information is used to determine the specific time zone used in the execution of the first transaction (for example, using China Standard Time (CST) as the execution time zone). During the execution process, the subsequent database statements in the first transaction need to use the time zone (for example, CST) determined after the execution of the previous database statement as the execution time zone to complete the corresponding operation of the database statement.
[0085] For another example, after the first database statement is executed, the generated state information includes encoding information, and the encoding information determines that the first transaction uses UTF-8 encoding. Subsequent database statements of the first transaction (such as the second database statement) need to use UTF-8 encoding.
[0086] The control information of the first transaction may also include the execution result of the first database statement. The database management system may determine the current state of the first transaction according to the execution result of the first database statement, and determine the operation to be performed next according to the current state of the first transaction.
[0087] For example, when the first database statement fails to execute, the first transaction needs to enter the abort state. After the first transaction enters the abort state, abort-related operations, such as rollback, can be performed.
[0088] For another example, when the first database statement is successfully executed, the first transaction continues to execute normally. The database management system can normally analyze the next database statement to be executed (such as the second database statement), determine the database node that executes the database statement, and send the statement directly to the database node.
[0089] The control information of the first transaction may also include connection information of the first transaction. The connection information of the first transaction may refer to information of all established connections during the execution of the first transaction.
[0090] For example, during the execution of the first transaction, a first database connection is established with the first database node, and a second database connection is established with the second database node. At this time, the connection information may record information about the first database connection and the second database connection.
[0091] Recording the connection information of a transaction can help the transaction quickly locate all database nodes that need to be executed when the state changes.
[0092] For example, when the first transaction needs to be rolled back or committed, the connection information of the first transaction records all the connection information established during the execution of the first transaction. The database management system can quickly locate all database nodes that have executed the first transaction based on the connection information of the first transaction, so that all database nodes that have executed the first transaction can perform the same operation (for example, commit or rollback) to ensure the atomicity of the first transaction.
[0093] In the disclosed embodiment, the management system of the database can receive the control information of the first transaction returned by the first database, and forward the control information to the database node corresponding to the second database statement, so that the database node corresponding to the second database statement can obtain the control information of the first transaction, thereby avoiding the need for the database node corresponding to the second database statement to obtain the control information of the first transaction through remote execution in the traditional solution, which is beneficial to reducing the overhead occupied by remote execution in the database.
[0094] In some embodiments, the control information of the first transaction may be stored in a local or temporary table of the first database node. When the database management system or other database nodes need the control information of the first transaction, the control information of the first transaction may be obtained from the first database node through remote access.
[0095] When the data volume of the control information of the first transaction is very large (for example, the control information of the first transaction is 1G), storing the control information of the first transaction in a database node or a temporary table can effectively save the time required to transmit the control information of the first transaction, thereby further improving the efficiency of processing transactions.
[0096] The first database node and the first database statement in this embodiment are only for convenience of description. The first database node can be any node in the database. The first database statement can refer to any database statement in the first transaction.
[0097] In some embodiments, before establishing the second database connection with the second database node, the first database connection may be disconnected first.
[0098] In the database, since the database management system interacts with the database, it needs to be completed through the database connection. Therefore, the database connection is a very important resource.
[0099] In the embodiment of the present disclosure, during the execution of the first transaction, after the database management system completes the interaction with the database node, the database management system disconnects from the database node, thereby improving the utilization rate of database connection resources.
[0100] Figure 4 This is a schematic diagram of a method for processing transactions provided by an embodiment of the present disclosure. Figure 4, a method for processing transactions provided by the present disclosure is introduced with a specific embodiment.
[0101] Figure 4 The system includes a database management system 410 and a distributed database 420. The distributed database 420 includes n database nodes (database node 421 to database node 42n).
[0102] In this embodiment, the database management system 410 may receive a first transaction, and the first transaction may be used to process data stored in the distributed database 420 .
[0103] The first transaction may include n database statements, for example, the first database statement to the nth database statement. The database statements may use the SQL language. For ease of description, in this embodiment, the first database statement to the nth database statement are referred to as sql1 to sqln.
[0104] The specific execution node of each database statement can be selected according to actual needs. For example, sql1 to sqln can be executed on the same database node (such as database node 421). For another example, sql1 to sqln can be executed on different database nodes respectively. For another example, sql1 and sql3 are executed on the same database node, and the remaining database statements are executed on different database nodes.
[0105] After receiving the first transaction, the database management system 410 analyzes the database node on which the database statements in the first transaction should be executed. For example, the database management system 410 analyzes that sql1 should be executed on the database node 422 .
[0106] In step S401 , the database management system 410 establishes a first database connection with the database node 422 , and sends sql1 to the database node 422 .
[0107] In some embodiments, the database node 422 may need the control information of the first transaction when executing sql1. The database node 422 may obtain the control information of the current first transaction in a variety of ways.
[0108] For example, when the database management system 410 sends sql1 to the database node 422 , it may simultaneously send the control information of the first transaction to the database node 422 .
[0109] For another example, the control information of the first transaction may be stored in a certain database node (eg, database node 421) or a temporary table. When the database node 422 needs the control information of the first transaction, it may be obtained remotely.
[0110] In step S402, after executing sql1, the database node 422 may send first feedback information to the database management system 410. The first feedback information may include control information of the first transaction. The control information of the first transaction may include the execution result of sql1 and the status of the first transaction.
[0111] The control information of the first transaction in the first feedback information may be incremental or full control information based on the control information of the first transaction obtained before the database node 422 executes sql1.
[0112] In step S403 , after receiving the first feedback information from the database node 422 , the database management system 410 may disconnect the first database connection to improve the utilization efficiency of the database connection.
[0113] The database management system 410 determines, based on the first feedback information, that the database node corresponding to sql2 is the database node 421 .
[0114] In step S404 , the database management system 410 establishes a second database connection with the database node 421 , and sends sql2 to the database node 421 .
[0115] In step S405 , the database node 421 sends second feedback information to the database management system 410 .
[0116] After executing sql2, the database node 421 can determine the amount of state data of the first transaction generated locally. When it is determined that the amount of state data of the first transaction is large (for example, greater than a certain threshold), the state of the first transaction may no longer be sent in the second feedback information, but only the execution result of sql2 may be sent. At this time, the database node 421 saves the state of the first transaction locally.
[0117] In step S406, after receiving the second feedback information, the database management system 410 disconnects the second database connection.
[0118] The execution process of the remaining database statements of the first transaction is similar to the aforementioned steps and will not be repeated here.
[0119] Front combination Figures 1 to 4 The method embodiment of the present disclosure is introduced. Figures 5 and 6 The device embodiment of the present disclosure is introduced. It should be understood that the description of the method embodiment corresponds to the description of the device embodiment. Therefore, for the parts not described in detail in the device embodiment, reference can be made to the description in the method embodiment in the foregoing text.
[0120] Figure 5 It is a schematic structural diagram of an apparatus for processing transactions provided in one embodiment of the present disclosure. Figure 5The transaction processing apparatus shown may include a receiving unit 510 , a first connecting unit 520 , a first sending unit 530 , a second connecting unit 540 , and a second sending unit 550 .
[0121] The receiving unit 510 may be configured to receive a first transaction, the first transaction being a non-read-only transaction, the first transaction comprising a first database statement and a second database statement, the first database statement and the second database statement being used to operate a first database node and a second database node in a distributed database, respectively;
[0122] The first connection unit 520 may be configured to establish a first database connection with the first database node;
[0123] The first sending unit 530 may be configured to send the first database statement to the first database node through the first database connection;
[0124] The second connection unit 540 may be configured to establish a second database connection with the second database node;
[0125] The second sending unit 550 may be configured to send the second database statement to the second database node through the second database connection.
[0126] Optionally, the receiving unit 510 is further configured to: receive feedback information from the first database regarding the first database statement, the feedback information including control information of the first transaction; the second sending unit 550 is further configured to send the control information to a database node corresponding to the second database statement.
[0127] Optionally, the control information of the first transaction includes an execution result of the first database statement and / or a status of the first transaction.
[0128] Optionally, before establishing the second database connection with the second database node, the first connection unit is further configured to: disconnect the first database connection.
[0129] Optionally, the database statement in the first transaction is a SQL statement.
[0130] Figure 6600 is a schematic diagram of a structure of a device for processing transactions provided by another embodiment of the present disclosure. The device 600 for processing transactions may be a user terminal or a database proxy server. The device 600 may include a memory 610 and a processor 620. The memory 610 may be used to store executable code. The processor 620 may be used to execute the executable code stored in the memory 610 to implement the steps in the various methods described above. In some embodiments, the device 600 may also include a network interface 630, and data exchange between the processor 620 and an external device may be implemented through the network interface 630.
[0131] It should be understood that in the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0132] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0133] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems and devices 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0134] 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.
[0135] In addition, each functional unit in each embodiment of the present disclosure 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.
[0136] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for processing transactions, applied to a database management system, the method comprising: Receive a first transaction, where the first transaction is a non-read-only transaction, and the first transaction includes a first database statement and a second database statement, where the first database statement and the second database statement are used to operate a first database node and a second database node in a distributed database, respectively; Establishing a first database connection with the first database node; sending the first database statement to the first database node through the first database connection; Establishing a second database connection with the second database node; sending the second database statement to the second database node through the second database connection; receiving feedback information from the first database node regarding the first database statement, the feedback information including control information of the first transaction; Sending the control information to a database node corresponding to the second database statement; The first transaction continues to be executed normally, the database management system analyzes the second database statement, determines the second database node that executes the second database statement, and sends the second database statement to the second database node.
2. The method according to claim 1, wherein the control information of the first transaction comprises an execution result of the first database statement and / or a status of the first transaction.
3. The method according to claim 1, before establishing the second database connection with the second database node, the method further comprises: Disconnect the first database connection.
4. According to the method of claim 1, the database statement in the first transaction is a structured query language SQL statement.
5. A device for processing transactions, applied to a database management system, the device comprising: A receiving unit is configured to receive a first transaction, the first transaction is a non-read-only transaction, the first transaction includes a first database statement and a second database statement, the first database statement and the second database statement are respectively used to operate a first database node and a second database node in a distributed database; A first connection unit, configured to establish a first database connection with the first database node; A first sending unit, configured to send the first database statement to the first database node through the first database connection; A second connection unit, configured to establish a second database connection with the second database node; a second sending unit, configured to send the second database statement to the second database node through the second database connection; The receiving unit is further configured to receive feedback information from the first database node regarding the first database statement, wherein the feedback information includes control information of the first transaction; The second sending unit is further configured to send the control information to the database node corresponding to the second database statement; The first transaction continues to be executed normally, the database management system analyzes the second database statement, determines the second database node that executes the second database statement, and sends the second database statement to the second database node. 6 . The device according to claim 5 , wherein the control information of the first transaction comprises an execution result of the first database statement and / or a status of the first transaction.
7. The apparatus according to claim 5, before establishing the second database connection with the second database node, the first connection unit is further configured to: Disconnect the first database connection.
8. The device according to claim 5, wherein the database statement in the first transaction is a structured query language SQL statement.
9. A device for processing transactions, comprising a memory and a processor, wherein the memory stores executable codes, and the processor is configured to execute the executable codes to implement the method according to any one of claims 1 to 4.
