Download failure is caused by a communication error during download or a user aborting the download. MobiLink has functionality that helps you recover from download failure, and may help you avoid having to retransmit the entire download. This functionality has separate implementations for SQL Anywhere and UltraLite remote databases.
When synchronization fails during a download, none of the download is applied to the remote database. However, the part of the download that was successfully transmitted is stored in a temporary file on the remote device. You cannot access this file directly, but dbmlsync provides functionality that makes use of the file. When you use this functionality, you may be able to avoid lengthy retransmission of data. You may also be able to recover from download failure automatically.
The download cannot be resumed when the SendDownloadACK extended option is set to ON (the default is OFF) or when the DownloadBufferSize extended option is set to 0 (which is also not the default).
There are three ways to implement this functionality. In all cases, the resumed download will fail if there is any new data to be uploaded, and dbmlsync will abort.
-dc After a download fails, use -dc the next time you start dbmlsync to resume the download. If part of the failed download was transmitted, the MobiLink server will only transmit the remainder of the download.
For more information, see -dc option.
ContinueDownload (cd) extended option When used on the dbmlsync command line, the cd extended option works just like the -dc option. You can also store this option in the database, or use sp_hook_dbmlsync_set_extended_options to set this option in a single synchronization.
sp_hook_dbmlsync_end hook You can use the restart parameter to cause a download to resume. You know a download is resumable if the restartable download parameter is set to true. You can also create logic in the hook to resume a download if a download file exists and is a certain size.
You can control the behavior of UltraLite applications following a failed download as follows:
If you set the Keep Partial Download synchronization parameter to true when you synchronize, and the download fails before completion, then UltraLite applies that portion of the changes that were downloaded. UltraLite also sets the Partial Download Retained synchronization parameter to true.
The UltraLite database may be in an inconsistent state at this point. Depending on your application, you may want to ensure that synchronization completes successfully or is rolled back before you allow changes to the data.
To resume the download, set the Resume Partial Download synchronization parameter to true and synchronize again.
The restarted synchronization does not carry out an upload, and downloads only those changes that would have been downloaded by the failed download. That is, it completes the failed download, but does not synchronize changes made since the previous attempt. To get those changes, you would need to synchronize again once the failed download has completed, or and call Rollback Partial Download and synchronize with Resume Partial Download set to false.
When you restart the download, many of the synchronization parameters from the failed synchronization are used again automatically. For example, the publications parameter is ignored: the synchronization downloads those publications requested on the initial download. The only parameters that must be set are the Resume Partial Download parameter (which must be set to true) and the User Name parameter. In addition, settings for the following parameters are obeyed, if set:
To roll back the changes from the failed download without resuming synchronization, call the function to roll back the changes. This function is ULRollbackPartialDownload function for embedded SQL. For UltraLite components, it is a method on the Connection object.
MobileVB RollbackPartialDownload method.
UltraLite.NET RollbackPartialDownload method
Embedded SQL ULRollbackPartialDownload function.
You may want to roll back the changes from a failed download if synchronization cannot be completed (perhaps the server or network is unavailable) and if you want to maintain a consistent set of data while letting the end user carry on working on the application.
For more information about communications errors, see SQL Anywhere® 10 - Error Messages.
If the send_download_ack synchronization parameter is set to true (which is not the default), the setting will be ignored for the resumed download.