Repository navigation
[2.x] fix: Key the notification email dedup lock on the notification, not its type - #4989
Merged
Merged
Conversation
…ts type SendEmailNotificationJob takes a short-lived lock so that two identical jobs racing through the queue only send one email. The lock was keyed on the notification type and recipient alone, so a genuinely different notification of the same type to the same user within the lock's lifetime was dropped too - a GDPR erasure request made, cancelled, then made again never sent its second confirmation email, leaving the user with no link. Key the lock on the notification's identity instead - type, sender, subject and data, the same attributes matchingBlueprint uses - so the notification-row guard and the email guard now agree on what counts as the same notification. A repeat of the same event is still deduplicated; a distinct notification of the same type sends as it should. Adds a core test that two distinct notifications of one type both email, alongside one proving two separate jobs for the same notification still email once, and a gdpr test covering request, cancel, re-request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
NotificationSyncer::sync()queues aSendEmailNotificationJobper recipient on every call, so whensync()fires twice in quick succession for the same notification (Posted then Revised, say) two identical jobs land in the queue for the same recipient.SendEmailNotificationJobguards against that with a short-lived atomic lock — the first job sends, the rest no-op.That lock was keyed on the notification's type and recipient alone. So a genuinely different notification of the same type to the same user, within the lock's 600s lifetime, was also dropped. The clearest case: a user requests account erasure, cancels it, then requests again — the second request reuses
gdpr_erasure_confirmfor the same user, hits the still-held lock, and its confirmation email is silently discarded. The user is left waiting for a link that never arrives, with no way to complete the request.This keys the lock on the notification's identity — type, sender, subject and data, the same attributes
Notification::matchingBlueprint()uses to decide whether two blueprints are the same notification:This also brings the email guard into line with the notification-row guard:
SendNotificationsJobalready dedupes onmatchingBlueprintidentity, so the row and the email now agree on what counts as the same notification, rather than the email half being coarser.Reviewers should focus on:
matchingBlueprintderives it, so the email guard and the row guard can't disagree.Necessity
SendEmailNotificationJob.Confirmed
composer test).Required changes: