Skip to content

fix: Keep refreshing the registry after a failed periodic refresh - #7219

Open
helloybz wants to merge 2 commits into
feast-dev:masterfrom
helloybz:fix/registry-refresh-timer-resilience
Open

helloybz wants to merge 2 commits into
feast-dev:masterfrom
helloybz:fix/registry-refresh-timer-resilience

Conversation

@helloybz

@helloybz helloybz commented Nov 24, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

The feature server refreshes its registry on a timer (async_refresh() in get_app()). The next threading.Timer was scheduled only after store.refresh_registry() and vs_registry.refresh() both succeeded. A single transient error from the registry backend, such as an ssl.SSLError while downloading an S3 registry, ended the timer thread without scheduling another. The worker stayed up and kept serving its cached registry, but it never refreshed the registry again until it was restarted. The only trace was the traceback that Python prints for an uncaught exception in a thread; nothing reported that refreshes had stopped.

async_refresh() is split into refresh_registry_caches(), schedule_refresh() and periodic_refresh(). The periodic refresh now logs the error and always schedules the next attempt, so the worker keeps serving the cached registry and retries on the next cycle. The first refresh still runs in the app lifespan and still fails startup on error, so startup behavior does not change. Scheduling a timer and stopping refreshes at shutdown now hold the same lock, so shutdown always cancels the latest timer, including one that a refresh is scheduling at that moment. Before, shutdown could cancel the previous timer while the next one was being created, and the new timer kept the process waiting for one more interval.

Only get_app() in feature_server.py changes.

Which issue(s) this PR fixes:

No existing issue. I searched open and closed issues and PRs for async_refresh and the registry refresh timer. #7065 also changes feature_server.py (a Gunicorn post_fork hook) but does not overlap with this change.

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

New tests in sdk/python/tests/unit/test_feature_server.py. threading.Timer is patched so each test can fire the scheduled refresh by hand:

  • test_periodic_registry_refresh_keeps_running_after_a_failure: a refresh that raises still schedules the next one, and the error is logged. Fails on master with the RuntimeError raised from the timer callback.
  • test_registry_refresh_failure_at_startup_still_fails_startup: a failed first refresh still fails app startup, and no timer is scheduled. Passes on master too; it pins the startup behavior.
  • test_registry_refresh_timer_scheduled_during_shutdown_is_cancelled: the app shuts down while a refresh is creating the next timer, and that timer must be cancelled. Fails without the lock: only the previous timer is cancelled.

make test-python-unit passes locally (4462 passed, 37 skipped), and ruff check, ruff format and mypy are clean on the changed files.

Misc

This change was written with help from an AI assistant (Claude Code). I reviewed it and ran the tests above.

🤖 Generated with Claude Code


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 9 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

The feature server scheduled the next registry refresh only after the
current one succeeded. A single transient error from the registry
backend (for example an SSL error while downloading an S3 registry)
ended the timer thread, and the worker kept serving its cached registry
without refreshing it again until restart.

Catch and log errors in the periodic refresh and always schedule the
next attempt. The first refresh still runs in the app lifespan and
fails startup on error, as before.

Scheduling a timer and stopping refreshes at shutdown now hold the same
lock. Before, shutdown could cancel the previous timer while a refresh
was scheduling the next one, and the new timer then kept the process
waiting for one more interval.

Signed-off-by: Youngbeom Choi <helloybz@gmail.com>
@helloybz
helloybz force-pushed the fix/registry-refresh-timer-resilience branch from 0dad9b9 to 16f51b3 Compare November 24, 2026 07:34
Signed-off-by: Youngbeom Choi <helloybz@gmail.com>

@franciscojavierarceo franciscojavierarceo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the periodic path now logs refresh failures and schedules the next attempt, while the lifespan still propagates the first refresh failure. the shared scheduling/shutdown lock cancels the newest timer. the three new tests exercise recovery, startup failure, and concurrent shutdown using the real file-registry/SQLite store fixture.

@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.14%. Comparing base (a291a0f) to head (b017f33).

Files with missing lines Patch % Lines
sdk/python/feast/feature_server.py 80.95% 1 Missing and 3 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7219      +/-   ##
==========================================
+ Coverage   54.10%   54.14%   +0.03%     
==========================================
  Files         467      467              
  Lines       58940    58951      +11     
  Branches     8688     8688              
==========================================
+ Hits        31890    31919      +29     
+ Misses      24892    24868      -24     
- Partials     2158     2164       +6     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.74% <80.95%> (+0.04%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/feature_server.py 69.21% <80.95%> (+2.32%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a291a0f...b017f33. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants