| 139 | } |
| 140 | |
| 141 | func (e *Engine) commitAttempt(materialized materializedState, epoch, commitSeq, attemptID uint64) error { |
| 142 | if e == nil { |
| 143 | return fmt.Errorf("chartengine: nil engine") |
| 144 | } |
| 145 | e.mu.Lock() |
| 146 | defer e.mu.Unlock() |
| 147 | |
| 148 | if e.state.outstanding != attemptID || e.state.outstanding == 0 { |
| 149 | return ErrStalePlanAttempt |
| 150 | } |
| 151 | if e.state.engineEpoch != epoch || e.state.commitSeq != commitSeq { |
| 152 | e.state.outstanding = 0 |
| 153 | return ErrStalePlanAttempt |
| 154 | } |
| 155 | |
| 156 | e.state.materialized = materialized |
| 157 | e.state.commitSeq++ |
| 158 | e.state.outstanding = 0 |
| 159 | return nil |
| 160 | } |
| 161 | |
| 162 | func (e *Engine) abortAttempt(attemptID uint64) { |
| 163 | if e == nil { |