Skip to content

Cancel signal does not interrupt cursored query fetching #536

@frdeboffles

Description

@frdeboffles

When going through the simple query protocol the Flux operator discardOnCancel (https://github.com/pgjdbc/r2dbc-postgresql/blob/main/src/main/java/io/r2dbc/postgresql/PostgresqlStatement.java#L248) does not seem to be propagated to the ReactorNettyClient.Conversation sink.

When a query is canceled, the Operators#discardOnCancel operator is supposed to discard the cancel event and send a very large Subscription#request to the subscriptions (see https://github.com/pgjdbc/r2dbc-postgresql/blob/main/src/main/java/io/r2dbc/postgresql/util/FluxDiscardOnCancel.java#L125). But the FluxSink#onRequest is never called (see https://github.com/pgjdbc/r2dbc-postgresql/blob/main/src/main/java/io/r2dbc/postgresql/client/ReactorNettyClient.java#L710) when FluxDiscardOnCancel.FluxDiscardOnCancelSubscriber#cancel is called. This leads to a dead ReactorNettyClient.Conversation since it is not canceled and its demand is exhausted.

Since this ReactorNettyClient.Conversation is able to handle the cancel state, I removed the Flux operator discardOnCancel from the PostgresqlStatement. Then everything worked as the ReactorNettyClient.Conversation was able to go through until the end even if the sink was canceled.

Do we still need this discardOnCancel operator here? If so, why is the large request not propagated to the ReactorNettyClient.Conversation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions