Sql-Server

Replicaton - 目前事務無法送出,也無法回滾到保存點

  • April 23, 2019

創建複製發布後,我繼續使用以下腳本創建訂閱:

-----------------BEGIN: Script to be run at Publisher 'MY_PUBLISHER_SERVER'--------------
use [MY_PUBLICATION_DB]
exec sp_addsubscription 
@publication = N'MY_PUBLICATION', 
@subscriber = N'MY_SUBSCRIBER_SERVER', 
@destination_db = N'ORCA_Repl_Sub', 
@subscription_type = N'Push', 
@sync_type = N'automatic', 
@article = N'all', 
@update_mode = N'read only', 
@subscriber_type = 0



exec sp_addpushsubscription_agent 
@publication = N'MY_PUBLICATION', 
@subscriber = N'MY_SUBSCRIBER_SERVER', 
@subscriber_db = N'ORCA_Repl_Sub', 
@job_login = N'MY_COMPANY\sqlrpl', 
@job_password = N'MYP455w0rd',
@subscriber_security_mode = 1, 
@frequency_type = 64, 
@frequency_interval = 0, 
@frequency_relative_interval = 0, 
@frequency_recurrence_factor = 0, 
@frequency_subday = 0, 
@frequency_subday_interval = 0, 
@active_start_time_of_day = 0, 
@active_end_time_of_day = 235959, 
@active_start_date = 20190423, 
@active_end_date = 99991231, 
@enabled_for_syncmgr = N'False', 
@dts_package_location = N'Distributor'
GO
--------------END: Script to be run at Publisher 'MY_PUBLISHER_SERVER'-----------------

令我驚訝的是,在執行第二個程序時出現以下所有錯誤:

Msg 50000, Level 16, State 1, Procedure msdb.dbo.sp_add_jobstep_internal, Line 255 [Batch Start Line 14]
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction.
Msg 3931, Level 16, State 1, Procedure sys.sp_MSadd_repl_job_unsafe, Line 376 [Batch Start Line 14]
The current transaction cannot be committed and cannot be rolled back to a savepoint. Roll back the entire transaction.

在此處輸入圖像描述

基本上複製腳本停止工作..

如何解決這個問題?在哪裡可以找到有關這些錯誤的更多資訊?

使用我的複制代理的憑據重新連接到 sql-server——它位於sysadmin我的發布伺服器上,以及db_owner我的訂閱伺服器上的訂閱數據庫上。

1 - 右鍵點擊 ssms 圖示

在此處輸入圖像描述

2 - 在上面的 SSMS 選項上,按 shift + 右鍵點擊並選擇Run as a different user

在此處輸入圖像描述

3 - 添加憑據different user- 在我的情況下,它是我的複制代理帳戶

之後一切正常,如下圖所示:

在此處輸入圖像描述

引用自:https://dba.stackexchange.com/questions/235523