Changeset: 4b4972d8d1a1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/4b4972d8d1a1 Modified Files: gdk/gdk_logger.c tools/mserver/mserver5.c Branch: default Log Message:
Clean up certain types of junk bats at start up with option --clean-BBP. Bats that are persistent, but not used by the SQL layer will be removed. diffs (93 lines): diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -2012,6 +2012,51 @@ log_json_upgrade_finalize(void) } #endif +/* clean up old junk left over from old upgrades: bats that are + * persistent but not in the SQL catalog and that have no name, and bats + * that do have a name that starts with "stat_opt_" (from the statistics + * optimizer that was removed in 2017) are removed here + * + * this function ignores any errors */ +static void +clean_bbp(logger *lg) +{ + BAT *b = COLnew(0, TYPE_int, 256, TRANSIENT); + if (b == NULL) + return; + if (BUNappend(b, &(int){0}, false) != GDK_SUCCEED) { + BBPreclaim(b); + return; + } + /* mark persistent bats that have no name or have a name + * starting with "stat_opt_" */ + for (bat bid = 1, bsz = getBBPsize(); bid < bsz; bid++) + if (BBP_status(bid) & BBPEXISTING && + (BBP_logical(bid) == NULL || + strncmp(BBP_logical(bid), "tmp_", 4) == 0 || + strncmp(BBP_logical(bid), "stat_opt_", 9) == 0)) + BBP_status_on(bid, 1U << 31); + /* remove mark from bats that are in the SQL catalog */ + for (BUN i = 0, n = BATcount(lg->catalog_bid); i < n; i++) + BBP_status_off(((int *) lg->catalog_bid->theap->base)[i], 1U << 31); + /* what's left over are junk bats */ + for (bat bid = 1, bsz = getBBPsize(); bid < bsz; bid++) + if (BBP_status(bid) & (1U << 31)) { + BBP_status_off(bid, 1U << 31); + if (BATmode(BBP_desc(bid), true) != GDK_SUCCEED || + BUNappend(b, &bid, false) != GDK_SUCCEED) { + BBPreclaim(b); + return; + } + printf("# removing bat %d (tmp_%o)\n", bid, bid); + } + /* if there were any junk bats, commit their removal */ + if (b->batCount > 1 && + TMsubcommit_list(Tloc(b, 0), NULL, (int) b->batCount, -1) != GDK_SUCCEED) + printf("clean_bbp transaction failed\n"); + BBPreclaim(b); +} + /* Load data from the logger logdir * Initialize new directories and catalog files if none are present, * unless running in read-only mode @@ -2328,6 +2373,8 @@ log_load(const char *fn, logger *lg, cha if (log_json_upgrade_finalize() == GDK_FAIL) goto error; #endif + if (GDKgetenv_isyes("clean-BBP")) + clean_bbp(lg); return GDK_SUCCEED; error: if (fp) diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c --- a/tools/mserver/mserver5.c +++ b/tools/mserver/mserver5.c @@ -336,10 +336,12 @@ main(int argc, char **av) {"threads", no_argument, NULL, 0}, {"transactions", no_argument, NULL, 0}, - {"read-password-initialize-and-exit", no_argument, NULL, 0}, {"loadmodule", required_argument, NULL, 0}, {"without-geom", no_argument, NULL, 0}, + + {"read-password-initialize-and-exit", no_argument, NULL, 0}, {"process-wal-and-exit", no_argument, NULL, 0}, + {"clean-BBP", no_argument, NULL, 0}, {NULL, 0, NULL, 0} }; @@ -521,6 +523,11 @@ main(int argc, char **av) "process-wal-and-exit", "yes"); break; } + if (strcmp(long_options[option_index].name, "clean-BBP") == 0) { + setlen = mo_add_option(&set, setlen, opt_cmdline, + "clean-BBP", "yes"); + break; + } if (strcmp(long_options[option_index].name, "loadmodule") == 0) { if (mods < MAX_MODULES) modules[mods++] = optarg; _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org