Merge lp:~ahasenack/charms/precise/postgresql/use-postgres-instead-of-template1 into lp:charms/postgresql

Proposed by Andreas Hasenack
Status: Merged
Merged at revision: 83
Proposed branch: lp:~ahasenack/charms/precise/postgresql/use-postgres-instead-of-template1
Merge into: lp:charms/postgresql
Diff against target: 20 lines (+2/-2)
1 file modified
hooks/hooks.py (+2/-2)
To merge this branch: bzr merge lp:~ahasenack/charms/precise/postgresql/use-postgres-instead-of-template1
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+204226@code.launchpad.net

Commit message

Use the postgres database instead of template1 so we don't block database creation by others.

Description of the change

Use the postgres database instead of template1 so we don't block database creation by others.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

As discussed on IRC, the reason for this change is that createdb uses template1 by default as its template database. If there are connections to the template database, and they can hang around for a few moments on the server after being closed by the client, the createdb will fail.

The simplest solutions are to either not open connections to the template database, or use template0 as the createdb template database. This fix does the former.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-01-22 12:45:31 +0000
+++ hooks/hooks.py 2014-01-31 13:00:14 +0000
@@ -699,7 +699,7 @@
699 return None699 return None
700700
701701
702def db_cursor(autocommit=False, db='template1', user='postgres',702def db_cursor(autocommit=False, db='postgres', user='postgres',
703 host=None, timeout=30):703 host=None, timeout=30):
704 import psycopg2704 import psycopg2
705 if host:705 if host:
@@ -1962,7 +1962,7 @@
1962 return int(logid, 16) * 16 * 1024 * 1024 * 255 + int(offset, 16)1962 return int(logid, 16) * 16 * 1024 * 1024 * 255 + int(offset, 16)
19631963
19641964
1965def wait_for_db(timeout=120, db='template1', user='postgres', host=None):1965def wait_for_db(timeout=120, db='postgres', user='postgres', host=None):
1966 '''Wait until the db is fully up.'''1966 '''Wait until the db is fully up.'''
1967 db_cursor(db=db, user=user, host=host, timeout=timeout)1967 db_cursor(db=db, user=user, host=host, timeout=timeout)
19681968

Subscribers

People subscribed via source and target branches