Skip to content

durable: a host read of the instance clock during a step is journaled but can't be replayed #247

Open

Description

@reka18

What happens

state.Instance.Clock() is exported. A durable Handle's instance uses the Handle's recording clock, so when host code reads it during a step, for example an action that calls h.Instance().Clock().Now(), the read is journaled with the step's own. Recover can't make that read again: no Handle exists during replay, so the host code can't reach the replay clock. Each later replayed read then takes the reading after the one it should have, and the timers that step and later steps arm come back at the wrong deadlines.

Reproduction: TestRecover_ReplaysAStepWhoseHostCodeReadTheInstanceClock in durable/chained_deadline_internal_test.go (skipped with a pointer to this issue). An action on the transition into a timed state reads the instance clock. Live, the timer is armed at 1.001s. After Recover, it's armed at 1.000s.

Possible fix

The kernel never reads the clock; only the Scheduler does, and it takes the instance's clock. Give the scheduler durable's recording clock, and the instance an unrecorded one for host code, through an additive state option such as NewScheduler(inst, WithSchedulerClock(c)). Host reads are then not journaled, and replay stays aligned whatever host code reads.

Context: found while reviewing #234. It predates #234, and isn't one of #214's items.

Relates to: #214, #234

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions