synchronization_statistics connection event

Tracks synchronization statistics.

Parameters

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.

In SQL scripts, you can specify event parameters by name or with a question mark, but you cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you want to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts

Description

Order

s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable

s.username

VARCHAR(128). The MobiLink user name.

1

s.warnings

INTEGER. The number of warnings issued during the synchronization.

2

s.errors

INTEGER. The number of errors that occurred during the synchronization.

3

s.deadlocks

INTEGER. The number of deadlocks in the consolidated database that were detected for the synchronization.

4

s.synchronized_tables

INTEGER. The number of client tables that were involved in the synchronization.

5

s.connection_retries

INTEGER. The number of times the MobiLink server retried the connection to the consolidated database.

6

Default action

None.

Remarks

The synchronization_statistics event allows you to gather, for any user and connection, various statistics about the current synchronization. The synchronization_statistics connection script is called just prior to the commit at the end of the end synchronization transaction.

See also
SQL example

The following example inserts synchronization statistics into the sync_con_audit table.

CALL ml_add_connection_script(
  'ver1',
  'synchronization_statistics',
 'INSERT INTO sync_con_audit(
   ml_user, 
   warnings, 
   errors,
   deadlocks, 
   synchronized_tables,
   connection_retries)
  VALUES (
   {ml s.username}, 
   {ml s.warnings}, 
   {ml s.errors}, 
   {ml s.deadlocks}, 
   {ml s.synchronized_tables}, 
   {ml s.connection_retries})' )

Once statistics are inserted into the audit table, you may use these statistics to monitor your synchronizations and make optimizations where applicable.

Java example

The following call to a MobiLink system procedure registers a Java method called synchronizationStatisticsConnection as the script for the synchronization_statistics connection event when synchronizing the script version ver1.

CALL ml_add_java_connection_script(
  'ver1',
  'synchronization_statistics',
  'ExamplePackage.ExampleClass.synchronizationStatisticsConnection'
)

The following is the sample Java method synchronizationStatisticsConnection. It logs some of the statistics to the MobiLink message log. (Note that logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

public String synchronizationStatisticsConnection(
  String user, 
  int warnings, 
  int errors, 
  int deadlocks,
  int synchronizedTables, 
  int connectionRetries ) {
  java.lang.System.out.println( 
   "synch statistics number of deadlocks: " 
   + deadlocks ;
  return( null ); 
}
.NET example

The following call to a MobiLink system procedure registers a .NET method called SyncStats as the script for the synchronization_statistics connection event when synchronizing the script version ver1.

CALL ml_add_dnet_connection_script(
  'ver1',
  'synchronization_statistics',
  'TestScripts.Test.SyncStats'
)

The following is the sample .NET method SyncStats. It logs some of the statistics to the MobiLink message log. (Note that logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

public string SyncStats(
  string user,
  int warnings,
  int errors,
  int deadLocks,
  int syncedTables,
  int connRetries ) {
  System.Console.WriteLine( "synch statistics
   number of deadlocks: " + deadlocks ;
  return( null ); 
}