Repository navigation
UNOMI-1002: Stop serializing public requests in compatibility mode - #915
Merged
Merged
Conversation
Public requests no longer serialize on a method lock or re-read the default tenant from persistence on every hit. Cache on first success, lock only on miss, and invalidate on save/delete/key rotation.
The getOrCreateTenant cache was local to one node and never expired, so a tenant deleted or changed on another node, or directly in the search engine, was never noticed and the default tenant was not created again. - Entries expire after 30 seconds. While one thread refreshes an expired entry the others keep answering from it rather than queue behind the read. - A null tenant id is rejected with IllegalArgumentException again. - Tests now fail when an invalidation, the expiry or the lock is removed, and cover API key generation, a delete on another node, a tenant created by another node during creation, and failures not being cached. - Drop a catch that could never fire from the filter test. - Document the cached, shared result on TenantService and in the manual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The 30 seconds is not a hard bound: an expired entry is still served while a reload runs. Say so in the Javadoc and the manual. - Retry from another thread in the failure test, so a lock left held by the failed call is detected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TenantServiceImpl.getOrCreateTenantcaches the tenant so single-tenant compatibility mode public requests (context.json, event collector) no longer wait on each other or hit persistence every time (UNOMI-1002 / follow-up to UNOMI-980).defaulttenant is gone, it is created again at that point.saveTenant,deleteTenant, and API-key generation, so local changes normally show on the next call. A load that overlaps the change can keep the earlier version until the entry expires.defaultonly (no request header can steer it). Multi-tenant paths do not use this cache.https://issues.apache.org/jira/browse/UNOMI-1002
Test plan
mvn -pl services,rest test -Dtest=TenantServiceImplTest,AuthenticationFilterBlankPasswordTestSingleTenantCompatibilityModeIT(UNOMI-980) still passes🤖 Generated with Claude Code