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

Make writing of marks files atomic #55

Open
fingolfin opened this issue May 17, 2016 · 7 comments
Open

Make writing of marks files atomic #55

fingolfin opened this issue May 17, 2016 · 7 comments

Comments

@fingolfin
Copy link
Contributor

Right now, git-remote-hg can die while in the middle of writing the marks files, fatally corrupting the state of git-remote-hg, and potentially forcing the user to make a fresh clone.

Things would be better if the marks files were writing atomically, or if at least the time during which a dieing process would cause issues was minimized. E.g. write the the marks first to new files; then swap old and new files atomically (on systems that support that; on systems that don't, first move the old files away, then move the new files into place, then delete the old files; this way, it is quite easy to recover manually).

@felipec
Copy link
Owner

felipec commented May 17, 2016

Marks are stored in a single line of code.

json.dump(self.dict(), open(self.path, 'w'))

@fingolfin
Copy link
Contributor Author

Sure. But what is the relevance of that remark?

@felipec
Copy link
Owner

felipec commented May 17, 2016

I doubt very much in reality the process is actually dying in the middle of that single line of code.

@fingolfin
Copy link
Contributor Author

This kind of bug has been known for decades, and countless people have shared your doubt, and paid for it. In this particular case, it can even be reproducibly triggered within git-remote-hg. Hint: Take a repository with a couple hundred thousands of commits in it to increase the likelihood, and then write a stress test script.

Of course it can also happen with a repo that just contains 5000 commits.

@felipec
Copy link
Owner

felipec commented May 17, 2016

Those are different issues.

@fingolfin
Copy link
Contributor Author

How is the git-remote-hg script dieing in the middle of that "single line of code", resulting in an invalid / incomplete JSON marks file, a different issue?

@felipec
Copy link
Owner

felipec commented May 17, 2016

It's not happening. Show me an incomplete JSON marks file that a user reported with a recent version of git-remote-hg and Git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants