-
Notifications
You must be signed in to change notification settings - Fork 279
Fix scoreboard update after rejudging. #3089
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
Conversation
Previous buggy flow was something like: - fetch all submissions that for this team/contest/problem combination - that are valid - and have a valid judging The idea of https://github.com/DOMjudge/domjudge/blob/95df1de7bce91f43600cfcb8760ea85762936614/webapp/src/Service/ScoreboardService.php#L240 was that this would filter the OneToMany collection down to only valid judgings. This is also what happens on the database side. However, on the doctrine side, the entity manager keeps a cache, and if the submission is already in the cache with the full collection of valid and invalid judgings, it will only merged with new data from the database query, no data (i.e. no judgings) will magically disappear. In order to fix this, we explicitly filter on the PHP side. An alternative would be to add a new `OneToMany` mapping with a `where` on it and use that. Fixes DOMjudge#2883
3a0d2fa
to
0e76202
Compare
Why is it so hard (or expensive) to fix this in the DB side? I miss that comment currently. |
I am not aware of any fix on the DB side. We could decide to switch off doctrine or disable any entity caching which would cost performance. In case you are refering to what I wrote in the commit description:
The two options are relatively equal. I picked filtering on the PHP side since 99% of submissions have 1 judging, so it is very cheap to do so. The other solution would not change the DB but allow us to to do an implicit DB query but it would require a migration. |
foreach ($this->judgings as $j) { | ||
if ($j->getValid()) { | ||
return $j; | ||
} | ||
} | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach ($this->judgings as $j) { | |
if ($j->getValid()) { | |
return $j; | |
} | |
} | |
return null; | |
return $this->judgings->findFirst(fn(Judging $j) => $j->getValid()); |
maybe?
I assume the current code will get merged but just for the discussion. I think doing this with the migration is better. We use Doctrine to handle the translation between database and what we get in PHP and we found one location where this is an issue. By doing this with the migration I think we force the solution to other (future) locations, by doing it in the PHP we have more code to read because of something which Doctrine is doing which is easily removed which would re-introduce the bug. We wouldn't change a OneToMany that easily so when we touch that code again we will most likely pickup this change in the
|
@vmcj note that in both cases (with this change and the migration), you have a PHP function |
Ok, I still don't understand but I'll assume you know what you're doing. |
Previous buggy flow was something like:
The idea of
domjudge/webapp/src/Service/ScoreboardService.php
Line 240 in 95df1de
However, on the doctrine side, the entity manager keeps a cache, and if the submission is already in the cache with the full collection of valid and invalid judgings, it will only merged with new data from the database query, no data (i.e. no judgings) will magically disappear.
In order to fix this, we explicitly filter on the PHP side. An alternative would be to add a new
OneToMany
mapping with awhere
on it and use that.Fixes #2883