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

BUGFIX: do not crash when node already disabled/enabled #4284

Merged
merged 3 commits into from
May 25, 2023

Conversation

skurfuerst
Copy link
Member

How to reproduce:

  • User A: log into backend
  • User B: log into backend
  • User A: Hide Node X
  • User B: Hide Node X
  • User B: Publish
  • User A: Publish <-- here the crash has occurred during rebase.

Fix idea: IMHO we can relax the checks in these command handlers a bit, to simply do nothing in this case.

How to reproduce:

- User A: log into backend
- User B: log into backend
- User A: Hide Node X
- User B: Hide Node X
- User B: Publish
- User A: Publish <-- here the crash has occurred during rebase.

Fix idea: IMHO we can relax the checks in these command handlers
a bit, to simply do nothing in this case.
@skurfuerst
Copy link
Member Author

@ahaeslich I was able to reproduce one of the errors on the demo site now :)

@bwaidelich please check whether you like the solution idea; or whether you prefer a APIs in detail. Feel free to continue working here in case you want to have something changed; from my side this would be ready :)

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

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

Apart from the (partly nitpicky) comments and the failing tests this is a pragmatic solution that should be perfectly fine IMO.
I wonder though if we should (in the long term?) solve these kind of issues with a more sophisticated conflict resolution, i.e. avoid/merge the commands if necessary during rebase.

For the disabled case, pseudo code:

foreach ($eventsOfCurrentContentStream as $event) {
  if ($event instanceof NodeAggregateWasDisabled) {
     // remember disabled node
  } 
}
foreach ($originalCommands as $command) {
  if ($command instanceof DisableNodeAggregate && $this->alreadyDisabled(...)) {
     // continue
  }
}

..maybe this can even be combined with #4263 ?

PendingProjections::empty(),
new CommitResult(
Version::first(),
SequenceNumber::none()
Copy link
Member

Choose a reason for hiding this comment

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

This could be a bit dangerous/misleading if consumers don't check for the pending projections properly and use the CommitResult to determine the progress of the ES.
Probably not a real issue, but it might be safer to use a union type EmptyCommandResult (or similar) instead?

@skurfuerst
Copy link
Member Author

@bwaidelich actually this change avoids storing the command during rebase; so it leads to the "cleaned up behavior".

Generally I am all in for further compaction mechanisms .

As I am currently not near a laptop, it would be great if we get this merged and somebody of you could take this over? :)

All the best,
Sebastian

@bwaidelich
Copy link
Member

Thanks!
I will take care of this one and get it merged asap – we can always replace it by a more sophisticated compraction mechanism once that exists

@bwaidelich bwaidelich self-assigned this May 24, 2023
@bwaidelich bwaidelich merged commit 26adf21 into 9.0 May 25, 2023
@bwaidelich bwaidelich deleted the 90-do-not-crash-when-node-already-disabled-enabled branch May 25, 2023 13:11
bwaidelich added a commit that referenced this pull request Nov 9, 2024
…ging

Previously, when trying to disable an already disabled node, we just ignored that fact and did not produce any events.
That leads to a potentially opaque behavior:

```
User A: log into backend
User B: log into backend
User A: Hide Node X
User B: Hide Node X
User B: Publish
User A: Rebase
User B: Unhide Node X
User B: Publish
User A: Rebase <--- now Node X is re-enabled even though User A had explicitly disabled it
```

With this change, the sequence is:

```
User A: log into backend
User B: log into backend
User A: Hide Node X
User B: Hide Node X
User B: Publish
User A: Rebase <--- this leads to a conflict because both users disabled the same node. And User A can now explicitly decide to ignore that fact
```

Note: This mostly reverts #4284 that was introduced because we did not have a conflict resolution in place

Related: #4284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants