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

FIX: Duplicated switchover event. #850

Closed
wants to merge 1 commit into from

Conversation

brido4125
Copy link
Collaborator

๐Ÿ”— Related Issue

โŒจ๏ธ What I did

findChangedGroups ๋กœ์ง์—์„œ swichover์˜ old ํ˜•์ƒ์œผ๋กœ ๋˜๋Œ๋ฆฌ๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.
๋กœ์ง์€ ๋Œ€๋žต ์•„๋ž˜์™€ ๊ฐ™์ด ๊ตฌํ˜„๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค.

  1. ๊ฒ€์‚ฌํ•˜๋ ค๋Š” node์˜ ๊ทธ๋ฃน์ด alreadySwitched์ธ์ง€ ํ™•์ธ
  2. master / slave ์—ฌ๋ถ€๋ฅผ ์ œ์™ธํ•œ groupname, ip, port ์ •๋ณด๋“ค ์ค‘ ๋ณ€๊ฒฝ ์žˆ๋Š”์ง€ ํ™•์ธ
  3. master / slave ์—ฌ๋ถ€๊ฐ€ old ํ˜•์ƒ์œผ๋กœ ๋˜๋Œ๋ ค์กŒ๋Š”์ง€ ํ™•์ธ
  4. flag ์›๋ณต

์šฐ์„  ๋ฆฌ๋ทฐ๋ฅผ ์œ„ํ•ด ํ•œ๊ธ€๋กœ ์ฃผ์„์„ ๋‹ฌ์•„๋‘์—ˆ์Šต๋‹ˆ๋‹ค.
์ถ”ํ›„ ๋ฆฌ๋ทฐ ์™„๋ฃŒ๋˜๋ฉด ์ œ๊ฑฐ ๋˜๋Š” ์˜์–ด๋กœ ๋ณ€๊ฒฝํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

@brido4125 brido4125 self-assigned this Dec 10, 2024
@brido4125 brido4125 requested a review from uhm0311 December 10, 2024 06:17
@brido4125 brido4125 marked this pull request as draft December 10, 2024 07:17
@brido4125 brido4125 marked this pull request as ready for review December 10, 2024 08:42
@brido4125 brido4125 marked this pull request as draft December 10, 2024 09:05
@brido4125 brido4125 marked this pull request as ready for review December 10, 2024 09:11
@brido4125 brido4125 requested a review from uhm0311 December 10, 2024 10:06
uhm0311
uhm0311 previously approved these changes Dec 11, 2024
@jhpark816
Copy link
Collaborator

@oliviarla @namsic
๋ณธ PR์— ๋Œ€ํ•ด ์ถ”๊ฐ€ ๋ฆฌ๋ทฐ์–ด๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

namsic

This comment was marked as resolved.

@brido4125

This comment was marked as resolved.

@namsic

This comment was marked as resolved.

@brido4125

This comment was marked as resolved.

@namsic

This comment was marked as resolved.

@brido4125
Copy link
Collaborator Author

brido4125 commented Dec 16, 2024

๊ทน๋‹จ์ ์ธ ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ์˜ˆ์‹œ๋กœ ๋“ค๊ณ  ์žˆ๊ธฐ๋Š” ํ•˜์ง€๋งŒ, ๋ฐœ์ƒ ํ™•๋ฅ ์ด ๋‚ฎ์œผ๋‹ˆ ๊ณ ๋ คํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค๋Š” ๋…ผ๋ฆฌ๋Š” ์ ์ ˆํ•˜์ง€ ์•Š์•„ ๋ณด์ž…๋‹ˆ๋‹ค.

@namsic ๋‹˜์˜ ์ œ์•ˆํ•ด์ฃผ์‹  ์˜๊ฒฌ์ด ๋„ˆ๋ฌด ๊ทน๋‹จ์ ์ด๋ผ ํ•„์š”ํ•˜์ง€ ์•Š๋‹ค๋ผ๋Š” ๋Š๋‚Œ์˜ ์ฝ”๋ฉ˜ํŠธ๋Š” ์•„๋‹ˆ๋‹ˆ๊นŒ ์˜คํ•ด๋Š” ํ•˜์ง€ ๋ง์•„์ฃผ์‹œ๊ณ , ์ด๋ ‡๊ฒŒ ์ด์•ผ๊ธฐํ•œ ๊ฐ€์žฅ ํฐ ์ด์œ ๋Š” ๊ทน๋‹จ์ ์ธ case๋“ค์— ๋Œ€ํ•ด ๋…ผ์˜ ๋•Œ๋ฌธ์— ์›๋ž˜ ์กด์žฌํ•˜๋Š” PR์˜ ๋ชฉ์ ์„ ์žƒ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žฆ์•„์„œ ๋ง์”€๋“œ๋ ธ์Šต๋‹ˆ๋‹ค.

๋ณ€๊ฒฝ๋œ ๊ตฌํ˜„์—์„œ, alreadySwitched๋ฅผ ํฌํ•จํ•œ ๊ธฐํƒ€ ๋ณ€์ˆ˜๋“ค์ด ๋‹ค์–‘ํ•œ ์‹œ๋‚˜๋ฆฌ์˜ค์—์„œ ์ผ๊ด€๋œ ์ƒํƒœ๋กœ ์ˆ˜๋ ดํ•˜๋Š” ๊ฒƒ์ด ๋ณด์žฅ๋˜๋Š”์ง€๊ฐ€ ๊ถ๊ธˆํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋™์ผํ•œ ๊ทธ๋ฃน์— ๋Œ€ํ•ด ์œ„ ์‹œ๋‚˜๋ฆฌ์˜ค์—์„œ alreadySwitched๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

1. cache list ์กฐํšŒ ์‹œ 1์ฐจ, 2์ฐจ swtichover ๋ชจ๋‘ ์กฐํšŒ ํ•˜๋Š” ๊ฒฝ์šฐ

  • ์บ์‹œ ์„œ๋ฒ„ ์‘๋‹ต์— ์˜ํ•œ 1์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„(flag true๋กœ ๋ณ€๊ฒฝ) (M - S)
  • ์บ์‹œ ์„œ๋ฒ„ ์‘๋‹ต์— ์˜ํ•œ 2์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„(flag true๋กœ ๋ณ€๊ฒฝ) (S - M)
  • 1์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„์— ๋Œ€ํ•œ zk event ๋ฐœ์ƒ -> ๏ฟฝold ํ˜•์ƒ(M - S)์— ๋Œ€ํ•œ zk ์ด๋ฒคํŠธ ๋ฐœ์ƒ (true ๊ฐ’ ๋ฐ ํ˜„์žฌ ํ˜•์ƒ ์œ ์ง€)
  • 2์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„์— ๋Œ€ํ•œ zk event ๋ฐœ์ƒ -> ํ˜•์ƒ(S - M)์ด ๊ฐ™๊ธฐ์— false๋กœ ๋ณ€๊ฒฝ

2. zk ์ด๋ฒคํŠธ ๋ฐœ์ƒ ํ›„ cache list ์กฐํšŒ ์‹œ 2์ฐจ swtichover ํ˜•์ƒ ์กฐํšŒ(๋ง์”€ํ•˜์‹  ๊ฒฝ์šฐ)

  • ์บ์‹œ ์„œ๋ฒ„ ์‘๋‹ต์— ์˜ํ•œ 1์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„(flag true๋กœ ๋ณ€๊ฒฝ) (M - S)
  • ์บ์‹œ ์„œ๋ฒ„ 2์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„ ์‹คํ–‰
  • 2์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„์— ๋Œ€ํ•œ zk event ๋ฐœ์ƒ (S - M) -> ์ตœ์‹  ํ˜•์ƒ์ž„์—๋„ locator ์ž…์žฅ์—์„œ๋Š” old ํ˜•์ƒ -> ๏ฟฝtrue ์œ ์ง€
  • ์บ์‹œ ์„œ๋ฒ„ ์‘๋‹ต์— ์˜ํ•œ 2์ฐจ ์Šค์œ„์น˜ ์˜ค๋ฒ„(flag true๋กœ ๋ณ€๊ฒฝ) (S - M)
  • ์ผ์ • ์‹œ์  ํ›„์— zk ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ, zk์˜ ํ˜•์ƒ๊ณผ locator์˜ ํ˜•์ƒ์ด ๊ฐ™์•„์„œ false๋กœ ๋ณ€๊ฒฝ

๋ง์”€ํ•˜์‹  ๊ฒฝ์šฐ๋„ eventually ํ˜•์ƒ์ด ํ†ต์ผ๋˜๊ณ  flag ๊ฐ’๋„ false๋กœ ๋ณ€๊ฒฝ๋ฉ๋‹ˆ๋‹ค.

namsic
namsic previously approved these changes Dec 18, 2024
Copy link
Collaborator

@namsic namsic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ œ๊ฐ€ ์ดํ•ดํ•œ ๋Œ€๋กœ ์ •๋ฆฌํ•˜๋ฉด,

  1. switchover ์ด์ „ ํ˜•์ƒ์œผ๋กœ ๋˜๋Œ์•„๊ฐ€๋Š” ๊ฒฝ์šฐ๊ฐ€ ์—ฌ์ „ํžˆ ์žˆ์„ ์ˆ˜ ์žˆ๊ณ 
  2. AlreadySwitched flag๊ฐ€ ์ œ ๋•Œ ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์ง€๋งŒ
  3. ์œ„์™€ ๊ฐ™์€ ์‹œ๋‚˜๋ฆฌ์˜ค๋Š” ์—ฌ๋Ÿฌ ๊ทน๋‹จ์  ์ƒํ™ฉ์ด ๊ฒน์น˜๋Š” ์ฝ”๋„ˆ ์ผ€์ด์Šค์— ํ•ด๋‹นํ•˜์—ฌ ์‹ค์ œ ์šด์˜ ํ™˜๊ฒฝ์—์„œ ๋ฐœ์ƒ ๊ฐ€๋Šฅ์„ฑ์ด ์•„์ฃผ ์ž‘์Šต๋‹ˆ๋‹ค.
  4. ๋˜ํ•œ ๊ทธ ๊ฒฝ์šฐ์—๋„ ZK event๋ฅผ ๋” ์ˆ˜์‹ ํ•˜๋‹ค ๋ณด๋ฉด ์–ธ์  ๊ฐ€๋Š” ์ตœ์‹  ํ˜•์ƒ์œผ๋กœ ์ „์ดํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

Copy link
Collaborator

@oliviarla oliviarla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ตœ์ข… ๋ฆฌ๋ทฐ ์™„๋ฃŒ์ž…๋‹ˆ๋‹ค.

@brido4125 brido4125 requested review from jhpark816 and removed request for jhpark816 December 18, 2024 08:31
Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

// old ํ˜•์ƒ์ด ๋“ค์–ด์˜จ ๊ฒฝ์šฐ flag ์›๋ณต skip -> ์ถ”ํ›„ ์‹œ์ ์— ์›๋ณต ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ์ด๋ฒคํŠธ ๋ฌด์กฐ๊ฑด ๋ฐœ์ƒ
// newMaster๊ฐ€ null์ด๋”๋ผ๋„, ์ถ”ํ›„ ์‹œ์ ์—” ์ •์ƒ์ ์ธ ์ด๋ฒคํŠธ ๋ฐœ์ƒ์œผ๋กœ flag ์›๋ณต
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์‚ผ์ค‘ํ™”์—์„œ switchover ์ˆ˜ํ–‰ํ•œ ๋‘ ์บ์‹œ ๋…ธ๋“œ๋Š” ๊ทธ๋Œ€๋กœ ์กด์žฌํ•˜๊ณ 
๋‚˜๋จธ์ง€ 1๊ฐœ slave ๋…ธ๋“œ๊ฐ€ ๋‹ค์šด๋œ ๊ฒฝ์šฐ, changed group์œผ๋กœ ํŒ๋ณ„๋ฉ๋‹ˆ๋‹ค.
์ด ๊ฒฝ์šฐ, ๋‹ค์šด๋œ slave ๋…ธ๋“œ๋ฅผ ์ œ๊ฑฐํ•˜๋ฉด์„œ๋„
switchover๋ฅผ ์›๋ณตํ•˜์ง€ ์•Š๋‚˜์š”?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„์€ ์ฝ”๋“œ๋กœ ํ™•์ธํ•  ์ˆ˜ ์—†๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.
์šด์˜์ž๊ฐ€ ์ •๋ง๋กœ ์‚ผ์ค‘ํ™”๋ฅผ ์ด์ค‘ํ™”๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ์–ด์„œ ์Šค์œ„์น˜์˜ค๋ฒ„ ์ˆ˜ํ–‰ ํ›„ ์Šฌ๋ ˆ์ด๋ธŒ๋ฅผ ํ•˜๋‚˜ ๋‚ด๋ฆฐ ๊ฒƒ์ธ์ง€, ์Šค์œ„์น˜์˜ค๋ฒ„ ์งํ›„์— ์Šฌ๋ ˆ์ด๋ธŒ ํ•˜๋‚˜์— ์žฅ์• ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒƒ์ธ์ง€ ์•Œ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

if (newAddrMap.remove(repl.toString()) == null) { // removed node
changedGroupSet.add(oldGroup.getGroupName());
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ „์ฒด์ ์œผ๋กœ ๋ณต์žกํ•œ ๊ตฌํ˜„์ธ ๋ฐ, ๋” ๋‹จ์ˆœํ•œ ๊ตฌํ˜„์€ ์—†๋Š” ์ง€ ?

@brido4125
Copy link
Collaborator Author

๋ณ„๋„์˜ ํ•ด๊ฒฐ๋ฐฉ์•ˆ์œผ๋กœ ์ฒ˜๋ฆฌ์ค‘์ด๊ธฐ์— closeํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

@brido4125 brido4125 closed this Jan 3, 2025
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.

5 participants