Skip to content

Commit

Permalink
Add election leader idle issue and graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed Nov 3, 2023
1 parent 0436c7d commit a604310
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ and this project adheres to
Unreleased
-------------------------------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Added
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``election_leader_idle`` field to GraphQL API.

- new issue when ``box.info.election.leader_idle`` is too high.

-------------------------------------------------------------------------------
[2.8.4] - 2023-10-31
-------------------------------------------------------------------------------
Expand Down
24 changes: 22 additions & 2 deletions cartridge/issues.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ local function list_on_instance(opts)
}
table.insert(ret, issue)
end

for _, replication_info in pairs(box.info.replication) do
local box_info = box.info
for _, replication_info in pairs(box_info.replication) do
local replica = enabled_servers[replication_info.uuid]
if replica == nil then
goto continue
Expand Down Expand Up @@ -292,6 +292,26 @@ local function list_on_instance(opts)
::continue::
end

if box_info.election then
local leader_idle = box_info.election.leader_idle
if leader_idle ~= nil
and leader_idle >= 4 * box.cfg.replication_timeout then
local issue = {
level = 'warning',
topic = 'raft',
replicaset_uuid = replicaset_uuid,
instance_uuid = instance_uuid,
message = string.format(
"Raft leader idle is %f on %s. "..
"Is raft leader alive and connection is healthy?",
leader_idle,
instance_uri
)
}
table.insert(ret, issue)
end
end

local failover_error = failover.get_error()
if failover_error ~= nil then
table.insert(ret, {
Expand Down
1 change: 1 addition & 0 deletions cartridge/lua-api/boxinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ local function get_info(uri)
ro = box_info.ro,
ro_reason = box_info.ro_reason,
election_state = box_info.election and box_info.election.state,
election_leader_idle = box_info.election and box_info.election.leader_idle,
election_mode = box.cfg.election_mode or "off",
synchro_queue_owner = box_info.synchro and box_info.synchro.queue.owner or 0,
},
Expand Down
5 changes: 4 additions & 1 deletion cartridge/webui/gql-boxinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ local boxinfo_schema = {
kind = gql_types.string,
description = 'Current read-only state reason',
},

election_leader_idle = {
kind = gql_types.float,
description = 'Leader idle value in seconds',
},
election_state = {
kind = gql_types.string,
description = 'State after Raft leader election',
Expand Down
17 changes: 10 additions & 7 deletions doc/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# source: http://127.0.0.1:8081/admin/api
# timestamp: Fri Mar 17 2023 16:41:38 GMT+0300 (Москва, стандартное время)
# timestamp: Fri Nov 03 2023 16:54:14 GMT+0300 (Moscow Standard Time)

"""Custom scalar specification."""
directive @specifiedBy(
Expand Down Expand Up @@ -747,27 +747,30 @@ type ServerInfoGeneral {
"""State after Raft leader election"""
election_state: String

"""The number of seconds since the instance started"""
uptime: Float!

"""
The maximum number of threads to use during execution of certain internal
processes (currently socket.getaddrinfo() and coio_call())
"""
worker_pool_threads: Int

"""The number of seconds since the instance started"""
uptime: Float!

"""The UUID of the replica set"""
replicaset_uuid: String!

"""Current working directory of a process"""
work_dir: String

"""A directory where write-ahead log (.xlog) files are stored"""
wal_dir: String

"""Current working directory of a process"""
work_dir: String

"""Current read-only state reason"""
ro_reason: String

"""Leader idle value in seconds"""
election_leader_idle: Float

"""Id of current queue owner"""
synchro_queue_owner: Int!

Expand Down

0 comments on commit a604310

Please sign in to comment.