jsilva_im has asked for the wisdom of the Perl Monks concerning the following question:

All, I'm having a rather strange problem while trying to save files out to our ReadyNas file store. The file contents are being pulled from our MySQL database and onto our ReadyNas. When I copy the file to the local drive, the file is copied without any corruption. When I try and copy the file directly to our mapped ReadyNas drive, the file is corrupted everytime. The file size is roughly 89megs and I have binmode turned on. I can copy the file to the local drive and THEN onto the ReadyNas without any problems. I have tried disabling all the buffers, but the copy will still fail. I'm tempted to just do the two separate copies, but it seems like it should work in all cases.
my $getFiles = $dbh->prepare($sql)|| die "Unable to get getMaxFile"; $getFiles->execute(); $rv = $getFiles->bind_columns(\$file_id, \$filename,\$content); open FILE, ">$filename"; binmode FILE; print FILE "$content"; close FILE;
Help.

Replies are listed 'Best First'.
Re: ReadyNas File Store Copy
by samtregar (Abbot) on Mar 11, 2008 at 20:26 UTC
    You need to check your return codes for your I/O calls. One of them may be failing. For example:

    print FILE "$content" or die "Print failed: $!";

    Do that for open() and close() too, although I imagine you would have noticed if open() had failed.

    -sam

      Ah! A clue! Okay, with the "print" command I get the error: "Invalid argument" Even with this error, part of the file is copied over to the ReadyNas.
        That's a mysterious error, not a lot to go on. Have you tried using syswrite() instead of print()?

        Is there anything odd about the filename or directory name you're trying to create? Googling around leads me to think your ReadyNas is likely a FAT32 filesystem and it's not hard to give FAT32 indigestion.

        -sam

Re: ReadyNas File Store Copy
by starbolin (Hermit) on Mar 12, 2008 at 02:11 UTC

    Most illuminating would be tcpdump logs. Also see if there are any errors in your system logs. The ReadyNAS also can generate a complete set of logs.

    Although I am reluctant to quickly point the finger at the "other guy", I did do some browsing on the Neatgear forum and I found them very 'educational'. I think the guys at Infrant are probably better prepared to comment on the cause of failure than us perl mongers.


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
      I tried using Syswrite and it failed as well. There is nothing too odd about the file names as I am specifically copying to "test.pdf". It just seems that it fails on ONLY the larger sized files, roughly greater than 70megs. Even this is random though, because we have had a few normal ones get written without a problem.

        More literature search has led to the possibility that the NAS drivers use some socket internally that is timing out on long transfers.

        That it breaks the same under Syswrite further points to a network stack problem vs an interface problem as once the data is written to the interface it has to be repackaged into MTUs. So block size into the interface is inconsequential.


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