From: Josh Durgin Date: Tue, 6 Mar 2018 01:04:10 +0000 (-0500) Subject: tools: Add pg log trim command to ceph-objectstore-tool X-Git-Tag: v13.0.2~38^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b01e4ea5e2c1d2e9e997f53621aba73a7f7c9241;p=ceph.git tools: Add pg log trim command to ceph-objectstore-tool Add test script that verifies the command in qa/standalone/osd Fixes: http://tracker.ceph.com/issues/23242 Signed-off-by: Josh Durgin Signed-off-by: David Zafman --- diff --git a/qa/standalone/osd/repro_long_log.sh b/qa/standalone/osd/repro_long_log.sh new file mode 100755 index 0000000000000..28afca6e03e3d --- /dev/null +++ b/qa/standalone/osd/repro_long_log.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2014 Cloudwatt +# Copyright (C) 2018 Red Hat +# +# Author: Josh Durgin +# Author: David Zafman +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library Public License for more details. +# + +source $CEPH_ROOT/qa/standalone/ceph-helpers.sh + +function run() { + local dir=$1 + shift + + export CEPH_MON="127.0.0.1:7100" # git grep '\<7100\>' : there must be only one + export CEPH_ARGS + CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " + CEPH_ARGS+="--mon-host=$CEPH_MON " + + local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} + for func in $funcs ; do + setup $dir || return 1 + $func $dir || return 1 + teardown $dir || return 1 + done +} + +function test_log_size() +{ + PGID=$1 + EXPECTED=$2 + ceph tell osd.\* flush_pg_stats + sleep 3 + ceph pg $PGID query | jq .info.stats.log_size + ceph pg $PGID query | jq .info.stats.log_size | grep "${EXPECTED}" +} + +function do_repro_long_log() { + local dir=$1 + local which=$2 + + run_mon $dir a || return 1 + run_mgr $dir x || return 1 + run_osd $dir 0 || return 1 + run_osd $dir 1 || return 1 + run_osd $dir 2 || return 1 + + ceph osd pool create test 1 1 || true + POOL_ID=$(ceph osd dump --format json | jq '.pools[] | select(.pool_name == "test") | .pool') + PGID="${POOL_ID}.0" + + ceph tell osd.\* injectargs -- --osd-min-pg-log-entries 20 || return 1 + ceph tell osd.\* injectargs -- --osd-max-pg-log-entries 30 || return 1 + ceph tell osd.\* injectargs -- --osd-pg-log-trim-min 10 || return 1 + ceph tell osd.\* injectargs -- --osd-pg-log-dups-tracked 10 || return 1 + + touch foo + for i in $(seq 1 20) + do + rados -p test put foo foo || return 1 + done + + test_log_size $PGID 20 || return 1 + + rados -p test rm foo || return 1 + + # generate error entries + for i in $(seq 1 20) + do + rados -p test rm foo + done + + # this demonstrates the problem - it should fail + test_log_size $PGID 41 || return 1 + + if [ "$which" = "test1" ]; + then + # regular write should trim the log + rados -p test put foo foo || return 1 + test_log_size $PGID 22 || return 1 + else + PRIMARY=$(ceph pg $PGID query | jq '.info.stats.up_primary') + kill_daemons $dir TERM osd.$PRIMARY || return 1 + CEPH_ARGS="--osd-max-pg-log-entries=30 --osd-pg-log-trim-max=5" ceph-objectstore-tool --data-path $dir/$PRIMARY --pgid $PGID --op trim-pg-log || return 1 + run_osd $dir $PRIMARY || return 1 + wait_for_clean || return 1 + test_log_size $PGID 30 || return 1 + fi +} + +function TEST_repro_long_log1() +{ + local dir=$1 + + do_repro_long_log $dir test1 +} + +function TEST_repro_long_log2() +{ + local dir=$1 + + do_repro_long_log $dir test2 +} + +main repro-long-log "$@" + +# Local Variables: +# compile-command: "cd ../.. ; make -j4 && ../qa/run-standalone.sh repro_long_log.sh" +# End: diff --git a/qa/standalone/special/ceph_objectstore_tool.py b/qa/standalone/special/ceph_objectstore_tool.py index afb463f76cac0..72ed80da16a3a 100755 --- a/qa/standalone/special/ceph_objectstore_tool.py +++ b/qa/standalone/special/ceph_objectstore_tool.py @@ -1027,7 +1027,7 @@ def main(argv): # Specify a bad --op command cmd = (CFSD_PREFIX + "--op oops").format(osd=ONEOSD) - ERRORS += test_failure(cmd, "Must provide --op (info, log, remove, mkfs, fsck, repair, export, export-remove, import, list, fix-lost, list-pgs, dump-journal, dump-super, meta-list, get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete, dump-import)") + ERRORS += test_failure(cmd, "Must provide --op (info, log, remove, mkfs, fsck, repair, export, export-remove, import, list, fix-lost, list-pgs, dump-journal, dump-super, meta-list, get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete, dump-import, trim-pg-log)") # Provide just the object param not a command cmd = (CFSD_PREFIX + "object").format(osd=ONEOSD) diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index 0f26db037cdb0..ff9880fcee1fe 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -769,6 +769,7 @@ OPTION(osd_max_pg_log_entries, OPT_U32) // max entries, say when degraded, befor OPTION(osd_pg_log_dups_tracked, OPT_U32) // how many versions back to track combined in both pglog's regular + dup logs OPTION(osd_force_recovery_pg_log_entries_factor, OPT_FLOAT) // max entries factor before force recovery OPTION(osd_pg_log_trim_min, OPT_U32) +OPTION(osd_pg_log_trim_max, OPT_U32) OPTION(osd_op_complaint_time, OPT_FLOAT) // how many seconds old makes an op complaint-worthy OPTION(osd_command_max_records, OPT_INT) OPTION(osd_max_pg_blocked_by, OPT_U32) // max peer osds to report that are blocking our progress diff --git a/src/common/options.cc b/src/common/options.cc index d99d71bb5c470..e2779583fe680 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -2876,6 +2876,13 @@ std::vector