Back end state transitions

The processing of workunits and results involves several independent activities. To keep track of these activities, workunit and result database records have several "state" fields, and their processing can be viewed as the combination of several finite-state machines.

A workunit has the following state fields:

Invariants:

A result has the following state fields:

Invariants:

A note on scheduling

- when is it feasible to send a result to a host? Request msg should include X = amount of work currently queued. TODO: include % time active in calculation?? Decision for each WU: is X + time for WUs sent so far < delay_bound? - When is a result declared "unsendable"? Not a good idea to do on the basis of time; do it only if a result is flushed from FIFO (see below)

State transitions


fields of "result" table:

server_state
    UNSENT
        (on creation)
    IN_PROGRESS
        from UNSENT
            scheduler: when send
    OVER
        from IN_PROGRESS
            scheduler: get reply from host
            timeout_check: now > report_deadline
        from UNSENT
            validate: got canonical result for this WU and server_state=UNSENT
            timeout_check: WU has error

file_delete_state
    INIT
        (on creation)
    READY
        from INIT:
            scheduler: got reply and server_state = OVER
            timeout_check: all results are OVER
            assimilator: all results are OVER or result is not canonical
        from DONE:
            scheduler: got reply and server_state = OVER
    DONE
        from READY
            file_deleter: tried to delete files

validate_state
    INIT
    VALID
        from INIT:
            validate: outcome = SUCCESS and matched canonical result
    INVALID
        from INIT:
            scheduler: got reply, client error
            validate: didn't match canonical result

-------------
fields of "workunit" table

need_validate
    FALSE
        (on creation)
        from TRUE:
            validate: done checking
    TRUE
        from FALSE:
            scheduler: got reply w/ client_state = DONE (i.e. no error)

file_delete_state
    INIT
        (on creation)
    READY
        timeout_check: all results haver server_state=OVER
            and wu.assimilate_state = DONE
        assimilate:
            all results have server_state = OVER
            (and wu.assimilate_state = DONE)
    DONE

assimilate_state
    INIT
        (on creation)
    READY
        from INIT:
            timeout_check: WU has error
            validate: found canonical result
    DONE
        from READY:
            assimilator: done

error_mask
    COULDNT_SEND
        timeout_check: some result has outcome COULDNT_SEND
    TOO_MANY_ERROR_RESULTS
        timeout_check: too many error results
    TOO_MANY_RESULTS
        timeout_check: too many results

timeout_check_time:
    nonzero
        (on creation)
    zero
        timeout_check: all results are OVER and validate_state = DONE