Skip to content

Commit

Permalink
Add scanner invariants (uber#3257)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjdawson2016 authored May 12, 2020
1 parent 5321680 commit bcc0d8f
Show file tree
Hide file tree
Showing 48 changed files with 1,430 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .gen/go/admin/admin.go

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

2 changes: 1 addition & 1 deletion .gen/go/admin/adminserviceclient/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/admin/adminservicefx/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/admin/adminservicefx/doc.go

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

2 changes: 1 addition & 1 deletion .gen/go/admin/adminservicefx/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/admin/adminserviceserver/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/admin/adminservicetest/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/cadence.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/workflowserviceclient/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/workflowservicefx/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/workflowservicefx/doc.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/workflowservicefx/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/workflowserviceserver/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/cadence/workflowservicetest/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/history.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/historyserviceclient/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/historyservicefx/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/historyservicefx/doc.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/historyservicefx/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/historyserviceserver/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/history/historyservicetest/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matching.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matchingserviceclient/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matchingservicefx/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matchingservicefx/doc.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matchingservicefx/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matchingserviceserver/server.go

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

2 changes: 1 addition & 1 deletion .gen/go/matching/matchingservicetest/client.go

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

2 changes: 1 addition & 1 deletion .gen/go/replicator/replicator.go

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

2 changes: 1 addition & 1 deletion .gen/go/shared/shared.go

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

2 changes: 1 addition & 1 deletion .gen/go/sqlblobs/sqlblobs.go

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

2 changes: 1 addition & 1 deletion common/persistence/versionHistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (h *VersionHistories) GetVersionHistory(
branchIndex int,
) (*VersionHistory, error) {

if branchIndex < 0 || branchIndex > len(h.Histories) {
if branchIndex < 0 || branchIndex >= len(h.Histories) {
return nil, &shared.BadRequestError{Message: "invalid branch index."}
}

Expand Down
6 changes: 3 additions & 3 deletions service/frontend/adminHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *adminHandlerSuite) SetupTest() {
},
}
config := &Config{
EnableAdminProtection: dynamicconfig.GetBoolPropertyFn(false),
EnableAdminProtection: dynamicconfig.GetBoolPropertyFn(false),
EnableCleanupReplicationTask: dynamicconfig.GetBoolPropertyFn(false),
}
s.handler = NewAdminHandler(s.mockResource, params, config)
Expand Down Expand Up @@ -553,8 +553,8 @@ func (s *adminHandlerSuite) Test_AddSearchAttribute_Permission() {
ctx := context.Background()
handler := s.handler
handler.config = &Config{
EnableAdminProtection: dynamicconfig.GetBoolPropertyFn(true),
AdminOperationToken: dynamicconfig.GetStringPropertyFn(common.DefaultAdminOperationToken),
EnableAdminProtection: dynamicconfig.GetBoolPropertyFn(true),
AdminOperationToken: dynamicconfig.GetStringPropertyFn(common.DefaultAdminOperationToken),
EnableCleanupReplicationTask: dynamicconfig.GetBoolPropertyFn(false),
}

Expand Down
4 changes: 2 additions & 2 deletions service/history/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ type Config struct {
ReplicationTaskProcessorCleanupInterval dynamicconfig.DurationPropertyFnWithShardIDFilter
ReplicationTaskProcessorCleanupJitterCoefficient dynamicconfig.FloatPropertyFnWithShardIDFilter
// TODO: those two flags are for migration. Consider remove them after the migration complete
EnableRPCReplication dynamicconfig.BoolPropertyFn
EnableKafkaReplication dynamicconfig.BoolPropertyFn
EnableRPCReplication dynamicconfig.BoolPropertyFn
EnableKafkaReplication dynamicconfig.BoolPropertyFn
EnableCleanupReplicationTask dynamicconfig.BoolPropertyFn

// The following are used by consistent query
Expand Down
3 changes: 3 additions & 0 deletions service/worker/scanner/executions/common/blobstoreIterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func getBlobstoreFetchPageFn(
if err := json.Unmarshal(p, &soe); err != nil {
return pagination.Page{}, err
}
if err := ValidateExecution(&soe.Execution); err != nil {
return pagination.Page{}, err
}
executions = append(executions, &soe.Execution)
}
var nextPageToken interface{} = index + 1
Expand Down
2 changes: 1 addition & 1 deletion service/worker/scanner/executions/common/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type (
// It can also be used to fix the invariant for an execution.
Invariant interface {
Check(Execution, *InvariantResourceBag) CheckResult
Fix(Execution, *InvariantResourceBag) FixResult
Fix(Execution) FixResult
InvariantType() InvariantType
}

Expand Down
24 changes: 14 additions & 10 deletions service/worker/scanner/executions/common/persistenceIterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package common

import (
"github.com/uber/cadence/common/codec"
"github.com/uber/cadence/common/pagination"
"github.com/uber/cadence/common/persistence"
)
Expand All @@ -40,15 +41,15 @@ func NewPersistenceIterator(
shardID int,
) ExecutionIterator {
return &persistenceIterator{
itr: pagination.NewIterator(nil, getPersistenceFetchPageFn(pr, pageSize, shardID)),
itr: pagination.NewIterator(nil, getPersistenceFetchPageFn(pr, codec.NewThriftRWEncoder(), pageSize, shardID)),
}
}

// Next returns the next execution
func (i *persistenceIterator) Next() (*Execution, error) {
exec, err := i.itr.Next()
if exec != nil {
return exec.(*Execution), err
return exec.(*Execution), nil
}
return nil, err
}
Expand All @@ -60,6 +61,7 @@ func (i *persistenceIterator) HasNext() bool {

func getPersistenceFetchPageFn(
pr PersistenceRetryer,
encoder *codec.ThriftRWEncoder,
pageSize int,
shardID int,
) pagination.FetchFn {
Expand All @@ -76,22 +78,24 @@ func getPersistenceFetchPageFn(
}
executions := make([]pagination.Entity, len(resp.Executions), len(resp.Executions))
for i, e := range resp.Executions {
branchToken := e.ExecutionInfo.BranchToken
if e.VersionHistories != nil {
versionHistory, err := e.VersionHistories.GetCurrentVersionHistory()
if err != nil {
return pagination.Page{}, err
}
branchToken = versionHistory.GetBranchToken()
branchToken, treeID, branchID, err := GetBranchToken(e, encoder)
if err != nil {
return pagination.Page{}, err
}
executions[i] = &Execution{
exec := &Execution{
ShardID: shardID,
DomainID: e.ExecutionInfo.DomainID,
WorkflowID: e.ExecutionInfo.WorkflowID,
RunID: e.ExecutionInfo.RunID,
BranchToken: branchToken,
TreeID: treeID,
BranchID: branchID,
State: e.ExecutionInfo.State,
}
if err := ValidateExecution(exec); err != nil {
return pagination.Page{}, err
}
executions[i] = exec
}
var nextToken interface{} = resp.PageToken
if len(resp.PageToken) == 0 {
Expand Down
Loading

0 comments on commit bcc0d8f

Please sign in to comment.