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

Failed to connect using PostgreSQL URI #399

Open
melroy89 opened this issue Feb 12, 2024 · 2 comments
Open

Failed to connect using PostgreSQL URI #399

melroy89 opened this issue Feb 12, 2024 · 2 comments

Comments

@melroy89
Copy link

Unable to use PostgreSQL Connection URIs, errors on:

goroutine 1 [running]:
github.com/jmoiron/sqlx.MustExec(...)
	github.com/jmoiron/[email protected]/sqlx.go:722
github.com/jmoiron/sqlx.(*DB).MustExec(0xc000421988?, {0xdc5808?, 0xc000421988?}, {0x0?, 0xc000421901?, 0xc0004219d8?})
	github.com/jmoiron/[email protected]/sqlx.go:366 +0x46
github.com/matrix-org/sliding-sync/state.NewRoomsTable(...)
	github.com/matrix-org/sliding-sync/state/rooms_table.go:24
github.com/matrix-org/sliding-sync/state.NewStorageWithDB(0xc0005fc300, 0x8?)
	github.com/matrix-org/sliding-sync/state/storage.go:86 +0x38
github.com/matrix-org/sliding-sync.Setup({0xc00003e00e, 0x20}, {0xc00004200a, 0x76}, {0xc00004005e, 0x40}, {0x0, 0x0, 0x0, 0x3b9aca00, ...})
	github.com/matrix-org/sliding-sync/v3.go:117 +0x212
main.main()
	github.com/matrix-org/sliding-sync/cmd/syncv3/main.go:213 +0x175b
Sync v3 [0.99.15] (bbb886e)
Debug=false LogLevel= MaxConns=0
panic: parse "postgresql://synapse:secret@%2Fvar%2Flib%2Fpostgresql/syncv3": invalid URL escape "%2F"

While the PostgreSQL documentation clearly mentions this should be allowed:

The host part is interpreted as described for the parameter host. In particular, a Unix-domain socket connection is chosen if the host part is either empty or looks like an absolute path name, otherwise a TCP/IP connection is initiated. Note, however, that the slash is a reserved character in the hierarchical part of the URI. So, to specify a non-standard Unix-domain socket directory, either omit the host part of the URI and specify the host as a named parameter, or percent-encode the path in the host part of the URI:

postgresql:///dbname?host=/var/lib/postgresql
postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
@melroy89
Copy link
Author

melroy89 commented Feb 12, 2024

Ps. postgresql://synapse:secret@syncv3?host=/var/lib/postgresql is NOT working either. Since your code is not using the postgresql string URI string correctly. I still tries to use localhost with port:

panic: dial tcp: lookup syncv3 on 127.0.0.11:53: no such host

@spaetz
Copy link

spaetz commented Mar 26, 2024

Given this seems to be handled by https://github.com/lib/pq which describes itself as in maintenance mode and recommends the use of another package (https://github.com/jackc/pgx), I would not expect a speedy resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants