Open charles-dyfis-net opened 5 years ago
The title is a bit misleading, as the filesystem is not quite empty even in the failing case -- we've still had a .beeshome
subvol created by the wrapper, after all.
Do you have the log output from the failing case? Among other things it will have the context leading up to the exception.
Edited an additional file log.txt
into the previously-linked gist.
So it's failing to find the extent tree in the root tree. Fascinating.
Maybe there's some race condition during the first btrfs mount where transid 1 or the extent tree doesn't exist yet?
In any case, some other things are going wrong after that: somehow we get a transid_max
of 18446744073709551615 (maybe need something like 90132182fdb2c06a2811ce9d45c54046adaf536d for transid_max()
). After that, nothing works because we're assuming the largest possible transaction rate and won't accept any smaller transid than the maximum possible transid.
It should be possible to work around this by forcing a sync
after creating .beeshome
.
Confirmed: Adding that sync
(as in charles-dyfis-net/nixpkgs@5ed17dfb01e82db9f78c2f78a694c321ba07c697) does indeed work around the immediate issue.
This was discovered when writing a NixOS system test for the bees module.
The testing logic in https://github.com/NixOS/nixpkgs/blob/923a3e4970226293e4698e44e3e5d5ccf7487603/nixos/tests/bees.nix consistently succeeds every time: This code first creates files on a new filesystem, then starts the bees service. That (passing) test is roughly equivalent to the following shell script:
By contrast, a test akin to the following -- which starts the service after the filesystem is created and initially mounted, but before any content has been created -- consistently fails, with bees running in a loop which is trying to poll the status of a file descriptor referring to a file that doesn't exist:
The actual failing test can be found at https://github.com/charles-dyfis-net/nixpkgs/blob/bees-test-failing/nixos/tests/bees.nix; if checking out the relevant branch of nixpkgs, it can be run (from the root of that working tree) with
nix-build -I nixpkgs="$PWD" ./nixos/tests/bees.nix
.strace of the loop taking place when in that failed state can be seen at https://gist.github.com/charles-dyfis-net/34ac2e4d2bada0c3a3c8632cab98c8d9