CN116303510A - Resource transfer transaction processing method, device, computer equipment and storage medium - Google Patents

Resource transfer transaction processing method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN116303510A
CN116303510A CN202310300613.6A CN202310300613A CN116303510A CN 116303510 A CN116303510 A CN 116303510A CN 202310300613 A CN202310300613 A CN 202310300613A CN 116303510 A CN116303510 A CN 116303510A
Authority
CN
China
Prior art keywords
transaction
data
sub
adjusted
resource transfer
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
CN202310300613.6A
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310300613.6A priority Critical patent/CN116303510A/en
Publication of CN116303510A publication Critical patent/CN116303510A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/2379Updates performed during online database operations; commit processing
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a resource transfer transaction processing method, a resource transfer transaction processing device, computer equipment and a storage medium. Relates to the field of computers. Can be used in the financial field or other related fields. The method comprises the following steps: acquiring a main transaction aiming at a target resource transfer task; for any sub-transaction in each sub-transaction, acquiring corresponding transaction data to be adjusted from a database; under the condition that the data adjustment authority for the transaction data to be adjusted is obtained, executing data table adjustment operation on the transaction data to be adjusted to obtain adjusted transaction data corresponding to any sub-transaction; and updating the processing state of the main transaction under the condition that the adjusted transaction data is successfully submitted to the database. By adopting the method, after the transaction data adjustment processing is carried out on each sub-transaction, the processing state of the main transaction is updated based on the submitting state of the data after the adjustment of each sub-transaction, so that the complicated business logic caused by the examination of the submitting state after each sub-transaction is avoided, and the transaction processing efficiency is further improved.

Description

Resource transfer transaction processing method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technology, and in particular, to a method, an apparatus, a computer device, a storage medium, and a computer program product for resource transfer transaction processing.
Background
With the development of computer technology, a distributed architecture is developed, and when a distributed architecture is adopted to perform transaction processing, a participant of a transaction, a server supporting the transaction, a resource server and a transaction manager can be respectively arranged on different nodes of different distributed systems by the distributed transaction.
In the process of transferring the business of the resources related to the main business and the sub-business, when the sub-business is processed by adopting the traditional technology, after each sub-business executes business analysis and business data submission, the rollback log is deleted according to the business data submission result or the rollback data is rolled back according to the rollback log.
However, the conventional method is complicated for the sub-transaction processing process, and is disadvantageous to improving the transaction processing efficiency.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a resource transfer transaction processing method, apparatus, computer device, computer readable storage medium, and computer program product that can improve transaction processing efficiency.
In a first aspect, the present application provides a method for resource transfer transaction, the method comprising:
acquiring a main transaction aiming at a target resource transfer task; the main transaction includes at least one sub-transaction; the sub-transaction is a data table adjustment transaction for the target resource transfer task;
for any sub-transaction in each sub-transaction, acquiring transaction data to be adjusted corresponding to any sub-transaction from a database;
under the condition that the data adjustment authority for the transaction data to be adjusted is obtained, performing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted to obtain adjusted transaction data corresponding to any sub-transaction;
and under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, updating the processing state of the main transaction.
In one embodiment, the performing, when the data adjustment authority for the transaction data to be adjusted is acquired, a data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted includes:
acquiring a local data adjustment permission code aiming at the transaction data to be adjusted;
Responding to a local data adjustment instruction corresponding to the local data adjustment authority code, and executing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted;
and under the condition that the data table adjustment operation is completed, canceling executing the local data adjustment authority code.
In one embodiment, the method further comprises:
acquiring global data submission authority codes of the adjusted transaction data corresponding to each sub-transaction;
and responding to a data submitting instruction corresponding to the global data submitting permission code, and submitting the adjusted transaction data corresponding to each sub-transaction to the database.
In one embodiment, the method further comprises:
generating a data recovery log corresponding to each sub-transaction according to the transaction data to be adjusted and the adjusted transaction data corresponding to each sub-transaction;
and deleting the data recovery log under the condition of successfully submitting the adjusted transaction data corresponding to each sub-transaction to the database, and updating the processing state of the main transaction to a completion state.
In one embodiment, the method further comprises:
Under the condition that the transaction data corresponding to at least one sub-transaction in the sub-transactions fails to be submitted to the database, according to the data recovery log corresponding to the sub-transactions, recovering the transaction data corresponding to the sub-transactions to be regulated;
and deleting the data recovery log corresponding to each sub-transaction.
In one embodiment, the obtaining, from the database, transaction data to be adjusted corresponding to the any sub-transaction includes:
acquiring a data table to be adjusted corresponding to any sub-transaction from the database;
determining the position of the data to be adjusted in the data table to be adjusted;
and determining the transaction data to be adjusted according to the position of the data to be adjusted.
In one embodiment, the acquiring the master transaction for the target resource transfer task includes:
acquiring a field identifier corresponding to the target resource transfer task;
and determining the main transaction corresponding to the target resource transfer task according to the field identification.
In a second aspect, the present application further provides a resource transfer transaction apparatus, the apparatus comprising:
the transaction acquisition module is used for acquiring a main transaction aiming at a target resource transfer task; the main transaction includes at least one sub-transaction; the sub-transaction is a data table adjustment transaction for the target resource transfer task;
The data acquisition module is used for acquiring transaction data to be adjusted corresponding to any sub-transaction from a database for any sub-transaction in the sub-transactions;
the data adjustment module is used for executing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted under the condition that the data adjustment authority for the transaction data to be adjusted is acquired, so as to obtain adjusted transaction data corresponding to any sub-transaction;
and the transaction updating module is used for updating the processing state of the main transaction under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory and a processor, the memory storing a computer program which, when executed by the processor, implements the steps of the method described above.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the method described above.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprising a computer program which, when executed by a processor, implements the steps of the method described above.
According to the resource transfer transaction processing method, the device, the computer equipment, the storage medium and the computer program product, the main transaction aiming at the target resource transfer task is acquired, so that the sub-transaction included in the main transaction is determined, namely, the data table adjustment transaction aiming at the target resource transfer task is determined, for any sub-transaction in all sub-transactions, the to-be-adjusted transaction data corresponding to any sub-transaction is acquired from the database, so that the data to be adjusted of each sub-transaction is positioned, under the condition that the data adjustment authority aiming at the to-be-adjusted transaction data is acquired, the data table adjustment operation matched with the target resource transfer task is executed on the to-be-adjusted transaction data, so that the adjusted transaction data corresponding to any sub-transaction is obtained, and therefore, the transaction with the related data adjustment authority is adjusted based on the data adjustment authority, so that the data is prevented from being confused due to the adjustment of the same data, under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted, the sub-transaction state of the main transaction is updated based on the sub-transaction is updated, the fact that the sub-transaction is updated based on the sub-transaction state of the sub-transaction corresponding to the sub-transaction after the adjustment data is successfully submitted, and the sub-transaction state of the sub-transaction is updated after the adjustment data corresponding to the sub-transaction is adjusted, thereby improving the transaction processing efficiency.
Drawings
FIG. 1 is a flow diagram of a method of resource transfer transactions in one embodiment;
FIG. 2 is a flow diagram of adjusting transaction data in one embodiment;
FIG. 3 is a flow chart of a method of resource transfer transaction processing according to another embodiment;
FIG. 4 is a block diagram of a resource transfer transaction device in one embodiment;
fig. 5 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
It will be appreciated that the method may be applied to a terminal, a server, a system comprising a terminal and a server, and implemented by interaction of the terminal and the server.
In some embodiments, as shown in fig. 1, a method for transferring a transaction by using a resource is provided, where the method is applied to a terminal for illustrating, it is understood that the method may also be applied to a server, and may also be applied to a system including the terminal and the server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the steps of:
Step S102, a main transaction for a target resource transfer task is acquired.
Wherein the main transaction comprises at least one sub-transaction.
The sub-transactions are data table adjustment transactions for the target resource transfer task.
In practical application, a main transaction can comprise a plurality of sub-transactions, and when the plurality of sub-transactions comprising the main transaction are all completed, the main transaction is completed; taking a main transaction as an example of book selling, a first sub-transaction is used for reducing inventory, a second sub-transaction is used for obtaining income, the first sub-transaction and the second sub-transaction jointly form the main transaction, and the first sub-transaction and the second sub-transaction are completed, namely, the book selling flow corresponding to the main transaction is completed.
As one example, in response to a transaction instruction for a target resource transfer task, a server determines a master transaction corresponding to the target resource transfer task, and the server determines a number of sub-transactions included in the master transaction.
Step S104, for any sub-transaction in each sub-transaction, transaction data to be adjusted corresponding to any sub-transaction is obtained from the database.
The database may refer to a database where a data table that needs to be processed by each sub-transaction is located.
The transaction data to be adjusted may refer to data to be adjusted in a data table to be adjusted in a sub-transaction when the processing state of the sub-transaction is set to a completion state, and in practical application, when the transaction data to be adjusted in the data table to be adjusted in a certain sub-transaction is adjusted, the processing state of the sub-transaction may be set to the completion state.
As an example, since the main transaction includes several sub-transactions, for any of all the sub-transactions included in the main transaction, the server determines the data table in which each sub-transaction needs to be adjusted using sql parsing, and the server determines the transaction data to be adjusted in the data table.
Step S106, under the condition that the data adjustment authority for the transaction data to be adjusted is obtained, the data table adjustment operation matched with the target resource transfer task is executed for the transaction data to be adjusted, and the adjusted transaction data corresponding to any sub-transaction is obtained.
The data adjustment authority may refer to an authority that an initiator of the data adjustment operation should have when performing data adjustment on transaction data to be adjusted corresponding to each sub-transaction, in practical application, the transaction with the data adjustment authority may perform data adjustment on the transaction data to be adjusted, the data adjustment authority may include an instruction implemented by a database statement, and the data adjustment authority may include a local lock.
As an example, a server obtains a local lock for transaction data to be adjusted, the server performs a data table adjustment operation matched with a target resource transfer task on the transaction data to be adjusted corresponding to each sub-transaction, the server obtains adjusted transaction data corresponding to any sub-transaction, the server generates a rollback log for the data table adjustment operation, and each sub-transaction corresponds to one rollback log.
Step S108, under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, the processing state of the main transaction is updated.
As an example, the server obtains the global lock, the server sends the adjusted transaction data corresponding to each sub-transaction to the database, when the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, the server deletes the rollback log corresponding to each sub-transaction, the server sets the processing state of each sub-transaction to be a successful state, and the server updates the processing state of the main transaction to be a successful state.
According to the resource transfer transaction processing method, the sub-transaction included in the main transaction is determined by acquiring the main transaction aiming at the target resource transfer task, namely, the data table adjustment transaction aiming at the target resource transfer task and included in the main transaction is determined, for any sub-transaction in all sub-transactions, the to-be-adjusted transaction data corresponding to any sub-transaction is acquired from the database, so that the data to be adjusted of each sub-transaction is positioned, under the condition that the data adjustment authority aiming at the to-be-adjusted transaction data is acquired, the data table adjustment operation matched with the target resource transfer task is performed on the to-be-adjusted transaction data, so that the adjusted transaction data corresponding to any sub-transaction is obtained, the transaction with the related data adjustment authority is adjusted on the basis of the data adjustment authority, the data is prevented from being confused due to the fact that a plurality of transactions are adjusted simultaneously, under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, the processing state of the main transaction is updated on the basis of a plurality of sub-transactions, the processing state of the sub-transaction is updated on the basis of the fact that the data corresponding to the sub-transaction is successfully submitted, and the state of each sub-transaction is updated is prevented from being updated, and accordingly, the transaction efficiency after the transaction state adjustment is improved is achieved.
In some embodiments, as shown in fig. 2, in a case where the data adjustment authority for the transaction data to be adjusted is acquired, performing a data table adjustment operation matching the target resource transfer task on the transaction data to be adjusted, including:
step S202, obtaining a local data adjustment permission code for transaction data to be adjusted.
The local data adjustment permission code may refer to a local lock, in practical application, the local lock may be implemented by a statement of a database select.
As one example, as each sub-transaction is processed by a server, the server obtains a local lock for the transaction data to be adjusted and the server runs the local lock.
Step S204, responding to the local data adjustment instruction corresponding to the local data adjustment authority code, and executing the data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted.
As an example, after the server acquires the local lock, the server responds to a local data adjustment instruction corresponding to the local lock and aiming at the transaction data to be adjusted, the server executes data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted, and the server obtains modified transaction data corresponding to the transaction data to be adjusted.
In step S206, when the data table adjustment operation is completed, the execution of the local data adjustment authority code is canceled.
As an example, after the server performs a data table adjustment operation matching the target resource transfer task on the transaction data to be adjusted, the server cancels the execution of the local lock, i.e., the server releases the local lock.
In this embodiment, by acquiring the local data adjustment permission code for the transaction data to be adjusted, and responding to the local data adjustment instruction corresponding to the local data adjustment permission code, performing a data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted, and under the condition that the data table adjustment operation is completed, canceling the execution of the local data adjustment permission code, the data confusion caused by the concurrent modification of data of a plurality of transactions can be prevented based on the local lock, and the transaction data processing accuracy is ensured.
In some embodiments, the above method further comprises: acquiring global data submission authority codes of the adjusted transaction data corresponding to each sub-transaction; and responding to a data submitting instruction corresponding to the global data submitting authority code, and submitting the adjusted transaction data corresponding to each sub-transaction to a database.
The GLOBAL data submitting authority code may refer to a GLOBAL LOCK, in practical application, the GLOBAL LOCK is implemented by a code, and maintains information through a database table global_lock_info, and indicates that data with an id of Y in an X-sheet table is in distributed transaction, and modification is not allowed; internal transactions can be prevented from accessing each other, the global lock prohibits inter-transaction modification data from the code layer, and only the global lock is taken, the server can submit local transactions.
As an example, after the server performs the data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted, the server obtains adjusted transaction data corresponding to any sub-transaction, after the server acquires the global lock, the server responds to a data submission instruction corresponding to the global data submission authority code, and the server submits the adjusted transaction data corresponding to each sub-transaction to the database.
In this embodiment, the global data submission authority code of the adjusted transaction data corresponding to each sub-transaction is obtained; and responding to a data submitting instruction corresponding to the global data submitting authority code, and submitting the adjusted transaction data corresponding to each sub-transaction to a database, so that the modified transaction data can be accurately submitted based on the global lock, and the transaction processing accuracy is improved.
In some embodiments, the above method further comprises: generating a data recovery log corresponding to each sub-transaction according to the transaction data to be adjusted and the adjusted transaction data corresponding to each sub-transaction; and under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, deleting the data recovery log, and updating the processing state of the main transaction to a completion state.
The data recovery log may refer to data used for recording data adjustment operations of the transaction data to be adjusted corresponding to each sub-transaction, and in practical application, the data recovery log may include a rollback log.
As an example, in the process of performing data adjustment operation on the transaction data to be adjusted corresponding to each sub-transaction, the server generates a rollback log corresponding to each sub-transaction according to the transaction data to be adjusted and the adjusted transaction data, in practical application, the server records the transaction data to be adjusted corresponding to each sub-transaction in the rollback log, that is, the server records the transaction data before adjustment of each sub-transaction in the rollback log, the server can restore the transaction data to a state before data start according to the rollback log, when the server successfully submits the modified transaction data corresponding to each sub-transaction to the database, the server determines that the processing state of each sub-transaction is a successful state, the server deletes the rollback log, and the server updates the processing state of the main transaction to a completion state.
In this embodiment, a data recovery log corresponding to each sub-transaction is generated according to the transaction data to be adjusted and the adjusted transaction data corresponding to each sub-transaction; under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, deleting the data recovery log, updating the processing state of the main transaction to be the completion state, determining the rollback log based on the transaction data to be adjusted and the adjusted transaction data corresponding to each sub-transaction, ensuring the sustainable operation and the data stability of the transaction processing by using the rollback log, and under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, deleting the data recovery log, updating the processing state of the main transaction to be the completion state, and improving the transaction processing accuracy.
In some embodiments, the above method further comprises: under the condition that the transaction data corresponding to at least one sub-transaction in each sub-transaction fails to be submitted to the database, according to the data recovery log corresponding to each sub-transaction, the transaction data corresponding to each sub-transaction after adjustment is recovered to the transaction data corresponding to each sub-transaction to be adjusted; and deleting the data recovery log corresponding to each sub-transaction.
As an example, when the server detects that the transaction data corresponding to at least one sub-transaction in each sub-transaction fails to be submitted to the database, the server restores the adjusted transaction data corresponding to each sub-transaction to the transaction data to be adjusted corresponding to each sub-transaction according to the data restoration log corresponding to each sub-transaction, the server deletes the data restoration log corresponding to each sub-transaction, the server acquires the local lock of the transaction data to be adjusted corresponding to each sub-transaction again, the server executes step S106 and subsequent steps until the server successfully submits the modified transaction data corresponding to each sub-transaction to the database, the server determines that the processing state of each sub-transaction is a successful state, the server deletes the rollback log, and the server updates the processing state of the main transaction to a completion state.
In this embodiment, under the condition that the transaction data corresponding to at least one sub-transaction in each sub-transaction fails to be submitted to the database, according to the data recovery log corresponding to each sub-transaction, the adjusted transaction data corresponding to each sub-transaction is recovered to the transaction data to be adjusted corresponding to each sub-transaction; deleting the data recovery log corresponding to each sub-transaction can recover the transaction data according to the rollback log based on the rollback log under the condition that the transaction data is failed to be submitted after adjustment corresponding to the sub-transaction, thereby ensuring the consistency of the transaction data and improving the transaction processing accuracy.
In some embodiments, obtaining transaction data to be adjusted corresponding to any sub-transaction from the database includes: acquiring a data table to be adjusted corresponding to any sub-transaction from a database; determining the position of data to be adjusted in a data table to be adjusted; and determining transaction data to be adjusted according to the position of the data to be adjusted.
The data table to be adjusted may refer to a data table where transaction data to be adjusted corresponding to the sub-transaction is located.
The data position to be adjusted may refer to position information of the transaction data to be adjusted corresponding to the sub-transaction in the data table to be adjusted, and in practical application, the data position to be adjusted may include a data line position and a data id.
As an example, a server acquires a data table to be adjusted corresponding to any sub-transaction from a database, the server determines position information of the transaction data to be adjusted in the data table to be adjusted according to data types of the transaction data to be adjusted corresponding to each sub-transaction, the server determines the transaction data to be adjusted according to positions of the data to be adjusted, and the server records the transaction data to be adjusted in rollback logs corresponding to each sub-transaction.
In this embodiment, the obtaining transaction data to be adjusted corresponding to any sub-transaction from the database includes: acquiring a data table to be adjusted corresponding to any sub-transaction from a database; determining the position of data to be adjusted in a data table to be adjusted; according to the position of the data to be adjusted, the transaction data to be adjusted is determined, the transaction data to be adjusted corresponding to each sub-transaction can be determined based on the position of the data to be adjusted in the data table to be adjusted corresponding to each sub-transaction, the transaction data to be adjusted is accurately positioned, and the transaction processing accuracy is improved.
In some embodiments, obtaining a master transaction for a target resource transfer task includes: acquiring a field identification of a target resource transfer task; and determining the main transaction corresponding to the target resource transfer task according to the field identification.
The field identifier may refer to an identifier that characterizes a transaction type corresponding to the target resource transfer task, and in practical application, the field identifier may include @ TccAction annotation.
As an example, when the target resource transfer task is started, the server scans the service stub of the transaction related to the target resource transfer task, and when the server detects that the service stub contains the field identifier corresponding to the target resource transfer task, the server determines the transaction containing the field identifier corresponding to the target resource transfer task in the service stub as a sub-transaction, where the sub-transactions together form a main transaction, that is, the server determines the main transaction corresponding to the target resource transfer task.
In this embodiment, the field identifier of the target resource transfer task is obtained; according to the field identification, the main transaction corresponding to the target resource transfer task is determined, the transaction object corresponding to the target resource transfer task can be accurately determined based on the field identification, and the transaction accuracy is improved.
For the understanding of those skilled in the art, fig. 3 exemplarily proposes a flow chart of a resource transfer transaction processing method, taking a main transaction as an example of selling books, where the main transaction includes two sub-transactions, a first sub-transaction is to reduce inventory, a second sub-transaction is to obtain income, the first sub-transaction and the second sub-transaction together form a main transaction to complete the book selling flow, a method defining the main transaction is named selbook, a method of the first sub-transaction is named as decreestore, a method of the second sub-transaction is named as addAccount, the decreestore needs to operate the store data table to let the value of the transaction data a to be adjusted be-1, the addAccount needs to operate the account data table to let the value of the transaction data B to be adjusted be +10, and a clean sub-transaction of another main transaction needs to modify the store data table to let the corresponding value of the transaction data a to be-100, where the processing logic of a resource transfer task can be expressed as: the server analyzes the service sql to obtain a table name, id and the like needing to be modified, the descalestore obtains a local lock, the descalestore obtains a global lock, the server executes the service sql, the server modifies the service data (not submitted) to obtain modified service data, the server generates a rollback log (not submitted), the descalestore releases the global lock (not submitted), the server simultaneously submits the modified service data, the rollback log and the released global lock of the sub-transaction descalestore in one local transaction (the local transaction is the function of the database, the database can ensure that all the local transactions are submitted) to the database, if the server needs to execute a cleanup sub-transaction, the server tries to modify the storage table, the modification fails because the local lock cannot be obtained, the descalestore releases the local lock, releases a connection resource, the server executes the cleanup sub-transaction, the server modifies the cleanup sub-transaction, and the cleanup sub-transaction corresponds to the database which is not successfully modified, but the database is only able to modify the database A, and the database is not successfully modified; the method comprises the steps that a server performs try logic, the server analyzes service sql to obtain table names, ids and the like to be modified, the addAccount obtains local locks, the addAccount obtains global locks, the server performs execution service sql, the server modifies service data (not submitted), the server generates a rollback log (not submitted), the addAccount releases the global locks (not submitted), the server simultaneously submits the modified service data of the addAccount, the rollback log and the released global locks in a local transaction (the local transaction is the function of a database, the database can ensure to be submitted), the addAccount releases the local locks, releases connection resources, and releases global locks, if a clean sub-transaction tries to obtain the global locks, the server can obtain success and successfully submit, and at the moment, the value of the transaction data A to be regulated in a store data table in the database is-101, the addaccoundstock releases the global locks, the addaccoundstock executes a concim logic, and the addaccoundstock performs self logic; the try logic and the confrim logic may include a try phase and a confrim phase of the TCC mode, among others.
In an exemplary embodiment, the existing TCC mode has the disadvantage of strong service intrusion, three phases of the TCC mode all need to be accessed to apply self-design and coding, the TCC mode is adapted to the AT mode, the AT mode can ensure the advantage of strong isolation and supplement the disadvantage of the TCC mode, the three phases of operation generated automatically are utilized to reduce the service intrusion, and if the AT sub-transaction is adapted to the TCC mode, the situation to be completed can be expressed as: (1) Try: and analyzing the service sql, submitting the service data, the rollback log and the global lock in the same local transaction, and releasing the local lock and the connection resource, wherein the connection resource refers to the resource of the connection database. The database connection itself consumes resources such as network, memory, CPU and the like, so the database connection needs to be released in time after the use is finished; (2) Confirm: deleting the rollback log; (3) cancer: and rolling back by using the rollback log, and then deleting the rollback log. Table structure changes that need to be made for AT mode adaptation TCC mode may include: (1) dtx_tcc_sub: the original sub-transaction table needs to have a field added to indicate whether this is a sub-transaction for an AT; (2) GLOBAL_LOCK_INFO: the sub-transaction newly-added table is used for recording the information of the global lock, and main fields include a main transaction id, a sub-transaction id, a line number, a database name, a table name and the like. The local lock representation may modify local data, while the global lock representation may commit. The transaction needs to check whether this in-table lock is released before commit, where the global lock is released when the try phase is performed, whether successful or failed; (3) UNDO_LOG: the sub-transaction newly-added table is used for recording the rollback log of the sub-transaction, and the SQL analysis can be utilized to obtain the data change related to a certain transaction processing service, namely, the main transaction id, the sub-transaction id, the table name, the line number, the value before change, the value after change and the like.
In one exemplary embodiment, the sub-transaction of the At mode does not require the write try, confirm, cancel method, only the write traffic method, but the At requires an automatic three phase registration method due to the need to adapt the TCC mode and the great similarity in flow of the At mode. In practical application, a field is first added to the @ TccAction note to identify whether this is an AT sub-transaction, useAt defaults false. Similar to the Spring-based loading of beans for TCC traffic handling in the traditional TCC mode, such as abstract reference Proxyfactor, these beans scan the service stubs associated with TCC AT application start, the service stubs scan AT application start, if this annotation is scanned and useat=true is obtained, it is known that this is an AT sub-transaction, this annotation needs to be stored in context, with continuous delivery of service calls. In the case of TCC sub-transactions, we need to record service names, try methods, confirm methods, and cancel methods, etc. in the cache, however, one AT sub-transaction, like recording service names, its try methods record service codes, confirm and cancel records really about to be executed are confirm methods and cancel methods provided by attunextractor, and one service can be written, named attunextractor, in which fixed confirm methods and cancel methods are written. Because of the special design of the AT mode, all sub-transaction confirm methods delete the corresponding images, all cancel methods restore data using images and then delete images, each sub-transaction is executed only for the corresponding images, and images are distinguished by sub-transaction ids, which are recorded in the transaction context. The application does not need to rewrite any TCC code, and only needs to write business logic in the method of @ TccAction mark.
In an exemplary embodiment, the AT identification needs to be transferred by using a Filter of an RPC framework, such as a Filter mechanism of Dubbo, writing dubbotccconsummer Filter, setting useat=true in an indication when a service is invoked, and the DubboTccProviderFilter obtains the identification from the indication and then sets the identification in TccTransactionContext to be transferred along with a thread; the AT mode needs to walk the database agent, the database agent is enhanced in front and behind the conventional database operation, when the framework calls AT mode sub-transaction, processing logic needed by the framework is added when the written service code is applied, then the connection agent is returned, and then the SQLStatent agent is returned, the SQLStatent agent generates a rollback log by utilizing SQL analysis, wherein the SQL analysis can be realized by means of related tools, such as a drive, the SQLStatent object is taken by the agent, then the MYSQLSchemastatVisor is used for establishing a server, then the table-name can be obtained by the object table, the table value can be obtained by the operation (such as SELECT), the value of where the window condition value, the value of the insert and the like can be obtained by traversing, if the SQL statement is only the SELECT statement, the rollback log can be not needed, the condition in the SQL can be obtained, the modified data can be found, and the data before the data can be updated can be recorded; the front mirror image of insert only needs to show that the new data is deleted when rolling back, and the front mirror image of delete only needs to record the deleted data, and the data is reinserted when rolling back.
In this embodiment, an AT sub-transaction is introduced into a TCC mode, the AT sub-transaction is adapted to the TCC mode, and three phases of the AT sub-transaction are automatically registered, so that the AT mode joins in the TCC mode, the AT sub-transaction identifier is transmitted by using a Filter mechanism, and the AT sub-transaction is completed by using SQL parsing and a database proxy, so that the AT mode and the TCC mode can be adapted to realize a resource transfer transaction, thereby reducing the business invasiveness of the TCC mode to the original processing framework, simplifying the processing flow of the resource transfer transaction, and improving the transaction processing efficiency.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a resource transfer transaction processing device for implementing the above related resource transfer transaction processing method. The implementation of the solution provided by the apparatus is similar to the implementation described in the above method, so the specific limitation of one or more embodiments of the resource transfer transaction apparatus provided below may be referred to the limitation of the resource transfer transaction method hereinabove, and will not be repeated here.
In one embodiment, as shown in FIG. 4, there is provided a resource transfer transaction apparatus comprising: a transaction acquisition module 402, a data acquisition module 404, a data adjustment module 406, and a transaction update module 408, wherein:
a transaction acquisition module 402, configured to acquire a main transaction for a target resource transfer task; the main transaction includes at least one sub-transaction; the sub-transaction is a data table adjustment transaction for the target resource transfer task;
a data obtaining module 404, configured to obtain, for any one of the sub-transactions, transaction data to be adjusted corresponding to the any one of the sub-transactions from a database;
the data adjustment module 406 is configured to perform a data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted, to obtain adjusted transaction data corresponding to the any sub-transaction, when a data adjustment authority for the transaction data to be adjusted is obtained;
The transaction update module 408 is configured to update a processing state of the main transaction in case that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database.
In an exemplary embodiment, the data adjustment module 406 is specifically further configured to obtain a local data adjustment permission code for the transaction data to be adjusted; responding to a local data adjustment instruction corresponding to the local data adjustment authority code, and executing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted; and under the condition that the data table adjustment operation is completed, canceling executing the local data adjustment authority code.
In an exemplary embodiment, the apparatus further includes a data commit module, where the data commit module is specifically configured to obtain a global data commit rights code for the adjusted transaction data corresponding to each of the sub-transactions; and responding to a data submitting instruction corresponding to the global data submitting permission code, and submitting the adjusted transaction data corresponding to each sub-transaction to the database.
In an exemplary embodiment, the apparatus further includes a log deletion module, where the log deletion module is specifically configured to generate a data recovery log corresponding to each sub-transaction according to the transaction data to be adjusted and the adjusted transaction data corresponding to each sub-transaction; and deleting the data recovery log under the condition of successfully submitting the adjusted transaction data corresponding to each sub-transaction to the database, and updating the processing state of the main transaction to a completion state.
In an exemplary embodiment, the foregoing apparatus further includes a data recovery module, where the data recovery module is specifically configured to, in a case where the submitting of the adjusted transaction data corresponding to at least one of the sub-transactions to the database fails, recover, according to a data recovery log corresponding to each of the sub-transactions, the adjusted transaction data corresponding to each of the sub-transactions to transaction data to be adjusted corresponding to each of the sub-transactions; and deleting the data recovery log corresponding to each sub-transaction.
In an exemplary embodiment, the data obtaining module 404 is specifically further configured to obtain a data table to be adjusted corresponding to the any sub-transaction from the database; determining the position of the data to be adjusted in the data table to be adjusted; and determining the transaction data to be adjusted according to the position of the data to be adjusted.
In an exemplary embodiment, the transaction obtaining module 402 is specifically further configured to obtain a field identifier corresponding to the target resource transfer task; and determining the main transaction corresponding to the target resource transfer task according to the field identification.
The various modules in the resource transfer transaction device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program, when executed by a processor, implements a resource transfer transaction method. The display unit of the computer device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 5 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to comply with the related laws and regulations and standards of the related countries and regions.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (11)

1. A method of resource transfer transaction, the method comprising:
acquiring a main transaction aiming at a target resource transfer task; the main transaction includes at least one sub-transaction; the sub-transaction is a data table adjustment transaction for the target resource transfer task;
for any sub-transaction in each sub-transaction, acquiring transaction data to be adjusted corresponding to any sub-transaction from a database;
Under the condition that the data adjustment authority for the transaction data to be adjusted is obtained, performing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted to obtain adjusted transaction data corresponding to any sub-transaction;
and under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database, updating the processing state of the main transaction.
2. The method according to claim 1, wherein the performing, in a case where the data adjustment authority for the transaction data to be adjusted is acquired, a data table adjustment operation matching the target resource transfer task on the transaction data to be adjusted includes:
acquiring a local data adjustment permission code aiming at the transaction data to be adjusted;
responding to a local data adjustment instruction corresponding to the local data adjustment authority code, and executing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted;
and under the condition that the data table adjustment operation is completed, canceling executing the local data adjustment authority code.
3. The method according to claim 1, wherein the method further comprises:
Acquiring global data submission authority codes of the adjusted transaction data corresponding to each sub-transaction;
and responding to a data submitting instruction corresponding to the global data submitting permission code, and submitting the adjusted transaction data corresponding to each sub-transaction to the database.
4. The method according to claim 1, wherein the method further comprises:
generating a data recovery log corresponding to each sub-transaction according to the transaction data to be adjusted and the adjusted transaction data corresponding to each sub-transaction;
and deleting the data recovery log under the condition of successfully submitting the adjusted transaction data corresponding to each sub-transaction to the database, and updating the processing state of the main transaction to a completion state.
5. The method according to claim 4, wherein the method further comprises:
under the condition that the transaction data corresponding to at least one sub-transaction in the sub-transactions fails to be submitted to the database, according to the data recovery log corresponding to the sub-transactions, recovering the transaction data corresponding to the sub-transactions to be regulated;
And deleting the data recovery log corresponding to each sub-transaction.
6. The method of claim 1, wherein the obtaining transaction data to be adjusted corresponding to the any sub-transaction from a database comprises:
acquiring a data table to be adjusted corresponding to any sub-transaction from the database;
determining the position of the data to be adjusted in the data table to be adjusted;
and determining the transaction data to be adjusted according to the position of the data to be adjusted.
7. The method of claim 1, wherein the acquiring the master transaction for the target resource transfer task comprises:
acquiring a field identifier corresponding to the target resource transfer task;
and determining the main transaction corresponding to the target resource transfer task according to the field identification.
8. A resource transfer transaction device, the device comprising:
the transaction acquisition module is used for acquiring a main transaction aiming at a target resource transfer task; the main transaction includes at least one sub-transaction; the sub-transaction is a data table adjustment transaction for the target resource transfer task;
the data acquisition module is used for acquiring transaction data to be adjusted corresponding to any sub-transaction from a database for any sub-transaction in the sub-transactions;
The data adjustment module is used for executing data table adjustment operation matched with the target resource transfer task on the transaction data to be adjusted under the condition that the data adjustment authority for the transaction data to be adjusted is acquired, so as to obtain adjusted transaction data corresponding to any sub-transaction;
and the transaction updating module is used for updating the processing state of the main transaction under the condition that the adjusted transaction data corresponding to each sub-transaction is successfully submitted to the database.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
11. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 7.
CN202310300613.6A 2023-03-24 2023-03-24 Resource transfer transaction processing method, device, computer equipment and storage medium Pending CN116303510A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310300613.6A CN116303510A (en) 2023-03-24 2023-03-24 Resource transfer transaction processing method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310300613.6A CN116303510A (en) 2023-03-24 2023-03-24 Resource transfer transaction processing method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116303510A true CN116303510A (en) 2023-06-23

Family

ID=86799478

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310300613.6A Pending CN116303510A (en) 2023-03-24 2023-03-24 Resource transfer transaction processing method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116303510A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116680277A (en) * 2023-07-28 2023-09-01 腾讯科技(深圳)有限公司 Information verification method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116680277A (en) * 2023-07-28 2023-09-01 腾讯科技(深圳)有限公司 Information verification method, device, equipment and storage medium
CN116680277B (en) * 2023-07-28 2024-02-02 腾讯科技(深圳)有限公司 Information verification method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
JP4890811B2 (en) Validate dynamically generated operations against the data store
CN109582496B (en) Method and device for creating consistent snapshot group and computer readable storage medium
CN113010549B (en) Data processing method based on remote multi-activity system, related equipment and storage medium
CN116303510A (en) Resource transfer transaction processing method, device, computer equipment and storage medium
CN114328018B (en) Snapshot creation method, computing device and storage medium
CN115421969A (en) Backup data recovery method and computing device
CN111753141B (en) Data management method and related equipment
WO2021109710A1 (en) Method and system for detecting and resolving write conflict
US10853194B1 (en) Selective data restoration
CN115878655A (en) Data operation method and device, computer equipment and storage medium
US20210311635A1 (en) Modified Representation of Backup Copy on Restore
US20180239535A1 (en) Replicating Data in a Data Storage System
US20170364418A1 (en) Integrity of transactional memory of card computing devices in case of card tear events
CN112596954A (en) Data backup and reconstruction method, device, equipment and storage medium
CN117271148B (en) Hardware mutual exclusion lock sharing method and device and computer equipment
KR950011056B1 (en) Method of log/recovery management in transaction processing system
CN117076147B (en) Deadlock detection method, device, equipment and storage medium
CN112783969B (en) Request processing method and device, computer system and readable storage medium
CN116432229A (en) Browser screen capture prevention method, device, computer equipment, medium and program product
JP2002108673A (en) Shared file system and metal data server computer to be applied to the same
US20240129374A1 (en) Performance-enhancing cross-system request handling via shared memory cache
CN115495203A (en) Distributed transaction processing method, system, computer device and storage medium
CN117311930A (en) Task scheduling method, device, equipment, storage medium and program product
CN116010171A (en) Resource record processing method, device, computer equipment and storage medium
CN117235046A (en) Account migration data updating method and device, computer equipment and storage medium

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