Migration possibly reporting the wrong database size change on DB testing job
## What is this about **Tl;DR;** The database testing job reported a DB size change of "+8.00 Kb" for a migration that adds an index. But we added this index async during the weekend, and the index was already part of the test database. So the migration was only supposed to add the index to the schema. **The question is: why did it report adding 8Kb to the database size?** When checking the artifacts produced by the database testing job, I see that indeed no index was created by this migration. Although, there was another migration which also reported "+8.00 Kb" change, which indeed created an index. Could we have a bug in the [`Database size change: <%= total_size_change(migration) %>`](https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/blob/d3c3c105d021395c824a2dc8036446fa31482c90/notifier/templates/detail.erb#L5), which overrides the result of the migration with another one? The migration which should not report the 8Kb was: `AddIndexIssuesOnProjectHealthStatusDescWorkItemType`. The migration which correctly reports the 8Kb was: `AddUniqueIndexForNpmPackagesOnProjectIdNameVersion`. --- The following discussion from gitlab-org/gitlab!124235 should be addressed: - [ ] @project_278964_bot_c29560c0b368f96e598f3882911366f5 started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/124235#note_1446168283): (+5 comments) > <!-- gitlab-org/database-team/gitlab-com-database-testing:identifiable-note --> > ### Database migrations (on the main database) > > > Migrations included in this change have been executed on gitlab.com data for testing purposes. For details, please see the [migration testing pipeline](https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/pipelines/2057478) (limited access). > > | Migration | Type | Total runtime | Result | DB size change | > | --------- | ---- | ------------- | ------ | -------------- | > | 20230620201738 - AddIndexIssuesOnProjectHealthStatusAscWorkItemType | Post deploy | 3.2 s | :white_check_mark: | +0.00 B | > | 20230620201817 - AddIndexIssuesOnProjectHealthStatusDescWorkItemType | Post deploy | 3.0 s | :white_check_mark: | +8.00 KiB | > > <details> > <summary>Runtime Histogram for all migrations</summary> > > | Query Runtime | Count | > |---------------|-------| > |0 seconds - 0.01 seconds | 0 | > |0.01 seconds - 0.1 seconds | 4 | > |0.1 seconds - 1 second | 0 | > |1 second - 5 seconds | 0 | > |5 seconds - 15 seconds | 0 | > |15 seconds - 5 minutes | 0 | > |5 minutes + | 0 | > > </details> > > > #### Migration: <b>20230620201738 - AddIndexIssuesOnProjectHealthStatusAscWorkItemType</b> > > * Type: Post deploy > * Duration: 3.2 s > * Database size change: +0.00 B > > | Calls | Total Time | Max Time | Mean Time | Rows | Query | > | ----- | ---------- | -------- | --------- | ---- | ----- | > | 2 | 0.0 ms | 0.0 ms | 0.0 ms | 2 | <pre>SELECT pg_backend_pid()</pre> | > > > <details> > <summary>Histogram for AddIndexIssuesOnProjectHealthStatusAscWorkItemType</summary> > > | Query Runtime | Count | > |---------------|-------| > |0 seconds - 0.01 seconds | 0 | > |0.01 seconds - 0.1 seconds | 2 | > |0.1 seconds - 1 second | 0 | > |1 second - 5 seconds | 0 | > |5 seconds - 15 seconds | 0 | > |15 seconds - 5 minutes | 0 | > |5 minutes + | 0 | > > </details> > > #### Migration: <b>20230620201817 - AddIndexIssuesOnProjectHealthStatusDescWorkItemType</b> > > * Type: Post deploy > * Duration: 3.0 s > * Database size change: +8.00 KiB > > | Calls | Total Time | Max Time | Mean Time | Rows | Query | > | ----- | ---------- | -------- | --------- | ---- | ----- | > | 2 | 0.0 ms | 0.0 ms | 0.0 ms | 2 | <pre>SELECT pg_backend_pid()</pre> | > > > <details> > <summary>Histogram for AddIndexIssuesOnProjectHealthStatusDescWorkItemType</summary> > > | Query Runtime | Count | > |---------------|-------| > |0 seconds - 0.01 seconds | 0 | > |0.01 seconds - 0.1 seconds | 2 | > |0.1 seconds - 1 second | 0 | > |1 second - 5 seconds | 0 | > |5 seconds - 15 seconds | 0 | > |15 seconds - 5 minutes | 0 | > |5 minutes + | 0 | > > </details> > > > > #### Other information > > <details> > <summary>Other migrations pending on GitLab.com</summary> > > | Migration | Type | Total runtime | Result | DB size change | > | --------- | ---- | ------------- | ------ | -------------- | > | 20230616164309 - CreateSubscriptionUserAddOnAssignments | Regular | 2.4 s | :warning: | +32.00 KiB | > | 20230616164705 - AddForeignKeyAddOnPurchaseIdOnSubscriptionUserAddOnAssignments | Regular | 2.1 s | :white_check_mark: | +0.00 B | > | 20230616164731 - AddForeignKeyUserIdOnSubscriptionUserAddOnAssignments | Regular | 1.9 s | :white_check_mark: | +0.00 B | > | 20230621065943 - AddElasticsearchRequeueWorkersToApplicationSettings | Regular | 1.5 s | :white_check_mark: | +0.00 B | > | 20230621070810 - UpdateRequeueWorkersInApplicationSettingsForGitlabCom | Regular | 1.5 s | :white_check_mark: | +0.00 B | > | 20230608145500 - AddPreparedAtIndexToMergeRequests | Post deploy | 2.9 s | :white_check_mark: | +0.00 B | > | 20230616082958 - AddUniqueIndexForNpmPackagesOnProjectIdNameVersion | Post deploy | 45.0 s | :warning: | +131.03 MiB | > | 20230619123701 - ScheduleRemovalIndexJobArtifactsIdAndExpireAt | Post deploy | 2.2 s | :white_check_mark: | +0.00 B | > | 20230620134708 - ValidateUserTypeConstraint | Post deploy | 56.2 s | :warning: | +0.00 B | > > </details> > > <details> > <summary>Clone details</summary> > > | Clone ID | Clone Created At | Clone Data Timestamp | Expected Removal Time | > | -------- | ---------------- | -------------------- | --------------------- | > | [`database-testing-2057478-10440087-main`](https://console.postgres.ai/gitlab/gitlab-production-tunnel/instances/59/clones/database-testing-2057478-10440087-main) | 2023-06-26T17:26:16Z | 2023-06-26T16:22:49Z | 2023-06-27 05:32:37 +0000 | > | [`database-testing-2057478-10440087-ci`](https://console.postgres.ai/gitlab/gitlab-production-ci/instances/165/clones/database-testing-2057478-10440087-ci) | 2023-06-26T17:26:16Z | 2023-06-26T16:46:57Z | 2023-06-27 05:32:37 +0000 | > > </details> > > [Job artifacts](https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/jobs/10440088/artifacts/browse/migration-testing/) > > <!-- JSON: eyJ2ZXJzaW9uIjoyLCJkYXRhIjpbeyJ2ZXJzaW9uIjoyMDIzMDYyMDIwMTcz > OCwid2FsbHRpbWUiOjMuMTUyNzUwMTEyMTE2MzM3LCJ0b3RhbF9kYXRhYmFz > ZV9zaXplX2NoYW5nZSI6MCwic3VjY2VzcyI6dHJ1ZX0seyJ2ZXJzaW9uIjoy > MDIzMDYyMDIwMTgxNywid2FsbHRpbWUiOjMuMDI1MTk3Njg0NzY0ODYyLCJ0 > b3RhbF9kYXRhYmFzZV9zaXplX2NoYW5nZSI6ODE5Miwic3VjY2VzcyI6dHJ1 > ZX1dfQ== > --> > <!-- gitlab-org/database-team/gitlab-com-database-testing:identifiable-note --> > ### Database migrations (on the ci database) > > > Migrations included in this change have been executed on gitlab.com data for testing purposes. For details, please see the [migration testing pipeline](https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/pipelines/2057478) (limited access). > > | Migration | Type | Total runtime | Result | DB size change | > | --------- | ---- | ------------- | ------ | -------------- | > | 20230620201738 - AddIndexIssuesOnProjectHealthStatusAscWorkItemType | Post deploy | 3.7 s | :white_check_mark: | +0.00 B | > | 20230620201817 - AddIndexIssuesOnProjectHealthStatusDescWorkItemType | Post deploy | 3.7 s | :white_check_mark: | +8.00 KiB | > > <details> > <summary>Runtime Histogram for all migrations</summary> > > | Query Runtime | Count | > |---------------|-------| > |0 seconds - 0.01 seconds | 0 | > |0.01 seconds - 0.1 seconds | 4 | > |0.1 seconds - 1 second | 0 | > |1 second - 5 seconds | 0 | > |5 seconds - 15 seconds | 0 | > |15 seconds - 5 minutes | 0 | > |5 minutes + | 0 | > > </details> > > > #### Migration: <b>20230620201738 - AddIndexIssuesOnProjectHealthStatusAscWorkItemType</b> > > * Type: Post deploy > * Duration: 3.7 s > * Database size change: +0.00 B > > | Calls | Total Time | Max Time | Mean Time | Rows | Query | > | ----- | ---------- | -------- | --------- | ---- | ----- | > | 2 | 0.0 ms | 0.0 ms | 0.0 ms | 2 | <pre>SELECT pg_backend_pid()</pre> | > > > <details> > <summary>Histogram for AddIndexIssuesOnProjectHealthStatusAscWorkItemType</summary> > > | Query Runtime | Count | > |---------------|-------| > |0 seconds - 0.01 seconds | 0 | > |0.01 seconds - 0.1 seconds | 2 | > |0.1 seconds - 1 second | 0 | > |1 second - 5 seconds | 0 | > |5 seconds - 15 seconds | 0 | > |15 seconds - 5 minutes | 0 | > |5 minutes + | 0 | > > </details> > > #### Migration: <b>20230620201817 - AddIndexIssuesOnProjectHealthStatusDescWorkItemType</b> > > * Type: Post deploy > * Duration: 3.7 s > * Database size change: +8.00 KiB > > | Calls | Total Time | Max Time | Mean Time | Rows | Query | > | ----- | ---------- | -------- | --------- | ---- | ----- | > | 2 | 0.0 ms | 0.0 ms | 0.0 ms | 2 | <pre>SELECT pg_backend_pid()</pre> | > > > <details> > <summary>Histogram for AddIndexIssuesOnProjectHealthStatusDescWorkItemType</summary> > > | Query Runtime | Count | > |---------------|-------| > |0 seconds - 0.01 seconds | 0 | > |0.01 seconds - 0.1 seconds | 2 | > |0.1 seconds - 1 second | 0 | > |1 second - 5 seconds | 0 | > |5 seconds - 15 seconds | 0 | > |15 seconds - 5 minutes | 0 | > |5 minutes + | 0 | > > </details> > > > > #### Other information > > <details> > <summary>Other migrations pending on GitLab.com</summary> > > | Migration | Type | Total runtime | Result | DB size change | > | --------- | ---- | ------------- | ------ | -------------- | > | 20230616164309 - CreateSubscriptionUserAddOnAssignments | Regular | 2.7 s | :white_check_mark: | +40.00 KiB | > | 20230616164705 - AddForeignKeyAddOnPurchaseIdOnSubscriptionUserAddOnAssignments | Regular | 2.7 s | :white_check_mark: | +0.00 B | > | 20230616164731 - AddForeignKeyUserIdOnSubscriptionUserAddOnAssignments | Regular | 2.8 s | :warning: | +0.00 B | > | 20230621065943 - AddElasticsearchRequeueWorkersToApplicationSettings | Regular | 2.3 s | :white_check_mark: | +0.00 B | > | 20230621070810 - UpdateRequeueWorkersInApplicationSettingsForGitlabCom | Regular | 2.2 s | :white_check_mark: | +0.00 B | > | 20230608145500 - AddPreparedAtIndexToMergeRequests | Post deploy | 4.3 s | :white_check_mark: | +0.00 B | > | 20230616082958 - AddUniqueIndexForNpmPackagesOnProjectIdNameVersion | Post deploy | 3.4 s | :white_check_mark: | +8.00 KiB | > | 20230619123701 - ScheduleRemovalIndexJobArtifactsIdAndExpireAt | Post deploy | 2.8 s | :white_check_mark: | +0.00 B | > | 20230620134708 - ValidateUserTypeConstraint | Post deploy | 2.3 s | :white_check_mark: | +0.00 B | > > </details> > > <details> > <summary>Clone details</summary> > > | Clone ID | Clone Created At | Clone Data Timestamp | Expected Removal Time | > | -------- | ---------------- | -------------------- | --------------------- | > | [`database-testing-2057478-10440087-main`](https://console.postgres.ai/gitlab/gitlab-production-tunnel/instances/59/clones/database-testing-2057478-10440087-main) | 2023-06-26T17:26:16Z | 2023-06-26T16:22:49Z | 2023-06-27 05:32:37 +0000 | > | [`database-testing-2057478-10440087-ci`](https://console.postgres.ai/gitlab/gitlab-production-ci/instances/165/clones/database-testing-2057478-10440087-ci) | 2023-06-26T17:26:16Z | 2023-06-26T16:46:57Z | 2023-06-27 05:32:37 +0000 | > > </details> > > [Job artifacts](https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/jobs/10440088/artifacts/browse/migration-testing/) > > <!-- JSON: eyJ2ZXJzaW9uIjoyLCJkYXRhIjpbeyJ2ZXJzaW9uIjoyMDIzMDYyMDIwMTcz > OCwid2FsbHRpbWUiOjMuNzQ2MDY3OTcwOTkxMTM0NiwidG90YWxfZGF0YWJh > c2Vfc2l6ZV9jaGFuZ2UiOjAsInN1Y2Nlc3MiOnRydWV9LHsidmVyc2lvbiI6 > MjAyMzA2MjAyMDE4MTcsIndhbGx0aW1lIjozLjc0NjE2NjQ2MDIxNjA0NTQs > InRvdGFsX2RhdGFiYXNlX3NpemVfY2hhbmdlIjo4MTkyLCJzdWNjZXNzIjp0 > cnVlfV19 > --> > --- > Brought to you by [gitlab-org/database-team/gitlab-com-database-testing](https://gitlab.com/gitlab-org/database-team/gitlab-com-database-testing). [Epic](https://gitlab.com/groups/gitlab-org/database-team/-/epics/9)
issue