diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 598906ad64..0773287e59 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -1920,7 +1920,17 @@ sub connect_ok
 	if (@log_like or @log_unlike)
 	{
 		# Don't let previous log entries match for this connection.
-		truncate $self->logfile, 0;
+		# On Windows, the truncation would not work, so rotate the log
+		# file before restarting the server afresh.
+		if ($TestLib::windows_os)
+		{
+			$self->rotate_logfile;
+			$self->restart;
+		}
+		else
+		{
+			truncate $self->logfile, 0;
+		}
 	}
 
 	# Never prompt for a password, any callers of this routine should
@@ -1994,7 +2004,17 @@ sub connect_fails
 	if (@log_like or @log_unlike)
 	{
 		# Don't let previous log entries match for this connection.
-		truncate $self->logfile, 0;
+		# On Windows, the truncation would not work, so rotate the log
+		# file before restarting the server afresh.
+		if ($TestLib::windows_os)
+		{
+			$self->rotate_logfile;
+			$self->restart;
+		}
+		else
+		{
+			truncate $self->logfile, 0;
+		}
 	}
 
 	# Never prompt for a password, any callers of this routine should
@@ -2175,7 +2195,9 @@ Run a command on the node, then verify that $expected_sql appears in the
 server log file.
 
 Reads the whole log file so be careful when working with large log outputs.
-The log file is truncated prior to running the command, however.
+The log file is truncated prior to running the command, however.  On Windows,
+the truncation would not work, so rotate to a new log file and restart the
+server.
 
 =cut
 
@@ -2187,7 +2209,16 @@ sub issues_sql_like
 
 	local %ENV = $self->_get_env();
 
-	truncate $self->logfile, 0;
+	if ($TestLib::windows_os)
+	{
+		$self->rotate_logfile;
+		$self->restart;
+	}
+	else
+	{
+		truncate $self->logfile, 0;
+	}
+
 	my $result = TestLib::run_log($cmd);
 	ok($result, "@$cmd exit code 0");
 	my $log = TestLib::slurp_file($self->logfile);
