open-nomad/nomad/state
Tim Gross 37134a4a37
eval delete: move batching of deletes into RPC handler and state (#15117)
During unusual outage recovery scenarios on large clusters, a backlog of
millions of evaluations can appear. In these cases, the `eval delete` command can
put excessive load on the cluster by listing large sets of evals to extract the
IDs and then sending larges batches of IDs. Although the command's batch size
was carefully tuned, we still need to be JSON deserialize, re-serialize to
MessagePack, send the log entries through raft, and get the FSM applied.

To improve performance of this recovery case, move the batching process into the
RPC handler and the state store. The design here is a little weird, so let's
look a the failed options first:

* A naive solution here would be to just send the filter as the raft request and
  let the FSM apply delete the whole set in a single operation. Benchmarking with
  1M evals on a 3 node cluster demonstrated this can block the FSM apply for
  several minutes, which puts the cluster at risk if there's a leadership
  failover (the barrier write can't be made while this apply is in-flight).

* A less naive but still bad solution would be to have the RPC handler filter
  and paginate, and then hand a list of IDs to the existing raft log
  entry. Benchmarks showed this blocked the FSM apply for 20-30s at a time and
  took roughly an hour to complete.

Instead, we're filtering and paginating in the RPC handler to find a page token,
and then passing both the filter and page token in the raft log. The FSM apply
recreates the paginator using the filter and page token to get roughly the same
page of evaluations, which it then deletes. The pagination process is fairly
cheap (only abut 5% of the total FSM apply time), so counter-intuitively this
rework ends up being much faster. A benchmark of 1M evaluations showed this
blocked the FSM apply for 20-30ms at a time (typical for normal operations) and
completes in less than 4 minutes.

Note that, as with the existing design, this delete is not consistent: a new
evaluation inserted "behind" the cursor of the pagination will fail to be
deleted.
2022-11-14 14:08:13 -05:00
..
indexer core: add ACL token expiry state, struct, and RPC handling. (#13718) 2022-07-13 15:40:34 +02:00
paginator build: run gofmt on all go source files 2022-08-16 11:14:11 -05:00
autopilot.go autopilot: correctly return errors within state functions. (#12714) 2022-04-21 08:54:50 +02:00
autopilot_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
deployment_events_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
events.go acl: add ACL roles to event stream topic and resolve policies. (#14923) 2022-10-20 09:43:35 +02:00
events_test.go acl: add ACL roles to event stream topic and resolve policies. (#14923) 2022-10-20 09:43:35 +02:00
iterator.go csi: use node MaxVolumes during scheduling (#7565) 2020-03-31 17:16:47 -04:00
schema.go acl: sso auth method schema and store functions (#15191) 2022-11-10 19:42:41 +01:00
schema_test.go ci: swap ci parallelization for unconstrained gomaxprocs 2022-03-15 12:58:52 -05:00
state_changes.go events: Use single eventsFromChanges func (#9281) 2020-11-05 13:06:52 -08:00
state_store.go eval delete: move batching of deletes into RPC handler and state (#15117) 2022-11-14 14:08:13 -05:00
state_store_acl.go acl: add ACL roles to event stream topic and resolve policies. (#14923) 2022-10-20 09:43:35 +02:00
state_store_acl_sso.go acl: sso auth method schema and store functions (#15191) 2022-11-10 19:42:41 +01:00
state_store_acl_sso_test.go acl: sso auth method schema and store functions (#15191) 2022-11-10 19:42:41 +01:00
state_store_acl_test.go cleanup: rename Equals to Equal for consistency (#14759) 2022-10-10 09:28:46 -05:00
state_store_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
state_store_restore.go acl: sso auth method schema and store functions (#15191) 2022-11-10 19:42:41 +01:00
state_store_restore_test.go acl: sso auth method schema and store functions (#15191) 2022-11-10 19:42:41 +01:00
state_store_service_regisration_test.go cleanup: rename Equals to Equal for consistency (#14759) 2022-10-10 09:28:46 -05:00
state_store_service_registration.go cleanup: rename Equals to Equal for consistency (#14759) 2022-10-10 09:28:46 -05:00
state_store_test.go eval delete: move batching of deletes into RPC handler and state (#15117) 2022-11-14 14:08:13 -05:00
state_store_variables.go cleanup: rename Equals to Equal for consistency (#14759) 2022-10-10 09:28:46 -05:00
state_store_variables_oss.go rename SecureVariables to Variables throughout 2022-08-26 16:06:24 -04:00
state_store_variables_test.go cleanup: rename Equals to Equal for consistency (#14759) 2022-10-10 09:28:46 -05:00
testing.go CSI: allow updates to volumes on re-registration (#12167) 2022-03-07 11:06:59 -05:00