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

Race condition when identical programs run by multiple users #360

Closed
cdsmith opened this issue Sep 23, 2016 · 1 comment
Closed

Race condition when identical programs run by multiple users #360

cdsmith opened this issue Sep 23, 2016 · 1 comment
Labels

Comments

@cdsmith
Copy link
Collaborator

cdsmith commented Sep 23, 2016

During one of my classes today, on the first day, we gave everyone a simple program (main = drawingOf(codeWorldLogo), and had them all compile and run it. It broke for a lot of students.

Here's what happened:

  1. Many students in the class tried to run their identical programs at the same time.
  2. Since the program had not been compiled yet, each of their handler threads invoked the compiler on the same source file.
  3. One of the compilers finished first, and deleted all the temporary files.
  4. The remaining compilers found that their (still used) temporary files were missing, and failed.
  5. The last compiler won, and wrote the resulting error message. From that point on, attempts to rebuild the same source code returned the same error.

Two things are notable here: First, running many instances of GHC simultaneously with the same output files was probably always doomed. And second, it would be great to retry errors like this. (We don't want to retry successes, though)

The immediate fix seems pretty obvious. Instead of building in-place, we should create a unique temp directory, build there, and then copy the result and delete the temporaries, once the build is done.

@cdsmith
Copy link
Collaborator Author

cdsmith commented Sep 24, 2016

Wow, this is causing a lot of problems. I should fix this quickly. :(

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

No branches or pull requests

1 participant