Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51109 closed defect (bug) (fixed)

Random term meta test failures

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:


There is a recent race condition in the tests, causing random failures:

There was 1 failure:

1) Tests_Term_Meta::test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_loop
Failed asserting that 201618 is identical to 201619.


Could be a coincidence, but [48840] seems to be the only recent commit dealing with terms, so might be related.

Change History (2)

#1 @SergeyBiryukov
4 years ago

If looks like [48840] is not the culprit per se, it just uncovered the fact that the failing test was fragile in the first place.

Specifically, the test ensures that metadata for an orphan term is not lazy loaded, because it's not attached to any posts. However, by the time the test runs, the WP_Metadata_Lazyloader queue contains quite a few IDs from previous tests, one of which can coincide with the orphan term ID from this test. When that happens, the term meta is retrieved from the cache and not from the database, as the test attempts to verify.

Clearing the lazyloader queue at the beginning of the test appears to resolve the issue.

Version 1, edited 4 years ago by SergeyBiryukov (previous) (next) (diff)

#2 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48844:

Tests: Clear any previous term IDs from the metadata lazyloader queue in term meta lazy-loading test.

This fixes random test failures when one of the term IDs from previous tests coincides with the orphan term ID from this test that should not be lazy-loaded.

Follow-up to [34529], [36566].

Fixes #51109.

Note: See TracTickets for help on using tickets.