MCPcopy Create free account
hub / github.com/apache/cloudberry / ShutdownPostgres

Function ShutdownPostgres

src/backend/utils/init/postinit.c:1629–1658  ·  view source on GitHub ↗

* 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 *

Source from the content-addressed store, hash-verified

1627 * cleanup fails.
1628 */
1629static void
1630ShutdownPostgres(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/*

Callers

nothing calls this directly

Calls 5

AbortOutOfAnyTransactionFunction · 0.85
GPMemoryProtect_ShutdownFunction · 0.85
SessionState_ShutdownFunction · 0.85
LockReleaseAllFunction · 0.85
TerminateGPOPTFunction · 0.50

Tested by

no test coverage detected