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

orderBy() does not works on Redis slaves #181

Open
nnrudakov opened this issue Mar 4, 2019 · 0 comments
Open

orderBy() does not works on Redis slaves #181

nnrudakov opened this issue Mar 4, 2019 · 0 comments
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@nnrudakov
Copy link

Redis SORT command returns an error on slave instances and orderBy() always returns empty result.

To reproduce the problem make Redis master and slave, make and add any ActiveRecord model. Do query with orderBy() on slave instance:

$model = Model::find()->orderBy(['id' => \SORT_DESC])->one();

null will be return. Lua script that will be executed:

local allpks=redis.pcall('SORT', 'model', 'BY', 'model' .. ':a:*->' .. 'id', 'DESC')
if allpks['err'] then
    allpks=redis.pcall('SORT', 'model', 'BY', 'model' .. ':a:*->' .. 'id', 'DESC', 'ALPHA')
end
local pks={}
-- inside doesn't matter
return pks -- {} this is will be return

allpks will be contain an error:

(error) @user_script: 3: -READONLY You can't write against a read only replica.

And empty pks will be return.

Additional info

Q A
Yii vesion 2.0.16
Yii2-Redis vesion 2.0.9
PHP version 7.0+
Redis version 3.6+
Operating system Debian
@samdark samdark added type:bug Bug status:to be verified Needs to be reproduced and validated. labels Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants