请帮助我从快照恢复后为什么要得到这条sys.transmission_queue.transmission_status消息?
发送方数据库中的代理处于单用户模式。在单用户模式下无法传递消息。
这就是我尝试过但没有成功的地方:
是否有另一个要查询的DMV或目录来查找服务代理的状态?
谢谢。
发布于 2011-11-02 20:56:32
数据库恢复之后,激活的Service队列似乎没有正确地设置其队列监视器,即使在恢复期间指定了使用ENABLE_BROKER的队列。
显式重新启用service将使队列监视器被正确地重新创建。如果有人有更好的解决办法,我很想听听。
您可以通过查询dm_broker_queue_monitors来检查这个问题,查询处于无文档状态的“丢弃”状态的任何队列,这些队列也没有相应的队列处于不同的状态(例如:‘'INACTIVE')
如果这个查询有任何结果,那么就会有一个断开的队列:
select database_id,queue_id,[state] from sys.dm_broker_queue_monitors m
WHERE state='DROPPED'
and not exists (select 1 from sys.dm_broker_queue_monitors m2
where state <> 'DROPPED'
and m.queue_id=m2.queue_id
and m.database_id=m2.database_id)您可以通过重新启用service来修复它(是的,即使它已经启用;重新启用它将使队列得到正确的重建)。您需要在单个用户中启用service:
ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE [dbname] SET ENABLE_BROKER WITH NO_WAIT
ALTER DATABASE [dbname] SET MULTI_USER发布于 2011-10-21 16:36:47
在单用户模式下无法传递消息。
这还不够清楚吗?
复制后编辑
您发布的repro是不完整的,它使用对象而不是定义din (数据库和快照)。我使用这个脚本来测试一些我认为类似于您的情况的东西:
USE master
GO
if db_id('Accounting') is not null
begin
alter database Accounting set single_user with rollback immediate;
drop database Accounting;
end
go
create database Accounting;
go
alter authorization on database::Accounting to sa;
use Accounting;
go
create queue q;
create service s on queue q ([DEFAULT]);
go
-- Drop to single user mode
ALTER DATABASE [Accounting] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
declare @h uniqueidentifier;
begin dialog conversation @h
from service [s]
to service N's'
with encryption = off;
send on conversation @h ('Hello, World');
go
-- Give the queue a bit of time to process
WAITFOR DELAY '0:00:02';
GO
-- Take a look after sending a message
SELECT * FROM sys.transmission_queue; -- 1 row, transmission_status = "...single user ..."
GO
-- Retry same multiuser with ENABLE_BROKER
USE master
GO
ALTER DATABASE Accounting SET MULTI_USER, ENABLE_BROKER WITH NO_WAIT
GO
use Accounting;
go
-- wait for the message delivery
WAITFOR (receive cast(message_body as varchar(8000)), * from q), timeout 60;
GO
-- Look at xmit queue
USE Accounting;
SELECT * FROM sys.transmission_queue; -- 1 row, no error status.
GO
-- Look again at xmit queue, in 10 seconds
waitfor delay '00:00:10';
USE Accounting;
SELECT * FROM sys.transmission_queue; -- row is gone
GO这个脚本显示:
发布于 2011-10-22 01:08:52
尝尝这个,
ALTER DATABASE database_name
SET MULTI_USER, ENABLE_BROKER; 有一个目录视图sys.databases,使用列user_access。
https://dba.stackexchange.com/questions/7153
复制相似问题