Use Joe's suggested change to u3_pier_snap().
@@ -524,33 +524,11 @@ _pier_work_save(u3_pier* pir_u)
u3_disk* log_u = pir_u->log_u;
u3_save* sav_u = pir_u->sav_u;
- // This is wrong? We can have requested that the worker should snapshot
- // between when the worker was given a compute request and when the worker
- // returns a compute response. (See the c3_max() call in u3_pier_snap().) I
- // don't know what the semantics are supposed to be here.
- //
- // Let's say we're in replay of the event log from nothing. We might have
- // u3_pier_snap() called from a timer. I've seen crashes when:
- //
- // god_u->dun_d: 24, sav_u->req_d: 25, log_u->com_d: 31
- //
- // com_d is greater than req_d is greater than dun_d because we're waiting
- // for the worker to complete replay of already committed events. And this
- // seems OK because we can totally request that the worker produce a snapshot
- // of event 25 even though we haven't marked it as done because we know that
- // it committed previously?
- //
- // No! This breaks because it ignores the req_d and instead tells the worker
- // to go with what was req_d.
- //
- // c3_assert( god_u->dun_d == sav_u->req_d );
-
+ c3_assert( god_u->dun_d == sav_u->req_d );
c3_assert( log_u->com_d >= god_u->dun_d );
{
- // TODO: Verify change to req_d is correct during code review.
- //
- u3_noun mat = u3ke_jam(u3nc(c3__save, u3i_chubs(1, &sav_u->req_d)));
+ u3_noun mat = u3ke_jam(u3nc(c3__save, u3i_chubs(1, &god_u->dun_d)));
u3_newt_write(&god_u->inn_u, mat, 0);
// XX wait on some report of success before updating?
@@ -1771,7 +1749,8 @@ u3_pier_snap(u3_pier* pir_u)
// save eagerly if all computed events are already committed
//
- if ( log_u->com_d >= top_d ) {
+ if ( (log_u->com_d >= top_d) &&
+ (god_u->dun_d == top_d) ) {
_pier_work_save(pir_u);
}
}
