CTLIB Application Changes

NoteAn application installed in a cluster must be able to run on both the primary and secondary companions. That is, if you install an application that requires a parallel configuration, the secondary companion must also be configured for parallel processing so it can run the application during failover.

You must modify all of your applications that are written with CTLIB API calls before they can work with Sybase’s failover software. The following steps describe the modifications:

  1. Set the CS_HAFAILOVER property using the ct_config and ct_con_props CTLIB API calls. You can set this property at either the context or the connection level. This property is set using the following syntax:

    ct_config(context, action, CS_HAFAILOVER, buf, buflen, outlen)
    ct_con_props(connection, action, CS_HAFAILOVER, buf, buflen, outlen)
    
  2. Modify the interfaces file so clients fail over to the secondary companion.

    The interfaces file includes a line labeled hafailover that enables clients for reconnect to the secondary companion when the primary companion crashes or you issue a shutdown with nowait, triggering failover.

    See “Add Entries for Both Adaptive Servers to the Interfaces File” for information about adding this line to the interfaces file.

  3. Write application failover messages according to the following parameters:

    However, if the failover property is set but the interfaces file does not have a entry for the hafailover server (or vice-versa), then it is a not a failover connection. Instead, it is a normal non-high availability connection with the failover property turned off. The user must check the failover property to know whether or not the connection was a failover connection

  4. Add return codes

    When a successful failover occurs, the client issues a return value named CS_RET_HAFAILOVER, which is specific to the following CTLIB API calls:

    ret = ct_results(cmd, result_type)
    
    ret = ct_send(cmd)
    

    CS_RET_HAFAILOVER is returned from the API call during a synchronous connection. In an asynchronous connection, these API `s issue CS_PENDING and the callback function returns CS_RET_HAFAILOVER. Depending on the return code, the customer can do the required processing, such as sending the next command to be executed.

    1. Rebuild your applications, linking them with the libraries included with the failover software.

      NoteYou cannot connect clients with the failover property (for example isql -Q) until you issue sp_companion resume. If you do try to reconnect them after issuing sp_companion prepare_failback, the client hangs until you issue sp_companion resume.