Skip to content

Commit

Permalink
Update cancel blocked query for gpdb7
Browse files Browse the repository at this point in the history
Gpdb7 bring in changes to pg_stat_activity. Update that cancel blocked
query function to work with gpdb7.

Authored-by: Kevin Yeap <kyeap@vmware.com>
  • Loading branch information
kyeap-vmware authored and AJR-VMware committed Nov 22, 2022
1 parent a0c731f commit 83c70d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,10 @@ func cancelBlockedQueries(timestamp string) {
// Query for all blocked queries
pids := make([]int64, 0)
findBlockedQuery := fmt.Sprintf("SELECT procpid from pg_stat_activity WHERE application_name='gpbackup_%s' AND waiting='t' AND waiting_reason='lock';", timestamp)
if conn.Version.AtLeast("6") {
if conn.Version.Is("6") {
findBlockedQuery = fmt.Sprintf("SELECT pid from pg_stat_activity WHERE application_name='gpbackup_%s' AND waiting='t' AND waiting_reason='lock';", timestamp)
} else if conn.Version.AtLeast("7") {
findBlockedQuery = fmt.Sprintf("SELECT pid from pg_stat_activity WHERE application_name='gpbackup_%s' AND wait_event_type='Lock';", timestamp)
}
err := conn.Select(&pids, findBlockedQuery)
gplog.FatalOnError(err)
Expand Down

0 comments on commit 83c70d9

Please sign in to comment.