Skip to content

Remove obsolete wiki notes

What does this MR do and why?

In this MR we're adding a background migration to remove obsolete Wiki notes. It seems they were created during the early stages of the platform and, at some point, it was decided not to use them. Besides, it's impossible to create or interact with them with the current codebase.

There are only 5 of them in the production database:

gitlabhq_production=> SELECT COUNT(*) FROM "notes" WHERE "notes"."noteable_type" = 'Wiki';
 count
-------
     5
(1 row)

And they are quite old:

gitlabhq_production=> SELECT id, noteable_type, created_at FROM "notes" WHERE "notes"."noteable_type" = 'Wiki';
97  | Wiki          | 2012-12-12 21:17:42+00
98  | Wiki          | 2012-12-12 21:30:22+00
110 | Wiki          | 2012-12-19 13:11:43+00
242 | Wiki          | 2013-01-16 10:38:21+00
272 | Wiki          | 2013-01-23 02:23:21+00

Therefore, given the number of them in the database and that self-hosted customers don't have them either, we can safely remove them all at once in a single post-migration.

SQL times

Migration times

== 20220322094410 RemoveWikiNotes: migrating ==================================
== 20220322094410 RemoveWikiNotes: migrated (0.0391s) =========================
== 20220322094410 RemoveWikiNotes: reverting ==================================
== 20220322094410 RemoveWikiNotes: reverted (0.0000s) =========================

Query times

The final query is:

DELETE FROM notes WHERE notes.noteable_type = 'Wiki' AND notes.id IN (97, 98, 110, 242, 272)

The times with warm caches are:

Time: 0.426 ms
  - planning: 0.233 ms
  - execution: 0.193 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 32 (~256.00 KiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 1 (~8.00 KiB)
  - writes: 0

The query plan is https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/9448/commands/33538

MR acceptance checklist

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

Related to #353381 (closed)

Edited by Francisco Javier López

Merge request reports

Loading