Skip to content

Free pending RedisCluster MULTI callbacks on destruction - #2956

Open
ebubekiryigit wants to merge 2 commits into
phpredis:developfrom
ebubekiryigit:fix/cluster-multi-queue-leak
Open

ebubekiryigit wants to merge 2 commits into
phpredis:developfrom
ebubekiryigit:fix/cluster-multi-queue-leak

Conversation

@ebubekiryigit

Copy link
Copy Markdown
Contributor

Destroying a RedisCluster object with an open MULTI leaves its pending reply callbacks and allocated callback contexts behind.

Call the existing cluster_free_queue() helper during object destruction. This releases pending callbacks and their registered contexts without executing the transaction or changing connection handling.

Add a memory regression test using queued GET and HMGET commands. A warmup and bounded tolerance accommodate connection bookkeeping while still detecting retained transaction contexts.

Validation:

  • Redis, RedisArray, RedisCluster and RedisSentinel suites passed on PHP 8.5 / Redis 8.8.
  • The regression passed 12 repeated runs per persistent-pooling mode and failed on current develop.
  • Focused Valgrind probes reported no errors or leaks with pooling enabled and disabled.

Separate aggregate-result ownership leaks in abandoned or discarded distributed commands, such as MGET/MSETNX, remain outside this patch and are addressed in #2798.

Release pending fold items and their owned contexts when the object is destroyed without EXEC or DISCARD. Add a regression with queued GET and HMGET commands.
Warm up connection bookkeeping before measuring retained transaction
contexts. Increase the sample window and allow bounded allocator noise
while keeping the regression well below the unfixed memory growth.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant