summaryrefslogtreecommitdiff
path: root/src/server.h
diff options
context:
space:
mode:
authorMoti Cohen <moti.cohen@redis.com>2022-10-27 11:57:04 +0300
committerGitHub <noreply@github.com>2022-10-27 11:57:04 +0300
commitc0d7226274feb6a519a17a169421295da827a30c (patch)
tree5979108e5896190fd08146f61578e00d13b36a60 /src/server.h
parent38028dab8d6d2721865aa17e6fbc31a64ee26761 (diff)
downloadredis-c0d7226274feb6a519a17a169421295da827a30c.tar.gz
Refactor and (internally) rebrand from pause-clients to pause-actions (#11098)
Renamed from "Pause Clients" to "Pause Actions" since the mechanism can pause several actions in redis, not just clients (e.g. eviction, expiration). Previously each pause purpose (which has a timeout that's tracked separately from others purposes), also implicitly dictated what it pauses (reads, writes, eviction, etc). Now it is explicit, and the actions that are paused (bit flags) are defined separately from the purpose. - Previously, when using feature pause-client it also implicitly means to make the server static: - Pause replica traffic - Pauses eviction processing - Pauses expire processing Making the server static is used also for failover and shutdown. This PR internally rebrand pause-client API to become pause-action API. It also Simplifies pauseClients structure by replacing pointers array with static array. The context of this PR is to add another trigger to pause-client which will activated in case of OOM as throttling mechanism ([see here](https://github.com/redis/redis/issues/10907)). In this case we want only to pause client, and eviction actions.
Diffstat (limited to 'src/server.h')
-rw-r--r--src/server.h39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/server.h b/src/server.h
index 80e07fb9d..32b24afc4 100644
--- a/src/server.h
+++ b/src/server.h
@@ -568,13 +568,22 @@ typedef enum {
#define PROPAGATE_AOF 1
#define PROPAGATE_REPL 2
-/* Client pause types, larger types are more restrictive
- * pause types than smaller pause types. */
-typedef enum {
- CLIENT_PAUSE_OFF = 0, /* Pause no commands */
- CLIENT_PAUSE_WRITE, /* Pause write commands */
- CLIENT_PAUSE_ALL /* Pause all commands */
-} pause_type;
+/* Actions pause types */
+#define PAUSE_ACTION_CLIENT_WRITE (1<<0)
+#define PAUSE_ACTION_CLIENT_ALL (1<<1) /* must be bigger than PAUSE_ACTION_CLIENT_WRITE */
+#define PAUSE_ACTION_EXPIRE (1<<2)
+#define PAUSE_ACTION_EVICT (1<<3)
+#define PAUSE_ACTION_REPLICA (1<<4) /* pause replica traffic */
+
+/* common sets of actions to pause/unpause */
+#define PAUSE_ACTIONS_CLIENT_WRITE_SET (PAUSE_ACTION_CLIENT_WRITE|\
+ PAUSE_ACTION_EXPIRE|\
+ PAUSE_ACTION_EVICT|\
+ PAUSE_ACTION_REPLICA)
+#define PAUSE_ACTIONS_CLIENT_ALL_SET (PAUSE_ACTION_CLIENT_ALL|\
+ PAUSE_ACTION_EXPIRE|\
+ PAUSE_ACTION_EVICT|\
+ PAUSE_ACTION_REPLICA)
/* Client pause purposes. Each purpose has its own end time and pause type. */
typedef enum {
@@ -585,7 +594,7 @@ typedef enum {
} pause_purpose;
typedef struct {
- pause_type type;
+ uint32_t paused_actions; /* Bitmask of actions */
mstime_t end;
} pause_event;
@@ -1531,10 +1540,9 @@ struct redisServer {
rax *clients_timeout_table; /* Radix tree for blocked clients timeouts. */
int in_nested_call; /* If > 0, in a nested call of a call */
rax *clients_index; /* Active clients dictionary by client ID. */
- pause_type client_pause_type; /* True if clients are currently paused */
+ uint32_t paused_actions; /* Bitmask of actions that are currently paused */
list *postponed_clients; /* List of postponed clients */
- mstime_t client_pause_end_time; /* Time when we undo clients_paused */
- pause_event *client_pause_per_purpose[NUM_PAUSE_PURPOSES];
+ pause_event client_pause_per_purpose[NUM_PAUSE_PURPOSES];
char neterr[ANET_ERR_LEN]; /* Error buffer for anet.c */
dict *migrate_cached_sockets;/* MIGRATE cached sockets */
redisAtomic uint64_t next_client_id; /* Next client unique ID. Incremental. */
@@ -2528,10 +2536,11 @@ void flushSlavesOutputBuffers(void);
void disconnectSlaves(void);
void evictClients(void);
int listenToPort(connListener *fds);
-void pauseClients(pause_purpose purpose, mstime_t end, pause_type type);
-void unpauseClients(pause_purpose purpose);
-int areClientsPaused(void);
-int checkClientPauseTimeoutAndReturnIfPaused(void);
+void pauseActions(pause_purpose purpose, mstime_t end, uint32_t actions_bitmask);
+void unpauseActions(pause_purpose purpose);
+uint32_t isPausedActions(uint32_t action_bitmask);
+uint32_t isPausedActionsWithUpdate(uint32_t action_bitmask);
+void updatePausedActions(void);
void unblockPostponedClients();
void processEventsWhileBlocked(void);
void whileBlockedCron();