TSQL复制sp_addsubscription,sp_link_publication死锁

时间:2014-05-15 22:41:30

标签: sql-server tsql replication ssms transactional-replication

在以编程方式设置Push复制时,我注意到在运行sp_link_publication时我遇到了死锁。死锁似乎与触发顺序有关。

以下是我认为出错的地方:

var publisherSubscriptionParams = new Dictionary<string, object>
            {
                {"publication", publisherDatabase}, {"article", "all"}, {"subscriber", subscriberServer},
                {"destination_db", subscriberDatabase}, {"subscription_type", "Push"}, {"sync_type", "replication support only"}, {"update_mode", "queued failover"}
            };

使用sp_addsubscription

var publisherPushSubscriptionAgentParams = new Dictionary<string, object> { { "publication", publisherDatabase }, { "subscriber", subscriberServer }, { "subscriber_db", subscriberDatabase }, { "subscriber_security_mode", 1 } };

使用sp_addpushsubscription_agent

var subscriberParams = new Dictionary<string, object>
        {
            {"publisher", publisherServer}, {"publisher_db", publisherDatabase},
            {"publication", publisherDatabase}, {"distributor", distributorServer}, {"security_mode", 1}
        };

使用sp_link_publication

sp_addsubscription将[trg_MSsync_del _...]等触发器添加到我的数据库表对象中。然而,当发生这种情况时,我认为sp_link_publication命令会发生冲突并形成死锁。有没有人有这方面的经验/建议?

我可以看到通过查询添加的触发器:

select sys.tables.name,sys.triggers.name,sys.trigger_events.type
,sys.trigger_events.type_desc, is_first,is_last
,sys.triggers.create_date,sys.triggers.modify_date
from sys.triggers inner join sys.trigger_events
on sys.trigger_events.object_id = sys.triggers.object_id
inner join sys.tables on sys.tables.object_id = sys.triggers.parent_id
order by modify_date

添加所有触发器之后,如果我运行sp_link_publication,则没有死锁。

有什么想法吗?

0 个答案:

没有答案