-
-
Notifications
You must be signed in to change notification settings - Fork 366
SQL pool timeout #15
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
Comments
A few questions:
|
Both the mail server and the MySQL server are running in a docker-compose project. Here is a snippet of the config: [directory."sql"]
type = "sql"
address = "mysql://user:pass@mysql:3306/stalwart?ssl_mode=disabled"
[directory."sql".pool]
max-connections = 10
min-connections = 0
#idle-timeout = "10m"
[directory."sql".cache]
entries = 500
ttl = {positive = '1h', negative = '10m'}
[directory."sql".query]
name = "SELECT name, type, secret, description, quota FROM accounts WHERE name = ? AND active = true"
members = "SELECT member_of FROM group_members WHERE name = ?"
recipients = "SELECT name FROM emails WHERE address = ?"
emails = "SELECT address FROM emails WHERE name = ? AND type != 'list' ORDER BY type DESC, address ASC"
verify = "SELECT address FROM emails WHERE address LIKE CONCAT('%', ?, '%') AND type = 'primary' ORDER BY address LIMIT 5"
expand = "SELECT p.address FROM emails AS p JOIN emails AS l ON p.name = l.name WHERE p.type = 'primary' AND l.address = ? AND l.type = 'list' ORDER BY p.address LIMIT 50"
domains = "SELECT 1 FROM emails WHERE address LIKE CONCAT('%@', ?) LIMIT 1" When I start the server everything seems to work for a couple of minutes, I can login and receive emails so it is able to connect to the MySQL server. |
The Stalwart Docker image has the CA certificates missing (this will be fixed on the next release scheduled for next week), so just in case this is causing the problem please install the CA certs in the Stalwart container as follows: $ apt-get update
$ apt-get install ca-certificates If this keeps happening please switch the logging level to |
I installed the CA certificates and set the log level to debug and the issue is still there. There aren't any SQL/directory related log entries (except the pool timed out error). I tried testing it with Postgres which does seem to work. So the issue might be with the implementation of the connection pool for MySQL. |
I'll have a look at this. Both PostreSQL and mySQL use the same pool and library so this might be a problem on the mySQL implementation. Can you share the directory schema you are using? Or if it also fails with the sample directory schema included in the documentation then it is not necessary. |
I made some small changes to the schema/queries to make them compatible with MySQL/Postgres MySQL: CREATE TABLE accounts (name VARCHAR(32) PRIMARY KEY, secret VARCHAR(1024), description VARCHAR(1024), type VARCHAR(32) NOT NULL, quota INTEGER DEFAULT 0, active BOOLEAN DEFAULT 1);
CREATE TABLE group_members (name VARCHAR(32) NOT NULL, member_of VARCHAR(32) NOT NULL, PRIMARY KEY (name, member_of));
CREATE TABLE emails (name VARCHAR(32) NOT NULL, address VARCHAR(128) NOT NULL, type VARCHAR(32), PRIMARY KEY (name, address));
Postgres: CREATE TABLE accounts (name TEXT PRIMARY KEY, secret TEXT, description TEXT, type TEXT NOT NULL, quota INTEGER DEFAULT 0, active BOOLEAN DEFAULT true);
CREATE TABLE group_members (name TEXT NOT NULL, member_of TEXT NOT NULL, PRIMARY KEY (name, member_of));
CREATE TABLE emails (name TEXT NOT NULL, address TEXT NOT NULL, type TEXT, PRIMARY KEY (name, address));
|
Thanks, I'll run some tests this week and let you know. |
Update: This is indeed a bug in the |
There is indeed a bug in |
This issue has now been fixed in version |
I set up a MySQL server as a directory and when starting the mail server everything works for about 5 minutes, after that I get the following error message:
Here is my pool config:
When I set max-connections to something like 100 it takes about 30 minutes for the error to show up so I'm thinking it might have something to do with connections silently failing until all connections in the pool have failed.
The text was updated successfully, but these errors were encountered: