handle unlimited connections when terminating sessions. (#536)

This commit is contained in:
Jim authored and GitHub committed 2020-10-05 17:01:22 -04:00
1 parent 9f11d12f6d
commit dc379ed09f
4 files changed
+43 -11

No files matched your search

+9 -5
View File
@@ -4172,11 +4172,15 @@ create or replace function
now() > us.expiration_time or
-- connection limit reached...
(
select count (*)
from session_connection sc
where
sc.session_id = us.public_id
) >= connection_limit or
-- handle unlimited connections...
connection_limit != -1 and
(
select count (*)
from session_connection sc
where
sc.session_id = us.public_id
) >= connection_limit
) or
-- canceled sessions
us.public_id in (
select
@@ -336,11 +336,15 @@ create or replace function
now() > us.expiration_time or
-- connection limit reached...
(
select count (*)
from session_connection sc
where
sc.session_id = us.public_id
) >= connection_limit or
-- handle unlimited connections...
connection_limit != -1 and
(
select count (*)
from session_connection sc
where
sc.session_id = us.public_id
) >= connection_limit
) or
-- canceled sessions
us.public_id in (
select
+5 -1
View File
@@ -182,11 +182,15 @@ where
now() > us.expiration_time or
-- connection limit reached...
(
-- handle unlimited connections...
connection_limit != -1 and
(
select count (*)
from session_connection sc
where
sc.session_id = us.public_id
) >= connection_limit or
) >= connection_limit
) or
-- canceled sessions
us.public_id in (
select
@@ -879,6 +879,26 @@ func TestRepository_TerminateCompletedSessions(t *testing.T) {
}
},
},
{
name: "sessions-with-unlimited-connections",
setup: func() testArgs {
cnt := 5
wantTermed := map[string]TerminationReason{}
sessions := make([]*Session, 0, 5)
for i := 0; i < cnt; i++ {
// make one with unlimited connections
s := setupFn(-1, time.Hour+1, false)
// make one with limit of one all connections closed
s2 := setupFn(1, time.Hour+1, false)
sessions = append(sessions, s, s2)
wantTermed[s2.PublicId] = ConnectionLimit
}
return testArgs{
sessions: sessions,
wantTermed: wantTermed,
}
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {