docker-postgresql icon indicating copy to clipboard operation
docker-postgresql copied to clipboard

If dbserver too slow to start, post_start_action() fails

Open paoloantinori opened this issue 11 years ago • 7 comments

Hi, I want to report a problem that happens on my system but not on a constant base.

Sometimes the scripts are not creating correctly the user.

I have tracked down the reason of the problem to this script

wait_for_postgres_and_run_post_start_action() {
  # Wait for postgres to finish starting up first.
  while [[ ! -e /run/postgresql/9.3-main.pid ]] ; do
inotifywait -q -e create /run/postgresql/ >> /dev/null
  done

post_start_action
}

Apparently the presence of /run/postgresql/9.3-main.pid is not enough to identify Postgres as ready to accept connections.

I have random error and logs shows that post_start_action before all the startup log entries are displayed.

I have also notice that the logic in this fork https://github.com/waterlink/docker-postgresql/blob/master/scripts/first_run.sh helps to avoid the problem.

Could you consider to change the "wait" logic?

paoloantinori avatar Apr 04 '14 13:04 paoloantinori

Thank you very much for reporting this. I can't reproduce this on my environments, so please give this a try and let me know if it fixes it.

Painted-Fox avatar Apr 04 '14 14:04 Painted-Fox

@paoloantinori @Painted-Fox Thanks for referencing me. I think I should have created PR, but I though it was only my environment being weird.

waterlink avatar Apr 04 '14 15:04 waterlink

No problem, @waterlink. I try to give credit where it's due.

Painted-Fox avatar Apr 04 '14 15:04 Painted-Fox

Working well now for me!

Thank you!

paoloantinori avatar Apr 04 '14 16:04 paoloantinori

@paoloantinori Thank you for reporting and verifying!

Painted-Fox avatar Apr 04 '14 16:04 Painted-Fox

I took this fix out, so this issue might be back. I was getting into an infinite loop, so I'm going to need to find a more elegant way to fix this.

Painted-Fox avatar May 19 '14 17:05 Painted-Fox

@Painted-Fox recently I had similar problem with other rdbms and solved it by using linux watch utility

something like: watch -e "! $COMMAND_TO_CREATE_USER" <>/dev/null. This will try to execute command each 2 seconds and will exit once it is a success.

waterlink avatar Nov 01 '14 00:11 waterlink