From 1e23eeb797f1bbe48e3d3977d864a3d148b71597 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Mon, 26 Apr 2010 15:03:36 +0200 Subject: [PATCH 1/1] Stop testing a target if we got to many timeouts (>= 3). See bug #3382 --- lib/ZOOM/IRSpy.pm | 11 +++++++++++ lib/ZOOM/IRSpy/Record.pm | 2 ++ lib/ZOOM/IRSpy/Test/Record/Fetch.pm | 19 +++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/ZOOM/IRSpy.pm b/lib/ZOOM/IRSpy.pm index 5b7e28a..dcba350 100644 --- a/lib/ZOOM/IRSpy.pm +++ b/lib/ZOOM/IRSpy.pm @@ -25,6 +25,7 @@ our $VERSION = '1.02'; our $irspy_to_zeerex_xsl = dirname(__FILE__) . '/../../xsl/irspy2zeerex.xsl'; our $debug = 0; our $xslt_max_depth = 250; +our $max_timeout_errors = 3; # Enumeration for callback functions to return @@ -434,6 +435,8 @@ sub check { my $timeout = $this->{timeout}; $this->log("irspy", "beginnning with test '$topname' (timeout $timeout)"); + $timeout = 2; + my $nskipped = 0; my @conn = @{ $this->{connections} }; @@ -442,8 +445,12 @@ sub check { while (1) { my @copy_conn = @conn; # avoid alias problems after splice() my $nconn = scalar(@copy_conn); + + foreach my $i0 (0 .. $#copy_conn) { my $conn = $copy_conn[$i0]; + #warn Dumper($conn); + #print "connection $i0 of $nconn/", scalar(@conn), " is $conn\n"; next if !defined $conn; if (!$conn->current_task()) { @@ -458,6 +465,10 @@ sub check { $conn->log("irspy_test", "checking for next test after '$address'"); $nextaddr = $this->_next_test($address); + if ($nextaddr && $conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) { + $conn->log("irspy", "Got to many timeouts, stop testing: " . $conn->record->zoom_error->{TIMEOUT}); + $nextaddr = ""; + } } if (!defined $nextaddr) { $conn->log("irspy", "has no more tests: removing"); diff --git a/lib/ZOOM/IRSpy/Record.pm b/lib/ZOOM/IRSpy/Record.pm index b0b0bfd..c5b6c1b 100644 --- a/lib/ZOOM/IRSpy/Record.pm +++ b/lib/ZOOM/IRSpy/Record.pm @@ -41,6 +41,7 @@ sub new { target => $target, parser => $parser, zeerex => $parser->parse_string($zeerex)->documentElement(), + zoom_error => { TIMEOUT => 0 }, }, $class; #Scalar::Util::weaken($this->{irspy}); @@ -49,6 +50,7 @@ sub new { return $this; } +sub zoom_error { return shift->{'zoom_error'} } sub _empty_zeerex_record { my($target) = @_; diff --git a/lib/ZOOM/IRSpy/Test/Record/Fetch.pm b/lib/ZOOM/IRSpy/Test/Record/Fetch.pm index 2288715..b6ff9b4 100644 --- a/lib/ZOOM/IRSpy/Test/Record/Fetch.pm +++ b/lib/ZOOM/IRSpy/Test/Record/Fetch.pm @@ -10,6 +10,7 @@ use warnings; use ZOOM::IRSpy::Test; our @ISA = qw(ZOOM::IRSpy::Test); +our $max_timeout_errors = $ZOOM::IRSpy::max_timeout_errors; # These queries my @queries = ( @@ -41,6 +42,16 @@ sub completed_search { $conn->log("irspy_test", "Fetch test search (", $task->render_query(), ") ", ref $event && $event->isa("ZOOM::Exception") ? "failed: $event" : "found $n records (event=$event)"); + + # remember how often a target record hit a timeout + if (ref $event && $event->isa("ZOOM::Exception")) { + if ($event =~ /Timeout/i) { + $conn->record->zoom_error->{TIMEOUT}++; + $conn->log("irspy_test", "Increase timeout error counter to: " . + $conn->record->zoom_error->{TIMEOUT}); + } + } + if ($n == 0) { $task->{rs}->destroy(); my $qindex = $udata->{queryindex}+1; @@ -48,10 +59,14 @@ sub completed_search { return ZOOM::IRSpy::Status::TEST_SKIPPED if !defined $q; - $conn->log("irspy_test", "Trying another search ..."); - $conn->irspy_search_pqf($queries[$qindex], { queryindex => $qindex }, {}, + if ($conn->record->zoom_error->{TIMEOUT} >= $max_timeout_errors) { + $conn->log("irspy_test", "Got $max_timeout_errors timeouts, give up..."); + } else { + $conn->log("irspy_test", "Trying another search ..."); + $conn->irspy_search_pqf($queries[$qindex], { queryindex => $qindex }, {}, ZOOM::Event::ZEND, \&completed_search, exception => \&completed_search); + } return ZOOM::IRSpy::Status::TASK_DONE; } -- 1.7.10.4