Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cluster_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -2651,7 +2651,7 @@ cluster_xclaim_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
CLUSTER_RETURN_FALSE(c);
}

array_init(&z_msg);
ZVAL_UNDEF(&z_msg);

ZEND_ASSERT(ctx.mode == REDIS_CTX_DEFAULT || ctx.mode == REDIS_CTX_XAUTOCLAIM);

Expand Down
42 changes: 42 additions & 0 deletions tests/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7996,6 +7996,48 @@ public function testXClaim() {
}
}

public function testXClaimDoesNotLeakMemory() {
if ( ! $this->minVersionCheck('5.0'))
$this->markTestSkipped();
if (memory_get_usage() === 0)
$this->markTestSkipped('Zend memory manager is required');

$this->redis->del('claim-memory');
$this->redis->xGroup('CREATE', 'claim-memory', 'group', '0-0', true);

for ($i = 0; $i < 10; $i++) {
$this->redis->xClaim('claim-memory', 'group', 'consumer', 0, ['0-1'], []);
}

$before = memory_get_usage();
for ($i = 0; $i < 100; $i++) {
$this->redis->xClaim('claim-memory', 'group', 'consumer', 0, ['0-1'], []);
}
$this->assertLTE(0, memory_get_usage() - $before);
$this->redis->del('claim-memory');
}

public function testXAutoClaimDoesNotLeakMemory() {
if ( ! $this->minVersionCheck('6.2'))
$this->markTestSkipped();
if (memory_get_usage() === 0)
$this->markTestSkipped('Zend memory manager is required');

$this->redis->del('autoclaim-memory');
$this->redis->xGroup('CREATE', 'autoclaim-memory', 'group', '0-0', true);

for ($i = 0; $i < 10; $i++) {
$this->redis->xAutoClaim('autoclaim-memory', 'group', 'consumer', 0, '0-0');
}

$before = memory_get_usage();
for ($i = 0; $i < 100; $i++) {
$this->redis->xAutoClaim('autoclaim-memory', 'group', 'consumer', 0, '0-0');
}
$this->assertLTE(0, memory_get_usage() - $before);
$this->redis->del('autoclaim-memory');
}

/* Make sure our XAUTOCLAIM handler works */
public function testXAutoClaim() {
$this->redis->del('ships');
Expand Down
Loading