From 036953fa541af384ec43f7cde6f2ac1270b95cf6 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Mon, 23 Feb 2015 08:14:24 +0100 Subject: [PATCH] light: provisionary allow fetch during detach --- docu/mars-manual.lyx | 213 +++++++++++++++++++++++++++++++++++++ kernel/sy_old/mars_light.c | 12 +++ 2 files changed, 225 insertions(+) diff --git a/docu/mars-manual.lyx b/docu/mars-manual.lyx index 8324550d..38d2ea70 100644 --- a/docu/mars-manual.lyx +++ b/docu/mars-manual.lyx @@ -27547,6 +27547,219 @@ demand running. \end_layout +\begin_layout Chapter +Tips and Tricks +\end_layout + +\begin_layout Section +Creating Backups via Pseudo Snapshots +\end_layout + +\begin_layout Standard +When all your secondaries are all homogenously located in a standby datacenter, + they will be almost idle all the time. + This is a waste of computing resources. +\end_layout + +\begin_layout Standard +Since MARS Light is no substitute for a full-fledged backup system, and + since backups may put high system load onto your active side, you may want + to utilize your passive hardware resources in a better way. +\end_layout + +\begin_layout Standard +MARS Light supports this thanks to its ability to switch the +\family typewriter +pause-replay +\family default + +\emph on +independently +\emph default + from +\family typewriter +pause-fetch +\family default +. +\end_layout + +\begin_layout Standard +The basic idea is simple: just use +\family typewriter +pause-replay +\family default + at your secondary site, but leave the replication of transaction logfiles + intact by deliberately +\emph on +not +\emph default + saying +\family typewriter +pause-fetch +\family default +. + This way, your secondary replica (block device) will stay frozen for a + limited time, without loosing your redundancy: since the transaction logs + will continue to replicate in the meantime, you can start +\family typewriter +resume-replay +\family default + at any time, in particular when a primary-side incident should happen unexpecte +dly. + The former secondary will just catch up by replaying the outstanding parts + of the transaction logs in order to become recent. +\end_layout + +\begin_layout Standard +However, some +\emph on +details +\emph default + have to be obeyed. + In particular, the current version of MARS Light needs an additional +\family typewriter +detach +\family default + operation, in order to release exclusive access to the underlying disk + +\family typewriter +/dev/lv/$res +\family default +. + Future versions of MARS Light are planned to support this more directly, + without need for an intermediate +\family typewriter +detach +\family default + operation. +\end_layout + +\begin_layout Standard +\begin_inset Graphics + filename images/MatieresCorrosives.png + lyxscale 50 + scale 17 + +\end_inset + +Beware: +\family typewriter +mount -o ro /dev/vg/$res +\family default + can lead to +\series bold +unnoticed write operations +\series default + if you are not careful! Some journalling filesystems like +\family typewriter +xfs +\family default + or +\family typewriter +ext4 +\family default + may replay their journals onto the disk, leading to +\emph on +binary +\emph default + differences and thus +\series bold +destroying your consistency +\series default + later when you re-enable +\family typewriter +resume-replay +\family default +! +\end_layout + +\begin_layout Standard +\begin_inset Graphics + filename images/lightbulb_brightlit_benj_.png + lyxscale 12 + scale 7 + +\end_inset + +Therefore, you may use small LVM snapshots (only in such cases). + Typically, +\family typewriter +xfs +\family default + journal replay will require only a few megabytes. + Therefore you typically don't need much temporary space for this. + Here is a more detailed description of steps: +\end_layout + +\begin_layout Enumerate + +\family typewriter +marsadm pause-replay $res +\end_layout + +\begin_layout Enumerate + +\family typewriter +marsadm detach $res +\end_layout + +\begin_layout Enumerate + +\family typewriter +lvcreate --size 100m --snapshot --name ro-$res /dev/vg/$res +\end_layout + +\begin_layout Enumerate + +\family typewriter +mount -o ro /dev/vg/ro-$res /mnt/tmp +\end_layout + +\begin_layout Enumerate +Now draw your backup from +\family typewriter +/mnt/tmp/ +\end_layout + +\begin_layout Enumerate + +\family typewriter +umount /mnt/tmp +\end_layout + +\begin_layout Enumerate + +\family typewriter +lvremove -f /dev/vg/ro-$res +\end_layout + +\begin_layout Enumerate + +\family typewriter +marsadm up $res +\end_layout + +\begin_layout Standard +Hint: during the backup, the transaction logs will accumulate on +\family typewriter +/mars/ +\family default +. + In order to avoid overflow of +\family typewriter +/mars/ +\family default + (c.f. + section +\begin_inset CommandInset ref +LatexCommand ref +reference "sec:Defending-Overflow" + +\end_inset + +), don't unnecessarily prolong the backup duration. +\end_layout + \begin_layout Chapter MARS for Developers \end_layout diff --git a/kernel/sy_old/mars_light.c b/kernel/sy_old/mars_light.c index 1134dd66..29072888 100644 --- a/kernel/sy_old/mars_light.c +++ b/kernel/sy_old/mars_light.c @@ -1689,11 +1689,23 @@ int _update_file(struct mars_dent *parent, const char *switch_path, const char * make_msg(msg_pair, "disabling fetch due to rmmod"); do_start = false; } +#if 0 + /* Disabled for now. Re-enable this code after a new feature has been + * implemented: when pause-replay is given, /dev/mars/mydata should + * appear in _readonly_ form. + * The idea is to _not_ disable the fetch during this! + * You may draw a backup from the readonly device without losing your + * redundancy, because the transactions logs will contiue to be updated. + * Until the new feature is implemented, use + * "marsadm pause-replay $res; marsadm detach $res; mount -o ro /dev/lv/$res" + * as a workaround. + */ if (do_start && !_check_allow(global, parent, "attach")) { MARS_DBG("disabling fetch due to detach\n"); make_msg(msg_pair, "disabling fetch due to detach"); do_start = false; } +#endif if (do_start && !_check_allow(global, parent, "connect")) { MARS_DBG("disabling fetch due to disconnect\n"); make_msg(msg_pair, "disabling fetch due to disconnect");