-
Notifications
You must be signed in to change notification settings - Fork 28
comp_task requests are sequentially committed for each node in the project #2043
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
Codecov Report
@@ Coverage Diff @@
## master #2043 +/- ##
======================================
Coverage 72.5% 72.6%
======================================
Files 404 405 +1
Lines 14794 14844 +50
Branches 1496 1502 +6
======================================
+ Hits 10738 10782 +44
- Misses 3659 3666 +7
+ Partials 397 396 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
this pattern is new to me. What is it about? Avoids the director-v2 getting angry? 😤 🤣 😉
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.
Some minor optimization ;-)
**task_db.dict(by_alias=True, exclude_unset=True) | ||
) | ||
insert_stmt = insert(comp_tasks).values( | ||
**task_db.dict(by_alias=True, exclude_unset=True) |
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.
MINOR optimization: export to dict only once
# ... let's upseRT (insert or update) so people do not get upset! ;-)
task_values: Dict[str,Any] = task_db.dict(by_alias=True, exclude_unset=True)
upsert_stmt = insert(comp_tasks).values(**task_values).on_conflict_do_update(
index_elements=[comp_tasks.c.project_id, comp_tasks.c.node_id],
set_=task_values,
)
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.
sorry but I am against that change for now.
the first line in the function deletes the comp_tasks so the problem lies somewhere else.
there should be no need to upsert here. the problem is probably more that this code gets called asynchronously several times. doing upserts here will certainly generate some undefined state in the DB.
You are correct about your assumption. I thought the same. But for some reason the another process/task is interacting with Have a look at the attached log (the error is still present in the deployment). |
yes. as I said. THE only one inserting there is the director-v2. the sidecar/services are only updating.
|
That sounds really possible. Would you something like this working here:
|
this sounds like a good proposal. |
services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks.py
Show resolved
Hide resolved
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.
see comment. I think something from master went away
services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks.py
Outdated
Show resolved
Hide resolved
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.
all good!
What do these changes do?
NOTE: Original PR code was scraped as it did not address the issue
Issue explained by @sanderegg
see original below
THE only one (service) inserting there is the director-v2. the sidecar/services are only updating.
Therefore, I think the problem is the following:
webclient -> PUT /projects/{uuid}
-> webserver saves project AND sends a /POST /computations/{uuid} to the director-v2
-> director-v2 inserts the new computation by deleting and then inserting
PROBLEM: if you move a node the webclient also triggers a PUT cause the node changed, therefore if the user moves his things/add nodes/modify nodes triggering a lot of PUTs, I think the director-v2 receives a string of requests (which are all async). so my guess is that the director-v2 is still treating the request when a nother arrives.
Approved implementation proposal:
see original below
run_sequentially_in_context
decorator which will be applied to a function responsible for updating each individual node in the projectRelated issue number
How to test
Checklist
make openapi-specs
,git commit ...
and thenmake version-*
)