Skip to content

StatVFS is flaky #463

Closed
Closed

Description

@puellanivis

There is a race-condition where we ask for a StatVFS, and then check it against the current results. This has one a number of occasions caused tests to fail, despite being correct code. Usually, the problem is the filesystem changed in between the asking for the StatVFS, and checking the result.

We should find some kind of way of making this deterministic.

Activity

  1. christhomas commented on Oct 15, 2026

    @christhomas
    Contributor

    We did a small code audit of the open issues. Part of this is addressed, but not all of it.

    The client integration tests are fixed. The Linux test has compared only values that don't change (Frsize, Bsize and Namemax) since fc30a3e in 2016:

    if vfs.Frsize != uint64(s.Frsize) {
    t.Fatalf("fr_size does not match, expected: %v, got: %v", s.Frsize, vfs.Frsize)
    }
    if vfs.Bsize != uint64(s.Bsize) {
    t.Fatalf("f_bsize does not match, expected: %v, got: %v", s.Bsize, vfs.Bsize)
    }
    if vfs.Namemax != uint64(s.Namelen) {
    t.Fatalf("f_namemax does not match, expected: %v, got: %v", s.Namelen, vfs.Namemax)

    #666 changed the macOS test, which compared Files, Bfree and Favail, to compare only stable values as well:

    if vfs.Frsize != uint64(s.Bsize) {
    t.Fatalf("f_frsize does not match, expected: %v, got: %v", s.Bsize, vfs.Frsize)
    }
    if vfs.Bsize != uint64(s.Iosize) {
    t.Fatalf("f_bsize does not match, expected: %v, got: %v", s.Iosize, vfs.Bsize)
    }
    if vfs.Blocks != s.Blocks {
    t.Fatalf("f_blocks does not match, expected: %v, got: %v", s.Blocks, vfs.Blocks)

    Edit: TestRequestStatVFS in request-server_test.go still compares Bavail and Bfree for /, and it failed for us while something else was writing to the disk (expected: 0x2a0ef54, actual: 0x2a0ef58):

    sftp/request-server_test.go

    Lines 848 to 849 in 16147c5

    require.Equal(t, expected.Bavail, vfs.Bavail)
    require.Equal(t, expected.Bfree, vfs.Bfree)

    So this isn't ready to close yet. Comparing only the stable values in that test, the same way #666 did, should finish it.

  2. added a commit that references this issue on Oct 23, 2026
    eb379c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions