mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Remove ipcclean utility command --- didn't work on all Unixes and on
Windows. Users should use their operating system tools instead.
This commit is contained in:
parent
fe11719c2e
commit
39627b1ae6
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.72 2007/08/21 21:08:47 tgl Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.73 2008/03/27 17:24:16 momjian Exp $
|
||||
PostgreSQL documentation
|
||||
Complete list of usable sgml source files in this directory.
|
||||
-->
|
||||
@ -145,7 +145,6 @@ Complete list of usable sgml source files in this directory.
|
||||
<!entity dropuser system "dropuser.sgml">
|
||||
<!entity ecpgRef system "ecpg-ref.sgml">
|
||||
<!entity initdb system "initdb.sgml">
|
||||
<!entity ipcclean system "ipcclean.sgml">
|
||||
<!entity pgConfig system "pg_config-ref.sgml">
|
||||
<!entity pgControldata system "pg_controldata.sgml">
|
||||
<!entity pgCtl system "pg_ctl-ref.sgml">
|
||||
|
@ -1,70 +0,0 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/ipcclean.sgml,v 1.14 2007/01/31 23:26:04 momjian Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
<refentry id="APP-IPCCLEAN">
|
||||
<refmeta>
|
||||
<refentrytitle id="APP-IPCCLEAN-TITLE"><application>ipcclean</application></refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo>Application</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>ipcclean</refname>
|
||||
<refpurpose>remove shared memory and semaphores from a failed <productname>PostgreSQL</productname> server</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<indexterm zone="app-ipcclean">
|
||||
<primary>ipcclean</primary>
|
||||
</indexterm>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>ipcclean</command>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id="R1-APP-IPCCLEAN-1">
|
||||
<title>Description</title>
|
||||
<para>
|
||||
<command>ipcclean</command> removes all shared memory segments and
|
||||
semaphore sets owned by the current user. It is intended to be
|
||||
used for cleaning up after a crashed
|
||||
<productname>PostgreSQL</productname> server (<xref
|
||||
linkend="app-postgres">). Note that immediately restarting the
|
||||
server will also clean up shared memory and semaphores, so this
|
||||
command is of little real utility.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Only the database administrator should execute this program as it
|
||||
can cause bizarre behavior (i.e., crashes) if run during multiuser
|
||||
execution. If this command is executed while a server is running,
|
||||
the shared memory and semaphores allocated by that server will be
|
||||
deleted, which would have rather severe consequences for that
|
||||
server.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Notes</title>
|
||||
|
||||
<para>
|
||||
This script is a hack, but in the many years since it was written,
|
||||
no one has come up with an equally effective and portable solution.
|
||||
Since <command>postgres</command> can now clean up by
|
||||
itself, it is unlikely that <command>ipcclean</command> will be
|
||||
improved upon in the future.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The script makes assumptions about the output format of the
|
||||
<command>ipcs</command>
|
||||
utility which might not be true across different operating systems.
|
||||
Therefore, it might not work on your particular OS. It's wise to
|
||||
look at the script before trying it.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.65 2007/08/21 21:08:47 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.66 2008/03/27 17:24:16 momjian Exp $ -->
|
||||
|
||||
<part id="reference">
|
||||
<title>Reference</title>
|
||||
@ -211,7 +211,6 @@
|
||||
</partintro>
|
||||
|
||||
&initdb;
|
||||
&ipcclean;
|
||||
&pgControldata;
|
||||
&pgCtl;
|
||||
&pgResetxlog;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.166 2008/01/03 21:23:15 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.167 2008/03/27 17:24:16 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -841,8 +841,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
id1, id2),
|
||||
errhint("If you're sure there are no old "
|
||||
"server processes still running, remove "
|
||||
"the shared memory block with "
|
||||
"the command \"ipcclean\", \"ipcrm\", "
|
||||
"the shared memory block "
|
||||
"or just delete the file \"%s\".",
|
||||
filename)));
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/bin/Makefile,v 1.52 2008/03/18 16:24:50 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/bin/Makefile,v 1.53 2008/03/27 17:24:16 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -13,7 +13,7 @@ subdir = src/bin
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
DIRS = initdb ipcclean pg_ctl pg_dump \
|
||||
DIRS = initdb pg_ctl pg_dump \
|
||||
psql scripts pg_config pg_controldata pg_resetxlog
|
||||
ifeq ($(PORTNAME), win32)
|
||||
DIRS+=pgevent
|
||||
|
@ -1,32 +0,0 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile for src/bin/ipcclean
|
||||
#
|
||||
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/bin/ipcclean/Makefile,v 1.22 2008/01/01 19:45:55 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
subdir = src/bin/ipcclean
|
||||
top_builddir = ../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
all: ipcclean
|
||||
|
||||
ipcclean: ipcclean.sh
|
||||
cp $< $@
|
||||
chmod a+x $@
|
||||
|
||||
install: all installdirs
|
||||
$(INSTALL_SCRIPT) ipcclean '$(DESTDIR)$(bindir)/ipcclean'
|
||||
|
||||
installdirs:
|
||||
$(mkinstalldirs) '$(DESTDIR)$(bindir)'
|
||||
|
||||
uninstall:
|
||||
rm -f '$(DESTDIR)$(bindir)/ipcclean'
|
||||
|
||||
clean distclean maintainer-clean:
|
||||
rm -f ipcclean
|
@ -1,116 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/bin/ipcclean/ipcclean.sh,v 1.18 2006/03/03 21:52:37 momjian Exp $
|
||||
#
|
||||
|
||||
CMDNAME=`basename $0`
|
||||
|
||||
if [ "$1" = '-?' -o "$1" = "--help" ]; then
|
||||
echo "$CMDNAME cleans up shared memory and semaphores from aborted PostgreSQL"
|
||||
echo "backends."
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo " $CMDNAME"
|
||||
echo
|
||||
echo "Note: Since the utilities underlying this script are very different"
|
||||
echo "from platform to platform, chances are that it might not work on"
|
||||
echo "yours. If that is the case, please write to <pgsql-bugs@postgresql.org>"
|
||||
echo "so that your platform can be supported in the future."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# test for running as root
|
||||
|
||||
ISROOT="N"
|
||||
if id -u >/dev/null 2>&1
|
||||
then if [ `id -u` -eq 0 ]
|
||||
then ISROOT="Y"
|
||||
fi
|
||||
elif # only check $LOGNAME if $USER is not set
|
||||
[ "$USER" = 'root' -o \( ! "$USER" -a "$LOGNAME" = 'root' \) ]
|
||||
then ISROOT="Y"
|
||||
fi
|
||||
|
||||
if [ "$ISROOT" = "Y" ]
|
||||
then
|
||||
(
|
||||
echo "$CMDNAME: cannot be run as root" 1>&2
|
||||
echo "Please log in (using, e.g., \"su\") as the (unprivileged) user that" 1>&2
|
||||
echo "owned the server process." 1>&2
|
||||
) 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
|
||||
|
||||
#-----------------------------------
|
||||
# List of platform-specific hacks
|
||||
# Feel free to add yours here.
|
||||
#-----------------------------------
|
||||
#
|
||||
# This is based on RedHat 5.2.
|
||||
#
|
||||
if [ `uname` = 'Linux' ]; then
|
||||
did_anything=
|
||||
|
||||
if ps x | grep -s '[p]ostmaster' >/dev/null 2>&1 ; then
|
||||
echo "$CMDNAME: a postmaster is still running" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shared memory
|
||||
for val in `ipcs -m -p | grep '^[0-9]' | awk '{printf "%s:%s:%s\n", $1, $3, $4}'`
|
||||
do
|
||||
save_IFS=$IFS
|
||||
IFS=:
|
||||
set X $val
|
||||
shift
|
||||
IFS=$save_IFS
|
||||
ipcs_shmid=$1
|
||||
ipcs_cpid=$2
|
||||
ipcs_lpid=$3
|
||||
|
||||
# Note: We can do -n here, because we know the platform.
|
||||
echo -n "Shared memory $ipcs_shmid ... "
|
||||
|
||||
# Don't do anything if process still running.
|
||||
# (This check is conceptually phony, but it's
|
||||
# useful anyway in practice.)
|
||||
ps hj $ipcs_cpid $ipcs_lpid >/dev/null 2>&1
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "skipped; process still exists (pid $ipcs_cpid or $ipcs_lpid)."
|
||||
continue
|
||||
fi
|
||||
|
||||
# try remove
|
||||
ipcrm shm $ipcs_shmid
|
||||
if [ "$?" -eq 0 ]; then
|
||||
did_anything=t
|
||||
else
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
# semaphores
|
||||
for val in `ipcs -s -c | grep '^[0-9]' | awk '{printf "%s\n", $1}'`; do
|
||||
echo -n "Semaphore $val ... "
|
||||
# try remove
|
||||
ipcrm sem $val
|
||||
if [ "$?" -eq 0 ]; then
|
||||
did_anything=t
|
||||
else
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
[ -z "$did_anything" ] && echo "$CMDNAME: nothing removed" && exit 1
|
||||
exit 0
|
||||
fi # end Linux
|
||||
|
||||
|
||||
# This is the original implementation. It seems to work
|
||||
# on FreeBSD, SunOS/Solaris, HP-UX, IRIX, and probably
|
||||
# some others.
|
||||
|
||||
ipcs | egrep '^m .*|^s .*' | egrep "$EffectiveUser" | \
|
||||
awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' | sh
|
Loading…
Reference in New Issue
Block a user