Fill the forecast-prefetch cold-start gap with a startup catch-up - #27
Merged
Merged
Conversation
ForecastPrefetchThread only refreshed forecast/actuals data at its fixed daily wake times, so a restart (deploy, crash, dev testing) left /forecast empty until the next scheduled wake - unlike rce_prefetch.py's read path, forecast_history.get_latest_merged has no live-fetch fallback on a miss. Add run_catch_up(), called once before the wait loop: per source (meteosource, solcast forecast, solcast actuals), fetch immediately only if nothing has been written since the most recent wake time that should already have fired (has_fetched_since + the new last_wake_time, the backward-looking mirror of next_wake_time). A quick restart minutes after a real fetch finds everything fresh and costs nothing extra; a genuine cold start fetches what's missing once. Solcast actuals catch-up always excludes today (fetch_and_store_solcast_actuals's new max_date param) - writing a partial "today" snapshot mid-day risks permanently stranding that day with holes if the service goes down again before the normal 23:00 slot completes it. Today's actuals stay that slot's job, never catch-up's. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Fill the forecast-prefetch cold-start gap with a startup catch-up
ForecastPrefetchThreadonly refreshed forecast/actuals data at its fixed daily wake times (06:00/11:00/21:00forecast,23:00actuals). A restart — deploy, crash, dev testing — left/forecastempty until the next scheduled wake, sinceforecast_history.get_latest_merged(unlikerce_prefetch.py's read path) has no live-fetch fallback on a miss.Fix: a
run_catch_up()pass runs once before the wait loop. Per source, it fetches immediately only if nothing's been written since the most recent wake time that should already have fired (has_fetched_since+last_wake_time, the backward-looking mirror ofnext_wake_time) — a quick restart minutes after a real fetch costs nothing extra; a genuine cold start fills what's missing once.Solcast actuals catch-up never writes today (
fetch_and_store_solcast_actuals's newmax_dateparam) — writing a partial "today" snapshot mid-day risks permanently stranding that day with holes if the service goes down again before the normal23:00slot completes it. Today's actuals stay that slot's job.Tests added for
last_wake_time,has_fetched_since,max_datefiltering, andrun_catch_up's staleness gating. Full suite (202 tests) green, including underTZ=UTC.