ioBroker / ioBroker.sql

Store history data in SQL Database: MySQL, PostgreSQL or SQLite
MIT License
44 stars 26 forks source link

Error: connect ETIMEDOUT sowie Too many connections #248

Closed ChrMaass closed 2 years ago

ChrMaass commented 2 years ago

** English version below

Hallo zusammen,

Seit dem Update auf 2.0.2 von Version 1.X.X habe ich ständig Probleme mit der Verbindung zu meiner MariaDB Datenbank (Version 10). Im Protokoll steht erst mehrfach "Error: Too many connections", und dann hundertfach "Error: connect ETIMEDOUT".

Bei den Einstellungen des Adapters habe ich schon verschiedene Einstellung bzgl. maximal gleichzeitiger Verbindungen versucht, aktuell steht diese bei 50. Wenn ich "Gleichzeitige Verbindung zulassen" deaktiviere, kommt der Adapter mit den Loggen nicht hinterher und hat zu viel in seiner Queue. Die Datenbank habe ich auch schon gewechselt, die aktuelle befindet sich auf dem gleichen System. Ebenfalls habe ich dort die Anzahl der Verbindungen erfolgreich auf 500 konfiguriert. Sobald der Fehler auftritt steht die MySQL Variable "Max Used Connections" auch auf 501. Der Datenbankserver bedienst ausschließen Biobroker und hat keine zusätzlichen Datenbanken laufen.

iobroker läuft in Version 4.0.23 SQL in Version 2.0.2 Javascript in Version 5.7.0

Anbei eine Logdatei.

SQL Error.log

Gerne helfe ich mit weiteren Informationen um das Problem zu finden. Neuinstalliert habe ich die SQL Instanz bisher noch nicht.

+++++++++++

Hi together,

Since the update to 2.0.2 from version 1.X.X I have constant problems with the connection to my MariaDB database (version 10). In the log it shows multiple times "Error: Too many connections", and after that hundreds of times "Error: connect ETIMEDOUT".

In the settings of the adapter I have already tried different settings regarding the maximum number of simultaneous connections, currently it is set to 50. If I deactivate "Allow simultaneous connection", the adapter does not keep up with the logging and has too much in its queue. I have also changed the database, the current one is on the same system. I have also successfully configured the number of connections to 500. As soon as the error occurs, the MySQL variable "Max Used Connections" is also set to 501. The database server is running Biobroker and has no additional databases.

iobroker runs in version 4.0.23 SQL in version 2.0.2 Javascript in version 5.7.0

Attached is a log file.

SQL Error.log

I'm happy to help with more information to find the problem. I have not reinstalled the SQL instance yet.

Apollon77 commented 2 years ago

In fact we can only debug that on your system because I tried several times and were never able to do so :-( additionally the "limiter" is in a different library ... so it would be manual changing some files and let in run e.g. in a screento see additional console logs and hopefully spot something.

Possible for you to support here?

ChrMaass commented 2 years ago

Yeah sure, no problem. How can we proceed here? Shall we arrange for a TeamViewer session?

Currently the "Max_used_connections" variable has gone up to 156 since my last message, so I seem to have some air until the next error :-)

Apollon77 commented 2 years ago

oooh ... I digged through code and foudn at least one place where connection was not given back on error ... do you do user queries?

Apollon77 commented 2 years ago

Let me fix that first and I add a debug log for connection counte ... maybe we see more then

ChrMaass commented 2 years ago

No, I do not currently use user queries. But what could be interesting is that I have a flot running in the background.

Okay, I'll gladly wait for your update. Thanks for your effort.

Apollon77 commented 2 years ago

Ok, install GitHub please ... it should spam some more debug logs whern you enable it ... and I found some more places where - mainly in error cases on query - a connection was maybe not returned corrrectly,. lets see what the log brings. ideally it "floats around a certain low number +/-" ... when this gets higher we can analyze log

Apollon77 commented 2 years ago

The basic "good" news is that at least the running test suite end with a "0 connections", so there is no leak in general ... now we need to find whats up

ChrMaass commented 2 years ago

I have now selected "Install from own source" via admin and then selected Github there. How can I see that it is really the current version? It says again 2.0.2

Apollon77 commented 2 years ago

version number did not change ... enablce debug log and manually restart adapter and you should see "Borrowed from pool" and "return to pool" logs with how many connections are active (borrowed but not returned)

ChrMaass commented 2 years ago

There are many messages, but I can't find it.

If you just had a minute, you can ask to look on my screen with teamviewer.

Apollon77 commented 2 years ago

I sent you my phone number ... should be faster I think :-)

ChrMaass commented 2 years ago

We have now looked at and adjusted some things together and are watching the system a bit now....

Apollon77 commented 2 years ago

bsically caused by https://github.com/intellinote/sql-client/issues/7

ChrMaass commented 2 years ago

Thanks @Apollon77 for the hotfix/workaround (installable per Github install/update)

Apollon77 commented 2 years ago

2.1.0