-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stale (Machine) objects are written back to database #93
Labels
Comments
kradalby
added a commit
to kradalby/headscale
that referenced
this issue
Aug 21, 2021
We are currently holding Machine objects in memory for a long time, while waiting for stream/longpoll, this might make us end up with stale objects, that we just call save on, potentially overwriting stuff in the database. A typical scenario would be someone changing something from the CLI, e.g. enabling routes, which in turn is overwritten again by the stale object in the longpolling function. The code has been left with TODO's and a discussion is available in juanfont#93.
kradalby
added a commit
to kradalby/headscale
that referenced
this issue
Aug 21, 2021
We are currently holding Machine objects in memory for a long time, while waiting for stream/longpoll, this might make us end up with stale objects, that we just call save on, potentially overwriting stuff in the database. A typical scenario would be someone changing something from the CLI, e.g. enabling routes, which in turn is overwritten again by the stale object in the longpolling function. The code has been left with TODO's and a discussion is available in juanfont#93.
2 tasks
This issue is stale because it has been open for 180 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a series of calls to
h.db.Save
around the code which is typically done on long livingMachine
objects loaded/created when themap
endpoint (longpolling) is opened.headscale/poll.go
Lines 51 to 53 in 5b1b40c
By calling save on this object, sometimes with only a single change (e.g. last seen), a potentially stale object is written to the database.
This becomes apparent when you use the CLI to modify Machines, where the next update from the server will revert your change.
For example:
headscale
cli to enable an advertised route on client1Machine
object.We should probably get all the database calls out of the code, and into some helper functions so we can control the behaviour from a single place.
The text was updated successfully, but these errors were encountered: