Skip to content

Commit

Permalink
Expose logdel headroom bug
Browse files Browse the repository at this point in the history
Signed-off-by: Morgan Douglas <mdouglas47@bloomberg.net>
  • Loading branch information
morgando committed Dec 10, 2024
1 parent 29be87c commit b2f0cd2
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bdb/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ struct timeval last_timer_pstack;
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;
Expand Down Expand Up @@ -4045,7 +4046,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);
Expand Down
1 change: 1 addition & 0 deletions db/db_tunables.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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;
Expand Down
2 changes: 2 additions & 0 deletions db/db_tunables.h
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,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,
Expand Down
9 changes: 9 additions & 0 deletions tests/logdel_headroom_bug.test/Makefile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/logdel_headroom_bug.test/lrl.options
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions tests/logdel_headroom_bug.test/runit
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b2f0cd2

Please sign in to comment.