Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document postgresql upgrade #82739

Merged
merged 2 commits into from Mar 31, 2020
Merged

Conversation

danbst
Copy link
Contributor

@danbst danbst commented Mar 16, 2020

Fixes #7454. Rendered:

image

cc @martinetd @domenkozar @Shados @wizeman are wording/upgrade method instructions clear?

Copy link
Member

@martinetd martinetd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a couple of nitpicks, but this already is much better than nothing :)

</listitem>
<listitem>
<para>
After upgrade you may want to <literal>ANALYZE</literal> new db.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth mentioning the two scripts pg_upgrade created here in new db dir? (analyze_new_cluster.sh and delete_old_cluster.sh)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For convenience, would you mind referencing the postgresql-manual about ANALYZE here?

</listitem>
<listitem>
<para>
Run <literal>upgrade-pg-cluster</literal>. It will stop old postgresql, initialize new one and migrate old one to new one. You may supply arguments like <literal>--jobs 4</literal> and <literal>--link</literal> to speedup migration process. See <link xlink:href="https://www.postgresql.org/docs/current/pgupgrade.html" /> for details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migrate usually means the data is converted and old one is removed, but it might be worth saying old data is left in place?

@@ -63,25 +53,83 @@ Type "help" for help.
<title>Upgrading</title>

<para>
FIXME: document dump/upgrade/load cycle.
Major PostgreSQL upgrade requires PostgreSQL downtime and a few imperative steps to be called. To simplify this process, use the following NixOS module:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to link the upstream docs about upgrading (if any) here. This provides users an easy way to troubleshoot in case something goes wrong.

And it might be useful to remind people reading this to make a backup first :)

## set a custom new dataDir
# dataDir = "/some/data/dir";
};
environment.systemPackages =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nitpick) how about linking service options using <link linkend="opt-attr.path">text</link>?

export OLDBIN="${config.services.postgresql.package}/bin"
export NEWBIN="${newpg.package}/bin"

install -d -m 0700 -o postgres -g postgres "$NEWDATA"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to use ${config.service.postgresql.superUser} here.

environment.systemPackages =
let newpg = config.containers.temp-pg.config.services.postgresql;
in [
(pkgs.writeScriptBin "upgrade-pg-cluster" ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if something like this should be part of the actual postgresql-module.

</listitem>
<listitem>
<para>
After upgrade you may want to <literal>ANALYZE</literal> new db.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For convenience, would you mind referencing the postgresql-manual about ANALYZE here?

@symphorien
Copy link
Member

I tried the instructions and it did work, thanks!
The only thing is that I was puzzled by the involvement of nixos containers. It took me a long time to understand that they are only there to work around the fact that the postgresql module only allows one postgresql cluster at once.

@Ma27 Ma27 added this to the 20.03 milestone Mar 21, 2020
@Ma27 Ma27 added the 9.needs: port to stable A PR needs a backport to the stable release. label Mar 21, 2020
@Ekleog
Copy link
Member

Ekleog commented Mar 31, 2020

@Ma27 @martinetd This being a doc PR that doesn't appear to include wrong information, and nixos being in a state where any doc is better than no doc, I'm merging and backporting -- would be happy if you sent in PR's/commits with the improvements you listed, though, feel free to poke me (ideally on IRC) about them if need be :)

@Ekleog Ekleog merged commit bb5c622 into NixOS:master Mar 31, 2020
@Ekleog
Copy link
Member

Ekleog commented Mar 31, 2020

Backported in 55b0101..5d671c7

@Ma27
Copy link
Member

Ma27 commented Mar 31, 2020

Damn it, I guess I just forgot about this (next time, feel free to remind me), sorry!

I actually tried this out a while ago and the migration went perfectly fine, so merging is fine.

Thanks a lot for taking care of this @danbst @Ekleog !

@Ma27 Ma27 added 8.has: port to stable A PR already has a backport to the stable release. and removed 9.needs: port to stable A PR needs a backport to the stable release. labels Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document Postgresql upgrade
5 participants