Quantcast
Channel: StackExchange Replication Questions
Viewing all 17268 articles
Browse latest View live

Database Merging and Replication

$
0
0

So we have seven servers, one for each of our locations, each server has the exact same schemas/table setup. We were making a reporting server to be able to look at the data from all sites at once. In order to do this at first what we did was a daily load of each server unto the reporting server. We added a SourceServerID column to each table and had that generated by the SSIS package. These were put into a database named ODS.

Our seven servers are going through an upgrade right now. With this upgrade changes are being made that will allow us to use replication instead of the daily load like we were before. With the replication we are creating a staging database on the reporting server for each of the seven servers naming them like SourceServer1. Then creating views on the ODS that do simple Select... Union type of query to combine the data from all the SourceServerX databases.

This is causing the reports we run to go much slower(ex: from 5mins to 2 hours).

1) Could the slow down be due to pulling from the multiple SourceServerX databases as opposed to the one ODS database like before even though these are all on the same instance of SQL?

2) If we combined the tables into one database and then added the SourceServer name to the front of the tables would the views then run faster?

3) With replication could we combine the tables from all the SourceServers into one set of tables adding in the SourceServerID column like we did for the daily load?

4) Is there a different method that would allow for better performance while maintaining the up to date data that replication provides?

We are using SQL Server 2012.

I had posted this here but I think it would be better over in dba.stackexchange.com so I have posted it there now.

https://dba.stackexchange.com/questions/179493/database-merging-and-replication


Snapshot Agent - Merge Replication: Failed to read from Server

$
0
0

We currently have Merge replication with 1 publisher and 2 subscribers. This morning I noticed the snapshot agent failed. I have tried to kick this off manually, but it keeps failing. The following is the error message that I get:

Error messages:
Message: Failed to read from server
Stack:    at Microsoft.SqlServer.Replication.Snapshot.SqlServer.NativeBcpOutProvider.ThrowNativeBcpOutException(CConnection* pNativeConnectionWrapper)
   at Microsoft.SqlServer.Replication.Snapshot.SqlServer.NativeBcpOutProvider.BcpOut(String strBcpObjectName, String strBcpObjectOwner, String strBaseBcpObjectName, Boolean fUnicodeConversion, String strDataFile, String strLoadOrderingHint, String strWhereClause, Boolean useTableLockHint, Int32 bcpFileFormatVersion)
   at Microsoft.SqlServer.Replication.Snapshot.SqlServer.NativeBcpOutProvider.BcpOut(String strBcpObjectName, String strBcpObjectOwner, String strBaseBcpObjectName, Boolean fUnicodeConversion, String strDataFile, String strLoadOrderingHint)
   at Microsoft.SqlServer.Replication.Snapshot.SqlServer.NativeBcpOutProvider.BcpOut(String strBcpObjectName, String strBcpObjectOwner, String strDataFile)
   at Microsoft.SqlServer.Replication.Snapshot.MergeContentsBcpOutWorkItem.DoWork(MergeSnapshotProvider snapshotProvider, IBcpOutProvider bcpOutProvider)
   at Microsoft.SqlServer.Replication.WorkerThread.NonExceptionBasedAgentThreadProc()
   at Microsoft.SqlServer.Replication.AgentCore.BaseAgentThread.AgentThreadProcWrapper() (Source: MSSQLServer, Error number: 0)
Get help: http://help/0
Message: COLV_90_TO_80: Cannot convert parameter param1: Resulting colv would have too many entries.
Stack:  (Source: MSSQLServer, Error number: 20005)
Get help: http://help/20005
Message: The statement has been terminated.
Stack:  (Source: MSSQLServer, Error number: 3621)

What does this error mean? How do I get the snapshot agent to run successfully again?

MySQL merge two tables of different database to single database [closed]

$
0
0

Friends, i have database named as DB1 with a table called TB1A and another database as DB2 with a table TB2A.

TB1A having 5 columns and TB2A having 8 columns, All the columns available in TB1A is present in TB2A.

I want to create new table called TB3A which should be a merged result of a TB1A and TB2A. Means TB3A will have 8 columns and contains all the datas of TB1A and TB2A.

CREATE TABLE TB3A AS (

SELECT * 
  FROM DB1.TB1A 
  JOIN  DB2.TB2A 
) 

While i trying like above it is showing an error like below

Error Code: 1060

Duplicate column name 'Agreement_Id'

Execution Time : 0 sec

Transfer Time : 0 sec

Total Time : 0 sec

Does any one have any idea about this. I have google it this issue but i am not able to find the solution for this ..

Merge Replication customize synchronization cycle and its performance

$
0
0

I'm trying to implement Merge Replication between just two servers, a publisher and one Subscriber.

Assume these tables :

--Main table in Publisher
Ticket (id, userId, reqId, blockedDate, usedDate, returnDate, transferDate, ...)

--On Subscriber (The fields are in Publication)
Ticket (id, userId, blockedDate, usedDate)

We must assign current date to transferDate whenever a row goes to Subscriber, and assign to returnDate whenever it comes back from Subscriber. As we HAVE to consider a file syncing (transfer/return data to/from subscriber with a USB stick!) these fields must be assigned on syncing either on file syncing or on replication.

I know you can add your custom business logic for Conflict Resolution (when a conflict occurs). I'm looking for something like triggers for replication events, which gain me the ability to manipulate some fields out of Publication (or even another table whenever needed).

Questions

  • Is it possible to handle replication events(push and pull) manually?** (customize or override PULL/PUSH's. Not conflict resolver)**

  • Can you give me a comparison between implementing a customized merge replication and syncing with help of a distributed transaction SP?

I need synchronization to be scheduled (at midnight when there's no load on DB server), BUT it is highly needed we'll be able to sync manually (from within our web application).

In second question I need their performance, reliability, and of course their maintainability. These factors especially the first two, are a big concern. Suppose Publisher may have about millions of records, and Subscriber may have about several ten thousand. So with each synchronization, about several ten thousand records will be transferred.

Merge replication checks rows; if there's a change and there's not a conflict, the row merges. if there's a conflict, a conflict resolver (could be your custom stored procedure resolver) handles the conflict. I want to write my own logic in the first case (data changed without conflict) instead of SQL's built-in merge mechanism. Clearly I want to customize it.

There's onlyid, userId, blockedDate, usedDate columns in the article. I want to fill returnDate whenever a Ticket comes back to Publisher (on a pull) and fill transferDate whenever a Ticket goes to Subscriber (on a push).

Advise on SQL server data replication and cost saving

$
0
0

We are about to implement fail over and replication. We will be using two different servers where 2 of our websites will be hosted along with their databases. due to some reason, When site 1 is down, Traffic will directed to site 2 and site 2 has its own database, and when site 1 back online traffic will redirect to site 1. We want to keep up to date data in our both server's. Please suggest any idea where we can apply which type of replication?

We will have two different sql server as well.

Merge replication - corrupt row continually trying to INSERT

$
0
0

We have "push" SQL replication sent up, with one publisher and three subscribers. Two of the three are working fine, but one is continually causing trouble. I went through the pain and heartache of reinitialising the subscription at the weekend, and just a few days later it's stuck again.

This time, the error I'm seeing in replmerg.log (after turning up the verbosity) is:

The merge process could not replicate one or more INSERT statements to the 'Publisher'. A stored procedure failed to execute. Troubleshoot by using SQL Profiler.

I've tracked this down to a single table in the database: for some reason, an obviously corrupt row is continually trying to be INSERTed into the table, with a rowguid of 00000000-0000-0000-0000-000000000000. DBCC CHECKDB shows no sign of corruption.

Here's the row:

enter image description here

If I try to get rid of the bad row on the Publisher:

delete from mytable
where rowguid like '00000000-0000-0000-0000-000000000000'

I get the error:

Msg 2601, Level 14, State 1, Procedure MSmerge_del_590C419D78ED4A36A40292C23CF5F67B, Line 68 Cannot insert duplicate key row in object 'dbo.MSmerge_tombstone' with unique index 'uc1MSmerge_tombstone'. The duplicate key value is (3095029, 00000000-0000-0000-0000-000000000000). The statement has been terminated.

If I manually remove the row from MSmerge_tombstone, it comes back after the next replication cycle (which is continuous, so typically 60 seconds later).

I really don't want to have to reinitialise this subscription again. Is there any way of purging this set of corrupt transactions out of the "queue", or otherwise returning the replication back to normal?

is it possible to do the Merge Replication in databases that having two different database structures?

$
0
0

is it possible to do the Merge Replication in databases that having two different database structures ?

When Setuping the Merge Replication The Rows are Read only cannot be changed in subscriber Side

$
0
0

I Setup the Merge Replication In two instance with creating a database, the merge Setup was run successfully.But in subscriber side the rows are Read Only ,They cannot be Update or Delete.In the Publisher side the replication is working successfully(If We update some rows on publisher side it is replicating).

In the Subscriber Side The Replicated Database Rows are Read Only

The Data Synchronization Status


Replication recommendation

$
0
0

I am asked to investigate viability to use SQL Server replication technology for one of our upcoming project. In this project, basically there will be one central server located at corporate HQ (say Hub) and there will be multiple servers located at remote locations (say Nodes). All nodes will get data by using our application and Hub will get data directly injected into SQL Server. I am given 2 business requirements that need to be satisfied by this solution,

  1. Data to be synchronized between hub and nodes both ways.
  2. Data from one node NOT to appear on another node.

So based on those requirements, I chose to try Merge Replication.For test, I setup hub and 2 nodes. Hub is also acting as distributor. Then selected all objects of database and created subscription. And registered both nodes as subscribers. And this setup works... almost. The issue I am facing is, if I update data from node1 it appears in hub as well as node2 (and vise versa). That doesn't satisfy our 2nd requirement.

I am familiar with Replication but not master at it and I would really appreciate if someone can suggest if something is wrong with my approach. Or is merge replication not a good choice for my case?

I am using SQL Server 2014 standard editions for all 3 instances installed in Windows Server 2012R2.

Sync SQL Server 2014 and SQL Server 2014 Express database using stored procedure or C#

$
0
0

I have a C# Windows Forms application (writen in Visual Studio 2013) and I have the same database schema in both SQL Server (for master user) and in SQL Server Express (for clients). My database size is around 2 GB for each client.

I want to synchronize this databases once in a day or when needed. In SQL Server 2008, we have used RMO, but that API has been deprecated with SQL Server 2012.

I have tried using Merge Replication using T-SQL and able to create publication, add articles to publication, create subscriber and also able to register subscriber to publication but data was not synchronized.

Is there any good example for this(merge replication) which will work for SQL Server 2014 or later version then please suggest it.

Thanks.!

Replication Errors with no Meaningful Error Messages

$
0
0

We are in the process of testing a migration from SQL Server 2008R2 to 2014. As part of this we have done a dry run on our UAT platform. Everything seems to be running well but we have an odd situation with replication from one of the new servers.

Replication appears to be running fine. Tracer tokens are passing with about three seconds total latency but each time replication runs an there is an error produced by the Log Reader Agent. The problem we have is that the error message generated is 'The last step did not log any message' which is less than helpful. The error number returned is MSSQL_REPL22037. The SQL Server Error log also has Error; 14151, Severity: 18, State: 1 recorded but this seems to be a pretty generic error message.

When I search for the MSSQL_REPL22037, all the results have the error MSSQL_REPL20011 'could not execute sp_replcmds' associated with them. As far as I can see this is running (because the Tracer Tokens work).

Can anybody help?

What is the "Replication" key for in a SQL Server connection string?

$
0
0

In a SQL Server connection string you can specify a boolean value for the Replication key, for example:

Data Source=.;Initial Catalog=Example;Integrated Security=True;Replication=True;

The closest I can find to documentation of this is here, which says:

Gets or sets a Boolean value that indicates whether replication is supported using the connection.

But to me that doesn't really explain in enough detail what the setting actually does. Can someone give a deeper explanation of this?

I am working with databases that make use of replication, so it seems that this setting could be relevant.

Move transactional replication subscriber to another server without re-snapshotting

$
0
0

I have publisher and subscriber at same server. I need to move subscriber's DB to another server but without creating new snapshot. I've tried this steps:

  • Stop all agents
  • Backup subscriber's DB
  • Restore subscriber's DB on another server with KEEP_REPLICATION
  • Changed server name insyssubscriptions, MSsubscriber_info, MSsubscriber_schedule
  • Changed server name in scheduled task for replication

Then I've started agents and got error 20053 (Server not registered). I fixed it with adding linked server to new server

After that I've got an error 20044 (Subscription is outdated or not present), but subscription is present.

What did I do wrong or maybe I have missed any step(s)?

I can't use initialization from backup, because subscriber has some additional tables, views, routines. Thanks

How to migrate databases using transactional replication to a new server without resynching everything

$
0
0

We are currently looking at moving several databases (SQL Server 2012 SP3) that heavily using SQL transactional replication. We are looking at ways that we can restore the database on a new server, but have replication pick up from the last backup. These tables are very large so resynching them completely would take a significant amount of time and trying to avoid this.

I enabled sync with backup on all the publisher and distribution db’s in server and I scripted all the replication(publications, distribution and subscriptions), however, when I restored the databases I was unable to get replication to resynch without rebuilding it completely.

When I checked BOL, it looks like it says you cannot resume replication on a new server without rebuilding it. However, it did mention that you could use log shipping in advance, however, when we looked into this it appears that we would need to restore msdb and master during the cutover. And then rename the new server to match the old one. And then restore the service master key. This will not work for us though. The databases will be moving from a traditional SQL Cluster to a AlwaysON AG so configurations\names will be different.

Another thought that we had is that we could setup replication from the same target to the old server and go ahead and configure the same replication to the new server. This would at least limit the downtime needed for the cutover. This would work for some databases exclusively consist of replicated tables, however, we have several databases that consists of replicated tables and static ones. So will not work for these since we need to retain all changed data from the other tables at cutover time.

We have tried several things and spent weeks testing out scenarios of moving replication with rebuilding and so far there does not seem to be a good answer so wanted to check with the DBA community to see if you guys have other suggestions

SQL Server : merge replication error

$
0
0

Can anyone please help me out to solve this error in SQL Server merge replication?

The merge process could not replicate one or more INSERT statements to the 'Subscriber'. A stored procedure failed to execute. Troubleshoot by using SQL Profiler. (Source: MSSQLServer, Error number: -2147200990)

A query executing on Subscriber 'DB-TEST' failed because the connection was chosen as the victim in a deadlock. Please rerun the merge process if you still see this error after internal retries by the merge process. (Source: MSSQLServer, Error number: 20245)

Cannot issue SAVE TRANSACTION when there is no active transaction. (Source: MSSQLServer, Error number: 628)


Availability Group of SQL Servers 2012, 2012 and 2016 possible?

$
0
0

We have two SQL servers combined into Availability Group in primary data center (dc1):

dc1 server 1: SQL Server 2012 SP3 on Windows 2016
dc1 server 2: SQL Server 2012 SP3 on Windows 2012 R2

We are going to open new data center (dc2) which is going eventually to be new primary data center In dc2 there is going to be third SQL server

dc2 server 3: SQL Server 2016 (or 2012) on Windows 2016

We would like to have SQL Server 2016 on server 3, but here are my questions:

1) --> What are potential problems if we add SQL Server 2016 as a third node to existing Availability Group that has two SQL Servers 2012?

2) --> Will AG be working properly or ? If you have any practical experience of doing so, please share

3) --> Do we really need to deploy server 3 as SQL Server 2012 (instead of 2016) in order for AG to be working ?

4) --> What are best options (aside of AG) to keep SQL servers 1, 2, and 3 in sync if we chose to deploy server 3 as SQL Server 2016 ? is that transactional replication

Thanks in advance!

SQL Merge Replication Error-1

$
0
0

I'm facing a problem in SQL merge replication:

Error message:

The merge process was unable to verify the existence of a generation at 'publisher'. Îf this failure persists, reintilialize the subscription.

TCP Provider: The semaphore timeout period has expired. (Source: MSSQLServer, Error number:121)

Communication link failure (Source: MSSQLServer: Error number: 121) Get help:

While I'm not in position to reintialize subscription due to production database environment.

what happens to the unsent data from distributor in Replication

$
0
0

In Replication, My Subscriber has stopped working. All the unsent data are present in Distributor. And as per distributor, all the history will get removed after 72 hours(default value). So my doubt is, whether my unsent data will also get removed from the distributor after 72 hours if Subscriber doesn't come online?

stored procedure MSenumgenerations90 is slowing down merge replication

$
0
0

I have a merge replication that has been running fine for a year (the system has been active for several years but I recreated the replication a year ago because of some other problems).

Everything is still working but when someone is (re-)initializing a subscription (downloading a new subscription-database) it takes much longer time and there are some locks appearing. the subscribers are ca 300 windows ce devices with sql server compact.

What I can see is that a stored procedure called MSenumgenerations90 is the culprit and it takes up alot of IO and CPU. the most common wait i can see in activity monitor i CXPACKET and I understand that this is parallelism. I can see some pageiolatch and at least some of them is pointing to the tempdb. the table msMerge_GenHistory contains a bit more then 1,5 million records and i tried to add indexes to it to make the expensive operation in the stored procedure to run quicker but with no success.

My retention period is high. it is set to 60 days but i can still see that there is generations in MSMerge_GenHistory that is created (coldate) when I recreated the replication a year ago however there seems to be some generations removed since the generationid of the latest one is above 2,2 million. could there be something wrong with the metadata cleanup or is this normal behavior? When the CXPACKET waits are showing i get Buffer I/O wait times at 2000 ms/s and there is also a lot of IO_COMPLETION waits, when I monitor the disk at the server i can see that tempdb-file is getting the most reads and writes. One of the things I have read is that you can setup multiple files for tempdb and that it could relieve the pressure on tempdb, could this be something that would help my situation?

Is it safe to add more files to tempdb when you have a merge replication running?

UPDATE. I ran the stored procedure to get the actual execution plan and there is a sort warning that says the sort is spilling to tempdb. I am guessing this is the reason for my problem, the sp is running in parallel and it spills to tempdb and 8 consecutive threads are accessing the the tempdb to try and sort results and that is why the waits in IO is high and why CXPACKET is showing!?my sort waring how can i get it to stop spilling to tempdb? could it be done by indexing better? I cannot modify the sp since it is part of the replication. Any help is welcome.

Does adding non-clustered indexes to Transactional Replication increase latency

$
0
0

I would like to add non-clustered indexes to my Publication for Transactional Replication. I am aware that replication works by reading the transaction log for the published database and sends the updates to the subscribers. My question is: does transaction log include updates to indexes and therefore would this double the updates sent to the subscriber? Will it send updates to subscriber when I run Index maintenance ie: Rebuilding/Reorganizing indexes?

If so, then perhaps creating non-clustered indexes as part of post snapshot script application is a better way. If not, then I prefer to keep it as part of Publication.

Viewing all 17268 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>