Skip to content

[BUG] p2c inflight counter leaks on downstream cancellation (no doOnCancel/doFinally) #6733

Description

@Aias00
  • severity: Medium
  • files: shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/DividePlugin.java:133-135
  • description: For loadBalance=p2c, responseTrigger (which calls upstream.getInflight().decrementAndGet()) is wired only via .doOnSuccess(...).doOnError(...). There is no .doOnCancel(...)/.doFinally(...). When the downstream subscriber cancels before terminal signal (client disconnect, timeout cancellation), neither onSuccess nor onError fires, so the decrement never runs. inflight ratchets upward forever.
  • impact: Persistent inflight inflation on client disconnects; affected upstream is increasingly starved by p2c.
  • suggested_fix: Replace .doOnSuccess(...).doOnError(...) with .doFinally(sig -> ...) (or add .doOnCancel(...)).
  • confidence: Medium
  • related_existing: none — [BUG] DividePlugin.beginTime is a shared mutable instance field, racy under shortestResponse load balancing #6544/FUNC-D2 is the beginTime race, not the p2c inflight leak.

Identified during the 2026-08-02 deep re-scan; full list in docs/scan2-2026-08-02/06-medium-tiers.md.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions