diff --git a/CHANGES b/CHANGES
index a24e6803752abb0eb57e02284a6c440fa6289b4c..6dc78b000ed809fcc60c2db47e5d41dcd88dea24 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@ OpenLDAP 2.4.15 Engineering
 	Fixed libldap GnuTLS compilation (ITS#5955)
 	Fixed slapd corrupt contextCSN (ITS#5947)
 	Fixed slapd syncrepl order to match on add/delete (ITS#5954)
+	Fixed slapd-bdb/hdb behavior with unallocatable shm (ITS#5956)
 	Fixed slapo-rwm objectClass preservation (ITS#5760)
 	Build Environment
 		Fixed tester library linking for windows (ITS#5740)
diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c
index ab1fa16a4445490324de27f6d157c3d7013a1abe..a029fee3c8266d843572705cc1de94c5944a3a1a 100644
--- a/servers/slapd/back-bdb/init.c
+++ b/servers/slapd/back-bdb/init.c
@@ -111,6 +111,7 @@ bdb_db_open( BackendDB *be, ConfigReply *cr )
 	Entry *e = NULL;
 	int do_recover = 0, do_alock_recover = 0;
 	int alockt, quick = 0;
+	int do_retry = 1;
 
 	if ( be->be_suffix == NULL ) {
 		Debug( LDAP_DEBUG_ANY,
@@ -335,11 +336,12 @@ shm_retry:
 		if ( !do_recover && bdb->bi_shm_key ) {
 			bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
 			rc = db_env_create( &bdb->bi_dbenv, 0 );
-			if( rc == 0 ) {
+			if( rc == 0 && do_retry ) {
 				Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_db_open)
 					": database \"%s\": "
 					"shared memory env open failed, assuming stale env.\n",
 					be->be_suffix[0].bv_val, 0, 0 );
+				do_retry = 0;
 				goto shm_retry;
 			}
 		}