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

Postgresql not compatible with ON_ERROR_STOP option #1431

Open
autra opened this issue Sep 9, 2024 · 2 comments
Open

Postgresql not compatible with ON_ERROR_STOP option #1431

autra opened this issue Sep 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@autra
Copy link

autra commented Sep 9, 2024

Describe the bug
When \set ON_ERROR_STOP 'on' is present on user's own psqlrc or in the initialScript, if an error happens on the script, devenv seems to loose track of the original postgresql pid

To reproduce

Please use this gist: https://gist.github.com/autra/647f30ed267c99681f19522010b0bf30

The logs are like this:

ERROR:  column "foo" does not exist
LINE 1: select foo;
               ^
Time: 0,071 ms 

PostgreSQL database directory appears to contain a database; Skipping initialization
2024-09-09 12:11:14.552 GMT [915180] FATAL:  lock file "postmaster.pid" already exists
2024-09-09 12:11:14.552 GMT [915180] HINT:  Is another postmaster (PID 915161) running in data directory "/home/augustin/repos/devenv_test_cases/.devenv/state/postgres"? 



PostgreSQL database directory appears to contain a database; Skipping initialization

2024-09-09 12:11:15.604 GMT [915189] FATAL:  lock file "postmaster.pid" already exists
2024-09-09 12:11:15.604 GMT [915189] HINT:  Is another postmaster (PID 915161) running in data directory "/home/augustin/repos/devenv_test_cases/.devenv/state/postgres"?



PostgreSQL database directory appears to contain a database; Skipping initialization

2024-09-09 12:11:16.655 GMT [915196] FATAL:  lock file "postmaster.pid" already exists
2024-09-09 12:11:16.655 GMT [915196] HINT:  Is another postmaster (PID 915161) running in data directory "/home/augustin/repos/devenv_test_cases/.devenv/state/postgres"?

Then, the last 5 lines are looping constantly.

If I type f9, process-compose exits, but the original postgres process still runs in the background.

Version

devenv 1.0.5 (x86_64-linux)

@autra autra added the bug Something isn't working label Sep 9, 2024
@autra
Copy link
Author

autra commented Sep 9, 2024

ON_ERROR_STOP changes the behaviour of psql. By default, a scripting error still causes psql to complete successfully with error code 0. With ON_ERROR_STOP to "on", psql stops at the first error and returns 3.

It seems that this behaviour somehow makes devenv try to start another postgresql.

While this bug is about not loosing track of postgres's pid if psql fails for some reason, I'd also argue that ON_ERROR_STOP should actually be the default in the context of devenv.

@autra
Copy link
Author

autra commented Sep 9, 2024

Edited to add one precision

If I type f9, process-compose exits, but the original postgres process still runs in the background.

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
Development

No branches or pull requests

1 participant