Skip to content

keeper: improve db start logic#401

Merged
sgotti merged 1 commit into
sorintlab:masterfrom
sgotti:update_pg_start_wait_logic
Jan 10, 2018
Merged

keeper: improve db start logic#401
sgotti merged 1 commit into
sorintlab:masterfrom
sgotti:update_pg_start_wait_logic

Conversation

@sgotti

@sgotti sgotti commented Jan 9, 2018

Copy link
Copy Markdown
Member

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 force-pushed the update_pg_start_wait_logic branch from e2a3527 to da6ba1a Compare January 9, 2018 18:32
@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.

1 participant