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

Cleanup PostgreSQL for state version 17.09 #25753

Merged
merged 5 commits into from
May 30, 2017
Merged

Conversation

bachp
Copy link
Member

@bachp bachp commented May 12, 2017

Motivation for this change
  • Update PostgreSQL to 9.6
  • Change the superuser to be the more standard postgres user

Both these changes only apply if system.stateVersion is 17.09 or higher.

See: #18144

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@bachp, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @MarcWeber and @peti to be potential reviewers.

@Mic92
Copy link
Member

Mic92 commented May 13, 2017

could be added to release notes.

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

Pretty good!

I think that all that's missing is a release note that explains the change and how to upgrade from 9.5 to 9.6 including changing the createuser -s postgres

@bachp
Copy link
Member Author

bachp commented May 15, 2017

Can somebody point me to where the releasenote cam be updated?

@LnL7
Copy link
Member

LnL7 commented May 16, 2017

The 17.09 release notes are part of the nixos manual and you can build it with
nix-build ./nixos/release.nix -A manual.x86_64-linux

@bachp
Copy link
Member Author

bachp commented May 16, 2017

I tried to add this the information to the release notes but I'm strugling to get the docbook syntax right. I first need to find some time to dig into this. So if somebody else is willing to write the entry please feel free to step up 😉

@basvandijk
Copy link
Member

+1 on this change.

What about having the following change as well?

{
  dataDir = mkOption {
    default = 
      if versionAtLeast config.system.stateVersion "17.09" 
      then "/var/db/postgresql/${config.services.postgresql.package.psqlSchema}"
      else "/var/db/postgresql";
  };
}

Including the schema version (like "9.6") in the dataDir has the advantage that it's easier running multiple different versions of postgresql side by side. More importantly it makes running pg_upgrade easier.

Ubuntu, Debian and Gentoo do this as well.

@bachp
Copy link
Member Author

bachp commented May 19, 2017

@balajisivaraman I tought about this aswell. I f no objections are there I will add the schema version to the path.

@bachp
Copy link
Member Author

bachp commented May 19, 2017

I added the change proposed by @balajisivaraman

@balajisivaraman
Copy link

@bachp I think you are mentioning me by mistake in this thread. Just letting you know so you can tag the correct person. 👍

@bachp
Copy link
Member Author

bachp commented May 20, 2017

@balajisivaraman Sorry I did this on my mobile 😉 I actually wanted to mention @basvandijk.

@edolstra
Copy link
Member

Looks good to me.

@zimbatm
Copy link
Member

zimbatm commented May 28, 2017

Added some release notes to the branch. @bachp if you can rebase the branch I will merge it.

@bachp bachp changed the title Cleanup PostgreSQL for state version 17.09 WIP: Cleanup PostgreSQL for state version 17.09 May 29, 2017
@bachp
Copy link
Member Author

bachp commented May 29, 2017

I'm thinking if changing the data dir to /var/db makes sense. I would rather keep it in /var/lib as this is more common. See also discussion in #25931.

@basvandijk
Copy link
Member

@bachp I would also slightly prefer that the default is moved to /var/lib/postgresql/$psqlSchema since most applications store state under /var/lib and other distributions also store their PostgreSQL databases under /var/lib:

OS $PGDATA
Ubuntu /var/lib/postgresql/$psqlSchema/$cluster
Debian /var/lib/postgresql/$psqlSchema/$cluster
Gentoo /var/lib/postgresql/$psqlSchema/data
Arch /var/lib/postgres/data
Fedora /var/lib/pgsql/data

@zimbatm
Copy link
Member

zimbatm commented May 29, 2017

I just noticed that the release note I added already mentions /var/lib/postgres as I assumed that we followed convention with other distros ^_^

bachp and others added 4 commits May 30, 2017 21:51
Change the default superuser from `root` to `postgres` for state
version 17.09
The new directory includes the schema version of the database.
This makes upgrades easier and is more consistent with other distros.
@bachp bachp changed the title WIP: Cleanup PostgreSQL for state version 17.09 Cleanup PostgreSQL for state version 17.09 May 30, 2017
@bachp
Copy link
Member Author

bachp commented May 30, 2017

@zimbatm @basvandijk I rebase the PR and change the path to /var/lib so it is consistent with the changelog.

The <literal>postgres</literal> superuser name has changed from <literal>root</literal> to <literal>postgres</literal> to more closely follow what other Linux distributions are doing.
</para>
<para>
The <literal>postgres</literal> default <literal>dataDir</literal> has changed from <literal>/var/lib/postgres</literal> to <literal>/var/db/postgresql/$psqlSchema</literal> where $psqlSchema is 9.6 for example.
Copy link
Member

Choose a reason for hiding this comment

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

The rename described here is the wrong way around (my fault). It should be from /var/db/postgres to /var/lib/postgres/$psqlSchema

@zimbatm zimbatm merged commit de52d24 into NixOS:master May 30, 2017
@zimbatm
Copy link
Member

zimbatm commented May 30, 2017

!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants