Skip to content
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

Issue 18: Housekeeping shouldn't fail when attempting to cleanup a path that is already deleted #19

Merged
merged 13 commits into from
Apr 25, 2018

Conversation

courtsVII
Copy link

@courtsVII courtsVII commented Apr 20, 2018

Fixes #18

@courtsVII courtsVII requested review from a team and removed request for a team April 20, 2018 10:07
@coveralls
Copy link

coveralls commented Apr 20, 2018

Coverage Status

Coverage decreased (-2.3%) to 74.176% when pulling e2fe441 on issue-18 into e790509 on master.

Courtney Edwards added 2 commits April 20, 2018 13:51
@courtsVII courtsVII requested a review from a team April 20, 2018 14:17
Copy link
Contributor

@massdosage massdosage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mostly good, have you tested it with "for real" by manually deleting some paths that are in the DB and running the tool? Should be fairly straightforward to reproduce before/after behaviour if you've managed to get the "tool" into this project (I can't remember where we are with that?)

@@ -47,39 +48,65 @@ public FileSystemHousekeepingService(LegacyReplicaPathRepository legacyReplicaPa
LOG.warn("{}.fixIncompleteRecord(LegacyReplicaPath) should be removed in future.", getClass());
}

private FileSystem fileSystemForPath(LegacyReplicaPath cleanUpPath) {
LOG.info("Attempting to delete path '{}' from file system", cleanUpPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't doing a delete? Update comment to clarify that this is trying to determine the FS for a path, or just remove it. If you do decide to keep it it's probably worth putting on debug rather than info.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it to more relevant place, aftermath of copy and paste :)

Path path = new Path(cleanUpPath.getPath());
FileSystem fs;
try {
fs = path.getFileSystem(conf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just return this and then you don't even need the "fs" variable. The scope expanding out on line 54 definitely isn't needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -47,39 +48,65 @@ public FileSystemHousekeepingService(LegacyReplicaPathRepository legacyReplicaPa
LOG.warn("{}.fixIncompleteRecord(LegacyReplicaPath) should be removed in future.", getClass());
}

private FileSystem fileSystemForPath(LegacyReplicaPath cleanUpPath) {
LOG.info("Attempting to delete path '{}' from file system", cleanUpPath);
Path path = new Path(cleanUpPath.getPath());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method could take the Path type directly so you don't have to create it twice (once here and once in the calling method currently)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@ddcprg ddcprg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
}
} catch (Exception e) {
LOG.warn("Path '{}' was not deleted from the housekeeping database. {}", cleanUpPath, e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does prevent housekeeping from failing but it won't delete the path from the repo, so we'll get this warning on every run of housekeeping or am I missing something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is only reached if legacyReplicaPathRepository.delete(cleanUpPath); fails, signifying a failure to delete the specified path from the Housekeeping database

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if oneOfMySiblingsWillTakeCareOfMyAncestors(path, rootPath, fs) || thereIsNothingMoreToDelete(fs, rootPath) throws an exception which I thought was why we got the error in the first place, we'll hit the catch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I was looking at wrong try block.. I'm hesitant to delete data from the Housekeeping database here as it may fail for another unforeseen reason that isn't the path being deleted already, do you think we should just do the deletion anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to know exactly at what point we got the error and check what path we were trying to delete is that some parent path or something else? What would happen if we warn and run again, failure at same place?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becomes complex cause of eventual consistency and the likes, I would rather leave it like this, they will get a small warning in their logs when they run their application but I would rather that over leaving behind data that I may be paying for

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let's go for this, if the warnings become an issue we can revisit.

@courtsVII courtsVII merged commit 93977a1 into master Apr 25, 2018
@courtsVII courtsVII deleted the issue-18 branch April 25, 2018 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants