[go: up one dir, main page]

CN115952167A - Method and device for recording retry in business processing, electronic equipment and storage medium - Google Patents

Method and device for recording retry in business processing, electronic equipment and storage medium Download PDF

Info

Publication number
CN115952167A
CN115952167A CN202211608001.5A CN202211608001A CN115952167A CN 115952167 A CN115952167 A CN 115952167A CN 202211608001 A CN202211608001 A CN 202211608001A CN 115952167 A CN115952167 A CN 115952167A
Authority
CN
China
Prior art keywords
target
record
preset
retry
preset table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211608001.5A
Other languages
Chinese (zh)
Inventor
张苏磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ziroom Information Technology Co Ltd
Original Assignee
Beijing Ziroom Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ziroom Information Technology Co Ltd filed Critical Beijing Ziroom Information Technology Co Ltd
Priority to CN202211608001.5A priority Critical patent/CN115952167A/en
Publication of CN115952167A publication Critical patent/CN115952167A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Retry When Errors Occur (AREA)

Abstract

The application provides a method and a device for recording retry in business processing, an electronic device and a storage medium, wherein the method comprises the following steps: acquiring an association record related to a target task to be executed, wherein the association record comprises the current retry times and the current time of a method function corresponding to the target task and the interval duration between the current time and the next execution time; storing the association record to a first preset table, and operating a target task; and moving the association record to a second preset table or a third preset table according to the operation result and the target times acquired after the association record is scanned by the target thread, wherein the target times are values obtained by calling the preset times for the method function based on the interval duration and increasing the preset times for the current retry times. By the method and the device, the problems that in the related technology, retry does not leave traces and retry records cannot be inquired in time subsequently are solved.

Description

业务处理中记录重试的方法和装置、电子设备和存储介质Method and device for recording retry in business processing, electronic equipment and storage medium

技术领域technical field

本申请涉及计算机技术领域,尤其涉及一种业务处理中记录重试的方法和装置、电子设备和存储介质。The present application relates to the field of computer technology, and in particular to a method and device for recording retry in business processing, electronic equipment and a storage medium.

背景技术Background technique

目前,有一些常用的重试工具,比如spring框架提供的@Retryable注解,这个注解可以标注在方法上,这样当方法抛出异常时,会按照设置的延迟策略在指定的时间后,进行若干次重试;At present, there are some commonly used retry tools, such as the @Retryable annotation provided by the spring framework. This annotation can be marked on the method, so that when the method throws an exception, it will be performed several times after the specified time according to the set delay strategy. Retry;

但是,现有的上述重试方式不管最终方法执行成功还是失败,均未留下相关记录,导致后续无法及时查询记录。However, the existing above-mentioned retry methods do not leave relevant records regardless of whether the final method is successfully executed or fails, resulting in the inability to query records in a timely manner.

因此,相关技术中存在重试未留痕,后续无法及时查询重试记录的问题。Therefore, there is a problem in the related technology that the retry does not leave a trace, and the subsequent retry record cannot be queried in time.

发明内容Contents of the invention

本申请提供了一种业务处理中记录重试的方法和装置、电子设备和存储介质,以至少解决相关技术中存在重试未留痕,后续无法及时查询重试记录的问题。The present application provides a method and device for recording retries in business processing, electronic equipment, and a storage medium, so as to at least solve the problem in the related art that retries do not leave traces, and subsequent retries cannot be queried in time.

根据本申请实施例的一个方面,提供了一种业务处理中记录重试的方法,该方法包括:According to an aspect of an embodiment of the present application, a method for recording retry in business processing is provided, the method includes:

获取与待执行的目标任务相关的关联记录,其中,所述关联记录中包含所述目标任务对应的方法函数的当前重试次数、当前时间以及所述当前时间与下次执行时间之间的间隔时长;Obtain an association record related to the target task to be executed, wherein the association record includes the current number of retries, the current time, and the interval between the current time and the next execution time of the method function corresponding to the target task duration;

将所述关联记录存储至第一预设表,并运行所述目标任务;storing the associated record in a first preset table, and running the target task;

根据运行结果和目标线程扫描到所述关联记录后获取的目标次数,将所述关联记录移至第二预设表或第三预设表,其中,所述目标次数为基于所述间隔时长对所述方法函数调用了预设次数,并对所述当前重试次数增加所述预设次数后所得数值。According to the running result and the target number of times obtained after the target thread scans the associated record, the associated record is moved to the second preset table or the third preset table, wherein the target number of times is based on the interval duration The method function calls a preset number of times, and the value obtained by adding the preset number of times to the current retry times.

根据本申请实施例的另一个方面,还提供了一种业务处理中记录重试的装置,该装置包括:According to another aspect of the embodiment of the present application, there is also provided an apparatus for recording retry in business processing, the apparatus includes:

第一获取模块,用于获取与待执行的目标任务相关的关联记录,其中,所述关联记录中包含所述目标任务对应的方法函数的当前重试次数、当前时间以及所述当前时间与下次执行时间之间的间隔时长;The first acquisition module is configured to acquire an associated record related to the target task to be executed, wherein the associated record includes the current number of retries of the method function corresponding to the target task, the current time, and the relationship between the current time and the next The interval between execution times;

存储模块,用于将所述关联记录存储至第一预设表,并运行所述目标任务;a storage module, configured to store the associated record in a first preset table, and run the target task;

移送模块,用于根据运行结果和目标线程扫描到所述关联记录后获取的目标次数,将所述关联记录移至第二预设表或第三预设表,其中,所述目标次数为基于所述间隔时长对所述方法函数调用了预设次数,并对所述当前重试次数增加所述预设次数后所得数值。The transfer module is used to move the associated record to the second preset table or the third preset table according to the running result and the target number of times obtained after the target thread scans the associated record, wherein the target number of times is based on The interval duration calls the method function a preset number of times, and the value obtained by adding the preset number of times to the current number of retries.

可选地,移送模块包括:Optionally, the transfer module includes:

第一移送单元,用于在所述运行结果为成功的情况下,将所述关联记录移至所述第二预设表;a first transfer unit, configured to move the associated record to the second preset table when the operation result is successful;

调整单元,用于在所述运行结果为失败的情况下,利用所述目标线程陆续扫描所述第一预设表,获取满足预设条件的目标记录,对所述目标记录执行调用,并调整所述目标记录的当前重试次数的数值;An adjustment unit, configured to use the target thread to scan the first preset table successively to obtain target records satisfying preset conditions, call the target records, and adjust The value of the current number of retries recorded by the target;

第二移送单元,用于在确定调整后的目标记录的当前重试次数的数值大于第一预设阈值的情况下,将所述目标记录移至所述第三预设表,其中,所述关联记录内包含所述目标记录。The second moving unit is configured to move the target record to the third preset table when it is determined that the adjusted value of the current number of retries of the target record is greater than a first preset threshold, wherein the The associated record contains the target record.

可选地,调整单元包括:Optionally, the adjustment unit includes:

第一获取子模块,用于获取到所述关联记录中下次执行时间小于或者等于所述目标线程的当前时间的所述目标记录;The first obtaining submodule is used to obtain the target record whose next execution time is less than or equal to the current time of the target thread in the associated record;

增加子模块,用于对所述目标记录执行调用,并把所述目标记录的当前重试次数增加第一预设数值,得到增加所述第一预设数值后的中间重试次数。Adding a submodule, configured to call the target record, and increase the current number of retries of the target record by a first preset value to obtain an intermediate number of retries after the increase of the first preset value.

可选地,第二移送单元包括:Optionally, the second transfer unit includes:

第二获取子模块,用于获取所述中间重试次数的当前时间;The second obtaining submodule is used to obtain the current time of the intermediate number of retries;

计算子模块,用于根据所述中间重试次数的当前时间和所述间隔时长计算所述中间重试次数对应的所述目标记录的下次执行时间;A calculation submodule, configured to calculate the next execution time of the target record corresponding to the intermediate retry times according to the current time of the intermediate retry times and the interval duration;

移送子模块,用于在当前时间达到所述中间重试次数对应的所述目标记录的下次执行时间时,对所述中间重试次数对应的所述目标记录执行调用,直到多个所述预设数值之和为所述目标次数,且所述目标次数大于所述第一预设阈值时,则将所述目标记录移至所述第三预设表。The transfer sub-module is configured to call the target record corresponding to the intermediate retry times when the current time reaches the next execution time of the target record corresponding to the intermediate retry times, until a plurality of the The sum of preset values is the target number of times, and when the target number of times is greater than the first preset threshold, the target record is moved to the third preset table.

可选地,该装置还包括:Optionally, the device also includes:

第三移送单元,用于在将所述关联记录移至第三预设表之后,在获取将所述第三预设表内的错误对象修复成功的情况下,将所述第三预设表内已修复的错误对象所在的参考记录移至所述第二预设表;The third transfer unit is configured to, after moving the associated record to the third preset table, transfer the third preset table to the third preset table under the condition that the error object in the third preset table is successfully repaired. the reference record where the wrong object has been fixed is moved to said second preset table;

第一设置模块,用于将所述参考记录的当前重试次数设置为初始数值状态,将所述参考记录的下次执行时间设置为当前时间;A first setting module, configured to set the current number of retries of the reference record as an initial value state, and set the next execution time of the reference record as the current time;

触发模块,用于在实际时间达到所述当前时间的情况下,对所述参考记录执行调用,触发重试机制。A triggering module, configured to call the reference record to trigger a retry mechanism when the actual time reaches the current time.

可选地,该装置还包括:Optionally, the device also includes:

第二设置模块,用于设置所述目标任务对应的多个方法函数的优先级;The second setting module is used to set the priority of multiple method functions corresponding to the target task;

遍历模块,用于遍历当前获取的所述第一预设表内的所述关联记录;A traversal module, configured to traverse the currently acquired associated records in the first preset table;

执行模块,用于在确定存在第一方法函数的优先级大于第二预设阈值的情况下,将所述第一方法函数所在的所述关联记录放至所述第二预设表的队尾,并对所述第一方法函数的优先级执行减少第二预设数值操作;在确定存在第二方法函数的优先级等于所述第二预设阈值的情况下,对所述第二方法函数执行调用。An execution module, configured to put the associated record where the first method function is located at the tail of the second preset table when it is determined that the priority of the first method function is greater than a second preset threshold , and perform a second preset value reduction operation on the priority of the first method function; if it is determined that the priority of the second method function is equal to the second preset threshold, the second method function Execute the call.

可选地,该装置还包括:Optionally, the device also includes:

扫描模块,用于在所述遍历当前获取的所述第一预设表内的所述关联记录之后,利用所述目标线程陆续扫描所述第一预设表;A scanning module, configured to use the target thread to successively scan the first preset table after traversing the currently acquired associated records in the first preset table;

增加模块,用于在确定所述第一预设表内的所述关联记录被执行优先级比较操作的数量超过第三预设阈值的情况下,继续增加未执行优先级比较操作的所述关联记录。An adding module, configured to continue adding the associations for which priority comparison operations have not been performed when it is determined that the number of priority comparison operations performed on the association records in the first preset table exceeds a third preset threshold Record.

根据本申请实施例的又一个方面,还提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器、通信接口和存储器通过通信总线完成相互间的通信;其中,存储器,用于存储计算机程序;处理器,用于通过运行所述存储器上所存储的所述计算机程序来执行上述任一实施例中的方法步骤。According to yet another aspect of the embodiments of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein, the processor, the communication interface, and the memory complete mutual communication through the communication bus; wherein, The memory is used to store a computer program; the processor is used to execute the method steps in any one of the above embodiments by running the computer program stored in the memory.

根据本申请实施例的又一个方面,还提供了一种计算机可读的存储介质,该存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一实施例中的方法步骤。According to still another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is set to execute the method in any of the above-mentioned embodiments when running step.

在本申请实施例中,通过获取与待执行的目标任务相关的关联记录,其中,关联记录中包含目标任务对应的方法函数的当前重试次数、当前时间以及当前时间与下次执行时间之间的间隔时长;将关联记录存储至第一预设表,并运行目标任务;根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,其中,目标次数为基于间隔时长对方法函数调用了预设次数,并对当前重试次数增加预设次数后所得数值。由于本申请实施例提前设有第一预设表、第二预设表和第三预设表,首先把所有的关联记录保存在第一预设表进行留痕保存,然后根据待执行的目标任务相关的关联记录的调用运行结果和关联记录的重试次数将关联记录移送至第二预设表或第三预设表,这样重试不管成功还是失败,都做了保留,从而可以实现及时查询重试记录,准确定位问题,提高工作效率的目的,进而解决了相关技术中存在的重试未留痕,后续无法及时查询重试记录的问题。In this embodiment of the application, by obtaining the associated record related to the target task to be executed, wherein the associated record contains the current number of retries, the current time, and the time between the current time and the next execution time of the method function corresponding to the target task the interval time; store the associated record in the first preset table, and run the target task; move the associated record to the second preset table or the third preset table according to the running result and the target number of times obtained after the target thread scans the associated record. Set up a table, wherein the target number of times is the value obtained by calling the method function a preset number of times based on the interval duration and adding the preset number of times to the current retry times. Since the first preset table, the second preset table, and the third preset table are provided in advance in the embodiment of the present application, all associated records are first saved in the first preset table for trace preservation, and then according to the target to be executed The call operation result of the task-related association record and the number of retries of the association record are transferred to the second preset table or the third preset table, so that the retry is preserved regardless of whether it succeeds or fails, so that timely The purpose of querying retry records, accurately locating problems, and improving work efficiency solves the problem of retry leaving no traces in related technologies, and subsequent inability to query retry records in time.

附图说明Description of drawings

此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application.

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, In other words, other drawings can also be obtained from these drawings on the premise of not paying creative work.

图1是根据本申请实施例的一种可选的业务处理中记录重试的方法的流程示意图;FIG. 1 is a schematic flowchart of an optional method for recording retry in business processing according to an embodiment of the present application;

图2是根据本申请实施例的一种可选的基于重试次数完成记录移表的整体流程图;Fig. 2 is an optional overall flow chart of completing the record shift table based on the number of retries according to an embodiment of the present application;

图3是根据本申请实施例的一种可选的基于重试优先级完成记录移表的整体流程图;Fig. 3 is an optional overall flow chart of completing record shifting table based on retry priority according to an embodiment of the present application;

图4是根据本申请实施例的一种可选的业务处理中记录重试的装置的结构框图;FIG. 4 is a structural block diagram of an optional device for recording retries in business processing according to an embodiment of the present application;

图5是根据本申请实施例的一种可选的电子设备的结构框图。Fig. 5 is a structural block diagram of an optional electronic device according to an embodiment of the present application.

具体实施方式Detailed ways

为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiment of the application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiment of the application. Obviously, the described embodiment is only It is an embodiment of a part of the application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.

需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first" and "second" in the description and claims of the present application and the above drawings are used to distinguish similar objects, but not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a sequence of steps or elements is not necessarily limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.

目前有一些常用的重试工具,比如spring框架提供的@Retryable注解,这个注解可以标注在方法函数上,这样当方法函数抛出异常时,会按照设置的延迟策略在指定的时间后,进行若干次重试,例如:At present, there are some commonly used retry tools, 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 follow the set delay strategy after the specified time. retries, for example:

Figure BDA0003999284810000061
Figure BDA0003999284810000061

     

Figure BDA0003999284810000071
     
Figure BDA0003999284810000071

value=Exception.class:当方法抛出Exception类型的异常时,会触发重试。value=Exception.class: When the method throws an exception of type Exception, a retry will be triggered.

maxAttempts=3:重试3次。maxAttempts=3: retry 3 times.

backoff=@Backoff(delay=2000,multiplier=1.5):方法失败2秒后开始第一次重试,如果成功则重试结束;否则2*1.5=3秒后开始第二次重试,继续失败则3*1.5=4.5秒后开始第三次重试。backoff=@Backoff(delay=2000,multiplier=1.5): The first retry starts after 2 seconds after the method fails, and the retry ends if it succeeds; otherwise, the second retry starts after 2*1.5=3 seconds and continues to fail Then start the third retry after 3*1.5=4.5 seconds.

但这类工具不管最终方法执行成功还是失败,都无法再次查阅。However, such tools cannot be consulted again regardless of whether the final method execution succeeds or fails.

为了解决上述问题,本申请实施例提出一种业务处理中记录重试的方法,如图1所示,该方法可以应用于服务器侧,该方法包括:In order to solve the above problems, the embodiment of the present application proposes a method for record retry in business processing, as shown in Figure 1, the method can be applied to the server side, the method includes:

步骤S101,获取与待执行的目标任务相关的关联记录,其中,关联记录中包含目标任务对应的方法函数的当前重试次数、当前时间以及当前时间与下次执行时间之间的间隔时长;Step S101, obtaining an association record related to the target task to be executed, wherein the association record includes the current number of retries, the current time, and the interval between the current time and the next execution time of the method function corresponding to the target task;

步骤S102,将关联记录存储至第一预设表,并运行目标任务;Step S102, storing the associated record in the first preset table, and running the target task;

步骤S103,根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,其中,目标次数为基于间隔时长对方法函数调用了预设次数,并对当前重试次数增加预设次数后所得数值。Step S103, move the associated record to the second preset table or the third preset table according to the running result and the target number of times obtained after the target thread scans the associated record, wherein the target number of times is the preset number of calls to the method function based on the interval time. Set the number of times, and add the value obtained by adding the preset number of times to the current number of retries.

可选地,在本申请实施例中,仍然沿用在方法函数上加注解的方式:Optionally, in the embodiment of this application, the method of annotating the method function is still used:

Figure BDA0003999284810000072
Figure BDA0003999284810000072

Figure BDA0003999284810000081
Figure BDA0003999284810000081

intervalSecond="5,10,15,20,25,30":代表重试6次,第一次重试为5秒后,如果继续失败,则第二次重试是第一次重试失败后的10s,以此类推。intervalSecond="5,10,15,20,25,30": means to retry 6 times, the first retry is 5 seconds later, if the failure continues, the second retry is after the first retry fails 10s, and so on.

同时提前采用了三张预设表来完成重试:第一预设表:ready表、第二预设表:finish表和第三预设表:error表。At the same time, three preset tables are used in advance to complete the retry: the first preset table: ready table, the second preset table: finish table and the third preset table: error table.

当前首先获取到与待执行的目标任务相关的关联记录,在开始执行这些关联记录内的方法函数时,先把相关记录中与该方案函数对应的方法名、方法参数、当前重试次数(初始化为1)、下次执行时间(当前时间根据重试次数计算所得,例如当前时间是2011-11-01 08:00:12,重试次数是1,则下次执行时间就是2011-11-01 08:00:17)保存到ready表,之后开始运行目标任务,执行方法函数。At present, the associated records related to the target tasks to be executed are obtained first. When the method functions in these associated records are started to be executed, the method names, method parameters, and current retry times (initialization) corresponding to the program functions in the related records are first 1), the next execution time (the current time is calculated based on the number of retries, for example, the current time is 2011-11-01 08:00:12, and the number of retries is 1, then the next execution time is 2011-11-01 08:00:17) Save it to the ready table, and then start running the target task and executing the method function.

之后根据对方法函数的执行结果(其也是目标任务的运行结果)和后台的目标线程不断扫描ready表内的关联记录后得到的该方法函数一共被重试调用的总次数,将该关联记录移至finish表或error表。Afterwards, according to the execution result of the method function (which is also the running result of the target task) and the total number of times the method function is retried and called after the target thread in the background continuously scans the associated records in the ready table, move the associated record to to the finish table or error table.

需要说明的是,将关联记录移至finish表或error表是需要与运行结果和对方法函数的调用重试次数挂钩的,比如在执行方法函数成功的情况下,将关联记录移至finish表,如果不成功,则根据目标线程扫描到ready表内的关联记录后,基于间隔时长对该方法函数调用了预设次数,并对关联记录内记载的当前重试次数增加预设次数后所得目标次数的数值,去决定是否将关联记录移至error表的。It should be noted that moving the associated record to the finish table or error table needs to be linked to the running result and the number of retries to call the method function. For example, when the method function is successfully executed, the associated record is moved to the finish table. If it is unsuccessful, after the target thread scans the associated record in the ready table, the method function is called the preset number of times based on the interval time, and the current retry count recorded in the associated record is increased by the preset number to obtain the target number of times value to decide whether to move the associated record to the error table.

另外,目标线程可以是一个也可以是多个,当目标线程是一个的情况下,每当再次尝试调用该方法函数时,都是由目标线程陆续指向ready表进行扫描;若目标线程是多个的情况下,每个线程只负责扫描与其对应的特定重试次数的记录,也即是,在再次尝试调用该方法函数时,使用新线程指向ready表进行扫描。In addition, there can be one or more target threads. When there is one target thread, each time the method function is called again, the target thread will point to the ready list for scanning; if there are multiple target threads In the case of , each thread is only responsible for scanning the records corresponding to the specific number of retries, that is, when trying to call the method function again, use a new thread to point to the ready table for scanning.

在本申请实施例中,通过获取与待执行的目标任务相关的关联记录,其中,关联记录中包含目标任务对应的方法函数的当前重试次数、当前时间以及当前时间与下次执行时间之间的间隔时长;将关联记录存储至第一预设表,并运行目标任务;根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,其中,目标次数为基于间隔时长对方法函数调用了预设次数,并对当前重试次数增加预设次数后所得数值。由于本申请实施例提前设有第一预设表、第二预设表和第三预设表,首先把所有的关联记录保存在第一预设表进行留痕保存,然后根据待执行的目标任务相关的关联记录的调用运行结果和关联记录的重试次数将关联记录移送至第二预设表或第三预设表,这样重试不管成功还是失败,都做了保留,从而可以实现及时查询重试记录,准确定位问题,提高工作效率的目的,进而解决了相关技术中存在的重试未留痕,后续无法及时查询重试记录的问题。In this embodiment of the application, by obtaining the associated record related to the target task to be executed, wherein the associated record contains the current number of retries, the current time, and the time between the current time and the next execution time of the method function corresponding to the target task the interval time; store the associated record in the first preset table, and run the target task; move the associated record to the second preset table or the third preset table according to the running result and the target number of times obtained after the target thread scans the associated record. Set up a table, wherein the target number of times is the value obtained by calling the method function a preset number of times based on the interval duration and adding the preset number of times to the current retry times. Since the first preset table, the second preset table, and the third preset table are provided in advance in the embodiment of the present application, all associated records are first saved in the first preset table for trace preservation, and then according to the target to be executed The call operation result of the task-related association record and the number of retries of the association record are transferred to the second preset table or the third preset table, so that the retry is preserved regardless of whether it succeeds or fails, so that timely The purpose of querying retry records, accurately locating problems, and improving work efficiency solves the problem of retry leaving no traces in related technologies, and subsequent inability to query retry records in time.

基于上述各实施例的内容,作为一种可选实施例,根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,包括:Based on the contents of the above-mentioned embodiments, as an optional embodiment, according to the running result and the target number of times obtained after the target thread scans the associated record, the associated record is moved to the second preset table or the third preset table, including :

在运行结果为成功的情况下,将关联记录移至第二预设表;If the operation result is successful, move the associated record to the second preset table;

在运行结果为失败的情况下,利用目标线程陆续扫描第一预设表,获取满足预设条件的目标记录,对目标记录执行调用,并调整目标记录的当前重试次数的数值;In the case that the operation result is a failure, the target thread is used to scan the first preset table one after another to obtain the target record satisfying the preset condition, execute a call to the target record, and adjust the value of the current number of retries of the target record;

在确定调整后的目标记录的当前重试次数的数值大于第一预设阈值的情况下,将目标记录移至第三预设表,其中,关联记录内包含目标记录。If it is determined that the adjusted value of the current number of retries of the target record is greater than the first preset threshold, the target record is moved to a third preset table, wherein the associated record contains the target record.

可选地,在本申请实施例中,在运行结果为成功的情况下,将关联记录移至finish表;在运行结果为失败的情况下,有一个后台目标线程不断扫描ready表,从ready表中获取满足预设条件的目标记录,比如获取关联记录中下次执行时间小于或者等于目标线程的当前时间的记录,然后对目标记录内的方法函数再次尝试调用时,需要同时把目标记录的当前重试次数的数值增加第一预设数值,比如增加1,得到增加第一预设数值后的中间重试次数,并根据中间重试次数的当前时间和间隔时长计算中间重试次数对应的目标记录的下次执行时间。Optionally, in the embodiment of the present application, when the operation result is successful, the associated record is moved to the finish table; when the operation result is failure, there is a background target thread that constantly scans the ready table, from the ready table Get the target records that meet the preset conditions, such as getting the records in the associated records whose next execution time is less than or equal to the current time of the target thread, and then try to call the method function in the target record again, you need to add the current time of the target record at the same time Increase the value of the number of retries by increasing the first preset value, such as by 1, to obtain the intermediate number of retries after increasing the first preset value, and calculate the target corresponding to the number of intermediate retries based on the current time and interval of the number of intermediate retries The next execution time of the record.

在当前时间达到中间重试次数对应的目标记录的下次执行时间时,对目标记录执行调用,这样只要方法没有正常结束,ready表内的该条记录就不会被挪走,会被不断重试,同时增加重试次数,直到重试次数在不断加1后,得到的数值(即总的重试次数)大于第一预设阈值,比如大于6次后,会将目标记录从ready表挪到error表。这样完成了重试留痕。When the current time reaches the next execution time of the target record corresponding to the number of retries in the middle, execute the call to the target record, so that as long as the method does not end normally, the record in the ready table will not be removed and will be continuously replayed At the same time, increase the number of retries until the number of retries is continuously increased by 1, and the obtained value (that is, the total number of retries) is greater than the first preset threshold, for example, after more than 6 times, the target record will be moved from the ready table to the error table. This completes the retry trace.

在本申请实施例中,不管重试是成功还是失败,都有对应的表格进行存储相关记录,方便后续查询和问题的定位。In this embodiment of the application, no matter whether the retry is successful or failed, there is a corresponding table to store related records, which is convenient for subsequent query and problem location.

作为一种可选实施例,如图2所示,图2是根据本申请实施例的一种可选的基于重试次数完成记录移表的整体流程图,具体地:As an optional embodiment, as shown in FIG. 2, FIG. 2 is an optional overall flow chart of completing the record shift table based on the number of retries according to the embodiment of the present application, specifically:

扫描ready表,拿到下次执行时间小于等于当前时间的一批记录;Scan the ready table to get a batch of records whose next execution time is less than or equal to the current time;

判断是否存在这样的记录;determine whether such a record exists;

若存在,则遍历这批ready记录;若不存在,则后续继续扫描;If it exists, traverse the batch of ready records; if it does not exist, continue scanning;

判断是否遍历到最后一条记录;Determine whether to traverse to the last record;

若确定当前是最后一条记录后,则执行扫描ready表,拿到下次执行时间小于等于当前时间的一批记录的操作;If it is determined that the current record is the last record, scan the ready table to obtain a batch of records whose next execution time is less than or equal to the current time;

在确定当前不是最后一条记录后,判断重试次数是否小于等于6次;After determining that the current is not the last record, determine whether the number of retries is less than or equal to 6 times;

若大于6次,则把记录从ready表挪到error表,再循环处理多条ready表内的记录;若确定小于等于6次,则更新ready记录的执行次数和下次执行时间;If it is greater than 6 times, move the record from the ready table to the error table, and recycle multiple records in the ready table; if it is determined to be less than or equal to 6 times, update the execution times and next execution time of the ready record;

根据记录的方法名和方法参数、尝试调用方法;According to the recorded method name and method parameters, try to call the method;

若执行异常,则处理下条ready数据;若执行成功,将ready记录转移至finish表,再循环处理下条ready数据。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 recycled.

基于上述各实施例的内容,作为一种可选实施例,在将关联记录移至第三预设表之后,方法还包括:Based on the contents of the above embodiments, as an optional embodiment, after moving the associated record to the third preset table, the method further includes:

在获取将第三预设表内的错误对象修复成功的情况下,将第三预设表内已修复的错误对象所在的参考记录移至第二预设表;In the case that the error object in the third preset table is successfully repaired, the reference record where the repaired error object in the third preset table is located is moved to the second preset table;

将参考记录的当前重试次数设置为初始数值状态,将参考记录的下次执行时间设置为当前时间;Set the current number of retries of the reference record to the initial value state, and set the next execution time of the reference record to the current time;

在实际时间达到当前时间的情况下,对参考记录执行调用,触发重试机制。In case the actual time reaches the current time, a call is made to the reference record, triggering the retry mechanism.

可选地,通常方法执行异常,很大可能是代码错误造成,单纯的重试无法解决问题,还需要开发人员修改代码重新上线,但传统解决方案重试结束后,就算代码修复了也没办法再次重试了。在本申请实施例中,把重试信息持久化,如果最终重试失败,在error表里是有记录的,当开发人员将error表内的错误对象(比如代码等)修复成功后,可以手动把已修复数据从error表挪到ready表,同时设置重试次数为初始数值状态,比如1,下次执行时间设置为当前时间,这样当实际时间达到当前执行时间时,就可以自动触发重试机制进行重新调用。Optionally, usually the abnormal execution of the method is likely to be caused by a code error. Simply retrying cannot solve the problem, and developers need to modify the code and go online again. However, after the retry of the traditional solution, even if the code is repaired, there is no way Tried again. In the embodiment of this application, the retry information is persisted. If the final retry fails, it is recorded in the error table. After the developer successfully repairs the error object (such as code, etc.) in the error table, he can manually Move the repaired data from the error table to the ready table, and set the number of retries to the initial value state, such as 1, and set the next execution time to the current time, so that when the actual time reaches the current execution time, a retry can be automatically triggered The mechanism is recalled.

在本申请实施例中,如果最终重试失败,当代码修复后,仍然可以再次触发重试动作,解决现有技术中代码错误后不能再投入使用的问题。In this embodiment of the application, if the final retry fails, after the code is repaired, the retry action can still be triggered again, which solves the problem in the prior art that the code cannot be put into use after an error.

基于上述各实施例的内容,作为一种可选实施例,该方法还包括:Based on the contents of the foregoing embodiments, as an optional embodiment, the method further includes:

设置目标任务对应的多个方法函数的优先级;Set the priority of multiple method functions corresponding to the target task;

遍历当前获取的第一预设表内的关联记录;traversing the associated records in the currently acquired first preset table;

在确定存在第一方法函数的优先级大于第二预设阈值的情况下,将第一方法函数所在的关联记录放至第二预设表的队尾,并对第一方法函数的优先级执行减少第二预设数值操作;在确定存在第二方法函数的优先级等于第二预设阈值的情况下,对第二方法函数执行调用。When it is determined that the priority of the first method function is greater than the second preset threshold, the associated record where the first method function is located is placed at the end of the queue of the second preset table, and the priority of the first method function is executed Decrease a second preset value operation; when it is determined that the priority of the second method function is equal to the second preset threshold, call the second method function.

可选地,在本申请实施例中,在@Retry注解上增加一个表示重试优先级的参数,这时需要提前设置好目标任务对应的多个方法函数的优先级,在这里,可以设置为值越高代表的优先级越低。Optionally, in the embodiment of this application, a parameter indicating the retry priority is added to the @Retry annotation. At this time, the priority of multiple method functions corresponding to the target task needs to be set in advance. Here, it can be set as Higher values represent lower priority.

每次查询出一批ready记录后,一条条遍历,如果发现存在一方法函数的重试优先级大于第二预设阈值,比如第一方法函数的优先级大于1,则把该条ready记录的重试优先级减少第二预设数值,比如第一方法函数的优先级减1,同时将第一方法函数所在的关联记录放回到这批ready记录的队列末尾;如果重试优先级等于1,则执行当前方法函数。After querying a batch of ready records each time, traverse them one by one. If it is found that there is a method function whose retry priority is greater than the second preset threshold, for example, the priority of the first method function is greater than 1, then the ready record will be The retry priority is reduced by the second preset value, for example, the priority of the first method function is reduced by 1, and at the same time, the associated record where the first method function is located is put back to the end of the queue of this batch of ready records; if the retry priority is equal to 1 , the current method function is executed.

在本申请实施例中,增加了重试优先级,这样当有大量重试任务时,可以先执行优先级高的任务,防止高优先级任务被低优先级任务阻塞。In the embodiment of this application, the retry priority is added, so that when there are a large number of retry tasks, the tasks with higher priority can be executed first to prevent high priority tasks from being blocked by low priority tasks.

基于上述各实施例的内容,作为一种可选实施例,在遍历当前获取的第一预设表内的关联记录之后,方法还包括:Based on the contents of the above-mentioned embodiments, as an optional embodiment, after traversing the associated records in the currently obtained first preset table, the method further includes:

利用目标线程陆续扫描第一预设表;Using the target thread to scan the first preset table successively;

在确定第一预设表内的关联记录被执行优先级比较操作的数量超过第三预设阈值的情况下,继续增加未执行优先级比较操作的关联记录。If it is determined that the number of associated records in the first preset table for which priority comparison operations have been performed exceeds a third preset threshold, continue to add associated records for which priority comparison operations have not been performed.

可选地,在本申请实施例中,为了保证第一预设表内的所有关联记录都实现了重试优先级越高越先执行的操作,本申请实施例会有一个后台目标线程陆续扫描第一预设表,发现这批ready记录中被执行优先级比较操作的数量超过第三预设阈值,比如超过一半的数量后,马上再补充一批未执行优先级比较操作的ready记录,这样就实现了重试优先级越高越先执行。Optionally, in this embodiment of the application, in order to ensure that all associated records in the first preset table implement the operation that the higher the retry priority, the earlier the execution, the embodiment of the application will have a background target thread to successively scan the first A preset table, if it is found that the number of priority comparison operations performed in this batch of ready records exceeds the third preset threshold, for example, after more than half of the number, immediately add a batch of ready records that have not performed priority comparison operations, so that The higher the retry priority, the earlier it will be executed.

在本申请实施例中,通过重试优先级的设置,给了高优先级方法更多的重试机会,解决现有技术中存在大量耗时又不重要的方法需要重试时,导致后面的重要方法迟迟得不到重试的问题。In the embodiment of this application, through the setting of retry priority, more retry opportunities are given to high priority methods, which solves the problem that when a large number of time-consuming and unimportant methods in the prior art need to be retried, resulting in subsequent The important method is not getting retried for a long time.

作为一种可选实施例,如图3所示,图3是根据本申请实施例的一种可选的基于重试优先级完成记录移表的整体流程图,具体地:As an optional embodiment, as shown in FIG. 3, FIG. 3 is an optional overall flow chart of completing the record shift table based on the retry priority according to the embodiment of the present application, specifically:

读取1000条ready记录放入队列;Read 1000 ready records and put them into the queue;

从队列读取一个任务;read a task from the queue;

判断重试优先级是否大于1;Determine whether the retry priority is greater than 1;

若大于1,则将其重试优先级减1,将该条ready记录移到队尾,再循环执行队列读取任务操作;If it is greater than 1, reduce its retry priority by 1, move the ready record to the end of the queue, and then execute the queue read task operation in a loop;

若不大于1,则判断队列是否消费了500条记录;If it is not greater than 1, then judge whether the queue has consumed 500 records;

若是,则唤醒填充线程;若否,则判断重试次数是否小于或者等于6次;If so, wake up the filling thread; if not, then determine whether the number of retries is less than or equal to 6 times;

若小于等于6次,则更新ready记录的执行次数和下次执行时间,执行异常则处理下条ready记录,否则根据记录的方法名和方法参数,尝试调用方法,若依旧执行成功,则将该条ready记录转移到finish表。If it is less than or equal to 6 times, update the number of executions and the next execution time of the ready record, and process the next ready record if the execution is abnormal. Otherwise, try to call the method according to the recorded method name and method parameters. If the execution is still successful, the entry The ready records are transferred to the finish table.

其中,唤醒填充线程后,确定队列消费了500条记录,则读取500条ready记录放入队列;若确定队列未消费了500条记录,设置等待时长(比如等待500s),在到达等待时长后,循环判断队列是否消费了500条记录。Among them, after waking up the filling thread, it is determined that the queue has consumed 500 records, then read 500 ready records and put them into the queue; if it is determined that the queue has not consumed 500 records, set the waiting time (such as waiting for 500s), after reaching the waiting time , loop to determine whether the queue has consumed 500 records.

需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。It should be noted that for the foregoing method embodiments, for the sake of simple description, they are expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described action sequence. Depending on the application, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions and modules involved are not necessarily required by this application.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM(Read-Only Memory,只读存储器)/RAM(Random Access Memory,随机存取存储器)、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例的方法。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 implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is Better implementation. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product in essence or in other words, the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM (Read-Only Memory, Read-only memory)/RAM (Random Access Memory, random access memory), magnetic disk, optical disk), including several instructions to make a terminal device (which can be a mobile phone, computer, server, or network device, etc.) execute this Applies the method of each embodiment.

根据本申请实施例的另一个方面,还提供了一种用于实施上述业务处理中记录重试的方法的业务处理中记录重试的装置。图4是根据本申请实施例的一种可选的业务处理中记录重试的装置的结构框图,如图4所示,该装置可以包括:According to another aspect of the embodiments of the present application, there is also provided an apparatus for recording retry in business processing for implementing the above method for recording retry in business processing. Fig. 4 is a structural block diagram of an optional device for recording retry in business processing according to an embodiment of the present application. As shown in Fig. 4, the device may include:

第一获取模块401,用于获取与待执行的目标任务相关的关联记录,其中,关联记录中包含目标任务对应的方法函数的当前重试次数、当前时间以及当前时间与下次执行时间之间的间隔时长;The first acquisition module 401 is configured to acquire an associated record related to the target task to be executed, wherein the associated record includes the current number of retries of the method function corresponding to the target task, the current time, and the time between the current time and the next execution time the interval of time;

存储模块402,用于将关联记录存储至第一预设表,并运行目标任务;A storage module 402, configured to store the associated records in the first preset table, and run the target task;

移送模块403,用于根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,其中,目标次数为基于间隔时长对方法函数调用了预设次数,并对当前重试次数增加预设次数后所得数值。The transfer module 403 is used to move the associated record to the second preset table or the third preset table according to the running result and the target number of times obtained after the target thread scans the associated record, wherein the target number of times is based on the interval time length pair method function The preset number of times has been invoked, and the value obtained by adding the preset number of times to the current number of retries.

需要说明的是,该实施例中的第一获取模块401可以用于执行上述步骤S101,该实施例中的存储模块402可以用于执行上述步骤S102,该实施例中的移送模块403可以用于执行上述步骤S103。It should be noted that the first acquisition module 401 in this embodiment can be used to perform the above step S101, the storage module 402 in this embodiment can be used to perform the above step S102, and the transfer module 403 in this embodiment can be used for Execute the above step S103.

通过上述模块,提前设有第一预设表、第二预设表和第三预设表,首先把所有的关联记录保存在第一预设表进行留痕保存,然后根据待执行的目标任务相关的关联记录的调用运行结果和关联记录的重试次数将关联记录移送至第二预设表或第三预设表,这样重试不管成功还是失败,都做了保留,从而可以实现及时查询重试记录,准确定位问题,提高工作效率的目的,进而解决了相关技术中存在的重试未留痕,后续无法及时查询重试记录的问题。Through the above modules, the first preset table, the second preset table and the third preset table are set in advance, and all related records are first saved in the first preset table for trace preservation, and then according to the target task to be executed The call operation results of the related associated records and the number of retries of the associated records are transferred to the second preset table or the third preset table, so that the retries are preserved regardless of success or failure, so that timely query can be realized The purpose of retrying records, accurately locating problems, and improving work efficiency, and then solving the problem of retrying without leaving traces in related technologies, and subsequent inability to query retrying records in time.

作为一种可选的实施例,移送模块包括:As an optional embodiment, the transfer module includes:

第一移送单元,用于在运行结果为成功的情况下,将关联记录移至第二预设表;The first transfer unit is used to move the associated record to the second preset table when the operation result is successful;

调整单元,用于在运行结果为失败的情况下,利用目标线程陆续扫描第一预设表,获取满足预设条件的目标记录,对目标记录执行调用,并调整目标记录的当前重试次数的数值;The adjustment unit is configured to use the target thread to scan the first preset table one after another when the operation result is a failure, obtain target records satisfying the preset conditions, perform calls on the target records, and adjust the current retry times of the target records value;

第二移送单元,用于在确定调整后的目标记录的当前重试次数的数值大于第一预设阈值的情况下,将目标记录移至第三预设表,其中,关联记录内包含目标记录。The second transfer unit is configured to move the target record to a third preset table when it is determined that the value of the current number of retries of the adjusted target record is greater than the first preset threshold, wherein the associated record contains the target record .

作为一种可选的实施例,调整单元包括:As an optional embodiment, the adjustment unit includes:

第一获取子模块,用于获取到关联记录中下次执行时间小于或者等于目标线程的当前时间的目标记录;The first obtaining submodule is used to obtain the target record whose next execution time is less than or equal to the current time of the target thread in the associated record;

增加子模块,用于对目标记录执行调用,并把目标记录的当前重试次数增加第一预设数值,得到增加第一预设数值后的中间重试次数。A sub-module is added for calling the target record, and increasing the current number of retries of the target record by a first preset value to obtain an intermediate number of retries after the first preset value is increased.

作为一种可选的实施例,第二移送单元包括:As an optional embodiment, the second transfer unit includes:

第二获取子模块,用于获取中间重试次数的当前时间;The second acquisition sub-module is used to acquire the current time of the number of intermediate retries;

计算子模块,用于根据中间重试次数的当前时间和间隔时长计算中间重试次数对应的目标记录的下次执行时间;The calculation sub-module is used to calculate the next execution time of the target record corresponding to the intermediate retry times according to the current time and the interval length of the intermediate retry times;

移送子模块,用于在当前时间达到中间重试次数对应的目标记录的下次执行时间时,对中间重试次数对应的目标记录执行调用,直到多个预设数值之和为目标次数,且目标次数大于第一预设阈值时,则将目标记录移至第三预设表。The transfer sub-module is used to call the target record corresponding to the intermediate retry count when the current time reaches the next execution time of the target record corresponding to the intermediate retry count until the sum of multiple preset values is the target count, and When the target count is greater than the first preset threshold, the target record is moved to the third preset table.

作为一种可选的实施例,该装置还包括:As an optional embodiment, the device also includes:

第三移送单元,用于在将关联记录移至第三预设表之后,在获取将第三预设表内的错误对象修复成功的情况下,将第三预设表内已修复的错误对象所在的参考记录移至第二预设表;The third transfer unit is configured to transfer the repaired error object in the third preset table under the condition that the error object in the third preset table is successfully repaired after the associated record is moved to the third preset table. where the reference record is moved to the second default table;

第一设置模块,用于将参考记录的当前重试次数设置为初始数值状态,将参考记录的下次执行时间设置为当前时间;The first setting module is used to set the current number of retries of the reference record as the initial numerical state, and set the next execution time of the reference record as the current time;

触发模块,用于在实际时间达到当前时间的情况下,对参考记录执行调用,触发重试机制。The trigger module is used for calling the reference record and triggering the retry mechanism when the actual time reaches the current time.

作为一种可选的实施例,该装置还包括:As an optional embodiment, the device also includes:

第二设置模块,用于设置目标任务对应的多个方法函数的优先级;The second setting module is used to set the priority of multiple method functions corresponding to the target task;

遍历模块,用于遍历当前获取的第一预设表内的关联记录;A traversal module, configured to traverse the associated records in the currently acquired first preset table;

执行模块,用于在确定存在第一方法函数的优先级大于第二预设阈值的情况下,将第一方法函数所在的关联记录放至第二预设表的队尾,并对第一方法函数的优先级执行减少第二预设数值操作;在确定存在第二方法函数的优先级等于第二预设阈值的情况下,对第二方法函数执行调用。The execution module is used to put the associated record where the first method function is located at the end of the second preset table when it is determined that the priority of the first method function is greater than the second preset threshold, and execute the first method function The priority of the function is reduced by a second preset value; when it is determined that the priority of the function of the second method is equal to the second preset threshold, the function of the second method is called.

作为一种可选的实施例,该装置还包括:As an optional embodiment, the device also includes:

扫描模块,用于在遍历当前获取的第一预设表内的关联记录之后,利用目标线程陆续扫描第一预设表;A scanning module, configured to use the target thread to successively scan the first preset table after traversing the associated records in the currently acquired first preset table;

增加模块,用于在确定第一预设表内的关联记录被执行优先级比较操作的数量超过第三预设阈值的情况下,继续增加未执行优先级比较操作的关联记录。An adding module, configured to continue adding associated records for which priority comparison operations have not been performed when it is determined that the number of associated records in the first preset table for which priority comparison operations have been performed exceeds a third preset threshold.

根据本申请实施例的又一个方面,还提供了一种用于实施上述业务处理中记录重试的方法的电子设备,该电子设备可以是服务器、终端、或者其组合。According to still another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the above method for recording retry in business processing, and the electronic device may be a server, a terminal, or a combination thereof.

图5是根据本申请实施例的一种可选的电子设备的结构框图,如图5所示,包括处理器501、通信接口502、存储器503和通信总线504,其中,处理器501、通信接口502和存储器503通过通信总线504完成相互间的通信,其中,Fig. 5 is a structural block diagram of an optional electronic device according to the embodiment of the present application, as shown in Fig. 502 and memory 503 complete mutual communication through communication bus 504, wherein,

存储器503,用于存储计算机程序;memory 503, for storing computer programs;

处理器501,用于执行存储器503上所存放的计算机程序时,实现如下步骤:When the processor 501 is used to execute the computer program stored on the memory 503, the following steps are implemented:

获取与待执行的目标任务相关的关联记录,其中,关联记录中包含目标任务对应的方法函数的当前重试次数、当前时间以及当前时间与下次执行时间之间的间隔时长;Obtain an associated record related to the target task to be executed, wherein the associated record includes the current number of retries, the current time, and the interval between the current time and the next execution time of the method function corresponding to the target task;

将关联记录存储至第一预设表,并运行目标任务;storing the associated records in the first preset table, and running the target task;

根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,其中,目标次数为基于间隔时长对方法函数调用了预设次数,并对当前重试次数增加预设次数后所得数值。According to the running result and the target number of times obtained after the target thread scans the associated record, move the associated record to the second preset table or the third preset table, wherein the target number of times is the preset number of times the method function is called based on the interval length, And the value obtained by adding the preset number of times to the current number of retries.

可选地,在本实施例中,上述的通信总线可以是PCI(Peripheral ComponentInterconnect,外设部件互连标准)总线、或EISA(Extended Industry StandardArchitecture,扩展工业标准结构)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。Optionally, in this embodiment, the aforementioned communication bus may be a PCI (Peripheral Component Interconnect, Peripheral Component Interconnect Standard) bus, or an EISA (Extended Industry Standard Architecture, Extended Industry Standard Architecture) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 5 , but it does not mean that there is only one bus or one type of bus.

通信接口用于上述电子设备与其他设备之间的通信。The communication interface is used for communication between the electronic device and other devices.

存储器可以包括RAM,也可以包括非易失性存储器(non-volatile memory),例如,至少一个磁盘存储器。可选地,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include RAM, and may also include non-volatile memory (non-volatile memory), for example, at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

作为一种示例,如图5所示,上述存储器503中可以但不限于包括上述业务处理中记录重试的装置中的第一获取模块401、存储模块402、移送模块403。此外,还可以包括但不限于上述业务处理中记录重试的装置中的其他模块单元,本示例中不再赘述。As an example, as shown in FIG. 5 , the memory 503 may include, but is not limited to, the first acquisition module 401 , the storage module 402 , and the transfer module 403 in the apparatus for recording retry in business processing. In addition, it may also include but not limited to other module units in the above-mentioned apparatus for recording retries in business processing, which will not be described in detail in this example.

上述处理器可以是通用处理器,可以包含但不限于:CPU(Central ProcessingUnit,中央处理器)、NP(Network Processor,网络处理器)等;还可以是DSP(DigitalSignal Processing,数字信号处理器)、ASIC(Application Specific IntegratedCircuit,专用集成电路)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。Above-mentioned processor can be general-purpose processor, can include but not limited to: CPU (Central Processing Unit, central processing unit), NP (Network Processor, network processor) etc.; Can also be DSP (DigitalSignal Processing, digital signal processor), ASIC (Application Specific Integrated Circuit, application specific integrated circuit), FPGA (Field-Programmable Gate Array, field programmable gate array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

此外,上述电子设备还包括:显示器,用于显示业务处理中记录重试的结果。In addition, the above-mentioned electronic device further includes: a display, used for displaying the result of retrying records in business processing.

可选地,本实施例中的具体示例可以参考上述实施例中所描述的示例,本实施例在此不再赘述。Optionally, for specific examples in this embodiment, reference may be made to the examples described in the foregoing embodiments, and details are not repeated in this embodiment.

本领域普通技术人员可以理解,图5所示的结构仅为示意,实施上述业务处理中记录重试的方法的设备可以是终端设备,该终端设备可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌上电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。图5其并不对上述电子设备的结构造成限定。例如,终端设备还可包括比图5中所示更多或者更少的组件(如网络接口、显示装置等),或者具有与图5所示的不同的配置。Those of ordinary skill in the art can understand that the structure shown in Figure 5 is only for illustration, and the device that implements the method for recording retry in the above-mentioned business processing can be a terminal device, and the terminal device can be a smart phone (such as an Android phone, an iOS phone, etc. ), Tablet PCs, PDAs, and mobile Internet devices (Mobile Internet Devices, MID), PAD and other terminal equipment. FIG. 5 does not limit the structure of the above-mentioned electronic equipment. For example, the terminal device may also include more or less components than those shown in FIG. 5 (such as a network interface, a display device, etc.), or have a different configuration from that shown in FIG. 5 .

本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、ROM、RAM、磁盘或光盘等。Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium can be Including: flash disk, ROM, RAM, magnetic disk or optical disk, etc.

根据本申请实施例的又一个方面,还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以用于执行业务处理中记录重试的方法的程序代码。According to still another aspect of the embodiments of the present application, a storage medium is also provided. Optionally, in this embodiment, the above-mentioned storage medium may be used to execute the program code of the method for recording retry in business processing.

可选地,在本实施例中,上述存储介质可以位于上述实施例所示的网络中的多个网络设备中的至少一个网络设备上。Optionally, in this embodiment, the foregoing storage medium may be located on at least one network device among the plurality of network devices in the network shown in the foregoing embodiments.

可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:Optionally, in this embodiment, the storage medium is configured to store program codes for performing the following steps:

获取与待执行的目标任务相关的关联记录,其中,关联记录中包含目标任务对应的方法函数的当前重试次数、当前时间以及当前时间与下次执行时间之间的间隔时长;Obtain an associated record related to the target task to be executed, wherein the associated record includes the current number of retries, the current time, and the interval between the current time and the next execution time of the method function corresponding to the target task;

将关联记录存储至第一预设表,并运行目标任务;storing the associated records in the first preset table, and running the target task;

根据运行结果和目标线程扫描到关联记录后获取的目标次数,将关联记录移至第二预设表或第三预设表,其中,目标次数为基于间隔时长对方法函数调用了预设次数,并对当前重试次数增加预设次数后所得数值。According to the running result and the target number of times obtained after the target thread scans the associated record, move the associated record to the second preset table or the third preset table, wherein the target number of times is the preset number of times the method function is called based on the interval length, And the value obtained by adding the preset number of times to the current number of retries.

可选地,本实施例中的具体示例可以参考上述实施例中所描述的示例,本实施例中对此不再赘述。Optionally, for specific examples in this embodiment, reference may be made to the examples described in the foregoing embodiments, which will not be repeated in this embodiment.

可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、ROM、RAM、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。Optionally, in this embodiment, the above-mentioned storage medium may include, but not limited to, various media capable of storing program codes such as USB flash drive, ROM, RAM, removable hard disk, magnetic disk, or optical disk.

根据本申请实施例的又一个方面,还提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中;计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述任一个实施例中的业务处理中记录重试的方法步骤。According to yet another aspect of the embodiments of the present application, a computer program product or computer program is also provided, the computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; the processor of the computer device The computer instruction is read from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method steps of recording retry in business processing in any one of the above embodiments.

上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.

上述实施例中的集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在上述计算机可读取的存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在存储介质中,包括若干指令用以使得一台或多台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例业务处理中记录重试的方法的全部或部分步骤。If the integrated units in the above embodiments are realized in the form of software function units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium. Several instructions are included to enable one or more computer devices (which may be personal computers, servers or network devices, etc.) to execute all or part of the steps of the method for recording retry in business processing in various embodiments of the present application.

在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present application, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.

在本申请所提供的几个实施例中,应该理解到,所揭露的客户端,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Wherein, the device embodiments described above are only illustrative, such as the division of units, which is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components can be combined or integrated into Another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of units or modules may be in electrical or other forms.

作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例中所提供的方案的目的。A unit described as a separate component may or may not be physically separated, and a component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution provided in this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

以上所述仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above description is only the preferred embodiment of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present application, some improvements and modifications can also be made. These improvements and modifications are also It should be regarded as the protection scope of this application.

Claims (10)

1. A method for logging retries in a transaction, the method comprising:
acquiring an association record related to a target task to be executed, wherein the association record comprises the current retry times and the current time of a method function corresponding to the target task and the interval duration between the current time and the next execution time;
storing the association record to a first preset table, and operating the target task;
and moving the association record to a second preset table or a third preset table according to the operation result and the target frequency acquired after the association record is scanned by the target thread, wherein the target frequency is a value obtained after the preset frequency is added to the current retry frequency by calling the method function based on the interval duration.
2. The method of claim 1, wherein moving the association record to a second preset table or a third preset table according to the running result and the target times obtained after the target thread scans the association record comprises:
under the condition that the operation result is successful, the association record is moved to the second preset table;
under the condition that the operation result is failure, the target thread is utilized to successively scan the first preset table, a target record meeting preset conditions is obtained, the target record is called, and the value of the current retry number of the target record is adjusted;
and under the condition that the adjusted numerical value of the current retry times of the target record is larger than a first preset threshold value, moving the target record to the third preset table, wherein the associated record comprises the target record.
3. The method of claim 2, wherein the obtaining a target record satisfying a predetermined condition, performing a call to the target record, and adjusting the value of the current retry number of the target record comprises:
acquiring the target record of which the next execution time is less than or equal to the current time of the target thread in the associated records;
and executing calling on the target record, and increasing the current retry number of the target record by a first preset value to obtain the intermediate retry number after the first preset value is increased.
4. The method of claim 3, wherein the moving the target record to the third predetermined table in the case that it is determined that the value of the adjusted current retry number of the target record is greater than the first predetermined threshold value comprises:
obtaining the current time of the intermediate retry times;
calculating the next execution time of the target record corresponding to the intermediate retry times according to the current time of the intermediate retry times and the interval duration;
and when the current time reaches the next execution time of the target record corresponding to the intermediate retry times, executing calling on the target record corresponding to the intermediate retry times until the sum of the preset values is the target times and the target times are greater than the first preset threshold value, and moving the target record to the third preset table.
5. The method of claim 1, wherein after moving the association record to a third predetermined table, the method further comprises:
under the condition that the error objects in the third preset table are successfully repaired, moving the reference record where the repaired error objects in the third preset table are located to the second preset table;
setting the current retry times of the reference records as an initial numerical value state, and setting the next execution time of the reference records as the current time;
and under the condition that the actual time reaches the current time, calling the reference record to trigger a retry mechanism.
6. The method of any of claims 1 to 5, further comprising:
setting the priorities of a plurality of method functions corresponding to the target task;
traversing the currently acquired association record in the first preset table;
under the condition that the priority of a first method function is determined to be larger than a second preset threshold value, recording the association of the first method function to the tail of the second preset table, and performing operation of reducing a second preset numerical value on the priority of the first method function; in the event that it is determined that there is a second method function whose priority is equal to the second preset threshold, performing a call to the second method function.
7. The method of claim 6, wherein after said traversing said currently obtained associated record in said first predetermined table, said method further comprises:
scanning the first preset table by using the target thread in sequence;
in the case that the number of the executed priority comparison operations of the associated records in the first preset table is determined to exceed a third preset threshold, continuing to increase the associated records which are not executed with priority comparison operations.
8. An apparatus for recording retries in a transaction, the apparatus comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring an association record related to a target task to be executed, and the association record comprises the current retry times and the current time of a method function corresponding to the target task and the interval duration between the current time and the next execution time;
the storage module is used for storing the association record to a first preset table and operating the target task;
and the transfer module is used for transferring the association record to a second preset table or a third preset table according to the operation result and the target times acquired after the association record is scanned by the target thread, wherein the target times are values obtained by calling the preset times for the method function based on the interval duration and increasing the preset times for the current retry times.
9. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein said processor, said communication interface and said memory communicate with each other via said communication bus,
the memory for storing a computer program;
the processor for performing the method steps of any one of claims 1 to 7 by running the computer program stored on the memory.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 7.
CN202211608001.5A 2022-12-14 2022-12-14 Method and device for recording retry in business processing, electronic equipment and storage medium Pending CN115952167A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211608001.5A CN115952167A (en) 2022-12-14 2022-12-14 Method and device for recording retry in business processing, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211608001.5A CN115952167A (en) 2022-12-14 2022-12-14 Method and device for recording retry in business processing, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115952167A true CN115952167A (en) 2023-04-11

Family

ID=87281825

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211608001.5A Pending CN115952167A (en) 2022-12-14 2022-12-14 Method and device for recording retry in business processing, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115952167A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060241959A1 (en) * 2005-04-26 2006-10-26 Microsoft Corporation Business alerts on process instances based on defined conditions
US8996482B1 (en) * 2006-02-10 2015-03-31 Amazon Technologies, Inc. Distributed system and method for replicated storage of structured data records
CN111611057A (en) * 2020-04-23 2020-09-01 瑞庭网络技术(上海)有限公司 Distributed retry method, device, electronic equipment and storage medium
CN112667384A (en) * 2020-12-31 2021-04-16 青岛海尔科技有限公司 Task flow scheduling method, device, storage medium and electronic device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060241959A1 (en) * 2005-04-26 2006-10-26 Microsoft Corporation Business alerts on process instances based on defined conditions
US8996482B1 (en) * 2006-02-10 2015-03-31 Amazon Technologies, Inc. Distributed system and method for replicated storage of structured data records
CN111611057A (en) * 2020-04-23 2020-09-01 瑞庭网络技术(上海)有限公司 Distributed retry method, device, electronic equipment and storage medium
CN112667384A (en) * 2020-12-31 2021-04-16 青岛海尔科技有限公司 Task flow scheduling method, device, storage medium and electronic device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
向勇等: "基于QEMU的动态函数调用跟踪", 计算机研究与发展, no. 07, 15 July 2017 (2017-07-15) *

Similar Documents

Publication Publication Date Title
JP6818014B2 (en) Operation retry method and equipment for jobs
US9411689B2 (en) Method and relevant apparatus for starting boot program
WO2019041753A1 (en) Information modification method, apparatus, computer device and computer-readable storage medium
CN107766236A (en) Test assignment automatic management method, apparatus, equipment and storage medium
CN110753084B (en) Uplink data reading method, cache server and computer readable storage medium
CN108255620B (en) Service logic processing method, device, service server and system
CN109034668B (en) ETL task scheduling method, ETL task scheduling device, computer equipment and storage medium
WO2021135272A1 (en) Memory anomaly processing method and system, electronic device, and storage medium
WO2017193964A1 (en) Component upgrade method, apparatus and system
WO2021135742A1 (en) Reconciliation and liquidation method and apparatus
CN109358873B (en) Application program updating method, storage medium and terminal device
US20230030856A1 (en) Distributed table storage processing method, device and system
CN108121774B (en) Data table backup method and terminal equipment
CN112115055A (en) A kind of multi-machine automatic testing method, device and computer equipment
CN112181853A (en) Program debugging method, device and system
CN111737055A (en) Business processing method, apparatus, device, and computer-readable storage medium
CN115952167A (en) Method and device for recording retry in business processing, electronic equipment and storage medium
CN113127479B (en) Method and device for loading elastic search index, computer equipment and storage medium
CN109286672B (en) A method, device and server for processing user request
WO2024103583A1 (en) Method and apparatus for changed bios options to take effect, nonvolatile readable storage medium, and electronic apparatus
CN117518916A (en) Process monitoring methods, devices, electronic equipment and storage media
CN110543349B (en) Application starting acceleration method and device and computer readable storage medium
CN115858114A (en) Scheduling method and device of idle task, electronic equipment and readable storage medium
CN115269252A (en) Application fault handling method, device, device and storage medium
CN115129200A (en) Method, apparatus, device and storage medium for processing list content items

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