terminate "completed" sessions (#477)

This commit is contained in:
Jim authored and GitHub committed 2020-10-01 10:13:57 -04:00
1 parent d851ab07d8
commit 19aecfefae
8 files changed
+416 -33

No files matched your search

@@ -71,7 +71,9 @@ begin;
'closed by end-user',
'terminated',
'network error',
'system error'
'system error',
'connection limit',
'canceled'
)
)
);
@@ -83,7 +85,9 @@ begin;
('closed by end-user'),
('terminated'),
('network error'),
('system error');
('system error'),
('connection limit'),
('canceled');
create table session (
public_id wt_public_id primary key,
@@ -236,18 +240,26 @@ begin;
as $$
begin
if new.termination_reason is not null then
-- check to see if there are any open connections.
perform from
session_connection sc,
session_connection_state scs
where
sc.public_id = scs.connection_id and
scs.state != 'closed' and
sc.session_id = new.public_id;
if found then
raise 'session %s has existing open connections', new.public_id;
perform from
session
where
public_id = new.public_id and
public_id not in (
select session_id
from session_connection
where
public_id in (
select connection_id
from session_connection_state
where
state != 'closed' and
end_time is null
)
);
if not found then
raise 'session %s has open connections', new.public_id;
end if;
-- check to see if there's a terminated state already, before inserting a
-- new one.
perform from