Uploading from upload link fails, works for a logged in user from web interface

I’m trying to track down an issue with uploads failing when using an upload link. Uploads fail with a notice “Network error” in the Web UI.

Screenshot_2020-01-08_16-39-20

I have checked all relevant logs but have not found much of help. In nginx log the upstream seafile server returns a HTTP 500 - Internal server error.

After turning on debug logging in nginx and comparing with a successful upload it looks like everything is working as it should, up to the HTTP 500 reply.

While uploading, the file appears on the server in seafile-data/httptemp/cluster-shared/ but once transfer completes, it vanishes. The only trace it was ever there I see in seafile.log:

[01/08/2020 01:56:26 PM] upload-file.c(368): clamdscan process encounter error, error code: 2.
[01/08/2020 01:59:11 PM] repo-mgr.c(7374): Temp file /opt/seafile/seafile-data/httptemp/cluster-shared/IKARUS-TestVirus.apkL3RYD0 doesn't exist, remove reocrd from db.

I’ve chown -R seafile:seafile’d the whole seafile directory tree just in case but this did not fix it.

For comparison, I tested uploading as a logged in user which works as expected.

I’m all out of ideas. How to track this down?

And what is in the clam logs? Looks like clam removes the file, but error code 2 means “An error occured.” while 1 would be virus found. Do uploads also fail for non test viruses?

For logged in users most probably scanning is performed in the background while for upload shares I could happen before the file is added to Seafile at all.

Yes, uploading also fails for regular files. Only in the case of the test virus, I get the log entry in seafile.log. Curiously, there is nothing in the clam logs.

Does anyone have an idea on how to troubleshoot this? I really don’t fancy the outlook of rebuilding from scratch, but right now it looks like the most sensible option. This depresses me. If there’s an error, there must be a log, right?

I sympathize!
Without logs, troubleshooting is difficult! I have a feeling the problem lies with ClamAV, though.
What about removing ClamAV (the ClamAV integration) to rule out the problem there. You can also try to disable virus scan when uploading files. Just disable in seahub_settings.py:

# Check virus after upload files to shared upload links.Defaults to `False`.
# Since version 6.0
ENABLE_UPLOAD_LINK_VIRUS_CHECK = True

If this works, you know the clamd conf is not correct.

You were right, it was clam causing the issue! Seemed very unlikely to me, given that the problem occured no matter whether a virus or clean file was uploaded. Thanks for making me check!

I made sure to mirror the configuration from the clamd setup guide, although the only issue I found was with freshclam, not clamd itself. Even though, after fixing it and restarting the service, upload now works.

PS: still there is nothing meaningful in the logs, even though clam is (and was) being run with LogVerbose true. What gives?

1 Like

I need to revisit this. Originally it looked like the problem was fixed, but it isn’t - it just doesn’t happen all the time. I haven’t found out what triggers this (bug?), but restarting seafile-server.service magically fixes it.

After restarting seafile-server I can upload a seemingly arbitrary number of files or amount of bytes before it (the bug?) happens again.

I still can’t see anything suspicious in the logs and I’d appreciate any help trying to get to the bottom of this. For the time being, I have to set ENABLE_UPLOAD_LINK_VIRUS_CHECK = False because this happens rampantly now.

Where should I look? What debug settings can I enable to increase log verbosity? I’ve set

in /etc/clamav/clamd.conf:
LogClean true
LogVerbose true
LogSyslog false
Debug true

in /etc/clamav/freshclam.conf:
LogVerbose true
LogSyslog false
Debug true

But nothing appears in /var/log/clamav/clamav.log or /var/log/clamav/freshclam.log

All out of ideas. Hjalp?!

Noone with any ideas on this one? :frowning: