WARNING

This text was automatically converted from troff me macros to HTML. Information may have been lost, added, or changed in the process. Lars Aronsson and Lysator do not guarantee the correctness of this HTML document.

NAME

shmemdoc - POSTGRES shared memory doctor

SYNOPSIS

shmemdoc [ "-p port" ] [ "-B nbuffers" ]

DESCRIPTION

The shmemdoc program understands the layout of POSTGRES data in shared memory, and can be used to examine shared structures. This program is intended only for debugging POSTGRES, and should not be used in normal operation.

When some backend dies abnormally, the postmaster normally reinitializes shared memory and semaphores, and forces all peers of the dead backend to exit. If the postmaster is started with the -n flag, then shared memory will not be reinitialized, and shmemdoc can be used to examine shared state after the crash.

A simple command interpreter reads user commands from standard input and prints results on standard output. The available commands, and their actions, are:

"semstat" Show the status of system semaphores. Status includes semaphore names and values, the process id of the last process to change each semaphore, and a count of processes sleeping on each semaphore.

"semset n val" Set the value of semaphore number n (with zero being the first semaphore named by semstat ) to val . This is really only useful for resetting system state maually after a crash, and you don't want to do it.

"bufdescs" Print the contents of the shared buffer descriptor table.

"bufdesc n" Print the shared buffer descriptor table entry for buffer n .

"buffer n type level" Print the contents of buffer number n in the shared buffer table. The buffer is interpreted as a page from a type relation, where type may be heap , btree , or rtree . The level argument controls the amount of detail presented. Level zero prints only page headers, level one prints page headers and line pointer tables, and level two (or higher) prints headers, line pointer tables, and tuples.

"linp n which" Print line pointer table entry which of buffer n .

"tuple n type which" Print tuple which of buffer n . The buffer is interpreted as a page from a type relation, where type may be heap , btree , or rtree .

"setbase ptr" Set the logical base address of shared memory for shmemdoc to ptr . Normally, shmemdoc uses the address of each structure in its own address space when interpreting commands and printing results. If setbase is used, then on input and output, addresses are translated so that the shared memory segment appears to start at address ptr .

This is useful when a debugger is examining a core file produced by POSTGRES and you want to use the shared memory addresses that appear in the core file. The base of shared memory in POSTGRES is stored in the variable ShmemBase , which may be examined by a debugger.

Ptr may be expressed in octal (leading zero), decimal, or hexadecimal (leading 0x).

"shmemstat" Print shared memory layout and allocation statistics.

"whatis ptrP" Identify the shared memory structure pointed at by ptr .

help Print a brief command summary.

quit Exit shmemdoc .

ARGUMENTS

"-B nbuffers" The number of buffers used by the backend. This value is ignored in the present implementation of shmemdoc , but is important if you choose to change the number allocated by POSTGRES. In that case, you're out of luck for now.

"-p port" The port on which the postmaster was listening. This value is used to compute the shared memory key used by the postmaster when shared memory was initialized.

BUGS

Probably doesn't work on anything but DECstations.

All of the sizes, offsets, and values for shared data are hardwired into this program; it shares no code with the ordinary POSTGRES system, so changes to shared memory layout will require changes to this program, as well.