cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

I am developing an iPad application with Client-Consolidated DB synchronization model. After synchronization I am performing a cleanup operation which deletes irrelevant records from client db. My cleanup procedure has 40 delete statements. The workflow for this cleanup is:
1. STOP SYNCHRONIZATION DELETE
2. Run all the delete queries.
3. COMMIT
4. START SYNCHRONIZATION DELETE
I have searched the documentation in which COMMIT is given after START SYNC command. I think it should not be the problem here.
I have tested this logic by executing through ULPreparedStatement::ExecuteStatement() and from the inbuilt C++ API function connection->stopSynchronizationDelete(). In both cases I am getting a true return value, but from the server log I can see that it is trying to upload those deletes to server.

View Entire Topic
Breck_Carter
Participant

Here's the test I just ran using SQL Anywhere 12.0.1.3298. It shows that STOP SYNCHRONIZATION DELETE prevented 40 DELETE operations from being uploaded even though the COMMIT preceded the START SYNCHRONIZATION DELETE.


001_setup_cons_remo.bat
"%SQLANY12%bin32dbinit.exe" cons.db

"%SQLANY12%bin32dbspawn.exe" -f "%SQLANY12%bin32dbeng12.exe" -o dbeng12_log_cons.txt -os 1M -x none cons.db

"%SQLANY12%bin32dbisql.com" -c "ENG=cons;DBN=cons;UID=dba;PWD=sql" READ ENCODING Cp1252 "%SQLANY12%MobiLinksetupsyncsa.sql"

PAUSE

"%SQLANY12%bin32dbisql.com" -c "ENG=cons;DBN=cons;UID=dba;PWD=sql" READ ENCODING Cp1252 001s_script_to_setup_cons.sql

PAUSE

REM Use bin32 if running on 32-bit Windows...

"%SQLANY12%bin64dbdsn.exe" -ws cons -y -c "ENG=cons;DBN=cons;UID=dba;PWD=sql"

PAUSE

"%SQLANY12%bin32dbinit.exe" remo.db

"%SQLANY12%bin32dbspawn.exe" -f "%SQLANY12%bin32dbeng12.exe" -o dbeng12_log_remo.txt -os 1M -x none remo.db

"%SQLANY12%bin32dbisql.com" -c "ENG=remo;DBN=remo;UID=dba;PWD=sql" READ ENCODING Cp1252 001s_script_to_setup_remo.sql

PAUSE

"%SQLANY12%bin32dbisql.com" -c "ENG=cons;DBN=cons;UID=dba;PWD=sql"

"%SQLANY12%bin32dbisql.com" -c "ENG=remo;DBN=remo;UID=dba;PWD=sql"

PAUSE All done...


001s_script_to_setup_cons.sql


-- Define GLOBAL AUTOINCREMENT partition number.

SET OPTION PUBLIC.GLOBAL_DATABASE_ID = '0';


BEGIN DROP TABLE d; EXCEPTION WHEN OTHERS THEN END;

CREATE TABLE d ( key_1 UNSIGNED BIGINT NOT NULL DEFAULT GLOBAL AUTOINCREMENT ( 1000000000 ), non_key_1 VARCHAR ( 100 ) NOT NULL DEFAULT '', last_updated TIMESTAMP NOT NULL DEFAULT TIMESTAMP, PRIMARY KEY ( key_1 ) );


CALL ml_add_table_script ( 'v1', 'd', 'upload_insert', NULL ); CALL ml_add_table_script ( 'v1', 'd', 'upload_insert', ' INSERT d ( key_1, non_key_1 ) VALUES ( ?, ? )' );


CALL ml_add_table_script ( 'v1', 'd', 'upload_update', NULL ); CALL ml_add_table_script ( 'v1', 'd', 'upload_update', ' UPDATE d SET non_key_1 = ? WHERE key_1 = ?' );


CALL ml_add_table_script ( 'v1', 'd', 'upload_delete', NULL ); CALL ml_add_table_script ( 'v1', 'd', 'upload_delete', ' DELETE d WHERE key_1 = ?' );


CALL ml_add_table_script ( 'v1', 'd', 'download_cursor', NULL ); CALL ml_add_table_script ( 'v1', 'd', 'download_cursor', ' SELECT key_1, non_key_1 FROM d WHERE last_updated >= ?' );


CALL ml_add_table_script ( 'v1', 'd', 'download_delete_cursor', NULL ); CALL ml_add_table_script ( 'v1', 'd', 'download_delete_cursor', '--{ml_ignore}' );


-- Insert rows to download and then delete.

BEGIN DECLARE @rowcount INTEGER; SET @rowcount = 1; WHILE @rowcount <= 100 LOOP INSERT d VALUES ( DEFAULT, DEFAULT, DEFAULT ); SET @rowcount = @rowcount + 1; END LOOP; COMMIT; END;


001s_script_to_setup_remo.sql


-- Define GLOBAL AUTOINCREMENT partition number.

SET OPTION PUBLIC.GLOBAL_DATABASE_ID = '1';


BEGIN REVOKE CONNECT FROM REMOTE_DBA; EXCEPTION WHEN OTHERS THEN END;

GRANT CONNECT TO REMOTE_DBA IDENTIFIED BY SQL; GRANT REMOTE DBA TO REMOTE_DBA;


BEGIN DROP SYNCHRONIZATION SUBSCRIPTION TO p1 FOR "1"; EXCEPTION WHEN OTHERS THEN END;

BEGIN DROP SYNCHRONIZATION USER "1"; EXCEPTION WHEN OTHERS THEN END;

BEGIN DROP PUBLICATION p1; EXCEPTION WHEN OTHERS THEN END;


BEGIN DROP TABLE d; EXCEPTION WHEN OTHERS THEN END;

CREATE TABLE d ( key_1 UNSIGNED BIGINT NOT NULL DEFAULT GLOBAL AUTOINCREMENT ( 1000000000 ), non_key_1 VARCHAR ( 100 ) NOT NULL DEFAULT '', last_updated TIMESTAMP NOT NULL DEFAULT TIMESTAMP, PRIMARY KEY ( key_1 ) );


CREATE PUBLICATION p1 ( TABLE d ( key_1, non_key_1 ) );

CREATE SYNCHRONIZATION USER "1" TYPE tcpip;

CREATE SYNCHRONIZATION SUBSCRIPTION TO p1 FOR "1";


002_run_mlsrv12.bat
"%SQLANY12%bin64mlsrv12.exe"^
  -c "DSN=cons;UID=dba;PWD=sql"^
  -o mlsrv12_log_cons.txt^
  -os 10M^
  -ppv 60^
  -vcefhkmnopstuU^
  -zu+ 


003_run_dbmlsync.bat
"%SQLANY12%bin32dbmlsync.exe"^
  -c "ENG=remo;DBN=remo;UID=REMOTE_DBA;PWD=SQL"^
  -e "adr='host=localhost';sv=v1"^
  -o dbmlsync_log_remo.txt^
  -os 10M^
  -vnosu^
  -x


004_test_STOP_SYNCHRONIZATION_DELETE.sql


-- Run initial sync.


-- Run this on remote database...

STOP SYNCHRONIZATION DELETE; DELETE d WHERE key_1 <= 40; COMMIT; START SYNCHRONIZATION DELETE;


-- Run second sync.


-- Run this on consolidated database...

SELECT * FROM d;

key_1,non_key_1,last_updated 1,'','2012-05-08 08:42:21.104' 2,'','2012-05-08 08:42:21.137' ... 40,'','2012-05-08 08:42:21.140' 41,'','2012-05-08 08:42:21.140' 42,'','2012-05-08 08:42:21.140' ... 100,'','2012-05-08 08:42:21.143'