* Backend-shutdown callback. Do cleanup that we want to be sure happens * before all the supporting modules begin to nail their doors shut via * their own callbacks. * * User-level cleanup, such as temp-relation removal and UNLISTEN, happens * via separate callbacks that execute before this one. We don't combine the * callbacks because we still want this one to happen if the user-level *
| 1627 | * cleanup fails. |
| 1628 | */ |
| 1629 | static void |
| 1630 | ShutdownPostgres(int code, Datum arg) |
| 1631 | { |
| 1632 | /* Make sure we've killed any active transaction */ |
| 1633 | AbortOutOfAnyTransaction(); |
| 1634 | |
| 1635 | /* |
| 1636 | * If there was a segment OOM for which we haven't already reported |
| 1637 | * our usage, report now. |
| 1638 | */ |
| 1639 | ReportOOMConsumption(); |
| 1640 | |
| 1641 | #ifdef USE_ORCA |
| 1642 | TerminateGPOPT(); |
| 1643 | |
| 1644 | if (OptimizerMemoryContext != NULL) |
| 1645 | MemoryContextDelete(OptimizerMemoryContext); |
| 1646 | #endif |
| 1647 | |
| 1648 | /* Disable memory protection */ |
| 1649 | GPMemoryProtect_Shutdown(); |
| 1650 | /* Release SessionState entry */ |
| 1651 | SessionState_Shutdown(); |
| 1652 | |
| 1653 | /* |
| 1654 | * User locks are not released by transaction end, so be sure to release |
| 1655 | * them explicitly. |
| 1656 | */ |
| 1657 | LockReleaseAll(USER_LOCKMETHOD, true); |
| 1658 | } |
| 1659 | |
| 1660 | |
| 1661 | /* |
nothing calls this directly
no test coverage detected