changeset 18711:2336a3127a0f

doveadm director flush: Unless -F parameter is used, do the flush by moving users. User moving causes the users to be properly kicked out of the old backends before new connections are made to the new backends. This way the user isn't accessed simultaneously by different backends.
author Timo Sirainen <tss@iki.fi>
date Fri, 15 May 2015 16:50:27 +0300
parents 5175f8e600e9
children 0b13bfe5d09b
files src/doveadm/doveadm-director.c
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-director.c	Fri May 15 16:46:14 2015 +0300
+++ b/src/doveadm/doveadm-director.c	Fri May 15 16:50:27 2015 +0300
@@ -24,7 +24,7 @@
 	const char *tag;
 	struct istream *input;
 	bool explicit_socket_path;
-	bool hash_map, user_map;
+	bool hash_map, user_map, force_flush;
 };
 
 struct user_list {
@@ -106,6 +106,9 @@
 		case 'f':
 			ctx->users_path = optarg;
 			break;
+		case 'F':
+			ctx->force_flush = TRUE;
+			break;
 		case 'h':
 			ctx->hash_map = TRUE;
 			break;
@@ -549,7 +552,8 @@
 {
 	const char *line;
 
-	director_send(ctx, "HOST-FLUSH\n");
+	director_send(ctx, ctx->force_flush ?
+		      "HOST-FLUSH\n" : "HOST-RESET-USERS\n");
 
 	line = i_stream_read_next_line(ctx->input);
 	if (line == NULL) {
@@ -572,7 +576,7 @@
 	const char *host, *line;
 	int ret;
 
-	ctx = cmd_director_init(argc, argv, "a:", cmd_director_flush);
+	ctx = cmd_director_init(argc, argv, "a:F", cmd_director_flush);
 	host = argv[optind++];
 	if (host == NULL || argv[optind] != NULL)
 		director_cmd_help(cmd_director_flush);
@@ -593,8 +597,9 @@
 	}
 
 	for (i = 0; i < ips_count; i++) {
-		director_send(ctx,
-			t_strdup_printf("HOST-FLUSH\t%s\n", net_ip2addr(&ip)));
+		director_send(ctx, t_strdup_printf("%s\t%s\n",
+			ctx->force_flush ? "HOST-FLUSH" : "HOST-RESET-USERS",
+			net_ip2addr(&ip)));
 	}
 	for (i = 0; i < ips_count; i++) {
 		line = i_stream_read_next_line(ctx->input);
@@ -779,7 +784,7 @@
 	{ cmd_director_kick, "director kick",
 	  "[-a <director socket path>] <user>" },
 	{ cmd_director_flush, "director flush",
-	  "[-a <director socket path>] <host>|all" },
+	  "[-a <director socket path>] [-f] <host>|all" },
 	{ cmd_director_dump, "director dump",
 	  "[-a <director socket path>]" },
 	{ cmd_director_ring_add, "director ring add",