← Back to context

Comment by freemint

4 years ago

Since no Mac device has two power support adding a second UPS means chaining which will only increase the risk of something going wrong in the chain.

Nobody expects 100% data integrity on power of. What is expected is that data that what was fsynced has 100% data integrity once that system call returns. This information is also used when moving files across the network, the file gets deleted on the sender when the receiver said fsync is completed. This means you could loose entire files of data when moving things over the network onto a Mac

For what it's worth, adding an external UPS to a Mac laptop counts as two, and in fact you can add one per Type C port + MagSafe, so you can have up to 5 battery backups for the 2021 Macbook Pro line (internal + MagSafe + 3 x Type C).

It's silly, but you can :-)

  • I never considered Mac Laptops as they are not vulnerable to data loss in case of a power outage. How is the situation with Mac Minis which don't have a battery? Are there multiple redundant power input the Mac Mini can switch in-between without tuning of?

    • There aren't; you'd have to hack that in. It should be possible, though, since I think the entire system is powered from a single primary 12V rail internally.

      1 reply →

This means the world would be full of complaints from macOS users, but for some reason, we only know about this detail because of that “shocking” Twitter thread.

  •     #!/usr/bin/python
        import os, sys, time, datetime
    
        t = datetime.datetime.now().isoformat()
    
        print(t)
        for i in range(5):
            time.sleep(1)
            print(4 - i)
    
        fd = os.open(sys.argv[1], os.O_RDWR|os.O_CREAT)
        os.lseek(fd, 0, 0)
        os.write(fd, b"test: " + t.encode("ascii") + b"\n");
        os.fsync(fd)
        print("done!")
        time.sleep(100)
    

    Run that on a Mac Mini. Do it a couple times. Remember the timestamp of the last one. Let it count down, then pull the plug within a few seconds after "done!" shows up. Boot up again. The file contents will have reverted to a prior point in time.

    This isn't some hypothetical thing, this is a trivial test you can do. fsync() on macOS does not guarantee data is on stable storage. And this is actually well documented.

    Then if you want to see the performance problem, make it a loop instead and use `fcntl.fcntl(fd, fcntl.F_FULLFSYNC, 1)`. You'll get 40-odd IOPS, but at least your data won't disappear after power loss.

  • Looking at the Apple support forums, the world is full of complaints about all sorts of malfunctions (which may or may not be related).