Lock waiting management method and device, program product, electronic equipment and storage medium

By acquiring the tag value of the lock waiting queue in the database, judging the release of data resources and retrying the task in a timely manner, the problem of poor lock waiting queue management is solved, and efficient utilization of data resources and optimization of computing resources is achieved.

CN119088812APending Publication Date: 2024-12-06BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411125619.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

In the prior art, the lock waiting queue management of the database when executing SQL requests is poor, resulting in idle data resources and delayed data processing tasks, and the task cannot wake up and try again after lock conflict, resulting in wasted computing resources.

Method used

By acquiring the mark value of the lock waiting queue, we judge whether the data resource has been released, and retry the task in time after it is released, avoiding multiple tasks retry at the same time, and adopting the placeholder task mechanism to avoid lock conflicts.

Benefits of technology

It realizes timely wake-up of data resources and efficient utilization of computing resources, avoids idle data resources and waste of computing resources, and ensures timely completion of data processing tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088812A_ABST
    Figure CN119088812A_ABST
Patent Text Reader

Abstract

The invention provides a lock waiting management method and device, a program product, electronic equipment and a storage medium, and the method comprises the steps: obtaining a first mark value of a lock waiting queue corresponding to target data if a lock conflict occurs on the target data corresponding to the target task in a process of executing the target task; rolling back the target task, and obtaining a second mark value of a lock waiting queue corresponding to the target data after rolling back is completed; and if the first mark value is different from the second mark value and no task exists in the lock waiting queue corresponding to the target data, adding a placeholder task corresponding to the target task to the lock waiting queue corresponding to the target data, and retrying the target task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of database technology, and in particular, to a lock waiting management method and device, a program product, an electronic device, and a storage medium. Background Art

[0002] With the rapid development of the Internet and informatization, the generation of data is exploding, so the requirements for databases and their management are getting higher and higher. When executing data processing tasks such as SQL requests, databases often need to add locks to the targeted data resources, such as shared locks, exclusive locks, etc., to maintain data consistency and transaction isolation when data resources are accessed concurrently. This means that different data processing tasks may have lock conflicts on the same data resource, that is, multiple data processing tasks need to lock the same data resource and cannot be implemented at the same time. This requires the management of these data processing tasks so that different tasks can lock data resources in sequence, such as adding tasks that cannot immediately lock data resources to the lock waiting queue, and retrying tasks in the lock waiting queue when the data resources can be locked later.

[0003] However, in the related art, the management effect of the lock waiting queue of data resources is general, which leads to problems such as the data processing tasks in the lock waiting queue cannot be woken up and retried in time, the data resources are idle, and the data processing tasks have high processing delays. Summary of the invention

[0004] In view of this, one or more embodiments of the present specification provide a lock waiting management method and apparatus, a program product, an electronic device, and a storage medium.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of one or more embodiments of this specification, a lock waiting management method is proposed, the method comprising:

[0007] If a lock conflict occurs on the target data targeted by the target task during the execution of the target task, obtaining a first mark value of the lock waiting queue corresponding to the target data;

[0008] Rolling back the target task, and obtaining a second mark value of the lock waiting queue corresponding to the target data after the rollback is completed;

[0009] If the first tag value is different from the second tag value and there is no task in the lock waiting queue corresponding to the target data, a placeholder task corresponding to the target task is added to the lock waiting queue corresponding to the target data, and the target task is retried.

[0010] In a possible embodiment of this specification, the method further includes:

[0011] If the first mark value is different from the second mark value, and there is a task in the lock waiting queue corresponding to the target data, the target task is added to the lock waiting queue corresponding to the target data.

[0012] In a possible embodiment of this specification, the method further includes:

[0013] After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0014] If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data;

[0015] If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

[0016] In a possible embodiment of this specification, the method further includes:

[0017] If the first mark value is the same as the second mark value, the target task is added to the lock waiting queue corresponding to the target data.

[0018] In a possible embodiment of this specification, the method further includes:

[0019] After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0020] If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data;

[0021] If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

[0022] In a possible embodiment of this specification, the method further includes:

[0023] Each time a task related to the target data is completed, the mark value of the lock waiting queue corresponding to the target data is incremented.

[0024] In a possible embodiment of this specification, the method further includes:

[0025] Each time a task in the lock waiting queue corresponding to the target data is retried and completed, the first task in the lock waiting queue corresponding to the target data is retried.

[0026] In a possible embodiment of this specification, the method further includes:

[0027] According to the hash value of the target data, a lock waiting queue corresponding to the target data is determined, wherein the lock waiting queue of each data is identified by the hash value of the data.

[0028] According to a second aspect of one or more embodiments of this specification, a lock waiting management device is provided, the device comprising:

[0029] A lock conflict module, configured to obtain a first mark value of a lock waiting queue corresponding to a target data if a lock conflict occurs on the target data targeted by the target task during the execution of the target task;

[0030] A rollback module, used for rolling back the target task and obtaining a second mark value of the lock waiting queue corresponding to the target data after the rollback is completed;

[0031] A retry module is used to add a placeholder task corresponding to the target task to the lock waiting queue corresponding to the target data, and retry the target task if the first tag value is different from the second tag value and there is no task in the lock waiting queue corresponding to the target data.

[0032] In a possible embodiment of the present specification, the device further includes a first lock waiting module, which is used to:

[0033] If the first mark value is different from the second mark value, and there is a task in the lock waiting queue corresponding to the target data, the target task is added to the lock waiting queue corresponding to the target data.

[0034] In a possible embodiment of the present specification, the device further includes a first lock confirmation module, which is used to:

[0035] After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0036] If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data;

[0037] If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

[0038] In a possible embodiment of the present specification, the device further includes a second lock waiting module, which is used to:

[0039] If the first mark value is the same as the second mark value, the target task is added to the lock waiting queue corresponding to the target data.

[0040] In a possible embodiment of the present specification, the device further includes a second lock confirmation module, which is used to:

[0041] After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0042] If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data;

[0043] If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

[0044] In a possible embodiment of the present specification, the device further includes an incrementing module, which is used to:

[0045] Each time a task related to the target data is completed, the mark value of the lock waiting queue corresponding to the target data is incremented.

[0046] In a possible embodiment of the present specification, the device further includes a releasing module, which is used to:

[0047] Each time a task in the lock waiting queue corresponding to the target data is retried and completed, the first task in the lock waiting queue corresponding to the target data is retried.

[0048] In a possible embodiment of the present specification, the device further includes a hash module, configured to:

[0049] According to the hash value of the target data, a lock waiting queue corresponding to the target data is determined, wherein the lock waiting queue of each data is identified by the hash value of the data.

[0050] According to a third aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.

[0051] According to a fourth aspect of one or more embodiments of this specification, an electronic device is provided, including:

[0052] processor;

[0053] a memory for storing processor-executable instructions;

[0054] The processor implements the method as described in the first aspect by running the executable instructions.

[0055] According to a fifth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0056] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0057] The lock waiting management method provided in the embodiment of the present specification, if a lock conflict occurs on the target data targeted by the target task during the execution of the target task, obtain the first mark value of the lock waiting queue corresponding to the target data; roll back the target task, and obtain the second mark value of the lock waiting queue corresponding to the target data after the rollback is completed; if the first mark value is different from the second mark value, and there is no task in the lock waiting queue corresponding to the target data, add a placeholder task corresponding to the target task to the lock waiting queue corresponding to the target data, and retry the target task. Since the mark value of the lock waiting queue corresponding to the target data will increase each time the task related to the target data is completed, the method timely and accurately judges whether the target data is released in the time interval from the occurrence of the lock conflict to the transaction rollback by whether the first mark value and the second mark value are consistent, so that when the first mark value and the second mark value are different, it is timely found that the target data has been released, and then the task with the lock conflict is retried; and when the task with the lock conflict is retried, it can be judged whether the target data is locked by other tasks after being released by whether there is a task in the lock waiting queue, and when the target data is not locked by other tasks after being released and the target task is retried, a placeholder task is added to the lock waiting queue, so that other tasks with lock conflicts will not be retried again, so as to avoid the waste of computing resources caused by the simultaneous retry of multiple tasks with lock conflicts. In summary, the method can be timely discovered by the relevant tasks when the data resources have a lock conflict and are released during the transaction rollback of the relevant tasks, and only part of the tasks in the relevant tasks (only one task in most cases) are retried, thereby ensuring the timely awakening of the data processing tasks to avoid idle data resources and avoiding the waste of computing resources caused by the simultaneous awakening and retry of multiple data processing tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 It is a structural diagram of a distributed database provided by an exemplary embodiment.

[0059] Figure 2 is a flowchart of a lock waiting management method provided by an exemplary embodiment.

[0060] Figure 3 It is a control logic diagram of a lock waiting management method provided by an exemplary embodiment.

[0061] Figure 4 It is a structural schematic diagram of a device provided by an exemplary embodiment.

[0062] Figure 5 It is a block diagram of a lock waiting management device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0063] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0064] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0065] In the related art, after a lock conflict occurs on a data resource, the related tasks will be added to the lock waiting queue corresponding to the data resource, and each task in the lock waiting queue will be woken up and retried in turn when the data resource is released. For example, after a lock conflict occurs on a data resource, the thread executing the related task will add the task to the lock waiting queue and release the thread; the thread that is executing the task for the data resource can remove and retry the first task in the lock waiting queue after completing the task and releasing the data resource.

[0066] Obviously, after a lock conflict occurs, the related tasks will roll back the transaction, and the data resources where the lock conflict occurs may be released during the transaction rollback. If the lock waiting queue corresponding to the data resource is empty when the data resource is released, the related tasks will be starved to death after performing the lock waiting queue corresponding to the data resource, that is, they will not be awakened.

[0067] Based on this, at least one embodiment of the present specification provides a lock waiting management method, which can determine in real time whether the data resource is released after a lock conflict occurs in the data resource, and immediately retry some of the related tasks, in most cases only one task, when it is released, thereby ensuring the timely awakening of the data processing task to avoid idle data resources, and avoiding the waste of computing resources caused by the simultaneous awakening and retry of multiple data processing tasks.

[0068] This method can be applied to database management systems, such as Figure 1 The management system run by each database instance in the distributed database based on the LSM-Tree storage engine is shown.

[0069] Please refer to the attached Figure 2, which exemplarily shows the process of the lock waiting management method, including steps S201 to S203.

[0070] In step S201, if a lock conflict occurs on target data targeted by the target task during execution of the target task, a first mark value of a lock waiting queue corresponding to the target data is obtained.

[0071] The target task may be a SQL (Structured Query Language) request.

[0072] Among them, after generating or receiving the target task, the database instance executing the method will allocate an execution thread to the target task; the thread will execute the target task, and during the execution process, it is necessary to lock part or all of the data targeted by it. The locking process can be in the form of unified locking or sequential locking. If a lock conflict is found when locking a certain data, for example, the data has been locked by a thread executing other tasks, then the first mark value of the lock waiting queue corresponding to the data is obtained. It should be understood that the data with the lock conflict mentioned above can be called target data to distinguish it from the data resources targeted by the target task that do not have a lock conflict. For convenience, when describing the operation of the thread executing each task below, the thread will be omitted and the task execution operation will be directly described; it should be understood that this description should be considered as the operation performed by the thread executing the task.

[0073] For example, the lock waiting queue of each data is identified by the hash value of the data. When obtaining the first tag value of the lock waiting queue corresponding to the target data, the lock waiting queue corresponding to the target data can be determined first according to the hash value of the target data.

[0074] For example, the tag value (data sequence number, seq) of the lock waiting queue is used to mark each release of the data resource corresponding to the lock waiting queue. Taking the target data as an example, each time a task related to the target data is completed, the tag value of the lock waiting queue corresponding to the target data is incremented, for example, by 1. Therefore, it is possible to determine whether a data resource is released by the tag value of the lock waiting queue of a data resource. If the lock waiting queue changes, it means that the data resource is released.

[0075] The tag value of the lock waiting queue provides a way to determine whether the data resource is released. The first tag value, the second tag value, the third tag value, etc. in this specification are used to distinguish the tag values ​​of the lock waiting queue corresponding to the target data obtained at different times. There is no necessary relationship between their values, and they may be the same or different.

[0076] Exemplarily, each time a task in the lock waiting queue corresponding to the target data is removed and retried and completed, the first task in the lock waiting queue corresponding to the target data, that is, the next task after the completed task, is retried.

[0077] In step S201, the target task is rolled back, and after the rollback is completed, a second mark value of the lock waiting queue corresponding to the target data is obtained.

[0078] It should be understood that the target task may be part or all of the data resources targeted by the target task. If it is part or all of the data resources targeted by the target task, the target task may have been executed on some of the data resources. Therefore, it is necessary to roll back the transaction for this part of the progress of the target task to ensure data consistency.

[0079] In step S203, if the first tag value is different from the second tag value and there is no task in the lock waiting queue corresponding to the target data, a placeholder task corresponding to the target task is added to the lock waiting queue corresponding to the target data, and the target task is retried.

[0080] If the first mark value and the second mark value are different, it means that the target data has been released at least once during the period from the occurrence of the lock conflict to the transaction rollback. At this time, the target data may be in a released state, or is likely to be in a released state.

[0081] If there is no task in the lock waiting queue corresponding to the target data, it may be that there is no task in the lock waiting queue when the target data is released. In this case, the target data may be in a released state. To avoid the target data being idle, the relevant tasks need to be retried immediately. In order to avoid multiple related tasks that have lock conflicts being retried, resulting in a waste of computing resources and further lock conflicts, each related task can determine whether there is a related task to be retried before retrying. If there is no related task to be retried, it will retry itself. If there is a related task to be retried, it will be added to the lock waiting queue to wait for wake-up.

[0082] Therefore, for the target task, if the first tag value is different from the second tag value, and there is no task in the lock waiting queue corresponding to the target data, a placeholder task corresponding to the target task is added to the lock waiting queue corresponding to the target data, and the target task is retried.

[0083] The placeholder task is not the target task itself, but is used to occupy the head of the queue in the lock waiting queue, so as to notify other tasks that enter the lock waiting queue later that there is a task to retry. When the target task retry is completed and the target data is released, the placeholder task of the target task in the lock waiting queue will be deleted at the same time, and the next task will be awakened to retry. For example, the target task can be added to the lock waiting queue after the mark "is placeholder = true".

[0084] It should be noted that if the target data is released at least once during the period from the occurrence of a lock conflict to the transaction rollback, and when the transaction rollback is completed, a task originally in the lock waiting queue has locked and occupied it, and the task that locked and occupied the target data is the last task in the lock waiting queue, the target task will be retried because there is no task in the lock waiting queue and its placeholder task will be added to the lock waiting queue. At this time, if a lock conflict occurs again when the target task is retried, it will enter the lock waiting queue to replace its placeholder task and actually enter the lock waiting queue to wait for the task that locked and occupied the target data to release the target data and wake up and retry.

[0085] Therefore, for the target task, if the first tag value is different from the second tag value, and there is a task in the lock waiting queue corresponding to the target data, the target task is added to the lock waiting queue corresponding to the target data. For example, the target task can be added to the lock waiting queue after the tag "is placeholder = false".

[0086] Since it takes a certain amount of time to add the target task to the lock waiting queue corresponding to the target data, the target data may have been released in the time interval before and after the target task is added to the lock waiting queue corresponding to the target data. If there is a task (real task or placeholder task) in the lock waiting queue corresponding to the target data when released, the existing task can be retried to lock the target data. If there is no task in the lock waiting queue corresponding to the target data when released, the target data is idle, and the target data is not released after the target task is added to the lock waiting queue corresponding to the target data, so that the target task is starved to death after being added to the lock waiting queue, and other subsequent tasks are also starved to death, because the task in the lock waiting queue will only be awakened when the previous task releases the target data. For example, a lock conflict occurs between the target task and another task on the target data. The target task is retried because the first tag value and the second tag value are different and there is no task in the lock waiting queue, and its placeholder task is added to the head of the lock waiting queue. The other task is added to the lock waiting queue because there is a task in the waiting queue (i.e., the placeholder task of the target task). If the target task completes the retry and releases the target data during the process of adding the other task to the lock waiting queue, and the target task is found to not exist when waking up the next task in the lock waiting queue, the waking up is abandoned, and the other task will not be woken up again after being added to the lock waiting queue, and will be starved to death.

[0087] Based on the above problems, preferably, it is possible to determine whether the target data is released in the time interval before and after the target task enters the lock waiting queue in the following manner, and keep it in the lock waiting queue if it is not released, and retry it when it is released to avoid being starved and unable to wake up due to the problems mentioned in the above scenario. The specific steps are as follows:

[0088] First, after adding the target task to the lock waiting queue corresponding to the target data, a third mark value of the lock waiting queue corresponding to the target data is obtained.

[0089] Next, if the third tag value is the same as the second tag value, the target task is kept in the lock waiting queue corresponding to the target data; if the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and the target task is retried.

[0090] In this embodiment, since the mark value of the lock waiting queue corresponding to the target data will increase each time a task related to the target data is completed, the method can timely and accurately determine whether the target data is released within the time interval from the occurrence of the lock conflict to the rollback of the transaction by determining whether the first mark value and the second mark value are consistent, so that when the first mark value and the second mark value are different, it can be discovered in time that the target data has been released, and then the task that has caused the lock conflict can be retried to reduce the long-tail problem during the lock conflict; when retrying the task that has caused the lock conflict, it can be determined whether the target data is locked by other tasks after being released by determining whether there is a task in the lock waiting queue, and when the target data is not locked by other tasks after being released and the target task is retried, a placeholder task can be added to the lock waiting queue, so that other tasks that have caused the lock conflict will not be retried again, so as to avoid the waste of computing resources (such as CPU jitter) caused by the simultaneous retry of multiple tasks that have caused the lock conflict. In summary, this method can be discovered in time by related tasks when a lock conflict occurs in data resources and is released during the transaction rollback process of the related tasks, and only part of the related tasks (only one task in most cases) are retried, thereby ensuring the timely awakening of data processing tasks to avoid idle data resources and avoiding the waste of computing resources caused by the simultaneous awakening and retry of multiple data processing tasks.

[0091] Moreover, this method can also solve the technical problem that the data resources causing the lock conflict are released during the transaction rollback process, and the lock waiting queue corresponding to the data resource is empty when the data resource is released, which causes the related tasks causing the lock conflict to be starved to death and unable to be awakened. That is, the related tasks causing the lock conflict will not be starved to death and unable to be awakened in the above scenario.

[0092] In some embodiments of the present disclosure, if the first mark value is the same as the second mark value, the target task is added to a lock waiting queue corresponding to the target data.

[0093] Among them, if the first tag value is consistent with the second tag value, it can be explained that the target task has not been released during the time interval from the occurrence of the lock conflict to the transaction rollback, that is, the target data is still occupied by the task that locked it when the lock conflict occurred. Therefore, the target task can be added to the lock waiting queue corresponding to the target data.

[0094] Since it takes a certain amount of time to add the target task to the lock waiting queue corresponding to the target data, the target data may have been released in the time interval before and after the target task is added to the lock waiting queue corresponding to the target data. If there is a task in the lock waiting queue corresponding to the target data when releasing, the existing task can retry to lock the target data. If there is no task in the lock waiting queue corresponding to the target data when releasing, the target data is idle. However, the target data is not released after the target task is added to the lock waiting queue corresponding to the target data, so that the target task is starved to death after being added to the lock waiting queue, and other subsequent tasks are also starved to death, because only when the previous task releases the target data will the task in the lock waiting queue be awakened. For example, the target task has a lock conflict on the target data, and the target task is added to the lock waiting queue because the first tag value and the second tag value are the same; if the task that previously locked the target data releases the target data during the process of adding the target task to the lock waiting queue, when waking up the next task in the lock waiting queue, it is found that there is no task and the awakening is abandoned. After the target task is added to the lock waiting queue, it will not be awakened again and will be starved to death.

[0095] Based on this problem, preferably, it is possible to determine whether the target data is released in the time interval before and after the target task enters the lock waiting queue in the following manner, and keep it in the lock waiting queue if it is not released, and retry it when it is released to avoid being starved and unable to wake up due to the problems mentioned in the above scenario. The specific steps are as follows:

[0096] First, after adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0097] Next, if the third tag value is the same as the second tag value, the target task is kept in the lock waiting queue corresponding to the target data; if the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and the target task is retried.

[0098] This embodiment adds the target task to the lock waiting queue when the first tag value and the second tag value are the same, and determines whether the target data is released in the process by whether the second tag value and the third tag value are consistent before and after the target task is added to the lock waiting queue. If released, the target task is retried, thereby avoiding the problem that the target data is released in the process and the lock waiting queue has no task when the target task is not added successfully, resulting in the target task being unable to wake up and being starved to death. This further improves the utilization rate of data resources and further reduces the delay of data processing tasks.

[0099] Please refer to the attached Figure 3 , which shows the control logic of the lock waiting management method obtained by combining the above embodiments. Figure 3 For a more vivid and specific understanding of the complete lock waiting management process provided in this specification, the details of the process have been introduced in detail in the above embodiments and will not be repeated here.

[0100] Figure 4 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 4 At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a non-volatile memory 410, and may also include hardware required for other tasks. One or more embodiments of this specification may be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0101] Please refer to Figure 5 The lock waiting management device can be applied to Figure 4 The device shown in the figure can realize the technical solution of this specification. The lock waiting management device can include:

[0102] A lock conflict module 501 is used to obtain a first mark value of a lock waiting queue corresponding to the target data if a lock conflict occurs on the target data targeted by the target task during the execution of the target task;

[0103] A rollback module 502 is used to roll back the target task and obtain a second mark value of the lock waiting queue corresponding to the target data after the rollback is completed;

[0104] The retry module 503 is used to add a placeholder task corresponding to the target task to the lock waiting queue corresponding to the target data, and retry the target task if the first tag value is different from the second tag value and there is no task in the lock waiting queue corresponding to the target data.

[0105] In a possible embodiment of the present specification, the device further includes a first lock waiting module, which is used to:

[0106] If the first mark value is different from the second mark value, and there is a task in the lock waiting queue corresponding to the target data, the target task is added to the lock waiting queue corresponding to the target data.

[0107] In a possible embodiment of the present specification, the device further includes a first lock confirmation module, which is used to:

[0108] After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0109] If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data;

[0110] If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

[0111] In a possible embodiment of the present specification, the device further includes a second lock waiting module, which is used to:

[0112] If the first mark value is the same as the second mark value, the target task is added to the lock waiting queue corresponding to the target data.

[0113] In a possible embodiment of the present specification, the device further includes a second lock confirmation module, which is used to:

[0114] After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data;

[0115] If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data;

[0116] If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

[0117] In a possible embodiment of the present specification, the device further includes an incrementing module, which is used to:

[0118] Each time a task related to the target data is completed, the mark value of the lock waiting queue corresponding to the target data is incremented.

[0119] In a possible embodiment of the present specification, the device further includes a releasing module, which is used to:

[0120] Each time a task in the lock waiting queue corresponding to the target data is retried and completed, the first task in the lock waiting queue corresponding to the target data is retried.

[0121] In a possible embodiment of the present specification, the device further includes a hash module, configured to:

[0122] According to the hash value of the target data, a lock waiting queue corresponding to the target data is determined, wherein the lock waiting queue of each data is identified by the hash value of the data.

[0123] One or more embodiments of the present specification also provide a computer program product, including a computer program / instruction, which implements the steps of the method provided in any of the above embodiments when executed by a processor.

[0124] One or more embodiments of the present specification further provide a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method provided in any of the above embodiments.

[0125] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0126] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0127] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0128] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0129] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0130] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0131] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0132] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0133] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0134] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A lock waiting management method, the method comprising: If a lock conflict occurs on the target data targeted by the target task during the execution of the target task, obtaining a first mark value of the lock waiting queue corresponding to the target data; Rolling back the target task, and obtaining a second mark value of the lock waiting queue corresponding to the target data after the rollback is completed; If the first tag value is different from the second tag value and there is no task in the lock waiting queue corresponding to the target data, a placeholder task corresponding to the target task is added to the lock waiting queue corresponding to the target data, and the target task is retried.

2. The lock waiting management method according to claim 1, further comprising: If the first mark value is different from the second mark value, and there is a task in the lock waiting queue corresponding to the target data, the target task is added to the lock waiting queue corresponding to the target data.

3. The lock waiting management method according to claim 2, further comprising: After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data; If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data; If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

4. The lock waiting management method according to claim 1, further comprising: If the first mark value is the same as the second mark value, the target task is added to the lock waiting queue corresponding to the target data.

5. The lock waiting management method according to claim 4, further comprising: After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data; If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data; If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

6. The lock waiting management method according to claim 1, further comprising: Each time a task related to the target data is completed, the mark value of the lock waiting queue corresponding to the target data is incremented.

7. The lock waiting management method according to claim 1, further comprising: Each time a task in the lock waiting queue corresponding to the target data is retried and completed, the first task in the lock waiting queue corresponding to the target data is retried.

8. The lock waiting management method according to claim 1, further comprising: According to the hash value of the target data, a lock waiting queue corresponding to the target data is determined, wherein the lock waiting queue of each data is identified by the hash value of the data.

9. A lock waiting management device, the device comprising: A lock conflict module, configured to obtain a first mark value of a lock waiting queue corresponding to a target data if a lock conflict occurs on the target data targeted by the target task during the execution of the target task; A rollback module, used for rolling back the target task and obtaining a second mark value of the lock waiting queue corresponding to the target data after the rollback is completed; A retry module is used to add a placeholder task corresponding to the target task to the lock waiting queue corresponding to the target data, and retry the target task if the first tag value is different from the second tag value and there is no task in the lock waiting queue corresponding to the target data.

10. The lock waiting management device according to claim 1, further comprising a first lock waiting module, configured to: If the first mark value is different from the second mark value, and there is a task in the lock waiting queue corresponding to the target data, the target task is added to the lock waiting queue corresponding to the target data.

11. The lock waiting management method according to claim 10, wherein the device further comprises a first lock confirmation module, configured to: After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data; If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data; If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

12. The lock waiting management device according to claim 9, further comprising a second lock waiting module, configured to: If the first mark value is the same as the second mark value, the target task is added to the lock waiting queue corresponding to the target data.

13. The lock waiting management device according to claim 12, further comprising a second lock confirmation module, configured to: After adding the target task to the lock waiting queue corresponding to the target data, obtaining a third mark value of the lock waiting queue corresponding to the target data; If the third mark value is the same as the second mark value, keeping the target task in the lock waiting queue corresponding to the target data; If the third tag value is different from the second tag value, and the target task is the first task in the lock waiting queue corresponding to the target data, the target task is deleted from the lock waiting queue corresponding to the target data and is retried.

14. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 8.

15. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 8 by running the executable instructions.

16. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 8.