Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failover support #64

Open
formicas opened this issue Jun 27, 2018 · 4 comments
Open

Add failover support #64

formicas opened this issue Jun 27, 2018 · 4 comments
Labels
connection parameter drop-in replacement For issues related to dropping this driver into a pre-existing .net framework project enhancement help wanted
Projects

Comments

@formicas
Copy link
Contributor

No description provided.

@formicas formicas added enhancement help wanted drop-in replacement For issues related to dropping this driver into a pre-existing .net framework project connection parameter labels Jun 27, 2018
@senseibaka senseibaka changed the title Failover suport Add failover support Jun 27, 2018
@senseibaka
Copy link
Collaborator

From https://www.connectionstrings.com/ase-ado-net-data-provider/
We need to support the following parameters:

  • HASession - when set to 1 this means we need to operate in a mode which supports failover - I'll call this "HA mode"
  • AlternateServers - a comma-separated list of alternative servers to connect when opening a connection
    • Format: server:port[,server:port/*...*/,server:port]
  • Secondary Data Source + Secondary Server Port - alternate way to specify an alternative server

Also, it sounds like once the client establishes a connection with one of the servers specified, the client will receive a list of all available failover targets (servers).

Planned behaviour (still being thought about. not final):

  • Alter Open behaviour to fall back to the alternate servers
  • Implement handling for when servers send a list of failover targets
    • Not sure yet whether each connection in the pool will maintain its own list, or have one per-pool... I think it'll be safe enough to do it per-pool, as long as there's some thread control in there. Then again, it might be cleaner/easier to keep lists per-connection...
  • Investigate how the reference driver handles this stuff. I've heard that if a failover is required, it will emit some sort of failover exception, and it's up to the user to handle (e.g. by trying all sql commands again).
    • However it's done, we'll have to implement the same outcome.

@senseibaka senseibaka added this to To do in Main Aug 28, 2018
@senseibaka
Copy link
Collaborator

@senseibaka
Copy link
Collaborator

There are a few TDS_MSG types, prefixed with TDS_MSG_MIG_, which appear to be related to failover.

In the normal case:

  1. Primary will signal to the client that they need to prepare to migrate (TDS_MSG_MIG_REQ) to a different server (address gets provided as another token).
  2. The client will acknowledge it (TDS_MSG_MIG_SYNC)
  3. Primary will signal to initiate migration (TDS_MSG_MIG_CONT) or cancel migration (TDS_MSG_MIG_IGN).
  4. Client will login to the secondary (providing some sort of migration ID).
  5. If the client fails, it will tell the Primary (TDS_MSG_MIG_FAIL).

In the normal case, it sounds like the Primary will send data to the client until it's time to migrate, and then the client will receive the rest of the data from the new server.

I'm not sure what behaviour should be in other circumstances, not sure when AseFailoverException comes into it.

@c-j-hughes
Copy link
Collaborator

Will have an HADR environment to test against available from 14th-18th January so we can suss this out. The AseFailoverException could just be some legacy thing from a previous failover mechanism maybe just associated with the HASession, AlternateServers, Secondary Data Source, and Secondary Server Port connection string properties.

Connection failover enhancement
Existing connection failover allows a client application to switch to an alternate ASE server if the primary server becomes unavailable due to an unplanned event, like power outage or a socket failure. This feature is enhanced to allow client applications to failover numerous times to multiple servers using dynamic failover addresses.

With the High Availability enabled, the client application does not need to be configured to know the possible failover targets. ASE keeps the client updated with the best failover list based on cluster membership, logical cluster usage and load distribution. During failover, the client refers to the ordered failover list while attempting to reconnect. If the driver successfully connects to a server, the driver internally updates the list of host values based on the list returned. Otherwise, the driver throws a connection failure exception.

Enabling extended connection failover in ADO.NET
To enable the extended failover, you need to set the HASession connection string property to 1. For example:

Data Source=server1;Port=port1;User ID=sa;Password=; Initial Catalog=sdc;HASession=1; AlternateServers=server2:port2,...,serverN:portN;

In the preceding example, Data Source defines the primary server and port. ADO.NET Provider by Sybase will try to establish connection to the primary server first and, if unsuccessful, will go through the servers listed in Alternate Servers until a connection is established or until the end of the list is reached.

Note - The list of alternate servers specified in the connection string is used only during initial connection. After the connection is established with any available instance, and the client supports high-availability, the client will receive an updated list of the best possible failover targets from the server. This new list overrides the specified list.

Source: Software Developer Kit 15.0 > New Features Open Server and SDK 15.0 for Windows, Linux, and UNIX > New features in ESD #12 > jConnect, ODBC, OLEDB and ADO.NET support for Adaptive Server Cluster Edition

Not necessarily a priority for us, but it sounds like the mechanic of getting the list of other servers in the response from the logon server is the same in this model as it is in the HA/DR one, so maybe we can support both at the same time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connection parameter drop-in replacement For issues related to dropping this driver into a pre-existing .net framework project enhancement help wanted
Projects
Main
To do
Development

No branches or pull requests

3 participants