Resuming failed downloads

Download failure is caused by a communication error during the download or a user cancelling the download. The MobiLink server holds download data that has not been received by the client for use in a restartable download. You can reduce the probability of download failure by decreasing the maximum amount of data allocated for restartable downloads using the -ds option. The server does not release download data until one of the following occurs:

  • The user successfully completes the download.
  • The user comes back with a new sync request without resume enabled.
  • The cache is needed for incoming requests. The oldest unsuccessful download is cleared first.

MobiLink has functionality that can assist with download failure recovery, and prevent retransmission of the entire download. This functionality has separate implementations for SQL Anywhere and UltraLite remote databases. See -ds option.

SQL Anywhere remote databases

When synchronization fails during a download, the downloaded data is not applied to the remote database, however, the successfully transmitted download portions are stored in a temporary file on the remote device. Dbmlsync uses this file to avoid lengthy retransmission of data, and to recover from download failure.

There are three ways to implement this functionality. In all cases, dbmlsync aborts and the resumed download fails if there is any new data to be uploaded.

  • -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 only transmits 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.

    See ContinueDownload (cd) extended option and sp_hook_dbmlsync_set_extended_options.

  • 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.

    See sp_hook_dbmlsync_end.

UltraLite remote databases

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. See Keep Partial Download synchronization parameter, and Partial Download Retained synchronization parameter.

  • To resume the download, set the Resume Partial Download synchronization parameter to true and synchronize again. See Resume Partial Download synchronization parameter.

    The restarted synchronization does not perform 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 need to synchronize again once the failed download has completed, or 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:

    • Keep Partial Download (in case of further interruption)
    • DisableConcurrency
    • Observer
    • User Data
  • 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.

    You may want to roll back the changes from a failed download if synchronization cannot be completed, for example if the server or network is unavailable, and if you want to maintain a consistent set of data while letting the end user continue to work.

For more information about communications errors, see Error Messages.

Note

If the send_download_ack synchronization parameter is set to true, the setting is ignored for the resumed download.