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

BUG: Importing a dump via cr:import will create duplicate content stream entries #4298

Closed
1 task done
ahaeslich opened this issue May 29, 2023 · 0 comments · Fixed by #4914
Closed
1 task done

BUG: Importing a dump via cr:import will create duplicate content stream entries #4298

ahaeslich opened this issue May 29, 2023 · 0 comments · Fixed by #4914
Assignees

Comments

@ahaeslich
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Using cr:import instead of cr:migratelegacydata to set up a neos 9 instance will result in:

  • there will be two recorded events of type ContentStreamWasCreated in cr_default_events
  • the table cr_default_p_contentstream will have two entries with the same contentStreamId and different states

Example import result:

contentStreamId version sourceContentStreamId state removed
80efbe37-9642-4109-8448-c09db47523aa 14 null IN_USE_BY_WORKSPACE 0
80efbe37-9642-4109-8448-c09db47523aa 14 null CREATED 0

Why does this matter?

I stumbled upon this while using the cli command ./flow contentstream:prune --remove-temporary based on the data dump included in Neos.Demo. Running ./flow contentstream:prune --remove-temporary removed the live workspace in my test installation so I investigated what caused this.

The ContentStreamFinder will remove the temporary entries of state CREATED or FORKED so why are there multiple entries for the live workspace?

Why does this happen?

The cr:export command will export all events from the contentstream connected to the live workspace. This includes the first event ContentStreamWasCreated, which in comparison is not included in the events generated by cr:migratelegacydata.

As the EventStoreImportProcessor creates the contentstream and the live workspace before applying all events to import we end up with the described result.

$contentStreamStreamName = ContentStreamEventStreamName::fromContentStreamId($this->contentStreamId)->getEventStreamName();
$events = Events::with(
$this->normalizeEvent(
new ContentStreamWasCreated(
$this->contentStreamId,
)
)
);
try {
$contentStreamCreationCommitResult = $this->eventStore->commit($contentStreamStreamName, $events, ExpectedVersion::NO_STREAM());
} catch (ConcurrencyException $e) {
return ProcessorResult::error(sprintf('Failed to publish workspace events because the event stream "%s" already exists (1)', $this->contentStreamId->value));
}
$workspaceName = WorkspaceName::forLive();
$workspaceStreamName = WorkspaceEventStreamName::fromWorkspaceName($workspaceName)->getEventStreamName();
$events = Events::with(
$this->normalizeEvent(
new RootWorkspaceWasCreated(
$workspaceName,
WorkspaceTitle::fromString('live workspace'),
WorkspaceDescription::fromString('live workspace'),
$this->contentStreamId
)
)
);
try {
$this->eventStore->commit($workspaceStreamName, $events, ExpectedVersion::NO_STREAM());
} catch (ConcurrencyException $e) {
return ProcessorResult::error(sprintf('Failed to publish workspace events because the event stream "%s" already exists (2)', $workspaceStreamName->value));
}

Expected Behavior

The contentstream for the live workspace should only be created once.

Steps To Reproduce

Reproduce with a newlyy created site:

  1. Have an empty neos 9 project with the Neos.Demo package at hand
  2. Setup the CR (./flow cr:setup)
  3. Create a new site via ./flow site:create neosdemo Neos.Demo Neos.Demo:Document.Homepage
  4. Export the CR via ./flow cr:export --path=./crExportTest
  5. Cleanup your CR for reimporting the export via ./flow cr:prune
  6. Import via ./flow cr:import --path=./crExportTest

Reproduce via Neos.Demo dump:

  1. Have an empty neos 9 project with the Neos.Demo package at hand
  2. Setup the CR is set up (./flow cr:setup)
  3. Make sure there is an active Site in your installation (./flow site:create neosdemo Neos.Demo Neos.Demo:Document.Homepage)
  4. Empty your CR via ./flow cr:prune
  5. Import all content from the Neos.Demo site package via ./flow cr:import ./Packages/Sites/Neos.Demo/Resources/Private/Content/

Environment

- Flow: 9.0
- Neos: 9.0
- PHP: 8.2

Anything else?

No response

@bwaidelich bwaidelich changed the title BUG: Importing a dump via cr:import will create dublicate content stream entries BUG: Importing a dump via cr:import will create duplicate content stream entries May 30, 2023
@nezaniel nezaniel self-assigned this Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment