Implement targeted message deletion via background job
What does this MR do and why?
This MR moves the targeted message deletion from a synchronous operation to an asynchronous background job.
Closes: #581579
Related sql:
Query plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/46312/commands/141359
DELETE FROM targeted_messages WHERE id = <id>
Query plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/46312/commands/141364
DELETE FROM "targeted_message_dismissals"
WHERE "id" IN (
SELECT "id" FROM "targeted_message_dismissals"
WHERE "targeted_message_dismissals"."targeted_message_id" = 1
ORDER BY "targeted_message_dismissals"."id" ASC
LIMIT 1000
)
Query plan: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/46367/commands/141454
DELETE FROM "targeted_message_namespaces"
WHERE "id" IN (
SELECT "id" FROM "targeted_message_namespaces"
WHERE "targeted_message_namespaces"."targeted_message_id" = 1
ORDER BY "targeted_message_namespaces"."id" ASC
LIMIT 1000
)
References
Screenshots or screen recordings
This is a bad tophat, but the changes work with the background deletes.
| Before | After |
|---|---|
|
|
How to set up and validate locally
Example:
- Simulate SaaS: https://docs.gitlab.com/development/ee_features/#simulate-a-saas-instance
- In rails console, run the following:
Feature.enable(:targeted_messages_admin_ui) namespace1 = Namespace.first namespace2 = Namespace.second Notifications::TargetedMessage.create!( target_type: :banner_page_level, namespaces: [namespace1, namespace2] ) - Visit
localhost:3000/admin/targeted_messagesand you will see a targeted_message existing - Delete the message and you will see a banner. -->
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #581579!
Edited by Roy Liu

