vip-go-mu-plugins icon indicating copy to clipboard operation
vip-go-mu-plugins copied to clipboard

Add additional data to MemcachePool errors.

Open emrikol opened this issue 2 years ago • 2 comments

Description

While we have a maximum size of (compressed) data per individual cache key, right now we have no way of determining what keys might be causing these issues at the application layer.

Currently, we will see PHP notices such as this:

Notice: MemcachePool::set(): Server example.local. (tcp 12345, udp 0) failed with: SERVER_ERROR object too large for cache (3)

I'm hoping we can use our custom error handler to extract additional information from the backtrace and add it to the message. I'm also moving this to E_WARNING because, in my opinion, this is more in line with the severity of an error like this. Having objects uncached can cause site stability issues.

The new messages would look more like this:

Warning: MemcachePool::set(): Server example.local. (tcp 12345, udp 0) failed with: SERVER_ERROR object too large for cache (3) (Key: test123, Group: default, Data Size: 19999999)

Changelog Description

Checklist

Please make sure the items below have been covered before requesting a review:

  • [ ] This change works and has been tested locally (or has an appropriate fallback).
  • [x] This change works and has been tested on a Go sandbox.
  • [ ] This change has relevant unit tests (if applicable).
  • [ ] This change has relevant documentation additions / updates (if applicable).
  • [ ] I've created a changelog description that aligns with the provided examples.

Steps to Test

I've been testing this in a sandbox using this snippet in a client-mu-plugin:

if ( isset( $_GET['mc-test'] ) && 'thisisabadidea' === $_GET['mc-test'] ) {
	ini_set('display_errors', 1);
	ini_set('display_startup_errors', 1);
	error_reporting(E_ALL);
	$string = substr(str_shuffle(str_repeat($x='12345', ceil(20000000/strlen($x)) )),1,20000000);
	wp_cache_set( 'test123', $string );
	wp_die( 'Ran a large MC test with a size of ' . number_format( strlen( $string ) ) );
}

emrikol avatar May 17 '22 18:05 emrikol

Codecov Report

Merging #3166 (a845b7f) into develop (a5fc7b9) will decrease coverage by 0.04%. The diff coverage is 0.00%.

:exclamation: Current head a845b7f differs from pull request most recent head c53d3c0. Consider uploading reports for the commit c53d3c0 to get more accurate results

@@              Coverage Diff              @@
##             develop    #3166      +/-   ##
=============================================
- Coverage      34.53%   34.49%   -0.05%     
+ Complexity      3575     3567       -8     
=============================================
  Files            216      216              
  Lines          13846    13844       -2     
=============================================
- Hits            4782     4775       -7     
- Misses          9064     9069       +5     
Impacted Files Coverage Δ
lib/wpcom-error-handler/wpcom-error-handler.php 0.00% <0.00%> (ø)
lib/helpers/wp-cli-db/class-wp-cli-db.php 65.00% <0.00%> (-1.67%) :arrow_down:
vip-mail.php 64.78% <0.00%> (-0.55%) :arrow_down:
000-pre-vip-config/requires.php 0.00% <0.00%> (ø)
lib/helpers/wp-cli-db/class-config.php 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 29 '22 00:07 codecov[bot]

Foresight Workflow Report

Lint files workflow has finished in 1 minute 22 seconds and finished at 22nd Sep, 2022. Conclusion: SUCCESS. Here is the analysis:


Job Failed Steps Tests Not tested changed lines*
Lint Search Dev Tools files -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Lint PHP files -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details

Dependency Review workflow has finished in 3 minutes 48 seconds and finished at 22nd Sep, 2022. Conclusion: SUCCESS. Here is the analysis:


Job Failed Steps Tests Not tested changed lines*
Review Dependencies -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details

CI (Parse.ly) workflow has finished in 9 minutes 23 seconds and finished at 22nd Sep, 2022. Conclusion: SUCCESS. Here is the analysis:


Job Failed Steps Tests Not tested changed lines*
Parse.ly: 3.1 filter_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Parse.ly: 3.1 option_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Parse.ly: 3.2 filter_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Parse.ly: 3.2 option_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Parse.ly: 3.3 filter_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Parse.ly: 3.3 option_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Parse.ly: 3.3 filter_and_option_enabled -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details

Run e2e tests workflow has finished in 10 minutes 49 seconds and finished at 22nd Sep, 2022. Conclusion: SUCCESS. Here is the analysis:


Job Failed Steps Tests Not tested changed lines*
Run E2E Tests -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details

CI workflow has finished in 12 minutes 24 seconds and finished at 22nd Sep, 2022. Conclusion: SUCCESS. Here is the analysis:


Job Failed Steps Tests Not tested changed lines*
Run WP Core Tests (WordPress latest, multisite: no) -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Run WP Core Tests (WordPress latest, multisite: yes) -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP 5.7.x, multisite: no, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP 5.8.x, multisite: no, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP 5.9.x, multisite: no, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: no, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP nightly, multisite: no, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: yes, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP nightly, multisite: yes, JP: yes, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: no, JP: no, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: yes, JP: no, PHP: 7.4 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: no, JP: yes, PHP: 8.0 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: yes, JP: yes, PHP: 8.0 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP nightly, multisite: no, JP: yes, PHP: 8.0 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP nightly, multisite: yes, JP: yes, PHP: 8.0 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: no, JP: yes, PHP: 8.1 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP latest, multisite: yes, JP: yes, PHP: 8.1 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP nightly, multisite: no, JP: yes, PHP: 8.2 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
WP nightly, multisite: yes, JP: yes, PHP: 8.2 -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details
Build Search Dev Tools -     :link:  ✅ -  ❌ -  ⏭ -     N/A    See Details

*Not tested changed lines calculated for determining how much of the changes are covered by the tests.

runforesight[bot] avatar Sep 22 '22 20:09 runforesight[bot]

Let's do some manual testing once this gets merged into develop

rinatkhaziev avatar Sep 22 '22 20:09 rinatkhaziev

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Sep 25 '22 12:09 sonarqubecloud[bot]