Skip Menu |
 

This queue is for tickets about the File-Tail CPAN distribution.

Report information
The Basics
Id: 12762
Status: new
Priority: 0/
Queue: File-Tail

People
Owner: Nobody in particular
Requestors: michael.protulipac [...] pnc.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.99.1
Fixed in: (no value)

Attachments


Subject: "uninitialized value" messages when machine experiences I/O issues
Download (untitled) / with headers
text/plain 1002b
Environment: File-Tail-0.99.1 on Sparc Solaris 2.9 - perl 5.8.5 - both perl and File::Tail built with gcc 3.3.2 I am using File::Tail to monitor 30+ files on a Solaris 2.9 machine. We experienced disk issues which resulted with the OS taking the disks offline (the disks where the monitored files resided). During this time, File::Tail began spewing the following messages repeatedly: Use of uninitialized value in numeric lt (<) at /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 405. Use of uninitialized value in numeric eq (==) at /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 405. Use of uninitialized value in subtraction (-) at /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 413. Use of uninitialized value in subtraction (-) at /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 417. Not sure what could be done to prevent File::Tail from behaving in this manner (want to retain using perl -w). I realize this is a rare event, nonetheless wanted to share it.
From: michael.protulipac [...] pnc.com
[guest - Wed May 11 13:47:51 2005]: Show quoted text
> Environment: File-Tail-0.99.1 on Sparc Solaris 2.9 - perl 5.8.5 - > both perl and File::Tail built with gcc 3.3.2 > > I am using File::Tail to monitor 30+ files on a Solaris 2.9 machine. > We experienced disk issues which resulted with the OS taking the > disks offline (the disks where the monitored files resided). > During this time, File::Tail began spewing the following messages > repeatedly: > > Use of uninitialized value in numeric lt (<) at > /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 405. > Use of uninitialized value in numeric eq (==) at > /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 405. > Use of uninitialized value in subtraction (-) at > /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 413. > Use of uninitialized value in subtraction (-) at > /usr/local/lib/perl5/site_perl/5.8.5/File/Tail.pm line 417. > > Not sure what could be done to prevent File::Tail from behaving in > this manner (want to retain using perl -w). I realize this is a > rare event, nonetheless wanted to share it.
I found some quiet time to address these issues and included a patch (attached). Please consider adding it into the next release. Specifically, it addresses the "Use of uninitialized value" warnings. In addition, I created another parameter (io_tolerant) to the new() method which enables one to control the behavior of File::Tail whenever the partition/mountpoint of the file goes away. Testing revealed sysseek fails to seek to EOF and returns undef. With io_tolerant set, it will close the file and treat it as if the file never existed. If io_tolerant not set, it will set the EOF location to the last known end position and quietly resume its monitoring where it left off when the partition returns. See the updated (File::Tail perldoc for more information). This was tested on Solaris 8 and 9 using perl 5.8.5 and File::Tail 0.99.1 (with enclosed patch applied). The Solaris 9 environment was a SunCluster (HA active/passive environment). Mike
Download Tail.pm.diff
text/x-diff 3.1k
--- Tail.pm.orig 2005-05-10 15:34:22.000000000 -0400 +++ Tail.pm 2005-06-09 14:35:17.001250000 -0400 @@ -183,6 +183,12 @@ return $self->{ignore_nonexistant}; } +sub io_tolerant { + my $self=shift; + $self->{io_tolerant}=shift if @_; + return $self->{io_tolerant}; +} + sub TIEHANDLE { my $ref=new(@_); } @@ -269,6 +275,8 @@ } # $object->{curpos}=0; # ADDED 25May01: undef warnings when # $object->{endpos}=0; # starting up on a nonexistant file + # Added June 9, 2005: handle partition issues + $object->{"io_tolerant"}=($params{"io_tolerant"} || 0); return $object; } @@ -393,15 +401,38 @@ my $object=shift @_; my $old_lastcheck = $object->{lastcheck}; + + # Added June 9, 2005: Will complain if not defined (partition issues) + # The sysseek below will return undef - therefore, save off old position + my $old_endpos = $object->{"endpos"}; + $object->{"lastcheck"}=time; - unless ($object->{handle}) { + unless ( defined($object->{handle}) ) { $object->reset_pointers; - unless ($object->{handle}) { # This try did not open the file either + unless ( defined($object->{handle}) ) { # This try did not open the file either return 0; } } $object->{"endpos"}=sysseek($object->{handle},0,SEEK_END); + + # When filesystem partions are dismounted - File::Tail will complain about null endpos value + + unless ( defined($object->{"endpos"}) ) { + + if ( $object->{"io_tolerant"} ) { + # Close handle - want to treat it as a new file + close($object->{handle}); + $object->{handle} = undef; + $object->reset_pointers; + # No need to proceed + return 0; + } else { + # Assign last known endpos + $object->{"endpos"} ||= $old_endpos; + } + } + if ($object->{"endpos"}<$object->{curpos}) { # file was truncated $object->position; } elsif (($object->{curpos}==$object->{"endpos"}) @@ -704,6 +735,26 @@ opened or when it is to be reopened. (File may be reopened after resetafter seconds have passed since last data was found.) +=item io_tolerant + + Treat file as new (first time opened) when the system loses +the partition where the file resides. This is particularly useful +in high available (HA) systems configured in an active/passive +configuration. If not specified, File::Tail remembers the last +position of the file it monitored and resumes monitoring from the last +known location (otherwise may duplicate monitored lines especially +if the file is written to and monitored on the other node). + +Default value is 0 (off). + +In the following case, we would want to set io_tolerant: + + 1. Node A monitors a file on an HA partition + 2. Node B tries to monitor a file that is not there + 3. Node A fails to node B + 4. Node B start monitoring the file and app writes to the file + 5. Node B fails back to node A + =item tail When first started, read and return C<n> lines from the file.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.