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

DM-44462: Try to trap case where another eups process deletes the db file #152

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

timj
Copy link
Collaborator

@timj timj commented Jun 24, 2024

No description provided.

timj added 4 commits June 24, 2024 15:25
No need to use a regex and store the value since it's used twice.
Allows it to easily be used in a with block.
Some other EUPS process could remove the db file that was created
by this process.
fd = open(fileName, "rb")
lookup = pickle.load(fd)
fd.close()
with open(fileName, "rb") as fd:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The code is littered with the old style opens. I have only fixed the one that was in the same file as I was editing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what I'm supposed to do about the race in this code. Maybe it's a bit early in the day for me but that code gets the file name from the flavor, calls stat without checking if the cache file is there, then tries to open it. I think the code is assuming that the reload call is gated by a check higher up.

if file not in self.modtimes:
return True
try:
older = os.stat(file).st_mtime <= self.modtimes[file]
Copy link
Contributor

Choose a reason for hiding this comment

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

There seem to be a number of similar os.stat() calls. They don't need protection as well?

It's curious that the only thing that seems to remove this file is an admin command.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will take a look at the other places.

I was also wondering how the file disappears even in the case where 30 EUPS processes in parallel are trying to read the same database file. The atomic rename should not result in the file disappearing so I realize that this is papering over the cracks a little. @RobertLuptonTheGood do you know of a way that the pickle file could be deleted in normal usage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added a couple more traps but reload is a problem.

Copy link
Contributor

@ktlim ktlim left a comment

Choose a reason for hiding this comment

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

Even if this isn't the ultimate solution, it still looks better than what was there before.

@timj timj merged commit e5ba4dc into master Jun 26, 2024
8 checks passed
@timj timj deleted the tickets/DM-44462 branch June 26, 2024 04:54
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.

2 participants