Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0 - Fix log delete bug that occurs when there's low disk space #4891

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bdb/bdb_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,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);
Expand Down
66 changes: 10 additions & 56 deletions bdb/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3583,7 +3583,6 @@ static void delete_log_files_int(bdb_state_type *bdb_state)
char **file;
struct stat sb;
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;
Expand All @@ -3596,7 +3595,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;
Expand All @@ -3616,8 +3614,7 @@ 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))
(bdb_state->attr->logdeleteage > now)))
return;

/* get the lowest filenum of anyone in our sanc list. we cant delete
Expand Down Expand Up @@ -3737,15 +3734,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);
Expand Down Expand Up @@ -3802,8 +3790,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';
Expand Down Expand Up @@ -3952,18 +3938,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) {
/* delete this file if we got this far AND it's under the
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)
Expand Down Expand Up @@ -4021,40 +4000,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;
Expand Down Expand Up @@ -4101,13 +4062,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;

Expand Down
10 changes: 0 additions & 10 deletions plugins/logdelete/logdelete.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ static int handle_logdelete_request(comdb2_appsock_arg_t *arg)
backend_update_sync(thedb);
logdelete_unlock(__func__, __LINE__);

/* 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");
Expand Down Expand Up @@ -136,13 +133,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
Expand Down