CN109634762B - Data recovery method and device, electronic equipment and storage medium - Google Patents
Data recovery method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN109634762B CN109634762B CN201811554207.8A CN201811554207A CN109634762B CN 109634762 B CN109634762 B CN 109634762B CN 201811554207 A CN201811554207 A CN 201811554207A CN 109634762 B CN109634762 B CN 109634762B
- Authority
- CN
- China
- Prior art keywords
- data
- recovered
- recovery
- message
- recycled
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application relates to a data recovery method, a data recovery device, electronic equipment and a storage medium. The data recovery method comprises the following steps: a write thread acquires a recovery message aiming at data to be recovered, wherein the recovery message carries a data identifier of the data to be recovered; determining the data to be recovered according to the data identifier carried in the recovery message; determining whether a read thread is reading the data to be recycled; if a read thread is reading the data to be recycled, postponing the recycling operation of the data to be recycled; and if no read thread is reading the data to be recycled, recycling the data to be recycled. When the data to be recovered is recovered, whether a reading thread is reading the data to be recovered is determined, and the data to be recovered is recovered under the condition that no reading thread is reading the data to be recovered, so that the reading thread can effectively access the data to be recovered.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data recovery method and apparatus, an electronic device, and a storage medium.
Background
Memory is a memory device in a computer system that can be used to store data and read data. With the rapid development of internet technology and business, more and more data are stored in the memory, but the storage space of the memory is limited, and if the unused data in the memory is not recycled, the storage space of the memory is consumed in time. For example, in an advertiser operating system, an advertiser needs to change the advertisement delivery state at any time, and after the advertiser operating system transmits corresponding change information to the advertisement delivery system, it means that the advertisement data in the memory of the advertisement delivery system that the advertiser wants to not deliver any more needs to be recovered, otherwise, the storage space of the memory will be consumed by the empty in time.
At present, in the process of performing read-write operation on a memory, when data to be recovered in the memory needs to be recovered, a preset time is delayed to ensure that no read thread accesses the data to be recovered as much as possible, and then the data to be recovered is subjected to recovery operation through a write thread.
However, the preset time is difficult to control, and if the preset time is too short, it cannot be guaranteed that all the read threads do not access the data to be recovered any more, and at this time, the write thread performs recovery operation on the data to be recovered, so that the read thread program accessing the data to be recovered is broken down, and the read thread cannot effectively access the data to be recovered.
Disclosure of Invention
In order to solve the problems in the related art, the present application provides a data recovery method, an apparatus, an electronic device, and a storage medium, so as to solve the problem in the related art that a read thread cannot effectively access data to be recovered when a write thread performs a recovery operation on the data to be recovered.
According to a first aspect of embodiments of the present application, there is provided a data recovery method, including:
a write thread acquires a recovery message aiming at data to be recovered, wherein the recovery message carries a data identifier of the data to be recovered;
determining the data to be recovered according to the data identifier carried in the recovery message;
determining whether a read thread is reading the data to be recycled;
if a read thread is reading the data to be recycled, postponing the recycling operation of the data to be recycled;
and if no read thread is reading the data to be recycled, recycling the data to be recycled.
Optionally, the step of acquiring, by the write thread, a recovery message for the data to be recovered includes:
in the current period, the write thread determines whether a recovery message aiming at the data to be recovered exists in the message queue;
if the message queue has a recovery message aiming at the data to be recovered, the write thread extracts the recovery message stored earliest from the message queue;
the step of determining the data to be recovered according to the data identifier carried in the recovery message includes:
determining data to be recovered corresponding to the period according to the data identifier carried in the recovery message extracted from the message queue, and recording the determined data to be recovered in a recovery list, wherein the recovery list records: in the data to be recovered corresponding to all periods before the current period, the data to be recovered which is not recovered yet and the data to be recovered corresponding to the current period;
the step of determining whether a read thread is reading the data to be recycled comprises:
determining whether a reading thread reads the data to be recovered or not aiming at each data to be recovered in the recovery list;
if no read thread is reading the data to be recycled, the step of recycling the data to be recycled comprises:
and for each data to be recycled in the recycling list, if no reading thread is reading the data to be recycled, recycling the data to be recycled in the period.
Optionally, after the step of performing a recovery operation on the data to be recovered, the method further includes:
and deleting the record of the data to be recovered in the recovery list.
Optionally, after the step of determining, by the write thread, whether a recycle message for the data to be recycled exists in the message queue in the current cycle, the method further includes:
and if the message queue does not have the recovery message aiming at the data to be recovered, the write thread executes the operation of determining whether the recovery message aiming at the data to be recovered exists in the message queue in the next period.
Optionally, the step of determining, by the write thread, whether a recycle message for the data to be recycled exists in the message queue includes:
and the write thread accesses the message queue and determines whether a recovery message aiming at the data to be recovered exists in the message queue.
Optionally, the step of determining whether a read thread is reading the data to be recycled includes:
determining whether a read thread is reading the data to be recycled through an epoch-based recycling algorithm EBR.
Optionally, the step of performing a recovery operation on the data to be recovered includes:
and calling a recaim function provided by the ERB to carry out recovery operation on the data to be recovered.
According to a second aspect of embodiments of the present application, there is provided a data recovery apparatus, including:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is configured to acquire a recovery message aiming at data to be recovered by a write thread, and the recovery message carries a data identifier of the data to be recovered;
a first determining module, configured to determine the data to be recovered according to the data identifier carried in the recovery message;
a second determination module configured to determine whether a read thread is reading the data to be recycled;
a first processing module configured to postpone a recovery operation on the data to be recovered if a read thread is reading the data to be recovered;
the second processing module is configured to perform recovery operation on the data to be recovered if no read thread is reading the data to be recovered.
Optionally, the obtaining module is specifically configured to determine, by the write thread, whether a recovery message for the data to be recovered exists in the message queue in a current cycle; if the message queue has a recovery message aiming at the data to be recovered, the write thread extracts the recovery message stored earliest from the message queue;
the first determining module is specifically configured to determine, according to the data identifier carried in the recovery message extracted from the message queue, to-be-recovered data corresponding to the period, and record the determined to-be-recovered data in a recovery list, where: in the data to be recovered corresponding to all periods before the current period, the data to be recovered which is not recovered yet and the data to be recovered corresponding to the current period;
the second determining module is specifically configured to determine, for each to-be-recycled data in the recycling list, whether a read thread is reading the to-be-recycled data;
the second processing module is specifically configured to, for each to-be-recycled data in the recycling list, perform a recycling operation on the to-be-recycled data in the present period if no read thread is reading the to-be-recycled data.
Optionally, the apparatus further comprises: and the deleting module is configured to delete the record of the data to be recovered in the recovery list after the second determining module performs recovery operation on the data to be recovered.
Optionally, the obtaining module is further configured to, after the write thread determines whether a recycle message exists in the message queue in the current cycle, if a recycle message for the data to be recycled does not exist in the message queue, the write thread performs an operation of determining whether a recycle message for the data to be recycled exists in the message queue in a next cycle.
Optionally, the obtaining module is specifically configured to access a message queue by a write thread, and determine whether a recovery message for data to be recovered exists in the message queue.
Optionally, the second determining module is specifically configured to determine whether any read thread is reading the data to be recycled through a period-based recycling algorithm EBR.
Optionally, the second processing module is specifically configured to call a recaim function provided by the ERB to perform a recovery operation on the data to be recovered.
According to a third aspect of embodiments of the present application, there is provided an electronic apparatus, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to: the data recovery method according to the first aspect is implemented when the instructions stored in the memory are executed.
According to a fourth aspect of embodiments herein, there is provided a non-transitory computer readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the data reclamation method as described above in the first aspect.
According to a fifth aspect of embodiments of the present application, there is provided a computer program product, wherein instructions of the computer program product, when executed by a processor of an electronic device, enable the electronic device to perform the data reclamation method as described in the first aspect above.
The technical scheme provided by the embodiment of the application can have the following beneficial effects: in the application, the write thread determines the data to be recovered according to the acquired recovery message aiming at the data to be recovered, and determines whether a read thread is reading the data to be recovered; if a reading thread is reading the data to be recovered, delaying the recovery operation of the data to be recovered; and if no read thread is reading the data to be recycled, recycling the data to be recycled. By adopting the data recovery method provided by the application, when the data to be recovered is recovered, whether a read thread is reading the data to be recovered is determined at first, and the data to be recovered is recovered under the condition that no read thread is reading the data to be recovered, so that the read thread can effectively access the data to be recovered.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flow chart illustrating a method of data recovery in accordance with an exemplary embodiment;
FIG. 2 is a flow diagram illustrating another method of data reclamation in accordance with an exemplary embodiment;
FIG. 3 is a flow diagram illustrating another method of data reclamation in accordance with an exemplary embodiment;
FIG. 4 is a block diagram illustrating a data recovery device in accordance with an exemplary embodiment;
FIG. 5 is a block diagram illustrating an electronic device in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating an apparatus for data reclamation in accordance with an exemplary embodiment;
FIG. 7 is a block diagram illustrating another apparatus for data reclamation in accordance with an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The present application provides a data recovery method, as shown in fig. 1, which may include the following steps:
s101, a write thread acquires a recovery message aiming at data to be recovered, wherein the recovery message carries a data identifier of the data to be recovered;
s102, determining data to be recovered according to the data identification carried in the recovery message;
s103, determining whether a reading thread is reading data to be recycled;
s104, if a reading thread is reading the data to be recovered, delaying the recovery operation of the data to be recovered;
s105, if no reading thread is reading the data to be recycled, recycling the data to be recycled.
The technical scheme provided by the embodiment of the application can have the following beneficial effects: in the application, the write thread determines the data to be recovered according to the acquired recovery message aiming at the data to be recovered, and determines whether a read thread is reading the data to be recovered; if a reading thread is reading the data to be recovered, delaying the recovery operation of the data to be recovered; and if no read thread is reading the data to be recycled, recycling the data to be recycled. By adopting the data recovery method provided by the application, when the data to be recovered is recovered, whether a read thread is reading the data to be recovered is determined at first, and the data to be recovered is recovered under the condition that no read thread is reading the data to be recovered, so that the read thread can effectively access the data to be recovered.
The above data recovery method provided by the present application is described in detail below with reference to the accompanying drawings.
The execution main body of the data recovery method provided by the application can be electronic equipment. In a specific application, the electronic device may be a terminal device or a server. Illustratively, the terminal device may be: smart phones, tablet computers, desktop computers, and the like.
The present application provides another data recovery method, as shown in fig. 2, which may include the following steps:
s201, in the current period, a write thread determines whether a recovery message aiming at data to be recovered exists in a message queue; and if the message queue has a recovery message aiming at the data to be recovered, the write thread extracts the recovery message stored earliest from the message queue, wherein the recovery message carries the data identification of the data to be recovered.
The message queue is a queue for storing a recycle message for data to be recycled. Specifically, when data to be recovered needs to be recovered, a recovery message for the data to be recovered may be generated, and each recovery message may be stored in the message queue according to the sequence of the generation time. In the recovery message, a data identifier of the data to be recovered may be carried, so that the write thread may determine the data to be recovered according to the data identifier. The data identity may be: name or storage location of the data to be reclaimed, etc. In one particular example, the data to be reclaimed may be: advertisement data, such as advertisement a, that the advertiser wishes to no longer make impressions. Then, the data identifier of the advertisement a, such as the name a of the advertisement a, may be carried in the corresponding recycle message. In this particular example, each reclaim message for data to be reclaimed may be transmitted from the advertiser operating system to the advertising system in a message queue.
The write thread is a thread for recovering data to be recovered. The recovery here means: and recovering the physical storage space occupied by the data to be recovered in the memory. Corresponding to the above specific example, the advertisement data is usually stored in the memory of the advertisement delivery system, so the recycling of the advertisement data is: and recovering the physical storage space occupied by the advertisement data in the memory of the advertisement delivery system by the write thread. In a specific application, an advertisement index for advertisement data may be constructed in the advertisement delivery system, that is, the advertisement data may be stored and organized by a data structure such as the advertisement index. Then, the recycling or reading of the advertisement data is actually to recycle or read the index data corresponding to the advertisement index.
In this embodiment, the write thread may periodically determine whether a recovery message for the data to be recovered exists in the message queue, so as to execute a corresponding operation according to a determination result. In one particular approach, during the current cycle, the write thread may access the message queue to determine whether there is a eviction message in the message queue for the data to be evicted.
If a recycle message for the data to be recycled exists in the message queue, the write thread may extract the oldest stored recycle message from the message queue to perform the next operation on the data to be recycled for which the recycle message is directed. Corresponding to the specific example described above, the recycle message in the message queue is formed according to the change of the advertiser to the advertisement placement state. For example, if the advertiser wishes to no longer deliver ad A, a recycle message for ad A is generated accordingly in the advertiser operating system. Since the advertiser's change to the advertisement placement status is subjective behavior, then: and storing a plurality of recycled messages in the message queue. For this case, the write thread may extract the oldest deposited recycle message for processing. Of course, in practical applications, the recycle messages in the message queue may be labeled with importance degrees, and it is reasonable that the write thread can extract the most important recycle message for processing.
Further, if there is no recycle message for the data to be recycled in the message queue, the write thread may perform an operation of determining whether there is a recycle message for the data to be recycled in the message queue for the next cycle. That is, the write thread can determine whether a recycle message for the data to be recycled exists in the message queue in a loop, and this active determination is more beneficial to quickly and efficiently process the recycle message in the message list.
S202, according to the data identification carried in the recovery message extracted from the message queue, determining the data to be recovered corresponding to the period, and recording the determined data to be recovered in a recovery list, wherein the recovery list records: in the data to be recovered corresponding to all periods before the current period, the data to be recovered which is not recovered yet and the data to be recovered corresponding to the current period.
Because the recovery message carries the data identifier of the data to be recovered, after the write thread extracts the recovery message, the data to be recovered corresponding to the cycle can be determined directly according to the data identifier carried in the recovery message.
In this embodiment, in order to solve the problem in the related art that when a write thread performs a recovery operation on data to be recovered, a read thread cannot effectively access the data to be recovered, in a cycle, if the data to be recovered corresponding to the cycle is being read by the read thread, the write thread may postpone the recovery of the data to be recovered. The delayed recovery here means: in this cycle, the write thread does not recover the data to be recovered, but in a cycle subsequent to this cycle, if the data to be recovered is not read by the read thread, the write thread recovers the data to be recovered.
Based on this, a recovery list can be constructed, and the data to be recovered which is not recovered yet in the data to be recovered corresponding to all the periods before the period and the data to be recovered corresponding to the period are all recorded in the recovery list, so that in the period, all the data to be recovered which is not being read by the read thread in the recovery list is recovered. That is, recorded in the recycle list are: data to be reclaimed that needs to be reclaimed, but has not yet been reclaimed.
S203, aiming at each data to be recycled in the recycling list, determining whether a reading thread reads the data to be recycled.
Since the data to be recycled which needs to be recycled but has not been recycled is recorded in the recycling list. Therefore, the write thread can determine whether a read thread is reading the data to be recycled or not for each data to be recycled in the recycling list, and then execute corresponding operation according to the determination result. In practical applications, there may be one or more read threads. In the case that there are multiple read threads, the write thread may determine, for each to-be-recycled data in the recycle list, successively whether the recycle data is being read by each read thread. The successive determination means: for each read thread, it is determined whether the read thread is reading the data to be recycled. Of course, in the process of successive determination, as long as it is determined that the data to be recovered is being read by a certain read thread, the determination may be stopped, and it is determined that: the data to be recycled is being read by the read thread; if it is determined that the data to be recycled is not being read by one of the read threads, then the following determinations may be continued: whether the data to be recycled is being read by the next read thread.
The specific determination method may be various, and the determination method is not limited in this embodiment.
S204, if a read thread is reading the data to be recycled, the recycling operation of the data to be recycled is postponed.
Specifically, for each data to be recycled in the recycling list, if a read thread is reading the data to be recycled, the recycling operation of the data to be recycled can be postponed. The delayed recovery here means: in this cycle, the write thread does not recover the data to be recovered, but in a cycle subsequent to this cycle, if the data to be recovered is not read by the read thread, the write thread recovers the data to be recovered.
When the write thread performs recovery operation on the data to be recovered, the read thread can effectively access the data to be recovered by the mode of delaying recovery. That is to say, for any data to be recycled, the write thread does not recycle the data to be recycled when the read thread is reading the data to be recycled, so that the read thread is ensured not to crash programs, and the data to be recycled can be effectively accessed.
S205, for each data to be recycled in the recycling list, if no read thread is reading the data to be recycled, the data to be recycled is recycled in the current cycle.
In this embodiment, the data to be recovered may be recovered through two ways:
the first mode is as follows: and recovering the data to be recovered when determining that one data to be recovered is not read by the reading thread. It can also be understood that: a single recovery mode.
The second mode is as follows: and after the determination of each data to be recycled in the recycling list is finished, carrying out batch recycling on all the data to be recycled which are not read by the reading thread.
Of course, the data to be recycled can also be recycled in other manners. The specific selection of the method may be determined according to actual conditions, and the present application is not limited thereto.
Further, after the step of performing a recycling operation on the data to be recycled, the write thread may also delete a record of the data to be recycled in the recycling list. In this way, during the recycling process of the write thread in each cycle, all the data to be recycled which is not recycled by the cycle is recorded in the recycling list.
The technical scheme provided by the embodiment of the application can have the following beneficial effects: in the application, a write thread determines whether a recovery message aiming at data to be recovered exists in a message queue in a current period; if so, extracting the recovery message stored earliest in the message queue; determining the data to be recovered corresponding to the period according to the data identification carried in the extracted recovery message, and recording the determined data to be recovered in a recovery list; then the write thread determines whether a read thread is reading the data to be recycled aiming at each data to be recycled in the recycling list; if yes, postponing the recovery operation of the data to be recovered; if not, in the period, the data to be recycled is recycled. By adopting the data recovery method provided by the application, when the data to be recovered is recovered, whether a read thread is reading the data to be recovered is determined at first, and the data to be recovered is recovered under the condition that no read thread is reading the data to be recovered, so that the read thread can effectively access the data to be recovered.
The present application provides another data recovery method, as shown in fig. 3, which may include the following steps:
s301, the write thread acquires a recovery message aiming at the data to be recovered, wherein the recovery message carries the data identification of the data to be recovered.
S302, determining the data to be recovered according to the data identification carried in the recovery message.
S301 and S302 may be respectively identical to S101 and S102 in the embodiment shown in fig. 1, and are not described again here.
S303, determining whether a reading thread reads data to be recovered or not through an EBR (Epoch Based recovery) algorithm.
The EBR algorithm is a lock-free garbage collection algorithm. In the following, taking an example that there is one write thread and three read threads in the recycling process, the process of determining whether there is a read thread reading data to be recycled through the EBR algorithm will be briefly described. The EBR algorithm comprises a global epoch value with values of 0, 1 and 2 and three global recycle lists, wherein each read thread corresponds to one recycle list, and each value of the global epoch value corresponds to one recycle list. And each recovery list records the data to be recovered which is being read by the corresponding read thread. Each thread corresponds to a local epoch value, and the values are also 0, 1 and 2. In the EBR algorithm, at any time, if the global epoch value is t, then the local epoch value for any read thread is t or t-1, and cannot be t + 1. In particular, the method comprises the following steps of,
when the global epoch value is 1, the local epoch value of the read thread is 1 or 0, and cannot be 2. Therefore, the write thread can recycle the data to be recycled in the recycle list corresponding to the read thread with the local epoch value of 2.
When the global epoch value is 0, the local epoch value of the read thread is either 0 or 2, and cannot be 1. Therefore, the write thread can recycle the data to be recycled in the recycle list corresponding to the read thread with the corresponding local epoch value of 1.
When the global epoch value is 2, the local epoch value of the read thread is 2 or 1, and cannot be 0. Therefore, the write thread can recycle the data to be recycled in the recycle list corresponding to the read thread with the corresponding local epoch value of 0.
S304, if a reading thread is reading the data to be recovered, delaying the recovery operation of the data to be recovered;
s304 may be identical to S104 in the embodiment shown in fig. 1, and is not described herein again.
S305, if no read thread is reading the data to be recycled, calling a recaim function provided by the ERB to recycle the data to be recycled.
The recaim function is a function provided by the ERB algorithm and used for physically recovering the data to be recovered. Physical recovery means: and recovering the physical space occupied by the data to be recovered in the memory.
The technical scheme provided by the embodiment of the application can have the following beneficial effects: in the method, a write thread determines the data to be recovered according to the acquired recovery message aiming at the data to be recovered, and determines whether a read thread reads the data to be recovered through an EBR algorithm; if a reading thread is reading the data to be recovered, delaying the recovery operation of the data to be recovered; and if no read thread is reading the data to be recycled, calling a recaim function provided by the ERB to recycle the data to be recycled. By adopting the data recovery method provided by the application, when the data to be recovered is recovered, whether a read thread is reading the data to be recovered is determined at first, and the data to be recovered is recovered under the condition that no read thread is reading the data to be recovered, so that the read thread can effectively access the data to be recovered. Moreover, the data to be recycled is recycled based on the EBR algorithm, the data to be recycled can be recycled without lock, and the recycling efficiency can be improved.
Fig. 4 is a block diagram illustrating a video information recognition apparatus according to an example embodiment. Referring to fig. 4, the apparatus includes: an acquisition module 401, a first determination module 402, a second determination module 403, a first processing module 404 and a second processing module 405, wherein,
an obtaining module 401 configured to obtain, by a write thread, a recovery message for data to be recovered, where the recovery message carries a data identifier of the data to be recovered;
a first determining module 402, configured to determine the data to be recovered according to the data identifier carried in the recovery message;
a second determining module 403 configured to determine whether a read thread is reading the data to be recycled;
a first processing module 404 configured to postpone performing a recycling operation on the data to be recycled if a read thread is reading the data to be recycled;
a second processing module 405 configured to perform a recycling operation on the data to be recycled if no read thread is reading the data to be recycled.
The technical scheme provided by the embodiment of the application can have the following beneficial effects: in the application, the write thread determines the data to be recovered according to the acquired recovery message aiming at the data to be recovered, and determines whether a read thread is reading the data to be recovered; if a reading thread is reading the data to be recovered, delaying the recovery operation of the data to be recovered; and if no read thread is reading the data to be recycled, recycling the data to be recycled. By adopting the data recovery method provided by the application, when the data to be recovered is recovered, whether a read thread is reading the data to be recovered is determined at first, and the data to be recovered is recovered under the condition that no read thread is reading the data to be recovered, so that the read thread can effectively access the data to be recovered.
Optionally, the obtaining module 401 is specifically configured to determine, by a write thread, whether a recovery message for the data to be recovered exists in a message queue in a current cycle; if the message queue has a recovery message aiming at the data to be recovered, the write thread extracts the recovery message stored earliest from the message queue;
the first determining module 402 is specifically configured to determine, according to the data identifier carried in the recovery message extracted from the message queue, to-be-recovered data corresponding to the period, and record the determined to-be-recovered data in a recovery list, where: in the data to be recovered corresponding to all periods before the current period, the data to be recovered which is not recovered yet and the data to be recovered corresponding to the current period;
the second determining module 403 is specifically configured to determine, for each to-be-recycled data in the recycling list, whether a reading thread is reading the to-be-recycled data;
the second processing module 405 is specifically configured to, for each data to be recycled in the recycle list, if no read thread is reading the data to be recycled, perform a recycle operation on the data to be recycled in the current period.
Optionally, the apparatus further comprises: a deletion module;
the deleting module is configured to delete the record of the data to be recovered in the recovery list after the second determining module 403 performs the recovery operation on the data to be recovered.
Optionally, the obtaining module 401 is further configured to, after the write thread determines whether a recycle message exists in the message queue in the current cycle, if a recycle message for the data to be recycled does not exist in the message queue, the write thread performs an operation of determining whether a recycle message for the data to be recycled exists in the message queue in a next cycle.
Optionally, the obtaining module 401 is specifically configured to access, by a write thread, a message queue, and determine whether a recovery message for data to be recovered exists in the message queue.
Optionally, the second determining module 403 is specifically configured to determine whether a read thread is reading the data to be recycled through a period-based recycling algorithm EBR.
Optionally, the second processing module 405 is specifically configured to call a recaim function provided by the ERB to perform a recovery operation on the data to be recovered.
In addition, corresponding to the data recovery method provided in the foregoing embodiment, an embodiment of the present application further provides an electronic device, as shown in fig. 5, where the electronic device may include:
a processor 510;
a memory 520 for storing processor-executable instructions;
wherein the processor 510 is configured to: when the instructions stored in the memory 520 are executed, the steps of the data recovery method provided by the embodiment of the present application are implemented.
It is understood that the electronic device may be a server or a terminal device, and in particular applications, the terminal device 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.
FIG. 6 is a block diagram illustrating an apparatus 600 for data reclamation in accordance with an exemplary embodiment. For example, the apparatus 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 6, apparatus 600 may include one or more of the following components: a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an interface to input/output (I/O) 612, a sensor component 614, and a communication component 616.
The processing component 602 generally controls overall operation of the device 600, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 602 can include one or more modules that facilitate interaction between the processing component 602 and other components. For example, the processing component 602 can include a multimedia module to facilitate interaction between the multimedia component 604 and the processing component 602.
The memory 604 is configured to store various types of data to support operations at the apparatus 600. Examples of such data include instructions for any application or method operating on device 600, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 604 may be implemented by any type or combination of volatile or non-volatile memory devices 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 or optical disks.
The multimedia component 608 includes a screen that provides an output interface between the device 600 and a 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 an input signal from a 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 boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 600 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 610 is configured to output and/or input audio signals. For example, audio component 610 includes a Microphone (MIC) configured to receive external audio signals when apparatus 600 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 604 or transmitted via the communication component 616. In some embodiments, audio component 610 further includes a speaker for outputting audio signals.
The I/O interface 612 provides an interface between the processing component 602 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor component 614 includes one or more sensors for providing status assessment of various aspects of the apparatus 600. For example, the sensor component 614 may detect an open/closed state of the device 600, the relative positioning of components, such as a display and keypad of the device 600, the sensor component 614 may also detect a change in position of the device 600 or a component of the device 600, the presence or absence of user contact with the device 600, orientation or acceleration/deceleration of the device 600, and a change in temperature of the device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 616 is configured to facilitate communications between the apparatus 600 and other devices in a wired or wireless manner. The apparatus 600 may access a wireless network based on a communication standard, such as WiFi, an operator network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 600 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, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 604 comprising instructions, executable by the processor 620 of the apparatus 600 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
FIG. 7 is a block diagram illustrating an apparatus 700 for data reclamation in accordance with an exemplary embodiment. For example, the apparatus 700 may be provided as a server. Referring to fig. 7, apparatus 700 includes a processing component 722 that further includes one or more processors and memory resources, represented by memory 732, for storing instructions, such as applications, that are executable by processing component 722. The application programs stored in memory 732 may include one or more modules that each correspond to a set of instructions. Further, the processing component 722 is configured to execute instructions to perform the above-described methods.
The apparatus 700 may also include a power component 726 configured to perform power management of the apparatus 700, a wired or wireless network interface 750 configured to connect the apparatus 700 to a network, and an input output (I/O) interface 758. The apparatus 700 may operate based on an operating system stored in memory 732, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
In addition, the present application also provides a non-transitory computer readable storage medium, and when executed by a processor of an electronic device, the instructions in the storage medium enable the electronic device to perform the steps of the data recovery method provided in the present application.
In addition, the present application also provides a computer program product, and when instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the steps of the data recovery method provided by the present application.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements 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 invention is limited only by the appended claims.
Claims (14)
1. A method of data recovery, comprising:
in the current period, the write thread determines whether a recovery message aiming at the data to be recovered exists in the message queue;
if the message queue has a recovery message for the data to be recovered, the write thread extracts the recovery message meeting a preset condition from the message queue, wherein the recovery message carries a data identifier of the data to be recovered;
determining data to be recovered corresponding to the period according to the data identifier carried in the recovery message extracted from the message queue, and recording the determined data to be recovered in a recovery list, wherein the recovery list records: in the data to be recovered corresponding to all periods before the current period, the data to be recovered which is not recovered yet and the data to be recovered corresponding to the current period;
determining whether a reading thread reads the data to be recovered or not aiming at each data to be recovered in the recovery list;
if a read thread is reading the data to be recycled, postponing the recycling operation of the data to be recycled;
and for each data to be recycled in the recycling list, if no reading thread is reading the data to be recycled, recycling the data to be recycled in the period.
2. The data recovery method of claim 1, wherein after the step of performing the recovery operation on the data to be recovered, the method further comprises:
and deleting the record of the data to be recovered in the recovery list.
3. The data reclamation method as recited in claim 1, wherein after the step of the write thread determining whether a reclamation message for the data to be reclaimed exists in the message queue in the current cycle, the method further comprises:
and if the message queue does not have the recovery message aiming at the data to be recovered, the write thread executes the operation of determining whether the recovery message aiming at the data to be recovered exists in the message queue in the next period.
4. The data reclamation method as recited in claim 1, wherein the step of the write thread determining whether a reclamation message for the data to be reclaimed exists in the message queue comprises:
and the write thread accesses the message queue and determines whether a recovery message aiming at the data to be recovered exists in the message queue.
5. The data recovery method of claim 1, wherein the step of determining whether a read thread is reading the data to be recovered comprises:
determining whether a read thread is reading the data to be recycled through an epoch-based recycling algorithm EBR.
6. The data recovery method according to claim 5, wherein the step of performing a recovery operation on the data to be recovered comprises:
and calling a recaim function provided by the time-based recovery algorithm EBR to perform recovery operation on the data to be recovered.
7. A data recovery device, comprising:
the acquisition module is configured to determine whether a recovery message aiming at the data to be recovered exists in the message queue or not by the write thread in the current period; if the message queue has a recovery message for the data to be recovered, the write thread extracts the recovery message meeting a preset condition from the message queue, wherein the recovery message carries a data identifier of the data to be recovered;
a first determining module, configured to determine, according to the data identifier carried in the recovery message extracted from the message queue, to-be-recovered data corresponding to the period, and record the determined to-be-recovered data in a recovery list, where: in the data to be recovered corresponding to all periods before the current period, the data to be recovered which is not recovered yet and the data to be recovered corresponding to the current period;
the second determining module is configured to determine whether a reading thread reads the data to be recycled or not for each data to be recycled in the recycling list;
a first processing module configured to postpone a recovery operation on the data to be recovered if a read thread is reading the data to be recovered;
and the second processing module is configured to, for each to-be-recycled data in the recycling list, perform recycling operation on the to-be-recycled data in the current period if no read thread is reading the to-be-recycled data.
8. The data recovery apparatus of claim 7, wherein the apparatus further comprises:
and the deleting module is configured to delete the record of the data to be recovered in the recovery list after the second processing module performs recovery operation on the data to be recovered.
9. The data recovery apparatus according to claim 7,
the obtaining module is further configured to, after the write thread determines whether a recycle message exists in the message queue in the current cycle, if a recycle message for the data to be recycled does not exist in the message queue, the write thread executes an operation of determining whether a recycle message for the data to be recycled exists in the message queue in a next cycle.
10. The data recovery device according to claim 7, wherein the obtaining module is specifically configured to access a message queue by a write thread, and determine whether a recovery message for the data to be recovered exists in the message queue.
11. The data recovery apparatus according to claim 7,
the second determination module is specifically configured to determine whether any read thread is reading the data to be recycled through a period-based recycling algorithm EBR.
12. The data recovery apparatus of claim 11,
the second processing module is specifically configured to invoke a recaim function provided by the time-based recovery algorithm EBR to perform a recovery operation on the data to be recovered.
13. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to: when the instructions stored in the memory are executed, the data recovery method according to any one of claims 1 to 6 is implemented.
14. A non-transitory computer readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the data reclamation method of any of claims 1-6.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811554207.8A CN109634762B (en) | 2018-12-19 | 2018-12-19 | Data recovery method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811554207.8A CN109634762B (en) | 2018-12-19 | 2018-12-19 | Data recovery method and device, electronic equipment and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN109634762A CN109634762A (en) | 2019-04-16 |
| CN109634762B true CN109634762B (en) | 2021-06-18 |
Family
ID=66075173
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201811554207.8A Active CN109634762B (en) | 2018-12-19 | 2018-12-19 | Data recovery method and device, electronic equipment and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN109634762B (en) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110647294B (en) * | 2019-09-09 | 2022-03-25 | Oppo广东移动通信有限公司 | Storage block recovery method and device, storage medium and electronic equipment |
| CN112714492B (en) * | 2020-12-21 | 2022-11-01 | 京信网络系统股份有限公司 | UWB data packet processing method, system, electronic device and storage medium thereof |
| CN117271141B (en) * | 2023-11-21 | 2024-02-23 | 新华三技术有限公司 | Resource updating system, device and network equipment |
Family Cites Families (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6938130B2 (en) * | 2003-02-13 | 2005-08-30 | Sun Microsystems Inc. | Method and apparatus for delaying interfering accesses from other threads during transactional program execution |
| CN101685408B (en) * | 2008-09-24 | 2013-10-09 | 国际商业机器公司 | Method and device for accessing shared data structure by multiple threads in parallel |
| WO2011148553A1 (en) * | 2010-05-24 | 2011-12-01 | 株式会社ソニー・コンピュータエンタテインメント | Information processing device and information processing method |
| CN103729304B (en) * | 2012-10-11 | 2017-03-15 | 腾讯科技(深圳)有限公司 | Data processing method and device |
| CN104216767B (en) * | 2014-09-18 | 2017-10-31 | 东软集团股份有限公司 | The method and device of accessing shared data between multithreading |
-
2018
- 2018-12-19 CN CN201811554207.8A patent/CN109634762B/en active Active
Also Published As
| Publication number | Publication date |
|---|---|
| CN109634762A (en) | 2019-04-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| EP3188066B1 (en) | A method and an apparatus for managing an application | |
| CN104050035B (en) | The processing method and processing device of application program | |
| CN106033397B (en) | Memory buffer area adjusting method, device and terminal | |
| CN105912450B (en) | Applied state information display method and device | |
| CN112632184A (en) | Data processing method and device, electronic equipment and storage medium | |
| CN109634762B (en) | Data recovery method and device, electronic equipment and storage medium | |
| CN104615546A (en) | File data management method and device | |
| CN114428589A (en) | Data processing method and device, electronic equipment and storage medium | |
| CN108804244A (en) | Data transmission method for uplink, device and storage medium | |
| CN107729098B (en) | User interface display method and device | |
| CN104360875B (en) | Privacy mode starts method and apparatus | |
| CN110968523B (en) | Methods and apparatus for memory defragmentation | |
| CN112416219A (en) | Target object processing method, device and system, electronic equipment and storage medium | |
| CN110008135B (en) | Information processing method and device and electronic equipment | |
| CN114077461A (en) | Application running method, device, device and storage medium | |
| CN110020346B (en) | Page storage method and device | |
| CN110502714B (en) | Information detection method and device, electronic equipment and storage medium | |
| CN108762944B (en) | Processing method, device, equipment and medium of business system | |
| CN106339470A (en) | Method and device for processing file | |
| CN105488131B (en) | File opening method and device | |
| CN106502719A (en) | The method and device of the component of management application program | |
| CN111753235A (en) | Page loading method and device and storage medium | |
| CN114116075B (en) | A method, device, electronic device and storage medium for obtaining page parameters | |
| CN113934452B (en) | Data processing method and device, electronic equipment and storage medium | |
| CN114531493B (en) | Request processing method and device, electronic equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |