Skip to content

Optimistic Concurrency Pt.2 #841

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

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft

Optimistic Concurrency Pt.2 #841

wants to merge 44 commits into from

Conversation

FoseFx
Copy link
Member

@FoseFx FoseFx commented Sep 26, 2024

Which issues does this pull request close?

closes #808
closes #860

  • UpdateWardResponse
  • UpdatePropertyResponse
  • AttachPropertyValueResponse
  • UpdateBedResponse
  • UpdatePatientResponse
  • AssignBedResponse
  • UnassignBedResponse
  • UpdateRoomResponse
  • UpdateTaskResponse
  • AssignTaskResponse
  • UpdateSubtaskResponse
  • UpdateTaskTemplateResponse
  • UpdateTaskTemplateSubTaskResponse
  • tests: also do unrelated updates in between
  • use copier
  • use one generic conflict type
  • de-duplicate util/conflict.go
  • deduplicate some of the diff logic
  • merge main / review org changes

return consistency, not oldConsistency

@FoseFx FoseFx self-assigned this Sep 26, 2024
@FoseFx FoseFx force-pushed the issue/808-optimistic-2 branch 4 times, most recently from 7d5ac76 to 8717556 Compare September 28, 2024 08:05
@FoseFx FoseFx force-pushed the issue/808-optimistic-2 branch from 8717556 to 7785583 Compare October 7, 2024 07:28
@FoseFx FoseFx marked this pull request as ready for review October 14, 2024 12:52
@FoseFx FoseFx requested a review from a team as a code owner October 14, 2024 12:52
@FoseFx FoseFx requested review from MaxSchaefer and PaulKalho and removed request for a team October 14, 2024 12:52
@FoseFx FoseFx added the is-blocked This gets blocked. Check out "Blocked by #xyz" comments. label Oct 26, 2024
@FoseFx FoseFx removed the is-blocked This gets blocked. Check out "Blocked by #xyz" comments. label Oct 26, 2024
Copy link
Contributor

@MaxSchaefer MaxSchaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a huge

  • Enhancement of conflict detection
  • Large rewrite of some types in the property-svc
  • Bare bone conflict resolution via retries
  • Conflict diffs (most of this pr)

The conflict diff is done manually in our API layer. All of those areas are marked with a TODO comment to find a more generic approach later on. Are there currently any ideas how we can abstract this?

@@ -181,3 +181,46 @@ func OrEmptySlice[T any](as []T) []T {

return make([]T, 0)
}

func Without[T comparable](original, itemsToRemove []T) []T {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests

}

// SameItems yields true, iff a and b have the same elements (order may vary!)
func SameItems[T comparable](a, b []T) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests

Comment on lines +25 to +30
PropertyValue: &models.PropertyValue{
ID: id,
PropertyID: uuid.UUID{},
SubjectID: uuid.UUID{},
Value: nil,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why getting rid of the constructor?

SubjectID string `json:"subject_id"`
ID string `json:"id"`
PropertyID string `json:"property_id"`
ValueChange models.TypedValueChange `json:"value_change"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why suffix ValueChange with Value? Its the value of the property. A new event for the property value has a new value.

Comment on lines +62 to +66
if expConsistency != nil && *expConsistency != newToken {
return newToken, &common.Conflict[*models.Property]{
Was: oldState,
Is: a.Property,
}, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every command handler has this check. Can we move this one layer down?

@MaxSchaefer
Copy link
Contributor

We discussed this via audio

Before we can merge the diff/conflict detection we need to have a future plan in place to get rid of the manual mappings.

  • Create a new PR that does not contain the diff/conflict detection down to a field logic
  • Mark this PR as draft
  • Meeting with the whole team to discuss this logic

@FoseFx FoseFx marked this pull request as draft November 13, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistency Tokens / Optimistic Concurrency Proper model for PropertyValue values
2 participants