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

INTERNAL: changeRole logic when repl nodes updated. #822

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

brido4125
Copy link
Collaborator

๐Ÿ”— Related Issue

https://github.com/jam2in/arcus-works/issues/598

โŒจ๏ธ What I did

๊ธฐ์กด ReplLocator์˜ update ๋ฉ”์„œ๋“œ๋Š”
์˜ค๋ฒ„๋กœ๋”ฉ๋˜์–ด ์•„๋ž˜์˜ ๋‘ ๊ฐ€์ง€๋ฅผ ๊ฐ€์ง„๋‹ค.

  • public void update(Collection<MemcachedNode> toAttach, Collection<MemcachedNode> toDelete)
  • public void update(Collection<MemcachedNode> toAttach, Collection<MemcachedNode> toDelete, Collection<MemcachedReplicaGroup> changeRoleGroups)

์‹ค์ œ๋กœ ์บ์‹œ ๋ฆฌ์ŠคํŠธ update ์‹œ ์‚ฌ์šฉ์‹œ ํ˜ธ์ถœ๋˜๋Š” ๊ฒƒ์€ ๋‘๋ฒˆ์งธ ๋ฉ”์„œ๋“œ์ด๊ณ 
Locator ์ธํ„ฐํŽ˜์ด์Šค๋กœ๋ถ€ํ„ฐ ์ƒ์† ๋ฐ›์€ ๋ฉ”์„œ๋“œ๋Š” ์ฒซ๋ฒˆ์งธ ๋ฉ”์„œ๋“œ์ด๋‹ค.

์œ„ ๋‘ ๋ฉ”์„œ๋“œ๋ฅผ ๋ถ„๋ฆฌํ•ด์„œ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ 
1๋ฒˆ ๋ฉ”์„œ๋“œ๋กœ ํ†ต์ผํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์„ ๊ฐ€์ง„ PR์ด๋‹ค.

ํ†ต์ผ์„ ํ•ด์•ผ ์ถ”ํ›„ locator.update(...)๋ฅผ ํ†ตํ•ด
Repl๊ณผ Relp์ด ์ ์šฉ๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ๋ฅผ ํ•œ๋ฒˆ์— ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋‹ค.

changeRoleGroups ์ธ์ž๋Š” switch over ๋˜๋Š” fail over๊ฐ€ ๋ฐœ์ƒํ•œ Repl ๊ทธ๋ฃน์„ ์ปฌ๋ ‰์…˜์— ๋ชจ์•„๋‘”๋‹ค.
์ถ”ํ›„ master <-> slave ๊ฐ„์˜ ์—ญํ•  ๋ณ€๊ฒฝ์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•จ์ด๋‹ค.

์ •๋ฆฌํ•˜์ž๋ฉด ํ•˜๋‚˜์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด update์˜
changeRoleGroups ์ธ์ž๋ฅผ ์ œ๊ฑฐํ•˜๋Š” PR์ด๋‹ค.

๋กœ์ง ์„ค๋ช…

switch over ๋˜๋Š” fail over์ธ ๊ฒฝ์šฐ๋Š” oldSlave์— newMaster๊ฐ€ ์กด์žฌํ•œ๋‹ค.
์ฆ‰, attachNodes์— master node๊ฐ€ ๋  ๋…ธ๋“œ๋Š” ์—†๊ณ  ์ƒˆ๋กœ์šด Slave๊ฐ€ ๋  ๋…ธ๋“œ๋Š” ์กด์žฌํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ธฐ์กด ๋กœ์ง์€ locator ๋‚ด์—์„œ remove -> changeRole -> add ์ˆœ์œผ๋กœ ๋กœ์ง์„ ์ฒ˜๋ฆฌํ•œ๋‹ค.
์ค‘๊ฐ„์— changeRole์„ ํ•˜๊ฒŒ ๋˜๋ฉด old master๋Š” slave๋กœ
master candidate์ธ slave๋Š” new master๋กœ ์Šน๊ฒฉํ•œ๋‹ค.

๊ธฐ์กด ๋กœ์ง์˜ ์˜ˆ๋ฅผ ๋“ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

  • master canditate : b
  • ์‚ญ์ œ ์˜ˆ์ • slave : d
------๊ธฐ์กด----------------remove---------------changeRole---->
(M : a, S : b, c, d) -> (M : a, S : b, c) -> (M : b, S : c, a)

๋ณ€๊ฒฝ๋œ ๋กœ์ง์€ changeRole -> remove -> add ์ˆœ์œผ๋กœ update๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค.

------๊ธฐ์กด----------------changeRole---------------remove---->
(M : a, S : b, c, d) -> (M : b, S : c, d, a) -> (M : b, S : c, a)

์ฐธ๊ณ ๋กœ remove ๋กœ์ง์€ MemcachedReplicaGroupImpl์˜
deleteMemcachedNode ์—์„œ ์ˆ˜ํ–‰ํ•œ๋‹ค.

@brido4125 brido4125 self-assigned this Sep 30, 2024
@brido4125 brido4125 marked this pull request as draft September 30, 2024 07:15
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.

1 participant