}
 #endif
 
+       sprintf(buffer, "%08x ", time(0L));
        va_start( vl, fmt );
-       vsnprintf( buffer, sizeof(buffer), fmt, vl );
+       vsnprintf( buffer+9, sizeof(buffer)-9, fmt, vl );
        buffer[sizeof(buffer)-1] = '\0';
        if( log_file != NULL ) {
                fputs( buffer, log_file );
 
                AttributeDescription *ad = NULL;
                const char *text = NULL;
                Entry *e_ctx;
+               BackendDB db;
 
                e = entry_alloc();
                ber_dupbv( &e->e_name, li->li_db->be_suffix );
                        }
                        be_entry_release_rw( op, e_ctx, 0 );
                }
-               op->o_bd = li->li_db;
+               db = *li->li_db;
+               op->o_bd = &db;
 
                op->ora_e = e;
                op->o_req_dn = e->e_name;
                op->o_callback = &nullsc;
                SLAP_DBFLAGS( op->o_bd ) |= SLAP_DBFLAG_NOLASTMOD;
                rc = op->o_bd->be_add( op, &rs );
-               SLAP_DBFLAGS( op->o_bd ) ^= SLAP_DBFLAG_NOLASTMOD;
                if ( e == op->ora_e )
                        entry_free( e );
        }
 
                SYNCTYPE="type=refreshOnly interval=00:00:00:03"
                ;;
        rp)
-               SYNCTYPE="type=refreshAndPersist"
+               SYNCTYPE="type=refreshAndPersist interval=00:00:00:03"
                ;;
        *)
                echo "unknown sync mode $SYNCMODE"
        exit $RC
 fi
 
-echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
-sleep $SLEEP1
+THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
+sleep 1
+for i in 1 2 3; do
+       $LDAPSEARCH -S "" -b "$THEDN" -H $URI1 \
+               -s base '(objectClass=*)' entryCSN > "${MASTEROUT}.$i" 2>&1
+       RC=$?
+
+       if test $RC = 0 ; then
+               break
+       fi
+
+       if test $RC != 32 ; then
+               echo "ldapsearch failed at slave ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       fi
+
+       echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
+       sleep $SLEEP1
+done
 
 n=1
 while [ $n -le $MMR ]; do
 done
 
 echo "Using ldapmodify to force conflicts between server 1 and 2..."
-THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
        >> $TESTOUT 2>&1 << EOF
 dn: $THEDN