5

I have installed Microsoft SQL-Server on my ubuntu machine. Now it works fine, but every time I shutdown the machine, shutdown halts at

A stop job is running for microsoft sql server database engine ( x/30min )

Now if you wait 30 minutes, then it shuts off, so technically, it's not a bug. However, when I have to shut off the laptop I don't have time to wait 30 minutes ... Also, I sometimes have to restart the machine, and don't want to have to wait 30 minutes to restart it...

Is there any way to block or disable this stop-job? Where are stop-jobs configured?

WitchCraft
  • 1,792
  • 6
  • 28
  • 38
  • Are you sure this is not a timezone problem? I seem to remember seeing this for mysql once. -- *yay* for my memory: https://askubuntu.com/questions/892026/shutdown-hangs-on-a-stop-job-is-running-to-for-mysql-community-server :) – Rinzwind Mar 15 '19 at 08:41
  • @Rinzwind: So you're suggesting this is a service-boot-order-problem ? sudo dpkg-reconfigure tzdata – WitchCraft Mar 15 '19 at 09:29

1 Answers1

6

Tried sudo dpkg-reconfigure tzdata, but that didn't help.
What helps is the following:

Open /lib/systemd/system/mssql-server.service with a text-editor
and change TimeoutSec=30min to TimeoutSec=5sec

Then run

systemctl daemon-reload

to reload the configuration.

That's it, the timeout is now 5 seconds instead of 30 minutes.

For risks and side effects, read the package leaflet and ask your doctor or pharmacist - and keep a backup handy at all times.
You should do that anyway.

For more information: RTFM / man page

Note:
As per PerlDuck's tipp, instead of directly editing /lib/systemd/system/mssql-server.service, you should sudo systemctl edit mssql-server.service to create a drop-in that does not get overwritten when mssql is updated.

The file /etc/systemd/system/mssql-server.service.d/override.conf should only contain the values it overrides, e.g.

[Service]
TimeoutSec=5sec
WitchCraft
  • 1,792
  • 6
  • 28
  • 38
  • 2
    I would suggest you use 5 minutes instead of 5 seconds becuase MSSQL Server will get straight killed after 5 seconds and that could cause some nasty evil with MSSQL in the long run. – Thomas Ward Mar 19 '19 at 17:28
  • @Thomas Ward: That already happened once before - master database file gone. apt-get remove --purge and reinstall with restore db from backup helped. Seriously, MS should apply the google rule: if it takes longer than 4 seconds, it's a bug. No rule without exception. – WitchCraft Mar 19 '19 at 17:33
  • Yes, but if MSSQL doesn't want to stop in the first place, then this won't matter. – GNULinuxOnboard Mar 19 '19 at 17:33
  • @The MATE Man: Yep, agree. It will be killed either way. – WitchCraft Mar 19 '19 at 17:34
  • 1
    Honestly, I just try stay away from Microsoft software because I've had little, annoying problems like this in the past with Microsoft software running on Linux. – GNULinuxOnboard Mar 19 '19 at 17:35
  • @The MATE Man: I've actually switched to Linux entirely, privately. But at work, we're using MS. I work an hour or two per day on the private laptop while on train - counts as work-time. But I need ms-sql for that, unfortunately. For private things, I use pg anyway, so much nicer with array parameters and gis. ;) I presume their database running on a linux-laptop is what ms considers an edge-case anyway. – WitchCraft Mar 19 '19 at 17:43
  • 1
    Instead of directly editing `/lib/systemd/system/mssql-server.service` you should `sudo systemctl edit mssql-server.service` to create a drop-in that does not get overwritten when mssql is updated. – PerlDuck Mar 19 '19 at 18:19