Skip to content

Update process status in the database before broadcasting that process status has changed (fix #6579)#6580

Merged
sphuber merged 3 commits intoaiidateam:mainfrom
agoscinski:fix/6579/update-process-state-before-fire-event
Oct 25, 2024
Merged

Update process status in the database before broadcasting that process status has changed (fix #6579)#6580
sphuber merged 3 commits intoaiidateam:mainfrom
agoscinski:fix/6579/update-process-state-before-fire-event

Conversation

@agoscinski
Copy link
Copy Markdown
Collaborator

@agoscinski agoscinski commented Oct 4, 2024

Fix for #6579

Processes start to broadcast their event before they update their process status in the database. This can cause issues if the next process directly tries to access the last process state retrieving it from the database while it has not been updated in the database.

TODO: test

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.86%. Comparing base (ef60b66) to head (4cda6e8).
Report is 183 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6580      +/-   ##
==========================================
+ Coverage   77.51%   77.86%   +0.36%     
==========================================
  Files         560      566       +6     
  Lines       41444    42095     +651     
==========================================
+ Hits        32120    32772     +652     
+ Misses       9324     9323       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agoscinski
Copy link
Copy Markdown
Collaborator Author

agoscinski commented Oct 4, 2024

I guess the CI failure is because of some unrelated problems.

I would like to have some feedback if anyone sees that this moving the setting of the process status might cause problems. The tests pass so far.

@agoscinski agoscinski marked this pull request as ready for review October 4, 2024 09:20
Copy link
Copy Markdown
Contributor

@sphuber sphuber 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 for tracking this one down @agoscinski and @t-reents . This one is my fault. I changed the behavior in this method two months ago to make sure a node was sealed when it excepted. I was thinking about the location of the super call and didn't remember why I moved it to the beginning originally, so I moved it back. Bad mistake! My comment on line 429 even explicitly reminded myself that attaching outputs has to happen before calling the parent, I just put "for reasons unknown". I guess we now know :D Could you perhaps please update the comment and replace/

For reasons unknown, it is important to update the outputs first, before doing anything else, otherwise there is the risk that certain outputs do not get attached before the process reaches a terminal state.

with

The updating of outputs and state has to be performed before the super is called because the super will broadcast state changes and parent processes may start running again before the state change is completed. It is possible that they will read the old process state and outputs that they check may not yet have been attached

@agoscinski agoscinski force-pushed the fix/6579/update-process-state-before-fire-event branch from 507e5e3 to a2fe4d2 Compare October 25, 2024 15:00
…e broadcasting that process event has changed

Processes start to broadcast their event before they update their
process status in the database. This can cause issues if the next
process directly tries to access the last process state retrieving it
from the database while it has not been updated in the database.
@agoscinski agoscinski force-pushed the fix/6579/update-process-state-before-fire-event branch from a2fe4d2 to e6d318a Compare October 25, 2024 15:00
@agoscinski
Copy link
Copy Markdown
Collaborator Author

agoscinski commented Oct 25, 2024

@sphuber Added your text, but on the place where the super is invoked. Also added a test now.

@agoscinski agoscinski requested a review from sphuber October 25, 2024 15:02
@sphuber sphuber merged commit 867353c into aiidateam:main Oct 25, 2024
@agoscinski agoscinski deleted the fix/6579/update-process-state-before-fire-event branch October 26, 2024 09:23
@danielhollas
Copy link
Copy Markdown
Collaborator

This one is my fault. I changed the behavior in this method two months ago to make sure a node was sealed when it excepted. I was thinking about the location of the super call and didn't remember why I moved it to

Just to clarify, which versions are affected by this bug? The linked issues mentioned that the bug is present in both 2.2 and 2.6 but that doesn't seem in line with the comment above?

@sphuber
Copy link
Copy Markdown
Contributor

sphuber commented Oct 27, 2024

The bug has never been released, it was just sitting on main

@agoscinski
Copy link
Copy Markdown
Collaborator Author

The linked issues mentioned that the bug is present in both 2.2

I think when I did the test my aiida-core upgraded at the installation of the pseudo potential, so this was wrong. At least I don't get the bug in 2.6.1. I'll correct it in the issue. But the bug was released for 2.6.2 https://github.com/aiidateam/aiida-core/blob/v2.6.2/src/aiida/engine/processes/process.py#L421

@danielhollas
Copy link
Copy Markdown
Collaborator

Thank, makes sense. So I guess it would make sense to push a new patch release, and I'll have to then upgrade aiida-core in AiiDAlab image which now uses 2.6.2

@sphuber
Copy link
Copy Markdown
Contributor

sphuber commented Oct 28, 2024

Ah @agoscinski is right, it was released. I just quickly looked at the commit where the change was introduced and Github didn't show any associated tags, which is usually a useful feature. However, I forgot that in this case, we made the release from a support branch and so the linked commit was cherry-picked onto the support branch before being released, and so the tag didn't show.

agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Nov 4, 2024
…idateam#6580)

Processes start to broadcast their event before they update their
process status in the database. This can cause issues if the next
process directly tries to access the last process state retrieving it
from the database while it has not been updated in the database.

Cherry-pick: 867353c
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Nov 4, 2024
…idateam#6580)

Processes start to broadcast their event before they update their
process status in the database. This can cause issues if the next
process directly tries to access the last process state retrieving it
from the database while it has not been updated in the database.

Cherry-pick: 867353c
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Nov 5, 2024
…idateam#6580)

Processes start to broadcast their event before they update their
process status in the database. This can cause issues if the next
process directly tries to access the last process state retrieving it
from the database while it has not been updated in the database.

Cherry-pick: 867353c
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Nov 5, 2024
…idateam#6580)

Processes start to broadcast their event before they update their
process status in the database. This can cause issues if the next
process directly tries to access the last process state retrieving it
from the database while it has not been updated in the database.

Cherry-pick: 867353c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants