• Resolved Graham Stoney

    (@greyham)


    Firstly, thanks for MailPoet. I tried a lot of options for creating an automated post notification newsletter before settling on MailPoet. However, I have a problem which I suspect it may be causing:

    I have a number of low-traffic sites on shared servers with Bluehost and Hostgator, all of which have been plagued for a long time by intermittent database connection errors that appear to be triggered by WordPress exceeding the host’s maximum of 25 simultaneous MySQL connections.

    These sites work fine most of the time, so I know the problem isn’t the DB_… settings in wp-config.php. Normally I get the intermittent database connection error messages when navigating in the WordPress backend, doing typical operations such as creating new posts or approving and responding to comments. This is annoying, but occasionally I (and presumably my site visitors) also see them on the front end; which is really bad.

    All the sites have a similar collection of plugins, including caching plugins that should reduce database activity, and they don’t get enough traffic to ever have anything like 25 simultaneous visitors. My attempts to resolve the issue with each company’s online support so far have been unsuccessful, and switching hosting providers hasn’t solved it either.

    I also get intermittent messages in the WordPress backend saying that MailPoet has failed to connect to the database, pointing me to the MailPoet knowledgebase article Solving Database Connection Issues. Implementing the solutions in the article doesn’t solve the problem; MailPoet can connect to the database OK, just not all the time.

    However, the article makes me suspect that MailPoet may be the culprit behind the intermittent database connection errors I’m getting in WordPress generally. I’m not a PHP/mySQL guru but I don’t understand why MailPoet isn’t using the $wpdb class to access the database using the existing WordPress MySQL connection.

    On one site I usually only make monthly posts, so I tried disabling MailPoet between them, and got no errors all month while approving and responding to comments, which would normally trigger the intermittent error.

    I reenabled MailPoet prior to publishing this month’s post so that the plugin could send it out the Post Notification newsletter with this month’s post, and immediately got the intermittent database connection error messages again while creating the post.

    I also got this error message emailed to me immediately after posting the new article, also showing that MailPoet’s attempts to connect to the database are sometimes failing:
    WordPress version 5.7.2
    Current theme: Hestia (version 3.0.16)
    Current plugin: MailPoet 3 (New) (version 3.64.2)
    PHP version 7.4.20

    Error Details
    =============
    An error of type E_ERROR was caused in line 2 of the file /home4/…/cfs-survivors.org/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php. Error message: Uncaught PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /home4/…/cfs-survivors.org/wp-content/plugins/mailpoet/lib/Doctrine/Driver/PDOStatement.php:88
    Stack trace:
    #0 /home4/…/cfs-survivors.org/wp-content/plugins/mailpoet/lib/Doctrine/Driver/PDOStatement.php(88): PDOStatement->execute(NULL)
    #1 /home4/…/cfs-survivors.org/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(2): MailPoet\Doctrine\Driver\PDOStatement->execute()
    #2 /home4/…/cfs-survivors.org/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(2): MailPoetVendor\Doctrine\DBAL\Connection->executeQuery(‘SELECT w0_.hash…’, Array, Array, NULL)
    #3 /home4/…/cfs-survivors.org/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/orm/lib/Doctrine/ORM/Query.php(2): MailPoetVendor\Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(Object(MailPoet\Doctrine\SerializableConnection), Array, Array)
    #4

    Is it possible that MailPoet is opening multiple concurrent MySQL connections that are exceeding my host’s simultaneous MySQL connection limit? If so, how can I get it to use WordPress’s existing database connection instead?

    Thanks,
    Graham

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Bruna a11n

    (@bruberries)

    Hi Graham, thanks for sharing your issue with us.

    The SQLSTATE[HY000]: General error is a temporary error that happens when MailPoet could not establish a database connection at that time. It is automatically retried later and doesn’t affect how the plugin works.

    We have an article on how to fix this issue: How to Fix General Error: 2006 MySQL Server has Gone Away

    Have you gone through the suggestions mentioned in this article?

    Thread Starter Graham Stoney

    (@greyham)

    Thanks for your response Bruna.
    I contacted HostGator support and they added these settings to my php.ini, because I can’t edit my.cnf:
    wait_timeout=28800
    innodb_file_size=128M
    max_allowed_packet=128M
    I re-enabled the plugin, and will report back if I still get the intermittent database connection errors.
    I’m still curious why MailPoet is opening its own database connection rather than using $wpdb to access the database using the existing WordPress MySQL connection?

    Hi there @greyham,

    Thanks for getting back to us!

    I’m still curious why MailPoet is opening its own database connection rather than using $wpdb to access the database using the existing WordPress MySQL connection?

    This has been an architectural decision made a while ago and we’ll be looking into changing it, but we can’t give any estimated ETA since it’s a big change.

    I hope this clarifies a bit, but please let us know if you have any questions!

    Thread Starter Graham Stoney

    (@greyham)

    Thanks for answering my question Elvira. I’m imagining that this would cause each WordPress+MailPoet process to consume 2 database connections; but this is still far short of the 25 limit. Is it possible that either one could be kicking off multiple concurrent processes in the background of the WordPress dashboard that consume even more, perhaps as a wp_cron task or something?

    Thread Starter Graham Stoney

    (@greyham)

    Here’s the bad news: I’m still getting the error “MailPoet Error: Unable to connect to the database” in the WordPress backend even after applying the settings in the article How to Fix General Error: 2006 MySQL Server has Gone Away. Looks like something is still maxxing out the concurrent database connections, and I suspect that something is MailPoet.

    Thread Starter Graham Stoney

    (@greyham)

    Just got the General error: 2006 MySQL server has gone away again too. This looks like a pretty nasty reliability issue. Any idea when you’ll be tackling it?

    Hi there @greyham,

    I’m sorry to hear that you’re still getting the same error!

    I checked with our developers and it doesn’t seem like this is something we can fix on our end. We can’t know the reason why your SQL server drops the connection.

    In most cases we’ve seen, it was resolved by tweaking server configuration.

    More reference:

    https://www.percona.com/blog/2020/09/25/diagnosing-and-fixing-mysql-server-has-gone-away-messages/
    https://haydenjames.io/mysql-server-has-gone-away-error-solutions/

    The only option I can suggest is to reach out to your hosting company and ask them to look into the issue again and any logs available. It may shed some light on why the connections are dropped even after applying the fixes from our docs.

    Enjoy the rest of your day and stay safe!

    Thread Starter Graham Stoney

    (@greyham)

    Thanks for your suggestions Elvira. I contacted HostGator tech support and they suggested upgrading to a VPS plan which has no MySQL connection limit; but it’s more expensive and that would be unnecessary if MailPoet was only using a single MySQL connection at a time.

    They increased these settings, as suggested in:
    https://haydenjames.io/mysql-server-has-gone-away-error-solutions/
    default_socket_timeout=90
    max_execution_time = 90
    max_input_time = 90

    I’ll let you know if I still see the problem.

    Do the developers test MailPoet on shared hosting plans with HostGator and BlueHost? I can’t be the only person running the plugin on these popular hosts.

    I’ve switched one of my sites to MailChimp as a workaround to verify that MailPoet really is the cause of the intermittent database connection errors.

    Hi there @greyham,

    Do the developers test MailPoet on shared hosting plans with HostGator and BlueHost? I can’t be the only person running the plugin on these popular hosts.

    We definitely have other users on these platforms but we rarely see this issue happening so I’d assume it is related to your server environment and your site’s code (theme and plugins).

    I hope this clarifies a bit, but please let us know if you have any questions!

    Hi there @greyham,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    Thread Starter Graham Stoney

    (@greyham)

    Thanks for getting back to me Elvira. Since disabling MailPoet on my sites and migrating to MailChimp, I haven’t had any problems with intermittent database connection requests.

    I like MailPoet, but making multiple concurrent database connection requests is a significant architectural flaw which caused outages on my sites and it wasn’t easy to track the cause back to MailPoet. Your other users may not realise that MailPoet is the cause when they experience intermittent database connection errors. The hosting company is likely to simply recommend upgrading to a more expensive plan which probably resolves the issue, so users are unlikely to report it to you.

    My conclusion is that MailPoet in its current form simply isn’t compatible with low cost hosting plans like Hostgator’s Baby plan and BlueHost’s Basic plan.

    I’m on a Bluehost pro account and having the same problem. It wasn’t a frequent problem for me before August of this year so I suspect there may have been a change to Mailpoet. I manually send out a newsletter about once a week, but more recently set up a daily post email. I’m wondering if the automated email causes more database problems.

    I’ve used mailpoet and bluehost together for years and had occasional database timeouts/errors, but now the problem seems more frequent.

    Thread Starter Graham Stoney

    (@greyham)

    That’s interesting @tedandtom. I was using MailPoet almost exclusively for the automated post feature, so maybe that’s why I hit this all the time. I really hope they address it because MailChimp’s RSS-based equivalent isn’t anywhere near as customisable or appealing as MailPoet’s.

    @greyham I turned off the post notifications today and saw no improvement so I doubt that is it. I believe it was starting in late July when this became a real problem for me. I’ve used mailpoet and Bluehost together for many years – but now it’s giving me database errors all the time. I started using the post notifications also in late July, but I think now that was just a coincidence.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Is MailPoet making multiple concurrent MySQL connections?’ is closed to new replies.