Documentation ¶
Overview ¶
Package lifecycle contains the code to run and manage the lifecycle of a postgres Instance
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresLifecycle ¶
type PostgresLifecycle struct {
// contains filtered or unexported fields
}
PostgresLifecycle implements the manager.Runnable interface for a postgres.Instance
func NewPostgres ¶
func NewPostgres( ctx context.Context, instance *postgres.Instance, initialization concurrency.MultipleExecuted, ) *PostgresLifecycle
NewPostgres creates a new PostgresLifecycle
func (*PostgresLifecycle) GetGlobalContext ¶
func (i *PostgresLifecycle) GetGlobalContext() context.Context
GetGlobalContext returns the PostgresLifecycle's context
type PostgresOrphansReaper ¶ added in v1.15.1
type PostgresOrphansReaper struct {
// contains filtered or unexported fields
}
PostgresOrphansReaper implements the Runnable interface and handles orphaned postmaster child processes.
We are running as PID 1 in our container and we may receive SIGCHLD for the following reasons:
1 - a child process we manually executed via `exec.Cmd` (i.e. the postmaster) exited 2 - a postmaster worker process terminated after the postmaster itself
The second condition may seem unlikely but it unfortunately happens everytime the postmaster ends, even if just for the logging collector subprocess.
As we can see in the postgres codebase (see 1) the logging collector process will ignore any termination signal sent by the postmaster and just wait for every upstream process to be gone. This is why it will terminate after the postmaster and we'll receive a SIGCHLD.
If we don't collect the logging collector exit code we would get a zombie process everytime we restart the postmaster.
Anyway, if we just accept any SIGCHLD signal, we would break the internals of `os.exec.Command` preventing the detection of the exit code of the child process.
This is why our zombie reaper works only for processes whose executable is `postgres`.
func NewPostgresOrphansReaper ¶ added in v1.15.1
func NewPostgresOrphansReaper(instance *postgres.Instance) *PostgresOrphansReaper
NewPostgresOrphansReaper returns a new PostgresOrphansReaper for an instance