From b724757b8aa894acd3482974b00685e2a168013d Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Mon, 1 Feb 2016 14:53:55 +0100 Subject: [PATCH 1/2] Bugfix: Ensure to inject the superuser username when connecting. When running patroni with a superuser different than the os-user, the connection was being established using the os-username. This fixes this. --- patroni/postgresql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 6e4ecddf..403da667 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -131,6 +131,7 @@ class Postgresql: def connection(self): if not self._connection or self._connection.closed != 0: r = parseurl('postgres://{}/postgres'.format(self.local_address)) + r['user'] = self.superuser['user'] self._connection = psycopg2.connect(**r) self._connection.autocommit = True self.server_version = self._connection.server_version @@ -138,7 +139,7 @@ class Postgresql: def _cursor(self): if not self._cursor_holder or self._cursor_holder.closed or self._cursor_holder.connection.closed != 0: - logger.info("established a new patroni connection to the postgres cluster") + logger.info("establishing a new patroni connection to the postgres cluster") self._cursor_holder = self.connection().cursor() return self._cursor_holder From a5207e7d5795ee000057153e92686d4cd507bafb Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Mon, 1 Feb 2016 14:58:40 +0100 Subject: [PATCH 2/2] Superuser specification: only overwrite values if specified. --- patroni/postgresql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 403da667..5e2312cb 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -131,7 +131,7 @@ class Postgresql: def connection(self): if not self._connection or self._connection.closed != 0: r = parseurl('postgres://{}/postgres'.format(self.local_address)) - r['user'] = self.superuser['user'] + r.update(self.superuser) self._connection = psycopg2.connect(**r) self._connection.autocommit = True self.server_version = self._connection.server_version