Skip to content

Conversation

@Jonas-Isr
Copy link
Member

@Jonas-Isr Jonas-Isr commented Dec 18, 2025

Context

This PR fixes a problem with the new PreLookup check. The issue was that the destination options (more precisely, the retrieval strategy) was not used when performing the call to get all destinations. This led to situations where some destinations where not correctly found. To fix this, these options are now propagated to the getAllDestinations call.

Important Note

During investigation of this issue we realised that the caching logic of the GetOrComputeAllDestinationsCommand class has a flaw: In GetOrComputeAllDestinationsCommand, cache keys are build from the entire DestinationOptions object. These options might very well contain information that is irrelevant for the call to get all destinations. This will lead to (potentially many) unnecessary HTTP calls due to over-eager cache isolation.
(This was most-probably also already an issue before the addition of the PreLookup check: When change detection was enabled and DestinationService.tryGetDestination was called, we also invoke GetOrComputeAllDestinationsCommand which then uses an unnecessarily struct cache. But in that case the outcome is merely an unnecessary cache-miss, which is probably why we did not notice it before.)

Example
Assume there are 2 different destinations, dest1 and dest2, with the same destination options, but the options of dest1 include a custom header that is only relevant for getting this single destination. If we now call tryGetDestination(dest1, options1) and afterwards tryGetDestination(dest2, options2), the invocation of getOrComputeAllDestinations in preLookupCheckSuccessful in the second call will not hit the cache as the cache key build from options2 differs from the one from options1.

There is a second PR to solve this problem by adapting the caching logic in GetOrComputeAllDestinationsCommand to only use the relevant retrieval strategy as cache key.

Comment on lines +393 to +394
return new ArrayList<>(
Cache.getOrComputeAllDestinations(options, this::getAllDestinationsByRetrievalStrategy).get())
Copy link
Contributor

Choose a reason for hiding this comment

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

(Comment/Discussion)

I feel like with the motivation of this PR, the following would be more explicit while higher-level(?)

Suggested change
return new ArrayList<>(
Cache.getOrComputeAllDestinations(options, this::getAllDestinationsByRetrievalStrategy).get())
final DestinationServiceRetrievalStrategy retrievalStrategy =
DestinationServiceOptionsAugmenter
.getRetrievalStrategy(options)
.getOrElse(DestinationServiceRetrievalStrategy.CURRENT_TENANT);
return getAllDestinationProperties(retrievalStrategy)

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.

3 participants