paxos问题与相关的资料记下,回头再好好整理

2024-03-21 17:48

本文主要是介绍paxos问题与相关的资料记下,回头再好好整理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


自己思考的几个问题:

1. paxos为什么要两阶段?一阶段不行吗?

我在paxos made simple中找到这句话

【在一次消息中】Several values could be proposed by different proposers at about the same time, leading to a situation in which every acceptor has accepted a value, but no single value is accepted by a majority of them.

就是如果同时有多个议案,可能会导致每个acceptor都接受一个议案,形成不了大多数

2. 什么叫value被选择了?

A value is chosen when a single proposal with that value has been accepted by a majority of the acceptors. In that case, we say that the proposal (as well as its value) has been chosen.

3. value被选择了能改变吗?

For any v and n, if a proposal with value v and number n is issued, then there is a set S consisting of a majority of acceptors such that
either 

(a) no acceptor in S has accepted any proposal numbered less than n

(b) v is the value of the highest-numbered proposal among all proposals numbered less than n accepted by the acceptors in S.

从(b)中可以看出一旦v被选择了,则作为 value of the highest-numbered proposal , 是不会改变的

4. acceptor做什么事情?

第一阶段:

如果OK(An acceptor can accept a proposal numbered n iff it has not responded to a prepare request having a number greater than n)

  (a) A promise never again to accept a proposal numbered less than n, and
  (b) The proposal with the highest number less than n that it has accepted, if any

否则可以忽视

第二阶段:

 If an acceptor receives an accept request for a proposal numbered n, it accepts the proposal unless it has already responded to a prepare
request having a number greater than n

5. 为什么优化后(指的是可以忽视number小的提议)要remember信息, 原文:With this optimization, an acceptor needs to remember only the highest-numbered proposal that it has ever accepted and the number of the highest-numbered prepare request to which it has responded,Why?

Because P2c must be kept invariant regardless of failures, an acceptor must remember this information even if it fails and then restarts.

即需要保证P2C这个前提,参考3的问题,值不能改变,不能丢失。

6. 接着上面的问题,那我不优化是不是就可以不记住这些信息呢?即不用持久化了,可以吗?

这个问题暂时搁着

7. 为什么需要leader?

leader为了解决活锁问题,同时,在实际设计中,为了简化复杂性,所有的proposal都交给leader提出,理论上,任何的一个Proposer都可以提的,这也是为什么称它为Proposer。

8. proposer干什么的?

第一阶段:

A proposer selects a proposal number n and sends a prepare request with number n to a majority of acceptors.

第二阶段:

If the proposer receives a response to its prepare requests(numbered n) from a majority of acceptors, then it sends an accept
request to each of those acceptors for a proposal numbered n with a value v, where v is the value of the highest-numbered proposal among the responses, or is any value if the responses reported no proposals。

实际上,都是由leader来干的事情

9.有一小段看的不是很懂,关于leaner的

Because of message loss, a value could be chosen with no learner ever finding out. The learner could ask the acceptors what proposals they have accepted, but failure of an acceptor could make it impossible to know whether or not a majority had accepted a particular proposal.In that case, learners will find out what value is chosen only when a new proposal is chosen. If a learner needs to know whether a value has been chosen, it can have a proposer issue a proposal, using the algorithm described above.

In that case指的是failure of an acceptor吗?既然失败了,为什么还会有learners will find out what value is chosen?

最后一句话的意思是让proposer也像提给其他的人那样给learner也发一次吗?


10. 关于leader选举,paxos made simple中提到的是这样的

The famous result of Fischer, Lynch, and Patterson [1] implies that a reliable algorithm for electing a proposer must use either randomness or real time—for example, by using timeouts. H

[1] 指的是Michael J. Fischer, Nancy Lynch, and Michael S. Paterson. Impossibility of distributed consensus with one faulty process. Journal of the ACM, 32(2):374–382, April 1985.


11. 什么是Byzantine fault?

Byzantine fault is an arbitrary fault that occurs during the execution of an algorithm by a distributed system. It encompasses both omission failures (e.g., crash failures, failing to receive a request, or failing to send a response) andcommission failures (e.g., processing a request incorrectly, corrupting local state, and/or sending an incorrect or inconsistent response to a request). When a Byzantine failure has occurred, the system may respond in any unpredictable way, unless it is designed to have Byzantine fault tolerance.

【任意失败】

12. paxos made simple中的例子

所有的instances(1-134, 138, 139) 已经完成 phase 2, 但并没有被执行


实例:命令
instance1: account1 存款 $1000
instance2: account2 取款 $200
instance3: account3 存款$50
...
instance134: account134 转账 $1000
instance135: instances (1-135, 138, 139) 将会对135提出的决议产生影响. 比如, instance135(对account1做了改变) 依赖于之前的 instances,比如说是instance1(同样对account1做了改变),这些信息可以从acceptors获得
原文是In phase 1, an acceptor responds with more than a simple OK only if it has already received a phase 2 message from some proposer. (In the scenario, this was the case only for instances 135 and 140.)
instance136: 
出现gap的可能
1. 对某一账户account136的操作,消息在一阶段提议给过程中可能是丢失了
2. 在一阶段提议后被其他更高的投票取代
3. 第二阶段发送请求接受(accept!)给acceptors的时候丢失,或者被acceptors接受要慢于其他的编号更高的请求。
对于,136则执行no-op操作
instance137: 同上,执行no-op操作
instance138: 两阶段执行完毕
instance139: account139 转账 $1000
instance140: 和135同样的情形 
instance141---:只需要第二个阶段就行了,但是可能会出现gap的可能
原因是
1. 提出的提案编号总是递增的,由于acceptors第一阶段必然会接受的
2. 能够形成大多数,因为实例之间不互相干扰
如果形成不了大多数,还是要跳会到第一阶段的。

以上是基于我的理解



材料:

Paxos Made Practical

http://read.seas.harvard.edu/~kohler/class/08w-dsi/mazieres07paxos.pdf


Paxos Made Live - An Engineering Perspective

http://www.cs.ucla.edu/~kohler/class/08w-dsi/chandra07paxos.pdf

paxos实现

另一个实现是在北大天网实验室的类chubby实现---debby,是使用ICE现实的,看 过之后总觉得有些不太通顺的地方,似乎代码的实现并没有严格遵循paxos算法(很可能是本人水平不足,没看出其中的玄机);还有一个是Diskless Paxos的实现,不使用disk保存状态怎么实现各个角色的“可重启”呢?还没时间研究,应该还是挺有意思的;除了这些,在google code上有paxos的java实现,BerkeleyDB的复制也有使用了paxos算法。

Paxos适合什么场合?

    参考转载的《Paxos算法在大型系统中常见的应用场景》

摘:http://www.cnblogs.com/chinacloud/archive/2011/01/10/1931669.html


paxos made simple:http://pdos.csail.mit.edu/6.824/papers/paxos-simple.pdf

中文翻译:http://blog.csdn.net/sparkliang/article/details/5740882

paxos made simple ppt:http://www.google.com.hk/url?sa=t&rct=j&q=paxos+made+simple&source=web&cd=8&ved=0CGkQFjAH&url=http%3A%2F%2Fwww.cs.nyu.edu%2Fsrg%2Ftalks%2FPaxos.ppt&ei=62pZT_XaFIL2mAWW45XODw&usg=AFQjCNH2sTjV57BZb6pec3AKt-vCWFqAMg&cad=rja

paxos made simple pdf:http://homes.cerias.purdue.edu/~crisn/courses/cs590T/cs590T_lect3_paxos_simple.pdf



paxos made code:http://www.inf.usi.ch/faculty/pedone/MScThesis/marco.pdf


wiki:http://en.wikipedia.org/wiki/Paxos_(computer_science)



the-paxos-commit-algorithm:

http://www.slideshare.net/paolos84/the-paxos-commit-algorithm






这篇关于paxos问题与相关的资料记下,回头再好好整理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/833422

相关文章

解决IDEA报错:编码GBK的不可映射字符问题

《解决IDEA报错:编码GBK的不可映射字符问题》:本文主要介绍解决IDEA报错:编码GBK的不可映射字符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录IDEA报错:编码GBK的不可映射字符终端软件问题描述原因分析解决方案方法1:将命令改为方法2:右下jav

Maven中引入 springboot 相关依赖的方式(最新推荐)

《Maven中引入springboot相关依赖的方式(最新推荐)》:本文主要介绍Maven中引入springboot相关依赖的方式(最新推荐),本文给大家介绍的非常详细,对大家的学习或工作具有... 目录Maven中引入 springboot 相关依赖的方式1. 不使用版本管理(不推荐)2、使用版本管理(推

MyBatis模糊查询报错:ParserException: not supported.pos 问题解决

《MyBatis模糊查询报错:ParserException:notsupported.pos问题解决》本文主要介绍了MyBatis模糊查询报错:ParserException:notsuppo... 目录问题描述问题根源错误SQL解析逻辑深层原因分析三种解决方案方案一:使用CONCAT函数(推荐)方案二:

Redis 热 key 和大 key 问题小结

《Redis热key和大key问题小结》:本文主要介绍Redis热key和大key问题小结,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、什么是 Redis 热 key?热 key(Hot Key)定义: 热 key 常见表现:热 key 的风险:二、

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

Spring 中的循环引用问题解决方法

《Spring中的循环引用问题解决方法》:本文主要介绍Spring中的循环引用问题解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录什么是循环引用?循环依赖三级缓存解决循环依赖二级缓存三级缓存本章来聊聊Spring 中的循环引用问题该如何解决。这里聊

Spring Boot中JSON数值溢出问题从报错到优雅解决办法

《SpringBoot中JSON数值溢出问题从报错到优雅解决办法》:本文主要介绍SpringBoot中JSON数值溢出问题从报错到优雅的解决办法,通过修改字段类型为Long、添加全局异常处理和... 目录一、问题背景:为什么我的接口突然报错了?二、为什么会发生这个错误?1. Java 数据类型的“容量”限制

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

SpringBoot项目中报错The field screenShot exceeds its maximum permitted size of 1048576 bytes.的问题及解决

《SpringBoot项目中报错ThefieldscreenShotexceedsitsmaximumpermittedsizeof1048576bytes.的问题及解决》这篇文章... 目录项目场景问题描述原因分析解决方案总结项目场景javascript提示:项目相关背景:项目场景:基于Spring