Add some test scaffolding to allow cache-flush stress testing (and I do
authorTom Lane <[email protected]>
Thu, 19 Jan 2006 21:49:30 +0000 (21:49 +0000)
committerTom Lane <[email protected]>
Thu, 19 Jan 2006 21:49:30 +0000 (21:49 +0000)
mean stress ... system is orders of magnitude slower with this enabled).

src/backend/utils/cache/inval.c

index e09bb385dd8ca62c7204f98691c25d110686f119..a8046468a3caeeb8280753dbf2e061a9493a9276 100644 (file)
@@ -625,6 +625,36 @@ AcceptInvalidationMessages(void)
 {
        ReceiveSharedInvalidMessages(LocalExecuteInvalidationMessage,
                                                                 InvalidateSystemCaches);
+
+       /*
+        * Test code to force cache flushes anytime a flush could happen.
+        *
+        * If used with CLOBBER_FREED_MEMORY, CLOBBER_CACHE_ALWAYS provides a
+        * fairly thorough test that the system contains no cache-flush hazards.
+        * However, it also makes the system unbelievably slow --- the regression
+        * tests take about 100 times longer than normal.
+        *
+        * If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY.
+        * This slows things by at least a factor of 10000, so I wouldn't suggest
+        * trying to run the entire regression tests that way.  It's useful to
+        * try a few simple tests, to make sure that cache reload isn't subject
+        * to internal cache-flush hazards, but after you've done a few thousand
+        * recursive reloads it's unlikely you'll learn more.
+        */
+#if defined(CLOBBER_CACHE_ALWAYS)
+       {
+               static bool in_recursion = false;
+
+               if (!in_recursion)
+               {
+                       in_recursion = true;
+                       InvalidateSystemCaches();
+                       in_recursion = false;
+               }
+       }
+#elif defined(CLOBBER_CACHE_RECURSIVELY)
+       InvalidateSystemCaches();
+#endif
 }
 
 /*