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

Crash when address already bound #45

Closed
ringerc opened this issue Jun 12, 2024 · 1 comment · Fixed by #46
Closed

Crash when address already bound #45

ringerc opened this issue Jun 12, 2024 · 1 comment · Fixed by #46
Labels
bug Something isn't working

Comments

@ringerc
Copy link
Collaborator

ringerc commented Jun 12, 2024

Instead of a graceful exit the scraper panics with a segfault if the listening address is already bound

level=error timestamp=2024-06-12T01:21:25.773821082Z caller=utils.go:76 msg="http server failed: listen tcp :9630: bind: address already in use"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x88f2d5]

goroutine 1 [running]:
database/sql.(*DB).Close(0x0)
	/home/craig/apps/go-1.22/src/database/sql/sql.go:910 +0x35
github.com/Vonng/pg_exporter/exporter.(*Exporter).Close(0xc000228000)
	/home/craig/projects/EDB/pg_exporter/exporter/exporter.go:209 +0x188
github.com/Vonng/pg_exporter/exporter.Run()
	/home/craig/projects/EDB/pg_exporter/exporter/main.go:219 +0xd17
main.main()
	/home/craig/projects/EDB/pg_exporter/main.go:22 +0xf
@Vonng
Copy link
Owner

Vonng commented Jun 15, 2024

The usual exit log would be like:

$ pg_exporter --web.listen-address=:9630 --url='postgres://dbuser_monitor:DBUser.Monitor@:5432/postgres?sslmode=disable&host=/var/run/postgresql'
level=info timestamp=2024-06-15T05:55:26.864156054Z caller=utils.go:56 msg="retrieve target url postgres://dbuser_monitor:xxxxx@:5432/postgres?sslmode=disable&host=/var/run/postgresql from command line"
level=info timestamp=2024-06-15T05:55:26.86419695Z caller=utils.go:56 msg="fallback on default config path: /etc/pg_exporter.yml"
level=info timestamp=2024-06-15T05:55:26.881175487Z caller=utils.go:56 msg="server [postgres] version changed: from [0] to [160002]"
level=info timestamp=2024-06-15T05:55:26.882476185Z caller=utils.go:56 msg="pg_exporter for postgres://dbuser_monitor:xxxxx@:5432/postgres?sslmode=disable&host=/var/run/postgresql start, listen on http://:9630/metrics"
level=error timestamp=2024-06-15T05:55:26.882562236Z caller=utils.go:76 msg="http server failed: listen tcp :9630: bind: address already in use"
level=info timestamp=2024-06-15T05:55:26.882602071Z caller=utils.go:56 msg="pg exporter closed"

This error seems related to the database/sql driver Close connection part. Could you add some more context info about this error?

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
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants