diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-12-11 22:03:09 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-12-11 22:09:49 +0000 |
commit | b1e3b9f570c04100f73f63ceaff6ab07f938476a (patch) | |
tree | 2f22be88195c49545927c035a1d9e390c90ad74a | |
parent | 81f4cf3eda8f42040149da4ad267adf6adcf3e83 (diff) | |
download | mogilefs-client-b1e3b9f570c04100f73f63ceaff6ab07f938476a.tar.gz |
each_fids was too buggy and likely to yield false positives
-rw-r--r-- | examples/stale_fid_checker.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/examples/stale_fid_checker.rb b/examples/stale_fid_checker.rb index 77cb23d..2dab866 100644 --- a/examples/stale_fid_checker.rb +++ b/examples/stale_fid_checker.rb @@ -4,25 +4,38 @@ # * Ruby 1.9.2+ # * upstream MogileFS::Server 2.45 or later $stdout.sync = $stderr.sync = true +usage = <<EOF +Usage: #$0 -t TRACKERS" + +The output of this script can be piped to awk + curl to DELETE the files: +#$0 -t TRACKERS | awk '{system("curl -XDELETE "$3)}' +EOF + require 'uri' require 'optparse' require 'mogilefs' require 'net/http/persistent' Thread.abort_on_exception = true +MogileFS::VERSION <= "3.0.0" and + abort "Upgrade mogilefs-client (to a version that distributes this script)" \ + "MogileFS::Admin#each_fid is probably broken in this version" trackers = [] ARGV.options do |x| - x.banner = "Usage: #$0 -t TRACKERS" + x.banner = usage.strip x.separator '' x.on('-t', '--trackers=host1[,host2]', '--hosts=host1[,host2]', Array, 'hostnames/IP addresses of trackers') do |args| trackers = args end + + x.on('-h', '--help', 'Show this help message.') { puts x; exit } x.parse! end adm = MogileFS::Admin.new(:hosts => trackers) NHP = Net::HTTP::Persistent.new(File.basename($0)) +client = MogileFS::MogileFS.new(:hosts => trackers, :domain => "none") def start_perdev_thread(pfx) todo = Queue.new @@ -82,6 +95,12 @@ adm.each_fid do |fid| dev_map.each_value { |done| check(bad, curfid, done.shift) } next if bad.empty? + begin + info = client.file_debug(curfid) + abort "BUG: #{info.inspect} found!" if info["fid_dkey"] + rescue MogileFS::Backend::UnknownFidError + end + puts bad.join end end |