My Merge Replication was working correctly till New Year.
The initial synchronization is always synchronous (I must have a
database in order to start my application) and the rest of them are
asynchronous. This scenarios was working perfectly.
Now, without making any changes, initial replication (copy of the whole
database) is correctly done, but subsequent replication calls fail, and
fail without giving any error! I've got a catch block where I display a
messagebox with the thrown exception but this code is never reached. An
aplication is completely closed without any error message.
What can be happening? It's really strange and very urgent. I promise
you this code was perfecty working before Christmas.
Ah! I've also tried making a synchronous replication second time, but
same thing occurs.I've deleted the local database, created again the
publication on the server.........
I would really appreciate any help on this. Thanks very much.
Can you successfully run the merge agent from SSMS? If not, is there any
message sent?
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I've now checked another thing: when I've already got a local database,
second, third, fourth and subsequent synchronizations are correctly
done, and they ar ein asynchronous mode.
The problems is starting the application for the first time, with no
database. Database is correctly downloaded first time, but second time,
my application exits without any error message.
Sorry for my poor SQL Server knowledge, but how do I run the Merge
Agent from Management Studio?
Really strange.......thanks for your help.
|||To start the merge agent in SQL Server 2000, open Enterprise Manager,
Replication Monitor, Expand the publication and on the RHS you'll see the
related agents. Right-clicking on it will allow you to start the agent. In
SSMS (SQL Server 2005) the process is similar, but Replication Monitor is a
separate application that is started by right-clicking the replication
folder.
Also, I proobably need a little more clarification about some of your
descriptions. You mention starting the application when you don't have a
local database. Does your application create a local database and then
create the publication, subscription and then initialize the subscription?
Also, you're using asychronous and synchronous processing - are you
referring to MSMQ, Service Broker or some such mechanism?
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I've been able to start the Merge Agent from SQL Server 2005 Management
Studio. Agent runs correctly.
Some clarifications:
I use always Merge Replication.
My application initially checks if there is a local database
(downloaded before maybe); if there is, the synchronization is
asynchronous because we have data to play with.
If there is no database, I make a synchronous call with Synchronize()
method and wait. Then, I again have got data to play with. Next calls
will also be asynchronous.
This is the merge replication code I'm using. Really simple:
private void CheckReplicationStatus(object sender, EventArgs e)
{
if (true)
{
try
{
ConfigureReplicationManager();
if (replicationManager !=3D null &&
systemCanReplicate)
{
replicationManager.HostName =3D userId;
// Check if the database file already exists
if
(!System.IO.File.Exists(Constants.DatabaseFilePath ))
{
// Add a new subscripton and create the
local database file
replicationManager.AddSubscription(AddOption.Creat eDatabase);
// La replicaci=F3n inicial es
necesariamente s=EDncrona ya que no existe la BD en local
replicationManager.Synchronize();
replicationManager.Dispose();
}
else
{
// Replicaci=F3n as=EDncrona
IAsyncResult ar =3D
replicationManager.BeginSynchronize(new
AsyncCallback(SyncCompletedCallback), replicationManager);
}
}
else // No ha sido capaz de leer los ficheros de
configuraci=F3n y no ha podido configurar la replicaci=F3n
{
// La idea es ver si la BD existe en el
dispositivo --> Se le deja continuar ejecutando la aplicaci=F3n
// pero se cancela la replicaci=F3n. Pero no hay
manera ya que el path de la BD est=E1 tambi=E9n en los ficheros de
configuraci=F3n
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_CannotRea=
dConfigurationFiles);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToUpper());
replicationManager.Dispose();
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_InitialSy=
nchronizationFailed);
// TODO: BORRAR LA BD YA QUE NO ES UNA BD OPERATIVA
Application.Exit();
}
}
}
/// <summary>
/// Evento que recoge los resultados de la sincronizaci=F3n
as=EDncrona
/// </summary>
/// <param name=3D"ar"></param>
public void SyncCompletedCallback(IAsyncResult ar)
{
try
{
SqlCeReplication repl =3D
(SqlCeReplication)ar.AsyncState;
replicationManager =3D (SqlCeReplication)ar.AsyncState;
replicationManager.EndSynchronize(ar);
}
catch (SqlCeException exc)
{
// Fallo en la sincronizaci=F3n as=EDncrona --> La
aplicaci=F3n sigue corriendo ya que tenemos BD en local
replicationManager.CancelSynchronize();
}
finally
{
replicationManager.Dispose();
}
}
This is all what I have Paul. Don't know what to do yet! It was working
and I'm spending my second day after a solution for this.
What do you think? Seems SQL Server's fault to me but cannot explain
why only fails second synchronization after first synchronization in
which I download all database.
Thanks for your time. Regards.
|||Hi again Paul,
I've tried to debug but I loose debugger when executing Synchronize()
method for the second time. I'm suffering this problem with the
debugger. It tells me:
"The remote connection to the device has been lost. Please verify the
device connection and restart debugging".
I saw a solution for this error on the internet and although I don't
know if it's related, I installed "Virtual Machine Network Driver for
Microsoft Device Emulator".
But debugger continues failing.
I don't know what else could I do. What frustrating is this situation!
Thanks.
|||If the merge agent can be successfully run in the case of the Synchronous
setup, then it seems to point to an application issue. Sorry, but
unfortunately I'm probably not the best to help in terms of debugging the C#
code (and debugging the debugger itself), so hopefully someone else can
continue the thread. If not, I'd recommend posting this in the C# newsgroup.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Starting the application without database and debugging, first
synchronization is correctly done. Second one crashes again my
debugger.
Starting the application with the database downloaded in the first try,
first synchronization is again correct. Second crashes again my
debugger.
Thanks Paul for your interest. Don't know exactly how but I suddenly
received just before having lunch this error from the application:
"A call to SQL Server Reconciler failed. Try to resynchronize.; The
Subscriber's schema version information is inconsistent with the
Publisher's schema version information. It is likely that the Publisher
has been restored from a backup whose schema change version is
different from the Subscriber. Rerun the Snapshot agent and
reinitialize the subscriptions. The Publisher and Subscriber schema
guids and version are:
'FFE575BF-5368-41BE-A451-10723451634B',272,'892E72E7-962F-437A-9228-F757FED7ECB9',272
respectively.}"
I've never seen that error before but I understand deleting and
generating again the publication will solve it.
Thanks for your time.
|||Your schema versions do not match. If you reinitialize, it will clean this
up.
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Lonifasiko" <mloichate@.gmail.com> wrote in message
news:1136285094.858729.123150@.g49g2000cwa.googlegr oups.com...
I've been able to start the Merge Agent from SQL Server 2005 Management
Studio. Agent runs correctly.
Some clarifications:
I use always Merge Replication.
My application initially checks if there is a local database
(downloaded before maybe); if there is, the synchronization is
asynchronous because we have data to play with.
If there is no database, I make a synchronous call with Synchronize()
method and wait. Then, I again have got data to play with. Next calls
will also be asynchronous.
This is the merge replication code I'm using. Really simple:
private void CheckReplicationStatus(object sender, EventArgs e)
{
if (true)
{
try
{
ConfigureReplicationManager();
if (replicationManager != null &&
systemCanReplicate)
{
replicationManager.HostName = userId;
// Check if the database file already exists
if
(!System.IO.File.Exists(Constants.DatabaseFilePath ))
{
// Add a new subscripton and create the
local database file
replicationManager.AddSubscription(AddOption.Creat eDatabase);
// La replicacin inicial es
necesariamente sncrona ya que no existe la BD en local
replicationManager.Synchronize();
replicationManager.Dispose();
}
else
{
// Replicacin asncrona
IAsyncResult ar =
replicationManager.BeginSynchronize(new
AsyncCallback(SyncCompletedCallback), replicationManager);
}
}
else // No ha sido capaz de leer los ficheros de
configuracin y no ha podido configurar la replicacin
{
// La idea es ver si la BD existe en el
dispositivo --> Se le deja continuar ejecutando la aplicacin
// pero se cancela la replicacin. Pero no hay
manera ya que el path de la BD est tambin en los ficheros de
configuracin
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_CannotReadConfigurationFiles);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToUpper());
replicationManager.Dispose();
GeneralBehaviour.ShowErrorMessage(Properties.Resou rces.MasterForm_InitialSynchronizationFailed);
// TODO: BORRAR LA BD YA QUE NO ES UNA BD OPERATIVA
Application.Exit();
}
}
}
/// <summary>
/// Evento que recoge los resultados de la sincronizacin
asncrona
/// </summary>
/// <param name="ar"></param>
public void SyncCompletedCallback(IAsyncResult ar)
{
try
{
SqlCeReplication repl =
(SqlCeReplication)ar.AsyncState;
replicationManager = (SqlCeReplication)ar.AsyncState;
replicationManager.EndSynchronize(ar);
}
catch (SqlCeException exc)
{
// Fallo en la sincronizacin asncrona --> La
aplicacin sigue corriendo ya que tenemos BD en local
replicationManager.CancelSynchronize();
}
finally
{
replicationManager.Dispose();
}
}
This is all what I have Paul. Don't know what to do yet! It was working
and I'm spending my second day after a solution for this.
What do you think? Seems SQL Server's fault to me but cannot explain
why only fails second synchronization after first synchronization in
which I download all database.
Thanks for your time. Regards.
Saturday, February 25, 2012
Application is closed during second synchronization
Labels:
adatabase,
application,
closed,
correctly,
database,
initial,
merge,
microsoft,
mysql,
oracle,
order,
replication,
second,
server,
sql,
synchronization,
synchronous,
working
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment