diff --git a/bdb/file.c b/bdb/file.c index 0b576d6f2c..b7a453f093 100644 --- a/bdb/file.c +++ b/bdb/file.c @@ -133,6 +133,7 @@ extern int get_commit_lsn_map_switch_value(); extern int is_db_roomsync(); extern int get_schema_change_in_progress(const char *func, int line); +int gbl_test_logdel_with_low_headroom = 0; int gbl_debug_children_lock = 0; int gbl_queuedb_genid_filename = 1; int gbl_queuedb_file_threshold = 0; @@ -4030,7 +4031,8 @@ static void delete_log_files_int(bdb_state_type *bdb_state) } } - if (has_low_headroom(bdb_state->txndir,bdb_state->attr->lowdiskthreshold, 0)) { + if (has_low_headroom(bdb_state->txndir,bdb_state->attr->lowdiskthreshold, 0) + || gbl_test_logdel_with_low_headroom) { low_headroom_count++; is_low_headroom = 1; free(list); diff --git a/db/db_tunables.c b/db/db_tunables.c index 0d0ea1564d..1d466343e9 100644 --- a/db/db_tunables.c +++ b/db/db_tunables.c @@ -51,6 +51,7 @@ extern int gbl_berkdb_epochms_repts; extern int gbl_pmux_route_enabled; extern int gbl_allow_user_schema; extern int gbl_test_badwrite_intvl; +extern int gbl_test_logdel_with_low_headroom; extern int gbl_broken_max_rec_sz; extern int gbl_broken_num_parser; extern int gbl_crc32c; diff --git a/db/db_tunables.h b/db/db_tunables.h index 08b7ac4958..44bc5df952 100644 --- a/db/db_tunables.h +++ b/db/db_tunables.h @@ -1156,6 +1156,8 @@ REGISTER_TUNABLE("temptable_limit", NULL, NULL, NULL); REGISTER_TUNABLE("test_blob_race", NULL, TUNABLE_INTEGER, &gbl_test_blob_race, READONLY, NULL, NULL, NULL, NULL); +REGISTER_TUNABLE("test_logdel_with_low_headroom", NULL, TUNABLE_INTEGER, &gbl_test_logdel_with_low_headroom, + INTERNAL, NULL, NULL, NULL, NULL); REGISTER_TUNABLE("test_scindex_deadlock", "Test index on expressions schema change deadlock", TUNABLE_BOOLEAN, &gbl_test_scindex_deadlock, READONLY, NULL, diff --git a/tests/logdel_headroom_bug.test/Makefile b/tests/logdel_headroom_bug.test/Makefile new file mode 100644 index 0000000000..eb5f2606b0 --- /dev/null +++ b/tests/logdel_headroom_bug.test/Makefile @@ -0,0 +1,9 @@ +ifeq ($(TESTSROOTDIR),) + include ../testcase.mk +else + include $(TESTSROOTDIR)/testcase.mk +endif +ifeq ($(TEST_TIMEOUT),) + export TEST_TIMEOUT=1m +endif +unexport CLUSTER diff --git a/tests/logdel_headroom_bug.test/lrl.options b/tests/logdel_headroom_bug.test/lrl.options new file mode 100644 index 0000000000..9645753d10 --- /dev/null +++ b/tests/logdel_headroom_bug.test/lrl.options @@ -0,0 +1,5 @@ +setattr min_keep_logs 0 +setattr min_keep_logs_age 0 +setattr logdeleteage 0 +setattr debug_log_deletion 1 +test_logdel_with_low_headroom 1 diff --git a/tests/logdel_headroom_bug.test/runit b/tests/logdel_headroom_bug.test/runit new file mode 100755 index 0000000000..dba9832519 --- /dev/null +++ b/tests/logdel_headroom_bug.test/runit @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +set -e + +DBNAME=$1 +tier="default" + +push_logs_to_second_logfile() { + cdb2sql ${CDB2_OPTIONS} $DBNAME $tier "exec procedure sys.cmd.send('pushnext')" + for (( i=0; i<3; ++i )); + do + cdb2sql ${CDB2_OPTIONS} $DBNAME $tier "exec procedure sys.cmd.send('flush')" + sleep 1 + done +} + +get_num_archivable_logs() { + cdb2sql ${CDB2_OPTIONS} $DBNAME $tier "exec procedure sys.cmd.send('bdb log_archive')" | wc -l +} + +delete_first_logfile() { + # first delete command should result in node updating its local low file number. + # second delete command should result in the actual deletion. + + cdb2sql ${CDB2_OPTIONS} $DBNAME $tier "exec procedure sys.cmd.send('deletelogs')" + cdb2sql ${CDB2_OPTIONS} $DBNAME $tier "exec procedure sys.cmd.send('deletelogs')" +} + +main() { + push_logs_to_second_logfile + + local num_archivable_logs + num_archivable_logs=$(get_num_archivable_logs) + if (( num_archivable_logs != 1 )); + then + echo "ERROR: Expected to have an archivable log after pushing to next logfile" + return 1 + fi + + delete_first_logfile + + num_archivable_logs=$(get_num_archivable_logs) + if (( num_archivable_logs != 0 )); + then + echo "ERROR: Expected to have no archivable logs after log deletion" + return 1 + fi + + return 0 +} + +main +