-
Notifications
You must be signed in to change notification settings - Fork 1.3k
NUTCH-2518 Cleaning up the file system after a job failure. #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Path outPath = FileOutputFormat.getOutputPath(job); | ||
| if (fs.exists(outPath)) | ||
| fs.delete(outPath, true); | ||
| LOG.error("Crawl job failed ", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please always use parameterized logging e.g.
LOG.error("Crawl job failed {}", e);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK! I will incorporate this change and send a commit covering all the 25 instances. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
The CrawlDb cleanup method looks same as that from Injector: maybe move it to CrawlDb.java - there are already methods to lock and install the CrawlDb shared by various jobs (inject, update, merge, generate).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not shift the sub routine cleanup to the class nutch/src/java/org/apache/nutch/util/NutchJob.java? This is a nutch job utils file, I think this would be more appropriate. I have cross checked that cleanup sub routine would be useful outside crawldb like in hostdb, indexer etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It's not specific to the CrawlDb because lock file and temp dir are passed explicitly.
|
I have added a new commit, please feel free to review it and let me know if any changes are required. I will squash the commits at the end. |
sebastian-nagel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 great job! One point needs a fix. Thanks!
| + job.getStatus().getFailureInfo(); | ||
| LOG.error(message); | ||
| cleanupAfterFailure(tempCrawlDb, lock, fs); | ||
| CrawlDb.cleanupAfterFailure(tempCrawlDb, lock, fs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be NutchJob.cleanupAfterFailure(...)
| } | ||
| LockUtil.removeLockFile(fs, lock); | ||
| } catch (IOException e) { | ||
| CrawlDb.cleanupAfterFailure(tempCrawlDb, lock, fs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change this, Thanks.
| + job.getStatus().getFailureInfo(); | ||
| LOG.error(message); | ||
| NutchJob.cleanupAfterFailure(tempDir, lock, fs); | ||
| NutchJob.cleanupAfterFailure(tempDir2, lock, fs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, it's not an error to try to remove the lock file a second time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No @sebastian-nagel. AFAIK if I try to remove a lock file that does not exist, the function would just return False.
|
+1 Thanks, @Omkar20895! I'll step forward and commit the fix. |
|
Thanks @sebastian-nagel :) |
NUTCH-2518 Cleaning up the file system after a job failure.
|
Squashed, rebased and committed in 8682b96. Thanks again, @Omkar20895! |
|
This is ready to be merged @sebastian-nagel ? |
|
That's already merged but with a rebase and squash done in command-line. Sorry, that's not automatically detected by github and I forgot to manually close this PR. Thanks! |
Confusion:
Thanks.