Quota size check to not be exceeded

It hangs indefinetly too. If it matters the used disk space of the server is 60004KB and the hard limit is 60005KB. I started the backup when the used disk space was 60000KB. As we speak it is hanging with the message Waiting for upload to finish ….

@Kanellaman

There is a discrepancy between what we see that begs for an explanation.
If you connect to your sftp server using an ordinary client (plain sftp if your client is Linux for example) and you try to ‘put’ a file of some size (1 MB if you are at 4 KB of the limit), does the client hang or does it errors out ? Here is what I see (almost immediately):

Couldn’t write to remote file “/fichiers/myfile.txt”: Failure

It’s coherent with what I see in Duplicati (after all it’s the same server)

Err, you are using a recent Duplicati version ?

I am using the latest Duplicati version.
The problem has to lay on the remote server as I tested a simple C# program as you suggested that creates a file and it indeed hangs.
As I mentioned before the server uses quota package to determine the available disk space for each user and I am wondering if that is the reason it sends back a bad error message(If it even sends back an error message)

probably not since your C# client hangs - if you are using Windows, how about downloading psftp (the software coming with putty) to test it ?

I used psftp as you suggested and indeed I get the error
error while writing: failure

I’d worry about filling a filesystem the OS was relying on, but maybe you used tmpfs or a loop mount?

OpenSSH Specifications at least says what they support – draft-ietf-secsh-filexfer-02 – an earlier one.

SSH File Transfer Protocol
draft-ietf-secsh-filexfer-05.txt

Add SSH_FX_NO_SPACE_ON_FILESYSTEM, SSH_FX_QUOTA_EXCEEDED, and
SSH_FX_UNKNOWN_PRINCIPLE error codes.

I suppose you can see if the OpenSSH Manual Pages logging offerings can get you that information.

-v
Raise logging level. This option is also passed to ssh.

in sftp might be the easiest to try out, but sftp-server seems to provide an extensive set of log options.

psftp might accept -v: increase verbosity, but I didn’t immediately find the exact documentation.

Short error messages so far seem to match the error code well, but any hang chase might need more.

I setup data servers (ftp, sftp) on separate partitions.

A bit sad - to be fair, portability may be a problem.

It may come from the quota thing. I have never tried that. I use a much simpler way of limiting data on my sftp/ftp servers: a separate partition. But of course I don’t worry about several users.

Well using man sftp-server I saw this T. Ylonen and S. Lehtinen, SSH File Transfer Protocol, draft-ietf-secsh-filexfer-02.txt, October 2001, work in progress material.
So I guess the missing error codes are what is wrong with my server. I will try a newer version that has draft-ietf-secsh-filexfer-05.txt and see if it fixes things.

I don’t think such a thing exists. I downloaded git openssh and checked that.

??? I’m quoting today’s OpenSSH documentation. Maybe you mean you’ll try another brand of server? There are plenty of FTP server options, but I don’t know follow SSH/SFTP servers nearly so closely…

It depends on the goal. If you want a more accurate error, that’s one thing. Hang avoidance is another.

I’m not sure the developer you’re working with was able to get a hang repro, and I don’t know why, but possibly you could use the logging options I mentioned to try to understand what the program is doing.

Oh didnt realize it.

I ll check it thanks.

@Kanellaman

All right, I can repro it with Proftpd with quotas on. On Mono or on Windows, do not matter.
It may be a SSH.NET problem :frowning:

I’ll let @ts678 provide links to the SSH.NET issues :slight_smile: but you can find them yourself. The code is here and it begs for some investigation for sure. It’s supposed to throw exceptions when bad things happen and it don’t seem to do that.

A workaround is to set ssh-operation-timeout - I set it to 5 minutes and it allows at least to terminate the job (ungracefully of course).

It’s the top link on Google for ssh.net issues. Then you look around for things like quota and space.

SftpClient.UploadFile hangs indefinitely when server has run out of space #343 is referenced from:

UploadFile is used at

Is there something we could put in their open issue (maybe a repro) to see if it will lead to faster fix?

I’m not sure if I saw that in this topic, but a simple repro might assist the SSH.NET issue.

Yes that would be a good thing but using SSH.NET. I (vaguely) intend to do that. Truth to be said, I expect to have to debug the thing myself.

I didn’t know it didn’t. I now wonder what the code did.

If making a simple SSH.NET C# repro isn’t desired, Duplicati.CommandLine.BackendTool.exe might do.

I am kinda lost here guys :joy:
So it is a problem of SSH.NET afterall? How so? The error code returned (4) isn’t handled well? Or it is something else?

Would that impact slow connectivity issues? If a file takes more than 5 minutes duo to slow internet will the connection be dropped?
I will keep this solution in mind though.

EDIT
The “ungracefully” part will be solved only if duplicati handles it well right(which relies on ssh.net library not handling it well)?

I would guess the “have to debug the thing myself” refers to SSH.NET, but it’s still way early in that.

There are 2 distinct problems.

  • when the problem is caused by a full partition, SSH.NET (hence Duplicati) is handling the failure reasonably well, except that the error code is wrong, and ssh (the server) is at fault
  • when the problem is caused by a quota, I have found a hang, like you said. It is more likely that SSH.NET is at fault, but as I don’t know why this hang occurs, I can’t be sure.

The maximum file size with Duplicati is around 50 MB. If you have fiber (about 8 Mbits/s upload at least, usually more), such a file should transmit in about 1 minute so a 5 minutes delay is more than enough. If you have ADSL (about 1 Mbits/s) the timeout should be set to 10 minutes at least.

it looks like it. As I said, I don’t know what is causing the hang with quota. If the software handling the quota don’t fail when the quota is exceeded but just, well, keep the current write operation waiting
, it seems difficult to handle correctly. I have no idea how this is working.

@ts678
I expect that a bug report will not be taken with much urgency if not linked to an analysis of where the problem occurs. Usually bug reports that boils down to ‘it does not work !’ are finishing their life in oblivion.

1 Like