Method and apparatus for recording retry in service processing, electronic device and storage medium

By using three preset tables to record retry information in business processes, the problem of no trace left for retries in existing technologies is solved, enabling timely querying and accurate location of retry records, thus improving work efficiency.

CN115952167BActive Publication Date: 2026-04-10北京自如信息科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-14
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing retry tools do not leave relevant records after a method execution is successful or fails, making it impossible to query retry records in a timely manner.

Method used

Three pre-defined tables (ready, finish, and error) are used to record retry information. Based on the execution result of the method function and the number of retries, the associated records are moved to the corresponding tables to ensure that the retry information is recorded and supports subsequent queries.

Benefits of technology

It enables timely querying and accurate location of retry information, improves work efficiency, and solves the problem of no trace left for retry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115952167B_ABST
    Figure CN115952167B_ABST
Patent Text Reader

Abstract

The application provides a method and device for recording retries in business processing, an electronic device and a storage medium, wherein the method comprises: obtaining an associated record related to a target task to be executed, wherein the associated record contains a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time; storing the associated record to a first preset table and running the target task; and moving the associated record to a second preset table or a third preset table according to a target number obtained after scanning the associated record according to a running result and a target thread, wherein the target number is a value obtained by increasing the preset number to the current retry number after the method function is called the preset number of times based on the interval duration. Through the application, the problem of leaving no trace of retries and being unable to query the retry record in time in the subsequent process in the related art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to a method and device for recording retry in business processing, electronic equipment and storage medium. BACKGROUND

[0002] Currently, some common retry tools exist, such as a @Retryable annotation provided by a spring framework. The annotation can be marked on a method, so that when the method throws an exception, a plurality of retries are performed after a specified time according to a set delay strategy.

[0003] However, the existing retry method does not leave any record whether the method finally succeeds or fails, so that the record cannot be queried in time subsequently.

[0004] Therefore, the related art has the problem that retry leaves no trace and the retry record cannot be queried in time subsequently. SUMMARY

[0005] The present application provides a method and device for recording retry in business processing, electronic equipment and storage medium, to at least solve the problem that retry leaves no trace and the retry record cannot be queried in time subsequently in the related art.

[0006] According to an aspect of an embodiment of the present application, a method for recording retry in business processing is provided, which comprises:

[0007] obtaining an associated record related to a target task to be executed, wherein the associated record contains a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time;

[0008] storing the associated record to a first preset table, and running the target task;

[0009] moving the associated record to a second preset table or a third preset table according to a target number obtained after the associated record is scanned by a target thread according to a running result, wherein the target number is a number obtained by adding a preset number to the current retry number based on that the method function is called the preset number of times according to the interval duration.

[0010] According to another aspect of an embodiment of the present application, a device for recording retry in business processing is also provided, which comprises:

[0011] a first obtaining module configured to obtain an associated record related to a target task to be executed, wherein the associated record contains a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time;

[0012] a storage module, configured to store the association record into a first preset table, and run the target task;

[0013] a transfer module, configured to transfer the association record to a second preset table or a third preset table according to a target number of times obtained after the target thread scans the association record according to the running result, wherein the target number of times is a number of times that the method function is called based on the interval duration, and a number of times that the current retry number is increased by the preset number of times.

[0014] Optionally, the transfer module comprises:

[0015] a first transfer unit, configured to transfer the association record to the second preset table when the running result is success.

[0016] an adjustment unit, configured to, when the running result is failure, successively scan the first preset table by using the target thread, obtain a target record satisfying a preset condition, execute a call on the target record, and adjust a number of times of the current retry number of the target record.

[0017] a second transfer unit, configured to, when the number of times of the current retry number of the adjusted target record is greater than a first preset threshold, transfer the target record to the third preset table, wherein the association record comprises the target record.

[0018] Optionally, the adjustment unit comprises:

[0019] a first obtaining sub-module, configured to obtain the target record whose next execution time is less than or equal to a current time of the target thread in the association record.

[0020] an increasing sub-module, configured to execute a call on the target record, and increase the current retry number of the target record by a first preset number of times to obtain an intermediate retry number after the first preset number of times is added.

[0021] Optionally, the second transfer unit comprises:

[0022] a second obtaining sub-module, configured to obtain a current time of the intermediate retry number.

[0023] a calculating sub-module, configured to calculate a next execution time of the target record corresponding to the intermediate retry number according to the current time of the intermediate retry number and the interval duration.

[0024] The transferring sub-module is configured to execute the call of the target record corresponding to the intermediate retry number when the next execution time of the target record corresponding to the intermediate retry number reaches the current time, until the sum of the preset number of values is the target number, and the target number is greater than the first preset threshold, and then move the target record to the third preset table.

[0025] Optionally, the apparatus further comprises:

[0026] The third transferring unit is configured to, after moving the associated record to the third preset table, move the reference record in which the error object in the third preset table is repaired successfully to the second preset table when it is determined that the error object in the third preset table is successfully repaired.

[0027] The first setting module is configured to set the current retry number of the reference record as an initial number state, and set the next execution time of the reference record as the current time.

[0028] The triggering module is configured to execute the call of the reference record to trigger the retry mechanism when the actual time reaches the current time.

[0029] Optionally, the apparatus further comprises:

[0030] The second setting module is configured to set the priority of the plurality of method functions corresponding to the target task.

[0031] The traversing module is configured to traverse the associated record in the first preset table currently acquired.

[0032] The execution module is configured to, when it is determined that the priority of the first method function is greater than the second preset threshold, move the associated record in which the first method function is located to the end of the second preset table, and execute the operation of reducing the priority of the first method function by the second preset number; and when it is determined that the priority of the second method function is equal to the second preset threshold, execute the call of the second method function.

[0033] Optionally, the apparatus further comprises:

[0034] The scanning module is configured to, after traversing the associated record in the first preset table currently acquired, successively scan the first preset table by using the target thread.

[0035] The increasing module is configured to, when it is determined that the number of the associated records in the first preset table that are subjected to the priority comparison operation exceeds the third preset threshold, continue to increase the associated records that are not subjected to the priority comparison operation.

[0036] According to a further aspect of the embodiments of the present application, an electronic device is also provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete the communication among each other through the communication bus; wherein the memory is configured to store a computer program; and the processor is configured to execute the method steps in any of the above embodiments by running the computer program stored in the memory.

[0037] According to a further aspect of the embodiments of the present application, a computer readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the method steps in any of the above embodiments when running.

[0038] In the embodiments of the present application, the associated record related to the target task to be executed is acquired, wherein the associated record contains the current retry number of the method function corresponding to the target task, the current time, and the interval duration between the current time and the next execution time; the associated record is stored to the first preset table, and the target task is run; the associated record is moved to the second preset table or the third preset table according to the target number obtained after the associated record is scanned according to the running result and the target thread, wherein the target number is the value obtained after the preset number of method function calls based on the interval duration and the current retry number is increased by the preset number. Since the first preset table, the second preset table and the third preset table are provided in advance in the embodiments of the present application, all the associated records are first saved in the first preset table for trace saving, and then the associated records are moved to the second preset table or the third preset table according to the calling running result of the associated record related to the target task to be executed and the retry number of the associated record. In this way, the retry is retained whether it succeeds or fails, so as to achieve the purpose of querying the retry record in time, accurately positioning the problem and improving the work efficiency, and further solve the problem of no trace left for the retry in the related art, and the problem of being unable to query the retry record in time subsequently. BRIEF DESCRIPTION OF DRAWINGS

[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the specification.

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or the prior art description will be briefly introduced as follows, and obviously, other drawings can also be obtained by those skilled in the art without any creative effort on the premise of not paying any creative effort.

[0041] Figure 1 is a flow diagram of an optional method for recording retry in business processing according to the embodiments of the present application;

[0042] Figure 2 is a whole flow chart of completing record migration table based on retry number according to an embodiment of the application;

[0043] Figure 3 is a whole flow chart of completing record migration table based on retry priority according to an embodiment of the application;

[0044] Figure 4 is a structure block diagram of an apparatus for record retry in service processing according to an embodiment of the application;

[0045] Figure 5 is a structure block diagram of an electronic device according to an embodiment of the application. DETAILED DESCRIPTION

[0046] In order to make the personnel in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.

[0047] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0048] There are some commonly used retry tools at present, such as the @Retryable annotation provided by the spring framework. This annotation can be marked on the method function, so that when the method function throws an exception, it will be retried for a number of times after a specified time according to the set delay strategy, for example:

[0049]

[0050]

[0051] value=Exception.class: When the method throws an exception of type Exception, the retry is triggered.

[0052] maxAttempts=3: Retry 3 times.

[0053] backoff=@Backoff(delay=2000,multiplier=1.5): The first retry starts 2 seconds after the method fails, and the retry ends if it succeeds; otherwise, the second retry starts 3 seconds (2*1.5) after the first retry fails, and the third retry starts 4.5 seconds (3*1.5) after the second retry fails.

[0054] However, such tools cannot be consulted again regardless of whether the final method execution succeeds or fails.

[0055] To solve the above problems, an embodiment of the present application proposes a method for recording retries in business processing, as shown in the method can be applied to the server side, and the method comprises: Figure 1

[0056] In step S101, an associated record related to a target task to be executed is obtained, wherein the associated record contains the current retry number of the method function corresponding to the target task, the current time, and the interval duration between the current time and the next execution time.

[0057] In step S102, the associated record is stored in a first preset table, and the target task is run.

[0058] In step S103, the associated record is moved to a second preset table or a third preset table according to the running result and the target number obtained after scanning the associated record, wherein the target number is the value obtained by increasing the preset number to the current retry number based on the interval duration.

[0059] Optionally, in the embodiment of the present application, the method function is still annotated:

[0060]

[0061]

[0062] intervalSecond="5,10,15,20,25,30": represents 6 retries, the first retry is 5 seconds after the first retry, if it continues to fail, the second retry is 10s after the first retry fails, and so on.

[0063] Meanwhile, three preset tables are used to complete the retry: the first preset table: the ready table, the second preset table: the finish table, and the third preset table: the error table.​

[0064] Firstly, the associated record related to the target task to be executed is acquired, and when the method function in the associated record is executed, the method name, method parameter, current retry number (initialized as 1) and next execution time (the current time calculated according to the retry number, for example, the current time is 2011-11-01 08:00:12, and the retry number is 1, so the next execution time is 2011-11-01 08:00:17) corresponding to the method function in the associated record are saved to the ready table, and then the target task is executed to execute the method function.

[0065] Then, according to the execution result of the method function (which is also the running result of the target task) and the total number of retry calls of the method function obtained by continuously scanning the associated record in the ready table by the background target thread, the associated record is moved to the finish table or the error table.

[0066] It should be noted that the associated record is moved to the finish table or the error table in conjunction with the running result and the number of retry calls of the method function, for example, in the case of successful execution of the method function, the associated record is moved to the finish table, and if it is unsuccessful, the associated record is moved to the error table based on the number of preset times of interval duration of the method function and the target number obtained by increasing the preset number of times to the current retry number recorded in the associated record.

[0067] In addition, the target thread can be one or multiple, and when the target thread is one, the target thread is used to successively scan the ready table when the method function is called again. If the target thread is multiple, each thread is only responsible for scanning the record of a specific retry number corresponding to the thread, that is, when the method function is called again, a new thread is used to scan the ready table.

[0068] In the embodiments of the present application, the associated record related to the target task to be executed is acquired, wherein the associated record contains the current retry number of the method function corresponding to the target task, the current time, and the interval duration between the current time and the next execution time; the associated record is stored in the first preset table, and the target task is run; the associated record is moved to the second preset table or the third preset table according to the target number obtained after the associated record is scanned according to the running result and the target thread, wherein the target number is the value obtained after the preset number of method function calls based on the interval duration and the preset number of current retry numbers are added. Since the first preset table, the second preset table and the third preset table are provided in advance in the embodiments of the present application, all the associated records are first saved in the first preset table for trace saving, and then the associated records are moved to the second preset table or the third preset table according to the calling running result of the associated record related to the target task to be executed and the retry number of the associated record. In this way, the retry is retained whether it is successful or failed, so as to realize the purpose of timely querying the retry record, accurately locating the problem and improving the work efficiency, and further solve the problem of no trace left for the retry in the related art, and the problem of no timely query of the retry record in the subsequent process.

[0069] Based on the content of each of the above embodiments, as an optional embodiment, the associated record is moved to the second preset table or the third preset table according to the target number obtained after the associated record is scanned according to the running result and the target thread, comprising:

[0070] In the case where the running result is successful, the associated record is moved to the second preset table;

[0071] In the case where the running result is failed, the first preset table is scanned by the target thread successively, the target record satisfying the preset condition is acquired, the target record is executed by calling, and the value of the current retry number of the target record is adjusted;

[0072] In the case where the value of the current retry number of the adjusted target record is greater than the first preset threshold, the target record is moved to the third preset table, wherein the associated record contains the target record.

[0073] Optionally, in this embodiment, if the execution result is successful, the associated record is moved to the finish table; if the execution result is unsuccessful, a background target thread continuously scans the ready table to obtain target records that meet preset conditions, such as obtaining records in the associated records whose next execution time is less than or equal to the current time of the target thread. When attempting to call the method function in the target record again, the current retry count of the target record needs to be increased by a first preset value, such as by 1, to obtain the intermediate retry count after increasing the first preset value. The next execution time of the target record corresponding to the intermediate retry count is calculated based on the current time and interval of the intermediate retry count.

[0074] When the next execution time of the target record corresponding to the intermediate retries reaches the current time, the call is executed on the target record. As long as the method does not terminate normally, the record in the `ready` table will not be moved and will be continuously retried, with the retry count increasing until the total number of retries exceeds a first preset threshold, such as more than 6 times. Then, the target record is moved from the `ready` table to the `error` table. This completes the retry tracking.

[0075] In this embodiment of the application, regardless of whether the retry is successful or not, there is a corresponding table to store the relevant records, which facilitates subsequent querying and problem localization.

[0076] As an alternative embodiment, such as Figure 2 As shown, Figure 2 This is an optional overall flowchart of record shifting based on the number of retries according to an embodiment of this application, specifically:

[0077] Scan the ready table to get a batch of records whose next execution time is less than or equal to the current time;

[0078] Determine if such a record exists;

[0079] If it exists, then iterate through this batch of ready records; if it does not exist, continue scanning.

[0080] Determine if the last record has been reached;

[0081] If it is determined that the current record is the last one, then the ready table is scanned to retrieve a batch of records whose next execution time is less than or equal to the current time.

[0082] After determining that the current record is not the last record, check if the number of retries is less than or equal to 6.

[0083] If greater than 6 times, the record is moved from the ready table to the error table, and the record in the ready table is processed again; if determined to be less than or equal to 6 times, the execution times and the next execution time of the ready record are updated;

[0084] According to the recorded method name and method parameter, the method is called;

[0085] If the execution is abnormal, the next ready data is processed; if the execution is successful, the ready record is transferred to the finish table, and the next ready data is processed again.

[0086] Based on the content of the above embodiments, as an optional embodiment, after the associated record is moved to the third preset table, the method further comprises:

[0087] In the case that the error object in the third preset table is successfully repaired, the reference record in which the repaired error object in the third preset table is located is moved to the second preset table;

[0088] The current retry times of the reference record are set to an initial value state, and the next execution time of the reference record is set to the current time;

[0089] In the case that the actual time reaches the current time, the reference record is executed to trigger the retry mechanism.

[0090] Optionally, generally, the method execution is abnormal, and it is very likely that the code is wrong, and the problem cannot be solved by simply retrying, and the developer needs to modify the code and put it online again, but in the traditional solution, after the retry ends, even if the code is repaired, it cannot be retried again. In the embodiment of the application, the retry information is persisted, if the final retry fails, the error object (such as code) in the error table is recorded, when the developer successfully repairs the error object in the error table, the repaired data can be manually moved from the error table to the ready table, and the retry times are set to an initial value state, such as 1, and the next execution time is set to the current time, so that when the actual time reaches the current execution time, the retry mechanism can be automatically triggered to call again.

[0091] In the embodiment of the application, if the final retry fails, after the code is repaired, the retry action can still be triggered again, solving the problem that the code cannot be used again after the code error in the prior art.

[0092] Based on the content of the above embodiments, as an optional embodiment, the method further comprises:

[0093] The priority of the plurality of method functions corresponding to the target task is set;

[0094] The associated record in the first preset table currently acquired is traversed;

[0095] In a case where it is determined that the priority of the first method function is greater than the second preset threshold, the associated record in which the first method function is located is placed at the tail of the second preset table, and the priority of the first method function is decremented by the second preset value; in a case where it is determined that the priority of the second method function is equal to the second preset threshold, the second method function is called.

[0096] Optionally, in the embodiment of the present application, a parameter representing retry priority is added to the @Retry annotation, and the priorities of the plurality of method functions corresponding to the target task need to be set in advance, and here, the higher the value, the lower the priority.

[0097] After a batch of ready records are queried each time, the ready records are traversed one by one, and if it is found that the retry priority of a method function is greater than the second preset threshold, for example, the priority of the first method function is greater than 1, the retry priority of the ready record is decremented by the second preset value, for example, the priority of the first method function is decremented by 1, and meanwhile, the associated record in which the first method function is located is placed at the tail of the queue of the batch of ready records; if the retry priority is equal to 1, the current method function is executed.

[0098] In the embodiment of the present application, the retry priority is added, so that when there are a large number of retry tasks, the tasks with high priority can be executed first, preventing the tasks with high priority from being blocked by the tasks with low priority.

[0099] Based on the contents of the above embodiments, as an optional embodiment, after the associated records in the first preset table obtained currently are traversed, the method further includes:

[0100] The target thread is used to successively scan the first preset table.

[0101] In a case where it is determined that the number of the associated records in the first preset table on which the priority comparison operation is performed exceeds the third preset threshold, the associated records on which the priority comparison operation is not performed are continuously added.

[0102] Optionally, in the embodiment of the present application, in order to ensure that all the associated records in the first preset table are implemented to be executed in the order of higher priority first, a background target thread is used to successively scan the first preset table, and after it is found that the number of the ready records on which the priority comparison operation is performed exceeds the third preset threshold, for example, exceeds half of the number, a batch of ready records on which the priority comparison operation is not performed is immediately supplemented, so that the operation of being executed in the order of higher priority first is implemented.

[0103] In the embodiments of the present application, by setting the retry priority, more retry opportunities are given to the high-priority method, thereby solving the problem that when a large number of time-consuming and unimportant methods need to be retried in the prior art, important methods in the rear cannot be retried in time.

[0104] As an optional embodiment, as shown in Figure 3 Figure 3 is an optional overall flowchart of completing record migration from the ready table to the finish table based on the retry priority according to the embodiments of the present application, and specifically:

[0105] Reading 1000 ready records into a queue;

[0106] Reading a task from the queue;

[0107] Determining whether the retry priority is greater than 1;

[0108] If the retry priority is greater than 1, the retry priority of the record is reduced by 1, the record is moved to the tail of the queue, and the queue reading task operation is executed again;

[0109] If the retry priority is not greater than 1, it is determined whether 500 records have been consumed from the queue;

[0110] If yes, the filling thread is woken up; if no, it is determined whether the retry number is less than or equal to 6 times;

[0111] If the retry number is less than or equal to 6 times, the execution number and the next execution time of the ready record are updated, the next ready record is processed in the case of an exception, otherwise, the method is called according to the method name and the method parameters of the record, and if the execution is still successful, the record is moved to the finish table.

[0112] After the filling thread is woken up, it is determined that 500 records have been consumed from the queue, and 500 ready records are read into the queue; if it is determined that 500 records have not been consumed from the queue, a waiting time (for example, 500s) is set, and after the waiting time is reached, it is determined whether 500 records have been consumed from the queue.

[0113] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all described as a combination of a series of actions, but those skilled in the art should know that the present application is not limited to the action order described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0114] ​Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software on a general hardware platform, and of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product in essence or the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk, or an optical disk), and includes a plurality of instructions for causing an end device (which can be a mobile phone, a computer, a server, or a network device) to execute the method of each embodiment of the present application.

[0115] According to another aspect of the embodiments of the present application, a device for implementing the method of retrying a record in a service process is also provided. Figure 4 is a structural block diagram of an optional device for retrying a record in a service process according to an embodiment of the present application, as shown in Figure 4 The device can include:

[0116] The first obtaining module 401 is configured to obtain an associated record related to a target task to be executed, wherein the associated record includes a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time.

[0117] The storage module 402 is configured to store the associated record to a first preset table and execute the target task.

[0118] The transfer module 403 is configured to transfer the associated record to a second preset table or a third preset table according to a target number obtained after scanning the associated record according to an execution result and a target thread, wherein the target number is a value obtained after increasing the current retry number by a preset number based on the interval duration and calling the method function by the preset number.

[0119] It should be noted that the first obtaining module 401 in this embodiment can be configured to execute the above step S101, the storage module 402 in this embodiment can be configured to execute the above step S102, and the transfer module 403 in this embodiment can be configured to execute the above step S103.

[0120] By the above module, the first preset table, the second preset table and the third preset table are provided in advance, all the associated records are first saved in the first preset table for trace saving, then the associated records are transferred to the second preset table or the third preset table according to the calling running result of the associated records related to the target task to be executed and the retry number of the associated records, so that the retry is reserved regardless of success or failure, thereby the purpose of timely querying the retry record, accurately locating the problem and improving the work efficiency is achieved, and the problem of not leaving traces in the related art and the problem of not being able to timely query the retry record in the subsequent process are solved.

[0121] As an optional embodiment, the transferring module comprises:

[0122] The first transferring unit is configured to transfer the associated record to the second preset table when the running result is success.

[0123] The adjusting unit is configured to, when the running result is failure, successively scan the first preset table by using the target thread, acquire the target record satisfying the preset condition, execute the calling on the target record, and adjust the value of the current retry number of the target record.

[0124] The second transferring unit is configured to, when the value of the current retry number of the adjusted target record is greater than the first preset threshold, transfer the target record to the third preset table, wherein the associated record contains the target record.

[0125] As an optional embodiment, the adjusting unit comprises:

[0126] The first acquiring submodule is configured to acquire the target record in the associated record whose next execution time is less than or equal to the current time of the target thread.

[0127] The increasing submodule is configured to execute the calling on the target record, and increase the current retry number of the target record by the first preset value to obtain the intermediate retry number after the first preset value is added.

[0128] As an optional embodiment, the second transferring unit comprises:

[0129] The second acquiring submodule is configured to acquire the current time of the intermediate retry number.

[0130] The calculating submodule is configured to calculate the next execution time of the target record corresponding to the intermediate retry number according to the current time of the intermediate retry number and the interval duration.

[0131] The transferring submodule is configured to execute the calling on the target record corresponding to the intermediate retry number when the current time reaches the next execution time of the target record corresponding to the intermediate retry number, until the sum of the plurality of preset values is the target number and the target number is greater than the first preset threshold, and then transfer the target record to the third preset table.

[0132] As an optional embodiment, the apparatus further comprises:

[0133] a third transferring unit, configured to, after the associated record is moved to the third preset table, move the reference record in which the error object in the third preset table has been repaired to the second preset table if it is determined that the error object in the third preset table is successfully repaired;

[0134] a first setting module, configured to set the current retry number of the reference record as an initial value state and set the next execution time of the reference record as the current time;

[0135] a triggering module, configured to execute the call on the reference record and trigger the retry mechanism if the actual time reaches the current time.

[0136] As an optional embodiment, the apparatus further comprises:

[0137] a second setting module, configured to set the priority of the plurality of method functions corresponding to the target task;

[0138] a traversing module, configured to traverse the associated record in the first preset table currently acquired;

[0139] an executing module, configured to, if it is determined that the priority of the first method function is greater than the second preset threshold, move the associated record in which the first method function is located to the tail of the second preset table and execute the operation of reducing the second preset value on the priority of the first method function; and execute the call on the second method function if it is determined that the priority of the second method function is equal to the second preset threshold.

[0140] As an optional embodiment, the apparatus further comprises:

[0141] a scanning module, configured to, after the associated record in the first preset table currently acquired is traversed, successively scan the first preset table by using the target thread;

[0142] an increasing module, configured to, if it is determined that the number of the associated records in the first preset table on which the priority comparison operation is performed exceeds the third preset threshold, continue to increase the associated records on which the priority comparison operation is not performed.

[0143] According to still another aspect of the embodiments of the present application, an electronic device for implementing the method for record retry in the business processing is provided, and the electronic device can be a server, a terminal, or a combination thereof.

[0144] Figure 5 is a structural block diagram of an optional electronic device according to the embodiments of the present application, as shown in Figure 5As shown, it includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504. The processor 501, communication interface 502, and memory 503 communicate with each other via the communication bus 504.

[0145] Memory 503 is used to store computer programs;

[0146] When processor 501 executes a computer program stored in memory 503, it performs the following steps:

[0147] Retrieve the associated records related to the target task to be executed. The associated records contain the current number of retries, the current time, and the interval between the current time and the next execution time for the method function corresponding to the target task.

[0148] Store the associated records in the first preset table and run the target task;

[0149] Based on the running results and the target number of times the target thread scans the associated records, the associated records are moved to the second or third preset table. The target number is the value obtained by adding the preset number of times the method function is called based on the interval time and the current retries to the preset number.

[0150] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0151] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0152] The memory may include RAM, or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0153] As an example, such as Figure 5 As shown, the memory 503 may include, but is not limited to, the first acquisition module 401, storage module 402, and transfer module 403 in the device for recording retries in the above-mentioned service processing. Furthermore, it may include, but is not limited to, other module units in the device for recording retries in the above-mentioned service processing, which will not be elaborated upon in this example.

[0154] The processor can be a general processor, which can include but is not limited to: a CPU (Central Processing Unit), a NP (Network Processor), etc.; and can also be a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0155] In addition, the electronic device further includes a display configured to display a result of retrying the record in the service processing.

[0156] Optionally, specific examples in the embodiment can refer to the examples described in the above embodiments, and the embodiment will not be described here again.

[0157] Those skilled in the art can understand that Figure 5 The structure shown is only schematic, and the device for implementing the method of retrying the record in the service processing can be a terminal device, which can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, etc. Figure 5 It does not limit the structure of the electronic device. For example, the terminal device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the embodiment, or have a different configuration from that shown in the embodiment. Figure 5 Figure 5 The structure shown is only schematic, and the device for implementing the method of retrying the record in the service processing can be a terminal device, which can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, etc.

[0158] Those skilled in the art can understand that all or part of the steps of the various methods in the above embodiments can be completed by programs instructing the related hardware of the terminal device, and the programs can be stored in a computer readable storage medium, which can include a flash disk, a ROM, a RAM, a magnetic disk or an optical disk, etc.

[0159] According to another aspect of the embodiment of the present application, a storage medium is further provided. Optionally, in the embodiment, the storage medium can be used for executing the program code of the method of retrying the record in the service processing.

[0160] Optionally, in the embodiment, the storage medium can be located on at least one of the plurality of network devices in the network shown in the above embodiment.​

[0161] Optionally, in the embodiment, the storage medium is configured to store program code for performing the following steps:

[0162] obtaining an association record related to a target task to be executed, wherein the association record contains a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time;

[0163] storing the association record to a first preset table, and running the target task;

[0164] moving the association record to a second preset table or a third preset table according to a target number obtained after scanning the association record according to a running result and a target thread, wherein the target number is a value obtained by increasing the current retry number by a preset number after calling the method function based on the interval duration for a preset number of times.

[0165] Optionally, specific examples in the embodiment can refer to the examples described in the above embodiments, and details are not described herein.

[0166] Optionally, in the embodiment, the storage medium can include, but is not limited to, a U disk, a ROM, a RAM, a mobile hard disk, a magnetic disk or an optical disk, and various storage media that can store program codes.

[0167] According to still another aspect of the embodiments of the present application, a computer program product or a computer program is provided, which includes computer instructions stored in a computer readable storage medium; a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the method steps for recording retries in service processing in any one of the above embodiments.

[0168] The above sequence numbers of the embodiments of the present application are only for description, and do not represent advantages or disadvantages of the embodiments.

[0169] The integrated units in the above embodiments, if realized in the form of software function units and sold or used as independent products, can be stored in the above computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art or the whole or part of the technical solutions can be embodied in the form of software products, which are stored in the storage medium and include a number of instructions to enable one or more computer devices (which can be personal computers, servers or network devices, etc.) to execute all or part of the steps of the method for recording retries in service processing.

[0170] In the above-described embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.

[0171] In several embodiments provided in the present application, it should be understood that the disclosed client can be implemented by other manners. Among them, the above-described device embodiments are only schematic, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between units or modules, and can be in electrical or other forms.

[0172] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place or distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the scheme provided in the embodiments.

[0173] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The above integrated unit can be realized in the form of hardware or in the form of software functional unit.

[0174] The above is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present application.

Claims

1. A method of recording retries in a transaction processing, characterized by, The method comprises: obtaining an associated record related to a target task to be executed, wherein the associated record contains a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time; storing the associated record to a first preset table and running the target task; moving the associated record to a second preset table or a third preset table according to a target number obtained after scanning the associated record according to a running result and a target thread, wherein the target number is a preset number of times of calling the method function based on the interval duration, and the associated record is moved to the second preset table or the third preset table after the current retry number is increased by the preset number of times; wherein the moving the associated record to the second preset table or the third preset table according to the running result and the target number obtained after scanning the associated record by the target thread comprises: in a case that the running result is successful, moving the associated record to the second preset table; in a case that the running result is unsuccessful, successively scanning the first preset table by the target thread to obtain a target record satisfying a preset condition, executing a call on the target record, and adjusting a value of the current retry number of the target record; in a case that the value of the current retry number of the adjusted target record is greater than a first preset threshold, moving the target record to the third preset table, wherein the associated record contains the target record.

2. The method of claim 1, wherein, the obtaining the target record satisfying the preset condition, executing the call on the target record, and adjusting the value of the current retry number of the target record comprises: obtaining the target record in which the next execution time is less than or equal to the current time of the target thread in the associated record; executing the call on the target record, and increasing the current retry number of the target record by a first preset value to obtain an intermediate retry number after the first preset value is added.

3. The method of claim 2, wherein, the moving the target record to the third preset table in a case that the value of the current retry number of the adjusted target record is greater than the first preset threshold comprises: obtaining a current time of the intermediate retry number; calculating a next execution time of the target record corresponding to the intermediate retry number according to the current time of the intermediate retry number and the interval duration; in a case that the current time reaches the next execution time of the target record corresponding to the intermediate retry number, executing the call on the target record corresponding to the intermediate retry number until a sum of a plurality of preset values is the target number, and the target number is greater than the first preset threshold, and then moving the target record to the third preset table.

4. The method of claim 1, wherein, after the associated record is moved to the third preset table, the method further comprises: in a case that an error object in the third preset table is repaired successfully, moving a reference record in which the repaired error object is located in the second preset table; setting the current retry number of the reference record to an initial value state, and setting the next execution time of the reference record to the current time; In a case where an actual time reaches the current time, the reference record is invoked, triggering a retry mechanism.

5. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: setting priorities of the plurality of method functions corresponding to the target task; traversing the associated records in the first preset table currently acquired; in a case where it is determined that the priority of the first method function is greater than a second preset threshold, placing the associated record in which the first method function is located at the tail of the second preset table, and performing a second preset value reduction operation on the priority of the first method function; in a case where it is determined that the priority of the second method function is equal to the second preset threshold, invoking the second method function.

6. The method of claim 5, wherein, After the traversing the associated records in the first preset table currently acquired, the method further comprises: continuously scanning the first preset table by using the target thread; in a case where it is determined that the number of the associated records in the first preset table on which the priority comparison operation is performed exceeds a third preset threshold, continuously increasing the associated records on which the priority comparison operation is not performed.

7. An apparatus for recording retries in a transaction processing, characterized by The device comprises: a first acquisition module configured to acquire an associated record related to a target task to be executed, wherein the associated record contains a current retry number of a method function corresponding to the target task, a current time, and an interval duration between the current time and a next execution time; a storage module configured to store the associated record into a first preset table and run the target task; a transfer module configured to transfer the associated record to a second preset table or a third preset table according to a target number of times obtained after the target thread scans the associated record and a running result, wherein the target number of times is a number of times the method function is invoked based on the interval duration, and the number of times the current retry number is increased after the method function is invoked the preset number of times; wherein the transfer module comprises: a first transfer unit configured to transfer the associated record to the second preset table in a case where the running result is success; an adjustment unit configured to, in a case where the running result is failure, continuously scan the first preset table by using the target thread, obtain a target record satisfying a preset condition, invoke the target record, and adjust a value of the current retry number of the target record; a second transfer unit configured to, in a case where the value of the current retry number of the adjusted target record is greater than a first preset threshold, transfer the target record to the third preset table, wherein the associated record contains the target record.

8. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein, The processor, the communication interface, and the memory complete communication with each other through the communication bus, and the processor, the communication interface, and the memory are characterized in that: the memory is configured to store a computer program; the processor is configured to execute the method steps of any one of claims 1 to 6 by running the computer program stored on the memory.

9. A computer readable storage medium, characterized in that, The storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps in any one of claims 1 to 6. The storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Distributed retry method and device, electronic equipment and storage medium

    CN111611057A

  • Task flow scheduling method and device, storage medium and electronic device

    CN112667384A