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
This commit is contained in:
Michael Paquier 2019-10-01 15:19:32 +09:00
parent e788bd924c
commit 002962dc72
1 changed files with 9 additions and 0 deletions

View File

@ -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");
}