Criticité : 🔴 Élevée (Empêche l'utilisateur de recevoir les notifications push lors de l'alerte concernée)
Occurrences (sur 28 j) : ~4 occurrences (impactant de nouveaux utilisateurs)
Description of the issue
When multiple BREAK_IN_ALERT or SENTRY_ALERT events are triggered simultaneously for a user who doesn't have a NotificationPreferences record yet, the VehicleAlertNotifierService attempts to create it concurrently. This results in a PostgreSQL unique constraint violation (PK_notification_preferences_userId - code 23505).
Steps to Reproduce
- Trigger multiple concurrent alerts for a new user without notification preferences.
- The
findOrCreatePreferences method triggers multiple concurrent INSERT queries.
Expected Behavior
The service should handle concurrent inserts gracefully, either by catching the unique constraint error and fetching the newly created record, or by using a Postgres upsert mechanism (e.g., ON CONFLICT DO NOTHING).
Logs
[NOTIFICATION_ERROR] Failed to send BREAK_IN_ALERT to user X...
Key ("userId")=(X) already exists. (code: 23505)
Criticité : 🔴 Élevée (Empêche l'utilisateur de recevoir les notifications push lors de l'alerte concernée)
Occurrences (sur 28 j) : ~4 occurrences (impactant de nouveaux utilisateurs)
Description of the issue
When multiple
BREAK_IN_ALERTorSENTRY_ALERTevents are triggered simultaneously for a user who doesn't have aNotificationPreferencesrecord yet, theVehicleAlertNotifierServiceattempts to create it concurrently. This results in a PostgreSQL unique constraint violation (PK_notification_preferences_userId- code 23505).Steps to Reproduce
findOrCreatePreferencesmethod triggers multiple concurrentINSERTqueries.Expected Behavior
The service should handle concurrent inserts gracefully, either by catching the unique constraint error and fetching the newly created record, or by using a Postgres
upsertmechanism (e.g.,ON CONFLICT DO NOTHING).Logs