Skip to content

Commit

Permalink
Fix missing start time in executions table (cadence-workflow#2687)
Browse files Browse the repository at this point in the history
  • Loading branch information
yux0 authored and wxing1292 committed Oct 18, 2019
1 parent a6e1211 commit 1da0ebf
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 42 deletions.
6 changes: 3 additions & 3 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type (
taskAllocator taskAllocator
replicator *historyReplicator
nDCReplicator nDCHistoryReplicator
activityReplicator activityReplicator
nDCactivityReplicator nDCActivityReplicator
replicatorProcessor ReplicatorQueueProcessor
historyEventNotifier historyEventNotifier
tokenSerializer common.TaskTokenSerializer
Expand Down Expand Up @@ -209,7 +209,7 @@ func NewEngineWithShardContext(
historyEngImpl.eventsReapplier,
logger,
)
historyEngImpl.activityReplicator = newActivityReplicator(
historyEngImpl.nDCactivityReplicator = newNDCActivityReplicator(
shard,
historyCache,
logger,
Expand Down Expand Up @@ -1970,7 +1970,7 @@ func (e *historyEngineImpl) SyncActivity(
request *h.SyncActivityRequest,
) (retError error) {

return e.activityReplicator.SyncActivity(ctx, request)
return e.nDCactivityReplicator.SyncActivity(ctx, request)
}

func (e *historyEngineImpl) ResetWorkflowExecution(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -copyright_file ../../LICENSE -package $GOPACKAGE -source $GOFILE -destination activityReplicator_mock.go
//go:generate mockgen -copyright_file ../../LICENSE -package $GOPACKAGE -source $GOFILE -destination nDCActivityReplicator_mock.go

package history

Expand All @@ -39,34 +39,34 @@ import (
)

type (
activityReplicator interface {
nDCActivityReplicator interface {
SyncActivity(
ctx ctx.Context,
request *h.SyncActivityRequest,
) error
}

activityReplicatorImpl struct {
nDCActivityReplicatorImpl struct {
historyCache *historyCache
clusterMetadata cluster.Metadata
logger log.Logger
}
)

func newActivityReplicator(
func newNDCActivityReplicator(
shard ShardContext,
historyCache *historyCache,
logger log.Logger,
) *activityReplicatorImpl {
) *nDCActivityReplicatorImpl {

return &activityReplicatorImpl{
return &nDCActivityReplicatorImpl{
historyCache: historyCache,
clusterMetadata: shard.GetService().GetClusterMetadata(),
logger: logger.WithTags(tag.ComponentHistoryReplicator),
}
}

func (r *activityReplicatorImpl) SyncActivity(
func (r *nDCActivityReplicatorImpl) SyncActivity(
ctx ctx.Context,
request *h.SyncActivityRequest,
) (retError error) {
Expand Down Expand Up @@ -189,7 +189,7 @@ func (r *activityReplicatorImpl) SyncActivity(
return context.updateWorkflowExecutionAsPassive(now)
}

func (r *activityReplicatorImpl) shouldApplySyncActivity(
func (r *nDCActivityReplicatorImpl) shouldApplySyncActivity(
domainID string,
workflowID string,
runID string,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type (
mockTimerProcessor *MockTimerQueueProcessor
historyCache *historyCache

activityReplicator activityReplicator
nDCActivityReplicator nDCActivityReplicator
}
)

Expand Down Expand Up @@ -152,7 +152,7 @@ func (s *activityReplicatorSuite) SetupTest() {
}
s.mockShard.SetEngine(engine)

s.activityReplicator = newActivityReplicator(
s.nDCActivityReplicator = newNDCActivityReplicator(
s.mockShard,
s.historyCache,
s.logger,
Expand Down Expand Up @@ -207,7 +207,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_WorkflowNotFound() {
), nil,
)

err := s.activityReplicator.SyncActivity(ctx.Background(), request)
err := s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -256,7 +256,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_WorkflowClosed() {
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -313,7 +313,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_IncomingScheduleIDLarger_Inco
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -370,7 +370,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_IncomingScheduleIDLarger_Inco
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Equal(newRetryTaskErrorWithHint(ErrRetrySyncActivityMsg, domainID, workflowID, runID, nextEventID), err)
}

Expand Down Expand Up @@ -449,7 +449,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_VersionHistories_IncomingVers
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -527,7 +527,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_DifferentVersionHistories_Inc
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Equal(newNDCRetryTaskErrorWithHint(
domainID,
workflowID,
Expand Down Expand Up @@ -619,7 +619,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_VersionHistories_IncomingSche
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Equal(newNDCRetryTaskErrorWithHint(
domainID,
workflowID,
Expand Down Expand Up @@ -708,7 +708,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_VersionHistories_SameSchedule
), nil,
)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -765,7 +765,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_ActivityCompleted() {
)
msBuilder.On("GetActivityInfo", scheduleID).Return(nil, false)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -824,7 +824,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_ActivityRunning_LocalActivity
Version: lastWriteVersion - 1,
}, true)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Nil(err)
}

Expand Down Expand Up @@ -901,7 +901,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_ActivityRunning_Update_SameVe
expectedErr := errors.New("this is error is used to by pass lots of mocking")
msBuilder.On("ReplicateActivityInfo", request, false).Return(expectedErr)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Equal(expectedErr, err)
}

Expand Down Expand Up @@ -978,7 +978,7 @@ func (s *activityReplicatorSuite) TestSyncActivity_ActivityRunning_Update_SameVe
expectedErr := errors.New("this is error is used to by pass lots of mocking")
msBuilder.On("ReplicateActivityInfo", request, true).Return(expectedErr)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Equal(expectedErr, err)
}

Expand Down Expand Up @@ -1055,6 +1055,6 @@ func (s *activityReplicatorSuite) TestSyncActivity_ActivityRunning_Update_Larger
expectedErr := errors.New("this is error is used to by pass lots of mocking")
msBuilder.On("ReplicateActivityInfo", request, true).Return(expectedErr)

err = s.activityReplicator.SyncActivity(ctx.Background(), request)
err = s.nDCActivityReplicator.SyncActivity(ctx.Background(), request)
s.Equal(expectedErr, err)
}
2 changes: 2 additions & 0 deletions service/history/nDCStateRebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ func (r *nDCStateRebuilderImpl) rebuild(
return nil, 0, err
}

// mutable state rebuild should use the same time stamp
rebuiltMutableState.GetExecutionInfo().StartTimestamp = now
return rebuiltMutableState, r.rebuiltHistorySize, nil
}

Expand Down
1 change: 1 addition & 0 deletions service/history/nDCStateRebuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,5 @@ func (s *nDCStateRebuilderSuite) TestRebuild() {
[]*persistence.VersionHistoryItem{persistence.NewVersionHistoryItem(lastEventID, version)},
),
), rebuildMutableState.GetVersionHistories())
s.Equal(rebuildMutableState.GetExecutionInfo().StartTimestamp, now)
}

0 comments on commit 1da0ebf

Please sign in to comment.