Skip to content

Added Hyperf\Crontab\Mutex\RedisServerMutexByNodeName.#7555

Merged
limingxinleo merged 9 commits intohyperf:masterfrom
onekb:master
Feb 1, 2026
Merged

Added Hyperf\Crontab\Mutex\RedisServerMutexByNodeName.#7555
limingxinleo merged 9 commits intohyperf:masterfrom
onekb:master

Conversation

@onekb
Copy link
Contributor

@onekb onekb commented Oct 8, 2025

  • 修复多节点 Docker 环境下容器默认 MAC 前缀一致(例:02:42:ac:..)导致多容器 Redis 锁误判为同一节点的问题:原本的 swoole_get_local_mac() 返回的地址相同,使得节点互相抢锁却都认为自己持有锁(src/Mutex/RedisServerMutex.php:24, 86-139)
  • 改为在启动时生成随机节点标识并缓存于容器或进程,确保每个实例拥有独立身份;若外部注入了 ServerNodeInterface,仍优先使用其名称以支持自定义实现

@huangdijia
Copy link
Member

是不是新增一个独立的类更好

@onekb
Copy link
Contributor Author

onekb commented Oct 8, 2025

是不是新增一个独立的类更好

是说这样?
image
image

@huangdijia
Copy link
Member

不是,通过di更换

limingxinleo
limingxinleo previously approved these changes Feb 1, 2026
@limingxinleo limingxinleo changed the title 使用随机节点标识替换基于 MAC 的 Redis 锁节点区分 Added Hyperf\Crontab\Mutex\RedisServerMutexByNodeName. Feb 1, 2026
@limingxinleo limingxinleo merged commit 2e8cb67 into hyperf:master Feb 1, 2026
76 of 77 checks passed
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.

3 participants