-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
FEATURE: Overhaul content stream pruner to work on event stream #5297
FEATURE: Overhaul content stream pruner to work on event stream #5297
Conversation
Followup to neos@041f239 By diffing `findAllContentStreamEventNames` with the `$transitiveUsedStreams` we can remove the `removed` flag from content streams, which would just introduce to much complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I don't have the brains anymore to do a proper review right now, so just a nitpicky-comment for now. But it looks great at first sight already!
Neos.ContentRepository.Core/Classes/Service/ContentStreamPruner.php
Outdated
Show resolved
Hide resolved
Via neos#4965 the status REBASE_ERROR is obsolete. Instead of still using this status on replay we mimic the new logic: > In case of a [rebase error}, reopen the old content stream and remove the newly created Additionally, to not break `findContentStreams` when fetching all content streams we make sure that the streams with `REBASE_ERROR` are transformed to `NO_LONGER_IN_USE` so they can be cleaned up. Related neos#5101
Neos.ContentRepository.Core/Classes/Service/ContentStreamPruner.php
Outdated
Show resolved
Hide resolved
Neos.ContentRepository.Core/Classes/Service/ContentStreamPruner.php
Outdated
Show resolved
Hide resolved
…ream` the command will be removed in the future
Otherwise, its not possible to prune if the projections are out of date or broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this works fine for me, I checked the status cases and they all make sense to me.
With the pruner now building up the state from scratch we dont need to project it any further. The only exception is the content stream state that wasnt one to begin with: the closed state. It will get its own column.
Also as we dont expose the command anymore we can get rid of the constraint checks and: > the command CloseContentStream is executed with payload and exceptions are caught
During rebase of the base workspace, its content stream will be now fully removed from the projection (no soft removal) thats why we have to adjust the calculation to not rely on the select being `null` ONLY for when it has no base. Its also null if the source content stream was removed. ``` 001 Scenario: Publishing to the root workspace render dependents outdated # Features/Workspaces/WorkspaceState.feature:71 Then workspace user-ws-two has status OUTDATED ```
Neos.ContentRepository.Core/Classes/Feature/ContentStreamEventStreamName.php
Outdated
Show resolved
Hide resolved
Neos.ContentRepository.Core/Classes/Service/ContentStreamPruner.php
Outdated
Show resolved
Hide resolved
Neos.ContentRepository.Core/Classes/Service/ContentStreamPruner.php
Outdated
Show resolved
Hide resolved
Neos.ContentRepositoryRegistry/Classes/Command/ContentStreamCommandController.php
Outdated
Show resolved
Hide resolved
…t are older than x That way we ensure this command can be run during production and doent kill any workspaces that are *just* created
…s) from tests that is part of the publishing now
I tested out that one can use
to recover from #5327 as the content streams with the fake events (with workspace=live) will just be pruned. Does anyone else wants to have a final look? (And try it out yourself?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, this should do well!
removed
flag from content streams
Bugfix: Harden content stream pruner and remove
removed
flag from content streamsResolves: #4913
Resolves: #5220
With #5096 i introduced the
ContentStream::removed
flag and got rid of the sql queryfindUnusedAndRemovedContentStreamIds
and calculated this information in php: 041f239While i thought this was a good idea, it seems it was a right step in the right direction but we can improve on that:
$commandHandlingDependencies->contentStreamExists()
is allowed to return false if a contentstream existed once, as we fork withExpectedVersion::NO_STREAM()
and thus would still check that the fork is REALLY the first event. So any "hacked" case like deleting a content stream and using the same again to create a workspace is safe.Additionally as part of the migration for the repaired publishing #5301 we require the dangling content streams to be pruned. This is currently unstable as we rely on the projection to be up to date which is not the case for users of beta14 if they run into the publish bug.
For this reason we iterate over the events of the event store directly - filtering already the desired event types to limit the set - and build up the state of which content streams were removed, are no longer in use or in use by workspace.
That allows us to remove the same logic from the projection.
The change will also remove the left-over content stream commands that are not required by the workspace command handler anymore, by publishing events directly to replace their use in tests and in the pruner.
New command
flow contentstream:status
Detects if dangling content streams exists and which content streams could be pruned from the event stream
Dangling content streams
Content streams that are not removed via the event ContentStreamWasRemoved and are not in use by a workspace
(not a current's workspace content stream).
Previously before Neos 9 beta 15 (#5301), dangling content streams were not removed during publishing, discard or rebase.
Pruneable content streams
Content streams that were removed ContentStreamWasRemoved e.g. after publishing, and are not required for a full
replay to reconstruct the current projections state. The ability to reconstitute a previous state will be lost.
Example output
Changes to
flow contentStream:removeDangling
(previouslycontentStream:prune
)The command was renamed to better distinct between pruning and removing.
We will now always include temporary content streams like
FORKED
orCREATED
in the removal if they are older than 1 day. See--remove-temporary-before=-1day
option. That way we can be sure not to remove temporary content streams of a users current action.Upgrade instructions
Review instructions
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions