-
Notifications
You must be signed in to change notification settings - Fork 16.8k
[stable/postgresql] Database defined by postgresqlDatabase is not always created #14533
Comments
Hi @POD666 I was unable to reproduce your issue using the values.yaml below: image:
tag: "9.6"
debug: true
persistence:
enabled : false
postgresqlUsername: "mydb"
postgresqlPassword: "mydb"
postgresqlDatabase: "mydb"
initdbScripts:
init_anotherdb.sh: |
#!/bin/sh
set -e
echo "Create DATABASE anotherdb with OWNER anotherdb:"
psql -v ON_ERROR_STOP=1 --username "postgres" --dbname "template1" <<-EOSQL
CREATE USER anotherdb WITH PASSWORD 'anotherdb';
CREATE DATABASE anotherdb;
GRANT ALL PRIVILEGES ON DATABASE anotherdb TO anotherdb;
EOSQL
echo "Done." Commands used:
As you can see the script is being executed and the databases |
It's flaky, try this few times until it fails:
Here is what I get, the first attempt is successful and the second one failed:
Right before creating this issue, It was reproduced with 9th attempt. |
Hi @POD666 What did you obtain in the logs when it failed? Could you please share it.
|
For the record, I tried 20 times with the chart postgresql-5.3.4 and it worked 20/20. |
the chart postgresql-4.0.0
Looks like problem is here:
I will try to reproduce it on the latest master but It already was reproduced for 5.3.0. |
I have also failed to reproduce it on the latest master with a number of attempts but you should be able to reproduce it at |
I have walked through changes since 5.3.0 and see nothing suspicious, except this. |
Well, yes, reproduced at So looks like I can just upgrade to 5.3.7 to solve my issue. |
I have no idea how Just for notice
|
I am afraid I am unable to reproduce it on postgresql-4.0.0 nor postgresql-5.3.0. I am using this command to deploy the chart 10 times:
The values.yaml file is: persistence:
enabled : false
postgresqlUsername: "mydb"
postgresqlPassword: "mydb"
postgresqlDatabase: "mydb"
initdbScripts:
init_anotherdb.sh: |
#!/bin/sh
set -e
echo "Create DATABASE anotherdb with OWNER anotherdb:"
psql -v ON_ERROR_STOP=1 --username "postgres" --dbname "template1" <<-EOSQL
CREATE USER anotherdb WITH PASSWORD 'anotherdb';
CREATE DATABASE anotherdb;
GRANT ALL PRIVILEGES ON DATABASE anotherdb TO anotherdb;
EOSQL
echo "Done." Then in order to check the dbs were creates:
Being ID the chart index. My helm versions here:
Could you exec into one of those pods and execute this command to get the exact postgresql image used?
|
Upgraded to
The issue persist for
What else can be different and be a reason why it's so hard to reproduce the issue?
|
I was wrong, the issue persists for 5.3.7. |
I can reproduce the issue even with very simple values.yaml
here is my full testing script:
And here is output (sploiler: 5,6,7,10 failed): Click to expand
So looks like the issue is not related to PostgreSQL version or to chart version or to What else can it be? |
I assumed that there might be a delay before env variables are set, so I added the following command here:
1 of 10 delpoyments failed with the following output:
So looks like postgresql might ignore POSTGRES_DB for some reason. |
After looking at this, decided to also check
Output:
|
I'm not longer able to reproduce the issue (10/10 + 50/50) after changing command to:
Output:
|
Should I move the issue to |
Yes please @POD666! Thanks a lot for digging into that. However, I am still surprised that I couldn't reproduce the issue. |
The issue moved to |
Some of my deployments (1 of 10) fails because the database defined by
postgresqlDatabase
was not created.The issue was reproduced for PostgreSQL chart version
4.0.0
and5.3.0
.I have the following values in
values.yml
:Log:
Env variables seem to be set as expected:
YAML:
Is there anything else I can add?
The text was updated successfully, but these errors were encountered: