Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1552759 Remove attempt to detect DBUS_SESSION_BUS_ADDRESS and emitting warning message (revert #1058 except the doc changes) #1184

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading