handle unlimited connections when terminating sessions. (#536)

helpful-text
Jim 5 years ago committed by GitHub
parent 9f11d12f6d
commit dc379ed09f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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) {

Loading…
Cancel
Save