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

Cached FHIR Profile not invalidated upon write #3812

Closed
rahul1 opened this issue Jan 25, 2024 · 1 comment · Fixed by #3864
Closed

Cached FHIR Profile not invalidated upon write #3812

rahul1 opened this issue Jan 25, 2024 · 1 comment · Fixed by #3864
Assignees
Labels
bug Something isn't working fhir-datastore Related to the FHIR datastore, includes API and FHIR operations

Comments

@rahul1
Copy link
Member

rahul1 commented Jan 25, 2024

Background

User Driven: https://discord.com/channels/905144809105260605/1194887284537954304

User has uploaded a custom profile as a StructureDefinition. However, when they upload a new version of the StructureDefintion is saved to the DB, the relevant Redis entry is not updated.

Repro

  1. Upload test-profile.json
  2. Upload test-encounter.json
  3. Update the StructureDefinition resource created in step 1 with the following: test-profile-2.json (this removes a constraint on Encounter.identifier)
  4. Upload test-encounter.json again

Expected Behavior

  • Encounter fails validation on step 2
  • Encounter passes validation on step 4

Actual Behavior

  • Encounter fails validation both times

Relevant Code

private async loadProfile(url: string): Promise<StructureDefinition | undefined> {
const redis = getRedis();
const cacheKey = `Project/${this.context.project}/StructureDefinition/${url}`;
// Try retrieving from cache
const cachedProfile = await redis.get(cacheKey);
if (cachedProfile) {
return (JSON.parse(cachedProfile) as CacheEntry<StructureDefinition>).resource;
}
// Fall back to loading from the DB; descending version sort approximates version resolution for some cases
const profile = await this.searchOne<StructureDefinition>({
resourceType: 'StructureDefinition',
filters: [
{
code: 'url',
operator: Operator.EQUALS,
value: url,
},
],
sortRules: [
{
code: 'version',
descending: true,
},
],
});
if (profile) {
// Store loaded profile in cache
await redis.set(
cacheKey,
JSON.stringify({ resource: profile, projectId: profile.meta?.project }),
'EX',
24 * 60 * 60 // 24 hours in seconds
);
}
return profile;

@rahul1 rahul1 added this to the January 31st, 2024 milestone Jan 25, 2024
@rahul1 rahul1 added bug Something isn't working fhir-datastore Related to the FHIR datastore, includes API and FHIR operations labels Jan 25, 2024
codyebberson added a commit that referenced this issue Jan 25, 2024
@codyebberson
Copy link
Member

Fixed in #3813

medplumbot added a commit that referenced this issue Jan 31, 2024
Fixes #3794 - MeasureReport.period search (#3850)
Extra check for vmcontext bots (#3863)
Add and use vite-plugin-turbosnap (#3849)
Downgrade chromatic (#3848)
Repo sql fixes for cockroachdb (#3844)
Remove Health Gorilla from medplum-demo-bots (#3845)
fix-3815 cache presigned s3 binary urls (#3834)
Use tsvector index for token text search (#3791)
rate limit should return `OperationOutcome` (#3843)
Add global var "module" to vm context bots (#3842)
Fix lookup table tsv indexes (#3841)
Always use estimate count first (#3840)
Disambiguate getClient (#3839)
Fix invalid mermaid graph in diagnostic catalog docs (#3836)
fix-3809 race condition in Subscription extension fhir-path-criteria-expression %previous value lookup (#3810)
Fix Sonar code smells: mark React props readonly (#3832)
RDS proxy (#3827)
Fixed lookup tables in migration generator (#3830)
Fixed deprecated jest matchers (#3831)
Update README.md (#3828)
Update fhir-basics.md (#3829)
Case study content and images (#3820)
Added rdsReaderInstanceType and RDS upgrade docs (#3826)
Dependency upgrades (#3825)
Separate search popup menus for 'text' and 'token' (#3824)
Improve performance of token sort (#3823)
Additional logging (#3790)
Fix calendar input button style (#3817)
Don't add _total default in SearchControl (#3818)
Dark mode (#3814)
Fixes #3812 - FHIR profile cache bug (#3813)
Document using medplum client to integrate with external FHIR servers (#3811)
Use specific advisory locks (#3805)
Nested transactions (#3788)
Fix signin page on graphiql (#3802)
fix(heartbeat): start heartbeat on first bind to sub (#3793)
Fix async job tests (#3795)
Document using vm context bots (#3784)
Refactored access policy docs based on customer feedback (#3785)
Support Redis TLS config from Env (#3787)
feat(subscriptions): add `heartbeat` for WS subs (#3740)
Update Bot metrics (#3763)
github-merge-queue bot pushed a commit that referenced this issue Jan 31, 2024
Fixes #3794 - MeasureReport.period search (#3850)
Extra check for vmcontext bots (#3863)
Add and use vite-plugin-turbosnap (#3849)
Downgrade chromatic (#3848)
Repo sql fixes for cockroachdb (#3844)
Remove Health Gorilla from medplum-demo-bots (#3845)
fix-3815 cache presigned s3 binary urls (#3834)
Use tsvector index for token text search (#3791)
rate limit should return `OperationOutcome` (#3843)
Add global var "module" to vm context bots (#3842)
Fix lookup table tsv indexes (#3841)
Always use estimate count first (#3840)
Disambiguate getClient (#3839)
Fix invalid mermaid graph in diagnostic catalog docs (#3836)
fix-3809 race condition in Subscription extension fhir-path-criteria-expression %previous value lookup (#3810)
Fix Sonar code smells: mark React props readonly (#3832)
RDS proxy (#3827)
Fixed lookup tables in migration generator (#3830)
Fixed deprecated jest matchers (#3831)
Update README.md (#3828)
Update fhir-basics.md (#3829)
Case study content and images (#3820)
Added rdsReaderInstanceType and RDS upgrade docs (#3826)
Dependency upgrades (#3825)
Separate search popup menus for 'text' and 'token' (#3824)
Improve performance of token sort (#3823)
Additional logging (#3790)
Fix calendar input button style (#3817)
Don't add _total default in SearchControl (#3818)
Dark mode (#3814)
Fixes #3812 - FHIR profile cache bug (#3813)
Document using medplum client to integrate with external FHIR servers (#3811)
Use specific advisory locks (#3805)
Nested transactions (#3788)
Fix signin page on graphiql (#3802)
fix(heartbeat): start heartbeat on first bind to sub (#3793)
Fix async job tests (#3795)
Document using vm context bots (#3784)
Refactored access policy docs based on customer feedback (#3785)
Support Redis TLS config from Env (#3787)
feat(subscriptions): add `heartbeat` for WS subs (#3740)
Update Bot metrics (#3763)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fhir-datastore Related to the FHIR datastore, includes API and FHIR operations
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants