Skip to content
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

LastInsertId is not supported by Postgres #1755

Closed
2 tasks done
MichaelSasser opened this issue Feb 15, 2024 · 1 comment · Fixed by #1756 or #1762
Closed
2 tasks done

LastInsertId is not supported by Postgres #1755

MichaelSasser opened this issue Feb 15, 2024 · 1 comment · Fixed by #1756 or #1762
Labels
bug Something isn't working
Milestone

Comments

@MichaelSasser
Copy link

MichaelSasser commented Feb 15, 2024

Bug description

Hi, I've tried to update to the v0.23 release and I received the following error:

{"level":"fatal","error":"LastInsertId is not supported by this driver","time":1708000343,"message":"Migration failed: LastInsertId is not supported by this driver"}

Just to make sure, I've updated Postgres to the latest 16.x version, but I'm still receiving this error message.

I'm not certain what LastInsertId should do, I'm guessing it should return the latest used sequential number on INSERT? Since it doesn't seem supported by Postgres, I would maybe suggest looking into RETURNING (see PostgreSQL - INSERT) if there is no simpler workaround.

The optional RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted [...]. This is primarily useful for obtaining values that were supplied by defaults, such as a serial sequence number.

Environment

  • Version of headscale used: headscale/headscale:0.23.0; Postgres 15.x and 16.x
  • Headscale is behind a (reverse) proxy (envoyproxy/envoy:v1.29.1)
  • Headscale runs in a container

To Reproduce

  1. Have an existing (working) installation using PostgreSQL
  2. Update the config to accommodate for the breaking changes (db_* -> database.postgres.*) and set the database to postgres again.
  3. Update the command in docker from ´headscale servetoserve`
  4. Deploy the new version
  5. See error messages in logs

Logs and attachments

(Headscale doesn't start)

Host Headscale

  • Linux acme 5.10.0-27-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64 GNU/Linux
  • Docker version 25.0.1, build 29cf629
ID    NAME    CORES   CPU TYPE    ARCHITECTURE   MEMORY     DISK     STORAGE TYPE   TRAFFIC
1     cx11    1       shared      x86            2.0 GB     20 GB    local          20 TB

Host Postgres

  • Linux pg01 6.1.0-17-arm64 #1 SMP Debian 6.1.69-1 (2023-12-30) aarch64 GNU/Linux
  • Docker version 25.0.1, build 29cf629
ID    NAME    CORES   CPU TYPE    ARCHITECTURE   MEMORY     DISK     STORAGE TYPE   TRAFFIC
93    cax21   4       shared      arm            8.0 GB     80 GB    local          20 TB
@MichaelSasser MichaelSasser added the bug Something isn't working label Feb 15, 2024
@kradalby
Copy link
Collaborator

This seem to be a regression in Gorm: go-gorm/gorm#6812

Also tracking issue in the migration framework: go-gormigrate/gormigrate#217

I'm rolling back the versions for now in a PR.

kradalby added a commit to kradalby/headscale that referenced this issue Feb 15, 2024
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
@kradalby kradalby added this to the v0.23.0 milestone Feb 15, 2024
kradalby added a commit to kradalby/headscale that referenced this issue Feb 16, 2024
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
kradalby added a commit that referenced this issue Feb 17, 2024
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants