improve tracking of maxxfuid

do it when the corresponding expiration events are logged/replayed.
that makes it unnecessary to log it separately just to make the
autotest happy.
This commit is contained in:
Oswald Buddenhagen 2021-12-10 20:56:36 +01:00
parent 0f6362f2e2
commit 61b08880c8
3 changed files with 4 additions and 15 deletions

View File

@ -932,7 +932,6 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
svars->oldmaxuid[F] = svars->maxuid[F]; svars->oldmaxuid[F] = svars->maxuid[F];
svars->oldmaxuid[N] = svars->maxuid[N]; svars->oldmaxuid[N] = svars->maxuid[N];
svars->oldmaxxfuid = svars->maxxfuid;
info( "Synchronizing...\n" ); info( "Synchronizing...\n" );
for (t = 0; t < 2; t++) for (t = 0; t < 2; t++)
@ -1201,8 +1200,6 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
/* The message is excess or was already (being) expired. */ /* The message is excess or was already (being) expired. */
srec->status |= S_NEXPIRE; srec->status |= S_NEXPIRE;
debug( " pair(%u,%u) expired\n", srec->uid[F], srec->uid[N] ); debug( " pair(%u,%u) expired\n", srec->uid[F], srec->uid[N] );
if (svars->maxxfuid < srec->uid[F])
svars->maxxfuid = srec->uid[F];
todel--; todel--;
} }
} }
@ -1505,6 +1502,8 @@ flags_set_p2( sync_vars_t *svars, sync_rec_t *srec, int t )
if (t == N) { if (t == N) {
uchar nex = (srec->status / S_NEXPIRE) & 1; uchar nex = (srec->status / S_NEXPIRE) & 1;
if (nex != ((srec->status / S_EXPIRED) & 1)) { if (nex != ((srec->status / S_EXPIRED) & 1)) {
if (nex && svars->maxxfuid < srec->uid[F])
svars->maxxfuid = srec->uid[F];
srec->status = (srec->status & ~S_EXPIRED) | (nex * S_EXPIRED); srec->status = (srec->status & ~S_EXPIRED) | (nex * S_EXPIRED);
JLOG( "~ %u %u %d", (srec->uid[F], srec->uid[N], srec->status & S_LOGGED), JLOG( "~ %u %u %d", (srec->uid[F], srec->uid[N], srec->status & S_LOGGED),
"expired %d - commit", nex ); "expired %d - commit", nex );
@ -1728,12 +1727,6 @@ box_closed_p2( sync_vars_t *svars, int t )
} }
} }
// This is just an optimization, so it needs no journaling of intermediate states.
// However, doing it before the entry purge would require ensuring that the
// exception list includes all relevant messages.
if (svars->maxxfuid != svars->oldmaxxfuid)
JLOG( "! %u", svars->maxxfuid, "max expired UID on far side" );
save_state( svars ); save_state( svars );
sync_bail( svars ); sync_bail( svars );

View File

@ -61,7 +61,6 @@ typedef struct {
uint newuidval[2]; // UID validity obtained from driver uint newuidval[2]; // UID validity obtained from driver
uint finduid[2]; // TUID lookup makes sense only for UIDs >= this uint finduid[2]; // TUID lookup makes sense only for UIDs >= this
uint maxxfuid; // highest expired UID on far side uint maxxfuid; // highest expired UID on far side
uint oldmaxxfuid; // highest expired UID on far side before this run
uchar good_flags[2], bad_flags[2]; uchar good_flags[2], bad_flags[2];
} sync_vars_t; } sync_vars_t;

View File

@ -286,9 +286,6 @@ load_state( sync_vars_t *svars )
tn = 0; tn = 0;
bad = (sscanf( buf + 2, "%u %u %n", &t1, &t2, &tn ) < 2) || !tn || (ll - (uint)tn != TUIDL + 2); bad = (sscanf( buf + 2, "%u %u %n", &t1, &t2, &tn ) < 2) || !tn || (ll - (uint)tn != TUIDL + 2);
break; break;
case '!':
bad = sscanf( buf + 2, "%u", &t1 ) != 1;
break;
case 'N': case 'N':
case 'F': case 'F':
case 'T': case 'T':
@ -324,8 +321,6 @@ load_state( sync_vars_t *svars )
svars->finduid[t1] = t2; svars->finduid[t1] = t2;
} else if (c == 'T') { } else if (c == 'T') {
*uint_array_append( &svars->trashed_msgs[t1] ) = t2; *uint_array_append( &svars->trashed_msgs[t1] ) = t2;
} else if (c == '!') {
svars->maxxfuid = t1;
} else if (c == '|') { } else if (c == '|') {
svars->uidval[F] = t1; svars->uidval[F] = t1;
svars->uidval[N] = t2; svars->uidval[N] = t2;
@ -387,6 +382,8 @@ load_state( sync_vars_t *svars )
break; break;
case '~': case '~':
srec->status = (srec->status & ~S_LOGGED) | t3; srec->status = (srec->status & ~S_LOGGED) | t3;
if ((srec->status & S_EXPIRED) && svars->maxxfuid < srec->uid[F])
svars->maxxfuid = srec->uid[F];
debug( "status now %#x\n", srec->status ); debug( "status now %#x\n", srec->status );
break; break;
case '_': case '_':