diff options
Diffstat (limited to 'src/server.h')
-rw-r--r-- | src/server.h | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/src/server.h b/src/server.h index eb967a042..b293afcee 100644 --- a/src/server.h +++ b/src/server.h @@ -115,6 +115,7 @@ typedef long long ustime_t; /* microsecond time type. */ #define NET_ADDR_STR_LEN (NET_IP_STR_LEN+32) /* Must be enough for ip:port */ #define CONFIG_BINDADDR_MAX 16 #define CONFIG_MIN_RESERVED_FDS 32 +#define CONFIG_DEFAULT_PROC_TITLE_TEMPLATE "{title} {listen-addr} {server-mode}" #define ACTIVE_EXPIRE_CYCLE_SLOW 0 #define ACTIVE_EXPIRE_CYCLE_FAST 1 @@ -270,6 +271,8 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT]; #define CLIENT_DENY_BLOCKING (1ULL<<41) /* Indicate that the client should not be blocked. currently, turned on inside MULTI, Lua, RM_Call, and AOF client */ +#define CLIENT_REPL_RDBONLY (1ULL<<42) /* This client is a replica that only wants + RDB without replication buffer. */ /* Client block type (btype field in client structure) * if CLIENT_BLOCKED flag is set. */ @@ -317,6 +320,14 @@ typedef enum { REPL_STATE_CONNECTED, /* Connected to master */ } repl_state; +/* The state of an in progress coordinated failover */ +typedef enum { + NO_FAILOVER = 0, /* No failover in progress */ + FAILOVER_WAIT_FOR_SYNC, /* Waiting for target replica to catch up */ + FAILOVER_IN_PROGRESS /* Waiting for target replica to accept + * PSYNC FAILOVER request. */ +} failover_state; + /* State of slaves from the POV of the master. Used in client->replstate. * In SEND_BULK and ONLINE state the slave receives new updates * in its output queue. In the WAIT_BGSAVE states instead the server is waiting @@ -870,6 +881,7 @@ typedef struct client { size_t sentlen; /* Amount of bytes already sent in the current buffer or object being sent. */ time_t ctime; /* Client creation time. */ + long duration; /* Current command duration. Used for measuring latency of blocking/non-blocking cmds */ time_t lastinteraction; /* Time of the last interaction, used for timeout */ time_t obuf_soft_limit_reached_time; uint64_t flags; /* Client flags: CLIENT_* macros. */ @@ -942,6 +954,19 @@ struct moduleLoadQueueEntry { robj **argv; }; +struct sentinelLoadQueueEntry { + int argc; + sds *argv; + int linenum; + sds line; +}; + +struct sentinelConfig { + list *pre_monitor_cfg; + list *monitor_cfg; + list *post_monitor_cfg; +}; + struct sharedObjectsStruct { robj *crlf, *ok, *err, *emptybulk, *czero, *cone, *pong, *space, *colon, *queued, *null[4], *nullarray[4], *emptymap[4], *emptyset[4], @@ -951,7 +976,8 @@ struct sharedObjectsStruct { *busykeyerr, *oomerr, *plus, *messagebulk, *pmessagebulk, *subscribebulk, *unsubscribebulk, *psubscribebulk, *punsubscribebulk, *del, *unlink, *rpop, *lpop, *lpush, *rpoplpush, *lmove, *blmove, *zpopmin, *zpopmax, - *emptyscan, *multi, *exec, *left, *right, + *emptyscan, *multi, *exec, *left, *right, *persist, *set, *pexpireat, + *pexpire, *pxat, *px, *select[PROTO_SHARED_SELECT_CMDS], *integers[OBJ_SHARED_INTEGERS], *mbulkhdr[OBJ_SHARED_BULKHDR_LEN], /* "*<value>\r\n" */ @@ -1124,6 +1150,7 @@ struct redisServer { int config_hz; /* Configured HZ value. May be different than the actual 'hz' field value if dynamic-hz is enabled. */ + mode_t umask; /* The umask value of the process on startup */ int hz; /* serverCron() calls frequency in hertz */ int in_fork_child; /* indication that this is a fork child */ redisDb *db; @@ -1280,6 +1307,8 @@ struct redisServer { int supervised; /* 1 if supervised, 0 otherwise. */ int supervised_mode; /* See SUPERVISED_* */ int daemonize; /* True if running as a daemon */ + int set_proc_title; /* True if change proc title */ + char *proc_title_template; /* Process title template format */ clientBufferLimitsConfig client_obuf_limits[CLIENT_TYPE_OBUF_COUNT]; /* AOF persistence */ int aof_enabled; /* AOF configuration */ @@ -1530,6 +1559,7 @@ struct redisServer { int lazyfree_lazy_expire; int lazyfree_lazy_server_del; int lazyfree_lazy_user_del; + int lazyfree_lazy_user_flush; /* Latency monitor */ long long latency_monitor_threshold; dict *latency_events; @@ -1554,6 +1584,16 @@ struct redisServer { char *bio_cpulist; /* cpu affinity list of bio thread. */ char *aof_rewrite_cpulist; /* cpu affinity list of aof rewrite process. */ char *bgsave_cpulist; /* cpu affinity list of bgsave process. */ + /* Sentinel config */ + struct sentinelConfig *sentinel_config; /* sentinel config to load at startup time. */ + /* Coordinate failover info */ + mstime_t failover_end_time; /* Deadline for failover command. */ + int force_failover; /* If true then failover will be foreced at the + * deadline, otherwise failover is aborted. */ + char *target_replica_host; /* Failover target host. If null during a + * failover then any replica can be used. */ + int target_replica_port; /* Failover target port */ + int failover_state; /* Failover state */ }; typedef struct pubsubPattern { @@ -1679,6 +1719,7 @@ extern dictType hashDictType; extern dictType replScriptCacheDictType; extern dictType dbExpiresDictType; extern dictType modulesDictType; +extern dictType sdsReplyDictType; /*----------------------------------------------------------------------------- * Functions prototypes @@ -1728,7 +1769,8 @@ void getRandomBytes(unsigned char *p, size_t len); uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); void exitFromChild(int retcode); size_t redisPopcount(void *s, long count); -void redisSetProcTitle(char *title); +int redisSetProcTitle(char *title); +int validateProcTitleTemplate(const char *template); int redisCommunicateSystemd(const char *sd_notify_msg); void redisSetCpuAffinity(const char *cpulist); @@ -1973,6 +2015,10 @@ void feedReplicationBacklog(void *ptr, size_t len); void showLatestBacklog(void); void rdbPipeReadHandler(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask); void rdbPipeWriteHandlerConnRemoved(struct connection *conn); +void clearFailoverState(void); +void updateFailoverStatus(void); +void abortFailover(const char *err); +const char *getFailoverStateString(); /* Generic persistence functions */ void startLoadingFile(FILE* fp, char* filename, int rdbflags); @@ -2042,7 +2088,7 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen); sds ACLDefaultUserFirstPassword(void); uint64_t ACLGetCommandCategoryFlagByName(const char *name); int ACLAppendUserForLoading(sds *argv, int argc, int *argc_err); -char *ACLSetUserStringError(void); +const char *ACLSetUserStringError(void); int ACLLoadConfiguredUsers(void); sds ACLDescribeUser(user *u); void ACLLoadUsersAtStartup(void); @@ -2236,6 +2282,7 @@ void appendServerSaveParams(time_t seconds, int changes); void resetServerSaveParams(void); struct rewriteConfigState; /* Forward declaration to export API. */ void rewriteConfigRewriteLine(struct rewriteConfigState *state, const char *option, sds line, int force); +void rewriteConfigMarkAsProcessed(struct rewriteConfigState *state, const char *option); int rewriteConfig(char *path, int force_all); void initConfigValues(); @@ -2330,7 +2377,9 @@ int clusterSendModuleMessageToTarget(const char *target, uint64_t module_id, uin void initSentinelConfig(void); void initSentinel(void); void sentinelTimer(void); -char *sentinelHandleConfiguration(char **argv, int argc); +const char *sentinelHandleConfiguration(char **argv, int argc); +void queueSentinelConfig(sds *argv, int argc, int linenum, sds line); +void loadSentinelConfigFromQueue(void); void sentinelIsRunning(void); /* redis-check-rdb & aof */ @@ -2344,6 +2393,7 @@ int ldbRemoveChild(pid_t pid); void ldbKillForkedSessions(void); int ldbPendingChildren(void); sds luaCreateFunction(client *c, lua_State *lua, robj *body); +void freeLuaScriptsAsync(dict *lua_scripts); /* Blocked clients */ void processUnblockedClients(void); @@ -2356,6 +2406,7 @@ void disconnectAllBlockedClients(void); void handleClientsBlockedOnKeys(void); void signalKeyAsReady(redisDb *db, robj *key, int type); void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeout, robj *target, struct listPos *listpos, streamID *ids); +void updateStatsOnUnblock(client *c, long blocked_us, long reply_us); /* timeout.c -- Blocked clients timeout and connections timeout. */ void addClientToTimeoutTable(client *c); @@ -2403,6 +2454,8 @@ void setnxCommand(client *c); void setexCommand(client *c); void psetexCommand(client *c); void getCommand(client *c); +void getexCommand(client *c); +void getdelCommand(client *c); void delCommand(client *c); void unlinkCommand(client *c); void existsCommand(client *c); @@ -2505,6 +2558,7 @@ void zpopminCommand(client *c); void zpopmaxCommand(client *c); void bzpopminCommand(client *c); void bzpopmaxCommand(client *c); +void zrandmemberCommand(client *c); void multiCommand(client *c); void execCommand(client *c); void discardCommand(client *c); @@ -2538,6 +2592,7 @@ void hvalsCommand(client *c); void hgetallCommand(client *c); void hexistsCommand(client *c); void hscanCommand(client *c); +void hrandfieldCommand(client *c); void configCommand(client *c); void hincrbyCommand(client *c); void hincrbyfloatCommand(client *c); @@ -2607,6 +2662,7 @@ void lolwutCommand(client *c); void aclCommand(client *c); void stralgoCommand(client *c); void resetCommand(client *c); +void failoverCommand(client *c); #if defined(__GNUC__) void *calloc(size_t count, size_t size) __attribute__ ((deprecated)); |