CN106570027B - Transactional task processing method and device - Google Patents

Transactional task processing method and device Download PDF

Info

Publication number
CN106570027B
CN106570027B CN201510654810.3A CN201510654810A CN106570027B CN 106570027 B CN106570027 B CN 106570027B CN 201510654810 A CN201510654810 A CN 201510654810A CN 106570027 B CN106570027 B CN 106570027B
Authority
CN
China
Prior art keywords
task
attribute
transaction type
unit
transactional
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.)
Active
Application number
CN201510654810.3A
Other languages
Chinese (zh)
Other versions
CN106570027A (en
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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201510654810.3A priority Critical patent/CN106570027B/en
Publication of CN106570027A publication Critical patent/CN106570027A/en
Application granted granted Critical
Publication of CN106570027B publication Critical patent/CN106570027B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/2308Concurrency control

Landscapes

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

Abstract

The embodiment of the application discloses a transactional task processing method and device. The method comprises the following steps: receiving a current transaction type task, inquiring the state attribute of a lock object of a database corresponding to the current transaction type task according to the current transaction type task, if the state attribute is displayed as completion, executing the current transaction type task, modifying the state attribute into operation, wherein the lock object contains the state attribute of the execution state of the transaction type task, and submitting the current transaction type task according to the execution condition of the current transaction type task. When the transactional task is processed, the problem of concurrent execution of the transactional task is solved by using the lock object provided by the application, and the problem that a database lock mechanism depends on service data of a database in the prior art is solved because the lock object does not depend on the service data in the database.

Description

Transactional task processing method and device
Technical Field
The present application relates to the field of computer task processing technologies, and in particular, to a transactional task processing method and apparatus.
Background
With the development of computer information technology, more and more transactional tasks appear in distributed systems. The transactional task performs a series of operations on the database, either all or none of which are performed as an integral whole. When there are multiple transactional tasks concurrently executing, errors may occur in the results of the database operations. For example, while transactional task a performs ten plus 1 operations on the database and obtains the operation result, transactional task B performs ten minus 1 operations on the database, which may cause transactional task a to obtain an erroneous result due to the execution of transactional task B.
To solve the problem of concurrent execution of multiple transactional tasks, the prior art employs a database lock mechanism. The database lock mechanism constructs a database lock based on data in a database, and regulates concurrent execution of multiple transactional tasks through the database lock. That is, before the transaction type task starts, the system takes the service data in the database as the database lock, when a transaction type task arrives, the database lock is acquired first and then executed, after the transaction type task is finished, the database lock is released, and then other transaction type tasks can acquire the database lock again and execute the database lock.
Therefore, the database locking mechanism can solve the problem of concurrent execution of a plurality of transactional tasks and ensure the accuracy of data in the concurrent execution process of the plurality of transactional tasks. However, the database lock mechanism depends heavily on the service data of the database itself, and if there is no service data suitable as the database lock in the database, the database lock mechanism is difficult to use. In addition, after a transactional task acquires a database lock, if the transactional task executes very slowly, it may cause long waiting times for other transactional tasks.
Disclosure of Invention
The embodiment of the application provides a transactional task processing method and device, which are used for processing transactional tasks in a database.
The embodiment of the application adopts the following technical scheme:
a transactional task processing method, comprising:
receiving a current transactional task;
inquiring the state attribute of a lock object of a database corresponding to the current transaction task according to the current transaction task, if the state attribute is displayed as completion, executing the current transaction task, and modifying the state attribute into operation, wherein the lock object comprises the state attribute of the execution state of the transaction task;
and submitting the current transaction type task according to the execution condition of the current transaction type task.
Preferably, the method further comprises:
building a record in a distributed system, the record containing at least a field for determining a transactional task state attribute;
and mapping the record to a database of the distributed system as a lock object corresponding to the database.
Preferably, the lock object is stored in a database corresponding to the lock object in the distributed system, or in another database other than the database corresponding to the lock object in the distributed system.
Preferably, the lock object further includes a task identifier attribute, a start time attribute, and a timeout threshold attribute, where the task identifier attribute is used to record a task identifier of a most recently executed task, the start time attribute is used to record a time when the current transactional task is executed, and the timeout threshold attribute is the maximum time that a processing task can be used, and the method further includes:
and if the state attribute shows that the task is running, judging whether the execution time of the task recorded by the task identifier of the lock object is greater than the value of the overtime threshold attribute, and if so, executing the current transaction type task.
Preferably, the method further comprises:
judging whether the execution time of the current transaction type task is larger than the value of the overtime threshold attribute, if so, rolling back the current transaction type task; if not, submitting the current transaction type task according to the execution condition.
Preferably, the execution time of the task is specifically a difference between a current time and a time recorded by the start time attribute of the lock object when the task starts.
Preferably, the lock object further includes an overtime attribute and an overtime threshold attribute, the overtime attribute is used to record the number of times that the transaction type task is executed overtime, the overtime threshold attribute refers to the maximum value of the overtime attribute, and before submitting the current transaction type task according to the execution condition, the method further includes:
judging whether the execution time of the current transaction type task is larger than the value of the overtime threshold attribute, if so, rolling back the current transaction type task and increasing the value of the overtime number attribute; if not, submitting the current transaction type task according to the execution condition.
Preferably, the value of the attribute for increasing the number of times of timeout is specifically to add 1 to the value of the attribute for increasing the number of times of timeout.
Preferably, the method further comprises:
and judging whether the value of the overtime time attribute is greater than the value of the overtime time threshold attribute, if so, increasing the value of the overtime threshold attribute, and adjusting the value of the overtime time attribute to 0.
Preferably, the value of the timeout threshold attribute is specifically multiplied by 2.
Preferably, the method further comprises: and judging whether the current transactional task has errors, if so, rolling back the current transactional task.
A transactional task processing apparatus, comprising:
receiving unit, judging unit, lock object unit, execution unit and submitting unit, wherein:
the system comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a processing request of a current transaction type task to a database, and the current transaction type task refers to a transaction type task for processing the database;
the judging unit is used for judging the lock object unit and judging the size;
the system comprises an object locking unit, a task identification subunit and a state subunit, wherein the object locking unit is used for adjusting the concurrent execution of multiple tasks in a database and comprises a task identification subunit and a state subunit, and the state attribute of the state subunit comprises operation and completion;
the execution unit is used for executing the current transaction type task when the judgment unit judges that the state attribute of the state subunit of the lock object unit is finished;
and the submitting unit is used for submitting the current transaction type task according to the execution condition.
Preferably, the lock object unit further includes a start time subunit and a timeout threshold subunit, where the start time subunit is configured to record time when the current transaction type task is executed, the timeout threshold subunit is configured to set a maximum time for processing a task, and when the determining unit determines that the state attribute of the state subunit of the lock object unit is running: the judging unit judges whether the execution time of the task recorded by the task identifier subunit of the object locking unit is greater than the value of the timeout threshold subunit, if so, the executing unit executes the current transaction type task.
Preferably, the lock object unit further comprises:
the system comprises an overtime frequency subunit and an overtime frequency threshold subunit, wherein the overtime frequency subunit is used for recording the overtime frequency of task execution, the overtime frequency threshold subunit is used for setting the maximum value of an overtime frequency attribute, and when the submission unit submits the current transaction type task: the judging unit judges whether the execution time of the current transaction type task is larger than the value of the overtime threshold subunit, if so, the value of the overtime frequency subunit is increased, and the submitting unit rolls back the current transaction type task; if not, the submitting unit submits the current transaction type task.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects:
when the transactional task is processed, the problem of concurrent execution of the transactional task is solved by using the lock object provided by the application, and the problem that a database lock mechanism depends on service data of a database in the prior art is solved because the lock object does not depend on the service data in the database. In addition, at least one embodiment of the present application solves the problem of long waiting time of other transactional tasks under the condition that the transactional task is executed slowly by setting the timeout threshold attribute in the lock object.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic flowchart of a transactional task processing method provided in embodiment 1 of the present application;
fig. 2 is a schematic flowchart of a transactional task processing method provided in embodiment 2 of the present application;
fig. 3 is a schematic flowchart of a transactional task processing method provided in embodiment 3 of the present application;
fig. 4 is a schematic flowchart of a transactional task processing method provided in embodiment 4 of the present application;
fig. 5 is a schematic flowchart of a transactional task processing method provided in embodiment 5 of the present application;
fig. 6 is a schematic structural diagram of a transactional task processing device according to embodiment 6 of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the 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 application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Example 1
Embodiment 1 provides a method for transactional task processing in a system. The specific flow diagram of the method is shown in fig. 1, and the method comprises the following steps:
step 101: a current transactional task is received.
The distributed system receives a current transactional task. In a distributed system, when a computer needs to perform an indivisible series of operations on a database, it needs to send a task to the distributed system. Here, the whole of such an indivisible series of operations is referred to as a current transactional task, which is a transactional task for processing a database.
The payment system comprises a plurality of transactional tasks, a distributed system executes the tasks at regular time according to a set time rule, and the distributed system starts the processing flow of the task when the time point of executing a certain task is up to the present according to the set time rule.
Step 102: lock objects are built in a distributed system and then stored.
Building a record in a distributed system, the record containing at least a field for determining a transactional task state attribute; and mapping the record to a database of the distributed system as a lock object corresponding to the database.
And constructing a record in the distributed system, wherein the record at least comprises one field, and the field is used for defining the attribute, and then mapping the record to a database of the distributed system to be used as a lock object corresponding to the database.
In this embodiment, a record is constructed in the distributed system, the constructed record is used as a lock object, a mapping relationship is established between the lock object and the database, and then the lock object is stored. The constructed record at least comprises a state field, and the state field is used for defining state attributes. Multiple different fields may be included in the record for different attributes, such that the distributed lock implements different functions.
In particular, the constructed record may include a task identification field for defining task identification attributes and a status field for defining status attributes. In this way, the constructed lock object contains a task identification attribute and a state attribute.
Since the lock object is constructed directly by creating a record in the distributed system and is not dependent on the business data in the corresponding database, the lock object can be stored in the corresponding database of the distributed system or other databases of the distributed system during storage.
It should be noted that, when the order between step 102 and step 101 in this embodiment is interchanged, the implementation of the technical effect in this embodiment is not affected. That is, during the process of processing the task, the lock object may be constructed in the distributed system first, and then the current transactional task is received.
Step 103: and inquiring the state attribute of the lock object of the database corresponding to the current transaction task according to the current transaction task, and executing step 104 if the state attribute is displayed as completion, wherein the lock object comprises the state attribute of the execution state of the transaction task.
After receiving the task request of the current transaction type task, the distributed system queries the state attribute of the lock object. The state attribute of the lock object can be two types, one is completion (FINISH), which indicates that the lock object is in an idle state; the other is Run (RUNNING), which indicates that the lock object is in a locked state. If the query is complete, then execution begins at step 104. The lock object contains a state attribute for displaying the execution state of the lock object
Step 104: and executing the current transaction type task, and modifying the state attribute into operation.
When the state attribute of the lock object is shown as complete, the current transactional task is executed, and since the current transactional task already occupies the lock object, the state attribute of the lock object is changed to run.
In particular, errors often occur during the execution of a task, which may be caused by the task itself or by external factors. For example: when the transfer task is processed, if the account amount of the sender is not enough, a task error is caused, and the task error is caused by the task itself; if network interruption or power failure occurs in the transfer process, task errors can be caused, and the task errors are caused by external reasons. In order to prevent database errors caused by errors in the task execution process, step 1041 is added in the task execution process.
Step 1041: and judging whether the current transactional task has errors in the process of executing the current transactional task, and if so, rolling back the current transactional task.
And in the execution process of the current transaction type task, judging whether an error occurs, if so, rolling back the current transaction type task, namely returning the database to the state attribute before the current transaction type task is executed, and changing the state attribute of the lock into the lock completion state attribute.
Step 105: and submitting the current transaction type task according to the execution condition of the current transaction type task.
And if the current transaction type task completes all the operations without errors, submitting the current transaction type task and changing the state attribute of the lock object into completion.
By adopting the method provided by the embodiment 1, the lock object is constructed in the distributed system, and the concurrent execution of the transactional task is controlled through the state attribute of the lock object, so that the problem that the database lock mechanism in the prior art is difficult to use because no business data suitable for being used as a database lock exists when aiming at a non-relational database is solved.
Example 2
Embodiment 2 provides a transactional task processing method for processing a transactional task. The specific flow diagram of the method is shown in fig. 2, and the method comprises the following steps:
step 201: a current transactional task is received.
Step 202: and querying the state attribute of the lock object of the database corresponding to the current transactional task according to the current transactional task, executing step 2021 if the state attribute is displayed as complete, and executing step 2022 if the state attribute is displayed as running.
The lock object may include a task identifier attribute, a state attribute, a start time attribute, and a timeout threshold attribute, where the state attribute is used to display an operating state of the lock object, the start time attribute is used to record a time when the current transactional task is executed, the timeout threshold attribute is used to set a maximum time for processing a task, and the task identifier is used to uniquely represent a task. The state attribute of the lock object is inquired according to the current transaction type task processing request, and two situations may occur to the state attribute of the lock object, so that two different operation flows are generated. When the state attribute of the lock object is shown as complete, perform step 2021; step 2022 is performed when the state property of the lock object is shown as running.
Step 2021: and executing the current transaction type task, recording the task identifier and the current time of the current transaction type task, and modifying the state attribute to be running.
Step 2022: and judging whether the execution time of the previous task is greater than the value of the overtime threshold attribute, if so, executing the current transactional task, and recording the task identifier and the current time of the current transactional task, wherein the previous task refers to the transactional task recorded by the task identifier of the lock object before the current transactional task is executed.
The lock object provided in step 202, step 2021, and step 2022 may include four attributes, namely, a task identifier attribute, a state attribute, a start time attribute (startTime) and a timeout threshold attribute (overtime minutethreshhold), where the task identifier attribute is used to record a task identifier of a recently executed task, the state attribute is used to display an execution state of the lock, which represents whether the lock is idle, the start time attribute is used to record a time when the current transactional task starts to execute, and the timeout threshold attribute is the longest time that the processing task can be used.
After receiving the current transaction type task, the distributed system queries the state attribute of the lock object, if the state attribute of the lock object is found to be completed, the distributed system starts to execute the current transaction type task, records the task identifier carried by the current transaction type task in the task identifier attribute of the lock object, records the current time in the start time attribute, and changes the state attribute of the lock object into operation; if the state attribute of the lock object is found to be running, the execution time of the previous task needs to be compared with the value of the overtime threshold attribute, if the execution time of the previous task is greater than the value of the overtime threshold attribute, the current transaction type task is directly executed, the task identifier carried by the current transaction type task is recorded in the task identifier attribute of the lock, and meanwhile, the current time is recorded in the starting time attribute. The current time refers to the current displayed time of the system, the execution time of the task refers to the time of the task, and the specific calculation method comprises the following steps: the difference between the current time and the start time recorded by the start time attribute of the lock object at the start of the task.
Step 203: and submitting the current transaction type task according to the execution condition.
According to the method provided by the embodiment, the lock object is constructed in the distributed system, and the concurrent execution of the transactional task is controlled through the state attribute of the lock object, so that the problem that a database lock mechanism in the prior art is difficult to use due to the fact that no business data suitable for being used as a database lock exists when aiming at a non-relational database is solved; in addition, in this embodiment, by setting the start time attribute and the timeout threshold attribute in the lock object, after receiving the current transactional task, it can be determined whether the previous task is timeout, and the current transactional task is directly executed under the condition that the previous task is timeout, so that the problem of long-time waiting of other transactional tasks caused when the transactional task is slowly executed is solved.
Example 3
In embodiment 2, it is mentioned that the current transactional task is submitted according to an execution condition, and in fact before the current transactional task is submitted, the embodiment may further include determining whether an execution time of the current transactional task is greater than a value of the timeout threshold attribute. Thus, example 3 of the present application was constituted, and the steps of example 3 of the present application were the same as those of example 2 except for step 203. Referring to fig. 3, step 203 of embodiment 2 is changed in this embodiment to:
step 3031: and judging whether the execution time of the current transactional task is larger than the value of the overtime threshold attribute, if so, executing step 3032, and otherwise, executing step 3033.
Step 3032: rolling back the current transactional task.
Step 3033: and submitting the current transactional task.
At the end of the current transactional task execution, whether rolling back or committing, the present embodiment may also include changing the state attribute of the lock to completion.
By adopting the method provided by the embodiment 3, the following beneficial effects can be obtained: firstly, a lock object is constructed in a system, and the concurrent execution of a transaction type task is controlled through the state attribute of the lock object, so that the problem that a database lock mechanism in the prior art is difficult to use because no business data suitable for being used as a database lock exists when aiming at a non-relational database is solved; secondly, in this embodiment, by setting the start time attribute and the timeout threshold attribute in the lock object, after receiving the current transactional task, it can be determined whether the previous task is timeout, and the current transactional task is directly executed under the condition that the previous task is timeout, so that the problem of long-time waiting of other transactional tasks caused by slow execution of the transactional task is solved; thirdly, before the present transactional task is submitted, the present embodiment determines whether the present transactional task is submitted by determining whether the execution time of the present transactional task is greater than the value of the timeout threshold attribute, thereby preventing the problem of an error in updating the database when multiple tasks are executed concurrently.
Example 4
Embodiment 4 provides a transactional task processing method for processing a transactional task. The specific flow diagram of the method is shown in fig. 4, and the method comprises the following steps:
step 401: a current transactional task processing request is received.
Step 402: and querying the state attribute of the lock object of the database corresponding to the current transactional task according to the current transactional task, if the state attribute is displayed as completion, executing the step 4021, and if the state attribute is displayed as operation, executing the step 4022.
Step 4021: and executing the current transaction type task, recording the task identifier and the current time of the current transaction type task, and modifying the state attribute to be running.
Step 4022: and judging whether the execution time of the previous task is overtime, if so, executing the current transaction type task, and recording the task identifier and the current time of the current transaction type task.
In this embodiment, before querying the state attribute of the lock object of the database corresponding to the current transactional task according to the current transactional task in step 402, the method may also include constructing and storing the lock object;
the lock object provided in step 202, step 2021, and step 2022 may include a task identifier attribute, a state attribute, a start time attribute, a timeout threshold attribute, a timeout number attribute, and a timeout number threshold attribute, where the state attribute is used to display an operating state of the lock, the start time attribute is used to record a time when the task starts to be executed, the timeout threshold attribute is used to set a maximum time for processing the task, the timeout number attribute is used to record a number of times the task is executed, the timeout number threshold attribute is used to set a maximum value of the timeout number attribute, and the task identifier is used to uniquely represent the task;
as shown in table 1, the attribute information of the lock object in this embodiment includes six attributes, i.e., a task identifier attribute, a state attribute, a start time attribute, a timeout threshold attribute, a timeout time attribute (timeOutTimes) and a timeout time threshold attribute (timeoutthreshhold).
Table 1: attribute information for lock objects
taskName startTime overTimeMinutesThresHold timeOutTimes timeOutThresHold status
In the attributes of the lock object in this embodiment, the task identifier attribute is used to record a task identifier of a recently executed task, the state attribute displays an operating state of the lock object, which represents whether the lock object is idle, the start time attribute is used to record a time when a current transactional task starts to be executed, the timeout threshold attribute is used to set a maximum time that a processing task can use, the timeout number attribute is used to record a number of times that a task in a system is executed overtime, and the timeout number threshold attribute is used to set a maximum value of the timeout number attribute.
Step 4031: and judging whether the execution time of the current transaction type task is larger than the value of the overtime threshold attribute.
Step 4032: and if so, rolling back the current transaction type task and increasing the value of the overtime time attribute.
Step 4033: if not, submitting the current transaction type task.
When the execution time of the current transaction type task is judged to be greater than the value of the timeout threshold attribute, the value of the timeout frequency attribute can be increased in various modes, and particularly, when the execution time of the current transaction type task is judged to be greater than the value of the timeout threshold attribute, the task is rolled back, the value of the timeout frequency attribute is added with 1, and the timeout frequency attribute can be used for counting the total number of times of the execution task of the system within a period of time.
By adopting the method provided by the embodiment 4, the following beneficial effects can be obtained: firstly, a lock object is constructed in a system, and the concurrent execution of a transaction type task is controlled through the state attribute of the lock object, so that the problem that a database lock mechanism in the prior art is difficult to use because no business data suitable for being used as a database lock exists when aiming at a non-relational database is solved; secondly, in this embodiment, by setting the start time attribute and the timeout threshold attribute in the lock object, after receiving the current transactional task, it can be determined whether the previous task is timeout, and the current transactional task is directly executed under the condition that the previous task is timeout, so that the problem of long-time waiting of other transactional tasks caused by slow execution of the transactional task is solved; thirdly, before submitting the current transactional task, the embodiment determines whether the current transactional task is submitted by judging whether the execution time of the current transactional task is greater than the value of the timeout threshold attribute, so that the problem of error in updating the database when multiple tasks are executed concurrently is solved; fourthly, when the executed task is overtime, the lock object provided by the embodiment is used for counting the overtime times of the system operation process by changing the value of the overtime times attribute of the lock.
Example 5
In embodiment 4, the value of the timeout number attribute is increased, and after the value of the timeout number attribute is increased, the embodiment may further include comparing the value of the timeout number attribute with the value of the timeout number threshold attribute, so as to adjust the value of the timeout threshold attribute. Thus, example 5 of the present application was constructed, and compared with example 4, example 5 of the present application has the same steps except for steps 504 and 505. Referring to FIG. 5:
step 504: and judging whether the value of the timeout attribute is larger than that of the timeout threshold attribute.
Step 505: if yes, increasing the value of the timeout threshold attribute, and adjusting the value of the timeout number attribute to 0.
When the timeout attribute is greater than the value of the timeout threshold attribute within a period of time (e.g., a day), it means that the set value of the timeout threshold attribute is too small, which causes frequent timeout of task execution and affects the efficiency of task execution, and therefore, the value of the timeout threshold attribute needs to be increased. One preferred way to increase the value of the timeout threshold attribute is to multiply the value of the timeout threshold attribute by 2.
By adopting the method provided by the embodiment 5, the following beneficial effects can be obtained: firstly, a lock object is constructed in a system, and the concurrent execution of a transaction type task is controlled through the state attribute of the lock object, so that the problem that a database lock mechanism in the prior art is difficult to use because no business data suitable for being used as a database lock exists when aiming at a non-relational database is solved; secondly, in this embodiment, by setting the start time attribute and the timeout threshold attribute in the lock object, after receiving the current transactional task, it can be determined whether the previous task is timeout, and the current transactional task is directly executed under the condition that the previous task is timeout, so that the problem of long-time waiting of other transactional tasks caused by slow execution of the transactional task is solved; thirdly, before submitting the current transactional task, the embodiment determines whether the current transactional task is submitted by judging whether the execution time of the current transactional task is greater than the value of the timeout threshold attribute, so that the problem of error in updating the database when multiple tasks are executed concurrently is solved; fourthly, when the executed task is overtime, the lock object provided by the embodiment is used for counting the overtime times of the system operation process by changing the value of the overtime time attribute of the lock; fourthly, the lock object provided by the embodiment can judge whether timeout is frequent, and the efficiency of executing the task is improved by increasing the value of the timeout threshold attribute under the condition of frequent timeout.
Example 6
Based on the same inventive concept, embodiment 6 provides a transactional task processing apparatus for processing a transactional task. As shown in fig. 6, the apparatus 600 includes: a receiving unit 601, a judging unit 602, a lock object unit 603, an executing unit 604 and a submitting unit 605, wherein:
a receiving unit 601, configured to receive a request for processing a database by a current transactional task;
a determining unit 602, configured to determine a lock object unit and determine a size;
the lock object unit 603 is used for adjusting the concurrent execution of multiple tasks in the database, and comprises a task identification subunit 6031 and a state subunit 6032, and the state attribute of the state subunit comprises operation and completion;
an executing unit 604, configured to execute the current transaction type task when the determining unit determines that the state attribute of the state subunit of the lock object unit is complete;
a committing unit 605, configured to commit the current transactional task according to an execution situation.
After the receiving unit receives a processing request of a current transaction type task to the database, the judging unit judges the state attribute of the state subunit of the object locking unit, if the state attribute is displayed to be completed, the executing unit executes the current transaction type task, and finally, the submitting unit submits the current transaction type task according to the execution condition of the executing unit to the task.
In particular, the apparatus may further include a monitoring unit 606 for monitoring whether the task is in error during the execution of the task, and if the task is monitored to be in error, the task is rolled back directly by the execution unit 604.
In particular, the lock object unit may further include a start time subunit 6033 and a timeout threshold subunit 6034, where the start time subunit 6033 is configured to record a time when the current transactional task is executed, the timeout threshold subunit 6034 is configured to set a maximum time for which a processing task can be used, and when the determination unit 602 determines that the state attribute of the state subunit 6032 of the lock object unit 603 is run: the determining unit 602 determines whether the execution time of the task recorded by the task identification subunit 6031 of the lock object unit 603 is greater than the value of the timeout threshold subunit 6034, and if so, the execution unit executes the current transaction type task, and the start time subunit 6033 records the time when the current transaction type task is executed.
In particular, the lock object unit may further include: a start time subunit 6033, a timeout threshold subunit 6034, a timeout number subunit 6035, and a timeout number threshold subunit 6036, where the start time subunit 6033 is configured to record time when the current-transaction-type task is executed, the timeout threshold subunit 6034 is configured to set the longest time during which a processing task can be used, the timeout number subunit 6035 is configured to record the number of times a task is executed overtime, and the timeout number threshold subunit 6036 is configured to set the maximum value of the timeout number attribute, and when the commit unit 605 commits the current-transaction-type task: the determining unit 602 determines whether the execution time of the current transactional task is greater than the value of the timeout threshold subunit 6034, if yes, the value of the timeout number subunit 6035 is increased, and the committing unit 605 rolls back the current transactional task; if not, then commit unit 605 commits the current transactional task. In addition, after increasing the value of the timeout number subunit 6035, the determination unit 602 may also determine whether the value of the timeout number subunit 6035 is greater than the value of the timeout number threshold subunit 6036, and if so, increase the value of the timeout threshold subunit 6034 and modify the value of the timeout number subunit 6035 to 0.
With the transactional task processing device provided in embodiment 6, because the use of the locking unit of the transactional task processing device does not depend on the service data of the database, the problem that the database locking mechanism in the prior art depends on the service data of the database is overcome.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (12)

1. A transactional task processing method, comprising:
receiving a current transactional task;
inquiring a state attribute of a lock object of a database corresponding to the current transaction task according to the current transaction task, if the state attribute is displayed as finished, executing the current transaction task, and modifying the state attribute to be running, wherein the lock object is a record which is constructed in a distributed system and is mapped to the database, the record comprises at least one field, the field is used for defining attributes, the lock object comprises a state attribute of a transaction task execution state, a task identification attribute, a start time attribute and a timeout threshold attribute, the task identification attribute is used for recording a task identifier of a recently executed task, the start time attribute is used for recording the time when the current transaction task is started to be executed, and the timeout threshold attribute is the longest time for processing the task;
submitting the current transaction type task according to the execution condition of the current transaction type task;
and if the state attribute shows that the task is running, judging whether the execution time of the task recorded by the task identifier of the lock object is greater than the value of the overtime threshold attribute, and if so, executing the current transaction type task.
2. The method of claim 1, wherein prior to said querying a state attribute of a corresponding lock object in accordance with the current transactional task, the method further comprises:
building a record in a distributed system, the record containing at least a field for determining a transactional task state attribute;
and mapping the record to a database of the distributed system as a lock object corresponding to the database.
3. The method of claim 2, wherein the lock object is stored in a database in the distributed system corresponding to the lock object or in a database in the distributed system other than the database corresponding to the lock object.
4. The method of claim 1, wherein prior to said committing said current transactional task according to execution, said method further comprises:
judging whether the execution time of the current transaction type task is larger than the value of the overtime threshold attribute, if so, rolling back the current transaction type task; if not, submitting the current transaction type task according to the execution condition.
5. The method of claim 4, wherein the execution time of the current transactional task is specified as a difference between a current time and a time recorded by the start time attribute of the lock object at a start of the current transactional task.
6. The method of claim 4, wherein the lock object further comprises a timeout attribute for recording the number of times the transactional task has timed out for execution and a timeout threshold attribute, wherein the timeout threshold attribute is the maximum value of the timeout attribute, and wherein the method further comprises, before committing the current transactional task according to the execution:
judging whether the execution time of the current transaction type task is larger than the value of the overtime threshold attribute, if so, rolling back the current transaction type task and increasing the value of the overtime number attribute; if not, submitting the current transaction type task according to the execution condition.
7. The method as claimed in claim 6, wherein the value of the attribute for increasing the number of times of timeout is specifically to add 1 to the value of the attribute for increasing the number of times of timeout.
8. The method of claim 6, wherein after increasing the value of the time-out number attribute, the method further comprises:
and judging whether the value of the overtime time attribute is greater than the value of the overtime time threshold attribute, if so, increasing the value of the overtime threshold attribute, and adjusting the value of the overtime time attribute to 0.
9. The method of claim 8, wherein increasing the value of the timeout threshold attribute is embodied as multiplying the value of the timeout threshold attribute by 2.
10. The method of claim 1, wherein in said executing the current transactional task, the method further comprises: and judging whether the current transactional task has errors, if so, rolling back the current transactional task.
11. A transactional task processing apparatus, comprising:
receiving unit, judging unit, lock object unit, execution unit and submitting unit, wherein:
the system comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a processing request of a current transaction type task to a database, and the current transaction type task refers to a transaction type task for processing the database;
the judging unit is used for judging the lock object unit and judging the size;
the system comprises an object locking unit, a task identification subunit and a state subunit, wherein the object locking unit is used for adjusting the concurrent execution of multiple tasks in a database and comprises a task identification subunit and a state subunit, and the state attribute of the state subunit comprises operation and completion;
the execution unit is used for executing the current transaction type task when the judgment unit judges that the state attribute of the state subunit of the lock object unit is finished;
the submitting unit is used for submitting the current transaction type task according to the execution condition;
the lock object unit further comprises a start time subunit and a timeout threshold subunit, the start time subunit is configured to record a time when the current transactional task starts to be executed, the timeout threshold subunit is configured to set a maximum time for which a processing task can be used, the lock object is a record that is constructed in a distributed system and is mapped to the database, and the record includes at least one field used for defining an attribute;
when the judging unit judges that the state attribute of the state subunit of the lock object unit is running: the judging unit judges whether the execution time of the task recorded by the task identifier subunit of the object locking unit is greater than the value of the timeout threshold subunit, if so, the executing unit executes the current transaction type task.
12. The apparatus of claim 11, wherein the lock object unit further comprises:
the system comprises an overtime frequency subunit and an overtime frequency threshold subunit, wherein the overtime frequency subunit is used for recording the overtime frequency of task execution, the overtime frequency threshold subunit is used for setting the maximum value of an overtime frequency attribute, and when the submission unit submits the current transaction type task: the judging unit judges whether the execution time of the current transaction type task is larger than the value of the overtime threshold subunit, if so, the value of the overtime frequency subunit is increased, and the submitting unit rolls back the current transaction type task; if not, the submitting unit submits the current transaction type task.
CN201510654810.3A 2015-10-10 2015-10-10 Transactional task processing method and device Active CN106570027B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510654810.3A CN106570027B (en) 2015-10-10 2015-10-10 Transactional task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510654810.3A CN106570027B (en) 2015-10-10 2015-10-10 Transactional task processing method and device

Publications (2)

Publication Number Publication Date
CN106570027A CN106570027A (en) 2017-04-19
CN106570027B true CN106570027B (en) 2020-08-25

Family

ID=58506247

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510654810.3A Active CN106570027B (en) 2015-10-10 2015-10-10 Transactional task processing method and device

Country Status (1)

Country Link
CN (1) CN106570027B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107316124B (en) * 2017-05-10 2018-08-31 中国航天系统科学与工程研究院 Extensive affairs type job scheduling and processing general-purpose system under big data environment
CN110019530A (en) * 2017-12-29 2019-07-16 百度在线网络技术(北京)有限公司 Transaction methods and device based on distributed data base
CN109033364A (en) * 2018-07-26 2018-12-18 郑州云海信息技术有限公司 A kind of method, configuration center and node handling distributed transaction
CN109495452B (en) * 2018-10-24 2020-08-11 苏宁易购集团股份有限公司 Response timeout processing method, server and client response timeout processing system
CN109634726A (en) * 2018-10-25 2019-04-16 平安科技(深圳)有限公司 Processing method, device, equipment and the storage medium of timed task
CN109783203B (en) * 2018-12-28 2023-05-09 深圳竹云科技股份有限公司 Implementation method based on process task transaction processing mechanism
CN110609741A (en) * 2019-09-23 2019-12-24 中国银行股份有限公司 Task concurrent processing method and device
CN111026734B (en) * 2019-12-10 2020-11-13 北京北龙云海网络数据科技有限责任公司 Database management method, system, device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156928A (en) * 2011-04-29 2011-08-17 浪潮通信信息系统有限公司 Method for system concurrency control through business logic lock
CN102651006A (en) * 2011-02-25 2012-08-29 上海网环信息科技有限公司 Database table record locking method and device
CN103514164A (en) * 2012-06-15 2014-01-15 阿里巴巴集团控股有限公司 Data migration method and system
CN104239418A (en) * 2014-08-19 2014-12-24 天津南大通用数据技术股份有限公司 Distributed lock method for supporting distributed database and distributed database system
CN104793988A (en) * 2014-01-20 2015-07-22 阿里巴巴集团控股有限公司 Cross-database distributed transaction implementation method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102651006A (en) * 2011-02-25 2012-08-29 上海网环信息科技有限公司 Database table record locking method and device
CN102156928A (en) * 2011-04-29 2011-08-17 浪潮通信信息系统有限公司 Method for system concurrency control through business logic lock
CN103514164A (en) * 2012-06-15 2014-01-15 阿里巴巴集团控股有限公司 Data migration method and system
CN104793988A (en) * 2014-01-20 2015-07-22 阿里巴巴集团控股有限公司 Cross-database distributed transaction implementation method and device
CN104239418A (en) * 2014-08-19 2014-12-24 天津南大通用数据技术股份有限公司 Distributed lock method for supporting distributed database and distributed database system

Also Published As

Publication number Publication date
CN106570027A (en) 2017-04-19

Similar Documents

Publication Publication Date Title
CN106570027B (en) Transactional task processing method and device
US9589041B2 (en) Client and server integration for replicating data
US8161070B2 (en) Efficient delta handling in star and snowflake schemes
CN106802932B (en) Routing method and device of database and database system
CN109241067B (en) Transaction data management method and device
US20170351667A1 (en) Transaction processing method, processing node, central node, and cluster
CN108647357B (en) Data query method and device
RU2557761C2 (en) Bottom-up optimised search system and method
US10872086B2 (en) Selectivity estimation for database query planning
CN102073540A (en) Distributed affair submitting method and device thereof
US11449550B2 (en) Ad-hoc graph definition
CN107533474B (en) Transaction processing method and device
CN109002462A (en) A kind of method and system for realizing distributed things
CN107133367A (en) A kind of information processing method and system, server
CN114022188A (en) Target crowd circling method, device, equipment and storage medium
CN105653654B (en) Lottery qualification indexing system and method
CN112016009B (en) Data processing method, balance acquisition device, equipment and storage medium
US20190171478A1 (en) Efficient and scalable transaction processing using a consensus-based transaction model
CN106649584B (en) Index processing method and device in master-slave database system
US20060004807A1 (en) Performing recursive database operations
CN104636422A (en) Method and system for mining of patterns in a data set
US9916373B2 (en) Dynamic data partitioning extension
CN110457272B (en) Bill batch processing method and device
US20220027337A1 (en) Parallel processing of changes in a distributed system
US10324758B1 (en) Read load task throttling

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20200918

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200918

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right