diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 537d92c0cf..570d2d2557 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -1219,11 +1219,13 @@ CreateLockFile(const char *filename, bool amPostmaster,
 		/*
 		 * Couldn't create the pid file. Probably it already exists.
 		 */
-		if ((errno != EEXIST && errno != EACCES) || ntries > 100)
+		if ((errno != EEXIST && errno != EACCES) || ntries > 10)
+{
 			ereport(FATAL,
 					(errcode_for_file_access(),
-					 errmsg("could not create lock file \"%s\": %m",
-							filename)));
+					 errmsg("could not create lock file (ntries: %d) \"%s\": %m",
+							ntries, filename)));
+}
 
 		/*
 		 * Read the file to get the old owner's PID.  Note race condition
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 6295783cde..583ed7d449 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -1479,7 +1479,7 @@ stop_standby_server(const char *datadir)
 	char	   *pg_ctl_cmd;
 	int			rc;
 
-	pg_ctl_cmd = psprintf("\"%s\" stop -D \"%s\" -s", pg_ctl_path,
+	pg_ctl_cmd = psprintf("\"%s\" stop -D \"%s\" ", pg_ctl_path,
 						  datadir);
 	pg_log_debug("pg_ctl command is: %s", pg_ctl_cmd);
 	rc = system(pg_ctl_cmd);
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index e7e878c22f..04787c6aec 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -276,6 +276,9 @@ get_pgpid(bool is_status_request)
 	pidf = fopen(pid_file, "r");
 	if (pidf == NULL)
 	{
+int en = errno;
+write_stderr("!!!get_pgpid| pid_file: %s, pidf: %p, errno: %d\n", pid_file, pidf, en);
+errno = en;
 		/* No pid file, not an error on startup */
 		if (errno == ENOENT)
 			return 0;
@@ -723,7 +726,10 @@ wait_for_postmaster_stop(void)
 		pid_t		pid;
 
 		if ((pid = get_pgpid(false)) == 0)
+{
+write_stderr("!!!wait_for_postmaster_stop| pid: %d\n", pid);
 			return true;		/* pid file is gone */
+}
 
 		if (kill(pid, 0) != 0)
 		{
diff --git a/src/port/open.c b/src/port/open.c
index 13e49af8d4..f7cbc819c0 100644
--- a/src/port/open.c
+++ b/src/port/open.c
@@ -138,8 +138,14 @@ pgwin32_open_handle(const char *fileName, int fileFlags, bool backup_semantics)
 		 * invisible.  With O_CREAT, we have no choice but to report that
 		 * there's a file in the way (which wouldn't happen on Unix).
 		 */
+DWORD ntstat = pg_RtlGetLastNtStatus();
+if (strstr(fileName, "postmaster.pid") != NULL)
+{
+fprintf(stderr, "!!!pgwin32_open_handle| fileFlags: %X, err: %d, ntstatus: %X\n", fileFlags, err, ntstat);
+}
+
 		if (err == ERROR_ACCESS_DENIED &&
-			pg_RtlGetLastNtStatus() == STATUS_DELETE_PENDING)
+			ntstat == STATUS_DELETE_PENDING)
 		{
 			if (fileFlags & O_CREAT)
 				err = ERROR_FILE_EXISTS;
@@ -214,6 +220,12 @@ pgwin32_fopen(const char *fileName, const char *mode)
 		openmode |= O_TEXT;
 
 	fd = pgwin32_open(fileName, openmode);
+if (strstr(fileName, "postmaster.pid") != NULL)
+{
+int en = errno;
+fprintf(stderr, "!!!pgwin32_fopen| fileName: %s, fd: %d, errno: %d\n", fileName, fd, en);
+errno = en;
+}
 	if (fd == -1)
 		return NULL;
 	return _fdopen(fd, mode);
