Skip to content

Commit

Permalink
* Revert #1058 except the doc changes (#1184)
Browse files Browse the repository at this point in the history
* Short term 'fix' to avoid unnecessary messages due to some apparent false positives
* Long term fix on separate ticket
  • Loading branch information
sfc-gh-dszmolka authored Jul 25, 2024
1 parent cecf890 commit e066320
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 0 additions & 9 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"database/sql"
"database/sql/driver"
"os"
"runtime"
"strings"
"sync"
)
Expand Down Expand Up @@ -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{})
}
Expand Down
28 changes: 0 additions & 28 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"io"
"math/rand"
"os"
"os/exec"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -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
}

0 comments on commit e066320

Please sign in to comment.