Verify all database connections are closed when process is killed #633

Closed
opened 2025-12-29 02:21:24 +01:00 by adam · 6 comments
Owner

Originally created by @TotoTheDragon on GitHub (Feb 13, 2024).

Why

SQLite sometimes has trouble with locks. This often occurs when there was a connection being used while the process is killed.

Description

Verify that on all ways of exiting an application the database connections are closed properly and implement where lacking

Originally created by @TotoTheDragon on GitHub (Feb 13, 2024). <!-- We typically have a clear roadmap for what we want to improve and reserve the right to close feature requests that does not fit in the roadmap, or fit with the scope of the project, or we actually want to implement ourselves. Headscale is a multinational community across the globe. Our language is English. All bug reports needs to be in English. --> ## Why <!-- Include the reason, why you would need the feature. E.g. what problem does it solve? Or which workflow is currently frustrating and will be improved by this? --> SQLite sometimes has trouble with locks. This often occurs when there was a connection being used while the process is killed. ## Description <!-- A clear and precise description of what new or changed feature you want. --> Verify that on all ways of exiting an application the database connections are closed properly and implement where lacking
adam added the enhancement label 2025-12-29 02:21:24 +01:00
adam closed this issue 2025-12-29 02:21:24 +01:00
Author
Owner

@ohdearaugustin commented on GitHub (Feb 13, 2024):

This issue can be tested. Please add more information like which version on which system. Installed with docker or without. etc.

With which configuration can this issue be recreated.

@ohdearaugustin commented on GitHub (Feb 13, 2024): This issue can be tested. Please add more information like which version on which system. Installed with docker or without. etc. With which configuration can this issue be recreated.
Author
Owner

@RainrZufall commented on GitHub (Feb 14, 2024):

This issue can be tested. Please add more information like which version on which system. Installed with docker or without. etc.

With which configuration can this issue be recreated.

I have the same problem.
I use Ubuntu, Docker and the current stable release image.

It always occurs when, for example, I have to restart the server because of a kernel update or Docker is being updated.
I then have to manually restart the container again using “docker restart headscale” so that it works again.

@RainrZufall commented on GitHub (Feb 14, 2024): > This issue can be tested. Please add more information like which version on which system. Installed with docker or without. etc. > > With which configuration can this issue be recreated. I have the same problem. I use Ubuntu, Docker and the current stable release image. It always occurs when, for example, I have to restart the server because of a kernel update or Docker is being updated. I then have to manually restart the container again using “docker restart headscale” so that it works again.
Author
Owner

@kradalby commented on GitHub (Feb 15, 2024):

This is a fair concern, we should check the shutdown logic.

@kradalby commented on GitHub (Feb 15, 2024): This is a fair concern, we should check the shutdown logic.
Author
Owner

@kradalby commented on GitHub (Feb 15, 2024):

So I've looked into this a bit, and SIGKILL (signal 9) cannot be trapped in Go, I think that is the main "missing" signal that we could receive that isnt handled, but there is no way to also do it. I'm not sure if there are any other situation within the code as of now.

@kradalby commented on GitHub (Feb 15, 2024): So I've looked into this a bit, and SIGKILL (signal 9) cannot be trapped in Go, I think that is the main "missing" signal that we could receive that isnt handled, but there is no way to also do it. I'm not sure if there are any other situation within the code as of now.
Author
Owner

@TotoTheDragon commented on GitHub (Feb 20, 2024):

Seems like this issue only occurs when containers are killed and restart within the sqlite lock timeout. Cannot do anything to fix this, so I propose we close this @kradalby

@TotoTheDragon commented on GitHub (Feb 20, 2024): Seems like this issue only occurs when containers are killed and restart within the sqlite lock timeout. Cannot do anything to fix this, so I propose we close this @kradalby
Author
Owner

@kradalby commented on GitHub (Feb 20, 2024):

Ok, let's fix the lock instead

@kradalby commented on GitHub (Feb 20, 2024): Ok, let's fix the lock instead
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#633