CN112231144A - Data processing method and device and electronic equipment - Google Patents

Data processing method and device and electronic equipment Download PDF

Info

Publication number
CN112231144A
CN112231144A CN202011051598.9A CN202011051598A CN112231144A CN 112231144 A CN112231144 A CN 112231144A CN 202011051598 A CN202011051598 A CN 202011051598A CN 112231144 A CN112231144 A CN 112231144A
Authority
CN
China
Prior art keywords
transaction
database
target
branch
branch transaction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011051598.9A
Other languages
Chinese (zh)
Inventor
张甫
李志伟
常俊峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai I2finance Software Co ltd
Original Assignee
Shanghai I2finance Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai I2finance Software Co ltd filed Critical Shanghai I2finance Software Co ltd
Priority to CN202011051598.9A priority Critical patent/CN112231144A/en
Publication of CN112231144A publication Critical patent/CN112231144A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1474Saving, restoring, recovering or retrying in transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/80Database-specific techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/82Solving problems relating to consistency

Abstract

The embodiment of the invention discloses a data processing method, a data processing device and electronic equipment, wherein the method comprises the following steps: the method comprises the steps of determining a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is failed, detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction or not, and rolling back the database based on the database modification log under the condition that the database modification log is detected to exist, so as to achieve the consistency of the target transaction. In this way, data processing efficiency can be improved while achieving consistency of target transactions.

Description

Data processing method and device and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data processing method and apparatus, and an electronic device.
Background
With the continuous development of computer technology, distributed applications under a micro-service framework gradually become a trend, under the micro-service framework, a plurality of remote service interfaces are required to be called to complete a business transaction, business data used by each remote service interface is stored in a local database, and if a certain remote service call fails in the execution process of the business transaction, how to process the business data of all other related remote service interfaces of the business transaction so as to ensure the consistency of the business data becomes a focus problem.
At present, the consistency of service data can be ensured through the reverse operation of the service. For example, taking a business transaction as a ticket purchasing transaction as an example, the ticket purchasing transaction can be divided into a deduction branch transaction and a deduction branch transaction, and if the deduction branch transaction is successfully executed and the deduction branch transaction is unsuccessfully executed due to insufficient remaining tickets, the deduction branch transaction needs to be reversely operated to ensure the consistency of the business data of the ticket purchasing transaction.
However, the business transaction usually includes many sub-transactions, and if one sub-transaction fails to be executed, global reverse operation needs to be performed on other executed sub-transactions included in the business transaction, which causes problems of large workload and low data processing efficiency.
Disclosure of Invention
Embodiments of the present invention provide a data processing method, an apparatus, and an electronic device, so as to solve a problem in the prior art that data consistency cannot be guaranteed under a distributed architecture.
To solve the above technical problem, the embodiment of the present invention is implemented as follows:
in a first aspect, an embodiment of the present invention provides a data processing method, where the method includes:
determining a target branch transaction corresponding to a first branch transaction in the case of detecting that the first branch transaction of the target transaction fails to execute, wherein the target branch transaction comprises a preceding branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction;
detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction;
and under the condition that the database modification log is detected to exist, performing rollback operation on the database based on the database modification log so as to realize the consistency of the target transaction.
Optionally, in the case that execution failure of a first branch transaction of a target transaction is detected, before determining a target branch transaction corresponding to the first branch transaction, the method further includes:
when a second branch transaction of the target transaction is executed, a database modification instruction corresponding to the second branch transaction is obtained, wherein the second branch transaction is any one or more branch transactions of the target transaction;
and generating a database modification log corresponding to the second branch transaction based on the database modification instruction and target data corresponding to the database modification instruction in the database, and storing the database modification log in the database.
Optionally, before the generating a database modification log corresponding to the second branch transaction based on the database modification instruction and target data in the database corresponding to the database modification instruction, the method further includes:
analyzing the content in the database modification instruction to obtain element data corresponding to the database modification instruction, wherein the element data comprises preset field information related to the target data in the database modification instruction;
generating metadata for determining the target data in the database based on the element data, and determining the target data based on the metadata, wherein the metadata comprises position information of the target data in the database.
Optionally, the method further comprises:
and after the rollback operation is carried out on the database, deleting the database modification log of the target branch transaction corresponding to the rollback operation.
In a second aspect, an embodiment of the present invention provides a data processing apparatus, where the apparatus includes:
the transaction determining module is used for determining a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is failed, wherein the target branch transaction comprises a front branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction;
the log detection module is used for detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction;
and the rollback module is used for performing rollback operation on the database based on the database modification log under the condition that the database modification log is detected to exist so as to realize the consistency of the target transaction.
Optionally, the apparatus further comprises:
the instruction acquisition module is used for acquiring a database modification instruction corresponding to a second branch transaction of the target transaction when the second branch transaction is executed, wherein the second branch transaction is any one or more branch transactions of the target transaction;
and the log generation module is used for generating a database modification log corresponding to the second branch transaction based on the database modification instruction and the target data corresponding to the database modification instruction in the database, and storing the database modification log in the database.
Optionally, the apparatus further comprises:
the processing module is used for analyzing and processing the content in the database modification instruction to obtain element data corresponding to the database modification instruction, wherein the element data comprises preset field information related to the target data in the database modification instruction;
a determining module, configured to generate metadata for determining the target data in the database based on the element data, and determine the target data based on the metadata, where the metadata includes location information of the target data in the database.
Optionally, the apparatus further comprises:
and the deleting module is used for deleting the database modification log of the target branch transaction corresponding to the rollback operation after the rollback operation is performed on the database.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a computer program stored on the memory and executable on the processor, where the computer program, when executed by the processor, implements the steps of the data processing method provided in the foregoing embodiment.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the data processing method provided in the foregoing embodiment.
As can be seen from the above technical solutions provided by the embodiments of the present invention, in the embodiment of the present invention, when it is detected that the first branch transaction of the target transaction fails to be executed, the target branch transaction corresponding to the first branch transaction is determined, where the target branch transaction includes a pre-branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction, and whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction is detected, and in the case that the database modification log is detected to exist, a rollback operation is performed on the database based on the database modification log, so as to achieve consistency of the target transaction. Therefore, the consistency of the target transaction can be realized only by performing rollback operation on the target branch transaction with the database modification log in the database, and business reverse operation on all executed transactions contained in the target transaction is not required, so that the workload of transaction processing is reduced, and the data processing efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flow chart illustrating a data processing method according to the present invention;
FIG. 2 is a schematic flow chart of another data processing method according to the present invention;
FIG. 3 is a schematic diagram of a data processing flow according to the present invention;
FIG. 4 is a schematic diagram of a process flow of a target transaction of the present invention;
FIG. 5 is a schematic diagram of a data processing apparatus according to the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to the present invention.
Detailed Description
The embodiment of the invention provides a data processing method and device and electronic equipment.
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
As shown in fig. 1, an execution subject of the method may be a server, where the server may be an independent server, or a server cluster composed of multiple servers, and the method may specifically include the following steps:
in S102, in the case that the execution failure of the first branch transaction of the target transaction is detected, the target branch transaction corresponding to the first branch transaction is determined.
The target transaction may be a transaction including one or more branch transactions, for example, the target transaction may be a ticket purchase transaction, and the transaction may include a deduction branch transaction and a deduction branch transaction, where the deduction branch transaction may be a preceding branch transaction of the deduction branch transaction, that is, after the deduction branch transaction is successfully executed, the deduction branch transaction may be continuously executed. The target branch transaction may comprise a preceding branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction, e.g. assuming that the target transaction is a ticketing transaction and the target branch transaction is a deducting branch transaction, the first branch transaction may be a preceding branch transaction of the deducting branch transaction, i.e. the first branch transaction may be a deducting branch transaction.
In implementation, with the continuous development of computer technology, distributed applications under a micro-service framework gradually become a trend, in the micro-service framework, a plurality of remote service interfaces are required to be called to complete a business transaction, business data used by each remote service interface is stored in a local database, and if a certain remote service call fails in the execution process of the business transaction, how to process the business data of all other related remote service interfaces of the business transaction so as to ensure the consistency of the business data becomes a focus problem.
At present, the consistency of service data can be ensured through the reverse operation of the service. For example, taking a business transaction as a ticket purchasing transaction as an example, the ticket purchasing transaction can be divided into a deduction branch transaction and a deduction branch transaction, and if the deduction branch transaction is successfully executed and the deduction branch transaction is unsuccessfully executed due to insufficient remaining tickets, the deduction branch transaction needs to be reversely operated to ensure the consistency of the business data of the ticket purchasing transaction. However, the business transaction usually includes many sub-transactions, and if one sub-transaction fails to be executed, global reverse operation needs to be performed on other executed sub-transactions included in the business transaction, which causes problems of large workload and low data processing efficiency. Therefore, an implementation scheme provided in the embodiments of the present invention may specifically include the following:
the server may be deployed with a transaction manager, a transaction coordinator, and a resource manager, where the transaction manager may be configured to control a boundary of a target transaction, is responsible for starting the target transaction, and initiate a resolution of a commit operation of the target transaction or a resolution of a rollback operation of a branch transaction in the target transaction according to an execution status of the target transaction. The transaction coordinator may be used to maintain the running state of the target transaction, and is responsible for coordinating and determining the commit or rollback operations of the target transaction. The resource manager may be configured to control a branch transaction of the target transaction, perform registration operation on the branch transaction, report execution status of the branch transaction, and the like, and may receive an instruction of the transaction coordinator to drive a commit operation or a rollback operation of the branch transaction.
The server may receive execution instructions of a plurality of target transactions, the transaction manager may open one or more target transactions, and notify the transaction coordinator of opening one or more target transactions by the transaction manager, the transaction coordinator may perform a communication negotiation with the resource manager, and the resource manager performs a specific execution operation on a branch transaction included in each target transaction.
When the target transaction is executed, in a case that it is detected that a first branch transaction of the target transaction fails to be executed, a preceding branch transaction of the first branch transaction and/or a branch transaction of the first branch transaction executed in parallel may be determined according to a branch transaction execution order of the target transaction, that is, a target branch transaction corresponding to the first branch transaction is determined, where the target branch transaction may include one or more branch transactions.
In S104, it is detected whether a database modification log corresponding to the target branch transaction exists in the database corresponding to the target transaction.
The database modification log may be a modification log generated by performing operations such as inserting, updating, and deleting on data in the database when the target branch transaction is executed, the database corresponding to the target transaction may include a sub-database corresponding to each branch transaction, and the database modification log corresponding to each branch transaction may be stored in a log storage database preset in a server of the target transaction, or may be stored in the sub-database corresponding to each branch transaction, respectively.
In an implementation, whether a database modification log corresponding to the target branch transaction exists may be looked up in a database (including a preset database and/or a sub-database corresponding to each branch transaction). For example, when a branch transaction is executed, the resource manager may perform a registration operation on the branch transaction and assign a corresponding transaction number to the branch transaction, and then may store a database modification log corresponding to the branch transaction in the database with the transaction number.
In the case that the target branch transaction is determined, whether a corresponding database modification log exists may be searched in the database according to the transaction number of the target branch transaction.
In S106, in the case that the database modification log is detected to exist, a rollback operation is performed on the database based on the database modification log to achieve consistency of the target transaction.
In implementation, the resource manager may report an execution condition of each branch transaction of the target transaction to the transaction coordinator, and when it is detected that the reported execution condition of the first branch transaction is an execution failure, the transaction manager may report the execution condition of the first branch transaction to the transaction coordinator, and the transaction coordinator may determine, according to the execution condition of the first branch transaction, whether to submit the branch transaction or perform a rollback operation on the database, and send a determination result to the transaction manager, and the transaction manager drives the resource manager to perform an operation (i.e., a commit operation or a rollback operation) according to the determination result.
In the case that the execution of the first branch transaction fails, a rollback operation may be performed on the database based on the database modification log of the target branch transaction, that is, the modified data is restored to the data before modification (that is, the modified data is restored to the data before the target branch transaction is not executed), so as to ensure the consistency of the global transaction.
In addition, after the rollback operation is executed, the database modification log corresponding to the rollback operation in the database may be deleted.
The embodiment of the invention provides a data processing method, which comprises the steps of determining a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is detected to be failed, detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction or not, and performing rollback operation on the database based on the database modification log under the condition that the database modification log is detected to exist, so as to realize the consistency of the target transaction. Therefore, the consistency of the target transaction can be realized only by performing rollback operation on the target branch transaction with the database modification log in the database, and business reverse operation on all executed transactions contained in the target transaction is not required, so that the workload of transaction processing is reduced, and the data processing efficiency is improved.
Example two
As shown in fig. 2, an execution subject of the method may be a server, where the server may be an independent server, or a server cluster composed of multiple servers, and the method may specifically include the following steps:
in S202, when a second branch transaction of the target transaction is executed, a database modification instruction corresponding to the second branch transaction is acquired.
The second branch transaction may be any one or more branch transactions of the target transaction, and the database modification instruction may be a database modification instruction generated based on a Data Manipulation Language (DML) and used for performing operations such as inserting, updating, and deleting on data in the database.
In S204, the content in the database modification instruction is analyzed to obtain the element data corresponding to the database modification instruction.
The element data may include preset field information related to the target data in the database modification instruction, for example, the element data may include field information for describing an attribute of the target data, field information for describing a location of the target data, field information for describing a type of operation on the target data, and other field information.
In S206, metadata for determining target data in the database is generated based on the element data, and the target data is determined based on the metadata.
Wherein the metadata may contain location information of the target data in the database.
In an implementation, the second branch transaction may correspond to a plurality of database modification instructions, and corresponding metadata may be generated based on the element data parsed from the content in each database instruction, where the metadata may be an electronic catalog including location information of a plurality of target data, and the corresponding target data may be searched in the database by using the location information of each target data included in the metadata in the database.
In S208, a database modification log corresponding to the second branch transaction is generated based on the database modification instruction and the target data in the database corresponding to the database modification instruction, and the database modification log is stored in the database.
In practice, the processing manner of S208 may be varied, and an alternative implementation manner is provided below, which may specifically refer to the following processing from step one to step two.
Step one, executing a database modification instruction to modify the target data and determining the modified target data.
And step two, generating a database modification log corresponding to the second branch transaction based on the database modification instruction, the target data and the modified target data.
In implementation, the database modification instruction, the target data, and the modified target data may be stored in the database corresponding to the second branch transaction in a log form, that is, the database modification log of the second branch transaction may be stored in the database corresponding to the second branch transaction, or the database modification log of the second branch transaction may be stored in a preset log storage database corresponding to the target transaction.
In addition, as shown in fig. 3, a transaction manager, a transaction coordinator, and a resource manager are deployed in the server, the transaction manager is configured to open a target transaction, and drive the resource manager to perform a registration operation on each branch transaction of the target transaction, meanwhile, the resource management area is driven to report the execution condition of each branch transaction to the transaction coordinator, the resource manager can also analyze and process the content of the database modification instruction, that is, the element data in the database modification instruction is extracted, the server can generate corresponding metadata according to the element data, and through the generated metadata, searching the corresponding target data in the database, then generating a database modification log corresponding to the branch transaction (namely, the second branch transaction) based on the database modification instruction, the target data and the modified target data, and storing the database modification log in the database.
In S210, in the case that the execution failure of the first branch transaction of the target transaction is detected, the target branch transaction corresponding to the first branch transaction is determined.
In implementation, taking a target transaction as a ticket purchasing transaction as an example, as shown in fig. 4, the ticket purchasing transaction may include a deduction branch transaction and a deduction branch transaction, after the target transaction is started, the transaction manager may call the resource manager to perform execution of the deduction branch transaction, after the deduction is successful, may execute a corresponding database modification instruction, and based on the database modification instruction, the corresponding target data, and the modified target data, generate a database modification log, store the database modification log in a corresponding database (i.e., a database corresponding to the deduction branch transaction), register the deduction branch transaction, and report the execution condition of the branch transaction to the transaction coordinator. At this time, the charging branch transaction is the second branch transaction.
After the deduction branch transaction is successfully executed, the deduction branch transaction can be continuously carried out, when the number of the tickets is insufficient and the deduction operation cannot be carried out, the deduction branch transaction is failed to be executed (the deduction branch transaction is the first branch transaction), at this time, the resource manager can register the deduction branch transaction and report the first branch transaction execution failure to the transaction coordinator, and therefore the front branch transaction of the deduction branch transaction is the target branch transaction (namely, the deduction branch transaction can be the target branch transaction).
In S212, it is detected whether a database modification log corresponding to the target branch transaction exists in the database corresponding to the target transaction.
In implementation, a database may be looked up for the presence of a database modification log corresponding to the deductive branch transaction.
In S214, in the case that the database modification log is detected to exist, a rollback operation is performed on the database based on the database modification log to achieve consistency of the target transaction.
In implementation, when the database modification log corresponding to the deduction branch transaction is detected to exist in the database, a rollback operation can be performed through the database modification log to increase the deducted fee, so that the consistency of the service data is realized.
In S216, after the rollback operation is performed on the database, the database modification log of the target branch transaction corresponding to the rollback operation is deleted.
The embodiment of the invention provides a data processing method, which comprises the steps of determining a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is detected to be failed, detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction or not, and performing rollback operation on the database based on the database modification log under the condition that the database modification log is detected to exist, so as to realize the consistency of the target transaction. Therefore, the consistency of the target transaction can be realized only by performing rollback operation on the target branch transaction with the database modification log in the database, and business reverse operation on all executed transactions contained in the target transaction is not required, so that the workload of transaction processing is reduced, and the data processing efficiency is improved.
EXAMPLE III
Based on the same idea, the data processing method provided in the embodiment of the present invention further provides a data processing apparatus, as shown in fig. 5.
The data processing apparatus includes: a transaction determination module 501, a log detection module 502, and a rollback module 503, wherein:
a transaction determining module 501, configured to determine, when it is detected that a first branch transaction of a target transaction fails to be executed, a target branch transaction corresponding to the first branch transaction, where the target branch transaction includes a preceding branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction;
a log detection module 502, configured to detect whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction;
a rollback module 503, configured to, when it is detected that the database modification log exists, perform a rollback operation on the database based on the database modification log, so as to achieve consistency of the target transaction.
In an embodiment of the present invention, the apparatus further includes:
the instruction acquisition module is used for acquiring a database modification instruction corresponding to a second branch transaction of the target transaction when the second branch transaction is executed, wherein the second branch transaction is any one or more branch transactions of the target transaction;
and the log generation module is used for generating a database modification log corresponding to the second branch transaction based on the database modification instruction and the target data corresponding to the database modification instruction in the database, and storing the database modification log in the database.
In an embodiment of the present invention, the apparatus further includes:
the processing module is used for analyzing and processing the content in the database modification instruction to obtain element data corresponding to the database modification instruction, wherein the element data comprises preset field information related to the target data in the database modification instruction;
a determining module, configured to generate metadata for determining the target data in the database based on the element data, and determine the target data based on the metadata, where the metadata includes location information of the target data in the database.
In an embodiment of the present invention, the apparatus further includes:
and the deleting module is used for deleting the database modification log of the target branch transaction corresponding to the rollback operation after the rollback operation is performed on the database.
The embodiment of the invention provides a data processing device, which determines a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is detected to be failed, wherein the target branch transaction comprises a pre-branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction, detects whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction, and performs rollback operation on the database based on the database modification log under the condition that the database modification log is detected to exist, so as to realize the consistency of the target transaction. Therefore, the consistency of the target transaction can be realized only by performing rollback operation on the target branch transaction with the database modification log in the database, and business reverse operation on all executed transactions contained in the target transaction is not required, so that the workload of transaction processing is reduced, and the data processing efficiency is improved.
Example four
Figure 6 is a schematic diagram of a hardware configuration of an electronic device implementing various embodiments of the invention,
the electronic device 600 includes, but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, a processor 610, and a power supply 611. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 6 does not constitute a limitation of the electronic device, and that the electronic device may include more or fewer components than shown, or some components may be combined, or a different arrangement of components. In the embodiment of the present invention, the electronic device includes, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted terminal, a wearable device, a pedometer, and the like.
The processor 610 is configured to determine, in a case that execution of a first branch transaction of a target transaction is failed, a target branch transaction corresponding to the first branch transaction, where the target branch transaction includes a preceding branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction;
a processor 610, configured to detect whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction;
and the processor 610 is configured to, when it is detected that the database modification log exists, perform a rollback operation on the database based on the database modification log to achieve consistency of the target transaction.
In addition, the processor 610 is further configured to, when a second branch transaction of the target transaction is executed, obtain a database modification instruction corresponding to the second branch transaction, where the second branch transaction is any one or more branch transactions of the target transaction;
in addition, the processor 610 is further configured to generate a database modification log corresponding to the second branch transaction based on the database modification instruction and target data in the database corresponding to the database modification instruction, and store the database modification log in the database.
In addition, the processor 610 is further configured to analyze content in the database modification instruction to obtain element data corresponding to the database modification instruction, where the element data includes preset field information related to the target data in the database modification instruction;
in addition, the processor 610 is further configured to generate metadata for determining the target data in the database based on the element data, and determine the target data based on the metadata, where the metadata includes location information of the target data in the database.
In addition, the processor 610 is further configured to delete the database modification log of the target branch transaction corresponding to the rollback operation after the rollback operation is performed on the database.
The embodiment of the invention provides electronic equipment, which determines a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is detected to be failed, wherein the target branch transaction comprises a pre-branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction, detects whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction, and performs rollback operation on the database based on the database modification log under the condition that the database modification log exists, so as to realize the consistency of the target transaction. Therefore, the consistency of the target transaction can be realized only by performing rollback operation on the target branch transaction with the database modification log in the database, and business reverse operation on all executed transactions contained in the target transaction is not required, so that the workload of transaction processing is reduced, and the data processing efficiency is improved.
It should be understood that, in the embodiment of the present invention, the radio frequency unit 601 may be used for receiving and sending signals during a message sending and receiving process or a call process, and specifically, receives downlink data from a base station and then processes the received downlink data to the processor 610; in addition, the uplink data is transmitted to the base station. In general, radio frequency unit 601 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, and the like. In addition, the radio frequency unit 601 may also communicate with a network and other electronic devices through a wireless communication system.
The electronic device provides wireless broadband internet access to the user via the network module 602, such as assisting the user in sending and receiving e-mails, browsing web pages, and accessing streaming media.
The audio output unit 603 may convert audio data received by the radio frequency unit 601 or the network module 602 or stored in the memory 609 into an audio signal and output as sound. Also, the audio output unit 603 may also provide audio output related to a specific function performed by the electronic apparatus 600 (e.g., a call signal reception sound, a message reception sound, etc.). The audio output unit 603 includes a speaker, a buzzer, a receiver, and the like.
The input unit 604 is used to receive audio or video signals. The input Unit 604 may include a Graphics Processing Unit (GPU) 6041 and a microphone 6042, and the Graphics processor 6041 processes image data of a still picture or video obtained by an image capturing apparatus (such as a camera) in a video capture mode or an image capture mode. The processed image frames may be displayed on the display unit 606. The image frames processed by the graphic processor 6041 may be stored in the memory 609 (or other storage medium) or transmitted via the radio frequency unit 601 or the network module 602. The microphone 6042 can receive sound, and can process such sound into audio data. The processed audio data may be converted into a format output transmittable to a mobile communication base station via the radio frequency unit 601 in case of the phone call mode.
The electronic device 600 also includes at least one sensor 605, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor that can adjust the brightness of the display panel 6061 according to the brightness of ambient light, and a proximity sensor that can turn off the display panel 6061 and/or the backlight when the electronic apparatus 600 is moved to the ear. As one type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), detect the magnitude and direction of gravity when stationary, and can be used to identify the posture of an electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), and vibration identification related functions (such as pedometer, tapping); the sensors 605 may also include fingerprint sensors, pressure sensors, iris sensors, molecular sensors, gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which are not described in detail herein.
The display unit 606 is used to display information input by the user or information provided to the user. The Display unit 606 may include a Display panel 6061, and the Display panel 6061 may be configured by a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
The user input unit 607 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device. Specifically, the user input unit 607 includes a touch panel 6071 and other input devices 6072. Touch panel 6071, also referred to as a touch screen, may collect touch operations by a user on or near it (e.g., operations by a user on or near touch panel 6071 using a finger, stylus, or any suitable object or accessory). The touch panel 6071 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 610, receives a command from the processor 610, and executes the command. In addition, the touch panel 6071 can be implemented by various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The user input unit 607 may include other input devices 6072 in addition to the touch panel 6071. Specifically, the other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a track ball, a mouse, and a joystick, which are not described herein again.
Further, the touch panel 6071 can be overlaid on the display panel 6061, and when the touch panel 6071 detects a touch operation on or near the touch panel 6071, the touch operation is transmitted to the processor 610 to determine the type of the touch event, and then the processor 610 provides a corresponding visual output on the display panel 6061 according to the type of the touch event. Although the touch panel 6071 and the display panel 6061 are shown in fig. 6 as two separate components to implement the input and output functions of the electronic device, in some embodiments, the touch panel 6071 and the display panel 6061 may be integrated to implement the input and output functions of the electronic device, and this is not limited here.
The interface unit 608 is an interface for connecting an external device to the electronic apparatus 600. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device having an identification module, an audio input/output (I/O) port, a video I/O port, an earphone port, and the like. The interface unit 608 may be used to receive input (e.g., data information, power, etc.) from external devices and transmit the received input to one or more elements within the electronic device 600 or may be used to transmit data between the electronic device 600 and external devices.
The memory 609 may be used to store software programs as well as various data. The memory 609 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 609 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The processor 610 is a control center of the electronic device, connects various parts of the whole electronic device by using various interfaces and lines, performs various functions of the electronic device and processes data by running or executing software programs and/or modules stored in the memory 609, and calling data stored in the memory 609, thereby performing overall monitoring of the electronic device. Processor 610 may include one or more processing units; preferably, the processor 610 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 610.
The electronic device 600 may further include a power supply 611 (e.g., a battery) for supplying power to the various components, and preferably, the power supply 611 may be logically connected to the processor 610 via a power management system, such that the power management system may be used to manage charging, discharging, and power consumption.
Preferably, an embodiment of the present invention further provides an electronic device, which includes a processor 610, a memory 609, and a computer program stored in the memory 609 and capable of running on the processor 610, where the computer program, when executed by the processor 610, implements each process of the data processing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not described here again.
EXAMPLE five
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the data processing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
The embodiment of the invention provides a computer-readable storage medium, which is used for determining a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is detected to fail, wherein the target branch transaction comprises a pre-branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction, detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction, and performing rollback operation on the database based on the database modification log under the condition that the database modification log is detected to exist so as to realize the consistency of the target transaction. Therefore, the consistency of the target transaction can be realized only by performing rollback operation on the target branch transaction with the database modification log in the database, and business reverse operation on all executed transactions contained in the target transaction is not required, so that the workload of transaction processing is reduced, and the data processing efficiency is improved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable batch processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable batch processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable batch processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable batch processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include transitory computer readable media (transient media) such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above description is only an example of the present invention, and is not intended to limit the present invention. Various modifications and alterations to this invention will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.

Claims (10)

1. A method of data processing, the method comprising:
determining a target branch transaction corresponding to a first branch transaction in the case of detecting that the first branch transaction of the target transaction fails to execute, wherein the target branch transaction comprises a preceding branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction;
detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction;
and under the condition that the database modification log is detected to exist, performing rollback operation on the database based on the database modification log so as to realize the consistency of the target transaction.
2. The method of claim 1, wherein before determining a target branch transaction corresponding to a first branch transaction of a target transaction if execution of the first branch transaction fails is detected, further comprising:
when a second branch transaction of the target transaction is executed, a database modification instruction corresponding to the second branch transaction is obtained, wherein the second branch transaction is any one or more branch transactions of the target transaction;
and generating a database modification log corresponding to the second branch transaction based on the database modification instruction and target data corresponding to the database modification instruction in the database, and storing the database modification log in the database.
3. The method of claim 2, further comprising, prior to the generating a database modification log corresponding to the second branch transaction based on the database modification instruction and target data in the database corresponding to the database modification instruction:
analyzing the content in the database modification instruction to obtain element data corresponding to the database modification instruction, wherein the element data comprises preset field information related to the target data in the database modification instruction;
generating metadata for determining the target data in the database based on the element data, and determining the target data based on the metadata, wherein the metadata comprises position information of the target data in the database.
4. The method of claim 1, further comprising:
and after the rollback operation is carried out on the database, deleting the database modification log of the target branch transaction corresponding to the rollback operation.
5. A data processing apparatus, characterized in that the apparatus comprises:
the transaction determining module is used for determining a target branch transaction corresponding to a first branch transaction under the condition that the execution of the first branch transaction of the target transaction is failed, wherein the target branch transaction comprises a front branch transaction of the first branch transaction and/or a branch transaction executed in parallel with the first branch transaction;
the log detection module is used for detecting whether a database modification log corresponding to the target branch transaction exists in a database corresponding to the target transaction;
and the rollback module is used for performing rollback operation on the database based on the database modification log under the condition that the database modification log is detected to exist so as to realize the consistency of the target transaction.
6. The apparatus of claim 5, further comprising:
the instruction acquisition module is used for acquiring a database modification instruction corresponding to a second branch transaction of the target transaction when the second branch transaction is executed, wherein the second branch transaction is any one or more branch transactions of the target transaction;
and the log generation module is used for generating a database modification log corresponding to the second branch transaction based on the database modification instruction and the target data corresponding to the database modification instruction in the database, and storing the database modification log in the database.
7. The apparatus of claim 6, further comprising:
the processing module is used for analyzing and processing the content in the database modification instruction to obtain element data corresponding to the database modification instruction, wherein the element data comprises preset field information related to the target data in the database modification instruction;
a determining module, configured to generate metadata for determining the target data in the database based on the element data, and determine the target data based on the metadata, where the metadata includes location information of the target data in the database.
8. The apparatus of claim 5, further comprising:
and the deleting module is used for deleting the database modification log of the target branch transaction corresponding to the rollback operation after the rollback operation is performed on the database.
9. An electronic device, comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the data processing method according to any one of claims 1 to 4.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the data processing method according to any one of claims 1 to 4.
CN202011051598.9A 2020-09-29 2020-09-29 Data processing method and device and electronic equipment Pending CN112231144A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011051598.9A CN112231144A (en) 2020-09-29 2020-09-29 Data processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011051598.9A CN112231144A (en) 2020-09-29 2020-09-29 Data processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN112231144A true CN112231144A (en) 2021-01-15

Family

ID=74120839

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011051598.9A Pending CN112231144A (en) 2020-09-29 2020-09-29 Data processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112231144A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764888A (en) * 2021-01-21 2021-05-07 中信银行股份有限公司 Distributed transaction checking and judging method and system based on log analysis
CN113420011A (en) * 2021-06-29 2021-09-21 平安消费金融有限公司 Redis transaction rollback method, device, computer equipment and storage medium
CN115577031A (en) * 2022-10-24 2023-01-06 北京力控元通科技有限公司 Database transaction processing method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598992A (en) * 2015-10-15 2017-04-26 中兴通讯股份有限公司 Database operating method and device
US20170161353A1 (en) * 2015-12-08 2017-06-08 Alibaba Group Holding Limited System, method and device for optimizing database operations
CN109491768A (en) * 2018-11-21 2019-03-19 四川长虹电器股份有限公司 A kind of distributed transaction method for dynamically processing and system based on subtransaction stream
CN110019443A (en) * 2017-09-08 2019-07-16 阿里巴巴集团控股有限公司 Non-relational database transaction methods, device and electronic equipment
CN110032428A (en) * 2019-02-21 2019-07-19 阿里巴巴集团控股有限公司 The execution method and apparatus of distributed transaction
CN111414266A (en) * 2020-03-23 2020-07-14 山东浪潮通软信息科技有限公司 Synchronous and asynchronous communication method and device for distributed transactions

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598992A (en) * 2015-10-15 2017-04-26 中兴通讯股份有限公司 Database operating method and device
US20170161353A1 (en) * 2015-12-08 2017-06-08 Alibaba Group Holding Limited System, method and device for optimizing database operations
CN110019443A (en) * 2017-09-08 2019-07-16 阿里巴巴集团控股有限公司 Non-relational database transaction methods, device and electronic equipment
CN109491768A (en) * 2018-11-21 2019-03-19 四川长虹电器股份有限公司 A kind of distributed transaction method for dynamically processing and system based on subtransaction stream
CN110032428A (en) * 2019-02-21 2019-07-19 阿里巴巴集团控股有限公司 The execution method and apparatus of distributed transaction
CN111414266A (en) * 2020-03-23 2020-07-14 山东浪潮通软信息科技有限公司 Synchronous and asynchronous communication method and device for distributed transactions

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764888A (en) * 2021-01-21 2021-05-07 中信银行股份有限公司 Distributed transaction checking and judging method and system based on log analysis
CN113420011A (en) * 2021-06-29 2021-09-21 平安消费金融有限公司 Redis transaction rollback method, device, computer equipment and storage medium
CN115577031A (en) * 2022-10-24 2023-01-06 北京力控元通科技有限公司 Database transaction processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN108089977B (en) Application program exception handling method and device and mobile terminal
CN112231144A (en) Data processing method and device and electronic equipment
CN109857494B (en) Message prompting method and terminal equipment
CN109522278B (en) File storage method and terminal equipment
CN110674112A (en) Data query method and device and electronic equipment
CN110990679A (en) Information searching method and electronic equipment
CN107908492B (en) Black screen detection method, mobile terminal and computer readable storage medium
CN111405043A (en) Information processing method and device and electronic equipment
CN109067979B (en) Prompting method and mobile terminal
CN112650498B (en) Static library integration method and device, electronic equipment and storage medium
CN108363499B (en) Text recovery method and mobile terminal
CN108089935B (en) Application program management method and mobile terminal
CN107832191B (en) Black screen detection method, mobile terminal and computer readable storage medium
CN109871324B (en) Control operation method and device
CN111045588B (en) Information viewing method and electronic equipment
US11567822B2 (en) Method of monitoring closed system, apparatus thereof and monitoring device
CN110764668B (en) Comment information acquisition method and electronic equipment
CN114707793A (en) Emergency plan generation method and device, storage medium and electronic equipment
CN112486567A (en) Code merging request sending method and device, electronic equipment and storage medium
CN112035180A (en) Automatic instance loading method and device, electronic equipment and storage medium
CN111475141A (en) List generation method and device and electronic equipment
CN110659329A (en) Data processing method and device and electronic equipment
CN110955468A (en) Method and device for calling operation entrance and electronic equipment
CN113032361B (en) Database configuration changing method and device, electronic equipment and storage medium
CN109088814B (en) Data processing method of mobile terminal and mobile terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 306, No. 799, Ximen Road, Chengqiao Town, Chongming District, Shanghai 202150

Applicant after: SHANGHAI I2FINANCE SOFTWARE CO.,LTD.

Address before: Room 2076, area C, building 8, No.2, Guanshan Road, Chengqiao Town, Chongming District, Shanghai 202150

Applicant before: SHANGHAI I2FINANCE SOFTWARE CO.,LTD.

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210115