diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index b4f65902914df441ad00bda365a4d1981ee4e781..1ba4946cd361e994ca1a7265dce4bcac45604fa8 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -2648,18 +2648,15 @@ pre_sync_fname(const char *fname, bool isdir, int elevel)
 	{
 		if (errno == EACCES || (isdir && errno == EISDIR))
 			return;
-
-#ifdef ETXTBSY
-		if (errno == ETXTBSY)
-			return;
-#endif
-
 		ereport(elevel,
 				(errcode_for_file_access(),
 				 errmsg("could not open file \"%s\": %m", fname)));
 		return;
 	}
 
+	/*
+	 * We ignore errors from pg_flush_data() because this is only a hint.
+	 */
 	(void) pg_flush_data(fd, 0, 0);
 
 	(void) CloseTransientFile(fd);
@@ -2703,12 +2700,6 @@ fsync_fname_ext(const char *fname, bool isdir, int elevel)
 	{
 		if (errno == EACCES || (isdir && errno == EISDIR))
 			return;
-
-#ifdef ETXTBSY
-		if (errno == ETXTBSY)
-			return;
-#endif
-
 		ereport(elevel,
 				(errcode_for_file_access(),
 				 errmsg("could not open file \"%s\": %m", fname)));
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index f0d66fa12e3c9b90c9fc3cb5b41d8e13275b512f..6a73e9688bc069d5e7688a6a235dc8e29f4665be 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -619,12 +619,6 @@ pre_sync_fname(const char *fname, bool isdir)
 	{
 		if (errno == EACCES || (isdir && errno == EISDIR))
 			return;
-
-#ifdef ETXTBSY
-		if (errno == ETXTBSY)
-			return;
-#endif
-
 		fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
 				progname, fname, strerror(errno));
 		return;
@@ -684,12 +678,6 @@ fsync_fname_ext(const char *fname, bool isdir)
 	{
 		if (errno == EACCES || (isdir && errno == EISDIR))
 			return;
-
-#ifdef ETXTBSY
-		if (errno == ETXTBSY)
-			return;
-#endif
-
 		fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
 				progname, fname, strerror(errno));
 		return;