[
https://issues.apache.org/jira/browse/CAMEL-27477?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27477 started by shashank.
----------------------------------------
> camel-ftp - the producer health check waits for the whole upload in progress,
> so readiness times out during a long but healthy upload
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27477
> URL: https://issues.apache.org/jira/browse/CAMEL-27477
> Project: Camel
> Issue Type: Bug
> Components: camel-ftp
> Reporter: shashank
> Assignee: shashank
> Priority: Major
>
> h3. What happens
> Producer health checks are off by default; they are turned on with
> {{camel.health.producersEnabled=true}}.
> The health check of an ftp, ftps or sftp producer
> ({{RemoteFileProducerHealthCheck}}) calls {{doPreWriteCheck(exchange,
> true)}}, which sends a {{NOOP}} through {{RemoteFileOperations.sendNoop()}}.
> Since CAMEL-27214 each operation of {{FtpOperations}} holds one lock, as
> {{SftpOperations}} and {{MinaSftpOperations}} already did, and the upload
> holds it for the whole transfer. So the check waits until the upload ends.
> {{AbstractHealthCheck.call}} holds the lock of the check while it runs, with
> no deadline, so every further readiness call waits behind it, and its thread
> stays blocked after the caller gave up (a Kubernetes readiness probe gives up
> after 1 s by default). During each long upload to a healthy server the
> application is reported not ready, and the probe threads pile up until the
> upload ends. On a server that stops taking data during the upload, the wait
> lasts as long as the upload hangs, which {{soTimeout}} does not bound for a
> blocked write.
> h3. How to reproduce
> With the embedded FTP server of the camel-ftp tests and producer health
> checks enabled: upload a small file (readiness UP), then upload a body that
> stops half way (a big file or a slow network). Three readiness calls made
> during the upload do not answer within 5 s; they answer UP right after the
> upload ends.
> Found with a TLA+ model of the producer, the operations lock and the health
> probes.
> h3. Fix
> A new default method {{RemoteFileOperations.runIfIdle(check)}}, implemented
> by {{FtpOperations}}, {{SftpOperations}} and {{MinaSftpOperations}} with
> {{tryLock()}}: the health check runs its check only when no other thread uses
> the connection, and holds the lock while it runs. When the connection is in
> use, the check sends no {{NOOP}} and does not connect: it reports the state
> that its last check of the connection found ({{UP}} before the first one),
> with the detail {{busy=true}}. As for the check of a polling consumer, a long
> transfer alone is not a failure. An upload that hangs is reported the same
> way until it fails (the socket timeouts bound reads, not a blocked write);
> CAMEL-26998 gave polling consumers an opt-in bound for that
> ({{healthCheckMaxPollDuration}}), which the producer does not get here.
> Not changed: on an idle connection to a server that does not answer, the
> {{NOOP}} still waits up to {{soTimeout}}. The checks of two producers to the
> same host share one id, which is another ticket. A probe that reconnects can
> leave the {{loggedIn}} flag of the producer set while the route closes that
> connection (low, needs {{sendNoop=false}}), and a probe can reconnect over a
> connection that the route just opened or after the producer stopped (narrow
> windows): these are left as they are.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)