Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASPaxos 在Acceptor里缺少一个vballot #2

Closed
drmingdrmer opened this issue Mar 19, 2022 · 2 comments
Closed

CASPaxos 在Acceptor里缺少一个vballot #2

drmingdrmer opened this issue Mar 19, 2022 · 2 comments

Comments

@drmingdrmer
Copy link

这篇文章里:
https://vizee.org/2019/12/11/caspaxos-implement/

Acceptor 需要存储2个ballot: 除了下面这个见到的最大ballot, 还有一个最后接受一个value时的ballot:

type Acceptor struct {
	mu        sync.Mutex
	ballotNum int
        // vballot int
	value     *ValueType
}

onAccept时, 需要更新vballot:

func onAccept(args *Propose) *Accept {
	acceptor := &self.acceptor
	acceptor.mu.Lock()
	defer acceptor.mu.Unlock()
	if acceptor.ballotNum > args.BallotNum {
		return &Accept{
			OK: false,
		}
	}
	acceptor.ballotNum = args.BallotNum
        // Add the following line:
        // acceptor.vbalot = args.BallotNum
	acceptor.value = args.Value
	return &Accept{
		OK: true,
	}
}

CASPaxos paper里写的不清楚,完全没提vballot, 它的TLA里有提到:
https://gist.github.com/grogers0/c7e87f9dfe58c6070b19db9d3c073b72#file-gryadkacasregister-tla-L50

ballot跟vballot跟classic paxos中的行为是一样的. 这里有一个classic paxos中实现accept的例子:
https://github.com/openacid/paxoskv/blob/93cbcd20b37d5588880130d263a8dcfdec5d4544/paxoskv/impl.go#L258-L281

@vizee
Copy link
Owner

vizee commented Jun 1, 2022

@drmingdrmer 抱歉,我今天才看到 issue,这个 vballot 的设计我需要再理解一下,非常感谢大佬指正!

@vizee
Copy link
Owner

vizee commented Jun 10, 2022

已经修复问题代码,再次感谢 xp 大佬回复❤️

@vizee vizee closed this as completed Jun 10, 2022
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

No branches or pull requests

2 participants