diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index b1bcd93345dacd459c73e548198d48f7e5c90e17..21ae8531b3ccb4974cde2c09580e519c63a289af 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -1386,7 +1386,8 @@ RestoreSlotFromDisk(const char *name)
 
 	elog(DEBUG1, "restoring replication slot from \"%s\"", path);
 
-	fd = OpenTransientFile(path, O_RDONLY | PG_BINARY);
+	/* on some operating systems fsyncing a file requires O_RDWR */
+	fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
 
 	/*
 	 * We do not need to handle this as we are rename()ing the directory into