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

Sessions terminated using kill command still leave behind entries in dm_exec_sessions #3390

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions contrib/babelfishpg_tds/src/backend/tds/tds.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,17 @@ tds_status_shmem_startup(void)
static void
tds_stats_shmem_shutdown(int code, Datum arg)
{
/* Don't try to save the outlines during a crash. */
if (code)
return;
volatile TdsStatus *myTdsStatusEntry = MyTdsStatusEntry;

/* Safety check ... shouldn't get here unless shmem is set up. */
if (TdsStatusArray == NULL || MyTdsStatusEntry == NULL)
return;

PGSTAT_BEGIN_WRITE_ACTIVITY(MyTdsStatusEntry);
PGSTAT_BEGIN_WRITE_ACTIVITY(myTdsStatusEntry);

MyTdsStatusEntry->st_procpid = 0; /* mark invalid */
myTdsStatusEntry->st_procpid = 0; /* mark invalid */

PGSTAT_END_WRITE_ACTIVITY(MyTdsStatusEntry);
PGSTAT_END_WRITE_ACTIVITY(myTdsStatusEntry);

MyTdsStatusEntry = NULL;

Expand Down
13 changes: 13 additions & 0 deletions test/JDBC/expected/kill-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ create table tab_kill_spid(spid int)
go
create login victim_user_tds with password = '12345678';
go
select count(*) as count into #kill_temp_table from sys.dm_exec_sessions
go

-- tsql user=victim_user_tds password=12345678
select 1
Expand Down Expand Up @@ -763,3 +765,14 @@ int
0
~~END~~


IF ((SELECT COUNT(*) FROM sys.dm_exec_sessions) = (SELECT count FROM #kill_temp_table))
SELECT 'SUCESS';
ELSE
SELECT 'FAILURE expected count ==> ', (SELECT count FROM #kill_temp_table), ' actual count ==> ', count(*) from sys.dm_exec_sessions b;
GO
~~START~~
varchar
SUCESS
~~END~~

13 changes: 13 additions & 0 deletions test/JDBC/expected/single_db/kill-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ create table tab_kill_spid(spid int)
go
create login victim_user_tds with password = '12345678';
go
select count(*) as count into #kill_temp_table from sys.dm_exec_sessions
go

-- tsql user=victim_user_tds password=12345678
select 1
Expand Down Expand Up @@ -863,3 +865,14 @@ int
0
~~END~~


IF ((SELECT COUNT(*) FROM sys.dm_exec_sessions) = (SELECT count FROM #kill_temp_table))
SELECT 'SUCESS';
ELSE
SELECT 'FAILURE expected count ==> ', (SELECT count FROM #kill_temp_table), ' actual count ==> ', count(*) from sys.dm_exec_sessions b;
GO
~~START~~
varchar
SUCESS
~~END~~

10 changes: 9 additions & 1 deletion test/JDBC/input/kill-vu-verify.mix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ create table tab_kill_spid(spid int)
go
create login victim_user_tds with password = '12345678';
go
select count(*) as count into #kill_temp_table from sys.dm_exec_sessions
go

-- tsql user=victim_user_tds password=12345678
select 1
Expand Down Expand Up @@ -403,4 +405,10 @@ SELECT count(*) from sys.dm_exec_sessions where login_name = 'test_kill'
GO

SELECT COUNT(*) from pg_stat_activity where usename = 'test_kill'
GO
GO

IF ((SELECT COUNT(*) FROM sys.dm_exec_sessions) = (SELECT count FROM #kill_temp_table))
SELECT 'SUCESS';
ELSE
SELECT 'FAILURE expected count ==> ', (SELECT count FROM #kill_temp_table), ' actual count ==> ', count(*) from sys.dm_exec_sessions b;
GO