[Bug] DB migration fails to 24.2 (FK constraints on preauth_keys in nodes table) #935

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

Originally created by @epichub on GitHub (Feb 5, 2025).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

It seems upgrading from 23.* or 24 beta to 24.2 fails in migrating the sqlite database:

ERR Foreign key constraint violated parent=pre_auth_keys row_id=SOMEID table=nodes

This happened on two instances I am running, and to fix it I had to delete the offending rows in the nodes table and re-auth these nodes.

Expected Behavior

The migration should work? I know this is beta SW (and I love it!), however it is nice when upgrades dont break DB schemas.

Steps To Reproduce

  1. Use docker image version 23 or 24 beta
  2. Add users and preauth keys to these users
  3. Let them use the keys?
  4. Upgrade to 24.2 (maybe 24.1/24.0 too?)
  5. See the FK constraints in the log - headscale will not start.

Environment

- OS: Arch linux
- Headscale version: 23/24beta --upgrading to--> 24.2
- Tailscale version: 1.80.0

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Anything else?

No response

Originally created by @epichub on GitHub (Feb 5, 2025). ### Is this a support request? - [x] This is not a support request ### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior It seems upgrading from 23.* or 24 beta to 24.2 fails in migrating the sqlite database: ` ERR Foreign key constraint violated parent=pre_auth_keys row_id=SOMEID table=nodes` This happened on two instances I am running, and to fix it I had to delete the offending rows in the nodes table and re-auth these nodes. ### Expected Behavior The migration should work? I know this is beta SW (and I love it!), however it is nice when upgrades dont break DB schemas. ### Steps To Reproduce 1. Use docker image version 23 or 24 beta 2. Add users and preauth keys to these users 3. Let them use the keys? 4. Upgrade to 24.2 (maybe 24.1/24.0 too?) 5. See the FK constraints in the log - headscale will not start. ### Environment ```markdown - OS: Arch linux - Headscale version: 23/24beta --upgrading to--> 24.2 - Tailscale version: 1.80.0 ``` ### Runtime environment - [x] Headscale is behind a (reverse) proxy - [x] Headscale runs in a container ### Anything else? _No response_
adam added the bug label 2025-12-29 02:26:24 +01:00
adam closed this issue 2025-12-29 02:26:24 +01:00
Author
Owner

@nblock commented on GitHub (Feb 5, 2025):

Duplicate of #2373

@nblock commented on GitHub (Feb 5, 2025): Duplicate of #2373
Author
Owner

@kradalby commented on GitHub (Feb 6, 2025):

Please email me a copy of the db, and note which version it was on and which version you upgraded to.
Strip all info that is PII and similar as I would like to include them in test, which means checking them into git.

Email in profile.

@kradalby commented on GitHub (Feb 6, 2025): Please email me a copy of the db, and note which version it was on and which version you upgraded to. Strip all info that is PII and similar as I would like to include them in test, which means checking them into git. Email in profile.
Author
Owner

@epichub commented on GitHub (Feb 10, 2025):

I will try :)

@epichub commented on GitHub (Feb 10, 2025): I will try :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#935