Skip to content

Support routing to named read replicas #3641

@mdaigle

Description

@mdaigle

Summary

Azure SQL hyperscale is introducing a new gateway feature to load balance read requests between named reader replicas. Load balancing support is accessed by connecting to a "reader endpoint" FQDN at the gateway, separate from the regular gateway FQDN. The load balancing occurs without the client needing to specify the replica's database name (each replica may have its own unique name and may differ from the primary's database name).

The current routing ENVCHANGE token supports protocol, port, and FQDN. To connect to a particular database at the routed location, we need to introduce a mechanism for the gateway to specify which database to use.

Feature Design

TDS Updates

Update TDS to include a new FEATUREEXT 0x10 (EnhancedRouting) token, and an accompanying FEATUREEXTACK to indicate gateway support.

Update TDS to include a new ENVCHANGE 0x21 (EnhancedRouting) payload type. The payload includes all of the data currently present in 0x20 (Routing) plus a required database name field.

ENVCHANGE 0x21 (EnhancedRouting) payload shape:

TokenType: BYTE				 // 0xE3 = ENVCHANGE token 
Length:    USHORT                // byte length of EnvValueData 
Type:      BYTE                  // 0x15 = Type 21, EnhancedRouting 
 
EnvValueData: 
  Protocol:         BYTE        // 0x00 = TCP/IP 
  ProtocolProperty: USHORT      // Port 8080 (hex 1F90) 
  AlternateServer:  US_VARCHAR  // USHORT character stream 
  AlternateDatabase: US_VARCHAR // USHORT character stream, not to exceed 128 characters 

Driver Behavior

New driver versions will always send the new FEATUREEXT 0x0F (EnhancedRouting) token on all connection requests.

If (and only if) EnhancedRouting support is successfully negotiated with the server (via the ENHANCEDROUTINGSUPPORT featureext ack), the driver will respect ENVCHANGE 0x21 (EnhancedRouting) tokens, otherwise the token is rejected.

This feature is separate from the ReadOnly intent feature and does not require ReadOnly intent to be set.

Metadata

Metadata

Assignees

Labels

Enhancement 💡Issues that are feature requests for the drivers we maintain.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions