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: Flush node content caches without workspace name #5122

Merged

Conversation

dlubitz
Copy link
Contributor

@dlubitz dlubitz commented Jun 3, 2024

As we don't want to iterate over all workspaces on flushing content caches, caused by asset changes, we add addionally node cache tags without a workspace name. So we can flush all node aggregates in all workspaces with just the node aggregate id.

@dlubitz dlubitz self-assigned this Jun 3, 2024
@dlubitz dlubitz removed the Bug label Jun 3, 2024
@github-actions github-actions bot added the Bug label Jun 3, 2024
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.

Thanks, this makes a lot of sense in general!
I'm just a bit skeptical about the nullable arguments and would suggest to remove those from the public methods again.

The other suggestions we could address in a follow up

Neos.Neos/Classes/Fusion/Cache/CacheTag.php Outdated Show resolved Hide resolved
Comment on lines 56 to 60
return self::forNodeAggregate(
$node->contentRepositoryId,
null,
$node->aggregateId
);
Copy link
Member

Choose a reason for hiding this comment

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

...change this to sth like

Suggested change
return self::forNodeAggregate(
$node->contentRepositoryId,
null,
$node->aggregateId
);
return new self(
'Node_'
. self::getHashForContentRepositoryId($contentRepositoryId)
. '_' . $nodeAggregateId->value
);

and we could reduce the amount of repetition, by introducing some private fromParts constructor, e.g.:

return self::fromParts(self::NODE_PREFIX, self::hashed($contentRepositoryId), $nodeAggregateId->value);

that would also make it easier to change our internal pattern because I think:
<prefix>_sha1(<workspace>@<cr>)_<aggregateId> is not safe (because the NodeAggregateId could contain underscores for example – not currently, but it is being requested)

<prefix>|sha1(<workspace>)|sha1(<cr>)|<aggregateId> would make more sense to me – even though: I don't understand why we randomly(?) use sha1 for 2 of those?

Copy link
Contributor Author

@dlubitz dlubitz Jun 4, 2024

Choose a reason for hiding this comment

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

The sha1 is to reduce/fix the length of the key.

is not safe (because the NodeAggregateId could contain underscores for example

There is also no need to change this, as this is just a visual delimiter, without any meaning.

Copy link
Member

Choose a reason for hiding this comment

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

The sha1 is to reduce/fix the length of the key

It was used to avoid special characters to render the tags inconsistent – but this should no longer be an issue with our restrictive ValueObjects.
Re length:
The max length of a cache tag is 250 characters.
SHA1 hashes are 40 characters long.
workspaceName can be up to 200 characters
cr id only 16 (i.e. hashing the cr ID increases its length)

We could just hash the complete tag, but that would obviously make it impossible to read so I would not suggest to do so.
Instead I'd say (sorry, this is not related to your change, but since we talk about it):

  • Reduce the length of WorkspaceName dramatically – 200 characters is crazy
  • use a delimiter that can' be part of aggregate id, workspace name or cr id
  • don't hash the parts at all

There is also no need to change this, as this is just a visual delimiter, without any meaning

Well, it's not just visual, imagine a node aggregate id of foo_notAWorkspace :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but can we move this into a dedicated issue?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sorry ;)

Copy link
Member

Choose a reason for hiding this comment

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

created an issue because the sha1 bugged me while debugging: #5164

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.

@dlubitz two more little issues – I'll push a PR-PR with some suggestions

Neos.Neos/Classes/Fusion/Cache/CacheTag.php Outdated Show resolved Hide resolved
Neos.Neos/Classes/Fusion/Cache/CacheTag.php Outdated Show resolved Hide resolved
@kitsunet
Copy link
Member

I still like bastis comment about the bool/ second WorkspaceName but otherwise wonderful thanks for sifting through this!

@kitsunet
Copy link
Member

For some reason I seem to have ended up on an older commit 🙈 Great

@dlubitz dlubitz merged commit baf35c3 into neos:9.0 Jun 14, 2024
9 checks passed
@dlubitz dlubitz deleted the 90/bugfix/asset-cache-flush-without-workspace branch June 14, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants