Skip to content

Commit 8c0715f

Browse files
committed
comments addressed
1 parent eab31a1 commit 8c0715f

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

service/history/api/queryworkflow/api.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ func Invoke(
179179
}
180180
queryID, completionCh := queryReg.BufferQuery(req.GetQuery())
181181
defer queryReg.RemoveQuery(queryID)
182+
183+
msResp, err := api.GetMutableState(ctx, shardContext, workflowKey, workflowConsistencyChecker)
184+
if err != nil {
185+
return nil, err
186+
}
187+
182188
workflowLease.GetReleaseFn()(nil) // release the lock - no access to mutable state beyond this point!
183189
select {
184190
case <-completionCh:
@@ -187,11 +193,6 @@ func Invoke(
187193
metrics.QueryRegistryInvalidStateCount.With(scope).Record(1)
188194
return nil, err
189195
}
190-
msResp, err := api.GetMutableState(ctx, shardContext, workflowKey, workflowConsistencyChecker)
191-
if err != nil {
192-
return nil, err
193-
}
194-
195196
switch completionState.Type {
196197
case workflow.QueryCompletionTypeSucceeded:
197198
result := completionState.Result
@@ -253,10 +254,6 @@ func Invoke(
253254
return nil, consts.ErrQueryEnteredInvalidState
254255
}
255256
case <-ctx.Done():
256-
msResp, err := api.GetMutableState(ctx, shardContext, workflowKey, workflowConsistencyChecker)
257-
if err != nil {
258-
return nil, err
259-
}
260257
emitWorkflowQueryMetrics(
261258
scope,
262259
nsEntry,
@@ -346,6 +343,9 @@ func queryDirectlyThroughMatching(
346343
stickyStartTime := time.Now().UTC()
347344
matchingResp, err := rawMatchingClient.QueryWorkflow(stickyContext, stickyMatchingRequest)
348345
metrics.DirectQueryDispatchStickyLatency.With(metricsHandler).Record(time.Since(stickyStartTime))
346+
if err != nil {
347+
return nil, err
348+
}
349349
cancel()
350350
if err == nil {
351351
metrics.DirectQueryDispatchStickySuccessCount.With(metricsHandler).Record(1)
@@ -413,14 +413,11 @@ func emitWorkflowQueryMetrics(
413413
metrics.QueryTypeTag(queryType),
414414
}
415415

416-
if err != nil {
417-
if common.IsContextDeadlineExceededErr(err) {
418-
metrics.WorkflowQueryTimeoutCount.With(metricsHandler).Record(1, commonTags...)
419-
} else {
420-
metrics.WorkflowQueryFailureCount.With(metricsHandler).Record(1, commonTags...)
421-
}
422-
return
416+
if err == nil {
417+
metrics.WorkflowQuerySuccessCount.With(metricsHandler).Record(1, commonTags...)
418+
} else if common.IsContextDeadlineExceededErr(err) {
419+
metrics.WorkflowQueryTimeoutCount.With(metricsHandler).Record(1, commonTags...)
420+
} else {
421+
metrics.WorkflowQueryFailureCount.With(metricsHandler).Record(1, commonTags...)
423422
}
424-
425-
metrics.WorkflowQuerySuccessCount.With(metricsHandler).Record(1, commonTags...)
426423
}

service/history/timer_queue_active_task_executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ func (t *timerQueueActiveTaskExecutor) emitTimeoutMetricScopeWithNamespaceTag(
863863
operation string,
864864
timerType enumspb.TimeoutType,
865865
effectiveVersioningBehavior enumspb.VersioningBehavior,
866-
firstAttempt int32,
866+
taskAttempt int32,
867867
) {
868868
namespaceEntry, err := t.registry.GetNamespaceByID(namespaceID)
869869
if err != nil {
@@ -873,7 +873,7 @@ func (t *timerQueueActiveTaskExecutor) emitTimeoutMetricScopeWithNamespaceTag(
873873
metrics.OperationTag(operation),
874874
metrics.NamespaceTag(namespaceEntry.Name().String()),
875875
metrics.VersioningBehaviorTag(effectiveVersioningBehavior),
876-
metrics.FirstAttemptTag(firstAttempt),
876+
metrics.FirstAttemptTag(taskAttempt),
877877
)
878878
switch timerType {
879879
case enumspb.TIMEOUT_TYPE_SCHEDULE_TO_START:

0 commit comments

Comments
 (0)