Clear Jira Mail Queue

Deleted user March 4, 2013

I have a backlog of old emails in my JIRA queue that I would like to delete, hundreds. I have read that stopping the JIRA service and starting it again will clear this but the emails just seem to go back into the queue again when started.

7 answers

0 votes
Patrick S
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 21, 2018

I just spent way too much time fixing this on our JSD instance, so I'm publishing this answer on every article that seems related in case it saves others time.

This answer does involve some database manipulation (the email queue is stored in AO_4E8AE6_NOTIF_BATCH_QUEUE), which I know is frowned upon, but it was the only thing that worked after trying every other solution I found (clearing caches, changing ntp, trying safe mode, etc).

  1. Take note of the emails that are failing to send. This will be obvious in the Mail Queue (Admin Cog → System → Mail Queue).

    1. -- AO_4E8AE6_NOTIF_BATCH_QUEUE is where the mail queue is stored in the database
      -- This will return the matching emails in the database
      select
      -- Join the project key on the issue number to get something the issueKey <PROJ-325>
      distinct p.pkey + '-' + cast(i.issuenum as varchar) as issueKey
      -- AO_4E8AE6_NOTIF_BATCH_QUEUE is the table that stores the pending notifications. This is the email queue!
      from JIRAServiceDesk.jiraschema.AO_4E8AE6_NOTIF_BATCH_QUEUE as q
      left join jiraschema.jiraissue i on i.id = q.ISSUE_ID
      left join jiraschema.project p on p.id = i.PROJECT
  2. Stop the JIRA website
  3. Delete all indexes
    1. rm {JIRA-HOME}/caches/indexes/* -f -R
  4. Backup the records that are failing to send for safe-keeping in SQL server
    1. select q.*
      into JIRAServiceDesk.jiraschema.[AO_4E8AE6_NOTIF_BATCH_QUEUE-BACKUP_BEFORE_CLEARING_QUEUE]
      from JIRAServiceDesk.jiraschema.AO_4E8AE6_NOTIF_BATCH_QUEUE as q
      where q.SENT_TIME is null
  5. Set the SENT_TIME on the stuck notifications so they don't try to send again.
    1. update JIRAServiceDesk.jiraschema.AO_4E8AE6_NOTIF_BATCH_QUEUE
      set SENT_TIME = 1526297477500 -- UNIX time that wasn't used on any other issues
      where sent_time is null
  6. Start the Service Desk.
  7. Confirm that the Mail Queue is empty in the  (Admin Cog → System → Mail Queue).
  8. Run a Locked index to rebuild the ones we deleted (Admin Cog → System → Indexing → Lock JIRA and rebuild index)
  9. Continue to monitor the Mail Queue as Customer Notifications should be sent out.
0 votes
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2013

Do a user lookup by email of your incoming address. If a user has been created, this can happen. What mail handler are you using?

0 votes
Deleted user March 5, 2013

My mail queue is 1218 and growing. I've canged my SMTP detail to somethigng invalid so emails don't get sent

0 votes
Deleted user March 5, 2013

It actually looks like some sort of email loop as apposed to a back log of emails. I cleared all the emails from the inbox of the account that jira uses. Now it appears that there are 5-6 tickets that are in a loop of continuous emial notification/jira comments being added.

0 votes
codelab expert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2013

Stopping and starting the service don't delete the mail queue. Please go to your admin page where you configure the mail service. There you will find a button which will clear the mail queue.

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 17, 2013

That's not true, you cannore remove the queue from the interface, the only way to remove it is to restart Jira. Flushin does SENT the emails NOW.

Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 17, 2013

Actually, if you Disable the Outbound Mail (there is a button in the UI), doing a Mail Queue Flush will actually result in the clearing of the current Queue. Given the error queue can be deleted too, seems possible to do this through the UI?

Like Ivkov Max likes this
0 votes
Naren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2013

If its still putting the outgoing emails in queure again then you must check with the SMTP server configration with JIRA or if there is a memory problem. You can check for the cause in the application server log file.

You may like to refer this below links -

https://confluence.atlassian.com/display/JIRAKB/Mail+Queue+Never+Flushed+Automatically

https://confluence.atlassian.com/display/JIRA041/Troubleshoot+Mail+Notification+Problems

0 votes
richie_gee
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2013

Hi there,

You seems to be bumping into this issue as the documentation below:

https://confluence.atlassian.com/display/JIRAKB/Mail+Queue+Never+Flushed+Automatically

Try to see if the resolution helps.

Hope it helps, cheers :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events