Skip to content

Conversation

@sanderegg
Copy link
Member

@sanderegg sanderegg commented May 22, 2025

What do these changes do?

This PR fixes the issue described in #7722.
The comp_tasks table uses an event trigger and the webservers listens to that event to transmit changes in comp_tasks outputs, state. This includes payload generation for table updates and ensures proper handling of outputs and state fields changes. The procedure used to transmit the whole row as payload through pg_notify. This is limited to 8000 bytes.

This PR changes the procedure to not pass the row in the payload anymore due to that limitation.

Therefore changes are now in the listener code of the webserver, such that an additional query to comp_tasks is necessary in order to transmit the notifications to the next nodes/frontend.

What is still not good?

Related issue/s

How to test

Dev-ops

@sanderegg sanderegg added this to the Bazinga! milestone May 22, 2025
@sanderegg sanderegg self-assigned this May 22, 2025
@sanderegg sanderegg added the a:director-v2 issue related with the director-v2 service label May 22, 2025
@codecov
Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.34%. Comparing base (b23a6d5) to head (b4ee34b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7725      +/-   ##
==========================================
+ Coverage   87.32%   87.34%   +0.01%     
==========================================
  Files        1840     1834       -6     
  Lines       71475    71266     -209     
  Branches     1214     1214              
==========================================
- Hits        62418    62249     -169     
+ Misses       8714     8674      -40     
  Partials      343      343              
Flag Coverage Δ
integrationtests 64.38% <94.11%> (-0.04%) ⬇️
unittests 86.58% <94.11%> (+0.03%) ⬆️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library 93.92% <ø> (ø)
pkg_dask_task_models_library 79.55% <ø> (ø)
pkg_models_library 93.08% <ø> (ø)
pkg_notifications_library 85.26% <ø> (ø)
pkg_postgres_database 88.61% <ø> (ø)
pkg_service_integration 69.92% <ø> (ø)
pkg_service_library 71.86% <ø> (ø)
pkg_settings_library 90.90% <ø> (ø)
pkg_simcore_sdk 84.89% <ø> (-0.18%) ⬇️
agent 96.46% <ø> (ø)
api_server 91.79% <ø> (ø)
autoscaling 96.07% <ø> (ø)
catalog 92.29% <ø> (ø)
clusters_keeper 99.25% <ø> (ø)
dask_sidecar 91.67% <ø> (ø)
datcore_adapter 98.12% <ø> (ø)
director 76.78% <ø> (ø)
director_v2 91.00% <ø> (ø)
dynamic_scheduler 96.76% <ø> (ø)
dynamic_sidecar 90.19% <ø> (ø)
efs_guardian 89.79% <ø> (ø)
invitations 93.28% <ø> (ø)
payments 92.63% <ø> (ø)
resource_usage_tracker 88.91% <ø> (-0.27%) ⬇️
storage 87.49% <ø> (-0.08%) ⬇️
webclient ∅ <ø> (∅)
webserver 85.71% <94.11%> (+0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b23a6d5...b4ee34b. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sanderegg sanderegg force-pushed the bugfix/comp-tasks-hanlding-of-large-input-outputs branch 4 times, most recently from 5894e69 to f26b047 Compare May 23, 2025 15:04
@sanderegg sanderegg changed the title 🐛Computational services with large amount of inputs/outputs fail to start 🐛Computational services with large amount of inputs/outputs fail to start (🗃️) May 23, 2025
@sanderegg sanderegg marked this pull request as ready for review May 23, 2025 16:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a bug where computational task notifications fail to start due to oversized payloads by changing the trigger to emit only key identifiers and refactoring the listener to fetch full row data. Tests and mocks are updated to validate the new minimal payload and listener behavior.

  • Trigger now sends only task_id, project_id, node_id, table, action, and changes
  • Listener code uses a Pydantic model and queries the DB for full task data
  • Tests and fixtures revised to align with minimal payload and new retry logic

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/web/server/tests/unit/with_dbs/04/notifications/test_notifications__db_comp_tasks_listening_task.py Adapted tests for minimal payload, added retry helper and spy
services/web/server/src/simcore_service_webserver/db_listener/plugin.py Removed unused RabbitMQ setup
services/web/server/src/simcore_service_webserver/db_listener/_models.py Added CompTaskNotificationPayload Pydantic model
services/web/server/src/simcore_service_webserver/db_listener/_db_comp_tasks_listening_task.py Refactored listener to use minimal payload and fetch full row
packages/pytest-simcore/src/pytest_simcore/db_entries_mocks.py Added centralized comp_task fixture for task insertion
packages/postgres-database/tests/test_comp_tasks.py Updated expectations for minimal payload and table metadata
packages/postgres-database/src/simcore_postgres_database/models/comp_tasks.py Modified trigger to emit only identifier fields
packages/postgres-database/src/simcore_postgres_database/migration/versions/278daef7e99d_remove_whole_row_in_payload.py New migration removing full-row JSON from payload
.github/copilot-instructions.md Added rules for relative imports and import ordering
Comments suppressed due to low confidence (2)

services/web/server/tests/unit/with_dbs/04/notifications/test_notifications__db_comp_tasks_listening_task.py:105

  • The names wait_fixed and stop_after_delay are used but not imported; add from tenacity.wait import wait_fixed and from tenacity.stop import stop_after_delay at the top of the file.
wait=wait_fixed(1),

services/web/server/src/simcore_service_webserver/db_listener/_db_comp_tasks_listening_task.py:70

  • The function uses cast but cast is not imported; add from typing import cast or import cast from typing.
return cast(RowProxy | None, await result.fetchone())

Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sanderegg sanderegg force-pushed the bugfix/comp-tasks-hanlding-of-large-input-outputs branch from e6d0723 to 81deb76 Compare May 26, 2025 06:19
Copy link
Contributor

@wvangeit wvangeit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @sanderegg !

@sanderegg sanderegg force-pushed the bugfix/comp-tasks-hanlding-of-large-input-outputs branch from a14b0c2 to e0eee41 Compare May 26, 2025 09:16
@sanderegg sanderegg added the 🤖-automerge marks PR as ready to be merged for Mergify label May 26, 2025
@sanderegg
Copy link
Member Author

@mergify merge

@sanderegg
Copy link
Member Author

@mergify queue

@sanderegg sanderegg enabled auto-merge (squash) May 26, 2025 09:17
@mergify
Copy link
Contributor

mergify bot commented May 26, 2025

merge

❌ Sorry but I didn't understand the command. Please consult the commands documentation 📚.

@mergify
Copy link
Contributor

mergify bot commented May 26, 2025

queue

🛑 The pull request has been merged manually

The pull request has been merged manually at 403186c

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx!

@sanderegg sanderegg force-pushed the bugfix/comp-tasks-hanlding-of-large-input-outputs branch from e0eee41 to a8d86cd Compare May 26, 2025 11:54
Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@sonarqubecloud
Copy link

@sanderegg sanderegg merged commit 403186c into ITISFoundation:master May 26, 2025
94 of 96 checks passed
@sanderegg sanderegg deleted the bugfix/comp-tasks-hanlding-of-large-input-outputs branch May 26, 2025 13:20
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Jun 6, 2025
92 tasks
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Aug 5, 2025
88 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify a:director-v2 issue related with the director-v2 service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Computational service can not run if service has around 20 input / outputs

6 participants