Email's are stuck in state "waiting to send" RRS feed

  • Question

  • For the last few days emails in a single organization, in an environment with several organizations, have begun stalling when being sent through the email router.

    • The user has email router outgoing
    • The email router gives a successful when testing the access of the user in question
    • The email router works for 3 other organizations
    • The outgoing smtp server has sucesfully sent mails from that user in the past
    • We've updated statistics on the ORGANIZATION_MSCRM DB
    • We've restarted the email router
    • We've renamed the Microsoft.Crm.Tools.EmailAgent.xml and restarted the service
    • We've restarted the SQL service that hosts the ORGANIZATION database
    • We've created a second outgoing profile and tried using that for the user in question
    • We've checked if the domain has been blacklisted on spamhaus
    • We've tried sending mails from that organization with different users
    • We've executed everything in: https://community.dynamics.com/crm/b/dynamicscrmsupportblog/archive/2013/09/06/crm-e-mail-router-performance-based-error-messages.aspx
    • OlebDBTimeout has been increased to 3000

    A temporary solution that worked was assigning 5000 unsent emails to an email queue belonging to that user, this caused 3000 of them to be sent, however we've still got 2000+ emails stuck from that batch, and require a more reliable solution.

    We're receiving the following errors:

    1. #61346 - An error occurred while checking for outgoing e-mail messages to process for SMTP: https://Organization.orbitone.com/Organization. System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: SQL timeout expired. (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault)
    2. Query execution time of 120.0 seconds exceeded the threshold of 20 seconds
     Thread: 79; Database: Organization_MSCRM; Server:SQL; Query: select 
    top 5 "email0".Subject as "subject"
    , "email0".Description as "description"
    , "email0".PriorityCode as "prioritycode"
    , "email0".ActivityId as "activityid"
    , "email0".ModifiedOn as "modifiedon"
    , "email0".StateCode as "statecode"
    , "email0".StatusCode as "statuscode"
    , "email0".DeliveryAttempts as "deliveryattempts" 
     Email as "email0" (NOLOCK)  join ActivityParty as "activityparty1" (NOLOCK)  on ("email0".ActivityId  =  "activityparty1".ActivityId and (((("activityparty1".ParticipationTypeMask = 1 and ("activityparty1".PartyId in ('1a42caba-53c4-e111-995c-005056bd4b39'
    , '5026eba8-0c7c-e211-b518-005056bd4b39'
    , 'e3e9aff5-227c-e211-b518-005056bd4b39'
    , 'ee614303-7f81-e211-b518-005056bd4b39'
    , 'c0383a32-6886-e211-b518-005056bd4b39'))))))) 
     (("email0".StateCode = Closed and ("email0".StatusCode != Sent or "email0".StatusCode is null) and "email0".DirectionCode = 1 and (((((("email0".DeliveryAttempts = 0)))))))) order by
     "email0".ActualEnd asc.

       3. The CrmKeyGenerator encountered an error generating/monitoring key type Microsoft.Crm.CrmConfigObjectNotFoundException: CrmKey With Id does not exist

    When we run the above query ourselves, filling in the correct StateCodes, the query takes 3 minutes.
    Which is markedly higher than the 120 seconds mentioned.
    Another oddity is that each warning states the query took exactly 120 seconds, which is unrealistic.

    We've noticed that the ActivityPointerBase table is larger than we'd expect, 40gig with 2,6 million rows.

    name rows reserved data index_size unused
    ActivityPointerBase 2625378             41829168 KB 38362136 KB 3453344 KB 13688 KB

    This in a CRM database that is 90gig in size.
    We were also unable to find the correct installer to repair the installation of the email router with rollup 13.
    The full installation package says it's the wrong version, and the update rollup package is not a valid package.

    Wednesday, February 12, 2014 12:47 PM


  • Apparently the solution was to shut down the CRM, restart the SQL, then restart SQL and restart CRM.

    We're still not sure what happened and have instituted monitoring on our outgoing emails from CRM, but for now the emails are going out once more.

    • Marked as answer by Reaces Tuesday, February 18, 2014 12:07 PM
    Tuesday, February 18, 2014 12:07 PM