Skip to content

Create mutation for bulk deletion of artifacts

What does this MR do and why?

  1. Add a mutation that will delete more than one artifact by taking in an array of artifact IDs.
  2. Introduce BulkDeleteService for artifacts

Related to #33348 (closed) and frontend changes are tracked in !111389 (merged)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Enable the feature flag in rails console ($rails c)
Feature.enable(:ci_job_artifact_bulk_destroy)
  1. Navigate to the graphql explorer
http://localhost:3000/-/graphql-explorer. # can be different based on gdk config
  1. Copy and paste and run the following query to the graphql explorer to test:
mutation {
  bulkDestroyJobArtifacts(input:{
    projectId: "gid://gitlab/Project/1123",
    ids: ["gid://gitlab/Ci::JobArtifact/1838", "gid://gitlab/Ci::JobArtifact/2957"]
  }) {
     destroyedCount
     destroyedIds
     errors
  }
}

Database Queries

EXPLAINS was executed to delete the maximum allowed batch in 50 ci_job_artifacts

executed 3 explains with reset database after each.

SQLs
explain DELETE FROM ci_job_artifacts WHERE id IN (
2962926,2962980,2963018,2963040,2963268,2963289,2963437,2963500,2963537,2963595,2963622,2963623,
2963663,2963727,2963737,2963834,2963837,2963900,2963908,2963925,2963980,2964009,2964010,2964013,
2964048,2964105,2964128,2964158,2964218,2964248,2964257,2964264,2964301,2964329,2964360,2964373,
2964405,2964425,2964427,2964452,2964460,2964465,2964501,2964503,2964506,2964522,2964537,2964563,
2964567,2964597)
Time: 22.187 ms
  - planning: 9.564 ms
  - execution: 12.623 ms
    - I/O read: 2.381 ms
    - I/O write: 0.000 ms
Query plan https://console.postgres.ai/shared/e585725a-f12d-4c3c-9a03-d9ea57d652ae
Time: 39.657 ms  
  - planning: 21.172 ms  
  - execution: 18.485 ms  
    - I/O read: 2.497 ms  
    - I/O write: 0.000 ms 
Query plan https://console.postgres.ai/shared/812e4dfe-8fbe-4d72-9a32-624accbdd9a8
Time: 73.996 ms  
  - planning: 13.524 ms  
  - execution: 60.472 ms  
    - I/O read: 20.852 ms  
    - I/O write: 0.000 ms  
Query plan https://console.postgres.ai/shared/3e548e8c-b7f1-413d-b7ff-0c1244b05a49

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Dmytro Biryukov

Merge request reports

Loading