Skip to content

Stored procedure with multiple rows hangs indefinitely (no completion) in r2dbc-mssql #297

@Khudayberganovnuriddin

Description

@Khudayberganovnuriddin

Describe the bug

When using r2dbc-mssql to call a stored procedure that returns multiple rows, the result never completes — the Flux hangs indefinitely unless a .timeout(...) is applied. No rows are emitted, and .doOnComplete() is never called.

This only happens with stored procedures that return full result sets. Simple procedures with SELECT TOP 1 or no result sets work fine.

Environment

  • r2dbc-mssql version: [your version]
  • SQL Server version: [e.g., SQL Server 2019]
  • Java version: [e.g., OpenJDK 17]
  • Spring Boot version: [if applicable]

Reproduction Steps

  1. Create a stored procedure like:
CREATE PROCEDURE GET_ALL_DATA
AS
BEGIN
  SET NOCOUNT ON;
  SELECT * FROM SomeTable;  -- Returns many rows
END

2. Call it via DatabaseClient:

databaseClient
    .sql("EXEC GET_ALL_DATA")
    .map((row, meta) -> ...) // any valid mapper
    .all()
    .doOnComplete(() -> System.out.println("done"))
    .doOnError(e -> e.printStackTrace())
    .subscribe();

    Result: Nothing happens. No rows. No errors. No completion. Just hangs.

If the procedure returns a single row (e.g., SELECT TOP 1), it completes normally.
Expected behavior

Procedure result set should be emitted and completed properly, like a normal SELECT.
Workaround

Calling the same logic via raw SELECT (instead of procedure) works fine:

databaseClient
    .sql("SELECT * FROM SomeTable")
    .map(...)
    .all();

Notes

This behavior suggests a protocol parsing or result handling bug in the driver when dealing with full result sets from stored procedures.

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