Skip to content
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

fix(session): Update session state transition trigger #2046

Merged
merged 1 commit into from
May 2, 2022

Conversation

irenarindos
Copy link
Collaborator

Fixes #2040

Session state trigger is updated to set prior state to the most recent session state.
In the prior version of the trigger, prior_state was set to the last most recent state that represented a valid state transition for the inserted state (Ex: A session could go through pending, active, terminated, and then canceling would be inserted with active as prior)
With this change, canceling will fail on insert as terminated-> canceling is an invalid state transition

Comment on lines 102 to 103
new.prior_state = query.state from(
select state from session_state where session_id=new.session_id order by start_time desc limit 1) as query;
Copy link
Member

Choose a reason for hiding this comment

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

Can this be incorporated into the update statement using a returning clause?

Comment on lines 105 to 107
if new.prior_state is null then
new.prior_state='pending';
end if;
Copy link
Member

Choose a reason for hiding this comment

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

Can this be incorporated into the if not found then block starting on line 91?

drop function insert_session_state();

create function
insert_session_state()
Copy link
Member

Choose a reason for hiding this comment

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

Do we have unit tests to cover this?

@jefferai jefferai added this to the 0.8.0 milestone May 2, 2022
mgaffney
mgaffney previously approved these changes May 2, 2022
@@ -0,0 +1,113 @@
begin;
Copy link
Member

Choose a reason for hiding this comment

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

I think this should still be in 28, but should be 28/02

@irenarindos irenarindos requested a review from tmessi May 2, 2022 19:55
tmessi
tmessi previously approved these changes May 2, 2022
@irenarindos irenarindos force-pushed the irindos-session-transition-trigger branch from b0b1ade to c6764e8 Compare May 2, 2022 19:58
@irenarindos irenarindos merged commit ca2599e into main May 2, 2022
@irenarindos irenarindos deleted the irindos-session-transition-trigger branch May 2, 2022 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sessions stuck in cancelling state
4 participants