Data deletion method and device
By adding data processing marks to the storage space corresponding to the deleted process in the database and determining whether to delete data based on preset conditions, the data processing problem after deletion of the database instance process is solved, and data delay deletion and effective management of storage space is realized.
Patent Information
- Application Number
- CN202411666948.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art cannot effectively solve the data processing problems after the database instance process is deleted, resulting in data loss, wasted storage space or excessive data transmission time.
In response to the process being deleted, the storage space corresponding to the process is determined based on the process identification of the process and a data processing mark is added. This flag indicates that the data in the storage space is deleted if the process meets the preset conditions. If the process resumes within the preset time period, delete the tag; if it is not restored, delete the data according to the conditions indicated by the tag.
Delayed data deletion is realized, which avoids data loss caused by process error deletion, and ensures timely release of storage space and avoids waste of disk space.
Smart Images

Figure CN119645299A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data management, and in particular to a data deletion method and device. Background Art
[0002] Currently, in the field of database resource management, after deleting the process of a database instance, there are usually the following methods for handling the data corresponding to the instance: 1. Immediately delete the data corresponding to the instance; 2. Mark the data corresponding to the instance for deletion; 3. Back up the data corresponding to the instance before deleting it.
[0003] However, the first method cannot restore the accidentally deleted instances, which may easily cause data loss; although the second method is easy to restore the accidentally deleted instances, it prevents the storage space from being released, resulting in a waste of disk space; although the third method can restore the deleted instances, it will consume more data transmission time and also cause a waste of storage space.
[0004] Therefore, the above three data processing methods cannot effectively solve the data processing problem of the data corresponding to the instance after the instance process is deleted. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a data deletion method and device, including: in response to a process being deleted, determining a storage space corresponding to the process identifier according to the process identifier of the process; the storage space stores data corresponding to the process; adding a data processing mark to the storage space, the data processing mark indicating that the data in the storage space is deleted when the process meets a preset condition; in response to the process resuming operation within the first preset time after the process is deleted, deleting the data processing mark of the storage space; in response to the process not resuming operation within the first preset time, deleting the data in the storage space according to the data processing mark of the storage space. Thus, by marking the storage space corresponding to the deleted process, it is determined whether the process is restored within the preset time, and the mark of the storage space is deleted after the process is restored. If the process is not restored, the data in the corresponding storage space is deleted according to the preset condition indicated by the mark, thereby realizing delayed data deletion, avoiding data loss caused by mistaken deletion of the process, and at the same time allowing the storage space to be released in time, avoiding waste of disk space.
[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a data deletion method is provided.
[0007] A data deletion method according to an embodiment of the present invention includes: in response to a process being deleted, determining a storage space corresponding to the process identifier according to the process identifier of the process; the storage space stores data corresponding to the process; adding a data processing mark to the storage space, the data processing mark indicating that the data in the storage space is deleted when the process meets a preset condition; in response to the process resuming operation within a first preset time period after the process is deleted, deleting the data processing mark of the storage space; in response to the process not resuming operation within the first preset time period, deleting the data in the storage space according to the data processing mark of the storage space.
[0008] Optionally, the method provided by the present invention also includes: determining whether the space identifier of the storage space and the container of the process are in an associated state within a first preset time period; in response to the space identifier and the container of the process being in an associated state, determining that the process corresponding to the space identifier resumes operation within the first preset time period.
[0009] Optionally, data in the storage space is deleted according to the data processing mark of the storage space, including: calculating the interval duration between the deletion time of the process and the current time; judging whether the interval duration is greater than a second preset duration indicated by the preset condition; in response to the interval duration being greater than the second preset duration, determining that the process meets the preset condition; in response to the process meeting the preset condition, deleting the data in the storage space.
[0010] Optionally, after deleting the process, the space identifier of the storage space and the deletion time of the process are written into the queue to be deleted as a data record; traverse each data record in the queue to be deleted, and filter out the target space identifier corresponding to the process that meets the preset conditions; determine the corresponding target storage space according to the target space identifier, and delete the data in the target storage space.
[0011] Optionally, the data identifier of the data stored in the storage space is written into the data record corresponding to the storage space; the data in the target storage space is deleted, including: in the queue to be deleted, determining the first data identifier corresponding to the target storage space; determining the second data identifier of the data stored in the target storage space; determining whether the second data identifier is consistent with the first data identifier; in response to the second data identifier being consistent with the first data identifier, deleting the data stored in the target storage space.
[0012] Optionally, the method provided by the present invention further includes: in response to the second data identifier being inconsistent with the first data identifier, deleting the data record corresponding to the first data identifier from the queue to be deleted.
[0013] Optionally, the method provided by the present invention further comprises: after executing the step of deleting the data processing mark of the storage space, deleting the data record corresponding to the storage space from the queue to be deleted.
[0014] To achieve the above objective, according to another aspect of an embodiment of the present invention, a data deleting device is provided.
[0015] A data deletion device according to an embodiment of the present invention includes: a process monitoring module, which is used to determine a storage space corresponding to a process identifier according to the process identifier of the process in response to a process being deleted; the storage space stores data corresponding to the process; a space management module, which is used to add a data processing mark to the storage space, the data processing mark indicating that the data in the storage space will be deleted when the process meets a preset condition; in response to the process resuming operation within a first preset time period after the process is deleted, the data processing mark of the storage space is deleted; and a data deletion module, which is used to delete the data in the storage space according to the data processing mark of the storage space in response to the process not resuming operation within the first preset time period.
[0016] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device for deleting data is provided.
[0017] An electronic device for data deletion according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a data deletion method according to an embodiment of the present invention.
[0018] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.
[0019] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a data deletion method according to an embodiment of the present invention is implemented.
[0020] An embodiment of the above invention has the following advantages or beneficial effects: in response to a process being deleted, a storage space corresponding to the process identifier is determined according to the process identifier of the process; the storage space stores data corresponding to the process; a data processing mark is added to the storage space, and the data processing mark indicates that the data in the storage space is deleted when the process meets the preset conditions; in response to the process resuming operation within the first preset time after the process is deleted, the data processing mark of the storage space is deleted; in response to the process not resuming operation within the first preset time, the data in the storage space is deleted according to the data processing mark of the storage space. Thus, by marking the storage space corresponding to the deleted process, it is determined whether the process is restored within the preset time, and the mark of the storage space is deleted after the process is restored. If the process is not restored, the data in the corresponding storage space is deleted according to the preset conditions indicated by the mark, thereby achieving delayed data deletion, avoiding data loss caused by accidental deletion of the process, and at the same time allowing the storage space to be released in time, avoiding waste of disk space.
[0021] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0023] Figure 1 is a flow chart of a data deletion method according to an embodiment of the present invention;
[0024] Figure 2 is a schematic diagram of a flow chart for determining whether a process is restored according to an embodiment of the present invention;
[0025] Figure 3 is a flow chart of another data deletion method according to an embodiment of the present invention;
[0026] Figure 4 is a schematic diagram of a queue to be deleted according to an embodiment of the present invention;
[0027] Figure 5 is a schematic diagram of another queue to be deleted according to an embodiment of the present invention;
[0028] Figure 6 is a schematic diagram of a process for constructing a queue to be deleted according to an embodiment of the present invention;
[0029] Figure 7 is a schematic diagram of a process of deleting data by traversing a queue to be deleted according to an embodiment of the present invention;
[0030] Figure 8is a schematic diagram of main modules of a data deletion device according to an embodiment of the present invention;
[0031] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0032] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0034] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.
[0035] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.
[0036] Figure 1 is a schematic diagram of main steps of a data deletion method according to an embodiment of the present invention.
[0037] like Figure 1 As shown, the data deletion method of the embodiment of the present invention mainly includes steps S101-S104:
[0038] Step S101: In response to the process being deleted, a storage space corresponding to the process identifier is determined according to the process identifier of the process; the storage space stores data corresponding to the process. The execution subject of the data deletion method in the embodiment of the present invention is the controller of the database. The database can be a TiDB database. After determining that a certain process is deleted, the controller determines in which storage space the data processed by the process during execution is stored, so as to mark the storage space, and delete the data in the marked storage space when the conditions are met, so that the storage space is recycled. Among them, the process runs in kubernetes in a containerized manner, and the status of the container can be monitored and checked, and whether the process has been deleted can be determined according to the status of the container. In practice, a container may correspond to one or more processes, and a process may correspond to one or more storage spaces. In this embodiment, in order to facilitate the explanation of the principle of the data deletion method, the embodiment of the present invention takes one container corresponding to one process and one process corresponding to one storage space as an example, and the data deletion method of the embodiment of the present invention is described in detail.
[0039] Step S102: Add a data processing mark to the storage space, and the data processing mark indicates that the data in the storage space will be deleted when the process meets the preset conditions. After determining that a process is deleted, add a data processing mark to the storage space corresponding to the process, and the data processing mark indicates that the data in the storage space needs to be deleted when the process meets the preset conditions. In order to prevent data loss caused by accidental deletion of the process, the data processing mark can indicate a second preset time length, and when the time after the process is deleted reaches or exceeds the second preset time length, the data corresponding to the process is deleted, thereby achieving delayed deletion of data. For example, the deletion time of process A is 9:00, and the corresponding data processing mark indicates that the corresponding data will be deleted when the time after the process is deleted reaches or exceeds 1 hour, then the data can be deleted at 10:00 or after 10:00. It can be understood that 1 hour is an example, and it can be any time length, which can be flexibly set according to business needs.
[0040] Before the data in the storage space corresponding to the process is deleted, in order to detect whether the process has been restored, in an optional embodiment of the present invention, the method further includes: determining whether the space identifier of the storage space is in an associated state with the container of the process within a first preset time period; in response to the space identifier being in an associated state with the container of the process, determining that the process corresponding to the space identifier is restored to run within the first preset time period. After the process is deleted and before the data corresponding to the process is deleted, it is checked regularly whether the process has been restored. The space identifier of the storage space is configured in the configuration information corresponding to the process container, which indicates that when the process is running, the corresponding running data is stored in the storage space corresponding to the space identifier. When the process is deleted, the configuration information corresponding to its container is also deleted, that is, the corresponding space identifier is also deleted, that is, the association between the space identifier and the process container is cut off. In a short period of time after the process is deleted, such as within half an hour, when it is restored, the original container is allocated to the process and configuration information is created for the container, and the space identifier of the original storage space is configured in the configuration information, so that the restored process can still use the data in the original storage space and store the new running data in the original storage space. That is, the space identifier corresponding to the original storage space is re-associated with the original container.
[0041] Therefore, determining whether the space identifier of the storage space is associated with the container of the deleted process may include: determining the configuration information of the original container corresponding to the process; determining the first space identifier indicated by the configuration information, which is the space identifier associated with the process in the container; and determining whether the first space identifier is the second space identifier of the original storage space corresponding to the process. If the first space identifier is consistent with the second space identifier, it is determined that the space identifier of the original storage space corresponding to the deleted process is associated with the original container corresponding to the process, that is, the original storage space is associated with the original container. Previously, because the process was deleted, the association between the original container and the original storage space was cut off. Later, because the process was restored, the association between the original container and the original storage space was restored.
[0042] The main steps of determining whether a process is restored in the above embodiment are further described below with a specific embodiment. Figure 2 As shown:
[0043] Step S201: Determine the container C corresponding to the deleted process A.
[0044] Step S202: Determine the space identifier indicated by the configuration information of container C.
[0045] Step S203: Determine whether the space identifier is consistent with the space identifier B of the storage space corresponding to process A before deletion. If yes, execute step S204; if not, execute step S205.
[0046] Step S204: Determine that container C is in an associated state with storage space B, and determine that process A is restored.
[0047] Step S205: Determine that container C is in a non-associated state with storage space B, and determine that process A has not been restored.
[0048] In this embodiment, process A runs in container C and stores running data in storage space B.
[0049] Step S103: In response to the process resuming operation within the first preset time after the process is deleted, the data processing mark of the storage space is deleted. Within the first preset time after the process A is deleted, such as within half an hour, if it is detected that container C is associated with storage space B, it is determined that process A is restored within the preset time, and the delayed processing mark corresponding to storage space B is deleted to indicate that the data in storage space B is not processed. The first preset time can be flexibly set according to business needs, and the first preset time is less than the second preset time. Therefore, the first preset time can be determined according to business needs and the second preset time.
[0050] Step S104: In response to the process not being restored within the first preset time, the data in the storage space is deleted according to the data processing mark of the storage space. If the container C is not detected to be associated with the storage space B within the preset time after the process A is deleted, such as half an hour, it is determined that the process A is not restored within the preset time, then according to the delay processing mark corresponding to the storage space B, it is determined whether the time after the process A is deleted reaches a second preset time, such as 1 hour, and if the second preset time of 1 hour is reached, the data in the storage space B is deleted.
[0051] In order to determine whether the data in storage space B meets the deletion condition when process A is not restored within a first preset time, such as half an hour, in an optional embodiment of the present invention, the data in the storage space is deleted according to the data processing mark of the storage space, including: calculating the interval between the deletion time of the process and the current time; judging whether the interval is greater than the second preset time indicated by the preset condition; in response to the interval being greater than the second preset time, determining that the process meets the preset condition; in response to the process meeting the preset condition, deleting the data in the storage space. Determining whether the data in storage space B meets the deletion condition is specifically based on whether the difference between the deletion time of process A and the current time reaches the second preset time, such as 1 hour. In the case where the difference reaches the second preset time, such as 1 hour, that is, in the case where process A meets the preset condition, the data in storage space B is deleted.
[0052] In an optional embodiment of the present invention, the preset conditions indicated by the data processing marks corresponding to different storage spaces are different, that is, the second preset time periods indicated by the preset conditions are different. The second preset time period can be 1 hour, 3 hours, 1 day, 5 days, 1 week or 1 month, etc., and can be flexibly set according to business needs.
[0053] The data deletion method in the above embodiment is further described below with a specific embodiment. Figure 3 As shown:
[0054] Step S301: determine process A and its corresponding storage space B and container C, wherein container C and storage space B are associated with each other.
[0055] Step S302: after process A is deleted, a data processing mark is added to storage space B, and it is determined that the association between container C and storage space B is severed.
[0056] Step S303: within the first preset time period, periodically check container C to determine whether container C is re-associated with storage space B. If yes, execute step S304; if not, execute step S305.
[0057] Step S304: Delete the data processing mark of storage space B.
[0058] Step S305: Determine whether the duration after process A is deleted reaches the second preset duration indicated by the data processing mark. If yes, execute step S306; if not, execute step S305.
[0059] Step S306: Delete the data stored in the storage space B.
[0060] In an optional embodiment of the present invention, the method further includes: after deleting the process, writing the space identifier of the storage space and the deletion time of the process as a data record into a queue to be deleted; traversing each data record in the queue to be deleted, screening out the target space identifier corresponding to the process that meets the preset conditions; determining the corresponding target storage space according to the target space identifier, and deleting the data in the target storage space. After process A is deleted, the space identifier B of storage space B and the deletion time 9:00 of process A are packaged into a data record 1, such as B-9:00, and the data record is written into a queue to form a queue to be deleted, such as Figure 4As shown, the space identifiers B, B1 and B2 of the storage spaces corresponding to the three processes, and the deletion times 9:00, 10:00 and 11:00 respectively corresponding to the three processes are shown. When there are many processes to be deleted, multiple data records 1, 2, 3, ... can be written into the queue to be deleted. When the controller performs data management, each data record in the queue to be deleted can be traversed. For data record 1, according to the deletion time in data record 1, it is determined whether the time interval between the deletion time and the current time reaches the second preset time length, such as 1 hour. If the time interval reaches the second preset time length, such as 1 hour, it is determined that the data in storage space B meets the deletion condition, and the data in storage space B is deleted.
[0061] In an optional embodiment of the present invention, a second preset duration can also be added to the corresponding data record, and the data record can be written into the queue to be deleted. When traversing the queue to be deleted, for each data record corresponding to the deletion time and the second preset duration, determine whether the corresponding data meets the deletion condition. For example, when traversing data record 1, according to the deletion time of process A 9:00 and the second preset duration of 1 hour, determine whether data D meets the deletion condition; for the deletion time of process X of data record 2 Monday and the second preset duration of 3 days, determine that the data Y corresponding to process X meets the deletion condition on Thursday. Furthermore, in addition to indicating the delayed deletion duration, that is, the second preset duration, the data processing mark can also indicate the processing method of the data, such as deletion, backup, mark deletion, etc., so as to achieve differentiated and diversified processing for data in different storage spaces. For each deleted process, the processing method of its corresponding data can be added to the corresponding data record, and the data record is written into the queue to be deleted.
[0062] In order to prevent data that does not meet the deletion conditions from being deleted, in an optional embodiment of the present invention, the method also includes: writing the data identifier of the data stored in the storage space into the data record corresponding to the storage space; deleting the data in the target storage space, including: determining the first data identifier corresponding to the target storage space in the queue to be deleted; determining the second data identifier of the data stored in the target storage space; determining whether the second data identifier is consistent with the first data identifier; in response to the second data identifier being consistent with the first data identifier, deleting the data stored in the target storage space.
[0063] In actual scenarios, there is another situation: when data D in storage space B does not meet the deletion conditions, the relevant personnel manually delete the data D in storage space B, but do not delete the data records of storage space B in the queue to be deleted. The relevant personnel may be operation and maintenance personnel or database administrators, etc. A new process N is created and storage space B is allocated to process N. The process N is run to generate operation data M, and data M is stored in storage space B. This results in two data records corresponding to storage space B appearing in the queue to be deleted, namely B—9:00 and B—9:40. Figure 5 As shown, the space identifiers B, B1, B2 and B of the storage spaces corresponding to the four processes, the deletion times 9:00, 10:00, 11:00 and 9:40 corresponding to the three processes, and the data identifiers D, D1, D2 and M corresponding to the three processes are shown. The deletion time corresponding to one data record is 9:00, and the deletion time corresponding to the other data record is 9:40, and the storage spaces indicated by the two space identifiers B are the same storage space, for example Figure 5 For B-9:00, when it is determined that storage space B meets the deletion condition, if the data in storage space B is directly deleted, it is not the data D corresponding to process A that is deleted, but the data M corresponding to process N, but the data M corresponding to process N has not met the deletion condition. This makes the data M that does not meet the deletion condition be deleted.
[0064] In order to prevent data that does not meet the deletion conditions from being deleted, a corresponding data identifier is added to each data record in the queue to be deleted. For example, after adding data identifier D to data record 1, data record 1 is: B-9:00-D, and the data record corresponding to process N is B-9:00-M. Figure 5 As shown. For data record 1, B—9:00—D, when deleting data, determine the data actually stored in storage space B and its corresponding data identifier M, and compare the data identifier D in the queue to be deleted with the data identifier M of the actually stored data. If the two are consistent, delete the data in storage space B; if the two are inconsistent, it means that the data stored in storage space B cannot be deleted. This avoids the situation where data that does not meet the deletion conditions is deleted. In addition, if the two are inconsistent, it also means that the data D corresponding to the data record B—9:00—D has been deleted, so the data record in the queue to be deleted has become invalid.
[0065] In addition, in order to prevent the invalid data records in the queue to be deleted from interfering with the data deletion, in an optional embodiment of the present invention, the method further includes: in response to the second data identifier being inconsistent with the first data identifier, deleting the data record corresponding to the first data identifier from the queue to be deleted. The invalid data record B-9:00-D is deleted from the queue to be deleted, thereby preventing the controller from traversing the data record again or even multiple times, and then judging whether the deletion condition is met, and comparing the data identifiers, wasting computing resources and saving overhead.
[0066] For process A, in order to prevent accidental deletion of data, in an optional embodiment of the present invention, the method further includes: after executing the step of deleting the data processing mark of the storage space, deleting the data record corresponding to the storage space from the queue to be deleted. After process A is deleted, the data record B-9:00-D corresponding to process A is written into the queue to be deleted. If it is determined at 9:20 that process A is restored, the data record B-9:00-D corresponding to process A is deleted, thereby preventing the situation where data D is determined to meet the deletion condition and deleted according to 9:00 in the queue to be deleted, resulting in the situation of accidental deletion of data.
[0067] The main steps of constructing the queue to be deleted in the above embodiment are further described below with another specific embodiment. Figure 6 As shown:
[0068] Step S601: In response to a process being deleted, a corresponding data processing mark is added to a storage space corresponding to the process.
[0069] Step S602: Write the storage space, deletion time, data identifier, and data processing mark corresponding to the process into the queue to be deleted as a data record.
[0070] Step S603: within the first preset time period, determine whether process A is resumed, if yes, execute step S604; if no, execute step S601.
[0071] Step S604: Delete the data record 1 corresponding to process A from the queue to be deleted.
[0072] The main steps of deleting data by traversing the queue to be deleted in the above embodiment are further described below with another specific embodiment. Figure 7 As shown:
[0073] Step S701: traverse each piece of data in the queue to be deleted.
[0074] Step S702: For data record 1, based on the deletion time 9:00 and the 1 hour indicated by the data processing mark, determine whether data D meets the processing conditions. If yes, execute step S703; if not, execute step S701.
[0075] Step S703: Determine whether the data identifier D in the queue to be deleted is consistent with the data identifier currently actually stored in the storage space B. If yes, execute step S704; if not, execute step S705.
[0076] Step S704: Delete the data in the storage space B according to the data deletion indicated by the data processing mark.
[0077] Step S705: Delete data record 1 in the queue to be deleted.
[0078] The following is a specific example to further illustrate the application of the data deletion method in the above embodiment in Kubernetes. The data deletion method in this embodiment is applied to Kubernetes and includes the following main steps:
[0079] First, traverse the CR (Custom Resource) corresponding to each storage space in Kubernetes, check the spec.suspend field in the CR, and determine whether the data in the storage space needs to be delayed deleted based on the spec.suspend field, and determine the first PVC (PersistentVolumeClaim) corresponding to all storage spaces that need to perform delayed deletion.
[0080] Secondly, the spec.selector field in the CR of all storage spaces is checked. According to the spec.selector field, the second PVC corresponding to the storage space corresponding to the deleted process is determined from the first PVC, and the PVCmap and the queue to be deleted status.WaitingDeletePVCs are constructed according to the second PVC.
[0081] Third, check the pods corresponding to the deleted processes, generate a pod array, traverse the pod array, obtain the PVCs associated with the pods in the pod array, and remove the associated PVCs from the PVCmap.
[0082] Fourth, traverse the queue status.WaitingDeletePVCs to be deleted, and match each traversed PVC with the PVC in PVCmap. If the match fails, delete the traversed PVC from the queue status.WaitingDeletePVCs to be deleted.
[0083] Fifth, according to the deletion time unusedTime of the process corresponding to each PVC in the queue status.WaitingDeletePVCs to be deleted, determine whether the time difference between unusedTime and the current time exceeds the preset delay time spec.reserveMinutes in the CR. If so, determine that the data in the storage space corresponding to the PVC has met the deletion condition.
[0084] Sixth, the data identifier corresponding to the storage space in the to-be-deleted queue that has met the deletion condition is compared with the data identifier of the data actually stored in the storage space to determine whether the two data identifiers are consistent.
[0085] Seventh, if the above two data identifiers are consistent, a deletion request is submitted to kubernetes for the storage space to delete the data in the storage space, and the deletion time of the data, the PVC identifier corresponding to the storage space, the size of the corresponding storage space, and the data identifier of the data stored in the storage space are recorded in the deleted queue status.DeletedPVcs.
[0086] Eighth, determine whether the number of records in the deleted queue status.DeletedPVcs exceeds the upper limit in CR. If so, delete the entries with older deletion time in status.DeeletedPVCs.
[0087] Ninth, update the time record status.lastScheduledTime of the data delayed deletion operation of CR to record the time of this data deletion.
[0088] The data deletion method of the embodiment of the present invention determines the storage space corresponding to the process identifier according to the process identifier of the process in response to the process being deleted; the storage space stores data corresponding to the process; adds a data processing mark to the storage space, the data processing mark indicates that the data in the storage space will be deleted when the process meets the preset conditions; in response to the process resuming operation within the first preset time after the process is deleted, the data processing mark of the storage space is deleted; in response to the process not resuming operation within the first preset time, the data in the storage space is deleted according to the data processing mark of the storage space. Thus, by marking the storage space corresponding to the deleted process, it is determined whether the process is restored within the preset time, and the mark of the storage space is deleted after the process is restored. If the process is not restored, the data in the corresponding storage space is deleted according to the preset conditions indicated by the mark, thereby realizing delayed data deletion, avoiding data loss caused by accidental deletion of the process, and at the same time allowing the storage space to be released in time, avoiding waste of disk space.
[0089] Figure 8 Schematic diagram of main modules of a data deletion device according to an embodiment of the present invention.
[0090] like Figure 8 As shown, the data deletion device 800 of the embodiment of the present invention includes:
[0091] The process monitoring module 801 is used to determine the storage space corresponding to the process identifier according to the process identifier of the process in response to the process being deleted; the storage space stores data corresponding to the process;
[0092] The space management module 802 is used to add a data processing mark to the storage space, the data processing mark indicating that the data in the storage space is deleted when the process meets the preset condition; in response to the process resuming operation within a first preset time period after the process is deleted, delete the data processing mark of the storage space;
[0093] The data deletion module 803 is used to delete the data in the storage space according to the data processing mark of the storage space in response to the process not resuming operation within the first preset time period.
[0094] In an optional embodiment of the present invention, the space management module 802 is also used to determine whether the space identifier of the storage space and the container of the process are in an associated state within a first preset time period; in response to the space identifier and the container of the process being in an associated state, determine that the process corresponding to the space identifier resumes operation within the first preset time period.
[0095] In an optional embodiment of the present invention, the data deletion module 803 is also used to calculate the interval between the deletion time of the process and the current time; determine whether the interval is greater than a second preset time indicated by the preset condition; in response to the interval being greater than the second preset time, determine that the process meets the preset condition; in response to the process meeting the preset condition, delete the data in the storage space.
[0096] Optionally, in an optional embodiment of the present invention, the data deletion module 803 is also used to write the space identifier of the storage space and the deletion time of the process as a data record into the queue to be deleted after deleting the process; traverse each data record in the queue to be deleted, and filter out the target space identifier corresponding to the process that meets the preset conditions; determine the corresponding target storage space according to the target space identifier, and delete the data in the target storage space.
[0097] In an optional embodiment of the present invention, the data deletion module 803 is also used to write the data identifier of the data stored in the storage space into the data record corresponding to the storage space; in the queue to be deleted, determine the first data identifier corresponding to the target storage space; determine the second data identifier of the data stored in the target storage space; determine whether the second data identifier is consistent with the first data identifier; in response to the second data identifier being consistent with the first data identifier, delete the data stored in the target storage space.
[0098] In an optional embodiment of the present invention, the data deletion module 803 is further configured to delete the data record corresponding to the first data identifier from the queue to be deleted in response to the second data identifier being inconsistent with the first data identifier.
[0099] In an optional embodiment of the present invention, the data deletion module 803 is further used to delete the data record corresponding to the storage space from the queue to be deleted after executing the step of deleting the data processing mark of the storage space.
[0100] The data deletion device of the embodiment of the present invention determines the storage space corresponding to the process identifier according to the process identifier of the process in response to the process being deleted; the storage space stores data corresponding to the process; adds a data processing mark to the storage space, the data processing mark indicates that the data in the storage space will be deleted when the process meets the preset conditions; in response to the process resuming operation within the first preset time after the process is deleted, deletes the data processing mark of the storage space; in response to the process not resuming operation within the first preset time, deletes the data in the storage space according to the data processing mark of the storage space. Thus, by marking the storage space corresponding to the deleted process, it is determined whether the process is restored within the preset time, and the mark of the storage space is deleted after the process is restored. If the process is not restored, the data in the corresponding storage space is deleted according to the preset conditions indicated by the mark, thereby realizing delayed data deletion, avoiding data loss caused by accidental deletion of the process, and at the same time allowing the storage space to be released in time, avoiding waste of disk space.
[0101] Fig. 9 An exemplary system architecture 900 is shown to which the data deletion method or data deletion device according to the embodiment of the present invention can be applied.
[0102] like Fig. 9 As shown, the system architecture 900 may include process monitoring terminals 901, 902, 903, a network 907, and data deletion terminals 904, 905, 906. The network 907 is used to provide a medium for communication links between the process monitoring terminals 901, 902, 903 and the data deletion terminals 904, 905, 906. The network 907 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0103] The process monitoring terminals 901, 902, 903 interact with the data deleting terminals 904, 905, 906 through the network 907 to receive or send messages, etc. The process monitoring terminals 901, 902, 903 are devices for monitoring the running status of the process, and the data deleting terminals 904, 905, 906 are controllers of the database, which obtain the process running status information from the process monitoring terminals 901, 902, 903, analyze the process running status information, and determine whether to delete the data corresponding to the process.
[0104] The data deletion terminals 904, 905, and 906 may be servers that provide various services. For example, the data deletion terminals 904, 905, and 906 are background management servers that provide support for obtaining process running status information from the process monitoring terminals 901, 902, and 903 and analyzing and processing the process running status information. The background management server may analyze and process the obtained process running status information, and delete the data in the storage space corresponding to the process according to the processing result.
[0105] It should be noted that the data deletion method provided in the embodiment of the present invention is generally executed by the data deletion terminals 904 , 905 , and 906 . Accordingly, the data deletion device is generally disposed in the data deletion terminals 904 , 905 , and 906 .
[0106] It should be understood that Fig. 9 The number of process monitoring terminals, networks, and data deletion terminals in the embodiment is only for illustration. Any number of process monitoring terminals, networks, and data deletion terminals may be provided according to implementation requirements.
[0107] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of an electronic device suitable for implementing an embodiment of the present invention. Fig.10 The platform end shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0108] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the computer system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0109] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0110] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.
[0111] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0112] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0113] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a process monitoring module, a space management module, and a data deletion module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, a data deletion module may also be described as a "module for deleting data in a storage space."
[0114] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: in response to a process being deleted, determining a storage space corresponding to the process identifier according to the process identifier of the process; the storage space stores data corresponding to the process; adding a data processing mark to the storage space, the data processing mark indicating that the data in the storage space is deleted when the process meets a preset condition; in response to the process resuming operation within the first preset time after the process is deleted, deleting the data processing mark of the storage space; in response to the process not resuming operation within the first preset time, deleting the data in the storage space according to the data processing mark of the storage space.
[0115] According to the technical solution of the embodiment of the present invention, in response to the process being deleted, the storage space corresponding to the process identifier is determined according to the process identifier of the process; the storage space stores data corresponding to the process; a data processing mark is added to the storage space, and the data processing mark indicates that the data in the storage space will be deleted when the process meets the preset conditions; in response to the process resuming operation within the first preset time after the process is deleted, the data processing mark of the storage space is deleted; in response to the process not resuming operation within the first preset time, the data in the storage space is deleted according to the data processing mark of the storage space. Thus, by marking the storage space corresponding to the deleted process, it is determined whether the process is restored within the preset time, and the mark of the storage space is deleted after the process is restored. If the process is not restored, the data in the corresponding storage space is deleted according to the preset conditions indicated by the mark, thereby realizing delayed data deletion, avoiding data loss caused by accidental deletion of the process, and at the same time allowing the storage space to be released in time, avoiding waste of disk space.
[0116] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data deletion method, characterized in that: include: In response to a process being deleted, determining a storage space corresponding to the process identifier according to the process identifier of the process; The storage space stores data corresponding to the process; adding a data processing mark to the storage space, wherein the data processing mark indicates that the data in the storage space is deleted when the process meets a preset condition; In response to the process resuming operation within a first preset time period after the process is deleted, deleting the data processing mark of the storage space; In response to the process not resuming operation within the first preset time period, the data in the storage space is deleted according to the data processing mark of the storage space.
2. The method according to claim 1, characterized in that Also includes: Within the first preset time period, determining whether the space identifier of the storage space and the container of the process are in an associated state; In response to the space identifier being associated with the container of the process, it is determined that the process corresponding to the space identifier resumes running within the first preset time period.
3. The method according to claim 1, characterized in that The deleting the data in the storage space according to the data processing mark of the storage space includes: Calculate the interval between the deletion time of the process and the current time; Determining whether the interval duration is greater than a second preset duration indicated by the preset condition; In response to the interval duration being greater than the second preset duration, determining that the process satisfies the preset condition; In response to the process satisfying the preset condition, the data in the storage space is deleted.
4. The method according to claim 1, characterized in that: Also includes: After deleting the process, writing the space identifier of the storage space and the deletion time of the process into the queue to be deleted as a data record; Traversing each data record in the queue to be deleted, and filtering out the target space identifier corresponding to the process that meets the preset condition; The corresponding target storage space is determined according to the target space identifier, and the data in the target storage space is deleted.
5. The method according to claim 4, characterized in that Also includes: Writing the data identifier of the data stored in the storage space into the data record corresponding to the storage space; The deleting the data in the target storage space includes: In the queue to be deleted, determining a first data identifier corresponding to the target storage space; Determining a second data identifier of the data stored in the target storage space; Determining whether the second data identifier is consistent with the first data identifier; In response to the second data identifier being consistent with the first data identifier, the data stored in the target storage space is deleted.
6. The method according to claim 5, characterized in that Also includes: In response to the second data identifier being inconsistent with the first data identifier, the data record corresponding to the first data identifier is deleted from the queue to be deleted.
7. The method according to claim 4, characterized in that Also includes: After executing the step of deleting the data processing mark of the storage space, the data record corresponding to the storage space is deleted from the queue to be deleted.
8. A data deletion device, characterized in that: include: A process monitoring module, configured to determine, in response to a process being deleted, a storage space corresponding to the process identifier according to the process identifier of the process; The storage space stores data corresponding to the process; a space management module, configured to add a data processing mark to the storage space, wherein the data processing mark indicates that the data in the storage space is deleted when the process meets a preset condition; In response to the process resuming operation within a first preset time period after the process is deleted, deleting the data processing mark of the storage space; The data deletion module is used to delete the data in the storage space according to the data processing mark of the storage space in response to the process not resuming operation within the first preset time period.
9. An electronic device for data processing, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.