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

Stateful failover #604

Merged
merged 2 commits into from
Mar 23, 2020
Merged

Stateful failover #604

merged 2 commits into from
Mar 23, 2020

Conversation

rosik
Copy link
Contributor

@rosik rosik commented Feb 25, 2020

This patch introduces new failover mode - stateful.

There are 3 main concepts:

Internal coordinator is a new role, which makes decisions regarding leadership. Earlier it was a part of every instances' failover module, but now it's split away. There may be only one active coordinator in cluster at a time. Its uniqueness is ensured by external storage which manages the lock and saves appointments.

External storage (kingdom.lua) is a stand-alone Tarantool instance which provides locking mechanism and keeps decisions made by the coordinator.

Failover module (the old one) operates on every instance in cluster and gathers leadership information for others modules. It was refactored too, and now it can be described with 4 functions with clearly separated responsibilities:

  • _get_appointments_* generates leadership map by itself or polls it from external storage depending on the mode setting (disabled/eventual/stateful).
  • accept_appointments() just refreshes the cache and tracks if anything changed.
  • failover_loop (a fiber) repeatedly gets new appointments and accepts them using corresponding functions from the above.
  • cfg is called from confapplier.apply_config() (on restart or on committing new clusterwide configuration). At first it gets appointments synchronously and then starts the failover loop.

I didn't forget about

  • Tests
  • Changelog
  • Documentation

Close #148

@rosik rosik force-pushed the gh-148-stateful-failover branch 4 times, most recently from 4a2746d to 4082451 Compare March 17, 2020 16:56
@rosik rosik marked this pull request as ready for review March 17, 2020 17:09
cartridge/failover.old.lua Outdated Show resolved Hide resolved
kingdom.lua Outdated Show resolved Hide resolved
kingdom.lua Outdated Show resolved Hide resolved
kingdom.lua Outdated Show resolved Hide resolved
kingdom.lua Outdated Show resolved Hide resolved
kingdom.lua Outdated Show resolved Hide resolved
@rosik rosik added this to the 2.1.0 (stateful failover) milestone Mar 18, 2020
@rosik rosik force-pushed the gh-148-stateful-failover branch 4 times, most recently from 8340cfc to e882318 Compare March 18, 2020 18:06
@rosik rosik force-pushed the gh-148-stateful-failover branch 2 times, most recently from 553fe0c to e441dee Compare March 18, 2020 22:35
Copy link

@Kasen Kasen left a comment

Choose a reason for hiding this comment

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

I suggest allowing the node to check its status and push it into membership. It may be made with some kind of callback. It may be necessary to check node replication status if this node is storage.

cartridge/failover.lua Show resolved Hide resolved
cartridge/failover.lua Show resolved Hide resolved
cartridge/failover.lua Outdated Show resolved Hide resolved
cartridge/failover.lua Show resolved Hide resolved
cartridge/failover.lua Show resolved Hide resolved
cartridge/roles/coordinator.lua Outdated Show resolved Hide resolved
cartridge/roles/coordinator.lua Show resolved Hide resolved
kingdom.lua Outdated Show resolved Hide resolved
kingdom.lua Show resolved Hide resolved
test/integration/kingdom_test.lua Outdated Show resolved Hide resolved
)

local parts = uri.parse(topology.failover.coordinator_uri)
local parts = uri.parse(topology.failover.storage_uri)
Copy link
Contributor

@HustonMmmavr HustonMmmavr Mar 20, 2020

Choose a reason for hiding this comment

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

Maybe use pool.format_uri, something like that:

local _, err = pool.format_uri(uri)
e_config:assert(
    not err,
    '%s.failover.storage_uri: %s',
    field, err.err
)

@rosik rosik merged commit 887843a into master Mar 23, 2020
@rosik rosik deleted the gh-148-stateful-failover branch March 23, 2020 16:55
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.

☂️ Separate voter role that will help to do failover
6 participants