Mail.Que database too large

Hello,

Today I will show you how to safely delete and recreate the mail.que – mail queue database file in Exchange server. Upon deletion of the mail.que Exchange will auto create a new mail.que database file, once you restart the Microsoft Exchange transport service.

This is useful, if your mail.que file is getting too large or consuming a lot of space on your drive, but be sure to properly investigate the root cause of the growth, such as safetynetholdtime, pipeline tracing value etc – In my case the safetynetholdtime value Exchange 2016 was set to 7 days which caused the growth of mail.que. MS has a good article to get started on these settings –  https://docs.microsoft.com/en-us/powershell/module/exchange/mail-flow/set-transportconfig?view=exchange-ps

Using Exchange management powershell we can check the existing size of mail.que

Get-ChildItem “D:\Exchange Server\TransportRoles\data\Queue\mail.que” |select name,@{Label=”size”;Expression={“{0:N0}” -F ($_.Length/1GB)}}

screenshot-20190116161259-906x110
screenshot-20190116165503-667x215

By default  your mail.que file location should be at :-  %ExchangeInstallPath%TransportRoles\data\Queue

  1. Put your server in maintenance mode in SCOM etc, or best schedule to perform these actions during out of business hours.
  2. Suspend Microsoft Exchange Transport service (NOT STOP) This will allow the current queue to no longer accept more mails in queue and until the remaining mails are sent out:-
  3.  Suspend-service -name “Microsoft Exchange Transport”
  4. Get-queue  – to check and ensure queues are empty.
  5.  Wait for the queue to drain and ensure no more mails in queue, and message count is 0.   keep checking with Get-Queue. Do not worry about shadow redundancy. Once queues is empty it is now safe to stop the transport service.
  6. Stop-service -name “Microsoft Exchange Transport”
  7. Go over to the mail.que location, select all and move to a different folder or drive with enough space, you can rename it as mail.que.old backup
  8. Start the transport service
  9. Start-service -name “Microsoft Exchange Transport”
  10. You will see a new mail.que is auto created
  11. Get-queue  – check and monitor and ensure mail flow is back to normal

Tip: use a tool such as Treesize free to get a detailed view of files and the size in your drive. It can come in handy when you want to check the size of files in your exchange data path.