Quantcast
Channel: SQL Server Replication forum
Viewing all 4054 articles
Browse latest View live

Does Log reader agent use sa in sp_replcmds?

$
0
0

We have publisher, subscriber, and distributor on separate servers. Replication is Push Transactional with replication agents setup to run under SQL Agent account context. We are in the process of disabling sa from everywhere and I am monitoring sessions that use sa to make sure there is no impact.

I see that log reader agent session sometimes uses sa as login name in its sessions on publisher. In sys.dm_exec_sessions, there are two columns for login: Login_Name and Original_Login_Name. The Login_Name shows sa. Most of the time the SPID of log reader agent on publisher shows the SQL agent service account as login name of the session. But sometimes the same SPID shows sa as login name. This always coincides with session running SP_REPLCMDS without any parameters and also messages like "The Log Reader Agent is scanning the transaction log for command to be replicated. Approximately...." in Replication Monitor. Normally, the session would run SP_REPLCMDS giving some parameters. When this happens, in sys.dm_exec_sessions, the log reader SPID keeps showing Original Login name as that of Distributor agent service account but login_name sa.

Does sp_replcmds run as sa? If I disable sa on publisher, distributor, and subscriber, will it break replication?


Error while configuring SQL 2012 DB as a Subscriber to a Oracle Publisher.

$
0
0

When Configuring the Subscription for Oracle as a publisher, we receive the following error message.

Msg 18757, Level 16, State 4, Procedure sp_replpostcmd, Line 1
Unable to execute procedure. The database is not published. Execute the procedure in a database that is published for replication.
The Subscriber was dropped.

"

Same message is received if add the subscription through script or through SQL Management studio.


However Oracle as a publisher has been configured successfully on a SQL 2012 DB server, Which is also the  Distribution server

using the following links. 

https://msdn.microsoft.com/en-us/library/ms151243(v=sql.110).aspx

https://msdn.microsoft.com/en-us/library/ms152481(v=sql.110).aspx

Note: Same Steps successfully work from a SQL 2008 Machine. i.e If i use SQL 2008 machine to configure Oracle as a Publisher and then subscribe to SQL 2012 machine as Subscriber.

Is there a known issue? or some extra steps for 2012 that are not documented. Any help will be much appreciated.

Client Oracle Version:9i

Subscriber DB Version: SQL Server 2012 SP2


Thanks and Regards, Ibrahim Mehdi. MCSE-DataPlatform

SQL Merge replication destination table

$
0
0

Hi all,

is it possibile to have a merge replication that synchronize a table with different name on publisher and on subscriber (but with the same schema)? Thanks.

SQL 2012 and later will fail to publish a database for any tables with a default constraint that references a user defined function.

$
0
0

Script will create database, 3 database objects and publish.  The error is due to the generation script to create the conflict tables that is not stripping out default constraints that reference a UDF. 

Error messages:

    • Message: There is already an object named 'DF__repTable__id__117F9D94' in the database.
      Could not create constraint. See previous errors.
      Command Text: CREATE TABLE [dbo].[MSmerge_conflict_MergeRepFailurePublication_repTable](
              [id] [varchar](8) NULL CONSTRAINT [DF__repTable__id__117F9D94]  DEFAULT ([dbo].[repUDF]()),
              [somedata] [varchar](64) NULL,
              [rowguid] [uniqueidentifier] ROWGUIDCOL  NULL,
              [someint] [int] NULL,
              [somestring] [varchar](64) NULL
      )


      Parameters:
      Stack:    at Microsoft.SqlServer.Replication.AgentCore.ReMapSqlException(SqlException e, SqlCommand command)
         at Microsoft.SqlServer.Replication.AgentCore.AgentExecuteNonQuery(SqlCommand command, Int32 queryTimeout)
         at Microsoft.SqlServer.Replication.AgentCore.ExecuteDiscardResults(CommandSetupDelegate commandSetupDelegate, Int32 queryTimeout)
         at Microsoft.SqlServer.Replication.Snapshot.YukonMergeConflictTableScriptingManager.ApplyBaseConflictTableScriptToPublisherIfNeeded(String strConflictScriptPath)
         at Microsoft.SqlServer.Replication.Snapshot.BaseMergeConflictTableScriptingManager.DoConflictTableScriptingTransaction(SqlConnection connection)
         at Microsoft.SqlServer.Replication.RetryableSqlServerTransactionManager.ExecuteTransaction(Boolean bLeaveTransactionOpen)
         at Microsoft.SqlServer.Replication.Snapshot.BaseMergeConflictTableScriptingManager.DoConflictTableScripting()
         at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateTableArticleCftScript(Scripter scripter, BaseArticleWrapper articleWrapper, Table smoTable)
         at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateTableArticleScripts(ArticleScriptingBundle articleScriptingBundle)
         at Microsoft.SqlServer.Replication.Snapshot.MergeSmoScriptingManager.GenerateArticleScripts(ArticleScriptingBundle articleScriptingBundle)
         at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.GenerateObjectScripts(ArticleScriptingBundle articleScriptingBundle)
         at Microsoft.SqlServer.Replication.Snapshot.SmoScriptingManager.DoScripting()
         at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.DoScripting()
         at Microsoft.SqlServer.Replication.Snapshot.MergeSnapshotProvider.DoScripting()
         at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()
         at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()
         at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: MSSQLServer, Error number: 2714)
      Get help: http://help/2714
    • Server COL-PCANINOW540\SQL2012, Level 16, State 0, Procedure , Line 1
      Could not create constraint. See previous errors. (Source: MSSQLServer, Error number: 1750)
      Get help: http://help/1750
    • Server COL-PCANINOW540\SQL2012, Level 16, State 0, Procedure , Line 1
      Could not create constraint. See previous errors. (Source: MSSQLServer, Error number: 1750)
      Get help: http://help/1750

    As you can see the failure is on the generation script for the conflict table. The conflict table should be a bucket table that shouldn’t enforce data integrity. See how the default constraints for the columns someint and somestring were stripped out of the generation logic however the default constraint that utilizes a UDF persist and uses the same object name that was used on the production table, this occurs if I explicitly name the constraint or let the system generate the name for me like in the example posted.   The only way I could see getting around this right now is to drop all default constraints in the system that uses a UDF, publish then add the constraints back which is vulnerable to invalid data and a lot of moving steps.  This all worked with SQL 2000, 2005, 2008, 2008r2, it’s stopped working in SQL 2012 and continues to not work in SQL 2014. 


    Pauly C

USE [master]
GO
CREATE DATABASE [MergeRepFailure]
ALTER DATABASE [MergeRepFailure] SET COMPATIBILITY_LEVEL = 110
GO
USE [MergeRepFailure]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view
[dbo].[repView] as select right(newid(),8) as id
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[repUDF]()
RETURNS varchar(8)
BEGIN
	declare  @val varchar(8)
	select top 1 @val = id from [repView]
	return @val
END
GO

create table repTable
(
	id varchar(8) default([dbo].[repUDF]()),
	somedata varchar(64) null,
	rowguid uniqueidentifier ROWGUIDCOL default(newid()),
	someint int default(1),
	somestring varchar(64) default('somestringvalue')
)

GO
insert into reptable (somedata) values ('whatever1')
insert into reptable (somedata) values ('whatever2')

go
/*test to make sure function is working*/
select * from reptable

GO

/*Publish database*/

use [MergeRepFailure]
exec sp_replicationdboption @dbname = N'MergeRepFailure', @optname = N'merge publish', @value = N'true'
GO
declare @Descrip nvarchar(128)
select @Descrip = 'Merge publication of database ''MergeRepFailure'' from Publisher ''' + @@servername +'''.'
print @Descrip


-- Adding the merge publication
use [MergeRepFailure]
exec sp_addmergepublication @publication = N'MergeRepFailurePublication', @description = N'@Descrip',
@sync_mode = N'native', @retention = 14, @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'true',
@enabled_for_internet = N'false', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'false', @ftp_port = 21,
@ftp_subdirectory = N'ftp', @ftp_login = N'anonymous', @allow_subscription_copy = N'false', @add_to_active_directory = N'false',
@dynamic_filters = N'false', @conflict_retention = 14, @keep_partition_changes = N'false', @allow_synctoalternate = N'false',
@max_concurrent_merge = 0, @max_concurrent_dynamic_snapshots = 0, @use_partition_groups = null, @publication_compatibility_level = N'100RTM',
@replicate_ddl = 1, @allow_subscriber_initiated_snapshot = N'false', @allow_web_synchronization = N'false', @allow_partition_realignment = N'true',
@retention_period_unit = N'days', @conflict_logging = N'both', @automatic_reinitialization_policy = 0
GO


exec sp_addpublication_snapshot @publication = N'MergeRepFailurePublication', @frequency_type = 4, @frequency_interval = 14, @frequency_relative_interval = 1,
@frequency_recurrence_factor = 0, @frequency_subday = 1, @frequency_subday_interval = 5, @active_start_time_of_day = 500, @active_end_time_of_day = 235959,
@active_start_date = 0, @active_end_date = 0, @job_login = null, @job_password = null, @publisher_security_mode = 1


use [MergeRepFailure]
exec sp_addmergearticle @publication = N'MergeRepFailurePublication', @article = N'repTable', @source_owner = N'dbo', @source_object = N'repTable', @type = N'table',
@description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x000000010C034FD1, @identityrangemanagementoption = N'manual',
@destination_owner = N'dbo', @force_reinit_subscription = 1, @column_tracking = N'false', @subset_filterclause = null, @vertical_partition = N'false',
@verify_resolver_signature = 1, @allow_interactive_resolver = N'false', @fast_multicol_updateproc = N'true', @check_permissions = 0, @subscriber_upload_options = 0,
@delete_tracking = N'true', @compensate_for_errors = N'false', @stream_blob_columns = N'false', @partition_options = 0
GO


use [MergeRepFailure]
exec sp_addmergearticle @publication = N'MergeRepFailurePublication', @article = N'repView', @source_owner = N'dbo', @source_object = N'repView',
@type = N'view schema only', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x0000000008000001,
@destination_owner = N'dbo', @destination_object = N'repView', @force_reinit_subscription = 1
GO


use [MergeRepFailure]
exec sp_addmergearticle @publication = N'MergeRepFailurePublication', @article = N'repUDF', @source_owner = N'dbo', @source_object = N'repUDF',
@type = N'func schema only', @description = null, @creation_script = null, @pre_creation_cmd = N'drop', @schema_option = 0x0000000008000001,
@destination_owner = N'dbo', @destination_object = N'repUDF', @force_reinit_subscription = 1
GO



Replication issue

$
0
0

Hi Team,

I have one transactional publication using this publication I configured 3 subscribers.

Here when I generate the new snapshot those 3 subscribers are updated, but I need to update only 2 subscribers. How it is possible?

Regards,

Change

The merge process could not allocate memory for an operation; your system may be running low on virtual memory. Restart the Merge Agent.

$
0
0

I encountered this problem on our SQL2012 and I have tried different scenarios (see below) to no avail. I have decided to give up and check if someone here has encountered this and resolved it. 

One thing I know, it's not a memory issue. Both servers we're using has lots of memory to spare and we monitor the memory as the replication goes through it's steps. 

I hope someone can help me on this. Thanks!

The Error:

The merge process could not allocate memory for an operation; your system may be running low on virtual memory. Restart the Merge Agent.

Our Scenario

  • We're using SQL Server 2012 SP1. All subscriptions are pull based.
  • We're using direct Merge Replication (not FTP or web sync)
  • We already have 10 active replications with larger databases. Only 1 has this issue.
  • Database size is less than 5 GB
  • Rebuilding the publisher is not an option.

What have I tried?

  • There is no memory problem --- we have lots to spare
  • I have tried re-initialization of the database. Same problem.
  • I tried deleting the database and reinitializing it. Same problem
  • New snapshot. Same problem.
  • I tried changing the subscriber server but still same issue. 



MCP, MCSD, MCDBA (ANXA)

AlwaysOn: primary sync or async?

$
0
0
Hi, I succesfully setup an AlwaysOn between two sql2014 servers for development purposes. I configured both the primary and the secondary as synchronous. Now developers say that it is slower than one single server, and they are right because this configuration causes delays. So, I know I can set the secondary replica as asynchronous, but the wizard lets me to set also the primary as asynchronous, and I can't understand this. Honestly, when I set up the environment, I didn't focus on it but now I'm asking: why should the primary replica be async? If it is the primary (let's say the "most important") it should be sync by default. Who should be the primary async with?

Transactional replication of a 6 billion+ record article only replicating a total of 2147473647 records

$
0
0

We are using SQL 2014 transaction replication to replicate a huge table, about 6 billion records. I created a publication just for this article on a sql 2014 publisher server and the subscription is on a different sql 2012 server.  The distribution db is also a sql 2014 server on a separate server.   Once I started the initial snapshot which was successful, synchronization started and ended in about 8 hours.   Everything looks fine and no errors but the subscription db  only has a little bit over 2 billion records, 2147473647 in the table.  I thought I did something wrong so I dropped the subscription and article and did the whole thing again.... again same result, 2147473647 in subscriber db.   When I look at the number closely, 2147473647  is almost the same number as the integer max limit.     I am wondering if I am hitting some limit or having some setting incorrectly.  

Normally for this kind of big table, I use the 'initialize with backup' method but the problem is that my subscriber server is a sql 2012 server.   And I can't upgrade it to sql 2014. 

Any help on this is very much appreciated.

OD

 

Ocean Deep


Transactional Replication: Non-Clustered Indexes not copying.

$
0
0

Hello,

I set up replication on our servers at work to streamline some procedures we run daily/weekly on them.

This copies around 15 articles from two databases on the "Master" server to another server used for execution purposes. For the most part it was a pretty straight forward task and it seemed to work nicely; but I realised after some investigation that the non-clustered indexes weren't copying over to the child server.

I set the non-clustered indexes property in the properties of the publishing articles to "True" and generated a new snapshot, this seemed to work, but I've come into work this morning to find the property has reset to "False" and I have no indexes on the table again. Why is this happening and is there any way I can resolve the matter so the indexes are copied over concurrently?

Thanks in advance for your advice.

JB

MSmerge_history table cleanup

$
0
0

Hello experts,

we have done the sql server 2008 R2 SP3 upgrade on our live servers on the last saturday. i can see more than 57 million records were updated at that particular time in the table MSmerge_history. when the agent cleanup job kicks in with retention of 48 hours, it is causing so much of blocking, then i digged into it and understood that there are huge number of records. now cleanup is not happening. I stopped and disabled the job.

I did not understand why these many records were updated in that table in just 3 minutes. how can I delete these records? I tried to execute the procedure EXEC dbo.sp_MShistory_cleanup @history_retention = 48 (the same procedure is called with the agent history cleanup job), distrubution database log has eaten all the log drive space, and grown upto 135 GB. if I keep auto growth off for the distrubution database, is that good?

please I need your inputs to resolve this issue. if i keep this cleanup to the weekend, is that fine? will it not impact business?

please suggest.


Cheers, Vinod Mallolu

Transactional Replication sp_MSupd RUNNABLE and never ends

$
0
0

Hello,

I came across not understandable problem connecting transactional pull replication. Once or twice a month I have a problem that stored procedure on subscription server (sp_MSupd) cannot be finished. It is not blocked by any other session and does not have any wait type. It simply hangs and remains in task status RUNNABLE. The only one way to recover the replication is initilizing it from backup or snapshot. Do you have any suggestions. Have you faced similiar problem?

Can a Merge Publication have (2 different types of subscribers) a web subscriber and a non-web subscriber ?

$
0
0
Can a Merge Publication have (2 different types of subscribers) a web subscriber and a non-web subscriber ?

Ranga

Replication articles read-only in one publication and editable in another

$
0
0
We have many users with a mobile application running SQL Mobile and using merge replication to get data back to the SQL 2008 R2 database. This has worked very well for many years.

We now have a requirement to have this data reported on using Reporting Services. This is where it gets messy.

Due to a limitation of Report Builder(see this blog) we cannot provide access to users for creating their own reports. The report database is remote from the host and there is no VPN.

We hit upon the idea of creating an almost identical publication but the articles as read-only. It was only after this was done that we started having trouble with our existing mobile users. 

It seems that a published article is EITHER Bi-directional OR Read-only even if they are in separate publications.

I then thought of using Transactional Publication but this too is blocked on creation with "automatic identity range support is useful only for publications that allow updating subscribers"(Merge and Transactional publication are mutually exclusive)

So in the final analysis is there a way for me to have merge replication AND some other form of SQL replication/data transfer that can have the same data transmitted readonly to a separate full SQL server database?

Your insights, ideas and advice appreciated.
 

Violation of Primary Key in Merge Replication

$
0
0

I have one Publisher and one Subscriber. They haveUK (Col1, Col2), PK is col1 + col2, and the MERGE REPLICATION adds a ROWGUID. Sometimes they insert the same row when they are offline ( they generate the same UK, it's not IDENTITY column), because of it, they generate different ROWGUID for the same row. Then, when I run the JOB for Merge Replication, I have a PRIMARY KEY violationI need to use the UK instead of ROWGUID. It is possible?

Example:

Table_1 (Publisher)
Name: John (UK)
ID: 1234 (UK)
ROWGUID: xxxxx (Created by Merge Replication)

Table_1 (Subscriber)
Name: John (UK)
ID: 1234 (UK)
ROWGUID: yyyyy (Created by Merge Replication)


Agent ID in MSmerge_sessions

$
0
0

Hi All,

please could you let me know the process to identify which agent_id is which merge agent? i can see Agent_id is a numeric digit, but not sure whcih agent it is related to.

how can i co-relate this with publication id or subscription id or with any sync job.

please help.


Cheers, Vinod Mallolu


Implementing transnational replication for whole database on two different systems in sqlsever 2005

$
0
0

Folks,

Can anyone share a step-by-step document on Implementing transnational replication on two different systems in sql sever 2005.

Thanks

Surendra.

MSmerge_History data deletion

$
0
0

Hello Experts,

i would like to delete data from this table based on few seconds instead of hours or minutes or days.

becuase most of the data came to the table in the span of 3 minutes. so some one please help me with a while loop for the timings between 18th april 2015 08:20 to 18th april 2015 08:25

thanks in advance

Vinod 


Cheers, Vinod Mallolu

Merge Replication from SQL2014 publisher to SQL2008R2 subscriber

$
0
0

My company replaced an aging SQL2008R2 server with a new SQL2014 server. The server, both in its old and new forms, acted as both distributor and publisher in the replication of about 40 merge publications, 100-150 articles per publication. The publications are scheduled to synchronize nightly to a subscriber SQL2008R2 server (on our LAN) and their start times are staggered to reduce server load. All subscriptions are pull subscriptions.

We recently did an update that affected every record of one of the highest row count articles in each publication. In some publications this approaches hundreds of millions of rows. Typically this article synchronizes changes at a speed of about 4000 rows per second. When attempting to synchronize these large changes from our new server the speed of dropped as low as 25 rows per second, even when we ensured that only one synchronization was running at a time and there was low activity on the publisher and no other processing on the subscriber. However updates affecting lower volumes of records also continue to synchronize at about 4000 rows per second. As I've continued to test the cutoff point is between 20 million and 28 million records (20 million updates normally, and 28 million is slow).

Because we still have the old 2008R2 server on our network we have been able to test replicating large changes from that server as well, but we do not see the same issue. We have been able to verify that the 2014 server's publication and article settings exactly match those of the 2008R2 server it replaced. We have also checked to ensure that the Agent Profile settings for each replication agent are the same between old and new servers.

While we recognize that such a high update volume is not an ideal scenario for merge replication, we do not see the same behavior when replicating from 2008R2 to 2008R2 machines, only when replicating from 2014 to 2008R2. Therefore we are wondering if this issue should be reported as a bug? If that is the case, how would one go about doing that?




script execution in replication after initialization

$
0
0
Hi, 
is there anyway to execute script automatically on publisher after initialization. does sp_addscriptexec execute script on subscriber only??

Cannot insert rows into IHPublications. Please help!!

$
0
0

Hello,

I am trying to create a new publisher on SQL Server 2005 (Version 9.00.3077.00). I did clean up previous transactional replication setup manually. I have tried a zillion times till now...

All I get is:

Cannot insert NULL into column of table tlMain.dbo.IHPublications.

If I did manage to fool the Create Publication wizard by inserting a dummy row in the table (like below),

insert into IHPublications
(pubid,
name,
repl_freq,
status,
sync_method,
snapshot_jobid,
enabled_for_internet,
immediate_sync_ready,
allow_queued_tran,
allow_sync_tran,
autogen_sync_procs,
snapshot_in_defaultfolder,
alt_snapshot_folder,
pre_snapshot_script,
post_snapshot_script,
compress_snapshot,
ftp_address,
ftp_port,
ftp_subdirectory,
ftp_login,
ftp_password,
allow_dts,
allow_anonymous,
centralized_conflicts,
conflict_retention,
conflict_policy,
queue_type,
ad_guidname,
backward_comp_level,
description,
independent_agent,
immediate_sync,
allow_push,
allow_pull,
retention,
allow_subscription_copy,
allow_initialize_from_backup,
min_autonosync_lsn,
replicate_ddl,
options)
VALUES (1,'tlMain',0,1,0,0x782BDE714C43B942BCC180BE7A086CF7,0,0,0,0,0,1,NULL,NULL,NULL,0,
NULL,21,NULL,'Anonymous',NULL,0,0,NULL,14,NULL,NULL,NULL,10,'Transactional Replication',
0,0,1,1,0,0,0,NULL,1,0)

I get,

Cannot insert NULL into 'table_id' of tlMain.dbo.IHArticles, later, when 'finish'ing the wizard.

I have setup transactional replication more than a couple of times on SQL Server 2005. I have never seen these tables which start with 'IH'...

Please advise on how I can workaround this problem. Any pointers are greatly appreciated!! Thank you.


Vijay V
Viewing all 4054 articles
Browse latest View live




Latest Images