Make WordPress Core

Opened 4 years ago

Last modified 15 months ago

#49545 new defect (bug)

update_meta_cache issue while getting record from user meta table in multi site

Reported by: classicalrehan's profile classicalrehan Owned by:
Milestone: Awaiting Review Priority: normal
Severity: blocker Version: 5.3.2
Component: Users Keywords: dev-feedback
Focuses: multisite, performance, coding-standards Cc:

Description

Hi All,

I am facing a strange wp problem. I have a multisite setup and around 10K sites are running over it. Lots of sites are created with superuser i.e. user_id=1

every time when site hit in the browser then following query executed:

Filename: wp-includes/meta.php
Method: update_meta_cache
Line No: #825
My Application Traffic: 50million/day

SELECT user_id, meta_key, meta_value FROM wp_usermeta WHERE user_id IN (1) ORDER BY umeta_id ASC;

Problem:

if suppose 5k sites created with user_id=1 and then whenever traffic come over my application then it will fetch all rows against this user_id =1 from user meta table and as now around 20k ROWS_EXAMINED and ROWS_SENT in every query but I, in reality, it will require only 4-5 rows based on current blog id (site id).

There should be a check for blog id (site id) inside this function because other returning row is useless and due to this my query going slow.

I have tried the following things:

  1. Change usermeta table engine. MyISAM to InnoDB but its not work There is no possibility of row-level locking, relational integrity in MyISAM but with InnoDB this is possible. MyISAM has table-level locking [Not worked]
  1. Try table engine MyISAM to Memory but it's also not working because usermeta contain meta_value and whose data type blob but unfortunate Memory engine will not work with blob so can't able to change the engine to Memory [Not worked]
  1. Can I comment this function call or add return null [Not try as of now because this is wp core file and whenever I will update wp version it will show conflict and also not a good approach to change wp core file]
  1. Can I some other cache inside here? [not tested because again it's wp core file]
  1. Can I add current blog ID check inside this function and retrieve only those records whose belong to this site only [but again this check need to put inside wp core file ie. wp-includes/meta.php]
  1. is there any hooks or something which I can use over here?

Attachments (1)

Naukri Mysql slow log dashboard - Kibana.png (58.8 KB) - added by classicalrehan 4 years ago.

Download all attachments as: .zip

Change History (8)

#1 follow-up: @afercia
4 years ago

  • Focuses accessibility removed
  • Severity changed from blocker to normal

@classicalrehan thanks for your report. I'm going to remove the accessibility focus as this issue doesn't seem related to web content accessibility (WCAG and the like). Seems something more appropriate for the Multisite team.

#2 in reply to: ↑ 1 @classicalrehan
4 years ago

Replying to afercia:

@classicalrehan thanks for your report. I'm going to remove the accessibility focus as this issue doesn't seem related to web content accessibility (WCAG and the like). Seems something more appropriate for the Multisite team.

@afercia can you please help me to solve this issue as tried everything but nothing going work until unless I change the core file which I want to avoid.

Is there any way where I can override "update_meta_cache"?

As I check in function.php with different hook i.e. init, wp_head, etc cache available but update_meta_cache always update the result set.

Last edited 4 years ago by classicalrehan (previous) (diff)

#3 @classicalrehan
4 years ago

  • Keywords update_cache_meta added
  • Severity changed from normal to blocker

#4 @classicalrehan
4 years ago

can someone help me to resolve this issue?

#5 follow-up: @SergeyBiryukov
4 years ago

  • Keywords dev-feedback added; update_cache_meta removed

Hi there, welcome to WordPress Trac! Thanks for the report.

Just removing the update_cache_meta keyword as it's not one of the workflow keywords, adding dev-feedback instead to follow up later.

#6 in reply to: ↑ 5 @classicalrehan
4 years ago

@SergeyBiryukov is there any solutions you would suggest?

Replying to SergeyBiryukov:

Hi there, welcome to WordPress Trac! Thanks for the report.

Just removing the update_cache_meta keyword as it's not one of the workflow keywords, adding dev-feedback instead to follow up later.

Note: See TracTickets for help on using tickets.