Make WordPress Core

Opened 3 years ago

Last modified 4 months ago

#58559 new defect (bug)

Database error bug in wordpress current version

Reported by: zoddshop63 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Database Version:
Severity: normal Keywords:
Cc: Focuses:

Description (last modified by sabernhardt)

2023-06-16  8:52:53 47 [Warning] Aborted connection 47 to db: 'wordpressdb' user: 'wpuser' host: 'localhost' (Got an error reading communication packets)
2023-06-16  8:52:53 46 [Warning] Aborted connection 46 to db: 'wordpressdb' user: 'wpuser' host: 'localhost' (Got an error writing communication packets)

I am constantly seeing read and write errors in database due to wordpress in the current version. I have been running wordpress for years.

Upon checking the logs the read errors last query is

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID
                                        FROM wp_posts
                                        WHERE 1=1  AND (wp_posts.post_author = 2) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish')))

                                        ORDER BY wp_posts.post_date DESC
                                        LIMIT 0, 32

The write error last query is

SELECT DISTINCT post_author FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2

Both queries execute fine manually. The problem is not related to timeouts or max allowed packets as both execute manually.

I noticed they are both increasing the aborted clients value in mysql. There is also no quit sent at the end of the mysql connections.

It seems to be a bug within wordpress. I have literally gone through everything else possible to solve this bug.

Change History (3)

#1 @zoddshop63
3 years ago

And yes I have disabled all plugins and reinstalled wordpress.

#2 @sabernhardt
3 years ago

  • Component GeneralDatabase
  • Description modified (diff)

#3 @juzar
4 months ago

Hi @zoddshop63,

Could you share a bit more about your environment?

  • MySQL/MariaDB version?
  • Approximate number of posts in your wp_posts table?
  • PHP version and max_execution_time setting?

I tried reproducing this on the latest version of WordPress but was unable to.

Regarding SQL_CALC_FOUND_ROWS: this function can become very slow on large sites with many posts. It has to count all matching rows before applying the LIMIT, which on a big table can take long enough for PHP to time out mid-query. This is a known limitation and there are existing discussions in core around making it more efficient.

---
"For anyone landing here with the same issue: the "no quit sent" symptom typically points to PHP terminating the script before WordPress could close the MySQL connection — not a core bug. Also worth trying: swap DB_HOST in wp-config.php between localhost and 127.0.0.1 — if the errors stop, the issue is with your connection method."

Note: See TracTickets for help on using tickets.