Skip to content

notifications: bulk_create missing ignore_conflicts causes duplicate in-app notifications on Celery task retry #9600

Description

@harsh4vardhan

Bug Description

Notification.objects.bulk_create in the
otifications Celery task is missing ignore_conflicts=True. If the task is dispatched twice for the same event (worker restart, Celery retry, duplicate .delay() call upstream), every subscriber receives duplicate in-app notification entries that are permanently visible in their inbox.

The omission stands out because the very next line, EmailNotificationLog.objects.bulk_create, already uses ignore_conflicts=True.

Affected file

�pps/api/plane/bgtasks/notification_task.py, lines 669-670:

`python
Notification.objects.bulk_create(bulk_notifications, batch_size=100)

vs. the line immediately after:

EmailNotificationLog.objects.bulk_create(bulk_email_logs, batch_size=100, ignore_conflicts=True)
`

Failure scenario

  1. A Celery worker processes the
    otifications task and crashes after �ulk_create (before ACK).
  2. The broker re-queues the task. The second worker runs the same task for the same event.
  3. Notification.objects.bulk_create succeeds again (no unique constraint to block it).
  4. Every workspace member who was notified now has two identical entries in their notification feed. These are permanent - there is no deduplication on read.

This also occurs when two Celery Beat instances run (multi-pod deployments) and both schedule the same notification.

Fix

python Notification.objects.bulk_create(bulk_notifications, batch_size=100, ignore_conflicts=True)

A unique constraint on (receiver_id, actor_id, entity_identifier, entity_type) would make the fix robust, but ignore_conflicts=True is the minimal safe change matching the existing email log pattern.

Environment

Plane develop branch (2026-08-13).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions