darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
998 stars 342 forks source link

On Windows, temporary file not deleted - leads to warning #101

Closed btostevepritchard closed 9 years ago

btostevepritchard commented 9 years ago

When I run ora2pg for a COPY, I get the following message at the end:

WARNING: an error occurs during data export. Please check what's happen.

This happens because a temporary file hasn't been cleaned up.

(Windows 7, perl v5.18.2 built for MSWin32-x64-multi-thread)

Checking the code in Ora2Pg.pm, I found that the unlink of the temporary file on line 7944 was failing because the file was still open. Changing this to...

close($tempfiles[0]->[0]);
unlink($tempfiles[0]->[1]);

...fixes the problem.

darold commented 9 years ago

Thanks for the report, the issue is now fixed with last commit a52c425.

Best regards,

btostevepritchard commented 9 years ago

Darold,

Many thanks for the extremely quick response.

One thing I should have asked in my original issue report was why a temporary file is created in the first place. As far I as I can see, "tempfiles" is never used - it just gets unlinked at the end. I guess that some earlier code used a temporary file and that this has now been removed or replaced.

Would it be worth removing all reference to "tempfiles"? One less thing to go wrong!

Steve

On 18 December 2014 at 12:39, Darold notifications@github.com wrote:

Thanks for the report, the issue is now fixed with last commit a52c425 https://github.com/darold/ora2pg/commit/a52c4259262050db60ce58d85f9ff7916dd4006b .

Best regards,

— Reply to this email directly or view it on GitHub https://github.com/darold/ora2pg/issues/101#issuecomment-67480498.

Steve Pritchard Oracle Database Developer

British Trust for Ornithology, The Nunnery, Thetford, Norfolk IP24 2PU, UK Tel: +44 (0)1842 750050, fax: +44 (0)1842 750030 Registered Charity No 216652 (England & Wales) No SC039193 (Scotland) Company Limited by Guarantee No 357284 (England & Wales)

darold commented 9 years ago

Hi,

Ora2Pg always report errors from the Oracle client, this is the way you know if everything is well done and you trust Ora2Pg. During data export in multiprocess mode, you can experience OOM on some BLOB extraction process and there's no error reported to the main Ora2Pg process. This can mislead you that all your data was well exported.

To fix that Ora2Pg now creates a temporary file when a call to the export function is done and removed the file when it leave the function. Like that in case of OOM, the temporary file is still present and the error can be detected by the main process.

I hope I'm clear enough. But I'm agree that on Windows this could be removed/disabled because multiprocess is not supported.

Best regards,

btostevepritchard commented 9 years ago

Darold,

Yes that makes sense - a clever way of trapping the OOM errors.It just wasn't obvious from the code.

No problem having it in for Windows as well, now that you've ensured that temp file is closed.

Steve

On 19 December 2014 at 16:32, Darold notifications@github.com wrote:

Hi,

Ora2Pg always report errors from the Oracle client, this is the way you know if everything is well done and you trust Ora2Pg. During data export in multiprocess mode, you can experience OOM on some BLOB extraction process and there's no error reported to the main Ora2Pg process. This can mislead you that all your data was well exported.

To fix that Ora2Pg now creates a temporary file when a call to the export function is done and removed the file when it leave the function. Like that in case of OOM, the temporary file is still present and the error can be detected by the main process.

I hope I'm clear enough. But I'm agree that on Windows this could be removed/disabled because multiprocess is not supported.

Best regards,

— Reply to this email directly or view it on GitHub https://github.com/darold/ora2pg/issues/101#issuecomment-67661274.

Steve Pritchard Oracle Database Developer

British Trust for Ornithology, The Nunnery, Thetford, Norfolk IP24 2PU, UK Tel: +44 (0)1842 750050, fax: +44 (0)1842 750030 Registered Charity No 216652 (England & Wales) No SC039193 (Scotland) Company Limited by Guarantee No 357284 (England & Wales)