[Pkg-openldap-devel] Re: Bug#255276: slapd/slapcat hang in endless loops

Steve Langasek vorlon@debian.org
Wed, 25 May 2005 17:02:42 -0700


--mvpLiMfbWzRoNl4x
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, May 25, 2005 at 11:26:03PM +0800, Eugene Konev wrote:

>  On Mon, 23 May 2005 17:11:44 +0200
>  you wrote:

>  TL> Looks like we should do that after bazillions of people requested it.
>  TL> Any suggestions how to implement this correctly?

> The attached patch adds calling db4.2_recover to slapd.init on every
> slapd startup.

Are there any objections to applying this patch for sarge?

--=20
Steve Langasek
postmodern programmer

> diff -Nru openldap2.2-2.2.23/debian/slapd.init openldap2.2-hack/debian/sl=
apd.init
> --- openldap2.2-2.2.23/debian/slapd.init	2005-05-24 19:42:21.000000000 +0=
800
> +++ openldap2.2-hack/debian/slapd.init	2005-05-25 23:15:35.000000000 +0800
> @@ -48,6 +48,10 @@
>  		"$SLAPD_CONF"`
>  fi
> =20
> +# Find out slapd db directories
> +SLAPD_DBDIRS=3D`sed -ne 's/^directory[[:space:]]\+"*\([^"]\+\).*/\1/p' \
> +                "$SLAPD_CONF" `
> +=09
>  # XXX: Breaks upgrading if there is no pidfile (invoke-rc.d stop will fa=
il)
>  # -- Torsten
>  if [ -z "$SLAPD_PIDFILE" ]; then
> @@ -107,6 +111,24 @@
>  }
> =20
> =20
> +# Try to recover slapd database
> +try_fix_db() {
> +	if [ "$SLAPD_TRYFIXDB" !=3D yes -o \
> +	      -z "$SLAPD_DBDIRS" ]; then
> +		return 0
> +	fi
> +	echo -n " (possibly) fixing db,"
> +	for DBDIR in $SLAPD_DBDIRS; do
> +	    if [ -d "$DBDIR" -a -f "$DBDIR/objectClass.bdb" ]; then
> +		db4.2_recover -eh $DBDIR 2>&1
> +		if [ $? -ne 0 ]; then
> +		    reason=3D"Automatic recovery of slapd database failed. You will ne=
ed to perform recovery by hand, possibly from backup."
> +		    exit 1
> +		fi
> +	    fi
> +	done
> +}
> +
>  # Start the slapd daemon and capture the error message if any to=20
>  # $reason.
>  start_slapd() {
> @@ -157,6 +179,7 @@
>  start() {
>  	echo -n "Starting OpenLDAP:"
>  	trap 'report_failure' 0
> +	try_fix_db
>  	start_slapd
>  	start_slurpd
>  	trap "-" 0


--mvpLiMfbWzRoNl4x
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFClRIiKN6ufymYLloRAmDnAKCNI0pvLHBfa1+Q4M8cgxx5/DCWyQCeMtJ2
PGhNOiYkn22TYXKqWp75Y5E=
=BNlG
-----END PGP SIGNATURE-----

--mvpLiMfbWzRoNl4x--