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 WMS guava cache concurrency issues #467

Merged
merged 13 commits into from
Feb 28, 2024

Conversation

tdrwenski
Copy link
Contributor

The changes from #461 introduced concurrency issues in the WMS cache. This happened because cache entries were mutated after access since the NetcdfFile that is part of the ThreddsWmsCatalogue was reacquired and then closed after use.

This PR:

  • fixes concurrency issue by again allowing the NetcdfFiles needed by the WMS cache entries to remain locked so they don't have to be closed/reopened. This should not cause memory issues as the cache is limited to 100 entries.
  • Adds RemovalListener which closes the NetcdfFile when guava removes catalogue from the cache
  • Uses Guava's get(Key, Callable<v>) pattern to retrieve or create a value in the cache
  • The get(Key, Callable<v>) will throw an ExecutionException or UncheckedExecutionException, so we also need to catch and rethrow these since the WmsServlet only expects IOExceptions or EdalExceptions (and everything else becomes a 500 error).
  • Add tests

@tdrwenski tdrwenski marked this pull request as ready for review February 22, 2024 16:23
@tdrwenski tdrwenski marked this pull request as draft February 22, 2024 16:41
@tdrwenski tdrwenski marked this pull request as ready for review February 28, 2024 18:52
@haileyajohnson haileyajohnson merged commit 7f5f22e into Unidata:main Feb 28, 2024
9 checks passed
@tdrwenski tdrwenski deleted the wms-cache branch February 28, 2024 21:58
WeatherGod pushed a commit to WeatherGod/tds that referenced this pull request Apr 18, 2024
* Add test for WMS requests in parallel

* Do not mutate (by reopening/closing) files in the wms cache

* Update wms cache tests

* Use guava cache loader instead of put

* Add test for bad wms request

* Rethrow execution exceptions io or edal exceptions

* Clear wms cache before netcdf file cache

* Update test before/after steps to avoid problems with locked files

* Revert "Update test before/after steps to avoid problems with locked files"

This reverts commit 3188915.

* Ignore WMS test that updates a file

* Update WMS cache tests to alter last modified rather than replace file to test cache

* Add extra asserts to test after step

* Disable Raf cache to avoid file locks for wms tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants