Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hmget returns erroneous data with compression on #1945

@aolley

Description

@aolley

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions