BUG #16526: pg_test_fsync in v12 doesn't run in Windows

The Post Office <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: jeff.janes@gmail.com
Date: 2020-07-03T16:01:46Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16526
Logged by:          Jeff Janes
Email address:      jeff.janes@gmail.com
PostgreSQL version: 12.3
Operating system:   windows 2019
Description:        

When I install PG12 on Windows 10 using the EDB installer, pg_test_fsync
doesn't work.  But I notice Windows 10 is not officially supported, so I
repeated the exercise with EDB installer on a rented box: 
Microsoft Windows Server 2019 with Desktop Experience Locale English AMI
provided by Amazon

And it still doesn't work, see capture from CMD.exe done immediately after
running the EDB installer:

Microsoft Windows [Version 10.0.17763.1282]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\Administrator>"c:\Program
Files\PostgreSQL\12\bin\pg_test_fsync.exe"
5 seconds per test
O_DIRECT supported on this platform for open_datasync and open_sync.

Compare file sync methods using one 8kB write:
(in wal_sync_method preference order, except fdatasync is Linux's default)
        open_datasync                 pg_test_fsync: error: write failed:
Invalid argument

Note that it abandons the run here it does not just report an error and then
continue.
I'm not in a position to compile on Windows, so I can't run git bisect nor
tell if this is something specific to EDB.  But I suspect this rather has
something to do with commit 0ba06e0bfb8cfd24ff17aca92aa72245ddd6c4d7

On v11, this does work.  Or at least it runs to completion, I guess the
numbers reported might be bogus, which is why the indicated commit was done.

Commits

  1. Switch pg_test_fsync to use binary mode on Windows

  2. Allow concurrent-safe open() and fopen() in frontend code for Windows