Skip to content

[HttpFoundation][Cache][Messenger] Replace redis "DEL" commands with "UNLINK" #37993

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

Merged
merged 1 commit into from
Sep 27, 2020

Conversation

jonashrem
Copy link
Contributor

@jonashrem jonashrem commented Aug 30, 2020

Q A
Branch? master
Bug fix? no
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

This PR replaces DEL Command with UNLINK command.

Details about UNLINK can be found here https://redis.io/commands/unlink .

As noticed here redis/redis#1748 (comment) this will not change the behavior.

As there is no check of Redis version included, it will break Redis Versions < 4.0 through.

As Redis 4.0 was released on 2017-07-14 and Redis 3 went EOL with the Redis 5 on 2018-10-17, I don't expect this being an issue.

With redis 4.0 there is a new unlink command intruded ( https://redis.io/commands/unlink ) with is a smarter version of del() as it deletes keys in O(1) and frees the memory in background.

See also http://antirez.com/news/93 and redis/redis#1748

This won't change the behavior but only the memory usage as clarified here: redis/redis#1748 (comment) which shouldn't be an issue with most Magento instances

With this, I recommend replacing DEL operations with UNLINK operations.

@nicolas-grekas nicolas-grekas added this to the next milestone Aug 31, 2020
@nicolas-grekas
Copy link
Member

The method is also used in src/Symfony/Component/Cache/Traits/RedisTrait.php and in src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Would you advise updating these also? If yes, can you please update the PR?
I'm fine with dropping support for Redis 3 on 5.2.

Can you please add a note in the UPGRADE-5.2 file, in each component's section?

@fabpot
Copy link
Member

fabpot commented Sep 6, 2020

@jonashrem Still interested in finishing this PR?

@jonashrem
Copy link
Contributor Author

@fabpot yes, I was just a bit busy the last days. I still plan looking into this.

@nicolas-grekas nicolas-grekas changed the title replace redis "DEL" Commands with "UNLINK" [HttpFoundation][Cache][Messenger]replace redis "DEL" Commands with "UNLINK" Sep 8, 2020
@nicolas-grekas nicolas-grekas changed the title [HttpFoundation][Cache][Messenger]replace redis "DEL" Commands with "UNLINK" [HttpFoundation][Cache][Messenger] Replace redis "DEL" Commands with "UNLINK" Sep 8, 2020
@nicolas-grekas nicolas-grekas changed the title [HttpFoundation][Cache][Messenger] Replace redis "DEL" Commands with "UNLINK" [HttpFoundation][Cache][Messenger] Replace redis "DEL" commands with "UNLINK" Sep 8, 2020
@nicolas-grekas
Copy link
Member

/cc @andrerom btw, any opinion about the proposed bump to Redis >= 4?

@andrerom
Copy link
Contributor

For master that should be ok from my POV 👍

Make sure to mention it clearly in release notes though, not everyone expect bumps in requirements in minor releases.

@jonashrem jonashrem requested a review from sroze as a code owner September 13, 2020 12:25
@jonashrem
Copy link
Contributor Author

I replaced the other occurrences.

For the failing auto-tests, is it possible the test instance is still using redis 3?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 14, 2020

For the failing auto-tests, is it possible the test instance is still using redis 3?

The CI runs Redis 6 apparently, but the failures are helpful: Predis doesn't know about the unlink command. Looking at the code, that's the case: https://github.com/predis/predis/tree/main/src/Command/Redis

Would you like to send a PR there to add the command?

Also, can't we add a command "manually" on our side in order to teach Predis about it?

Last note here: don't forget to add a note in the UPGRADE-5.2 file, in each component's section.

Thanks.

@nicolas-grekas
Copy link
Member

@jonashrem friendly ping. Are you OK with my previous comment?

@jonashrem
Copy link
Contributor Author

@jonashrem friendly ping. Are you OK with my previous comment?

yes, that's fine. I will look into this further if it's possible to set this manually.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I updated the code to fallback to DEL when UNLINK is not available.
I also submitted predis/predis#666 to add UNLINK to Predis.
Ready on my side.

@jonashrem
Copy link
Contributor Author

oh, that's a very good idea.

In this case we don't even loose backwards compatibility with redis 3.x.

Very nice.

So for my understanding when the Integration tests run through there is nothing left to do here?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 27, 2020

So for my understanding when the Integration tests run through there is nothing left to do here?

Correct, there should be nothing else to do here. Now waiting for the CI to be green for the components.

@nicolas-grekas
Copy link
Member

Thank you @jonashrem.

@nicolas-grekas nicolas-grekas merged commit d8d90b0 into symfony:master Sep 27, 2020
@jonashrem
Copy link
Contributor Author

Thanks, as well. And sorry you had to do so much in the end by yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants