light: stop syncing upon logfile holes

This commit is contained in:
Thomas Schoebel-Theuer 2015-02-19 02:08:02 +01:00 committed by Thomas Schoebel-Theuer
parent 827b5b5192
commit f10e7358ad
2 changed files with 48 additions and 5 deletions

View File

@ -13704,7 +13704,7 @@ new
This works because the secondaries are regularly checking the logfile numbers
for contiguity, and they will refuse to replay anything which is not contiguous.
As a result, the secondaries will be left in a consistent, but outdated
state.
state (at least if they already were consistent before that).
\end_layout
\begin_layout Enumerate
@ -13726,7 +13726,18 @@ reference "sec:The-Transaction-Logger"
\begin_layout Enumerate
After the temporary memory buffer is empty, all local IO requests (whether
reads or writes) are directly going to the underlying disk.
This has the same effect as if MARS was not present anymore.
This has the same effect as if MARS would not be present anymore.
Transaction logging does no longer take place.
\end_layout
\begin_layout Enumerate
Any sync from any secondary is stopped ASAP.
In case they are resuming their sync somewhen later, they will start over
from the beginning (position
\begin_inset Formula $0$
\end_inset
).
\end_layout
\begin_layout Standard

View File

@ -559,6 +559,7 @@ struct mars_rotate {
bool res_shutdown;
bool has_error;
bool has_double_logfile;
bool has_hole_logfile;
bool allow_update;
bool forbid_replay;
bool replay_mode;
@ -2945,9 +2946,25 @@ int make_log_step(void *buf, struct mars_dent *dent)
status = 0;
if (rot->relevant_log) {
if (!rot->next_relevant_log) {
rot->has_double_logfile = false;
if (_next_is_acceptable(rot, rot->relevant_log, dent))
if (unlikely(dent->d_serial == rot->relevant_log->d_serial)) {
// always prefer the one created by myself
if (!strcmp(rot->relevant_log->d_rest, my_id())) {
MARS_WRN("PREFER LOGFILE '%s' in front of '%s'\n",
rot->relevant_log->d_path, dent->d_path);
} else if (!strcmp(dent->d_rest, my_id())) {
MARS_WRN("PREFER LOGFILE '%s' in front of '%s'\n",
dent->d_path, rot->relevant_log->d_path);
rot->relevant_log = dent;
} else {
rot->has_double_logfile = true;
MARS_ERR("DOUBLE LOGFILES '%s' '%s'\n",
dent->d_path, rot->relevant_log->d_path);
}
} else if (_next_is_acceptable(rot, rot->relevant_log, dent)) {
rot->next_relevant_log = dent;
} else if (dent->d_serial > rot->relevant_log->d_serial + 5) {
rot->has_hole_logfile = true;
}
} else { // check for double logfiles => split brain
if (unlikely(dent->d_serial == rot->next_relevant_log->d_serial)) {
// always prefer the one created by myself
@ -2960,7 +2977,10 @@ int make_log_step(void *buf, struct mars_dent *dent)
rot->has_double_logfile = true;
MARS_ERR("DOUBLE LOGFILES '%s' '%s'\n", dent->d_path, rot->next_relevant_log->d_path);
}
} else if (dent->d_serial > rot->next_relevant_log->d_serial + 5) {
rot->has_hole_logfile = true;
}
}
MARS_DBG("next_relevant_log = %p\n", rot->next_relevant_log);
goto ok;
@ -2975,9 +2995,11 @@ int make_log_step(void *buf, struct mars_dent *dent)
/* Remember the relevant log.
*/
if (rot->aio_dent->d_serial == dent->d_serial) {
if (!rot->relevant_log && rot->aio_dent->d_serial == dent->d_serial) {
rot->relevant_serial = dent->d_serial;
rot->relevant_log = dent;
rot->has_double_logfile = false;
rot->has_hole_logfile = false;
}
ok:
@ -4217,6 +4239,16 @@ static int make_sync(void *buf, struct mars_dent *dent)
}
brick_string_free(tmp);
/* Don't sync when logfiles are discontiguous
*/
if (do_start && (rot->has_double_logfile | rot->has_hole_logfile)) {
MARS_WRN("no sync possible due to discontiguous logfiles (%d|%d)\n",
rot->has_double_logfile, rot->has_hole_logfile);
if (do_start)
start_pos = 0;
do_start = false;
}
/* Determine peer
*/
tmp = path_make("%s/primary", dent->d_parent->d_path);