From: Timo Sirainen Date: Mon, 24 Oct 2016 21:32:59 +0000 (+0300) Subject: director: Improve debug logging output. X-Git-Tag: 2.2.26~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5364c16b3e70a6a08837c20d96f651c1022fd336;p=thirdparty%2Fdovecot%2Fcore.git director: Improve debug logging output. --- diff --git a/src/director/director-connection.c b/src/director/director-connection.c index c79e4eb70a..7a71f9e4df 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -776,6 +776,8 @@ director_cmd_host_hand_start(struct director_connection *conn, if (remote_ring_completed && !conn->dir->ring_handshaked) { /* clear everything we have and use only what remote sends us */ + dir_debug("%s: We're joining a ring - replace all hosts", + conn->name); hosts = mail_hosts_get(conn->dir->mail_hosts); while (array_count(hosts) > 0) { hostp = array_idx(hosts, 0); @@ -783,16 +785,20 @@ director_cmd_host_hand_start(struct director_connection *conn, } } else if (!remote_ring_completed && conn->dir->ring_handshaked) { /* ignore whatever remote sends */ + dir_debug("%s: Remote is joining our ring - " + "ignore all remote HOSTs", conn->name); conn->ignore_host_events = TRUE; + } else { + dir_debug("%s: Merge rings' hosts", conn->name); } conn->handshake_sending_hosts = TRUE; return TRUE; } static int -director_cmd_is_seen(struct director_connection *conn, - const char *const **_args, - struct director_host **host_r) +director_cmd_is_seen_full(struct director_connection *conn, + const char *const **_args, unsigned int *seq_r, + struct director_host **host_r) { const char *const *args = *_args; struct ip_addr ip; @@ -808,6 +814,7 @@ director_cmd_is_seen(struct director_connection *conn, return -1; } *_args = args + 3; + *seq_r = seq; host = director_host_lookup(conn->dir, &ip, port); if (host == NULL || host->removed) { @@ -826,6 +833,16 @@ director_cmd_is_seen(struct director_connection *conn, return 0; } +static int +director_cmd_is_seen(struct director_connection *conn, + const char *const **_args, + struct director_host **host_r) +{ + unsigned int seq; + + return director_cmd_is_seen_full(conn, _args, &seq, host_r); +} + static bool director_cmd_user_weak(struct director_connection *conn, const char *const *args) @@ -1185,11 +1202,11 @@ director_cmd_user_killed_everywhere(struct director_connection *conn, const char *const *args) { struct director_host *dir_host; - unsigned int username_hash; + unsigned int seq, username_hash; int ret; - if ((ret = director_cmd_is_seen(conn, &args, &dir_host)) != 0) - return ret > 0; + if ((ret = director_cmd_is_seen_full(conn, &args, &seq, &dir_host)) < 0) + return FALSE; if (str_array_length(args) != 1 || str_to_uint(args[0], &username_hash) < 0) { @@ -1197,6 +1214,14 @@ director_cmd_user_killed_everywhere(struct director_connection *conn, return FALSE; } + if (ret > 0) { + i_assert(dir_host != NULL); + dir_debug("User %u - ignoring already seen USER-KILLED-EVERYWHERE " + "with seq=%u <= %s.last_seq=%u", username_hash, + seq, dir_host->name, dir_host->last_seq); + return TRUE; + } + director_user_killed_everywhere(conn->dir, conn->host, dir_host, username_hash); return TRUE; diff --git a/src/director/director.c b/src/director/director.c index 1c93c1d765..672794e2fa 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -791,6 +791,8 @@ director_flush_user(struct director *dir, struct user *user) t_strdup_printf("%u", user->username_hash), NULL}; user->kill_state = USER_KILL_STATE_FLUSHING; + dir_debug("Flushing user %u via %s", user->username_hash, + ctx->socket_path); if ((program_client_create(ctx->socket_path, args, &set, FALSE, &ctx->pclient, &error)) != 0) { @@ -816,6 +818,9 @@ static void director_user_move_free(struct director *dir, struct user *user) { i_assert(user->to_move != NULL); + dir_debug("User %u move finished at state=%s", user->username_hash, + user_kill_state_names[user->kill_state]); + user->kill_state = USER_KILL_STATE_NONE; timeout_remove(&user->to_move); @@ -1004,6 +1009,12 @@ void director_move_user(struct director *dir, struct director_host *src, username_hash); ipc_client_cmd(dir->ipc_proxy, cmd, director_kill_user_callback, ctx); + } else { + /* User is being moved again before the previous move + finished. We'll just continue wherever we left off + earlier. */ + dir_debug("User %u move restarted - previous kill_state=%s", + username_hash, user_kill_state_names[user->kill_state]); } if (orig_src == NULL) { @@ -1151,9 +1162,16 @@ void director_user_killed_everywhere(struct director *dir, struct user *user; user = user_directory_lookup(dir->users, username_hash); - if (user == NULL || - user->kill_state != USER_KILL_STATE_KILLED_WAITING_FOR_EVERYONE) + if (user == NULL) { + dir_debug("User %u no longer exists - ignoring USER-KILLED-EVERYWHERE", + username_hash); return; + } + if (user->kill_state != USER_KILL_STATE_KILLED_WAITING_FOR_EVERYONE) { + dir_debug("User %u kill_state=%s - ignoring USER-KILLED-EVERYWHERE", + username_hash, user_kill_state_names[user->kill_state]); + return; + } director_flush_user(dir, user); director_send_user_killed_everywhere(dir, src, orig_src, username_hash);