Data processing method, device, electronic device and storage medium

By setting counters for multi-level data in the database and processing data only under specific conditions, the dirty data problem is solved and the data processing efficiency and business system throughput are improved.

CN113342539BActive Publication Date: 2024-10-25BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202110605117.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-31
Publication Date
2024-10-25
Estimated Expiration
2041-05-31

AI Technical Summary

Technical Problem

In the database, the operation of multi-level data may lead to dirty data and affect the stability of the business system. The existing technology uses distributed locks to solve this problem, but it reduces the data processing efficiency and affects the throughput.

Method used

By setting a counter for data with a higher logical level, the data is only processed when the current value of the counter is equal to the initial value, avoiding the simultaneous processing of data at different levels, thus avoiding the generation of dirty data and improving data processing efficiency.

Benefits of technology

It effectively avoids the generation of dirty data, improves the data processing efficiency of the database, and improves the throughput of the business system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113342539B_ABST
    Figure CN113342539B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data processing method, device, electronic device and storage medium. The method comprises: receiving any first processing request for first data, wherein data information of the first data indicates that the logical level of the first data is lower than the logical level of second data; when the second data is not set with an exclusive lock, increasing the current value of the counter of the second data by a preset value according to any first processing request; processing the first data in response to any first processing request, and after the processing is completed, reducing the current value of the counter by the preset value, wherein when the current value of the counter is equal to the preset count initial value, the second data can be processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data management, and in particular to a data processing method, device, electronic device and storage medium. Background Art

[0002] For the data stored in the database, operations such as adding, deleting, and modifying can usually be performed. Taking multi-level data corresponding to multiple business levels as an example, threads corresponding to different levels performing the above operations on the data of the corresponding level may generate dirty data, thereby affecting the stability of the business system. For example, the database can store business data in a hierarchical order from high to low, such as project-task group-task-subtask. If a high-level thread A (such as a project thread) is deleting a task group data (the relevant data of the task group, the same below), and a low-level thread B (such as an internal thread of the task group) is creating a task in the task group, then after thread B successfully creates the task, it may not be able to query the task group where the newly created task is located, because the task group has been deleted by thread A, causing the task data of the newly created task to become dirty data.

[0003] To address this problem, the related technology uses distributed locks to solve it. For example, low-level thread B adds an exclusive lock to the project data corresponding to the task creation operation, thereby excluding other threads from operating on the project data during the time period when low-level thread B creates the task, so as to avoid generating dirty data. However, if the same implementation also has low-level threads C, D, etc. requesting to operate multiple project data in the same project group, then due to the existence of the above-mentioned exclusive lock, other low-level threads can only wait for the low-level thread B to complete the operation before they can operate in sequence, which reduces the data processing efficiency of the database and greatly affects the throughput of the business system. Summary of the invention

[0004] The present disclosure provides a data processing method, device, electronic device and storage medium to at least solve the technical problems in the related art. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a data processing method is provided, comprising:

[0006] receiving any first processing request for first data, wherein data information of the first data indicates that a logical level of the first data is lower than a logical level of second data;

[0007] In the case where the exclusive lock is not set for the second data, increasing a current value of a counter of the second data by a preset value according to any one of the first processing requests;

[0008] The first data is processed in response to any of the first processing requests, and after the processing is completed, the preset value is reduced for the current value of the counter, wherein the second data can be processed when the current value of the counter is equal to the preset count initial value.

[0009] Optionally, also include:

[0010] In the case where the second data is set with an exclusive lock, terminating the response process for any of the first processing requests; or,

[0011] In the case where the second data is set with an exclusive lock, wait for a first period of time and then recheck whether the second data is set with an exclusive lock. If the second data is still set with an exclusive lock when the number of checks on the exclusive lock reaches the first number, the response process for any first processing request is terminated.

[0012] Optionally, also include:

[0013] setting exclusive locks for the first data and the second data in case of receiving a second processing request for the second data;

[0014] If the current value of the counter is equal to the initial count value, processing the second data in response to the second processing request;

[0015] If the current value of the counter is greater than the initial count value, then terminating the response to the second processing request, or waiting until the current value of the counter is equal to the initial count value, and then processing the second data in response to the second processing request;

[0016] After processing of the second data is completed, the exclusive locks set for the first data and the second data are released.

[0017] Optionally, also include:

[0018] After terminating the response process for any request, a response failure message for any request is returned to the initiator of the any request.

[0019] Optionally, also include:

[0020] In a case where the current value of the counter is greater than the initial count value, if the multiple first processing requests corresponding to the current value are respectively used to request processing of multiple first data, then processing the multiple first data respectively in response to the multiple first processing requests;

[0021] If the multiple first processing requests corresponding to the current value are used to request processing of the same first data, the first data is processed in response to the multiple first processing requests in sequence according to the order in which the multiple first processing requests are received.

[0022] Optionally, the initial count value is 0 and the preset value is 1.

[0023] Optionally, the processing of any data includes at least one of the following:

[0024] Insert new data, delete existing data, and modify existing data.

[0025] According to a second aspect of an embodiment of the present disclosure, a data processing device is provided, including:

[0026] a request receiving module, configured to receive any first processing request for first data, wherein data information of the first data indicates that a logical level of the first data is lower than a logical level of second data;

[0027] a value increasing module, configured to increase a current value of a counter of the second data by a preset value according to any one of the first processing requests when the second data is not set with an exclusive lock;

[0028] The numerical reduction module is configured to process the first data in response to any of the first processing requests, and after the processing is completed, reduce the preset numerical value for the current value of the counter, wherein the second data can be processed when the current value of the counter is equal to the preset count initial value.

[0029] Optionally, also include:

[0030] a first termination module, configured to terminate the response process for any first processing request when the second data is set with an exclusive lock; or

[0031] The second termination module is configured to, when the second data is set with an exclusive lock, wait for a first period of time and then recheck whether the second data is set with an exclusive lock; if the second data is still set with an exclusive lock when the number of checks on the exclusive lock reaches a first number, terminate the response process for any of the first processing requests.

[0032] Optionally, also include:

[0033] an exclusive lock setting module, configured to set an exclusive lock for the first data and the second data in case of receiving a second processing request for the second data;

[0034] a first processing module, configured to process the second data in response to the second processing request if the current value of the counter is equal to the initial count value;

[0035] a second processing module configured to terminate responding to the second processing request if the current value of the counter is greater than the initial count value, or wait until the current value of the counter is equal to the initial count value, and then process the second data in response to the second processing request;

[0036] The exclusive lock releasing module is configured to release the exclusive locks set for the first data and the second data after processing the second data is completed.

[0037] Optionally, also include:

[0038] The message returning module is configured to return a response failure message for any request to the initiator of any request after terminating the response process for any request.

[0039] Optionally, also include:

[0040] a separate processing module, configured to, when the current value of the counter is greater than the initial count value, respectively process the multiple first data in response to the multiple first processing requests if the multiple first processing requests corresponding to the current value are respectively used to request processing of multiple first data;

[0041] The sequential processing module is configured to process the first data in response to the multiple first processing requests in sequence according to the order in which the multiple first processing requests are received if the multiple first processing requests corresponding to the current value are used to request processing of the same first data.

[0042] Optionally, the initial count value is 0 and the preset value is 1.

[0043] Optionally, the processing of any data includes at least one of the following:

[0044] Insert new data, delete existing data, and modify existing data.

[0045] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including:

[0046] processor;

[0047] a memory for storing instructions executable by the processor;

[0048] The processor is configured to execute the instructions to implement the data processing method as described in any embodiment of the first aspect above.

[0049] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is proposed. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the data processing method described in any embodiment of the first aspect above.

[0050] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is proposed, comprising a computer program and / or instructions, wherein when the computer program and / or instructions are executed by a processor, the data processing method described in any one of the embodiments of the first aspect is implemented.

[0051] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0052] According to an embodiment of the present disclosure, any first processing request for first data whose logical level is lower than that of second data is received, and when no exclusive lock is set for the second data, a preset value is added to the current value of the counter of the second data according to the first processing request, and then the first data is processed in response to the request, and after the processing is completed, the current value of the above-mentioned counter is reduced by the above-mentioned preset value, wherein when the current value of the counter is equal to the preset count initial value, the above-mentioned second data can be processed.

[0053] It can be seen that by setting a counter for the second data with a higher logical level, and processing the second data only when the current value of the counter is equal to the preset count initial value, the first data and the first data will not be processed at the same time, thereby effectively avoiding the generation of dirty data. It is understandable that there may be multiple first data with a lower logical level under the second data with a higher logical level, and multiple first processing requests for the first data under the same second data may be received in a short time. Therefore, multiple first data under the same second data can be processed at the same time, thereby effectively improving the data processing efficiency of the database, and thus contributing to the throughput of the business system corresponding to the database. In addition, because a preset value will be added to the counter of the second data when any first request is received, as long as there is a first processing request that has not been responded to, the current value of the counter of the second data will not be equal to the preset count initial value, and the second processing request will not be responded to, so the first data corresponding to each first request will not generate dirty data.

[0054] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0056] Figure 1 is a schematic diagram of a multi-level architecture provided by an exemplary embodiment;

[0057] Figure 2is a flow chart of a data processing method according to an embodiment of the present disclosure;

[0058] Figure 3 is a flow chart of a method for processing first data in a multi-level architecture according to an embodiment of the present disclosure;

[0059] Figure 4 is a flow chart of a method for processing second data in a multi-level architecture according to an embodiment of the present disclosure;

[0060] Figure 5 is an interactive flow chart of a data processing method according to an embodiment of the present disclosure;

[0061] Figure 6 is a schematic block diagram of a data processing device according to an embodiment of the present disclosure;

[0062] Figure 7 is a schematic block diagram of another data processing device according to an embodiment of the present disclosure;

[0063] Figure 8 is a structural diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0064] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0065] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0066] For the data stored in the database, operations such as adding, deleting, and modifying can usually be performed. Taking multi-level data corresponding to multiple business levels as an example, threads corresponding to different levels performing the above operations on the data of the corresponding level may generate dirty data, thereby affecting the stability of the business system. For example, the database can store business data at the level of project-task group-task-subtask. If high-level thread A is deleting the task group data while low-level thread B is creating a task in the task group, it may cause thread B to successfully create the task but fail to query the task group where the newly created task is located, because in fact the task group has been deleted by thread A, which will have an adverse impact on the stability of the business system.

[0067] To address this problem, the related technology uses distributed locks to solve it. For example, low-level thread B adds an exclusive lock to the project data corresponding to the task creation operation, thereby excluding other threads from operating on the project data during the time period when low-level thread B creates the task, to avoid generating dirty data. However, if the same implementation also has low-level threads C, D, etc. requesting to operate multiple project data in the same project group, then due to the existence of the above-mentioned exclusive lock, other low-level threads can only wait for the low-level thread B operation to complete before they can operate in sequence, which reduces the data processing efficiency of the database and greatly affects the throughput of the business system.

[0068] To this end, the present disclosure proposes a data processing method, which sets a counter for the second data with a higher logical level, and processes the second data only when the current value of the counter is equal to the preset count initial value, so that the first data and the first data will not be processed at the same time, thereby effectively avoiding the generation of dirty data. It is understandable that there may be multiple first data with a lower logical level under the second data with a higher logical level, and multiple first processing requests for the first data under the same second data may be received in a short time. Therefore, multiple first data under the same second data can be processed at the same time, thereby effectively improving the data processing efficiency of the database, and then contributing to the throughput of the business system corresponding to the database.

[0069] Figure 1This is a schematic diagram of a multi-level architecture provided by an exemplary embodiment, in which multiple logical levels such as level 1, level 2, and level 3 may be included. The height of the logical level is relative, for example, level 2 is a low level relative to level 1, and a high level relative to level 3; level 1 and level 2 are both high levels relative to level 3; level 2 and level 3 are both low levels relative to level 1. For the sake of simplicity, the "level" in the following text represents the "logical level", the "high level" represents the "relatively high logical level", and the "low level" represents the "relatively low logical level", which is hereby explained. Any high-level object located in a high-level may include several low-level objects located in a low-level. For example, project 1 located in level 1 may include task group M1, task group M2 and task group M3 located in level 2; similarly, task group M1 may include task M11 and task M12 located in level 3, task group M2 may include task M21 located in level 3, task group M3 may include task M31 and task M32 located in level 3, and so on. The details will not be repeated here.

[0070] In the above multi-level architecture, the object data of each object such as a project, a project group, a task group, etc. can also be stored in the database according to the position of each object in the architecture (i.e., the logical relationship between the object and other objects). For example, the project ID of project P1 and the task group ID of task group M1 can be recorded in the index information (such as Key value) of the project group data of task group M1, wherein the above project ID or task group ID can be in the form of number, name, project file address, etc., and the present disclosure does not limit this. The object data of any object can include the object name, member information, user data, operation log, etc. of the object.

[0071] Corresponding to the hierarchical relationship between objects, object data also has a corresponding hierarchical relationship. For example, the task group data of task group M1 is low-level data relative to the project data of project P1, and is high-level data relative to the task data of task M11 and task M12; the task group data of task group M1 and the task data of task M11 and task M12 are low-level data relative to the project data of project P1; the project data of project P1 and the task group data of task group M1 are high-level data relative to the task data of task M11 and task M12, which will not be described one by one. It can be seen that the hierarchical relationship between each object data corresponds one-to-one to the logical relationship between each object in the multi-level architecture, that is, the logical relationship between any two objects is the same as the logical relationship between their object data.

[0072] In addition to storing the object data of each object, the database can also store the location information of each object in the corresponding multi-level architecture, or the structural information of each object data in the multi-level data structure (corresponding to the multi-level architecture). The location information or structural information can be used to characterize the relative position relationship of each object in the multi-level architecture, and further can be used to characterize the relative position relationship of the object data of each object in the multi-level data structure. Figure 1 Taking the multi-level architecture shown in FIG. 1 as an example, the database can store the location information of each task group under project P1 and each task under each task group. For example, the location information can be a graph drawn according to a graph data structure, or, because Figure 1 The multi-level architecture shown is similar to a tree structure, so the routing information of the tree structure can also be stored in the database. The specific form can be found in the records of the following embodiments, which will not be described here.

[0073] It should be noted that the above-mentioned structural information can be saved separately or centrally: for example, the object data and structural information of any object can be saved in the storage space corresponding to the object; or in order to improve data query efficiency, the object data of each object can be saved in different storage spaces respectively, and the structural information of each object (in the form of a list, etc.) can be centrally saved in a certain storage space, so that the position of any object data in the multi-level data structure can be quickly queried through the centrally saved structural information, thereby improving data query speed.

[0074] In addition, the above-mentioned database can be a relational database (Structured Query Language, SQL) such as MySQL, SqlServe, Oracler, or a non-relational database (Notonly SQL, NoSQL) such as Cassandra, MongoDB, CouchDB, etc., and the present disclosure does not limit this.

[0075] It should be noted that the above-mentioned hierarchical relationship only represents the logical relationship between various objects or object data, and when the object data of any object is actually saved in the database, it can be saved in multiple dimensions such as table, column, field, row, etc. Correspondingly, in the processing operation process of any object data (low-level data or high-level data) involved in the disclosed scheme, the object data is processed according to the logical hierarchy, and the actual storage method of the object data in the database is not concerned. In other words, this scheme focuses on the processing of object data at the logical level, and does not limit the specific operations of the database during the processing of object data.

[0076] Figure 2FIG. 1 is a flow chart of a data processing method according to an embodiment of the present disclosure. Figure 2 As shown, the method is applied to a server. The embodiment of the present disclosure is described by taking the server as a database as an example, and may include the following steps 202-204.

[0077] Step 202: receiving any first processing request for first data, wherein data information of the first data indicates that a logical level of the first data is lower than a logical level of second data.

[0078] The data information of the first data indicates that the logical level of the first data is lower than that of the second data, that is, the first data is located at a lower level than the logical level of the second data, that is, the second data includes the first data. That is, the first data is equivalent to the aforementioned low-level data, and the second data is equivalent to the aforementioned high-level data. Of course, the same second data may include multiple second data, and this solution only focuses on any first processing request initiated for any of the first data. For example, corresponding to Figure 1 At the logical level, the project data of project P1 may include three task group data (i.e., task group data 1, task group data M2, and task group data M3) corresponding to the three task groups (i.e., task group M1, task group M2, and task group M3), and the "any first processing request" described in this solution is a processing request initiated for any of the task group data. A processing request for any data in the database may be initiated by an operator who has operation authority over the data, such as a database administrator or a database user. Of course, in order to ensure the legitimacy of operations on the data, after receiving any processing request, the database may first verify the legitimacy of the processing request based on the operation authority, operation type, etc., and respond to the request only if the verification passes.

[0079] In addition, the data information of the first data may include structural information of the first data in a multi-level data structure, for example, in a multi-level data structure similar to Figure 1 In the case of the tree structure shown in FIG. 1 , the structure information may be routing information corresponding to the tree structure. Figure 1 The routing information of the corresponding task data M12 can be "P1 / M1 / M12", which means that the task data M12 is under the task group data M1, and the logical level of M12 is lower than the logical level of M1, and the task group data M1 is under the project data P1, and the logical level of M1 is lower than the logical level of P1. Other data are similar and will not be repeated here.

[0080] The exclusive lock (or X lock, write lock) involved in the disclosed solution is similar to the exclusive lock in the related art, that is, when an exclusive lock is set for high-level data according to a second processing request issued by a thread A, any request (read request or write request) for the high-level data issued by other threads will not be effectively responded to, thereby ensuring that the thread A has exclusive processing rights for the high-level data. In other words, when any data is set with an exclusive lock by the database in response to any processing request, the database cannot process the data and the lower-level data under the data in response to other requests.

[0081] Therefore, in this embodiment, after receiving any first processing request for the first data, the database can first determine whether the second data where the first data is located has been set with an exclusive lock, and then perform corresponding processing according to the determination result: if the second data has not been set with an exclusive lock, it can proceed to step 204 for processing, which will not be described in detail here. Otherwise, if the second data has been set with an exclusive lock, the database can terminate the response process for the first processing request, so that if the request cannot be responded to in a timely and effective manner, it can return a failure result to the initiator as soon as possible to avoid the initiator waiting for a long time.

[0082] However, for the initiator of the first processing request, it usually hopes that the processing of the first data can be successfully completed in the data (that is, it hopes that the first processing request is effectively responded to) to obtain the processing result. Therefore, in order to achieve an effective response to the first processing request as much as possible, the database can recheck whether the second data is set with an exclusive lock after waiting for a first period of time when the second data is set with an exclusive lock: if it is found that the exclusive lock of the second data has been released during the recheck, the first data can be processed accordingly in response to the first processing request. Of course, the above recheck can be repeated multiple times, that is, the first data is checked once every first period of time. In order to fully ensure that the first processing request is effectively responded to, the database can repeat the above check until the exclusive lock of the second data is released. However, multiple checks over a long period of time may cause the initiator to wait for a long time, and even in the case of a database failure, the above check may fall into an infinite loop and waste the initiator's waiting time in vain. To this end, the first number can be set in advance (i.e., the upper limit of the number of checks for the exclusive lock of the second data is set), so that when the number of checks for the exclusive lock reaches the first number, if the second data is still set with an exclusive lock, the response process for any first processing request is terminated to avoid the initiator's waiting time being too long, which also helps to improve the request response efficiency of the database. In the practice of the solution, the above-mentioned first duration and the first number can be set according to database performance, current load, request type of the first processing request, etc., such as setting the first duration to 5ms, 100ms, 30ms, etc., and setting the first number to 2 times, 10 times, 5 times, etc., and the embodiment of the present disclosure does not limit this.

[0083] Step 204: if the exclusive lock is not set for the second data, increase the current value of the counter of the second data by a preset value according to any one of the first processing requests.

[0084] In this embodiment, any second data in the database may be provided with a counter, the count value of which corresponds to the number of processing requests for the first data under the second data being processed by the database. The current value of the counter at any moment is used to characterize the number of first processing requests (initiated for the first data under the second data) that the database has received but has not yet responded to. It can be understood that because the "high" and "low" of the data levels of the first data and the second data are relative, any data in the multi-level data structure may be the first data or the second data. Still with Figure 1Taking the multi-level architecture shown as an example, if the database receives a processing request for task group data M1, the data is the first data, and the project data P1 is the second data. At this time, a counter can be set for the project data P1; if the database receives a processing request for task data M11, the data is the first data, and the task group data M1 is the second data. At this time, a counter can be set for the task group data M1. It can be seen that because any data in the multi-level data structure (except the lowest level data) may be the second data, the database can set a counter for any data according to the received first request, so the counter can be flexibly set according to the first request, and then an exclusive lock can be set for each second data, so as to facilitate meeting the diverse data processing needs. It can be seen that any second data in the database can be set with the above counter to record the first processing request that has not yet been responded to for each second data. Because the first processing request involved in this scheme is a processing request initiated by the initiator of the request for the first data under the second data, for the purpose of describing the introduction, any first processing request received by the database below represents the processing request initiated by the database for the first data under the second data.

[0085] The counter of the second data can be pre-set with an initial counting value. After receiving the first first processing request, the database can increase the preset value for the counter based on the initial counting value. Thereafter, each time a first processing request is received, the preset value is increased for the current value of the counter; and each time the response process to a first processing request is completed (that is, the processing of the first data according to the first processing request completes or terminates the response process to the first processing request), the current value of the counter is reduced by the above-mentioned preset value to ensure that the current value of the counter corresponds to the number of first processing requests.

[0086] In one embodiment, the initial count value of the counter of the second processing request may be any value, such as 0, and the corresponding preset value may be any positive number, such as 1, 2, 3, etc., so that the counter value is increased or decreased according to the number of the first processing requests starting from 0. Taking the preset value of 1 as an example, when the first processing request is received, the current value of the counter is increased by 1; after the processing operation of the first processing request is completed, the current value of the counter is decreased by 1. At this time, the current value of the counter at any time is the number of first processing requests for the first data under the second data that the database has received but has not yet responded to.

[0087] Step 206, processing the first data in response to any of the first processing requests, and after the processing is completed, reducing the current value of the counter by the preset value, wherein the second data can be processed when the current value of the counter is equal to the preset count initial value.

[0088] In this embodiment, after the database increases the current value of the counter of the second data by the above-mentioned preset value in accordance with any first processing request, it can process the first data in response to the request, and after the processing is completed (that is, the first processing request has been effectively responded to), the current value of the counter is reduced by the preset value to ensure the correspondence between the current value of the counter and the number of first processing requests that the database has not yet responded to.

[0089] In one embodiment, the counter accumulates preset values ​​in sequence on the basis of the initial value, and the current value of the counter can represent the number of processing requests for the first data contained in the second data to be responded to at the current moment. When the current value of the counter is greater than the initial value of the count, it indicates that there is at least one first processing request that has not yet been responded to (has not started to respond or is being responded to), so when the number of first processing requests at the current moment is multiple, each request can be responded to separately. Specifically, if the multiple first processing requests corresponding to the current value are respectively used to request the processing of multiple first data under the above-mentioned second data, each first data can be the same first data, such as data 1; or different first data, such as data 1, 2, then each first data is processed separately in response to each first processing request to ensure the synchronous and efficient processing of each first data, and improve the data processing efficiency of the database. If the multiple first processing requests corresponding to the current value are used to request the processing of the same first data under the second data, the receiving order of the multiple first processing requests can be determined first, and then the multiple first processing requests can be responded to in sequence according to this receiving order to process the first data.

[0090] In one embodiment, the database may also receive a second processing request initiated by the initiator for the second data. To ensure that the processing process for the second data (i.e., the process of responding to the second processing request) does not cause a request conflict and thus avoid generating dirty data, the database may, after receiving the request, set corresponding exclusive locks for the second data and all the first data in the second data, thereby determining the current value of the counter of the second data, and performing subsequent operations according to the current value. For example, if the current value of the counter is equal to the initial count value of the counter, it indicates that there is no first data being processed by the database under the second data at the current moment, so the database may process the second data in response to the above-mentioned second processing request. Otherwise, if the current value of the counter is greater than the initial count value of the counter, it indicates that there is first data being processed by the database under the second data at the current moment, so the database cannot process the second data at the current moment, so it may terminate the response to the second processing request, or wait until the current value of the counter is equal to the initial count value, and then try to process the second data in response to the second processing request. It can be seen that no matter which of the above processing methods is used, the database processes the second data in response to the second processing request without processing the first data, so that the process of processing the second data does not conflict with the process of processing the first data under the second data, and no dirty data is generated. Of course, after the processing of the second data is completed, the database can release the above exclusive locks set for the first data and the second data to ensure the normal response of subsequent requests.

[0091] It should be noted that, in the above embodiment, there is no necessary order between the database receiving the first processing request and receiving the second processing request, and thus the present disclosure does not restrict the order in which the database responds to the first processing request and the second processing request. Because the database may receive the second processing request before receiving the first processing request, during the process of responding to the first processing request, or after the response to the first processing request is terminated, when the second processing request for the second data is received, the current value of the second data counter may be the initial value of the count (indicating that no first processing request has been received, or that all received first processing requests have been responded to) or greater than the initial value of the count (indicating that there is currently a first processing request that has not been responded to).

[0092] It can be seen from the above embodiments that in the processing process for any first data or any second data (i.e., the process of responding to any first processing request or any second processing request), it is possible to process normally or terminate the processing, so the database can return corresponding notification information to the initiator of the request. For example, after successfully responding to any processing request and completing the processing of the corresponding data, the database can return the corresponding processing results, such as modified data, write receipts, etc., to the initiator of the request (i.e., the initiator of the aforementioned request, such as a thread, a device, an application, a user, etc.). After terminating the response process for any request, the database can return a response failure message to the initiator of the request so that the initiator can be informed of the response status in a timely manner to ensure the transparency of the response to the first processing request.

[0093] Among them, the processing of any data such as the first data or the second data can have multiple forms. For example, it can be an addition operation, that is, inserting new data into the data, such as the first processing request for task group M1 can be used to create a new task M13 under task group M1, and the database can insert the task data of task M13 into the task group data of task group M13. Or it can also be a deletion operation, that is, deleting existing data, such as the first processing request for task M13 can be used to delete task M13 in task group M1, and the database can delete the task data of task M13 in the task group data of task group M13. Or it can also be a move operation, that is, changing existing data, such as the first processing request for task M11 is used to move task data M11 from task group data M1 to task group data M2, and the database can change the belonging object of task M11 from task group M1 to task group M2, thereby realizing the change of the existing data of task data M11.

[0094] Furthermore, when the response process to the second processing request is terminated, a processing failure message for the request can be returned to the initiator of the second processing request (such as a thread, a device, an application, a user, etc.) so that the relevant parties can be aware of the response status in a timely manner to ensure the transparency of the response to the second processing request.

[0095] According to an embodiment of the present disclosure, the database receives any first processing request for first data whose logical level is lower than that of second data, and when no exclusive lock is set for the second data, increases the current value of the counter of the second data by a preset value according to the first processing request, and then processes the first data in response to the request, and after the processing is completed, reduces the current value of the counter by the preset value, wherein when the current value of the counter is equal to the preset count initial value, the second data can be processed.

[0096] It can be seen that by setting a counter for the second data with a higher logical level, and processing the second data only when the current value of the counter is equal to the preset count initial value, the first data and the first data will not be processed at the same time, thereby effectively avoiding the generation of dirty data. It is understandable that there may be multiple first data with a lower logical level under the second data with a higher logical level, and multiple first processing requests for the first data under the same second data may be received in a short time. Therefore, multiple first data under the same second data can be processed at the same time, thereby effectively improving the data processing efficiency of the database, and thus contributing to the throughput of the business system corresponding to the database. In addition, because a preset value will be added to the counter of the second data when any first request is received, as long as there is a first processing request that has not been responded to, the current value of the counter of the second data will not be equal to the preset count initial value, and the second processing request will not be responded to, so the first data corresponding to each first request will not generate dirty data, thereby effectively solving the above-mentioned problems existing in the relevant technology.

[0097] Below Figure 1 As shown in the multi-level architecture, combined with Figure 3-Figure 5 Taking the first data as task data M11, the second data as task group data M1, the initial count value of the counter corresponding to the task group data M1 as 0, and the corresponding preset value as 1 as an example, the process of the database responding to the first processing request and the second processing request is described in detail.

[0098] Figure 3 is a flowchart of a method for processing first data in a multi-level architecture according to an embodiment of the present disclosure, first combining Figure 3 The response process for the first processing request is described. Figure 3 As shown, the process may include the following steps 301-309.

[0099] Step 301: The database receives a first processing request for first data.

[0100] In one embodiment, the database may receive a first processing request initiated by an initiator such as a thread, a device, an application, or a user at any time. The first processing request may correspond to a business behavior in the business system to which the database is connected, such as a user changing his or her own user information, interacting with other users online, liking, forwarding, commenting on works posted by other users, etc.; or, the first processing request may also correspond to a structural adjustment behavior of the business system, such as a back-end staff of the business system inserting task M13 into task group M1, deleting task M12 in task group M1, moving task M12 under task group M1 to task group M2, etc.

[0101] The above behavior may cause the behavior-related data to change, so the first processing request can be used to instruct the database to process the first data stored therein. After receiving the first processing request, the database starts a response process to the first processing request.

[0102] Step 302: Check whether the second data to which the first data belongs is set with an exclusive lock.

[0103] After receiving the first processing request, the database can first determine the first data to be processed corresponding to the first processing request. If the first data is the highest-level data under the current multi-level architecture (such as the project data of project P1), an exclusive lock can be set for the first data, and then the first data can be processed according to the first processing request to achieve a response to the first processing request. On the contrary, if the first data is low-level data under the current multi-level architecture (as long as the first data is not the highest-level data, the first data belongs to a higher-level data, so relative to the highest-level data, the first data is a low-level data), then the second data to which the first data belongs can be further determined, such as when the first data is task group data M1, it can be further determined that the corresponding second data is the project data of project P1 (i.e., project data P1), or when the first data is task data M11, it can be further determined that the corresponding second data includes project data P1 and task group data M1.

[0104] When the second data to which the first data belongs is set with an exclusive lock, it indicates that the data related to the second data (such as the second data, data below the logical level of the second data, and data above the logical level of the second data) is locked by the database in response to the processing request. It can be seen from the aforementioned characteristics of the exclusive lock that when any second data is set with an exclusive lock by the database in response to the first processing request, the operation permissions of all the first data contained therein (such as permissions to add, delete, modify, etc.) are locked to the first processing request, and any other request cannot perform operations on all the first data contained in the second data. After determining the second data to which the first data belongs, the database checks whether the second data has been set with an exclusive lock: if the exclusive lock has been set, go to step 303; otherwise, if the exclusive lock has not been set, go to step 306.

[0105] Step 303, determine whether the number of checks for the exclusive lock is less than the first number n1.

[0106] Step 304, waiting for a first time period T1.

[0107] At this time, in order to ensure an effective response to the first processing request and to achieve the user's unawareness of the conflict between the first data and the second data at this time, multiple retries (or spins) can be performed. Specifically, it is possible to first determine whether the current number of checks is less than the first number n1: if the current number of checks is less than n1, it indicates that the current number of checks for the exclusive lock has not reached the first number n1, so it is possible to proceed to step 304 and return to step 302 to check again after waiting for the first time period T1; otherwise, if the current number is greater than or equal to n1, it indicates that the current number of checks for the exclusive lock has reached the first number n1, but there is still an exclusive lock for the second data, so in order to avoid the response process of a single request taking too long, it is possible to proceed to step 305 to terminate the response process for the first processing request.

[0108] Among them, the above-mentioned first duration T1 and first number n1 can be preset fixed values, such as T1=50ms, n1=4 times, etc.; or, in order to ensure that the response process of the request is more in line with the actual situation of the database, the first duration T1 and the first number n1 at the current moment can be determined according to the actual situation such as the total number of requests to be responded to, the number of first processing requests for the first data, the current resource occupancy rate of the database, the type of request, etc. For example, the determination rules can be pre-set, such as setting the first duration T1 to be positively correlated with the current resource occupancy rate of the database, the first number n1 to be negatively correlated with the total number of requests to be responded to and / or the number of first processing requests for the first data, etc., and the present disclosure does not limit this.

[0109] Of course, the repeated checking process of the above steps 302-304 is optional. In fact, when it is determined in step 302 that the second data is set with an exclusive lock, the process proceeds to step 305 (not shown in the figure) to speed up the response speed of the first processing request and avoid the initiator of the first processing request waiting too long.

[0110] Step 305: terminate the response process for the first processing request, and return a processing failure message to the initiator of the request.

[0111] After terminating the response process for the first processing request, a processing failure message can be returned to the initiator of the request. The message can include failure-related information, such as the request reception time, termination time, data status of the data to be processed corresponding to the request, etc. The present disclosure does not limit this.

[0112] Step 306: add 1 to the current value of the counter corresponding to the second data.

[0113] At this time, the second data is not set with an exclusive lock, which means that the current database does not process the second data in response to the second processing request, so the processing operation can be performed on the first data according to the first processing request (ie, respond to the first processing request).

[0114] In order to ensure that the operation permission of the second data is not allocated to the second processing request received in the process of responding to the first processing request, the database can use the counter set for the second data to avoid the operation conflict between the second data and the first data. Specifically, the database can add 1 to the current value of the counter of the second data, and subtract 1 from the current value of the counter after the processing task data M11 is completed, thereby ensuring that as long as the database is processing the first data in response to the first processing request, the current value of the counter corresponding to the second data is not 0, and then the first data will not be processed at this time, thereby avoiding the generation of dirty data due to operation conflicts.

[0115] It should be noted that the database can set a counter for the second data when it is first written. For example, the database can add a counter current value field for each data in the multi-level data structure. The value of this field indicates the current value of the counter corresponding to each data (of course, this field may not be set for the data at the lowest level). Thus, after the database receives the first request for the first data under any second data, the field value of the counter current value field of the second data can be judged. Alternatively, the database can also set a counter for the second data when it first receives the first request for the first data under the second data. For example, the database may not set a counter for the task group data M1 when writing it, until the first request for the task data M11 or task M12 is received for the first time, and then set a counter for the task group data M1 and set the current value of the counter to 1 (the initial value of the count is 0).

[0116] In addition, after receiving the first request for any first data, the database needs to update the current value of the counter of each second data corresponding to the first data. As mentioned above, when the first data is task data M11, the second data includes project data P1 and task group data M1. Accordingly, when the database receives the first request for task data M11, it can add 1 to the current value of the counter of task group data M1 and project data P1 respectively. It should be noted that although task group data M2, task group data M3 and task group data M1 belong to the same level, task data M11 is not under task group data M2 and task group data M3 (that is, the two are not the current second data), so the database may not add 1 to the current value of the counter of task group data M2 and task group data M3. Of course, if there is an association relationship between task group data M2 and / or task group data M3 and task group data M1 (such as the value of task group M3 is the sum of the value of task group M1 and the value of task group M3), the current value of the counter of task group data M2 and / or task group data M3 can also be added by 1. In other words, while updating the current value of the counter of the second data, the counters of the data at the same level as the second data are also updated, which can be flexibly set according to the specific data relationship between the data, and the present disclosure does not limit this.

[0117] Furthermore, when the counter is set when the second data is first written, or when the counter is set when the first request for the first data under the second data is first received, and when the first request for any first data under the second data is received again, the database does not need to set a counter for the second data again (in fact, only one counter needs to be set for the same second data at any time), but only needs to update the current value of the counter of the second data.

[0118] Step 307: Process the task data M11 according to the first processing request.

[0119] In one embodiment, the processing operations performed on the task data M11 may include various forms, for example, inserting new data into the task data M11 (insertion), deleting original data in the task data M11 (deletion), moving original data in a task under the task data M11 to other tasks (movement, such as moving certain data in task M11 to task M12 as task data M12), etc., which will not be repeated here.

[0120] It should be noted that the current value of the counter corresponding to the second data may be greater than 1, that is, when the database receives a first processing request, it has already received other first processing requests for the first data contained in the second data corresponding to the request, and the request has not yet been fully responded to. Therefore, it is possible to respond to each first processing request based on the relationship between the current first processing requests.

[0121] Assume that the current value of the counter corresponding to the task group data M1 is 3, and the corresponding three first requests are respectively recorded as the first request 1, the first request 2 and the first request 3. In one embodiment, if the data to be processed by the three are task data M11, task data M12 and task data M13, then the database can simultaneously process task data M11 according to the first request 1, process task data M12 according to the first request 2 and process task data M13 according to the first request 3, that is, realize parallel processing of the three first requests. Obviously, compared with the three requests to obtain the exclusive lock for the task group data M1 and process them in sequence, the request throughput of the database is significantly expanded.

[0122] In another embodiment, if the data to be processed for the first request 1, the first request 2 and the first request 3 are task data M11, task data M11 and task data M12 respectively, then at this time the database can first determine the receiving order of the first request 1 and the first request 2, and then respond to the two first requests in sequence to process the task data M11 according to the receiving order; while processing the task data M11 according to the two first requests in sequence, the database can also process the task data M12 according to the first request 3.

[0123] In another embodiment, if the data to be processed for the first request 1, the first request 2 and the first request 3 are all task data M11, then the database can respond to the three first requests in sequence to process the task data M11 according to the order in which they are received.

[0124] Step 308: subtract 1 from the current value of the counter corresponding to the second data.

[0125] It is understandable that since there may be multiple first processing requests and the response time periods of each first processing request are not completely consistent, the counter value after subtracting 1 in step 308 and the counter value before adding 1 in step 306 may not be the same (because other first processing requests may be received or the pending data corresponding to other first processing requests may be processed during the execution of step 307). In other words, the value of the counter corresponding to the second data changes dynamically, and the present disclosure does not limit this.

[0126] Step 309: terminate the response process for the first processing request and return the processing result to the initiator of the request.

[0127] At this point, the complete processing process for the first processing request has been completed, that is, the response to the first processing request has been completed, so the corresponding processing result can be returned to the initiator of the first processing request. In addition, the data change information generated by the above operation can also be sent to relevant parties. For example, if the database is a MySQL database, the binlog log corresponding to step 307 can be sent to the maxwell parser so that the log can be parsed and subsequently processed, such as generating a queue message, etc. The specific process will not be repeated.

[0128] Figure 4 is a flow chart of a method for processing second data in a multi-level architecture according to an embodiment of the present disclosure. Figure 4 The response process to the second processing request is described below. Figure 4 As shown, the process may include the following steps:

[0129] Step 401: The database receives a second processing request for second data.

[0130] In this embodiment, the database may also receive a second processing request initiated by an initiator such as a thread, a device, an application, or a user at any time. Similar to the first processing request, the second processing request may also correspond to a business behavior in a business system to which the database is connected or a structural adjustment behavior of the business system, which will not be described in detail. The above-mentioned behavior may cause the behavior-related data to change, so the second request may be used to instruct the database to process the second data stored therein. After receiving the second processing request, the database begins the response process for the second processing request.

[0131] Step 402: Set an exclusive lock for the second data.

[0132] After receiving the second processing request, the database may first determine the second data to be processed corresponding to the second processing request. If the second data is the lowest-level data under the current multi-level architecture (such as the task data of task M11), the database may set an exclusive lock for the second data, and then process the second data according to the second processing request to achieve a response to the second processing request. Conversely, if the second data is high-level data under the current multi-level architecture (when the data to be processed corresponding to the second processing request contains data of a lower level, the data is determined as the second data), the database may set an exclusive lock for the second data and all data under the second data, and refuse to perform operations on the second data or any data under the second data in response to any other requests.

[0133] Step 403: Check whether the current value of the counter corresponding to the second data is 0.

[0134] For any second data, if the current value of the counter corresponding to it is not 0, the operation permission of at least one first data contained therein is occupied by the first processing request, and the database cannot process the second data in response to any other request (including the second processing request for the second data). Therefore, after setting an exclusive lock on the second data, the database can check the current value of the counter corresponding to the second data: if the current value is not 0, proceed to step 404; otherwise, if the current value is 0, proceed to step 407.

[0135] Step 404, determining whether the number of checks on the current value of the counter is less than the second number n2.

[0136] Step 405, waiting for a second time period T2.

[0137] At this time, in order to ensure an effective response to the second processing request and to achieve the user's unawareness of the conflict between the first data and the second data at this time, multiple retries can be made. Specifically, the process can proceed to step 404 to determine whether the current number of checks is less than the second number n2: if the current number of checks is less than n2, it indicates that the current number of checks on the current value of the counter has not reached the second number n2, so after proceeding to step 405 and waiting for the second time period T2, it can return to step 403 for another check; otherwise, if the current number is greater than or equal to n2, it indicates that the current number of checks on the current value of the counter has reached the second number n2, but there is still a first processing request for the first data contained in the second data that has not been responded to, so in order to avoid the single request response process taking too long and thus reduce the waiting time of the request initiator, the process can proceed to step 406 to terminate the response process for the second processing request.

[0138] Among them, similar to the aforementioned first duration T1 and the first number n1, the second duration T2 and the second number n2 in this embodiment can also be preset fixed values, such as T2 = 100ms, n2 = 3 times, etc.; or the second duration T2 and the second number n2 at the current moment can also be determined according to the actual situation such as the total number of requests to be responded to in the database, the number of first processing requests for the first data, the current resource occupancy rate of the database, the request type, etc. For example, the determination rules can be pre-set, such as setting the second duration T2 to be positively correlated with the current resource occupancy rate of the database, the second number n2 to be negatively correlated with the total number of requests to be responded to and / or the number of second processing requests for the first data, etc., and the present disclosure does not limit this.

[0139] Of course, the repeated checking process of the above steps 403-405 is optional. In fact, when it is determined in step 403 that the current value of the counter corresponding to the second data is not 0, the process proceeds to step 406 (not shown in the figure) to speed up the response speed of the second processing request and significantly reduce the waiting time of the initiator of the request.

[0140] Step 406: terminate the response process for the second processing request, and return a processing failure message to the initiator of the request.

[0141] After terminating the response process for the second processing request, a processing failure message can be returned to the initiator of the request. The message may include failure-related information, such as the request reception time, termination time, data status of the second data corresponding to the request, etc. The present disclosure does not limit this.

[0142] Step 407: Process the task group data M1 according to the second processing request.

[0143] The processing operations implemented on the task group data M1 may include various forms, for example, inserting task data M13 into the task group data M1 (insert), deleting task data M12 in the task group data M1 (delete), moving task data M12 under the task group data M1 to task group data M2 (move), etc., which will not be repeated here.

[0144] Step 408: terminate the response process for the second processing request and return the processing result to the initiator of the request.

[0145] At this point, the complete processing process for the second processing request has been completed, that is, the response to the second processing request has been completed, so the corresponding processing result can be returned to the aforementioned initiator of the second processing request. In addition, the data change information generated by the above operation can also be sent to relevant parties. For example, if the database is a MySQL database, the binlog log corresponding to step 407 can be sent to the maxwell parser so that the log can be parsed and subsequently processed, such as generating a queue message.

[0146] 409, releasing the exclusive lock set for the task group data M1 (ie, the second data).

[0147] After processing the second data, the database can release the above-mentioned exclusive locks set for the first data and the second data to ensure the normal response of subsequent requests. It can be understood that, in the case where the first data is included under the second data, such as the task group data M1 includes task data M11 and task data M12, the exclusive locks set in the above-mentioned step 402 are set for task group data M1, task data M11 and task data M12 respectively, so all exclusive locks should be released in this step to ensure the normal response of the subsequent first request or second request for task group data M1, and the first request for task data M11 or task data M12.

[0148] Figure 5 is an interactive flow chart of a data processing method according to an embodiment of the present disclosure. Figure 5 The response process of the first processing request for adding a new task M13 and the second processing request for deleting the task group M1 is described. Figure 5 As shown, the process may include the following steps:

[0149] Step 501: The first process obtains a task adding request and sends it to a database.

[0150] In this embodiment, in order to reflect the exclusive lock set for the second data, the counter corresponding to the second data, and the processing operation implemented on the data, the "exclusive lock", "counter" and "processing operation" contained in the database are regarded as different execution entities. Figure 5 , but the actual execution entities of the three should be understood as databases, hereby explained.

[0151] It should also be noted that the device that has a connection relationship with the database can create a processing process for the database to realize the read / write operation of the data managed by the database through the interaction process between the process and the database. It can be understood that the processing process running in any device is created by the operating system of the device. Generally, the device can perform different types of operations on the data in the database through different processes. In this embodiment, the first process initiates the task addition request (request to write task data) in step 501, and the second process initiates the task group deletion request (request to delete task group data) in step 506. Obviously, the first process and the second process can be different processes, and can even be run in different devices respectively. In other words, the processing requests for the first data (i.e., the task data M13 described below) and the second data (i.e., the task group data M1 described below) can be independent of each other. Among them, the device where any of the above processes are located can be a business server, a CDN (Content Delivery Network) server, a user terminal, etc., and the embodiment of the present disclosure does not limit this.

[0152] Step 502: The database checks at least once to determine whether there is an exclusive lock on the task group data M1.

[0153] Step 503: the database adds 1 to the current value of the counter corresponding to the task group data M1.

[0154] Step 504: the database inserts the newly added task data M13 into the task group data M1.

[0155] Step 505: the database decrements the current value of the counter corresponding to the task group data M1 by 1, and returns a message indicating that the task has been created successfully.

[0156] The specific execution process of the above steps 502-505 can be found in Figure 3 The corresponding steps of the aforementioned embodiments are not repeated here.

[0157] Step 506: The second process obtains a task adding request and sends it to the database.

[0158] In one embodiment, the first thread and the second thread involved in step 501 and step 506 respectively may be two different threads.

[0159] Step 507: The database sets an exclusive lock for the task group data M1.

[0160] Step 508: The database checks the current value of the counter corresponding to the second data at least once.

[0161] Step 509: The database deletes the task data M13 in the task group data M1 and returns a task deletion success message.

[0162] The specific execution process of the above steps 506-509 can be found in Figure 4 The corresponding steps of the above-mentioned embodiment are not repeated here. If the exclusive lock still exists after multiple checks in step 502, the response process for the task addition request can be ended (that is, steps 502-506 are not executed), and a creation failure message is returned to the first process accordingly; or, if the creation of task M13 fails due to any reason in step 504, the response process for the task addition request can be ended (that is, step 506 is not executed), and a creation failure message is returned to the first process accordingly.

[0163] Similarly, if the current value of the counter corresponding to the second data is still greater than 0 after multiple checks in step 508 (the check here exceeds the preset number of times threshold), the response process for the request to delete the task group can be terminated (i.e., steps 509-510 are not executed), and a deletion failure message is returned to the second process accordingly; or, if the deletion of the task group M1 fails due to any reason in step 509, the response process for the request to delete the task group can be terminated (i.e., step 510 is not executed), and a deletion failure message is returned to the second process accordingly.

[0164] In the present embodiment, as an exemplary implementation, it is possible to first receive and respond to a task addition request and then receive and respond to a task group deletion request (i.e., first perform steps 501-505 and then perform steps 506-510); or, as another exemplary implementation, it is possible to first receive and respond to a task group deletion request and then receive and respond to a task addition request (i.e., first perform steps 506-510 and then perform steps 501-505). In other words, there is no necessary order between "steps 501-505" and "steps 506-510", and they can be adjusted according to actual conditions. In addition, some specific steps can also be appropriately adjusted during actual use, which will not be repeated here.

[0165] Corresponding to the aforementioned embodiments of the data processing method, the present disclosure also proposes embodiments of a data processing device.

[0166] Figure 6 1 is a schematic block diagram of a data processing device according to an embodiment of the present disclosure. The data processing device shown in this embodiment can be applied to a database, which includes but is not limited to relational databases such as MySQL, SqlServe, Oracler, etc., and can also be a non-relational database such as Cassandra, MongoDB, CouchDB, etc., and the present disclosure does not limit this.

[0167] like Figure 6 As shown, the data processing device may include:

[0168] The request receiving module 601 is configured to receive any first processing request for first data, wherein data information of the first data indicates that a logical level of the first data is lower than a logical level of second data;

[0169] The value increasing module 602 is configured to increase the current value of the counter of the second data by a preset value according to any one of the first processing requests when the exclusive lock is not set for the second data;

[0170] The numerical reduction module 603 is configured to process the first data in response to any of the first processing requests, and after the processing is completed, reduce the preset numerical value for the current value of the counter, wherein the second data can be processed when the current value of the counter is equal to the preset count initial value.

[0171] for Figure 6 The data processing device shown may optionally include one or more other units. Figure 7 Another data processing device shown, such as Figure 7 As shown:

[0172] Optionally, also include:

[0173] The first termination module 704 is configured to terminate the response process for any first processing request when the second data is set with an exclusive lock; or

[0174] The second termination module 705 is configured to, when the second data is set with an exclusive lock, wait for a first period of time and then recheck whether the second data is set with an exclusive lock; if the second data is still set with an exclusive lock when the number of checks on the exclusive lock reaches the first number, terminate the response process for any first processing request.

[0175] Optionally, also include:

[0176] An exclusive lock setting module 706 is configured to set an exclusive lock for the first data and the second data when receiving a second processing request for the second data;

[0177] A first processing module 707 is configured to process the second data in response to the second processing request if the current value of the counter is equal to the initial count value;

[0178] The second processing module 708 is configured to terminate responding to the second processing request if the current value of the counter is greater than the initial count value, or wait until the current value of the counter is equal to the initial count value, and then process the second data in response to the second processing request;

[0179] The exclusive lock releasing module 709 is configured to release the exclusive locks set for the first data and the second data after processing the second data is completed.

[0180] Optionally, also include:

[0181] The message returning module 710 is configured to return a response failure message for any request to the initiator of any request after terminating the response process for any request.

[0182] Optionally, also include:

[0183] The respective processing module 711 is configured to, when the current value of the counter is greater than the initial count value, respectively process the plurality of first data in response to the plurality of first processing requests if the plurality of first processing requests corresponding to the current value are respectively used to request processing of the plurality of first data;

[0184] The sequential processing module 712 is configured to process the first data in response to the multiple first processing requests in sequence according to the order in which the multiple first processing requests are received if the multiple first processing requests corresponding to the current value are used to request processing of the same first data.

[0185] Optionally, the initial count value is 0 and the preset value is 1.

[0186] Optionally, the processing of any data includes at least one of the following:

[0187] Insert new data, delete existing data, and modify existing data.

[0188] The embodiment of the present disclosure further provides an electronic device, including:

[0189] processor;

[0190] a memory for storing instructions executable by the processor;

[0191] The processor is configured to execute the instructions to implement the data processing method as described in any of the above embodiments.

[0192] An embodiment of the present disclosure further provides a storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the data processing method described in any of the above embodiments.

[0193] An embodiment of the present disclosure further provides a computer program product, which is configured to execute the data processing method described in any of the above embodiments.

[0194] Figure 8 800 is a schematic block diagram of an electronic device according to an embodiment of the present disclosure. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0195] Reference Figure 8, the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 818 .

[0196] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned data processing method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0197] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0198] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.

[0199] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0200] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 818. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0201] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0202] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0203] The image acquisition component 816 can be used to collect image data of the subject to form an image of the subject, and can perform necessary processing on the image. The image acquisition component 816 can include a camera module, and the image sensor (Sensor) in the camera module senses the light from the subject through the lens, and provides the obtained photosensitive data to the image signal processor (ISP, Image Signal Processing), which generates an image corresponding to the subject based on the photosensitive data. Among them, the above-mentioned image sensor can be a CMOS sensor or a CCD sensor, of course, it can also be an infrared sensor, a depth sensor, etc.; the camera module can be built-in in the electronic device 800, or it can be an external module of the electronic device 800; the above-mentioned ISP can be built-in in the camera module, or it can be externally mounted in the above-mentioned electronic device (not in the camera module).

[0204] The communication component 818 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 818 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 818 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0205] In one embodiment of the present disclosure, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned data processing method.

[0206] In an embodiment of the present disclosure, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to complete the above data processing method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0207] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0208] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

[0209] It should be noted that, in the present disclosure, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, the elements defined by the statement "comprises one..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0210] The method and device provided in the embodiments of the present disclosure are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method of the present disclosure and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present disclosure, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present disclosure.

Claims

1. A data processing method, characterized in that: include: receiving any first processing request for first data, wherein data information of the first data indicates that a logical level of the first data is lower than a logical level of second data, and the second data includes the first data; In the case where the exclusive lock is not set for the second data, increasing a current value of a counter of the second data by a preset value according to any one of the first processing requests; The first data is processed in response to any of the first processing requests, and after the processing is completed, the preset value is reduced for the current value of the counter, wherein the second data can be processed when the current value of the counter is equal to the preset count initial value.

2. The method according to claim 1, characterized in that Also includes: In a case where the second data is set with an exclusive lock, terminating the response process for any one of the first processing requests; or, In the case where the second data is set with an exclusive lock, wait for a first period of time and then recheck whether the second data is set with an exclusive lock. If the second data is still set with an exclusive lock when the number of checks on the exclusive lock reaches the first number, the response process for any first processing request is terminated.

3. The method according to claim 1, characterized in that Also includes: setting exclusive locks for the first data and the second data in case of receiving a second processing request for the second data; If the current value of the counter is equal to the initial count value, processing the second data in response to the second processing request; If the current value of the counter is greater than the initial count value, then terminating the response to the second processing request, or waiting until the current value of the counter is equal to the initial count value, and then processing the second data in response to the second processing request; After processing of the second data is completed, the exclusive locks set for the first data and the second data are released.

4. The method according to claim 2 or 3, characterized in that: Also includes: After terminating the response process for any request, a response failure message for any request is returned to the initiator of the any request.

5. The method according to claim 1, characterized in that Also includes: In a case where the current value of the counter is greater than the initial count value, if the multiple first processing requests corresponding to the current value are respectively used to request processing of multiple first data, then processing the multiple first data respectively in response to the multiple first processing requests; If the multiple first processing requests corresponding to the current value are used to request processing of the same first data, the first data is processed in response to the multiple first processing requests in sequence according to the order in which the multiple first processing requests are received.

6. The method according to claim 1, characterized in that The initial count value is 0, and the preset value is 1.

7. The method according to claim 1, characterized in that The processing of any data includes at least one of the following: inserting new data, deleting existing data, and modifying existing data.

8. A data processing device, characterized in that: include: a request receiving module, configured to receive any first processing request for first data, wherein data information of the first data indicates that a logical level of the first data is lower than a logical level of second data, and the second data includes the first data; a value increasing module, configured to increase a current value of a counter of the second data by a preset value according to any one of the first processing requests when the second data is not set with an exclusive lock; The numerical reduction module is configured to process the first data in response to any of the first processing requests, and after the processing is completed, reduce the preset numerical value for the current value of the counter, wherein the second data can be processed when the current value of the counter is equal to the preset count initial value.

9. The device according to claim 8, characterized in that Also includes: a first termination module, configured to terminate a response process for any first processing request when an exclusive lock is set on the second data; or, The second termination module is configured to, when the second data is set with an exclusive lock, wait for a first period of time and then recheck whether the second data is set with an exclusive lock; if the second data is still set with an exclusive lock when the number of checks on the exclusive lock reaches a first number, terminate the response process for any of the first processing requests.

10. The device according to claim 8, characterized in that Also includes: an exclusive lock setting module, configured to set an exclusive lock for the first data and the second data in case of receiving a second processing request for the second data; a first processing module, configured to process the second data in response to the second processing request if the current value of the counter is equal to the initial count value; a second processing module configured to terminate responding to the second processing request if the current value of the counter is greater than the initial count value, or wait until the current value of the counter is equal to the initial count value, and then process the second data in response to the second processing request; The exclusive lock releasing module is configured to release the exclusive locks set for the first data and the second data after processing the second data is completed.

11. The device according to claim 9 or 10, characterized in that Also includes: The message returning module is configured to return a response failure message for any request to the initiator of any request after terminating the response process for any request.

12. The device according to claim 8, characterized in that Also includes: a separate processing module, configured to, when the current value of the counter is greater than the initial count value, respectively process the multiple first data in response to the multiple first processing requests if the multiple first processing requests corresponding to the current value are respectively used to request processing of multiple first data; The sequential processing module is configured to process the first data in response to the multiple first processing requests in sequence according to the order in which the multiple first processing requests are received if the multiple first processing requests corresponding to the current value are used to request processing of the same first data.

13. The device according to claim 8, characterized in that The initial count value is 0, and the preset value is 1.

14. The device according to claim 8, characterized in that The processing of any data includes at least one of the following: inserting new data, deleting existing data, and modifying existing data.

15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the data processing method according to any one of claims 1 to 7.

16. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data processing method as claimed in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device of accessing restriction on resource and terminal equipment

    CN108446181A

  • Request handling method and device, electronic device and computer readable storage medium

    CN108573013A

  • Multi-thread concurrency monitoring method, device and apparatus and storage medium

    CN111488255A

  • Concurrent access of shared resources

    CN1774699A

  • Configuration commit database approach and session locking approach in a two-stage network device configuration process

    US20060031427A1