- /* If a key was set, use shared memory for the BDB environment */
- if ( bdb->bi_shm_key ) {
- bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
- flags |= DB_SYSTEM_MEM;
+ /*
+ * The DB_CONFIG file may have changed. If so, recover the
+ * database so that new settings are put into effect. Also
+ * note the possible absence of DB_CONFIG in the log.
+ */
+ if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
+ if ( !do_recover ) {
+ char *ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
+ *ptr++ = LDAP_DIRSEP[0];
+ strcpy( ptr, "__db.001" );
+ if( stat( path, &stat2 ) == 0 ) {
+ if( stat2.st_mtime < stat1.st_mtime ) {
+ Debug( LDAP_DEBUG_ANY,
+ LDAP_XSTRING(bdb_db_open) ": DB_CONFIG for suffix \"%s\" has changed.\n",
+ be->be_suffix[0].bv_val, 0, 0 );
+ if ( quick ) {
+ Debug( LDAP_DEBUG_ANY,
+ "Cannot use Quick mode; perform manual recovery first.\n",
+ 0, 0, 0 );
+ slapMode ^= SLAP_TOOL_QUICK;
+ rc = -1;
+ goto fail;
+ } else {
+ Debug( LDAP_DEBUG_ANY,
+ "Performing database recovery to activate new settings.\n",
+ 0, 0, 0 );
+ }
+ do_recover = DB_RECOVER;
+ }
+ }
+ }
+ }
+ else {
+ Debug( LDAP_DEBUG_ANY,
+ LDAP_XSTRING(bdb_db_open) ": warning - no DB_CONFIG file found "
+ "in directory %s: (%d).\n"
+ "Expect poor performance for suffix \"%s\".\n",
+ bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );