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

[UIMA-6393]: Circular imports break resource manager cache #155

Merged

Conversation

reckart
Copy link
Member

@reckart reckart commented Nov 10, 2021

  • Added a minimal and a randomized test to reproduce the problem
  • Refactored import resolution algorithm. The types are no longer inlined in the cached type system descriptors. Instead, the import graph is walked on each call to resolveImports(). The imports are also no longer removed from the cached descriptors. This simplifies the algorithm and fixes the bug. Performance implications seem acceptable.
  • Type descriptors from imported type systems are defensively cloned into the resolved type system to avoid potential cache pollution
  • Added a several new tests
  • Import resolving mechanism was factored out into a separate ImportResolver class and is re-used for FSIndexCollections and TypePriorities
  • importUrlCache of the ResourceManager_impl is no longer used, has been deprecated and issues a warning when somebody tries to use it (was an internal detail so nobody should have been using it!)

reckart and others added 29 commits October 22, 2021 12:39
…to-access-config-names-of-fresh-context

[UIMA-6390] NPE when trying to access config names of fresh context
- Added a minimal and a randomized test to reproduce the problem
- Started refactoring the import resolving - WIP
- Added another test
- Renamed some test files
- various exploratory changes for testing different solutions, very work in progress
- resolve imports if possible for better caching
- added another test for that scenario
- Removed boolean return value for `resolvedImports` - we can simply check if there are no more imports in the resolved descriptor to see if it was fully resolved
- Refactored methods to load an imported type system from cache or from disk
- Pass original import through to the disk loading method because we want to have the original import URL as well as the resolved URL there for an error message
- Bit of cleaning up
- Added several comments and a sprinkle of JavaDoc
- Added cache synchronization
- Remove type cast from TypeSystemDescription to TypeSystemDescription_impl
- Change test so that it incrementally generates larger scenarios
- Pull code to generate the scenario out of the principal test method
- Improve import resolving performance by remembering which type systems were already visited (still over-generates type descriptions in collectec types and likely in the cached type systems)
- Skip self-imports
- Improve test
- Use a set to collect the unique found type descriptions
- Undo change to use a set for the collected types - this breaks some tests
- Fix bug that types that are imported from a type system which has already been visited last in a circle may not be resolved when the type system is reached a second time
- Added test for this scenario
- Added a few comments
- Added comments
- Updated a test to make it more detailed
- Keep track of where imported types come from and avoid collecting the same type twice (theoretically - clashes a bit with the inlining of types... but the inlining of types is a bad idea anyway)
- Added flag `iReallyReallyWantToInlineTypesAndRiskStrongAccumulation` to control the inlining of types to facilitate checking how the code behaves with and without inlining
- By default the flag is on because we have some unit tests that check the cache state and these currently would fail if inlining would be turned off
- Use a proper object instead of a concatenated string as the disambiguation key - the key uses object equality (basically turns the `aAllImportedTypes` into a LinkedIdentityHashSet
- No longer inline types or remove imports
- Pulled import resolving code out into a separate class
- Pulled import resolving tests out into a separate test class
- Changed log layout
- Use generic import resolver in TypeSystemDescription_impl, FsIndexCollection_impl and TypePriorities_impl
- Deprecate import resolving method allowing the passing "already imported" URLs in all three descriptor types
- Added back setting the source URL on imports if it was null
- Added back using the "already imported" argument of the deprecated resolve method in the generic import resolver - not because it is a good idea, just for backwards compatibility
- Deprecate ResourceManager_impl.getImportUrlsCache() - it is no longer used.
- Rename DescriptionAdapter to DescriptorAdapter
- Move import resolver test data to different test folder
- Better/added missing license header in the test files
- Defensive copy of the type descriptors into the resolved type system to avoid cache pollution
- Adjust unit test to check that cache pollution risk is gone
- Made complex import resolving scenario test multi-threaded
- Do not defensively copy type descriptions that already were in the type system descritor before resolving
- Added unit test for this change
- Added unit test for self-importing
- Log a warning with decreasing frequency if somebody still uses `ResourceManager_impl.getImportUrlsCache()`
- Remove unused list
- Added an information message about multi-threaded average duration to the randomized test
…urce-manager-cache_pk

* main: (65 commits)
  [UIMA-6390] NPE when trying to access config names of fresh context
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6372] Upgrade from JUnit 3 to JUnit 4 to JUnit 5
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6373] Format UIMA Core Java SDK codebase
  [UIMA-6378] Java SDK does not build on Java 16
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  [UIMA-6374] Create CAS (de)serialization test suite
  ...

% Conflicts:
%	uimaj-core/src/main/java/org/apache/uima/resource/metadata/FsIndexCollection.java
%	uimaj-core/src/main/java/org/apache/uima/resource/metadata/TypePriorities.java
%	uimaj-core/src/main/java/org/apache/uima/resource/metadata/TypeSystemDescription.java
%	uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/FsIndexCollection_impl.java
%	uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/TypePriorities_impl.java
%	uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/TypeSystemDescription_impl.java
%	uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/TypeSystemDescription_implTest.java
@reckart reckart added the 🦟 Bug Something isn't working label Nov 10, 2021
@reckart reckart added this to the 3.3.0 milestone Nov 10, 2021
@reckart reckart self-assigned this Nov 10, 2021
@reckart reckart merged commit 6859eec into main Nov 10, 2021
@reckart reckart deleted the bugfix/UIMA-6393-Circular-imports-break-resource-manager-cache_pk branch November 10, 2021 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦟 Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants