Database Error: Database connection failed

Database Error: Database connection failed

eric yullu -
回帖数:5
Testers的头像
Am running Moodle 4.2+ and mariadb 10.6.15 but of late am frequently receiving error

Error: Database connection failed

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php

Database: Too many connections after a few hours of usage
i have increased the max_connection to 1000 but still getting the same error


回复eric yullu

Re: Database Error: Database connection failed

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
There are many possible reasons. You really need to monitor the database. "show processlist" is your friend here. You need to find out what the database is doing. For example, is the database "busy" with lots of connections processing queries. Alternatively, are you seeing lots of connections in "sleep" state? This implies that Moodle processes have hung up and you need to look somewhere other than your database for the problem.

Whether 1000 connection is a lot or not enough depends on the size and normal activity of your site. However, I run a site with about 30,000 active users and the connections rarely exceed a few hundred.
回复Howard Miller

Re: Database Error: Database connection failed

eric yullu -
Testers的头像
That wonderful response Howard Miller really helped, I had so many connections in sleep state thus consuming my memory. Addressed by reducing the session wait_timeout.
回复eric yullu

Re: Database Error: Database connection failed

Shadrack Kimutai -

Hello Eric,

We also are experiencing a similar issue. We had 2000+ trainees on the LMS doing some assessments, and the system went down with that error. Did you resolve it? What was the cause? If the learner was doing the assessment the first is thrown, if not yet in the assessment the later would be thrown.

附件 bf722ba1-304e-4ac7-83d3-d6a4de3d7c4b.jpeg
附件 de93c89a-6e7f-4183-b07d-6c61a33ab9bf.jpeg
回复Shadrack Kimutai

Re: Database Error: Database connection failed

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
"some assessments"

What, exactly? For example, 2000 people all doing a quiz at the same time is a massive ask.
回复Shadrack Kimutai

Re: Database Error: Database connection failed

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
There is a limit to the load any server can handle. As Howard already pointed out 2000 users taking an exam at the same time create a huge load.

To investigate whether that limit can be raised you need to provide the information as requested in Before you post.. read this... You can start the journey on your own as explained in the documents Performance and Performance FAQ.

P.S. It is unlikely that the cause of eric's problem is the same as yours. So yours should be a new discussion. In fact, there is a dedicated forum dedicated to this topic, the Hardware and performance forum. You don't have to repost. The moderator may move your sub-discussion to that forum.