Fix SlotMap::offsetUnset() corrupting mappings when unsetting a slot in a gap (#1660)

This commit is contained in:
messikiller
2026-03-25 17:36:01 +08:00
committed by GitHub
parent 7a4fa99d13
commit 4c56d5d290
3 changed files with 25 additions and 2 deletions
+5 -2
View File
@@ -2,11 +2,14 @@
## Unreleased
### Added
- Added support for GCRA command (#1657)
- Handle `-READONLY` responses in Redis Cluster for AWS ElastiCache Redis OSS failover events
- Added support for `GCRA` command (#1657)
- Handle Redis Cluster `-READONLY` responses failover events (#1656)
### Changed
- Include command name in unsupported container command error messages (#1653)
### Fixed
- Fixed handling of gap slots in `SlotMap::offsetUnset()` (#1660)
## v3.4.2 (2026-03-09)
### Changed
+1
View File
@@ -264,6 +264,7 @@ class SlotMap implements ArrayAccess, IteratorAggregate, Countable
foreach ($this->slotRanges as $slotRange) {
if (!$slotRange->hasSlot($slot)) {
$results[] = $slotRange;
continue;
}
if (static::isValidRange($slotRange->getStart(), $slot - 1)) {
+19
View File
@@ -403,6 +403,25 @@ class SlotMapTest extends PredisTestCase
$this->assertFalse(isset($slotmap[5461]));
}
/**
* @group disconnected
*/
public function testOffsetUnsetDoesNotPolluteSlotMapOnGapSlot(): void
{
$slotmap = new SlotMap();
$slotmap->setSlots(0, 100, '127.0.0.1:6379');
$slotmap->setSlots(200, 300, '127.0.0.1:6380');
$this->assertFalse(isset($slotmap[150]));
$this->assertNull($slotmap[150]);
unset($slotmap[150]);
$this->assertFalse(isset($slotmap[150]));
$this->assertNull($slotmap[150]);
}
/**
* @group disconnected
*/