wordpress-sdk icon indicating copy to clipboard operation
wordpress-sdk copied to clipboard

Thousands of queries upon plugin activation in multisite

Open codex-m opened this issue 9 months ago • 4 comments

🐞 bug report

Behavior:

  • What is the issue? (*)
Upon plugin activation in multisite - user reports thousands of queries per minute originating from Freemius SDK library. These are the queries:

UPDATE wp_sitemeta SET meta_value = ... WHERE site_id = 1 AND meta_key = 'fs_accounts' According to the client, the same query is being repeated, causing performance degradation of the database server.

This issue was reported via a WordPress.org ticket.

  • What is the expected behavior?
No excessive database queries upon plugin activation that cause performance issues in multisite.

Versions: (*)

  • Freemius SDK Version: 2.11.0
  • WordPress Version: supported
  • PHP Version: supported

Plugin / Theme: (*)

  • Name: Prime Mover
  • Slug: prime-mover
  • Freemius ID: 3826 (Prime Mover)

Additional Information:

  • Browser Type: (*) Any browser
  • Browser Version: (*) n/a
  • OS: (*) Linux
  • Stack Traces:

Note: (*) indicates required information. Without this information, your issue may be auto-closed.

You can find your Freemius SDK version at /freemius/start.php

You can find your Freemius product ID in the Freemius dashboard: SETTINGS -> INTEGRATION.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

codex-m avatar Mar 20 '25 09:03 codex-m

Hello,

Thank you for reporting this. We haven't received any similar complain, but we do want to understand why this is happening. Are you able to give us any reproduction steps? If the issue is happening with the premium version of your product, please get in touch with our support so that we can help out.

swashata avatar May 01 '25 08:05 swashata

Thanks, this is a rare case as well. We tried this on our setup but were unable to reproduce it. But before we close this, let's wait a couple of releases to check if the client will report this issue again, and then we will ask for steps to reproduce or, much better, access to his test site. Cheers.

codex-m avatar May 05 '25 02:05 codex-m

The original problem documented in the WordPress.org ticket was solved by manually removing the Prime Mover plugin including its DB entries and remaining folders and then reinstalling version 2.0.4.

As a result, the number of these update queries

UPDATE  wp_sitemeta SET  meta_value = ... WHERE  site_id = 1 AND  meta_key = 'fs_accounts'

went from thousands a minute, to hundreds a minute. This was good enough for Prime Mover not to slow down our whole WordPress service while being active.

There is something interesting I notices after the update. The number of the mentioned update queries was lower when Prime Mover was active (8/minute) then when it was inactive (449/minute).

The picture bellow shows two time intervals when Prime Mover was active and the network traffic actually decreased by a lot.

Image

After some investigating I found a second plugin that uses the Freemius library, TablePress. I'm suspecting Prime Mover was silencing the queries TablePress would otherwise send.

After updating TablePress to v3.1.2 this problem was also solved. Now we no longer have problems with fs_account update quires flooding the db.

Here is how that affected our network traffic. Most of the traffic shown bellow is traffic between the WordPress nodes and the MySQL DB server. It turned out that the vast majority of that was because of Freemius sending the exact same UPDATE query again and again.

Image

It decreased by a factor of ten. Our p90 response times decreased by 100ms. We have a large WordPress Multisite installation with many subsites and a huge amount of traffic which is maybe why you had trouble replicating the issue.

malimart avatar May 21 '25 13:05 malimart

Thank you for sharing your detailed findings. That was helpful! The latest version of Prime Mover is now available (version 2.0.6), which also includes the latest Freemius SDK library (2.12.0). The latest Freemius SDK library contains several bug fixes and performance enhancements.

If you still encounter performance issues with the Freemius library, please share it here, and the Freemius technical team will be happy to assist with it. Otherwise, if everything is now OK, we can close this ticket. Cheers!

codex-m avatar May 28 '25 02:05 codex-m