0

I have an Ubuntu 16.04 LTS web server that mounts a Windows file server via Samba. The web server need to be able to occasionally perform tasks that interact with the files on that server. However, we recently had an outage with the Windows file server, which caused the web server to start behaving very poorly. I would hope that the mount going down would simply cause the commands that try to interact with that folder to fail immediately (allowing us to quickly catch and handle the exception), but instead, it appears that interactions with the mount happen very slowly instead.

Here is the entry in /etc/fstab for mounting the share:

//<Windows server hostname>/TPA /mnt/TPA cifs username=tasker,password=<redacted>,domain=<our domain>,sec=ntlm,iocharset=utf8,sec=ntlm 0 0

By "slowly", I mean that if I do ls /mnt, the command takes roughly 30 seconds to complete before giving me the following message:

user@server:/mnt$ ls
ls: cannot access 'TPA': Host is down

This slowness can be seen in the web app itself, too. If possible, I would like to be able to set up the web app to detect if the share is down and handle that gracefully, but I don't want it to take 30 seconds to do so with every request. Is there a way I can configure things so it can be handled more gracefully?

To make matters more complicated, the web app is actually inside a Docker container that has a volume added that points to /mnt, which may make things even worse, though I suppose if I solve the issues with the host, then the container should hopefully similarly fall into line.

Any advice would be greatly appreciated!

EDIT: I'll add that for the time being, we've unmounted the offending mount and commented out the line from fstab, and that seems to make it "happy", but ideally I would prefer a solution that isn't so manual.

Ben Torell
  • 805
  • 1
  • 6
  • 11

1 Answers1

1

Just some ideas...

I'm not sure how to test how /mnt will respond when you access it. But I have ideas on how to more accurately predict it.

You could use smbclient or nmap to attempt a connection to the server. Or have something run in the background with cron, etc... that looks fine a file under /mnt - that way it doesn't slow anything down when experiencing the timeout. If any of the tests fail, tell the web application.

test -d /mnt && echo true also fails when the file server is down... if that helps. But you need to wait for it to timeout.

smbclient //host/share -Uuser password will return almost instantly if the server is down so it won't slow anything down much. nmap too, but it's not really trying to log into the file server.

I hope some of this is helpful.

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36