[BUG] ManagedRequestPipeline.close() leaves in-flight request futures pending forever
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- backend, distributed-systems
Research direction
Start with base-rpc/base-rpc-client/src/main/java/org/apache/bifromq/baserpc/client/ManagedRequestPipeline.java and compare close() with onStreamError(), especially how preflightTaskQueue and inflightTaskQueue are cancelled. Verify that closing a pipeline completes both unsent and already-sent request futures, using the full client/server RPC stack or the in-process transport reproduction described in the issue.
Written by the indexing model from the issue text.
Description
Environment
- BiFroMQ
4.0.0/main @ eef5e3af - Module:
base-rpc/base-rpc-client - File:
base-rpc/base-rpc-client/src/main/java/org/apache/bifromq/baserpc/client/ManagedRequestPipeline.java(close())
Summary
close() cancels only preflightTaskQueue (requests not yet sent). It never touches inflightTaskQueue (sent, awaiting a response). After super.close() disposes the stream, responses can never arrive and onStreamError() — the only path that calls cancelInflightTasks() — will not fire again, so the futures of already-sent requests never complete. Callers on the direct (non-batched) query/execute path hang forever; the batched path is only saved by Batcher's orTimeout(maxBurstLatency) fallback.
Pipelines are replaced via old.close() on store→server route changes, so one range migration with a query in flight triggers this.
Suggested fix
Abort in-flight tasks on close, mirroring onStreamError:
if (isClosed.compareAndSet(false, true)) {
super.close();
meter.recordCount(RPCMetric.ReqPipelineCompleteCount);
cancelPreflightTasks(new RequestAbortException("Pipeline has closed"));
cancelInflightTasks(new RequestAbortException("Pipeline has closed"));
}
Verification note
A regression test requires a full RPC stack (client + server + stream disposal); we verified the path statically and in a rolling multi-node deployment (see below). A reproduction using the in-process transport can be provided if useful.
Production validation
A 6-node BifroMQ 4.0.0 cluster (standalone.sh, systemd, mTLS clientAuth=REQUIRE), fronted by a TCP load balancer with 6 backends. Live clients: 3 bridge replicas (MQTT5, $oshare subscribers) and 10 backend service instances (persistent sessions). RocksDB engine, default configuration otherwise.
The fix (plus other changes) was rolled across all six nodes one node at a time (wholesale lib/ replacement, then restart), with a per-node gate (service active, all four ports listening, cluster mesh re-established). Six of six nodes succeeded, zero rollbacks.
Post-deploy checks (all measured after the rollout):
| Check | Result |
|---|---|
| Cluster mesh (inter-node 8898/8899 connections, per node) | 408–417 established on every node |
| Live client connections (3 bridge replicas + 10 backend services over mTLS) | 13/13 reconnected and stable |
| Cross-node delivery end-to-end | publish on one node → bridge (connected elsewhere) consumed it → forwarded (counter 0 → 1) |
| Client-visible protocol smoke | connect / subscribe / publish with QoS 1 all CONNACK 0 / PUBACK 0 |
No non-batched caller hangs were observed in the rollout window; the fix removes the latent path.
- Dominant language
- Java
- Stars
- 805
- Forks
- 99
- Avg merge
- 16h 32m
- Merged PRs (30d)
- 2
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/bifromq
-
[BUG] KVRangeRestorer leaves the restore future uncompleted when startRestore() throws, permanently wedging the rangePossibly taken @ImDanXie claimed this 32 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
[BUG] TopicUtil.isValidTopicFilter accepts "$share/g/" — a shared subscription with an empty filter that can never matchPossibly taken @efegokdemir claimed this 34 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[BUG] UTF8Util.isWellFormed inverts the surrogate-pair check: valid non-BMP characters are rejected, lone surrogates acceptedPossibly taken @efegokdemir claimed this 34 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Inbound and outbound packet-size checks differ, so a QoS 1 message just under MaxUserPayloadBytes is accepted but never delivered (blocks a persistent subscriber)May be free again @abhiramaab claimed this 26 days ago, and no pull request is open. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Similar issues
-
bug web-server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jooby-project/jooby#4035 ·
Maintainers usually reply within 1 day
-
L: javascript
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dependabot/dependabot-core#16744 ·
Maintainers usually reply within 1 day
-
intake mcp-intake needs-human-review priority:high type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Ikalus1988/MisakaNet#3987 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
quarkiverse/quarkus-google-cloud-services#1187 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
locationtech/jts#1250 ·