mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-27 18:19:52 -05:00
Fix replog sequencing - assign sequence numbers at beginning of operation,
instead of getting a timestamp at the end. This makes it possible for slurpd to sort the log later.
This commit is contained in:
parent
c7da63df3d
commit
d31230f859
10 changed files with 48 additions and 15 deletions
|
|
@ -308,6 +308,7 @@ do_add( Operation *op, SlapReply *rs )
|
|||
#endif /* LDAP_SLAPI */
|
||||
|
||||
op->ora_e = e;
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_add)( op, rs ) == 0 ) {
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
if ( !repl_user )
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ do_delete(
|
|||
slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
|
||||
}
|
||||
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_delete)( op, rs ) == 0 ) {
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
|
||||
|
|
|
|||
|
|
@ -498,6 +498,7 @@ do_modify(
|
|||
}
|
||||
|
||||
op->orm_modlist = modlist;
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_modify)( op, rs ) == 0
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
&& !repl_user
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ do_modrdn(
|
|||
#endif
|
||||
{
|
||||
op->orr_deleteoldrdn = deloldrdn;
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_modrdn)( op, rs ) == 0
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
&& ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ int passwd_extop(
|
|||
NULL, 0 );
|
||||
|
||||
if ( rs->sr_err == LDAP_SUCCESS ) {
|
||||
repstamp( op );
|
||||
rs->sr_err = op2.o_bd->be_modify( &op2, rs );
|
||||
}
|
||||
if ( rs->sr_err == LDAP_SUCCESS ) {
|
||||
|
|
|
|||
|
|
@ -913,6 +913,7 @@ LDAP_SLAPD_F (int) add_replica_suffix LDAP_P(( Backend *be,
|
|||
LDAP_SLAPD_F (int) add_replica_attrs LDAP_P(( Backend *be,
|
||||
int nr, char *attrs, int exclude ));
|
||||
LDAP_SLAPD_F (void) replog LDAP_P(( Operation *op ));
|
||||
LDAP_SLAPD_F (void) repstamp LDAP_P(( Operation *op ));
|
||||
|
||||
/*
|
||||
* result.c
|
||||
|
|
|
|||
|
|
@ -116,10 +116,30 @@ add_replica_attrs(
|
|||
return ( be->be_replica[nr]->ri_attrs == NULL );
|
||||
}
|
||||
|
||||
static struct timestamp {
|
||||
long time;
|
||||
long seq;
|
||||
} oldstamp;
|
||||
|
||||
static void
|
||||
print_vals( FILE *fp, struct berval *type, struct berval *bv );
|
||||
static void
|
||||
replog1( struct slap_replica_info *ri, Operation *op, FILE *fp, long now);
|
||||
replog1( struct slap_replica_info *ri, Operation *op, FILE *fp );
|
||||
|
||||
void
|
||||
repstamp( Operation *op )
|
||||
{
|
||||
ldap_pvt_thread_mutex_lock( &replog_mutex );
|
||||
op->o_time = slap_get_time();
|
||||
if ( op->o_time == oldstamp.time ) {
|
||||
op->o_tseq = ++oldstamp.seq;
|
||||
} else {
|
||||
oldstamp.time = op->o_time;
|
||||
oldstamp.seq = 0;
|
||||
op->o_tseq = 0;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &replog_mutex );
|
||||
}
|
||||
|
||||
void
|
||||
replog( Operation *op )
|
||||
|
|
@ -133,7 +153,6 @@ replog( Operation *op )
|
|||
int count = 0;
|
||||
#endif
|
||||
int subsets = 0;
|
||||
long now = slap_get_time();
|
||||
|
||||
if ( op->o_bd->be_replogfile == NULL && replogfile == NULL ) {
|
||||
return;
|
||||
|
|
@ -189,7 +208,7 @@ replog( Operation *op )
|
|||
}
|
||||
#endif
|
||||
|
||||
replog1( NULL, op, fp, now );
|
||||
replog1( NULL, op, fp );
|
||||
|
||||
if ( subsets > 0 ) {
|
||||
for ( i = subsets - 1; op->o_bd->be_replica[i] != NULL; i++ ) {
|
||||
|
|
@ -226,7 +245,7 @@ replog( Operation *op )
|
|||
/* Other operations were logged in the first pass */
|
||||
continue;
|
||||
}
|
||||
replog1( op->o_bd->be_replica[i], op, fp, now );
|
||||
replog1( op->o_bd->be_replica[i], op, fp );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,14 +257,13 @@ static void
|
|||
rephdr(
|
||||
struct slap_replica_info *ri,
|
||||
Operation *op,
|
||||
FILE *fp,
|
||||
long now
|
||||
FILE *fp
|
||||
)
|
||||
{
|
||||
if ( ri ) {
|
||||
fprintf( fp, "replica: %s\n", ri->ri_host );
|
||||
}
|
||||
fprintf( fp, "time: %ld\n", now );
|
||||
fprintf( fp, "time: %ld.%ld\n", op->o_time, op->o_tseq );
|
||||
fprintf( fp, "dn: %s\n", op->o_req_dn.bv_val );
|
||||
}
|
||||
|
||||
|
|
@ -253,8 +271,7 @@ static void
|
|||
replog1(
|
||||
struct slap_replica_info *ri,
|
||||
Operation *op,
|
||||
FILE *fp,
|
||||
long now
|
||||
FILE *fp
|
||||
)
|
||||
{
|
||||
Modifications *ml;
|
||||
|
|
@ -328,7 +345,7 @@ replog1(
|
|||
/* Found a match, log it */
|
||||
if ( match ) {
|
||||
if ( dohdr ) {
|
||||
rephdr( ri, op, fp, now );
|
||||
rephdr( ri, op, fp );
|
||||
fprintf( fp, "changetype: modify\n" );
|
||||
dohdr = 0;
|
||||
}
|
||||
|
|
@ -352,7 +369,7 @@ replog1(
|
|||
}
|
||||
}
|
||||
if ( dohdr ) {
|
||||
rephdr( ri, op, fp, now );
|
||||
rephdr( ri, op, fp );
|
||||
fprintf( fp, "changetype: modify\n" );
|
||||
dohdr = 0;
|
||||
}
|
||||
|
|
@ -400,7 +417,7 @@ replog1(
|
|||
match ^= ri->ri_exclude;
|
||||
if ( match ) {
|
||||
if ( dohdr ) {
|
||||
rephdr( ri, op, fp, now );
|
||||
rephdr( ri, op, fp );
|
||||
fprintf( fp, "changetype: add\n" );
|
||||
dohdr = 0;
|
||||
}
|
||||
|
|
@ -412,7 +429,7 @@ replog1(
|
|||
}
|
||||
}
|
||||
if ( dohdr ) {
|
||||
rephdr( ri, op, fp, now );
|
||||
rephdr( ri, op, fp );
|
||||
fprintf( fp, "changetype: add\n" );
|
||||
dohdr = 0;
|
||||
}
|
||||
|
|
@ -421,12 +438,12 @@ replog1(
|
|||
break;
|
||||
|
||||
case LDAP_REQ_DELETE:
|
||||
rephdr( ri, op, fp, now );
|
||||
rephdr( ri, op, fp );
|
||||
fprintf( fp, "changetype: delete\n" );
|
||||
break;
|
||||
|
||||
case LDAP_REQ_MODRDN:
|
||||
rephdr( ri, op, fp, now );
|
||||
rephdr( ri, op, fp );
|
||||
fprintf( fp, "changetype: modrdn\n" );
|
||||
fprintf( fp, "newrdn: %s\n", op->orr_newrdn.bv_val );
|
||||
fprintf( fp, "deleteoldrdn: %d\n", op->orr_deleteoldrdn ? 1 : 0 );
|
||||
|
|
|
|||
|
|
@ -1904,6 +1904,7 @@ typedef struct slap_op {
|
|||
ber_int_t o_protocol; /* version of the LDAP protocol used by client */
|
||||
ber_tag_t o_tag; /* tag of the request */
|
||||
time_t o_time; /* time op was initiated */
|
||||
long o_tseq; /* time/sequence number */
|
||||
|
||||
struct berval o_req_dn; /* DN of target of request */
|
||||
struct berval o_req_ndn;
|
||||
|
|
|
|||
|
|
@ -559,6 +559,7 @@ slapi_delete_internal(
|
|||
if ( op->o_bd->be_delete ) {
|
||||
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
|
||||
if ( log_change ) repstamp( op );
|
||||
if ( (*op->o_bd->be_delete)( op, &rs ) == 0 ) {
|
||||
if ( log_change ) {
|
||||
replog( op );
|
||||
|
|
@ -640,6 +641,7 @@ slapi_add_entry_internal_locked(
|
|||
if ( op->o_bd->be_add ) {
|
||||
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
|
||||
if ( log_changes ) repstamp( op );
|
||||
if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) {
|
||||
if ( log_changes ) {
|
||||
replog( op );
|
||||
|
|
@ -832,6 +834,7 @@ slapi_modrdn_internal(
|
|||
if ( op->o_bd->be_modrdn ) {
|
||||
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
|
||||
if ( log_change ) repstamp( op );
|
||||
if ( (*op->o_bd->be_modrdn)( op, &rs ) == 0 ) {
|
||||
if ( log_change ) {
|
||||
replog( op );
|
||||
|
|
@ -1044,6 +1047,7 @@ slapi_modify_internal(
|
|||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if ( log_change ) repstamp( op );
|
||||
if ( (*op->o_bd->be_modify)( op, &rs ) == 0 ) {
|
||||
if ( log_change ) {
|
||||
replog( op );
|
||||
|
|
|
|||
|
|
@ -194,6 +194,11 @@ const char * connection_state2str( int state )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void repstamp( Operation *op )
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void replog( Operation *op )
|
||||
{
|
||||
assert(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue