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

Fix sys.dm_exec_sessions having rows for backends which are already terminated #3329

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
12 changes: 10 additions & 2 deletions contrib/babelfishpg_tds/src/backend/tds/tds.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ typedef struct LocalTdsStatus
} LocalTdsStatus;

static TdsStatus *TdsStatusArray = NULL;
static TdsStatus *MyTdsStatusEntry;
static TdsStatus *MyTdsStatusEntry = NULL;
static LocalTdsStatus *localTdsStatusTable = NULL;

uint32_t MyTdsClientVersion = 0;
Expand Down Expand Up @@ -446,9 +446,17 @@ tds_stats_shmem_shutdown(int code, Datum arg)
return;

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

PGSTAT_BEGIN_WRITE_ACTIVITY(MyTdsStatusEntry);

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

PGSTAT_END_WRITE_ACTIVITY(MyTdsStatusEntry);

MyTdsStatusEntry = NULL;

return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/upgrade/13_6/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ sys-datefirst
sys-dm_exec_connections
sys-dm_exec_connections-dep
sys-dm_exec_sessions
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-dm_hadr_cluster
sys-dm_hadr_database_replica_states
sys-dm_os_host_info
Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/upgrade/13_9/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ sys-datefirst
sys-dm_exec_connections
sys-dm_exec_connections-dep
sys-dm_exec_sessions
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-dm_hadr_cluster
sys-dm_hadr_database_replica_states
sys-dm_os_host_info
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/upgrade/14_12/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ column_domain_usage
constraint_column_usage
select-strip-parens-before-15_5
sp_describe_first_result_set
#sys-host_name-before-15_8-or-16_4 TODO:BABEL-5414
sys-host_name-before-15_8-or-16_4
SYSTEM_USER
indexproperty
sys-all_parameters
Expand Down Expand Up @@ -240,7 +240,7 @@ sys-index_columns-dep
sys-sp_databases-dep
sys-syscolumns-dep
sys-dm_exec_connections-dep
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-table_types-before-dep
sys-all_sql_modules-dep_before_16_5
sys-sql_modules-dep_before_16_5
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/upgrade/14_15/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ column_domain_usage
constraint_column_usage
select-strip-parens-before-15_5
sp_describe_first_result_set
#sys-host_name-before-15_8-or-16_4 TODO:BABEL-5414
sys-host_name-before-15_8-or-16_4
SYSTEM_USER
indexproperty
sys-all_parameters
Expand Down Expand Up @@ -240,7 +240,7 @@ sys-index_columns-dep
sys-sp_databases-dep
sys-syscolumns-dep
sys-dm_exec_connections-dep
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-table_types-before-dep
sys-all_sql_modules-dep_before_16_5
sys-sql_modules-dep_before_16_5
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/upgrade/14_16/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ column_domain_usage
constraint_column_usage
select-strip-parens-before-15_5
sp_describe_first_result_set
#sys-host_name-before-15_8-or-16_4 TODO:BABEL-5414
sys-host_name-before-15_8-or-16_4
SYSTEM_USER
indexproperty
sys-all_parameters
Expand Down Expand Up @@ -241,7 +241,7 @@ sys-index_columns-dep
sys-sp_databases-dep
sys-syscolumns-dep
sys-dm_exec_connections-dep
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-table_types-before-dep
sys-all_sql_modules-dep_before_16_5
sys-sql_modules-dep_before_16_5
Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/upgrade/14_3/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ sys-datefirst
sys-dm_exec_connections
sys-dm_exec_connections-dep
sys-dm_exec_sessions
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-dm_hadr_cluster
sys-dm_hadr_database_replica_states
sys-dm_os_host_info
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/upgrade/14_5/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ sys-datefirst
sys-dm_exec_connections
sys-dm_exec_connections-dep
sys-dm_exec_sessions
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-dm_hadr_cluster
sys-dm_hadr_database_replica_states
sys-dm_os_host_info
Expand All @@ -236,7 +236,7 @@ sys-fulltext_stoplists
sys-hash_indexes
sys-has_perms_by_name
sys-has_perms_by_name-dep
#sys-host_name-before-15_8-or-16_4 TODO:BABEL-5414
sys-host_name-before-15_8-or-16_4
sys-identity_columns
sys-identity_columns-dep
sys-index_columns
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/upgrade/14_6/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ sys-default_constraints-dep
sys-dm_exec_connections
sys-dm_exec_connections-dep
sys-dm_exec_sessions
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-dm_hadr_cluster
sys-dm_hadr_database_replica_states
sys-dm_os_host_info
Expand All @@ -269,7 +269,7 @@ sys-fulltext_stoplists
sys-hash_indexes
sys-has_perms_by_name
sys-has_perms_by_name-dep
#sys-host_name-before-15_8-or-16_4 TODO:BABEL-5414
sys-host_name-before-15_8-or-16_4
sys-identity_columns
sys-identity_columns-dep
sys-index_columns
Expand Down
4 changes: 2 additions & 2 deletions test/JDBC/upgrade/15_2/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ sys-default_constraints-dep
sys-dm_exec_connections
sys-dm_exec_connections-dep
sys-dm_exec_sessions
#sys-dm_exec_sessions-dep TODO:BABEL-5414
sys-dm_exec_sessions-dep
sys-dm_hadr_cluster
sys-dm_hadr_database_replica_states
sys-dm_os_host_info
Expand All @@ -292,7 +292,7 @@ sys-fulltext_stoplists
sys-hash_indexes
sys-has_perms_by_name
sys-has_perms_by_name-dep
#sys-host_name-before-15_8-or-16_4 TODO:BABEL-5414
sys-host_name-before-15_8-or-16_4
sys-identity_columns
sys-identity_columns-dep
sys-index_columns
Expand Down