Does this help? From my fiddling with ITS#5340 (REP_ENTRY_MODIFIABLE). I do not understand syncprov's handling of REP_ENTRY_MUSTRELEASE though. (For one thing it seems to assume that REP_ENTRY_MUSTRELEASE is set if and only if rs.sr_entry->e_private != NULL. Which is possibly true with back-bdb but seems a shaky assumption in general.)
Index: syncprov.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/overlays/syncprov.c,v retrieving revision 1.227 diff -u -2 -r1.227 syncprov.c --- syncprov.c 3 Apr 2008 06:43:48 -0000 1.227 +++ syncprov.c 9 Apr 2008 10:29:40 -0000 @@ -2390,7 +2390,13 @@ if ( !ap ) { if ( !(rs->sr_flags & REP_ENTRY_MODIFIABLE) ) { - rs->sr_entry = entry_dup( rs->sr_entry ); - rs->sr_flags |= - REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED; + Entry *new = entry_dup( rs->sr_entry ); + if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) { + be_entry_release_r( op, rs->sr_entry ); + } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) { + entry_free( rs->sr_entry ); + } + rs->sr_entry = new; + rs->sr_flags = (rs->sr_flags & ~REP_ENTRY_MASK) | + REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED; a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_contextCSN );