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

[Lock] compatiblity with redis cluster 7 #54252

Merged
merged 1 commit into from Mar 13, 2024

Conversation

bastnic
Copy link
Contributor

@bastnic bastnic commented Mar 12, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

While upgrading from redis 5 (no cluster) to AWS Elasticache redis 7 (cluster serverless), I stumble upon a fail.

This Redis command is not allowed from script script

Investigating, the fail is here, TIME is not available in cluster mode.

if (!isset($this->supportTime)) {
// Redis < 5.0 does not support TIME (not deterministic) in script.
// https://redis.io/commands/eval#replicating-commands-instead-of-scripts
// This code asserts TIME can be use, otherwise will fallback to a timestamp generated by the PHP process.
$script = '
local now = redis.call("TIME")
redis.call("SET", KEYS[1], "1", "PX", 1)
return 1
';

redis > EVAL 'local now = redis.call("TIME"); redis.call("SET", KEYS[1], "1", "PX", 1); return 1;' 1 pouet
(error) ERR This Redis command is not allowed from script script: b0e701c57bb0187cbd6ec8e404a7f6ba19b11a94, on @user_script:1.

BUT the error does not contains commands not allowed after non deterministic anymore, so no fallback on the PHP implementation.

Hence, the new exception catch.

See https://redis.io/docs/interact/programmability/eval-intro/#replicating-commands-instead-of-scripts

@nicolas-grekas
Copy link
Member

Thank you @bastnic.

@nicolas-grekas nicolas-grekas merged commit c44cc73 into symfony:5.4 Mar 13, 2024
10 of 12 checks passed
@bastnic bastnic deleted the feat/lock-redis-7-cluster branch March 14, 2024 09:58
This was referenced Apr 2, 2024
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.

None yet

3 participants