Skip to content

ADR: Delete record versions

Status

  • Proposed
  • Trialing
  • Under review
  • Approved
  • Retired

Problem Statement

Storage service allows creation of record versions without any restrictions. Once number of record versions goes beyond certain limit (e.g. 1K for Azure), it's very costly to fetch the record. Please refer to ADR for more details.

ADR implementation restricts the maximum number of versions to avoid any accidently cost spikes.

This ADR proposes a solution to delete record versions.

Back to TOC

Proposed solution

Storage API should provide a new endpoint to delete record versions. It will permanently delete record versions and operation cannot be undone. Users must be member of 'users.datalake.admins' role and OWNER of the record

API specification
"/records/{id}/versions":
    delete:
      tags:
        - Records
      summary: Purge record versions
      description: "The API performs the permanent physical deletion of the given record versions excluding latest version and any linked records or files if there are any. 
      If 'from' query parameter is used then it will delete all versions before current one (exclusive). If 'limit' query parameter is used then it will delete oldest versions defined by 'limit'. 
      If both 'from' and 'limit' are used then API will delete 'limit' number of versions starting 'from' version. Instead of using 'limit' or 'from', list of versions can be provided on 'versionIds' query parameter. 
      API will delete all versions defined by 'versionIds' query parameter. Maximum 50 record versions can be deleted per request.
      This operation cannot be undone. Required roles: 'users.datalake.admins' who is the OWNER of the record."
      operationId: Purge record versions
      parameters:
        - name: id
          in: path
          description: Valid record id following "^[\\w\\-\\.]+:[\\w-\\.]+:[\\w\\-\\.\\:\\%]+$" pattern
          required: true
          schema:
            type: string
        - name: from
          in: query
          description: Record version id from which all record versions aside from the current one are deleted
          required: false
          schema:
            type: long
        - name: limit
          in: query
          description: Number of oldest record versions to be deleted. Value must not exceed number of record versions (excluding latest version) 
          required: false
          schema:
            type: integer
        - name: versionIds
          in: query
          description: Comma separated version list (excluding latest version) to be deleted. Maximum 50 versions can be deleted per request. 
          required: false
          schema:
            type: string
        - name: data-partition-id
          in: header
          description: Tenant Id
          required: true
          schema:
            type: string
      responses:
        "204":
          description: Record deleted successfully.
        "400":
          description: Validation error.
          content:
             application/json:
                schema:
                   $ref: "#/components/schemas/AppError"
        "403":
          description: User not authorized to perform the action.
          content:
             application/json:
                schema:
                   $ref: "#/components/schemas/AppError"
        "404":
          description: Record not found.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AppError"
        "500":
          description: Unknown Error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AppError"
      security:
        - bearer: []

Back to TOC

Consequences

  • New API added to Storage service
  • New endpoint is available on Storage service's swagger page
  • Tutorial is updated with new endpoint

Back to TOC

Edited by Neelesh Thakur