Skip to content

hmget returns erroneous data with compression on #1945

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

Closed
2 tasks done
aolley opened this issue Mar 9, 2021 · 3 comments
Closed
2 tasks done

hmget returns erroneous data with compression on #1945

aolley opened this issue Mar 9, 2021 · 3 comments

Comments

@aolley
Copy link
Contributor

aolley commented Mar 9, 2021

Expected behaviour

Calling hmget after setting data with hset should return the same data with or without compression enabled.

Actual behaviour

If compression is enabled, hmget doesn't appear to decompress the data from the fields it fetches.

I'm seeing this behaviour on

  • OS: CentOS 7
  • Redis: 6.0.8
  • PHP: 7.4.12
  • phpredis: 5.3.2

Steps to reproduce, backtrace or example script

<?php

$redis = new RedisCluster(null, ['127.0.0.1:6379']);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);

$redis->hset('a', 'b', ['abc' => 'xyz']);
echo "hget (comp off)\n";
var_export($redis->hget('a', 'b'));
echo "\nhmget (comp off)\n";
var_export($redis->hmget('a', ['b']));

echo "\n\n";

$redis->setOption(Redis::OPT_COMPRESSION, Redis::COMPRESSION_ZSTD);
$redis->hset('c', 'd', ['abc' => 'xyz']);
echo "hget (comp on)\n";
var_export($redis->hget('c', 'd'));
echo "\nhmget (comp on)\n";
var_export($redis->hmget('c', ['d']));

Output:

hget (comp off)                                                                                                                                               
array (
  'abc' => 'xyz',
)
hmget (comp off)
array (
  'b' => 
  array (
    'abc' => 'xyz',
  ),
)

hget (comp on)                                                                                                                                                
array (                                                                                                                                                       
  'abc' => 'xyz',
)
hmget (comp on)
array (
  'd' => '(/ ' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . 'abcxyz',
)

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch
@aolley aolley changed the title hmget returns erroneous data with both compression on hmget returns erroneous data with compression on Mar 9, 2021
@aolley
Copy link
Contributor Author

aolley commented Mar 10, 2021

This looks like the same issue as #1370 - except with hmget rather than hget. I've just confirmed that in code - pull request shortly...

aolley added a commit to aolley/phpredis that referenced this issue Mar 10, 2021
Without this, performing a HMGET call fails to decompress the data before
returning it to php.
@aolley
Copy link
Contributor Author

aolley commented Mar 10, 2021

See: #1946

aolley added a commit to aolley/phpredis that referenced this issue Mar 10, 2021
Without this, performing a HMGET call fails to decompress the data before
returning it to php.
michael-grunder added a commit that referenced this issue Mar 10, 2021
Pass compression flag when performing HMGET (#1945)
@michael-grunder
Copy link
Member

Closing via #1946

michael-grunder pushed a commit that referenced this issue Mar 22, 2021
Without this, performing a HMGET call fails to decompress the data before
returning it to php.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants