Skip to content

Commit 88402f5

Browse files
review @pcrespov
1 parent 05bfe3e commit 88402f5

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

services/web/server/src/simcore_service_webserver/projects/_project_document_service.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from models_library.api_schemas_webserver.socketio import SocketIORoomStr
1616
from models_library.projects import ProjectID, ProjectTemplateType
1717
from models_library.projects import ProjectType as ProjectTypeAPI
18+
from servicelib.logging_errors import create_troubleshootting_log_kwargs
1819
from servicelib.redis import (
1920
PROJECT_DB_UPDATE_REDIS_LOCK_KEY,
2021
exclusive,
@@ -156,16 +157,40 @@ async def remove_project_documents_as_admin(app: web.Application) -> None:
156157
project_uuid,
157158
)
158159
else:
160+
# Create a synthetic exception for this unexpected state
161+
unexpected_state_error = RuntimeError(
162+
f"Project {project_uuid} has {len(room_sessions)} connected users but is not in Redis Resources table"
163+
)
159164
_logger.error(
160-
"Project %s has %d connected users in the socket io room (This is not expected, as project resource is not in the Redis Resources table), keeping document just in case",
161-
project_uuid,
162-
len(room_sessions),
165+
**create_troubleshootting_log_kwargs(
166+
user_error_msg=f"Project {project_uuid} has {len(room_sessions)} connected users in the socket io room (This is not expected, as project resource is not in the Redis Resources table), keeping document just in case",
167+
error=unexpected_state_error,
168+
error_context={
169+
"project_uuid": str(project_uuid),
170+
"project_room": project_room,
171+
"key_str": key_str,
172+
"connected_users_count": len(room_sessions),
173+
"room_sessions": room_sessions[
174+
:5
175+
], # Limit to first 5 sessions for debugging
176+
},
177+
tip="This indicates a potential race condition or inconsistency between the Redis Resources table and socketio room state. Check if the project was recently closed but users are still connected, or if there's a synchronization issue between services.",
178+
)
163179
)
180+
continue
164181

165-
except (KeyError, AttributeError, ValueError):
182+
except (KeyError, AttributeError, ValueError) as exc:
166183
_logger.exception(
167-
"Failed to check room participants for project %s",
168-
project_uuid,
184+
**create_troubleshootting_log_kwargs(
185+
user_error_msg=f"Failed to check room participants for project {project_uuid}",
186+
error=exc,
187+
error_context={
188+
"project_uuid": str(project_uuid),
189+
"project_room": project_room,
190+
"key_str": key_str,
191+
},
192+
tip="Check if socketio server is properly initialized and the room exists. This could indicate a socketio manager issue or invalid room format.",
193+
)
169194
)
170195
continue
171196

0 commit comments

Comments
 (0)