--- tags: Ozone --- # Process deleting keys in trash-enabled buckets In recovery side of [design doc](https://issues.apache.org/jira/secure/attachment/12985273/Ozone_Trash_Feature.docx), we should process the issue when deleting keys in trash-enabled buckets. **note** - buckets are opt-in with trash-enabled. - using recovery window. (For example, if we set recovery-window 4 hours, we will get keys deleted up to 4hr) ## Method 1 ### Create a new table to cache them. When deleting the keys in trash-enabled buckets, we would add the deleted key to the **new-table** up to the time of `RECOVERY_WINDOW`. After timeout or empty-trash, we set the deleted key to the original `DeleteKeyRequest`. ## Method 2 (:heavy_check_mark:) ### Process along the original flow of deleting key, and recoverd key from original `deletedTable`. We set [`modificationTime`](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyDeleteRequest.java#L81L82) when deleting key. So I think we can compare the `modificationTime` with `RECOVERY_WINDOW` to exclude keys(exist in trash-enabled buckets) from purging. Code snippet would be added after this [line](https://github.com/apache/hadoop-ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java#L923) might like ```Java if (trashEnable(info.getBucketName()) && (Time.now() - info.getModificationTime()) < RECOVERY_WINDOW) { /* Would not delete key in this situation. */ } ```