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, you must also configure the secondary companion for parallel processing so it can run the application during fail over.

You must modify all applications that are written with CTLIB API calls before they can work with the Sybase Failover. Use:

  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. 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 to reconnect to the secondary companion when the primary companion crashes, or when you issue a shutdown with nowait, triggering a failover.

    See the “Adding entries for both Adaptive Servers to the interfaces file” section in the chapter for your platform for information about adding this line.

  3. Write application failover messages according to these parameters:

    • As soon as the companion begins to go down, clients receive an informational message that fail over is about to occur. Treat this as an informational message in the client error handlers.

    • Once the failover property is set (from step 1) and the interfaces file has a valid entry for the hafailover server, the client connection is a failover connection, and clients reconnect to the secondary companion appropriately.

      However, if the failover property is set but the interfaces file does not have an entry for the hafailover server (or vice-versa), then it is a not a failover connection. Instead, it is a normal connection with the failover property turned off. Inform the user to check the failover property to determine whether or not the connection is 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 perform 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 until you issue sp_companion resume. If you do try to reconnect them after issuing sp_companion prepare_failback, the client stops responding until you issue sp_companion resume.