Repository navigation
Fixture session adapter: park the cache refresh instead of starting a worker job - #979
Merged
Merged
Conversation
… worker job (#978) Since #973 every app frame runs the session owner's cache refill. While the process-global session cache is Unloaded (a fresh process, or after any test that dropped a TempSession), the owner emits RefreshCache and SessionAdapter::begin_cache_refresh submitted a real storage-worker job, even for Resources::Fixture, the test resource boundary. The answer, AppMsg::Session(CacheRefreshed), landed on whichever later frame the worker beat, so every Bridge::for_test message stream depended on timing. home_worker_results_cross_the_addressed_dispatcher_ingest_once taps every result and panicked "wrong result type" when it landed between its frames (three of four CI jobs on #977). A fixture adapter now parks the production job (refresh_cache_job) in FixtureResources, the way StoreRunner::Held parks store jobs, and submits nothing. It runs only when a test asks, on the test thread (SessionAdapter::run_held_cache_refresh, Bridge::run_held_cache_refresh_for_test), and take_cache_refresh hands the outcome back on the next result pass. cache_refresh_req covers a parked refresh, so land_session_cache's reconcile still reads it as held, not lost. Live adapters, including the live-resources-for-test ones, are untouched. Regression tests: the adapter-level a_fixture_adapter_submits_no_storage_worker_job_for_a_cache_refresh, and the Home test now starts from an Unloaded cache and drains the worker between its frames (its tap stays strict and nothing prefills the cache). Both failed on the old behaviour every time. The refill tests in plex_session_app_tests keep every assertion; their frames helper (and the one test that runs the queued effect itself) now also runs the parked refresh where it used to drain the worker. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test and doc only. - Add a_live_adapter_begins_a_cache_refresh_without_taking_the_session_io_lock: the live adapter's begin_cache_refresh runs while this thread holds the session IO lock inside a FrameScope and must return None without taking the lock or reading; the job then runs on the worker once the lock is released. The login-frame test's refill half only exercised the parked fixture branch, so a live begin that took the lock would have passed it. - home_retention_tests: assert the premise (refresh_need() is Some) after invalidate_for_test(), and say why: invalidate_for_test leaves a Revoked cache alone. - FixtureResources: debug_assert that the single parked slot is Idle before parking, so a silently overwritten job is caught. - run_held_cache_refresh: document that the job takes the session IO lock on the caller's thread (not under with_io_for_test, not inside a FrameScope). - Fix wording the change made false: "run on the storage worker", "loses its job's ticket", "the queue took the job", "the queue refused nothing"; drop the drain and invalidate in a_replaced_adapter_cannot_strand_an_in_flight_refresh and the drain after run_held_cache_refresh_for_test, which had nothing left to do, and assert the need instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes #978
Since #973, every app frame runs the session owner's cache refill. While the process-global session cache is
Unloaded, the owner emitsRefreshCache. That happens in a fresh process, or after any test that drops aTempSession.SessionAdapter::begin_cache_refreshthen submitted a real storage-worker job, even forResources::Fixture, the test resource boundary. The answer,AppMsg::Session(CacheRefreshed), landed on whichever frame the worker beat, so everyBridge::for_testmessage stream depended on timing.home_worker_results_cross_the_addressed_dispatcher_ingest_oncetaps every result. It panicked withwrong result typewhen that answer landed between its frames. That happened in three of four CI test jobs on #977, and never locally.Change
refresh_cache_job) inFixtureResourcesand submits nothing, the wayStoreRunner::Heldparks store jobs. It runs only when a test asks, on the test thread, throughSessionAdapter::run_held_cache_refreshandBridge::run_held_cache_refresh_for_test.take_cache_refreshhands it back then.cache_refresh_reqcovers it, soland_session_cache's reconcile reads it as held, not lost.cache_refresh_reqbecoming a block with the same live expression.Bridgetest with noTempSessionran the refill against the canonical auth paths. It could install a developer's realauth.jsoninto the process-wide cache for later tests to read.Rejected alternatives
beginlogin_frames_never_wait_for_the_session_io_lockholds the session IO lock across 30 fixture frames and asserts no read.FixtureResources.diskTests
a_fixture_adapter_submits_no_storage_worker_job_for_a_cache_refresh.a_live_adapter_begins_a_cache_refresh_without_taking_the_session_io_lockcovers whatlogin_frames_never_wait_for_the_session_io_lockcan no longer see through a fixture. A live adapter begins the refresh inside aFrameScopewhile the IO lock is held, then settles after the lock is released. Making the live begin take the lock fails it (main-thread block: session storage I/O).debug_assert!catches a parked refresh being overwritten.Unloadedcache and drains the worker between its frames. Its tap stays strict, and nothing prefills the cache.plex_session_app_tests: they keep every assertion. Theirframeshelper, and the one test that runs the queued effect itself, now run the parked refresh where they used to drain the worker.Gates, run on the committed tree
make checktest result:line isokwith 0 failed.make check-nodefmake check-replayverdict=SAME(run on the first commit; the review-fix commit is test and doc only)Review
One review, verdict MERGE. Its should-fix (the live IO-lock coverage above) and its four notes are applied: the Home test's premise is now asserted, the parked-slot
debug_assert!is added, therun_held_cache_refreshdoc names the lock, and stale wording is fixed.ARM
makewas not run: no live behaviour changed.🤖 Generated with Claude Code