惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

ZooKeeper

Zookeeper Go Client 原理总结 - V2EX etcd vs zookeeper - V2EX zookeeper 关于事务提交的一点疑惑 - V2EX
不懂就问: Zookeeper 分布式锁实现过程中如何保证原子性? - V2EX
garyxiongxiong · 2021-02-02 · via ZooKeeper

garyxiongxiong

V2EX  ›  ZooKeeper

 

garyxiongxiong · 2021 年 2 月 2 日 · 2464 次点击

这是一个创建于 1959 天前的主题,其中的信息可能已经有所发展或是发生改变。

在实现 zookeeper 分布式锁的过程中,为了避免羊群效应,需要在阻塞获取锁的过程中执行以下步骤:

  1. 添加顺序临时节点至锁路径
  2. 获取所路径下的节点列表,判断添加的节点是否在第一位,不在则需阻塞等待锁
  3. 获取节点列表,并监听当前的前一节点
  4. 等待前一节点被删除,重新检查是否获取到锁

在按此逻辑编写后,发现第三步中存在问题,可能会出现如下情况:

在获取节点列表并计算出前一节点preNode后,监听preNode删除事件前,此preNode被删除,则监听器永远不会被触发,造成死锁。

这种情况如何保证第三步的原子性?