Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
领导者选举
|
181
图 10-1 展示了霸道领导者选举算法:
•
a) 进程 3 注意到前一个领导者 6 已崩溃,于是向具有更高标识符的进程发送选举消
息来开始新的选举。
•
b) 4 和 5 回应 Alive(存活)消息,因为它们具有比 3 更高的排名。
•
c) 3 通知在此轮响应中排名最高的进程 5。
•
d) 5 被选为新的领导者,它广播 Elected(选举完成)消息,将选举结果通知排名
较低的进程。
a) b) c) d)
图
10-1
:霸道算法。以前的领导者(
6
)发生故障,进程
3
发起新的选举
这种算法的一个明显问题是,在存在网络分区的情况下,它违反了安全性保证(一次最
多只能选举一个领导者)。很容易出现这样的情况:节点将被分成两个或多个独立运行
的子集,每个子集选举出了这个子集的领导者。这种情况被称为
脑裂
(split brain)。
该算法的另一个问题是对排名较高节点有强烈的偏向性,如果这些节点不稳定,可能导
致算法一直处于重新选举状态。一个不稳定的高排名节点提议出任领导者,此后不久发
生故障,稍后又再次赢得选举,然后再次发生故障,整个过程重复进行。可以通过分发
主机质量的度量并在选举时将其纳入考虑因素来解决这一问题。
10.2
依次故障转移
霸道算法有许多改进其各种性质的版本。例如,我们可以使用多个依次(next-in-line)
替代进程作为故障转移候选来缩短重选过程 [GHOLIPOUR09]。
每个选举出的领导者都提供一个故障转移节点的列表。当其中一个进程检测到领导者故
障时,它通过向列表中排名最高的 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787111655169