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

Fail to migrate sql with 1.5.0-beta.5 with postgres ident #1892

Closed
dalcde opened this issue Jun 5, 2020 · 10 comments
Closed

Fail to migrate sql with 1.5.0-beta.5 with postgres ident #1892

dalcde opened this issue Jun 5, 2020 · 10 comments
Labels
upstream Issue is caused by an upstream dependency.

Comments

@dalcde
Copy link
Contributor

dalcde commented Jun 5, 2020

Describe the bug

hydra migrate sql postgres:///hydra on a clean installation fails with 1.5.0-beta.5

Reproducing the bug

Steps to reproduce the behavior:

  1. Start with a clean VM
  2. Install and setup postgres with a hydra user
  3. Install hydra binary
  4. Run sudo -u hydra hydra migrate sql postgres:///hydra

Server logs

The following migration is planned:

Could not get the migration status:
pq: password authentication failed for user "hydra"
could not create new transaction
github.com/gobuffalo/pop/v5.newTX
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/tx.go:28
github.com/gobuffalo/pop/v5.(*dB).Transaction
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/db.go:18
github.com/gobuffalo/pop/v5.(*Connection).NewTransaction
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/connection.go:172
github.com/gobuffalo/pop/v5.(*Connection).Transaction.func1
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/connection.go:139
github.com/gobuffalo/pop/v5.commonDialect.Lock
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/dialect_common.go:30
github.com/gobuffalo/pop/v5.(*Connection).Transaction
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/connection.go:137
github.com/gobuffalo/pop/v5.CreateSchemaMigrations
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/migrator.go:197
github.com/gobuffalo/pop/v5.Migrator.CreateSchemaMigrations
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/migrator.go:214
github.com/gobuffalo/pop/v5.Migrator.Status
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/migrator.go:219
github.com/ory/hydra/persistence/sql.(*Persister).MigrationStatus
        /home/ory/persistence/sql/persister.go:40
github.com/ory/hydra/cmd/cli.(*MigrateHandler).MigrateSQL
        /home/ory/cmd/cli/handler_migrate.go:74
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:846
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:950
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/ory/hydra/cmd.Execute
        /home/ory/cmd/root.go:62
main.main
        /home/ory/main.go:33
runtime.main
        /usr/local/go/src/runtime/proc.go:203
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373
couldn't start a new transaction
github.com/gobuffalo/pop/v5.(*Connection).NewTransaction
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/connection.go:174
github.com/gobuffalo/pop/v5.(*Connection).Transaction.func1
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/connection.go:139
github.com/gobuffalo/pop/v5.commonDialect.Lock
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/dialect_common.go:30
github.com/gobuffalo/pop/v5.(*Connection).Transaction
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/connection.go:137
github.com/gobuffalo/pop/v5.CreateSchemaMigrations
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/migrator.go:197
github.com/gobuffalo/pop/v5.Migrator.CreateSchemaMigrations
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/migrator.go:214
github.com/gobuffalo/pop/v5.Migrator.Status
        /go/pkg/mod/github.com/gobuffalo/pop/[email protected]/migrator.go:219
github.com/ory/hydra/persistence/sql.(*Persister).MigrationStatus
        /home/ory/persistence/sql/persister.go:40
github.com/ory/hydra/cmd/cli.(*MigrateHandler).MigrateSQL
        /home/ory/cmd/cli/handler_migrate.go:74
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:846
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:950
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/ory/hydra/cmd.Execute
        /home/ory/cmd/root.go:62
main.main
        /home/ory/main.go:33
runtime.main
        /usr/local/go/src/runtime/proc.go:203
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373
github.com/ory/hydra/persistence/sql.(*Persister).MigrationStatus
        /home/ory/persistence/sql/persister.go:40
github.com/ory/hydra/cmd/cli.(*MigrateHandler).MigrateSQL
        /home/ory/cmd/cli/handler_migrate.go:74
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:846
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:950
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/ory/hydra/cmd.Execute
        /home/ory/cmd/root.go:62
main.main
        /home/ory/main.go:33
runtime.main
        /usr/local/go/src/runtime/proc.go:203
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373
github.com/ory/hydra/cmd/cli.(*MigrateHandler).MigrateSQL
        /home/ory/cmd/cli/handler_migrate.go:75
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:846
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:950
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/ory/hydra/cmd.Execute
        /home/ory/cmd/root.go:62
main.main
        /home/ory/main.go:33
runtime.main
        /usr/local/go/src/runtime/proc.go:203
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373

Expected behavior

Migration to be successful

Environment

  • Version: v1.5.0-beta.5
  • Environment: Ubuntu 20.04

Additional context

It works with v1.4.10.

@aeneasr
Copy link
Member

aeneasr commented Jun 5, 2020

This is an underlying driver issue (pgx supports this but pg doesn't afaik) so I don't think this will be fixed, especially because the workaround is pretty straight forward (not use the shorthand version).

@aeneasr aeneasr closed this as completed Jun 5, 2020
@dalcde
Copy link
Contributor Author

dalcde commented Jun 5, 2020 via email

@aeneasr
Copy link
Member

aeneasr commented Jun 5, 2020

postgres:///hydra just means that you're using the default user, no password, and the default host and port iirc? So that should equal postgres://postgres@localhost/hydra.

@dalcde
Copy link
Contributor Author

dalcde commented Jun 5, 2020 via email

@aeneasr
Copy link
Member

aeneasr commented Jun 5, 2020

PostgreSQL DSNs typically support unix socket connections (though you are correct, without the host should work since PostgreSQL 9.2): https://stackoverflow.com/questions/27037990/connecting-to-postgres-via-database-url-and-unix-socket-in-rails

Seems like you can set the socket path like this:

postgresql://%2Fvar%2Flib%2Fpostgresql/dbname

I have created an issue upstream to address this by switching from lib/pq to pgx: gobuffalo/pop#559

@aeneasr aeneasr reopened this Jun 5, 2020
@aeneasr aeneasr added the upstream Issue is caused by an upstream dependency. label Jun 5, 2020
@aeneasr
Copy link
Member

aeneasr commented Jun 16, 2020

Took a bit of time but I've been working with the gobuffalo team on bringing pgx to pop: gobuffalo/pop#562 :)

@dalcde
Copy link
Contributor Author

dalcde commented Jun 16, 2020 via email

@aeneasr
Copy link
Member

aeneasr commented Jun 16, 2020

Yes, I was able to confirm that it was an underlying driver issue. The PR still needs to be merged but given that maintainers already gave feedback it shouldn't be too long.

@dalcde
Copy link
Contributor Author

dalcde commented Jun 21, 2020

All that is left is to update go.mod to use pop v5.2.0.

@aeneasr
Copy link
Member

aeneasr commented Jun 22, 2020

We also need gobuffalo/fizz#94 this merged before

aeneasr added a commit that referenced this issue Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Issue is caused by an upstream dependency.
Projects
None yet
Development

No branches or pull requests

2 participants