Evict cached sync providers when an endpoint is repointed or its data store edited - #4
Merged
Conversation
… store edited Cached providers never expire and were only evicted by the publish toggle. Repointing an endpoint at another configuration is allowed while published, so the endpoint kept serving the previous configuration's tables until the next toggle or restart. Editing a data store's connection string, tracking mode or change retention had the same effect on every endpoint on it. Both actions now invalidate. The tests needed the host behind the authenticated client: CreateAuthenticatedClient runs a separate WebApplicationFactory with its own singletons, so CreateAuthenticatedFactory exposes it.
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.
Cached sync providers never expire, and until now only the publish toggle evicted them. Two changes are allowed while an endpoint is published, and neither evicted the cache:
PUT api/datastores/{id}/endpoints/{endpointId}/configuration). The endpoint kept serving the previous configuration's tables until the next publish toggle or restart. We hit this on MDC-FINS: after a new table configuration went live, fish tables configured as UploadAndDownload were still served as UploadOnly.PUT api/datastores/{id}). Changes to the connection string, tracking mode or change retention did not reach any endpoint on that data store.Both actions now call
ISyncProviderCache.Invalidate. Table-rule edits were already safe: they are refused while an endpoint is published.Tests
SyncProviderCacheInvalidationTests:Invalidateitself: evicts the endpoint's entry.Without the controller change, the repoint and data store tests fail. The full suite passes (51/51).
CreateAuthenticatedClientruns a separateWebApplicationFactorywith its own singletons. A test that resolved the cache from the fixture'sServiceswas therefore reading a different instance than the one the controller invalidated. The newCreateAuthenticatedFactoryexposes that host, andCreateAuthenticatedClientbehaves as before.