[PATCH 0/5] PostgreSQL service improvements

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal

Debbugs page

Christopher Baines wrote 4 years ago
(address . guix-patches@gnu.org)
87lfgo1nlv.fsf@cbaines.net
Christopher Baines (5):
Replace (postgresql-service) with (service postgresql-service-type)
Add some subheadings in to the Databases section of the docs
Remove the postgresql-service procedure
Define postgresql-10
Don't specify a default postgresql version to use for the service

doc/guix.texi | 52 +++++++++++++++++++++++++++++++-------
gnu/packages/databases.scm | 2 ++
gnu/services/databases.scm | 25 ++----------------
gnu/tests/databases.scm | 4 ++-
gnu/tests/guix.scm | 1 +
gnu/tests/monitoring.scm | 4 ++-
gnu/tests/web.scm | 4 ++-
7 files changed, 57 insertions(+), 35 deletions(-)
Christopher Baines wrote 4 years ago
[PATCH 4/5] Define postgresql-10
(address . 43771@debbugs.gnu.org)
20201002184059.29033-4-mail@cbaines.net
So that it can be used, rather than postgresql. Because the major version of
the package is important, as it relates to the compatability with the data
files used by the service, it's useful to have a stable name to refer to a
package for version 10 of PostgreSQL.
---
gnu/packages/databases.scm | 2 ++
1 file changed, 2 insertions(+)

Toggle diff (15 lines)
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index ece4580c36..8cab3eb115 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -1038,6 +1038,8 @@ TIMESTAMP. It also supports storage of binary large objects, including
pictures, sounds, or video.")
(license (license:x11-style "file://COPYRIGHT"))))
+(define-public postgresql-10 postgresql)
+
(define-public postgresql-11
(package
(inherit postgresql)
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH 2/5] Add some subheadings in to the Databases section of the docs
(address . 43771@debbugs.gnu.org)
20201002184059.29033-2-mail@cbaines.net
To make it clearer where the relevant documentation for a particular service
starts and ends.
---
doc/guix.texi | 10 ++++++++++
1 file changed, 10 insertions(+)

Toggle diff (51 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 79c79b6a96..4197cd562a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17736,6 +17736,8 @@ details.
@cindex SQL
The @code{(gnu services databases)} module provides the following services.
+@subsubheading PostgreSQL
+
@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
[#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
[#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
@@ -17801,6 +17803,8 @@ dblink as they are already loadable by postgresql. This field is only
required to add extensions provided by other packages.
@end deffn
+@subsubheading MariaDB/MySQL
+
@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
Return a service that runs @command{mysqld}, the MySQL or MariaDB
database server.
@@ -17825,6 +17829,8 @@ TCP port on which the database server listens for incoming connections.
@end table
@end deftp
+@subsubheading Memcached
+
@defvr {Scheme Variable} memcached-service-type
This is the service type for the @uref{https://memcached.org/,
Memcached} service, which provides a distributed in memory cache. The
@@ -17857,6 +17863,8 @@ Additional command line options to pass to @code{memcached}.
@end table
@end deftp
+@subsubheading MongoDB
+
@defvr {Scheme Variable} mongodb-service-type
This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
The value for the service type is a @code{mongodb-configuration} object.
@@ -17883,6 +17891,8 @@ MongoDB is configured to use through the configuration file.
@end table
@end deftp
+@subsubheading Redis
+
@defvr {Scheme Variable} redis-service-type
This is the service type for the @uref{https://redis.io/, Redis}
key/value store, whose value is a @code{redis-configuration} object.
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH 3/5] Remove the postgresql-service procedure
(address . 43771@debbugs.gnu.org)
20201002184059.29033-3-mail@cbaines.net
It's unnecessary, using the service type directly is a better approach. While
this is unfortunately a breaking change, I'm also looking at making breaking
changes to the service type configuration, so I don't think this can be
avoided.
---
doc/guix.texi | 40 +++++++++++++++++++++++++++++---------
gnu/services/databases.scm | 19 ------------------
2 files changed, 31 insertions(+), 28 deletions(-)

Toggle diff (98 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 4197cd562a..641b410acf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17738,15 +17738,12 @@ The @code{(gnu services databases)} module provides the following services.
@subsubheading PostgreSQL
-@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
- [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
- [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
-Return a service that runs @var{postgresql}, the PostgreSQL database
-server.
+The following example describes a PostgreSQL service with the default
+configuration.
-The PostgreSQL daemon loads its runtime configuration from @var{config-file},
-creates a database cluster with @var{locale} as the default
-locale, stored in @var{data-directory}. It then listens on @var{port}.
+@lisp
+(service postgresql-service-type)
+@end lisp
If the services fails to start, it may be due to an incompatible
cluster already present in @var{data-directory}. Adjust it (or, if you
@@ -17766,6 +17763,29 @@ createuser --interactive
createdb $MY_USER_LOGIN # Replace appropriately.
@end example
+@deftp {Data Type} postgresql-configuration
+Data type representing the configuration for the
+@code{postgresql-service-type}.
+
+@table @asis
+@item @var{postgresql} (default: @code{postgresql})
+PostgreSQL package to use for the service.
+
+@item @var{port} (default: @code{5432})
+Port on which PostgreSQL should listen.
+
+@item @var{locale} (default: @code{"en_US.utf8"})
+Locale to use as the default when creating the database cluster.
+
+@item @var{config-file} (default: @code{(postgresql-config-file)})
+The configuration file to use when running PostgreSQL. The default
+behaviour uses the postgresql-config-file record with the default values
+for the fields.
+
+@item @var{data-directory} (default: @code{"/var/lib/postgresql/data"})
+Directory in which to store the data.
+
+@item @var{extension-packages} (default: @code{'()})
@cindex postgresql extension-packages
Additional extensions are loaded from packages listed in
@var{extension-packages}. Extensions are available at runtime. For instance,
@@ -17801,7 +17821,9 @@ psql -U postgres
There is no need to add this field for contrib extensions such as hstore or
dblink as they are already loadable by postgresql. This field is only
required to add extensions provided by other packages.
-@end deffn
+
+@end table
+@end deftp
@subsubheading MariaDB/MySQL
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 2bddf70f71..efad182a68 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -281,25 +281,6 @@ host all all ::1/128 md5"))
(compose list postgresql-configuration-postgresql))))
(default-value (postgresql-configuration))))
-(define* (postgresql-service #:key (postgresql postgresql)
- (port 5432)
- (locale "en_US.utf8")
- (config-file (postgresql-config-file))
- (data-directory "/var/lib/postgresql/data")
- (extension-packages '()))
- "Return a service that runs @var{postgresql}, the PostgreSQL database server.
-
-The PostgreSQL daemon loads its runtime configuration from @var{config-file}
-and stores the database cluster in @var{data-directory}."
- (service postgresql-service-type
- (postgresql-configuration
- (postgresql postgresql)
- (port port)
- (locale locale)
- (config-file config-file)
- (data-directory data-directory)
- (extension-packages extension-packages))))
-
;;;
;;; Memcached
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH 5/5] Don't specify a default postgresql version to use for the service
(address . 43771@debbugs.gnu.org)
20201002184059.29033-5-mail@cbaines.net
Currently, if the postgresql package major version changes, this is going to
break the service upon upgrade, because PostgreSQL will reject the data files
from the differing major version of the service.

Because it's important to either keep running a particular major version, or
intentionally upgrade, I think the configuration would be better with no
default. I think this is also going to be helpful when trying to assist users
upgrading PostgreSQL.
---
doc/guix.texi | 6 ++++--
gnu/services/databases.scm | 6 ++----
gnu/tests/databases.scm | 4 +++-
gnu/tests/guix.scm | 1 +
gnu/tests/monitoring.scm | 4 +++-
gnu/tests/web.scm | 4 +++-
6 files changed, 16 insertions(+), 9 deletions(-)

Toggle diff (107 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 641b410acf..4ce0072ed4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17742,7 +17742,9 @@ The following example describes a PostgreSQL service with the default
configuration.
@lisp
-(service postgresql-service-type)
+(service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))
@end lisp
If the services fails to start, it may be due to an incompatible
@@ -17768,7 +17770,7 @@ Data type representing the configuration for the
@code{postgresql-service-type}.
@table @asis
-@item @var{postgresql} (default: @code{postgresql})
+@item @var{postgresql}
PostgreSQL package to use for the service.
@item @var{port} (default: @code{5432})
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index efad182a68..96d2dc4935 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -146,8 +146,7 @@ host all all ::1/128 md5"))
(define-record-type* <postgresql-configuration>
postgresql-configuration make-postgresql-configuration
postgresql-configuration?
- (postgresql postgresql-configuration-postgresql ;<package>
- (default postgresql))
+ (postgresql postgresql-configuration-postgresql) ;<package>
(port postgresql-configuration-port
(default 5432))
(locale postgresql-configuration-locale
@@ -278,8 +277,7 @@ host all all ::1/128 md5"))
(service-extension account-service-type
(const %postgresql-accounts))
(service-extension profile-service-type
- (compose list postgresql-configuration-postgresql))))
- (default-value (postgresql-configuration))))
+ (compose list postgresql-configuration-postgresql))))))
;;;
diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm
index e0544bbcd2..d3045cc3f7 100644
--- a/gnu/tests/databases.scm
+++ b/gnu/tests/databases.scm
@@ -215,7 +215,9 @@
(define %postgresql-os
(simple-operating-system
- (service postgresql-service-type)))
+ (service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))))
(define (run-postgresql-test)
"Run tests in %POSTGRESQL-OS."
diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm
index 6139e31cf0..ebee8d43af 100644
--- a/gnu/tests/guix.scm
+++ b/gnu/tests/guix.scm
@@ -83,6 +83,7 @@
(service dhcp-client-service-type)
(service postgresql-service-type
(postgresql-configuration
+ (postgresql postgresql-10)
(config-file
(postgresql-config-file
(hba-file
diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm
index 17b9edc3ac..7371b02fe1 100644
--- a/gnu/tests/monitoring.scm
+++ b/gnu/tests/monitoring.scm
@@ -307,7 +307,9 @@ zabbix||{}
(let ((base-os
(simple-operating-system
(service dhcp-client-service-type)
- (service postgresql-service-type)
+ (service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))
(service zabbix-front-end-service-type
(zabbix-front-end-configuration
(db-password "zabbix")))
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 7513eab2e4..7f4518acd2 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -567,7 +567,9 @@ HTTP-PORT."
(config
(httpd-config-file
(listen '("8080"))))))
- (service postgresql-service-type)
+ (service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))
(service patchwork-service-type
(patchwork-configuration
(patchwork patchwork)
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH 1/5] Replace (postgresql-service) with (service postgresql-service-type)
(address . 43771@debbugs.gnu.org)
20201002184059.29033-1-mail@cbaines.net
As I'm looking at removing the procedure, in favour of always using the
service type.
---
gnu/tests/monitoring.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm
index d20b8ac59e..17b9edc3ac 100644
--- a/gnu/tests/monitoring.scm
+++ b/gnu/tests/monitoring.scm
@@ -307,7 +307,7 @@ zabbix||{}
(let ((base-os
(simple-operating-system
(service dhcp-client-service-type)
- (postgresql-service)
+ (service postgresql-service-type)
(service zabbix-front-end-service-type
(zabbix-front-end-configuration
(db-password "zabbix")))
--
2.28.0
Ludovic Courtès wrote 4 years ago
Re: [bug#43771] [PATCH 3/5] Remove the postgresql-service procedure
(name . Christopher Baines)(address . mail@cbaines.net)(address . 43771@debbugs.gnu.org)
87pn5x3wd0.fsf@gnu.org
Hi,

Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (5 lines)
> It's unnecessary, using the service type directly is a better approach. While
> this is unfortunately a breaking change, I'm also looking at making breaking
> changes to the service type configuration, so I don't think this can be
> avoided.

[...]

Toggle quote (4 lines)
> -(define* (postgresql-service #:key (postgresql postgresql)
> - (port 5432)
> - (locale "en_US.utf8")

Here I’d suggest to keep it as ‘define-deprecated’, like we did for
other such procedures.

Otherwise LGTM.

Thanks,
Ludo’.
Ludovic Courtès wrote 4 years ago
Re: [bug#43771] [PATCH 0/5] PostgreSQL service improvements
(name . Christopher Baines)(address . mail@cbaines.net)(address . 43771@debbugs.gnu.org)
87lfgl3wb7.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (7 lines)
> Christopher Baines (5):
> Replace (postgresql-service) with (service postgresql-service-type)
> Add some subheadings in to the Databases section of the docs
> Remove the postgresql-service procedure
> Define postgresql-10
> Don't specify a default postgresql version to use for the service

It all LGTM… except for commit logs. :-) Please add the conventional
subject line and ChangeLog-style entries. I’m sorry to spoil your
Monday morning. :-)

Ludo’.
Christopher Baines wrote 4 years ago
Re: [bug#43771] [PATCH 3/5] Remove the postgresql-service procedure
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 43771@debbugs.gnu.org)
87a6wihwg7.fsf@cbaines.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (18 lines)
> Hi,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> It's unnecessary, using the service type directly is a better approach. While
>> this is unfortunately a breaking change, I'm also looking at making breaking
>> changes to the service type configuration, so I don't think this can be
>> avoided.
>
> [...]
>
>> -(define* (postgresql-service #:key (postgresql postgresql)
>> - (port 5432)
>> - (locale "en_US.utf8")
>
> Here I’d suggest to keep it as ‘define-deprecated’, like we did for
> other such procedures.

Ah, yeah, I discounted that initially, as I didn't see a way to adapt it
to the new behaviour, but the deprecated procedure can just have the old
behaviour.

I'll send some updated patches with it deprecated.
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl+N4nhfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9Xd5iRAAqQcGqQQ10D0puIDptLEe6YDC13p+lSLh
i/TniWEDyxqrQWik49nYyPubvqjG2mLmy/QAmn4kMghkmufzPIF+QNYzbSi3t13J
y8jVFszDOd/d4roe4Ox0sP8epqsofIVDfZVQrQee/2gQNIko/RLehc9r/BgB6bxe
nw21O03UNqkkgjZYxu8R8L7nYoo3Sntr/WDwd8BOiTm+NjSEZ/8OWIJz34Qpe53T
QV346n78RH9Nzi7NVgImqX0uSxx6Xp1m3nQLWWsHtpQUmU6p/T7FMDTfOgAteJoG
svn9oUXNtHM9tlWu6G8FbRkfRA3vNjKEpAu6w9dC1NpUpFawRq+WOnQZaKr6bMj0
v/NddxelIZIsrKXlTgCgIOBZ4adTDLMq9f0nuzExWi6IWdlvKL8ekQHCQeTK/ycY
MuBwwimB61Q5w2cLeUuJ4W2bC7ezPDvZo0W7cftEw1MHIRHFwTrp8jFVGlJDSp72
3Obht/dcEcVgpupSzqHute1y4wmyP59B3DHbqjktfFqlI+fYOGVMDJvoGwlVIXgM
WuEecpLU4mV0vlk5TcjFJJEOzEMK08LuvAXGMJYCUwgX6bKFQ7H4UpdY8ZMGp+U/
QLKGi9LycDjk7L31Cbz6Cisv6frPvqex2Hk+BZluBk9lKUKiL+81JedgHEZNcgVS
fYdan5PPbfo=
=sZ19
-----END PGP SIGNATURE-----

Christopher Baines wrote 4 years ago
[PATCH v2 1/5] tests: monitoring: Use (service postgresql-service-type).
(address . 43771@debbugs.gnu.org)
20201019190259.11356-1-mail@cbaines.net
As I'm looking at removing the procedure, in favour of always using the
service type.

* gnu/tests/monitoring.scm (%zabbix-os): Use (service postgresql-service-type)
rather than (postgresql-service).
---
gnu/tests/monitoring.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm
index d20b8ac59e..17b9edc3ac 100644
--- a/gnu/tests/monitoring.scm
+++ b/gnu/tests/monitoring.scm
@@ -307,7 +307,7 @@ zabbix||{}
(let ((base-os
(simple-operating-system
(service dhcp-client-service-type)
- (postgresql-service)
+ (service postgresql-service-type)
(service zabbix-front-end-service-type
(zabbix-front-end-configuration
(db-password "zabbix")))
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH v2 2/5] doc: Add subheadings in to the Databases section.
(address . 43771@debbugs.gnu.org)
20201019190259.11356-2-mail@cbaines.net
To make it clearer where the relevant documentation for a particular service
starts and ends.

* doc/guix.texi (Database Services): Add subheadings.
---
doc/guix.texi | 10 ++++++++++
1 file changed, 10 insertions(+)

Toggle diff (51 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 130985d30f..d6d610acae 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18178,6 +18178,8 @@ details.
@cindex SQL
The @code{(gnu services databases)} module provides the following services.
+@subsubheading PostgreSQL
+
@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
[#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
[#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
@@ -18243,6 +18245,8 @@ dblink as they are already loadable by postgresql. This field is only
required to add extensions provided by other packages.
@end deffn
+@subsubheading MariaDB/MySQL
+
@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
Return a service that runs @command{mysqld}, the MySQL or MariaDB
database server.
@@ -18267,6 +18271,8 @@ TCP port on which the database server listens for incoming connections.
@end table
@end deftp
+@subsubheading Memcached
+
@defvr {Scheme Variable} memcached-service-type
This is the service type for the @uref{https://memcached.org/,
Memcached} service, which provides a distributed in memory cache. The
@@ -18299,6 +18305,8 @@ Additional command line options to pass to @code{memcached}.
@end table
@end deftp
+@subsubheading MongoDB
+
@defvr {Scheme Variable} mongodb-service-type
This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
The value for the service type is a @code{mongodb-configuration} object.
@@ -18325,6 +18333,8 @@ MongoDB is configured to use through the configuration file.
@end table
@end deftp
+@subsubheading Redis
+
@defvr {Scheme Variable} redis-service-type
This is the service type for the @uref{https://redis.io/, Redis}
key/value store, whose value is a @code{redis-configuration} object.
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH v2 4/5] gnu: databases: Define postgresql-10.
(address . 43771@debbugs.gnu.org)
20201019190259.11356-4-mail@cbaines.net
So that it can be used, rather than postgresql. Because the major version of
the package is important, as it relates to the compatability with the data
files used by the service, it's useful to have a stable name to refer to a
package for version 10 of PostgreSQL.

* gnu/packages/databases.scm (postgresql-10): New variable.
---
gnu/packages/databases.scm | 2 ++
1 file changed, 2 insertions(+)

Toggle diff (15 lines)
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 1236f57018..0d8342b04a 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -1040,6 +1040,8 @@ TIMESTAMP. It also supports storage of binary large objects, including
pictures, sounds, or video.")
(license (license:x11-style "file://COPYRIGHT"))))
+(define-public postgresql-10 postgresql)
+
(define-public postgresql-11
(package
(inherit postgresql)
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH v2 3/5] services: databases: Deprecate the postgresql-service procedure.
(address . 43771@debbugs.gnu.org)
20201019190259.11356-3-mail@cbaines.net
Using the service type directly is a better approach, making it easier to
configure the service.

* gnu/services/databases.scm (postgresql-service): Deprecate this procedure.
* doc/guix.texi (PostgreSQL): Update the documentation for the use of (service
postgresql-service-type).
---
doc/guix.texi | 40 +++++++++++++++++++++++++++++---------
gnu/services/databases.scm | 14 +++++++------
2 files changed, 39 insertions(+), 15 deletions(-)

Toggle diff (100 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index d6d610acae..8aaa896c8d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18180,15 +18180,12 @@ The @code{(gnu services databases)} module provides the following services.
@subsubheading PostgreSQL
-@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
- [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
- [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
-Return a service that runs @var{postgresql}, the PostgreSQL database
-server.
+The following example describes a PostgreSQL service with the default
+configuration.
-The PostgreSQL daemon loads its runtime configuration from @var{config-file},
-creates a database cluster with @var{locale} as the default
-locale, stored in @var{data-directory}. It then listens on @var{port}.
+@lisp
+(service postgresql-service-type)
+@end lisp
If the services fails to start, it may be due to an incompatible
cluster already present in @var{data-directory}. Adjust it (or, if you
@@ -18208,6 +18205,29 @@ createuser --interactive
createdb $MY_USER_LOGIN # Replace appropriately.
@end example
+@deftp {Data Type} postgresql-configuration
+Data type representing the configuration for the
+@code{postgresql-service-type}.
+
+@table @asis
+@item @var{postgresql} (default: @code{postgresql})
+PostgreSQL package to use for the service.
+
+@item @var{port} (default: @code{5432})
+Port on which PostgreSQL should listen.
+
+@item @var{locale} (default: @code{"en_US.utf8"})
+Locale to use as the default when creating the database cluster.
+
+@item @var{config-file} (default: @code{(postgresql-config-file)})
+The configuration file to use when running PostgreSQL. The default
+behaviour uses the postgresql-config-file record with the default values
+for the fields.
+
+@item @var{data-directory} (default: @code{"/var/lib/postgresql/data"})
+Directory in which to store the data.
+
+@item @var{extension-packages} (default: @code{'()})
@cindex postgresql extension-packages
Additional extensions are loaded from packages listed in
@var{extension-packages}. Extensions are available at runtime. For instance,
@@ -18243,7 +18263,9 @@ psql -U postgres
There is no need to add this field for contrib extensions such as hstore or
dblink as they are already loadable by postgresql. This field is only
required to add extensions provided by other packages.
-@end deffn
+
+@end table
+@end deftp
@subsubheading MariaDB/MySQL
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 2bddf70f71..7908a3e0f6 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -30,6 +30,7 @@
#:use-module (gnu packages databases)
#:use-module (guix build-system trivial)
#:use-module (guix build union)
+ #:use-module (guix deprecation)
#:use-module (guix modules)
#:use-module (guix packages)
#:use-module (guix records)
@@ -281,12 +282,13 @@ host all all ::1/128 md5"))
(compose list postgresql-configuration-postgresql))))
(default-value (postgresql-configuration))))
-(define* (postgresql-service #:key (postgresql postgresql)
- (port 5432)
- (locale "en_US.utf8")
- (config-file (postgresql-config-file))
- (data-directory "/var/lib/postgresql/data")
- (extension-packages '()))
+(define-deprecated (postgresql-service #:key (postgresql postgresql)
+ (port 5432)
+ (locale "en_US.utf8")
+ (config-file (postgresql-config-file))
+ (data-directory "/var/lib/postgresql/data")
+ (extension-packages '()))
+ postgresql-service-type
"Return a service that runs @var{postgresql}, the PostgreSQL database server.
The PostgreSQL daemon loads its runtime configuration from @var{config-file}
--
2.28.0
Christopher Baines wrote 4 years ago
[PATCH v2 5/5] services: databases: Don't specify a default postgresql version.
(address . 43771@debbugs.gnu.org)
20201019190259.11356-5-mail@cbaines.net
Currently, if the postgresql package major version changes, this is going to
break the service upon upgrade, because PostgreSQL will reject the data files
from the differing major version of the service.

Because it's important to either keep running a particular major version, or
intentionally upgrade, I think the configuration would be better with no
default. I think this is also going to be helpful when trying to assist users
upgrading PostgreSQL.

* gnu/services/databases.scm (<postgresql-configuration>): Remove default for
postgresql.
(postgresql-service-type): Remove the default value.
* gnu/tests/databases.scm (%postgresql-os): Update accordingly.
* gnu/tests/guix.scm (%guix-data-service-os): Update accordingly.
* gnu/tests/monitoring.scm (%zabbix-os): Update accordingly.
* gnu/tests/web.scm (patchwork-os): Update accordingly.
* doc/guix.texi (PostgreSQL): Update accordingly.
---
doc/guix.texi | 6 ++++--
gnu/services/databases.scm | 6 ++----
gnu/tests/databases.scm | 4 +++-
gnu/tests/guix.scm | 1 +
gnu/tests/monitoring.scm | 4 +++-
gnu/tests/web.scm | 4 +++-
6 files changed, 16 insertions(+), 9 deletions(-)

Toggle diff (107 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 8aaa896c8d..bc62a1f797 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18184,7 +18184,9 @@ The following example describes a PostgreSQL service with the default
configuration.
@lisp
-(service postgresql-service-type)
+(service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))
@end lisp
If the services fails to start, it may be due to an incompatible
@@ -18210,7 +18212,7 @@ Data type representing the configuration for the
@code{postgresql-service-type}.
@table @asis
-@item @var{postgresql} (default: @code{postgresql})
+@item @var{postgresql}
PostgreSQL package to use for the service.
@item @var{port} (default: @code{5432})
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 7908a3e0f6..d7b4594b9e 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -147,8 +147,7 @@ host all all ::1/128 md5"))
(define-record-type* <postgresql-configuration>
postgresql-configuration make-postgresql-configuration
postgresql-configuration?
- (postgresql postgresql-configuration-postgresql ;<package>
- (default postgresql))
+ (postgresql postgresql-configuration-postgresql) ;<package>
(port postgresql-configuration-port
(default 5432))
(locale postgresql-configuration-locale
@@ -279,8 +278,7 @@ host all all ::1/128 md5"))
(service-extension account-service-type
(const %postgresql-accounts))
(service-extension profile-service-type
- (compose list postgresql-configuration-postgresql))))
- (default-value (postgresql-configuration))))
+ (compose list postgresql-configuration-postgresql))))))
(define-deprecated (postgresql-service #:key (postgresql postgresql)
(port 5432)
diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm
index e0544bbcd2..d3045cc3f7 100644
--- a/gnu/tests/databases.scm
+++ b/gnu/tests/databases.scm
@@ -215,7 +215,9 @@
(define %postgresql-os
(simple-operating-system
- (service postgresql-service-type)))
+ (service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))))
(define (run-postgresql-test)
"Run tests in %POSTGRESQL-OS."
diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm
index 20b67d55d3..af7d8f0b21 100644
--- a/gnu/tests/guix.scm
+++ b/gnu/tests/guix.scm
@@ -156,6 +156,7 @@
(service dhcp-client-service-type)
(service postgresql-service-type
(postgresql-configuration
+ (postgresql postgresql-10)
(config-file
(postgresql-config-file
(hba-file
diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm
index 17b9edc3ac..7371b02fe1 100644
--- a/gnu/tests/monitoring.scm
+++ b/gnu/tests/monitoring.scm
@@ -307,7 +307,9 @@ zabbix||{}
(let ((base-os
(simple-operating-system
(service dhcp-client-service-type)
- (service postgresql-service-type)
+ (service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))
(service zabbix-front-end-service-type
(zabbix-front-end-configuration
(db-password "zabbix")))
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 7513eab2e4..7f4518acd2 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -567,7 +567,9 @@ HTTP-PORT."
(config
(httpd-config-file
(listen '("8080"))))))
- (service postgresql-service-type)
+ (service postgresql-service-type
+ (postgresql-configuration
+ (postgresql postgresql-10)))
(service patchwork-service-type
(patchwork-configuration
(patchwork patchwork)
--
2.28.0
Christopher Baines wrote 4 years ago
Re: [bug#43771] [PATCH 0/5] PostgreSQL service improvements
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 43771@debbugs.gnu.org)
877drmhqtx.fsf@cbaines.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (13 lines)
> Christopher Baines <mail@cbaines.net> skribis:
>
>> Christopher Baines (5):
>> Replace (postgresql-service) with (service postgresql-service-type)
>> Add some subheadings in to the Databases section of the docs
>> Remove the postgresql-service procedure
>> Define postgresql-10
>> Don't specify a default postgresql version to use for the service
>
> It all LGTM… except for commit logs. :-) Please add the conventional
> subject line and ChangeLog-style entries. I’m sorry to spoil your
> Monday morning. :-)

I've finally got around now to revising the commit messages and sent
some updated patches.
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl+N/upfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XcU3RAArTCjtpRoucDIz5mrgIt8y9qzz3YPX549
WixSNwZP0OJAb6hoaRDB3dOUxYlKHgadU0maPFiD66Uz9tHbZNR7UW9oPx5d2Bh0
OBR9gNk95UMwZBRRojsmKvpvg8zdZu4gcERopjVOKnx/uPuq+oQFacbd8J4ERcGn
RL/WBsm9gk9nyp5e7Q+u1RQMHWlREhfiXF/KziC1YsjohaSdgHbV0QI3acQRC2SW
XjT5kGe+HZ4SYNmtfc8oAqTYxKS5PpJepa87EhlQOrj775WGJpvkdtPo0TRG8Fb6
6d7ms+XxPh8SRkIcLm7TkqaPf8NKjUjyCWg0I0rANTTfni5Ye/ZdIBW4SWELPGGk
dNadEXVWMHLikcQ2w1w52dkOLDKIMMw3QIxlgJwNsIN3dE/XGsVkqzPKX3FPL4rJ
zYSYNMPwkp2gBVpl1LuaM8jHnTrutZDx7KeambxFbj0pVbTtOsZr5uK+Yh/GbvgL
8iz6VhcGCQTqnR/mGhGSg0z8h33YudjWXySgnI9yq4gIzBpbnkXRXTARAtwM4o0U
upcg6A7MXVW2zj85s1lfg55f7r6riC8tewzngBKi2asbh2lavkmiinQqkpUaRoXa
ET0zv0GDA0clHigKGBOJxxlPWVrTLyHVU9iq8HI4qDNMjBtczcKfCKX4ZeeSOIB5
+qH0NuxSzB0=
=TOYr
-----END PGP SIGNATURE-----

Ludovic Courtès wrote 4 years ago
(name . Christopher Baines)(address . mail@cbaines.net)(address . 43771@debbugs.gnu.org)
87d01cbn37.fsf@gnu.org
Hi,

Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (18 lines)
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Christopher Baines <mail@cbaines.net> skribis:
>>
>>> Christopher Baines (5):
>>> Replace (postgresql-service) with (service postgresql-service-type)
>>> Add some subheadings in to the Databases section of the docs
>>> Remove the postgresql-service procedure
>>> Define postgresql-10
>>> Don't specify a default postgresql version to use for the service
>>
>> It all LGTM… except for commit logs. :-) Please add the conventional
>> subject line and ChangeLog-style entries. I’m sorry to spoil your
>> Monday morning. :-)
>
> I've finally got around now to revising the commit messages and sent
> some updated patches.

Perfect, go for it!

Thanks,
Ludo’.
Christopher Baines wrote 4 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 43771-done@debbugs.gnu.org)
87sga8h667.fsf@cbaines.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (24 lines)
> Hi,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> Christopher Baines <mail@cbaines.net> skribis:
>>>
>>>> Christopher Baines (5):
>>>> Replace (postgresql-service) with (service postgresql-service-type)
>>>> Add some subheadings in to the Databases section of the docs
>>>> Remove the postgresql-service procedure
>>>> Define postgresql-10
>>>> Don't specify a default postgresql version to use for the service
>>>
>>> It all LGTM… except for commit logs. :-) Please add the conventional
>>> subject line and ChangeLog-style entries. I’m sorry to spoil your
>>> Monday morning. :-)
>>
>> I've finally got around now to revising the commit messages and sent
>> some updated patches.
>
> Perfect, go for it!

Great, I've pushed these as bdcf4d88d58798eca7811c8b1fbd4638168d05c3
now. Thanks!
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl+PZ4BfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XcfhxAAhORREKA8O0subiEo6IhvL7LVgwoxoJu2
9wBXl/R1E+SAGuLERHNrazK8TT3ng40flkM+PY7nvPm9xEZeV8S7O4QmhuyxfKHy
b60P65tylO7hgPT7DlwFo9j6yuipzPuTaOp5iAAjGYbapRrA5KOwM+kTlHsHElH6
C/xKEMuEr1uQmsLEg3ZmYF05yj2BjSDMkMMT6k0y6E+0laHDfIqybgMmMWeZB7Hk
ayBFoarQRXApiVMRT1MaRw2TCNIX4M4UbDsIBK8tBJd0glIoh4PKsx9vKIxdOZKe
HALZAKzgiiaSZni8K/dCJfcRedW/7KTOxzhCPBSGR9AvklQo4gEIzmXC76cQ/2e7
HDr25XNusSJ+ju/VZAhiN9zVdoG66WQCOsDUL/148WijL6HckdS/bgKVIRglTsiC
uD4i25LpClLu6AMT9KvBX3YfufDUeBHpVopQFog2BH0GHOx8fX7VYYjZSBTJ03qO
ugpVFqA9PY5HLglJzQQy/VsJK/npYyPxLxcfwv99ydY95Bh5BLJ58bGJ9wj71fwt
giJrkZA0ME49aOb+QwpceFAtZfqxU7MK7ZDsfz/URl3dORe02SIpk/4xavhgj2iB
rQviOWKLlFmBx6WWOok0O5u6J2+NZVqhRIXLNXXwSFsxzhzehhcp0kRxb2MBfVY5
oCk1D18vWk4=
=g8Pv
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 43771@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 43771
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help