Skip to content

Conversation

@D3V41
Copy link
Contributor

@D3V41 D3V41 commented Oct 18, 2025

Important

This change has been running in Magenta’s production environment for the past two weeks (as of the time of writing) without any issues.

Problem

The email tool was experiencing significant slowness (5–10 seconds delay) after successfully sending emails. Users were seeing a loading screen for an extended period while the email status was being updated, creating a poor user experience.

Root Cause

The EmailManager.updateEmailStatus() method was using emailLogDao.merge(), which forced Hibernate to re-write large BLOB fields (body, encryptedMessage, internalComment) and eagerly merge related attachments (emailAttachments), even though only status, errorMessage, and timestamp needed to be updated.

Solution

  • Added a new updateEmailStatus() method in EmailLogDao that performs a JPQL bulk update (updates only status, errorMessage, and timestamp)
  • Replaced the merge() call in EmailManager.updateEmailStatus() with this optimized JPQL update method

Outcome

  • Improved performance by 5–10 seconds per status update
  • Eliminated unnecessary BLOB field rewrites and attachment merging

@D3V41 D3V41 marked this pull request as ready for review October 18, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant