Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d5560d8

Browse filesBrowse files
Merge branch 'nik-idle-detection-fix' into 'master'
fix: idle clone check when user <> 'postgres': always connect with 'dbname=postgres', do not ignore 'idle in transaction' sessions See merge request postgres-ai/database-lab!78
2 parents d188491 + c3cb2b6 commit d5560d8
Copy full SHA for d5560d8

File tree

1 file changed

+5
-3
lines changed
Filter options

1 file changed

+5
-3
lines changed

‎pkg/services/cloning/mode_base.go

Copy file name to clipboardExpand all lines: pkg/services/cloning/mode_base.go
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,17 @@ func hasNotQueryActivity(session *provision.Session) (bool, error) {
561561

562562
// TODO(akartasov): Move the function to the provision service.
563563
func getSocketConnStr(session *provision.Session) string {
564-
return fmt.Sprintf("host=%s user=%s", session.SocketHost, session.User)
564+
return fmt.Sprintf("host=%s user=%s dbname=postgres", session.SocketHost, session.User)
565565
}
566566

567567
// checkActiveQueryNotExists runs query to check a user activity.
568568
func checkActiveQueryNotExists(db *sql.DB) (bool, error) {
569569
var isRunningQueryNotExists bool
570570

571-
query := `SELECT NOT EXISTS(
572-
SELECT * FROM pg_stat_activity WHERE state NOT ILIKE 'idle%' AND query NOT LIKE 'autovacuum: %' AND pid <> pg_backend_pid())`
571+
query := `select not exists (
572+
select * from pg_stat_activity
573+
where state <> 'idle' and query not like 'autovacuum: %' and pid <> pg_backend_pid()
574+
)`
573575
err := db.QueryRow(query).Scan(&isRunningQueryNotExists)
574576

575577
return isRunningQueryNotExists, err

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.