Skip to content

Commit

Permalink
Properly handle error cases in mutable state (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxing1292 authored Oct 16, 2019
1 parent f72adc5 commit cbf1d4a
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 152 deletions.
4 changes: 3 additions & 1 deletion common/cache/domainCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const (
domainCacheMaxSize = 64 * 1024
domainCacheTTL = 0 // 0 means infinity
// DomainCacheRefreshInterval domain cache refresh interval
DomainCacheRefreshInterval = 10 * time.Second
DomainCacheRefreshInterval = 10 * time.Second
// DomainCacheRefreshFailureRetryInterval is the wait time
// if refreshment encounters error
DomainCacheRefreshFailureRetryInterval = 1 * time.Second
domainCacheRefreshPageSize = 200

Expand Down
47 changes: 11 additions & 36 deletions service/history/MockMutableState.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,50 +1254,16 @@ func (_m *mockMutableState) CreateTransientDecisionEvents(_a0 *decisionInfo, _a1
return r0, r1
}

// DeleteActivity provides a mock function with given fields: _a0
func (_m *mockMutableState) DeleteActivity(_a0 int64) error {
ret := _m.Called(_a0)

var r0 error
if rf, ok := ret.Get(0).(func(int64) error); ok {
r0 = rf(_a0)
} else {
r0 = ret.Error(0)
}

return r0
}

// DeleteDecision provides a mock function with given fields:
func (_m *mockMutableState) DeleteDecision() {
_m.Called()
}

// DeletePendingChildExecution provides a mock function with given fields: _a0
func (_m *mockMutableState) DeletePendingChildExecution(_a0 int64) {
_m.Called(_a0)
}

// DeletePendingRequestCancel provides a mock function with given fields: _a0
func (_m *mockMutableState) DeletePendingRequestCancel(_a0 int64) {
_m.Called(_a0)
}

// DeletePendingSignal provides a mock function with given fields: _a0
func (_m *mockMutableState) DeletePendingSignal(_a0 int64) {
_m.Called(_a0)
}

// DeleteSignalRequested provides a mock function with given fields: requestID
func (_m *mockMutableState) DeleteSignalRequested(requestID string) {
_m.Called(requestID)
}

// DeleteUserTimer provides a mock function with given fields: _a0
func (_m *mockMutableState) DeleteUserTimer(_a0 string) {
_m.Called(_a0)
}

// FailDecision provides a mock function with given fields: _a0
func (_m *mockMutableState) FailDecision(_a0 bool) {
_m.Called(_a0)
Expand Down Expand Up @@ -2875,8 +2841,17 @@ func (_m *mockMutableState) UpdateReplicationStateVersion(_a0 int64, _a1 bool) {
}

// UpdateUserTimer provides a mock function with given fields: _a0, _a1
func (_m *mockMutableState) UpdateUserTimer(_a0 string, _a1 *persistence.TimerInfo) {
_m.Called(_a0, _a1)
func (_m *mockMutableState) UpdateUserTimer(_a0 string, _a1 *persistence.TimerInfo) error {
ret := _m.Called(_a0, _a1)

var r0 error
if rf, ok := ret.Get(0).(func(string, *persistence.TimerInfo) error); ok {
r0 = rf(_a0, _a1)
} else {
r0 = ret.Error(0)
}

return r0
}

// UpdateCurrentVersion provides a mock function with given fields: _a0, _a1
Expand Down
6 changes: 5 additions & 1 deletion service/history/historyReplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ func (r *historyReplicator) SyncActivity(
timeSource := clock.NewEventTimeSource()
timeSource.Update(now)
timerBuilder := newTimerBuilder(timeSource)
if tt := timerBuilder.GetActivityTimerTaskIfNeeded(msBuilder); tt != nil {
tt, err := timerBuilder.GetActivityTimerTaskIfNeeded(msBuilder)
if err != nil {
return err
}
if tt != nil {
timerTasks = append(timerTasks, tt)
}

Expand Down
7 changes: 1 addition & 6 deletions service/history/mutableState.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,8 @@ type (
CreateNewHistoryEvent(eventType workflow.EventType) *workflow.HistoryEvent
CreateNewHistoryEventWithTimestamp(eventType workflow.EventType, timestamp int64) *workflow.HistoryEvent
CreateTransientDecisionEvents(di *decisionInfo, identity string) (*workflow.HistoryEvent, *workflow.HistoryEvent)
DeleteActivity(int64) error
DeleteDecision()
DeletePendingChildExecution(int64)
DeletePendingRequestCancel(int64)
DeleteSignalRequested(requestID string)
DeletePendingSignal(int64)
DeleteUserTimer(string)
FailDecision(bool)
FlushBufferedEvents() error
GetActivityByActivityID(string) (*persistence.ActivityInfo, bool)
Expand Down Expand Up @@ -218,7 +213,7 @@ type (
UpdateDecision(*decisionInfo)
UpdateReplicationStateVersion(int64, bool)
UpdateReplicationStateLastEventID(int64, int64)
UpdateUserTimer(string, *persistence.TimerInfo)
UpdateUserTimer(string, *persistence.TimerInfo) error
UpdateCurrentVersion(version int64, forceUpdate bool) error
UpdateWorkflowStateCloseStatus(state int, closeStatus int) error

Expand Down
Loading

0 comments on commit cbf1d4a

Please sign in to comment.