The following code change submitted in your patch for PostgreSQL is incorrect.
File: src/backend/utils/init/postinit.c
...
static void
ShutdownPostgres(int code, Datum arg)
{
if (!IsBootstrapProcessingMode() && code == 0) {
shutdownTrigger = true;
StartTransactionCommand();
ExecTriggerSpecial(TRIGGER_TYPE_SHUTDOWN);
CommitTransactionCommand();
}
...
The reason it is incorrect is that during a shut down of the backend via a
FATAL or PANIC failure, the user will almost certainly be in a transaction of
some sort and therefore "StartTransactionCommand();" fails with message:
"StartTransactionCommand: unexpected state STARTED".
I am not sure of the correct solution here but I assume you are expecting no
transaction abort state when "code == 0". I think a better solution would be:
if (!IsBootstrapProcessingMode() && code == 0 &&
!IsTransactionOrTransactionBlock()) {
Regards
Donald Fraser.