From 9c00eb91d6eeb822ae565ab5a1dd86882d60e857 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 14 Sep 2025 02:01:41 +0200 Subject: [PATCH] WebHost: fix Internal Server Error if parallel access to /room/* happens (#5444) --- WebHostLib/misc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WebHostLib/misc.py b/WebHostLib/misc.py index c57a638612..b308826779 100644 --- a/WebHostLib/misc.py +++ b/WebHostLib/misc.py @@ -260,7 +260,10 @@ def host_room(room: UUID): # indicate that the page should reload to get the assigned port should_refresh = ((not room.last_port and now - room.creation_time < datetime.timedelta(seconds=3)) or room.last_activity < now - datetime.timedelta(seconds=room.timeout)) - with db_session: + + if now - room.last_activity > datetime.timedelta(minutes=1): + # we only set last_activity if needed, otherwise parallel access on /room will cause an internal server error + # due to "pony.orm.core.OptimisticCheckError: Object Room was updated outside of current transaction" room.last_activity = now # will trigger a spinup, if it's not already running browser_tokens = "Mozilla", "Chrome", "Safari"