pg_test_fsync file descriptor leak
The open_datasync code opens the output file as a test to make sure the
flags are accepted by the OS, and if it succeeds it then immediately opens
the file again with the same flags, overwriting and so leaking the
descriptor from the previous open.
On Windows MinGW, this prevents the final unlink from working, as the file
is still open.
Trivial fix attached.
Thanks,
Jeff
Attachments:
pg_test_fsync_leak.patchapplication/octet-stream; name=pg_test_fsync_leak.patchDownload
diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/contrib/pg_test_fsync/pg_test_fsync.c
new file mode 100644
index 3352f04..c842762
*** a/contrib/pg_test_fsync/pg_test_fsync.c
--- b/contrib/pg_test_fsync/pg_test_fsync.c
*************** test_sync(int writes_per_op)
*** 258,265 ****
}
else
{
- if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1)
- die("could not open output file");
START_TIMER;
for (ops = 0; alarm_triggered == false; ops++)
{
--- 258,263 ----
On Tue, Nov 18, 2014 at 3:41 PM, Jeff Janes <jeff.janes@gmail.com> wrote:
The open_datasync code opens the output file as a test to make sure the
flags are accepted by the OS, and if it succeeds it then immediately opens
the file again with the same flags, overwriting and so leaking the
descriptor from the previous open.On Windows MinGW, this prevents the final unlink from working, as the file
is still open.Trivial fix attached.
Committed and back-patched to 9.1. Thanks.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers