Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit efbe674

Browse files
committed
Add some test scaffolding to allow cache-flush stress testing (and I do
mean stress ... system is orders of magnitude slower with this enabled).
1 parent 248c9bd commit efbe674

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/backend/utils/cache/inval.c

+31-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* Portions Copyright (c) 1994, Regents of the University of California
8181
*
8282
* IDENTIFICATION
83-
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.74 2005/11/22 18:17:24 momjian Exp $
83+
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.75 2006/01/19 21:49:21 tgl Exp $
8484
*
8585
*-------------------------------------------------------------------------
8686
*/
@@ -625,6 +625,36 @@ AcceptInvalidationMessages(void)
625625
{
626626
ReceiveSharedInvalidMessages(LocalExecuteInvalidationMessage,
627627
InvalidateSystemCaches);
628+
629+
/*
630+
* Test code to force cache flushes anytime a flush could happen.
631+
*
632+
* If used with CLOBBER_FREED_MEMORY, CLOBBER_CACHE_ALWAYS provides a
633+
* fairly thorough test that the system contains no cache-flush hazards.
634+
* However, it also makes the system unbelievably slow --- the regression
635+
* tests take about 100 times longer than normal.
636+
*
637+
* If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY.
638+
* This slows things by at least a factor of 10000, so I wouldn't suggest
639+
* trying to run the entire regression tests that way. It's useful to
640+
* try a few simple tests, to make sure that cache reload isn't subject
641+
* to internal cache-flush hazards, but after you've done a few thousand
642+
* recursive reloads it's unlikely you'll learn more.
643+
*/
644+
#if defined(CLOBBER_CACHE_ALWAYS)
645+
{
646+
static bool in_recursion = false;
647+
648+
if (!in_recursion)
649+
{
650+
in_recursion = true;
651+
InvalidateSystemCaches();
652+
in_recursion = false;
653+
}
654+
}
655+
#elif defined(CLOBBER_CACHE_RECURSIVELY)
656+
InvalidateSystemCaches();
657+
#endif
628658
}
629659

630660
/*

0 commit comments

Comments
 (0)