Bug 849074

Summary: Got "database does not exist" error when restoring a scalable application with postgresql embedded
Product: OKD Reporter: Jianwei Hou <jhou>
Component: ContainersAssignee: Rob Millner <rmillner>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: mfisher
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libra_ami #2039 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-17 21:29:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
snapshot output none

Description Jianwei Hou 2012-08-17 08:55:01 UTC
Created attachment 605128 [details]
snapshot output

Description of problem:
Try to snapshot a scalable app having postgresql embedded, there were messages showing " Could not dump PostgreSQL databases" 

Version-Release number of selected component (if applicable):
on devenv_2009, int
cli: rhc-0.97.11

How reproducible:
Always

Steps to Reproduce:
1.Create a scalable application and embed postgresql
  rhc app create -a ps1 -t php-5.3 -s
  rhc app cartridge add -a ps1 -c postgresql-8.4
2.ssh into app and create some data in postgresql database
3.take snapshot for the app
  rhc app snapshot save ./ps1.tar.gz -a ps1
  
Actual results:
in the output, there are messages like :
pg_dumpall: could not connect to database "template1": could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

  0.0%

WARNING!  Could not dump PostgreSQL databases!  Continuing anyway


Expected results:
Snapshot should be successful.

Additional info:
Delete some data from postgresql db, and restore from previous snapshot, data is   not back.
for full infomation, please see attachment.

Comment 1 Rob Millner 2012-08-17 23:44:46 UTC
Pull request: https://github.com/openshift/crankcase/pull/402

Fixed both backup and restore to properly get the UUID from the db gear.

Comment 2 Rob Millner 2012-08-18 17:17:19 UTC
Pull request merged.

Comment 3 Jianwei Hou 2012-08-20 06:28:34 UTC
Verified on devenv_2029

The snapshot problem is gone, but when trying to restore, there were still errors:

Steps to reproduce:
1.Create scabable app with postgresql embedded.
2.ssh into app, connect to postgresql and make some change.
3.Take snapshot for this app
4.ssh into app again and delete some data
5.Restore app from snapshot
6.ssh into app and check deleted data is back

Result:
in step 5, when trying to restore:
WARNING: This ssh terminal was started without a tty.
          It is highly recommended to login with: ssh -t
PostgreSQL server instance already running
ERROR:  role "fcc0d8a304df4e42a516bf2ce5dfdc34" does not exist
\connect: FATAL:  database "perl1s" does not exist

in step 6, try to connect to database:
[perl1s-jhou.dev.rhcloud.com ~]\> set -x
[perl1s-jhou.dev.rhcloud.com ~]\> psql
+ psql
+ PGDATABASE=perl1s
+ PGHOST=a70c81cc9b-jhou.dev.rhcloud.com
+ PGPORT=35696
+ PGUSER=admin
+ PGPASSWORD=Ceux16jwWtLa
+ /usr/bin/psql --set 'HISTFILE=~/app-root/data/.psql_history'
psql: FATAL:  database "perl1s" does not exist

Comment 4 Rob Millner 2012-08-20 19:57:25 UTC
Pull request:
https://github.com/openshift/crankcase/pull/410

Comment 5 Rob Millner 2012-08-21 01:29:40 UTC
Pull request merged.

Comment 6 Jianwei Hou 2012-08-21 09:54:12 UTC
Verified on devenv_2402

Steps:
1.Create scabable app with postgresql embedded.
2.ssh into app, connect to postgresql and make some change.
3.Take snapshot for this app
4.ssh into app again and delete some data
5.Restore app from snapshot
6.ssh into app and check deleted data is back

Result:
Restore was successful, ssh into app and connect to postgresql, the deleted data is back

Comment 7 Jianwei Hou 2012-08-21 09:55:23 UTC
(In reply to comment #6)
> Verified on devenv_2402
> 
> Steps:
> 1.Create scabable app with postgresql embedded.
> 2.ssh into app, connect to postgresql and make some change.
> 3.Take snapshot for this app
> 4.ssh into app again and delete some data
> 5.Restore app from snapshot
> 6.ssh into app and check deleted data is back
> 
> Result:
> Restore was successful, ssh into app and connect to postgresql, the deleted
> data is back

A typo, verified on devenv_2042