edgedb
edgedb copied to clipboard
Unable to establish Grafana connection to EdgeDB
I should note as a disclaimer - I'm not 100% sure if this should be filed against EdgeDB or Grafana. I'm not sure where the issue is occurring, so I'm hoping someone might be able to offer further insight into the problem, and determine whether it's an EdgeDB issue or a problem on Grafana's end.
Description:
Per the documentation for 3.0 SQL support, I should be able to connect to any Postgres-compatible client. I'm running the latest Grafana build, and attempting to set up a PostgreSQL Data Source for my EdgeDB database.
I can verify that Grafana appears to be connecting to and detecting the database, because if I change the connection host/port, the attempted connection times out with a totally different error. Similarly, if I enter a random DB name that doesn't exist, I get a separate error from Grafana indicating that the specified database does not exist. So it's clearly connecting to, and recognizing my database to some extent, however, when I click "Save & Test" it simply says driver: bad connection
.
I'm connecting using TLS as instructed in the EdgeDB SQL documentation.
Checking the Grafana logs, I can see that the error occurs when I click "Save & Test" and it appears to perform a health check on the connection, which fails with the above error.
Again, I'm not sure if this is a problem on the EdgeDB side of things, or on Grafana's end. I notice that the documentation doesn't list Grafana under the "Tested SQL tools" at the bottom of the page, however, given that it supports Postgres, I would expect it to work no different than the other listed tools. The presence of a "driver" error makes me lean towards something on the Postgres side of things, putting it in EdgeDB territory which is why I'm filing it here for now. If someone else can confirm/refute this, I can either troubleshoot further, or file a similar issue in the Grafana project
Version Info:
- EdgeDB Version: 3.5+719acc6
- EdgeDB CLI Version: 4.0.1+5940674
- OS Version: Windows 11 (x64)
Steps to Reproduce:
- Download and install Grafana
- Create an EdgeDB database
- Add a new Grafana connection for PosgreSQL
- Connect using the appropriate edgedb
host:port
,database
, anduser credentials
,TLS = verify-full
andTLS Method = File system path
. All other connection settings are the defaults - Click "Save & Test" at the bottom. Observe the
driver: bad connection
error
@vpetrovykh Could you triage this, and send it over to @aljazerzen or @fantix depending on what seems wrong?
I've reproduced the bug with EdgeDB and Grafana, gettting the following error (as described by @Novark)
I've also verified that underlying lib/pq Postgres driver library works and connects correctly. See my example here: https://github.com/aljazerzen/edgedb-sql-go-example
This leads me to suspect that this is a Grafana bug. Even if this is not true, we need help from Grafana people to get more logs/hints what might be the problem here.
My setup:
Grafana in Docker, ran with following docker-compose:
version: "3.8"
services:
grafana:
image: grafana/grafana-enterprise
container_name: grafana
network_mode: "host"
EdgeDB local development build at b0d1618db
Applied schema:
module default {
type Person {
required first_name: str;
last_name: str;
}
type Genre {
required name: str;
}
type Content {
required title: str;
genre: Genre;
index fts::index on (
fts::with_options(.title, language := fts::Language.eng)
);
}
type Movie extending Content {
release_year: int64;
multi actors: Person {
role: str;
};
director: Person {
bar: str;
};
}
type Book extending Content {
required pages: int16;
multi chapters: str;
}
type novel extending Book {
foo: str;
index fts::index on ((
fts::with_options(.title, language := fts::Language.eng),
fts::with_options(.foo, language := fts::Language.eng),
));
}
module nested {
type Hello {
property hello -> str;
};
module deep {
type Rolling {
property rolling -> str;
};
};
};
abstract type X {
name: str;
}
type Y extending X {
age: int16;
}
};
insert Genre { name:= 'Fiction' };
insert Genre { name:= 'Drama' };
insert Genre { name:= '武侠' };
insert Person { first_name:= 'Tom', last_name:= 'Hanks' };
insert Person { first_name:= 'Robin' };
insert Person { first_name:= 'Steven', last_name:= 'Spielberg' };
insert Movie {
title := 'Forrest Gump',
release_year := 1994,
actors := (select Person
filter .first_name = 'Tom' or .first_name = 'Robin'
),
genre := (select Genre filter .name = 'Drama' limit 1),
};
insert Movie {
title := 'Saving Private Ryan',
release_year := 1998,
actors := (
select Person { @role := 'Captain Miller' } filter .first_name = 'Tom'
),
director := (
select Person filter .last_name = 'Spielberg' limit 1
),
genre := (select Genre filter .name = 'Drama' limit 1),
};
insert novel {
title:='Hunger Games',
foo := 'a dystopian novel',
pages := 374,
genre:= (select Genre filter .name = 'Fiction' limit 1)
};
insert Book {
title:='Chronicles of Narnia',
pages := 206,
genre:= (select Genre filter .name = 'Fiction' limit 1)
};
insert Content {
title := 'Halo 3',
genre := (select Genre filter .name = 'Fiction' limit 1)
};
This is minimal reproducible example:
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/lib/pq"
)
func main() {
str := "user=edgedb dbname=edgedb password=edgedb host=localhost port=5656 sslmode=require"
db, err := sql.Open("postgres", str)
if err != nil {
log.Fatal(err)
}
defer db.Close()
err = db.Ping()
if err != nil {
log.Fatal(err)
}
fmt.Println("ping was ok")
}
Error happens in this function: https://github.com/lib/pq/blob/master/conn_go18.go#L90-L100
Which calls cn.simpleQuery(";")
, which returns "pq: unknown response for simple query: 'n'"
.
It looks like 'n'
is PostgreSQL "no data" message.
@fantix Is this 'n'
a valid response to a simple query?
This issue has already been reported in #6682. Fantix has a partial fix, but needs to finish it up.
This issue should remain open, so I test Grafana when the upstream issue with pq if fixed.
I've verified that grafana now works:
The fix for this will be released with 5.x (this week).
I've verified that grafana now works:
[image]
The fix for this will be released with 5.x (this week).
Thanks for everyone's efforts getting this one fixed for the upcoming release - it's much appreciated! Looking forward to trying out 5.0!