Stream: services-flake

Topic: dataDir for postgres service has incorrect permissions


view this post on Zulip tgunnoe (Nov 30 2023 at 18:25):

I'm running into the local run directory for process-compose that I set with dataDir having the wrong permissions and its unable to initialize the database. Its possible the system has auto new directories having specific permissions, but I think we should check for that?

view this post on Zulip tgunnoe (Nov 30 2023 at 18:27):

Maybe something here: https://github.com/juspay/services-flake/blob/main/nix/postgres.nix#L354-L357

view this post on Zulip Srid (Nov 30 2023 at 18:29):

What do you mean by "wrong permissions"? For reference, this is what I see on my local machine (which happens to be a mac) when I nix run the example in the repo,

 ls -ld data/
drwxr-xr-x 4 srid staff 128 Nov 30 13:28 data/

❯ ls -ld data/pg1/global
drwx------ 63 srid staff 2016 Nov 30 13:28 data/pg1/global

view this post on Zulip Srid (Nov 30 2023 at 18:33):

And

 ls -dl data/pg1
drwx------ 25 srid staff 800 Nov 30 13:28 data/pg1

its unable to initialize the database

Could you post the error? Maybe initdb requires data directory to not be world-readable.

view this post on Zulip tgunnoe (Nov 30 2023 at 18:34):

image-4.png

view this post on Zulip Srid (Nov 30 2023 at 18:36):

Oh it is a locale related issue?

view this post on Zulip tgunnoe (Nov 30 2023 at 18:37):

sorry, looks unrelated :sweat_smile: but this is the start of it. I am troubleshooting someone elses environment. when he goes to run the postgres init again, then its a permissions issue

view this post on Zulip Srid (Nov 30 2023 at 18:39):

By the way, you can also pass -t=false arguments to get flat interleaved log output that is easier to copy-paste.

# Example
nix run . -- -t=false up

view this post on Zulip tgunnoe (Nov 30 2023 at 18:39):

good to know. seems the selection mode in process-compose doesn't work well

view this post on Zulip Srid (Nov 30 2023 at 18:40):

There is also the log_location (in #process-compose-flake) option to have it write to a log file

view this post on Zulip Srid (Nov 30 2023 at 18:42):

tgunnoe said:

image-4.png

Error in screenshot:

initdb: error: invalid locale settings: check LANG and LC_* environment variables

Perhaps services-flake should explicitly set this env. cc @Shivaraj B H

Ref: https://stackoverflow.com/a/42111789/55246

view this post on Zulip Srid (Nov 30 2023 at 18:43):

tgunnoe said:

sorry, looks unrelated :sweat_smile: but this is the start of it. I am troubleshooting someone elses environment. when he goes to run the postgres init again, then its a permissions issue

What's the permission issue in particular?

view this post on Zulip Srid (Nov 30 2023 at 18:43):

Can this problem be reproduced in another system? Then we have a bug report as well.

view this post on Zulip tgunnoe (Nov 30 2023 at 18:48):

What should services-flake set those vars to?

view this post on Zulip Srid (Nov 30 2023 at 18:50):

Probably the same as those in StackOverflow answer, so:

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

view this post on Zulip tgunnoe (Nov 30 2023 at 18:51):

would setting them in the shell before running process compose not be the same result?

view this post on Zulip Srid (Nov 30 2023 at 18:51):

I'd think so, yes.

view this post on Zulip Srid (Nov 30 2023 at 18:52):

Here's another answer from Nix context which suggests adding the glibcLocales package to the environment.

view this post on Zulip tgunnoe (Nov 30 2023 at 18:53):

that's a good bet

view this post on Zulip tgunnoe (Nov 30 2023 at 19:06):

image-6.png
well more logs in the latest, but still the same. i need to mess up my locales to solve this

view this post on Zulip tgunnoe (Nov 30 2023 at 19:07):

because its using the nix devshell, something needs to be set properly there. ah

view this post on Zulip Srid (Nov 30 2023 at 19:08):

The "cannot change locale" warnings are concerning.

view this post on Zulip tgunnoe (Nov 30 2023 at 19:11):

yeah. its trying to setlocale from within process compose in a nix shell :melting_face:

view this post on Zulip tgunnoe (Nov 30 2023 at 19:17):

https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/build-managers/msbuild/default.nix#L49-L52

# https://github.com/NixOS/nixpkgs/issues/38991
  # bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  env.LOCALE_ARCHIVE = lib.optionalString stdenv.hostPlatform.isLinux "${glibcLocales}/lib/locale/locale-archive";

view this post on Zulip tgunnoe (Nov 30 2023 at 19:21):

would this be enough as an env in the shell? or i wonder, does nixpkgs glibc have a general issue

view this post on Zulip Srid (Nov 30 2023 at 19:22):

would this be enough as an env in the shell?

Probably.

We might even want to add this to service-flake.

view this post on Zulip Srid (Nov 30 2023 at 19:23):

I've had locale issues on emanote (which too uses Nix) as well:

https://github.com/srid/emanote/issues/125

So, certainly not limited to postgres here.

view this post on Zulip Shivaraj B H (Nov 30 2023 at 20:01):

@tgunnoe Perhaps you can create an issue in services-flake and we can track it there?

view this post on Zulip tgunnoe (Nov 30 2023 at 23:02):

I will. could it be something with lib.getExe?

view this post on Zulip Shivaraj B H (Dec 01 2023 at 11:58):

could it be something with lib.getExe?

Not sure, but a way to reproduce would be great to debug


Last updated: Oct 12 2024 at 21:29 UTC