fix(entry-query): remove get_all_entries_asc#937
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
- get_entries_by_time() now queries entries directly with a date-bounded DB query instead of caching and slicing the full entry list - get_entries_paged() queries the full list directly instead of caching it as one object - add count_entries() for cheap, correctly deduplicated pagination counts get_all_entries_asc() cached a Liveblog post's whole entry list under one cache key. On posts with a lot of entries that blob can exceed the memcache 1MB object size limit, so the write silently fails and every request falls back to a full uncached DB read, which is exactly the scaling problem this was meant to avoid. Fixes Automattic#591
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_all_entries_asc()cached a Liveblog post's entire entry list under one cache key. On posts with a lot of entries that blob can exceed the memcache 1MB object size limit, so the write silently fails and every request falls back to a full uncached DB read - exactly the scaling problem this was meant to avoid. This replaces it with direct, date-bounded DB queries and a small cached count for pagination.Fixes #591
Changes
classes/class-wpcom-liveblog-entry-query.phpBefore:
After:
Why: queries the requested time range directly from the DB instead of loading and caching the whole entry list.
count_entries()givesget_entries_by_time()a correctly deduplicated pagination count without needing the full list either.liveblog.phpBefore:
After:
Why:
get_entries_by_time()is hit on every polling request, so it's the method that actually blows past the cache size limit on large liveblogs.get_entries_paged()was changed similarly, just querying the full ASC list directly instead of caching it as one object - its pagination math is unchanged.Testing
Test 1: date-bounded query returns the right entries
tests/Integration/EntryQueryTest.phpcoveringget_between_timestamps()against the new date_query path (mid-range, border timestamps)Result: passes, same coverage as before plus new
count_entries()tests for inserts, deletions, and edits.Test 2: pagination unaffected
tests/Integration/RestApiTest.phpcoverage forget_entries_paged()- page slicing, empty state, deleted entries excluded from totalResult: passes
Test 3: full suite
composer test:unit- 7 tests,composer test:integration- 166 tests,composer cson changed files,composer lintResult: all pass, 0 PHPCS errors/warnings on changed files
Screenshots
N/A, no UI changes.