From 002962dc7293043126561b0d0df79d6c76251804 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 1 Oct 2019 15:19:32 +0900 Subject: [PATCH] Fix test_session_hooks with parallel workers Several buildfarm machines have been complaining about the new module test_session_hooks to be unstable, like crake and thorntail. The issue was that the module was trying to log some start and end session activity for parallel workers, which makes little sense as they don't support DML, so just prevent this pattern to happen in the module. This could be reproduced by enforcing force_parallel_mode=regress, which is the value used by some of the buildfarm members. Discussion: https://postgr.es/m/20191001045246.GF2781@paquier.xyz --- src/test/modules/test_session_hooks/test_session_hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/modules/test_session_hooks/test_session_hooks.c b/src/test/modules/test_session_hooks/test_session_hooks.c index d047c5d219..a90c373c69 100644 --- a/src/test/modules/test_session_hooks/test_session_hooks.c +++ b/src/test/modules/test_session_hooks/test_session_hooks.c @@ -13,6 +13,7 @@ */ #include "postgres.h" +#include "access/parallel.h" #include "access/xact.h" #include "commands/dbcommands.h" #include "executor/spi.h" @@ -89,6 +90,10 @@ sample_session_start_hook(void) if (!OidIsValid(MyDatabaseId)) return; + /* no parallel workers */ + if (IsParallelWorker()) + return; + register_session_hook("START"); } @@ -107,6 +112,10 @@ sample_session_end_hook(void) if (!OidIsValid(MyDatabaseId)) return; + /* no parallel workers */ + if (IsParallelWorker()) + return; + register_session_hook("END"); }