Check for unstable ulog in ulog_get_entries
authorGreg Hudson <ghudson@mit.edu>
Sun, 26 Jan 2014 22:23:53 +0000 (17:23 -0500)
committerGreg Hudson <ghudson@mit.edu>
Thu, 30 Jan 2014 23:33:10 +0000 (18:33 -0500)
If a process terminates in the middle of a logged database update, it
will release its lock and leave the ulog in the KDB_UNSTABLE state.
kadmind should notice this when it calls ulog_get_entries, but right
now it only checks for the KDB_CORRUPT state (which is never set any
more) and does not recover.  Check for any state other than KDB_STABLE
and recover by resetting the ulog and forcing full resyncs to slaves.

ticket: 7853 (new)
target_version: 1.12.2
tags: pullup

src/lib/kdb/kdb_log.c

index 21cb09dc95a4f6d65891237e6d2176b2a172d651..71f0a330e53e0d772288df132826b4bd8b2e3200 100644 (file)
@@ -561,12 +561,10 @@ ulog_get_entries(krb5_context context, kdb_last_t last,
     if (retval)
         return retval;
 
-    /* Check to make sure we don't have a corrupt ulog first. */
-    if (ulog->kdb_state == KDB_CORRUPT) {
-        ulog_handle->ret = UPDATE_ERROR;
-        (void)ulog_lock(context, KRB5_LOCKMODE_UNLOCK);
-        return KRB5_LOG_CORRUPT;
-    }
+    /* If another process terminated mid-update, reset the ulog and force full
+     * resyncs. */
+    if (ulog->kdb_state != KDB_STABLE)
+        ulog_reset(ulog);
 
     /*
      * We need to lock out other processes here, such as kadmin.local, since we