-
Notifications
You must be signed in to change notification settings - Fork 5
Description
If the exercise grader running in the container uses concurrent processing somehow, then using the points command is not safe because points is not reentrant yet. It is thus possible, that process/thread A reads the points file, but process/thread B then reads and writes the points file before process A reaches the part for writing the points file. Then, the final points would not include any results that were handled by process B because they are overwritten by process A. Process A did not "see" any points from B when A was initially reading the points file.
It would be best to make points reentrant by explicitly locking the file (e.g., with flock https://stackoverflow.com/a/17480020).
The points command:
https://github.com/apluslms/grading-base/blob/master/bin/points
The flock command is already available in the grading-base container so I don't think we need to install any new packages.
The points file is read on this line:
Line 14 in 08172e7
| IFS=/ read points max_points < $pfile |
And the points file is written on this file:
Line 30 in 08172e7
| echo "$points/$max_points" > $pfile |
Do we need to lock both reading and writing the points file? I think so since we don't want any "process A" to read the points file just before another process is writing its changes to the points file. I think this also means that the lock must be held from the time of reading the points file to the time of writing the points file. If the lock is released between the reading and writing operations, then another process could modify the points file after someone has read the file, but before the file has been written.
Internal ticket from the teacher:
https://rt.cs.aalto.fi/Ticket/Display.html?id=24484
https://en.wikipedia.org/wiki/Reentrancy_(computing)
Differences between flock and lockf:
https://stackoverflow.com/questions/22409780/flock-vs-lockf-on-linux
flock only works on local filesystems while lockf works on NFS too.
In the grading container, if the lock file is written under the /var/ directory, I think that is under the local disk.
Filepaths /submission and /exercise are on NFS.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status