Commit d794327a authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

WIP ITS#9823 Check minCSN when setting up delta-log replay

parent 954c1d1a
Pipeline #4261 passed with stage
in 36 minutes and 2 seconds
......@@ -3084,7 +3084,7 @@ syncprov_op_search( Operation *op, SlapReply *rs )
sync_control *srs;
BerVarray ctxcsn;
int i, *sids, numcsns;
struct berval mincsn, maxcsn;
struct berval mincsn, maxcsn, *vals;
int minsid, maxsid;
int dirty = 0;
......@@ -3340,6 +3340,41 @@ no_change: if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
numcsns, sids, &mincsn, minsid ) ) {
do_present = SS_PRESENT;
}
} else if ( si->si_nopres && si->si_usehint && backend_attribute( op,
NULL, &op->o_bd->be_nsuffix[0], ad_minCSN, &vals, ACL_NONE
) == LDAP_SUCCESS && vals ) {
/* We are instructed to trust minCSN and it exists, is it contained
* in our cookie? */
int *log_sids, log_numcsns;
log_numcsns = ldap_count_values_len( &vals );
log_sids = slap_parse_csn_sids( vals, log_numcsns, op->o_tmpmemctx );
slap_sort_csn_sids( vals, log_sids, log_numcsns, op->o_tmpmemctx );
for ( i=0, j=0; i<log_numcsns; i++ ) {
while ( j < numcsns && log_sids[i] > sids[j] ) j++;
if ( j < numcsns && log_sids[i] == sids[j] &&
ber_bvcmp( &vals[i], &srs->sr_state.ctxcsn[j] ) <= 0 ) {
/* minCSN for this serverID is contained, keep going */
continue;
}
/*
* Log BD's minCSN claims we can only replay from a certain
* CSN for this serverID, but consumer's cookie hasn't met that
* threshold: they need to refresh
*/
/* ITS#9580 FIXME: when we've figured out and split the
* sessionlog/deltalog tracking, check the appropriate
* attribute */
Debug( LDAP_DEBUG_SYNC, "%s syncprov_op_search: "
"consumer not within recorded mincsn for DB's mincsn=%s\n",
op->o_log_prefix, vals[i].bv_val );
rs->sr_err = LDAP_SYNC_REFRESH_REQUIRED;
rs->sr_text = "sync cookie is stale";
slap_sl_free( log_sids, op->o_tmpmemctx );
goto bailout;
}
slap_sl_free( log_sids, op->o_tmpmemctx );
}
/*
* If sessionlog wasn't useful, see if we can find at least one entry
......@@ -3785,6 +3820,7 @@ sp_cf_gen(ConfigArgs *c)
break;
case SP_USEHINT:
si->si_usehint = c->value_int;
rc = syncprov_setup_accesslog();
break;
case SP_LOGDB:
if ( si->si_logs ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment