From 2d32982ed4e1a2b2881cb9bb85556802d94f9c93 Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Thu, 7 Jul 2016 23:00:29 -0400 Subject: [PATCH] Fix slave boostrap from incomplete master log When the master's log does not contain the complete history, slaves that bootstrap from scratch encountered a loop, because the master falsely assumed a race with log truncation. --- lib/kadm5/ipropd_master.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/kadm5/ipropd_master.c b/lib/kadm5/ipropd_master.c index 8b69fb33b..23bbc8d15 100644 --- a/lib/kadm5/ipropd_master.c +++ b/lib/kadm5/ipropd_master.c @@ -761,7 +761,12 @@ send_diffs (kadm5_server_context *server_context, slave *s, int log_fd, } if (ver == s->version + 1) break; - if (ver == s->version) { + + /* + * We don't expect to reach the slave's version, except when it is + * starting empty with the uber record. + */ + if (ver == s->version && !(ver == 0 && op == kadm_nop)) { /* * This shouldn't happen, but recall we're not holding a lock on * the log. @@ -772,7 +777,9 @@ send_diffs (kadm5_server_context *server_context, slave *s, int log_fd, send_are_you_there(context, s); return 0; } - if (left == 0) { + + /* If we've reached the uber record, send the complete database */ + if (left == 0 || (ver == 0 && op == kadm_nop)) { krb5_storage_free(sp); krb5_warnx(context, "slave %s (version %lu) out of sync with master "