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/ (+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:

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
1=== modified file 'hooks/'
2--- hooks/ 2014-01-22 12:45:31 +0000
3+++ hooks/ 2014-01-31 13:00:14 +0000
4@@ -699,7 +699,7 @@
5 return None
8-def db_cursor(autocommit=False, db='template1', user='postgres',
9+def db_cursor(autocommit=False, db='postgres', user='postgres',
10 host=None, timeout=30):
11 import psycopg2
12 if host:
13@@ -1962,7 +1962,7 @@
14 return int(logid, 16) * 16 * 1024 * 1024 * 255 + int(offset, 16)
17-def wait_for_db(timeout=120, db='template1', user='postgres', host=None):
18+def wait_for_db(timeout=120, db='postgres', user='postgres', host=None):
19 '''Wait until the db is fully up.'''
20 db_cursor(db=db, user=user, host=host, timeout=timeout)


People subscribed via source and target branches