Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return ShardOwnershipLostError as catch all from persistence layer #873

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions common/persistence/cassandraPersistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,12 +1098,14 @@ func (d *cassandraPersistence) CreateWorkflowExecution(request *CreateWorkflowEx
}

// At this point we only know that the write was not applied.
// Return the row information returned by Cassandra.
// It's much safer to return ShardOwnershipLostError as the default to force the application to reload
// shard to recover from such errors
var columns []string
for k, v := range previous {
columns = append(columns, fmt.Sprintf("%s=%v", k, v))
}
return nil, &ConditionFailedError{
return nil, &ShardOwnershipLostError{
ShardID: d.shardID,
Msg: fmt.Sprintf("Failed to create workflow execution. Request RangeID: %v, columns: (%v)",
request.RangeID, strings.Join(columns, ",")),
}
Expand Down Expand Up @@ -1624,13 +1626,15 @@ func (d *cassandraPersistence) UpdateWorkflowExecution(request *UpdateWorkflowEx
}

// At this point we only know that the write was not applied.
// Return the row information returned by Cassandra.
// It's much safer to return ShardOwnershipLostError as the default to force the application to reload
// shard to recover from such errors
var columns []string
for k, v := range previous {
columns = append(columns, fmt.Sprintf("%s=%v", k, v))
}

return &ConditionFailedError{
return &ShardOwnershipLostError{
ShardID: d.shardID,
Msg: fmt.Sprintf("Failed to update workflow execution. RangeID: %v, Condition: %v, columns: (%v)",
request.RangeID, request.Condition, strings.Join(columns, ",")),
}
Expand Down Expand Up @@ -1802,13 +1806,15 @@ func (d *cassandraPersistence) ResetMutableState(request *ResetMutableStateReque
}

// At this point we only know that the write was not applied.
// Return the row information returned by Cassandra.
// It's much safer to return ShardOwnershipLostError as the default to force the application to reload
// shard to recover from such errors
var columns []string
for k, v := range previous {
columns = append(columns, fmt.Sprintf("%s=%v", k, v))
}

return &ConditionFailedError{
return &ShardOwnershipLostError{
ShardID: d.shardID,
Msg: fmt.Sprintf("Failed to reset mutable state. RangeID: %v, Condition: %v, columns: (%v)",
request.RangeID, request.Condition, strings.Join(columns, ",")),
}
Expand Down