Method, medium, product and device for playback timeout control of database session

By introducing high-water threshold, low-water threshold and control factor into the database replay system, and dynamically calculating the timeout threshold, the misjudgment problem of traditional timeout strategies is solved, realizing efficient and flexible SQL replay control in heterogeneous database environments, and improving the efficiency and authenticity of replay results.

CN121210428BActive Publication Date: 2026-02-13CETC JINCANG (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511746646.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-26
Publication Date
2026-02-13
Estimated Expiration
2045-11-26

AI Technical Summary

Technical Problem

Existing database replay technology lacks flexible timeout control capabilities, which leads to prolonged replay time in complex business scenarios, affecting the validity and reference value of replay results. Furthermore, traditional timeout strategies are prone to inadvertently blocking normal but time-consuming SQL calls.

Method used

By acquiring the preset timeout control parameters of the session, including high water level threshold, low water level threshold and control factor, and calculating the dynamic timeout threshold, fine-grained control over database operation statements can be achieved. Lightweight mode and default mode are supported to ensure the flexibility and accuracy of the playback process.

Benefits of technology

It enables precise control over SQL execution time in heterogeneous database environments, avoids misjudgments, improves the efficiency and applicability of replay, and ensures the authenticity of replay results and business consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121210428B_ABST
    Figure CN121210428B_ABST
Patent Text Reader

Abstract

The application provides a playback timeout control method, medium, product and equipment of database session. The method comprises the following steps: obtaining preset timeout control parameters corresponding to the session, including a high water level threshold and a control factor; obtaining a to-be-playback database operation statement in the session; calculating a timeout threshold corresponding to the to-be-playback database operation statement according to the high water level threshold and the control factor; performing a playback operation on the to-be-playback database operation statement, and judging whether the execution time of the playback operation is higher than the timeout threshold; in the case that the execution time is higher than the timeout threshold, it is determined that the to-be-playback database operation statement is timed out, and the playback operation of the to-be-playback database operation statement is cancelled. The method of the application introduces multi-dimensional threshold parameters and dynamic control factors, so that the playback system can make more fine-grained judgment and processing on the execution time of SQL, thereby being closer to the actual business scenario and improving the applicability and operability of database playback.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, in particular to a database session playback timeout control method, medium, product and equipment. BACKGROUND

[0002] In the research and application of isomorphic database load playback or simulation technology, there are certain limitations. The existing scheme ignores the core and basic link of timeout control at the beginning of design, which leads to the lack of necessary response ability when facing complex business scenarios. The timeout problem that may occur during SQL execution is not fully considered, which often directly leads to the serious lengthening of the overall playback time, thereby weakening the effectiveness and reference value of the playback result. In addition, although some other schemes introduce timeout cancellation and other processing mechanisms, the implementation method is too simple and rigid, and usually adopts a "one-size-fits-all" strategy. Once the set threshold is exceeded, regardless of whether the call itself has business rationality, the system will directly terminate. This processing method lacks sufficient flexibility and intelligence, and is easy to misjudge normal but time-consuming SQL calls in some scenarios, thereby negatively affecting the integrity and authenticity of business playback.

[0003] However, in actual customer business scenarios, users have a very urgent need for flexible timeout control. Because different types of SQL have different complexity, importance and tolerance, customers often want to set different timeout strategies for different sessions or SQLs according to business characteristics and actual needs during playback, in order to avoid the risks brought by "one-size-fits-all". This requires the database playback system to have more refined and configurable session timeout control capabilities. SUMMARY

[0004] In view of the above problems, the present application provides a database session playback timeout control method, medium, product and equipment which can overcome the above problems or at least partially solve the above problems.

[0005] An object of the present application is to enable database playback to achieve higher flexibility and adaptability in the playback environment.

[0006] A further object of the present application is to ensure that the playback is closer to the actual business scenario.

[0007] In particular, the present application provides a database session playback timeout control method, comprising:

[0008] Obtaining preset timeout control parameters corresponding to the session, the preset timeout control parameters including a high water level threshold and a control factor;

[0009] Obtaining a database operation statement to be played back in the session;

[0010] According to the high-water threshold and the control factor, a timeout threshold corresponding to the database operation statement to be played back is calculated;

[0011] The playback operation of the database operation statement to be played back is performed, and it is determined whether the execution time of the playback operation is higher than the timeout threshold;

[0012] In the case that the execution time is higher than the timeout threshold, it is determined that the playback of the database operation statement to be played back is timed out, and the playback operation of the database operation statement to be played back is cancelled.

[0013] Optionally, the step of calculating the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor comprises:

[0014] A time reference value corresponding to the database operation statement to be played back is obtained, the time reference value being the execution time of the database operation statement to be played back at the source end database;

[0015] The timeout reference value is calculated based on the time reference value and the control factor;

[0016] The timeout threshold corresponding to the database operation statement to be played back is determined according to the timeout reference value and the high-water threshold.

[0017] Optionally, the calculation formula of the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor is:

[0018] To = min (Tc × factor, Tmax)

[0019] Wherein, To represents the timeout threshold, Tc represents the time reference value, factor represents the control factor, Tmax represents the high-water threshold, and min (Tc × factor, Tmax) represents the smaller value between the timeout reference value and the high-water threshold.

[0020] Optionally, the preset timeout control parameter further comprises a low-water threshold;

[0021] The step of performing the playback operation of the database operation statement to be played back further comprises:

[0022] In the case that the execution time of the playback operation is lower than the low-water threshold, it is determined that the playback of the database operation statement to be played back is normal;

[0023] It is determined whether the session is played back completely;

[0024] If not, the next unplayed database operation statement is obtained as the database operation statement to be played back;

[0025] The step of calculating the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor is performed.

[0026] Optionally, the method further comprises enabling a lightweight mode;

[0027] In the case that the lightweight mode is enabled, the step of obtaining the database operation statement to be replayed in the session further comprises:

[0028] directly replaying the database operation statement to be replayed, and determining whether the execution time of the replaying operation is higher than a low threshold value;

[0029] In the case that the execution time of the replaying operation is lower than the low threshold value, the time reference value corresponding to the database operation statement to be replayed is not required to be obtained, and it is directly determined that the replaying of the database operation statement to be replayed is normal.

[0030] Optionally, in the case that the lightweight mode is enabled, the step of determining whether the execution time of the replaying operation is higher than the low threshold value further comprises:

[0031] In the case that the execution time of the replaying operation is higher than the low threshold value, the time reference value corresponding to the database operation statement to be replayed is obtained;

[0032] calculating a timeout threshold value of the database operation statement to be replayed according to the time reference value, a high threshold value and a control factor;

[0033] The step of determining whether the execution time of the replaying operation is higher than the timeout threshold value is executed.

[0034] Optionally, the step of obtaining the database operation statement to be replayed in the session comprises: determining whether the session is replayed completely; if not, obtaining the next unreplayed database operation statement as the database operation statement to be replayed.

[0035] The step of canceling the replaying operation of the database operation statement to be replayed further comprises: generating a timeout error code.

[0036] According to another aspect of the present application, there is also provided a computer readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned database session replay timeout control methods.

[0037] According to still another aspect of the present application, there is also provided a computer program product comprising a computer program which, when executed by a processor, implements the steps of any of the above-mentioned database session replay timeout control methods.

[0038] According to yet another aspect of the present application, there is also provided a computer device comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, and the processor implements the steps of any of the above-mentioned database session replay timeout control methods when executing the machine executable program.

[0039] The playback timeout control method of the database session of the application firstly acquires preset timeout control parameters corresponding to the session, the preset timeout control parameters including a high water level threshold and a control factor; then acquires a database operation statement to be played back in the session; subsequently calculates a timeout threshold corresponding to the database operation statement to be played back according to the high water level threshold and the control factor; performs a playback operation on the database operation statement to be played back, and judges whether the execution time of the playback operation is higher than the timeout threshold; in the case that the execution time is higher than the timeout threshold, it is determined that the playback of the database operation statement to be played back is timed out, and the playback operation of the database operation statement to be played back is cancelled. This method introduces multi-dimensional threshold parameters and dynamic control factors, so that the playback system can make more fine-grained judgments and processing on the execution time of SQL, thereby ensuring that the playback is closer to the actual business scenario, improving the applicability and operability of database playback, and avoiding the low efficiency and misjudgment problems caused by the traditional "one-size-fits-all" timeout strategy.

[0040] The above and other objects, advantages and features of the present application will become more apparent from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS

[0041] Some specific embodiments of the present application will be described in detail below with reference to the accompanying drawings. The same reference numbers in the drawings indicate the same or similar components or parts. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:

[0042] Figure 1 is a flowchart of a playback timeout control method of a database session according to an embodiment of the present application;

[0043] Figure 2 is a flowchart of a playback timeout control method of a database session according to another embodiment of the present application;

[0044] Figure 3 is a flowchart of a playback timeout control method of a database session according to still another embodiment of the present application;

[0045] Figure 4 is a schematic diagram of a computer program product according to an embodiment of the present application;

[0046] Figure 5 is a schematic diagram of a computer readable storage medium according to an embodiment of the present application; and

[0047] Figure 6 is a schematic diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0048] Those skilled in the art will understand that the embodiments described below are merely a part of the embodiments of the present application, and are not the whole embodiments of the present application, and the part of the embodiments are intended to explain the technical principles of the present application, and are not intended to limit the protection scope of the present application. Based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor shall fall within the protection scope of the present application.

[0049] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a list of executable instructions for implementing logical functions, and can be specifically embodied in any computer readable medium for use by an instruction execution system, device or apparatus, such as a computer-based system, a system including a processor, or other system that can fetch and execute instructions from the instruction execution system, device or apparatus, or in conjunction with these instructions.

[0050] At present, the commercial database market in China is still dominated by foreign products such as Oracle, SQL Server and MySQL. Especially in key fields such as finance and communication, Oracle occupies a core position with its mature ecology, and developers have formed a deep technical dependence on its SQL syntax, programming interface and advanced components (such as PL / SQL). Driven by the policy of China's information security, enterprises hope to achieve seamless replacement of domestic databases through minimal modification, in order to reduce migration costs and technical risks.

[0051] However, the database migration process often faces multiple challenges:

[0052] 1. Performance and compatibility risks: Differences between domestic databases and Oracle in SQL execution plan optimization, data type support, etc. can easily cause performance degradation and syntax compatibility problems (such as stored procedure rewriting, function incompatibility);

[0053] 2. Test environment distortion: Traditional test load is difficult to simulate the concurrent pressure and data distribution of real production environment, resulting in significant deviation between test results and actual business scenarios;

[0054] 3. Inefficient manual migration: Relying on manual checking of SQL and PL / SQL code, time-consuming and easy to miss, and after migration, repeated debugging is required, which delays project progress.

[0055] To address the above challenges, database playback technology has become a key solution, including:

[0056] Real load capture: Capture complete workloads from production environment to accurately reproduce business pressure model in test environment;

[0057] Intelligent analysis positioning: automatically compare performance indicators before and after migration, generate difference report, accurately identify compatibility defects and performance bottlenecks, etc.

[0058] In the actual database playback process, some special production scenarios, instances or SQLs are often encountered due to the reasons such as not being optimized or being subject to differences of heterogeneous database optimizers, so that the playback time is greatly prolonged. The root cause is that the SQL execution plan degenerates, thereby causing the playback running speed to decrease significantly, and even the playback to be suspended. In this regard, in addition to the need for SQL performance optimization before playback, a session timeout control mechanism should also be provided in the playback process, so that when the execution plan is poor and the query is out of control after database upgrade or replacement, the playback can be stopped in time.

[0059] Therefore, a flexible and controllable session timeout control processing mechanism is designed and implemented, which is the basic requirement of the database playback function. The mechanism needs to support accurate control of the execution timeout of the SQL in the session, as well as the implementation of functions such as SQL execution time and timeout error recording, to ensure that the original load can be efficiently and controllably played back in different performance scenarios.

[0060] Based on the above requirements, the application provides a database session playback timeout control method, Figure 1 The flowchart of the database session playback timeout control method according to an embodiment of the application is shown in Figure 1 The database session playback timeout control method comprises at least the following steps S101 to S105.

[0061] Step S101, obtain the preset timeout control parameters corresponding to the session. The preset timeout control parameters are timeout judgment reference parameters configured by the user according to the business scenario, and the core generally includes a high water level threshold (Tmax), a low water level threshold (Tmin) and a control factor (factor). The high water level threshold is the absolute upper limit of the SQL playback time, regardless of the dynamic calculation result, if it exceeds the threshold, it is determined as timeout, to avoid that the extreme time-consuming operation drags down the whole playback. The low water level threshold is the safe lower limit of the SQL playback time, and the operation below the threshold does not need additional judgment, and is directly regarded as normal execution, to reduce invalid calculation. The control factor is a coefficient for dynamically adjusting the timeout reference based on the source end execution time, which is used to adapt to the performance difference between the heterogeneous database and the source end database, and balance the risk of misjudgment and flexibility.

[0062] Under normal circumstances, the user can set the parameter group according to the business scenario through the configuration interface of the database playback system, and the system supports parameter template storage and reuse. The above parameter setting generally satisfies TminTmax, and the value of the control factor factor should be ensured to be within a reasonable range, to ensure the stability of the calculation logic.

[0063] In step S102, a database operation statement to be played back in the session is obtained. The specific execution process of step S102 can generally include: determining whether the session is played back completely; if not, obtaining the next unplayed database operation statement as the database operation statement to be played back. In this way, the playback order of the statements in the session can be consistent with the source production environment, and the real business pressure model can be reproduced.

[0064] In step S103, a timeout threshold corresponding to the database operation statement to be played back is calculated according to the high-water threshold and the control factor.

[0065] In some optional embodiments, the step of calculating the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor can generally include: obtaining a time reference value corresponding to the database operation statement to be played back, the time reference value being the execution time of the database operation statement to be played back in the source database; calculating a timeout reference value based on the time reference value and the control factor; and determining the timeout threshold corresponding to the database operation statement to be played back according to the timeout reference value and the high-water threshold. The timeout reference value calculated from the time reference value and the control factor can accurately reflect the upper limit of the dynamic execution time that can be tolerated by the statement in the playback process, thereby adapting to the inherent complexity differences of different statements.

[0066] Based on the high-water threshold, the low-water threshold, and the timeout reference value, the basic judgment rule of the method is: when the SQL playback time Tr is lower than Tmin, it is determined that the SQL is in a normal acceptable range, and the playback process does not need additional intervention; when Tr is higher than Tmax, the system will directly determine that it is a timeout, and immediately execute a cancel operation, and record the situation as a timeout event; when Tr is within the interval [Tmin, Tmax], the SQL execution time Tc during source capture is further introduced as a reference value. If Tr>Tc×factor, it is determined to be a timeout and a cancel and record are executed; otherwise, it is considered to be a normal execution. Through this design, a balance can be established between the fixed threshold and the dynamic reference, which can avoid misjudgment of normal long-time SQL, and effectively suppress abnormal timeout caused by execution plan degradation.

[0067] In the actual judgment process, considering that the sizes of the high-water threshold and the timeout reference value cannot be determined, the present application further selects the smaller value between the high-water threshold and the timeout reference value as the timeout threshold. Optionally, the calculation formula of the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor can be as shown in formula (1):

[0068] To=min(Tc×factor, Tmax) Formula (1)

[0069] Wherein, To represents a timeout threshold, Tc represents a time reference value, factor represents a control factor, Tmax represents a high water level threshold, and min(Tc*factor, Tmax) represents a smaller value between the timeout reference value and the high water level threshold.

[0070] In step S104, the playback operation of the database operation statement to be played back is performed.

[0071] In step S105, it is determined whether the execution time of the playback operation is higher than the timeout threshold. If the execution time of the playback operation is lower than the timeout threshold, it indicates that the playback operation is not timed out, and thus the next database operation statement to be played back in the session can be continuously played back until the session is played back completely.

[0072] In step S106, if the result of step S105 is yes, it is determined that the playback of the database operation statement to be played back is timed out, and the playback operation of the database operation statement to be played back is cancelled. After the playback operation of the database operation statement to be played back is cancelled, a timeout error code can be generated. The timeout error code generally records information such as a statement unique identifier, a timeout occurrence time, and target library real-time performance indicators (such as CPU utilization and IO delay). Such records not only provide data support for subsequent tuning and diagnosis, but also serve as part of the system log to ensure the traceability and interpretability of the database playback process.

[0073] Optionally, the preset timeout control parameter can further include a low water level threshold. After the step of performing the playback operation of the database operation statement to be played back, the following steps can be further included: if the execution time of the playback operation is lower than the low water level threshold, it is determined that the playback of the database operation statement to be played back is normal; it is determined whether the session is played back completely; if not, the next unplayed database operation statement is obtained as the database operation statement to be played back; and the step of calculating the timeout threshold corresponding to the database operation statement to be played back according to the high water level threshold and the control factor is performed.

[0074] The above scheme is generally a default mode of playback, which is suitable for scenarios with extremely high playback accuracy requirements (such as critical business system migration testing), and thus performs complete threshold calculation and determination logic. In addition, there is an optional lightweight mode, the core logic of which is to trigger the time reference value (Tc) acquisition on demand, and only high-time-consuming statements are subjected to complete determination, and low-time-consuming statements are directly and quickly released, which not only retains the accuracy of the default mode, but also effectively reduces the process of reference value acquisition in the playback process, thereby further improving the playback efficiency. Those skilled in the art can select the corresponding execution logic according to the actual situation.

[0075] In some optional embodiments, the timeout control method of the present application can also include a lightweight mode. In the case of starting the lightweight mode, the step of obtaining the database operation statement to be played back in the session can generally include: directly playing back the database operation statement to be played back, and determining whether the execution time of the playback operation is higher than the low water level threshold; in the case that the execution time of the playback operation is lower than the low water level threshold, the time reference value corresponding to the database operation statement to be played back is not obtained, and the database operation statement to be played back is directly determined to be normal. In this way, the low-time-consumption statement itself meets the normal business characteristics, and does not need to be determined with the assistance of the timeout threshold, so it is selected to be directly released, thereby reducing the overhead of obtaining the time reference value and calculating the timeout threshold.

[0076] If it is monitored that the SQL playback time Tr is higher than Tmin (for example, Tr=120 ms and Tmin=50 ms), it indicates that the statement time consumption exceeds the "safe lower limit", and there is an abnormal timeout risk, and the system needs to trigger the complete determination logic of the default mode to ensure that no abnormality is missed. Therefore, in the case of starting the lightweight mode, the step of determining whether the execution time of the playback operation is higher than the low water level threshold can generally further include: in the case that the execution time of the playback operation is higher than the low water level threshold, obtaining the time reference value corresponding to the database operation statement to be played back; calculating the timeout threshold of the database operation statement to be played back according to the time reference value, the high water level threshold and the control factor; and performing the step of determining whether the execution time of the playback operation is higher than the timeout threshold.

[0077] In summary, the method of the present application is configured with multiple parameters (Tmin, Tmax, factor) and designed with a double mode, the default mode guarantees the accuracy of the key scene, and the lightweight mode improves the efficiency of the high-frequency short query scene. Through the double constraints of "dynamic reference (Tc x factor) + static threshold (Tmax)", the risk of false negative of the traditional "one-size-fits-all" strategy is greatly reduced, and the multi-dimensional information record of the timeout error code can provide complete data support for subsequent performance tuning and compatibility defect positioning. The control factor can be dynamically adjusted according to the target library performance, compatible with the performance differences of domestic databases and foreign databases such as Oracle, reducing the repeated debugging cost of parameters in migration testing, and meeting the enterprise migration demand under the policy of innovation and creation. Finally, the database playback can realize higher flexibility and adaptability in a heterogeneous environment, improving the efficiency of playback, and ensuring the authenticity and business consistency of the results.

[0078] In order to more clearly illustrate the method of the present application, the specific execution processes in the default mode and the lightweight mode are described respectively through Figure 2 and Figure 3

[0079] Figure 2 ​is a flowchart of a database session playback timeout control method according to another embodiment of the present application, as shown in the default mode, the database session playback timeout control method comprises at least the following steps S201 to S209. Figure 2

[0080] The core feature of the default mode is full statement execution complete judgment logic, that is, regardless of the inherent time consumption of the database operation statement (such as SQL, PL / SQL) to be played back, the accurate timeout threshold (To) is calculated first, and then the playback and judgment are executed, ensuring that no potential timeout exception is missed, and ensuring that the database playback can efficiently, truly and controllably reproduce the original load. This mode solves the two defects of the traditional "one-size-fits-all timeout strategy": one is to avoid misjudging normal long-time-consuming statements (such as complex statistical queries) as timeout; the other is to prevent abnormal time-consuming statements (such as SQL with degraded execution plan) from continuously occupying resources due to the threshold being too wide, and finally achieve the goal of "efficiently, truly, and controllably reproducing the original database session load".

[0081] Step S201, obtaining the preset timeout control parameters corresponding to the session. Specifically, the system reads the preset timeout control parameters of the current session through the configuration interface of the database playback platform. The parameter group at least includes: high water level threshold (Tmax): the absolute upper limit of statement playback time consumption, which is configured by the user according to the maximum tolerable time consumption of the business; control factor (factor): a dynamic coefficient (generally >1, such as 1.2-2.0) that adapts to the performance differences of heterogeneous databases, which is used to convert the source end time consumption into the target end tolerable time consumption; (optional) low water level threshold (Tmin): the safe lower limit of statement playback time consumption, which is used to quickly judge the normal execution of short-time-consuming statements.

[0082] Step S202, judging whether the session is played back. Generally, the system determines the session state by comparing "total number of statements to be played back" and "number of completed playback statements": if they are equal, it means that all statements have been processed, and the current session playback is terminated; if they are not equal, step S203 is executed.

[0083] Step S203, in the case of "no" in step S202, obtaining the next unplayed database operation statement as the database operation statement to be played back.

[0084] Step S204, obtaining the time reference value corresponding to the database operation statement to be played back. The time reference value is the actual execution time consumption of the statement in the source end database (such as the production environment Oracle), which can generally be obtained by parsing the source end workload log and other methods. In this way, the source end real time consumption is introduced as a reference, solving the misjudgment problem of the traditional fixed threshold which is independent of the actual business characteristics, and providing a basis for dynamic threshold calculation.

[0085] ​Step S205, a timeout reference value is calculated based on the time reference value and a control factor. The formula for calculating the timeout reference value can be generally: timeout reference value=Tc x factor, wherein the value of factor is dynamically adjusted according to the performance difference between the target database and the source database, for example, if the performance of the target database is lower than that of the source, the value of factor can be slightly larger, for example, 1.5-2.0; if the performance of the target database is close to that of the source, the value of factor can be generally 1.1-1.3. The specific value of the control factor can be determined by the person skilled in the art according to the actual situation. By controlling the factor to adapt to the performance difference of the heterogeneous databases (such as the execution efficiency difference between the domestic database and Oracle), it is avoided that the normal time consumption is misjudged as timeout due to different environments.

[0086] Step S206, the timeout threshold corresponding to the database operation statement to be played back is determined according to the timeout reference value and the high water level threshold. The formula for calculating the timeout threshold is generally as shown in formula (1), that is, the smaller value of the dynamically calculated value and the static upper limit. In this way, through the double constraints of dynamic reference + static upper limit, the reasonable judgment of long time-consuming statements is ensured, and the resource occupation in the extreme case is limited.

[0087] Step S207, the playback operation is performed on the database operation statement to be played back.

[0088] Step S208, it is judged whether the execution time consumption of the playback operation is higher than the timeout threshold. In the case of no in step S208, it indicates that the playback operation is not timeout, and therefore step S202 can be continuously executed until the session playback is completed.

[0089] Step S209, in the case of yes in step S208, the playback operation of the database operation statement to be played back is cancelled, and a timeout error code is generated. Then step S202 is continuously executed until the session playback is completed. Such record not only can provide data support for subsequent optimization and diagnosis, but also can be used as part of the system log to ensure the traceability and explainability of the database playback process.

[0090] Through this method, more flexible customization options can be provided for users, and different timeout strategies are set for different sessions or SQLs according to business characteristics and actual needs in the playback process, so as to avoid the risk of "one size fits all", thereby ensuring that the playback is closer to the actual business scenario and improving the applicability and operability of the database playback.

[0091] Figure 3 is a flowchart of a database session playback timeout control method according to another embodiment of the application, as shown in Figure 3 In the lightweight mode, the database session playback timeout control method includes at least the following steps S301-S310.

[0092] Figure 3 The light mode shown is the efficient optimization process designed by the application based on the default mode, and its core feature is to trigger the acquisition and calculation of the time reference value on demand, filter the time-consuming of the statement through the low water level threshold, execute the complete determination logic only for the high time-consuming statement, and directly and quickly release the low time-consuming statement. Under the premise of ensuring the core accuracy, the invalid operation overhead is greatly reduced, and the defects of the traditional full-process determination, such as “low efficiency and resource waste”, are solved.

[0093] Step S301, a preset timeout control parameter corresponding to the session is acquired. The parameter group at least includes: a high water level threshold (Tmax): an absolute upper limit of the statement playback time-consuming, which is configured by a user according to the maximum tolerable time-consuming of the business; a control factor (factor): a dynamic coefficient (generally, the value > 1, such as 1.2-2.0) adapted to the performance difference of the heterogeneous database, which is used to convert the source end time-consuming into the target end tolerable time-consuming; and a low water level threshold (Tmin): a safe lower limit of the statement playback time-consuming, which is used to quickly determine the normal execution of the short time-consuming statement.

[0094] Step S302, it is judged whether the session is completed. Generally, the session state can be determined by comparing the “total to be played back statement number” and the “completed statement number”: if completed, the process is terminated; if not completed, step S303 is executed.

[0095] Step S303, in the case of no in step S302, the next unplayed database operation statement is acquired as the to-be-played-back database operation statement.

[0096] Step S304, the to-be-played-back database operation statement is played back. The to-be-played-back statement is executed in the target database, and the actual playback time-consuming is monitored in real time, and the time reference value is not acquired in advance, which is the core difference between the light mode and the default mode, and the overhead of analyzing the time reference value is saved.

[0097] Step S305, it is judged whether the execution time-consuming of the playback operation is higher than the low water level threshold. If the actual playback time-consuming < the low water level threshold: it is determined as a low time-consuming normal statement, and then step S302 can be directly returned, and the acquisition and threshold calculation of the time reference value are not executed.

[0098] Step S306, in the case of yes in step S305, the time reference value corresponding to the to-be-played-back database operation statement is acquired. When the execution time-consuming ≥ the low water level threshold, the acquisition of the time reference value is triggered, and the specific acquisition method is consistent with the default mode, that is, the time reference value is acquired by analyzing the source end working load log. In this way, the source end real time-consuming is introduced as the reference, the fixed threshold misjudgment problem of the traditional method which is independent of the actual business characteristics is solved, and the basis for the subsequent dynamic threshold calculation is provided.

[0099] Step S307, a timeout reference value is calculated based on the time reference value and the control factor. The timeout reference value calculation formula can be generally: timeout reference value=Tc x factor, wherein the value of factor is dynamically adjusted according to the performance difference between the target database and the source database, for example, if the target database performance is lower than the source, the value of factor can be slightly larger, for example, 1.5-2.0; if the target database performance is close to the source, the value of factor can generally be 1.1-1.3. The specific value of the control factor can be determined by the person skilled in the art according to the actual situation. The control factor is adapted to the performance difference of the heterogeneous database (such as the execution efficiency difference between the domestic database and Oracle), so as to avoid that the normal time consumption is misjudged as timeout due to different environments.

[0100] Step S308, the timeout threshold value corresponding to the database operation statement to be played back is determined according to the timeout reference value and the high water level threshold value. The calculation formula of the timeout threshold value is generally as shown in formula (1), that is, the smaller value of the dynamic calculation value and the static upper limit. In this way, through the double constraints of dynamic reference + static upper limit, the reasonable judgment of long time-consuming statements is ensured, and the resource occupation in the extreme case is limited.

[0101] Step S309, it is judged whether the execution time consumption of the playback operation is higher than the timeout threshold value. If step S309 is no, after the database operation statement to be played back is played back, step S302 is continued to be executed.

[0102] Step S310, in the case that step S309 is yes, the playback operation of the database operation statement to be played back is cancelled, and a timeout error code is generated. Then step S302 is continued to be executed until the session playback is completed.

[0103] Through this method, on the one hand, the low time-consuming statement skips the time reference value acquisition and threshold calculation, thereby further reducing the overall playback time consumption on the basis of the default mode, and improving the playback efficiency; on the other hand, only the high time-consuming statement is executed to complete the judgment, so as to ensure the accuracy of the timeout judgment of the core statement, and finally make the database playback can realize higher flexibility and adaptability in the heterogeneous environment, which not only improves the efficiency of the playback, but also guarantees the authenticity and business consistency of the result.

[0104] In summary, the application realizes a method for supporting session timeout control processing in heterogeneous database playback, which can balance the fixed threshold and the dynamic reference, avoid the "one-size-fits-all" timeout strategy, and thus improve the flexibility, efficiency and business fitting degree of the heterogeneous database playback.

[0105] The flowchart provided by the embodiment is not intended to indicate that the operations of the method should be executed in any particular order, or that all of the operations included in the method should be included in every case. In addition, the method can include additional operations. Additional changes can be made to the above-described method within the scope of the technical ideas provided by the method of the embodiment.

[0106] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above-described implementation, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0107] The embodiment also provides a computer program product 10, a computer readable storage medium 20, and a computer device 30. Figure 4 is a schematic diagram of the computer program product 10 according to one embodiment of the present application, Figure 5 is a schematic diagram of the computer readable storage medium 20 according to one embodiment of the present application, Figure 6 is a schematic diagram of the computer device 30 according to one embodiment of the present application. The computer program product 10 includes a computer program 11 which, when executed by the processor 32, implements the steps of any of the database session playback timeout control methods described above. The computer readable storage medium 20 has the computer program 11 described above stored thereon, and the computer program 11, when executed by the processor 32, implements the steps of any of the database session playback timeout control methods described above. The computer device 30 can include a memory 31, a processor 32, and a computer program 11 stored on the memory 31 and running on the processor 32.

[0108] Computer program 11, which can also comprise programs 11 for performing operations of the present application, can be assembly instructions, Instruction Set Architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state setting data, configuration data for an integrated circuit, or source code or object code written in any combination of one or more programming languages and processes. Computer program 11 can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate array (FPGA), or programmable logic array (PLA) can execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present application.

[0109] For the purposes of this description of the embodiments, computer program product 10 is a product of authorship that comprises computer program 11. For the purposes of this description of the embodiments, computer readable storage medium 20 is a tangible device that can retain and store computer program 11 for purposes of having computer program 11 accessible by a processing device, machine, or module. More specifically, computer readable storage medium 20 can be, for example, but is not limited to, portable computer diskette, hard disk, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or Flash memory), static random access memory (SRAM), portable compact disc read only memory (CD-ROM), digital versatile disk (DVD), memory stick, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium 20, as used herein, is expressly intended to encompass a computer readable storage medium 20 that is removable from the processing device, machine, or module that reads it, and to encompass a computer readable storage medium 20 that is non-removable from the processing device, machine, or module that reads it.

[0110] The computer device 30 can be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 30 can be a cloud computing node. The computer device 30 can be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules can include routines, programs, objects, components, logic, data structures, and so on that perform particular tasks or implement particular abstract data types. The computer device 30 can be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules can be located in both local and remote computer system storage media including memory storage devices.

[0111] The computer device 30 can include a processor 32 adapted to execute stored instructions, a memory 31 that provides temporary storage for operations of the instructions during operation. The processor 32 can be a single core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 31 can include random access memory (RAM), read only memory, flash memory, or any other suitable storage system.

[0112] The computer device 30 can also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows for input and output of data with external devices that can be connected to the computer device. The network adapter / interface can provide for communication between the computer device and a network, typically illustrated as a communication network.

[0113] To this end, it will be understood that, although the present application has been described herein in terms of several exemplary embodiments, modifications which fall within the scope of the present application can be made without departing from the spirit thereof, and it is intended to claim each individual embodiment separately as well as every distinct combination that can be made from the elements of the separate embodiments. Therefore, the scope of the present application should be understood to include all such modifications.

Claims

1. A method for controlling playback timeout of a database session, comprising: obtaining preset timeout control parameters corresponding to the session, the preset timeout control parameters comprising a high-water threshold and a control factor; obtaining a database operation statement to be played back in the session; calculating a timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor, the high-water threshold being an absolute upper limit of SQL playback time consumption, and the control factor being a coefficient for dynamically adjusting a timeout benchmark based on source-side execution time consumption; performing a playback operation on the database operation statement to be played back, and determining whether execution time consumption of the playback operation is higher than the timeout threshold; in the case where the execution time consumption is higher than the timeout threshold, determining that the database operation statement to be played back is timed out, and canceling the playback operation of the database operation statement to be played back; the step of calculating the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor comprises: obtaining a time benchmark value corresponding to the database operation statement to be played back, the time benchmark value being execution time consumption of the database operation statement to be played back in a source-side database; calculating a timeout benchmark value based on the time benchmark value and the control factor; and determining the timeout threshold corresponding to the database operation statement to be played back according to the timeout benchmark value and the high-water threshold; a calculation formula of the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor is: To = min (Tc × factor, Tmax) wherein, the To represents the timeout threshold, the Tc represents the time benchmark value, the factor represents the control factor, the Tmax represents the high-water threshold, and the min (Tc × factor, Tmax) represents taking a smaller value between the timeout benchmark value and the high-water threshold. 2.The method for controlling playback timeout of a database session according to claim 1, wherein, the preset timeout control parameters further comprise a low-water threshold; the step of performing a playback operation on the database operation statement to be played back further comprises: in the case where the execution time consumption of the playback operation is lower than the low-water threshold, determining that the database operation statement to be played back is played back normally; determining whether the session is played back completely; if not, obtaining a next database operation statement to be played back as the database operation statement to be played back; performing the step of calculating the timeout threshold corresponding to the database operation statement to be played back according to the high-water threshold and the control factor.

3. The database session playback timeout control method of claim 2, wherein, further comprising a lightweight mode; in the case where the lightweight mode is started, the step of obtaining a database operation statement to be played back in the session further comprises: directly performing a playback operation on the database operation statement to be played back, and determining whether execution time consumption of the playback operation is higher than the low-water threshold; If the execution time of the playback operation is lower than the low threshold, the time reference value corresponding to the database operation statement to be played back is not acquired, and it is directly determined that the database operation statement to be played back is played back normally.

4. The method of claim 3, wherein, If the light mode is started, the step of determining whether the execution time of the playback operation is higher than the low threshold comprises: If the execution time of the playback operation is higher than the low threshold, the time reference value corresponding to the database operation statement to be played back is acquired; The timeout threshold of the database operation statement to be played back is calculated according to the time reference value, the high threshold and the control factor; The step of determining whether the execution time of the playback operation is higher than the timeout threshold is executed.

5. The method of claim 1, wherein, The step of acquiring the database operation statement to be played back in the session comprises: determining whether the session is played back completely; if not, the next unplayed database operation statement is acquired as the database operation statement to be played back; The step of canceling the playback operation of the database operation statement to be played back further comprises: generating a timeout error code.

6. A computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the steps of the method of claim 1 to 5.

7. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the method of claim 1 to 5.

8. A computer device, comprising a memory, a processor, and a machine executable program stored on the memory and running on the processor, and the processor implements the steps of the method of claim 1 to 5 when executing the machine executable program.

Citation Information

Patent Citations

  • Searching and killing method and device, computer equipment and storage medium

    CN114490720A

  • SQL statement execution timeout control method and device

    CN115617561A