Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Skip refresh if already in progress or if lock is already held #5068

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

ntkathole
Copy link
Contributor

@ntkathole ntkathole commented Feb 18, 2025

What this PR does / why we need it:

This is the fix to prevent deadlocks on registry cache refresh.

  • Used self._refresh_lock.acquire(blocking=False) to avoid infinite waiting and avoids releasing an unlocked lock.
  • Fixed recursive calls by checking self._refresh_lock.locked() flag to prevent self.refresh() from calling itself indirectly.
  • Handled exceptions by wrapping logic inside try to catch errors and always release locks.

Which issue(s) this PR fixes:

#4898

Tests:

# pytest sdk/python/tests/unit/infra/registry/test_registry.py -svv
sdk/python/tests/unit/infra/registry/test_registry.py::test_cache_expiry_triggers_refresh 02/20/2025 03:36:21 PM feast.infra.registry.caching_registry INFO: Registry cache expired, so refreshing
02/20/2025 03:36:21 PM feast.infra.registry.caching_registry INFO: Skipping refresh if already in progress
02/20/2025 03:36:21 PM feast.infra.registry.caching_registry INFO: Registry cache expired, so refreshing
02/20/2025 03:36:21 PM feast.infra.registry.caching_registry INFO: Skipping refresh if already in progress
PASSED
sdk/python/tests/unit/infra/registry/test_registry.py::test_skip_refresh_if_lock_held 02/20/2025 03:36:21 PM feast.infra.registry.caching_registry INFO: Skipping refresh if lock is already held by another thread
PASSED
==================================================== 2 passed in 0.01s ====================================================

Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

it looks like CachingRegistry doesn't have tests anywhere at all. It'd be good to add some and start to catch some of this stuff.

Could you add a test under sdk/python/tests/units/infra/registry/test_registry.py?

@lokeshrangineni
Copy link
Contributor

integration test failure seems to be legit. may be better to investigate.

@ntkathole
Copy link
Contributor Author

it looks like CachingRegistry doesn't have tests anywhere at all. It'd be good to add some and start to catch some of this stuff.

Could you add a test under sdk/python/tests/units/infra/registry/test_registry.py?

Tests added.

Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

Nice thanks for this!

@franciscojavierarceo franciscojavierarceo merged commit f3a24de into feast-dev:master Feb 20, 2025
23 checks passed
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