AlwaysOn: Client (Re)Connecting to wrong server after fail-over?

  • Hi, I hope someone can point me into the right direction.

    We have a AlwaysOn HADR setup with 2 servers, one primary and one secondary replica for a couple of databases. Synchronous Commit, Automatic Failover, Readable Secondary defined, No ReadOnly Routing.

    SQL-01, *.*.*.240

    SQL-02, *.*.*.241

    -> AG Listener: SQL, IP *.*.*.229

    An application recently started behaving weird when a fail-over from one server to the other occurs. It seems to be re-connecting to the wrong (now secondary) server and thus will see an appropriate error message (DB is readonly) upon writing attempts.

    At the time of fail-over the application sees the following error message:

    "Unable to access database 'Execution' because its replica role is RESOLVING which does not allow connections. Try the operation again later."

    -> this is expected,

    a few (~10) seconds later the same application gets the following error

    "The target database ('Execution') is in an availability group and is currently accessible for connections when the application intent is set to read only."

    or the one that the target database is read-only

    I have checked the connection string of the application. It is using the AG listener DNS name [SQL], and [SQL] is always resolved to IP *.*.*.229

    Now I am wondering why the application hangs on to the wrong server?

    Kind regards, Frank

  • What does the AlwaysOn groups read only routing url config look like, specifically the url order for each replica when in the primary role

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Replica SecondaryRoleConnections ReadonlyRoutingUrl

    [SQL-01] READ_ONLY tcp://SQL-01.MKT.LOCAL:1433

    [SQL-02] ALL {NULL}

    sys.availability_read_only_routing_lists contains (only) 1 record

    replica_id routing_priority read_only_replica_id

    SQL-01 1 SQL-01

    (replaced the GUID with the replica name)

    Does that help?

    Thanks, Frank

  • Doh, sorry didnt see this

    ffoerster (5/6/2014)


    No ReadOnly Routing.

    Have you double checked the connection string, are you using std TCP port or non std?

    Was this an automatic failover or a manual failover?

    Could you check the results of the following please

    select replica_server_name,

    availability_mode_desc,

    failover_mode_desc,

    primary_role_allow_connections_desc,

    secondary_role_allow_connections_desc

    from [sys].[availability_replicas]

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Just completed my response but posting resulted in an "error" here on the board. 🙁

    Will type it together again, may take some minutes though

    Frank

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply