ADR: Recover a soft deleted record in storage
Ability to recover a soft deleted record in storage service
Decision Title
Status
-
Proposed -
Trialing -
Under review -
Approved -
Retired
Context & Scope
The storage service provides 2 ways to delete a record. One way is to logically delete the record in which the record with same id can be revived later because its version history is maintained and the other one is to purge the record in which case, the record's version history is deleted too. In both types of deletions, the record cannot be accessed using storage or search service.
Today there is no easy way to query or recover the soft-deleted records. Providing admin-only APIs will help admins to search, view and recover the soft-deleted data if required.
Tradeoff Analysis - Input to decision
Today users have to maintain the soft deleted record IDs on their own. Below is the workaround available today to attempt recovery of such records
- Recreate the record with existing id and random/empty data and meta blocks. This will mark the record as active.
- Fetch all versions of the record.
- Fetch the latest version prior to the one just created to get back the actual record data and meta blocks.
- Recreate the record using the response to create a new version of the record with the appropriate data.
Decision
Create 3 new APIs as below
- Fetch deleted records (accessible to users.datalake.admins) -> This will fetch a list of records. Since the list can be very long it should return a maximum of 100 records and support a from and to deletion dates filter along with pagination.
- Recover deleted records by id (accessible to users.datalake.admins) -> This will take a list of record ids (max 500) that are to be recovered and return the list of record ids that succeeded as well as failed.
- Recover deleted records by metadata filters (Currently support for only fromDeletedDate and toDeletedDate) (accessible to users.datalake.admins) -> This will take filter criteria of records that are to be recovered and return the list of record ids that succeeded as well as failed.
Consequences
- This will help users to bulk recover deleted records in a single go.
- The APIs will help prevent having garbage record versions that had to be created just to make the record active.
- This will help users to fetch a list of soft deleted records which was not possible earlier.
Open API spec for the service storage-recover-swagger.yaml