[Bug 4060] New: scp/sftp upload progress meter shows "stalled" for most of the transfer on slow links
bugzilla-daemon at mindrot.org
bugzilla-daemon at mindrot.org
Thu Nov 19 20:02:06 AEDT 2026
https://bugzilla.mindrot.org/show_bug.cgi?id=4060
Bug ID: 4060
Summary: scp/sftp upload progress meter shows "stalled" for
most of the transfer on slow links
Product: Portable OpenSSH
Version: 10.0p2
Hardware: amd64
OS: Linux
Status: NEW
Severity: minor
Priority: P5
Component: sftp
Assignee: unassigned-bugs at mindrot.org
Reporter: g57jpaf8j at mozmail.com
On a slow uplink, scp (in the default SFTP mode) shows "- stalled -" at
255KB for most of an upload, while the data is actually flowing. Near
the
end the meter jumps from a few percent to 100% at an unrealistic rate.
Example: a 20MB file over a link of about 300KB/s, client OpenSSH
10.0p2
(Debian 13), server OpenSSH 9.6p1 (Ubuntu 24.04):
file.bin 1% 255KB 150.6KB/s - stalled -
file.bin 1% 255KB 22.6KB/s - stalled -
file.bin 1% 255KB 8.8KB/s - stalled -
file.bin 4% 1020KB 80.3KB/s 04:03 ETA
file.bin 18% 3825KB 243.2KB/s 01:08 ETA
file.bin 94% 19MB 1.4MB/s 00:00 ETA
file.bin 100% 20MB 361.7KB/s 00:56
During the same transfer I logged the TCP socket with "ss -ti" once per
second. bytes_acked grew steadily from the start (about 180KB in the
first
second, 3.5MB after 13 seconds), so the transfer was not stalled. I
first took this for a network problem and spent a lot of time on it.
----- Cause -----
The upload loop in sftp_upload() (sftp-client.c) increases
progress_counter
only when it reads an SSH2_FXP_STATUS reply. It reads a reply only when
id == startid, at EOF, or when id - ackid >= conn->num_requests. This
loop
is the same in current master.
With an OpenSSH server, the limits at openssh.com extension gives a write
length of SFTP_MAX_MSG_LENGTH - 1024 = 261120 bytes, and num_requests
is
64. The client debug output confirms this:
debug3: server upload/download buffer sizes 261120 / 261120; using
261120 / 261120
debug3: server handle limit 1019; using 64
So the client puts up to 64 * 255KB, about 16MB, in flight before it
reads the second reply. The replies arrive from the server, but they
wait
unread in the buffer, and the meter stays at the first 255KB block. At
EOF
the loop drains the remaining replies at once, which gives the jump at
the
end.
On a fast link 16MB takes about a second, so the effect is not visible.
On
a link of a few hundred KB/s it takes about a minute, and files smaller
than about 16MB show "stalled" for almost the whole transfer.
----- Possible fix -----
Read the STATUS replies that are already available without blocking,
for
example by polling the input fd before sending the next write, and keep
the
current blocking read only when num_requests are outstanding. Then
progress_counter follows the replies as they arrive, and the window of
requests in flight stays the same.
Counting bytes when they are sent would bring back bug 2108, where the
meter ran ahead of the transfer. The fix for 2108 made the counter
follow
the acks, which is right, but with the larger writes from the limits
extension the acks are now read too late.
----- Workaround -----
"scp -X nrequests=4" makes the meter follow the transfer closely.
--
You are receiving this mail because:
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list