From 0fd49be8b342bbc3e0e641c7fc417b5dc2acc0f9 Mon Sep 17 00:00:00 2001 From: Morgan Douglas Date: Mon, 16 Dec 2024 10:51:27 -0500 Subject: [PATCH] Remove low headroom logic in log delete function Signed-off-by: Morgan Douglas --- bdb/bdb_api.h | 2 -- bdb/file.c | 67 ++++++----------------------------- plugins/logdelete/logdelete.c | 10 ------ 3 files changed, 11 insertions(+), 68 deletions(-) diff --git a/bdb/bdb_api.h b/bdb/bdb_api.h index bb4064a843..9af7df4e87 100644 --- a/bdb/bdb_api.h +++ b/bdb/bdb_api.h @@ -1350,8 +1350,6 @@ int bdb_fetch_last_key_tran(bdb_state_type *bdb_state, tran_type *tran, int bdb_rowlock(bdb_state_type *bdb_state, tran_type *tran, unsigned long long genid, int exclusive, int *bdberr); -int bdb_get_low_headroom_count(bdb_state_type *bdb_state); - enum { BDB_LOCK_READ, BDB_LOCK_WRITE }; int bdb_get_locker(bdb_state_type *bdb_state, unsigned int *lid); diff --git a/bdb/file.c b/bdb/file.c index 0b576d6f2c..d3ad7592ad 100644 --- a/bdb/file.c +++ b/bdb/file.c @@ -3551,7 +3551,6 @@ static void delete_log_files_int(bdb_state_type *bdb_state) char **file; struct stat logfile_stats; char logname[1024]; - int low_headroom_count = 0; int lowfilenum; /* the lowest log file across the cluster */ int local_lowfilenum = INT_MAX; /* the lowest log file of this node */ int lwm_lowfilenum = -1; @@ -3564,7 +3563,6 @@ static void delete_log_files_int(bdb_state_type *bdb_state) int lognum; DB_LSN snapylsn = {0}; DB_LSN recovery_lsn; - int is_low_headroom = 0; int send_filenum = 0; int filenum; int delete_adjacent; @@ -3583,10 +3581,10 @@ static void delete_log_files_int(bdb_state_type *bdb_state) /* dont delete log files during backups or hot copies */ time_t now = time(NULL); - if (((bdb_state->attr->logdeleteage == LOGDELETEAGE_NEVER) || - (bdb_state->attr->logdeleteage > now)) && - !has_low_headroom(bdb_state->txndir,bdb_state->attr->lowdiskthreshold, 0)) + if ((bdb_state->attr->logdeleteage == LOGDELETEAGE_NEVER) || + (bdb_state->attr->logdeleteage > now)) { return; + } /* get the lowest filenum of anyone in our sanc list. we cant delete log files greater than that filenum */ @@ -3705,15 +3703,6 @@ static void delete_log_files_int(bdb_state_type *bdb_state) } } -low_headroom: - if (bdb_state->attr->log_delete_low_headroom_breaktime && - low_headroom_count > - bdb_state->attr->log_delete_low_headroom_breaktime) { - logmsg(LOGMSG_WARN, "low_headroom, but tried %d times and giving up\n", - bdb_state->attr->log_delete_low_headroom_breaktime); - return; - } - delete_adjacent = 1; /* ask berk for a list of files that it thinks we can delete */ rc = bdb_state->dbenv->log_archive(bdb_state->dbenv, &list, 0); @@ -3770,8 +3759,6 @@ static void delete_log_files_int(bdb_state_type *bdb_state) ctrace("Snapylsn is %d:%d\n", snapylsn.file, snapylsn.offset); } - is_low_headroom = 0; - for (file = list, lognum = 0; *file != NULL && lognum < numlogs; ++file, ++lognum) { logname[0] = '\0'; @@ -3937,18 +3924,11 @@ static void delete_log_files_int(bdb_state_type *bdb_state) __txn_commit_map_delete_logfile_txns(bdb_state->dbenv, filenum); } - if ((filenum <= lowfilenum && delete_adjacent) || is_low_headroom) { + if (filenum <= lowfilenum && delete_adjacent) { /* delete this file if we got this far AND it's <= the * replicated low number */ - if (is_low_headroom) { - logmsg(LOGMSG_WARN, "LOW HEADROOM : delete_log_files: deleting " - "logfile: %s\n", - logname); - } - - print(bdb_state, "%sdelete_log_files: deleting logfile: %s " - "filenum %d lowfilenum was %d\n", - (is_low_headroom) ? "LOW HEADROOM : " : "", logname, + print(bdb_state, "delete_log_files: deleting logfile: %s " + "filenum %d lowfilenum was %d\n",logname, filenum, lowfilenum); print(bdb_state, "filenums: %s\n", filenums_str); if (gbl_rowlocks) @@ -4006,40 +3986,22 @@ static void delete_log_files_int(bdb_state_type *bdb_state) * loop, so don't actually delete so we don't create log holes. */ if (bdb_state->attr->debug_log_deletion) { - logmsg(LOGMSG_DEBUG, "not deleting %d, lowfilenum %d adj %d low %d\n", - filenum, lowfilenum, delete_adjacent, - is_low_headroom); + logmsg(LOGMSG_DEBUG, "not deleting %d, lowfilenum %d adj %d\n", + filenum, lowfilenum, delete_adjacent); } if (ctrace_info) - ctrace("not deleting %d, lowfilenum %d adj %d low %d\n", - filenum, lowfilenum, delete_adjacent, - is_low_headroom); + ctrace("not deleting %d, lowfilenum %d adj %d\n", + filenum, lowfilenum, delete_adjacent); delete_adjacent = 0; } if (gbl_new_snapisol_asof) { Pthread_mutex_unlock(&bdb_gbl_recoverable_lsn_mutex); } - - if (is_low_headroom && - !has_low_headroom(bdb_state->txndir, - bdb_state->attr->lowdiskthreshold, 0)) { - is_low_headroom = 0; - } else { - low_headroom_count++; - } } - - if (has_low_headroom(bdb_state->txndir,bdb_state->attr->lowdiskthreshold, 0)) { - low_headroom_count++; - is_low_headroom = 1; - free(list); - /* try again */ - goto low_headroom; - } - free(list); } + if (list == NULL || send_filenum == 0) { DB_LOGC *logc; DBT logrec; @@ -4086,13 +4048,6 @@ static void delete_log_files_int(bdb_state_type *bdb_state) ctrace("sending filenum %d\n", send_filenum); } -int bdb_get_low_headroom_count(bdb_state_type *bdb_state) -{ - if (bdb_state->parent) - bdb_state = bdb_state->parent; - return bdb_state->low_headroom_count; -} - static pthread_mutex_t logdelete_lk = PTHREAD_MUTEX_INITIALIZER; int gbl_logdelete_lock_trace = 0; diff --git a/plugins/logdelete/logdelete.c b/plugins/logdelete/logdelete.c index 6f033bb410..b157cfc11a 100644 --- a/plugins/logdelete/logdelete.c +++ b/plugins/logdelete/logdelete.c @@ -56,9 +56,6 @@ static int handle_logdelete_request(comdb2_appsock_arg_t *arg) backend_update_sync(thedb); - /* check for after commented out below as well - int before_count = bdb_get_low_headroom_count(thedb->bdb_env); - */ before_master = ATOMIC_LOAD32(gbl_master_changes); before_sc = gbl_sc_commit_count; logmsg(LOGMSG_INFO, "Disabling log file deletion\n"); @@ -134,13 +131,6 @@ static int handle_logdelete_request(comdb2_appsock_arg_t *arg) if (report_back) { /* If we deleted log files during that due to log file deletion * then report so */ - /* - int after_count = bdb_get_low_headroom_count(thedb->bdb_env); - if(after_count != before_count) { - sbuf2printf(sb, "Alert: log files deleted due to low disk - headroom\n"); - } - */ /* (this test is not reliable) */ /* If the master node changed during that then report that too