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

Redis wipeStorage does not wipe prometheus related keys #130

Open
bogdandubyk opened this issue Oct 4, 2023 · 2 comments
Open

Redis wipeStorage does not wipe prometheus related keys #130

bogdandubyk opened this issue Oct 4, 2023 · 2 comments

Comments

@bogdandubyk
Copy link

bogdandubyk commented Oct 4, 2023

library verstion v2.7.1
Redis version 3.2

Redis::wipeStorage() method does not work, I add some debug statements to get keys before wiping and after wiping and keys still exists, here is the method with debug statements

  public function wipeStorage(): void
    {
        $this->ensureOpenConnection();

        $searchPattern = "";

        $globalPrefix = $this->redis->getOption(\Redis::OPT_PREFIX);
        // @phpstan-ignore-next-line false positive, phpstan thinks getOptions returns int
        if (is_string($globalPrefix)) {
            $searchPattern .= $globalPrefix;
        }

        $searchPattern .= self::$prefix;
        $searchPattern .= '*';

        dump($this->redis->keys($searchPattern));


        $this->redis->eval(
            <<<LUA
local cursor = "0"
repeat 
    local results = redis.call('SCAN', cursor, 'MATCH', ARGV[1])
    cursor = results[1]
    for _, key in ipairs(results[2]) do
        redis.call('DEL', key)
    end
until cursor == "0"
LUA
            ,
            [$searchPattern],
            0
        );

        dump($this->redis->keys($searchPattern));
    }

so before the eval is called debug return output:

^ array:8 [
  0 => "PROMETHEUS_counter_METRIC_KEYS"
  1 => "PROMETHEUS_:histogram:http_response_body_size_bytes"
  2 => "PROMETHEUS_histogram_METRIC_KEYS"
  3 => "PROMETHEUS_:gauge:php_info"
  4 => "PROMETHEUS_gauge_METRIC_KEYS"
  5 => "PROMETHEUS_:histogram:http_request_duration_milliseconds"
  6 => "PROMETHEUS_:histogram:http_request_body_size_bytes"
  7 => "PROMETHEUS_:counter:http_responses_total"
]

and after eval dump output is identical, so nothing is deleted

@bogdandubyk
Copy link
Author

hmm, okay if I use Redis 5.0 all works fine, but does not work with 3.2

@bogdandubyk
Copy link
Author

I think this needs to be either fixed, to we need add to readme which redis version is supported?

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

1 participant