Two-phase HDB commit via iprop log, + GC for log
We used to update the iprop log and HDB in different orders depending on the kadm5 operation, which then led to various race conditions. The iprop log now functions as a two-phase commit (with roll forward) log for HDB changes. The log is auto-truncated, keeping the latest entries that fit in a configurable maximum number of bytes (defaults to 50MB). See the log-max-size parameter description in krb5.conf(5). The iprop log format and the protocol remain backwards-compatible with earlier versions of Heimdal. This is NOT a flag-day; there is NO need to update all the slaves at once with the master, though it is advisable in general. Rolling upgrades and downgrades should work. The sequence of updates is now (with HDB and log open and locked): a) check that the HDB operation will succeed if attempted, b) append to iprop log and fsync() it, c) write to HDB (which should fsync()), d) mark last log record committed (no fsync in this case). Every kadm5 write operation recover transactions not yet confirmed as committed, thus there can be at most one unconfirmed commit on a master KDC. Reads via kadm5_get_principal() also attempt to lock the log, and if successful, recover unconfirmed transactions; readers must have write access and must win any race to lock the iprop log. The ipropd-master daemon also attempts to recover unconfirmed transactions when idle. The log now starts with a nop record whose payload records the offset of the logical end of the log: the end of the last confirmed committed transaction. This is kown as the "uber record". Its purpose is two-fold: act as the confirmation of committed transactions, and provide an O(1) method of finding the end of the log (i.e., without having to traverse the entire log front to back). Two-phase commit makes all kadm5 writes single-operation atomic transactions (though some kadm5 operations, such as renames of principals, and changes to principals' aliases, use multiple low-level HDB write operations, but still all in one transaction). One can still hold a lock on the HDB across many operations (e.g., by using the lock command in a kadmin -l or calling kadm5_lock()) in order to push multiple transactions in sequence, but this sequence will not be atomic if the process or host crashes in the middle. As before, HDB writes which do not go through the kadm5 API are excluded from all of this, but there should be no such writes. Lastly, the iprop-log(1) command is enhanced as follows: - The dump, last-version, truncate, and replay sub-commands now have an option to not lock the log. This is useful for inspecting a running system's log file, especially on slave KDCs. - The dump, last-version, truncate, and replay sub-commands now take an optional iprop log file positional argument, so that they may be used to inspect log files other than the running system's configured/default log file. Extensive code review and some re-writing for clarity by Viktor Dukhovni.
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
.Os Heimdal
|
||||
.Sh NAME
|
||||
.Nm iprop-log
|
||||
.Nd maintain the iprop log file
|
||||
.Nd examine and maintain the iprop log file
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl Fl version
|
||||
@@ -54,7 +54,20 @@
|
||||
.Fl Fl realm= Ns Ar string
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl K Ar integer \*(Ba Xo
|
||||
.Fl Fl keep-entries= Ns Ar integer
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl B Ar integer \*(Ba Xo
|
||||
.Fl Fl max-bytes= Ns Ar integer
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl R \*(Ba Xo
|
||||
.Fl Fl reset
|
||||
.Xc
|
||||
.Oc
|
||||
.Op Fl h | Fl Fl help
|
||||
.Op Ar log-file
|
||||
.Pp
|
||||
.Nm iprop-log dump
|
||||
.Oo Fl c Ar file \*(Ba Xo
|
||||
@@ -65,7 +78,16 @@
|
||||
.Fl Fl realm= Ns Ar string
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl n \*(Ba Xo
|
||||
.Fl Fl no-lock
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl R \*(Ba Xo
|
||||
.Fl Fl reverse
|
||||
.Xc
|
||||
.Oc
|
||||
.Op Fl h | Fl Fl help
|
||||
.Op Ar log-file
|
||||
.Pp
|
||||
.Nm iprop-log replay
|
||||
.Op Fl Fl start-version= Ns Ar version-number
|
||||
@@ -79,6 +101,35 @@
|
||||
.Xc
|
||||
.Oc
|
||||
.Op Fl h | Fl Fl help
|
||||
.Op Ar log-file
|
||||
.Pp
|
||||
.Nm iprop-log last-version
|
||||
.Oo Fl c Ar file \*(Ba Xo
|
||||
.Fl Fl config-file= Ns Ar file
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl r Ar string \*(Ba Xo
|
||||
.Fl Fl realm= Ns Ar string
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl n \*(Ba Xo
|
||||
.Fl Fl no-lock
|
||||
.Xc
|
||||
.Oc
|
||||
.Op Fl h | Fl Fl help
|
||||
.Op Ar log-files
|
||||
.Pp
|
||||
.Nm iprop-log signal
|
||||
.Oo Fl c Ar file \*(Ba Xo
|
||||
.Fl Fl config-file= Ns Ar file
|
||||
.Xc
|
||||
.Oc
|
||||
.Oo Fl r Ar string \*(Ba Xo
|
||||
.Fl Fl realm= Ns Ar string
|
||||
.Xc
|
||||
.Oc
|
||||
.Op Fl h | Fl Fl help
|
||||
.Pp
|
||||
.Sh DESCRIPTION
|
||||
Supported options:
|
||||
.Bl -tag -width Ds
|
||||
@@ -94,11 +145,42 @@ command can be one of the following:
|
||||
configuration file
|
||||
.It Fl r Ar string , Fl Fl realm= Ns Ar string
|
||||
realm
|
||||
.It Xo
|
||||
.Fl K Ar integer ,
|
||||
.Fl Fl keep-entries= Ns Ar integer
|
||||
.Xc
|
||||
.It Xo
|
||||
.Fl B Ar integer ,
|
||||
.Fl Fl max-bytes= Ns Ar integer
|
||||
.Xc
|
||||
.It Xo
|
||||
.Fl R ,
|
||||
.Fl Fl reset
|
||||
.Xc
|
||||
.El
|
||||
.Pp
|
||||
Truncates the log. Sets the new logs version number for the to the
|
||||
last entry of the old log. If the log is truncted by emptying the
|
||||
file, the log will start over at the first version (0).
|
||||
If
|
||||
.Fl Fl reset
|
||||
is given, then the given, configured, or default log file will be
|
||||
truncated and will start at version 1. This forces full propagations to
|
||||
all slave KDCs.
|
||||
.Pp
|
||||
Otherwise the log will be truncated but some entries will be preserved,
|
||||
as specified by the
|
||||
.Fl Fl keep-entries
|
||||
and/or
|
||||
.Fl Fl max-bytes
|
||||
options. The largest number of
|
||||
.Fl Fl keep-entries
|
||||
entries that are available and fit in the given
|
||||
.Fl Fl max-bytes
|
||||
option will be used. The
|
||||
.Fl Fl keep-entries option defaults to 100, and the
|
||||
.Fl Fl max-bytes
|
||||
option defaults to the
|
||||
.Ar log-max-size
|
||||
parameter in the configuration.
|
||||
.Pp
|
||||
.It dump
|
||||
.Bl -tag -width Ds
|
||||
.It Fl c Ar file , Fl Fl config-file= Ns Ar file
|
||||
@@ -108,9 +190,23 @@ configuration file
|
||||
.Fl Fl realm= Ns Ar string
|
||||
.Xc
|
||||
realm
|
||||
.It Xo
|
||||
.Fl n Ar string ,
|
||||
.Fl Fl no-lock
|
||||
.Xc
|
||||
.It Xo
|
||||
.Fl R Ar string ,
|
||||
.Fl Fl reverse
|
||||
.Xc
|
||||
.El
|
||||
.Pp
|
||||
Print out all entries in the log to standard output.
|
||||
Print out all entries in the given, configured, or default log file to
|
||||
standard output. If the
|
||||
.Fl n
|
||||
option is used then don't lock the iprop log file. If the
|
||||
.Fl R
|
||||
option is used, then print the entries in reverse order
|
||||
(this can be useful when the log is very large).
|
||||
.It replay
|
||||
.Bl -tag -width Ds
|
||||
.It Fl Fl start-version= Ns Ar version-number
|
||||
@@ -125,17 +221,34 @@ configuration file
|
||||
realm
|
||||
.El
|
||||
.Pp
|
||||
Replay the changes from specified entries (or all if none is
|
||||
specified) in the transaction log to the database.
|
||||
Replay the changes from specified entries (or all if none is specified)
|
||||
in the given, configured, or default transaction log file to the
|
||||
database.
|
||||
.It last-version
|
||||
.Bl -tag -width Ds
|
||||
.It Fl c Ar file , Fl Fl config-file= Ns Ar file
|
||||
configuration file
|
||||
.It Fl r Ar string , Fl Fl realm= Ns Ar string
|
||||
realm
|
||||
.It Xo
|
||||
.Fl n Ar string ,
|
||||
.Fl Fl no-lock
|
||||
.Xc
|
||||
.El
|
||||
.Pp
|
||||
prints the version of the last record in each of the given log files, or
|
||||
the configured, or the default log file if none is given.
|
||||
.It signal
|
||||
.Bl -tag -width Ds
|
||||
.It Fl c Ar file , Fl Fl config-file= Ns Ar file
|
||||
configuration file
|
||||
.It Fl r Ar string , Fl Fl realm= Ns Ar string
|
||||
realm
|
||||
.El
|
||||
.Pp
|
||||
prints the version of the last log entry.
|
||||
Signals the ipropd-master daemon to send updates to slaves. Normally
|
||||
kadmin does this every time it writes to the database, so this should
|
||||
rarely be needed.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr iprop 8
|
||||
|
Reference in New Issue
Block a user