bicep/{postgres,mysql}: bindmount data storage with noatime #149

Merged
oysteikt merged 1 commits from bicep-dbms-noatime-bindmount into main 2026-07-22 13:01:02 +02:00
Owner

Fixes Drift/issues#387

bicep etter denne endringen basically:

stronk.gif

Fixes https://git.pvv.ntnu.no/Drift/issues/issues/387 bicep etter denne endringen basically: ![stronk.gif](/attachments/53e035db-0d96-464b-bd40-45ef710b1e1f)
1.1 MiB
oysteikt added 1 commit 2026-07-21 14:42:30 +02:00
bicep/{postgres,mysql}: bindmount data storage with noatime
Eval nix flake / evals (push) Successful in 7m28s
Eval nix flake / evals (pull_request) Successful in 8m57s
4ed1668ac5
felixalb requested changes 2026-07-22 11:36:06 +02:00
Dismissed
felixalb left a comment
Owner

Are the RequiresMountsFor necessary? Isn't this already in place because of the dependency chain from the WorkingDirectory(https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Implicit%20Dependencies) through the new bind mount unit?

Are the `RequiresMountsFor` necessary? Isn't this already in place because of the dependency chain from the WorkingDirectory(https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Implicit%20Dependencies) through the new bind mount unit?
@@ -99,6 +99,18 @@ in
mode = "0700";
};
fileSystems."/data/postgresql" = lib.mkIf cfg.enable {
Owner

minor nit: move repeated string "/data/postgresql" into let-var "dataDir", like in mysql

minor nit: move repeated string "/data/postgresql" into let-var "dataDir", like in mysql
Author
Owner

Are the RequiresMountsFor necessary? Isn't this already in place because of the dependency chain from the WorkingDirectory(https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Implicit%20Dependencies) through the new bind mount unit?

I don't think WorkingDirectory is even set, but if it is then WorkingDirectory=/var/lib/postgresql would be the correct value right? I'm not confident it follows the chain recursively all the way through /var/lib/postgresql -> /data/postgresql -> /data/postgresql -> /data -> ... If it does, then it's not very obvious from the docs at least.

The point where I think will fail would be the /var/lib/postgresql -> /data/postgresql jump, since RequiresMountsFor explicitly says that it is working with mount units. I have no idea if BindPaths is built on invisible transient mount units or if it's a custom concept within the service logic. If it is the latter (and I expect it to be), then WorkingDirectory (and RequiresMountsFor=/var/lib/postgresql by proxy) would not be able to see this jump.

> Are the `RequiresMountsFor` necessary? Isn't this already in place because of the dependency chain from the WorkingDirectory(https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Implicit%20Dependencies) through the new bind mount unit? I don't think `WorkingDirectory` is even set, but if it is then `WorkingDirectory=/var/lib/postgresql` would be the correct value right? I'm not confident it follows the chain recursively all the way through `/var/lib/postgresql` -> `/data/postgresql` -> `/data/postgresql` -> `/data` -> ... If it does, then it's not very obvious from the docs at least. The point where I think will fail would be the `/var/lib/postgresql` -> `/data/postgresql` jump, since `RequiresMountsFor` explicitly says that it is working with mount units. I have no idea if `BindPaths` is built on invisible transient mount units or if it's a custom concept within the service logic. If it is the latter (and I expect it to be), then `WorkingDirectory` (and `RequiresMountsFor=/var/lib/postgresql` by proxy) would not be able to see this jump.
Owner

The MySQL StateDirectory is /var/lib/mysql.

The PostgreSQL StateDirectory points to the specific versioned subdirectory of /var/lib/postgres.

The "Implicit Dependencies" of systemd.exec and systemd.mount seem to indicate that we get automatic dependencies on the state dir itself, and all parent directories required to mount it, but seemingly not if the "target" is a bind mount itself. IDK, the suggested change is probably fine, if we don't want to replace the BindPaths-thing entirely.

The [MySQL StateDirectory](https://github.com/NixOS/nixpkgs/blob/fd1462031fdee08f65fd0b4c6b64e22239a77870/nixos/modules/services/databases/mysql.nix#L763) is /var/lib/mysql. The [PostgreSQL StateDirectory](https://github.com/NixOS/nixpkgs/blob/fd1462031fdee08f65fd0b4c6b64e22239a77870/nixos/modules/services/databases/postgresql.nix#L850) points to the specific versioned subdirectory of /var/lib/postgres. The "Implicit Dependencies" of [systemd.exec](https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Implicit%20Dependencies) and [systemd.mount](https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html#Implicit%20Dependencies) seem to indicate that we get automatic dependencies on the state dir itself, and all parent directories required to mount it, but seemingly not if the "target" is a bind mount itself. IDK, the suggested change is probably fine, if we don't want to replace the BindPaths-thing entirely.
felixalb approved these changes 2026-07-22 12:36:06 +02:00
felixalb left a comment
Owner

Approved if tested working >:)

Approved if tested working >:)
oysteikt merged commit 28794691bf into main 2026-07-22 13:01:02 +02:00
oysteikt deleted branch bicep-dbms-noatime-bindmount 2026-07-22 13:01:03 +02:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Drift/pvv-nixos-config#149