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

keeper: improve db start logic #401

Merged
merged 1 commit into from
Jan 10, 2018

Conversation

sgotti
Copy link
Member

@sgotti sgotti commented Jan 9, 2018

Unfortunately pg_ctl start changed behavior in postgresql 10:

pg_ctl for postgres < 10 with -w will returns 0 also if the instance isn't ready
to accept connections.

While in postgres >= 10 it will return a non 0 exit code (1 like when the
instance fails to start) making it impossible to distinguish between problems
starting an instance (i.e. wrong parameters) or an instance started but not
ready to accept connections.

To work with all the versions and since we want to distinguish between a failed
start and a started but not ready instance we are forced to not use pg_ctl and
write part of its logic here (I hate to do this).

Now PGManager.start method directly starts the instance using the "postgres"
executable and waits 1 minute to see if the process starts (checking its pid file)
or exits due to an error. It doesn't check if the instance is ready to accept
connections. When needed this is done inside the keeper calling WaitReady.

Unfortunately pg_ctl start changed behavior in postgresql 10:

pg_ctl for postgres < 10 with -w will returns 0 also if the instance isn't ready
to accept connections.

Whle in postgres >= 10 it will return a non 0 exit code (1 like when the
instance fails to start) making it impossible to distinguish between problems
starting an instance (i.e. wrong parameters) or an instance started but not
ready to accept connections.

To work with all the versions and since we want to distinguish between a failed
start and a started but not ready instance we are forced to not use pg_ctl and
write part of its logic here (I hate to do this).

Now PGManager.start method directly starts the instance using the "postgres"
executable and waits 1 minute to see if the process starts (checking its pid file)
or exits due to an error. It doesn't check if the instance is ready to accept
connections. When needed this is done inside the keeper calling WaitReady.
@sgotti sgotti merged commit da6ba1a into sorintlab:master Jan 10, 2018
sgotti added a commit that referenced this pull request Jan 10, 2018
@sgotti sgotti added this to the v0.8.0 milestone Jan 18, 2018
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

Successfully merging this pull request may close these issues.

None yet

1 participant