Database mail issue "Message: The read on the database failed"

来源:互联网 发布:php前景 知乎 编辑:程序博客网 时间:2024/04/28 02:53

今天遇到一个很棘手的问题:database mail无法启动。database mail服务在windows中对应的进程名是DatabaseMail.exe。

使用sysmail_start_sp启动database mail后很快自动shut down. 错误是:


Exception Type: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException
Message: The read on the database failed. Reason: The error description is 'Whitespace is not allowed at this location.'.
Data: System.Collections.ListDictionaryInternal
TargetSite: Microsoft.SqlServer.Management.SqlIMail.Server.Objects.QueueItem GetQueueItemFromCommand(System.Data.SqlClient.SqlCommand)
HelpLink: NULL
Source: DatabaseMailEngine

Google了一会儿,有人说是因为已发送的mail中的一些字段非法导致的(例如邮件接收者为空)。一旦启动database mail,它会自动尝试再次发送email,然后由于失败shut down。解决方法是使用sysmail_delete_mailitems_sp删除在系统表sysmail_allitems中保存的未发送的邮件。

我将该表中发送失败的邮件删除后,问题依旧。尽管如此,从报错来看'Whitespace is not allowed at this location.'确实可能是由于某个邮件有问题导致的,但该邮件并不在sysmail_allitems中。应该有另外一个queue保存发送的邮件。另外我发现该系统表中的数据明显少,有一些发送成功的mail并没有被记录在该表中。从而进一步肯定有另外的mail queue存在。

于是使用profiler跟踪数据库在发送邮件时的动作。找到了如下的报错:

2014-06-05 21:37:28.61 spid25s     An error occurred in Service Broker internal activation while trying to scan the user queue 'msdb.dbo.ExternalMailQueue' for its status. Error: 1222, State: 56. Lock request time out period exceeded. This is an informational message only. No user action is required.

ExternalMailQueue很可疑。

Google了ExternalMailQueue后找到以下网页:

http://blogs.msdn.com/b/sqlserverfaq/archive/2010/03/18/database-mail-failing-with-the-service-queue-externalmailqueue-is-currently-disabled-message.aspx


大家自己看吧,解决方法就是删除该queue中的数据。




0 0
原创粉丝点击