[
https://issues.apache.org/jira/browse/NIFI-16676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xinyu Wang updated NIFI-16676:
------------------------------
Component/s: Core Framework
> Clustered requests hang until timeout (503) after clients abort large
> replicated GET requests: HTTP/2 replication connection stops making progress
> and does not recover while traffic continues
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: NIFI-16676
> URL: https://issues.apache.org/jira/browse/NIFI-16676
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 2.13.0
> Reporter: Xinyu Wang
> Priority: Major
>
> In a clustered NiFi (HTTP/2 replication, the default), aborting a client
> connection in the middle of a large replicated GET response can leave the
> node-to-node HTTP/2 connection in a state where later replicated requests,
> even tiny ones such as {{GET /nifi-api/flow/current-user}}, hang until a
> timeout and return 503 (Jetty request timeout, 60 s by default). The
> condition persists as long as requests keep arriving, and clears only after
> the cluster has been idle for roughly 1-2 minutes or after a restart.
> This was reproduced on unmodified {{apache/nifi:2.13.0}} with a 2-node
> cluster, with no OOM, no GC pressure and an otherwise idle JVM.
> Related, but not the same as, NIFI-16020 (request body not fully read in the
> two-phase commit path) and NIFI-16011 (adds
> {{nifi.cluster.node.protocol.http.version}}). The symptom is similar to
> NIFI-14977 ({{too many concurrent streams}}).
> h3. Environment
> * {{apache/nifi:2.13.0}} official image, JDK 21.0.13.1, 2-node secure cluster
> + ZooKeeper, all properties at defaults except
> {{nifi.cluster.node.read.timeout=90 sec}} and JVM heap 4 GB
> * Replication protocol: HTTP/2 (default)
> * Observed originally on a 2.5.0-based 2-node cluster in a shared development
> environment, where it lasted hours because browsers keep polling
> h3. Steps to reproduce
> # Create a parameter context with a large number of parameters (50,000
> parameters; the GET response is about 27 MB raw / 5 MB gzip). Any endpoint
> returning a multi-MB body that is replicated works in principle.
> # Run 12 concurrent clients in a loop for 10 minutes against node 1: {{GET
> /nifi-api/parameter-contexts/\{id\}}} with {{Accept-Encoding: gzip}}, and
> abort the client connection after a random 0.2-1.5 s (for example {{curl -m
> <t>}}), so the response is only partially read.
> # In parallel, probe every 10 s: {{GET /nifi-api/flow/current-user}} against
> node 1.
> # Stop the load and keep probing.
> h3. Expected
> After the load stops, {{flow/current-user}} returns 200 in milliseconds.
> Aborted client requests should not affect later requests.
> h3. Actual
> * During the load, probes fail intermittently (503 after 60 s, plus fast 409s
> once the replicator reaches its 100 outstanding requests limit; the 409s are
> a separate, expected effect).
> * After the load stops, probes continue to return 503 after 60 s. In 3 of 3
> runs on 2.13.0 the cluster did not recover within the 15 minute observation
> window (the last check was still failing).
> ||Run||Probes during load failing||First failure||Recovered within 15 min
> after load||
> |1|67/71|116 s|no|
> |2|31/35|76 s|no|
> |3|46/49|13 s|no|
> A single-node cluster (replication to itself over loopback) shows the same
> behavior, but less deterministically (2 of 5 runs recovered).
> h3. Analysis
> Code read at tag {{rel/nifi-2.13.0}} ({{nifi-framework-cluster}}). The JDK
> {{HttpClient}} only sends HTTP/2 {{WINDOW_UPDATE}} after the application
> reads the buffered body, so a replicated response that is neither read to the
> end nor closed keeps its stream open (counting against the server's
> {{MAX_CONCURRENT_STREAMS}}) and keeps consuming connection-level flow-control
> window. The replication connection to a node is one long-lived HTTP/2
> connection, so once its window is exhausted even a response of a few hundred
> bytes cannot be written (node 2 blocks in {{HttpOutput.channelWrite}}), and
> the requesting replicate thread waits forever for a first byte. While
> requests keep using that connection it stays bad.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)