From 441feb54646dc7cd6f80e6dd6163d74dc159db4c Mon Sep 17 00:00:00 2001 From: sfc-gh-dszmolka Date: Wed, 24 Jul 2024 13:56:47 +0200 Subject: [PATCH] * Revert #1058 except the doc changes * Short term 'fix' to avoid unnecessary messages due to some apparent false positives * Long term fix on separate ticket --- README.md | 2 -- driver.go | 9 --------- util.go | 28 ---------------------------- 3 files changed, 39 deletions(-) diff --git a/README.md b/README.md index dffb4fc51..a252e255d 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,4 @@ Until we replace the offending dependency with one which doesn't have the bug, a * cleaning up the runaway processes periodically * setting envvar `DBUS_SESSION_BUS_ADDRESS=$XDG_RUNTIME_DIR/bus` (if that socket exists, or create it) or even `DBUS_SESSION_BUS_ADDRESS=/dev/null` -The driver will try to detect automatically, whether your runtime is susceptible for this bug or not, and if so, log a message on `Warning` loglevel. - Details in [issue 773](https://github.com/snowflakedb/gosnowflake/issues/773) diff --git a/driver.go b/driver.go index bd99d110e..9679118bb 100644 --- a/driver.go +++ b/driver.go @@ -7,7 +7,6 @@ import ( "database/sql" "database/sql/driver" "os" - "runtime" "strings" "sync" ) @@ -75,14 +74,6 @@ func skipRegisteration() bool { var logger = CreateDefaultLogger() func init() { - if runtime.GOOS == "linux" { - // TODO: delete this once we replaced 99designs/keyring (SNOW-1017659) and/or keyring#103 is resolved - leak, logMsg := canDbusLeakProcesses() - if leak { - // 99designs/keyring#103 -> gosnowflake#773 - logger.Warn(logMsg) - } - } if !skipRegisteration() { sql.Register("snowflake", &SnowflakeDriver{}) } diff --git a/util.go b/util.go index 1274723c1..9352dc7e1 100644 --- a/util.go +++ b/util.go @@ -9,7 +9,6 @@ import ( "io" "math/rand" "os" - "os/exec" "strings" "sync" "time" @@ -319,30 +318,3 @@ func contains[T comparable](s []T, e T) bool { func chooseRandomFromRange(min float64, max float64) float64 { return rand.Float64()*(max-min) + min } - -func isDbusDaemonRunning() bool { - // TODO: delete this once we replaced 99designs/keyring (SNOW-1017659) and/or keyring#103 is resolved - cmd := exec.Command("pidof", "dbus-daemon") - _, err := cmd.Output() - - // false: process not running, pidof not available (sysvinit-tools, busybox, etc missing) - return err == nil -} - -func canDbusLeakProcesses() (bool, string) { - // TODO: delete this once we replaced 99designs/keyring (SNOW-1017659) and/or keyring#103 is resolved - leak := false - message := "" - - valDbus, haveDbus := os.LookupEnv("DBUS_SESSION_BUS_ADDRESS") - if !haveDbus || strings.Contains(valDbus, "unix:abstract") { - // if DBUS_SESSION_BUS_ADDRESS is not set or set to an abstract socket, it's not necessarily a problem, only if dbus-daemon is running - if isDbusDaemonRunning() { - // we're probably susceptible to https://github.com/99designs/keyring/issues/103 here - leak = true - message += "DBUS_SESSION_BUS_ADDRESS envvar looks to be not set, this can lead to runaway dbus-daemon processes. " + - "To avoid this, set envvar DBUS_SESSION_BUS_ADDRESS=$XDG_RUNTIME_DIR/bus (if it exists) or DBUS_SESSION_BUS_ADDRESS=/dev/null." - } - } - return leak, message -}