DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
738 stars 260 forks source link

Removing a problem from a contest fails if there are submissions #2210

Open vmcj opened 1 year ago

vmcj commented 1 year ago

Description of the problem

We get the following error: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`domjudge`.`judging_run`, CONSTRAINT `FK_29A6E6E13CBA64F2` FOREIGN KEY (`judgetaskid`) REFERENCES `judgetask` (`judgetaskid`))

Your environment

Steps to reproduce

Expected behaviour

The contest problem gets deleted or we don't allow removing the problem from the contest, no server errors expected

Actual behaviour

Error, problem is not removed (so we stay consistent)

meisterT commented 1 year ago

I cannot repro this, and thought it is fixed via https://github.com/DOMjudge/domjudge/commit/181ae06a5625611274f7217be85cfd28d5f351b4

If you have a dump and know the exact source state BAPC ran in I would be interested into looking into this.

vmcj commented 1 year ago

I cannot repro this, and thought it is fixed via 181ae06

If you have a dump and know the exact source state BAPC ran in I would be interested into looking into this.

Strange, I think I also got this after BAPC (but on an empty DB) by loading the example problems and trying to delete the admin user.

meisterT commented 1 year ago

trying to delete the admin user

This issue is about removing a problem. https://github.com/DOMjudge/domjudge/issues/2207 is about deleting the user

vmcj commented 1 year ago

trying to delete the admin user

This issue is about removing a problem. #2207 is about deleting the user

You're right, but also this is about removing a problem from a contest (which I think is important)

I tried to remove the hello world from /problems, that works, if you remove (or unlink actually) the problem from the demo contest than we get an issue.

tuupke commented 3 months ago

Fixed in #2658, but the confirm modal is slightly different than the others. Will check first and PR when needed before closing this issue.

tuupke commented 3 months ago

Ok there indeed is an 'issue' with the modal. The magic that is used to show how many of which entity will be removed explicitly ignores compound keys. This is needed to check which entities would be affected.

By changing around the order of the foreaches we can check whether an entity matches a foreign key instead of trying to match a foreign key to an entity. Will probably do the refactor somewhere this week.