Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Man, File::Tail is just beating me down!

by starbolin (Hermit)
on Jan 17, 2008 at 23:52 UTC ( #662978=note: print w/ replies, xml ) Need Help??


in reply to Man, File::Tail is just beating me down!

In your code this:

if (!defined $first_record) { $first_record = $line;

seems really dangerous as you can't say for certain the contents of $line. Could be a null, a lone line terminator or whatever the last thing was you wrote to the socket. I know you may have convinced yourself there are only valid records but the validation checks need to be done in code and not in the head. Put the validation checks in the code elsewise you're just guessing.


s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}


Comment on Re: Man, File::Tail is just beating me down!
Download Code
Re^2: Man, File::Tail is just beating me down!
by hallikpapa (Scribe) on Jan 18, 2008 at 02:45 UTC
    It's an excellent point and something I will defintely review, but because this problem has been ongoing, I am logging where it fails, which record, etc...and in some cases have even caught it happening. The problem I have discussed in this thread is seems to be unrelated. When I see a restart, I look at the line it restarted on, and check that line, the previous 10, and even the next 10. All standard...

      Rereading my post I realize that I was very unclear as to what I was seeing. I was assuming only the evidence you had for a restart was the logger script. If I was wrong then please supply any other logs you may have. Seeing that the logger was flawed I assumed that cleaning up the logger would give a clearer picture of what was happening. I saw nothing in what you had posted to convince me it wasn't a logger problem. Are you saying that some problem manifests itself even without the posted logger script running?? You'll have to excuse me in that I was a bit myopic in focusing on the code that was posted.

      Could you, please, post the code in the host machine that calls the suspected module?



      s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
        Originally it showed in the log on the client. There is a sequence number in each record that the process watches. If the sequence number was less than the current one, it figured it was a restart. printed to the log what the previous sequence number was, and the current one, and over and over everytime it got to that warning in the log, the sequence number was from the first record in the file. In my original post I put the logic to watch for a restart so it wouldn't try and stream all that data. that had been processed already. That code in the original post is almost the whole script minus the Socket connection. First the script receives the last record inserted into the database, creates the file::tail instance, then starts processing the log file and doesn't start streaming records until it gets to last line inserted. I guess that was a long winded way of saying everything is in the original post of this thread. I am convinced that one of the options I set here
        $file=File::Tail->new(name=>$filename, maxinterval=>5, interval=>1, ta +il=>-1, ignore_nonexistant => 1, errmode=>\&do_exit);
        has something in it's subroutine that causes a restart when I don't want one. It also looks like he does some sort of seek? Maybe to find where it left off? That would be cool to jump straight to where it left off by tracking the bytes. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://662978]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-07-10 22:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (217 votes), past polls