Skip to main content

What is a Postmaster PID file in PostgreSQL?

 

  • As per the PostgreSQL architecture, the postmaster is the first background process that will starts when the cluster is started.
  • It is a parent process of all other background processes.
  • In case any of the other background processes got failed, The postmaster automatically restart the dead processes.
  • It also works as a listener. When the client’s request to the server first it will land into the postmaster and perform syntax and semantic checking, Once it is pass and spawn a new connection this process called “Pgprocess”.
  • The postmaster act as a listener well as the parent process, so it is also called “Supervision”.
ps -ef|grep postmasterpostgres 393 32729 0 22:28 pts/3 00:00:00 grep postmaster

Purpose of Postmaster PID file:

  • The postmaster PID file resides on the data directory when the cluster is up and running.
  • The purpose of this PID file uses to capture

1. the current postmaster process ID (PID),

2. cluster data directory path, postmaster start timestamp,

3. port number,

4. Unix domain socket directory path,

5. listen_address (IP address)

6. shared memory segment id.

  • The captured PID file details are being locked when the cluster was up and running. It protects to access the same port number or data directory for another cluster launch or running.
$cd $PGDATA$lsbase     pg_commit_ts  pg_ident.conf  pg_notify    pg_snapshots  pg_subtrans  PG_VERSION  postgresql.auto.conf  postmaster.pid
global pg_dynshmem pg_logical pg_replslot pg_stat pg_tblspc pg_wal postgresql.conf
logfile pg_hba.conf pg_multixact pg_serial pg_stat_tmp pg_twophase pg_xact postmaster.opts

To view the postmaster PID file:

$ cat postmaster.pid4693/u01/pgdatabase/data16156884855432/tmp*5432001 3604491ready

· Now I have just stopped my cluster services using pg_ctl

pg_ctl stop -mfwaiting for the server to shut down.... doneserver stopped

After the cluster is stopped of we verify that the postmaster PID file it was automatically disappeared from the data directory.

summary:

· The postmaster PID file will be generated automatically when the cluster services are up and running.

· It is a lock file that maintains the current cluster details i.e not allow to use of these details to run another cluster on the same port or data directory

Comments

Popular posts from this blog

PostgreSQL Vacuum and Vacuum full are not two different processes

  PostgreSQL’s   VACUUM   and   VACUUM FULL   are not separate processes but rather different operational modes of the same maintenance command. Here’s why: Core Implementation Both commands share the same underlying codebase and are executed through the  vacuum_rel()  function in PostgreSQL’s source code ( src/backend/commands/vacuum.c ). The key distinction lies in the  FULL  option, which triggers additional steps: Standard  VACUUM : Removes dead tuples (obsolete rows) and marks space reusable  within PostgreSQL Updates the visibility map to optimize future queries Runs concurrently with read/write operations VACUUM FULL : Rewrites the entire table into a new disk file, compressing it and reclaiming space for the  operating system Rebuilds all indexes and requires an  ACCESS EXCLUSIVE  lock, blocking other operations Key Differences in Behavior Aspect Standard VACUUM VACUUM FULL Space Reclamation Internal reuse onl...

PostgreSQL Health Check - Performance Audit and Recommendations

   PostgreSQL Server Capacity Planning and Optimization: Conduct a thorough assessment of current and projected workload demands on the database server's critical resources. This evaluation should cover key factors such as CPU utilization, RAM consumption, storage requirements, I/O performance, and network bandwidth usage. Consider both short-term fluctuations and long-term usage patterns to accurately forecast future needs and potential bottlenecks. Collect and analyze performance metrics over extended periods, including peak and off-peak hours, to gain a comprehensive understanding of server behavior. Use appropriate monitoring tools to gather detailed data on query execution times, resource utilization patterns, and system responsiveness under varying loads. Identify recurring performance issues, resource contention points, or capacity limitations that may affect the overall efficiency of the PostgreSQL environment. Based on this analysis, develop actionable recommendations...

PostgreSQL - Architecture

When you start PostgreSQL`s instance (via pg_ctl start) the main process of the databases is started. In the past versions it was known as the postmaster process and now days it is called postgres. When this processes is started it allocates memory for two main things : shared memory and other background processes. The shared memory is a memory that the database uses mainly for cashing. Its main goal is to reduce the I/O operations and as a result of that improve the performance of the database. The other processes that the postgres process starts are responsible for the ongoing work of the database.  PostgreSQL`s architecture is based on a client/server communication. In the server side there is a server process that manages the files, database operations, connection and so on.. On the client side there is a tool/program which can be a graphical tool (gui)  like pgAdmin or a command line tool(cli) like psql  that is repnsible for connection the database and all...