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

COG cache broken #288

Open
mhungen opened this issue Aug 24, 2023 · 0 comments · May be fixed by #289
Open

COG cache broken #288

mhungen opened this issue Aug 24, 2023 · 0 comments · May be fixed by #289

Comments

@mhungen
Copy link

mhungen commented Aug 24, 2023

Hi,
As soon as i turn on caching by specifying:

  var useCache = true;
  var cogUri = new BasicAuthURI(url, useCache); 
  var input = new CogSourceSPIProvider(
                  cogUri,
                  new CogImageReaderSpi(),
                  new CogImageInputStreamSpi(),
                  HttpRangeReader.class.getName()
  );
  ...

i get some NullPointerException caused by CachingCogImageInputStream.
I have added some tests to CogHTTPReadOnlineTest to demonstrate the problem.

I tried to fix these problems by keeping the header field of CachingCogImageInputStream up to date and my tests passed.

However, upon closer inspection of the current implementation of CachingCogImageInputStream, I noticed that it relies heavily on the cache and will most likely break when parts of the cache are evicted.
For example: Tile is cached when readRanges(.) is called -> ehcache decides to remove that tile -> call of read(...) tries to get the tile from the cache -> error

since a TODO in the code already noted that the implementation never worked well, i thought i'd give it a shot:
CachingCogImageInputStream extends DefaultCogImageInputStream and all the cache related stuff happens in readRanges(.)
If the tiles are in cache the will be copied, else we fetch them and add them to cache.
The downside of this solution is that we have to merge the cached tile-chunks into continuous-chunks because the read(.) method expects it that way. Which might raise concerns about memory management?

Please let me know your thoughts on this.

@mhungen mhungen linked a pull request Aug 24, 2023 that will close this issue
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 a pull request may close this issue.

1 participant