diff --git a/build-farm.conf.sample b/build-farm.conf.sample
index 7e80451..d7e6a62 100644
--- a/build-farm.conf.sample
+++ b/build-farm.conf.sample
@@ -98,6 +98,11 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__));
 		  --leak-check=no --gen-suppressions=all   --error-limit=no}
 	),
 
+	# if true run tests with debug_invalidate_system_caches_always=1, or
+	# the equivalent on older branches.  Do not set CLOBBER_CACHE_ALWAYS
+	# if you use this.
+	use_clobber_cache => undef,
+
 	# path to directory with auxiliary web script
 	# if relative, the must be relative to buildroot/branch
 	# Now only used on older Msys installations
diff --git a/run_build.pl b/run_build.pl
index 9ed6056..5c945b0 100755
--- a/run_build.pl
+++ b/run_build.pl
@@ -178,6 +178,7 @@ my (
 	$wait_timeout,              $use_accache,
 	$use_valgrind,              $valgrind_options,
 	$use_installcheck_parallel, $max_load_avg,
+	$use_clobber_cache,
 	$archive_reports
   )
   = @PGBuild::conf{
@@ -186,7 +187,7 @@ my (
 	  use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob
 	  ccache_failure_remove wait_timeout use_accache
 	  use_valgrind valgrind_options use_installcheck_parallel max_load_avg
-	  archive_reports)
+	  use_clobber_cache archive_reports)
   };
 
 $ts_prefix = sprintf('%s:%-13s ', $animal, $branch);
@@ -651,6 +652,19 @@ if ($extra_config && $extra_config->{DEFAULT})
 	}
 }
 
+if ($use_clobber_cache && ($branch eq 'HEAD' || $branch ge 'REL_14'))
+{
+    if (!exists $extra_config->{$branch})
+    {
+	$extra_config->{$branch} = ["debug_invalidate_system_caches_always = 1"];
+    }
+    else
+    {
+	push(@{ $extra_config->{$branch} },
+	     "debug_invalidate_system_caches_always = 1");
+    }
+}
+
 if ($extra_config && $extra_config->{$branch})
 {
 	my $tmpname = "$tmpdir/bfextra.conf";
@@ -1340,9 +1354,15 @@ sub initdb
 
 	chdir $installdir;
 
+	my $initdbopts = qq{-A trust -U buildfarm --locale=$locale};
+
+	if ($use_clobber_cache && ($branch eq 'HEAD' || $branch ge 'REL_14'))
+	{
+	    $initdbopts .= " --clobber-cache";
+	}
+
 	@initout =
-	  run_log(
-		qq{"bin/initdb" -A trust -U buildfarm --locale=$locale data-$locale});
+	  run_log(qq{"bin/initdb" $initdbopts data-$locale});
 
 	my $status = $? >> 8;
 
@@ -2370,6 +2390,17 @@ sub configure
 			}
 		}
 	}
+	if ($use_clobber_cache && $branch ne 'HEAD' && $branch lt 'REL_14')
+	{
+	    if (defined $env->{CPPFLAGS})
+	    {
+		$env->{CPPFLAGS} .= " -DCLOBBER_CACHE_ALWAYS";
+	    }
+	    else
+	    {
+		$env->{CPPFLAGS} = "-DCLOBBER_CACHE_ALWAYS";
+	    }
+	}
 
 	my $envstr = "";
 	while (my ($key, $val) = each %$env)
