Skip to content

Commit

Permalink
Fix visibility data on ES not deleted (cadence-workflow#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
vancexu authored Aug 12, 2019
1 parent 815db6f commit 4b95faa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ const (
ElasticsearchScanWorkflowExecutionsScope
// ElasticsearchCountWorkflowExecutionsScope tracks CountWorkflowExecutions calls made by service to persistence layer
ElasticsearchCountWorkflowExecutionsScope
// ElasticsearchDeleteWorkflowExecutionsScope tracks DeleteWorkflowExecution calls made by service to persistence layer
ElasticsearchDeleteWorkflowExecutionsScope

// SequentialTaskProcessingScope is used by sequential task processing logic
SequentialTaskProcessingScope
Expand Down Expand Up @@ -1054,6 +1056,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{
ElasticsearchListWorkflowExecutionsScope: {operation: "ListWorkflowExecutions"},
ElasticsearchScanWorkflowExecutionsScope: {operation: "ScanWorkflowExecutions"},
ElasticsearchCountWorkflowExecutionsScope: {operation: "CountWorkflowExecutions"},
ElasticsearchDeleteWorkflowExecutionsScope: {operation: "DeleteWorkflowExecution"},
SequentialTaskProcessingScope: {operation: "SequentialTaskProcessing"},

HistoryArchiverScope: {operation: "HistoryArchiver"},
Expand Down
12 changes: 11 additions & 1 deletion common/persistence/elasticsearch/esVisibilityMetricClients.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,17 @@ func (p *visibilityMetricsClient) CountWorkflowExecutions(request *p.CountWorkfl
}

func (p *visibilityMetricsClient) DeleteWorkflowExecution(request *p.VisibilityDeleteWorkflowExecutionRequest) error {
return nil // not applicable for elastic search, which relies on retention policies for deletion
p.metricClient.IncCounter(metrics.ElasticsearchDeleteWorkflowExecutionsScope, metrics.ElasticsearchRequests)

sw := p.metricClient.StartTimer(metrics.ElasticsearchDeleteWorkflowExecutionsScope, metrics.ElasticsearchLatency)
err := p.persistence.DeleteWorkflowExecution(request)
sw.Stop()

if err != nil {
p.updateErrorMetric(metrics.ElasticsearchDeleteWorkflowExecutionsScope, err)
}

return err
}

func (p *visibilityMetricsClient) updateErrorMetric(scope int, err error) {
Expand Down
2 changes: 1 addition & 1 deletion docs/visibility-on-elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To list only open workflows, add `CloseTime = missing` to the end of query.
### start workflow with search attributes

```
cadence --do samples-domain workflow start --tl helloWorldGroup --wt main.Workflow --et 60 --dt 10 -i '"vancexu"' -search_attr_key 'CustomIntField | CustomKeywordField | CustomStringField | CustomBoolField | CustomDatetimeField' -search_attr_value '5 | keyword1 | vancexu test | true | 2019-06-07T16:16:36-08:00'
cadence --do samples-domain workflow start --tl helloWorldGroup --wt main.Workflow --et 60 --dt 10 -i '"input arg"' -search_attr_key 'CustomIntField | CustomKeywordField | CustomStringField | CustomBoolField | CustomDatetimeField' -search_attr_value '5 | keyword1 | my test | true | 2019-06-07T16:16:36-08:00'
```

Note: start workflow with search attributes but without ES will succeed as normal, but will not be searchable and will not be shown in list result.
Expand Down

0 comments on commit 4b95faa

Please sign in to comment.