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

Master Database role in replication

$
0
0

While restoring databases, it mentioned that msdb and master database backups must be in sync in each on publisher/dist/subscriber...

Please what the role of master database in replication.

Here msdb is used for agent history and profiles. what the the role of master db?


Manish


Why foreign key not for replication is_not_trusted

$
0
0

Hi,

Why when I define FK not for replication" is_not_trusted=1?   even the table is not replicated at all.

What is the sense in it?

here is a script to illustrate it :

CREATE TABLE Persons
(P_Id int NOT NULL,
 somecolumn varchar(10)
CONSTRAINT PK_Persons PRIMARY KEY CLUSTERED (P_Id ASC)
)
CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
CONSTRAINT PK_Orders PRIMARY KEY CLUSTERED (O_Id ASC),
CONSTRAINT FK_Orders_Persons FOREIGN KEY (P_Id) REFERENCES Persons(P_Id) NOT FOR REPLICATION
)
CREATE TABLE OrderLines
(
O_Id int NOT NULL,
Line_Id int NOT NULL,
Amount int,
CONSTRAINT PK_OrderLines PRIMARY KEY CLUSTERED (O_Id ASC, Line_Id),
CONSTRAINT FK_OrderLines_Orders FOREIGN KEY (O_Id) REFERENCES Orders(O_Id)
)
 
SELECT name, is_not_trusted, is_not_for_replication FROM sys.foreign_keys WHERE name IN ('FK_Orders_Persons','FK_OrderLines_Orders')

ALTER TABLE Orders WITH CHECK CHECK CONSTRAINT FK_Orders_Persons; 

SELECT name, is_not_trusted, is_not_for_replication FROM sys.foreign_keys WHERE name IN ('FK_Orders_Persons','FK_OrderLines_Orders')

ALTER TABLE OrderLines NOCHECK CONSTRAINT FK_OrderLines_Orders
SELECT name, is_not_trusted, is_not_for_replication FROM sys.foreign_keys WHERE name IN ('FK_Orders_Persons','FK_OrderLines_Orders')

ALTER TABLE OrderLines WITH CHECK CHECK CONSTRAINT FK_OrderLines_Orders
SELECT name, is_not_trusted, is_not_for_replication FROM sys.foreign_keys WHERE name IN ('FK_Orders_Persons','FK_OrderLines_Orders')


Regards, Asi Pesa

Replication Error while creating subscription using backup

$
0
0
   

I am trying to set-up replication on SQL 2008 R2 database, copied and restored the database on subsrciber on same version, but when creating the subscription gettin this error below, any clues?

Msg 20027, Level 11, State 1, Procedure sp_MSadd_subscription, Line 223

The article '(null)' does not exist.

Msg 14070, Level 16, State 1, Procedure sp_MSrepl_changesubstatus, Line 1208

Could not update the distribution database subscription table. The subscription status could not be changed.

Msg 14057, Level 16, State 1, Procedure sp_MSrepl_addsubscription_article, Line 383

The subscription could not be create

Very slow replication

$
0
0

I have a replication with pull subscription. over the wan.

At times it is ok (Not briliant) but sometimes it gets realy slow.

For example today, we reached 2 commands per minute!!!!

at the same time we expirianced this, I copied from the same location a 13MB file and got 120-170kb/sec speed.

So I believe the IT guy saying the line is fine. I checked for locks - none. The waits are on network and they are short ones( a few seconds at the most).

The trace shows nothing during the wait (only at the end everything gushes through)

here is the agent log:

Date  10/06/2013 22:29:01
Log  Job History (HK-DB-LSD_HK-LSD_HK_PUB-ILREP01-LSD_HK_SUB-1AA4CA8A-B1AA-4D3D-8EC6-760F707898E6)

Step ID  1
Server  ILREP01
Job Name  HK-DB-LSD_HK-LSD_HK_PUB-ILREP01-LSD_HK_SUB-1AA4CA8A-B1AA-4D3D-8EC6-760F707898E6
Step Name  Run agent.
Duration  00:26:34
Sql Severity  0
Sql Message ID  0
Operator Emailed  
Operator Net sent  
Operator Paged  
Retries Attempted  0

Message
06-10-2013 22:55:34

Total Run Time (ms) : 1592521  Total Work Time  : 1580571
Total Num Trans     : 50  Num Trans/Sec    : 0.03
Total Num Cmds      : 50  Num Cmds/Sec     : 0.03
Total Idle Time     : 0

Writer Thread Stats
  Total Number of Retries   : 0
  Time Spent on Exec        : 46
  Time Spent on Commits (ms): 0  Commits/Sec         : 0.00
  Time to Apply Cmds (ms)   : 62  Cmds/Sec            : 806.45
  Time Cmd Queue Empty (ms) : 1581352  Empty Q Waits > 10ms: 3
  Total Time Request Blk(ms): 1581352
  P2P Work Time (ms)        : 0  P2P Cmds Skipped    : 0

Reader Thread Stats
  Calls to Retrieve Cmds    : 1
  Time to Retrieve Cmds (ms): 1580571  Cmds/Sec            : 0.03
  Time Cmd Queue Full (ms)  : 0  Full Q Waits > 10ms : 0
*******************************************************************************

2013-06-10 19:55:34.432 A total of 50 transaction(s) with 50 command(s) were delivered.


Is SQL Push Replication having row level filters?

$
0
0

Publisher:-SQL server 2012

Subscriber: - SQL Server 2008 R2 SP2

Push replication

Some tables inside publication have row level filters defined.

Now whenever we want to change filter criteria for any table having filters, this always asking for re-initialization of the entire publication for all the tables in that publication. This will take significant time to generate snapshot and then to have all table reinitialized.

We want to understand if there is anyway in SQL server that we can modify filter for a table without reinitializing all the tables at the subscriber end? We would like only impacted table (where filter criteria is changed) to get refreshed at the subscriber end).

Not retaining Identity in SQL Server Merge Replication

$
0
0

Hi,

I have implemented Merge Replication in SQL Server, but here I am getting one problem-

After implementing replication it is not retaining next identity for identity column.

Example-

Publisher Table- (tab_Emp)

Id (Identity field) 

1

2

3

After Replication Subscriber Table - (tab_Emp)

Id (Identity field) 

1

2

3

Now, when I am checking for next Identity value in subscriber tablethen it is -1,  it should be 4.

Please suggest me possible solution to replicate identity with next value.

Thanks in advance.

Publishing stored procedures

$
0
0

We're setting up transactional replication so we have a copy of our OLTP database that we can use mostly for running reports.

I see that we can publish stored procedures as well as tables.  I have two questions about it.

First, is it a good idea, or are there gotchas.

Second, if a stored procedure is published, I presume that "alter procedure" will be propagated to the subscribers, but does that mean it becomes illegal to drop and recreate a published SP?

I see that one semi-gotcha is that when you add a new SP, you have to manually add it to the publication.

We do want to maintain all the reporting SPs on both servers, we may sometimes want to run them on the OLTP server directly.

SQL 2008 R2.

Thanks,

Josh

Transactional replication - merge command performance

$
0
0

Hello,

I'm trying to find a solution to one performance issue with replication that I'm facing at the moment, so I'm hoping someone here could help.

I have one publisher database with 3 subscribers, and occasionally I need to update the publisher database with relatively large number of rows.

For that purpose I'm using merge operation, having separate database with new data as source and publisher database as target. Result of merge operation shows that there are 3 "problematic" tables that generate total of around 300 millions of rows to be distributed.

Publisher to Distributor History shows that data is transferred to distributor in acceptable time manner, but Distributor to Subscriber is taking very long. I traced the process on subscriber using the Profiler and saw that each row is being updated/inserted/deleted separately, and I believe that this causes the performance issue.

I was wandering if there is a way to do the merge operation on subscriber in batches, and not row by row?

I did the reinitialization on one subscriber and it worked fine and relatively quick, but it is not the option since I'm expecting increase of number of subscribers in future, and I need the process to be automatic.

Any help would be highly appreciated! :)

BR,

Miljan


what does a delicated distributor server use RAM for?

$
0
0

We are setting up  a push transaction replication with a dedicated distributor server in 2008 R2 enterprise and wondering how the distributor is using the RAM.  What are the deciding factors to decide how much RAM I would put  into the server?  There are about 100 tables published and most of them are moderate write tables but one of them has an insert rate of 9000 per min during peak hours.

OD


Ocean Deep

Agent message code 21100:replication job was running fine till yesterday without having such permission on folder now how suddenly job is getting failed?

$
0
0

Our replication job was getting failed with below error. To resolve this issue I have granted write permission to agent account on COM folder. Now job is running fine.

Error:Agent message code 21100. The distribution agent failed to create temporary files in 'C:\Program Files\Microsoft SQL Server\100\COM' directory

Question is, replication job was running fine till yesterday without having such permission on folder now how suddenly job is getting failed?

alter published stored proc in sql server

$
0
0

Hi,

  Have published a database and many subscribers are connected to it. Now I want to alter one of the stored procedure.  I dont want to re-publish the db again. I read in some forum that article for that stored procedure should be deleted and alter the stored proc and recreate the article again.  I dont know how to do it.  Any anyone tell me how can I do this?

  Thanks in advance,

Pavan


Pavan

Clear undistributed commands

$
0
0

Hello All,<o:p></o:p>

To fix data discrepancy in transactional replication, I have to clear up all the
undistributed transactions and then run RedGate data compare tool to manually
add/update/delete the records. <o:p></o:p>

How to I clear up the undistributed transactions from the distributor?<o:p></o:p>

Can I do that? Will this method sync up the data? I am going to choose to do it off
hours. But do I have to stop the log reader and distribution agent? I will do this individually for each publisher in a database. Also the subscriber is again a publisher to another subscriber. (A->B->C). Do I have to be concerned about it?


Article with a filter: Instead of updating, it is deleting rows at subscriber

$
0
0
EXEC sp_addarticle @publication = N'Sales_db__TranRepl', @article = N'DummyTable'
, @source_owner = N'dbo', @source_object = N'DummyTable', @type = N'logbased', @description = N''
, @creation_script = N'', @pre_creation_cmd = N'delete'
, @schema_option = 0x000000000803509F, @identityrangemanagementoption = N'manual'
, @destination_table = N'DummyTable', @destination_owner = N'dbo'
, @status = 24, @vertical_partition = N'false', @ins_cmd = N'CALL [dbo].[sp_MSins_dboDummyTable]'
, @del_cmd = N'CALL [dbo].[sp_MSdel_dboDummyTable]', @upd_cmd = N'SCALL [dbo].[sp_MSupd_dboDummyTable]'
, @filter_clause = N'[Delete_date] IS NULL'
GO
-- Adding the article filter
EXEC SP_ARTICLEFILTER @publication = N'Sales_db__TranRepl', @article = N'DummyTable'
, @filter_name = N'FLTR_DummyTable_1__91', @filter_clause = N'[Delete_date] IS NULL'
, @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
-- Adding the article synchronization object
EXEC sp_articleview @publication = N'Sales_db__TranRepl', @article = N'DummyTable'
, @view_name = N'SYNC_DummyTable_1__91', @filter_clause = N'[Delete_date] IS NULL'
, @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
GO

Env details:

SQL SERVER 2008 R2 for both publisher and subscriber.
Both are ent edition.
Article in question has a filter at column Delete_date which is a date column (NOT datetime, date only)



All inserts, deletes and updates are running fine
Except:
When for the article, I am trying to update the value of column Delete_date for a record from Null to a date value, lets say 2013-06-12, it is deleting that record from the subscriber.
I verified and found that the replication sp is fired the moment I am updating the column value on which filter is defined.
This looks strange to me.

My requirement is that:
when the column Delete_date has a value of not null, it must not be processed by replication.
So in the above example when I am putting a value to  the column Delete_date for a record, it should be ignored by replication (No effect at the subscriber).

Please help. In case I need to furnish more details, please let me know.

can't add new column to table in replication

$
0
0

I have a merge replication running and when I try to alter table with this commancd:

alter table mytable add cTestColumn nvarchar(10)

getting this error:

Msg 21531, Level 16, State 1, Procedure sp_MSmerge_altertable, Line 378
The data definition language (DDL) command cannot be executed at the Subscriber. DDL commands can only be executed at the Publisher. In a republishing hierarchy, DDL commands can only be executed at the root Publisher, not at any of the republishing Subscribers.
Msg 21530, Level 16, State 1, Procedure sp_MSmerge_ddldispatcher, Line 191
The schema change failed during execution of an internal replication procedure. For corrective action, see the other error messages that accompany this error message.
Msg 3609, Level 16, State 2, Line 1
The transaction ended in the trigger. The batch has been aborted.

I tried to drop the sunscription and publication and even after that I was not able to add the column or rename the table !!

I create a test db on the same server and everythign worked fine on test db

what is going on with my DB ? how can I get it reslved ? it's happening with almost all tables and not a specific table !!

any hints are valuable since I'm stuck and don't know how to progress

thank in advance,

Patrick


Patrick Alexander

replication settings for a table that has high insert rate

$
0
0

We have set up a push publication for a single large article which has high insert rate.  We are in SQL 2008 enterprise.  This table has over billion rows and has an insert rate of 6,000 to 9,000 per min during peak hours.   We also have other publications on the same publishing database (the same one the big table resides) to the same subscriber.  Sometimes we encounter latency, double digits in mins.  We have a dedicated distrubtor server.  Are there some settings in replication or better methodology to replicate such a large table with high insert rate?  Can SQL transaction replication handle such a large and high insert article by design?  Would sQL 2012 be better?

OD


Ocean Deep


SQL Server 2012 as Subscriber to SQL Server 2008 R2 Snapshot

$
0
0

  While this is certainly not the situation I would recommend or prefer, I have a situation that I may have to TEMPORARILY have an newer SQL Server running 2012 be a Subscriber for an SQL Server 2008 R2 Snapshot that is Published.  Is there any thing that flat out prevents this?

  If there is not specific software rules in SQL Server that prevents this all together, Are there any gotchas or issues that I should be aware of and on the look out for?

Thanks,


George P Botuwell, Programmer

Snapshot Replication fails - ALTER TABLE statement conflicted with the FOREIGN KEY constraint

$
0
0

Hi Everyone,

i have a strange problem when using Snapshot Replication on a Microsoft SQL Server 2012 - 11.0.2100.60 (X64) Standard Edition on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

I copy Data from a production-DB in a Test-DB. In "Article properties" I marked Copy foreign key constraints to "False" and ActionIfNameIsInUse to "Delete Data". When I ran the Replication the snapshot were created, but the distribution failed with the Error:

"The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_tbl1?GUID->tbl2?GUID". The conflict occurred in database "Training", table "tbl2", column 'GUID'."

First of all there are no FK's in the Test-Database. Second tbl1 is not part of the Snapshot. Maybe someone can help me out?

Dave

Generated Replication Publication Script adds pull subscription at the end

mergreplication does not longer work

$
0
0

We have a mergereplication between different site W2008 Server and SQL Server 2008 R2. The replication stopped wit the following error

    Can not find the save procedure 'dbo.sp_MScheckIsPubOfSub'

In the meantime the content of the databases is different. How can I restart the replication

Errors in Replication

$
0
0

Hi,

we are facing 'out of syncs' in our Replication (transactional with updateable Subscribers)

I checked MSrepl_errors and did a join to MSREPL_Commands over command ID - hope this is a valid one. In Comnands I found the  table (as article) which isn't updated.
I run the sp_browsereplcmds on the xact_seqno ofMSREPL_Commandsand found statements that should update the table  - but they didn't. (the column in subscriber is not changed)

The strange thing is, that in the errors table  an other table is named as causing an error (a constraint violation of a primary key) - thats confusing for me.

For example:
In errors an error on table A is writen. If a join command_id to commands table. Here TableB as article is listed. Running browserepcmds shows statements updating  tableB (which is the subscriber running out of sync)

Sorry, I'm new in replication, so a perhaps silly question:
Behind a seq_no there may be several statements, right?
What happens if the first statement fails? Will the other statements be run on subscriber or will the process just stop?

This issue is realy urgent for us, so I would be realy happy for some advice.

Thanks

Christian


Viewing all 4054 articles
Browse latest View live




Latest Images