Skip to content

TdsSslHandler incompatible with Netty 4.2 AdaptivePoolingAllocator (Spring Boot 4) #309

@kevin-nca

Description

@kevin-nca

Versions

  • Driver: r2dbc-mssql 1.0.4.RELEASE
  • Database: Microsoft SQL Server 2019
  • Java: 21
  • OS: Linux (Kubernetes container)
  • Netty: 4.2.9 (Spring Boot 4.0.2)

Current Behavior

All connections fail during TLS handshake. Netty 4.2 changed the default allocator to AdaptivePoolingAllocator (migration guide). TdsSslHandler.channelRead() calls alloc() on a released ByteBuf, which the new allocator rejects. This breaks every connection, including with sslMode=disable, since TDS always does a TLS handshake for login credentials (?).

Workaround: -Dio.netty.allocator.type=pooled

Stack trace
io.netty.util.IllegalReferenceCountException: null
    at i.n.b.AdaptivePoolingAllocator$AdaptiveByteBuf.rootParent(AdaptivePoolingAllocator.java:1427)
    at i.n.b.AdaptivePoolingAllocator$AdaptiveByteBuf.alloc(AdaptivePoolingAllocator.java:1481)
    at io.r2dbc.mssql.client.ssl.TdsSslHandler.channelRead(TdsSslHandler.java:346)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:354)
    at i.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1429)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918)

Table schema

N/A, it fails during connection establishment.

Steps to reproduce

  1. Spring Boot 4.0.x + r2dbc-mssql + any SQL Server instance
  2. Every connection attempt fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions