Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd5560d8

Browse files
committed
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' sessionsSee merge request postgres-ai/database-lab!78
2 parentsd188491 +c3cb2b6 commitd5560d8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎pkg/services/cloning/mode_base.go‎

Lines 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
funcgetSocketConnStr(session*provision.Session)string {
564-
returnfmt.Sprintf("host=%s user=%s",session.SocketHost,session.User)
564+
returnfmt.Sprintf("host=%s user=%s dbname=postgres",session.SocketHost,session.User)
565565
}
566566

567567
// checkActiveQueryNotExists runs query to check a user activity.
568568
funccheckActiveQueryNotExists(db*sql.DB) (bool,error) {
569569
varisRunningQueryNotExistsbool
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
returnisRunningQueryNotExists,err

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp