-
Notifications
You must be signed in to change notification settings - Fork 283
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
Conversation
internal/db/schema/migrations/oss/postgres/28/01_prior_session_trigger.up.sql
Outdated
Show resolved
Hide resolved
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; |
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.
Can this be incorporated into the update statement using a returning
clause?
if new.prior_state is null then | ||
new.prior_state='pending'; | ||
end if; |
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.
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() |
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.
Do we have unit tests to cover this?
internal/db/schema/migrations/oss/postgres/28/01_prior_session_trigger.up.sql
Outdated
Show resolved
Hide resolved
internal/db/schema/migrations/oss/postgres/28/01_prior_session_trigger.up.sql
Outdated
Show resolved
Hide resolved
fe42798
to
a77ee04
Compare
@@ -0,0 +1,113 @@ | |||
begin; |
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.
I think this should still be in 28
, but should be 28/02
b0b1ade
to
c6764e8
Compare
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