Skip to content

Fix inotify instance exhaustion in pickle backend (Issue #24)#277

Merged
shaypal5 merged 7 commits intomasterfrom
fix-inotify-bug
Jul 8, 2025
Merged

Fix inotify instance exhaustion in pickle backend (Issue #24)#277
shaypal5 merged 7 commits intomasterfrom
fix-inotify-bug

Conversation

@shaypal5
Copy link
Copy Markdown
Member

@shaypal5 shaypal5 commented Jul 7, 2025

Fixes Issue #24: inotify instance exhaustion in the pickle backend.

  • The pickle backend now reuses and properly cleans up watchdog observers, preventing inotify resource leaks.
  • If the inotify instance limit is reached, the backend falls back to polling.
  • A regression test is included: it will fail if the bug is present, and pass when the fix is in place.
  • All other pickle backend tests pass locally except two edge-case tests (test_bad_cache_file[False], test_delete_cache_file[False]), which may be timing-related and should be checked on CI (Linux).
  • The README documents this bug and its fix.

- Reuse and cleanup watchdog observers to prevent inotify resource leaks
- Fallback to polling if inotify instance limit is reached
- Add regression test (will fail if bug is present, pass when fixed)
- Document fix in README
- Note: Two edge-case tests may fail locally, check CI for Linux results
@shaypal5 shaypal5 requested a review from Copilot July 7, 2025 21:13
@shaypal5 shaypal5 self-assigned this Jul 7, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses inotify instance exhaustion in the pickle backend by reusing watchdog observers, cleaning them up properly, and falling back to polling when the inotify limit is reached.

  • Introduces _observer_cache and cleanup logic to prevent orphaned observers.
  • Adds a polling fallback (_wait_with_polling) for when the inotify instance limit is hit.
  • Updates the README with a bug-fix entry and includes a regression test for the issue.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/cachier/cores/pickle.py Added observer caching/cleanup, polling fallback, and config refactor.
README.rst Documented the inotify exhaustion bug and its fix.
Comments suppressed due to low confidence (2)

src/cachier/cores/pickle.py:36

  • The call to PatternMatchingEventHandler now omits case_sensitive=False and changes ignore_directories to False, which deviates from the original behavior. Restore case_sensitive=False and set ignore_directories=True to maintain consistent event filtering.
            )

src/cachier/cores/pickle.py:85

  • Directly assigning separate_files and reload bypasses the _update_with_defaults logic, so user or global defaults may be ignored. Reintroduce _update_with_defaults for these parameters to preserve expected default behavior.
        self.separate_files = separate_files

pre-commit-ci Bot and others added 6 commits July 7, 2025 21:19
- Restore _update_with_defaults calls for proper parameter handling
- Fix cache directory and separate_files parameter handling
- Restore original CacheChangeHandler behavior
- Make polling fallback more conservative (only for inotify-specific errors)
- All pickle core tests now pass locally
- Remove observer caching that caused 'threads can only be started once' errors
- Create new observer for each cache wait to ensure proper cleanup
- Maintain proper observer lifecycle management
- Fixes Issue #24: inotify instance exhaustion in pickle backend
@shaypal5 shaypal5 merged commit 8eff429 into master Jul 8, 2025
42 checks passed
@shaypal5 shaypal5 deleted the fix-inotify-bug branch July 8, 2025 06:37
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.

OSError: inotify instance limit reached

2 participants